File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include <stddef.h>
2+
3+ /* Forward declaration only; no body for `opaque` anywhere in this TU. */
4+ struct opaque ;
5+
6+ struct container {
7+ struct opaque * p ;
8+ int x ;
9+ };
10+
11+ int main (void ) {
12+ struct container c = {NULL , 42 };
13+ (void )c .p ;
14+ return c .x - 42 ;
15+ }
Original file line number Diff line number Diff line change 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+ #[ derive( Default ) ]
10+ pub struct container {
11+ pub p : Value < Ptr < opaque > > ,
12+ pub x : Value < i32 > ,
13+ }
14+ impl ByteRepr for container { }
15+ pub fn main ( ) {
16+ std:: process:: exit ( main_0 ( ) ) ;
17+ }
18+ fn main_0 ( ) -> i32 {
19+ let c: Value < container > = Rc :: new ( RefCell :: new ( container {
20+ p : Rc :: new ( RefCell :: new ( Ptr :: < opaque > :: null ( ) ) ) ,
21+ x : Rc :: new ( RefCell :: new ( 42 ) ) ,
22+ } ) ) ;
23+ ( * ( * c. borrow ( ) ) . p . borrow ( ) ) . clone ( ) ;
24+ return ( ( * ( * c. borrow ( ) ) . x . borrow ( ) ) - 42 ) ;
25+ }
26+ #[ repr( C ) ]
27+ pub struct opaque {
28+ _opaque : [ u8 ; 0 ] ,
29+ }
Original file line number Diff line number Diff line change 1+ extern crate libc;
2+ use libc:: * ;
3+ extern crate libcc2rs;
4+ use libcc2rs:: * ;
5+ use std:: collections:: BTreeMap ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
8+ use std:: rc:: Rc ;
9+ #[ repr( C ) ]
10+ #[ derive( Copy , Clone , Default ) ]
11+ pub struct container {
12+ pub p : * mut opaque ,
13+ pub x : i32 ,
14+ }
15+ pub fn main ( ) {
16+ unsafe {
17+ std:: process:: exit ( main_0 ( ) as i32 ) ;
18+ }
19+ }
20+ unsafe fn main_0 ( ) -> i32 {
21+ let mut c: container = container {
22+ p : std:: ptr:: null_mut ( ) ,
23+ x : 42 ,
24+ } ;
25+ & ( c. p ) ;
26+ return ( ( c. x ) - ( 42 ) ) ;
27+ }
28+ #[ repr( C ) ]
29+ pub struct opaque {
30+ _opaque : [ u8 ; 0 ] ,
31+ }
You can’t perform that action at this time.
0 commit comments