Add a test for enum discriminant range overflow.

It causes an LLVM assertion for every host/target word-size combination
on incoming at the time of this writing.
This commit is contained in:
Jed Davis 2013-02-23 12:15:30 -08:00
parent 04ecab909a
commit 7b2b4faba8
2 changed files with 31 additions and 1 deletions

View File

@ -139,7 +139,6 @@ fn generic_fields_of(cx: @CrateContext, r: &Repr, sizing: bool)
fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int)
-> ValueRef {
let ptr = GEPi(bcx, scrutinee, [0, 0]);
// XXX: write tests for the edge cases here
if max + 1 == min {
// i.e., if the range is everything. The lo==hi case would be
// rejected by the LLVM verifier (it would mean either an

View File

@ -0,0 +1,31 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub enum E64 {
H64 = 0x7FFF_FFFF_FFFF_FFFF,
L64 = 0x8000_0000_0000_0000
}
pub enum E32 {
H32 = 0x7FFF_FFFF,
L32 = 0x8000_0000
}
pub fn f(e64: E64, e32: E32) -> (bool,bool) {
(match e64 {
H64 => true,
L64 => false
},
match e32 {
H32 => true,
L32 => false
})
}
pub fn main() { }