On 2/6/19 9:23 PM, David Malcolm wrote:
PR c++/88680 reports excess warnings from -Wtype-limits after the C++
FE's use of location wrappers was extended in r267272 for cases such as:

   const unsigned n = 8;
   static_assert (n >= 0 && n % 2 == 0, "");

t.C:3:18: warning: comparison of unsigned expression >= 0 is always true
   [-Wtype-limits]
     3 | static_assert (n >= 0 && n % 2 == 0, "");
       |                ~~^~~~

The root cause is that the location wrapper around "n" breaks the
suppression of the warning for the "if OP0 is a constant that is >= 0"
case.

This patch fixes it by calling fold_for_warn on OP0, extracting the
constant.

Is there a reason not to do this for OP1 as well?

Jason

Reply via email to