Don't get confused on the number of braces when braces start after the first __asm
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Tue, 15 Jul 2014 02:21:41 +0000 (02:21 +0000)
committerEhsan Akhgari <ehsan.akhgari@gmail.com>
Tue, 15 Jul 2014 02:21:41 +0000 (02:21 +0000)
Summary:
Without this, we would not consume the closing brace which would cause
the parser to start consuming C++ and bad things would happen.

Reviewers: majnemer

Subscribers: cfe-commits

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

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

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

index de299fd5c4ae4f28685d0f4fd6c7c311edd2e060..f66121b1ec782fbc94307619a8bb3a606f2e2004 100644 (file)
@@ -323,7 +323,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
   SmallVector<Token, 4> AsmToks;
 
   unsigned BraceNesting = 0;
-  unsigned short savedBraceCount = 0;
+  unsigned short savedBraceCount = BraceCount;
   bool InAsmComment = false;
   FileID FID;
   unsigned LineNo = 0;
@@ -334,7 +334,6 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
   if (Tok.is(tok::l_brace)) {
     // Braced inline asm: consume the opening brace.
     BraceNesting = 1;
-    savedBraceCount = BraceCount;
     EndLoc = ConsumeBrace();
     LBraceLocs.push_back(EndLoc);
     ++NumTokensRead;
index 564f0081d38f00253714fe76f8c88d46a514a991..00508f5cf098988a5eb7f0f838bcc06db6d7946d 100644 (file)
@@ -45,6 +45,9 @@ void t10() {
     }
   }
 }
+void t11() {
+  do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
+}
 int t_fail() { // expected-note {{to match this}}
   __asm 
   __asm { // expected-error 3 {{expected}} expected-note {{to match this}}