[llvm] r343961 - [AsmParser] Return an error in the case of empty symbol ref in an expression
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 8 03:28:12 PDT 2018
Author: thegameg
Date: Mon Oct 8 03:28:11 2018
New Revision: 343961
URL: http://llvm.org/viewvc/llvm-project?rev=343961&view=rev
Log:
[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
Added:
llvm/trunk/test/MC/AArch64/expr-bad-symbol.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=343961&r1=343960&r2=343961&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Oct 8 03:28:11 2018
@@ -1103,7 +1103,7 @@ bool AsmParser::parsePrimaryExpr(const M
// This is a symbol reference.
StringRef SymbolName = Identifier;
if (SymbolName.empty())
- return true;
+ return Error(getLexer().getLoc(), "expected a symbol reference");
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
Added: llvm/trunk/test/MC/AArch64/expr-bad-symbol.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/expr-bad-symbol.s?rev=343961&view=auto
==============================================================================
--- llvm/trunk/test/MC/AArch64/expr-bad-symbol.s (added)
+++ llvm/trunk/test/MC/AArch64/expr-bad-symbol.s Mon Oct 8 03:28:11 2018
@@ -0,0 +1,6 @@
+// RUN: not llvm-mc -triple aarch64-- %s 2>&1 | FileCheck %s
+
+ .text
+_foo:
+ str q28, [x0, #1*6*4*@]
+// CHECK: error: expected a symbol reference
More information about the llvm-commits
mailing list