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]

Re: PATCH RFA: Implement -Wenum-compare for C


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.


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