Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 50833d1

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. rdar://44534987 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 8978a7c commit 50833d1

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
@@ -1100,7 +1100,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
11001100
// This is a symbol reference.
11011101
StringRef SymbolName = Identifier;
11021102
if (SymbolName.empty())
1103-
return true;
1103+
return Error(getLexer().getLoc(), "expected a symbol reference");
11041104

11051105
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
11061106

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)