aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@multimania.com>2002-03-21 18:03:46 -0800
committerRichard Henderson <rth@gcc.gnu.org>2002-03-21 18:03:46 -0800
commiteba80994397693d6ab3a65a05a05ef743ad76652 (patch)
tree487636832b303f5c58b5f3e01233b424c5621084 /gcc/testsuite
parentbac015e7922ccedbaeab8ab7bef539ddddd93c19 (diff)
downloadgcc-eba80994397693d6ab3a65a05a05ef743ad76652.zip
gcc-eba80994397693d6ab3a65a05a05ef743ad76652.tar.gz
gcc-eba80994397693d6ab3a65a05a05ef743ad76652.tar.bz2
re PR c/5597 ([regression from 2.95.3] Initialization of flexible char array member segfaults)
PR c/5597 * c-typeck.c (process_init_element): Flag non-static initialization of a flexible array member as illegal. From-SVN: r51156
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/array-6.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/array-6.c b/gcc/testsuite/gcc.dg/array-6.c
new file mode 100644
index 0000000..6ef6462
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/array-6.c
@@ -0,0 +1,18 @@
+/* PR c/5597 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Verify that GCC forbids non-static initialization of
+ flexible array members. */
+
+struct str { int len; char s[]; };
+
+struct str a = { 2, "a" };
+
+void foo()
+{
+ static struct str b = { 2, "b" };
+ struct str c = { 2, "c" }; /* { dg-error "(non-static)|(near initialization)" } */
+ struct str d = (struct str) { 2, "d" }; /* { dg-error "(non-static)|(near initialization)" } */
+ struct str e = (struct str) { d.len, "e" }; /* { dg-error "(non-static)|(initialization)" } */
+}