aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-29 14:26:23 -0400
committerGitHub <noreply@github.com>2022-06-29 14:26:23 -0400
commit98681b2da070755c29065d21d2ffb17be37d9619 (patch)
treecf9592ac47d5fd6d10557be65fb9d38c624728ee /src/Sema.zig
parent7cc417644862a9b9523545f4455da7722afc8209 (diff)
parentc3ae909e935f1548408f2e400464370ee02b7e82 (diff)
downloadzig-98681b2da070755c29065d21d2ffb17be37d9619.tar.gz
zig-98681b2da070755c29065d21d2ffb17be37d9619.zip
Merge pull request #11958 from ziglang/store-to-inferred-ptr
stage2: fix miscompilations for peer expressions any time they needed coercions to runtime types
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 798dc06db1..159574e3d5 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -3079,28 +3079,6 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
if (var_is_mut) {
try sema.validateVarType(block, ty_src, final_elem_ty, false);
-
- // The value might have been bitcasted into a comptime only
- // pointer type such as `*@Type(.EnumLiteral)` so we must now
- // update all the stores to not give backends invalid AIR.
-
- var air_tags = sema.air_instructions.items(.tag);
- var air_data = sema.air_instructions.items(.data);
- var peer_inst_index: usize = 0;
- var i = ptr_inst;
- while (i < air_tags.len and peer_inst_index < peer_inst_list.len) : (i += 1) {
- if (air_tags[i] != .store) continue;
- if (air_data[i].bin_op.rhs == peer_inst_list[peer_inst_index]) {
- peer_inst_index += 1;
- _ = (try sema.resolveMaybeUndefVal(block, .unneeded, air_data[i].bin_op.rhs)) orelse continue;
- const coerced_val = try sema.coerce(block, final_elem_ty, air_data[i].bin_op.rhs, .unneeded);
- air_tags = sema.air_instructions.items(.tag);
- air_data = sema.air_instructions.items(.data);
-
- air_data[i].bin_op.lhs = ptr;
- air_data[i].bin_op.rhs = coerced_val;
- }
- }
} else ct: {
// Detect if the value is comptime known. In such case, the
// last 3 AIR instructions of the block will look like this:
@@ -4478,6 +4456,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro
.label = &label,
.inlining = parent_block.inlining,
.is_comptime = parent_block.is_comptime,
+ .want_safety = parent_block.want_safety,
};
defer child_block.instructions.deinit(gpa);