aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-14 13:07:51 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-14 13:07:51 -0500
commit52c03de5c2495b369ae730ff203e5342e4f33a36 (patch)
tree6e9431418a20422112836190eaabd42eacd5c84d /test/compile_errors.zig
parente03c770145b5dc7b428d53b3cac97c2733fb84d8 (diff)
downloadzig-52c03de5c2495b369ae730ff203e5342e4f33a36.tar.gz
zig-52c03de5c2495b369ae730ff203e5342e4f33a36.zip
add missing compile error for OpaqueType inside structs/unions
closes #1862
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 630386aa4f..ac8d413d2c 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,27 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest(
+ "directly embedding opaque type in struct and union",
+ \\const O = @OpaqueType();
+ \\const Foo = struct {
+ \\ o: O,
+ \\};
+ \\const Bar = union {
+ \\ One: i32,
+ \\ Two: O,
+ \\};
+ \\export fn a() void {
+ \\ var foo: Foo = undefined;
+ \\}
+ \\export fn b() void {
+ \\ var bar: Bar = undefined;
+ \\}
+ ,
+ ".tmp_source.zig:3:8: error: opaque types have unknown size and therefore cannot be directly embedded in structs",
+ ".tmp_source.zig:7:10: error: opaque types have unknown size and therefore cannot be directly embedded in unions",
+ );
+
+ cases.addTest(
"implicit cast between C pointer and Zig pointer - bad const/align/child",
\\export fn a() void {
\\ var x: [*c]u8 = undefined;