[cfe-dev] warning: declaration does not declare anything / error: no member named 'LOW' in 'STRUCT'

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 30 14:22:09 PDT 2018


The Plan9 C extensions are described here:
http://doc.cat-v.org/plan_9/4th_edition/papers/compiler

... in which we find "The most important and most heavily used of the
extensions is the declaration of an unnamed substructure or subunion."
(Though it is worth observing that our extension here is less powerful than
the Plan9 C extension in a couple of ways.)

I think using -fplan9-extensions for "the set of Plan9 C extensions that we
support" seems appropriate, even if we don't support all of them, and if
that flag means something different from what it means to GCC as a result.
(And it's worth noting that we already support most of the other extensions
as either GNU extensions or as part of C99.)

On Mon, 30 Jul 2018 at 14:07, Friedman, Eli via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Adding a separate flag to control this is probably fine. Not sure about
> the name fplan9-extensions; in gcc, I think that includes some other
> extensions we don't implement.
>
> -Eli
>
> On 7/30/2018 12:52 PM, Richard Smith wrote:
>
> Would it make sense to add a -fplan9-extensions flag, to enable support
> for this without enabling all the other MS extensions that we support?
>
> On Mon, 30 Jul 2018 at 11:53, Friedman, Eli via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> On 7/30/2018 9:08 AM, Frank Redeker via cfe-dev wrote:
>> > Hello List,
>> >
>> > Given the following piece of code.
>> >
>> > typedef union {
>> >       struct {
>> >               unsigned char   LOW;
>> >               unsigned char   HIGH;
>> >       };
>> >       unsigned short  SHORT;
>> > } UNION;
>> >
>> > typedef struct {
>> >       UNION; // <-- use of type only
>> >       union {
>> >               unsigned char   FOO;
>> >       };
>> > } STRUCT;
>> >
>> > STRUCT        Variable;
>> >
>> > void Function () {
>> >       Variable.LOW = 1;
>> > }
>> >
>> >
>> > This code compiles without any error using gcc 7.2 (When compiling with
>> > -ansi -pedantic I get the warning "ISO C90 doesn't support unnamed
>> > structs/unions". If I add -std=c11 the warning disappears)
>>
>> Declaring an anonymous union like that non-standard; you need to pass
>> -fms-extensions.
>>
>> -Eli
>>
>> --
>> Employee of Qualcomm Innovation Center, Inc.
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
>> Linux Foundation Collaborative Project
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180730/e3cab921/attachment.html>


More information about the cfe-dev mailing list