Commit 7204877f by Jason Merrill Committed by Jason Merrill

re PR c++/50563 ([C++0x] Weird syntax acceptance rules for non-static data…

re PR c++/50563 ([C++0x] Weird syntax acceptance rules for non-static data members initialized in place)

	PR c++/50563
	* parser.c (cp_parser_cache_group): Handle end==CPP_COMMA.
	(cp_parser_save_nsdmi): Pass it.

From-SVN: r180003
parent 37d8632b
2011-10-14 Jason Merrill <jason@redhat.com> 2011-10-14 Jason Merrill <jason@redhat.com>
PR c++/50563
* parser.c (cp_parser_cache_group): Handle end==CPP_COMMA.
(cp_parser_save_nsdmi): Pass it.
PR c++/50507 PR c++/50507
* method.c (walk_field_subobs): Check for NSDMI before * method.c (walk_field_subobs): Check for NSDMI before
complaining about uninitialized fields. complaining about uninitialized fields.
......
...@@ -20617,7 +20617,8 @@ cp_parser_save_nsdmi (cp_parser* parser) ...@@ -20617,7 +20617,8 @@ cp_parser_save_nsdmi (cp_parser* parser)
cp_token *last; cp_token *last;
tree node; tree node;
cp_parser_cache_group (parser, CPP_CLOSE_PAREN, /*depth=*/0); /* Save tokens until the next comma or semicolon. */
cp_parser_cache_group (parser, CPP_COMMA, /*depth=*/0);
last = parser->lexer->next_token; last = parser->lexer->next_token;
...@@ -21719,6 +21720,12 @@ cp_parser_cache_group (cp_parser *parser, ...@@ -21719,6 +21720,12 @@ cp_parser_cache_group (cp_parser *parser,
kind of syntax error. */ kind of syntax error. */
return true; return true;
/* If we're caching something finished by a comma (or semicolon),
such as an NSDMI, don't consume the comma. */
if (end == CPP_COMMA
&& (token->type == CPP_SEMICOLON || token->type == CPP_COMMA))
return false;
/* Consume the token. */ /* Consume the token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* See if it starts a new group. */ /* See if it starts a new group. */
......
2011-10-14 Jason Merrill <jason@redhat.com> 2011-10-14 Jason Merrill <jason@redhat.com>
PR c++/50563
* g++.dg/cpp0x/nsdmi-list1.C: New.
PR c++/50507 PR c++/50507
* g++.dg/cpp0x/nsdmi-const1.C: New. * g++.dg/cpp0x/nsdmi-const1.C: New.
......
// PR c++/50563
// { dg-options -std=c++0x }
struct S1 {
int a{10}, b{20}; // OK
};
struct S2 {
int a, b = 20; // OK
};
struct S3 {
int a = 10, b = 20;
};
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