75 lines · c
1// RUN: %clang_cc1 -triple riscv32-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s2// RUN: %clang_cc1 -triple riscv64-unknown-elf -emit-llvm -DCHECK_IR < %s| FileCheck %s3// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only4// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only5 6#if defined(CHECK_IR)7// CHECK-LABEL: @foo_supervisor() #08// CHECK: ret void9__attribute__((interrupt("supervisor"))) void foo_supervisor(void) {}10// CHECK-LABEL: @foo_machine() #111// CHECK: ret void12__attribute__((interrupt("machine"))) void foo_machine(void) {}13// CHECK-LABEL: @foo_default() #114// CHECK: ret void15__attribute__((interrupt())) void foo_default(void) {}16// CHECK-LABEL: @foo_default2() #117// CHECK: ret void18__attribute__((interrupt())) void foo_default2(void) {}19// CHECK-LABEL: @foo_machine_twice() #120// CHECK: ret void21__attribute__((interrupt("machine", "machine")))22void foo_machine_twice(void) {}23// CHECK-LABEL: @foo_supervisor_twice() #024// CHECK: ret void25__attribute__((interrupt("supervisor", "supervisor")))26void foo_supervisor_twice(void) {}27 28// CHECK: attributes #029// CHECK: "interrupt"="supervisor"30// CHECK: attributes #131// CHECK: "interrupt"="machine"32#else33__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}}38struct a { int b; };39 40struct 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#endif74 75