blob: c7a4821412cd2ae1b14370172ebb0779b40029de [file] [log] [blame]
Aaron Ballman82bfa192012-10-02 14:26:08 +00001// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify
Hans Wennborg3636fb12013-10-08 21:52:56 +00002// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify
Nate Begemanb6789ca2008-03-07 20:04:49 +00003
Aaron Ballmanbaec7782013-07-23 19:30:11 +00004void __attribute__((fastcall)) foo(float *a) {
Nate Begemanb6789ca2008-03-07 20:04:49 +00005}
6
Aaron Ballmanbaec7782013-07-23 19:30:11 +00007void __attribute__((stdcall)) bar(float *a) {
Nate Begemanb6789ca2008-03-07 20:04:49 +00008}
9
Aaron Ballmanbaec7782013-07-23 19:30:11 +000010void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
Nate Begemanb6789ca2008-03-07 20:04:49 +000011}
John McCall9112b932009-11-04 03:36:09 +000012
Stephen Hines176edba2014-12-01 14:53:08 -080013void __attribute__((fastcall)) test0() {
John McCall9112b932009-11-04 03:36:09 +000014}
15
16void __attribute__((fastcall)) test1(void) {
17}
18
Hans Wennborg3636fb12013-10-08 21:52:56 +000019void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}}
20}
Hans Wennborg45d39502013-10-09 18:10:25 +000021void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}}
John McCall9112b932009-11-04 03:36:09 +000022}
Hans Wennborg45d39502013-10-09 18:10:25 +000023void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}}
24}
Eli Friedman8f4c59e2009-11-09 18:38:53 +000025
26void __attribute__((cdecl)) ctest0() {}
27
Aaron Ballmanbaec7782013-07-23 19:30:11 +000028void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
John McCallf82b4e82010-02-04 05:44:44 +000029
30void (__attribute__((fastcall)) *pfoo)(float*) = foo;
31
32void (__attribute__((stdcall)) *pbar)(float*) = bar;
33
34void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}}
35
36void (*pctest0)() = ctest0;
37
38void ctest2() {}
39void (__attribute__((cdecl)) *pctest2)() = ctest2;
40
John McCall04a67a62010-02-05 21:31:56 +000041typedef void (__attribute__((fastcall)) *Handler) (float *);
42Handler H = foo;
43
Aaron Ballmanbaec7782013-07-23 19:30:11 +000044int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
45int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
Aaron Ballmanfbf6f5c2013-09-13 17:48:25 +000046int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
47 // expected-error {{invalid PCS type}}
Aaron Ballman3cd6feb2013-07-30 01:31:03 +000048int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
Aaron Ballman82bfa192012-10-02 14:26:08 +000049/* These are ignored because the target is i386 and not ARM */
50int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
51int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
Richard Smithd03de6a2013-01-29 10:02:16 +000052int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
Benjamin Kramerfac8e432012-08-14 13:13:47 +000053
Charles Davis064f7db2010-02-23 06:13:55 +000054// PR6361
55void ctest3();
56void __attribute__((cdecl)) ctest3() {}
57
Charles Davis328ce342010-02-24 02:27:18 +000058// PR6408
59typedef __attribute__((stdcall)) void (*PROC)();
60PROC __attribute__((cdecl)) ctest4(const char *x) {}
61
Guy Benyei38980082012-12-25 08:53:55 +000062void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
Reid Kleckneref072032013-08-27 23:08:25 +000063
64typedef void typedef_fun_t(int);
65typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}}
66void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
Stephen Hines651f13c2014-04-23 16:59:28 -070067
68struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}}