File tree 2 files changed +14
-1
lines changed
c2rust-transpile/src/translator
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,14 @@ impl<'c> Translation<'c> {
190
190
if is_string {
191
191
let v = ids. first ( ) . unwrap ( ) ;
192
192
self . convert_expr ( ctx. used ( ) , * v)
193
+ } else if ids. len ( ) == 0 {
194
+ // this was likely a C array of the form `int x[16] = {}`,
195
+ // we'll emit that as [0; 16].
196
+ let len = mk ( ) . lit_expr ( mk ( ) . int_unsuffixed_lit ( n as u128 ) ) ;
197
+ self . implicit_default_expr ( ty, ctx. is_static ) ?
198
+ . and_then ( |default_value| {
199
+ Ok ( WithStmts :: new_val ( mk ( ) . repeat_expr ( default_value, len) ) )
200
+ } )
193
201
} else {
194
202
Ok ( ids
195
203
. iter ( )
Original file line number Diff line number Diff line change @@ -6,9 +6,14 @@ static char *foo = "mystring";
6
6
void entry (const unsigned buffer_size , int buffer [const ])
7
7
{
8
8
int arr [1 ][1 ] = { 1 };
9
-
10
9
arr [0 ][0 ] += 9 ;
11
10
11
+ int arr2 [16 ] = {};
12
+ arr2 [15 ] += 9 ;
13
+
14
+ struct {char * x ; int y ;} arr3 [1 ] = {};
15
+ arr3 [0 ].y += 9 ;
16
+
12
17
int i = 0 ;
13
18
14
19
char abc [] = "abc" ;
You can’t perform that action at this time.
0 commit comments