diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-06-25 11:31:38 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-06-25 11:31:38 -0400 |
| commit | c61e0a078cea2a6845ed7b03189409829d2cdf24 (patch) | |
| tree | 8a64733d2ecf5121dbdf0db998f4d69a4e5629e6 /src/ir.cpp | |
| parent | 3021e5ca67acca6cf7420bc5e2400aa6965596f9 (diff) | |
| download | zig-c61e0a078cea2a6845ed7b03189409829d2cdf24.tar.gz zig-c61e0a078cea2a6845ed7b03189409829d2cdf24.zip | |
fix union init with void payload
all std lib tests passing now
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 32e3692afd..2991dd5186 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17425,11 +17425,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction ConstExprValue *field_val = &struct_val->data.x_struct.fields[i]; field_val->special = ConstValSpecialUndef; field_val->type = struct_type->data.structure.fields[i].type_entry; - ConstParent *parent = get_const_val_parent(ira->codegen, field_val); - assert(parent != nullptr); - parent->id = ConstParentIdStruct; - parent->data.p_struct.struct_val = struct_val; - parent->data.p_struct.field_index = i; + field_val->parent.id = ConstParentIdStruct; + field_val->parent.data.p_struct.struct_val = struct_val; + field_val->parent.data.p_struct.field_index = i; } } IrInstruction *result; @@ -17507,11 +17505,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ ConstExprValue *payload_val = create_const_vals(1); payload_val->special = ConstValSpecialUndef; payload_val->type = field->type_entry; - ConstParent *parent = get_const_val_parent(ira->codegen, payload_val); - if (parent != nullptr) { - parent->id = ConstParentIdUnion; - parent->data.p_union.union_val = union_val; - } + payload_val->parent.id = ConstParentIdUnion; + payload_val->parent.data.p_union.union_val = union_val; union_val->special = ConstValSpecialStatic; bigint_init_bigint(&union_val->data.x_union.tag, &field->enum_field->value); @@ -25289,7 +25284,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { case IrInstructionIdReturnPtr: case IrInstructionIdTypeOf: case IrInstructionIdStructFieldPtr: - case IrInstructionIdUnionFieldPtr: case IrInstructionIdArrayType: case IrInstructionIdPromiseType: case IrInstructionIdSliceType: @@ -25389,6 +25383,8 @@ bool ir_has_side_effects(IrInstruction *instruction) { } case IrInstructionIdUnwrapErrCode: return reinterpret_cast<IrInstructionUnwrapErrCode *>(instruction)->initializing; + case IrInstructionIdUnionFieldPtr: + return reinterpret_cast<IrInstructionUnionFieldPtr *>(instruction)->initializing; case IrInstructionIdErrWrapPayload: return reinterpret_cast<IrInstructionErrWrapPayload *>(instruction)->result_loc != nullptr; case IrInstructionIdErrWrapCode: |
