authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-01 23:23:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-02 00:09:24-07:00
log12ce6eb8f65e6de5920c713cf2767e4b8ba0f1d3
tree1d8da259b78eddf706c7c3e0d0d3d1511c970c85
parent90ace40e07de7bca2558da72e6d67cf660f86192

stage2: support dbg_stmt at comptime


2 files changed, 8 insertions(+), 4 deletions(-)

src-self-hosted/zir_sema.zig+6-2
...@@ -643,8 +643,12 @@ fn analyzeInstBreakVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.BreakVoid)...@@ -643,8 +643,12 @@ fn analyzeInstBreakVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.BreakVoid)
643}643}
644644
645fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst {645fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst {
646 const b = try mod.requireRuntimeBlock(scope, inst.base.src);646 if (scope.cast(Scope.Block)) |b| {
647 return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .dbg_stmt);647 if (!b.is_comptime) {
648 return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .dbg_stmt);
649 }
650 }
651 return mod.constVoid(scope, inst.base.src);
648}652}
649653
650fn analyzeInstDeclRefStr(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRefStr) InnerError!*Inst {654fn analyzeInstDeclRefStr(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRefStr) InnerError!*Inst {
test/stage2/test.zig+2-2
...@@ -973,8 +973,8 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -973,8 +973,8 @@ pub fn addCases(ctx: *TestContext) !void {
973 \\comptime {973 \\comptime {
974 \\ _ = foo;974 \\ _ = foo;
975 \\}975 \\}
976 \\extern var foo;976 \\extern var foo: i32;
977 , &[_][]const u8{":2:5: error: unable to resolve comptime value"});977 , &[_][]const u8{":2:9: error: unable to resolve comptime value"});
978 case.addError(978 case.addError(
979 \\export fn entry() void {979 \\export fn entry() void {
980 \\ _ = foo;980 \\ _ = foo;