[Bug c++/79919] Warning specifies end of method rather than the correct line

2017-03-13 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79919

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #1 from Martin Sebor  ---
There also is no option to control this warning, and outside of pr16302.{C,c}
no tests for it.  It seems that a good option to put this warning under might
be -Wlogical-op.  The text of the warning could also be made consistent with
that issued by the option, i.e., like so (copied from c-family/c-warn.c):

  if (or_op)
warning_at (location, OPT_Wlogical_op,
"logical % of collectively exhaustive tests is "
"always true");
  else
warning_at (location, OPT_Wlogical_op,
"logical % of mutually exclusive tests is "
"always false");

The implementation of the warning issued for the test case is in fold-const.c:

  /* Handle the case of comparisons with constants.  If there is something in
 common between the masks, those bits of the constants must be the same.
 If not, the condition is always false.  Test for this to avoid generating
 incorrect code below.  */
  result = const_binop (BIT_AND_EXPR, ll_mask, rl_mask);
  if (! integer_zerop (result)
  && simple_cst_equal (const_binop (BIT_AND_EXPR, result, l_const),
   const_binop (BIT_AND_EXPR, result, r_const)) != 1)
{
  if (wanted_code == NE_EXPR)
{
  warning (0, "% of unmatched not-equal tests is always 1");
  return constant_boolean_node (true, truth_type);
}
  else
{
  warning (0, "% of mutually exclusive equal-tests is always 0");
  return constant_boolean_node (false, truth_type);
}
}

[Bug c++/79919] Warning specifies end of method rather than the correct line

2017-03-07 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79919

Paolo Carlini  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-03-07
 Ever confirmed|0   |1