[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / m68k-rtdcall.c
blob114af64aaa5a7511c2002eb04246a55cbd62f786
1 // RUN: %clang_cc1 -triple m68k-unknown-unknown -mrtd -std=c89 -verify -verify=rtd %s
2 // RUN: %clang_cc1 -triple m68k-unknown-unknown -std=c89 -verify -verify=nortd %s
4 // rtd-error@+2 {{function with no prototype cannot use the m68k_rtd calling convention}}
5 void foo(int arg) {
6 bar(arg);
9 // nortd-note@+4 {{previous declaration is here}}
10 // nortd-error@+4 {{function declared 'm68k_rtd' here was previously declared without calling convention}}
11 // nortd-note@+4 {{previous declaration is here}}
12 // nortd-error@+4 {{function declared 'm68k_rtd' here was previously declared without calling convention}}
13 void nonvariadic1(int a, int b, int c);
14 void __attribute__((m68k_rtd)) nonvariadic1(int a, int b, int c);
15 void nonvariadic2(int a, int b, int c);
16 void __attribute__((m68k_rtd)) nonvariadic2(int a, int b, int c) { }
18 // expected-error@+2 {{variadic function cannot use m68k_rtd calling convention}}
19 void variadic(int a, ...);
20 void __attribute__((m68k_rtd)) variadic(int a, ...);
22 // rtd-note@+2 {{previous declaration is here}}
23 // rtd-error@+2 {{redeclaration of 'a' with a different type: 'void ((*))(int, int) __attribute__((cdecl))' vs 'void (*)(int, int) __attribute__((m68k_rtd))'}}
24 extern void (*a)(int, int);
25 __attribute__((cdecl)) extern void (*a)(int, int);
27 extern void (*b)(int, ...);
28 __attribute__((cdecl)) extern void (*b)(int, ...);
30 // nortd-note@+2 {{previous declaration is here}}
31 // nortd-error@+2 {{redeclaration of 'c' with a different type: 'void ((*))(int, int) __attribute__((m68k_rtd))' vs 'void (*)(int, int)'}}
32 extern void (*c)(int, int);
33 __attribute__((m68k_rtd)) extern void (*c)(int, int);
35 // expected-error@+2 {{variadic function cannot use m68k_rtd calling convention}}
36 extern void (*d)(int, ...);
37 __attribute__((m68k_rtd)) extern void (*d)(int, ...);
39 // expected-warning@+1 {{'m68k_rtd' only applies to function types; type here is 'int'}}
40 __attribute__((m68k_rtd)) static int g = 0;
42 // expected-error@+1 {{'m68k_rtd' attribute takes no arguments}}
43 void __attribute__((m68k_rtd("invalid"))) z(int a);
45 // expected-error@+1 {{function with no prototype cannot use the m68k_rtd calling convention}}
46 void __attribute__((m68k_rtd)) e();