blob: 3175af7f1b072daa807c5ddfd89903450b28413d [file] [log] [blame]
Timur Iskhodzhanov33b52ad2013-02-22 12:42:50 +00001// RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi microsoft -fms-extensions -verify %s
2
3// Pointers to free functions
4void free_func_default();
5void __cdecl free_func_cdecl();
6void __stdcall free_func_stdcall(); // expected-note {{previous declaration is here}}
7void __fastcall free_func_fastcall(); // expected-note 2 {{previous declaration is here}}
8
9void __cdecl free_func_default(); // expected-note 2 {{previous declaration is here}}
10void __stdcall free_func_default(); // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
11void __fastcall free_func_default(); // expected-error {{function declared 'fastcall' here was previously declared without calling convention}}
12
13void free_func_cdecl(); // expected-note 2 {{previous declaration is here}}
14void __stdcall free_func_cdecl(); // expected-error {{function declared 'stdcall' here was previously declared 'cdecl'}}
15void __fastcall free_func_cdecl(); // expected-error {{function declared 'fastcall' here was previously declared 'cdecl'}}
16
17void __cdecl free_func_stdcall(); // expected-error {{function declared 'cdecl' here was previously declared 'stdcall'}}
18void free_func_stdcall(); // expected-note {{previous declaration is here}}
19void __fastcall free_func_stdcall(); // expected-error {{function declared 'fastcall' here was previously declared 'stdcall'}}
20
21void __cdecl free_func_fastcall(); // expected-error {{function declared 'cdecl' here was previously declared 'fastcall'}}
22void __stdcall free_func_fastcall(); // expected-error {{function declared 'stdcall' here was previously declared 'fastcall'}}
23void free_func_fastcall();
24
25// Overloaded functions may have different calling conventions
26void __fastcall free_func_default(int);
27void __cdecl free_func_default(int *);
28
29void __thiscall free_func_cdecl(char *);
30void __cdecl free_func_cdecl(double);
31
32
33// Pointers to member functions
34struct 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
58void __cdecl S::member_default1() {} // expected-error {{function declared 'cdecl' here was previously declared without calling convention}}
59void __thiscall S::member_default2() {}
60
61void S::member_cdecl1() {}
62void __thiscall S::member_cdecl2() {} // expected-error {{function declared 'thiscall' here was previously declared 'cdecl'}}
63
64void S::member_thiscall1() {}
65void __cdecl S::member_thiscall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'thiscall'}}
66
67void __cdecl S::static_member_default1() {}
68void __stdcall S::static_member_default2() {} // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
69
70void S::static_member_cdecl1() {}
71void __stdcall S::static_member_cdecl2() {} // expected-error {{function declared 'stdcall' here was previously declared 'cdecl'}}
72
73void __cdecl S::member_variadic_default(int x, ...) {
74 (void)x;
75}
76void S::member_variadic_cdecl(int x, ...) {
77 (void)x;
78}
79
80void __cdecl S::static_member_variadic_default(int x, ...) {
81 (void)x;
82}
83void S::static_member_variadic_cdecl(int x, ...) {
84 (void)x;
85}
86