diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-07-28 15:00:40 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-01 23:37:01 +0300 |
| commit | 57f9405a8fcaec6043d680fa47ae0e98709160c2 (patch) | |
| tree | 40614ac1850186954c45c91f169d60a4df2bdb2b /test/cases/compile_errors | |
| parent | e7b6a1833106a5d808e4e82a2d61abf417aff407 (diff) | |
| download | zig-57f9405a8fcaec6043d680fa47ae0e98709160c2.tar.gz zig-57f9405a8fcaec6043d680fa47ae0e98709160c2.zip | |
Sema: validate bitcast operand type
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/bitCast_to_enum_type.zig | 2 | ||||
| -rw-r--r-- | test/cases/compile_errors/intToPtr_with_misaligned_address.zig | 10 | ||||
| -rw-r--r-- | test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig (renamed from test/cases/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig) | 8 | ||||
| -rw-r--r-- | test/cases/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig | 10 |
4 files changed, 16 insertions, 14 deletions
diff --git a/test/cases/compile_errors/bitCast_to_enum_type.zig b/test/cases/compile_errors/bitCast_to_enum_type.zig index add531627f..a8fedb7d54 100644 --- a/test/cases/compile_errors/bitCast_to_enum_type.zig +++ b/test/cases/compile_errors/bitCast_to_enum_type.zig @@ -9,4 +9,4 @@ export fn entry() void { // target=native // // :3:24: error: cannot @bitCast to 'tmp.entry.E' -// :3:24: note: use @intToEnum for type coercion +// :3:24: note: use @intToEnum to cast from 'u32' diff --git a/test/cases/compile_errors/intToPtr_with_misaligned_address.zig b/test/cases/compile_errors/intToPtr_with_misaligned_address.zig new file mode 100644 index 0000000000..43f89ab3b5 --- /dev/null +++ b/test/cases/compile_errors/intToPtr_with_misaligned_address.zig @@ -0,0 +1,10 @@ +pub export fn entry() void { + var y = @intToPtr([*]align(4) u8, 5); + _ = y; +} + +// error +// backend=stage2 +// target=native +// +// :2:39: error: pointer type '[*]align(4) u8' requires aligned address diff --git a/test/cases/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig index cdc1def677..874f015ffb 100644 --- a/test/cases/compile_errors/stage1/obj/issue_3818_bitcast_from_parray-slice_to_u16.zig +++ b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig @@ -10,8 +10,10 @@ export fn foo2() void { } // error -// backend=stage1 +// backend=stage2 // target=native // -// tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8' -// tmp.zig:8:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16 +// :3:42: error: cannot @bitCast from '*[2]u8' +// :3:42: note: use @ptrToInt to cast to 'u16' +// :8:37: error: cannot @bitCast from '[]const u8' +// :8:37: note: use @ptrToInt to cast to 'u16' diff --git a/test/cases/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig b/test/cases/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig deleted file mode 100644 index 16b6bf565e..0000000000 --- a/test/cases/compile_errors/stage1/obj/intToPtr_with_misaligned_address.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - var y = @intToPtr([*]align(4) u8, 5); - _ = y; -} - -// error -// backend=stage1 -// target=native -// -// tmp.zig:2:13: error: pointer type '[*]align(4) u8' requires aligned address |
