1 | // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s |
2 | // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsyntax-only -verify %s |
3 | // RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only -verify %s |
4 | // RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -verify %s |
5 | // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 -fsyntax-only -verify %s |
6 | |
7 | struct a { |
8 | int b; |
9 | }; |
10 | |
11 | struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to non-K&R-style functions}} |
12 | |
13 | __attribute__((interrupt)) int foo1(void) { return 0; } // expected-error-re {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'void' return type}} |
14 | __attribute__((interrupt)) void foo2(void) {} // expected-error-re {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have only a pointer parameter optionally followed by an integer parameter}} |
15 | __attribute__((interrupt)) void foo3(void *a, unsigned b, int c) {} // expected-error-re {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have only a pointer parameter optionally followed by an integer parameter}} |
16 | __attribute__((interrupt)) void foo4(int a) {} // expected-error-re {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a pointer as the first parameter}} |
17 | #ifdef _LP64 |
18 | // expected-error-re@+6 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}} |
19 | #elif defined(__x86_64__) |
20 | // expected-error-re@+4 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long long' type as the second parameter}} |
21 | #else |
22 | // expected-error-re@+2 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned int' type as the second parameter}} |
23 | #endif |
24 | __attribute__((interrupt)) void foo5(void *a, float b) {} |
25 | #ifdef _LP64 |
26 | // expected-error-re@+6 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}} |
27 | #elif defined(__x86_64__) |
28 | // expected-error-re@+4 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long long' type as the second parameter}} |
29 | #else |
30 | // expected-error-re@+2 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned int' type as the second parameter}} |
31 | #endif |
32 | __attribute__((interrupt)) void foo6(float *a, int b) {} |
33 | |
34 | #ifdef _LP64 |
35 | // expected-error-re@+4 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}} |
36 | #elif defined(__x86_64__) |
37 | // expected-error-re@+2 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long long' type as the second parameter}} |
38 | #endif |
39 | __attribute__((interrupt)) void foo7(int *a, unsigned b) {} |
40 | __attribute__((interrupt)) void foo8(int *a) {} |
41 | |
42 | void g(void (*fp)(int *)); |
43 | int main(int argc, char **argv) { |
44 | void *ptr = (void *)&foo7; |
45 | g(foo8); |
46 | |
47 | (void)ptr; |
48 | #ifndef __x86_64__ |
49 | // expected-error@+2 {{interrupt service routine cannot be called directly}} |
50 | #endif |
51 | foo7((int *)argv, argc); |
52 | foo8((int *)argv); // expected-error {{interrupt service routine cannot be called directly}} |
53 | return 0; |
54 | } |
55 | |
56 | |