diff options
| author | raulgrell <raulgrell@gmail.com> | 2018-09-07 22:43:01 +0100 |
|---|---|---|
| committer | raulgrell <raulgrell@gmail.com> | 2018-09-07 22:49:19 +0100 |
| commit | 09a1162af57858a9579ef112b75472f82581e1d3 (patch) | |
| tree | 7d955ccaf912924421807ff84ea24e0e90020da6 /test/compile_errors.zig | |
| parent | b18af37c578b118a245c911508d73ed23c303ee0 (diff) | |
| download | zig-09a1162af57858a9579ef112b75472f82581e1d3.tar.gz zig-09a1162af57858a9579ef112b75472f82581e1d3.zip | |
builtin functions: @byteOffsetOf and @bitOffsetOf
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 185ca62973..3f4dea776b 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3706,22 +3706,22 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ); cases.add( - "@offsetOf - non struct", + "@byteOffsetOf - non struct", \\const Foo = i32; \\export fn foo() usize { - \\ return @offsetOf(Foo, "a",); + \\ return @byteOffsetOf(Foo, "a",); \\} , ".tmp_source.zig:3:22: error: expected struct type, found 'i32'", ); cases.add( - "@offsetOf - bad field name", + "@byteOffsetOf - bad field name", \\const Foo = struct { \\ derp: i32, \\}; \\export fn foo() usize { - \\ return @offsetOf(Foo, "a",); + \\ return @byteOffsetOf(Foo, "a",); \\} , ".tmp_source.zig:5:27: error: struct 'Foo' has no field 'a'", @@ -5029,12 +5029,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ); cases.add( - "taking offset of void field in struct", + "taking byte offset of void field in struct", \\const Empty = struct { \\ val: void, \\}; \\export fn foo() void { - \\ const fieldOffset = @offsetOf(Empty, "val",); + \\ const fieldOffset = @byteOffsetOf(Empty, "val",); + \\} + , + ".tmp_source.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset", + ); + + cases.add( + "taking bit offset of void field in struct", + \\const Empty = struct { + \\ val: void, + \\}; + \\export fn foo() void { + \\ const fieldOffset = @bitOffsetOf(Empty, "val",); \\} , ".tmp_source.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset", |
