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 fromb(b: bool) -> const_val { const_int(b as i64) }
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 fromb(b: bool) -> const_val { const_int(b as i64) }
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, _) {