From d483a107910c708cdd60901a28e0f5a4e360b6d2 Mon Sep 17 00:00:00 2001 From: Coby Tayree Date: Wed, 2 Aug 2017 17:36:10 +0000 Subject: [AsmParser][GAS-compatibility] Ignore an empty 'p2align' directive GAS ignores the aforementioned issue this patch aligns LLVM + throws in an appropriate warning Differential Revision: https://reviews.llvm.org/D36060 llvm-svn: 309841 --- llvm/lib/MC/MCParser/AsmParser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp') diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 2756cb71ed9..a75476d2298 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3199,7 +3199,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) { int64_t MaxBytesToFill = 0; auto parseAlign = [&]() -> bool { - if (checkForValidSection() || parseAbsoluteExpression(Alignment)) + if (parseAbsoluteExpression(Alignment)) return true; if (parseOptionalToken(AsmToken::Comma)) { // The fill expression can be omitted while specifying a maximum number of @@ -3218,6 +3218,13 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) { return parseToken(AsmToken::EndOfStatement); }; + if (checkForValidSection()) + return addErrorSuffix(" in directive"); + // Ignore empty '.p2align' directives for GNU-as compatibility + if (IsPow2 && (ValueSize == 1) && getTok().is(AsmToken::EndOfStatement)) { + Warning(AlignmentLoc, "p2align directive with no operand(s) is ignored"); + return parseToken(AsmToken::EndOfStatement); + } if (parseAlign()) return addErrorSuffix(" in directive"); -- cgit v1.2.3