From eba80994397693d6ab3a65a05a05ef743ad76652 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@multimania.com>
Date: Thu, 21 Mar 2002 18:03:46 -0800
Subject: 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
---
 gcc/testsuite/gcc.dg/array-6.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/array-6.c

(limited to 'gcc/testsuite/gcc.dg/array-6.c')

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)" } */
+}
-- 
cgit v1.1