| 1 |
// RUN: %clang_cc1 -triple riscv32-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple riscv64-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s |
| 3 |
// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only |
| 4 |
// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only |
| 5 |
|
| 6 |
#if defined(CHECK_IR) |
| 7 |
// CHECK-LABEL: @foo_supervisor() #0 |
| 8 |
// CHECK: ret void |
| 9 |
__attribute__((interrupt("supervisor"))) void foo_supervisor(void) {} |
| 10 |
// CHECK-LABEL: @foo_machine() #1 |
| 11 |
// CHECK: ret void |
| 12 |
__attribute__((interrupt("machine"))) void foo_machine(void) {} |
| 13 |
// CHECK-LABEL: @foo_default() #1 |
| 14 |
// CHECK: ret void |
| 15 |
__attribute__((interrupt())) void foo_default(void) {} |
| 16 |
// CHECK-LABEL: @foo_default2() #1 |
| 17 |
// CHECK: ret void |
| 18 |
__attribute__((interrupt())) void foo_default2(void) {} |
| 19 |
// CHECK-LABEL: @foo_machine_twice() #1 |
| 20 |
// CHECK: ret void |
| 21 |
__attribute__((interrupt("machine", "machine"))) |
| 22 |
void foo_machine_twice(void) {} |
| 23 |
// CHECK-LABEL: @foo_supervisor_twice() #0 |
| 24 |
// CHECK: ret void |
| 25 |
__attribute__((interrupt("supervisor", "supervisor"))) |
| 26 |
void foo_supervisor_twice(void) {} |
| 27 |
|
| 28 |
// CHECK: attributes #0 |
| 29 |
// CHECK: "interrupt"="supervisor" |
| 30 |
// CHECK: attributes #1 |
| 31 |
// CHECK: "interrupt"="machine" |
| 32 |
#else |
| 33 |
__attribute__((interrupt("machine"), interrupt("supervisor"))) void foo6(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ |
| 34 |
// expected-note {{repeated RISC-V 'interrupt' attribute is here}} |
| 35 |
|
| 36 |
__attribute__((interrupt, interrupt)) void foo7(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ |
| 37 |
// expected-note {{repeated RISC-V 'interrupt' attribute is here}} |
| 38 |
struct a { int b; }; |
| 39 |
|
| 40 |
struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} |
| 41 |
|
| 42 |
__attribute__((interrupt)) int foo3(void) {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}} |
| 43 |
__attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}} |
| 44 |
|
| 45 |
__attribute__((interrupt("machine", "supervisor", "machine"))) void foo15(void) {} // expected-error {{'interrupt' attribute takes no more than 2 arguments}} |
| 46 |
|
| 47 |
__attribute__((interrupt(42))) void foo0(void) {} // expected-error {{expected string literal as argument of 'interrupt' attribute}} |
| 48 |
__attribute__((interrupt("machine", 1))) void foo2(void) {} // expected-error {{expected string literal as argument of 'interrupt' attribute}} |
| 49 |
__attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: "USER"}} |
| 50 |
__attribute__((interrupt("user"))) void foo1b(void) {} // expected-warning {{'interrupt' attribute argument not supported: "user"}} |
| 51 |
__attribute__((interrupt("MACHINE"))) void foo1c(void) {} // expected-warning {{'interrupt' attribute argument not supported: "MACHINE"}} |
| 52 |
|
| 53 |
__attribute__((interrupt(""))) void foo8(void) {} // expected-warning {{'interrupt' attribute argument not supported}} |
| 54 |
|
| 55 |
__attribute__((interrupt("machine", "supervisor"))) void foo_machine_supervisor(void) {} // expected-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}} |
| 56 |
__attribute__((interrupt("supervisor", "machine"))) void foo_supervisor_machine(void) {} // expected-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}} |
| 57 |
|
| 58 |
__attribute__((interrupt())) void foo4(void); |
| 59 |
__attribute__((interrupt())) void foo4(void) {} |
| 60 |
|
| 61 |
__attribute__((interrupt("supervisor"))) void foo9(void); |
| 62 |
__attribute__((interrupt("machine"))) void foo9(void); |
| 63 |
|
| 64 |
__attribute__((interrupt("supervisor"))) void foo11(void) {} |
| 65 |
__attribute__((interrupt("machine"))) void foo12(void) {} |
| 66 |
__attribute__((interrupt())) void foo13(void) {} |
| 67 |
__attribute__((interrupt)) void foo14(void) {} |
| 68 |
|
| 69 |
__attribute__((interrupt("machine", "machine"))) void foo_machine_twice(void) {} |
| 70 |
__attribute__((interrupt("supervisor", "supervisor"))) void foo_supervisor_supervisor(void) {} |
| 71 |
|
| 72 |
|
| 73 |
#endif |
| 74 |
|