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