From 1b36c8183586b92176cd67dc2250623632120a4c Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 5 Oct 2004 20:54:26 +0100 Subject: [PATCH] c-decl.c (pushdecl): When an extern declaration at block scope refers to a visible entity with... * 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 | 6 ++++++ gcc/c-decl.c | 1 + gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/compile/20041005-1.c | 6 ++++++ 4 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20041005-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71aa4a9626f..71f86e0e474 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-10-05 Joseph S. Myers + + * 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 * tree-cfg.c (cleanup_tree_cfg): Remove extra parentheses in diff --git a/gcc/c-decl.c b/gcc/c-decl.c index cd003a3b972..415a7579239 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2046,6 +2046,7 @@ pushdecl (tree x) just need to fall through to make the declaration in this scope. */ nested = true; + x = visdecl; } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8849504824c..b95a6ee9ed1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-10-05 Joseph S. Myers + + * gcc.c-torture/compile/20041005-1.c: New test. + 2004-10-05 Nathan Sidwell 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 index 00000000000..b0a65117ec3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20041005-1.c @@ -0,0 +1,6 @@ +/* This wrongly caused duplicate definitions of x in the assembler + output. */ +/* Origin: Joseph Myers */ + +static int x = 1; +void f (void) { extern int x; } -- 2.30.2