| 1 |
// RUN: %clang_cc1 -std=c++14 -verify=both,expected %s -fexperimental-new-constant-interpreter |
| 2 |
// RUN: %clang_cc1 -std=c++14 -verify=both,ref %s |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
constexpr int(*null_ptr)() = nullptr; |
| 7 |
constexpr int test4 = (*null_ptr)(); // both-error {{must be initialized by a constant expression}} \ |
| 8 |
// both-note {{evaluates to a null function pointer}} |
| 9 |
|
| 10 |
struct E { |
| 11 |
int n = 0; |
| 12 |
struct { |
| 13 |
void *x = this; |
| 14 |
}; |
| 15 |
void *y = this; |
| 16 |
}; |
| 17 |
constexpr E e1 = E(); |
| 18 |
static_assert(e1.x != e1.y, ""); |
| 19 |
constexpr E e2 = E{0}; |
| 20 |
static_assert(e2.x != e2.y, ""); |
| 21 |
|
| 22 |
struct S { |
| 23 |
int &&a = 2; |
| 24 |
int b[1]{a}; |
| 25 |
}; |
| 26 |
constexpr int foo() { |
| 27 |
S s{12}; |
| 28 |
return s.b[0]; |
| 29 |
} |
| 30 |
static_assert(foo() == 12, ""); |