xref: /llvm-project/clang/test/AST/ast-print-method-decl.cpp (revision 9391ff8c86007562d40c240ea082b7c0cbf35947)
13e66a174STimo Stripf // RUN: %clang_cc1 -ast-print -triple i386-linux-gnu %s -o - -std=c++20 | FileCheck %s
22ca74162STimo Stripf 
30e4c5cc5STimo Stripf // CHECK: struct DelegatingCtor1 {
40e4c5cc5STimo Stripf struct DelegatingCtor1 {
50e4c5cc5STimo Stripf   // CHECK-NEXT: DelegatingCtor1();
60e4c5cc5STimo Stripf   DelegatingCtor1();
72ca74162STimo Stripf 
80e4c5cc5STimo Stripf   // CHECK-NEXT: DelegatingCtor1(int) : DelegatingCtor1() {
DelegatingCtor1DelegatingCtor190e4c5cc5STimo Stripf   DelegatingCtor1(int) : DelegatingCtor1() {
102ca74162STimo Stripf     // CHECK-NEXT: }
112ca74162STimo Stripf   }
122ca74162STimo Stripf 
132ca74162STimo Stripf   // CHECK-NEXT: };
142ca74162STimo Stripf };
152ca74162STimo Stripf 
162ca74162STimo Stripf 
170e4c5cc5STimo Stripf // CHECK: struct DelegatingCtor2 {
180e4c5cc5STimo Stripf struct DelegatingCtor2 {
190e4c5cc5STimo Stripf   // CHECK-NEXT: template <typename Ty> DelegatingCtor2(Ty);
200e4c5cc5STimo Stripf   template <typename Ty> DelegatingCtor2(Ty);
212ca74162STimo Stripf 
222ca74162STimo Stripf   // FIXME: Implicitly specialized method should not be output
230e4c5cc5STimo Stripf   // CHECK-NEXT: template<> DelegatingCtor2<float>(float);
242ca74162STimo Stripf 
250e4c5cc5STimo Stripf   // CHECK-NEXT: DelegatingCtor2(int X) : DelegatingCtor2((float)X) {
DelegatingCtor2DelegatingCtor2260e4c5cc5STimo Stripf   DelegatingCtor2(int X) : DelegatingCtor2((float)X) {
272ca74162STimo Stripf   // CHECK-NEXT: }
282ca74162STimo Stripf   }
292ca74162STimo Stripf 
302ca74162STimo Stripf   // CHECK-NEXT: };
312ca74162STimo Stripf };
322ca74162STimo Stripf 
330e4c5cc5STimo Stripf // CHECK: struct DelegatingCtor3 {
340e4c5cc5STimo Stripf struct DelegatingCtor3 {
3517f0680fSKrystian Stasiowski   // CHECK: DelegatingCtor3(auto);
360e4c5cc5STimo Stripf   DelegatingCtor3(auto);
372ca74162STimo Stripf 
382ca74162STimo Stripf   // FIXME: Implicitly specialized method should not be output
390e4c5cc5STimo Stripf   // CHECK: template<> DelegatingCtor3<const char *>(const char *);
402ca74162STimo Stripf 
410e4c5cc5STimo Stripf   // CHECK: DelegatingCtor3(int) : DelegatingCtor3("") {
DelegatingCtor3DelegatingCtor3420e4c5cc5STimo Stripf   DelegatingCtor3(int) : DelegatingCtor3("") {
430e4c5cc5STimo Stripf   // CHECK-NEXT: }
440e4c5cc5STimo Stripf   }
450e4c5cc5STimo Stripf 
460e4c5cc5STimo Stripf   // CHECK-NEXT: };
470e4c5cc5STimo Stripf };
480e4c5cc5STimo Stripf 
490e4c5cc5STimo Stripf // CHECK: struct CurlyCtorInit {
500e4c5cc5STimo Stripf struct CurlyCtorInit {
510e4c5cc5STimo Stripf   // CHECK-NEXT: struct A {
520e4c5cc5STimo Stripf   struct A {
530e4c5cc5STimo Stripf     // CHECK-NEXT: int x;
540e4c5cc5STimo Stripf     int x;
550e4c5cc5STimo Stripf   // CHECK-NEXT: };
560e4c5cc5STimo Stripf   };
570e4c5cc5STimo Stripf 
580e4c5cc5STimo Stripf   // CHECK-NEXT: A a;
590e4c5cc5STimo Stripf   A a;
600e4c5cc5STimo Stripf   // CHECK-NEXT: int i;
610e4c5cc5STimo Stripf   int i;
620e4c5cc5STimo Stripf 
630e4c5cc5STimo Stripf   // FIXME: /*implicit*/(int)0 should not be output
640e4c5cc5STimo Stripf   // CHECK-NEXT: CurlyCtorInit(int *) : a(), i(/*implicit*/(int)0) {
CurlyCtorInitCurlyCtorInit650e4c5cc5STimo Stripf   CurlyCtorInit(int *) : a(), i() {
660e4c5cc5STimo Stripf   // CHECK-NEXT: }
670e4c5cc5STimo Stripf   }
680e4c5cc5STimo Stripf 
690e4c5cc5STimo Stripf   // CHECK-NEXT: CurlyCtorInit(int **) : a{}, i{} {
CurlyCtorInitCurlyCtorInit700e4c5cc5STimo Stripf   CurlyCtorInit(int **) : a{}, i{} {
710e4c5cc5STimo Stripf   // CHECK-NEXT: }
720e4c5cc5STimo Stripf   }
730e4c5cc5STimo Stripf 
740e4c5cc5STimo Stripf   // CHECK-NEXT: CurlyCtorInit(int ***) : a({}), i(0) {
CurlyCtorInitCurlyCtorInit750e4c5cc5STimo Stripf   CurlyCtorInit(int ***) : a({}), i(0) {
760e4c5cc5STimo Stripf   // CHECK-NEXT: }
770e4c5cc5STimo Stripf   }
780e4c5cc5STimo Stripf 
790e4c5cc5STimo Stripf   // FIXME: Implicit this should not be output
800e4c5cc5STimo Stripf   // CHECK-NEXT: CurlyCtorInit(int ****) : a({.x = 0}), i(this->a.x) {
CurlyCtorInitCurlyCtorInit810e4c5cc5STimo Stripf   CurlyCtorInit(int ****) : a({.x = 0}), i(a.x) {
822ca74162STimo Stripf   // CHECK-NEXT: }
832ca74162STimo Stripf   }
842ca74162STimo Stripf 
852ca74162STimo Stripf   // CHECK-NEXT: };
862ca74162STimo Stripf };
873e66a174STimo Stripf 
883e66a174STimo Stripf 
893e66a174STimo Stripf // CHECK: struct DefMethodsWithoutBody {
903e66a174STimo Stripf struct DefMethodsWithoutBody {
913e66a174STimo Stripf   // CHECK-NEXT: DefMethodsWithoutBody() = delete;
923e66a174STimo Stripf   DefMethodsWithoutBody() = delete;
933e66a174STimo Stripf 
943e66a174STimo Stripf   // CHECK-NEXT: DefMethodsWithoutBody() = default;
953e66a174STimo Stripf   ~DefMethodsWithoutBody() = default;
963e66a174STimo Stripf 
97*9391ff8cSVassil Vassilev   // CHECK-NEXT: void m1() __attribute__((alias("X")));
983e66a174STimo Stripf   void m1() __attribute__((alias("X")));
993e66a174STimo Stripf 
1003e66a174STimo Stripf   // CHECK-NEXT: };
1013e66a174STimo Stripf };
102291eb258STimo Stripf 
103291eb258STimo Stripf 
104291eb258STimo Stripf // ---- Check that implict (non-written) constructor initializers are not output
105291eb258STimo Stripf 
106291eb258STimo Stripf struct ImplicitCtorInit1 {
107291eb258STimo Stripf   int a;
108291eb258STimo Stripf };
109291eb258STimo Stripf 
110291eb258STimo Stripf // CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
111291eb258STimo Stripf struct ImplicitCtorInit2 : ImplicitCtorInit1 {
112291eb258STimo Stripf 
113291eb258STimo Stripf   // CHECK-NEXT: ImplicitCtorInit2(int *) {
ImplicitCtorInit2ImplicitCtorInit2114291eb258STimo Stripf   ImplicitCtorInit2(int *) {
115291eb258STimo Stripf   // CHECK-NEXT: }
116291eb258STimo Stripf   }
117291eb258STimo Stripf 
118291eb258STimo Stripf   // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
ImplicitCtorInit2ImplicitCtorInit2119291eb258STimo Stripf   ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
120291eb258STimo Stripf   // CHECK-NEXT: }
121291eb258STimo Stripf   }
122291eb258STimo Stripf 
123291eb258STimo Stripf   // CHECK-NEXT: };
124291eb258STimo Stripf };
125