This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add -Womitted-conditional-op warning
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andi Kleen <ak at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Feb 2007 17:57:27 +0000 (UTC)
- Subject: Re: [PATCH] Add -Womitted-conditional-op warning
- References: <200702021802.59563.ak@suse.de>
On Fri, 2 Feb 2007, Andi Kleen wrote:
> I implemented a warning for this case. I guess it's relatively obscure, but will
> not hurt. The warning is enabled by default, but can be disabled with
> -Wno-omitted-conditional-op.
This extension seems like one that could be used in macros in system
headers and so maybe the warning should be disabled by __extension__ (for
C, see disable_extension_diagnostics / restore_extension_diagnostics).
Or do you think that the particular cases you warn for are never going to
arise from macros (given those could be replaced by ... ? 1 : ...)?
> +@item -Wno-omitted-conditional-op
> +@opindex Wno-omitted-conditional-op
> +Don't warn for dangerous uses of the
> +?: with omitted middle operand GNU extension. When the condition
> +in the ?: operator is a computed boolean the omitted value will
> +be always 1. Often the user expects it to be a value computed
> +inside the conditional expression instead. Gcc by default warns
> +for this, but this option disables it.
Two spaces after "." at end of sentence in Texinfo. "GCC" not "Gcc". Use
@code or @samp around "?:". Include a cross-reference to the section of
the manual documenting this extension.
--
Joseph S. Myers
joseph@codesourcery.com