| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-Wparentheses" } |
| 3 |
|
| 4 |
// Template version of Wparentheses-9.C. |
| 5 |
|
| 6 |
int foo (int); |
| 7 |
|
| 8 |
template<class T> |
| 9 |
void |
| 10 |
bar (T a, T b, T c) |
| 11 |
{ |
| 12 |
foo (a & b | c); // { dg-warning "parentheses" "correct warning" } |
| 13 |
foo ((a & b) | c); |
| 14 |
foo (a & (b | c)); |
| 15 |
foo (1 & 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 16 |
foo ((1 & 2) | c); |
| 17 |
foo (1 & (2 | c)); |
| 18 |
foo (1 & 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 19 |
foo ((1 & 2) | 3); |
| 20 |
foo (1 & (2 | 3)); |
| 21 |
foo (a | b & c); // { dg-warning "parentheses" "correct warning" } |
| 22 |
foo ((a | b) & c); |
| 23 |
foo (a | (b & c)); |
| 24 |
foo (1 | 2 & c); // { dg-warning "parentheses" "correct warning" } |
| 25 |
foo ((1 | 2) & c); |
| 26 |
foo (1 | (2 & c)); |
| 27 |
foo (1 | 2 & 3); // { dg-warning "parentheses" "correct warning" } |
| 28 |
foo ((1 | 2) & 3); |
| 29 |
foo (1 | (2 & 3)); |
| 30 |
foo (a ^ b | c); // { dg-warning "parentheses" "correct warning" } |
| 31 |
foo ((a ^ b) | c); |
| 32 |
foo (a ^ (b | c)); |
| 33 |
foo (1 ^ 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 34 |
foo ((1 ^ 2) | c); |
| 35 |
foo (1 ^ (2 | c)); |
| 36 |
foo (1 ^ 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 37 |
foo ((1 ^ 2) | 3); |
| 38 |
foo (1 ^ (2 | 3)); |
| 39 |
foo (a | b ^ c); // { dg-warning "parentheses" "correct warning" } |
| 40 |
foo ((a | b) ^ c); |
| 41 |
foo (a | (b ^ c)); |
| 42 |
foo (1 | 2 ^ c); // { dg-warning "parentheses" "correct warning" } |
| 43 |
foo ((1 | 2) ^ c); |
| 44 |
foo (1 | (2 ^ c)); |
| 45 |
foo (1 | 0x2 ^ 3); // { dg-warning "parentheses" "correct warning" } |
| 46 |
foo ((1 | 2) ^ 3); |
| 47 |
foo (1 | (0x2 ^ 3)); |
| 48 |
foo (a + b | c); // { dg-warning "parentheses" "correct warning" } |
| 49 |
foo ((a + b) | c); |
| 50 |
foo (a + (b | c)); |
| 51 |
foo (1 + 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 52 |
foo ((1 + 2) | c); |
| 53 |
foo (1 + (2 | c)); |
| 54 |
foo (1 + 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 55 |
foo ((1 + 2) | 3); |
| 56 |
foo (1 + (2 | 3)); |
| 57 |
foo (a | b + c); // { dg-warning "parentheses" "correct warning" } |
| 58 |
foo ((a | b) + c); |
| 59 |
foo (a | (b + c)); |
| 60 |
foo (1 | 2 + c); // { dg-warning "parentheses" "correct warning" } |
| 61 |
foo ((1 | 2) + c); |
| 62 |
foo (1 | (2 + c)); |
| 63 |
foo (1 | 2 + 3); // { dg-warning "parentheses" "correct warning" } |
| 64 |
foo ((1 | 2) + 3); |
| 65 |
foo (1 | (2 + 3)); |
| 66 |
foo (a - b | c); // { dg-warning "parentheses" "correct warning" } |
| 67 |
foo ((a - b) | c); |
| 68 |
foo (a - (b | c)); |
| 69 |
foo (1 - 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 70 |
foo ((1 - 2) | c); |
| 71 |
foo (1 - (2 | c)); |
| 72 |
foo (1 - 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 73 |
foo ((1 - 2) | 3); |
| 74 |
foo (1 - (2 | 3)); |
| 75 |
foo (a | b - c); // { dg-warning "parentheses" "correct warning" } |
| 76 |
foo ((a | b) - c); |
| 77 |
foo (a | (b - c)); |
| 78 |
foo (1 | 2 - c); // { dg-warning "parentheses" "correct warning" } |
| 79 |
foo ((1 | 2) - c); |
| 80 |
foo (1 | (2 - c)); |
| 81 |
foo (1 | 2 - 3); // { dg-warning "parentheses" "correct warning" } |
| 82 |
foo ((1 | 2) - 3); |
| 83 |
foo (1 | (2 - 3)); |
| 84 |
foo (a > b | c); // { dg-warning "parentheses" "correct warning" } |
| 85 |
foo ((a > b) | c); |
| 86 |
foo (a > (b | c)); |
| 87 |
foo (1 > 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 88 |
foo ((1 > 2) | c); |
| 89 |
foo (1 > (2 | c)); |
| 90 |
foo (1 > 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 91 |
foo ((1 > 2) | 3); |
| 92 |
foo (1 > (2 | 3)); |
| 93 |
foo (a | b > c); // { dg-warning "parentheses" "correct warning" } |
| 94 |
foo ((a | b) > c); |
| 95 |
foo (a | (b > c)); |
| 96 |
foo (1 | 2 > c); // { dg-warning "parentheses" "correct warning" } |
| 97 |
foo ((1 | 2) > c); |
| 98 |
foo (1 | (2 > c)); |
| 99 |
foo (1 | 2 > 3); // { dg-warning "parentheses" "correct warning" } |
| 100 |
foo ((1 | 2) > 3); |
| 101 |
foo (1 | (2 > 3)); |
| 102 |
foo (a <= b | c); // { dg-warning "parentheses" "correct warning" } |
| 103 |
foo ((a <= b) | c); |
| 104 |
foo (a <= (b | c)); |
| 105 |
foo (1 <= 2 | c); // { dg-warning "parentheses" "correct warning" } |
| 106 |
foo ((1 <= 2) | c); |
| 107 |
foo (1 <= (2 | c)); |
| 108 |
foo (1 <= 2 | 3); // { dg-warning "parentheses" "correct warning" } |
| 109 |
foo ((1 <= 2) | 3); |
| 110 |
foo (1 <= (2 | 3)); |
| 111 |
foo (a | b <= c); // { dg-warning "parentheses" "correct warning" } |
| 112 |
foo ((a | b) <= c); |
| 113 |
foo (a | (b <= c)); |
| 114 |
foo (1 | 2 <= c); // { dg-warning "parentheses" "correct warning" } |
| 115 |
foo ((1 | 2) <= c); |
| 116 |
foo (1 | (2 <= c)); |
| 117 |
foo (1 | 2 <= 3); // { dg-warning "parentheses" "correct warning" } |
| 118 |
foo ((1 | 2) <= 3); |
| 119 |
foo (1 | (2 <= 3)); |
| 120 |
} |
| 121 |
|
| 122 |
template void bar<int> (int, int, int); // { dg-message "required" } |