OSDN Git Service

* c-parse.in (array_declarator): Use expr_no_commas.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Oct 2003 15:30:37 +0000 (15:30 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Oct 2003 15:30:37 +0000 (15:30 +0000)
Fixes PR c/11943.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72900 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-parse.in
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c99-arraydecl-2.c [new file with mode: 0644]

index 19ab2ed..445a006 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * config/mips/linux.h: Wrap MD_FALLBACK_FRAME_STATE_FOR and
index c785017..22bab99 100644 (file)
@@ -1973,16 +1973,16 @@ direct_absdcl1:
 /* The [...] part of a declarator for an array type.  */
 
 array_declarator:
-       '[' maybe_type_quals_attrs expr ']'
+       '[' maybe_type_quals_attrs expr_no_commas ']'
                { $$ = build_array_declarator ($3, $2, 0, 0); }
        | '[' maybe_type_quals_attrs ']'
                { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
        | '[' maybe_type_quals_attrs '*' ']'
                { $$ = 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); }
        /* 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); }
        ;
 
index 7a56993..dd43b93 100644 (file)
@@ -1,3 +1,7 @@
+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>
 
        PR c++/11076
diff --git a/gcc/testsuite/gcc.dg/c99-arraydecl-2.c b/gcc/testsuite/gcc.dg/c99-arraydecl-2.c
new file mode 100644 (file)
index 0000000..e2085e1
--- /dev/null
@@ -0,0 +1,16 @@
+/* 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" } */
+}