aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrea Orru <andrea@orru.io>2018-03-13 22:07:40 -0700
committerAndrea Orru <andrea@orru.io>2018-03-13 22:07:40 -0700
commitc828c23f71055fc4614ada20a20fb1c7bfee50c6 (patch)
tree2c601b10869b3ea4ee287a44ae5bf37b08445569 /test/compile_errors.zig
parent7ac44037db686b93de25b6d826f596985d79ea42 (diff)
downloadzig-c828c23f71055fc4614ada20a20fb1c7bfee50c6.tar.gz
zig-c828c23f71055fc4614ada20a20fb1c7bfee50c6.zip
Tests for zero-bit field compiler error
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 564ad5d521..027e000953 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3141,4 +3141,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
\\}
,
".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value");
+
+ cases.add("taking offset of void field in struct",
+ \\const Empty = struct {
+ \\ val: void,
+ \\};
+ \\export fn foo() void {
+ \\ const fieldOffset = @offsetOf(Empty, "val");
+ \\}
+ ,
+ ".tmp_source.zig:5:42: error: zero-bit field 'val' has no offset in struct 'Empty'");
}