OSDN Git Service

* decl.c (maybe_commonize_var): Set DECL_UNINLINABLE for statics
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Nov 2000 23:50:20 +0000 (23:50 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Nov 2000 23:50:20 +0000 (23:50 +0000)
        in inlines.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37394 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/comdat1.C [new file with mode: 0644]

index a84276e..12947e1 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-09  Jason Merrill  <jason@redhat.com>
+
+       * decl.c (maybe_commonize_var): Set DECL_UNINLINABLE for statics
+       in inlines.
+
 2000-11-10  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * decl.c (grokdeclarator, save_function_data): Use memcpy, not bcopy.
        
 2000-11-07  Eric Christopher  <echristo@redhat.com>
 
-        * decl.c (init_decl_processing): Change definition of
-        __wchar_t to wchar_t.  Remove artificial declaration of
-        wchar_t.
-        * lex.c: Change instances of __wchar_t to wchar_t.
+       * decl.c (init_decl_processing): Change definition of
+       __wchar_t to wchar_t.  Remove artificial declaration of
+       wchar_t.
+       * lex.c: Change instances of __wchar_t to wchar_t.
 
 2000-11-09  Nathan Sidwell  <nathan@codesourcery.com>
 
index d23ef2f..0d677fe 100644 (file)
@@ -7655,6 +7655,7 @@ maybe_commonize_var (decl)
         inlining of such functions.  */
       current_function_cannot_inline
        = "function with static variable cannot be inline";
+      DECL_UNINLINABLE (current_function_decl) = 1;
 
       /* If flag_weak, we don't need to mess with this, as we can just
         make the function weak, and let it refer to its unique local
diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc
new file mode 100644 (file)
index 0000000..4f5a73c
--- /dev/null
@@ -0,0 +1,10 @@
+inline int f ()
+{
+  static int k;
+  return ++k;
+}
+
+int g ()
+{
+  return f();
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1.C b/gcc/testsuite/g++.old-deja/g++.other/comdat1.C
new file mode 100644 (file)
index 0000000..5dd43a8
--- /dev/null
@@ -0,0 +1,24 @@
+// Test that statics in inline functions are unified between
+// translation units.  Currently we handle this by just suppressing
+// inling and relying on unification of the function itself.
+
+// Special g++ Options: -O
+
+// Additional sources: comdat1-aux.cc
+
+inline int f ()
+{
+  static int i;
+  return ++i;
+}
+
+int g ();
+
+int main ()
+{
+  if (f() != 1
+      || g() != 2
+      || f() != 3)
+    return 1;
+  return 0;
+}