blob: be41c81c9bb23ba1b58a2c6df6c4d824e710ab06 [file] [log] [blame]
NAKAMURA Takumi0acd8a72013-12-04 03:41:33 +00001// REQUIRES: x86-registered-target
Chad Rosiere3aac2c2013-01-22 19:38:32 +00002// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
Bob Wilson317be452012-09-24 19:57:59 +00003
4void t1(void) {
Eli Friedmand5d136b2012-10-23 02:43:30 +00005 __asm __asm // expected-error {{__asm used with no assembly instructions}}
6}
7
8void f() {
Chad Rosier0130f822012-10-26 18:33:59 +00009 int foo;
Eli Friedmand5d136b2012-10-23 02:43:30 +000010 __asm {
11 mov eax, eax
12 .unknowndirective // expected-error {{unknown directive}}
13 }
14 f();
15 __asm {
Benjamin Kramer6b724722013-12-01 11:48:10 +000016 mov eax, 1+=2 // expected-error {{unknown token in expression}}
Eli Friedmand5d136b2012-10-23 02:43:30 +000017 }
18 f();
19 __asm {
Benjamin Kramer6b724722013-12-01 11:48:10 +000020 mov eax, 1+++ // expected-error {{unknown token in expression}}
Eli Friedmand5d136b2012-10-23 02:43:30 +000021 }
Chad Rosier92c487d2013-01-18 00:51:29 +000022 f();
23 __asm {
Benjamin Kramer6b724722013-12-01 11:48:10 +000024 mov eax, LENGTH bar // expected-error {{unable to lookup expression}}
Chad Rosier92c487d2013-01-18 00:51:29 +000025 }
26 f();
27 __asm {
Benjamin Kramer6b724722013-12-01 11:48:10 +000028 mov eax, SIZE bar // expected-error {{unable to lookup expression}}
Chad Rosier92c487d2013-01-18 00:51:29 +000029 }
30 f();
31 __asm {
Benjamin Kramer6b724722013-12-01 11:48:10 +000032 mov eax, TYPE bar // expected-error {{unable to lookup expression}}
Chad Rosier92c487d2013-01-18 00:51:29 +000033 }
Bob Wilson317be452012-09-24 19:57:59 +000034}
Dmitri Gribenkofc13b8b2013-12-03 00:48:09 +000035
36void 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
39 // properly.
40
41 // expected-error@+2 {{expected identifier}}
42 __asm {
43 and ecx, ~15
44 }
45
46 int x = 0;
47 // expected-error@+3 {{expected identifier}}
48 __asm {
49 and ecx, x
50 and ecx, ~15
51 }
52}