[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / AST / overloaded-destructors.cpp
blobc0b17f7304449d23b8f84c320dd0f10495b39e8f
1 // RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-linux -ast-dump=json %s | FileCheck %s
2 // RUN: %clang_cc1 -std=c++20 -triple x86_64-pc-win32 -ast-dump=json %s | FileCheck %s -check-prefixes=CHECK,WIN32
4 // This test validates that we compute correct AST properties of classes after choosing
5 // their destructor when doing destructor overload resolution with concepts.
7 template <int N>
8 struct A {
9 ~A() requires(N == 1) = default;
10 ~A() requires(N == 2) = delete;
11 ~A() requires(N == 3);
12 constexpr ~A() requires(N == 4);
14 private:
15 ~A() requires(N == 5) = default;
19 template struct A<1>;
20 // CHECK: "kind": "ClassTemplateSpecializationDecl",
21 // CHECK: "definitionData": {
22 // CHECK-NEXT: "canConstDefaultInit": true,
23 // CHECK-NEXT: "canPassInRegisters": true,
24 // CHECK-NEXT: "copyAssign": {
26 // CHECK: "dtor": {
27 // CHECK-NEXT: "irrelevant": true,
28 // CHECK-NEXT: "trivial": true,
29 // CHECK-NEXT: "userDeclared": true
30 // CHECK-NEXT: },
31 // CHECK-NEXT: "hasConstexprNonCopyMoveConstructor": true,
32 // CHECK-NEXT: "isAggregate": true,
33 // CHECK-NEXT: "isEmpty": true,
34 // CHECK-NEXT: "isLiteral": true,
35 // CHECK-NEXT: "isStandardLayout": true,
36 // CHECK-NEXT: "isTrivial": true,
37 // CHECK-NEXT: "isTriviallyCopyable": true,
38 // CHECK-NEXT: "moveAssign": {},
39 // CHECK-NEXT: "moveCtor": {}
41 template struct A<2>;
42 // CHECK: "kind": "ClassTemplateSpecializationDecl",
43 // CHECK: "definitionData": {
44 // CHECK-NEXT: "canConstDefaultInit": true,
45 // CHECK-NEXT: "canPassInRegisters": true,
46 // CHECK-NEXT: "copyAssign": {
48 // CHECK: "dtor": {
49 // CHECK-NEXT: "trivial": true,
50 // CHECK-NEXT: "userDeclared": true
51 // CHECK-NEXT: },
52 // CHECK-NEXT: "hasConstexprNonCopyMoveConstructor": true,
53 // CHECK-NEXT: "isAggregate": true,
54 // CHECK-NEXT: "isEmpty": true,
55 // CHECK-NEXT: "isStandardLayout": true,
56 // CHECK-NEXT: "isTrivial": true,
57 // CHECK-NEXT: "isTriviallyCopyable": true,
58 // CHECK-NEXT: "moveAssign": {},
59 // CHECK-NEXT: "moveCtor": {}
61 template struct A<3>;
62 // CHECK: "kind": "ClassTemplateSpecializationDecl",
63 // CHECK: "definitionData": {
64 // CHECK-NEXT: "canConstDefaultInit": true,
65 // WIN32-NEXT: "canPassInRegisters": true,
66 // CHECK-NEXT: "copyAssign": {
68 // CHECK: "dtor": {
69 // CHECK-NEXT: "nonTrivial": true,
70 // CHECK-NEXT: "userDeclared": true
71 // CHECK-NEXT: },
72 // CHECK-NEXT: "hasConstexprNonCopyMoveConstructor": true,
73 // CHECK-NEXT: "isAggregate": true,
74 // CHECK-NEXT: "isEmpty": true,
75 // CHECK-NEXT: "isStandardLayout": true,
76 // CHECK-NEXT: "moveAssign": {},
77 // CHECK-NEXT: "moveCtor": {}
79 template struct A<4>;
80 // CHECK: "kind": "ClassTemplateSpecializationDecl",
81 // CHECK: "definitionData": {
82 // CHECK-NEXT: "canConstDefaultInit": true,
83 // WIN32-NEXT: "canPassInRegisters": true,
84 // CHECK-NEXT: "copyAssign": {
86 // CHECK: "dtor": {
87 // CHECK-NEXT: "nonTrivial": true,
88 // CHECK-NEXT: "userDeclared": true
89 // CHECK-NEXT: },
90 // CHECK-NEXT: "hasConstexprNonCopyMoveConstructor": true,
91 // CHECK-NEXT: "isAggregate": true,
92 // CHECK-NEXT: "isEmpty": true,
93 // CHECK-NEXT: "isLiteral": true,
94 // CHECK-NEXT: "isStandardLayout": true,
95 // CHECK-NEXT: "moveAssign": {},
96 // CHECK-NEXT: "moveCtor": {}
98 template struct A<5>;
99 // CHECK: "kind": "ClassTemplateSpecializationDecl",
100 // CHECK: "definitionData": {
101 // CHECK-NEXT: "canConstDefaultInit": true,
102 // CHECK-NEXT: "canPassInRegisters": true,
103 // CHECK-NEXT: "copyAssign": {
105 // CHECK: "dtor": {
106 // CHECK-NEXT: "trivial": true,
107 // CHECK-NEXT: "userDeclared": true
108 // CHECK-NEXT: },
109 // CHECK-NEXT: "hasConstexprNonCopyMoveConstructor": true,
110 // CHECK-NEXT: "isAggregate": true,
111 // CHECK-NEXT: "isEmpty": true,
112 // CHECK-NEXT: "isLiteral": true,
113 // CHECK-NEXT: "isStandardLayout": true,
114 // CHECK-NEXT: "isTrivial": true,
115 // CHECK-NEXT: "isTriviallyCopyable": true,
116 // CHECK-NEXT: "moveAssign": {},
117 // CHECK-NEXT: "moveCtor": {}