Skip to content

Commit c6b3fd7

Browse files
committed
[MC] maybeParseSectionType: test CommentString instead of AllowAtInIdentifier
Rework https://reviews.llvm.org/D31026 AllowAtInIdentifier is a misnomer: it should be false for ELF targets, but is currently true as a hack to parse expr@specifier.
1 parent 04a6752 commit c6b3fd7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/MC/MCParser/ELFAsmParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,10 @@ bool ELFAsmParser::maybeParseSectionType(StringRef &TypeName) {
401401
Lex();
402402
if (L.isNot(AsmToken::At) && L.isNot(AsmToken::Percent) &&
403403
L.isNot(AsmToken::String)) {
404-
if (L.getAllowAtInIdentifier())
405-
return TokError("expected '@<type>', '%<type>' or \"<type>\"");
406-
else
404+
if (getContext().getAsmInfo()->getCommentString().starts_with('@'))
407405
return TokError("expected '%<type>' or \"<type>\"");
406+
else
407+
return TokError("expected '@<type>', '%<type>' or \"<type>\"");
408408
}
409409
if (!L.is(AsmToken::String))
410410
Lex();

llvm/test/MC/ELF/gnu-type-diagnostics.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
// CHECK: .type symbol 32
1616
// CHECK: ^
1717

18-
18+
.section "foo", "a", !progbits
19+
// CHECK: [[#@LINE-1]]:22: error: expected '@<type>', '%<type>' or "<type>"

0 commit comments

Comments
 (0)