From: Ehsan Akhgari Date: Tue, 15 Jul 2014 02:21:41 +0000 (+0000) Subject: Don't get confused on the number of braces when braces start after the first __asm X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7afe89ee4181191662f3381e7ceb300974997946;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213032 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseStmtAsm.cpp b/lib/Parse/ParseStmtAsm.cpp index de299fd5c4..f66121b1ec 100644 --- a/lib/Parse/ParseStmtAsm.cpp +++ b/lib/Parse/ParseStmtAsm.cpp @@ -323,7 +323,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { SmallVector 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; diff --git a/test/Parser/ms-inline-asm.c b/test/Parser/ms-inline-asm.c index 564f0081d3..00508f5cf0 100644 --- a/test/Parser/ms-inline-asm.c +++ b/test/Parser/ms-inline-asm.c @@ -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}}