| 1 |
// RUN: %clang_cc1 -frecovery-ast -verify %s |
| 2 |
|
| 3 |
struct X { |
| 4 |
int Y; |
| 5 |
constexpr X() |
| 6 |
: Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}} |
| 7 |
}; |
| 8 |
// no crash on evaluating the constexpr ctor. |
| 9 |
constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}} |
| 10 |
|
| 11 |
struct X2 { |
| 12 |
int Y = foo(); // expected-error {{use of undeclared identifier 'foo'}} |
| 13 |
constexpr X2() {} |
| 14 |
}; |
| 15 |
|
| 16 |
struct X3 { |
| 17 |
int Y; |
| 18 |
constexpr X3() |
| 19 |
: Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}} |
| 20 |
}; |
| 21 |
|
| 22 |
struct CycleDelegate { |
| 23 |
int Y; |
| 24 |
CycleDelegate(int) |
| 25 |
: Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}} |
| 26 |
// no bogus "delegation cycle" diagnostic |
| 27 |
CycleDelegate(float) : CycleDelegate(1) {} |
| 28 |
}; |
| 29 |
|
| 30 |
struct X4 { |
| 31 |
int* p = new int(invalid()); // expected-error {{use of undeclared identifier}} |
| 32 |
}; |
| 33 |
// no crash on evaluating the CXXDefaultInitExpr. |
| 34 |
constexpr int* s = X4().p; // expected-error {{must be initialized by}} |