From: Jim Wilson Date: Thu, 17 Mar 1994 23:45:04 +0000 (-0800) Subject: (pushdecl): Call lookup_name for external references. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7dcf01c29cbcc7056e41c27b912309dc60b44071;p=gcc.git (pushdecl): Call lookup_name for external references. Delete code to check external references against global declarations. (redeclaration_error_message): If newdecl has block scope, then return string only if olddecl has the same scope. From-SVN: r6807 --- diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 66ca3486694..7e079323bd5 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1798,7 +1798,10 @@ pushdecl (x) char *file; int line; - t = lookup_name_current_level (name); + if (DECL_EXTERNAL (x) && TREE_PUBLIC (x)) + t = lookup_name (name); + else + t = lookup_name_current_level (name); if (t != 0 && t == error_mark_node) /* error_mark_node is 0 for a while during initialization! */ { @@ -1901,26 +1904,20 @@ pushdecl (x) } /* Multiple external decls of the same identifier ought to match. - Check against both global declarations and out of scope (limbo) block - level declarations. + 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. We get warnings about inline functions where they are defined. Avoid duplicate warnings where they are used. */ - if (TREE_PUBLIC (x) && ! DECL_INLINE (x)) + if (TREE_PUBLIC (x) && ! DECL_INLINE (x) + && IDENTIFIER_LIMBO_VALUE (name)) { - tree decl; - - if (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; + tree decl = IDENTIFIER_LIMBO_VALUE (name); - if (decl && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl)) + if (! comptypes (TREE_TYPE (x), TREE_TYPE (decl)) /* If old decl is built-in, we already warned if we should. */ && !DECL_BUILT_IN (decl)) { @@ -2308,10 +2305,12 @@ redeclaration_error_message (newdecl, olddecl) return 0; else { - /* Objects declared with block scope: */ - /* Reject two definitions, and reject a definition - together with an external reference. */ - if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl))) + /* Newdecl has block scope. If olddecl has block scope also, then + reject two definitions, and reject a definition together with an + external reference. Otherwise, it is OK, because newdecl must + be an extern reference to olddecl. */ + if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)) + && DECL_CONTEXT (newdecl) == DECL_CONTEXT (olddecl)) return "redeclaration of `%s'"; return 0; }