1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fms-extensions -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
5 __asm __asm
// expected-error {{__asm used with no assembly instructions}}
12 .unknowndirective
// expected-error {{unknown directive}}
16 mov eax
, 1+=2 // expected-error {{unknown token in expression}}
20 mov eax
, 1+++ // expected-error {{unknown token in expression}}
24 mov eax
, LENGTH bar
// expected-error {{unable to lookup expression}}
28 mov eax
, SIZE bar
// expected-error {{unable to lookup expression}}
32 mov eax
, TYPE bar
// expected-error {{unable to lookup expression}} expected-error {{use of undeclared label 'bar'}}
36 void rdar15318432(void) {
37 // We used to crash on this. When LLVM called back to Clang to parse a name
38 // and do name lookup, if parsing failed, we did not restore the lexer state
54 int t2(int *arr
, int i
) {
59 mov eax
, arr
[1 + (2 * 5) - 3 + 1<<1];
62 // expected-error@+1 {{cannot use more than one symbol in memory operand}}
63 __asm
{ mov eax
, arr
[i
] }
64 // expected-error@+1 {{cannot use more than one symbol in memory operand}}
65 __asm
{ mov eax
, global
[i
] }
67 // expected-error@+1 {{cannot use more than one symbol in memory operand}}
68 __asm mov eax
, [arr
+ i
];
78 __asm
{ mov eax
, [eax
] UndeclaredId
} // expected-error {{unknown token in expression}} expected-error {{use of undeclared label 'UndeclaredId'}}
80 // FIXME: Only emit one diagnostic here.
81 // expected-error@+2 {{unexpected type name 'A': expected expression}}
82 // expected-error@+1 {{unknown token in expression}}
83 __asm
{ mov eax
, [eax
] A
}
87 // The dot in the "intel dot operator" is optional in MSVC. MSVC also does
88 // global field lookup, but we don't.
89 __asm
{ mov eax
, [0] A
.a
}
90 __asm
{ mov eax
, [0].A
.a
}
91 __asm
{ mov eax
, [0].a
} // expected-error {{Unable to lookup field reference!}}
92 __asm
{ mov eax
, fs
:[0] A
.a
}
93 __asm
{ mov eax
, fs
:[0].A
.a
}
94 __asm
{ mov eax
, fs
:[0].a
} // expected-error {{Unable to lookup field reference!}}
95 __asm
{ mov eax
, fs
:[0]. A
.a
} // expected-error {{unexpected token in argument list}}
98 void test_operand_size(void) {
99 __asm
{ call word t4
} // expected-error {{Expected 'PTR' or 'ptr' token!}}
102 __declspec(naked
) int t5(int x
) { // expected-note {{attribute is here}}
103 asm { movl eax
, x
} // expected-error {{parameter references not allowed in naked functions}} expected-error {{use of undeclared label 'x'}}
108 __declspec(naked
) int t6(int x
) {
109 asm { mov eax
, y
} // No error.
115 foo
: // expected-note {{inline assembly label 'foo' declared here}}
118 goto foo
; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
122 __asm foo
: // expected-note {{inline assembly label 'foo' declared here}}
124 goto foo
; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
128 goto foo
; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
130 foo
: // expected-note {{inline assembly label 'foo' declared here}}
136 goto foo
; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
137 __asm foo
: // expected-note {{inline assembly label 'foo' declared here}}
143 __asm mov eax
, foo
// expected-error {{use of undeclared label 'foo'}} expected-warning {{unused label 'foo'}}
148 __asm bar
: // expected-warning {{unused label 'bar'}}