* c-parse.in (array_designator): New.
(designator): Use it.
(initelt): Only permit array_designator without '=', not ".foo".
testsuite:
* gcc.dg/init-desig-obs-1.c, gcc.dg/init-desig-obs-2.c,
gcc.dg/init-desig-obs-3.c: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89560
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-10-25 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ PR c/16667
+ * c-parse.in (array_designator): New.
+ (designator): Use it.
+ (initelt): Only permit array_designator without '=', not ".foo".
+
2004-10-25 Kenneth Zadeck <zadeck@naturalbridge.com>
* gcc/Makefile.in: removed ggc for cgraphunit.
* gcc/cgraph.c.dump_cgraph_node: removed static var analysis.
designator_list '=' initval
{ if (pedantic && !flag_isoc99)
pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
- | designator initval
+ | array_designator initval
{ if (pedantic)
pedwarn ("obsolete use of designated initializer without %<=%>"); }
| identifier ':'
designator:
'.' identifier
{ set_init_label ($2); }
- | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
+ | array_designator
+
+array_designator:
+ '[' expr_no_commas ELLIPSIS expr_no_commas ']'
{ set_init_index ($2.value, $4.value);
if (pedantic)
pedwarn ("ISO C forbids specifying range of elements to initialize"); }
+2004-10-25 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ PR c/16667
+ * gcc.dg/init-desig-obs-1.c, gcc.dg/init-desig-obs-2.c,
+ gcc.dg/init-desig-obs-3.c: New tests.
+
2004-10-25 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/debug/20041023-1.c: New test.
--- /dev/null
+/* Test obsolete forms of designated initializers. Test with default
+ warning options: valid forms are accepted, while ".member" without
+ "=" should not be (bug 16667). */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+struct s { int a; };
+struct s s0 = { .a = 1 };
+struct s s1 = { a: 1 };
+
+int x0[] = { [0] = 1 };
+int x1[] = { [0] 1 };
+
+/* Invalid syntax: multiple designators without "=". */
+int x2[2][2] = { [0][0] 1 }; /* { dg-error "(syntax|parse) error" } */
+
+
+/* Invalid syntax: C99-style structure designator without "=". */
+struct s s2 = { .a 1 }; /* { dg-error "(syntax|parse) error" } */
--- /dev/null
+/* Test obsolete forms of designated initializers. Test with
+ -pedantic. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic" } */
+struct s { int a; };
+struct s s0 = { .a = 1 };
+struct s s1 = { a: 1 }; /* { dg-warning "warning: obsolete use of designated initializer with ':'" } */
+
+int x0[] = { [0] = 1 };
+int x1[] = { [0] 1 }; /* { dg-warning "warning: obsolete use of designated initializer without '='" } */
--- /dev/null
+/* Test obsolete forms of designated initializers. Test with
+ -pedantic-errors. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic-errors" } */
+struct s { int a; };
+struct s s0 = { .a = 1 };
+struct s s1 = { a: 1 }; /* { dg-error "error: obsolete use of designated initializer with ':'" } */
+
+int x0[] = { [0] = 1 };
+int x1[] = { [0] 1 }; /* { dg-error "error: obsolete use of designated initializer without '='" } */