[PATCH] explicit GNU flags

Richard Smith richard at metafoo.co.uk
Fri Aug 16 14:56:15 PDT 2013


On Fri, Aug 16, 2013 at 2:22 PM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Fri, Aug 16, 2013 at 2:39 AM, Peter N Lewis <peter at stairways.com.au>wrote:
>
>> This patch supersedes my previous patch and defines explicit flags for
>> each of the eight remaining generic -gnu features.
>>
>> Flags are:
>>
>>         -gnu-alignof-expression
>>         -gnu-case-range
>>         -gnu-complex-integer
>>         -gnu-conditional-omitted-operand
>>         -gnu-empty-initializer
>>         -gnu-label-as-value
>>         -gnu-local-label
>>         -gnu-statement-expression
>>
>> I would have preferred to do each as an independent patch, but because
>> they all touch the "def GNU : DiagGroup" line they would conflict which
>> each other unless applied in exactly the right order. They are all related
>> in any event, simply adding explicit control over the features covered by
>> -gnu.
>>
>> For conditional-omitted-operand, I changed the error message slightly,
>> from:
>>
>>         use of GNU ?: expression extension, eliding middle term
>>
>> to
>>
>>         use of GNU ?: conditional expression extension, omitting middle
>> operand
>>
>> to better match the GCC documentation of the feature and hence the flag
>> name.
>>
>> gnu-label-as-value covers both errors "use of GNU address-of-label
>> extension" and "use of GNU indirect-goto extension" as it would seem to me
>> that one is useless without the other, so they are functionally the same
>> feature.
>>
>> There does not seem to be any way to get the "use of GNU empty
>> initializer extension" warning without also getting some other warning
>> (such as "zero size arrays are an extension").
>>
>> There are test cases for each of the flags.
>>
>> I'd like to move on to some other similar patches now, so hopefully I can
>> get either approval of this patch or some feedback or something.
>>
>>
> diag::ext_gnu_local_label shouldn't exist; it's not something we need to
> diagnose.
>
> You can trigger ext_gnu_empty_initializer with "struct { int x; } x = {};"
>
> It would be nice if you could avoid adding thirty invocations of clang to
> the regression tests; we rely on them to run quickly.
>

Perhaps fold all the tests into one file, add a -D for each warning flag,
then do

// RUN: %clang_cc1 -verify %s
// RUN: %clang_cc1 -verify %s -Wgnu-alignof-expression -DALIGNOF
// RUN: %clang_cc1 -verify %s -Wgnu-case-range -DCASE_RANGE
// ...
// RUN: %clang_cc1 -verify %s -Wgnu -DALIGNOF -DCASE_RANGE
-DCOMPLEX_INTEGER ...

... though even this is more thorough testing than we'd usually have for
warning flags.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130816/874ed75b/attachment.html>


More information about the cfe-commits mailing list