| 1 |
// RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm %s -o - | FileCheck -check-prefix GCABI %s |
| 2 |
// RUN: %clang_cc1 -emit-llvm %s -o - -DMS_ABI -triple=i386-pc-win32 | FileCheck -check-prefix MSABI %s |
| 3 |
|
| 4 |
#ifdef MS_ABI |
| 5 |
# define METHOD_CC __thiscall |
| 6 |
#else |
| 7 |
# define METHOD_CC __attribute__ ((cdecl)) |
| 8 |
#endif |
| 9 |
|
| 10 |
// Test that it's OK to have multiple function declarations with the default CC |
| 11 |
// both mentioned explicitly and implied. |
| 12 |
void foo(); |
| 13 |
void __cdecl foo(); |
| 14 |
void __cdecl foo() {} |
| 15 |
// GCABI-LABEL: define{{.*}} void @_Z3foov() |
| 16 |
// MSABI: define dso_local void @"?foo@@YAXXZ" |
| 17 |
|
| 18 |
void __cdecl bar(); |
| 19 |
void bar(); |
| 20 |
void bar() {} |
| 21 |
// GCABI-LABEL: define{{.*}} void @_Z3barv() |
| 22 |
// MSABI: define dso_local void @"?bar@@YAXXZ" |
| 23 |
|
| 24 |
// Test that it's OK to mark either the method declaration or method definition |
| 25 |
// with a default CC explicitly. |
| 26 |
class A { |
| 27 |
public: |
| 28 |
void baz(); |
| 29 |
void METHOD_CC qux(); |
| 30 |
|
| 31 |
static void static_baz(); |
| 32 |
static void __cdecl static_qux(); |
| 33 |
}; |
| 34 |
|
| 35 |
void METHOD_CC A::baz() {} |
| 36 |
// GCABI-LABEL: define{{.*}} void @_ZN1A3bazEv |
| 37 |
// MSABI: define dso_local x86_thiscallcc void @"?baz@A@@QAEXXZ" |
| 38 |
void A::qux() {} |
| 39 |
// GCABI-LABEL: define{{.*}} void @_ZN1A3quxEv |
| 40 |
// MSABI: define dso_local x86_thiscallcc void @"?qux@A@@QAEXXZ" |
| 41 |
|
| 42 |
void __cdecl static_baz() {} |
| 43 |
// GCABI-LABEL: define{{.*}} void @_Z10static_bazv |
| 44 |
// MSABI: define dso_local void @"?static_baz@@YAXXZ" |
| 45 |
void static_qux() {} |
| 46 |
// GCABI-LABEL: define{{.*}} void @_Z10static_quxv |
| 47 |
// MSABI: define dso_local void @"?static_qux@@YAXXZ" |
| 48 |
|
| 49 |
namespace PR31656 { |
| 50 |
template <int I> |
| 51 |
void __cdecl callee(int args[I]); |
| 52 |
// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi( |
| 53 |
// MSABI: declare dso_local void @"??$callee@$00@PR31656@@YAXQAH@Z"( |
| 54 |
|
| 55 |
void caller() { callee<1>(0); } |
| 56 |
} |