annotate clang/test/Sema/attr-x86-interrupt.c @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 struct a {
anatofuz
parents:
diff changeset
8 int b;
anatofuz
parents:
diff changeset
9 };
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to non-K&R-style functions}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
17 #ifdef _LP64
anatofuz
parents:
diff changeset
18 // expected-error-re@+6 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}}
anatofuz
parents:
diff changeset
19 #elif defined(__x86_64__)
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
21 #else
anatofuz
parents:
diff changeset
22 // expected-error-re@+2 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned int' type as the second parameter}}
anatofuz
parents:
diff changeset
23 #endif
anatofuz
parents:
diff changeset
24 __attribute__((interrupt)) void foo5(void *a, float b) {}
anatofuz
parents:
diff changeset
25 #ifdef _LP64
anatofuz
parents:
diff changeset
26 // expected-error-re@+6 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}}
anatofuz
parents:
diff changeset
27 #elif defined(__x86_64__)
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
29 #else
anatofuz
parents:
diff changeset
30 // expected-error-re@+2 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned int' type as the second parameter}}
anatofuz
parents:
diff changeset
31 #endif
anatofuz
parents:
diff changeset
32 __attribute__((interrupt)) void foo6(float *a, int b) {}
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 #ifdef _LP64
anatofuz
parents:
diff changeset
35 // expected-error-re@+4 {{{{(x86|x86-64)}} 'interrupt' attribute only applies to functions that have a 'unsigned long' type as the second parameter}}
anatofuz
parents:
diff changeset
36 #elif defined(__x86_64__)
anatofuz
parents:
diff changeset
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}}
anatofuz
parents:
diff changeset
38 #endif
anatofuz
parents:
diff changeset
39 __attribute__((interrupt)) void foo7(int *a, unsigned b) {}
anatofuz
parents:
diff changeset
40 __attribute__((interrupt)) void foo8(int *a) {}
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 void g(void (*fp)(int *));
anatofuz
parents:
diff changeset
43 int main(int argc, char **argv) {
anatofuz
parents:
diff changeset
44 void *ptr = (void *)&foo7;
anatofuz
parents:
diff changeset
45 g(foo8);
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 (void)ptr;
anatofuz
parents:
diff changeset
48 #ifndef __x86_64__
anatofuz
parents:
diff changeset
49 // expected-error@+2 {{interrupt service routine cannot be called directly}}
anatofuz
parents:
diff changeset
50 #endif
anatofuz
parents:
diff changeset
51 foo7((int *)argv, argc);
anatofuz
parents:
diff changeset
52 foo8((int *)argv); // expected-error {{interrupt service routine cannot be called directly}}
anatofuz
parents:
diff changeset
53 return 0;
anatofuz
parents:
diff changeset
54 }
anatofuz
parents:
diff changeset
55