brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.9 KiB · 6d9f5d7 Raw
191 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc %s -verify -DBAD_CONVERSION2// RUN: %clang_cc1 -fsyntax-only -triple i386-windows-pc %s -verify -DBAD_CONVERSION -DWIN323// RUN: %clang_cc1 -triple x86_64-linux-pc %s -ast-dump | FileCheck %s --check-prefixes=CHECK,LIN64,NODEF4// RUN: %clang_cc1 -triple i386-windows-pc %s -ast-dump -DWIN32 | FileCheck %s --check-prefixes=CHECK,WIN32,NODEF5 6// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -verify -DBAD_VEC_CONVERS7// RUN: %clang_cc1 -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -ast-dump | FileCheck %s --check-prefixes=CHECK,VECTDEF8 9void useage() {10  auto normal = [](int, float, double) {};                                // #111  auto vectorcall = [](int, float, double) __attribute__((vectorcall)){}; // #212#ifdef WIN3213  auto thiscall = [](int, float, double) __attribute__((thiscall)){}; // #314#endif                                                                // WIN3215  auto cdecl = [](int, float, double) __attribute__((cdecl)){};16 17  auto genericlambda = [](auto a) {};                                      // #418  auto genericvectorcalllambda = [](auto a) __attribute__((vectorcall)){}; // #519 20  // None of these should be ambiguous.21  (void)+normal;22  (void)+vectorcall;23#ifdef WIN3224  (void)+thiscall;25#endif // WIN3226  (void)+cdecl;27 28#ifdef BAD_CONVERSION29  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}30  (void)+genericlambda;31  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}32  (void)+genericvectorcalllambda;33#endif // BAD_CONVERSION34 35  // CHECK: VarDecl {{.*}} normal '36  // CHECK: LambdaExpr37  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((thiscall)) const'38  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'39  // VECTDEF: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'40  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void41  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline42  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void43  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline44 45  // CHECK: VarDecl {{.*}} vectorcall '46  // CHECK: LambdaExpr47  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const __attribute__((vectorcall))':'void (int, float, double) __attribute__((vectorcall)) const'48  // CHECK: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void49  // CHECK: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline50 51  // WIN32: VarDecl {{.*}} thiscall '52  // WIN32: LambdaExpr53  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const __attribute__((thiscall))':'void (int, float, double) __attribute__((thiscall)) const'54  // WIN32: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void55  // WIN32: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline56 57  // CHECK: VarDecl {{.*}} cdecl '58  // CHECK: LambdaExpr59  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const __attribute__((cdecl))':'void (int, float, double) const'60  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void61  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline62  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void63  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline64 65  // CHECK: VarDecl {{.*}} genericlambda '66  // CHECK: LambdaExpr67  //68  // CHECK: FunctionTemplateDecl {{.*}} operator()69  // LIN64: CXXMethodDecl {{.*}} operator() 'auto (auto) const' inline70  // LIN64: CXXMethodDecl {{.*}} operator() 'void (char) const' implicit_instantiation inline71  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int) const' implicit_instantiation inline72  // WIN32: CXXMethodDecl {{.*}} operator() 'auto (auto) __attribute__((thiscall)) const' inline73  // WIN32: CXXMethodDecl {{.*}} operator() 'void (char) __attribute__((thiscall)) const' implicit_instantiation inline74  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int) __attribute__((thiscall)) const' implicit_instantiation inline75  //76  // NODEF: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0)77  // VECDEF: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall))78  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) 'auto (*() const noexcept)(auto)'79  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(char) 'void (*() const noexcept)(char)'80  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(int) 'void (*() const noexcept)(int)'81  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) 'auto (*() __attribute__((thiscall)) const noexcept)(auto)'82  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(char) 'void (*() __attribute__((thiscall)) const noexcept)(char)'83  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(int) 'void (*() __attribute__((thiscall)) const noexcept)(int)'84  // VECDEF: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall)) 'auto (*() const noexcept)(auto)' __attribute__((vectorcall))85  // VECDEF: CXXConversionDecl {{.*}} operator auto (*)(char) __attribute__((vectorcall)) 'void (*() const noexcept)(char)' __attribute__((vectorcall))86  // VECDEF: CXXConversionDecl {{.*}} operator auto (*)(int) __attribute__((vectorcall)) 'void (*() const noexcept)(int)' __attribute__((vectorcall))87  //88  // CHECK: FunctionTemplateDecl {{.*}} __invoke89  // NODEF: CXXMethodDecl {{.*}} __invoke 'auto (auto)'90  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (char)'91  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int)'92  // VECDEF: CXXMethodDecl {{.*}} __invoke 'auto (auto) __attribute__((vectorcall))'93  // VECDEF: CXXMethodDecl {{.*}} __invoke 'void (char) __attribute__((vectorcall))'94  // VECDEF: CXXMethodDecl {{.*}} __invoke 'void (int) __attribute__((vectorcall))'95  //96  // ONLY WIN32 has the duplicate here.97  // WIN32: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((thiscall))98  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((thiscall)) 'auto (*() __attribute__((thiscall)) const noexcept)(auto) __attribute__((thiscall))'99  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(char) __attribute__((thiscall)) 'void (*() __attribute__((thiscall)) const noexcept)(char) __attribute__((thiscall))'100  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(int) __attribute__((thiscall)) 'void (*() __attribute__((thiscall)) const noexcept)(int) __attribute__((thiscall))'101  //102  // WIN32: FunctionTemplateDecl {{.*}} __invoke103  // WIN32: CXXMethodDecl {{.*}} __invoke 'auto (auto) __attribute__((thiscall))'104  // WIN32: CXXMethodDecl {{.*}} __invoke 'void (char) __attribute__((thiscall))'105  // WIN32: CXXMethodDecl {{.*}} __invoke 'void (int) __attribute__((thiscall))'106 107  // CHECK: VarDecl {{.*}} genericvectorcalllambda '108  // CHECK: LambdaExpr109  // CHECK: FunctionTemplateDecl {{.*}} operator()110  // CHECK: CXXMethodDecl {{.*}} operator() 'auto (auto) __attribute__((vectorcall)) const' inline111  // CHECK: CXXMethodDecl {{.*}} operator() 'void (char) const __attribute__((vectorcall))':'void (char) __attribute__((vectorcall)) const' implicit_instantiation inline112  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int) const __attribute__((vectorcall))':'void (int) __attribute__((vectorcall)) const' implicit_instantiation inline113  // CHECK: FunctionTemplateDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall))114  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall)) 'auto (*() const noexcept)(auto) __attribute__((vectorcall))'115  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(char) __attribute__((vectorcall)) 'void (*() const noexcept)(char) __attribute__((vectorcall))'116  // LIN64: CXXConversionDecl {{.*}} operator auto (*)(int) __attribute__((vectorcall)) 'void (*() const noexcept)(int) __attribute__((vectorcall))'117  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(type-parameter-0-0) __attribute__((vectorcall)) 'auto (*() __attribute__((thiscall)) const noexcept)(auto) __attribute__((vectorcall))'118  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(char) __attribute__((vectorcall)) 'void (*() __attribute__((thiscall)) const noexcept)(char) __attribute__((vectorcall))'119  // WIN32: CXXConversionDecl {{.*}} operator auto (*)(int) __attribute__((vectorcall)) 'void (*() __attribute__((thiscall)) const noexcept)(int) __attribute__((vectorcall))'120  // CHECK: FunctionTemplateDecl {{.*}} __invoke121  // CHECK: CXXMethodDecl {{.*}} __invoke 'auto (auto) __attribute__((vectorcall))'122  // CHECK: CXXMethodDecl {{.*}} __invoke 'void (char) __attribute__((vectorcall))'123  // CHECK: CXXMethodDecl {{.*}} __invoke 'void (int) __attribute__((vectorcall))'124 125  // NODEF: UnaryOperator {{.*}} 'void (*)(int, float, double)' prefix '+'126  // NODEF-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double)'127  // NODEF-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double)'128  // VECTDEF: UnaryOperator {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))' prefix '+'129  // VECTDEF-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))'130  // VECTDEF-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double) __attribute__((vectorcall))'131 132  // CHECK: UnaryOperator {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))' prefix '+'133  // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))'134  // CHECK-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double) __attribute__((vectorcall))'135 136  // WIN32: UnaryOperator {{.*}} 'void (*)(int, float, double)' prefix '+'137  // WIN32-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double)'138  // WIN32-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double)'139 140  // NODEF: UnaryOperator {{.*}} 'void (*)(int, float, double)' prefix '+'141  // NODEF-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double)'142  // NODEF-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double)'143  // VECTDEF: UnaryOperator {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))' prefix '+'144  // VECTDEF-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int, float, double) __attribute__((vectorcall))'145  // VECTDEF-NEXT: CXXMemberCallExpr {{.*}}'void (*)(int, float, double) __attribute__((vectorcall))'146 147#ifdef BAD_CONVERSION148  // expected-error-re@+2 {{no viable conversion from {{.*}} to 'void (*)(int, float, double) __attribute__((vectorcall))}}149  // expected-note@#1 {{candidate function}}150  void (*__attribute__((vectorcall)) normal_ptr2)(int, float, double) = normal;151  // expected-error-re@+2 {{no viable conversion from {{.*}} to 'void (*)(int, float, double)}}152  // expected-note@#2 {{candidate function}}153  void (*vectorcall_ptr2)(int, float, double) = vectorcall;154#ifdef WIN32155  void (*__attribute__((thiscall)) thiscall_ptr2)(int, float, double) = thiscall;156#endif // WIN32157  // expected-error-re@+2 {{no viable conversion from {{.*}} to 'void (*)(char) __attribute__((vectorcall))'}}158  // expected-note@#4 {{candidate function}}159  void(__vectorcall * generic_ptr)(char) = genericlambda;160  // expected-error-re@+2 {{no viable conversion from {{.*}} to 'void (*)(char)}}161  // expected-note@#5 {{candidate function}}162  void (*generic_ptr2)(char) = genericvectorcalllambda;163#endif // BAD_CONVERSION164 165#ifdef BAD_VEC_CONVERS166  void (*__attribute__((vectorcall)) normal_ptr2)(int, float, double) = normal;167  void (*normal_ptr3)(int, float, double) = normal;168  // expected-error-re@+2 {{no viable conversion from {{.*}} to 'void (*)(int, float, double) __attribute__((regcall))}}169  // expected-note@#1 {{candidate function}}170  void (*__attribute__((regcall)) normalptr4)(int, float, double) = normal;171  void (*__attribute__((vectorcall)) vectorcall_ptr2)(int, float, double) = vectorcall;172  void (*vectorcall_ptr3)(int, float, double) = vectorcall;173#endif // BAD_VEC_CONVERS174 175  // Required to force emission of the invoker.176  void (*normal_ptr)(int, float, double) = normal;177  void (*__attribute__((vectorcall)) vectorcall_ptr)(int, float, double) = vectorcall;178#ifdef WIN32179  void (*thiscall_ptr)(int, float, double) = thiscall;180#endif // WIN32181  void (*cdecl_ptr)(int, float, double) = cdecl;182  void (*generic_ptr3)(char) = genericlambda;183  void (*generic_ptr4)(int) = genericlambda;184#ifdef WIN32185  void (*__attribute__((thiscall)) generic_ptr3b)(char) = genericlambda;186  void (*__attribute__((thiscall)) generic_ptr4b)(int) = genericlambda;187#endif188  void (*__attribute__((vectorcall)) generic_ptr5)(char) = genericvectorcalllambda;189  void (*__attribute__((vectorcall)) generic_ptr6)(int) = genericvectorcalllambda;190}191