aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-03 23:12:18 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 23:12:18 -0700
commit63c5c510b1a083fbbca4145b1b53d39da9b0fd81 (patch)
treefc00c36767b6c15a444ec5c57f69778517ac740b /test/behavior
parent26be5bb8b1e1c05ceab4b7620efa2a058a174886 (diff)
downloadzig-63c5c510b1a083fbbca4145b1b53d39da9b0fd81.tar.gz
zig-63c5c510b1a083fbbca4145b1b53d39da9b0fd81.zip
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.
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/pointers.zig20
1 files changed, 4 insertions, 16 deletions
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);