[cfe-dev] Bug in __extension__ handling for record fields

Chris Lattner clattner at apple.com
Fri Aug 14 17:28:19 PDT 2009


On Aug 13, 2009, at 2:53 AM, Abramo Bagnara wrote:

> This log shows the problem:
>
> $ cat q.c
>
> struct {
>  __extension__ unsigned long long b;
> } a;
> $ ~/llvm/Debug/bin/clang-cc -pedantic -std=c89 q.c
> q.c:3:31: warning: 'long long' is an extension when C99 mode is not  
> enabled
>  __extension__ unsigned long long b;
>                              ^
> 1 diagnostic generated.
>
> I've tracked down the problem to the fact that in
> Parser::ParseStructUnionBody it's called ParseStructDeclaration that
> during its execution disables the warning, but after its return the
> warning is generated by Actions.ActOnField call that operates with
> warnings enabled.
>
> A way to fix could be to add a flag to FieldDeclarator to remember  
> that
> the declaration was marked by __extension__.
>
> The flag would be set by ParseStructDeclaration and then read in the
> following loop to disable again the warnings for the execution of
> Actions.ActOnField.
>
> If you agree with this approach I'm willing to submit a patch.

This sounds like a reasonable approach to me!

-Chris



More information about the cfe-dev mailing list