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
This commit is contained in:
Jason Merrill 2011-10-14 15:12:57 -04:00 committed by Jason Merrill
parent 37d8632b51
commit 7204877f43
4 changed files with 29 additions and 1 deletions

View File

@ -1,5 +1,9 @@
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
* method.c (walk_field_subobs): Check for NSDMI before
complaining about uninitialized fields.

View File

@ -20617,7 +20617,8 @@ cp_parser_save_nsdmi (cp_parser* parser)
cp_token *last;
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;
@ -21719,6 +21720,12 @@ cp_parser_cache_group (cp_parser *parser,
kind of syntax error. */
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. */
cp_lexer_consume_token (parser->lexer);
/* See if it starts a new group. */

View File

@ -1,5 +1,8 @@
2011-10-14 Jason Merrill <jason@redhat.com>
PR c++/50563
* g++.dg/cpp0x/nsdmi-list1.C: New.
PR c++/50507
* g++.dg/cpp0x/nsdmi-const1.C: New.

View File

@ -0,0 +1,14 @@
// 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;
};