Commit e32fe224 by Jim Wilson

(pushdecl): Use lookup_name_current_level_global instead of lookup_name for extern references.

(pushdecl): Use lookup_name_current_level_global instead
of lookup_name for extern references.  Don't return duplicate decl
if it came from the global binding level, and there exists a
conflicting decl in an intervening block.
(lookup_name_current_level_global); New function.

From-SVN: r7189
parent 53dd9622
...@@ -1828,7 +1828,7 @@ pushdecl (x) ...@@ -1828,7 +1828,7 @@ pushdecl (x)
int line; int line;
if (DECL_EXTERNAL (x) && TREE_PUBLIC (x)) if (DECL_EXTERNAL (x) && TREE_PUBLIC (x))
t = lookup_name (name); t = lookup_name_current_level_global (name);
else else
t = lookup_name_current_level (name); t = lookup_name_current_level (name);
if (t != 0 && t == error_mark_node) if (t != 0 && t == error_mark_node)
...@@ -1869,6 +1869,11 @@ pushdecl (x) ...@@ -1869,6 +1869,11 @@ pushdecl (x)
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
} }
/* If this is a global decl, and there exists a conflicting local
decl in a parent block, then we can't return as yet, because we
need to register this decl in the current binding block. */
if (! DECL_EXTERNAL (x) || ! TREE_PUBLIC (x)
|| lookup_name (name) == t)
return t; return t;
} }
...@@ -2610,6 +2615,29 @@ lookup_name_current_level (name) ...@@ -2610,6 +2615,29 @@ lookup_name_current_level (name)
return t; return t;
} }
/* Similar to `lookup_name_current_level' but also look at the global binding
level. */
tree
lookup_name_current_level_global (name)
tree name;
{
register tree t = 0;
if (current_binding_level == global_binding_level)
return IDENTIFIER_GLOBAL_VALUE (name);
if (IDENTIFIER_LOCAL_VALUE (name) != 0)
for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
if (DECL_NAME (t) == name)
break;
if (t == 0)
t = IDENTIFIER_GLOBAL_VALUE (name);
return t;
}
/* Create the predefined scalar types of C, /* Create the predefined scalar types of C,
and some nodes representing standard constants (0, 1, (void *)0). and some nodes representing standard constants (0, 1, (void *)0).
Initialize the global binding level. Initialize the global binding level.
......
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