authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-07 10:24:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-07 10:24:57-07:00
logbcc371618fd71185e71a889c09eb68733ca66842
tree9fa3bff07baa61f3edadff24a3c5898418267472
parent2871d32be727fc729ba4be0c615cb5fe97591391

AstGen: fix `@breakpoint` ZIR

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

2 files changed, 11 insertions(+), 2 deletions(-)

src/AstGen.zig+2-2
...@@ -3894,11 +3894,11 @@ fn builtinCall(...@@ -3894,11 +3894,11 @@ fn builtinCall(
3894 return rvalue(gz, scope, rl, result, node);3894 return rvalue(gz, scope, rl, result, node);
3895 },3895 },
3896 .breakpoint => {3896 .breakpoint => {
3897 const result = try gz.add(.{3897 _ = try gz.add(.{
3898 .tag = .breakpoint,3898 .tag = .breakpoint,
3899 .data = .{ .node = gz.astgen.decl.nodeIndexToRelative(node) },3899 .data = .{ .node = gz.astgen.decl.nodeIndexToRelative(node) },
3900 });3900 });
3901 return rvalue(gz, scope, rl, result, node);3901 return rvalue(gz, scope, rl, .void_value, node);
3902 },3902 },
3903 .import => {3903 .import => {
3904 const target = try expr(gz, scope, .none, params[0]);3904 const target = try expr(gz, scope, .none, params[0]);
test/stage2/cbe.zig+9
...@@ -280,6 +280,15 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -280,6 +280,15 @@ pub fn addCases(ctx: *TestContext) !void {
280 \\}280 \\}
281 , "");281 , "");
282282
283 // If expression with breakpoint that does not get hit
284 case.addCompareOutput(
285 \\export fn main() c_int {
286 \\ var x: i32 = 1;
287 \\ if (x != 1) @breakpoint();
288 \\ return 0;
289 \\}
290 , "");
291
283 // Switch expression292 // Switch expression
284 case.addCompareOutput(293 case.addCompareOutput(
285 \\export fn main() c_int {294 \\export fn main() c_int {