69 lines · c
1// RUN: %clang_cc1 %s -verify -fsyntax-only -triple i686-pc-linux2 3int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}4 5__attribute__((naked)) int t0(void) {6 __asm__ volatile("mov r0, #0");7}8 9void t1(void) __attribute__((naked));10 11void t2(void) __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}12 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 17__attribute__((naked)) int t4(void) {18 asm("movl $42, %eax");19 asm("retl");20}21 22__attribute__((naked)) int t5(int x) {23 asm("movl x, %eax");24 asm("retl");25}26 27__attribute__((naked)) void t6(void) {28 ;29}30 31__attribute__((naked)) void t7(void) {32 asm("movl $42, %eax");33 ;34}35 36extern int x, y;37 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 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 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 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 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 64__attribute__((naked)) void t13(void) {65 register int a asm("eax");66 register int b asm("ebx"), c asm("ecx");67}68 69