This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ObjC testcase for designated initializers


In the course of reverse-engineering the Objective-C grammar I found
that my patch fixing bug 16667 had accidentally caused a case of
designated initializers to parse for Objective-C when it previously
didn't.  I think it is indeed desirable for this case to parse; this
patch adds a testcase for it.

There remain cases which parse only for C and not for Objective-C: if
the designator list starts with two array designators then the LALR(1)
parser commits too early to shifting the second '[', requiring it to
be a message expression (with a single array designator before and no
'=' between them) rather than reducing the first designator to a
designator list.  I don't think this is easily fixable with the Bison
parser; my new parser will strictly emulate what the Bison parser does
until it goes in mainline, after which if desired such designators
could be accepted in Objective-C.

The testcase passes on i686-pc-linux-gnu.  OK to commit?

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-11-01  Joseph S. Myers  <joseph@codesourcery.com>

	* objc.dg/desig-init-2.m: New test.

diff -rupN GCC.orig/gcc/testsuite/objc.dg/desig-init-2.m GCC/gcc/testsuite/objc.dg/desig-init-2.m
--- GCC.orig/gcc/testsuite/objc.dg/desig-init-2.m	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/objc.dg/desig-init-2.m	2004-11-01 16:22:43.000000000 +0000
@@ -0,0 +1,7 @@
+/* Test handling of C99 designator lists in Objective-C.  Test array
+   designators after structure member designators.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct s { int a[2]; } x = { .a[0] = 1 };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]