llvm-mc: Fix a crash on invalid due to a typo in relocatable expression
authorDaniel Dunbar <daniel@zuster.org>
Tue, 11 Aug 2009 17:47:52 +0000 (17:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 11 Aug 2009 17:47:52 +0000 (17:47 +0000)
evaluation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78692 91177308-0d34-0410-b5e6-96231b3b80d8

test/MC/AsmParser/exprs-invalid.s [new file with mode: 0644]
tools/llvm-mc/AsmExpr.cpp

diff --git a/test/MC/AsmParser/exprs-invalid.s b/test/MC/AsmParser/exprs-invalid.s
new file mode 100644 (file)
index 0000000..4accc39
--- /dev/null
@@ -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)
index c3362e4268c85c9ec38389e1d120538950a7255d..fbb0c53b1cf783072bbc317dc998f2c8fdc034aa 100644 (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());