]> granicus.if.org Git - clang/commitdiff
[ms-inline-asm] Fixing bug in single asm statement support
authorMarina Yatsina <marina.yatsina@intel.com>
Tue, 23 Feb 2016 08:53:45 +0000 (08:53 +0000)
committerMarina Yatsina <marina.yatsina@intel.com>
Tue, 23 Feb 2016 08:53:45 +0000 (08:53 +0000)
Fixing a crash caused by trying to merge a single-line asm statement with an asm block that follows it, e.g:
asm int 4
asm {
  int 5
}

Now, only adjacent single-line asm statements that are not surrounded by braces will be merged into one asm call.

Differential Revision: http://reviews.llvm.org/D17496

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261618 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmtAsm.cpp
test/CodeGen/ms-inline-asm.c
test/Parser/ms-inline-asm.c

index 3a236226707674daee6cddaba2cc60f8bc515064..7acf324bbe2b068361ec472a88e443f2c1424234 100644 (file)
@@ -423,6 +423,10 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
         // We're no longer in a comment.
         InAsmComment = false;
         if (isAsm) {
+          // If this is a new __asm {} block we want to process it seperately
+          // from the single-line __asm statements
+          if (PP.LookAhead(0).is(tok::l_brace))
+            break;
           LineNo = SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second);
           SkippedStartOfLine = Tok.isAtStartOfLine();
         }
index 2f5de676c72fe8ed44e2f81b6e577b0e08ea5761..e4d9756191d3a8408c937883d2c62b55429fcd8d 100644 (file)
@@ -63,10 +63,19 @@ void t7() {
 int t8() {
   __asm int 4 ; } comments for single-line asm
   __asm {}
-  __asm int 4
+  __asm { int 5}
+  __asm int 6
+  __asm int 7
+  __asm { 
+    int 8
+  }
   return 10;
 // CHECK: t8
-// CHECK: call i32 asm sideeffect inteldialect "int $$4\0A\09int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$5", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$6\0A\09int $$7", "={eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$8", "={eax},~{dirflag},~{fpsr},~{flags}"()
 // CHECK: ret i32 10
 }
 
index 6dde5f5c0d69be14e5ff3297f19dbff4383df2f7..5b0cabf7e6a3257c6e44e5f2fd9afb6c165ddd06 100644 (file)
@@ -55,4 +55,4 @@ void t12() {
 }
 int t_fail() { // expected-note {{to match this}}
   __asm 
-  __asm { // expected-error 2 {{expected}} expected-note {{to match this}}
+  __asm { // expected-error 3 {{expected}} expected-note {{to match this}}