| author | |
| committer | |
| log | 09d0b1f87a740e968ef739e75729204ff470c98a |
| tree | cf478594c27665ef2bb9e4e363013d709cb77029 |
| parent | 8d8140349fe2ea3197f8eea71cc120a0e8fa08d8 |
| signature |
They compile now! They don't *pass*, but they *compile*!6 files changed, 26 insertions(+), 30 deletions(-)
test/behavior/align.zig+15-7| ... | ... | @@ -307,11 +307,15 @@ test "runtime-known array index has best alignment possible" { |
| 307 | 307 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 308 | 308 | |
| 309 | 309 | // take full advantage of over-alignment |
| 310 | var array align(4) = [_]u8{ 1, 2, 3, 4 }; | |
| 310 | var array align(4) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; | |
| 311 | 311 | comptime assert(@TypeOf(&array[0]) == *align(4) u8); |
| 312 | comptime assert(@TypeOf(&array[1]) == *u8); | |
| 312 | comptime assert(@TypeOf(&array[1]) == *align(1) u8); | |
| 313 | 313 | comptime assert(@TypeOf(&array[2]) == *align(2) u8); |
| 314 | comptime assert(@TypeOf(&array[3]) == *u8); | |
| 314 | comptime assert(@TypeOf(&array[3]) == *align(1) u8); | |
| 315 | comptime assert(@TypeOf(&array[4]) == *align(4) u8); | |
| 316 | comptime assert(@TypeOf(&array[5]) == *align(1) u8); | |
| 317 | comptime assert(@TypeOf(&array[6]) == *align(2) u8); | |
| 318 | comptime assert(@TypeOf(&array[7]) == *align(1) u8); | |
| 315 | 319 | |
| 316 | 320 | // because align is too small but we still figure out to use 2 |
| 317 | 321 | var bigger align(2) = [_]u64{ 1, 2, 3, 4 }; |
| ... | ... | @@ -332,10 +336,14 @@ test "runtime-known array index has best alignment possible" { |
| 332 | 336 | try testIndex(smaller[runtime_zero..].ptr, 3, *align(2) u32); |
| 333 | 337 | |
| 334 | 338 | // has to use ABI alignment because index known at runtime only |
| 335 | try testIndex2(&array, 0, *u8); | |
| 336 | try testIndex2(&array, 1, *u8); | |
| 337 | try testIndex2(&array, 2, *u8); | |
| 338 | try testIndex2(&array, 3, *u8); | |
| 339 | try testIndex2(&array, 0, *align(1) u8); | |
| 340 | try testIndex2(&array, 1, *align(1) u8); | |
| 341 | try testIndex2(&array, 2, *align(1) u8); | |
| 342 | try testIndex2(&array, 3, *align(1) u8); | |
| 343 | try testIndex2(&array, 4, *align(1) u8); | |
| 344 | try testIndex2(&array, 5, *align(1) u8); | |
| 345 | try testIndex2(&array, 6, *align(1) u8); | |
| 346 | try testIndex2(&array, 7, *align(1) u8); | |
| 339 | 347 | } |
| 340 | 348 | fn testIndex(smaller: [*]align(2) u32, index: usize, comptime T: type) !void { |
| 341 | 349 | comptime assert(@TypeOf(&smaller[index]) == T); |
test/behavior/bitcast.zig-3| ... | ... | @@ -350,9 +350,6 @@ test "comptime @bitCast packed struct to int and back" { |
| 350 | 350 | iint_neg2: i3 = -2, |
| 351 | 351 | float: f32 = 3.14, |
| 352 | 352 | @"enum": enum(u2) { A, B = 1, C, D } = .B, |
| 353 | vectorb: @Vector(3, bool) = .{ true, false, true }, | |
| 354 | vectori: @Vector(2, u8) = .{ 127, 42 }, | |
| 355 | vectorf: @Vector(2, f16) = .{ 3.14, 2.71 }, | |
| 356 | 353 | }; |
| 357 | 354 | const Int = @typeInfo(S).@"struct".backing_integer.?; |
| 358 | 355 |
test/behavior/call.zig+5-6| ... | ... | @@ -551,19 +551,18 @@ test "generic function pointer can be called" { |
| 551 | 551 | |
| 552 | 552 | test "value returned from comptime function is comptime known" { |
| 553 | 553 | const S = struct { |
| 554 | fn fields(comptime T: type) switch (@typeInfo(T)) { | |
| 555 | .@"struct" => []const std.builtin.Type.StructField, | |
| 554 | fn fieldCount(comptime T: type) switch (@typeInfo(T)) { | |
| 555 | .@"struct" => comptime_int, | |
| 556 | 556 | else => unreachable, |
| 557 | 557 | } { |
| 558 | 558 | return switch (@typeInfo(T)) { |
| 559 | .@"struct" => |info| info.fields, | |
| 559 | .@"struct" => |info| info.fields.len, | |
| 560 | 560 | else => unreachable, |
| 561 | 561 | }; |
| 562 | 562 | } |
| 563 | 563 | }; |
| 564 | const fields_list = S.fields(@TypeOf(.{})); | |
| 565 | if (fields_list.len != 0) | |
| 566 | @compileError("Argument count mismatch"); | |
| 564 | const fields_len = S.fieldCount(@TypeOf(.{})); | |
| 565 | comptime assert(fields_len == 0); | |
| 567 | 566 | } |
| 568 | 567 | |
| 569 | 568 | test "registers get overwritten when ignoring return" { |
test/behavior/eval.zig-7| ... | ... | @@ -719,13 +719,6 @@ fn testVarInsideInlineLoop(args: anytype) !void { |
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | test "*align(1) u16 is the same as *align(1:0:2) u16" { | |
| 723 | comptime { | |
| 724 | try expect(*align(1:0:2) u16 == *align(1) u16); | |
| 725 | try expect(*align(2:0:2) u16 == *u16); | |
| 726 | } | |
| 727 | } | |
| 728 | ||
| 729 | 722 | test "array concatenation of function calls" { |
| 730 | 723 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 731 | 724 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
test/behavior/packed-struct.zig+1-1| ... | ... | @@ -820,7 +820,7 @@ test "packed struct passed to callconv(.c) function" { |
| 820 | 820 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 821 | 821 | |
| 822 | 822 | const S = struct { |
| 823 | const Packed = packed struct { | |
| 823 | const Packed = packed struct(u64) { | |
| 824 | 824 | a: u16, |
| 825 | 825 | b: bool = true, |
| 826 | 826 | c: bool = true, |
test/behavior/switch.zig+5-6| ... | ... | @@ -645,7 +645,7 @@ test "switch prong pointer capture alignment" { |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | switch (u) { |
| 648 | .a, .c => |*p| comptime assert(@TypeOf(p) == *const u8), | |
| 648 | .a, .c => |*p| comptime assert(@TypeOf(p) == *align(1) const u8), | |
| 649 | 649 | .b => |*p| { |
| 650 | 650 | _ = p; |
| 651 | 651 | return error.TestFailed; |
| ... | ... | @@ -1141,24 +1141,23 @@ test "decl literals as switch cases" { |
| 1141 | 1141 | try comptime E.doTheTest(.foo); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | // TODO audit after #15909 and/or #19855 are decided/implemented | |
| 1144 | // TODO audit after #15909 and/or #19855 are decided/implemented. | |
| 1145 | // When we do that, consider adding an 'error{}' case if possible. | |
| 1145 | 1146 | test "switch with uninstantiable union fields" { |
| 1146 | 1147 | const U = union(enum) { |
| 1147 | 1148 | ok: void, |
| 1148 | 1149 | a: noreturn, |
| 1149 | 1150 | b: noreturn, |
| 1150 | c: error{}, | |
| 1151 | 1151 | |
| 1152 | 1152 | fn doTheTest(u: @This()) void { |
| 1153 | 1153 | switch (u) { |
| 1154 | 1154 | .ok => {}, |
| 1155 | 1155 | .a => comptime unreachable, |
| 1156 | 1156 | .b => comptime unreachable, |
| 1157 | .c => comptime unreachable, | |
| 1158 | 1157 | } |
| 1159 | 1158 | switch (u) { |
| 1160 | 1159 | .ok => {}, |
| 1161 | .a, .b, .c => comptime unreachable, | |
| 1160 | .a, .b => comptime unreachable, | |
| 1162 | 1161 | } |
| 1163 | 1162 | switch (u) { |
| 1164 | 1163 | .ok => {}, |
| ... | ... | @@ -1166,7 +1165,7 @@ test "switch with uninstantiable union fields" { |
| 1166 | 1165 | } |
| 1167 | 1166 | switch (u) { |
| 1168 | 1167 | .a => comptime unreachable, |
| 1169 | .ok, .b, .c => {}, | |
| 1168 | .ok, .b => {}, | |
| 1170 | 1169 | } |
| 1171 | 1170 | } |
| 1172 | 1171 | }; |