From: Weiming Zhao Date: Thu, 1 Dec 2016 18:00:36 +0000 (+0000) Subject: [AsmParser] Diagnose empty symbol for .set directive X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b76e6a781e61aab9099c3054a0259a18cb5391dc;p=llvm [AsmParser] Diagnose empty symbol for .set directive Summary: Diagnose empty symbol to avoid hitting assertion in MCContext::getOrCreateSymbol Reviewers: eli.friedman, rengolin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26728 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288390 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 7fe4f9e669d..7ebe7b538a2 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -973,6 +973,9 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { // This is a symbol reference. StringRef SymbolName = Identifier; + if (SymbolName.empty()) + return true; + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; // Lookup the symbol variant if used. diff --git a/test/MC/AsmParser/equ.s b/test/MC/AsmParser/equ.s index 568f58fa129..fc5d5310305 100644 --- a/test/MC/AsmParser/equ.s +++ b/test/MC/AsmParser/equ.s @@ -5,5 +5,6 @@ .set a, 1 .equ a, 2 .equiv a, 3 +.set b, "" // CHECK: error: redefinition of 'a' - +// CHECK: error: missing expression in '.set' directive