This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Use IDENTIFIER_LIMBO_VALUE to match extern decl in block scope
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, ang at redhat dot com
- Cc: Neil Booth <neil at daikokuya dot demon dot co dot uk>, "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: 10 Jan 2002 02:35:22 -0200
- Subject: Use IDENTIFIER_LIMBO_VALUE to match extern decl in block scope
- Organization: GCC Team, Red Hat
While Neil's patch below fixed PR 653, it broke the testcase included
in the patch below.
2001-11-02 Neil Booth <neil@daikokuya.demon.co.uk>
* c-decl.c (pushdecl): Move block inside if conditional to remove
possibility of a segfault. Lookup block-level extern
variables in enclosing scopes correctly.
* testsuite/gcc.c-torture/compile/20001018-1.x: Remove XFAIL.
This patch restores the correct behavior for the included testcase
without breaking the formerly-fixed testcase. Boostrapped and
regression-tested on athlon-pc-linux-gnu. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* c-decl.c (pushdecl): If no global declaration is found for an
extern declaration in block scope, try a limbo one.
Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.287
diff -u -p -r1.287 c-decl.c
--- gcc/c-decl.c 2002/01/06 03:51:08 1.287
+++ gcc/c-decl.c 2002/01/10 04:29:09
@@ -2165,11 +2165,13 @@ pushdecl (x)
not errors. X11 for instance depends on this. */
if (! t && DECL_EXTERNAL (x) && TREE_PUBLIC (x) && ! flag_traditional)
{
- t = lookup_name (name);
+ t = IDENTIFIER_GLOBAL_VALUE (name);
/* Type decls at global scope don't conflict with externs declared
inside lexical blocks. */
- if (t && TREE_CODE (t) == TYPE_DECL)
- t = 0;
+ if (! t || TREE_CODE (t) == TYPE_DECL)
+ /* If there's no visible global declaration, try for an
+ invisible one. */
+ t = IDENTIFIER_LIMBO_VALUE (name);
different_binding_level = 1;
}
if (t != 0 && t == error_mark_node)
Index: gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* gcc.c-torture/compile/20020110.c: New test.
Index: gcc/testsuite/gcc.c-torture/compile/20020110.c
===================================================================
RCS file: 20020110.c
diff -N 20020110.c
--- /dev/null Tue May 5 13:32:27 1998
+++ gcc/testsuite/gcc.c-torture/compile/20020110.c Wed Jan 9 20:29:16 2002
@@ -0,0 +1,12 @@
+/* Copyright 2002 Free Software Foundation */
+
+/* Make sure the nested extern declaration doesn't conflict with the
+ non-extern one in the enclosing scope. */
+
+void foo() {
+ static long bar;
+
+ {
+ extern int bar;
+ }
+}
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me