This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFA: Implement -Wenum-compare for C
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 1 Apr 2009 10:54:49 +0200
- Subject: Re: PATCH RFA: Implement -Wenum-compare for C
- References: <m38wmlmdqz.fsf@google.com>
2009/4/1 Ian Lance Taylor <iant@google.com>:
>
> Is that patch OK to commit to mainline?
>
+ /* Warn about comparisons of different enum types. */
+ if (warn_enum_compare
+ && TREE_CODE_CLASS (code) == tcc_comparison
+ && TREE_CODE (type1) == ENUMERAL_TYPE
+ && TREE_CODE (type2) == ENUMERAL_TYPE
+ && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
+ warning (OPT_Wenum_compare,
+ "comparison between %qT and %qT",
+ type1, type2);
+
IMHO patches adding new warnings should use explicit locations where
possible (warning_at), particularly if the correct location is
available. (I am not sure about the latter in this case because the
patch does not use "diff -p". In any case, even warning_at
(input_location) should be always better than warning().
Cheers,
Manuel.