1 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx2a %s 2 // RUN: %clang_cc1 -std=c++23 -verify=expected %s 3 4 // p3: if the function is a constructor or destructor, its class shall not have 5 // any virtual base classes; 6 namespace vbase { 7 struct A {}; 8 struct B : virtual A { // expected-note {{virtual}} ~Bvbase::B9 constexpr ~B() {} // expected-error {{constexpr member function not allowed in struct with virtual base class}} 10 }; 11 } 12 13 namespace contents { 14 struct A { ~Acontents::A15 constexpr ~A() { 16 return; 17 goto x; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}} 18 x: ; 19 } 20 }; 21 struct B { ~Bcontents::B22 constexpr ~B() { 23 x:; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}} 24 } 25 }; 26 struct Nonlit { // cxx2a-note {{'Nonlit' is not literal because}} 27 Nonlit(); 28 }; 29 struct C { ~Ccontents::C30 constexpr ~C() { 31 return; 32 Nonlit nl; // cxx2a-error {{variable of non-literal type 'Nonlit' cannot be defined in a constexpr function before C++23}} 33 } 34 }; 35 struct D { ~Dcontents::D36 constexpr ~D() { 37 return; 38 static int a; // cxx2a-warning {{definition of a static variable in a constexpr function is a C++23 extension}} 39 } 40 }; 41 struct E { ~Econtents::E42 constexpr ~E() { 43 return; 44 thread_local int e; // cxx2a-warning {{definition of a thread_local variable in a constexpr function is a C++23 extension}} 45 } 46 }; 47 struct F { ~Fcontents::F48 constexpr ~F() { 49 return; 50 extern int f; 51 } 52 }; 53 } 54 55 // p5: for every subobject of class type or (possibly multi-dimensional) array 56 // thereof, that class type shall have a constexpr destructor 57 namespace subobject { 58 struct A { 59 ~A(); 60 }; 61 struct B : A { // cxx2a-note {{here}} ~Bsubobject::B62 constexpr ~B() {} // cxx2a-error {{destructor cannot be declared constexpr because base class 'A' does not have a constexpr destructor}} 63 }; 64 struct C { 65 A a; // cxx2a-note {{here}} ~Csubobject::C66 constexpr ~C() {} // cxx2a-error {{destructor cannot be declared constexpr because data member 'a' does not have a constexpr destructor}} 67 }; 68 struct D : A { 69 A a; 70 constexpr ~D() = delete; 71 }; 72 } 73