about summary refs log tree commit diff
path: root/tests/codegen-llvm/sanitizer/sanitize-off.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen-llvm/sanitizer/sanitize-off.rs')
-rw-r--r--tests/codegen-llvm/sanitizer/sanitize-off.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/codegen-llvm/sanitizer/sanitize-off.rs b/tests/codegen-llvm/sanitizer/sanitize-off.rs
index 0b0c01ed962..9f3f7cd9df7 100644
--- a/tests/codegen-llvm/sanitizer/sanitize-off.rs
+++ b/tests/codegen-llvm/sanitizer/sanitize-off.rs
@@ -116,3 +116,23 @@ pub fn expose_trait(b: &mut u8) -> u8 {
     <() as MyTrait>::unsanitized_default(&(), b);
     <() as MyTrait>::sanitized_default(&(), b)
 }
+
+#[sanitize(address = "off")]
+pub mod outer {
+    #[sanitize(thread = "off")]
+    pub mod inner {
+        // CHECK-LABEL: ; sanitize_off::outer::inner::unsanitized
+        // CHECK-NEXT:  ; Function Attrs:
+        // CHECK-NOT:   sanitize_address
+        // CHECK:       start:
+        // CHECK-NOT:   call void @__asan_report_load
+        // CHECK:       }
+        pub fn unsanitized() {
+            let xs = [0, 1, 2, 3];
+            // Avoid optimizing everything out.
+            let xs = std::hint::black_box(xs.as_ptr());
+            let code = unsafe { *xs.offset(4) };
+            std::process::exit(code);
+        }
+    }
+}