summaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c72
1 files changed, 32 insertions, 40 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 027a7b9d07a..0f897c96f07 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -273,7 +273,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
if (start_token > VEC_address (cp_token, buffer))
{
- cp_lexer_print_token (file, VEC_index (cp_token, buffer, 0));
+ cp_lexer_print_token (file, &VEC_index (cp_token, buffer, 0));
fprintf (file, " ... ");
}
@@ -313,8 +313,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
if (i == num && i < VEC_length (cp_token, buffer))
{
fprintf (file, " ... ");
- cp_lexer_print_token (file, VEC_index (cp_token, buffer,
- VEC_length (cp_token, buffer) - 1));
+ cp_lexer_print_token (file, &VEC_last (cp_token, buffer));
}
fprintf (file, "\n");
@@ -1723,11 +1722,11 @@ cp_parser_context_new (cp_parser_context* next)
/* Managing the unparsed function queues. */
#define unparsed_funs_with_default_args \
- VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues)->funs_with_default_args
+ VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).funs_with_default_args
#define unparsed_funs_with_definitions \
- VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues)->funs_with_definitions
+ VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).funs_with_definitions
#define unparsed_nsdmis \
- VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues)->nsdmis
+ VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).nsdmis
static void
push_unparsed_function_queues (cp_parser *parser)
@@ -2008,7 +2007,7 @@ static tree cp_parser_class_name
static tree cp_parser_class_specifier
(cp_parser *);
static tree cp_parser_class_head
- (cp_parser *, bool *, tree *);
+ (cp_parser *, bool *);
static enum tag_types cp_parser_class_key
(cp_parser *);
static void cp_parser_member_specification_opt
@@ -8048,7 +8047,7 @@ record_lambda_scope (tree lambda)
static void
finish_lambda_scope (void)
{
- tree_int *p = VEC_last (tree_int, lambda_scope_stack);
+ tree_int *p = &VEC_last (tree_int, lambda_scope_stack);
if (lambda_scope != p->t)
{
lambda_scope = p->t;
@@ -10515,7 +10514,7 @@ cp_parser_simple_declaration (cp_parser* parser,
if (cp_parser_declares_only_class_p (parser))
shadow_tag (&decl_specifiers);
/* Perform any deferred access checks. */
- perform_deferred_access_checks ();
+ perform_deferred_access_checks (tf_warning_or_error);
}
/* Consume the `;'. */
@@ -11993,8 +11992,7 @@ cp_parser_template_parameter_list (cp_parser* parser)
parm_loc,
parameter,
is_non_type,
- is_parameter_pack,
- 0);
+ is_parameter_pack);
else
{
tree err_parm = build_tree_list (parameter, parameter);
@@ -12417,7 +12415,8 @@ cp_parser_template_id (cp_parser *parser,
FOR_EACH_VEC_ELT (deferred_access_check, access_check, i, chk)
perform_or_defer_access_check (chk->binfo,
chk->decl,
- chk->diag_decl);
+ chk->diag_decl,
+ tf_warning_or_error);
}
/* Return the stored value. */
return check_value->value;
@@ -15752,7 +15751,7 @@ cp_parser_init_declarator (cp_parser* parser,
/* Perform the access control checks for the declarator and the
decl-specifiers. */
- perform_deferred_access_checks ();
+ perform_deferred_access_checks (tf_warning_or_error);
/* Restore the saved value. */
if (TREE_CODE (decl) == FUNCTION_DECL)
@@ -15849,8 +15848,8 @@ cp_parser_init_declarator (cp_parser* parser,
/* Core issue #226 (C++0x only): A default template-argument
shall not be specified in a friend class template
declaration. */
- check_default_tmpl_args (decl, current_template_parms, /*is_primary=*/1,
- /*is_partial=*/0, /*is_friend_decl=*/1);
+ check_default_tmpl_args (decl, current_template_parms, /*is_primary=*/true,
+ /*is_partial=*/false, /*is_friend_decl=*/1);
if (!friend_p && pushed_scope)
pop_scope (pushed_scope);
@@ -17962,15 +17961,13 @@ cp_parser_class_specifier_1 (cp_parser* parser)
bool saved_in_unbraced_linkage_specification_p;
tree old_scope = NULL_TREE;
tree scope = NULL_TREE;
- tree bases;
cp_token *closing_brace;
push_deferring_access_checks (dk_no_deferred);
/* Parse the class-head. */
type = cp_parser_class_head (parser,
- &nested_name_specifier_p,
- &bases);
+ &nested_name_specifier_p);
/* If the class-head was a semantic disaster, skip the entire body
of the class. */
if (!type)
@@ -17987,18 +17984,6 @@ cp_parser_class_specifier_1 (cp_parser* parser)
return error_mark_node;
}
- /* Process the base classes. If they're invalid, skip the
- entire class body. */
- if (!xref_basetypes (type, bases))
- {
- /* Consuming the closing brace yields better error messages
- later on. */
- if (cp_parser_skip_to_closing_brace (parser))
- 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. */
@@ -18284,14 +18269,14 @@ cp_parser_class_specifier (cp_parser* parser)
static tree
cp_parser_class_head (cp_parser* parser,
- bool* nested_name_specifier_p,
- tree *bases)
+ bool* nested_name_specifier_p)
{
tree nested_name_specifier;
enum tag_types class_key;
tree id = NULL_TREE;
tree type = NULL_TREE;
tree attributes;
+ tree bases;
cp_virt_specifiers virt_specifiers = VIRT_SPEC_UNSPECIFIED;
bool template_id_p = false;
bool qualified_p = false;
@@ -18308,8 +18293,6 @@ cp_parser_class_head (cp_parser* parser,
num_templates = 0;
parser->colon_corrects_to_scope_p = false;
- *bases = NULL_TREE;
-
/* Look for the class-key. */
class_key = cp_parser_class_key (parser);
if (class_key == none_type)
@@ -18672,7 +18655,15 @@ cp_parser_class_head (cp_parser* parser,
/* 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);
+ bases = cp_parser_base_clause (parser);
+ else
+ bases = NULL_TREE;
+
+ /* If we're really defining a class, process the base classes.
+ If they're invalid, fail. */
+ if (type && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)
+ && !xref_basetypes (type, bases))
+ type = NULL_TREE;
done:
/* Leave the scope given by the nested-name-specifier. We will
@@ -21018,7 +21009,7 @@ cp_parser_function_definition_from_specifiers_and_declarator
did not check, check them now. We must wait until we are in the
scope of the function to perform the checks, since the function
might be a friend. */
- perform_deferred_access_checks ();
+ perform_deferred_access_checks (tf_warning_or_error);
if (!success_p)
{
@@ -21207,7 +21198,6 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
{
/* Parse the template parameters. */
parameter_list = cp_parser_template_parameter_list (parser);
- fixup_template_parms ();
}
/* Get the deferred access checks from the parameter list. These
@@ -21313,7 +21303,7 @@ static void
cp_parser_perform_template_parameter_access_checks (VEC (deferred_access_check,gc)* checks)
{
++processing_template_parmlist;
- perform_access_checks (checks);
+ perform_access_checks (checks, tf_warning_or_error);
--processing_template_parmlist;
}
@@ -22762,7 +22752,7 @@ cp_parser_pre_parsed_nested_name_specifier (cp_parser *parser)
FOR_EACH_VEC_ELT (deferred_access_check, checks, i, chk)
perform_or_defer_access_check (chk->binfo,
chk->decl,
- chk->diag_decl);
+ chk->diag_decl, tf_warning_or_error);
}
/* Set the scope from the stored value. */
parser->scope = check_value->value;
@@ -24020,7 +24010,7 @@ cp_parser_objc_method_definition_list (cp_parser* parser)
if (!(ptk->type == CPP_PLUS || ptk->type == CPP_MINUS
|| ptk->type == CPP_EOF || ptk->keyword == RID_AT_END))
{
- perform_deferred_access_checks ();
+ perform_deferred_access_checks (tf_warning_or_error);
stop_deferring_access_checks ();
meth = cp_parser_function_definition_after_declarator (parser,
false);
@@ -26613,6 +26603,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
incr = cp_parser_omp_for_incr (parser, real_decl);
else
incr = cp_parser_expression (parser, false, NULL);
+ if (CAN_HAVE_LOCATION_P (incr) && !EXPR_HAS_LOCATION (incr))
+ SET_EXPR_LOCATION (incr, input_location);
}
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))