Skip to content

Commit 9a00564

Browse files
committed
[AsmParser] Return an error in the case of empty symbol ref in an expression
The following instruction: > str q28, [x0, #1*6*4*@] contains a @ which is parsed as an empty symbol. The parser returns true but has no error, so the assembler continues by ignoring the instruction. Differential Revision: https://reviews.llvm.org/D52645 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343961 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 944e6c5 commit 9a00564

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/MC/MCParser/AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
11031103
// This is a symbol reference.
11041104
StringRef SymbolName = Identifier;
11051105
if (SymbolName.empty())
1106-
return true;
1106+
return Error(getLexer().getLoc(), "expected a symbol reference");
11071107

11081108
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
11091109

test/MC/AArch64/expr-bad-symbol.s

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: not llvm-mc -triple aarch64-- %s 2>&1 | FileCheck %s
2+
3+
.text
4+
_foo:
5+
str q28, [x0, #1*6*4*@]
6+
// CHECK: error: expected a symbol reference

0 commit comments

Comments
 (0)