[cfe-dev] Problem with anonymous struct/union

Jianjiang Ceng jianjiang.ceng at googlemail.com
Thu Jan 26 08:57:08 PST 2012

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;

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.


More information about the cfe-dev mailing list