1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
2 
3 struct a {
4   int b __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'int'}}
fooa5   static void foo(int *a) __attribute__((no_caller_saved_registers)) {}
6 };
7 
8 struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'struct a'}}
9 
bar(int *)10 __attribute__((no_caller_saved_registers(999))) void bar(int *) {} // expected-error {{'no_caller_saved_registers' attribute takes no arguments}}
11 
foo(int *)12 void __attribute__((no_caller_saved_registers)) foo(int *){}
13 
foo2(int *)14 [[gnu::no_caller_saved_registers]] void foo2(int *) {}
15 
16 typedef __attribute__((no_caller_saved_registers)) void (*foo3)(int *);
17 
18 int (*foo4)(double a, __attribute__((no_caller_saved_registers)) float b); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'float'}}
19 
20 typedef void (*foo5)(int *);
21 
foo6()22 void foo6(){} // expected-note {{previous declaration is here}}
23 
24 void __attribute__((no_caller_saved_registers)) foo6(); // expected-error {{function declared with 'no_caller_saved_registers' attribute was previously declared without the 'no_caller_saved_registers' attribute}}
25 
main(int argc,char ** argv)26 int main(int argc, char **argv) {
27   void (*fp)(int *) = foo; // expected-error {{cannot initialize a variable of type 'void (*)(int *)' with an lvalue of type 'void (int *) __attribute__((no_caller_saved_registers))'}}
28   a::foo(&argc);
29   foo3 func = foo2;
30   func(&argc);
31   foo5 __attribute__((no_caller_saved_registers)) func2 = foo2;
32   return 0;
33 }
34