|
| 1 | +extern crate libcc2rs; |
| 2 | +use libcc2rs::*; |
| 3 | +use std::cell::RefCell; |
| 4 | +use std::collections::BTreeMap; |
| 5 | +use std::io::prelude::*; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::AsFd; |
| 8 | +use std::rc::{Rc, Weak}; |
| 9 | +pub fn classify_0(x: Ptr<i32>) -> i32 { |
| 10 | + let x: Value<Ptr<i32>> = Rc::new(RefCell::new(x)); |
| 11 | + if true { |
| 12 | + return ((*x.borrow()).read()); |
| 13 | + } else { |
| 14 | + } |
| 15 | + return 1; |
| 16 | +} |
| 17 | +pub fn classify_1(x: i64) -> i32 { |
| 18 | + let x: Value<i64> = Rc::new(RefCell::new(x)); |
| 19 | + if false { |
| 20 | + } else if true { |
| 21 | + return 2; |
| 22 | + } |
| 23 | + return 1; |
| 24 | +} |
| 25 | +pub fn classify_2(x: i32) -> i32 { |
| 26 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 27 | + if false { |
| 28 | + } else if false { |
| 29 | + } |
| 30 | + return 1; |
| 31 | +} |
| 32 | +pub fn keep_both_3(x: i32) -> i32 { |
| 33 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 34 | + if true { |
| 35 | + return ((*x.borrow()) + 1); |
| 36 | + } else { |
| 37 | + return ((*x.borrow()) - 1); |
| 38 | + } |
| 39 | + panic!("ub: non-void function does not return a value") |
| 40 | +} |
| 41 | +pub fn main() { |
| 42 | + __cpp2rust_init_globals(); |
| 43 | + std::process::exit(main_0()); |
| 44 | +} |
| 45 | +fn main_0() -> i32 { |
| 46 | + let v: Value<i32> = Rc::new(RefCell::new(7)); |
| 47 | + assert!((({ classify_0((v.as_pointer()),) }) == 7)); |
| 48 | + assert!((({ classify_1(1_i64,) }) == 2)); |
| 49 | + assert!((({ classify_2(1,) }) == 1)); |
| 50 | + assert!((({ keep_both_3(1,) }) == 2)); |
| 51 | + return 0; |
| 52 | +} |
| 53 | +pub fn __cpp2rust_init_globals() {} |
0 commit comments