The problem here was that we were saving away the second declarator as
part of the NSDMI for the first declarator. Fixed by stopping at a
non-nested comma.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 09f16be794e871607c2bb46bf74206ee40af1b74
Author: Jason Merrill <ja...@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.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index cabe9aa..ea0c4dc 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list1.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list1.C
new file mode 100644
index 0000000..526f29a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list1.C
@@ -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;
+};