@@ -3778,10 +3778,41 @@ impl<'c> Translation<'c> {
37783778 return self . convert_expr ( ctx, expr, override_ty) ;
37793779 }
37803780 }
3781+ if kind == CastKind :: ArrayToPointerDecay && override_ty. is_some ( ) {
3782+ let target_elem = match & self
3783+ . ast_context
3784+ . resolve_type ( override_ty. unwrap ( ) . ctype )
3785+ . kind
3786+ {
3787+ CTypeKind :: Pointer ( qtype) => qtype. ctype ,
3788+ k => panic ! ( "ArrayToPointerDecay producing non-pointer type {k:?}" ) ,
3789+ } ;
3790+ let new_array_override_ty_kind =
3791+ match & self . ast_context . resolve_type ( source_ty. ctype ) . kind {
3792+ CTypeKind :: ConstantArray ( _elem, len) => {
3793+ CTypeKind :: ConstantArray ( target_elem, * len)
3794+ }
3795+ CTypeKind :: VariableArray ( _elem, len) => {
3796+ CTypeKind :: VariableArray ( target_elem, * len)
3797+ }
3798+ k => panic ! ( "ArrayToPointerDecay on non-array type {k:?}" ) ,
3799+ } ;
3800+ //
3801+ // && Some(source_ty.ctype) != override_ty.map(|x| x.ctype)
3802+ let new_array_override_ty = self
3803+ . ast_context
3804+ . type_for_kind ( & new_array_override_ty_kind)
3805+ . expect ( & format ! (
3806+ "type id did not already exist for {:?}" ,
3807+ new_array_override_ty_kind
3808+ ) ) ;
3809+
3810+ self . convert_expr ( ctx, expr, Some ( CQualTypeId :: new ( new_array_override_ty) ) ) ?
3811+ }
37813812 // LValueToRValue casts don't actually change the type, so it still makes sense
37823813 // to translate their inner expression with the expected type from outside the
37833814 // cast.
3784- if kind == CastKind :: LValueToRValue
3815+ else if kind == CastKind :: LValueToRValue
37853816 && Some ( source_ty. ctype ) != override_ty. map ( |x| x. ctype )
37863817 {
37873818 self . convert_expr ( ctx, expr, override_ty) ?
0 commit comments