Skip to content

Commit 65c9c49

Browse files
committed
Add C rules for builtin mul overflow
In C++, builtin mul overflow is a variadic function: `bool (...)`. In C is an unprototyped function: `int ()`.
1 parent 52a6c16 commit 65c9c49

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

rules/builtin/tgt_refcount.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ fn f10(a0: i64, a1: i64, a2: Ptr<i64>) -> bool {
1313
a2.write(val);
1414
ovf
1515
}
16+
fn f12(a0: i64, a1: i64, a2: Ptr<i64>) -> bool {
17+
let (val, ovf) = a0.overflowing_mul(a1);
18+
a2.write(val);
19+
ovf
20+
}
21+
fn f13(a0: i64, a1: i64, a2: Ptr<i64>) -> bool {
22+
let (val, ovf) = a0.overflowing_mul(a1);
23+
a2.write(val);
24+
ovf
25+
}

rules/builtin/tgt_unsafe.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,14 @@ unsafe fn f10(a0: i64, a1: i64, a2: *mut i64) -> bool {
3838
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
3939
unsafe fn f11() {
4040
std::hint::spin_loop();
41+
42+
unsafe fn f12(a0: i64, a1: i64, a2: *mut i64) -> bool {
43+
let (val, ovf) = a0.overflowing_mul(a1);
44+
*a2 = val;
45+
ovf
46+
}
47+
unsafe fn f13(a0: i64, a1: i64, a2: *mut i64) -> bool {
48+
let (val, ovf) = a0.overflowing_mul(a1);
49+
*a2 = val;
50+
ovf
4151
}

0 commit comments

Comments
 (0)