Comments
Patch
commit 09f16be794e871607c2bb46bf74206ee40af1b74
Author: Jason Merrill <jason@redhat.com>
Date: Thu Oct 13 17:51:13 2011 -0400
PR c++/50563
* parser.c (cp_parser_cache_group): Handle end==CPP_COMMA.
(cp_parser_save_nsdmi): Pass it.
@@ -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. */
new file mode 100644
@@ -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;
+};