1 /* Test operation of -Wparentheses. Precedence warnings. && inside
2 ||. */
3 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
4
5 /* { dg-do compile } */
6 /* { dg-options "-Wparentheses" } */
7
8 int foo (int);
9
10 int
bar(int a,int b,int c)11 bar (int a, int b, int c)
12 {
13 foo (a && b || c); /* { dg-warning "parentheses" "correct warning" } */
14 foo ((a && b) || c);
15 foo (a && (b || c));
16 foo (1 && 2 || c); /* { dg-warning "parentheses" "correct warning" } */
17 foo ((1 && 2) || c);
18 foo (1 && (2 || c));
19 foo (1 && 2 || 3); /* { dg-warning "parentheses" "correct warning" } */
20 foo ((1 && 2) || 3);
21 foo (1 && (2 || 3));
22 foo (a || b && c); /* { dg-warning "parentheses" "correct warning" } */
23 foo ((a || b) && c);
24 foo (a || (b && c));
25 foo (1 || 2 && c); /* { dg-warning "parentheses" "correct warning" } */
26 foo ((1 || 2) && c);
27 foo (1 || (2 && c));
28 foo (1 || 2 && 3); /* { dg-warning "parentheses" "correct warning" } */
29 foo ((1 || 2) && 3);
30 foo (1 || (2 && 3));
31 }
32