From 8761e9bb43f8e336e6495eab1ad102cac5c06c93 Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Fri, 17 Mar 2017 11:10:17 +0000 Subject: [PATCH] [Asm] Don't list '@' in diag when '@' is a comment This fixes https://bugs.llvm.org//show_bug.cgi?id=31280 Differential revision: https://reviews.llvm.org/D31026 llvm-svn: 298067 --- llvm/lib/MC/MCParser/ELFAsmParser.cpp | 8 ++++++-- llvm/test/MC/ELF/ARM/gnu-type-hash-diagnostics.s | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 4ac16615cebd..337cf16e8650 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -391,8 +391,12 @@ bool ELFAsmParser::maybeParseSectionType(StringRef &TypeName) { return false; Lex(); if (L.isNot(AsmToken::At) && L.isNot(AsmToken::Percent) && - L.isNot(AsmToken::String)) - return TokError("expected '@', '%' or \"\""); + L.isNot(AsmToken::String)) { + if (L.getAllowAtInIdentifier()) + return TokError("expected '@', '%' or \"\""); + else + return TokError("expected '%' or \"\""); + } if (!L.is(AsmToken::String)) Lex(); if (L.is(AsmToken::Integer)) { diff --git a/llvm/test/MC/ELF/ARM/gnu-type-hash-diagnostics.s b/llvm/test/MC/ELF/ARM/gnu-type-hash-diagnostics.s index eb364755c4d7..7dc656d5a4d7 100644 --- a/llvm/test/MC/ELF/ARM/gnu-type-hash-diagnostics.s +++ b/llvm/test/MC/ELF/ARM/gnu-type-hash-diagnostics.s @@ -7,3 +7,7 @@ // CHECK: .type TYPE #32 // CHECK: ^ + // For ARM, the comment character is '@', so we don't list '@' as a + // valid option. + .section "foo", "a", @progbits +// CHECK: error: expected '%' or ""