Index: lib/Parse/Parser.cpp |
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp |
index 3b56102dcfad045b36288dc0ac5a35692460aa42..697fda9215df3f423c74b9e4b4e208e37e0413a2 100644 |
--- a/lib/Parse/Parser.cpp |
+++ b/lib/Parse/Parser.cpp |
@@ -669,8 +669,18 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, |
SourceLocation StartLoc = Tok.getLocation(); |
SourceLocation EndLoc; |
+ |
ExprResult Result(ParseSimpleAsm(&EndLoc)); |
+ // Check if GNU-style InlineAsm is disabled. |
+ // Empty asm string is allowed because it will not introduce |
+ // any assembly code. |
+ if (!(getLangOpts().GNUAsm || Result.isInvalid())) { |
+ const auto *SL = cast<StringLiteral>(Result.get()); |
+ if (!SL->getString().trim().empty()) |
+ Diag(StartLoc, diag::err_gnu_inline_asm_disabled); |
+ } |
+ |
ExpectAndConsume(tok::semi, diag::err_expected_after, |
"top-level asm block"); |