disallow C pointers to non-C-ABI-compatible element types

See #1059
This commit is contained in:
Andrew Kelley
2019-02-12 00:51:06 -05:00
parent 0abe6d668e
commit 285e2f62ba
4 changed files with 16 additions and 2 deletions

View File

@@ -1,6 +1,16 @@
const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest(
"C pointer pointing to non C ABI compatible type",
\\const Foo = struct {};
\\export fn entry() [*c]Foo {
\\ return undefined;
\\}
,
".tmp_source.zig:2:19: error: C pointers cannot point to non-C-ABI-compatible type 'Foo'",
);
cases.addTest(
"@truncate undefined value",
\\export fn entry() void {