This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Wcomparison-fixed (try 2) (PR7651 Define -Wextra strictly in terms of other warning flags)


:ADDPATCH c/c++:

As part of the effort to fix PR7651 [1], I proposed a
Wfutile-unsigned-comparison option (enabled by -Wextra) to take over
the function of warning  about comparison of unsigned variables
against zero with < or >=. [2]

Gabriel Dos Reis replied that this switch should include an unnamed
warning for comparisons that are always true because of type range
limits. (This is the warning that RMS was talking about not so long ago).

The new Wcomparison-fixed option comprises those warnings. (The name
was first proposed by Joseph Myers in a comment of PR12963 [3])

PR 29694 and 23587 are about the inconsistency of having some warnings
in Wextra and others issued unconditionally. Thus, this patch fixes
those.

PR 11856 is about warning for templates. This patch is not a
definitive fix, since Gabriel Dos Reis thinks that we should not warn
at all,  but it is a partial fix, since at least it gives to the user
the option of disabling the warning (and it allows the use #pragma
machinery), instead of using -w.

PR 12963 asks for a way to disable the unconditional warning without
using -w. This patch fixes that.

I took testcases from the PRs, bootstrapped and regression tested with
--enable-languages=all for i686-pc-linux-gnu.

Ok for mainline?

Manuel.


[1] http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01103.html [2] http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01661.html [3] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963

2007-01-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>

 PR middle-end/7651
 PR c++/11856
 PR c/12963
 PR c/23587
 PR other/29694
 * c.opt (Wcomparison-fixed): New.
 * doc/invoke.texi (Wcomparison-fixed): Document it.
 (Wextra): Enabled by -Wextra.
 * c-opts.c (c_common_post_options): Enabled by -Wextra.
 * c-common.c (shorten_compare): Warn with Wcomparison-fixed.

testsuite/
2007-01-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

 PR middle-end/7651
 PR c++/11856
 PR c/12963
 PR c/23587
 PR other/29694
 * gcc.dg/compare6.c: Replace Wall with Wcomparison-fixed.
 * gcc.dg/Wcomparison-fixed.c: New.
 * gcc.dg/Wcomparison-fixed-Wextra.c: New.
 * gcc.dg/Wcomparison-fixed-no.c: New.
 * g++.dg/warn/Wcomparison-fixed.C: New.
 * g++.dg/warn/Wcomparison-fixed-Wextra.C: New.
 * g++.dg/warn/Wcomparison-fixed-no.C: New.

Attachment: wcomparison-fixed.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]