GIMPLE output for compile/issue-4242.rs:
...
x = 1;
RUSTTMP.2 = x;
_1 = RUSTTMP.2 >= -55;
_2 = RUSTTMP.2 < 0;
_3 = _1 & _2;
if (_3 != 0) goto <D.112>; else goto <D.113>;
<D.112>:
{
RUSTTMP.1 = 2;
goto <D.105>;
}
<D.113>:
_4 = RUSTTMP.2 >= -99;
_5 = RUSTTMP.2 < -55;
_6 = _4 & _5;
if (_6 != 0) goto <D.114>; else goto <D.115>;
<D.114>:
{
RUSTTMP.1 = 3;
goto <D.105>;
}
...
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (compile_range_pattern_bound): Set litexpr
to negative if has_minus is present in the RangePatternBoundLiteral param.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
HIR::LiteralExpr litexpr (mappings, ref.get_literal (), locus,
std::vector<AST::Attribute> ());
+ if (ref.get_has_minus())
+ litexpr.set_negative();
result = CompileExpr::Compile (litexpr, ctx);
}
--- /dev/null
+#![feature(exclusive_range_pattern)]
+
+fn main() {
+ let x = 1;
+
+ match x {
+ -55..0 => 2,
+ -99..-55 => 3,
+ };
+}
\ No newline at end of file
--- /dev/null
+#![feature(exclusive_range_pattern)]
+
+fn main() -> i32 {
+ let x = -77;
+
+ match x {
+ -55..99 => 1,
+ -99..-55 => 0, // the correct case
+ _ => 1,
+ }
+}
\ No newline at end of file