@@ -10,6 +10,7 @@ expression: cat tests/snapshots/conditions.2021.rs
1010 unused_assignments ,
1111 unused_mut
1212)]
13+ #! [feature (raw_ref_op )]
1314#[no_mangle ]
1415pub unsafe extern " C" fn simple_if_else (mut x : ::core ::ffi ::c_int ) - > ::core ::ffi ::c_int {
1516 if x != 0 {
@@ -91,3 +92,82 @@ pub unsafe extern "C" fn nested_early_returns(mut x: ::core::ffi::c_int) -> ::co
9192 }
9293 return x ;
9394}
95+ #[no_mangle ]
96+ pub unsafe extern " C" fn conditional_operator (
97+ sz : ::core ::ffi ::c_uint ,
98+ buf : * mut ::core ::ffi ::c_int ,
99+ ) {
100+ let mut x: *mut ::core ::ffi ::c_int = (buf as *mut ::core ::ffi ::c_int )
101+ .offset (0 as ::core ::ffi ::c_int as isize )
102+ as *mut ::core ::ffi ::c_int ;
103+ let mut y: *mut ::core ::ffi ::c_int = (buf as *mut ::core ::ffi ::c_int )
104+ .offset (1 as ::core ::ffi ::c_int as isize )
105+ as *mut ::core ::ffi ::c_int ;
106+ let ref mut c2rust_fresh0 = * if false { &raw mut y } else { &raw mut x };
107+ * c2rust_fresh0 = 10 as ::core ::ffi ::c_int as *mut ::core ::ffi ::c_int ;
108+ * (buf as *mut ::core ::ffi ::c_int ).offset (2 as ::core ::ffi ::c_int as isize ) = if true {
109+ 2 as ::core ::ffi ::c_int
110+ } else {
111+ 3 as ::core ::ffi ::c_int
112+ };
113+ * (buf as *mut ::core ::ffi ::c_int ).offset (3 as ::core ::ffi ::c_int as isize ) = if false {
114+ 2 as ::core ::ffi ::c_int
115+ } else {
116+ 3 as ::core ::ffi ::c_int
117+ };
118+ }
119+ unsafe extern " C" fn id (mut i : ::core ::ffi ::c_int ) - > ::core ::ffi ::c_int {
120+ return i ;
121+ }
122+ unsafe extern " C" fn add (
123+ mut p : * mut ::core ::ffi ::c_int ,
124+ mut i : ::core ::ffi ::c_int ,
125+ mut r : ::core ::ffi ::c_int ,
126+ ) - > ::core ::ffi ::c_int {
127+ * p += i ;
128+ return r ;
129+ }
130+ #[no_mangle ]
131+ pub unsafe extern " C" fn binary_conditional_operator (
132+ sz : ::core ::ffi ::c_uint ,
133+ buf : * mut ::core ::ffi ::c_int ,
134+ ) {
135+ let ref mut c2rust_fresh1 = id (0 as ::core ::ffi ::c_int );
136+ * (buf as *mut ::core ::ffi ::c_int ).offset (0 as ::core ::ffi ::c_int as isize ) =
137+ if * c2rust_fresh1 != 0 {
138+ * c2rust_fresh1
139+ } else {
140+ id (1 as ::core ::ffi ::c_int )
141+ };
142+ let ref mut c2rust_fresh2 = id (2 as ::core ::ffi ::c_int );
143+ * (buf as *mut ::core ::ffi ::c_int ).offset (1 as ::core ::ffi ::c_int as isize ) =
144+ if * c2rust_fresh2 != 0 {
145+ * c2rust_fresh2
146+ } else {
147+ id (3 as ::core ::ffi ::c_int )
148+ };
149+ if add (
150+ (buf as *mut ::core ::ffi ::c_int ).offset (2 as ::core ::ffi ::c_int as isize ),
151+ 2 as ::core ::ffi ::c_int ,
152+ 0 as ::core ::ffi ::c_int ,
153+ ) == 0
154+ {
155+ add (
156+ (buf as *mut ::core ::ffi ::c_int ).offset (3 as ::core ::ffi ::c_int as isize ),
157+ 3 as ::core ::ffi ::c_int ,
158+ 0 as ::core ::ffi ::c_int ,
159+ );
160+ }
161+ if add (
162+ (buf as *mut ::core ::ffi ::c_int ).offset (4 as ::core ::ffi ::c_int as isize ),
163+ 4 as ::core ::ffi ::c_int ,
164+ 1 as ::core ::ffi ::c_int ,
165+ ) == 0
166+ {
167+ add (
168+ (buf as *mut ::core ::ffi ::c_int ).offset (5 as ::core ::ffi ::c_int as isize ),
169+ 5 as ::core ::ffi ::c_int ,
170+ 0 as ::core ::ffi ::c_int ,
171+ );
172+ }
173+ }
0 commit comments