| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s |
| 2 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s -DNO_CALLER_SAVED_REGISTERS=1 |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature -x87 -target-feature -mmx -target-feature -sse -fsyntax-only -verify %s -DGPRONLY=1 |
| 4 |
|
| 5 |
#if defined(NO_CALLER_SAVED_REGS) || defined(GPRONLY) |
| 6 |
// expected-no-diagnostics |
| 7 |
#else |
| 8 |
#define EXPECT_WARNING |
| 9 |
#endif |
| 10 |
|
| 11 |
#ifdef NO_CALLER_SAVED_REGS |
| 12 |
__attribute__((no_caller_saved_registers)) |
| 13 |
#endif |
| 14 |
#ifdef EXPECT_WARNING |
| 15 |
// expected-note@+3 {{'foo' declared here}} |
| 16 |
// expected-note@+2 {{'foo' declared here}} |
| 17 |
#endif |
| 18 |
extern void foo(void *); |
| 19 |
|
| 20 |
__attribute__((no_caller_saved_registers)) |
| 21 |
void no_caller_saved_registers(void *arg) { |
| 22 |
#ifdef EXPECT_WARNING |
| 23 |
// expected-warning@+2 {{function with attribute 'no_caller_saved_registers' should only call a function with attribute 'no_caller_saved_registers' or be compiled with '-mgeneral-regs-only'}} |
| 24 |
#endif |
| 25 |
foo(arg); |
| 26 |
} |
| 27 |
|
| 28 |
__attribute__((interrupt)) |
| 29 |
void interrupt(void *arg) { |
| 30 |
#ifdef EXPECT_WARNING |
| 31 |
// expected-warning@+2 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers' or be compiled with '-mgeneral-regs-only'}} |
| 32 |
#endif |
| 33 |
foo(arg); |
| 34 |
} |