aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2003-10-24 16:30:37 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2003-10-24 16:30:37 +0100
commit88682ff62d51b96c6278e30862068780f5eb6f1d (patch)
tree0e20c06d9c4524d1e9acb4a0a01a1f9474f0fd26 /gcc
parent3d39f00757c94705cd29e629359a3e63c2bbbe80 (diff)
downloadgcc-88682ff62d51b96c6278e30862068780f5eb6f1d.zip
gcc-88682ff62d51b96c6278e30862068780f5eb6f1d.tar.gz
gcc-88682ff62d51b96c6278e30862068780f5eb6f1d.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-parse.in6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/c99-arraydecl-2.c16
4 files changed, 28 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 19ab2ed..445a006 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index c785017..22bab99 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -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); }
;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7a56993..dd43b93 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..e2085e1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-arraydecl-2.c
@@ -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" } */
+}