blob: e487020c4c5316f9951c7deaeaddeefb510b53bb [file] [log] [blame]
Aaron Ballman82bfa192012-10-02 14:26:08 +00001// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -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}}
Aaron Ballman82bfa192012-10-02 14:26:08 +000043/* These are ignored because the target is i386 and not ARM */
44int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
45int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
Richard Smithd03de6a2013-01-29 10:02:16 +000046int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
Benjamin Kramerfac8e432012-08-14 13:13:47 +000047
Charles Davis064f7db2010-02-23 06:13:55 +000048// PR6361
49void ctest3();
50void __attribute__((cdecl)) ctest3() {}
51
Charles Davis328ce342010-02-24 02:27:18 +000052// PR6408
53typedef __attribute__((stdcall)) void (*PROC)();
54PROC __attribute__((cdecl)) ctest4(const char *x) {}
55
Derek Schuff263366f2012-10-16 22:30:41 +000056void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}}
Guy Benyei38980082012-12-25 08:53:55 +000057
58void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}