llvm-mc: Fix a crash on invalid due to a typo in relocatable expression

evaluation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78692 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-08-11 17:47:52 +00:00
parent 12ddd40953
commit b27a41b440
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,8 @@
// RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
// RUN: FileCheck -input-file %t %s
.text
a:
.data
// CHECK: expected relocatable expression
.long -(0 + a)

View File

@ -81,7 +81,7 @@ bool AsmExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const {
break;
case AsmUnaryExpr::Minus:
/// -(a - b + const) ==> (b - a - const)
if (Value.getSymA() && !Value.getSymA())
if (Value.getSymA() && !Value.getSymB())
return false;
Res = MCValue::get(Value.getSymB(), Value.getSymA(),
-Value.getConstant());