blob: 6c844a3733189c82784a39c1b98c0e3fa434d96a [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify
Nate Begemanb6789ca2008-03-07 20:04:49 +00002
3void __attribute__((fastcall)) foo(float *a) {
4}
5
6void __attribute__((stdcall)) bar(float *a) {
7}
8
John McCallbdc49d32011-03-02 12:15:05 +00009void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{attribute takes no arguments}}
Nate Begemanb6789ca2008-03-07 20:04:49 +000010}
John McCall9112b932009-11-04 03:36:09 +000011
John McCall04a67a62010-02-05 21:31:56 +000012void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
John McCall9112b932009-11-04 03:36:09 +000013}
14
15void __attribute__((fastcall)) test1(void) {
16}
17
John McCall04a67a62010-02-05 21:31:56 +000018void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use fastcall calling convention}}
John McCall9112b932009-11-04 03:36:09 +000019}
Eli Friedman8f4c59e2009-11-09 18:38:53 +000020
21void __attribute__((cdecl)) ctest0() {}
22
John McCallbdc49d32011-03-02 12:15:05 +000023void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{attribute takes no arguments}}
John McCallf82b4e82010-02-04 05:44:44 +000024
25void (__attribute__((fastcall)) *pfoo)(float*) = foo;
26
27void (__attribute__((stdcall)) *pbar)(float*) = bar;
28
29void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}}
30
31void (*pctest0)() = ctest0;
32
33void ctest2() {}
34void (__attribute__((cdecl)) *pctest2)() = ctest2;
35
John McCall04a67a62010-02-05 21:31:56 +000036typedef void (__attribute__((fastcall)) *Handler) (float *);
37Handler H = foo;
38
Benjamin Kramerfac8e432012-08-14 13:13:47 +000039int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{attribute takes one argument}}
40int __attribute__((pcs())) pcs2(void); // expected-error {{attribute takes one argument}}
41int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{attribute takes one argument}}
42int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires parameter 1 to be a string}}
43int __attribute__((pcs("aapcs"))) pcs5(void); // no-error
44int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // no-error
45int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{Invalid PCS type}}
46
Charles Davis064f7db2010-02-23 06:13:55 +000047// PR6361
48void ctest3();
49void __attribute__((cdecl)) ctest3() {}
50
Charles Davis328ce342010-02-24 02:27:18 +000051// PR6408
52typedef __attribute__((stdcall)) void (*PROC)();
53PROC __attribute__((cdecl)) ctest4(const char *x) {}
54