From 04e4dbd07cd613e086488a735d25e05ae939e117 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 23 Jul 2015 18:57:25 +0000 Subject: [PATCH] re PR c++/66572 (Bogus Wlogical-op warning for operands coming from template instantiations) PR c++/66572 * pt.c (tsubst_copy_and_build): Add warn_logical_op sentinel. * g++.dg/warn/Wlogical-op-2.C: New test. From-SVN: r226120 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/pt.c | 1 + gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/warn/Wlogical-op-2.C | 30 +++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/Wlogical-op-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7626492934a..51766ea4960 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-07-23 Marek Polacek + + PR c++/66572 + * pt.c (tsubst_copy_and_build): Add warn_logical_op sentinel. + 2015-07-23 Paolo Carlini PR c++/52987 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 95ec376430a..5004883a63e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14917,6 +14917,7 @@ tsubst_copy_and_build (tree t, { warning_sentinel s1(warn_type_limits); warning_sentinel s2(warn_div_by_zero); + warning_sentinel s3(warn_logical_op); tree op0 = RECUR (TREE_OPERAND (t, 0)); tree op1 = RECUR (TREE_OPERAND (t, 1)); tree r = build_x_binary_op diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c6d7e17c2a..6bbc2e65491 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-23 Marek Polacek + + PR c++/66572 + * g++.dg/warn/Wlogical-op-2.C: New test. + 2015-07-23 Alexandre Oliva PR rtl-optimization/64164 diff --git a/gcc/testsuite/g++.dg/warn/Wlogical-op-2.C b/gcc/testsuite/g++.dg/warn/Wlogical-op-2.C new file mode 100644 index 00000000000..755db08e7fb --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wlogical-op-2.C @@ -0,0 +1,30 @@ +// PR c++/66572 +// { dg-do compile { target c++11 } } +// { dg-options "-Wlogical-op" } + +struct false_type +{ + static constexpr bool value = false; +}; + +struct true_type +{ + static constexpr bool value = true; +}; + +template +struct is_unsigned : false_type {}; + +template<> +struct is_unsigned : true_type {}; + +template +bool foo() +{ + return is_unsigned::value && is_unsigned::value; +} + +int main() +{ + foo(); +} -- 2.30.2