tree saved_scope;
tree saved_qualifying_scope;
tree saved_object_scope;
+ bool pop_p = false;
/* Look for the `operator' token. */
if (!cp_parser_require_keyword (parser, RID_OPERATOR, "`operator'"))
In order to see that `I' is a type-name in the definition, we
must be in the scope of `S'. */
if (saved_scope)
- push_scope (saved_scope);
+ pop_p = push_scope (saved_scope);
/* Parse the conversion-type-id. */
type = cp_parser_conversion_type_id (parser);
/* Leave the scope of the class, if any. */
- if (saved_scope)
+ if (pop_p)
pop_scope (saved_scope);
/* Restore the saved scope. */
parser->scope = saved_scope;
bool is_non_constant_init;
int ctor_dtor_or_conv_p;
bool friend_p;
+ bool pop_p = false;
/* Assume that this is not the declarator for a function
definition. */
/* Enter the SCOPE. That way unqualified names appearing in the
initializer will be looked up in SCOPE. */
if (scope)
- push_scope (scope);
+ pop_p = push_scope (scope);
/* Perform deferred access control checks, now that we know in which
SCOPE the declared entity resides. */
is important to do this before calling cp_finish_decl because it
makes decisions about whether to create DECL_STMTs or not based
on the current scope. */
- if (scope)
+ if (pop_p)
pop_scope (scope);
/* For an in-class declaration, use `grokfield' to create the
bool saved_default_arg_ok_p = parser->default_arg_ok_p;
bool saved_in_declarator_p = parser->in_declarator_p;
bool first = true;
+ bool pop_p = false;
while (true)
{
handle_declarator:;
scope = get_scope_of_declarator (declarator);
if (scope)
- /* Any names that appear after the declarator-id for a member
- are looked up in the containing scope. */
- push_scope (scope);
+ /* Any names that appear after the declarator-id for a
+ member are looked up in the containing scope. */
+ pop_p = push_scope (scope);
parser->in_declarator_p = true;
if ((ctor_dtor_or_conv_p && *ctor_dtor_or_conv_p)
|| (declarator
cp_parser_error (parser, "expected declarator");
/* If we entered a scope, we must exit it now. */
- if (scope)
+ if (pop_p)
pop_scope (scope);
parser->default_arg_ok_p = saved_default_arg_ok_p;
int has_trailing_semicolon;
bool nested_name_specifier_p;
unsigned saved_num_template_parameter_lists;
+ bool pop_p = false;
push_deferring_access_checks (dk_no_deferred);
/* Start the class. */
if (nested_name_specifier_p)
- push_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type)));
+ pop_p = push_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type)));
type = begin_class_definition (type);
if (type == error_mark_node)
/* If the type is erroneous, skip the entire body of the class. */
TYPE_ATTRIBUTES (type) = NULL_TREE;
type = finish_struct (type, attributes);
}
- if (nested_name_specifier_p)
+ if (pop_p)
pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type)));
/* If this class is not itself within the scope of another class,
then we need to parse the bodies of all of the queued function
bool qualified_p = false;
bool invalid_nested_name_p = false;
bool invalid_explicit_specialization_p = false;
+ bool pop_p = false;
unsigned num_templates;
/* Assume no nested-name-specifier will be present. */
else
{
tree class_type;
+ bool pop_p = false;
/* Given:
class_type = current_class_type;
/* Enter the scope indicated by the nested-name-specifier. */
if (nested_name_specifier)
- push_scope (nested_name_specifier);
+ pop_p = push_scope (nested_name_specifier);
/* Get the canonical version of this type. */
type = TYPE_MAIN_DECL (TREE_TYPE (type));
if (PROCESSING_REAL_TEMPLATE_DECL_P ()
if (nested_name_specifier)
{
*nested_name_specifier_p = true;
- pop_scope (nested_name_specifier);
+ if (pop_p)
+ pop_scope (nested_name_specifier);
}
}
/* Indicate whether this class was declared as a `class' or as a
is valid. */
if (nested_name_specifier)
- push_scope (nested_name_specifier);
+ pop_p = push_scope (nested_name_specifier);
/* Now, look for the base-clause. */
token = cp_lexer_peek_token (parser->lexer);
if (token->type == CPP_COLON)
}
/* Leave the scope given by the nested-name-specifier. We will
enter the class scope itself while processing the members. */
- if (nested_name_specifier)
+ if (pop_p)
pop_scope (nested_name_specifier);
done:
}
else
{
+ bool pop_p = false;
+
/* If PARSER->SCOPE is a dependent type, then it must be a
class type, and we must not be checking dependencies;
otherwise, we would have processed this lookup above. So
that PARSER->SCOPE is not considered a dependent base by
lookup_member, we must enter the scope here. */
if (dependent_p)
- push_scope (parser->scope);
+ pop_p = push_scope (parser->scope);
/* If the PARSER->SCOPE is a a template specialization, it
may be instantiated during name lookup. In that case,
errors may be issued. Even if we rollback the current
tentative parse, those errors are valid. */
decl = lookup_qualified_name (parser->scope, name, is_type,
/*complain=*/true);
- if (dependent_p)
+ if (pop_p)
pop_scope (parser->scope);
}
parser->qualifying_scope = parser->scope;
&& !cp_parser_storage_class_specifier_opt (parser))
{
tree type;
+ bool pop_p = false;
unsigned saved_num_template_parameter_lists;
/* Names appearing in the type-specifier should be looked up
return false;
}
}
- push_scope (type);
+ pop_p = push_scope (type);
}
/* Inside the constructor parameter list, surrounding
= saved_num_template_parameter_lists;
/* Leave the scope of the class. */
- if (type)
+ if (pop_p)
pop_scope (type);
constructor_p = !cp_parser_error_occurred (parser);
tree pbases = BINFO_BASETYPES (pbinfo);
tree paccesses = BINFO_BASEACCESSES (pbinfo);
tree context = TYPE_CONTEXT (type);
+ bool pop_p;
int i;
/* We must enter the scope containing the type, as that is where
the accessibility of types named in dependent bases are
looked up from. */
- push_scope (context ? context : global_namespace);
+ pop_p = push_scope (context ? context : global_namespace);
/* Substitute into each of the bases to determine the actual
basetypes. */
information. */
xref_basetypes (type, base_list);
- pop_scope (context ? context : global_namespace);
+ if (pop_p)
+ pop_scope (context ? context : global_namespace);
}
/* Now that our base classes are set up, enter the scope of the
tree name;
tree decl;
int quals;
+ bool pop_p;
my_friendly_assert (TREE_CODE (type) == TYPENAME_TYPE,
20010702);
/* Enter the SCOPE so that name lookup will be resolved as if we
were in the class definition. In particular, SCOPE will no
longer be considered a dependent type. */
- push_scope (scope);
+ pop_p = push_scope (scope);
/* Look up the declaration. */
decl = lookup_member (scope, name, /*protect=*/0, /*want_type=*/true);
/* Obtain the set of qualifiers applied to the TYPE. */
if (type != error_mark_node && quals)
type = cp_build_qualified_type (type, quals);
/* Leave the SCOPE. */
- pop_scope (scope);
+ if (pop_p)
+ pop_scope (scope);
return type;
}