| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
constexpr int |
| 4 |
fn1 (int i, int j) |
| 5 |
{ |
| 6 |
return i << j; // { dg-error "is negative" } |
| 7 |
} |
| 8 |
|
| 9 |
constexpr int i1 = fn1 (1, -1); // { dg-message "in .constexpr. expansion of " } |
| 10 |
|
| 11 |
constexpr int |
| 12 |
fn2 (int i, int j) |
| 13 |
{ |
| 14 |
return i << j; // { dg-error "is greater than or equal to the precision .. of the left operand" } |
| 15 |
} |
| 16 |
|
| 17 |
constexpr int i2 = fn2 (1, 200); // { dg-message "in .constexpr. expansion of " } |
| 18 |
|
| 19 |
constexpr int |
| 20 |
fn3 (int i, int j) |
| 21 |
{ |
| 22 |
return i << j; // { dg-error "is negative" "" { target c++17_down } } |
| 23 |
} |
| 24 |
|
| 25 |
constexpr int i3 = fn3 (-1, 2); // { dg-message "in .constexpr. expansion of " "" { target c++17_down } } |
| 26 |
|
| 27 |
constexpr int |
| 28 |
fn4 (int i, int j) |
| 29 |
{ |
| 30 |
return i << j; // { dg-error "overflows" "" { target c++17_down } } |
| 31 |
} |
| 32 |
|
| 33 |
constexpr int i4 = fn4 (__INT_MAX__, 2); // { dg-message "in .constexpr. expansion of " "" { target c++17_down } } |
| 34 |
|
| 35 |
constexpr int |
| 36 |
fn5 (int i, int j) |
| 37 |
{ |
| 38 |
return i << j; |
| 39 |
} |
| 40 |
|
| 41 |
constexpr int i5 = fn5 (__INT_MAX__, 1); |
| 42 |
|
| 43 |
constexpr int |
| 44 |
fn6 (unsigned int i, unsigned int j) |
| 45 |
{ |
| 46 |
return i << j; // { dg-error "is greater than or equal to the precision .. of the left operand" } |
| 47 |
} |
| 48 |
|
| 49 |
constexpr int i6 = fn6 (1, -1); // { dg-message "in .constexpr. expansion of " } |
| 50 |
|
| 51 |
constexpr int |
| 52 |
fn7 (int i, int j) |
| 53 |
{ |
| 54 |
return i >> j; // { dg-error "is negative" } |
| 55 |
} |
| 56 |
|
| 57 |
constexpr int i7 = fn7 (1, -1); // { dg-message "in .constexpr. expansion of " } |
| 58 |
|
| 59 |
constexpr int |
| 60 |
fn8 (int i, int j) |
| 61 |
{ |
| 62 |
return i >> j; |
| 63 |
} |
| 64 |
|
| 65 |
constexpr int i8 = fn8 (-1, 1); |
| 66 |
|
| 67 |
constexpr int |
| 68 |
fn9 (int i, int j) |
| 69 |
{ |
| 70 |
return i >> j; // { dg-error "is greater than or equal to the precision .. of the left operand" } |
| 71 |
} |
| 72 |
|
| 73 |
constexpr int i9 = fn9 (1, 200); // { dg-message "in .constexpr. expansion of " } |