summaryrefslogtreecommitdiffstats
path: root/src/test/run-make-fulldeps/static-extern-type
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/run-make-fulldeps/static-extern-type
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/run-make-fulldeps/static-extern-type')
-rw-r--r--src/test/run-make-fulldeps/static-extern-type/Makefile5
-rw-r--r--src/test/run-make-fulldeps/static-extern-type/define-foo.c11
-rw-r--r--src/test/run-make-fulldeps/static-extern-type/use-foo.rs14
3 files changed, 30 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/static-extern-type/Makefile b/src/test/run-make-fulldeps/static-extern-type/Makefile
new file mode 100644
index 000000000..5879fc0ce
--- /dev/null
+++ b/src/test/run-make-fulldeps/static-extern-type/Makefile
@@ -0,0 +1,5 @@
+-include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,define-foo)
+ $(RUSTC) -ldefine-foo use-foo.rs
+ $(call RUN,use-foo) || exit 1
diff --git a/src/test/run-make-fulldeps/static-extern-type/define-foo.c b/src/test/run-make-fulldeps/static-extern-type/define-foo.c
new file mode 100644
index 000000000..39be5acfa
--- /dev/null
+++ b/src/test/run-make-fulldeps/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/src/test/run-make-fulldeps/static-extern-type/use-foo.rs b/src/test/run-make-fulldeps/static-extern-type/use-foo.rs
new file mode 100644
index 000000000..932b5b594
--- /dev/null
+++ b/src/test/run-make-fulldeps/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);
+ }
+}