Designated initializers for ObjC?

Stan Shebs shebs@apple.com
Tue Dec 5 18:00:00 GMT 2000


There's a strange little conditional in c-parse.in that effectively
removes designated initializers from Objective-C:

        /* These are for labeled elements.  The syntax for an array element
           initializer conflicts with the syntax for an Objective-C message,
           so don't include these productions in the Objective-C grammar.  */
ifc
        | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
                { set_init_index ($2, $4);
                  if (pedantic)
                    pedwarn ("ISO C forbids specifying range of elements to ini\
tialize"); }
        | '[' expr_no_commas ']'
                { set_init_index ($2, NULL_TREE); }
end ifc

This is obviously a problem for anyone that wants to use this
extension in ObjC programs.  My question is: why is it disabled?
I enabled this and noodled around a bit with example code; the
message-passing case and the designator case don't ever seem to
validly overlap, for instance you can't have a message send
inside an initializer because it's not a constant, and so far
the parser has been giving reasonable error messages.

Before proposing the patch, I'm going to test this on at least
some of Apple's million+ lines of ObjC source, but in the meantime,
I'd like to know if I'm missing the reason for this.  It's been
in there for quite some time, since 2.7 at least, so maybe it's
just another hysterical leftover?

Stan


More information about the Gcc mailing list