Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify |
Hans Wennborg | 3636fb1 | 2013-10-08 21:52:56 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 3 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 4 | void __attribute__((fastcall)) foo(float *a) { |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 5 | } |
| 6 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 7 | void __attribute__((stdcall)) bar(float *a) { |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 8 | } |
| 9 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 10 | void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}} |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 11 | } |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 12 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 13 | void __attribute__((fastcall)) test0() { |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | void __attribute__((fastcall)) test1(void) { |
| 17 | } |
| 18 | |
Hans Wennborg | 3636fb1 | 2013-10-08 21:52:56 +0000 | [diff] [blame] | 19 | void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}} |
| 20 | } |
Hans Wennborg | 45d3950 | 2013-10-09 18:10:25 +0000 | [diff] [blame] | 21 | void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}} |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 22 | } |
Hans Wennborg | 45d3950 | 2013-10-09 18:10:25 +0000 | [diff] [blame] | 23 | void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}} |
| 24 | } |
Eli Friedman | 8f4c59e | 2009-11-09 18:38:53 +0000 | [diff] [blame] | 25 | |
| 26 | void __attribute__((cdecl)) ctest0() {} |
| 27 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 28 | void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}} |
John McCall | f82b4e8 | 2010-02-04 05:44:44 +0000 | [diff] [blame] | 29 | |
| 30 | void (__attribute__((fastcall)) *pfoo)(float*) = foo; |
| 31 | |
| 32 | void (__attribute__((stdcall)) *pbar)(float*) = bar; |
| 33 | |
| 34 | void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}} |
| 35 | |
| 36 | void (*pctest0)() = ctest0; |
| 37 | |
| 38 | void ctest2() {} |
| 39 | void (__attribute__((cdecl)) *pctest2)() = ctest2; |
| 40 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 41 | typedef void (__attribute__((fastcall)) *Handler) (float *); |
| 42 | Handler H = foo; |
| 43 | |
Aaron Ballman | baec778 | 2013-07-23 19:30:11 +0000 | [diff] [blame] | 44 | int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}} |
| 45 | int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}} |
Aaron Ballman | fbf6f5c | 2013-09-13 17:48:25 +0000 | [diff] [blame] | 46 | int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \ |
| 47 | // expected-error {{invalid PCS type}} |
Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 48 | int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}} |
Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 49 | /* These are ignored because the target is i386 and not ARM */ |
| 50 | int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}} |
| 51 | int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}} |
Richard Smith | d03de6a | 2013-01-29 10:02:16 +0000 | [diff] [blame] | 52 | int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}} |
Benjamin Kramer | fac8e43 | 2012-08-14 13:13:47 +0000 | [diff] [blame] | 53 | |
Charles Davis | 064f7db | 2010-02-23 06:13:55 +0000 | [diff] [blame] | 54 | // PR6361 |
| 55 | void ctest3(); |
| 56 | void __attribute__((cdecl)) ctest3() {} |
| 57 | |
Charles Davis | 328ce34 | 2010-02-24 02:27:18 +0000 | [diff] [blame] | 58 | // PR6408 |
| 59 | typedef __attribute__((stdcall)) void (*PROC)(); |
| 60 | PROC __attribute__((cdecl)) ctest4(const char *x) {} |
| 61 | |
Guy Benyei | 3898008 | 2012-12-25 08:53:55 +0000 | [diff] [blame] | 62 | void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} |
Reid Kleckner | ef07203 | 2013-08-27 23:08:25 +0000 | [diff] [blame] | 63 | |
| 64 | typedef void typedef_fun_t(int); |
| 65 | typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}} |
| 66 | void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}} |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 67 | |
| 68 | struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}} |