Produce an error instead of a crash in an expr we cannot represent.

llvm-svn: 207414
This commit is contained in:
Rafael Espindola 2014-04-28 12:40:50 +00:00
parent da02d6849e
commit 55789b6ba9
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View 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