about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Maurer <mmaurer@google.com>2024-04-04 22:06:58 +0000
committerMatthew Maurer <mmaurer@google.com>2024-04-04 22:06:58 +0000
commitb53a0f2c9e96778a044cb72472aa898f9804471d (patch)
treeecdabf566a8e36a44f8644ca0dc4c606d5236f6a
parenta4b11c8e6057bd47f8d241baafd5ae1e813d62fd (diff)
downloadrust-b53a0f2c9e96778a044cb72472aa898f9804471d.tar.gz
rust-b53a0f2c9e96778a044cb72472aa898f9804471d.zip
CFI: Add test for `call_once` addr taken
One of the proposed ways to reduce the non-passed argument erasure would
cause this test to fail. Adding this now ensures that any attempt to
reduce non-passed argument erasure won't make the same mistake.
-rw-r--r--tests/ui/sanitizer/cfi-closures.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/sanitizer/cfi-closures.rs b/tests/ui/sanitizer/cfi-closures.rs
index f3d9be35716..9f9002da674 100644
--- a/tests/ui/sanitizer/cfi-closures.rs
+++ b/tests/ui/sanitizer/cfi-closures.rs
@@ -77,3 +77,14 @@ fn closure_addr_taken() {
     let call = Fn::<()>::call;
     use_closure(call, &f);
 }
+
+fn use_closure_once<C>(call: extern "rust-call" fn(C, ()) -> i32, f: C) -> i32 {
+    call(f, ())
+}
+
+#[test]
+fn closure_once_addr_taken() {
+    let g = || 3;
+    let call2 = FnOnce::<()>::call_once;
+    use_closure_once(call2, g);
+}