From 93f623faa97cf6a4a92e9b1b575c8b6c99fa898c Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Tue, 12 Jul 1994 18:37:25 -0700 Subject: (pushdecl): Don't call lookup_name_current_level_global when traditional. (pushdecl): Don't call lookup_name_current_level_global when traditional. When doing checks against IDENTIFIER_LIMBO_VALUE, also do check against INDENTIFIER_GLOBAL_VALUE when traditional. From-SVN: r7756 --- gcc/c-decl.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'gcc') diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 0a4b1f1..c1a8dc9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1842,7 +1842,10 @@ pushdecl (x) char *file; int line; - if (DECL_EXTERNAL (x) && TREE_PUBLIC (x)) + /* Don't type check externs here when -traditional. This is so that + code with conflicting declarations inside blocks will get warnings + not errors. X11 for instance depends on this. */ + if (DECL_EXTERNAL (x) && TREE_PUBLIC (x) && ! flag_traditional) t = lookup_name_current_level_global (name); else t = lookup_name_current_level (name); @@ -1953,20 +1956,26 @@ pushdecl (x) } /* Multiple external decls of the same identifier ought to match. - Check against out of scope (limbo) block level declarations. - - If this is a block level declaration, then DECL_EXTERNAL must also - be set, so we have already checked against global declarations above - via the lookup_name call. + Check against both global declarations (when traditional) and out of + scope (limbo) block level declarations. We get warnings about inline functions where they are defined. Avoid duplicate warnings where they are used. */ - if (TREE_PUBLIC (x) && ! DECL_INLINE (x) - && IDENTIFIER_LIMBO_VALUE (name)) + if (TREE_PUBLIC (x) && ! DECL_INLINE (x)) { - tree decl = IDENTIFIER_LIMBO_VALUE (name); + tree decl; + + if (flag_traditional && IDENTIFIER_GLOBAL_VALUE (name) != 0 + && (DECL_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name)) + || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name)))) + decl = IDENTIFIER_GLOBAL_VALUE (name); + else if (IDENTIFIER_LIMBO_VALUE (name) != 0) + /* Decls in limbo are always extern, so no need to check that. */ + decl = IDENTIFIER_LIMBO_VALUE (name); + else + decl = 0; - if (! comptypes (TREE_TYPE (x), TREE_TYPE (decl)) + if (decl && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl)) /* If old decl is built-in, we already warned if we should. */ && !DECL_BUILT_IN (decl)) { -- cgit v1.1