| author | |
| committer | |
| log | 65e74dfbda3e50ba09a2b59061ccb90a7dd68e9f |
| tree | 60faead2672c05bc933745300d323086937e7346 |
| parent | 508cbec69455d82c0e9bb5ae47f064ab33460469 |
24 files changed, 133 insertions(+), 19 deletions(-)
lib/std/lang.zig+2-1| ... | ... | @@ -1173,11 +1173,12 @@ pub const ExternOptions = struct { |
| 1173 | 1173 | |
| 1174 | 1174 | pub const Decoration = union(enum) { |
| 1175 | 1175 | location: u32, |
| 1176 | flat: u32, | |
| 1176 | 1177 | descriptor: Descriptor, |
| 1177 | 1178 | |
| 1178 | 1179 | pub const Descriptor = struct { |
| 1179 | binding: u32, | |
| 1180 | 1180 | set: u32, |
| 1181 | binding: u32, | |
| 1181 | 1182 | }; |
| 1182 | 1183 | }; |
| 1183 | 1184 |
src/InternPool.zig+4-4| ... | ... | @@ -5406,16 +5406,15 @@ pub const Tag = enum(u8) { |
| 5406 | 5406 | _: u23 = 0, |
| 5407 | 5407 | |
| 5408 | 5408 | pub const Source = enum(u1) { builtin, syntax }; |
| 5409 | pub const DecorationType = enum(u2) { none, location, descriptor }; | |
| 5409 | pub const DecorationType = enum(u2) { none, location, descriptor, flat }; | |
| 5410 | 5410 | }; |
| 5411 | 5411 | |
| 5412 | 5412 | pub fn decoration(self: Extern) ?std.lang.ExternOptions.Decoration { |
| 5413 | 5413 | return switch (self.flags.decoration_type) { |
| 5414 | 5414 | .none => null, |
| 5415 | .location => std.lang.ExternOptions.Decoration{ | |
| 5416 | .location = self.location_or_descriptor_set, | |
| 5417 | }, | |
| 5415 | .location => std.lang.ExternOptions.Decoration{ .location = self.location_or_descriptor_set }, | |
| 5418 | 5416 | .descriptor => std.lang.ExternOptions.Decoration{ .descriptor = .{ .set = self.location_or_descriptor_set, .binding = self.descriptor_binding } }, |
| 5417 | .flat => std.lang.ExternOptions.Decoration{ .flat = self.location_or_descriptor_set }, | |
| 5419 | 5418 | }; |
| 5420 | 5419 | } |
| 5421 | 5420 | }; |
| ... | ... | @@ -9199,6 +9198,7 @@ pub fn getExtern( |
| 9199 | 9198 | }) catch unreachable; // capacity asserted above |
| 9200 | 9199 | const decoration_type, const location_or_descriptor_set, const descriptor_binding = if (key.decoration) |decoration| switch (decoration) { |
| 9201 | 9200 | .location => |location| .{ Tag.Extern.Flags.DecorationType.location, location, undefined }, |
| 9201 | .flat => |location| .{ Tag.Extern.Flags.DecorationType.flat, location, undefined }, | |
| 9202 | 9202 | .descriptor => |descriptor| .{ Tag.Extern.Flags.DecorationType.descriptor, descriptor.set, descriptor.binding }, |
| 9203 | 9203 | } else .{ Tag.Extern.Flags.DecorationType.none, undefined, undefined }; |
| 9204 | 9204 | const extra_index = addExtraAssumeCapacity(extra, Tag.Extern{ |
src/Sema.zig+7| ... | ... | @@ -25021,6 +25021,13 @@ fn zirBuiltinExtern( |
| 25021 | 25021 | .pcrel => if (options.visibility == .default) return sema.fail(block, options_src, "cannot require a pc-relative relocation to a symbol with default visibility", .{}), |
| 25022 | 25022 | } |
| 25023 | 25023 | |
| 25024 | if (options.decoration) |decoration| switch (decoration) { | |
| 25025 | .flat => if (ptr_info.flags.address_space != .input) { | |
| 25026 | return sema.fail(block, options_src, "'flat' decoration requires 'input' address space", .{}); | |
| 25027 | }, | |
| 25028 | .location, .descriptor => {}, | |
| 25029 | }; | |
| 25030 | ||
| 25024 | 25031 | // TODO: error for threadlocal functions, non-const functions, etc |
| 25025 | 25032 | |
| 25026 | 25033 | const extern_val = try pt.getExtern(.{ |
src/codegen/spirv/Assembler.zig+9| ... | ... | @@ -393,6 +393,15 @@ fn processGenericInstruction(ass: *Assembler) !?AsmValue { |
| 393 | 393 | const actual_word_count = section.instructions.items.len - first_word; |
| 394 | 394 | section.instructions.items[first_word] |= @as(u32, @as(u16, @intCast(actual_word_count))) << 16 | @intFromEnum(ass.inst.opcode); |
| 395 | 395 | |
| 396 | switch (ass.inst.opcode) { | |
| 397 | .OpKill, | |
| 398 | .OpReturn, | |
| 399 | .OpReturnValue, | |
| 400 | .OpUnreachable, | |
| 401 | => ass.cg.block_terminated = true, | |
| 402 | else => {}, | |
| 403 | } | |
| 404 | ||
| 396 | 405 | if (maybe_result_id) |result| return .{ .value = result }; |
| 397 | 406 | return null; |
| 398 | 407 | } |
src/codegen/spirv/CodeGen.zig+30-10| ... | ... | @@ -118,6 +118,10 @@ block_stack: std.ArrayList(*Block) = .empty, |
| 118 | 118 | block_results: std.AutoHashMapUnmanaged(Air.Inst.Index, Id) = .empty, |
| 119 | 119 | base_line: u32, |
| 120 | 120 | block_label: Id = .none, |
| 121 | /// Whether the current block has been terminated by a terminator | |
| 122 | /// instruction (e.g. OpKill from inline assembly). When true, no further | |
| 123 | /// branch instructions should be emitted for the current block. | |
| 124 | block_terminated: bool = false, | |
| 121 | 125 | next_arg_index: u32 = 0, |
| 122 | 126 | args: std.ArrayList(Id) = .empty, |
| 123 | 127 | virtual_allocas: std.AutoHashMapUnmanaged(Id, ?Id) = .empty, |
| ... | ... | @@ -428,10 +432,13 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void { |
| 428 | 432 | if (ty.zigTypeTag(zcu) == .@"struct" and storage_class != .physical_storage_buffer) { |
| 429 | 433 | try cg.module.decorate(ty_id, .block); |
| 430 | 434 | } |
| 431 | try cg.module.decorate(ptr_ty_id, .{ | |
| 432 | .array_stride = .{ .array_stride = @intCast(ty.abiSize(zcu)) }, | |
| 433 | }); | |
| 434 | try cg.decorateLayout(ty, ty_id); | |
| 435 | ||
| 436 | if (ty.hasRuntimeBits(zcu)) { | |
| 437 | try cg.module.decorate(ptr_ty_id, .{ | |
| 438 | .array_stride = .{ .array_stride = @intCast(ty.abiSize(zcu)) }, | |
| 439 | }); | |
| 440 | try cg.decorateLayout(ty, ty_id); | |
| 441 | } | |
| 435 | 442 | }, |
| 436 | 443 | else => {}, |
| 437 | 444 | } |
| ... | ... | @@ -445,6 +452,10 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void { |
| 445 | 452 | .location = .{ .location = location }, |
| 446 | 453 | }); |
| 447 | 454 | }, |
| 455 | .flat => |location| { | |
| 456 | try cg.module.decorate(result_id, .{ .location = .{ .location = location } }); | |
| 457 | try cg.module.decorate(result_id, .flat); | |
| 458 | }, | |
| 448 | 459 | .descriptor => |descriptor| { |
| 449 | 460 | if (storage_class != .storage_buffer and storage_class != .uniform and storage_class != .uniform_constant) { |
| 450 | 461 | return cg.fail("storage class must be one of (storage_buffer, uniform, uniform_constant) but is {s}", .{@tagName(storage_class)}); |
| ... | ... | @@ -770,6 +781,7 @@ fn addFunctionDep(cg: *CodeGen, decl_index: Module.Decl.Index, storage_class: St |
| 770 | 781 | fn beginSpvBlock(cg: *CodeGen, label: Id) !void { |
| 771 | 782 | try cg.body.emit(cg.module.gpa, .OpLabel, .{ .id_result = label }); |
| 772 | 783 | cg.block_label = label; |
| 784 | cg.block_terminated = false; | |
| 773 | 785 | } |
| 774 | 786 | |
| 775 | 787 | /// Return the amount of bits in the largest supported integer type. This is either 32 (always supported), or 64 (if |
| ... | ... | @@ -2038,10 +2050,12 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2038 | 2050 | const elem_ty: Type = .fromInterned(spirv_type.ty); |
| 2039 | 2051 | const elem_ty_id = try cg.resolveType(elem_ty, .indirect); |
| 2040 | 2052 | const result_id = try cg.module.runtimeArrayType(ip_index, elem_ty_id); |
| 2041 | try cg.module.decorate( | |
| 2042 | result_id, | |
| 2043 | .{ .array_stride = .{ .array_stride = @intCast(elem_ty.abiSize(zcu)) } }, | |
| 2044 | ); | |
| 2053 | ||
| 2054 | if (elem_ty.hasRuntimeBits(zcu)) { | |
| 2055 | try cg.module.decorate(result_id, .{ .array_stride = .{ | |
| 2056 | .array_stride = @intCast(elem_ty.abiSize(zcu)), | |
| 2057 | } }); | |
| 2058 | } | |
| 2045 | 2059 | return result_id; |
| 2046 | 2060 | }, |
| 2047 | 2061 | } |
| ... | ... | @@ -6564,6 +6578,8 @@ fn structuredNextBlock(cg: *CodeGen, incoming: []const Block.Incoming) !Id { |
| 6564 | 6578 | /// terminating a body, there should be no instructions after it. |
| 6565 | 6579 | /// This function should only be called with structured control flow generation. |
| 6566 | 6580 | fn structuredBreak(cg: *CodeGen, target_block: Id) !void { |
| 6581 | if (cg.block_terminated) return; | |
| 6582 | ||
| 6567 | 6583 | const gpa = cg.module.gpa; |
| 6568 | 6584 | const sblock = cg.block_stack.getLast().?; |
| 6569 | 6585 | const merge_block = switch (sblock.*) { |
| ... | ... | @@ -6833,7 +6849,9 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void { |
| 6833 | 6849 | .next_block = then_next, |
| 6834 | 6850 | }; |
| 6835 | 6851 | |
| 6836 | try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label }); | |
| 6852 | if (!cg.block_terminated) { | |
| 6853 | try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label }); | |
| 6854 | } | |
| 6837 | 6855 | |
| 6838 | 6856 | try cg.beginSpvBlock(else_label); |
| 6839 | 6857 | const else_next = try cg.genStructuredBody(.selection, else_body); |
| ... | ... | @@ -6842,7 +6860,9 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void { |
| 6842 | 6860 | .next_block = else_next, |
| 6843 | 6861 | }; |
| 6844 | 6862 | |
| 6845 | try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label }); | |
| 6863 | if (!cg.block_terminated) { | |
| 6864 | try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label }); | |
| 6865 | } | |
| 6846 | 6866 | |
| 6847 | 6867 | try cg.beginSpvBlock(merge_label); |
| 6848 | 6868 | const next_block = try cg.structuredNextBlock(&.{ then_incoming, else_incoming }); |
test/behavior/basic.zig+4| ... | ... | @@ -302,6 +302,8 @@ test "compile time global reinterpret" { |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | test "cast undefined" { |
| 305 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 306 | ||
| 305 | 307 | const array: [100]u8 = undefined; |
| 306 | 308 | const slice = @as([]const u8, &array); |
| 307 | 309 | testCastUndefined(slice); |
| ... | ... | @@ -372,6 +374,7 @@ test "call function pointer in struct" { |
| 372 | 374 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 373 | 375 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 374 | 376 | try expect(mem.eql(u8, f3(true), "a")); |
| 377 | try expect(mem.eql(u8, f3(false), "b")); | |
| 375 | 378 | } |
| 376 | 379 | |
| 377 | 380 | fn f3(x: bool) []const u8 { |
| ... | ... | @@ -412,6 +415,7 @@ test "call result of if else expression" { |
| 412 | 415 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 413 | 416 | |
| 414 | 417 | try expect(mem.eql(u8, f2(true), "a")); |
| 418 | try expect(mem.eql(u8, f2(false), "b")); | |
| 415 | 419 | } |
| 416 | 420 | fn f2(x: bool) []const u8 { |
| 417 | 421 | return (if (x) &fA else &fB)(); |
test/behavior/bitcast.zig+3| ... | ... | @@ -35,6 +35,8 @@ test "@bitCast iX -> uX exotic integers" { |
| 35 | 35 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 36 | 36 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 37 | 37 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 38 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 39 | ||
| 38 | 40 | const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 }; |
| 39 | 41 | |
| 40 | 42 | inline for (bit_values) |bits| { |
| ... | ... | @@ -77,6 +79,7 @@ test "bitcast uX to bytes" { |
| 77 | 79 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 78 | 80 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 79 | 81 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 82 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 80 | 83 | |
| 81 | 84 | const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 }; |
| 82 | 85 | inline for (bit_values) |bits| { |
test/behavior/cast.zig+13| ... | ... | @@ -103,6 +103,10 @@ test "comptime_int @floatFromInt" { |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | test "@floatFromInt" { |
| 106 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 107 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 108 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 109 | ||
| 106 | 110 | const S = struct { |
| 107 | 111 | fn doTheTest() !void { |
| 108 | 112 | try testIntToFloat(-2); |
| ... | ... | @@ -128,9 +132,13 @@ fn testIntFromFloat(comptime F: type, f: F, comptime I: type, i: I) !void { |
| 128 | 132 | |
| 129 | 133 | test "@intFromFloat > 128 bits" { |
| 130 | 134 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 135 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 131 | 136 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 137 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 132 | 138 | |
| 139 | try testIntFromFloat(f16, 1024, u140, 1024); | |
| 133 | 140 | try testIntFromFloat(f16, -1024, i140, -1024); |
| 141 | ||
| 134 | 142 | try testIntFromFloat(f32, 1 << 24, u140, 1 << 24); |
| 135 | 143 | try testIntFromFloat(f32, -1 << 24, i140, -1 << 24); |
| 136 | 144 | |
| ... | ... | @@ -152,10 +160,13 @@ test "@floatFromInt > 128 bits" { |
| 152 | 160 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 153 | 161 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 154 | 162 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 163 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 155 | 164 | |
| 156 | 165 | try testFloatFromInt(u140, 1024, f16, 1024); |
| 166 | try testFloatFromInt(i140, -1024, f16, -1024); | |
| 157 | 167 | |
| 158 | 168 | try testFloatFromInt(u140, 1 << 24, f32, 1 << 24); |
| 169 | try testFloatFromInt(i140, -1 << 24, f32, -1 << 24); | |
| 159 | 170 | |
| 160 | 171 | try testFloatFromInt(u200, 1 << 53, f64, 1 << 53); |
| 161 | 172 | try testFloatFromInt(i200, -1 << 53, f64, -1 << 53); |
| ... | ... | @@ -416,9 +427,11 @@ test "implicit cast from *[N]T to [*c]T" { |
| 416 | 427 | var y: [*c]u16 = &x; |
| 417 | 428 | |
| 418 | 429 | try expect(std.mem.eql(u16, x[0..4], y[0..4])); |
| 430 | x[0] = 8; | |
| 419 | 431 | y[3] = 6; |
| 420 | 432 | try expect(std.mem.eql(u16, x[0..4], y[0..4])); |
| 421 | 433 | } |
| 434 | ||
| 422 | 435 | test "*usize to *void" { |
| 423 | 436 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 424 | 437 |
test/behavior/cast_int.zig+4| ... | ... | @@ -8,6 +8,8 @@ const minInt = std.math.minInt; |
| 8 | 8 | test "@intCast i32 to u7" { |
| 9 | 9 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 10 | 10 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 11 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 12 | ||
| 11 | 13 | var x: u128 = maxInt(u128); |
| 12 | 14 | var y: i32 = 120; |
| 13 | 15 | _ = .{ &x, &y }; |
| ... | ... | @@ -143,6 +145,7 @@ test "@intCast <= 64 bits" { |
| 143 | 145 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 144 | 146 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 145 | 147 | try testIntCast(i32, minInt(i32), i64, minInt(i32)); |
| 148 | try testIntCast(i32, maxInt(i32), i64, maxInt(i32)); | |
| 146 | 149 | try testIntCast(u32, maxInt(u32), u64, maxInt(u32)); |
| 147 | 150 | try testIntCast(u32, maxInt(i32), i64, maxInt(i32)); |
| 148 | 151 | try testIntCast(u32, maxInt(u32), i64, maxInt(u32)); |
| ... | ... | @@ -169,6 +172,7 @@ test "@intCast > 128 bits" { |
| 169 | 172 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 170 | 173 | |
| 171 | 174 | try testIntCast(u8, 123, u140, 123); |
| 175 | try testIntCast(u64, 1 << 63, u140, 1 << 63); | |
| 172 | 176 | try testIntCast(u127, maxInt(u127), u140, maxInt(u127)); |
| 173 | 177 | try testIntCast(i8, -42, i140, -42); |
| 174 | 178 | try testIntCast(i64, minInt(i64), i140, minInt(i64)); |
test/behavior/enum.zig+6| ... | ... | @@ -932,6 +932,7 @@ test "constant enum initialization with differing sizes" { |
| 932 | 932 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 933 | 933 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 934 | 934 | try test3_1(test3_foo); |
| 935 | try test3_2(test3_bar); | |
| 935 | 936 | } |
| 936 | 937 | const Test3Foo = union(enum) { |
| 937 | 938 | One: void, |
| ... | ... | @@ -972,7 +973,9 @@ test "@tagName" { |
| 972 | 973 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 973 | 974 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 974 | 975 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 976 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | |
| 975 | 977 | |
| 978 | try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three")); | |
| 976 | 979 | comptime assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three")); |
| 977 | 980 | } |
| 978 | 981 | |
| ... | ... | @@ -987,7 +990,9 @@ test "@tagName non-exhaustive enum" { |
| 987 | 990 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 988 | 991 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 989 | 992 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 993 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 990 | 994 | |
| 995 | try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B")); | |
| 991 | 996 | comptime assert(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B")); |
| 992 | 997 | } |
| 993 | 998 | const NonExhaustive = enum(u8) { A, B, _ }; |
| ... | ... | @@ -1029,6 +1034,7 @@ test "@tagName on enum literals" { |
| 1029 | 1034 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 1030 | 1035 | |
| 1031 | 1036 | try expect(mem.eql(u8, @tagName(.FooBar), "FooBar")); |
| 1037 | comptime assert(mem.eql(u8, @tagName(.FooBar), "FooBar")); | |
| 1032 | 1038 | } |
| 1033 | 1039 | |
| 1034 | 1040 | test "tag name with signed enum values" { |
test/behavior/error.zig+10| ... | ... | @@ -145,11 +145,17 @@ test "implicit cast to optional to error union to return result loc" { |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | test "fn returning empty error set can be passed as fn returning any error" { |
| 148 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | |
| 149 | ||
| 150 | entry(); | |
| 151 | comptime entry(); | |
| 148 | 152 | } |
| 149 | 153 | |
| 150 | 154 | test "fn returning empty error set can be passed as fn returning any error - pointer" { |
| 151 | 155 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 156 | ||
| 152 | 157 | entryPtr(); |
| 158 | comptime entryPtr(); | |
| 153 | 159 | } |
| 154 | 160 | fn entry() void { |
| 155 | 161 | foo2(bar2); |
| ... | ... | @@ -362,8 +368,10 @@ test "error: Infer error set from literals" { |
| 362 | 368 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 363 | 369 | |
| 364 | 370 | _ = nullLiteral("n") catch |err| handleErrors(err); |
| 371 | _ = floatLiteral("n") catch |err| handleErrors(err); | |
| 365 | 372 | _ = intLiteral("n") catch |err| handleErrors(err); |
| 366 | 373 | _ = comptime nullLiteral("n") catch |err| handleErrors(err); |
| 374 | _ = comptime floatLiteral("n") catch |err| handleErrors(err); | |
| 367 | 375 | _ = comptime intLiteral("n") catch |err| handleErrors(err); |
| 368 | 376 | } |
| 369 | 377 | |
| ... | ... | @@ -689,6 +697,7 @@ test "coerce error set to the current inferred error set" { |
| 689 | 697 | test "error union payload is properly aligned" { |
| 690 | 698 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 691 | 699 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 700 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 692 | 701 | |
| 693 | 702 | const S = struct { |
| 694 | 703 | a: u128, |
| ... | ... | @@ -746,6 +755,7 @@ test "pointer to error union payload" { |
| 746 | 755 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 747 | 756 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 748 | 757 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 758 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 749 | 759 | |
| 750 | 760 | var err_union: anyerror!u8 = 15; |
| 751 | 761 |
test/behavior/eval.zig-1| ... | ... | @@ -1181,7 +1181,6 @@ test "lazy sizeof is resolved in division" { |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | test "lazy sizeof union tag size in compare" { |
| 1184 | ||
| 1185 | 1184 | const A = union(enum) { |
| 1186 | 1185 | a: void, |
| 1187 | 1186 | b: void, |
test/behavior/floatop.zig+8| ... | ... | @@ -134,6 +134,8 @@ test "cmp f32" { |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | test "cmp f64" { |
| 137 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 138 | ||
| 137 | 139 | try testCmp(f64); |
| 138 | 140 | try comptime testCmp(f64); |
| 139 | 141 | } |
| ... | ... | @@ -142,7 +144,9 @@ test "cmp f128" { |
| 142 | 144 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 143 | 145 | if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| 144 | 146 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 147 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | |
| 145 | 148 | |
| 149 | try testCmp(f128); | |
| 146 | 150 | try comptime testCmp(f128); |
| 147 | 151 | } |
| 148 | 152 | |
| ... | ... | @@ -150,7 +154,10 @@ test "cmp f80/c_longdouble" { |
| 150 | 154 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 151 | 155 | if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| 152 | 156 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 157 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 153 | 158 | |
| 159 | try testCmp(f80); | |
| 160 | try comptime testCmp(f80); | |
| 154 | 161 | try testCmp(c_longdouble); |
| 155 | 162 | try comptime testCmp(c_longdouble); |
| 156 | 163 | } |
| ... | ... | @@ -225,6 +232,7 @@ test "vector cmp f32" { |
| 225 | 232 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 226 | 233 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 227 | 234 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 235 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isArm()) return error.SkipZigTest; | |
| 228 | 236 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest; |
| 229 | 237 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 230 | 238 |
test/behavior/fn.zig+6| ... | ... | @@ -292,6 +292,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void { |
| 292 | 292 | |
| 293 | 293 | test "call function with empty string" { |
| 294 | 294 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 295 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | |
| 296 | ||
| 297 | acceptsString(""); | |
| 295 | 298 | } |
| 296 | 299 | |
| 297 | 300 | fn acceptsString(foo: []u8) void { |
| ... | ... | @@ -302,7 +305,9 @@ test "function pointers" { |
| 302 | 305 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 303 | 306 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 304 | 307 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 308 | ||
| 305 | 309 | const fns = [_]*const @TypeOf(fn1){ |
| 310 | &fn1, | |
| 306 | 311 | &fn2, |
| 307 | 312 | &fn3, |
| 308 | 313 | &fn4, |
| ... | ... | @@ -440,6 +445,7 @@ test "method call with optional and error union first param" { |
| 440 | 445 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 441 | 446 | |
| 442 | 447 | const S = struct { |
| 448 | x: i32 = 1234, | |
| 443 | 449 | |
| 444 | 450 | fn opt(s: ?@This()) !void { |
| 445 | 451 | try expect(s.?.x == 1234); |
test/behavior/math.zig+1-1| ... | ... | @@ -574,6 +574,7 @@ test "large integer division" { |
| 574 | 574 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 575 | 575 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; |
| 576 | 576 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 577 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 577 | 578 | |
| 578 | 579 | { |
| 579 | 580 | var numerator: u256 = 99999999999999999997315645440; |
| ... | ... | @@ -654,7 +655,6 @@ fn testSignedWrappingEval(x: i32) !void { |
| 654 | 655 | } |
| 655 | 656 | |
| 656 | 657 | test "signed negation wrapping" { |
| 657 | ||
| 658 | 658 | try testSignedNegationWrappingEval(minInt(i16)); |
| 659 | 659 | try comptime testSignedNegationWrappingEval(minInt(i16)); |
| 660 | 660 | } |
test/behavior/maximum_minimum.zig+1| ... | ... | @@ -350,6 +350,7 @@ test "@min/@max with runtime signed and unsigned integers of same size" { |
| 350 | 350 | |
| 351 | 351 | test "@min/@max with runtime vectors of signed and unsigned integers of same size" { |
| 352 | 352 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 353 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 353 | 354 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 354 | 355 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 355 | 356 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
test/behavior/memcpy.zig-1| ... | ... | @@ -168,7 +168,6 @@ test "@memcpy with sentinel" { |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | test "@memcpy no sentinel source into sentinel destination" { |
| 171 | ||
| 172 | 171 | const S = struct { |
| 173 | 172 | fn doTheTest() void { |
| 174 | 173 | const src: []const u8 = &.{ 1, 2, 3 }; |
test/behavior/muladd.zig+3| ... | ... | @@ -34,6 +34,7 @@ test "@mulAdd f16" { |
| 34 | 34 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 35 | 35 | |
| 36 | 36 | try comptime testMulAdd16(); |
| 37 | try testMulAdd16(); | |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | fn testMulAdd16() !void { |
| ... | ... | @@ -48,7 +49,9 @@ test "@mulAdd f80" { |
| 48 | 49 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 49 | 50 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 50 | 51 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 52 | if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest; | |
| 51 | 53 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 54 | ||
| 52 | 55 | try comptime testMulAdd80(); |
| 53 | 56 | try testMulAdd80(); |
| 54 | 57 | } |
test/behavior/optional.zig+1| ... | ... | @@ -522,6 +522,7 @@ test "alignment of wrapping an optional payload" { |
| 522 | 522 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 523 | 523 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 524 | 524 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 525 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 525 | 526 | |
| 526 | 527 | const S = struct { |
| 527 | 528 | const I = extern struct { x: i128 }; |
test/behavior/packed-struct.zig+3| ... | ... | @@ -227,6 +227,8 @@ test "nested packed structs" { |
| 227 | 227 | test "regular in irregular packed struct" { |
| 228 | 228 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 229 | 229 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 230 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 231 | ||
| 230 | 232 | const Irregular = packed struct { |
| 231 | 233 | bar: Regular = Regular{}, |
| 232 | 234 | _: u24 = 0, |
| ... | ... | @@ -247,6 +249,7 @@ test "nested packed struct unaligned" { |
| 247 | 249 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 248 | 250 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 249 | 251 | const S1 = packed struct { |
| 252 | a: u4, | |
| 250 | 253 | b: u4, |
| 251 | 254 | c: u8, |
| 252 | 255 | }; |
test/behavior/struct.zig+3| ... | ... | @@ -446,6 +446,7 @@ test "runtime struct initialization of bitfield" { |
| 446 | 446 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 447 | 447 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 448 | 448 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 449 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 449 | 450 | |
| 450 | 451 | const s1 = Nibbles{ |
| 451 | 452 | .x = x1, |
| ... | ... | @@ -503,6 +504,7 @@ test "implicit cast packed struct field to const ptr" { |
| 503 | 504 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 504 | 505 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 505 | 506 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 507 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; // TODO | |
| 506 | 508 | |
| 507 | 509 | const LevelUpMove = packed struct { |
| 508 | 510 | move_id: u9, |
| ... | ... | @@ -536,6 +538,7 @@ test "packed struct with non-ABI-aligned field" { |
| 536 | 538 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 537 | 539 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 538 | 540 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 541 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | |
| 539 | 542 | |
| 540 | 543 | const S = packed struct { |
| 541 | 544 | x: u9, |
test/behavior/vector.zig+2| ... | ... | @@ -415,6 +415,7 @@ test "vector @splat" { |
| 415 | 415 | |
| 416 | 416 | test "load vector elements via comptime index" { |
| 417 | 417 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 418 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 418 | 419 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 419 | 420 | |
| 420 | 421 | const S = struct { |
| ... | ... | @@ -617,6 +618,7 @@ test "vector division operators" { |
| 617 | 618 | test "vector bitwise not operator" { |
| 618 | 619 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 619 | 620 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 621 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 620 | 622 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 621 | 623 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 622 | 624 |
test/behavior/while.zig-1| ... | ... | @@ -38,7 +38,6 @@ fn staticWhileLoop2() i32 { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | test "while with continue expression" { |
| 41 | ||
| 42 | 41 | var sum: i32 = 0; |
| 43 | 42 | { |
| 44 | 43 | var i: i32 = 0; |
test/cases/compile_errors/extern_spirv_decoration_validation.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | const x = @extern(*addrspace(.output) u32, .{ | |
| 2 | .name = "x", | |
| 3 | .decoration = .{ .flat = 0 }, | |
| 4 | }); | |
| 5 | comptime { | |
| 6 | _ = x; | |
| 7 | } | |
| 8 | ||
| 9 | // error | |
| 10 | // backend=selfhosted | |
| 11 | // target=spirv64-vulkan | |
| 12 | // | |
| 13 | // :1:45: error: 'flat' decoration requires 'input' address space |