* C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040)
@ 2017-08-31 14:03 Marek Polacek
2017-08-31 18:57 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2017-08-31 14:03 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
Here we got into re-entering the error reporting routines because the
warning_at call wasn't guarded with "complain", and crash ensued.
Bootstrapped/regtested on x86_64-linux, ok for trunk/7?
2017-08-31 Marek Polacek <polacek@redhat.com>
PR c++/82040
* typeck.c (cp_build_unary_op): Avoid re-entering reporting routines.
* g++.dg/warn/Wbool-operation-1.C: New test.
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>();
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040)
2017-08-31 14:03 C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040) Marek Polacek
@ 2017-08-31 18:57 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-08-31 18:57 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-31 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31 14:03 C++ PATCH to fix ICE with -Wbool-operation (PR c++/82040) Marek Polacek
2017-08-31 18:57 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).