about summary refs log tree commit diff
path: root/src/test/codegen/ffi-const.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2020-04-14 00:21:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2020-05-20 01:16:11 +0200
commita7d7f0bbe962811d2e5207762aa92c2059c33d1a (patch)
tree6756d577c66c6b68d4a674eccced564bb31b8b7b /src/test/codegen/ffi-const.rs
parentabc236414b4bd609513899e651c41f314f71bac4 (diff)
downloadrust-a7d7f0bbe962811d2e5207762aa92c2059c33d1a.tar.gz
rust-a7d7f0bbe962811d2e5207762aa92c2059c33d1a.zip
Add tests for `#[ffi_const]` and `#[ffi_pure]` function attributes
Based on the work of gnzlbg <gonzalobg88@gmail.com>.
Diffstat (limited to 'src/test/codegen/ffi-const.rs')
-rw-r--r--src/test/codegen/ffi-const.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/codegen/ffi-const.rs b/src/test/codegen/ffi-const.rs
new file mode 100644
index 00000000000..440d022a12c
--- /dev/null
+++ b/src/test/codegen/ffi-const.rs
@@ -0,0 +1,12 @@
+// compile-flags: -C no-prepopulate-passes
+#![crate_type = "lib"]
+#![feature(ffi_const)]
+
+pub fn bar() { unsafe { foo() } }
+
+extern {
+    // CHECK-LABEL: declare void @foo()
+    // CHECK-SAME: [[ATTRS:#[0-9]+]]
+    // CHECK-DAG: attributes [[ATTRS]] = { {{.*}}readnone{{.*}} }
+    #[ffi_const] pub fn foo();
+}