2007-11-25 08:25:21 +08:00
|
|
|
// RUN: clang %s -arch=i386 -verify -fsyntax-only
|
2007-11-24 03:43:50 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
f()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
asm ("foo\n" : : "a" (i + 2));
|
|
|
|
asm ("foo\n" : : "a" (f())); // expected-error {{invalid type 'void' in asm input}}
|
|
|
|
|
|
|
|
asm ("foo\n" : "=a" (f())); // expected-error {{invalid lvalue in asm output}}
|
|
|
|
asm ("foo\n" : "=a" (i + 2)); // expected-error {{invalid lvalue in asm output}}
|
2009-01-18 09:56:57 +08:00
|
|
|
|
|
|
|
asm ("foo\n" : [symbolic_name] "=a" (i) : "[symbolic_name]" (i));
|
|
|
|
asm ("foo\n" : "=a" (i) : "[" (i)); // expected-error {{invalid input constraint '[' in asm}}
|
|
|
|
asm ("foo\n" : "=a" (i) : "[foo" (i)); // expected-error {{invalid input constraint '[foo' in asm}}
|
|
|
|
asm ("foo\n" : "=a" (i) : "[symbolic_name]" (i)); // expected-error {{invalid input constraint '[symbolic_name]' in asm}}
|
2007-11-24 03:43:50 +08:00
|
|
|
}
|
2007-11-25 08:25:21 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
clobbers()
|
|
|
|
{
|
|
|
|
asm ("nop" : : : "ax", "#ax", "%ax");
|
|
|
|
asm ("nop" : : : "eax", "rax", "ah", "al");
|
|
|
|
asm ("nop" : : : "0", "%0", "#0");
|
|
|
|
asm ("nop" : : : "foo"); // expected-error {{unknown register name 'foo' in asm}}
|
|
|
|
asm ("nop" : : : "52");
|
|
|
|
asm ("nop" : : : "53"); // expected-error {{unknown register name '53' in asm}}
|
|
|
|
asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
|
|
|
|
asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
|
|
|
|
}
|
2008-07-23 14:46:56 +08:00
|
|
|
|
|
|
|
// rdar://6094010
|
|
|
|
void test3() {
|
|
|
|
int x;
|
|
|
|
asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
|
|
|
|
asm("foo" : L"=r"(x)); // expected-error {{wide string}}
|
|
|
|
}
|
|
|
|
|
2009-01-21 04:49:22 +08:00
|
|
|
// <rdar://problem/6156893>
|
|
|
|
void test4(const volatile void *addr)
|
|
|
|
{
|
|
|
|
asm ("nop" : : "r"(*addr)); // expected-error {{invalid type 'void const volatile' in asm input for constraint 'r'}}
|
|
|
|
asm ("nop" : : "m"(*addr));
|
|
|
|
|
|
|
|
asm ("nop" : : "r"(test4(addr))); // expected-error {{invalid type 'void' in asm input for constraint 'r'}}
|
|
|
|
asm ("nop" : : "m"(test4(addr))); // expected-error {{invalid lvalue in asm input for constraint 'm'}}
|
|
|
|
|
2009-01-21 14:27:20 +08:00
|
|
|
asm ("nop" : : "m"(f())); // expected-error {{invalid lvalue in asm input for constraint 'm'}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// <rdar://problem/6512595>
|
2009-03-11 07:51:40 +08:00
|
|
|
void test5() {
|
2009-01-21 14:27:20 +08:00
|
|
|
asm("nop" : : "X" (8));
|
2009-01-21 04:49:22 +08:00
|
|
|
}
|
2009-01-25 02:03:09 +08:00
|
|
|
|
|
|
|
// PR3385
|
2009-03-11 07:51:40 +08:00
|
|
|
void test6(long i) {
|
2009-01-25 02:03:09 +08:00
|
|
|
asm("nop" : : "er"(i));
|
2009-01-28 04:38:24 +08:00
|
|
|
}
|
2009-03-11 07:51:40 +08:00
|
|
|
|
|
|
|
void test7() {
|
|
|
|
asm("%!"); // simple asm string, %! is not an error.
|
|
|
|
asm("%!" : ); // expected-error {{invalid % escape in inline assembly string}}
|
|
|
|
}
|