blob: 72c96c3715d95373d8a32433a7116e55c1e9e8f1 [file] [log] [blame]
Alp Toker75e22532013-12-08 21:12:27 +00001// REQUIRES: x86-registered-target
Chad Rosier10280a52013-01-22 21:39:58 +00002// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -verify -fasm-blocks
Eli Friedmana4b02c32011-09-30 01:13:51 +00003
4#define M __asm int 0x2c
5#define M2 int
6
Chad Rosier33a6e112013-01-22 18:18:22 +00007void t1(void) { M }
8void t2(void) { __asm int 0x2c }
9void t3(void) { __asm M2 0x2c }
10void t4(void) { __asm mov eax, fs:[0x10] }
Eli Friedmana4b02c32011-09-30 01:13:51 +000011void t5() {
Chad Rosier33a6e112013-01-22 18:18:22 +000012 __asm {
Eli Friedmana4b02c32011-09-30 01:13:51 +000013 int 0x2c ; } asm comments are fun! }{
14 }
Chad Rosier33a6e112013-01-22 18:18:22 +000015 __asm {}
Eli Friedmana4b02c32011-09-30 01:13:51 +000016}
17int t6() {
Chad Rosier33a6e112013-01-22 18:18:22 +000018 __asm int 3 ; } comments for single-line asm
19 __asm {}
Eli Friedmana4b02c32011-09-30 01:13:51 +000020
Chad Rosier33a6e112013-01-22 18:18:22 +000021 __asm int 4
Eli Friedmana4b02c32011-09-30 01:13:51 +000022 return 10;
23}
Chad Rosier175ea242012-08-24 21:42:51 +000024void t7() {
Chad Rosier33a6e112013-01-22 18:18:22 +000025 __asm {
Chad Rosier0764e0b2012-06-12 19:03:42 +000026 push ebx
27 mov ebx, 0x07
28 pop ebx
29 }
30}
Chad Rosier075608e2012-06-12 20:30:26 +000031void t8() {
Chad Rosier33a6e112013-01-22 18:18:22 +000032 __asm nop __asm nop __asm nop
Chad Rosier075608e2012-06-12 20:30:26 +000033}
34void t9() {
Chad Rosier33a6e112013-01-22 18:18:22 +000035 __asm nop __asm nop ; __asm nop
Chad Rosier075608e2012-06-12 20:30:26 +000036}
Ehsan Akhgari0f89fac2014-07-06 05:26:54 +000037void t10() {
38 __asm {
39 mov eax, 0
40 __asm {
41 mov eax, 1
42 {
43 mov eax, 2
44 }
45 }
46 }
47}
Ehsan Akhgari833ed942014-07-15 02:21:41 +000048void t11() {
49 do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
50}
Ehsan Akhgari31097582014-09-22 02:21:54 +000051void t12() {
52 __asm jmp label // expected-error {{use of undeclared label 'label'}}
53}
Chad Rosier0764e0b2012-06-12 19:03:42 +000054int t_fail() { // expected-note {{to match this}}
Chad Rosier33a6e112013-01-22 18:18:22 +000055 __asm
Ehsan Akhgari2f93b442014-07-25 02:27:14 +000056 __asm { // expected-error 2 {{expected}} expected-note {{to match this}}