-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathsnapshots__transpile@exprs.c.2024.clang15.snap
More file actions
94 lines (94 loc) · 3.35 KB
/
Copy pathsnapshots__transpile@exprs.c.2024.clang15.snap
File metadata and controls
94 lines (94 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
source: c2rust-transpile/tests/snapshots.rs
expression: cat tests/snapshots/exprs.2024.clang15.rs
---
#![allow(
clippy::missing_safety_doc,
dead_code,
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
unsafe_op_in_unsafe_fn,
unused_assignments,
unused_mut
)]
unsafe extern "C" {
unsafe fn puts(str: *const ::core::ffi::c_char) -> ::core::ffi::c_int;
}
pub type ptrdiff_t = isize;
pub type E = ::core::ffi::c_uint;
pub const EA: E = 0;
pub type int_t = ::core::ffi::c_int;
pub type C2Rust_Unnamed = ::core::ffi::c_uint;
pub const C: C2Rust_Unnamed = 2;
pub const B: C2Rust_Unnamed = 1;
pub const A: C2Rust_Unnamed = 0;
unsafe extern "C" fn side_effect() -> ::core::ffi::c_int {
puts(b"the return of side effect\0".as_ptr() as *const ::core::ffi::c_char);
return 10 as ::core::ffi::c_int;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn unary_without_side_effect() {
let mut i: ::core::ffi::c_int = 5 as ::core::ffi::c_int;
-i;
i;
!i;
(i == 0) as ::core::ffi::c_int;
&raw mut i;
i;
i += 1;
i -= 1;
i -= 1;
i += 1;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn unary_with_side_effect() {
let mut arr: [*mut ::core::ffi::c_char; 1] = [::core::ptr::null_mut::<::core::ffi::c_char>()];
-side_effect();
side_effect();
!side_effect();
(side_effect() == 0) as ::core::ffi::c_int;
(b"\0".as_ptr() as *const ::core::ffi::c_char).offset(side_effect() as isize)
as *const ::core::ffi::c_char;
*arr[side_effect() as usize];
arr[side_effect() as usize] = arr[side_effect() as usize].offset(1);
arr[side_effect() as usize] = arr[side_effect() as usize].offset(-1);
arr[side_effect() as usize] = arr[side_effect() as usize].offset(1);
arr[side_effect() as usize] = arr[side_effect() as usize].offset(-1);
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn unsigned_compound_desugaring() {
let mut i: ::core::ffi::c_int = 0 as ::core::ffi::c_int;
let mut u: ::core::ffi::c_uint = 0 as ::core::ffi::c_uint;
let mut e: E = EA;
e = (e as ::core::ffi::c_uint).wrapping_add(u) as E;
i = (i as ::core::ffi::c_uint).wrapping_add(u) as ::core::ffi::c_int;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cast_literals() {
let mut i: ::core::ffi::c_int = 1 as ::core::ffi::c_int;
let mut it: int_t = 1 as int_t;
let mut i_neg: ::core::ffi::c_int = -1 as ::core::ffi::c_int;
let mut it_neg: int_t = -1 as int_t;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn compound_literal() {
let mut i: ::core::ffi::c_int = B as ::core::ffi::c_int;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn statement_expr() {
'_c2rust_label: {
puts(b"should execute\0".as_ptr() as *const ::core::ffi::c_char);
return;
};
puts(b"should be unreachable!\0".as_ptr() as *const ::core::ffi::c_char);
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pointer_arithmetic() {
let mut i1: [::core::ffi::c_int; 2] = [0 as ::core::ffi::c_int, 1 as ::core::ffi::c_int];
let mut i2: [::core::ffi::c_int; 2] = [10 as ::core::ffi::c_int, 11 as ::core::ffi::c_int];
let mut p1: *mut ::core::ffi::c_int = &raw mut i1 as *mut ::core::ffi::c_int;
let mut p2: *mut ::core::ffi::c_int = &raw mut i2 as *mut ::core::ffi::c_int;
let mut diff: ptrdiff_t = p1.offset_from(p2);
let mut diff_int: ::core::ffi::c_int = p1.offset_from(p2) as ::core::ffi::c_int;
}