aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-02-04 00:59:21 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2009-02-04 00:59:21 +0000
commit062c4bb37ac6f2af6753060d8f8db5230bc18b49 (patch)
treee3c8d3d5d76924587be86ae6609bd1a94db4b04f /gcc/testsuite
parent244c6ba0d3f7121fa0ee163c028a3ba066945e45 (diff)
downloadgcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.zip
gcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.tar.gz
gcc-062c4bb37ac6f2af6753060d8f8db5230bc18b49.tar.bz2
re PR c/29129 ([DR#341] unnamed parameters using [*])
PR c/29129 * c-decl.c (grokdeclarator): Mark [*] arrays in field declarators as having variable size. Do not give an error for unnamed parameters with [*] declarators. Give a warning for type names with [*] declarators and mark them as variable size. * c-parser.c (c_parser_sizeof_expression): Do not give an error for sizeof applied to [*] type names. testsuite: * c90-arraydecl-1.c: Do not expect error for [*] in abstract declarator. * vla-6.c: Likewise. Expect warning not error for [*] lexically inside function prototype but not part of parameter declarator. * vla-11.c: New test. From-SVN: r143918
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/c90-arraydecl-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/vla-11.c13
-rw-r--r--gcc/testsuite/gcc.dg/vla-6.c9
4 files changed, 29 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 67369d9..25dedae 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2009-02-03 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/29129
+ * c90-arraydecl-1.c: Do not expect error for [*] in abstract
+ declarator.
+ * vla-6.c: Likewise. Expect warning not error for [*] lexically
+ inside function prototype but not part of parameter declarator.
+ * vla-11.c: New test.
+
2009-02-03 Jason Merrill <jason@redhat.com>
* g++.dg/warn/main-4.C: New test.
diff --git a/gcc/testsuite/gcc.dg/c90-arraydecl-1.c b/gcc/testsuite/gcc.dg/c90-arraydecl-1.c
index 97dc1ee..2b7eadb 100644
--- a/gcc/testsuite/gcc.dg/c90-arraydecl-1.c
+++ b/gcc/testsuite/gcc.dg/c90-arraydecl-1.c
@@ -10,7 +10,7 @@
void foo0 (int a, int b[*]); /* { dg-error "ISO C90" "\[*\] not in C90" } */
void foo1 (int, int [*]); /* { dg-error "ISO C90" "\[*\] not in C90" } */
-/* { dg-error "allowed" "\'\[*\]\' not allowed in other than a declaration" { target *-*-* } 12 } */
+
/* Use of static and type qualifiers (not allowed with abstract declarators)
is a C99 feature. */
diff --git a/gcc/testsuite/gcc.dg/vla-11.c b/gcc/testsuite/gcc.dg/vla-11.c
new file mode 100644
index 0000000..8948e6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-11.c
@@ -0,0 +1,13 @@
+/* Further tests of [*] being rejected other that in declarations, as
+ per the consensus in DR#341 that the second example there should be
+ invalid (but warnings because the final wording appears to allow
+ these cases). */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+
+void foo11a(int x[sizeof(int *(*)[*])]); /* { dg-warning "not in a declaration" } */
+void foo11b(__SIZE_TYPE__ x, int y[(__SIZE_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */
+void foo11c(struct s { int (*x)[*]; } *y); /* { dg-error "a member of a structure or union cannot have a variably modified type" "variably modified" } */
+/* { dg-warning "'struct s' declared inside parameter list" "struct decl" { target *-*-* } 11 } */
+/* { dg-warning "its scope is only this definition or declaration" "struct scope" { target *-*-* } 11 } */
diff --git a/gcc/testsuite/gcc.dg/vla-6.c b/gcc/testsuite/gcc.dg/vla-6.c
index b7bdb31..a7f5f05 100644
--- a/gcc/testsuite/gcc.dg/vla-6.c
+++ b/gcc/testsuite/gcc.dg/vla-6.c
@@ -7,9 +7,12 @@ int foo3(int i)[*]; /* { dg-error "not allowed in other than function prototype
void foo4(int o[*][4]) { } /* { dg-error "not allowed in other than function prototype scope" } */
void foo5(int o[4][*]) { } /* { dg-error "not allowed in other than function prototype scope" } */
-/* [*] can't be used in a type that's not a declaration */
-void foo11(int x[sizeof(int (*)[*])]); /* { dg-error "not allowed in other than a declaration" } */
-void foo12(int [*]); /* { dg-error "not allowed in other than a declaration" } */
+/* [*] can't be used in a type that's not a declaration (maybe, the
+ final wording for DR#341 would allow it although the first
+ discussed intent would not). */
+void foo11(int x[sizeof(int (*)[*])]); /* { dg-warning "not in a declaration" } */
+/* This case is allowed per DR#341. */
+void foo12(int [*]);
extern int n;
int B[100];