Timur Iskhodzhanov | 33b52ad | 2013-02-22 12:42:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi microsoft -fms-extensions -verify %s |
| 2 | |
| 3 | // Pointers to free functions |
| 4 | void free_func_default(); |
| 5 | void __cdecl free_func_cdecl(); |
| 6 | void __stdcall free_func_stdcall(); // expected-note {{previous declaration is here}} |
| 7 | void __fastcall free_func_fastcall(); // expected-note 2 {{previous declaration is here}} |
| 8 | |
| 9 | void __cdecl free_func_default(); // expected-note 2 {{previous declaration is here}} |
| 10 | void __stdcall free_func_default(); // expected-error {{function declared 'stdcall' here was previously declared without calling convention}} |
| 11 | void __fastcall free_func_default(); // expected-error {{function declared 'fastcall' here was previously declared without calling convention}} |
| 12 | |
| 13 | void free_func_cdecl(); // expected-note 2 {{previous declaration is here}} |
| 14 | void __stdcall free_func_cdecl(); // expected-error {{function declared 'stdcall' here was previously declared 'cdecl'}} |
| 15 | void __fastcall free_func_cdecl(); // expected-error {{function declared 'fastcall' here was previously declared 'cdecl'}} |
| 16 | |
| 17 | void __cdecl free_func_stdcall(); // expected-error {{function declared 'cdecl' here was previously declared 'stdcall'}} |
| 18 | void free_func_stdcall(); // expected-note {{previous declaration is here}} |
| 19 | void __fastcall free_func_stdcall(); // expected-error {{function declared 'fastcall' here was previously declared 'stdcall'}} |
| 20 | |
| 21 | void __cdecl free_func_fastcall(); // expected-error {{function declared 'cdecl' here was previously declared 'fastcall'}} |
| 22 | void __stdcall free_func_fastcall(); // expected-error {{function declared 'stdcall' here was previously declared 'fastcall'}} |
| 23 | void free_func_fastcall(); |
| 24 | |
| 25 | // Overloaded functions may have different calling conventions |
| 26 | void __fastcall free_func_default(int); |
| 27 | void __cdecl free_func_default(int *); |
| 28 | |
| 29 | void __thiscall free_func_cdecl(char *); |
| 30 | void __cdecl free_func_cdecl(double); |
| 31 | |
| 32 | |
| 33 | // Pointers to member functions |
| 34 | struct S { |
| 35 | void member_default1(); // expected-note {{previous declaration is here}} |
| 36 | void member_default2(); |
| 37 | void __cdecl member_cdecl1(); |
| 38 | void __cdecl member_cdecl2(); // expected-note {{previous declaration is here}} |
| 39 | void __thiscall member_thiscall1(); |
| 40 | void __thiscall member_thiscall2(); // expected-note {{previous declaration is here}} |
| 41 | |
| 42 | // Static member functions can't be __thiscall |
| 43 | static void static_member_default1(); |
| 44 | static void static_member_default2(); // expected-note {{previous declaration is here}} |
| 45 | static void __cdecl static_member_cdecl1(); |
| 46 | static void __cdecl static_member_cdecl2(); // expected-note {{previous declaration is here}} |
| 47 | static void __stdcall static_member_stdcall1(); |
| 48 | static void __stdcall static_member_stdcall2(); |
| 49 | |
| 50 | // Variadic functions can't be other than default or __cdecl |
| 51 | void member_variadic_default(int x, ...); |
| 52 | void __cdecl member_variadic_cdecl(int x, ...); |
| 53 | |
| 54 | static void static_member_variadic_default(int x, ...); |
| 55 | static void __cdecl static_member_variadic_cdecl(int x, ...); |
| 56 | }; |
| 57 | |
| 58 | void __cdecl S::member_default1() {} // expected-error {{function declared 'cdecl' here was previously declared without calling convention}} |
| 59 | void __thiscall S::member_default2() {} |
| 60 | |
| 61 | void S::member_cdecl1() {} |
| 62 | void __thiscall S::member_cdecl2() {} // expected-error {{function declared 'thiscall' here was previously declared 'cdecl'}} |
| 63 | |
| 64 | void S::member_thiscall1() {} |
| 65 | void __cdecl S::member_thiscall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'thiscall'}} |
| 66 | |
| 67 | void __cdecl S::static_member_default1() {} |
| 68 | void __stdcall S::static_member_default2() {} // expected-error {{function declared 'stdcall' here was previously declared without calling convention}} |
| 69 | |
| 70 | void S::static_member_cdecl1() {} |
| 71 | void __stdcall S::static_member_cdecl2() {} // expected-error {{function declared 'stdcall' here was previously declared 'cdecl'}} |
| 72 | |
| 73 | void __cdecl S::member_variadic_default(int x, ...) { |
| 74 | (void)x; |
| 75 | } |
| 76 | void S::member_variadic_cdecl(int x, ...) { |
| 77 | (void)x; |
| 78 | } |
| 79 | |
| 80 | void __cdecl S::static_member_variadic_default(int x, ...) { |
| 81 | (void)x; |
| 82 | } |
| 83 | void S::static_member_variadic_cdecl(int x, ...) { |
| 84 | (void)x; |
| 85 | } |
| 86 | |