[cfe-dev] Problem with anonymous struct/union

Eli Friedman eli.friedman at gmail.com
Thu Jan 26 09:07:26 PST 2012


On Thu, Jan 26, 2012 at 8:57 AM, Jianjiang Ceng
<jianjiang.ceng at googlemail.com> wrote:
> Hi everyone,
>
> I met a problem with anonymous structs/unions. When the following
> piece of code is compiled with clang with -fms-extensions, clang will
> report an error "no member named 'a' in 's2'".
>
> typedef struct
> {
>        struct s1
>        {
>                int a;
>        };
> } s2;
>
> void foo()
> {
>        s2 b;
>        b.a=0;
> }
>
> I tested both the svn version and the 3.0 release version of clang,
> the result is the same. Tagged anonymous structs/unions cannot not be
> correctly compiled by clang. However, gcc and the microsoft compiler
> both have no problem with the above code.
>
> Since I want the problem fixed ASAP, I plan to investigate some time.
> In the meanwhile, I'm also new with clang, and need some help with
> solving the problem.
>
> So, can anybody gives a hint about where I should look at and how the
> problem can be best fixed.

The relevant code is in Sema::ParsedFreeStandingDeclSpec.

-Eli




More information about the cfe-dev mailing list