[AMDGPU][True16][CodeGen] true16 codegen pattern for f16 canonicalize (#122000)
[llvm-project.git] / clang / test / CXX / dcl.dcl / dcl.spec / dcl.constexpr / dtor.cpp
blob48bc8fb426bcb198fada867822dc6635ef8e2033
1 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx2a %s
2 // RUN: %clang_cc1 -std=c++23 -verify=expected %s
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}}
9 constexpr ~B() {} // expected-error {{constexpr member function not allowed in struct with virtual base class}}
13 namespace contents {
14 struct A {
15 constexpr ~A() {
16 return;
17 goto x; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}}
18 x: ;
21 struct B {
22 constexpr ~B() {
23 x:; // cxx2a-warning {{use of this statement in a constexpr function is a C++23 extension}}
26 struct Nonlit { // cxx2a-note {{'Nonlit' is not literal because}}
27 Nonlit();
29 struct C {
30 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}}
35 struct D {
36 constexpr ~D() {
37 return;
38 static int a; // cxx2a-warning {{definition of a static variable in a constexpr function is a C++23 extension}}
41 struct E {
42 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}}
47 struct F {
48 constexpr ~F() {
49 return;
50 extern int f;
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();
61 struct B : A { // cxx2a-note {{here}}
62 constexpr ~B() {} // cxx2a-error {{destructor cannot be declared constexpr because base class 'A' does not have a constexpr destructor}}
64 struct C {
65 A a; // cxx2a-note {{here}}
66 constexpr ~C() {} // cxx2a-error {{destructor cannot be declared constexpr because data member 'a' does not have a constexpr destructor}}
68 struct D : A {
69 A a;
70 constexpr ~D() = delete;