| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-Wparentheses" } |
| 3 |
|
| 4 |
// Template version of Wparentheses-7.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 >> 2 + 3); // { dg-warning "parentheses" "correct warning" } |
| 46 |
foo ((1 >> 2) + 3); |
| 47 |
foo (1 >> (2 + 3)); |
| 48 |
foo (a - b << c); // { dg-warning "parentheses" "correct warning" } |
| 49 |
foo ((a - b) << c); |
| 50 |
foo (a - (b << c)); |
| 51 |
foo (6 - 5 << c); // { dg-warning "parentheses" "correct warning" } |
| 52 |
foo ((6 - 5) << c); |
| 53 |
foo (6 - (5 << c)); |
| 54 |
foo (6 - 5 << 4); // { dg-warning "parentheses" "correct warning" } |
| 55 |
foo ((6 - 5) << 4); |
| 56 |
foo (6 - (5 << 4)); |
| 57 |
foo (a << b - c); // { dg-warning "parentheses" "correct warning" } |
| 58 |
foo ((a << b) - c); |
| 59 |
foo (a << (b - c)); |
| 60 |
foo (6 << 5 - c); // { dg-warning "parentheses" "correct warning" } |
| 61 |
foo ((6 << 5) - c); |
| 62 |
foo (6 << (5 - c)); |
| 63 |
foo (6 << 5 - 4); // { dg-warning "parentheses" "correct warning" } |
| 64 |
foo ((6 << 5) - 4); |
| 65 |
foo (6 << (5 - 4)); |
| 66 |
foo (a - b >> c); // { dg-warning "parentheses" "correct warning" } |
| 67 |
foo ((a - b) >> c); |
| 68 |
foo (a - (b >> c)); |
| 69 |
foo (6 - 5 >> c); // { dg-warning "parentheses" "correct warning" } |
| 70 |
foo ((6 - 5) >> c); |
| 71 |
foo (6 - (5 >> c)); |
| 72 |
foo (6 - 5 >> 4); // { dg-warning "parentheses" "correct warning" } |
| 73 |
foo ((6 - 5) >> 4); |
| 74 |
foo (6 - (5 >> 4)); |
| 75 |
foo (a >> b - c); // { dg-warning "parentheses" "correct warning" } |
| 76 |
foo ((a >> b) - c); |
| 77 |
foo (a >> (b - c)); |
| 78 |
foo (6 >> 5 - c); // { dg-warning "parentheses" "correct warning" } |
| 79 |
foo ((6 >> 5) - c); |
| 80 |
foo (6 >> (5 - c)); |
| 81 |
foo (6 >> 5 - 4); // { dg-warning "parentheses" "correct warning" } |
| 82 |
foo ((6 >> 5) - 4); |
| 83 |
foo (6 >> (5 - 4)); |
| 84 |
} |
| 85 |
|
| 86 |
template void bar<int> (int, int, int); // { dg-message "required" } |