mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
Produce an error instead of a crash in an expr we cannot represent.
llvm-svn: 207414
This commit is contained in:
parent
da02d6849e
commit
55789b6ba9
@ -606,7 +606,12 @@ static const MCSymbol *getBaseSymbol(const MCAsmLayout &Layout,
|
||||
MCValue Value;
|
||||
if (!Expr->EvaluateAsRelocatable(Value, &Layout))
|
||||
llvm_unreachable("Invalid Expression");
|
||||
assert(!Value.getSymB());
|
||||
const MCSymbolRefExpr *RefB = Value.getSymB();
|
||||
if (RefB) {
|
||||
Layout.getAssembler().getContext().FatalError(
|
||||
SMLoc(), Twine("symbol '") + RefB->getSymbol().getName() +
|
||||
"' could not be evaluated in a subtraction expression");
|
||||
}
|
||||
const MCSymbolRefExpr *A = Value.getSymA();
|
||||
if (!A)
|
||||
return nullptr;
|
||||
|
8
test/MC/ELF/subtraction-error.s
Normal file
8
test/MC/ELF/subtraction-error.s
Normal file
@ -0,0 +1,8 @@
|
||||
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux < %s 2>&1 | FileCheck %s
|
||||
|
||||
a:
|
||||
.section foo
|
||||
b:
|
||||
c = b - a
|
||||
|
||||
; CHECK: symbol 'a' could not be evaluated in a subtraction expression
|
Loading…
Reference in New Issue
Block a user