[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / riscv-interrupt-attr.c
blob2f5f2a44c778d26ff17c6d8dd5dce149d52d664e
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_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; };
31 struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}}
33 __attribute__((interrupt("USER"))) void foo1(void) {} // expected-warning {{'interrupt' attribute argument not supported: USER}}
35 __attribute__((interrupt("user", 1))) void foo2(void) {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
37 __attribute__((interrupt)) int foo3(void) {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}}
39 __attribute__((interrupt())) void foo4(void);
40 __attribute__((interrupt())) void foo4(void) {}
42 __attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}}
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}}
47 __attribute__((interrupt, interrupt)) void foo7(void) {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \
48 // expected-note {{repeated RISC-V 'interrupt' attribute is here}}
50 __attribute__((interrupt(""))) void foo8(void) {} // expected-warning {{'interrupt' attribute argument not supported}}
52 __attribute__((interrupt("user"))) void foo9(void);
53 __attribute__((interrupt("supervisor"))) void foo9(void);
54 __attribute__((interrupt("machine"))) void foo9(void);
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