r213032 - Don't get confused on the number of braces when braces start after the first __asm

Ehsan Akhgari ehsan.akhgari at gmail.com
Mon Jul 14 19:21:41 PDT 2014


Author: ehsan
Date: Mon Jul 14 21:21:41 2014
New Revision: 213032

URL: http://llvm.org/viewvc/llvm-project?rev=213032&view=rev
Log:
Don't get confused on the number of braces when braces start after the first __asm

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

Modified:
    cfe/trunk/lib/Parse/ParseStmtAsm.cpp
    cfe/trunk/test/Parser/ms-inline-asm.c

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=213032&r1=213031&r2=213032&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Mon Jul 14 21:21:41 2014
@@ -323,7 +323,7 @@ StmtResult Parser::ParseMicrosoftAsmStat
   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::ParseMicrosoftAsmStat
   if (Tok.is(tok::l_brace)) {
     // Braced inline asm: consume the opening brace.
     BraceNesting = 1;
-    savedBraceCount = BraceCount;
     EndLoc = ConsumeBrace();
     LBraceLocs.push_back(EndLoc);
     ++NumTokensRead;

Modified: cfe/trunk/test/Parser/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=213032&r1=213031&r2=213032&view=diff
==============================================================================
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Mon Jul 14 21:21:41 2014
@@ -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}}





More information about the cfe-commits mailing list