[cfe-dev] Flexible array members in ObjC classes

David Chisnall via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 22 01:06:02 PDT 2017


On 22 Sep 2017, at 06:31, John McCall <rjmccall at apple.com> wrote:
> 
>> Thanks everybody for their input. I plan to update the patch with different test cases so it's easier to discuss. But so far my summary is the following.
>> 
>> For flexible array members we allow them only as the last ivar in @interface, with no ivars in @implementation. If it's not last, if it is in @implementation, if there are more ivars in @implementation - that's an error.
>> 
>> For variable sized types (i.e. structs with last member a flexible array) we don't error but warn if we can detect more ivars after it (in @interface or in @implementation). If @implementation ivars end with variable sized ivar, no error or warning.
>> 
>> For subclassing we don't error but warn if we can detect more ivars after a flexible array member or after a variable sized type member.
> 
> I think most of this sounds reasonable.  I would recommend being lax about whether the ivar is declared in the @interface vs. the @implementation, though.

If nothing else, I’d recommend a warning if the ivar is in the @implementation, because that means that we can’t guarantee getting a warning for subclasses, but apart from that this looks like a sensible design.  Thanks!

David





More information about the cfe-dev mailing list