Rafael Espindola | 3497069 | 2013-12-12 16:07:11 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm %s -o - | FileCheck -check-prefix GCABI %s |
Hans Wennborg | c9bd88e | 2014-01-14 19:35:09 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -emit-llvm %s -o - -DMS_ABI -triple=i386-pc-win32 | FileCheck -check-prefix MSABI %s |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 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() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 15 | // GCABI-LABEL: define void @_Z3foov() |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 16 | // MSABI: define void @"\01?foo@@YAXXZ" |
| 17 | |
| 18 | void __cdecl bar(); |
| 19 | void bar(); |
| 20 | void bar() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 21 | // GCABI-LABEL: define void @_Z3barv() |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 22 | // MSABI: define void @"\01?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 | |
Timur Iskhodzhanov | 2e9bd80 | 2013-02-19 10:50:44 +0000 | [diff] [blame] | 31 | static void static_baz(); |
| 32 | static void __cdecl static_qux(); |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | void METHOD_CC A::baz() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 36 | // GCABI-LABEL: define void @_ZN1A3bazEv |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 37 | // MSABI: define x86_thiscallcc void @"\01?baz@A@@QAEXXZ" |
| 38 | void A::qux() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 39 | // GCABI-LABEL: define void @_ZN1A3quxEv |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 40 | // MSABI: define x86_thiscallcc void @"\01?qux@A@@QAEXXZ" |
| 41 | |
| 42 | void __cdecl static_baz() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 43 | // GCABI-LABEL: define void @_Z10static_bazv |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 44 | // MSABI: define void @"\01?static_baz@@YAXXZ" |
| 45 | void static_qux() {} |
Stephen Lin | 4362261 | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 46 | // GCABI-LABEL: define void @_Z10static_quxv |
John McCall | a5f46fb | 2012-08-25 02:00:03 +0000 | [diff] [blame] | 47 | // MSABI: define void @"\01?static_qux@@YAXXZ" |