parser.c (cp_parser_mem_initializer): Set input_location properly for init-list warning.

* parser.c (cp_parser_mem_initializer): Set input_location
	properly for init-list warning.
	(cp_parser_postfix_open_square_expression): Likewise.
	(cp_parser_parenthesized_expression_list): Likewise.
	(cp_parser_new_initializer): Likewise.
	(cp_parser_jump_statement): Likewise.
	(cp_parser_initializer): Likewise.
	(cp_parser_functional_cast): Likewise.

From-SVN: r208350
This commit is contained in:
Jason Merrill 2014-03-05 12:53:21 -05:00 committed by Jason Merrill
parent 487125e75b
commit 047023865e
3 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2014-03-05 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_mem_initializer): Set input_location
properly for init-list warning.
(cp_parser_postfix_open_square_expression): Likewise.
(cp_parser_parenthesized_expression_list): Likewise.
(cp_parser_new_initializer): Likewise.
(cp_parser_jump_statement): Likewise.
(cp_parser_initializer): Likewise.
(cp_parser_functional_cast): Likewise.
2014-03-04 Jason Merrill <jason@redhat.com> 2014-03-04 Jason Merrill <jason@redhat.com>
PR c++/60417 PR c++/60417

View File

@ -6359,6 +6359,8 @@ cp_parser_postfix_open_square_expression (cp_parser *parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
bool expr_nonconst_p; bool expr_nonconst_p;
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
index = cp_parser_braced_list (parser, &expr_nonconst_p); index = cp_parser_braced_list (parser, &expr_nonconst_p);
if (flag_cilkplus if (flag_cilkplus
@ -6671,6 +6673,8 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
/* A braced-init-list. */ /* A braced-init-list. */
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expr = cp_parser_braced_list (parser, &expr_non_constant_p); expr = cp_parser_braced_list (parser, &expr_non_constant_p);
if (non_constant_p && expr_non_constant_p) if (non_constant_p && expr_non_constant_p)
@ -7519,6 +7523,8 @@ cp_parser_new_initializer (cp_parser* parser)
{ {
tree t; tree t;
bool expr_non_constant_p; bool expr_non_constant_p;
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
t = cp_parser_braced_list (parser, &expr_non_constant_p); t = cp_parser_braced_list (parser, &expr_non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (t) = 1; CONSTRUCTOR_IS_DIRECT_INIT (t) = 1;
@ -10675,6 +10681,8 @@ cp_parser_jump_statement (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expr = cp_parser_braced_list (parser, &expr_non_constant_p); expr = cp_parser_braced_list (parser, &expr_non_constant_p);
} }
@ -12353,6 +12361,8 @@ cp_parser_mem_initializer (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
bool expr_non_constant_p; bool expr_non_constant_p;
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expression_list = cp_parser_braced_list (parser, &expr_non_constant_p); expression_list = cp_parser_braced_list (parser, &expr_non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1; CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
@ -18801,6 +18811,8 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init,
} }
else if (token->type == CPP_OPEN_BRACE) else if (token->type == CPP_OPEN_BRACE)
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
init = cp_parser_braced_list (parser, non_constant_p); init = cp_parser_braced_list (parser, non_constant_p);
CONSTRUCTOR_IS_DIRECT_INIT (init) = 1; CONSTRUCTOR_IS_DIRECT_INIT (init) = 1;
@ -23236,6 +23248,8 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
{ {
cp_token *token = cp_lexer_peek_token (parser->lexer);
cp_lexer_set_source_position_from_token (token);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
expression_list = cp_parser_braced_list (parser, &nonconst_p); expression_list = cp_parser_braced_list (parser, &nonconst_p);
CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1; CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;

View File

@ -4,5 +4,4 @@ template < unsigned >
struct A ; struct A ;
template < typename > template < typename >
struct B ; struct B ;
template < typename T , A < B < T > // { dg-error "initializer|parse error|valid type|expected" } template < typename T , A < B < T > {}// { dg-error "initializer|parse error|type|expected" }
{ }