Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -3199,7 +3199,7 @@ 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 @@ return parseToken(AsmToken::EndOfStatement); }; + if (checkForValidSection()) + return addErrorSuffix(" in directive"); + // GAS-Compatibility: Ignore empty '.p2align', but add a warning + 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"); Index: test/MC/AsmParser/directive_align.s =================================================================== --- test/MC/AsmParser/directive_align.s +++ test/MC/AsmParser/directive_align.s @@ -1,4 +1,5 @@ -# RUN: not llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s +# RUN: not llvm-mc -triple i386-apple-darwin9 %s 2> %t.err | FileCheck %s +# RUN: FileCheck < %t.err %s --check-prefix=CHECK-WARN # CHECK: TEST0: # CHECK: .p2align 1 @@ -14,3 +15,7 @@ # CHECK: .balign 3, 10 TEST2: .balign 3,10 + +# CHECK-WARN: p2align directive with no operand(s) is ignored +TEST3: + .p2align