c-decl.c (pushdecl): When an extern declaration at block scope refers to a visible...
authorJoseph Myers <jsm@polyomino.org.uk>
Tue, 5 Oct 2004 19:54:26 +0000 (20:54 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Tue, 5 Oct 2004 19:54:26 +0000 (20:54 +0100)
* c-decl.c (pushdecl): When an extern declaration at block scope
refers to a visible entity with internal linkage, use the old DECL
rather than the new one.

testsuite:
* gcc.c-torture/compile/20041005-1.c: New test.

From-SVN: r88570

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20041005-1.c [new file with mode: 0644]

index 71aa4a9626fef1d3746005c38bb001380a9090f5..71f86e0e474d0f24c705cc290dfc7103edf96587 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-05  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * c-decl.c (pushdecl): When an extern declaration at block scope
+       refers to a visible entity with internal linkage, use the old DECL
+       rather than the new one.
+
 2004-10-05  Kazu Hirata  <kazu@cs.umass.edu>
 
        * tree-cfg.c (cleanup_tree_cfg): Remove extra parentheses in
index cd003a3b9725ccffb6c1d582800468022789161a..415a75792394bff58af259c3899af3a23164bd0d 100644 (file)
@@ -2046,6 +2046,7 @@ pushdecl (tree x)
                 just need to fall through to make the declaration in
                 this scope.  */
              nested = true;
+             x = visdecl;
            }
          else
            {
index 8849504824cd2553655d74ed2c4f485265f5d5f5..b95a6ee9ed17fe4ffd41d68d68a5d16042faa566 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-05  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * gcc.c-torture/compile/20041005-1.c: New test.
+
 2004-10-05  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/17829
diff --git a/gcc/testsuite/gcc.c-torture/compile/20041005-1.c b/gcc/testsuite/gcc.c-torture/compile/20041005-1.c
new file mode 100644 (file)
index 0000000..b0a6511
--- /dev/null
@@ -0,0 +1,6 @@
+/* This wrongly caused duplicate definitions of x in the assembler
+   output.  */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+
+static int x = 1;
+void f (void) { extern int x; }