]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/62199 (ICE with -Wlogical-not-parentheses)
authorMarek Polacek <polacek@redhat.com>
Fri, 22 Aug 2014 19:44:27 +0000 (19:44 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 22 Aug 2014 19:44:27 +0000 (19:44 +0000)
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.

From-SVN: r214360

13 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr62199-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr62199.c [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wparentheses-25.C

index 2b78565a070a296bf0f861f761ffea74fa69877b..caa40b37f2fa8760eb948cba86d707681c9fed75 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/62199
+       * doc/invoke.texi: Update -Wlogical-not-parentheses description.
+
 2014-08-22  Marek Polacek  <polacek@redhat.com>
 
        PR c/61271
index 3bc50ef25261e31868c391172374f472d4afb0c5..4042306398d2b9b146d754151aae8b5884f748b5 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/62199
+       * 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.
+
 2014-08-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * c.opt (Wcomment): Use CPP, Var and LangEnabledBy.
index c5eb2a773e619dd84ea572dcfbba701ce791fca1..58b976378d5e14e23707a5aa81fc63fed1d6947c 100644 (file)
@@ -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,
index 995bc8ca50ed9f04a4d08859e842fbd1203b25b1..20b65e99663ac2cb2d956c363305f76a0d890cb5 100644 (file)
@@ -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);
index 77bc05bbcca40003ff13a64351a7505f14663b4e..00fb275613e61a21acd68abb9fa89afa47c4f366 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/62199
+       * c-typeck.c (parser_build_binary_op): Adjust call to
+       warn_logical_not_parentheses.
+
 2014-08-22  Igor Zamyatin  <igor.zamyatin@intel.com>
 
        PR other/62008
index d6d96cf3550f1adc29f3fce917034a049e2195dc..a7de8f3c7343d252ffc4c513c59b332b6807a252 100644 (file)
@@ -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.  */
index 2ea266539017debcbcc973920405cc72332053af..b71dcba151f0078ca0014fbe6cd958f16f945a43 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/62199
+       * parser.c (cp_parser_binary_expression): Check each LHS if it's
+       preceded with logical not.  Adjust call to
+       warn_logical_not_parentheses.
+
 2014-08-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c++/57709
index 9053bfa62e56876ab6889e9b63368090a471499f..4dc7c33cb337ae039057df0d42be3c86573fa154 100644 (file)
@@ -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 ==
index f8499bc046a68ef34871d874aadfe0bd3fb6d398..dda8e91250cd689e55da3f38bc187bca2ebb56f7 100644 (file)
@@ -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{}
index ce3e30e3572f33a7140364a20ff4a5dcfbbe011a..9f40c35c15965b9d70dc8311f18757978d03f93a 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/62199
+       * c-c++-common/pr62199.c: New test.
+       * c-c++-common/pr62199-2.c: New test.
+       * g++.dg/warn/Wparentheses-25.C: Drop XFAILs.
+
 2014-08-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c++/57709
diff --git a/gcc/testsuite/c-c++-common/pr62199-2.c b/gcc/testsuite/c-c++-common/pr62199-2.c
new file mode 100644 (file)
index 0000000..7647f16
--- /dev/null
@@ -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 a/gcc/testsuite/c-c++-common/pr62199.c b/gcc/testsuite/c-c++-common/pr62199.c
new file mode 100644 (file)
index 0000000..51078c8
--- /dev/null
@@ -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" } */
+}
index ab00c25f02a2d59ad8eaa70ca6f7a8684cb16db1..d9951a4f46b620ad9bad8284547586afe9995a53 100644 (file)
@@ -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);