PR c++/24907
* parser.c (cp_parser_simple_declaration): Require comma at the
beginning of processing second and later declarators, instead of
allowing the comma at the end of each iteration.
* g++.dg/parse/comma2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108462
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-12-13 Petr Machata <machata@post.cz>
+
+ PR c++/24907
+ * parser.c (cp_parser_simple_declaration): Require comma at the
+ beginning of processing second and later declarators, instead of
+ allowing the comma at the end of each iteration.
+
2005-12-12 Mark Mitchell <mark@codesourcery.com>
PR c++/25300
bool function_definition_p;
tree decl;
- saw_declarator = true;
+ if (saw_declarator)
+ {
+ /* If we are processing next declarator, coma is expected */
+ token = cp_lexer_peek_token (parser->lexer);
+ gcc_assert (token->type == CPP_COMMA);
+ cp_lexer_consume_token (parser->lexer);
+ }
+ else
+ saw_declarator = true;
+
/* Parse the init-declarator. */
decl = cp_parser_init_declarator (parser, &decl_specifiers,
function_definition_allowed_p,
token = cp_lexer_peek_token (parser->lexer);
/* If it's a `,', there are more declarators to come. */
if (token->type == CPP_COMMA)
- cp_lexer_consume_token (parser->lexer);
+ /* will be consumed next time around */;
/* If it's a `;', we are done. */
else if (token->type == CPP_SEMICOLON)
break;
+2005-12-13 Petr Machata <machata@post.cz>
+
+ PR c++/24907
+ * g++.dg/parse/comma2.C: New test.
+
2005-12-13 Mark Mitchell <mark@codesourcery.com>
Jakub Jelinek <jakub@redhat.com>
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2005 Free Software Foundation, Inc.
+
+// PR c++/24907 [3.4/4.0/4.1/4.2 Regression] "int x, ;" accepted
+
+int x;
+int y,; /* { dg-error "expected" } */
+
+int main()
+{
+ int a;
+ int b,; /* { dg-error "expected" } */
+ int c,d;
+ int e,f,; /* { dg-error "expected" } */
+ int g,h,i;
+ int j,k,l,;/* { dg-error "expected" } */
+ int m,,,n; /* { dg-error "expected" } */
+}