| 1 |
// PR c++/87594 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
|
| 4 |
constexpr bool always_false() { return false; } |
| 5 |
int f() { return 1; } |
| 6 |
|
| 7 |
constexpr int |
| 8 |
fn1() |
| 9 |
{ |
| 10 |
struct empty_range { |
| 11 |
constexpr int* begin() { return 0; } |
| 12 |
constexpr int* end() { return 0; } |
| 13 |
} e; |
| 14 |
for (auto x : e) |
| 15 |
f(); |
| 16 |
return 0; |
| 17 |
} |
| 18 |
|
| 19 |
constexpr int |
| 20 |
fn2 () |
| 21 |
{ |
| 22 |
int a[] = { 1, 2, 3 }; |
| 23 |
for (auto x : a) |
| 24 |
f(); // { dg-error "call to non-.constexpr. function" } |
| 25 |
return 0; |
| 26 |
} |
| 27 |
|
| 28 |
constexpr int |
| 29 |
fn3 () |
| 30 |
{ |
| 31 |
__extension__ int a[] = { }; |
| 32 |
for (auto x : a) |
| 33 |
f(); |
| 34 |
return 0; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
void |
| 39 |
bar () |
| 40 |
{ |
| 41 |
constexpr int i1 = fn1 (); |
| 42 |
constexpr int i2 = fn2 (); // { dg-message "in .constexpr. expansion of " } |
| 43 |
constexpr int i3 = fn3 (); |
| 44 |
} |