Skip to content

Commit 61aad58

Browse files
committed
Fix warning on align directives with non-zero fill value
The original patch (PR llvm#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.
1 parent d437e68 commit 61aad58

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
34523452
}
34533453
}
34543454

3455-
if (HasFillExpr) {
3455+
if (HasFillExpr && FillExpr != 0) {
34563456
MCSection *Sec = getStreamer().getCurrentSectionOnly();
34573457
if (Sec && Sec->isVirtualSection()) {
34583458
ReturnVal |=

llvm/test/MC/ELF/nobits-non-zero-value.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
# CHECK: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss'
1616
.align 4, 42
1717

18+
# CHECK-NOT: {{.*}}.s:[[#@LINE+1]]:11: warning: ignoring non-zero fill value in SHT_NOBITS section '.bss'
19+
.align 4, 0
20+
1821
# CHECK: <unknown>:0: error: SHT_NOBITS section '.bss' cannot have non-zero initializers
1922
.long 1

0 commit comments

Comments
 (0)