[PATCH] D58841: [Diagnostics] Support -Wtype-limits for GCC compatibility

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 1 12:44:19 PST 2019

lebedev.ri added inline comments.

Comment at: clang/include/clang/Basic/DiagnosticGroups.td:485
+// For compatibility with GCC; -Wtype-limits = -Wtautological-constant-in-range-compare
+def TypeLimits : DiagGroup<"type-limits", [TautologicalInRangeCompare]>;
 def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
xbolva00 wrote:
> lebedev.ri wrote:
> > Is gcc's `-Wtype-limits` *just* `-Wtautological-constant-in-range-compare`, or is something else should be there?
> -Wtautological-constant-in-range-compare is enough to diagnose 99% cases from:
> https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/gcc/testsuite/g%2B%2B.dg/warn/Wtype-limits.C
> One missed case is:
> int test (int x) 
> {
>   if ((long long)x <= 0x123456789ABCLL)
>     return 1;
>   else 
>     return 0;
> }
> Tried -Weverything, no help. We miss this case. I will open PR for that.
> But anyway, this missed case should not block this patch.
> -Wtautological-constant-in-range-compare is enough to diagnose 99% cases from:

That doesn't really answer the question.
I'm sure that *adding* `-Wtautological-constant-in-range-compare` helps.
But what about the other way around?
Does passing `-Wno-type-limits` silence *all* the expected diags in that file?



More information about the cfe-commits mailing list