summaryrefslogtreecommitdiffstats
path: root/tests/run-make/static-extern-type
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/static-extern-type')
-rw-r--r--tests/run-make/static-extern-type/Makefile6
-rw-r--r--tests/run-make/static-extern-type/define-foo.c11
-rw-r--r--tests/run-make/static-extern-type/use-foo.rs14
3 files changed, 31 insertions, 0 deletions
diff --git a/tests/run-make/static-extern-type/Makefile b/tests/run-make/static-extern-type/Makefile
new file mode 100644
index 000000000..778971543
--- /dev/null
+++ b/tests/run-make/static-extern-type/Makefile
@@ -0,0 +1,6 @@
+# ignore-cross-compile
+include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,define-foo)
+ $(RUSTC) -ldefine-foo use-foo.rs
+ $(call RUN,use-foo) || exit 1
diff --git a/tests/run-make/static-extern-type/define-foo.c b/tests/run-make/static-extern-type/define-foo.c
new file mode 100644
index 000000000..39be5acfa
--- /dev/null
+++ b/tests/run-make/static-extern-type/define-foo.c
@@ -0,0 +1,11 @@
+#include <stdint.h>
+
+struct Foo {
+ uint8_t x;
+};
+
+struct Foo FOO = { 42 };
+
+uint8_t bar(const struct Foo* foo) {
+ return foo->x;
+}
diff --git a/tests/run-make/static-extern-type/use-foo.rs b/tests/run-make/static-extern-type/use-foo.rs
new file mode 100644
index 000000000..932b5b594
--- /dev/null
+++ b/tests/run-make/static-extern-type/use-foo.rs
@@ -0,0 +1,14 @@
+#![feature(extern_types)]
+
+extern "C" {
+ type Foo;
+ static FOO: Foo;
+ fn bar(foo: *const Foo) -> u8;
+}
+
+fn main() {
+ unsafe {
+ let foo = &FOO;
+ assert_eq!(bar(foo), 42);
+ }
+}