Skip to content

Commit 359e1bc

Browse files
committed
transpile: Add override_ty tests to arrays.c
1 parent 832d4bd commit 359e1bc

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

c2rust-transpile/tests/snapshots/arrays.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ char static_char_array[] = "mystring";
44
char *static_char_ptr = "mystring";
55
void *static_void_ptr = (void*) static_char_array;
66

7+
typedef int int_t;
8+
79
void entry(void) {
810
int int_2d[1][1] = { 1 };
911
int_2d[0][0] += 9;
@@ -14,6 +16,9 @@ void entry(void) {
1416
int int_too_short[16] = {0};
1517
int_too_short[15] += 9;
1618

19+
int_t override_ty[] = { 1 };
20+
int_t override_ty_neg[] = { -1 };
21+
1722
struct {char* x; int y;} struct_init_too_short[1] = {};
1823
struct_init_too_short[0].y += 9;
1924
struct {short; int y;} struct_init_too_long[1] = { { 1, 2 } };

c2rust-transpile/tests/snapshots/snapshots__transpile@arrays.c.2021.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ expression: cat tests/snapshots/arrays.2021.rs
1212
unused_mut
1313
)]
1414
#![feature(raw_ref_op)]
15+
pub type int_t = ::core::ffi::c_int;
1516
#[derive(Copy, Clone)]
1617
#[repr(C)]
1718
pub struct C2Rust_Unnamed {
@@ -56,6 +57,8 @@ pub unsafe extern "C" fn entry() {
5657
let mut int_zero: [::core::ffi::c_int; 0] = [0; 0];
5758
let mut int_too_short: [::core::ffi::c_int; 16] = [0 as ::core::ffi::c_int; 16];
5859
int_too_short[15 as ::core::ffi::c_int as usize] += 9 as ::core::ffi::c_int;
60+
let mut override_ty: [int_t; 1] = [1 as ::core::ffi::c_int];
61+
let mut override_ty_neg: [int_t; 1] = [-1 as ::core::ffi::c_int];
5962
let mut struct_init_too_short: [C2Rust_Unnamed_0; 1] = [C2Rust_Unnamed_0 {
6063
x: ::core::ptr::null_mut::<::core::ffi::c_char>(),
6164
y: 0,

c2rust-transpile/tests/snapshots/snapshots__transpile@arrays.c.2024.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ expression: cat tests/snapshots/arrays.2024.rs
1212
unused_assignments,
1313
unused_mut
1414
)]
15+
pub type int_t = ::core::ffi::c_int;
1516
#[derive(Copy, Clone)]
1617
#[repr(C)]
1718
pub struct C2Rust_Unnamed {
@@ -56,6 +57,8 @@ pub unsafe extern "C" fn entry() {
5657
let mut int_zero: [::core::ffi::c_int; 0] = [0; 0];
5758
let mut int_too_short: [::core::ffi::c_int; 16] = [0 as ::core::ffi::c_int; 16];
5859
int_too_short[15 as ::core::ffi::c_int as usize] += 9 as ::core::ffi::c_int;
60+
let mut override_ty: [int_t; 1] = [1 as ::core::ffi::c_int];
61+
let mut override_ty_neg: [int_t; 1] = [-1 as ::core::ffi::c_int];
5962
let mut struct_init_too_short: [C2Rust_Unnamed_0; 1] = [C2Rust_Unnamed_0 {
6063
x: ::core::ptr::null_mut::<::core::ffi::c_char>(),
6164
y: 0,

0 commit comments

Comments
 (0)