Skip to content

Commit

Permalink
apply fix and add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongnull committed Nov 23, 2023
1 parent 6f8c597 commit 8afbb8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6189,7 +6189,10 @@ fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData)
const mod = sema.mod;
const ip = &mod.intern_pool;
const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
const builtin_src = LazySrcLoc.nodeOffset(extra.node);
const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
if (sema.func_index == .none)
return sema.fail(block, builtin_src, "@setCold outside function body", .{});
const is_cold = try sema.resolveConstBool(block, operand_src, extra.operand, .{
.needed_comptime_reason = "operand to @setCold must be comptime-known",
});
Expand Down Expand Up @@ -16756,7 +16759,9 @@ fn zirRetAddr(
block: *Block,
extended: Zir.Inst.Extended.InstData,
) CompileError!Air.Inst.Ref {
_ = extended;
const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
if (sema.func_index == .none)
return sema.fail(block, src, "@returnAddress outside function body", .{});
if (block.is_comptime) {
// TODO: we could give a meaningful lazy value here. #14938
return sema.mod.intRef(Type.usize, 0);
Expand Down
9 changes: 0 additions & 9 deletions test/cases/compile_errors/setAlignStack_outside_function.zig

This file was deleted.

0 comments on commit 8afbb8e

Please sign in to comment.