aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/MC/AsmParser/exprs-invalid.s8
-rw-r--r--tools/llvm-mc/AsmExpr.cpp2
2 files changed, 9 insertions, 1 deletions
diff --git a/test/MC/AsmParser/exprs-invalid.s b/test/MC/AsmParser/exprs-invalid.s
new file mode 100644
index 0000000..4accc39
--- /dev/null
+++ b/test/MC/AsmParser/exprs-invalid.s
@@ -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)
diff --git a/tools/llvm-mc/AsmExpr.cpp b/tools/llvm-mc/AsmExpr.cpp
index c3362e4..fbb0c53 100644
--- a/tools/llvm-mc/AsmExpr.cpp
+++ b/tools/llvm-mc/AsmExpr.cpp
@@ -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());