r218006 - Sema: Diagnose undefined structs used as Microsoft anonymous structs
jahanian
fjahanian at apple.com
Thu Sep 18 09:38:46 PDT 2014
On Sep 18, 2014, at 9:33 AM, jahanian <fjahanian at apple.com> wrote:
>
> On Sep 17, 2014, at 5:42 PM, David Majnemer <david.majnemer at gmail.com> wrote:
>
>> Author: majnemer
>> Date: Wed Sep 17 19:42:05 2014
>> New Revision: 218006
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=218006&view=rev
>> Log:
>> Sema: Diagnose undefined structs used as Microsoft anonymous structs
>>
>> Previously, we would not mark structs containing anonymous structs as
>> invalid. Later, horrific things would occur when trying to determine
>> the size of the parent record.
>>
>> Instead, require the struct to be a complete type when used as an
>> anonymous struct. Mark both the anonymous field for the struct and the
>> parent context as invalid (this is similar to what we do when a struct
>> contains a field with an incomplete type.)
>
>
> Thank you David for working on this. Will this test case continue to work without error. This was the behavior before:
>
> struct anon_fault {
> struct undefined;
> };
>
> struct undefined {
> int ii;
> };
>
> int main()
> {
> return sizeof(struct anon_fault);
> }
>
We get the error with your patch:
t.c:2:2: error: field has incomplete type 'struct undefined'
t.c:2:9: note: forward declaration of 'struct undefined'
struct undefined;
^
I am not familiar with details of microsoft’s anonymous structs. Is this the expected behavior?
- Thanks, Fariborz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140918/10313582/attachment.html>
More information about the cfe-commits
mailing list