Commit 88682ff6 by Joseph Myers Committed by Joseph Myers

re PR c/11943 (Accepts invalid declaration "int x[2, 3];" in C99 mode)

	* c-parse.in (array_declarator): Use expr_no_commas.
	Fixes PR c/11943.

testsuite:
	* gcc.dg/c99-arraydecl-2.c: New test.  PR c/11943.

From-SVN: r72900
parent 3d39f007
2003-10-24 Joseph S. Myers <jsm@polyomino.org.uk>
* c-parse.in (array_declarator): Use expr_no_commas.
Fixes PR c/11943.
2003-10-24 Richard Sandiford <rsandifo@redhat.com> 2003-10-24 Richard Sandiford <rsandifo@redhat.com>
* config/mips/linux.h: Wrap MD_FALLBACK_FRAME_STATE_FOR and * config/mips/linux.h: Wrap MD_FALLBACK_FRAME_STATE_FOR and
......
...@@ -1973,16 +1973,16 @@ direct_absdcl1: ...@@ -1973,16 +1973,16 @@ direct_absdcl1:
/* The [...] part of a declarator for an array type. */ /* The [...] part of a declarator for an array type. */
array_declarator: array_declarator:
'[' maybe_type_quals_attrs expr ']' '[' maybe_type_quals_attrs expr_no_commas ']'
{ $$ = build_array_declarator ($3, $2, 0, 0); } { $$ = build_array_declarator ($3, $2, 0, 0); }
| '[' maybe_type_quals_attrs ']' | '[' maybe_type_quals_attrs ']'
{ $$ = build_array_declarator (NULL_TREE, $2, 0, 0); } { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
| '[' maybe_type_quals_attrs '*' ']' | '[' maybe_type_quals_attrs '*' ']'
{ $$ = build_array_declarator (NULL_TREE, $2, 0, 1); } { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
| '[' STATIC maybe_type_quals_attrs expr ']' | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
{ $$ = build_array_declarator ($4, $3, 1, 0); } { $$ = build_array_declarator ($4, $3, 1, 0); }
/* declspecs_nosc_nots is a synonym for type_quals_attrs. */ /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
| '[' declspecs_nosc_nots STATIC expr ']' | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
{ $$ = build_array_declarator ($4, $2, 1, 0); } { $$ = build_array_declarator ($4, $2, 1, 0); }
; ;
......
2003-10-24 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/c99-arraydecl-2.c: New test. PR c/11943.
2003-10-24 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> 2003-10-24 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/11076 PR c++/11076
......
/* Test for C99 array declarators: expression must be an
assignment-expression. PR 11943. */
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
void
foo (void)
{
int a[2, 3]; /* { dg-error "parse|syntax" "bad array declarator" } */
void b(int x[2, 3]); /* { dg-error "parse|syntax" "bad array declarator" } */
void c(int [2, 3]); /* { dg-error "parse|syntax" "bad array declarator" } */
void d(int *x[restrict 2, 3]); /* { dg-error "parse|syntax" "bad array declarator" } */
void e(int *x[static restrict 2, 3]); /* { dg-error "parse|syntax" "bad array declarator" } */
void f(int *x[restrict static 2, 3]); /* { dg-error "parse|syntax" "bad array declarator" } */
}
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