+2009-02-08 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/36432
+ * c-decl.c (grokdeclarator): Don't treat [] declarators in fields
+ as indicating flexible array members unless the field itself is
+ being declarared as the incomplete array.
+
2009-02-07 Kaz Kojima <kkojima@gcc.gnu.org>
Backport from mainline:
}
else if (decl_context == FIELD)
{
- if (pedantic && !flag_isoc99 && !in_system_header)
+ bool flexible_array_member = false;
+ const struct c_declarator *t = declarator;
+ while (t->kind == cdk_attrs)
+ t = t->declarator;
+ flexible_array_member = (t->kind == cdk_id);
+ if (flexible_array_member
+ && pedantic && !flag_isoc99 && !in_system_header)
pedwarn ("ISO C90 does not support flexible array members");
/* ISO C99 Flexible array members are effectively
identical to GCC's zero-length array extension. */
- itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
+ if (flexible_array_member || array_parm_vla_unspec_p)
+ itype = build_range_type (sizetype, size_zero_node,
+ NULL_TREE);
}
else if (decl_context == PARM)
{
+2009-02-08 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/36432
+ * gcc.dg/c90-flex-array-2.c, gcc.dg/c99-flex-array-6.c: New tests.
+
2009-02-05 Joseph Myers <joseph@codesourcery.com>
PR c/35435
--- /dev/null
+/* [] does not indicate a flexible array member unless it is the field
+ itself being declared as an incomplete array type rather than a
+ pointer or other type derived from such a type. PR 36432. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+void
+f (void)
+{
+ int a[3];
+ int (*p)[];
+ struct { int (*p)[]; } s;
+ p = &a;
+ s.p = &a;
+}
--- /dev/null
+/* [] does not indicate a flexible array member unless it is the field
+ itself being declared as an incomplete array type rather than a
+ pointer or other type derived from such a type. PR 36432. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+void
+f (void)
+{
+ int a[3];
+ int (*p)[];
+ struct { int (*p)[]; } s;
+ p = &a;
+ s.p = &a;
+}