1 // RUN: %clang_cc1 %s -verify -fsyntax-only -triple i686-pc-linux
2
3 int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}
4
t0(void)5 __attribute__((naked)) int t0(void) {
6 __asm__ volatile("mov r0, #0");
7 }
8
9 void t1(void) __attribute__((naked));
10
11 void t2(void) __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}
12
t3(void)13 __attribute__((naked)) int t3(void) { // expected-note{{attribute is here}}
14 return 42; // expected-error{{non-ASM statement in naked function is not supported}}
15 }
16
t4(void)17 __attribute__((naked)) int t4(void) {
18 asm("movl $42, %eax");
19 asm("retl");
20 }
21
t5(int x)22 __attribute__((naked)) int t5(int x) {
23 asm("movl x, %eax");
24 asm("retl");
25 }
26
t6(void)27 __attribute__((naked)) void t6(void) {
28 ;
29 }
30
t7(void)31 __attribute__((naked)) void t7(void) {
32 asm("movl $42, %eax");
33 ;
34 }
35
36 extern int x, y;
37
t8(int z)38 __attribute__((naked)) void t8(int z) { // expected-note{{attribute is here}}
39 __asm__ ("movl $42, %1"
40 : "=r"(x),
41 "=r"(z) // expected-error{{parameter references not allowed in naked functions}}
42 );
43 }
44
t9(int z)45 __attribute__((naked)) void t9(int z) { // expected-note{{attribute is here}}
46 __asm__ ("movl %eax, %1"
47 : : "r"(x),
48 "r"(z) // expected-error{{parameter references not allowed in naked functions}}
49 );
50 }
51
t10(void)52 __attribute__((naked)) void t10(void) { // expected-note{{attribute is here}}
53 int a; // expected-error{{non-ASM statement in naked function is not supported}}
54 }
55
t11(void)56 __attribute__((naked)) void t11(void) { // expected-note{{attribute is here}}
57 register int a asm("eax") = x; // expected-error{{non-ASM statement in naked function is not supported}}
58 }
59
t12(void)60 __attribute__((naked)) void t12(void) { // expected-note{{attribute is here}}
61 register int a asm("eax"), b asm("ebx") = x; // expected-error{{non-ASM statement in naked function is not supported}}
62 }
63
t13(void)64 __attribute__((naked)) void t13(void) {
65 register int a asm("eax");
66 register int b asm("ebx"), c asm("ecx");
67 }
68
69