1b8fee677SJennifer Yu // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s
2b8fee677SJennifer Yu // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s
3b8fee677SJennifer Yu
4*50cac248SBill Wendling int a, b, c, d, e, f, g, h, i, j, k, l;
5*50cac248SBill Wendling
test1(void)6*50cac248SBill Wendling void test1(void) {
7*50cac248SBill Wendling __asm__ volatile goto (""
8*50cac248SBill Wendling :: [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
9*50cac248SBill Wendling [e] "r" (e), [f] "r" (f), [g] "r" (g), [h] "r" (h),
10*50cac248SBill Wendling [i] "r" (i), [j] "r" (j), [k] "r" (k), [l] "r" (l)
11*50cac248SBill Wendling ::lab1,lab2);
12*50cac248SBill Wendling lab1: return;
13*50cac248SBill Wendling lab2: return;
14*50cac248SBill Wendling }
15*50cac248SBill Wendling
test2(void)16*50cac248SBill Wendling void test2(void) {
17*50cac248SBill Wendling __asm__ volatile goto (""
18*50cac248SBill Wendling :: [a] "r,m" (a), [b] "r,m" (b), [c] "r,m" (c), [d] "r,m" (d),
19*50cac248SBill Wendling [e] "r,m" (e), [f] "r,m" (f), [g] "r,m" (g), [h] "r,m" (h),
20*50cac248SBill Wendling [i] "r,m" (i), [j] "r,m" (j), [k] "r,m" (k), [l] "r,m" (l)
21*50cac248SBill Wendling :: lab);
22*50cac248SBill Wendling lab: return;
23*50cac248SBill Wendling }
24*50cac248SBill Wendling
test3(int x)25*50cac248SBill Wendling int test3(int x) {
26*50cac248SBill Wendling __asm__ volatile goto ("decl %0; jnz %l[a]"
27*50cac248SBill Wendling : "=r" (x) : "m" (x) : "memory" : a);
28*50cac248SBill Wendling a:
29*50cac248SBill Wendling return -x;
30*50cac248SBill Wendling }
31*50cac248SBill Wendling
test4(int x)32*50cac248SBill Wendling int test4(int x) {
33*50cac248SBill Wendling int y;
34*50cac248SBill Wendling if (x > 42)
35*50cac248SBill Wendling __asm__ volatile goto ("decl %0; jnz %l[a]"
36*50cac248SBill Wendling : "=r" (x), "=r" (y) : "m" (x) : "memory" : a);
37*50cac248SBill Wendling else
38*50cac248SBill Wendling __asm__ volatile goto ("decl %0; jnz %l[b]"
39*50cac248SBill Wendling : "=r" (x), "=r" (y) : "m" (x) : "memory" : b);
40*50cac248SBill Wendling x = y + 42;
41*50cac248SBill Wendling a:
42*50cac248SBill Wendling return -x;
43*50cac248SBill Wendling b:
44*50cac248SBill Wendling return +x;
45*50cac248SBill Wendling }
46*50cac248SBill Wendling
test5(void)47*50cac248SBill Wendling int test5(void) {
48b8fee677SJennifer Yu int x,cond,*e;
49b8fee677SJennifer Yu // expected-error@+1 {{expected ')'}}
50b8fee677SJennifer Yu asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)
51*50cac248SBill Wendling // expected-error@+1 {{expected identifier}}
52b8fee677SJennifer Yu asm goto ("decl %0;" :: "m"(x) : "memory" : );
53b8fee677SJennifer Yu // expected-error@+1 {{expected ':'}}
54b8fee677SJennifer Yu asm goto ("decl %0;" :: "m"(x) : "memory" );
55b8fee677SJennifer Yu // expected-error@+1 {{use of undeclared label 'x'}}
56b8fee677SJennifer Yu asm goto ("decl %0;" :: "m"(x) : "memory" :x);
57b8fee677SJennifer Yu // expected-error@+1 {{use of undeclared label 'b'}}
58b8fee677SJennifer Yu asm goto ("decl %0;" :: "m"(x) : "memory" :b);
59b8fee677SJennifer Yu // expected-error@+1 {{invalid operand number in inline asm string}}
60b8fee677SJennifer Yu asm goto ("testl %0, %0; jne %l3;" :: "r"(cond)::label_true, loop);
61b8fee677SJennifer Yu // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}
62b8fee677SJennifer Yu asm goto ("decl %0; jnz %l[b]" :: "m"(x) : "memory" : a);
63b8fee677SJennifer Yu label_true:
64b8fee677SJennifer Yu loop:
65b8fee677SJennifer Yu a:
66b8fee677SJennifer Yu return 0;
67b8fee677SJennifer Yu }
68b8fee677SJennifer Yu
test6(int y)69*50cac248SBill Wendling int test6(int y) {
70*50cac248SBill Wendling int x,cond,*e;
71*50cac248SBill Wendling // expected-error@+1 {{expected ')'}}
72*50cac248SBill Wendling asm ("mov %[e], %[e]" : "=r" (y) : [e] "rm" (*e), "r" (y) :: a)
73*50cac248SBill Wendling // expected-error@+1 {{expected identifier}}
74*50cac248SBill Wendling asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" :);
75*50cac248SBill Wendling // expected-error@+1 {{expected ':'}}
76*50cac248SBill Wendling asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory");
77*50cac248SBill Wendling // expected-error@+1 {{use of undeclared label 'x'}}
78*50cac248SBill Wendling asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : x);
79*50cac248SBill Wendling // expected-error@+1 {{use of undeclared label 'b'}}
80*50cac248SBill Wendling asm goto ("decl %0;" : "=r" (y) : "m" (x), "r" (y) : "memory" : b);
81*50cac248SBill Wendling // expected-error@+1 {{invalid operand number in inline asm string}}
82*50cac248SBill Wendling asm goto ("testl %0, %0; jne %l5;" : "=r" (y) : "r" (cond), "r" (y) :: label_true, loop);
83*50cac248SBill Wendling // expected-error@+1 {{unknown symbolic operand name in inline assembly string}}
84*50cac248SBill Wendling asm goto ("decl %0; jnz %l[b]" : "=r" (y) : "m" (x), "r" (y) : "memory" : a);
85*50cac248SBill Wendling label_true:
86*50cac248SBill Wendling loop:
87*50cac248SBill Wendling a:
88*50cac248SBill Wendling return 0;
89b8fee677SJennifer Yu }
90