[cfe-dev] Unexpected warning in -std=gnu89 -pedantic mode.
Douglas Gregor
dgregor at apple.com
Wed Aug 26 08:04:22 PDT 2009
On Aug 26, 2009, at 5:12 AM, Enea Zaffanella wrote:
> There seems to be a problem in the handling of diagnostic for GNU
> extensions: some warnings are produced even though the -std=gnu89
> option
> is specified.
We probably have quite a few of these problems, because many of these
extension diagnostics were written before we distinguished between the
different kinds of extensions (e.g., Microsoft vs. GNU), so they
conflate "is an extension diagnostic" with "is a GNU extension.
> $ cat aaa.c
> int foo() {
> return ({2+3;});
> }
>
> $ clang-cc -std=gnu89 -pedantic aaa.c
> aaa.c:2:11: warning: use of GNU statement expression extension
> return ({2+3;});
> ^
> 1 diagnostic generated.
> $
The fix for this issue would be to change 1311 of ParseExpr.cpp from
Diag(Tok, diag::ext_gnu_statement_expr);
to
if (!getLang().GNUMode)
Diag(Tok, diag::ext_gnu_statement_expr);
> The same happens when using, e.g., __builtin_offsetof.
It'll happen in many places, all of which will need to be changed with
a check for GNUMode (for GNU extensions). I'd be happy to review and
apply such a patch, if someone feels like tackling this.
- Doug
More information about the cfe-dev
mailing list