re PR c++/82040 (ICE with -Wbool-operation and ~)
authorMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 1 Sep 2017 09:22:57 +0000 (09:22 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 1 Sep 2017 09:22:57 +0000 (09:22 +0000)
PR c++/82040
* typeck.c (cp_build_unary_op): Avoid re-entering reporting routines.

* g++.dg/warn/Wbool-operation-1.C: New test.

From-SVN: r251581

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wbool-operation-1.C [new file with mode: 0644]

index 4a791ddbbb4be60b29af5f713f1a85cbf630b823..e27f04c2b655ebb7b981f3fed950f0ed497304f6 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/82040
+       * typeck.c (cp_build_unary_op): Avoid re-entering reporting routines.
+
 2017-08-30  Jason Merrill  <jason@redhat.com>
 
        PR c++/82029 - __PRETTY_FUNCTION__ in lambda in template
index 171c2dfb57c047e7e031845942890f4f4cd5dcbb..0a09998aa21b94828739e758cb078a03cac69d30 100644 (file)
@@ -5982,6 +5982,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
        {
          /* Warn if the expression has boolean value.  */
          if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE
+             && (complain & tf_warning)
              && warning_at (location, OPT_Wbool_operation,
                             "%<~%> on an expression of type bool"))
            inform (location, "did you mean to use logical not (%<!%>)?");
index cd63ace82501a13380d63dadc2b08777eb5c203a..7e9f1591b5140bfa6bfeebb6c529dc4ea3b6ab97 100644 (file)
@@ -1,7 +1,12 @@
+2017-09-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/82040
+       * g++.dg/warn/Wbool-operation-1.C: New test.
+
 2017-08-31  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * gcc.target/arc/sdata-5.c: New test.
-        * gcc.target/arc/arc700-stld-hazard.c: Update test options.
+       * gcc.target/arc/arc700-stld-hazard.c: Update test options.
 
 2017-08-31  Claudiu Zissulescu  <claziss@synopsys.com>
 
diff --git a/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C b/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C
new file mode 100644 (file)
index 0000000..4512b85
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/82040
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wbool-operation" }
+
+template <class c>
+decltype (~c{})
+call ()
+{
+  return ~false; // { dg-warning "on an expression of type bool" }
+}
+template int call<bool>();