diff --git a/test/behavior/align.zig b/test/behavior/align.zig index b971c78596..2cbde2d56c 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -307,11 +307,15 @@ test "runtime-known array index has best alignment possible" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; // take full advantage of over-alignment - var array align(4) = [_]u8{ 1, 2, 3, 4 }; + var array align(4) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; comptime assert(@TypeOf(&array[0]) == *align(4) u8); - comptime assert(@TypeOf(&array[1]) == *u8); + comptime assert(@TypeOf(&array[1]) == *align(1) u8); comptime assert(@TypeOf(&array[2]) == *align(2) u8); - comptime assert(@TypeOf(&array[3]) == *u8); + comptime assert(@TypeOf(&array[3]) == *align(1) u8); + comptime assert(@TypeOf(&array[4]) == *align(4) u8); + comptime assert(@TypeOf(&array[5]) == *align(1) u8); + comptime assert(@TypeOf(&array[6]) == *align(2) u8); + comptime assert(@TypeOf(&array[7]) == *align(1) u8); // because align is too small but we still figure out to use 2 var bigger align(2) = [_]u64{ 1, 2, 3, 4 }; @@ -332,10 +336,14 @@ test "runtime-known array index has best alignment possible" { try testIndex(smaller[runtime_zero..].ptr, 3, *align(2) u32); // has to use ABI alignment because index known at runtime only - try testIndex2(&array, 0, *u8); - try testIndex2(&array, 1, *u8); - try testIndex2(&array, 2, *u8); - try testIndex2(&array, 3, *u8); + try testIndex2(&array, 0, *align(1) u8); + try testIndex2(&array, 1, *align(1) u8); + try testIndex2(&array, 2, *align(1) u8); + try testIndex2(&array, 3, *align(1) u8); + try testIndex2(&array, 4, *align(1) u8); + try testIndex2(&array, 5, *align(1) u8); + try testIndex2(&array, 6, *align(1) u8); + try testIndex2(&array, 7, *align(1) u8); } fn testIndex(smaller: [*]align(2) u32, index: usize, comptime T: type) !void { comptime assert(@TypeOf(&smaller[index]) == T); diff --git a/test/behavior/bitcast.zig b/test/behavior/bitcast.zig index 90d185c63f..910356e360 100644 --- a/test/behavior/bitcast.zig +++ b/test/behavior/bitcast.zig @@ -350,9 +350,6 @@ test "comptime @bitCast packed struct to int and back" { iint_neg2: i3 = -2, float: f32 = 3.14, @"enum": enum(u2) { A, B = 1, C, D } = .B, - vectorb: @Vector(3, bool) = .{ true, false, true }, - vectori: @Vector(2, u8) = .{ 127, 42 }, - vectorf: @Vector(2, f16) = .{ 3.14, 2.71 }, }; const Int = @typeInfo(S).@"struct".backing_integer.?; diff --git a/test/behavior/call.zig b/test/behavior/call.zig index 3433cc5971..fd13449943 100644 --- a/test/behavior/call.zig +++ b/test/behavior/call.zig @@ -551,19 +551,18 @@ test "generic function pointer can be called" { test "value returned from comptime function is comptime known" { const S = struct { - fn fields(comptime T: type) switch (@typeInfo(T)) { - .@"struct" => []const std.builtin.Type.StructField, + fn fieldCount(comptime T: type) switch (@typeInfo(T)) { + .@"struct" => comptime_int, else => unreachable, } { return switch (@typeInfo(T)) { - .@"struct" => |info| info.fields, + .@"struct" => |info| info.fields.len, else => unreachable, }; } }; - const fields_list = S.fields(@TypeOf(.{})); - if (fields_list.len != 0) - @compileError("Argument count mismatch"); + const fields_len = S.fieldCount(@TypeOf(.{})); + comptime assert(fields_len == 0); } test "registers get overwritten when ignoring return" { diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig index 9e3cd732f0..03550fef70 100644 --- a/test/behavior/eval.zig +++ b/test/behavior/eval.zig @@ -719,13 +719,6 @@ fn testVarInsideInlineLoop(args: anytype) !void { } } -test "*align(1) u16 is the same as *align(1:0:2) u16" { - comptime { - try expect(*align(1:0:2) u16 == *align(1) u16); - try expect(*align(2:0:2) u16 == *u16); - } -} - test "array concatenation of function calls" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig index 1b019acb72..d5b01f7c12 100644 --- a/test/behavior/packed-struct.zig +++ b/test/behavior/packed-struct.zig @@ -820,7 +820,7 @@ test "packed struct passed to callconv(.c) function" { if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; const S = struct { - const Packed = packed struct { + const Packed = packed struct(u64) { a: u16, b: bool = true, c: bool = true, diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 316421ea36..784305bca7 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -645,7 +645,7 @@ test "switch prong pointer capture alignment" { } switch (u) { - .a, .c => |*p| comptime assert(@TypeOf(p) == *const u8), + .a, .c => |*p| comptime assert(@TypeOf(p) == *align(1) const u8), .b => |*p| { _ = p; return error.TestFailed; @@ -1141,24 +1141,23 @@ test "decl literals as switch cases" { try comptime E.doTheTest(.foo); } -// TODO audit after #15909 and/or #19855 are decided/implemented +// TODO audit after #15909 and/or #19855 are decided/implemented. +// When we do that, consider adding an 'error{}' case if possible. test "switch with uninstantiable union fields" { const U = union(enum) { ok: void, a: noreturn, b: noreturn, - c: error{}, fn doTheTest(u: @This()) void { switch (u) { .ok => {}, .a => comptime unreachable, .b => comptime unreachable, - .c => comptime unreachable, } switch (u) { .ok => {}, - .a, .b, .c => comptime unreachable, + .a, .b => comptime unreachable, } switch (u) { .ok => {}, @@ -1166,7 +1165,7 @@ test "switch with uninstantiable union fields" { } switch (u) { .a => comptime unreachable, - .ok, .b, .c => {}, + .ok, .b => {}, } } };