mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Bitstruct as substruct fails to properly work with designated initializers. #2827
This commit is contained in:
@@ -519,13 +519,11 @@ static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type
|
||||
}
|
||||
}
|
||||
Type *original = flattened->canonical;
|
||||
bool is_bitstruct = original->type_kind == TYPE_BITSTRUCT;
|
||||
bool is_structlike = type_is_union_or_strukt(original) || is_bitstruct;
|
||||
bool is_structlike = type_is_union_or_strukt(original) || original->type_kind == TYPE_BITSTRUCT;
|
||||
ArrayIndex max_index = -1;
|
||||
bool optional = false;
|
||||
Type *inner_type = NULL;
|
||||
bool is_inferred = type_is_inferred(flattened);
|
||||
int bitmember_count_without_value = 0;
|
||||
FOREACH(Expr *, expr, init_expressions)
|
||||
{
|
||||
Decl *member;
|
||||
@@ -535,10 +533,8 @@ static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type
|
||||
Expr *value = expr->designator_expr.value;
|
||||
if (!value && is_bitmember && member->var.start_bit == member->var.end_bit && type_flatten(result) == type_bool)
|
||||
{
|
||||
ASSERT(is_bitstruct);
|
||||
value = expr_new_const_bool(INVALID_SPAN, type_bool, true);
|
||||
expr->designator_expr.value = value;
|
||||
bitmember_count_without_value += 1;
|
||||
}
|
||||
if (!value) RETURN_SEMA_ERROR(expr, "This initializer needs a value.");
|
||||
if (!sema_analyse_expr_rhs(context, result, value, true, no_match_ref, false)) return false;
|
||||
@@ -553,10 +549,6 @@ static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type
|
||||
inner_type = type_no_optional(value->type);
|
||||
}
|
||||
}
|
||||
if (bitmember_count_without_value != 0 && bitmember_count_without_value != vec_size(init_expressions))
|
||||
{
|
||||
RETURN_SEMA_ERROR(initializer, "Mixing the omission of initializers is not permitted.");
|
||||
}
|
||||
Type *type;
|
||||
if (!is_structlike && is_inferred)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user