diff options
| author | Dan Robertson <dan@dlrobertson.com> | 2019-02-05 15:52:54 +0000 |
|---|---|---|
| committer | Dan Robertson <dan@dlrobertson.com> | 2019-02-05 21:20:07 +0000 |
| commit | 80c052bed76d7b7406e956747012bc8a929fe909 (patch) | |
| tree | 77a17b1ae61363f1c0191da16bee3d4324b2956c /src/test | |
| parent | b2c6b8c29f13f8d1f242da89e587960b95337819 (diff) | |
| download | rust-80c052bed76d7b7406e956747012bc8a929fe909.tar.gz rust-80c052bed76d7b7406e956747012bc8a929fe909.zip | |
Do not ICE in codegen given a extern_type static
The layout of a extern_type static is unsized, but may pass the Well-Formed check in typeck. As a result, we cannot assume that a static is sized when generating the `Place` for an r-value.
Diffstat (limited to 'src/test')
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 00000000000..5879fc0ce77 --- /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 00000000000..39be5acfa11 --- /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 00000000000..932b5b5944b --- /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); + } +} |
