r193919 - Sema: Cleanup and simplify anonymous union diagnostics

Jordan Rose jordan_rose at apple.com
Mon Nov 4 11:17:47 PST 2013


On Nov 4, 2013, at 11:15, David Majnemer <david.majnemer at gmail.com> wrote:

> On Mon, Nov 4, 2013 at 11:14 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> On Nov 4, 2013, at 11:13, David Majnemer <david.majnemer at gmail.com> wrote:
> 
>> On Mon, Nov 4, 2013 at 9:09 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>> 
>> On Nov 2, 2013, at 3:38 , David Majnemer <david.majnemer at gmail.com> wrote:
>> 
>>> +                     : getLangOpts().CPlusPlus
>>> +                           ? diag::ext_flexible_array_union_gnu
>>> +                           : diag::err_flexible_array_union;
>> 
>> This doesn't look right. Flexible array members in unions shouldn't be an extension in C++ if they're disallowed in C.
>> 
>> My patch doesn't change this behavior.
>> 
>> Given:
>> union x { int a; int b[]; };
>> 
>> clang in c99 or c89:
>> error: field has incomplete type 'int []'
>> 
>> gcc in c99 or c89:
>> error: flexible array member in union
> 
> 
> Right, but in C++?
> 
> ...actually, it seems that we do accept this in C++ (before and after your patch). Does GCC?
> 
> Yes, with the following diagnostic under -pedantic:
> 
> warning: ISO C++ forbids zero-size array ‘b’ [-Wpedantic]

That's bizarre. Okay.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131104/d3205336/attachment.html>


More information about the cfe-commits mailing list