blob: 6bd049ffdca294dfbf93b2e2b55cfccd39dbf36a [file] [log] [blame]
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00001// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
2// RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify
Saleem Abdulrasool4d321332017-09-26 19:26:01 +00003// 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
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00006typedef void typedef_fun_t(int);
7
8void __attribute__((preserve_most)) foo(void *ptr) {
9}
10
11void __attribute__((preserve_most(1))) foo1(void *ptr) { // expected-error {{'preserve_most' attribute takes no arguments}}
12}
13
14void (__attribute__((preserve_most)) *pfoo1)(void *) = foo;
15
16void (__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))'}}
17void (*pfoo3)(void *) = foo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
18
19typedef_fun_t typedef_fun_foo; // expected-note {{previous declaration is here}}
20void __attribute__((preserve_most)) typedef_fun_foo(int x) { } // expected-error {{function declared 'preserve_most' here was previously declared without calling convention}}
21
22struct type_test_foo {} __attribute__((preserve_most)); // expected-warning {{'preserve_most' attribute only applies to functions and methods}}
23
24void __attribute__((preserve_all)) boo(void *ptr) {
25}
26
27void __attribute__((preserve_all(1))) boo1(void *ptr) { // expected-error {{'preserve_all' attribute takes no arguments}}
28}
29
30void (__attribute__((preserve_all)) *pboo1)(void *) = boo;
31
32void (__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))'}}
33void (*pboo3)(void *) = boo; // expected-warning {{incompatible pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
34
35typedef_fun_t typedef_fun_boo; // expected-note {{previous declaration is here}}
36void __attribute__((preserve_all)) typedef_fun_boo(int x) { } // expected-error {{function declared 'preserve_all' here was previously declared without calling convention}}
37
38struct type_test_boo {} __attribute__((preserve_all)); // expected-warning {{'preserve_all' attribute only applies to functions and methods}}