[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / riscv-interrupt-attr.c
blob756bfa0582de7bea71e90384c5ea8e07d58bdd94
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
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: attributes #0
20 // CHECK: "interrupt"="supervisor"
21 // CHECK: attributes #1
22 // CHECK: "interrupt"="machine"
23 #else
24 struct a { int b; };
26 struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}}
28 __attribute__((interrupt(42))) void foo0(void) {} // expected-error {{expected string literal as argument of 'interrupt' attribute}}
29 __attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: USER}}
30 __attribute__((interrupt("user"))) void foo1b(void) {} // expected-warning {{'interrupt' attribute argument not supported: user}}
31 __attribute__((interrupt("MACHINE"))) void foo1c(void) {} // expected-warning {{'interrupt' attribute argument not supported: MACHINE}}
33 __attribute__((interrupt("machine", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
35 __attribute__((interrupt)) int foo3(void) {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}}
37 __attribute__((interrupt())) void foo4(void);
38 __attribute__((interrupt())) void foo4(void) {}
40 __attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}}
42 __attribute__((interrupt("machine"), interrupt("supervisor"))) void foo6(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
43 // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
45 __attribute__((interrupt, interrupt)) void foo7(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
46 // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
48 __attribute__((interrupt(""))) void foo8(void) {} // expected-warning {{'interrupt' attribute argument not supported}}
50 __attribute__((interrupt("supervisor"))) void foo9(void);
51 __attribute__((interrupt("machine"))) void foo9(void);
53 __attribute__((interrupt("supervisor"))) void foo11(void) {}
54 __attribute__((interrupt("machine"))) void foo12(void) {}
55 __attribute__((interrupt())) void foo13(void) {}
56 __attribute__((interrupt)) void foo14(void) {}
57 #endif