xref: /aosp_15_r20/external/clang/test/Sema/preserve-call-conv.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
2*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify
3*67e74705SXin Li typedef void typedef_fun_t(int);
4*67e74705SXin Li 
foo(void * ptr)5*67e74705SXin Li void __attribute__((preserve_most)) foo(void *ptr) {
6*67e74705SXin Li }
7*67e74705SXin Li 
foo1(void * ptr)8*67e74705SXin Li void __attribute__((preserve_most(1))) foo1(void *ptr) { // expected-error {{'preserve_most' attribute takes no arguments}}
9*67e74705SXin Li }
10*67e74705SXin Li 
11*67e74705SXin Li void (__attribute__((preserve_most)) *pfoo1)(void *) = foo;
12*67e74705SXin Li 
13*67e74705SXin Li void (__attribute__((cdecl)) *pfoo2)(void *) = foo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
14*67e74705SXin Li void (*pfoo3)(void *) = foo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
15*67e74705SXin Li 
16*67e74705SXin Li typedef_fun_t typedef_fun_foo; // expected-note {{previous declaration is here}}
typedef_fun_foo(int x)17*67e74705SXin Li void __attribute__((preserve_most)) typedef_fun_foo(int x) { } // expected-error {{function declared 'preserve_most' here was previously declared without calling convention}}
18*67e74705SXin Li 
19*67e74705SXin Li struct type_test_foo {} __attribute__((preserve_most));  // expected-warning {{'preserve_most' attribute only applies to functions and methods}}
20*67e74705SXin Li 
boo(void * ptr)21*67e74705SXin Li void __attribute__((preserve_all)) boo(void *ptr) {
22*67e74705SXin Li }
23*67e74705SXin Li 
boo1(void * ptr)24*67e74705SXin Li void __attribute__((preserve_all(1))) boo1(void *ptr) { // expected-error {{'preserve_all' attribute takes no arguments}}
25*67e74705SXin Li }
26*67e74705SXin Li 
27*67e74705SXin Li void (__attribute__((preserve_all)) *pboo1)(void *) = boo;
28*67e74705SXin Li 
29*67e74705SXin Li void (__attribute__((cdecl)) *pboo2)(void *) = boo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
30*67e74705SXin Li void (*pboo3)(void *) = boo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
31*67e74705SXin Li 
32*67e74705SXin Li typedef_fun_t typedef_fun_boo; // expected-note {{previous declaration is here}}
typedef_fun_boo(int x)33*67e74705SXin Li void __attribute__((preserve_all)) typedef_fun_boo(int x) { } // expected-error {{function declared 'preserve_all' here was previously declared without calling convention}}
34*67e74705SXin Li 
35*67e74705SXin Li struct type_test_boo {} __attribute__((preserve_all));  // expected-warning {{'preserve_all' attribute only applies to functions and methods}}
36