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 foo_user(void)9__attribute__((interrupt("user"))) void foo_user(void) {} 10 // CHECK-LABEL: @foo_supervisor() #1 11 // CHECK: ret void foo_supervisor(void)12__attribute__((interrupt("supervisor"))) void foo_supervisor(void) {} 13 // CHECK-LABEL: @foo_machine() #2 14 // CHECK: ret void foo_machine(void)15__attribute__((interrupt("machine"))) void foo_machine(void) {} 16 // CHECK-LABEL: @foo_default() #2 17 // CHECK: ret void foo_default(void)18__attribute__((interrupt())) void foo_default(void) {} 19 // CHECK-LABEL: @foo_default2() #2 20 // CHECK: ret void foo_default2(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 foo1(void)33__attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: USER}} 34 foo2(void)35__attribute__((interrupt("user", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}} 36 foo3(void)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(); foo4()40__attribute__((interrupt())) void foo4() {}; 41 foo5(int a)42__attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}} 43 foo6(void)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 foo7(void)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 foo8(void)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 foo10(void)56__attribute__((interrupt("user"))) void foo10(void) {} foo11(void)57__attribute__((interrupt("supervisor"))) void foo11(void) {} foo12(void)58__attribute__((interrupt("machine"))) void foo12(void) {} foo13(void)59__attribute__((interrupt())) void foo13(void) {} foo14(void)60__attribute__((interrupt)) void foo14(void) {} 61 #endif 62 63