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_user() #0 |
8 | // CHECK: ret void |
9 | __attribute__((interrupt("user"))) void foo_user(void) {} |
10 | // CHECK-LABEL: @foo_supervisor() #1 |
11 | // CHECK: ret void |
12 | __attribute__((interrupt("supervisor"))) void foo_supervisor(void) {} |
13 | // CHECK-LABEL: @foo_machine() #2 |
14 | // CHECK: ret void |
15 | __attribute__((interrupt("machine"))) void foo_machine(void) {} |
16 | // CHECK-LABEL: @foo_default() #2 |
17 | // CHECK: ret void |
18 | __attribute__((interrupt())) void foo_default(void) {} |
19 | // CHECK-LABEL: @foo_default2() #2 |
20 | // CHECK: ret void |
21 | __attribute__((interrupt())) void foo_default2(void) {} |
22 | // CHECK: attributes #0 |
23 | // CHECK: "interrupt"="user" |
24 | // CHECK: attributes #1 |
25 | // CHECK: "interrupt"="supervisor" |
26 | // CHECK: attributes #2 |
27 | // CHECK: "interrupt"="machine" |
28 | #else |
29 | struct a { int b; }; |
30 | |
31 | struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} |
32 | |
33 | __attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: USER}} |
34 | |
35 | __attribute__((interrupt("user", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}} |
36 | |
37 | __attribute__((interrupt)) int foo3(void) {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}} |
38 | |
39 | __attribute__((interrupt())) void foo4(); |
40 | __attribute__((interrupt())) void foo4() {}; |
41 | |
42 | __attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}} |
43 | |
44 | __attribute__((interrupt("user"), interrupt("supervisor"))) void foo6(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ |
45 | // expected-note {{repeated RISC-V 'interrupt' attribute is here}} |
46 | |
47 | __attribute__((interrupt, interrupt)) void foo7(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ |
48 | // expected-note {{repeated RISC-V 'interrupt' attribute is here}} |
49 | |
50 | __attribute__((interrupt(""))) void foo8(void) {} // expected-warning {{'interrupt' attribute argument not supported}} |
51 | |
52 | __attribute__((interrupt("user"))) void foo9(void); |
53 | __attribute__((interrupt("supervisor"))) void foo9(void); |
54 | __attribute__((interrupt("machine"))) void foo9(void); |
55 | |
56 | __attribute__((interrupt("user"))) void foo10(void) {} |
57 | __attribute__((interrupt("supervisor"))) void foo11(void) {} |
58 | __attribute__((interrupt("machine"))) void foo12(void) {} |
59 | __attribute__((interrupt())) void foo13(void) {} |
60 | __attribute__((interrupt)) void foo14(void) {} |
61 | #endif |
62 | |
63 | |