mirror of
https://github.com/ziglang/zig.git
synced 2026-01-03 03:53:20 +00:00
Sema: fix type check in zirIntToPtr
Simple fix: don't assume a ptr type before it has been checked. Closes #13567
This commit is contained in:
parent
7b131a7cd4
commit
bc76873827
@ -18778,8 +18778,8 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
|
||||
const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
|
||||
const ptr_ty = try sema.resolveType(block, src, extra.lhs);
|
||||
const elem_ty = ptr_ty.elemType2();
|
||||
try sema.checkPtrType(block, type_src, ptr_ty);
|
||||
const elem_ty = ptr_ty.elemType2();
|
||||
const target = sema.mod.getTarget();
|
||||
const ptr_align = try ptr_ty.ptrAlignmentAdvanced(target, sema);
|
||||
|
||||
|
||||
9
test/cases/compile_errors/inttoptr_non_ptr_type.zig
Normal file
9
test/cases/compile_errors/inttoptr_non_ptr_type.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub export fn entry() void {
|
||||
_ = @intToPtr(i32, 10);
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:19: error: expected pointer type, found 'i32'
|
||||
Loading…
x
Reference in New Issue
Block a user