| ... | @@ -16103,24 +16103,44 @@ test "struct f32, f32, f32, f32, f32" { | ... | @@ -16103,24 +16103,44 @@ test "struct f32, f32, f32, f32, f32" { |
| 16103 | c_test_struct_f32_f32_f32_f32_f32(); | 16103 | c_test_struct_f32_f32_f32_f32_f32(); |
| 16104 | } | 16104 | } |
| 16105 | | 16105 | |
| | 16106 | const Struct_void_f32 = extern struct { |
| | 16107 | _: void = {}, |
| | 16108 | a: f32, |
| | 16109 | }; |
| | 16110 | |
| | 16111 | export fn zig_ret_struct_void_f32() Struct_void_f32 { |
| | 16112 | return .{ .a = 1 }; |
| | 16113 | } |
| | 16114 | export fn zig_struct_void_f32(s: Struct_void_f32, i: usize) void { |
| | 16115 | expect(s.a == 2) catch @panic("test failure"); |
| | 16116 | expect(i == 3) catch @panic("test failure"); |
| | 16117 | } |
| | 16118 | |
| | 16119 | extern fn c_ret_struct_void_f32() Struct_void_f32; |
| | 16120 | extern fn c_struct_void_f32(Struct_void_f32, usize) void; |
| | 16121 | extern fn c_test_struct_void_f32() void; |
| | 16122 | |
| | 16123 | test "struct void, f32" { |
| | 16124 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16125 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16126 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; |
| | 16127 | |
| | 16128 | const s = c_ret_struct_void_f32(); |
| | 16129 | try expect(s.a == 4); |
| | 16130 | c_struct_void_f32(.{ .a = 5 }, 6); |
| | 16131 | c_test_struct_void_f32(); |
| | 16132 | } |
| | 16133 | |
| 16106 | const Struct_array_1_f32 = extern struct { | 16134 | const Struct_array_1_f32 = extern struct { |
| 16107 | a: [1]f32, | 16135 | a: [1]f32, |
| 16108 | }; | 16136 | }; |
| 16109 | | 16137 | |
| 16110 | comptime { | 16138 | export fn zig_ret_struct_array_1_f32() Struct_array_1_f32 { |
| 16111 | skip: { | 16139 | return .{ .a = .{1} }; |
| 16112 | if (builtin.cpu.arch.isWasm()) break :skip; | 16140 | } |
| 16113 | | 16141 | export fn zig_struct_array_1_f32(s: Struct_array_1_f32, i: usize) void { |
| 16114 | _ = struct { | 16142 | expect(s.a[0] == 2) catch @panic("test failure"); |
| 16115 | export fn zig_ret_struct_array_1_f32() Struct_array_1_f32 { | 16143 | expect(i == 3) catch @panic("test failure"); |
| 16116 | return .{ .a = .{1} }; | | |
| 16117 | } | | |
| 16118 | export fn zig_struct_array_1_f32(s: Struct_array_1_f32, i: usize) void { | | |
| 16119 | expect(s.a[0] == 2) catch @panic("test failure"); | | |
| 16120 | expect(i == 3) catch @panic("test failure"); | | |
| 16121 | } | | |
| 16122 | }; | | |
| 16123 | } | | |
| 16124 | } | 16144 | } |
| 16125 | | 16145 | |
| 16126 | extern fn c_ret_struct_array_1_f32() Struct_array_1_f32; | 16146 | extern fn c_ret_struct_array_1_f32() Struct_array_1_f32; |
| ... | @@ -16133,8 +16153,6 @@ test "struct [1]f32" { | ... | @@ -16133,8 +16153,6 @@ test "struct [1]f32" { |
| 16133 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 16153 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 16134 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; | 16154 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| 16135 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; | 16155 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 16136 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | | |
| 16137 | if (builtin.cpu.arch.isWasm()) return error.SkipZigTest; | | |
| 16138 | | 16156 | |
| 16139 | const s = c_ret_struct_array_1_f32(); | 16157 | const s = c_ret_struct_array_1_f32(); |
| 16140 | try expect(s.a[0] == 4); | 16158 | try expect(s.a[0] == 4); |
| ... | @@ -16278,6 +16296,191 @@ test "struct [5]f32" { | ... | @@ -16278,6 +16296,191 @@ test "struct [5]f32" { |
| 16278 | c_test_struct_array_5_f32(); | 16296 | c_test_struct_array_5_f32(); |
| 16279 | } | 16297 | } |
| 16280 | | 16298 | |
| | 16299 | const Struct_array_0_sentinel_f32 = extern struct { |
| | 16300 | a: [0:0x1e1]f32, |
| | 16301 | }; |
| | 16302 | |
| | 16303 | export fn zig_ret_struct_array_0_sentinel_f32() Struct_array_0_sentinel_f32 { |
| | 16304 | return .{ .a = .{} }; |
| | 16305 | } |
| | 16306 | export fn zig_struct_array_0_sentinel_f32(s: Struct_array_0_sentinel_f32, i: usize) void { |
| | 16307 | var sentinel_index: usize = 0; |
| | 16308 | _ = &sentinel_index; |
| | 16309 | expect(s.a[sentinel_index] == 0x1e1) catch @panic("test failure"); |
| | 16310 | expect(i == 1) catch @panic("test failure"); |
| | 16311 | } |
| | 16312 | |
| | 16313 | extern fn c_ret_struct_array_0_sentinel_f32() Struct_array_0_sentinel_f32; |
| | 16314 | extern fn c_struct_array_0_sentinel_f32(Struct_array_0_sentinel_f32, usize) void; |
| | 16315 | extern fn c_test_struct_array_0_sentinel_f32() void; |
| | 16316 | |
| | 16317 | test "struct [0:sentinel]f32" { |
| | 16318 | if (builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| | 16319 | if (builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| | 16320 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16321 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16322 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 16323 | |
| | 16324 | var sentinel_index: usize = 0; |
| | 16325 | _ = &sentinel_index; |
| | 16326 | const s = c_ret_struct_array_0_sentinel_f32(); |
| | 16327 | try expect(s.a[sentinel_index] == 0x1e1); |
| | 16328 | c_struct_array_0_sentinel_f32(.{ .a = .{} }, 2); |
| | 16329 | c_test_struct_array_0_sentinel_f32(); |
| | 16330 | } |
| | 16331 | |
| | 16332 | const Struct_array_1_sentinel_f32 = extern struct { |
| | 16333 | a: [1:0x1e1]f32, |
| | 16334 | }; |
| | 16335 | |
| | 16336 | export fn zig_ret_struct_array_1_sentinel_f32() Struct_array_1_sentinel_f32 { |
| | 16337 | return .{ .a = .{1} }; |
| | 16338 | } |
| | 16339 | export fn zig_struct_array_1_sentinel_f32(s: Struct_array_1_sentinel_f32, i: usize) void { |
| | 16340 | var sentinel_index: usize = 1; |
| | 16341 | _ = &sentinel_index; |
| | 16342 | expect(s.a[0] == 2) catch @panic("test failure"); |
| | 16343 | expect(s.a[sentinel_index] == 0x1e1) catch @panic("test failure"); |
| | 16344 | expect(i == 3) catch @panic("test failure"); |
| | 16345 | } |
| | 16346 | |
| | 16347 | extern fn c_ret_struct_array_1_sentinel_f32() Struct_array_1_sentinel_f32; |
| | 16348 | extern fn c_struct_array_1_sentinel_f32(Struct_array_1_sentinel_f32, usize) void; |
| | 16349 | extern fn c_test_struct_array_1_sentinel_f32() void; |
| | 16350 | |
| | 16351 | test "struct [1:sentinel]f32" { |
| | 16352 | if (builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| | 16353 | if (builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| | 16354 | if (builtin.cpu.arch == .loongarch64 and builtin.abi.float() == .hard) return error.SkipZigTest; |
| | 16355 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16356 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16357 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 16358 | |
| | 16359 | var sentinel_index: usize = 1; |
| | 16360 | _ = &sentinel_index; |
| | 16361 | const s = c_ret_struct_array_1_sentinel_f32(); |
| | 16362 | try expect(s.a[0] == 4); |
| | 16363 | try expect(s.a[sentinel_index] == 0x1e1); |
| | 16364 | c_struct_array_1_sentinel_f32(.{ .a = .{5} }, 6); |
| | 16365 | c_test_struct_array_1_sentinel_f32(); |
| | 16366 | } |
| | 16367 | |
| | 16368 | const Struct_array_2_sentinel_f32 = extern struct { |
| | 16369 | a: [2:0x1e1]f32, |
| | 16370 | }; |
| | 16371 | |
| | 16372 | export fn zig_ret_struct_array_2_sentinel_f32() Struct_array_2_sentinel_f32 { |
| | 16373 | return .{ .a = .{ 1, 2 } }; |
| | 16374 | } |
| | 16375 | export fn zig_struct_array_2_sentinel_f32(s: Struct_array_2_sentinel_f32, i: usize) void { |
| | 16376 | var sentinel_index: usize = 2; |
| | 16377 | _ = &sentinel_index; |
| | 16378 | expect(s.a[0] == 3) catch @panic("test failure"); |
| | 16379 | expect(s.a[1] == 4) catch @panic("test failure"); |
| | 16380 | expect(s.a[sentinel_index] == 0x1e1) catch @panic("test failure"); |
| | 16381 | expect(i == 5) catch @panic("test failure"); |
| | 16382 | } |
| | 16383 | |
| | 16384 | extern fn c_ret_struct_array_2_sentinel_f32() Struct_array_2_sentinel_f32; |
| | 16385 | extern fn c_struct_array_2_sentinel_f32(Struct_array_2_sentinel_f32, usize) void; |
| | 16386 | extern fn c_test_struct_array_2_sentinel_f32() void; |
| | 16387 | |
| | 16388 | test "struct [2:sentinel]f32" { |
| | 16389 | if (builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| | 16390 | if (builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| | 16391 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| | 16392 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16393 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16394 | |
| | 16395 | var sentinel_index: usize = 2; |
| | 16396 | _ = &sentinel_index; |
| | 16397 | const s = c_ret_struct_array_2_sentinel_f32(); |
| | 16398 | try expect(s.a[0] == 6); |
| | 16399 | try expect(s.a[1] == 7); |
| | 16400 | try expect(s.a[sentinel_index] == 0x1e1); |
| | 16401 | c_struct_array_2_sentinel_f32(.{ .a = .{ 8, 9 } }, 10); |
| | 16402 | c_test_struct_array_2_sentinel_f32(); |
| | 16403 | } |
| | 16404 | |
| | 16405 | const Struct_array_3_sentinel_f32 = extern struct { |
| | 16406 | a: [3:0x1e1]f32, |
| | 16407 | }; |
| | 16408 | |
| | 16409 | export fn zig_ret_struct_array_3_sentinel_f32() Struct_array_3_sentinel_f32 { |
| | 16410 | return .{ .a = .{ 1, 2, 3 } }; |
| | 16411 | } |
| | 16412 | export fn zig_struct_array_3_sentinel_f32(s: Struct_array_3_sentinel_f32, i: usize) void { |
| | 16413 | var sentinel_index: usize = 3; |
| | 16414 | _ = &sentinel_index; |
| | 16415 | expect(s.a[0] == 4) catch @panic("test failure"); |
| | 16416 | expect(s.a[1] == 5) catch @panic("test failure"); |
| | 16417 | expect(s.a[2] == 6) catch @panic("test failure"); |
| | 16418 | expect(s.a[sentinel_index] == 0x1e1) catch @panic("test failure"); |
| | 16419 | expect(i == 7) catch @panic("test failure"); |
| | 16420 | } |
| | 16421 | |
| | 16422 | extern fn c_ret_struct_array_3_sentinel_f32() Struct_array_3_sentinel_f32; |
| | 16423 | extern fn c_struct_array_3_sentinel_f32(Struct_array_3_sentinel_f32, usize) void; |
| | 16424 | extern fn c_test_struct_array_3_sentinel_f32() void; |
| | 16425 | |
| | 16426 | test "struct [3:sentinel]f32" { |
| | 16427 | if (builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| | 16428 | if (builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| | 16429 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| | 16430 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16431 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16432 | |
| | 16433 | var sentinel_index: usize = 3; |
| | 16434 | _ = &sentinel_index; |
| | 16435 | const s = c_ret_struct_array_3_sentinel_f32(); |
| | 16436 | try expect(s.a[0] == 8); |
| | 16437 | try expect(s.a[1] == 9); |
| | 16438 | try expect(s.a[2] == 10); |
| | 16439 | try expect(s.a[sentinel_index] == 0x1e1); |
| | 16440 | c_struct_array_3_sentinel_f32(.{ .a = .{ 11, 12, 13 } }, 14); |
| | 16441 | c_test_struct_array_3_sentinel_f32(); |
| | 16442 | } |
| | 16443 | |
| | 16444 | const Struct_array_4_sentinel_f32 = extern struct { |
| | 16445 | a: [4:0x1e1]f32, |
| | 16446 | }; |
| | 16447 | |
| | 16448 | export fn zig_ret_struct_array_4_sentinel_f32() Struct_array_4_sentinel_f32 { |
| | 16449 | return .{ .a = .{ 1, 2, 3, 4 } }; |
| | 16450 | } |
| | 16451 | export fn zig_struct_array_4_sentinel_f32(s: Struct_array_4_sentinel_f32, i: usize) void { |
| | 16452 | var sentinel_index: usize = 4; |
| | 16453 | _ = &sentinel_index; |
| | 16454 | expect(s.a[0] == 5) catch @panic("test failure"); |
| | 16455 | expect(s.a[1] == 6) catch @panic("test failure"); |
| | 16456 | expect(s.a[2] == 7) catch @panic("test failure"); |
| | 16457 | expect(s.a[3] == 8) catch @panic("test failure"); |
| | 16458 | expect(s.a[sentinel_index] == 0x1e1) catch @panic("test failure"); |
| | 16459 | expect(i == 9) catch @panic("test failure"); |
| | 16460 | } |
| | 16461 | |
| | 16462 | extern fn c_ret_struct_array_4_sentinel_f32() Struct_array_4_sentinel_f32; |
| | 16463 | extern fn c_struct_array_4_sentinel_f32(Struct_array_4_sentinel_f32, usize) void; |
| | 16464 | extern fn c_test_struct_array_4_sentinel_f32() void; |
| | 16465 | |
| | 16466 | test "struct [4:sentinel]f32" { |
| | 16467 | if (builtin.cpu.arch.isArm()) return error.SkipZigTest; |
| | 16468 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| | 16469 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| | 16470 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16471 | |
| | 16472 | var sentinel_index: usize = 4; |
| | 16473 | _ = &sentinel_index; |
| | 16474 | const s = c_ret_struct_array_4_sentinel_f32(); |
| | 16475 | try expect(s.a[0] == 10); |
| | 16476 | try expect(s.a[1] == 11); |
| | 16477 | try expect(s.a[2] == 12); |
| | 16478 | try expect(s.a[3] == 13); |
| | 16479 | try expect(s.a[sentinel_index] == 0x1e1); |
| | 16480 | c_struct_array_4_sentinel_f32(.{ .a = .{ 14, 15, 16, 17 } }, 18); |
| | 16481 | c_test_struct_array_4_sentinel_f32(); |
| | 16482 | } |
| | 16483 | |
| 16281 | const Struct_f32a8 = extern struct { | 16484 | const Struct_f32a8 = extern struct { |
| 16282 | a: f32 align(8), | 16485 | a: f32 align(8), |
| 16283 | }; | 16486 | }; |
| ... | @@ -16579,20 +16782,12 @@ const Struct_array_1_f64 = extern struct { | ... | @@ -16579,20 +16782,12 @@ const Struct_array_1_f64 = extern struct { |
| 16579 | a: [1]f64, | 16782 | a: [1]f64, |
| 16580 | }; | 16783 | }; |
| 16581 | | 16784 | |
| 16582 | comptime { | 16785 | export fn zig_ret_struct_array_1_f64() Struct_array_1_f64 { |
| 16583 | skip: { | 16786 | return .{ .a = .{1} }; |
| 16584 | if (builtin.cpu.arch.isWasm()) break :skip; | 16787 | } |
| 16585 | | 16788 | export fn zig_struct_array_1_f64(s: Struct_array_1_f64, i: usize) void { |
| 16586 | _ = struct { | 16789 | expect(s.a[0] == 2) catch @panic("test failure"); |
| 16587 | export fn zig_ret_struct_array_1_f64() Struct_array_1_f64 { | 16790 | expect(i == 3) catch @panic("test failure"); |
| 16588 | return .{ .a = .{1} }; | | |
| 16589 | } | | |
| 16590 | export fn zig_struct_array_1_f64(s: Struct_array_1_f64, i: usize) void { | | |
| 16591 | expect(s.a[0] == 2) catch @panic("test failure"); | | |
| 16592 | expect(i == 3) catch @panic("test failure"); | | |
| 16593 | } | | |
| 16594 | }; | | |
| 16595 | } | | |
| 16596 | } | 16791 | } |
| 16597 | | 16792 | |
| 16598 | extern fn c_ret_struct_array_1_f64() Struct_array_1_f64; | 16793 | extern fn c_ret_struct_array_1_f64() Struct_array_1_f64; |
| ... | @@ -16605,8 +16800,6 @@ test "struct [1]f64" { | ... | @@ -16605,8 +16800,6 @@ test "struct [1]f64" { |
| 16605 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; | 16800 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 16606 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; | 16801 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| 16607 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; | 16802 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 16608 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; | | |
| 16609 | if (builtin.cpu.arch.isWasm()) return error.SkipZigTest; | | |
| 16610 | | 16803 | |
| 16611 | const s = c_ret_struct_array_1_f64(); | 16804 | const s = c_ret_struct_array_1_f64(); |
| 16612 | try expect(s.a[0] == 4); | 16805 | try expect(s.a[0] == 4); |
| ... | @@ -16750,6 +16943,36 @@ test "struct [5]f64" { | ... | @@ -16750,6 +16943,36 @@ test "struct [5]f64" { |
| 16750 | c_test_struct_array_5_f64(); | 16943 | c_test_struct_array_5_f64(); |
| 16751 | } | 16944 | } |
| 16752 | | 16945 | |
| | 16946 | const Union_f64 = extern union { |
| | 16947 | a: f64, |
| | 16948 | }; |
| | 16949 | |
| | 16950 | export fn zig_ret_union_f64() Union_f64 { |
| | 16951 | return .{ .a = 1 }; |
| | 16952 | } |
| | 16953 | export fn zig_union_f64(s: Union_f64, i: usize) void { |
| | 16954 | expect(s.a == 2) catch @panic("test failure"); |
| | 16955 | expect(i == 3) catch @panic("test failure"); |
| | 16956 | } |
| | 16957 | |
| | 16958 | extern fn c_ret_union_f64() Union_f64; |
| | 16959 | extern fn c_union_f64(Union_f64, usize) void; |
| | 16960 | extern fn c_test_union_f64() void; |
| | 16961 | |
| | 16962 | test "union f64" { |
| | 16963 | if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; |
| | 16964 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 16965 | if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; |
| | 16966 | if (builtin.cpu.arch.isRiscv32()) return error.SkipZigTest; |
| | 16967 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| | 16968 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; |
| | 16969 | |
| | 16970 | const s = c_ret_union_f64(); |
| | 16971 | try expect(s.a == 4); |
| | 16972 | c_union_f64(.{ .a = 5 }, 6); |
| | 16973 | c_test_union_f64(); |
| | 16974 | } |
| | 16975 | |
| 16753 | const Struct_u32_Union_u32_u32u32 = extern struct { | 16976 | const Struct_u32_Union_u32_u32u32 = extern struct { |
| 16754 | a: u32, | 16977 | a: u32, |
| 16755 | b: extern union { | 16978 | b: extern union { |