@@ -13713,7 +13713,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
13713
13713
.@"volatile" = inst_data.is_volatile,
13714
13714
.size = inst_data.size,
13715
13715
});
13716
- try sema.validatePtrTy(block, elem_ty_src, ty, inst_data.is_allowzero );
13716
+ try sema.validatePtrTy(block, elem_ty_src, ty);
13717
13717
return sema.addType(ty);
13718
13718
}
13719
13719
@@ -13799,11 +13799,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
13799
13799
.@"volatile" = inst_data.flags.is_volatile,
13800
13800
.size = inst_data.size,
13801
13801
});
13802
- try sema.validatePtrTy(block, elem_ty_src, ty, inst_data.flags.is_allowzero );
13802
+ try sema.validatePtrTy(block, elem_ty_src, ty);
13803
13803
return sema.addType(ty);
13804
13804
}
13805
13805
13806
- fn validatePtrTy(sema: *Sema, block: *Block, elem_src: LazySrcLoc, ty: Type, explicit_allowzer: bool ) CompileError!void {
13806
+ fn validatePtrTy(sema: *Sema, block: *Block, elem_src: LazySrcLoc, ty: Type) CompileError!void {
13807
13807
const ptr_info = ty.ptrInfo().data;
13808
13808
const pointee_tag = ptr_info.pointee_type.zigTypeTag();
13809
13809
if (pointee_tag == .NoReturn) {
@@ -13814,8 +13814,6 @@ fn validatePtrTy(sema: *Sema, block: *Block, elem_src: LazySrcLoc, ty: Type, exp
13814
13814
// TODO check extern type
13815
13815
if (pointee_tag == .Opaque) {
13816
13816
return sema.fail(block, elem_src, "C pointers cannot point to opaque types", .{});
13817
- } else if (explicit_allowzer) {
13818
- return sema.fail(block, elem_src, "C pointers always allow address zero", .{});
13819
13817
}
13820
13818
}
13821
13819
}
0 commit comments