[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / preserve-none-call-conv.c
blob678fa7d5317e552e8f0508eca6396535b926cad1
1 // RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
2 // RUN: %clang_cc1 %s -fsyntax-only -triple aarch64-unknown-unknown -verify
4 typedef void typedef_fun_t(int);
6 void __attribute__((preserve_none)) boo(void *ptr) {
9 void __attribute__((preserve_none(1))) boo1(void *ptr) { // expected-error {{'preserve_none' attribute takes no arguments}}
12 void (__attribute__((preserve_none)) *pboo1)(void *) = boo;
14 void (__attribute__((cdecl)) *pboo2)(void *) = boo; // expected-error {{incompatible function pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_none))'}}
15 void (*pboo3)(void *) = boo; // expected-error {{incompatible function pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_none))'}}
17 typedef_fun_t typedef_fun_boo; // expected-note {{previous declaration is here}}
18 void __attribute__((preserve_none)) typedef_fun_boo(int x) { } // expected-error {{function declared 'preserve_none' here was previously declared without calling convention}}
20 struct type_test_boo {} __attribute__((preserve_none)); // expected-warning {{'preserve_none' attribute only applies to functions and function pointers}}