aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-07-11 13:23:37 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-07-11 14:08:56 -0400
commit3f30897fdcdb6c5579bc5609dda9746f67551870 (patch)
tree6f3eb8ce8761b6a5cf8ab7d5e8a4694664c6dca0 /test/compile_errors.zig
parent3aaf814b9df6eecb6be025c4c73b8e9c46a112ba (diff)
downloadzig-3f30897fdcdb6c5579bc5609dda9746f67551870.tar.gz
zig-3f30897fdcdb6c5579bc5609dda9746f67551870.zip
add compile error for disallowed types in extern structs
closes #1218
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index a6db8d50b4..58c73b8ae4 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,33 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "optional pointer to void in extern struct",
+ \\const Foo = extern struct {
+ \\ x: ?*const void,
+ \\};
+ \\const Bar = extern struct {
+ \\ foo: Foo,
+ \\ y: i32,
+ \\};
+ \\export fn entry(bar: *Bar) void {}
+ ,
+ ".tmp_source.zig:2:5: error: extern structs cannot contain fields of type '?*const void'",
+ );
+
+ cases.add(
+ "use of comptime-known undefined function value",
+ \\const Cmd = struct {
+ \\ exec: fn () void,
+ \\};
+ \\export fn entry() void {
+ \\ const command = Cmd{ .exec = undefined };
+ \\ command.exec();
+ \\}
+ ,
+ ".tmp_source.zig:6:12: error: use of undefined value",
+ );
+
+ cases.add(
"use of comptime-known undefined function value",
\\const Cmd = struct {
\\ exec: fn () void,