]> git.proxmox.com Git - rustc.git/blob - tests/incremental/foreign.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / incremental / foreign.rs
1 // Test what happens we save incremental compilation state that makes
2 // use of foreign items. This used to ICE (#34991).
3 // ignore-sgx no libc
4
5 // revisions: rpass1
6
7 #![feature(rustc_private)]
8
9 extern crate libc;
10
11 use std::ffi::CString;
12
13 mod mlibc {
14 use libc::{c_char, c_long, c_longlong};
15
16 extern "C" {
17 pub fn atol(x: *const c_char) -> c_long;
18 pub fn atoll(x: *const c_char) -> c_longlong;
19 }
20 }
21
22 fn atol(s: String) -> isize {
23 let c = CString::new(s).unwrap();
24 unsafe { mlibc::atol(c.as_ptr()) as isize }
25 }
26
27 fn atoll(s: String) -> i64 {
28 let c = CString::new(s).unwrap();
29 unsafe { mlibc::atoll(c.as_ptr()) as i64 }
30 }
31
32 pub fn main() {
33 assert_eq!(atol("1024".to_string()) * 10, atol("10240".to_string()));
34 assert_eq!(
35 (atoll("11111111111111111".to_string()) * 10),
36 atoll("111111111111111110".to_string())
37 );
38 }