diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-03-04 15:39:24 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-05 02:56:24 -0500 |
| commit | e297860158cabb74a261a979f2f17305716c6e10 (patch) | |
| tree | 79408e971315aeaf3b7e5149620e757646d0c49e /test/behavior/pointers.zig | |
| parent | f2a5d0bf94897554e25e889dc1c6c4c7fc6c1217 (diff) | |
| download | zig-e297860158cabb74a261a979f2f17305716c6e10.tar.gz zig-e297860158cabb74a261a979f2f17305716c6e10.zip | |
stage2: test changed behavior of c pointer resolution from stage1
stage1 peer resolves the given test to `[*c]u8` but stage2 makes that a
const u8. I believe stage2 behavior is correct since the pointer itself
is const.
Diffstat (limited to 'test/behavior/pointers.zig')
| -rw-r--r-- | test/behavior/pointers.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig index dc46eeeca8..6fd7e41a6d 100644 --- a/test/behavior/pointers.zig +++ b/test/behavior/pointers.zig @@ -142,6 +142,15 @@ test "peer type resolution with C pointers" { try expect(@TypeOf(x4) == [*c]u8); } +test "peer type resolution with C pointer and const pointer" { + // stage1 incorrectly resolves to [*]u8 + if (builtin.zig_backend == .stage1) return error.SkipZigTest; + + var ptr_c: [*c]u8 = undefined; + const ptr_const: u8 = undefined; + try expect(@TypeOf(ptr_c, &ptr_const) == [*c]const u8); +} + test "implicit casting between C pointer and optional non-C pointer" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
