decay bitfield types in casting path, allow casting to integer types

This commit is contained in:
Ryan Fleury
2025-07-25 15:29:34 -07:00
parent 393c291f63
commit 163b79e4c0
3 changed files with 11 additions and 6 deletions
+8 -5
View File
@@ -848,8 +848,10 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
e_msg_list_concat_in_place(&result.msgs, &casted_tree.msgs);
E_TypeKey casted_type = e_type_key_unwrap(casted_tree.type_key, E_TypeUnwrapFlag_AllDecorative);
E_TypeKind casted_type_kind = e_type_kind_from_key(casted_type);
E_TypeKey casted_type_unwrapped = e_type_key_unwrap(casted_type, E_TypeUnwrapFlag_Bitfields|E_TypeUnwrapFlag_AllDecorative);
E_TypeKind casted_type_unwrapped_kind = e_type_kind_from_key(casted_type_unwrapped);
U64 casted_type_byte_size = e_type_byte_size_from_key(casted_type);
U8 in_group = e_type_group_from_kind(casted_type_kind);
U8 in_group = e_type_group_from_kind(casted_type_unwrapped_kind);
U8 out_group = e_type_group_from_kind(cast_type_unwrapped_kind);
RDI_EvalConversionKind conversion_rule = rdi_eval_conversion_kind_from_typegroups(in_group, out_group);
@@ -886,7 +888,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
{
new_tree = e_irtree_trunc(arena, in_tree, cast_type);
}
if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_kind) && !e_type_kind_is_signed(casted_type_kind))
if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind))
{
new_tree = e_irtree_trunc(arena, in_tree, cast_type);
}
@@ -1408,9 +1410,10 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
E_TypeKind cast_type_unwrapped_kind = e_type_kind_from_key(cast_type_unwrapped);
U64 cast_type_byte_size = e_type_byte_size_from_key(cast_type);
E_TypeKey casted_type = casted_tree.type_key;
E_TypeKind casted_type_kind = e_type_kind_from_key(casted_type);
E_TypeKey casted_type_unwrapped = e_type_key_unwrap(casted_type, E_TypeUnwrapFlag_Bitfields|E_TypeUnwrapFlag_AllDecorative);
E_TypeKind casted_type_unwrapped_kind = e_type_kind_from_key(casted_type_unwrapped);
U64 casted_type_byte_size = e_type_byte_size_from_key(casted_type);
U8 in_group = e_type_group_from_kind(casted_type_kind);
U8 in_group = e_type_group_from_kind(casted_type_unwrapped_kind);
U8 out_group = e_type_group_from_kind(cast_type_unwrapped_kind);
RDI_EvalConversionKind conversion_rule = rdi_eval_conversion_kind_from_typegroups(in_group, out_group);
@@ -1447,7 +1450,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
{
new_tree = e_irtree_trunc(arena, in_tree, cast_type);
}
if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_kind) && !e_type_kind_is_signed(casted_type_kind))
if(e_type_kind_is_signed(cast_type_unwrapped_kind) && e_type_kind_is_integer(casted_type_unwrapped_kind) && !e_type_kind_is_signed(casted_type_unwrapped_kind))
{
new_tree = e_irtree_trunc(arena, in_tree, cast_type);
}
+1
View File
@@ -1509,6 +1509,7 @@ e_type_key_unwrap(E_TypeKey key, E_TypeUnwrapFlags flags)
case E_TypeKind_MetaExpr: {done = !(flags & E_TypeUnwrapFlag_Meta);}break;
case E_TypeKind_Enum: {done = !(flags & E_TypeUnwrapFlag_Enums);}break;
case E_TypeKind_Alias: {done = !(flags & E_TypeUnwrapFlag_Aliases);}break;
case E_TypeKind_Bitfield: {done = !(flags & E_TypeUnwrapFlag_Bitfields);}break;
case E_TypeKind_Array:
case E_TypeKind_Ptr:
case E_TypeKind_RRef:
+2 -1
View File
@@ -16,8 +16,9 @@ enum
E_TypeUnwrapFlag_Meta = (1<<3),
E_TypeUnwrapFlag_Enums = (1<<4),
E_TypeUnwrapFlag_Aliases = (1<<5),
E_TypeUnwrapFlag_Bitfields = (1<<6),
E_TypeUnwrapFlag_All = 0xffffffff,
E_TypeUnwrapFlag_AllDecorative = (E_TypeUnwrapFlag_All & ~E_TypeUnwrapFlag_Pointers)
E_TypeUnwrapFlag_AllDecorative = (E_TypeUnwrapFlag_All & ~(E_TypeUnwrapFlag_Pointers|E_TypeUnwrapFlag_Bitfields))
};
////////////////////////////////