decl.c: Replace %H by an explicit location.

2009-07-06  Manuel López-Ibáñez  <manu@gcc.gnu.org>

cp/
	* decl.c: Replace %H by an explicit location. Update all calls.
	* except.c: Likewise.
	* semantics.c: Likewise.
	* parser.c: Likewise.

From-SVN: r149277
parent c4efba1c
2009-07-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
* decl.c: Replace %H by an explicit location. Update all calls.
* except.c: Likewise.
* semantics.c: Likewise.
* parser.c: Likewise.
2009-07-06 Simon Martin <simartin@users.sourceforge.net> 2009-07-06 Simon Martin <simartin@users.sourceforge.net>
PR c++/40557 PR c++/40557
......
...@@ -2490,7 +2490,7 @@ identify_goto (tree decl, const location_t *locus) ...@@ -2490,7 +2490,7 @@ identify_goto (tree decl, const location_t *locus)
else else
permerror (input_location, "jump to case label"); permerror (input_location, "jump to case label");
if (locus) if (locus)
permerror (input_location, "%H from here", locus); permerror (*locus, " from here");
} }
/* Check that a single previously seen jump to a newly defined label /* Check that a single previously seen jump to a newly defined label
......
...@@ -998,10 +998,11 @@ check_handlers_1 (tree master, tree_stmt_iterator i) ...@@ -998,10 +998,11 @@ check_handlers_1 (tree master, tree_stmt_iterator i)
tree handler = tsi_stmt (i); tree handler = tsi_stmt (i);
if (TREE_TYPE (handler) && can_convert_eh (type, TREE_TYPE (handler))) if (TREE_TYPE (handler) && can_convert_eh (type, TREE_TYPE (handler)))
{ {
warning (0, "%Hexception of type %qT will be caught", warning_at (EXPR_LOCATION (handler), 0,
EXPR_LOCUS (handler), TREE_TYPE (handler)); "exception of type %qT will be caught",
warning (0, "%H by earlier handler for %qT", TREE_TYPE (handler));
EXPR_LOCUS (master), type); warning_at (EXPR_LOCATION (master), 0,
" by earlier handler for %qT", type);
break; break;
} }
} }
...@@ -1030,8 +1031,8 @@ check_handlers (tree handlers) ...@@ -1030,8 +1031,8 @@ check_handlers (tree handlers)
if (tsi_end_p (i)) if (tsi_end_p (i))
break; break;
if (TREE_TYPE (handler) == NULL_TREE) if (TREE_TYPE (handler) == NULL_TREE)
permerror (input_location, "%H%<...%> handler must be the last handler for" permerror (EXPR_LOCATION (handler), "%<...%>"
" its try block", EXPR_LOCUS (handler)); " handler must be the last handler for its try block");
else else
check_handlers_1 (handler, i); check_handlers_1 (handler, i);
} }
......
...@@ -2079,7 +2079,8 @@ cp_parser_error (cp_parser* parser, const char* message) ...@@ -2079,7 +2079,8 @@ cp_parser_error (cp_parser* parser, const char* message)
if (token->type == CPP_PRAGMA) if (token->type == CPP_PRAGMA)
{ {
error ("%H%<#pragma%> is not allowed here", &token->location); error_at (token->location,
"%<#pragma%> is not allowed here");
cp_parser_skip_to_pragma_eol (parser, token); cp_parser_skip_to_pragma_eol (parser, token);
return; return;
} }
...@@ -2110,26 +2111,26 @@ cp_parser_name_lookup_error (cp_parser* parser, ...@@ -2110,26 +2111,26 @@ cp_parser_name_lookup_error (cp_parser* parser,
if (decl == error_mark_node) if (decl == error_mark_node)
{ {
if (parser->scope && parser->scope != global_namespace) if (parser->scope && parser->scope != global_namespace)
error ("%H%<%E::%E%> has not been declared", error_at (location, "%<%E::%E%> has not been declared",
&location, parser->scope, name); parser->scope, name);
else if (parser->scope == global_namespace) else if (parser->scope == global_namespace)
error ("%H%<::%E%> has not been declared", &location, name); error_at (location, "%<::%E%> has not been declared", name);
else if (parser->object_scope else if (parser->object_scope
&& !CLASS_TYPE_P (parser->object_scope)) && !CLASS_TYPE_P (parser->object_scope))
error ("%Hrequest for member %qE in non-class type %qT", error_at (location, "request for member %qE in non-class type %qT",
&location, name, parser->object_scope); name, parser->object_scope);
else if (parser->object_scope) else if (parser->object_scope)
error ("%H%<%T::%E%> has not been declared", error_at (location, "%<%T::%E%> has not been declared",
&location, parser->object_scope, name); parser->object_scope, name);
else else
error ("%H%qE has not been declared", &location, name); error_at (location, "%qE has not been declared", name);
} }
else if (parser->scope && parser->scope != global_namespace) else if (parser->scope && parser->scope != global_namespace)
error ("%H%<%E::%E%> %s", &location, parser->scope, name, desired); error_at (location, "%<%E::%E%> %s", parser->scope, name, desired);
else if (parser->scope == global_namespace) else if (parser->scope == global_namespace)
error ("%H%<::%E%> %s", &location, name, desired); error_at (location, "%<::%E%> %s", name, desired);
else else
error ("%H%qE %s", &location, name, desired); error_at (location, "%qE %s", name, desired);
} }
/* If we are parsing tentatively, remember that an error has occurred /* If we are parsing tentatively, remember that an error has occurred
...@@ -2164,7 +2165,7 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs, ...@@ -2164,7 +2165,7 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs,
if (ds == ds_long) if (ds == ds_long)
{ {
if (count > 2) if (count > 2)
error ("%H%<long long long%> is too long for GCC", &location); error_at (location, "%<long long long%> is too long for GCC");
else else
pedwarn_cxx98 (location, OPT_Wlong_long, pedwarn_cxx98 (location, OPT_Wlong_long,
"ISO C++ 1998 does not support %<long long%>"); "ISO C++ 1998 does not support %<long long%>");
...@@ -2187,7 +2188,7 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs, ...@@ -2187,7 +2188,7 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs,
"__complex", "__complex",
"__thread" "__thread"
}; };
error ("%Hduplicate %qs", &location, decl_spec_names[ds]); error_at (location, "duplicate %qs", decl_spec_names[ds]);
} }
} }
} }
...@@ -2231,7 +2232,8 @@ cp_parser_check_for_definition_in_return_type (cp_declarator *declarator, ...@@ -2231,7 +2232,8 @@ cp_parser_check_for_definition_in_return_type (cp_declarator *declarator,
if (declarator if (declarator
&& declarator->kind == cdk_function) && declarator->kind == cdk_function)
{ {
error ("%Hnew types may not be defined in a return type", &type_location); error_at (type_location,
"new types may not be defined in a return type");
inform (type_location, inform (type_location,
"(perhaps a semicolon is missing after the definition of %qT)", "(perhaps a semicolon is missing after the definition of %qT)",
type); type);
...@@ -2253,11 +2255,11 @@ cp_parser_check_for_invalid_template_id (cp_parser* parser, ...@@ -2253,11 +2255,11 @@ cp_parser_check_for_invalid_template_id (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) if (cp_lexer_next_token_is (parser->lexer, CPP_LESS))
{ {
if (TYPE_P (type)) if (TYPE_P (type))
error ("%H%qT is not a template", &location, type); error_at (location, "%qT is not a template", type);
else if (TREE_CODE (type) == IDENTIFIER_NODE) else if (TREE_CODE (type) == IDENTIFIER_NODE)
error ("%H%qE is not a template", &location, type); error_at (location, "%qE is not a template", type);
else else
error ("%Hinvalid template-id", &location); error_at (location, "invalid template-id");
/* Remember the location of the invalid "<". */ /* Remember the location of the invalid "<". */
if (cp_parser_uncommitted_to_tentative_parse_p (parser)) if (cp_parser_uncommitted_to_tentative_parse_p (parser))
start = cp_lexer_token_position (parser->lexer, true); start = cp_lexer_token_position (parser->lexer, true);
...@@ -2319,18 +2321,18 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, ...@@ -2319,18 +2321,18 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
/* If the lookup found a template-name, it means that the user forgot /* If the lookup found a template-name, it means that the user forgot
to specify an argument list. Emit a useful error message. */ to specify an argument list. Emit a useful error message. */
if (TREE_CODE (decl) == TEMPLATE_DECL) if (TREE_CODE (decl) == TEMPLATE_DECL)
error ("%Hinvalid use of template-name %qE without an argument list", error_at (location,
&location, decl); "invalid use of template-name %qE without an argument list",
decl);
else if (TREE_CODE (id) == BIT_NOT_EXPR) else if (TREE_CODE (id) == BIT_NOT_EXPR)
error ("%Hinvalid use of destructor %qD as a type", &location, id); error_at (location, "invalid use of destructor %qD as a type", id);
else if (TREE_CODE (decl) == TYPE_DECL) else if (TREE_CODE (decl) == TYPE_DECL)
/* Something like 'unsigned A a;' */ /* Something like 'unsigned A a;' */
error ("%Hinvalid combination of multiple type-specifiers", error_at (location, "invalid combination of multiple type-specifiers");
&location);
else if (!parser->scope) else if (!parser->scope)
{ {
/* Issue an error message. */ /* Issue an error message. */
error ("%H%qE does not name a type", &location, id); error_at (location, "%qE does not name a type", id);
/* If we're in a template class, it's possible that the user was /* If we're in a template class, it's possible that the user was
referring to a type from a base class. For example: referring to a type from a base class. For example:
...@@ -2378,11 +2380,11 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, ...@@ -2378,11 +2380,11 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
else if (parser->scope != error_mark_node) else if (parser->scope != error_mark_node)
{ {
if (TREE_CODE (parser->scope) == NAMESPACE_DECL) if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
error ("%H%qE in namespace %qE does not name a type", error_at (location, "%qE in namespace %qE does not name a type",
&location, id, parser->scope); id, parser->scope);
else if (TYPE_P (parser->scope)) else if (TYPE_P (parser->scope))
error ("%H%qE in class %qT does not name a type", error_at (location, "%qE in class %qT does not name a type",
&location, id, parser->scope); id, parser->scope);
else else
gcc_unreachable (); gcc_unreachable ();
} }
...@@ -2945,8 +2947,9 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok) ...@@ -2945,8 +2947,9 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok)
if (type == CPP_STRING) if (type == CPP_STRING)
type = tok->type; type = tok->type;
else if (tok->type != CPP_STRING) else if (tok->type != CPP_STRING)
error ("%Hunsupported non-standard concatenation " error_at (tok->location,
"of string literals", &tok->location); "unsupported non-standard concatenation "
"of string literals");
} }
obstack_grow (&str_ob, &str, sizeof (cpp_string)); obstack_grow (&str_ob, &str, sizeof (cpp_string));
...@@ -3148,8 +3151,8 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3148,8 +3151,8 @@ cp_parser_primary_expression (cp_parser *parser,
token = cp_lexer_consume_token (parser->lexer); token = cp_lexer_consume_token (parser->lexer);
if (TREE_CODE (token->u.value) == FIXED_CST) if (TREE_CODE (token->u.value) == FIXED_CST)
{ {
error ("%Hfixed-point types not supported in C++", error_at (token->location,
&token->location); "fixed-point types not supported in C++");
return error_mark_node; return error_mark_node;
} }
/* Floating-point literals are only allowed in an integral /* Floating-point literals are only allowed in an integral
...@@ -3240,9 +3243,9 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3240,9 +3243,9 @@ cp_parser_primary_expression (cp_parser *parser,
if (!parser->in_function_body if (!parser->in_function_body
|| parser->in_template_argument_list_p) || parser->in_template_argument_list_p)
{ {
error ("%Hstatement-expressions are not allowed outside " error_at (token->location,
"functions nor in template-argument lists", "statement-expressions are not allowed outside "
&token->location); "functions nor in template-argument lists");
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
expr = error_mark_node; expr = error_mark_node;
} }
...@@ -3299,8 +3302,8 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3299,8 +3302,8 @@ cp_parser_primary_expression (cp_parser *parser,
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
if (parser->local_variables_forbidden_p) if (parser->local_variables_forbidden_p)
{ {
error ("%H%<this%> may not be used in this context", error_at (token->location,
&token->location); "%<this%> may not be used in this context");
return error_mark_node; return error_mark_node;
} }
/* Pointers cannot appear in constant-expressions. */ /* Pointers cannot appear in constant-expressions. */
...@@ -3508,8 +3511,9 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3508,8 +3511,9 @@ cp_parser_primary_expression (cp_parser *parser,
decl = check_for_out_of_scope_variable (decl); decl = check_for_out_of_scope_variable (decl);
if (local_variable_p (decl)) if (local_variable_p (decl))
{ {
error ("%Hlocal variable %qD may not appear in this context", error_at (id_expr_token->location,
&id_expr_token->location, decl); "local variable %qD may not appear in this context",
decl);
return error_mark_node; return error_mark_node;
} }
} }
...@@ -3808,8 +3812,9 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -3808,8 +3812,9 @@ cp_parser_unqualified_id (cp_parser* parser,
if (scope && TREE_CODE (scope) == NAMESPACE_DECL) if (scope && TREE_CODE (scope) == NAMESPACE_DECL)
{ {
if (!cp_parser_uncommitted_to_tentative_parse_p (parser)) if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("%Hscope %qT before %<~%> is not a class-name", error_at (token->location,
&token->location, scope); "scope %qT before %<~%> is not a class-name",
scope);
cp_parser_simulate_error (parser); cp_parser_simulate_error (parser);
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
...@@ -3922,8 +3927,9 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -3922,8 +3927,9 @@ cp_parser_unqualified_id (cp_parser* parser,
if (declarator_p && scope && !check_dtor_name (scope, type_decl)) if (declarator_p && scope && !check_dtor_name (scope, type_decl))
{ {
if (!cp_parser_uncommitted_to_tentative_parse_p (parser)) if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("%Hdeclaration of %<~%T%> as member of %qT", error_at (token->location,
&token->location, type_decl, scope); "declaration of %<~%T%> as member of %qT",
type_decl, scope);
cp_parser_simulate_error (parser); cp_parser_simulate_error (parser);
return error_mark_node; return error_mark_node;
} }
...@@ -3936,8 +3942,9 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -3936,8 +3942,9 @@ cp_parser_unqualified_id (cp_parser* parser,
&& !DECL_IMPLICIT_TYPEDEF_P (type_decl) && !DECL_IMPLICIT_TYPEDEF_P (type_decl)
&& !DECL_SELF_REFERENCE_P (type_decl) && !DECL_SELF_REFERENCE_P (type_decl)
&& !cp_parser_uncommitted_to_tentative_parse_p (parser)) && !cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("%Htypedef-name %qD used as destructor declarator", error_at (token->location,
&token->location, type_decl); "typedef-name %qD used as destructor declarator",
type_decl);
return build_nt (BIT_NOT_EXPR, TREE_TYPE (type_decl)); return build_nt (BIT_NOT_EXPR, TREE_TYPE (type_decl));
} }
...@@ -4150,12 +4157,14 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, ...@@ -4150,12 +4157,14 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
&ambiguous_decls, &ambiguous_decls,
token->location); token->location);
if (TREE_CODE (decl) == TEMPLATE_DECL) if (TREE_CODE (decl) == TEMPLATE_DECL)
error ("%H%qD used without template parameters", error_at (token->location,
&token->location, decl); "%qD used without template parameters",
decl);
else if (ambiguous_decls) else if (ambiguous_decls)
{ {
error ("%Hreference to %qD is ambiguous", error_at (token->location,
&token->location, token->u.value); "reference to %qD is ambiguous",
token->u.value);
print_candidates (ambiguous_decls); print_candidates (ambiguous_decls);
decl = error_mark_node; decl = error_mark_node;
} }
...@@ -5002,7 +5011,8 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, ...@@ -5002,7 +5011,8 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
/* The type of the POSTFIX_EXPRESSION must be complete. */ /* The type of the POSTFIX_EXPRESSION must be complete. */
if (scope == unknown_type_node) if (scope == unknown_type_node)
{ {
error ("%H%qE does not have class type", &location, postfix_expression); error_at (location, "%qE does not have class type",
postfix_expression);
scope = NULL_TREE; scope = NULL_TREE;
} }
else else
...@@ -5086,7 +5096,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, ...@@ -5086,7 +5096,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
TYPE_DECL here. That is invalid code. */ TYPE_DECL here. That is invalid code. */
if (TREE_CODE (name) == TYPE_DECL) if (TREE_CODE (name) == TYPE_DECL)
{ {
error ("%Hinvalid use of %qD", &token->location, name); error_at (token->location, "invalid use of %qD", name);
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
} }
else else
...@@ -5668,8 +5678,8 @@ cp_parser_new_expression (cp_parser* parser) ...@@ -5668,8 +5678,8 @@ cp_parser_new_expression (cp_parser* parser)
message for this case. */ message for this case. */
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
{ {
error ("%Harray bound forbidden after parenthesized type-id", error_at (token->location,
&token->location); "array bound forbidden after parenthesized type-id");
inform (token->location, inform (token->location,
"try removing the parentheses around the type-id"); "try removing the parentheses around the type-id");
cp_parser_direct_new_declarator (parser); cp_parser_direct_new_declarator (parser);
...@@ -5873,8 +5883,9 @@ cp_parser_direct_new_declarator (cp_parser* parser) ...@@ -5873,8 +5883,9 @@ cp_parser_direct_new_declarator (cp_parser* parser)
/*complain=*/true); /*complain=*/true);
if (!expression) if (!expression)
{ {
error ("%Hexpression in new-declarator must have integral " error_at (token->location,
"or enumeration type", &token->location); "expression in new-declarator must have integral "
"or enumeration type");
expression = error_mark_node; expression = error_mark_node;
} }
} }
...@@ -6257,11 +6268,11 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, ...@@ -6257,11 +6268,11 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
&& token->type == CPP_RSHIFT && token->type == CPP_RSHIFT
&& !parser->greater_than_is_operator_p) && !parser->greater_than_is_operator_p)
{ {
warning (OPT_Wc__0x_compat, if (warning_at (token->location, OPT_Wc__0x_compat,
"%H%<>>%> operator will be treated as two right angle brackets in C++0x", "%<>>%> operator will be treated as"
&token->location); " two right angle brackets in C++0x"))
warning (OPT_Wc__0x_compat, inform (token->location,
"suggest parentheses around %<>>%> expression"); "suggest parentheses around %<>>%> expression");
} }
new_prec = TOKEN_PRECEDENCE (token); new_prec = TOKEN_PRECEDENCE (token);
...@@ -7122,8 +7133,9 @@ cp_parser_label_for_labeled_statement (cp_parser* parser) ...@@ -7122,8 +7133,9 @@ cp_parser_label_for_labeled_statement (cp_parser* parser)
if (parser->in_switch_statement_p) if (parser->in_switch_statement_p)
finish_case_label (token->location, expr, expr_hi); finish_case_label (token->location, expr, expr_hi);
else else
error ("%Hcase label %qE not within a switch statement", error_at (token->location,
&token->location, expr); "case label %qE not within a switch statement",
expr);
} }
break; break;
...@@ -7134,7 +7146,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser) ...@@ -7134,7 +7146,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser)
if (parser->in_switch_statement_p) if (parser->in_switch_statement_p)
finish_case_label (token->location, NULL_TREE, NULL_TREE); finish_case_label (token->location, NULL_TREE, NULL_TREE);
else else
error ("%Hcase label not within a switch statement", &token->location); error_at (token->location, "case label not within a switch statement");
break; break;
default: default:
...@@ -7274,7 +7286,7 @@ cp_parser_statement_seq_opt (cp_parser* parser, tree in_statement_expr) ...@@ -7274,7 +7286,7 @@ cp_parser_statement_seq_opt (cp_parser* parser, tree in_statement_expr)
else else
{ {
token = cp_lexer_consume_token (parser->lexer); token = cp_lexer_consume_token (parser->lexer);
error ("%H%<else%> without a previous %<if%>", &token->location); error_at (token->location, "%<else%> without a previous %<if%>");
} }
} }
...@@ -7404,10 +7416,9 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) ...@@ -7404,10 +7416,9 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
statement which does have an else clause. We warn statement which does have an else clause. We warn
about the potential ambiguity. */ about the potential ambiguity. */
if (nested_if) if (nested_if)
warning (OPT_Wparentheses, warning_at (EXPR_LOCATION (statement), OPT_Wparentheses,
("%Hsuggest explicit braces " "suggest explicit braces to avoid ambiguous"
"to avoid ambiguous %<else%>"), " %<else%>");
EXPR_LOCUS (statement));
} }
/* Now we're all done with the if-statement. */ /* Now we're all done with the if-statement. */
...@@ -7755,7 +7766,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -7755,7 +7766,7 @@ cp_parser_jump_statement (cp_parser* parser)
switch (in_statement) switch (in_statement)
{ {
case 0: case 0:
error ("%Hbreak statement not within loop or switch", &token->location); error_at (token->location, "break statement not within loop or switch");
break; break;
default: default:
gcc_assert ((in_statement & IN_SWITCH_STMT) gcc_assert ((in_statement & IN_SWITCH_STMT)
...@@ -7763,10 +7774,10 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -7763,10 +7774,10 @@ cp_parser_jump_statement (cp_parser* parser)
statement = finish_break_stmt (); statement = finish_break_stmt ();
break; break;
case IN_OMP_BLOCK: case IN_OMP_BLOCK:
error ("%Hinvalid exit from OpenMP structured block", &token->location); error_at (token->location, "invalid exit from OpenMP structured block");
break; break;
case IN_OMP_FOR: case IN_OMP_FOR:
error ("%Hbreak statement used with OpenMP for loop", &token->location); error_at (token->location, "break statement used with OpenMP for loop");
break; break;
} }
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
...@@ -7776,14 +7787,14 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -7776,14 +7787,14 @@ cp_parser_jump_statement (cp_parser* parser)
switch (parser->in_statement & ~(IN_SWITCH_STMT | IN_IF_STMT)) switch (parser->in_statement & ~(IN_SWITCH_STMT | IN_IF_STMT))
{ {
case 0: case 0:
error ("%Hcontinue statement not within a loop", &token->location); error_at (token->location, "continue statement not within a loop");
break; break;
case IN_ITERATION_STMT: case IN_ITERATION_STMT:
case IN_OMP_FOR: case IN_OMP_FOR:
statement = finish_continue_stmt (); statement = finish_continue_stmt ();
break; break;
case IN_OMP_BLOCK: case IN_OMP_BLOCK:
error ("%Hinvalid exit from OpenMP structured block", &token->location); error_at (token->location, "invalid exit from OpenMP structured block");
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -8185,7 +8196,7 @@ cp_parser_block_declaration (cp_parser *parser, ...@@ -8185,7 +8196,7 @@ cp_parser_block_declaration (cp_parser *parser,
else if (token1->keyword == RID_LABEL) else if (token1->keyword == RID_LABEL)
{ {
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
error ("%H%<__label__%> not at the beginning of a block", &token1->location); error_at (token1->location, "%<__label__%> not at the beginning of a block");
cp_parser_skip_to_end_of_statement (parser); cp_parser_skip_to_end_of_statement (parser);
/* If the next token is now a `;', consume it. */ /* If the next token is now a `;', consume it. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
...@@ -8322,8 +8333,9 @@ cp_parser_simple_declaration (cp_parser* parser, ...@@ -8322,8 +8333,9 @@ cp_parser_simple_declaration (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
error ("%Hmixing declarations and function-definitions is forbidden", error_at (token->location,
&token->location); "mixing"
" declarations and function-definitions is forbidden");
} }
/* Otherwise, we're done with the list of declarators. */ /* Otherwise, we're done with the list of declarators. */
else else
...@@ -8462,7 +8474,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, ...@@ -8462,7 +8474,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
case RID_FRIEND: case RID_FRIEND:
if (!at_class_scope_p ()) if (!at_class_scope_p ())
{ {
error ("%H%<friend%> used outside of class", &token->location); error_at (token->location, "%<friend%> used outside of class");
cp_lexer_purge_token (parser->lexer); cp_lexer_purge_token (parser->lexer);
} }
else else
...@@ -8516,10 +8528,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser, ...@@ -8516,10 +8528,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
/* Complain about `auto' as a storage specifier, if /* Complain about `auto' as a storage specifier, if
we're complaining about C++0x compatibility. */ we're complaining about C++0x compatibility. */
warning warning_at (token->location, OPT_Wc__0x_compat, "%<auto%>"
(OPT_Wc__0x_compat, " will change meaning in C++0x; please remove it");
"%H%<auto%> will change meaning in C++0x; please remove it",
&token->location);
/* Set the storage class anyway. */ /* Set the storage class anyway. */
cp_parser_set_storage_class (parser, decl_specs, RID_AUTO, cp_parser_set_storage_class (parser, decl_specs, RID_AUTO,
...@@ -8637,8 +8647,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser, ...@@ -8637,8 +8647,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
/* Don't allow a friend specifier with a class definition. */ /* Don't allow a friend specifier with a class definition. */
if (decl_specs->specs[(int) ds_friend] != 0 if (decl_specs->specs[(int) ds_friend] != 0
&& (*declares_class_or_enum & 2)) && (*declares_class_or_enum & 2))
error ("%Hclass definition may not be declared a friend", error_at (start_token->location,
&start_token->location); "class definition may not be declared a friend");
} }
/* Parse an (optional) storage-class-specifier. /* Parse an (optional) storage-class-specifier.
...@@ -8707,7 +8717,7 @@ cp_parser_function_specifier_opt (cp_parser* parser, ...@@ -8707,7 +8717,7 @@ cp_parser_function_specifier_opt (cp_parser* parser,
A member function template shall not be virtual. */ A member function template shall not be virtual. */
if (PROCESSING_REAL_TEMPLATE_DECL_P ()) if (PROCESSING_REAL_TEMPLATE_DECL_P ())
error ("%Htemplates may not be %<virtual%>", &token->location); error_at (token->location, "templates may not be %<virtual%>");
else if (decl_specs) else if (decl_specs)
++decl_specs->specs[(int) ds_virtual]; ++decl_specs->specs[(int) ds_virtual];
break; break;
...@@ -9198,8 +9208,8 @@ cp_parser_mem_initializer_list (cp_parser* parser) ...@@ -9198,8 +9208,8 @@ cp_parser_mem_initializer_list (cp_parser* parser)
/* Let the semantic analysis code know that we are starting the /* Let the semantic analysis code know that we are starting the
mem-initializer-list. */ mem-initializer-list. */
if (!DECL_CONSTRUCTOR_P (current_function_decl)) if (!DECL_CONSTRUCTOR_P (current_function_decl))
error ("%Honly constructors take base initializers", error_at (token->location,
&token->location); "only constructors take base initializers");
/* Loop through the list. */ /* Loop through the list. */
while (true) while (true)
...@@ -9220,8 +9230,9 @@ cp_parser_mem_initializer_list (cp_parser* parser) ...@@ -9220,8 +9230,9 @@ cp_parser_mem_initializer_list (cp_parser* parser)
if (mem_initializer != error_mark_node if (mem_initializer != error_mark_node
&& !TYPE_P (TREE_PURPOSE (mem_initializer))) && !TYPE_P (TREE_PURPOSE (mem_initializer)))
{ {
error ("%Hcannot expand initializer for member %<%D%>", error_at (token->location,
&token->location, TREE_PURPOSE (mem_initializer)); "cannot expand initializer for member %<%D%>",
TREE_PURPOSE (mem_initializer));
mem_initializer = error_mark_node; mem_initializer = error_mark_node;
} }
...@@ -9342,9 +9353,9 @@ cp_parser_mem_initializer_id (cp_parser* parser) ...@@ -9342,9 +9353,9 @@ cp_parser_mem_initializer_id (cp_parser* parser)
/* `typename' is not allowed in this context ([temp.res]). */ /* `typename' is not allowed in this context ([temp.res]). */
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME)) if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME))
{ {
error ("%Hkeyword %<typename%> not allowed in this context (a qualified " error_at (token->location,
"member initializer is implicitly a type)", "keyword %<typename%> not allowed in this context (a qualified "
&token->location); "member initializer is implicitly a type)");
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
/* Look for the optional `::' operator. */ /* Look for the optional `::' operator. */
...@@ -9873,11 +9884,12 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type, ...@@ -9873,11 +9884,12 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type,
id_declarator = id_declarator->declarator; id_declarator = id_declarator->declarator;
if (id_declarator && id_declarator->kind == cdk_id) if (id_declarator && id_declarator->kind == cdk_id)
error ("%Htemplate parameter pack %qD cannot have a default argument", error_at (start_token->location,
&start_token->location, id_declarator->u.id.unqualified_name); "template parameter pack %qD cannot have a default argument",
id_declarator->u.id.unqualified_name);
else else
error ("%Htemplate parameter pack cannot have a default argument", error_at (start_token->location,
&start_token->location); "template parameter pack cannot have a default argument");
/* Parse the default argument, but throw away the result. */ /* Parse the default argument, but throw away the result. */
cp_parser_default_argument (parser, /*template_parm_p=*/true); cp_parser_default_argument (parser, /*template_parm_p=*/true);
...@@ -9971,11 +9983,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack) ...@@ -9971,11 +9983,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack)
if (*is_parameter_pack) if (*is_parameter_pack)
{ {
if (identifier) if (identifier)
error ("%Htemplate parameter pack %qD cannot have a " error_at (token->location,
"default argument", &token->location, identifier); "template parameter pack %qD cannot have a "
"default argument", identifier);
else else
error ("%Htemplate parameter packs cannot have " error_at (token->location,
"default arguments", &token->location); "template parameter packs cannot have "
"default arguments");
default_argument = NULL_TREE; default_argument = NULL_TREE;
} }
pop_deferring_access_checks (); pop_deferring_access_checks ();
...@@ -10077,13 +10091,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack) ...@@ -10077,13 +10091,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack)
if (*is_parameter_pack) if (*is_parameter_pack)
{ {
if (identifier) if (identifier)
error ("%Htemplate parameter pack %qD cannot " error_at (token->location,
"have a default argument", "template parameter pack %qD cannot "
&token->location, identifier); "have a default argument",
identifier);
else else
error ("%Htemplate parameter packs cannot " error_at (token->location, "template parameter packs cannot "
"have default arguments", "have default arguments");
&token->location);
default_argument = NULL_TREE; default_argument = NULL_TREE;
} }
pop_deferring_access_checks (); pop_deferring_access_checks ();
...@@ -10305,8 +10319,7 @@ cp_parser_template_id (cp_parser *parser, ...@@ -10305,8 +10319,7 @@ cp_parser_template_id (cp_parser *parser,
user, as opposed to simply marking the tentative parse as user, as opposed to simply marking the tentative parse as
failed? */ failed? */
if (cp_parser_error_occurred (parser) && template_id != error_mark_node) if (cp_parser_error_occurred (parser) && template_id != error_mark_node)
error ("%Hparse error in template argument list", error_at (token->location, "parse error in template argument list");
&token->location);
} }
pop_deferring_access_checks (); pop_deferring_access_checks ();
...@@ -10420,9 +10433,9 @@ cp_parser_template_name (cp_parser* parser, ...@@ -10420,9 +10433,9 @@ cp_parser_template_name (cp_parser* parser,
cp_token_position start = 0; cp_token_position start = 0;
/* Explain what went wrong. */ /* Explain what went wrong. */
error ("%Hnon-template %qD used as template", error_at (token->location, "non-template %qD used as template",
&token->location, identifier); identifier);
inform (input_location, "use %<%T::template %D%> to indicate that it is a template", inform (token->location, "use %<%T::template %D%> to indicate that it is a template",
parser->scope, identifier); parser->scope, identifier);
/* If parsing tentatively, find the location of the "<" token. */ /* If parsing tentatively, find the location of the "<" token. */
if (cp_parser_simulate_error (parser)) if (cp_parser_simulate_error (parser))
...@@ -10555,8 +10568,8 @@ cp_parser_template_argument_list (cp_parser* parser) ...@@ -10555,8 +10568,8 @@ cp_parser_template_argument_list (cp_parser* parser)
if (argument == error_mark_node) if (argument == error_mark_node)
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
error ("%Hexpected parameter pack before %<...%>", error_at (token->location,
&token->location); "expected parameter pack before %<...%>");
} }
/* Consume the `...' token. */ /* Consume the `...' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
...@@ -10965,7 +10978,7 @@ cp_parser_explicit_specialization (cp_parser* parser) ...@@ -10965,7 +10978,7 @@ cp_parser_explicit_specialization (cp_parser* parser)
linkage. */ linkage. */
if (current_lang_name == lang_name_c) if (current_lang_name == lang_name_c)
{ {
error ("%Htemplate specialization with C linkage", &token->location); error_at (token->location, "template specialization with C linkage");
/* Give it C++ linkage to avoid confusing other parts of the /* Give it C++ linkage to avoid confusing other parts of the
front end. */ front end. */
push_lang_context (lang_name_cplusplus); push_lang_context (lang_name_cplusplus);
...@@ -12157,7 +12170,7 @@ cp_parser_namespace_name (cp_parser* parser) ...@@ -12157,7 +12170,7 @@ cp_parser_namespace_name (cp_parser* parser)
|| TREE_CODE (namespace_decl) != NAMESPACE_DECL) || TREE_CODE (namespace_decl) != NAMESPACE_DECL)
{ {
if (!cp_parser_uncommitted_to_tentative_parse_p (parser)) if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("%H%qD is not a namespace-name", &token->location, identifier); error_at (token->location, "%qD is not a namespace-name", identifier);
cp_parser_error (parser, "expected namespace-name"); cp_parser_error (parser, "expected namespace-name");
namespace_decl = error_mark_node; namespace_decl = error_mark_node;
} }
...@@ -12284,7 +12297,7 @@ cp_parser_namespace_alias_definition (cp_parser* parser) ...@@ -12284,7 +12297,7 @@ cp_parser_namespace_alias_definition (cp_parser* parser)
if (!cp_parser_uncommitted_to_tentative_parse_p (parser) if (!cp_parser_uncommitted_to_tentative_parse_p (parser)
&& cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
error ("%H%<namespace%> definition is not allowed here", &token->location); error_at (token->location, "%<namespace%> definition is not allowed here");
/* Skip the definition. */ /* Skip the definition. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
if (cp_parser_skip_to_closing_brace (parser)) if (cp_parser_skip_to_closing_brace (parser))
...@@ -12424,8 +12437,8 @@ cp_parser_using_declaration (cp_parser* parser, ...@@ -12424,8 +12437,8 @@ cp_parser_using_declaration (cp_parser* parser,
/* [namespace.udecl] /* [namespace.udecl]
A using declaration shall not name a template-id. */ A using declaration shall not name a template-id. */
error ("%Ha template-id may not appear in a using-declaration", error_at (token->location,
&token->location); "a template-id may not appear in a using-declaration");
else else
{ {
if (at_class_scope_p ()) if (at_class_scope_p ())
...@@ -12801,12 +12814,12 @@ cp_parser_init_declarator (cp_parser* parser, ...@@ -12801,12 +12814,12 @@ cp_parser_init_declarator (cp_parser* parser,
/* Neither attributes nor an asm-specification are allowed /* Neither attributes nor an asm-specification are allowed
on a function-definition. */ on a function-definition. */
if (asm_specification) if (asm_specification)
error ("%Han asm-specification is not allowed " error_at (asm_spec_start_token->location,
"on a function-definition", "an asm-specification is not allowed "
&asm_spec_start_token->location); "on a function-definition");
if (attributes) if (attributes)
error ("%Hattributes are not allowed on a function-definition", error_at (attributes_start_token->location,
&attributes_start_token->location); "attributes are not allowed on a function-definition");
/* This is a function-definition. */ /* This is a function-definition. */
*function_definition_p = true; *function_definition_p = true;
...@@ -12958,8 +12971,8 @@ cp_parser_init_declarator (cp_parser* parser, ...@@ -12958,8 +12971,8 @@ cp_parser_init_declarator (cp_parser* parser,
know what the user intended, so just silently know what the user intended, so just silently
consume the initializer. */ consume the initializer. */
if (decl != error_mark_node) if (decl != error_mark_node)
error ("%Hinitializer provided for function", error_at (initializer_start_token->location,
&initializer_start_token->location); "initializer provided for function");
cp_parser_skip_to_closing_parenthesis (parser, cp_parser_skip_to_closing_parenthesis (parser,
/*recovering=*/true, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
...@@ -13378,8 +13391,8 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -13378,8 +13391,8 @@ cp_parser_direct_declarator (cp_parser* parser,
in function scopes. */ in function scopes. */
else if (!parser->in_function_body) else if (!parser->in_function_body)
{ {
error ("%Harray bound is not an integer constant", error_at (token->location,
&token->location); "array bound is not an integer constant");
bounds = error_mark_node; bounds = error_mark_node;
} }
else if (processing_template_decl && !error_operand_p (bounds)) else if (processing_template_decl && !error_operand_p (bounds))
...@@ -13497,10 +13510,10 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -13497,10 +13510,10 @@ cp_parser_direct_declarator (cp_parser* parser,
/*only_current_p=*/false); /*only_current_p=*/false);
/* If that failed, the declarator is invalid. */ /* If that failed, the declarator is invalid. */
if (TREE_CODE (type) == TYPENAME_TYPE) if (TREE_CODE (type) == TYPENAME_TYPE)
error ("%H%<%T::%E%> is not a type", error_at (declarator_id_start_token->location,
&declarator_id_start_token->location, "%<%T::%E%> is not a type",
TYPE_CONTEXT (qualifying_scope), TYPE_CONTEXT (qualifying_scope),
TYPE_IDENTIFIER (qualifying_scope)); TYPE_IDENTIFIER (qualifying_scope));
qualifying_scope = type; qualifying_scope = type;
} }
...@@ -13524,9 +13537,10 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -13524,9 +13537,10 @@ cp_parser_direct_declarator (cp_parser* parser,
if (qualifying_scope if (qualifying_scope
&& CLASSTYPE_USE_TEMPLATE (name_type)) && CLASSTYPE_USE_TEMPLATE (name_type))
{ {
error ("%Hinvalid use of constructor as a template", error_at (declarator_id_start_token->location,
&declarator_id_start_token->location); "invalid use of constructor as a template");
inform (input_location, "use %<%T::%D%> instead of %<%T::%D%> to " inform (declarator_id_start_token->location,
"use %<%T::%D%> instead of %<%T::%D%> to "
"name the constructor in a qualified name", "name the constructor in a qualified name",
class_type, class_type,
DECL_NAME (TYPE_TI_TEMPLATE (class_type)), DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
...@@ -13700,7 +13714,7 @@ cp_parser_ptr_operator (cp_parser* parser, ...@@ -13700,7 +13714,7 @@ cp_parser_ptr_operator (cp_parser* parser,
code = INDIRECT_REF; code = INDIRECT_REF;
if (TREE_CODE (parser->scope) == NAMESPACE_DECL) if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
error ("%H%qD is a namespace", &token->location, parser->scope); error_at (token->location, "%qD is a namespace", parser->scope);
else else
{ {
/* The type of which the member is a member is given by the /* The type of which the member is a member is given by the
...@@ -13775,7 +13789,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) ...@@ -13775,7 +13789,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser)
if (cv_quals & cv_qualifier) if (cv_quals & cv_qualifier)
{ {
error ("%Hduplicate cv-qualifier", &token->location); error_at (token->location, "duplicate cv-qualifier");
cp_lexer_purge_token (parser->lexer); cp_lexer_purge_token (parser->lexer);
} }
else else
...@@ -14488,7 +14502,7 @@ cp_parser_parameter_declaration (cp_parser *parser, ...@@ -14488,7 +14502,7 @@ cp_parser_parameter_declaration (cp_parser *parser,
/* If we run out of tokens, issue an error message. */ /* If we run out of tokens, issue an error message. */
case CPP_EOF: case CPP_EOF:
case CPP_PRAGMA_EOL: case CPP_PRAGMA_EOL:
error ("%Hfile ends in default argument", &token->location); error_at (token->location, "file ends in default argument");
done = true; done = true;
break; break;
...@@ -14537,9 +14551,9 @@ cp_parser_parameter_declaration (cp_parser *parser, ...@@ -14537,9 +14551,9 @@ cp_parser_parameter_declaration (cp_parser *parser,
warning (0, "deprecated use of default argument for parameter of non-function"); warning (0, "deprecated use of default argument for parameter of non-function");
else else
{ {
error ("%Hdefault arguments are only " error_at (token->location,
"permitted for function parameters", "default arguments are only "
&token->location); "permitted for function parameters");
default_argument = NULL_TREE; default_argument = NULL_TREE;
} }
} }
...@@ -14547,20 +14561,23 @@ cp_parser_parameter_declaration (cp_parser *parser, ...@@ -14547,20 +14561,23 @@ cp_parser_parameter_declaration (cp_parser *parser,
|| (decl_specifiers.type || (decl_specifiers.type
&& PACK_EXPANSION_P (decl_specifiers.type))) && PACK_EXPANSION_P (decl_specifiers.type)))
{ {
const char* kind = template_parm_p? "template " : "";
/* Find the name of the parameter pack. */ /* Find the name of the parameter pack. */
cp_declarator *id_declarator = declarator; cp_declarator *id_declarator = declarator;
while (id_declarator && id_declarator->kind != cdk_id) while (id_declarator && id_declarator->kind != cdk_id)
id_declarator = id_declarator->declarator; id_declarator = id_declarator->declarator;
if (id_declarator && id_declarator->kind == cdk_id) if (id_declarator && id_declarator->kind == cdk_id)
error ("%H%sparameter pack %qD cannot have a default argument", error_at (declarator_token_start->location,
&declarator_token_start->location, template_parm_p
kind, id_declarator->u.id.unqualified_name); ? "template parameter pack %qD"
" cannot have a default argument"
: "parameter pack %qD cannot have a default argument",
id_declarator->u.id.unqualified_name);
else else
error ("%H%sparameter pack cannot have a default argument", error_at (declarator_token_start->location,
&declarator_token_start->location, kind); template_parm_p
? "template parameter pack cannot have a default argument"
: "parameter pack cannot have a default argument");
default_argument = NULL_TREE; default_argument = NULL_TREE;
} }
...@@ -14982,8 +14999,8 @@ cp_parser_class_name (cp_parser *parser, ...@@ -14982,8 +14999,8 @@ cp_parser_class_name (cp_parser *parser,
identifier_token->location); identifier_token->location);
if (ambiguous_decls) if (ambiguous_decls)
{ {
error ("%Hreference to %qD is ambiguous", error_at (identifier_token->location,
&identifier_token->location, identifier); "reference to %qD is ambiguous", identifier);
print_candidates (ambiguous_decls); print_candidates (ambiguous_decls);
if (cp_parser_parsing_tentatively (parser)) if (cp_parser_parsing_tentatively (parser))
{ {
...@@ -15448,8 +15465,9 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15448,8 +15465,9 @@ cp_parser_class_head (cp_parser* parser,
/* Reject typedef-names in class heads. */ /* Reject typedef-names in class heads. */
if (!DECL_IMPLICIT_TYPEDEF_P (type)) if (!DECL_IMPLICIT_TYPEDEF_P (type))
{ {
error ("%Hinvalid class name in declaration of %qD", error_at (type_start_token->location,
&type_start_token->location, type); "invalid class name in declaration of %qD",
type);
type = NULL_TREE; type = NULL_TREE;
goto done; goto done;
} }
...@@ -15461,14 +15479,14 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15461,14 +15479,14 @@ cp_parser_class_head (cp_parser* parser,
if (scope && !is_ancestor (scope, nested_name_specifier)) if (scope && !is_ancestor (scope, nested_name_specifier))
{ {
if (at_namespace_scope_p ()) if (at_namespace_scope_p ())
error ("%Hdeclaration of %qD in namespace %qD which does not " error_at (type_start_token->location,
"enclose %qD", "declaration of %qD in namespace %qD which does not "
&type_start_token->location, "enclose %qD",
type, scope, nested_name_specifier); type, scope, nested_name_specifier);
else else
error ("%Hdeclaration of %qD in %qD which does not enclose %qD", error_at (type_start_token->location,
&type_start_token->location, "declaration of %qD in %qD which does not enclose %qD",
type, scope, nested_name_specifier); type, scope, nested_name_specifier);
type = NULL_TREE; type = NULL_TREE;
goto done; goto done;
} }
...@@ -15480,8 +15498,8 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15480,8 +15498,8 @@ cp_parser_class_head (cp_parser* parser,
class member of a namespace outside of its namespace. */ class member of a namespace outside of its namespace. */
if (scope == nested_name_specifier) if (scope == nested_name_specifier)
{ {
permerror (input_location, "%Hextra qualification not allowed", permerror (nested_name_specifier_token_start->location,
&nested_name_specifier_token_start->location); "extra qualification not allowed");
nested_name_specifier = NULL_TREE; nested_name_specifier = NULL_TREE;
num_templates = 0; num_templates = 0;
} }
...@@ -15492,8 +15510,8 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15492,8 +15510,8 @@ cp_parser_class_head (cp_parser* parser,
&& parser->num_template_parameter_lists == 0 && parser->num_template_parameter_lists == 0
&& template_id_p) && template_id_p)
{ {
error ("%Han explicit specialization must be preceded by %<template <>%>", error_at (type_start_token->location,
&type_start_token->location); "an explicit specialization must be preceded by %<template <>%>");
invalid_explicit_specialization_p = true; invalid_explicit_specialization_p = true;
/* Take the same action that would have been taken by /* Take the same action that would have been taken by
cp_parser_explicit_specialization. */ cp_parser_explicit_specialization. */
...@@ -15522,8 +15540,8 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15522,8 +15540,8 @@ cp_parser_class_head (cp_parser* parser,
&& (DECL_FUNCTION_TEMPLATE_P (TREE_OPERAND (id, 0)) && (DECL_FUNCTION_TEMPLATE_P (TREE_OPERAND (id, 0))
|| TREE_CODE (TREE_OPERAND (id, 0)) == OVERLOAD)) || TREE_CODE (TREE_OPERAND (id, 0)) == OVERLOAD))
{ {
error ("%Hfunction template %qD redeclared as a class template", error_at (type_start_token->location,
&type_start_token->location, id); "function template %qD redeclared as a class template", id);
type = error_mark_node; type = error_mark_node;
} }
else else
...@@ -15604,10 +15622,10 @@ cp_parser_class_head (cp_parser* parser, ...@@ -15604,10 +15622,10 @@ cp_parser_class_head (cp_parser* parser,
that's an error. */ that's an error. */
if (type != error_mark_node && COMPLETE_TYPE_P (type)) if (type != error_mark_node && COMPLETE_TYPE_P (type))
{ {
error ("%Hredefinition of %q#T", error_at (type_start_token->location, "redefinition of %q#T",
&type_start_token->location, type); type);
error ("%Hprevious definition of %q+#T", error_at (type_start_token->location, "previous definition of %q+#T",
&type_start_token->location, type); type);
type = NULL_TREE; type = NULL_TREE;
goto done; goto done;
} }
...@@ -15874,8 +15892,8 @@ cp_parser_member_declaration (cp_parser* parser) ...@@ -15874,8 +15892,8 @@ cp_parser_member_declaration (cp_parser* parser)
/* If the `friend' keyword was present, the friend must /* If the `friend' keyword was present, the friend must
be introduced with a class-key. */ be introduced with a class-key. */
if (!declares_class_or_enum) if (!declares_class_or_enum)
error ("%Ha class-key must be used when declaring a friend", error_at (decl_spec_token_start->location,
&decl_spec_token_start->location); "a class-key must be used when declaring a friend");
/* In this case: /* In this case:
template <typename T> struct A { template <typename T> struct A {
...@@ -15889,8 +15907,9 @@ cp_parser_member_declaration (cp_parser* parser) ...@@ -15889,8 +15907,9 @@ cp_parser_member_declaration (cp_parser* parser)
&& TYPE_P (decl_specifiers.type)) && TYPE_P (decl_specifiers.type))
type = decl_specifiers.type; type = decl_specifiers.type;
if (!type || !TYPE_P (type)) if (!type || !TYPE_P (type))
error ("%Hfriend declaration does not name a class or " error_at (decl_spec_token_start->location,
"function", &decl_spec_token_start->location); "friend declaration does not name a class or "
"function");
else else
make_friend_class (current_class_type, type, make_friend_class (current_class_type, type,
/*complain=*/true); /*complain=*/true);
...@@ -16070,8 +16089,8 @@ cp_parser_member_declaration (cp_parser* parser) ...@@ -16070,8 +16089,8 @@ cp_parser_member_declaration (cp_parser* parser)
standard, since a pure function may be defined standard, since a pure function may be defined
outside of the class-specifier. */ outside of the class-specifier. */
if (initializer) if (initializer)
error ("%Hpure-specifier on function-definition", error_at (initializer_token_start->location,
&initializer_token_start->location); "pure-specifier on function-definition");
decl = cp_parser_save_member_function_body (parser, decl = cp_parser_save_member_function_body (parser,
&decl_specifiers, &decl_specifiers,
declarator, declarator,
...@@ -16179,7 +16198,7 @@ cp_parser_pure_specifier (cp_parser* parser) ...@@ -16179,7 +16198,7 @@ cp_parser_pure_specifier (cp_parser* parser)
} }
if (PROCESSING_REAL_TEMPLATE_DECL_P ()) if (PROCESSING_REAL_TEMPLATE_DECL_P ())
{ {
error ("%Htemplates may not be %<virtual%>", &token->location); error_at (token->location, "templates may not be %<virtual%>");
return error_mark_node; return error_mark_node;
} }
...@@ -16383,12 +16402,12 @@ cp_parser_base_specifier (cp_parser* parser) ...@@ -16383,12 +16402,12 @@ cp_parser_base_specifier (cp_parser* parser)
{ {
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
if (!processing_template_decl) if (!processing_template_decl)
error ("%Hkeyword %<typename%> not allowed outside of templates", error_at (token->location,
&token->location); "keyword %<typename%> not allowed outside of templates");
else else
error ("%Hkeyword %<typename%> not allowed in this context " error_at (token->location,
"(the base class is implicitly a type)", "keyword %<typename%> not allowed in this context "
&token->location); "(the base class is implicitly a type)");
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
...@@ -17288,8 +17307,8 @@ cp_parser_lookup_name (cp_parser *parser, tree name, ...@@ -17288,8 +17307,8 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
cp_parser_error, so we incorporate its actions directly. */ cp_parser_error, so we incorporate its actions directly. */
if (!cp_parser_simulate_error (parser)) if (!cp_parser_simulate_error (parser))
{ {
error ("%Hreference to %qD is ambiguous", error_at (name_location, "reference to %qD is ambiguous",
&name_location, name); name);
print_candidates (decl); print_candidates (decl);
} }
return error_mark_node; return error_mark_node;
...@@ -17489,7 +17508,7 @@ cp_parser_check_template_parameters (cp_parser* parser, ...@@ -17489,7 +17508,7 @@ cp_parser_check_template_parameters (cp_parser* parser,
something like: something like:
template <class T> template <class U> void S::f(); */ template <class T> template <class U> void S::f(); */
error ("%Htoo many template-parameter-lists", &location); error_at (location, "too many template-parameter-lists");
return false; return false;
} }
...@@ -17763,8 +17782,8 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, ...@@ -17763,8 +17782,8 @@ cp_parser_function_definition_after_declarator (cp_parser* parser,
returned. */ returned. */
cp_parser_identifier (parser); cp_parser_identifier (parser);
/* Issue an error message. */ /* Issue an error message. */
error ("%Hnamed return values are no longer supported", error_at (token->location,
&token->location); "named return values are no longer supported");
/* Skip tokens until we reach the start of the function body. */ /* Skip tokens until we reach the start of the function body. */
while (true) while (true)
{ {
...@@ -17838,8 +17857,8 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) ...@@ -17838,8 +17857,8 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
/* 14.5.2.2 [temp.mem] /* 14.5.2.2 [temp.mem]
A local class shall not have member templates. */ A local class shall not have member templates. */
error ("%Hinvalid declaration of member template in local class", error_at (token->location,
&token->location); "invalid declaration of member template in local class");
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
return; return;
} }
...@@ -17848,7 +17867,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) ...@@ -17848,7 +17867,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
A template ... shall not have C linkage. */ A template ... shall not have C linkage. */
if (current_lang_name == lang_name_c) if (current_lang_name == lang_name_c)
{ {
error ("%Htemplate with C linkage", &token->location); error_at (token->location, "template with C linkage");
/* Give it C++ linkage to avoid confusing other parts of the /* Give it C++ linkage to avoid confusing other parts of the
front end. */ front end. */
push_lang_context (lang_name_cplusplus); push_lang_context (lang_name_cplusplus);
...@@ -17995,8 +18014,8 @@ cp_parser_single_declaration (cp_parser* parser, ...@@ -17995,8 +18014,8 @@ cp_parser_single_declaration (cp_parser* parser,
/* There are no template typedefs. */ /* There are no template typedefs. */
if (decl_specifiers.specs[(int) ds_typedef]) if (decl_specifiers.specs[(int) ds_typedef])
{ {
error ("%Htemplate declaration of %qs", error_at (decl_spec_token_start->location,
&decl_spec_token_start->location, "typedef"); "template declaration of %<typedef%>");
decl = error_mark_node; decl = error_mark_node;
} }
...@@ -18059,8 +18078,8 @@ cp_parser_single_declaration (cp_parser* parser, ...@@ -18059,8 +18078,8 @@ cp_parser_single_declaration (cp_parser* parser,
&& explicit_specialization_p && explicit_specialization_p
&& decl_specifiers.storage_class != sc_none) && decl_specifiers.storage_class != sc_none)
{ {
error ("%Hexplicit template specialization cannot have a storage class", error_at (decl_spec_token_start->location,
&decl_spec_token_start->location); "explicit template specialization cannot have a storage class");
decl = error_mark_node; decl = error_mark_node;
} }
} }
...@@ -18288,9 +18307,8 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) ...@@ -18288,9 +18307,8 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser)
global source location is still on the token before the global source location is still on the token before the
'>>', so we need to say explicitly where we want it. */ '>>', so we need to say explicitly where we want it. */
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
error ("%H%<>>%> should be %<> >%> " error_at (token->location, "%<>>%> should be %<> >%> "
"within a nested template argument list", "within a nested template argument list");
&token->location);
token->type = CPP_GREATER; token->type = CPP_GREATER;
} }
...@@ -18301,8 +18319,9 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) ...@@ -18301,8 +18319,9 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser)
Same deal about the token location, but here we can get it Same deal about the token location, but here we can get it
right by consuming the '>>' before issuing the diagnostic. */ right by consuming the '>>' before issuing the diagnostic. */
cp_token *token = cp_lexer_consume_token (parser->lexer); cp_token *token = cp_lexer_consume_token (parser->lexer);
error ("%Hspurious %<>>%>, use %<>%> to terminate " error_at (token->location,
"a template argument list", &token->location); "spurious %<>>%>, use %<>%> to terminate "
"a template argument list");
} }
} }
else else
...@@ -18638,8 +18657,8 @@ cp_parser_set_storage_class (cp_parser *parser, ...@@ -18638,8 +18657,8 @@ cp_parser_set_storage_class (cp_parser *parser,
if (parser->in_unbraced_linkage_specification_p) if (parser->in_unbraced_linkage_specification_p)
{ {
error ("%Hinvalid use of %qD in linkage specification", error_at (location, "invalid use of %qD in linkage specification",
&location, ridpointers[keyword]); ridpointers[keyword]);
return; return;
} }
else if (decl_specs->storage_class != sc_none) else if (decl_specs->storage_class != sc_none)
...@@ -18651,7 +18670,7 @@ cp_parser_set_storage_class (cp_parser *parser, ...@@ -18651,7 +18670,7 @@ cp_parser_set_storage_class (cp_parser *parser,
if ((keyword == RID_EXTERN || keyword == RID_STATIC) if ((keyword == RID_EXTERN || keyword == RID_STATIC)
&& decl_specs->specs[(int) ds_thread]) && decl_specs->specs[(int) ds_thread])
{ {
error ("%H%<__thread%> before %qD", &location, ridpointers[keyword]); error_at (location, "%<__thread%> before %qD", ridpointers[keyword]);
decl_specs->specs[(int) ds_thread] = 0; decl_specs->specs[(int) ds_thread] = 0;
} }
...@@ -18993,7 +19012,7 @@ cp_parser_check_access_in_redeclaration (tree decl, location_t location) ...@@ -18993,7 +19012,7 @@ cp_parser_check_access_in_redeclaration (tree decl, location_t location)
!= (current_access_specifier == access_private_node)) != (current_access_specifier == access_private_node))
|| (TREE_PROTECTED (decl) || (TREE_PROTECTED (decl)
!= (current_access_specifier == access_protected_node))) != (current_access_specifier == access_protected_node)))
error ("%H%qD redeclared with different access", &location, decl); error_at (location, "%qD redeclared with different access", decl);
} }
/* Look for the `template' keyword, as a syntactic disambiguator. /* Look for the `template' keyword, as a syntactic disambiguator.
...@@ -19011,8 +19030,9 @@ cp_parser_optional_template_keyword (cp_parser *parser) ...@@ -19011,8 +19030,9 @@ cp_parser_optional_template_keyword (cp_parser *parser)
if (!processing_template_decl) if (!processing_template_decl)
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
error ("%H%<template%> (as a disambiguator) is only allowed " error_at (token->location,
"within templates", &token->location); "%<template%> (as a disambiguator) is only allowed "
"within templates");
/* If this part of the token stream is rescanned, the same /* If this part of the token stream is rescanned, the same
error message would be generated. So, we purge the token error message would be generated. So, we purge the token
from the stream. */ from the stream. */
...@@ -19277,8 +19297,9 @@ cp_parser_objc_expression (cp_parser* parser) ...@@ -19277,8 +19297,9 @@ cp_parser_objc_expression (cp_parser* parser)
break; break;
} }
default: default:
error ("%Hmisplaced %<@%D%> Objective-C++ construct", error_at (kwd->location,
&kwd->location, kwd->u.value); "misplaced %<@%D%> Objective-C++ construct",
kwd->u.value);
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
} }
...@@ -19421,8 +19442,8 @@ cp_parser_objc_encode_expression (cp_parser* parser) ...@@ -19421,8 +19442,8 @@ cp_parser_objc_encode_expression (cp_parser* parser)
if (!type) if (!type)
{ {
error ("%H%<@encode%> must specify a type as an argument", error_at (token->location,
&token->location); "%<@encode%> must specify a type as an argument");
return error_mark_node; return error_mark_node;
} }
...@@ -19738,7 +19759,7 @@ cp_parser_objc_selector (cp_parser* parser) ...@@ -19738,7 +19759,7 @@ cp_parser_objc_selector (cp_parser* parser)
if (!cp_parser_objc_selector_p (token->type)) if (!cp_parser_objc_selector_p (token->type))
{ {
error ("%Hinvalid Objective-C++ selector name", &token->location); error_at (token->location, "invalid Objective-C++ selector name");
return error_mark_node; return error_mark_node;
} }
...@@ -20069,7 +20090,7 @@ cp_parser_objc_protocol_declaration (cp_parser* parser) ...@@ -20069,7 +20090,7 @@ cp_parser_objc_protocol_declaration (cp_parser* parser)
if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
{ {
tok = cp_lexer_peek_token (parser->lexer); tok = cp_lexer_peek_token (parser->lexer);
error ("%Hidentifier expected after %<@protocol%>", &tok->location); error_at (tok->location, "identifier expected after %<@protocol%>");
goto finish; goto finish;
} }
...@@ -20205,8 +20226,8 @@ cp_parser_objc_declaration (cp_parser* parser) ...@@ -20205,8 +20226,8 @@ cp_parser_objc_declaration (cp_parser* parser)
cp_parser_objc_end_implementation (parser); cp_parser_objc_end_implementation (parser);
break; break;
default: default:
error ("%Hmisplaced %<@%D%> Objective-C++ construct", error_at (kwd->location, "misplaced %<@%D%> Objective-C++ construct",
&kwd->location, kwd->u.value); kwd->u.value);
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
} }
} }
...@@ -20338,8 +20359,8 @@ cp_parser_objc_statement (cp_parser * parser) { ...@@ -20338,8 +20359,8 @@ cp_parser_objc_statement (cp_parser * parser) {
case RID_AT_THROW: case RID_AT_THROW:
return cp_parser_objc_throw_statement (parser); return cp_parser_objc_throw_statement (parser);
default: default:
error ("%Hmisplaced %<@%D%> Objective-C++ construct", error_at (kwd->location, "misplaced %<@%D%> Objective-C++ construct",
&kwd->location, kwd->u.value); kwd->u.value);
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
} }
...@@ -20431,7 +20452,7 @@ check_no_duplicate_clause (tree clauses, enum omp_clause_code code, ...@@ -20431,7 +20452,7 @@ check_no_duplicate_clause (tree clauses, enum omp_clause_code code,
for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c)) for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c))
if (OMP_CLAUSE_CODE (c) == code) if (OMP_CLAUSE_CODE (c) == code)
{ {
error ("%Htoo many %qs clauses", &location, name); error_at (location, "too many %qs clauses", name);
break; break;
} }
} }
...@@ -20545,8 +20566,7 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location ...@@ -20545,8 +20566,7 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location
|| (n = tree_low_cst (num, 0)) <= 0 || (n = tree_low_cst (num, 0)) <= 0
|| (int) n != n) || (int) n != n)
{ {
error ("%Hcollapse argument needs positive constant integer expression", error_at (loc, "collapse argument needs positive constant integer expression");
&loc);
return list; return list;
} }
...@@ -20834,11 +20854,11 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location ...@@ -20834,11 +20854,11 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location
if (t == error_mark_node) if (t == error_mark_node)
goto resync_fail; goto resync_fail;
else if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME) else if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME)
error ("%Hschedule %<runtime%> does not take " error_at (token->location, "schedule %<runtime%> does not take "
"a %<chunk_size%> parameter", &token->location); "a %<chunk_size%> parameter");
else if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_AUTO) else if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_AUTO)
error ("%Hschedule %<auto%> does not take " error_at (token->location, "schedule %<auto%> does not take "
"a %<chunk_size%> parameter", &token->location); "a %<chunk_size%> parameter");
else else
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t;
...@@ -20985,7 +21005,7 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask, ...@@ -20985,7 +21005,7 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask,
/* Remove the invalid clause(s) from the list to avoid /* Remove the invalid clause(s) from the list to avoid
confusing the rest of the compiler. */ confusing the rest of the compiler. */
clauses = prev; clauses = prev;
error ("%H%qs is not valid for %qs", &token->location, c_name, where); error_at (token->location, "%qs is not valid for %qs", c_name, where);
} }
} }
saw_error: saw_error:
...@@ -21533,8 +21553,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -21533,8 +21553,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
if (OMP_CLAUSE_CODE (*c) == OMP_CLAUSE_FIRSTPRIVATE if (OMP_CLAUSE_CODE (*c) == OMP_CLAUSE_FIRSTPRIVATE
&& OMP_CLAUSE_DECL (*c) == real_decl) && OMP_CLAUSE_DECL (*c) == real_decl)
{ {
error ("%Hiteration variable %qD should not be firstprivate", error_at (loc, "iteration variable %qD"
&loc, real_decl); " should not be firstprivate", real_decl);
*c = OMP_CLAUSE_CHAIN (*c); *c = OMP_CLAUSE_CHAIN (*c);
} }
else if (OMP_CLAUSE_CODE (*c) == OMP_CLAUSE_LASTPRIVATE else if (OMP_CLAUSE_CODE (*c) == OMP_CLAUSE_LASTPRIVATE
...@@ -21571,12 +21591,13 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -21571,12 +21591,13 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
break; break;
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
&& OMP_CLAUSE_DECL (c) == decl) && OMP_CLAUSE_DECL (c) == decl)
error ("%Hiteration variable %qD should not be firstprivate", error_at (loc, "iteration variable %qD "
&loc, decl); "should not be firstprivate",
decl);
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
&& OMP_CLAUSE_DECL (c) == decl) && OMP_CLAUSE_DECL (c) == decl)
error ("%Hiteration variable %qD should not be reduction", error_at (loc, "iteration variable %qD should not be reduction",
&loc, decl); decl);
} }
if (c == NULL) if (c == NULL)
{ {
...@@ -21642,7 +21663,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -21642,7 +21663,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
else else
{ {
loc = cp_lexer_peek_token (parser->lexer)->location; loc = cp_lexer_peek_token (parser->lexer)->location;
error ("%Hnot enough collapsed for loops", &loc); error_at (loc, "not enough collapsed for loops");
collapse_err = true; collapse_err = true;
cp_parser_abort_tentative_parse (parser); cp_parser_abort_tentative_parse (parser);
declv = NULL_TREE; declv = NULL_TREE;
...@@ -21687,8 +21708,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -21687,8 +21708,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
{ {
if (!collapse_err) if (!collapse_err)
{ {
location_t loc = cp_lexer_peek_token (parser->lexer)->location; error_at (cp_lexer_peek_token (parser->lexer)->location,
error ("%Hcollapsed loops not perfectly nested", &loc); "collapsed loops not perfectly nested");
} }
collapse_err = true; collapse_err = true;
cp_parser_statement_seq_opt (parser, NULL); cp_parser_statement_seq_opt (parser, NULL);
...@@ -22102,11 +22123,11 @@ cp_parser_initial_pragma (cp_token *first_token) ...@@ -22102,11 +22123,11 @@ cp_parser_initial_pragma (cp_token *first_token)
cp_lexer_get_preprocessor_token (NULL, first_token); cp_lexer_get_preprocessor_token (NULL, first_token);
if (first_token->type != CPP_PRAGMA_EOL) if (first_token->type != CPP_PRAGMA_EOL)
error ("%Hjunk at end of %<#pragma GCC pch_preprocess%>", error_at (first_token->location,
&first_token->location); "junk at end of %<#pragma GCC pch_preprocess%>");
} }
else else
error ("%Hexpected string literal", &first_token->location); error_at (first_token->location, "expected string literal");
/* Skip to the end of the pragma. */ /* Skip to the end of the pragma. */
while (first_token->type != CPP_PRAGMA_EOL && first_token->type != CPP_EOF) while (first_token->type != CPP_PRAGMA_EOL && first_token->type != CPP_EOF)
...@@ -22139,8 +22160,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) ...@@ -22139,8 +22160,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context)
switch (id) switch (id)
{ {
case PRAGMA_GCC_PCH_PREPROCESS: case PRAGMA_GCC_PCH_PREPROCESS:
error ("%H%<#pragma GCC pch_preprocess%> must be first", error_at (pragma_tok->location,
&pragma_tok->location); "%<#pragma GCC pch_preprocess%> must be first");
break; break;
case PRAGMA_OMP_BARRIER: case PRAGMA_OMP_BARRIER:
...@@ -22150,8 +22171,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) ...@@ -22150,8 +22171,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context)
cp_parser_omp_barrier (parser, pragma_tok); cp_parser_omp_barrier (parser, pragma_tok);
return false; return false;
case pragma_stmt: case pragma_stmt:
error ("%H%<#pragma omp barrier%> may only be " error_at (pragma_tok->location, "%<#pragma omp barrier%> may only be "
"used in compound statements", &pragma_tok->location); "used in compound statements");
break; break;
default: default:
goto bad_stmt; goto bad_stmt;
...@@ -22165,8 +22186,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) ...@@ -22165,8 +22186,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context)
cp_parser_omp_flush (parser, pragma_tok); cp_parser_omp_flush (parser, pragma_tok);
return false; return false;
case pragma_stmt: case pragma_stmt:
error ("%H%<#pragma omp flush%> may only be " error_at (pragma_tok->location, "%<#pragma omp flush%> may only be "
"used in compound statements", &pragma_tok->location); "used in compound statements");
break; break;
default: default:
goto bad_stmt; goto bad_stmt;
...@@ -22180,9 +22201,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) ...@@ -22180,9 +22201,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context)
cp_parser_omp_taskwait (parser, pragma_tok); cp_parser_omp_taskwait (parser, pragma_tok);
return false; return false;
case pragma_stmt: case pragma_stmt:
error ("%H%<#pragma omp taskwait%> may only be " error_at (pragma_tok->location,
"used in compound statements", "%<#pragma omp taskwait%> may only be "
&pragma_tok->location); "used in compound statements");
break; break;
default: default:
goto bad_stmt; goto bad_stmt;
...@@ -22208,8 +22229,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) ...@@ -22208,8 +22229,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context)
return true; return true;
case PRAGMA_OMP_SECTION: case PRAGMA_OMP_SECTION:
error ("%H%<#pragma omp section%> may only be used in " error_at (pragma_tok->location,
"%<#pragma omp sections%> construct", &pragma_tok->location); "%<#pragma omp section%> may only be used in "
"%<#pragma omp sections%> construct");
break; break;
default: default:
......
...@@ -2563,20 +2563,21 @@ qualified_name_lookup_error (tree scope, tree name, ...@@ -2563,20 +2563,21 @@ qualified_name_lookup_error (tree scope, tree name,
else if (TYPE_P (scope)) else if (TYPE_P (scope))
{ {
if (!COMPLETE_TYPE_P (scope)) if (!COMPLETE_TYPE_P (scope))
error ("%Hincomplete type %qT used in nested name specifier", error_at (location, "incomplete type %qT used in nested name specifier",
&location, scope); scope);
else if (TREE_CODE (decl) == TREE_LIST) else if (TREE_CODE (decl) == TREE_LIST)
{ {
error ("%Hreference to %<%T::%D%> is ambiguous", &location, scope, name); error_at (location, "reference to %<%T::%D%> is ambiguous",
scope, name);
print_candidates (decl); print_candidates (decl);
} }
else else
error ("%H%qD is not a member of %qT", &location, name, scope); error_at (location, "%qD is not a member of %qT", name, scope);
} }
else if (scope != global_namespace) else if (scope != global_namespace)
error ("%H%qD is not a member of %qD", &location, name, scope); error_at (location, "%qD is not a member of %qD", name, scope);
else else
error ("%H%<::%D%> has not been declared", &location, name); error_at (location, "%<::%D%> has not been declared", name);
} }
/* If FNS is a member function, a set of member functions, or a /* If FNS is a member function, a set of member functions, or a
...@@ -3984,7 +3985,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, ...@@ -3984,7 +3985,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv,
} }
if (cond == error_mark_node) if (cond == error_mark_node)
{ {
error ("%Hinvalid controlling predicate", &elocus); error_at (elocus, "invalid controlling predicate");
return true; return true;
} }
diff = build_x_binary_op (MINUS_EXPR, TREE_OPERAND (cond, 1), diff = build_x_binary_op (MINUS_EXPR, TREE_OPERAND (cond, 1),
...@@ -3994,8 +3995,8 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, ...@@ -3994,8 +3995,8 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv,
return true; return true;
if (TREE_CODE (TREE_TYPE (diff)) != INTEGER_TYPE) if (TREE_CODE (TREE_TYPE (diff)) != INTEGER_TYPE)
{ {
error ("%Hdifference between %qE and %qD does not have integer type", error_at (elocus, "difference between %qE and %qD does not have integer type",
&elocus, TREE_OPERAND (cond, 1), iter); TREE_OPERAND (cond, 1), iter);
return true; return true;
} }
...@@ -4089,7 +4090,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, ...@@ -4089,7 +4090,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv,
if (incr == error_mark_node) if (incr == error_mark_node)
{ {
error ("%Hinvalid increment expression", &elocus); error_at (elocus, "invalid increment expression");
return true; return true;
} }
...@@ -4216,8 +4217,8 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, ...@@ -4216,8 +4217,8 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
if (decl == NULL) if (decl == NULL)
{ {
error ("%Hexpected iteration declaration or initialization", error_at (locus,
&locus); "expected iteration declaration or initialization");
return NULL; return NULL;
} }
} }
...@@ -4227,13 +4228,13 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, ...@@ -4227,13 +4228,13 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
if (cond == NULL) if (cond == NULL)
{ {
error ("%Hmissing controlling predicate", &elocus); error_at (elocus, "missing controlling predicate");
return NULL; return NULL;
} }
if (incr == NULL) if (incr == NULL)
{ {
error ("%Hmissing increment expression", &elocus); error_at (elocus, "missing increment expression");
return NULL; return NULL;
} }
...@@ -4287,8 +4288,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, ...@@ -4287,8 +4288,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
if (!DECL_P (decl)) if (!DECL_P (decl))
{ {
error ("%Hexpected iteration declaration or initialization", error_at (elocus, "expected iteration declaration or initialization");
&elocus);
return NULL; return NULL;
} }
...@@ -4313,7 +4313,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, ...@@ -4313,7 +4313,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
if (!INTEGRAL_TYPE_P (TREE_TYPE (decl)) if (!INTEGRAL_TYPE_P (TREE_TYPE (decl))
&& TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE) && TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE)
{ {
error ("%Hinvalid type for iteration variable %qE", &elocus, decl); error_at (elocus, "invalid type for iteration variable %qE", decl);
return NULL; return NULL;
} }
......
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