]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR lto/45956 (Promoted statics conflict)
authorRichard Guenther <rguenther@suse.de>
Sat, 9 Oct 2010 18:28:16 +0000 (18:28 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 9 Oct 2010 18:28:16 +0000 (18:28 +0000)
2010-10-09  Richard Guenther  <rguenther@suse.de>

PR lto/45956
* lto-streamer-in.c (lto_register_var_decl_in_symtab):
Properly check if a decl is an automatic var.

* gcc.dg/lto/20101009-2_0.c: New testcase.
* gcc.dg/lto/20101009-2_1.c: Likewise.
* gcc.dg/lto/20101009-2_2.c: Likewise.

From-SVN: r165235

gcc/ChangeLog
gcc/lto-streamer-in.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/20101009-2_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/20101009-2_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/20101009-2_2.c [new file with mode: 0644]

index 5c4d210611bbf02a8261ef96d9a044474fa376c2..5cb3cecba2c1ea6e4b62088ce47564a0d25a9cb9 100644 (file)
@@ -1,3 +1,9 @@
+2010-10-09  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/45956
+       * lto-streamer-in.c (lto_register_var_decl_in_symtab):
+       Properly check if a decl is an automatic var.
+
 2010-10-09  Richard Guenther  <rguenther@suse.de>
 
        PR lto/45947
index fb27e63b753d4506bebd66cdc9d26d5433692861..72ac6eca2f306d8538db10ec774114b07ac08627 100644 (file)
@@ -2367,27 +2367,26 @@ lto_input_tree_pointers (struct lto_input_block *ib, struct data_in *data_in,
 static void
 lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
 {
-  /* Register symbols with file or global scope to mark what input
-     file has their definition.  */
-  if (decl_function_context (decl) == NULL_TREE)
-    {
-      /* Variable has file scope, not local. Need to ensure static variables
-        between different files don't clash unexpectedly.  */
-      if (!TREE_PUBLIC (decl))
-        {
-         /* ??? We normally pre-mangle names before we serialize them
-            out.  Here, in lto1, we do not know the language, and
-            thus cannot do the mangling again. Instead, we just
-            append a suffix to the mangled name.  The resulting name,
-            however, is not a properly-formed mangled name, and will
-            confuse any attempt to unmangle it.  */
-         const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-         char *label;
-
-         ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
-         SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
-          rest_of_decl_compilation (decl, 1, 0);
-        }
+  tree context;
+
+  /* Variable has file scope, not local. Need to ensure static variables
+     between different files don't clash unexpectedly.  */
+  if (!TREE_PUBLIC (decl)
+      && !((context = decl_function_context (decl))
+          && auto_var_in_fn_p (decl, context)))
+    {
+      /* ??? We normally pre-mangle names before we serialize them
+        out.  Here, in lto1, we do not know the language, and
+        thus cannot do the mangling again. Instead, we just
+        append a suffix to the mangled name.  The resulting name,
+        however, is not a properly-formed mangled name, and will
+        confuse any attempt to unmangle it.  */
+      const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+      char *label;
+
+      ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
+      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
+      rest_of_decl_compilation (decl, 1, 0);
     }
 
   /* If this variable has already been declared, queue the
index 9c16eed597a5bc4c77185c5dc32923559aebc5df..d5af564c7ebcad22c21125056cd418a5c4e76632 100644 (file)
@@ -1,3 +1,10 @@
+2010-10-09  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/45956
+       * gcc.dg/lto/20101009-2_0.c: New testcase.
+       * gcc.dg/lto/20101009-2_1.c: Likewise.
+       * gcc.dg/lto/20101009-2_2.c: Likewise.
+
 2010-10-09  Richard Guenther  <rguenther@suse.de>
 
        PR lto/45947
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_0.c b/gcc/testsuite/gcc.dg/lto/20101009-2_0.c
new file mode 100644 (file)
index 0000000..249d0e0
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-lto-do link } */
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_1.c b/gcc/testsuite/gcc.dg/lto/20101009-2_1.c
new file mode 100644 (file)
index 0000000..887057d
--- /dev/null
@@ -0,0 +1,5 @@
+int foo (void)
+{
+  static int i;
+  return ++i;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_2.c b/gcc/testsuite/gcc.dg/lto/20101009-2_2.c
new file mode 100644 (file)
index 0000000..4a97fe8
--- /dev/null
@@ -0,0 +1,5 @@
+int bar (void)
+{
+  static int i;
+  return ++i;
+}