mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 16:43:07 +00:00
Merge pull request #15591 from jacobly0/undef-errdefer-capture
AstGen: fix branch on undefined
This commit is contained in:
commit
1e9811070b
@ -2905,7 +2905,15 @@ fn deferStmt(
|
||||
const sub_scope = if (!have_err_code) &defer_gen.base else blk: {
|
||||
try gz.addDbgBlockBegin();
|
||||
const ident_name = try gz.astgen.identAsString(payload_token);
|
||||
remapped_err_code = @intCast(u32, try gz.astgen.instructions.addOne(gz.astgen.gpa));
|
||||
remapped_err_code = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
|
||||
try gz.astgen.instructions.append(gz.astgen.gpa, .{
|
||||
.tag = .extended,
|
||||
.data = .{ .extended = .{
|
||||
.opcode = .errdefer_err_code,
|
||||
.small = undefined,
|
||||
.operand = undefined,
|
||||
} },
|
||||
});
|
||||
const remapped_err_code_ref = Zir.indexToRef(remapped_err_code);
|
||||
local_val_scope = .{
|
||||
.parent = &defer_gen.base,
|
||||
|
||||
@ -1198,6 +1198,7 @@ fn analyzeBodyInner(
|
||||
i += 1;
|
||||
continue;
|
||||
},
|
||||
.errdefer_err_code => unreachable, // never appears in a body
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@ -1979,7 +1979,7 @@ pub const Inst = struct {
|
||||
/// `operand` is `src_node: i32`.
|
||||
breakpoint,
|
||||
/// Implements the `@select` builtin.
|
||||
/// operand` is payload index to `Select`.
|
||||
/// `operand` is payload index to `Select`.
|
||||
select,
|
||||
/// Implement builtin `@errToInt`.
|
||||
/// `operand` is payload index to `UnNode`.
|
||||
@ -1999,7 +1999,7 @@ pub const Inst = struct {
|
||||
/// `operand` is payload index to `Cmpxchg`.
|
||||
cmpxchg,
|
||||
/// Implement the builtin `@addrSpaceCast`
|
||||
/// `Operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
|
||||
/// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
|
||||
addrspace_cast,
|
||||
/// Implement builtin `@cVaArg`.
|
||||
/// `operand` is payload index to `BinNode`.
|
||||
@ -2031,6 +2031,9 @@ pub const Inst = struct {
|
||||
/// Implements the `@inComptime` builtin.
|
||||
/// `operand` is `src_node: i32`.
|
||||
in_comptime,
|
||||
/// Used as a placeholder for the capture of an `errdefer`.
|
||||
/// This is replaced by Sema with the captured value.
|
||||
errdefer_err_code,
|
||||
|
||||
pub const InstData = struct {
|
||||
opcode: Extended,
|
||||
|
||||
@ -467,6 +467,7 @@ const Writer = struct {
|
||||
.breakpoint,
|
||||
.c_va_start,
|
||||
.in_comptime,
|
||||
.errdefer_err_code,
|
||||
=> try self.writeExtNode(stream, extended),
|
||||
|
||||
.builtin_src => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user