From: Marek Polacek Date: Fri, 1 Sep 2017 09:22:57 +0000 (+0000) Subject: re PR c++/82040 (ICE with -Wbool-operation and ~) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8dc9277a90672a0b2d5a18bd989c6d99ca362746;p=gcc.git re PR c++/82040 (ICE with -Wbool-operation and ~) 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4a791ddbbb4..e27f04c2b65 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-09-01 Marek Polacek + + PR c++/82040 + * typeck.c (cp_build_unary_op): Avoid re-entering reporting routines. + 2017-08-30 Jason Merrill PR c++/82029 - __PRETTY_FUNCTION__ in lambda in template diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 171c2dfb57c..0a09998aa21 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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 (%)?"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cd63ace8250..7e9f1591b51 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,12 @@ +2017-09-01 Marek Polacek + + PR c++/82040 + * g++.dg/warn/Wbool-operation-1.C: New test. + 2017-08-31 Claudiu Zissulescu * 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 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 index 00000000000..4512b858287 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C @@ -0,0 +1,11 @@ +// PR c++/82040 +// { dg-do compile { target c++11 } } +// { dg-options "-Wbool-operation" } + +template +decltype (~c{}) +call () +{ + return ~false; // { dg-warning "on an expression of type bool" } +} +template int call();