[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations

2015-07-23 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572

--- Comment #4 from Marek Polacek mpolacek at gcc dot gnu.org ---
Author: mpolacek
Date: Thu Jul 23 18:57:25 2015
New Revision: 226120

URL: https://gcc.gnu.org/viewcvs?rev=226120root=gccview=rev
Log:
PR c++/66572
* pt.c (tsubst_copy_and_build): Add warn_logical_op sentinel.

* g++.dg/warn/Wlogical-op-2.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wlogical-op-2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog


[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations

2015-07-23 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Marek Polacek mpolacek at gcc dot gnu.org ---
Fixed.


[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations

2015-06-17 Thread miyuki at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572

--- Comment #2 from Mikhail Maltsev miyuki at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #1)
 Why is it a regression?
Because GCC 5.1 and 4.9.2 do not issue such warning.

[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations

2015-06-17 Thread miyuki at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572

--- Comment #3 from Mikhail Maltsev miyuki at gcc dot gnu.org ---
Started with r222408. The commit message says:

PR c/63357
* c-common.c (warn_logical_operator): Warn if the operands have the same
expressions.
* doc/invoke.texi: Update description of -Wlogical-op.

Apperntly, the warning about same expressions in a logical expression was added
to Wlogical-op after GCC 5.1 release (I didn't know that) and it had this
problem from the very beginning.

In warn_logical_operator we have a check:

  /* We do not warn for constants because they are typical of macro
 expansions that test for features.  */
  if (CONSTANT_CLASS_P (op_left) || CONSTANT_CLASS_P (op_right))
return;

But in this case op_left and op_right are:
var_decl 0x76118bd0 value
type boolean_type 0x76263888 bool readonly public unsigned QI
size integer_cst 0x7610bf48 constant 8
unit size integer_cst 0x7610bf60 constant 1
align 8 symtab 0 alias set -1 canonical type 0x76263888 precision 1
min integer_cst 0x7612e1b0 0 max integer_cst 0x7612e1e0 1

I think it's still possible to fix this check to handle C++ boolean constants
properly (as if they were literal constants). But for general case we probably
must somehow know (e.g. add a new flag to enum tsubst_flags and pass it to
warn_logical_operator from build_new_op_1), that current expression depends on
template parameter.


[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations

2015-06-17 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-06-17
 CC||manu at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
Not idea how to fix it, but it seems logical that we should not warn. Why is it
a regression?