diff options
author | Steven Wu <stevenwu@apple.com> | 2015-05-12 00:16:37 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2015-05-12 00:16:37 +0000 |
commit | 18bbe191cdfe1b1bb64fc0d80ee5113f9cd56e4d (patch) | |
tree | 7149dd2bb2d391356fe0002e5ddd9beffb146562 /clang/lib/Parse/Parser.cpp | |
parent | 0ddaf2bfb9a8b4ffba4e3ecf093b528ab1929791 (diff) | |
download | bcm5719-llvm-18bbe191cdfe1b1bb64fc0d80ee5113f9cd56e4d.tar.gz bcm5719-llvm-18bbe191cdfe1b1bb64fc0d80ee5113f9cd56e4d.zip |
Allow empty assembly string literal with -fno-gnu-inline-asm
Empty assembly string will not introduce assembly code in the output
binary and it is often used as a trick in the header to disable
optimizations. It doesn't conflict with the purpose of the option so it
is allowed with -fno-gnu-inline-asm flag.
llvm-svn: 237073
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index ed27a9e3953..697fda9215d 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -670,12 +670,17 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, SourceLocation StartLoc = Tok.getLocation(); SourceLocation EndLoc; - // Check if GNU-style InlineAsm is disabled. - if (!getLangOpts().GNUAsm) - Diag(StartLoc, diag::err_gnu_inline_asm_disabled); - 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"); |