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

Abramo Bagnara abramobagnara at tin.it
Thu Aug 13 02:53:18 PDT 2009


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.



More information about the cfe-dev mailing list