[cfe-dev] Unexpected warning in -std=gnu89 -pedantic mode.
Enea Zaffanella
zaffanella at cs.unipr.it
Wed Aug 26 12:57:09 PDT 2009
Eli Friedman wrote:
> On Wed, Aug 26, 2009 at 5:12 AM, Enea Zaffanella<zaffanella at cs.unipr.it> wrote:
>> Hello.
>>
>> 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.
>>
>> $ 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.
>> $
>
> I think it's worth noting that our behavior matches gcc here... what
> exactly were you expecting?
>
> -Eli
You are right (to my surprise).
As a matter of fact, I am still trying to figure out what is the
intended behavior for the combined options -std=gnu89 -pedantic.
man gcc says:
===
By specifing a base standard, the compiler will accept all programs
following that standard and those using GNU extensions that do not
contradict it.
[...]
On the other hand, by specifing a GNU dialect of a standard, all
features the compiler support are enabled, even when those features
change the meaning of the base standard and some strict-conforming
programs may be rejected. The particular standard is used by -pedantic
to identify which features are GNU extensions given that version of the
standard.
===
Initially, I misread it and was assuming that gnu89 and gnu99 were
considered to be "standards", as much as c89 and c99. Then I realized
that each of them is just a "dialect of a standard". Under this
interpretation, as far as diagnostic is concerned, there should be no
difference at all between
-std=c89 -pedantic
and
-std=gnu89 -pedantic
Is that the intended behavior?
If it is ... then it still sounds a bit strange to me. In particular,
what would then be the reason for allowing a combination such as
-std=gnu89 -pedantic-errors
?
To summarize, I won't propose patches on this until I better understand
what is meant.
Sorry for the noise,
Enea Zaffanella.
More information about the cfe-dev
mailing list