From 61aad5837b4d9fef3cdbe1a5fa032846e8708bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Marques?= Date: Sat, 23 Sep 2023 13:56:39 +0100 Subject: [PATCH] Fix warning on align directives with non-zero fill value The original patch (PR #66792) did not properly check the non-zero fill value condition. This patch adds a new test case to ensure the overly aggressive check does not return. --- llvm/lib/MC/MCParser/AsmParser.cpp | 2 +- llvm/test/MC/ELF/nobits-non-zero-value.s | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 15ba96b84fa47..b36c5f067a953 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3452,7 +3452,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) { } } - if (HasFillExpr) { + if (HasFillExpr && FillExpr != 0) { MCSection *Sec = getStreamer().getCurrentSectionOnly(); if (Sec && Sec->isVirtualSection()) { ReturnVal |= diff --git a/llvm/test/MC/ELF/nobits-non-zero-value.s b/llvm/test/MC/ELF/nobits-non-zero-value.s index 8f37a957b6b56..9b2bea6278e69 100644 --- a/llvm/test/MC/ELF/nobits-non-zero-value.s +++ b/llvm/test/MC/ELF/nobits-non-zero-value.s @@ -15,5 +15,8 @@ # CHECK: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss' .align 4, 42 +# CHECK-NOT: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss' +.align 4, 0 + # CHECK: :0: error: SHT_NOBITS section '.bss' cannot have non-zero initializers .long 1