Message ID | 20170831121754.GH17069@redhat.com |
---|---|
State | New |
Headers | show |
Series | C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040) | expand |
On Thu, Aug 31, 2017 at 8:17 AM, Marek Polacek <polacek@redhat.com> wrote:
> + && (complain & tf_error)
This should be tf_warning.
OK with that change.
Jason
diff --git gcc/cp/typeck.c gcc/cp/typeck.c index 171c2dfb57c..b303ceaede1 100644 --- gcc/cp/typeck.c +++ 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_error) && warning_at (location, OPT_Wbool_operation, "%<~%> on an expression of type bool")) inform (location, "did you mean to use logical not (%<!%>)?"); diff --git gcc/testsuite/g++.dg/warn/Wbool-operation-1.C gcc/testsuite/g++.dg/warn/Wbool-operation-1.C index e69de29bb2d..4512b858287 100644 --- gcc/testsuite/g++.dg/warn/Wbool-operation-1.C +++ 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 <class c> +decltype (~c{}) +call () +{ + return ~false; // { dg-warning "on an expression of type bool" } +} +template int call<bool>();