Anders Carlsson | 6fa9086 | 2007-11-25 00:25:21 +0000 | [diff] [blame] | 1 | // RUN: clang %s -arch=i386 -verify -fsyntax-only |
Anders Carlsson | 04728b7 | 2007-11-23 19:43:50 +0000 | [diff] [blame] | 2 | |
| 3 | void |
| 4 | f() |
| 5 | { |
| 6 | int i; |
| 7 | |
| 8 | asm ("foo\n" : : "a" (i + 2)); |
| 9 | asm ("foo\n" : : "a" (f())); // expected-error {{invalid type 'void' in asm input}} |
| 10 | |
| 11 | asm ("foo\n" : "=a" (f())); // expected-error {{invalid lvalue in asm output}} |
| 12 | asm ("foo\n" : "=a" (i + 2)); // expected-error {{invalid lvalue in asm output}} |
Anders Carlsson | 42e1ee0 | 2009-01-18 01:56:57 +0000 | [diff] [blame] | 13 | |
| 14 | asm ("foo\n" : [symbolic_name] "=a" (i) : "[symbolic_name]" (i)); |
| 15 | asm ("foo\n" : "=a" (i) : "[" (i)); // expected-error {{invalid input constraint '[' in asm}} |
| 16 | asm ("foo\n" : "=a" (i) : "[foo" (i)); // expected-error {{invalid input constraint '[foo' in asm}} |
| 17 | asm ("foo\n" : "=a" (i) : "[symbolic_name]" (i)); // expected-error {{invalid input constraint '[symbolic_name]' in asm}} |
Anders Carlsson | 04728b7 | 2007-11-23 19:43:50 +0000 | [diff] [blame] | 18 | } |
Anders Carlsson | 6fa9086 | 2007-11-25 00:25:21 +0000 | [diff] [blame] | 19 | |
| 20 | void |
| 21 | clobbers() |
| 22 | { |
| 23 | asm ("nop" : : : "ax", "#ax", "%ax"); |
| 24 | asm ("nop" : : : "eax", "rax", "ah", "al"); |
| 25 | asm ("nop" : : : "0", "%0", "#0"); |
| 26 | asm ("nop" : : : "foo"); // expected-error {{unknown register name 'foo' in asm}} |
| 27 | asm ("nop" : : : "52"); |
| 28 | asm ("nop" : : : "53"); // expected-error {{unknown register name '53' in asm}} |
| 29 | asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}} |
| 30 | asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}} |
| 31 | } |
Chris Lattner | 6bc5211 | 2008-07-23 06:46:56 +0000 | [diff] [blame] | 32 | |
| 33 | // rdar://6094010 |
| 34 | void test3() { |
| 35 | int x; |
| 36 | asm(L"foo" : "=r"(x)); // expected-error {{wide string}} |
| 37 | asm("foo" : L"=r"(x)); // expected-error {{wide string}} |
| 38 | } |
| 39 | |
Anders Carlsson | d9fca6e | 2009-01-20 20:49:22 +0000 | [diff] [blame] | 40 | // <rdar://problem/6156893> |
| 41 | void test4(const volatile void *addr) |
| 42 | { |
| 43 | asm ("nop" : : "r"(*addr)); // expected-error {{invalid type 'void const volatile' in asm input for constraint 'r'}} |
| 44 | asm ("nop" : : "m"(*addr)); |
| 45 | |
| 46 | asm ("nop" : : "r"(test4(addr))); // expected-error {{invalid type 'void' in asm input for constraint 'r'}} |
| 47 | asm ("nop" : : "m"(test4(addr))); // expected-error {{invalid lvalue in asm input for constraint 'm'}} |
| 48 | |
Anders Carlsson | e6ea279 | 2009-01-21 06:27:20 +0000 | [diff] [blame^] | 49 | asm ("nop" : : "m"(f())); // expected-error {{invalid lvalue in asm input for constraint 'm'}} |
| 50 | } |
| 51 | |
| 52 | // <rdar://problem/6512595> |
| 53 | void test5() |
| 54 | { |
| 55 | asm("nop" : : "X" (8)); |
Anders Carlsson | d9fca6e | 2009-01-20 20:49:22 +0000 | [diff] [blame] | 56 | } |