From 63c5c510b1a083fbbca4145b1b53d39da9b0fd81 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 3 Mar 2022 23:12:18 -0700 Subject: Sema: rework peer type logic for pointers Now it's centered around a switch on the chosen type tag which gives us easy access to pointer data. The logic is simplied and in some cases logic is removed when it is sufficient to choose the type that is a better coercion target without knowing whether such coercion will succeed ahead of time. A bug is fixed at the bottom of the function; we were doing the opposite of what we were supposed to with `seen_const`. Also the bottom of the function has a more complete handling of the possible combinations of `any_are_null`, `convert_to_slice`, and `err_set_ty`. In the behavior tests, not as many backends needed to be skipped. --- test/behavior/pointers.zig | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'test/behavior/pointers.zig') diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig index 288be7f77e..dc46eeeca8 100644 --- a/test/behavior/pointers.zig +++ b/test/behavior/pointers.zig @@ -128,12 +128,6 @@ fn testDerefPtrOneVal() !void { } test "peer type resolution with C pointers" { - if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; - var ptr_one: *u8 = undefined; var ptr_many: [*]u8 = undefined; var ptr_c: [*c]u8 = undefined; @@ -163,11 +157,11 @@ test "implicit casting between C pointer and optional non-C pointer" { } test "implicit cast error unions with non-optional to optional pointer" { - if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { @@ -384,12 +378,6 @@ test "pointer arithmetic affects the alignment" { } test "@ptrToInt on null optional at comptime" { - if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; - { const pointer = @intToPtr(?*u8, 0x000); const x = @ptrToInt(pointer); -- cgit v1.2.3