static GTY((deletable (""))) struct cp_binding_level *free_binding_level;
-/* The outermost binding level, for names of file scope.
- This is created when the compiler is started and exists
- through the entire run. */
-
-static GTY(()) struct cp_binding_level *global_binding_level;
-
/* Nonzero means unconditionally make a BLOCK for the next level pushed. */
static int keep_next_level_flag;
static void
pop_binding_level (void)
{
- if (global_binding_level)
- {
- /* Cannot pop a level, if there are none left to pop. */
- if (current_binding_level == global_binding_level)
- abort ();
- }
+ if (NAMESPACE_LEVEL (global_namespace))
+ /* Cannot pop a level, if there are none left to pop. */
+ my_friendly_assert (!global_scope_p (current_binding_level), 20030527);
/* Pop the current level, and free the structure for reuse. */
#if defined(DEBUG_BINDING_LEVELS)
binding_depth--;
if (class_binding_level)
current_binding_level = class_binding_level;
- if (global_binding_level)
- {
- /* Cannot suspend a level, if there are none left to suspend. */
- if (current_binding_level == global_binding_level)
- abort ();
- }
+ if (NAMESPACE_LEVEL (global_namespace))
+ /* Cannot suspend a level, if there are none left to suspend. */
+ my_friendly_assert (!global_scope_p (current_binding_level), 20030527);
/* Suspend the current level. */
#if defined(DEBUG_BINDING_LEVELS)
binding_depth--;
int
global_bindings_p (void)
{
- return current_binding_level == global_binding_level;
+ return global_scope_p (current_binding_level);
}
/* Return the innermost binding level that is not for a class scope. */
print_other_binding_stack (struct cp_binding_level *stack)
{
struct cp_binding_level *level;
- for (level = stack; level != global_binding_level; level = level->level_chain)
+ for (level = stack; !global_scope_p (level); level = level->level_chain)
{
fprintf (stderr, "binding level ");
fprintf (stderr, HOST_PTR_PRINTF, (void *) level);
fprintf (stderr, HOST_PTR_PRINTF, (void *) current_binding_level);
fprintf (stderr, "\nclass_binding_level=");
fprintf (stderr, HOST_PTR_PRINTF, (void *) class_binding_level);
- fprintf (stderr, "\nglobal_binding_level=");
- fprintf (stderr, HOST_PTR_PRINTF, (void *) global_binding_level);
+ fprintf (stderr, "\nNAMESPACE_LEVEL (global_namespace)=");
+ fprintf (stderr, HOST_PTR_PRINTF,
+ (void *) NAMESPACE_LEVEL (global_namespace));
fprintf (stderr, "\n");
if (class_binding_level)
{
b = current_binding_level;
print_other_binding_stack (b);
fprintf (stderr, "global:\n");
- print_binding_level (global_binding_level);
+ print_binding_level (NAMESPACE_LEVEL (global_namespace));
}
/* Namespace binding access routines: The namespace_bindings field of
if (scope_chain && previous_class_type)
old_bindings = store_bindings (previous_class_values, old_bindings);
- /* Have to include global_binding_level, because class-level decls
+ /* Have to include the global scope, because class-scope decls
aren't listed anywhere useful. */
for (; b; b = b->level_chain)
{
inserted into namespace level, finish_file wouldn't find them
when doing pending instantiations. Therefore, don't stop at
namespace level, but continue until :: . */
- if (b == global_binding_level || (pseudo && b->template_parms_p))
+ if (global_scope_p (b) || (pseudo && b->template_parms_p))
break;
old_bindings = store_bindings (b->names, old_bindings);
tree name = DECL_NAME (x);
tree newval;
tree *ptr = (tree *)0;
- for (; b != global_binding_level; b = b->level_chain)
+ for (; !global_scope_p (b); b = b->level_chain)
{
tree shadowed = b->type_shadowed;
for (; shadowed; shadowed = TREE_CHAIN (shadowed))
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
-/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL,
- if appropriate. */
+/* Like pushdecl, only it places X in the global scope if appropriate. */
tree
pushdecl_top_level (tree x)
/* Make the binding_level structure for global names. */
pushlevel (0);
- global_binding_level = current_binding_level;
- global_binding_level->type_decls = binding_table_new (GLOBAL_SCOPE_HT_SIZE);
+ current_binding_level->type_decls = binding_table_new (GLOBAL_SCOPE_HT_SIZE);
/* The global level is the namespace level of ::. */
- NAMESPACE_LEVEL (global_namespace) = global_binding_level;
+ NAMESPACE_LEVEL (global_namespace) = current_binding_level;
declare_namespace_level ();
- VARRAY_TREE_INIT (global_binding_level->static_decls,
+ VARRAY_TREE_INIT (current_binding_level->static_decls,
200,
"Static declarations");
cplus_decl_attributes (&decl, attributes, 0);
/* If #pragma weak was used, mark the decl weak now. */
- if (current_binding_level == global_binding_level)
+ if (global_scope_p (current_binding_level))
maybe_apply_pragma_weak (decl);
if (TREE_CODE (decl) == FUNCTION_DECL
}
/* If a name was specified, get the string. */
- if (current_binding_level == global_binding_level)
+ if (global_scope_p (current_binding_level))
asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
if (asmspec_tree)
asmspec = TREE_STRING_POINTER (asmspec_tree);
cplus_decl_attributes (&decl1, attrs, 0);
/* If #pragma weak was used, mark the decl weak now. */
- if (current_binding_level == global_binding_level)
+ if (global_scope_p (current_binding_level))
maybe_apply_pragma_weak (decl1);
fntype = TREE_TYPE (decl1);