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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 05:34:38 PDT 2019


aaron.ballman added a comment.

I worry a little bit about our -Wtype-limits getting out of sync from GCC's due to making it a synonym for -Wtautological-constant-in-range-compare, but I'm also at a loss for why these two should ever have different functionality.

I think I'm okay with this, but I'd like @rsmith to weigh in as well.



================
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:
> > 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?
> Yes, silences it correctly.
Thoughts about why we behave differently here: https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/gcc/testsuite/g%2B%2B.dg/warn/Wtype-limits2.C


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58841/new/

https://reviews.llvm.org/D58841





More information about the cfe-commits mailing list