[cfe-dev] Explicit warning diagnostic flags for groups

David Blaikie dblaikie at gmail.com
Tue Aug 13 10:23:21 PDT 2013


On Tue, Aug 13, 2013 at 7:03 AM, Peter N Lewis <peter at stairways.com.au> wrote:
>
> On 13/08/2013, at 16:42 , Dmitri Gribenko <gribozavr at gmail.com> wrote:
> > This change looks correct.  There are two points to consider:
> > * choice of the option name.  Does GCC have a similar option?  Does
> > GCC have a name for this extension in the documentation?
>
> Very good question, to which I don't have a very good answer.  There does not appear to be a matching GCC option.
>
> GCC describes the issues as either "5.7 Conditionals with Omitted Operands", and mentions it as "the middle operand in a conditional expression may be omitted" or "omitting the middle term of a "?:" expression".  The operator is either a "conditional expression" or a "ternary operator".  And finally clang's warning is "use of GNU ?: expression extension, eliding middle term", making no mention of conditional, ternary or omitting.
>
> So far I chose ternary-eliding-expression and gnu-ternary-eliding-expression, matching the behaviour of static-float-init  and gnu-static-float-init, since despite it being originally a GNU extension, now it's a clang extension.
>
> "conditional" is too vague.

I disagree - this is the conditional operator. It also happens to be
the only ternary operator in the C++ language, but that's more luck
than good management (there's no fundamental reason there couldn't be
other ternary operators).

If we don't have any other flags for specific gnu extension then we've
no precedent for whether such flags should start with "gnu", but I
tend to think they should.

I'd imagine "-Wgnu-binary-conditional-operator" might make sense. (or
just -Wgnu-binary-conditional ? Not sure. People can bikeshed this as
they like - if you pick something, it goes in, people can speak up if
they find it particularly wrong)

>  ternary-omitted-operand would be fine, but then I would change the warning in clang to "use of GNU ?: expression extension, omitting middle term" to match, and I wasn't sure I wanted to do that.  I kind of prefer this one, but it's a slightly larger change, and I don't know the consequences of changing a warning message might have, though I suppose the warning will change slightly anyway with the introduction of the specific flag.

Changing text is possible, if there's a clear improvement in
readability by doing so.

>  I'm not sure what clang documentation might refer to this feature - is that something to worry about as well?

Not generally - CLang doesn't have extensive documentation of its flags.

> > * this change needs tests.  You can model tests for this option based on this example:
> >
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-static-const-float.cpp?revision=173841&view=markup
> >
> > The new test file should go into the same directory as the example.
>
> Yep, coincidently, that is *exactly* the test I based it on, although I decided it needed to be in the Sema directory instead because it's not a C++ issue.
>
> Thanks,
>    Peter.
>
> --
> Keyboard Maestro 6.1 now out - set web checkboxes & radio buttons, exit from loops, and more.
>
> Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
> <http://www.stairways.com/>           <http://download.keyboardmaestro.com/>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list