Commit 234f46ae by Neil Booth Committed by Neil Booth

c-decl.c (pushdecl): Move block inside if conditional to remove possibility of a segfault.

	* 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.

From-SVN: r46726
parent 1b5e9d7e
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.
2001-11-02 Aldy Hernandez <aldyh@redhat.com> 2001-11-02 Aldy Hernandez <aldyh@redhat.com>
* expmed.c (store_bit_field): Use simplify_gen_subreg to make * expmed.c (store_bit_field): Use simplify_gen_subreg to make
......
...@@ -2115,25 +2115,28 @@ pushdecl (x) ...@@ -2115,25 +2115,28 @@ pushdecl (x)
&& DECL_INITIAL (x) == 0 && DECL_EXTERNAL (x)) && DECL_INITIAL (x) == 0 && DECL_EXTERNAL (x))
DECL_CONTEXT (x) = 0; DECL_CONTEXT (x) = 0;
if (warn_nested_externs && DECL_EXTERNAL (x) && b != global_binding_level
&& x != IDENTIFIER_IMPLICIT_DECL (name)
/* Don't print error messages for __FUNCTION__ and __PRETTY_FUNCTION__ */
&& !DECL_IN_SYSTEM_HEADER (x))
warning ("nested extern declaration of `%s'", IDENTIFIER_POINTER (name));
if (name) if (name)
{ {
const char *file; const char *file;
int line; int line;
int different_binding_level = 0; int different_binding_level = 0;
if (warn_nested_externs
&& DECL_EXTERNAL (x)
&& b != global_binding_level
&& x != IDENTIFIER_IMPLICIT_DECL (name)
/* No error messages for __FUNCTION__ and __PRETTY_FUNCTION__. */
&& !DECL_IN_SYSTEM_HEADER (x))
warning ("nested extern declaration of `%s'",
IDENTIFIER_POINTER (name));
t = lookup_name_current_level (name); t = lookup_name_current_level (name);
/* Don't type check externs here when -traditional. This is so that /* Don't type check externs here when -traditional. This is so that
code with conflicting declarations inside blocks will get warnings code with conflicting declarations inside blocks will get warnings
not errors. X11 for instance depends on this. */ not errors. X11 for instance depends on this. */
if (! t && DECL_EXTERNAL (x) && TREE_PUBLIC (x) && ! flag_traditional) if (! t && DECL_EXTERNAL (x) && TREE_PUBLIC (x) && ! flag_traditional)
{ {
t = IDENTIFIER_GLOBAL_VALUE (name); t = lookup_name (name);
/* Type decls at global scope don't conflict with externs declared /* Type decls at global scope don't conflict with externs declared
inside lexical blocks. */ inside lexical blocks. */
if (t && TREE_CODE (t) == TYPE_DECL) if (t && TREE_CODE (t) == TYPE_DECL)
......
set torture_compile_xfail "*-*-*"
return 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment