diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-07-20 12:30:11 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-07-21 12:21:30 -0700 |
| commit | 794beafb9c2c687d993a0933be258a2ccdf0be4f (patch) | |
| tree | ca823524f3c46647f8cd79417faa5f471009f420 /test/behavior | |
| parent | 821e4063f9f32f71cce263265fdbacc632bd5af9 (diff) | |
| download | zig-794beafb9c2c687d993a0933be258a2ccdf0be4f.tar.gz zig-794beafb9c2c687d993a0933be258a2ccdf0be4f.zip | |
Sema: validate extern struct field types earlier
`validateExternType` does not require the type to be resolved so we can
check it earlier. Only doing it in `resolveTypeFully` lead to worse or
missing compile errors.
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/align.zig | 4 | ||||
| -rw-r--r-- | test/behavior/bugs/1310.zig | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/test/behavior/align.zig b/test/behavior/align.zig index ad9a6d9616..d09e97c05b 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -299,7 +299,7 @@ test "implicitly decreasing fn alignment" { try testImplicitlyDecreaseFnAlign(alignedBig, 5678); } -fn testImplicitlyDecreaseFnAlign(ptr: *align(1) const fn () i32, answer: i32) !void { +fn testImplicitlyDecreaseFnAlign(ptr: *const fn () align(1) i32, answer: i32) !void { try expect(ptr() == answer); } @@ -325,7 +325,7 @@ test "@alignCast functions" { fn fnExpectsOnly1(ptr: *const fn () align(1) i32) i32 { return fnExpects4(@alignCast(4, ptr)); } -fn fnExpects4(ptr: *align(4) const fn () i32) i32 { +fn fnExpects4(ptr: *const fn () align(4) i32) i32 { return ptr(); } fn simple4() align(4) i32 { diff --git a/test/behavior/bugs/1310.zig b/test/behavior/bugs/1310.zig index 1f19ec20c2..0f574942d3 100644 --- a/test/behavior/bugs/1310.zig +++ b/test/behavior/bugs/1310.zig @@ -4,7 +4,7 @@ const builtin = @import("builtin"); pub const VM = ?[*]const struct_InvocationTable_; pub const struct_InvocationTable_ = extern struct { - GetVM: ?fn (?[*]VM) callconv(.C) c_int, + GetVM: ?*const fn (?[*]VM) callconv(.C) c_int, }; pub const struct_VM_ = extern struct { @@ -23,5 +23,7 @@ fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { } test "fixed" { + if (builtin.zig_backend == .stage1) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; try expect(agent_callback(undefined, undefined) == 11); } |
