motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit bcc371618fd71185e71a889c09eb68733ca66842 (tree)
parent 2871d32be727fc729ba4be0c615cb5fe97591391
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  7 Apr 2021 10:24:57 -0700

AstGen: fix `@breakpoint` ZIR

Previously it relied on the breakpoint ZIR instruction being void, but
that's no longer how things work.

Diffstat:
Msrc/AstGen.zig | 4++--
Mtest/stage2/cbe.zig | 9+++++++++
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/AstGen.zig b/src/AstGen.zig @@ -3894,11 +3894,11 @@ fn builtinCall( return rvalue(gz, scope, rl, result, node); }, .breakpoint => { - const result = try gz.add(.{ + _ = try gz.add(.{ .tag = .breakpoint, .data = .{ .node = gz.astgen.decl.nodeIndexToRelative(node) }, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, scope, rl, .void_value, node); }, .import => { const target = try expr(gz, scope, .none, params[0]); diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig @@ -280,6 +280,15 @@ pub fn addCases(ctx: *TestContext) !void { \\} , ""); + // If expression with breakpoint that does not get hit + case.addCompareOutput( + \\export fn main() c_int { + \\ var x: i32 = 1; + \\ if (x != 1) @breakpoint(); + \\ return 0; + \\} + , ""); + // Switch expression case.addCompareOutput( \\export fn main() c_int {