brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · b88f38f Raw
34 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s2 3struct a {4  int b __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'int'}}5  static void foo(int *a) __attribute__((no_caller_saved_registers)) {}6};7 8struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' only applies to function types; type here is 'struct a'}}9 10__attribute__((no_caller_saved_registers(999))) void bar(int *) {} // expected-error {{'no_caller_saved_registers' attribute takes no arguments}}11 12void __attribute__((no_caller_saved_registers)) foo(int *){}13 14[[gnu::no_caller_saved_registers]] void foo2(int *) {}15 16typedef __attribute__((no_caller_saved_registers)) void (*foo3)(int *);17 18int (*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 20typedef void (*foo5)(int *);21 22void foo6(){} // expected-note {{previous declaration is here}}23 24void __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 26int 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