From patchwork Fri Aug 22 18:45:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 382321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A08721400D7 for ; Sat, 23 Aug 2014 04:45:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=an+w4RGWkQURPj8nu tRbHGa7G9mYgHYazl1f7XHv+5ZBGPCRW/E6QCX3eo0TnhA6N0J0HSHfwjEKrWiM8 L7PjgEf6BtwFYgPju0Sv/TJUQqh5GcmBR7oS+PfyAOMkef+6xVbcU+nqSLMIuM3U /5yn3YuTiuKEx3Hb9qa+4GE0NM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=zF9KI8eXbySUFHfqoT9IWdt eQUE=; b=hRl5AXSjwM9j0kDb8KXwrzn9fE7K0yzrHliUTLTGhCIwbyJZOhzW++r j6lqoRXy8lTFMjY1tVV79C7fqS2KMDaGUx58rkG9xiq4vObXQIfBl7N6qLWauKyZ RgKOnyg7QRWaEru+XKZmf5yyoMe0xitI6yFX0h1cLrEsZLNYDsOc= Received: (qmail 28110 invoked by alias); 22 Aug 2014 18:45:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28099 invoked by uid 89); 22 Aug 2014 18:45:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 22 Aug 2014 18:45:38 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7MIjbIg024050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Aug 2014 14:45:37 -0400 Received: from redhat.com (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7MIjXPX024929 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 22 Aug 2014 14:45:36 -0400 Date: Fri, 22 Aug 2014 20:45:33 +0200 From: Marek Polacek To: Jason Merrill Cc: Paolo Carlini , GCC Patches Subject: Re: [C++ PATCH] Fix -Wlogical-not-parentheses (PR c++/62199) Message-ID: <20140822184532.GF15033@redhat.com> References: <20140820200252.GO14320@redhat.com> <53F50CE0.5010305@redhat.com> <20140821154125.GS14320@redhat.com> <53F63BCE.4050006@redhat.com> <20140822144848.GB15033@redhat.com> <53F75981.3020401@oracle.com> <20140822155914.GD15033@redhat.com> <53F76EB0.7000507@redhat.com> <20140822163357.GE15033@redhat.com> <53F77563.30301@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <53F77563.30301@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) On Fri, Aug 22, 2014 at 12:52:51PM -0400, Jason Merrill wrote: > On 08/22/2014 12:33 PM, Marek Polacek wrote: > >On Fri, Aug 22, 2014 at 12:24:16PM -0400, Jason Merrill wrote: > >>Sorry to nitpick, but now that we aren't checking the lhs for BOOLEAN_TYPE, > >>do we need to look at it at all? > > > >I believe so: if the LHS is an INTEGER_CST, we can't use TREE_OPERAND > >on it. Happens e.g. for if (!5 > a). > > Yes, but why do we want to use TREE_OPERAND on it? Oh yeah, seems that we don't need that. Actually, I think we can take this one step further: since we can't use unary ! on a vector, we can drop the VECTOR_TYPE checks, meaning that we don't need the lhs parameter at all! What do you say? Bootstrapped/regtested on x86_64-linux. 2014-08-22 Marek Polacek PR c++/62199 * doc/invoke.texi: Update -Wlogical-not-parentheses description. c-family/ * c-common.c (warn_logical_not_parentheses): Don't check LHS. Don't check for vector types. Drop LHS argument. * c-common.h (warn_logical_not_parentheses): Adjust. c/ * c-typeck.c (parser_build_binary_op): Adjust call to warn_logical_not_parentheses. cp/ * parser.c (cp_parser_binary_expression): Check each LHS if it's preceded with logical not. Adjust call to warn_logical_not_parentheses. testsuite/ * c-c++-common/pr62199.c: New test. * c-c++-common/pr62199-2.c: New test. * g++.dg/warn/Wparentheses-25.C: Drop XFAILs. Marek diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index c5eb2a7..58b9763 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -1727,21 +1727,15 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, /* Warn about logical not used on the left hand side operand of a comparison. This function assumes that the LHS is inside of TRUTH_NOT_EXPR. - Do not warn if the LHS or RHS is of a boolean or a vector type. */ + Do not warn if RHS is of a boolean type. */ void warn_logical_not_parentheses (location_t location, enum tree_code code, - tree lhs, tree rhs) + tree rhs) { - if (TREE_CODE_CLASS (code) != tcc_comparison) - return; - if (TREE_TYPE (lhs) == NULL_TREE - || TREE_TYPE (rhs) == NULL_TREE) - ; - else if (TREE_CODE (TREE_TYPE (lhs)) == BOOLEAN_TYPE - || TREE_CODE (TREE_TYPE (rhs)) == BOOLEAN_TYPE - || VECTOR_TYPE_P (TREE_TYPE (lhs)) - || VECTOR_TYPE_P (TREE_TYPE (rhs))) + if (TREE_CODE_CLASS (code) != tcc_comparison + || TREE_TYPE (rhs) == NULL_TREE + || TREE_CODE (TREE_TYPE (rhs)) == BOOLEAN_TYPE) return; warning_at (location, OPT_Wlogical_not_parentheses, diff --git gcc/c-family/c-common.h gcc/c-family/c-common.h index 995bc8c..20b65e9 100644 --- gcc/c-family/c-common.h +++ gcc/c-family/c-common.h @@ -780,8 +780,7 @@ extern void overflow_warning (location_t, tree); extern bool warn_if_unused_value (const_tree, location_t); extern void warn_logical_operator (location_t, enum tree_code, tree, enum tree_code, tree, enum tree_code, tree); -extern void warn_logical_not_parentheses (location_t, enum tree_code, tree, - tree); +extern void warn_logical_not_parentheses (location_t, enum tree_code, tree); extern void check_main_parameter_types (tree decl); extern bool c_determine_visibility (tree); extern bool vector_types_compatible_elements_p (tree, tree); diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index d6d96cf..a7de8f3 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -3414,7 +3414,7 @@ parser_build_binary_op (location_t location, enum tree_code code, if (warn_logical_not_paren && code1 == TRUTH_NOT_EXPR && code2 != TRUTH_NOT_EXPR) - warn_logical_not_parentheses (location, code, arg1.value, arg2.value); + warn_logical_not_parentheses (location, code, arg2.value); /* Warn about comparisons against string literals, with the exception of testing for equality or inequality of a string literal with NULL. */ diff --git gcc/cp/parser.c gcc/cp/parser.c index 9053bfa..4dc7c33 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -8020,13 +8020,12 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, enum tree_code rhs_type; enum cp_parser_prec new_prec, lookahead_prec; tree overload; - bool parenthesized_not_lhs_warn - = cp_lexer_next_token_is (parser->lexer, CPP_NOT); /* Parse the first expression. */ + current.lhs_type = (cp_lexer_next_token_is (parser->lexer, CPP_NOT) + ? TRUTH_NOT_EXPR : ERROR_MARK); current.lhs = cp_parser_cast_expression (parser, /*address_p=*/false, cast_p, decltype_p, pidk); - current.lhs_type = ERROR_MARK; current.prec = prec; if (cp_parser_error_occurred (parser)) @@ -8081,8 +8080,9 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, /* Extract another operand. It may be the RHS of this expression or the LHS of a new, higher priority expression. */ + rhs_type = (cp_lexer_next_token_is (parser->lexer, CPP_NOT) + ? TRUTH_NOT_EXPR : ERROR_MARK); rhs = cp_parser_simple_cast_expression (parser); - rhs_type = ERROR_MARK; /* Get another operator token. Look up its precedence to avoid building a useless (immediately popped) stack entry for common @@ -8125,9 +8125,8 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, c_inhibit_evaluation_warnings -= current.lhs == truthvalue_true_node; if (warn_logical_not_paren - && parenthesized_not_lhs_warn) - warn_logical_not_parentheses (current.loc, current.tree_type, - TREE_OPERAND (current.lhs, 0), rhs); + && current.lhs_type == TRUTH_NOT_EXPR) + warn_logical_not_parentheses (current.loc, current.tree_type, rhs); overload = NULL; /* ??? Currently we pass lhs_type == ERROR_MARK and rhs_type == diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index f8499bc..dda8e91 100644 --- gcc/doc/invoke.texi +++ gcc/doc/invoke.texi @@ -4776,8 +4776,8 @@ bit-wise operator is likely to be expected. @opindex Wlogical-not-parentheses @opindex Wno-logical-not-parentheses Warn about logical not used on the left hand side operand of a comparison. -This option does not warn if the LHS or RHS operand is of a boolean or -a vector type. Its purpose is to detect suspicious code like the following: +This option does not warn if the RHS operand is of a boolean type. Its +purpose is to detect suspicious code like the following: @smallexample int a; @dots{} diff --git gcc/testsuite/c-c++-common/pr62199-2.c gcc/testsuite/c-c++-common/pr62199-2.c index e69de29..7647f16 100644 --- gcc/testsuite/c-c++-common/pr62199-2.c +++ gcc/testsuite/c-c++-common/pr62199-2.c @@ -0,0 +1,20 @@ +/* PR c++/62199 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-not-parentheses" } */ + +#ifndef __cplusplus +# define bool _Bool +#endif + +bool r; + +void +foo (bool b) +{ + r = !b == 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + r = !b != 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + r = !b > 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + r = !b >= 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + r = !b < 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + r = !b <= 1; /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ +} diff --git gcc/testsuite/c-c++-common/pr62199.c gcc/testsuite/c-c++-common/pr62199.c index e69de29..51078c8 100644 --- gcc/testsuite/c-c++-common/pr62199.c +++ gcc/testsuite/c-c++-common/pr62199.c @@ -0,0 +1,22 @@ +/* PR c++/62199 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-not-parentheses" } */ + +int r; +void +foo (int a) +{ + r = a > 0 || !a >= 2; /* { dg-warning "19:logical not is only applied to the left hand side of comparison" } */ + r = !a || a == 10; + r = !a && !a < 4; /* { dg-warning "16:logical not is only applied to the left hand side of comparison" } */ + r = !a > 0 && a < 6; /* { dg-warning "10:logical not is only applied to the left hand side of comparison" } */ + r = a + (!a < 12); /* { dg-warning "15:logical not is only applied to the left hand side of comparison" } */ + r = a == 7 || !a < 12; /* { dg-warning "20:logical not is only applied to the left hand side of comparison" } */ + r = (a == 7 * a > 0) || !a < 2; /* { dg-warning "30:logical not is only applied to the left hand side of comparison" } */ + r = (1 > !a) || (!42 > a); /* { dg-warning "24:logical not is only applied to the left hand side of comparison" } */ + r = (!5 > a); /* { dg-warning "11:logical not is only applied to the left hand side of comparison" } */ + r = (!0 > a); /* { dg-warning "11:logical not is only applied to the left hand side of comparison" } */ + r = (!-5 > a); /* { dg-warning "12:logical not is only applied to the left hand side of comparison" } */ + r = (!(5 + 3) > a); /* { dg-warning "17:logical not is only applied to the left hand side of comparison" } */ + r = (!(5 - a) > a); /* { dg-warning "17:logical not is only applied to the left hand side of comparison" } */ +} diff --git gcc/testsuite/g++.dg/warn/Wparentheses-25.C gcc/testsuite/g++.dg/warn/Wparentheses-25.C index ab00c25..d9951a4 100644 --- gcc/testsuite/g++.dg/warn/Wparentheses-25.C +++ gcc/testsuite/g++.dg/warn/Wparentheses-25.C @@ -8,7 +8,7 @@ int foo (int); int bar (int a, int b, int c) { - foo (!a & b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a & b); /* { dg-warning "parentheses" "correct warning" } */ foo (!a & (b < c)); foo (!a & (b > c)); foo (!a & (b == c)); @@ -20,7 +20,7 @@ bar (int a, int b, int c) foo (!a & !b); foo (!(a & b)); foo ((!a) & b); - foo (!a & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!a & (2 < c)); foo (!a & (2 > c)); foo (!a & (2 == c)); @@ -32,7 +32,7 @@ bar (int a, int b, int c) foo (!a & !2); foo (!(a & 2)); foo ((!a) & 2); - foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!1 & (2 < c)); foo (!1 & (2 > c)); foo (!1 & (2 == c)); @@ -44,7 +44,7 @@ bar (int a, int b, int c) foo (!1 & !2); foo (!(1 & 2)); - foo (!a | b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a | b); /* { dg-warning "parentheses" "correct warning" } */ foo (!a | (b < c)); foo (!a | (b > c)); foo (!a | (b == c)); @@ -56,7 +56,7 @@ bar (int a, int b, int c) foo (!a | !b); foo (!(a | b)); foo ((!a) | b); - foo (!a | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a | 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!a | (2 < c)); foo (!a | (2 > c)); foo (!a | (2 == c)); @@ -68,7 +68,7 @@ bar (int a, int b, int c) foo (!a | !2); foo (!(a | 2)); foo ((!a) | 2); - foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" } */ foo (!1 | (2 < c)); foo (!1 | (2 > c)); foo (!1 | (2 == c)); @@ -159,55 +159,55 @@ bar (int a, int b, int c) int baz (int a, int b, int c) { - foo (!a & (b << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & 2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ - foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" { xfail *-*-* } } */ + foo (!a & (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ foo ((b << c) & !a); foo ((b >> c) & !a); foo ((b + c) & !a);