mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
astgen.zig: fix false positive in breakExpr's checking for store_to_block_ptr
This commit is contained in:
parent
cde3dd365e
commit
79a3dfcfd8
@ -1691,9 +1691,9 @@ fn breakExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) Inn
|
||||
return Zir.Inst.Ref.unreachable_value;
|
||||
}
|
||||
block_gz.break_count += 1;
|
||||
const prev_rvalue_rl_count = block_gz.rvalue_rl_count;
|
||||
const operand = try expr(parent_gz, parent_scope, block_gz.break_result_loc, rhs);
|
||||
const have_store_to_block = block_gz.rvalue_rl_count != prev_rvalue_rl_count;
|
||||
// if list grew as much as rvalue_rl_count, then a break inside operand already saved the store_to_block_ptr
|
||||
const have_store_to_block = block_gz.rvalue_rl_count > block_gz.labeled_store_to_block_ptr_list.items.len;
|
||||
|
||||
const br = try parent_gz.addBreak(.@"break", block_inst, operand);
|
||||
|
||||
|
||||
@ -112,6 +112,7 @@ test {
|
||||
_ = @import("behavior/bugs/7047.zig");
|
||||
_ = @import("behavior/bugs/7250.zig");
|
||||
_ = @import("behavior/bugs/9584.zig");
|
||||
_ = @import("behavior/bugs/9967.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call_stage1.zig");
|
||||
|
||||
8
test/behavior/bugs/9967.zig
Normal file
8
test/behavior/bugs/9967.zig
Normal file
@ -0,0 +1,8 @@
|
||||
const std = @import("std");
|
||||
|
||||
test "nested breaks to same labeled block" {
|
||||
const a = blk: {
|
||||
break :blk break :blk @as(u32, 1);
|
||||
};
|
||||
try std.testing.expectEqual(a, 1);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user