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