Implement -fms-extensions. This allows us to fuzzy parse non-standard MS constructs used in "windows.h".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46838 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp
index a074463..052aa1a 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -153,7 +153,9 @@
break;
case tok::kw_asm:
- Res = ParseAsmStatement();
+ bool msAsm = false;
+ Res = ParseAsmStatement(msAsm);
+ if (msAsm) return Res;
SemiError = "asm statement";
break;
}
@@ -908,6 +910,14 @@
return Actions.ActOnReturnStmt(ReturnLoc, R.Val);
}
+Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
+ unsigned short savedBraceCount = BraceCount;
+ do {
+ ConsumeAnyToken();
+ } while (BraceCount > savedBraceCount && Tok.isNot(tok::eof));
+ return false;
+}
+
/// ParseAsmStatement - Parse a GNU extended asm statement.
/// [GNU] asm-statement:
/// 'asm' type-qualifier[opt] '(' asm-argument ')' ';'
@@ -923,10 +933,14 @@
/// asm-string-literal
/// asm-clobbers ',' asm-string-literal
///
-Parser::StmtResult Parser::ParseAsmStatement() {
+Parser::StmtResult Parser::ParseAsmStatement(bool &msAsm) {
assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
SourceLocation AsmLoc = ConsumeToken();
+ if (Tok.is(tok::l_brace)) {
+ msAsm = true;
+ return FuzzyParseMicrosoftAsmStatement();
+ }
DeclSpec DS;
SourceLocation Loc = Tok.getLocation();
ParseTypeQualifierListOpt(DS);