@@ -3053,11 +3053,10 @@ impl<'c> Translation<'c> {
30533053 CDeclKind :: EnumConstant { .. } => {
30543054 // If the variable is actually an `EnumConstant`, we need to add a cast to
30553055 // the expected integral type.
3056- if !self . enum_constant_matches_type (
3057- override_ty. unwrap_or ( qual_ty) . ctype ,
3058- decl_id,
3059- ) {
3060- val = self . convert_cast_from_enum ( qual_ty. ctype , val) ?;
3056+ let target_type_id = override_ty. unwrap_or ( qual_ty) ;
3057+
3058+ if !self . enum_constant_matches_type ( target_type_id. ctype , decl_id) {
3059+ val = self . convert_cast_from_enum ( target_type_id. ctype , val) ?;
30613060 }
30623061
30633062 return Ok ( WithStmts :: new_val ( val) ) ;
@@ -3597,6 +3596,18 @@ impl<'c> Translation<'c> {
35973596 if self . enum_constant_matches_type ( target_type_id. ctype , decl_id) {
35983597 return true ;
35993598 }
3599+
3600+ let source_enum_id = self . ast_context . parents [ & decl_id] ;
3601+ let source_integral_type_id = self . enum_integral_type ( source_enum_id) ;
3602+ let target_type_resolved_id = self
3603+ . ast_context
3604+ . resolve_type_id_no_typedef ( target_type_id. ctype ) ;
3605+
3606+ // Likewise, if we are casting to the inner integral type of the enum, then
3607+ // translate the enum constant directly as that.
3608+ if target_type_resolved_id == source_integral_type_id. ctype {
3609+ return true ;
3610+ }
36003611 }
36013612 }
36023613
0 commit comments