Handle integer-extending for C ABI
We need to supply sext/zext attributes to LLVM to ensure that arguments are extended to the appropriate width in the correct way. Most platforms extend integers less than 32 bits, though not all.
This commit is contained in:
parent
f92ce2e9fe
commit
4815f7e668
11 changed files with 102 additions and 21 deletions
22
src/test/run-pass/cabi-int-widening.rs
Normal file
22
src/test/run-pass/cabi-int-widening.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
#[link(name = "rust_test_helpers")]
|
||||
extern {
|
||||
fn rust_int8_to_int32(_: i8) -> i32;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = unsafe {
|
||||
rust_int8_to_int32(-1)
|
||||
};
|
||||
|
||||
assert!(x == -1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue