[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Parser / asm-goto.c
blobf9ad6c5ee9a409be6637d032405d141222482114
1 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
4 #if !__has_extension(gnu_asm)
5 #error Extension 'gnu_asm' should be available by default
6 #endif
7 #if !__has_extension(gnu_asm_goto_with_outputs)
8 #error Extension 'gnu_asm_goto_with_outputs' should be available by default
9 #endif
11 int a, b, c, d, e, f, g, h, i, j, k, l;
13 void test(void) {
14 __asm__ volatile goto (""
15 :: [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
16 [e] "r" (e), [f] "r" (f), [g] "r" (g), [h] "r" (h),
17 [i] "r" (i), [j] "r" (j), [k] "r" (k), [l] "r" (l)
18 ::lab1,lab2);
19 lab1: return;
20 lab2: return;
23 void test2(void) {
24 __asm__ volatile goto (""
25 :: [a] "r,m" (a), [b] "r,m" (b), [c] "r,m" (c), [d] "r,m" (d),
26 [e] "r,m" (e), [f] "r,m" (f), [g] "r,m" (g), [h] "r,m" (h),
27 [i] "r,m" (i), [j] "r,m" (j), [k] "r,m" (k), [l] "r,m" (l)
28 :: lab);
29 lab: return;
32 int test3(int x) {
33 __asm__ volatile goto ("decl %0; jnz %l[a]"
34 : "=r" (x) : "m" (x) : "memory" : a);
36 return -x;
39 int test4(int x) {
40 int y;
41 if (x > 42)
42 __asm__ volatile goto ("decl %0; jnz %l[a]"
43 : "=r" (x), "=r" (y) : "m" (x) : "memory" : a);
44 else
45 __asm__ volatile goto ("decl %0; jnz %l[b]"
46 : "=r" (x), "=r" (y) : "m" (x) : "memory" : b);
47 x = y + 42;
49 return -x;
51 return +x;
54 int test5(void) {
55 int x,cond,*e;
56 // expected-error@+1 {{expected ')'}}
57 asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)
58 // expected-error@+1 {{expected identifier}}
59 asm goto ("decl %0;" :: "m"(x) : "memory" : );
60 // expected-error@+1 {{expected ':'}}
61 asm goto ("decl %0;" :: "m"(x) : "memory" );
62 // expected-error@+1 {{use of undeclared label 'x'}}
63 asm goto ("decl %0;" :: "m"(x) : "memory" :x);
64 // expected-error@+1 {{use of undeclared label 'b'}}
65 asm goto ("decl %0;" :: "m"(x) : "memory" :b);
66 // expected-error@+1 {{invalid operand number in inline asm string}}
67 asm goto ("testl %0, %0; jne %l3;" :: "r"(cond)::label_true, loop);
68 // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}
69 asm goto ("decl %0; jnz %l[b]" :: "m"(x) : "memory" : a);
71 label_true:
72 loop:
73 return 0;
76 int test6(int y) {
77 int x,cond,*e;
78 // expected-error@+1 {{expected ')'}}
79 asm ("mov %[e], %[e]" : "=r" (y) : [e] "rm" (*e), "r" (y) :: a)
80 // expected-error@+1 {{expected identifier}}
81 asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" :);
82 // expected-error@+1 {{expected ':'}}
83 asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory");
84 // expected-error@+1 {{use of undeclared label 'x'}}
85 asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : x);
86 // expected-error@+1 {{use of undeclared label 'b'}}
87 asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : b);
88 // expected-error@+1 {{invalid operand number in inline asm string}}
89 asm goto ("testl %0, %0; jne %l5;" : "=r" (y) : "r" (cond), "r" (y) :: label_true, loop);
90 // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}
91 asm goto ("decl %0; jnz %l[b]" : "=r" (y) : "m" (x), "r" (y) : "memory" : a);
92 label_true:
93 loop:
95 return 0;