File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -444,3 +444,51 @@ fn mul_u64(x u64, y u64) u64 {
444444 }
445445 return res
446446}
447+
448+ // ///////////////////////////////////////////////////////////////////////////////////////////
449+ // These are here to prevent cgen errors for `./v -check-overflow vlib/math/vec/vec4_test.v`
450+ // TODO: check for correctness and add tests. Improve markused so it keeps them, when they are used.
451+ @[inline; markused]
452+ fn add_int (x int , y int ) int {
453+ return add_i32 (x, y)
454+ }
455+
456+ @[inline; markused]
457+ fn sub_int (x int , y int ) int {
458+ return sub_i32 (x, y)
459+ }
460+
461+ @[inline; markused]
462+ fn mul_int (x int , y int ) int {
463+ return mul_i32 (x, y)
464+ }
465+
466+ @[inline; markused]
467+ fn add_f32 (x f32 , y f32 ) f32 {
468+ return x + y
469+ }
470+
471+ @[inline; markused]
472+ fn sub_f32 (x f32 , y f32 ) f32 {
473+ return x - y
474+ }
475+
476+ @[inline; markused]
477+ fn mul_f32 (x f32 , y f32 ) f32 {
478+ return x * y
479+ }
480+
481+ @[inline; markused]
482+ fn add_f64 (x f64 , y f64 ) f64 {
483+ return x + y
484+ }
485+
486+ @[inline; markused]
487+ fn sub_f64 (x f64 , y f64 ) f64 {
488+ return x - y
489+ }
490+
491+ @[inline; markused]
492+ fn mul_f64 (x f64 , y f64 ) f64 {
493+ return x * y
494+ }
Original file line number Diff line number Diff line change @@ -1256,12 +1256,10 @@ fn (mut g Gen) gen_plain_infix_expr(node ast.InfixExpr) {
12561256 }
12571257 // do not use promoted_type for overflow detect
12581258 left_type := g.unwrap_generic (node.left_type)
1259- is_safe_add := node.op == .plus && g.pref.is_check_overflow && left_type.is_int ()
1260- && ! g.is_builtin_overflow_mod
1261- is_safe_sub := node.op == .minus && g.pref.is_check_overflow && left_type.is_int ()
1262- && ! g.is_builtin_overflow_mod
1263- is_safe_mul := node.op == .mul && g.pref.is_check_overflow && left_type.is_int ()
1264- && ! g.is_builtin_overflow_mod
1259+ checkoverflow_op := g.pref.is_check_overflow && ! g.is_builtin_overflow_mod && left_type.is_int ()
1260+ is_safe_add := checkoverflow_op && node.op == .plus
1261+ is_safe_sub := checkoverflow_op && node.op == .minus
1262+ is_safe_mul := checkoverflow_op && node.op == .mul
12651263 is_safe_div := node.op == .div && g.pref.div_by_zero_is_zero && typ.is_int ()
12661264 is_safe_mod := node.op == .mod && g.pref.div_by_zero_is_zero && typ.is_int ()
12671265 if node.left_type.is_ptr () && node.left.is_auto_deref_var () && ! node.right_type.is_pointer () {
You can’t perform that action at this time.
0 commit comments