summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-decl.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/20040322-1.c4
4 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3f09dbf01c..9e06227a286 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/14069
+ * c-decl.c (finish_struct): Change type of incorrect flexible array
+ field into error_mark_node.
+
2004-03-22 Andrew Pinski <pinskia@physics.uc.edu>
PR target/14580
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 46f352b3a62..46863ed531a 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5018,11 +5018,20 @@ finish_struct (tree t, tree fieldlist, tree attributes)
&& TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
{
if (TREE_CODE (t) == UNION_TYPE)
- error ("%Jflexible array member in union", x);
+ {
+ error ("%Jflexible array member in union", x);
+ TREE_TYPE (x) = error_mark_node;
+ }
else if (TREE_CHAIN (x) != NULL_TREE)
- error ("%Jflexible array member not at end of struct", x);
+ {
+ error ("%Jflexible array member not at end of struct", x);
+ TREE_TYPE (x) = error_mark_node;
+ }
else if (! saw_named_field)
- error ("%Jflexible array member in otherwise empty struct", x);
+ {
+ error ("%Jflexible array member in otherwise empty struct", x);
+ TREE_TYPE (x) = error_mark_node;
+ }
}
if (pedantic && TREE_CODE (t) == RECORD_TYPE
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 89b16aeedc9..359124ca2c8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/14069
+ * gcc.dg/20040322-1.c: New test.
+
2004-03-22 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/ultrasp2.c: Do not pass -m64. Remove redundant lines.
diff --git a/gcc/testsuite/gcc.dg/20040322-1.c b/gcc/testsuite/gcc.dg/20040322-1.c
new file mode 100644
index 00000000000..af5e0b4820c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20040322-1.c
@@ -0,0 +1,4 @@
+/* PR c/14069 */
+/* { dg-do compile } */
+struct S { int a; char b[]; char *c; }; /* { dg-error "error" "flexible array member not" } */
+struct S s = { .b = "foo", .c = .b }; /* { dg-error "error" "parse error before" } */