aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/switch_loop.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2025-07-22 04:50:34 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2025-07-22 14:50:22 -0400
commit687370237fdd80bf0693679cbc11598f14151f0a (patch)
treea050ac34480f02c83e97e43409c2f2b608d384f5 /test/behavior/switch_loop.zig
parentf34b4780b7bd52d14df253d0762d9c73db8eb226 (diff)
downloadzig-687370237fdd80bf0693679cbc11598f14151f0a.tar.gz
zig-687370237fdd80bf0693679cbc11598f14151f0a.zip
llvm: fix switch loop on larger than pointer integer
Diffstat (limited to 'test/behavior/switch_loop.zig')
-rw-r--r--test/behavior/switch_loop.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/behavior/switch_loop.zig b/test/behavior/switch_loop.zig
index 98605692be..35cc857b62 100644
--- a/test/behavior/switch_loop.zig
+++ b/test/behavior/switch_loop.zig
@@ -226,3 +226,28 @@ test "unanalyzed continue with operand" {
true => {},
}
}
+
+test "switch loop on larger than pointer integer" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
+
+ var entry: @Type(.{ .int = .{
+ .signedness = .unsigned,
+ .bits = @bitSizeOf(usize) + 1,
+ } }) = undefined;
+ entry = 0;
+ loop: switch (entry) {
+ 0 => {
+ entry += 1;
+ continue :loop 1;
+ },
+ 1 => |x| {
+ entry += 1;
+ continue :loop x + 1;
+ },
+ 2 => entry += 1,
+ else => unreachable,
+ }
+ try expect(entry == 3);
+}