| ... | @@ -2406,8 +2406,6 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { | ... | @@ -2406,8 +2406,6 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { |
| 2406 | ZigType *tag_int_type; | 2406 | ZigType *tag_int_type; |
| 2407 | if (enum_type->data.enumeration.layout == ContainerLayoutExtern) { | 2407 | if (enum_type->data.enumeration.layout == ContainerLayoutExtern) { |
| 2408 | tag_int_type = get_c_int_type(g, CIntTypeInt); | 2408 | tag_int_type = get_c_int_type(g, CIntTypeInt); |
| 2409 | } else if (enum_type->data.enumeration.layout == ContainerLayoutAuto && field_count == 1) { | | |
| 2410 | tag_int_type = g->builtin_types.entry_num_lit_int; | | |
| 2411 | } else { | 2409 | } else { |
| 2412 | tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); | 2410 | tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); |
| 2413 | } | 2411 | } |
| ... | @@ -2420,7 +2418,8 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { | ... | @@ -2420,7 +2418,8 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { |
| 2420 | ZigType *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr); | 2418 | ZigType *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr); |
| 2421 | if (type_is_invalid(wanted_tag_int_type)) { | 2419 | if (type_is_invalid(wanted_tag_int_type)) { |
| 2422 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; | 2420 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; |
| 2423 | } else if (wanted_tag_int_type->id != ZigTypeIdInt) { | 2421 | } else if (wanted_tag_int_type->id != ZigTypeIdInt && |
| | 2422 | wanted_tag_int_type->id != ZigTypeIdComptimeInt) { |
| 2424 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; | 2423 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; |
| 2425 | add_node_error(g, decl_node->data.container_decl.init_arg_expr, | 2424 | add_node_error(g, decl_node->data.container_decl.init_arg_expr, |
| 2426 | buf_sprintf("expected integer, found '%s'", buf_ptr(&wanted_tag_int_type->name))); | 2425 | buf_sprintf("expected integer, found '%s'", buf_ptr(&wanted_tag_int_type->name))); |
| ... | @@ -2806,14 +2805,12 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { | ... | @@ -2806,14 +2805,12 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { |
| 2806 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | 2805 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; |
| 2807 | return ErrorSemanticAnalyzeFail; | 2806 | return ErrorSemanticAnalyzeFail; |
| 2808 | } | 2807 | } |
| 2809 | if (tag_int_type->id != ZigTypeIdInt) { | 2808 | if (tag_int_type->id != ZigTypeIdInt && tag_int_type->id != ZigTypeIdComptimeInt) { |
| 2810 | add_node_error(g, enum_type_node, | 2809 | add_node_error(g, enum_type_node, |
| 2811 | buf_sprintf("expected integer tag type, found '%s'", buf_ptr(&tag_int_type->name))); | 2810 | buf_sprintf("expected integer tag type, found '%s'", buf_ptr(&tag_int_type->name))); |
| 2812 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | 2811 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; |
| 2813 | return ErrorSemanticAnalyzeFail; | 2812 | return ErrorSemanticAnalyzeFail; |
| 2814 | } | 2813 | } |
| 2815 | } else if (auto_layout && field_count == 1) { | | |
| 2816 | tag_int_type = g->builtin_types.entry_num_lit_int; | | |
| 2817 | } else { | 2814 | } else { |
| 2818 | tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); | 2815 | tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); |
| 2819 | } | 2816 | } |