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