@@ -114,16 +114,18 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
114
114
self . context . new_function_pointer_type ( None , return_type, params, false )
115
115
}
116
116
117
- fn type_struct ( & self , fields : & [ Type < ' gcc > ] , _packed : bool ) -> Type < ' gcc > {
117
+ fn type_struct ( & self , fields : & [ Type < ' gcc > ] , packed : bool ) -> Type < ' gcc > {
118
118
let types = fields. to_vec ( ) ;
119
119
if let Some ( typ) = self . struct_types . borrow ( ) . get ( fields) {
120
120
return typ. clone ( ) ;
121
121
}
122
122
let fields: Vec < _ > = fields. iter ( ) . enumerate ( )
123
123
. map ( |( index, field) | self . context . new_field ( None , * field, & format ! ( "field{}_TODO" , index) ) )
124
124
. collect ( ) ;
125
- // TODO(antoyo): use packed.
126
125
let typ = self . context . new_struct_type ( None , "struct" , & fields) . as_type ( ) ;
126
+ if packed {
127
+ typ. set_packed ( ) ;
128
+ }
127
129
self . struct_types . borrow_mut ( ) . insert ( types, typ) ;
128
130
typ
129
131
}
@@ -209,12 +211,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
209
211
self . type_array ( self . type_from_integer ( unit) , size / unit_size)
210
212
}
211
213
212
- pub fn set_struct_body ( & self , typ : Struct < ' gcc > , fields : & [ Type < ' gcc > ] , _packed : bool ) {
213
- // TODO(antoyo): use packed.
214
+ pub fn set_struct_body ( & self , typ : Struct < ' gcc > , fields : & [ Type < ' gcc > ] , packed : bool ) {
214
215
let fields: Vec < _ > = fields. iter ( ) . enumerate ( )
215
216
. map ( |( index, field) | self . context . new_field ( None , * field, & format ! ( "field_{}" , index) ) )
216
217
. collect ( ) ;
217
218
typ. set_fields ( None , & fields) ;
219
+ if packed {
220
+ typ. as_type ( ) . set_packed ( ) ;
221
+ }
218
222
}
219
223
220
224
pub fn type_named_struct ( & self , name : & str ) -> Struct < ' gcc > {
0 commit comments