authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-20 10:57:41-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-20 10:57:41-04:00
log599215cee46b83d052f57a3e6566098900332e38
tree57e57b3864bd8ad3e67c3fe6b85f0a8bf5df3e04
parent68f75a3130d09e1cd86caa1252ff3c4f517a452b

add compile error tests for offsetOf builtin


1 files changed, 16 insertions(+), 0 deletions(-)

test/compile_errors.zig+16
......@@ -1565,6 +1565,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
15651565 \\}
15661566 , ".tmp_source.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'");
15671567
1568 cases.add("@offsetOf - non struct",
1569 \\const Foo = i32;
1570 \\export fn foo() -> usize {
1571 \\ return @offsetOf(Foo, "a");
1572 \\}
1573 , ".tmp_source.zig:3:22: error: expected struct type, found 'i32'");
1574
1575 cases.add("@offsetOf - bad field name",
1576 \\const Foo = struct {
1577 \\ derp: i32,
1578 \\};
1579 \\export fn foo() -> usize {
1580 \\ return @offsetOf(Foo, "a");
1581 \\}
1582 , ".tmp_source.zig:5:27: error: struct 'Foo' has no field 'a'");
1583
15681584 cases.addExe("missing main fn in executable",
15691585 \\
15701586 , "error: no member named 'main' in '");