Handle differing signedness in constant shifts. Closes #2426.

This commit is contained in:
Michael Sullivan 2012-05-30 15:03:24 -07:00
parent ccb54f0ce0
commit 7fee392de5

View File

@ -49,7 +49,6 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
le { fromb(a <= b) } ne { fromb(a != b) }
ge { fromb(a >= b) } gt { fromb(a > b) }
}
}
(const_uint(a), const_uint(b)) {
alt check op {
@ -63,6 +62,17 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
ge { fromb(a >= b) } gt { fromb(a > b) }
}
}
// shifts can have any integral type as their rhs
(const_int(a), const_uint(b)) {
alt check op {
shl { const_int(a << b) } shr { const_int(a >> b) }
}
}
(const_uint(a), const_int(b)) {
alt check op {
shl { const_uint(a << b) } shr { const_uint(a >> b) }
}
}
}
}
expr_cast(base, _) {