blob: e3c392406957fbdfb5ef2297750ff882be865958 [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
Steven Wucb0d13f2015-01-16 23:05:28 +00003// Disabling gnu inline assembly should have no effect on this testcase
4// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -verify -fasm-blocks -fno-gnu-inline-asm
Eli Friedmana4b02c32011-09-30 01:13:51 +00005
6#define M __asm int 0x2c
7#define M2 int
8
Chad Rosier33a6e112013-01-22 18:18:22 +00009void t1(void) { M }
10void t2(void) { __asm int 0x2c }
11void t3(void) { __asm M2 0x2c }
12void t4(void) { __asm mov eax, fs:[0x10] }
Eli Friedmana4b02c32011-09-30 01:13:51 +000013void t5() {
Chad Rosier33a6e112013-01-22 18:18:22 +000014 __asm {
Eli Friedmana4b02c32011-09-30 01:13:51 +000015 int 0x2c ; } asm comments are fun! }{
16 }
Chad Rosier33a6e112013-01-22 18:18:22 +000017 __asm {}
Eli Friedmana4b02c32011-09-30 01:13:51 +000018}
19int t6() {
Chad Rosier33a6e112013-01-22 18:18:22 +000020 __asm int 3 ; } comments for single-line asm
21 __asm {}
Eli Friedmana4b02c32011-09-30 01:13:51 +000022
Chad Rosier33a6e112013-01-22 18:18:22 +000023 __asm int 4
Eli Friedmana4b02c32011-09-30 01:13:51 +000024 return 10;
25}
Chad Rosier175ea242012-08-24 21:42:51 +000026void t7() {
Chad Rosier33a6e112013-01-22 18:18:22 +000027 __asm {
Chad Rosier0764e0b2012-06-12 19:03:42 +000028 push ebx
29 mov ebx, 0x07
30 pop ebx
31 }
32}
Chad Rosier075608e2012-06-12 20:30:26 +000033void t8() {
Chad Rosier33a6e112013-01-22 18:18:22 +000034 __asm nop __asm nop __asm nop
Chad Rosier075608e2012-06-12 20:30:26 +000035}
36void t9() {
Chad Rosier33a6e112013-01-22 18:18:22 +000037 __asm nop __asm nop ; __asm nop
Chad Rosier075608e2012-06-12 20:30:26 +000038}
Ehsan Akhgari0f89fac2014-07-06 05:26:54 +000039void t10() {
40 __asm {
41 mov eax, 0
42 __asm {
43 mov eax, 1
44 {
45 mov eax, 2
46 }
47 }
48 }
49}
Ehsan Akhgari833ed942014-07-15 02:21:41 +000050void t11() {
51 do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
52}
Ehsan Akhgari31097582014-09-22 02:21:54 +000053void t12() {
54 __asm jmp label // expected-error {{use of undeclared label 'label'}}
55}
Marina Yatsina5f776792016-03-07 18:10:25 +000056void t13() {
57 __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}}
58}
59
Chad Rosier0764e0b2012-06-12 19:03:42 +000060int t_fail() { // expected-note {{to match this}}
Chad Rosier33a6e112013-01-22 18:18:22 +000061 __asm
Marina Yatsina146d2ec2016-02-23 08:53:45 +000062 __asm { // expected-error 3 {{expected}} expected-note {{to match this}}