| ... | ... | @@ -3626,8 +3626,7 @@ fn zirAllocExtended( |
| 3626 | 3626 | const alignment = if (small.has_align) blk: { |
| 3627 | 3627 | const align_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 3628 | 3628 | extra_index += 1; |
| 3629 | | const alignment = try sema.resolveAlign(block, align_src, align_ref); |
| 3630 | | break :blk alignment; |
| 3629 | break :blk try sema.resolveAlign(block, align_src, align_ref); |
| 3631 | 3630 | } else .none; |
| 3632 | 3631 | |
| 3633 | 3632 | if (block.is_comptime or small.is_comptime) { |
| ... | ... | @@ -3652,6 +3651,10 @@ fn zirAllocExtended( |
| 3652 | 3651 | } |
| 3653 | 3652 | const target = pt.zcu.getTarget(); |
| 3654 | 3653 | try var_ty.resolveLayout(pt); |
| 3654 | if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) { |
| 3655 | const var_src = block.src(.{ .node_offset_store_ptr = extra.data.src_node }); |
| 3656 | return sema.fail(block, var_src, "local variable in naked function", .{}); |
| 3657 | } |
| 3655 | 3658 | const ptr_type = try sema.pt.ptrTypeSema(.{ |
| 3656 | 3659 | .child = var_ty.toIntern(), |
| 3657 | 3660 | .flags = .{ |
| ... | ... | @@ -4087,10 +4090,15 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 4087 | 4090 | |
| 4088 | 4091 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 4089 | 4092 | const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node }); |
| 4093 | |
| 4090 | 4094 | const var_ty = try sema.resolveType(block, ty_src, inst_data.operand); |
| 4091 | 4095 | if (block.is_comptime) { |
| 4092 | 4096 | return sema.analyzeComptimeAlloc(block, var_ty, .none); |
| 4093 | 4097 | } |
| 4098 | if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) { |
| 4099 | const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node }); |
| 4100 | return sema.fail(block, mut_src, "local variable in naked function", .{}); |
| 4101 | } |
| 4094 | 4102 | const target = pt.zcu.getTarget(); |
| 4095 | 4103 | const ptr_type = try pt.ptrTypeSema(.{ |
| 4096 | 4104 | .child = var_ty.toIntern(), |
| ... | ... | @@ -4115,6 +4123,10 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 4115 | 4123 | if (block.is_comptime) { |
| 4116 | 4124 | return sema.analyzeComptimeAlloc(block, var_ty, .none); |
| 4117 | 4125 | } |
| 4126 | if (sema.func_is_naked and try sema.typeHasRuntimeBits(var_ty)) { |
| 4127 | const var_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node }); |
| 4128 | return sema.fail(block, var_src, "local variable in naked function", .{}); |
| 4129 | } |
| 4118 | 4130 | try sema.validateVarType(block, ty_src, var_ty, false); |
| 4119 | 4131 | const target = pt.zcu.getTarget(); |
| 4120 | 4132 | const ptr_type = try pt.ptrTypeSema(.{ |
| ... | ... | @@ -4248,7 +4260,10 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4248 | 4260 | // TODO: source location of runtime control flow |
| 4249 | 4261 | return sema.fail(block, src, "value with comptime-only type '{}' depends on runtime control flow", .{final_elem_ty.fmt(pt)}); |
| 4250 | 4262 | } |
| 4251 | | |
| 4263 | if (sema.func_is_naked and try sema.typeHasRuntimeBits(final_elem_ty)) { |
| 4264 | const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node }); |
| 4265 | return sema.fail(block, mut_src, "local variable in naked function", .{}); |
| 4266 | } |
| 4252 | 4267 | // Change it to a normal alloc. |
| 4253 | 4268 | sema.air_instructions.set(@intFromEnum(ptr_inst), .{ |
| 4254 | 4269 | .tag = .alloc, |