aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1994-03-17 15:45:04 -0800
committerJim Wilson <wilson@gcc.gnu.org>1994-03-17 15:45:04 -0800
commit7dcf01c29cbcc7056e41c27b912309dc60b44071 (patch)
treeeefbb2aff394ecf7c678981c0a98e45f192a31a9 /gcc/c-decl.c
parent597681f6d1f4905bb5ca063334a5fd824525f670 (diff)
downloadgcc-7dcf01c29cbcc7056e41c27b912309dc60b44071.zip
gcc-7dcf01c29cbcc7056e41c27b912309dc60b44071.tar.gz
gcc-7dcf01c29cbcc7056e41c27b912309dc60b44071.tar.bz2
(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
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 66ca348..7e07932 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;
}