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
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user