callingconv.c revision fbf6f5c8ac0a3feb9a5add5f9221a21f68ca487a
1// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify
2
3void __attribute__((fastcall)) foo(float *a) {
4}
5
6void __attribute__((stdcall)) bar(float *a) {
7}
8
9void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
10}
11
12void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
13}
14
15void __attribute__((fastcall)) test1(void) {
16}
17
18void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use fastcall calling convention}}
19}
20
21void __attribute__((cdecl)) ctest0() {}
22
23void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
24
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
36typedef void (__attribute__((fastcall)) *Handler) (float *);
37Handler H = foo;
38
39int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
40int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
41int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
42                                           // expected-error {{invalid PCS type}}
43int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
44/* These are ignored because the target is i386 and not ARM */
45int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
46int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
47int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
48
49// PR6361
50void ctest3();
51void __attribute__((cdecl)) ctest3() {}
52
53// PR6408
54typedef __attribute__((stdcall)) void (*PROC)();
55PROC __attribute__((cdecl)) ctest4(const char *x) {}
56
57void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}}
58
59void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
60
61typedef void typedef_fun_t(int);
62typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}}
63void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
64