static tree cp_parser_class_specifier
(cp_parser *);
static tree cp_parser_class_head
- (cp_parser *, bool *, tree *);
+ (cp_parser *, bool *, tree *, tree *);
static enum tag_types cp_parser_class_key
(cp_parser *);
static void cp_parser_member_specification_opt
bool saved_in_function_body;
tree old_scope = NULL_TREE;
tree scope = NULL_TREE;
+ tree bases;
push_deferring_access_checks (dk_no_deferred);
/* Parse the class-head. */
type = cp_parser_class_head (parser,
&nested_name_specifier_p,
- &attributes);
+ &attributes,
+ &bases);
/* If the class-head was a semantic disaster, skip the entire body
of the class. */
if (!type)
return error_mark_node;
}
+ /* Process the base classes. If they're invalid, skip the
+ entire class body. */
+ if (!xref_basetypes (type, bases))
+ {
+ cp_parser_skip_to_closing_brace (parser);
+
+ /* Consuming the closing brace yields better error messages
+ later on. */
+ cp_lexer_consume_token (parser->lexer);
+ pop_deferring_access_checks ();
+ return error_mark_node;
+ }
+
/* Issue an error message if type-definitions are forbidden here. */
cp_parser_check_type_definition (parser);
/* Remember that we are defining one more class. */
static tree
cp_parser_class_head (cp_parser* parser,
bool* nested_name_specifier_p,
- tree *attributes_p)
+ tree *attributes_p,
+ tree *bases)
{
tree nested_name_specifier;
enum tag_types class_key;
bool invalid_explicit_specialization_p = false;
tree pushed_scope = NULL_TREE;
unsigned num_templates;
- tree bases;
/* Assume no nested-name-specifier will be present. */
*nested_name_specifier_p = false;
type = NULL_TREE;
goto done;
}
+ else if (type == error_mark_node)
+ type = NULL_TREE;
/* We will have entered the scope containing the class; the names of
base classes should be looked up in that context. For example:
struct A::C : B {};
is valid. */
- bases = NULL_TREE;
+ *bases = NULL_TREE;
/* Get the list of base-classes, if there is one. */
if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
- bases = cp_parser_base_clause (parser);
-
- /* Process the base classes. */
- if (!xref_basetypes (type, bases))
- type = NULL_TREE;
+ *bases = cp_parser_base_clause (parser);
done:
/* Leave the scope given by the nested-name-specifier. We will