| ... | ... | @@ -12800,7 +12800,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 12800 | 12800 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 12801 | 12801 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 12802 | 12802 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 12803 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .div); |
| 12803 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 12804 | 12804 | |
| 12805 | 12805 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 12806 | 12806 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -12960,7 +12960,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12960 | 12960 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 12961 | 12961 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 12962 | 12962 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 12963 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .div_exact); |
| 12963 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 12964 | 12964 | |
| 12965 | 12965 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 12966 | 12966 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -13123,7 +13123,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13123 | 13123 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 13124 | 13124 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 13125 | 13125 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13126 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .div_floor); |
| 13126 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 13127 | 13127 | |
| 13128 | 13128 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 13129 | 13129 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -13239,7 +13239,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13239 | 13239 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 13240 | 13240 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 13241 | 13241 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13242 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .div_trunc); |
| 13242 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 13243 | 13243 | |
| 13244 | 13244 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 13245 | 13245 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -13482,7 +13482,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13482 | 13482 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 13483 | 13483 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 13484 | 13484 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13485 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .mod_rem); |
| 13485 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 13486 | 13486 | |
| 13487 | 13487 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 13488 | 13488 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -13665,7 +13665,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13665 | 13665 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 13666 | 13666 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 13667 | 13667 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13668 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .mod); |
| 13668 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 13669 | 13669 | |
| 13670 | 13670 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 13671 | 13671 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -13767,7 +13767,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 13767 | 13767 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| 13768 | 13768 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| 13769 | 13769 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| 13770 | | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty, .rem); |
| 13770 | try sema.checkInvalidPtrArithmetic(block, src, lhs_ty); |
| 13771 | 13771 | |
| 13772 | 13772 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 13773 | 13773 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ |
| ... | ... | @@ -14107,12 +14107,7 @@ fn analyzeArithmetic( |
| 14107 | 14107 | const air_tag: Air.Inst.Tag = switch (zir_tag) { |
| 14108 | 14108 | .add => .ptr_add, |
| 14109 | 14109 | .sub => .ptr_sub, |
| 14110 | | else => return sema.fail( |
| 14111 | | block, |
| 14112 | | src, |
| 14113 | | "invalid pointer arithmetic operand: '{s}''", |
| 14114 | | .{@tagName(zir_tag)}, |
| 14115 | | ), |
| 14110 | else => return sema.fail(block, src, "invalid pointer arithmetic operator", .{}), |
| 14116 | 14111 | }; |
| 14117 | 14112 | return sema.analyzePtrArithmetic(block, src, lhs, rhs, air_tag, lhs_src, rhs_src); |
| 14118 | 14113 | }, |
| ... | ... | @@ -20029,7 +20024,6 @@ fn checkInvalidPtrArithmetic( |
| 20029 | 20024 | block: *Block, |
| 20030 | 20025 | src: LazySrcLoc, |
| 20031 | 20026 | ty: Type, |
| 20032 | | zir_tag: Zir.Inst.Tag, |
| 20033 | 20027 | ) CompileError!void { |
| 20034 | 20028 | switch (try ty.zigTypeTagOrPoison()) { |
| 20035 | 20029 | .Pointer => switch (ty.ptrSize()) { |
| ... | ... | @@ -20037,8 +20031,8 @@ fn checkInvalidPtrArithmetic( |
| 20037 | 20031 | .Many, .C => return sema.fail( |
| 20038 | 20032 | block, |
| 20039 | 20033 | src, |
| 20040 | | "invalid pointer arithmetic operand: '{s}''", |
| 20041 | | .{@tagName(zir_tag)}, |
| 20034 | "invalid pointer arithmetic operator", |
| 20035 | .{}, |
| 20042 | 20036 | ), |
| 20043 | 20037 | }, |
| 20044 | 20038 | else => return, |