diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-21 13:10:21 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-21 13:10:21 -0400 |
| commit | 5a21d3dce0c020833bfe426049e2391ae3977846 (patch) | |
| tree | d1f5c329609672edbc26cb892649cc1f3d36fc51 /test/compile_errors.zig | |
| parent | 44f2ee101f244342ec7e4cd81bb21d9a0c23267b (diff) | |
| parent | f2186e5fa753ef84003fcc21cd60692e009a8941 (diff) | |
| download | zig-5a21d3dce0c020833bfe426049e2391ae3977846.tar.gz zig-5a21d3dce0c020833bfe426049e2391ae3977846.zip | |
Merge branch 'BitByteOffsetOfs' of https://github.com/raulgrell/zig into raulgrell-BitByteOffsetOfs
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 dfe17e9d82..7b659a8dc1 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3763,22 +3763,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'", @@ -5084,12 +5084,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", |
