Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
b2c6b8c
commit 80c052b
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
11 changes: 11 additions & 0 deletions
11
src/test/run-make-fulldeps/static-extern-type/define-foo.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |