Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 2 | |
| 3 | void __attribute__((fastcall)) foo(float *a) { |
| 4 | } |
| 5 | |
| 6 | void __attribute__((stdcall)) bar(float *a) { |
| 7 | } |
| 8 | |
John McCall | bdc49d3 | 2011-03-02 12:15:05 +0000 | [diff] [blame] | 9 | void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{attribute takes no arguments}} |
Nate Begeman | b6789ca | 2008-03-07 20:04:49 +0000 | [diff] [blame] | 10 | } |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 11 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 12 | void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}} |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | void __attribute__((fastcall)) test1(void) { |
| 16 | } |
| 17 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 18 | void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use fastcall calling convention}} |
John McCall | 9112b93 | 2009-11-04 03:36:09 +0000 | [diff] [blame] | 19 | } |
Eli Friedman | 8f4c59e | 2009-11-09 18:38:53 +0000 | [diff] [blame] | 20 | |
| 21 | void __attribute__((cdecl)) ctest0() {} |
| 22 | |
John McCall | bdc49d3 | 2011-03-02 12:15:05 +0000 | [diff] [blame] | 23 | void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{attribute takes no arguments}} |
John McCall | f82b4e8 | 2010-02-04 05:44:44 +0000 | [diff] [blame] | 24 | |
| 25 | void (__attribute__((fastcall)) *pfoo)(float*) = foo; |
| 26 | |
| 27 | void (__attribute__((stdcall)) *pbar)(float*) = bar; |
| 28 | |
| 29 | void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}} |
| 30 | |
| 31 | void (*pctest0)() = ctest0; |
| 32 | |
| 33 | void ctest2() {} |
| 34 | void (__attribute__((cdecl)) *pctest2)() = ctest2; |
| 35 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 36 | typedef void (__attribute__((fastcall)) *Handler) (float *); |
| 37 | Handler H = foo; |
| 38 | |
Charles Davis | 064f7db | 2010-02-23 06:13:55 +0000 | [diff] [blame] | 39 | // PR6361 |
| 40 | void ctest3(); |
| 41 | void __attribute__((cdecl)) ctest3() {} |
| 42 | |
Charles Davis | 328ce34 | 2010-02-24 02:27:18 +0000 | [diff] [blame] | 43 | // PR6408 |
| 44 | typedef __attribute__((stdcall)) void (*PROC)(); |
| 45 | PROC __attribute__((cdecl)) ctest4(const char *x) {} |
| 46 | |