annotate clang/test/Sema/callingconv.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 0572611fdcc8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
1 // RUN: %clang_cc1 %s -fsyntax-only -Wno-strict-prototypes -triple i386-unknown-unknown -verify
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
2 // RUN: %clang_cc1 %s -fsyntax-only -Wno-strict-prototypes -triple i386-unknown-unknown -fms-compatibility -DWIN -verify
150
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 void __attribute__((fastcall)) foo(float *a) {
anatofuz
parents:
diff changeset
5 }
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 void __attribute__((stdcall)) bar(float *a) {
anatofuz
parents:
diff changeset
8 }
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
anatofuz
parents:
diff changeset
11 }
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 void __attribute__((fastcall)) test0() {
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 void __attribute__((fastcall)) test1(void) {
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention is not supported on variadic function}}
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21 void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention is not supported on variadic function}}
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23 void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}}
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 void __attribute__((cdecl)) ctest0() {}
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 void (__attribute__((fastcall)) *pfoo)(float*) = foo;
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 void (__attribute__((stdcall)) *pbar)(float*) = bar;
anatofuz
parents:
diff changeset
33
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
34 void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-error {{incompatible function pointer types}}
150
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 void (*pctest0)() = ctest0;
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 void ctest2() {}
anatofuz
parents:
diff changeset
39 void (__attribute__((cdecl)) *pctest2)() = ctest2;
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 typedef void (__attribute__((fastcall)) *Handler) (float *);
anatofuz
parents:
diff changeset
42 Handler H = foo;
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
anatofuz
parents:
diff changeset
45 int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
anatofuz
parents:
diff changeset
46 int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
anatofuz
parents:
diff changeset
47 // expected-error {{invalid PCS type}}
anatofuz
parents:
diff changeset
48 int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
anatofuz
parents:
diff changeset
49 /* These are ignored because the target is i386 and not ARM */
anatofuz
parents:
diff changeset
50 int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
51 int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
anatofuz
parents:
diff changeset
52 int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 int __attribute__((aarch64_vector_pcs)) aavpcs(void); // expected-warning {{'aarch64_vector_pcs' calling convention is not supported for this target}}
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
55 int __attribute__((aarch64_sve_pcs)) aasvepcs(void); // expected-warning {{'aarch64_sve_pcs' calling convention is not supported for this target}}
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
56
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
57 int __attribute__((amdgpu_kernel)) amdgpu_kernel(void); // expected-warning {{'amdgpu_kernel' calling convention is not supported for this target}}
150
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 // PR6361
anatofuz
parents:
diff changeset
60 void ctest3();
anatofuz
parents:
diff changeset
61 void __attribute__((cdecl)) ctest3() {}
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 // PR6408
anatofuz
parents:
diff changeset
64 typedef __attribute__((stdcall)) void (*PROC)();
anatofuz
parents:
diff changeset
65 PROC __attribute__((cdecl)) ctest4(const char *x) {}
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 typedef void typedef_fun_t(int);
anatofuz
parents:
diff changeset
70 typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}}
anatofuz
parents:
diff changeset
71 void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}}
anatofuz
parents:
diff changeset
74
anatofuz
parents:
diff changeset
75 void __vectorcall __builtin_unreachable(); // expected-warning {{vectorcall calling convention is not supported on builtin function}}