aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-05 17:19:01 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-03-05 17:19:01 -0500
commit01c722c21cd4f0216a722fa698d704e23707a5ba (patch)
tree32e0b49d824a1c99ef5d1911709e40ad669e42e0 /src
parentf5954dad8356c05c294630f19609c343d65ea544 (diff)
downloadzig-01c722c21cd4f0216a722fa698d704e23707a5ba.tar.gz
zig-01c722c21cd4f0216a722fa698d704e23707a5ba.zip
Revert "Allow constant struct val to reallocate its fields when resolving an inferred struct field with a comptime value."
This reverts commit debcc79d56a40f77b92e243b4e344fc9385bd405. This caused a regression when building self-hosted
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 517c07147d..56ba634189 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -18477,15 +18477,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
IrInstGen *casted_ptr;
if (isf->already_resolved) {
field = find_struct_type_field(isf->inferred_struct_type, isf->field_name);
-
- // If the value originates from another node than the original value's we overwrite the inferred struct's
- // type so that the new result can be written successfully.
- // The duplicate field will be detected and reported in 'ir_analyze_container_init_fields'
- AstNode *decl_node = value ? value->base.source_node : suspend_source_instr->source_node;
- if (decl_node != field->decl_node) {
- field->type_entry = value_type;
- field->type_val = create_const_type(ira->codegen, field->type_entry);
- }
casted_ptr = result_loc;
} else {
isf->already_resolved = true;
@@ -18502,6 +18493,15 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
field->type_val = create_const_type(ira->codegen, field->type_entry);
field->src_index = old_field_count;
field->decl_node = value ? value->base.source_node : suspend_source_instr->source_node;
+ if (value && instr_is_comptime(value)) {
+ ZigValue *val = ir_resolve_const(ira, value, UndefOk);
+ if (!val)
+ return ira->codegen->invalid_inst_gen;
+ field->is_comptime = true;
+ field->init_val = ira->codegen->pass1_arena->create<ZigValue>();
+ copy_const_val(ira->codegen, field->init_val, val);
+ return result_loc;
+ }
ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false);
if (instr_is_comptime(result_loc)) {
@@ -18532,16 +18532,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
}
}
- if (value && instr_is_comptime(value)) {
- ZigValue *val = ir_resolve_const(ira, value, UndefOk);
- if (!val)
- return ira->codegen->invalid_inst_gen;
- field->is_comptime = true;
- field->init_val = ira->codegen->pass1_arena->create<ZigValue>();
- copy_const_val(ira->codegen, field->init_val, val);
- return result_loc;
- }
-
result_loc = ir_analyze_struct_field_ptr(ira, suspend_source_instr, field, casted_ptr,
isf->inferred_struct_type, true);
result_loc_pass1->resolved_loc = result_loc;
@@ -22967,9 +22957,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc
first_non_const_instruction = result_loc;
}
}
-
- heap::c_allocator.deallocate(field_assign_nodes, actual_field_count);
-
if (any_missing)
return ira->codegen->invalid_inst_gen;
@@ -22985,8 +22972,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc
}
}
- const_ptrs.deinit();
-
IrInstGen *result = ir_get_deref(ira, source_instr, result_loc, nullptr);
if (is_comptime && !instr_is_comptime(result)) {