This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: Jason Merrill <jason at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>
- Date: Tue, 18 Oct 2016 17:04:15 +0000
- Subject: Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops
- Authentication-results: sourceware.org; auth=none
- Authentication-results: trippelsdorf.de; dkim=none (message not signed) header.d=none;trippelsdorf.de; dmarc=none action=none header.from=hotmail.de;
- References: <87fuol77ri.fsf@mid.deneb.enyo.de> <HE1PR0701MB21694CB05881916BDFF3A251E4CC0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <CADzB+2n085rFdKy5AQuffwjnGOYMdR0zNzbbKJGJT+KrXUdFHA@mail.gmail.com> <HE1PR0701MB21692B89F7F6754AB32594EEE4CC0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <CADzB+2=pWuj6AUQFKAbc=f+pq616+Gx6tCNwzPU_e4Dp84PY4g@mail.gmail.com> <AM4PR0701MB2162EC708CAF70C79B380A62E4CF0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <CADzB+2kzJk5N5RctXS_SM1b2FKH8R8hAkbXK7RxzEtNaD2iqPg@mail.gmail.com> <AM4PR0701MB216289DC52D6AA7A184F9821E4CE0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <20161017152304.GA303@x4> <AM4PR0701MB2162DD1776443BDB025492A7E4D00@AM4PR0701MB2162.eurprd07.prod.outlook.com> <20161017171124.GB303@x4> <AM4PR0701MB2162458A7F27D68C8AF290D8E4D00@AM4PR0701MB2162.eurprd07.prod.outlook.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi,
this restricts the -Wint-in-bool-context warning to signed shifts,
to reduce the number of false positives Markus reported yesterday.
Bootstrap and reg-testing on x86_64-pc-linux-gnu was fine.
Is it OK for trunk?
Thanks
Bernd.
2016-10-17 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-common.c (c_common_truthvalue_conversion): Warn only for signed
integer shift ops in boolean context.
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c (revision 241270)
+++ gcc/c-family/c-common.c (working copy)
@@ -3328,8 +3328,10 @@
TREE_OPERAND (expr, 0));
case LSHIFT_EXPR:
- warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
- "<< in boolean context, did you mean '<' ?");
+ if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
+ && !TYPE_UNSIGNED (TREE_TYPE (expr)))
+ warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
+ "<< in boolean context, did you mean '<' ?");
break;
case COND_EXPR: