mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-24 22:54:59 -07:00
Add intrinsics.type_struct_has_implicit_padding #3844
This commit is contained in:
@@ -5839,6 +5839,31 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
||||
operand->mode = Addressing_Constant;
|
||||
operand->type = t_untyped_integer;
|
||||
break;
|
||||
case BuiltinProc_type_struct_has_implicit_padding:
|
||||
operand->value = exact_value_bool(false);
|
||||
if (operand->mode != Addressing_Type) {
|
||||
error(operand->expr, "Expected a struct type for '%.*s'", LIT(builtin_name));
|
||||
} else if (!is_type_struct(operand->type) && !is_type_soa_struct(operand->type)) {
|
||||
error(operand->expr, "Expected a struct type for '%.*s'", LIT(builtin_name));
|
||||
} else {
|
||||
Type *bt = base_type(operand->type);
|
||||
if (bt->Struct.is_packed) {
|
||||
operand->value = exact_value_bool(false);
|
||||
} else if (bt->Struct.fields.count != 0) {
|
||||
i64 size = type_size_of(bt);
|
||||
Type *field_type = nullptr;
|
||||
i64 last_offset = type_offset_of(bt, bt->Struct.fields.count-1, &field_type);
|
||||
if (last_offset+type_size_of(field_type) < size) {
|
||||
operand->value = exact_value_bool(true);
|
||||
} else {
|
||||
i64 packed_size = type_size_of_struct_pretend_is_packed(bt);
|
||||
operand->value = exact_value_bool(packed_size < size);
|
||||
}
|
||||
}
|
||||
}
|
||||
operand->mode = Addressing_Constant;
|
||||
operand->type = t_untyped_bool;
|
||||
break;
|
||||
|
||||
case BuiltinProc_type_proc_parameter_count:
|
||||
operand->value = exact_value_i64(0);
|
||||
|
||||
Reference in New Issue
Block a user