re PR c++/66572 (Bogus Wlogical-op warning for operands coming from template instanti...
authorMarek Polacek <polacek@redhat.com>
Thu, 23 Jul 2015 18:57:25 +0000 (18:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 23 Jul 2015 18:57:25 +0000 (18:57 +0000)
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
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wlogical-op-2.C [new file with mode: 0644]

index 7626492934a23d366ca354989e6c11f93deea7ef..51766ea4960b71377b543a2b212a8430873b028e 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/66572
+       * pt.c (tsubst_copy_and_build): Add warn_logical_op sentinel.
+
 2015-07-23  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/52987
index 95ec376430a41a6320ac97d0d78f4634a3b6e4a4..5004883a63e2811730c0e52f163599b386c5ce6e 100644 (file)
@@ -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
index 8c6d7e17c2a3001502285c994c4b4aced0260d5a..6bbc2e654914146cb9ac4b0541e2365bd7d2f973 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/66572
+       * g++.dg/warn/Wlogical-op-2.C: New test.
+
 2015-07-23  Alexandre Oliva <aoliva@redhat.com>
 
        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 (file)
index 0000000..755db08
--- /dev/null
@@ -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<typename T>
+struct is_unsigned : false_type {};
+
+template<>
+struct is_unsigned<unsigned> : true_type {};
+
+template<typename T1, typename T2>
+bool foo()
+{
+    return is_unsigned<T1>::value && is_unsigned<T2>::value;
+}
+
+int main()
+{
+    foo<unsigned, unsigned>();
+}