| ... | @@ -278,7 +278,7 @@ test "C ABI big struct" { | ... | @@ -278,7 +278,7 @@ test "C ABI big struct" { |
| 278 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; | 278 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 279 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 279 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 280 | | 280 | |
| 281 | var s = BigStruct{ | 281 | const s = BigStruct{ |
| 282 | .a = 1, | 282 | .a = 1, |
| 283 | .b = 2, | 283 | .b = 2, |
| 284 | .c = 3, | 284 | .c = 3, |
| ... | @@ -304,7 +304,7 @@ extern fn c_big_union(BigUnion) void; | ... | @@ -304,7 +304,7 @@ extern fn c_big_union(BigUnion) void; |
| 304 | test "C ABI big union" { | 304 | test "C ABI big union" { |
| 305 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 305 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 306 | | 306 | |
| 307 | var x = BigUnion{ | 307 | const x = BigUnion{ |
| 308 | .a = BigStruct{ | 308 | .a = BigStruct{ |
| 309 | .a = 1, | 309 | .a = 1, |
| 310 | .b = 2, | 310 | .b = 2, |
| ... | @@ -339,13 +339,13 @@ test "C ABI medium struct of ints and floats" { | ... | @@ -339,13 +339,13 @@ test "C ABI medium struct of ints and floats" { |
| 339 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 339 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 340 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 340 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 341 | | 341 | |
| 342 | var s = MedStructMixed{ | 342 | const s = MedStructMixed{ |
| 343 | .a = 1234, | 343 | .a = 1234, |
| 344 | .b = 100.0, | 344 | .b = 100.0, |
| 345 | .c = 1337.0, | 345 | .c = 1337.0, |
| 346 | }; | 346 | }; |
| 347 | c_med_struct_mixed(s); | 347 | c_med_struct_mixed(s); |
| 348 | var s2 = c_ret_med_struct_mixed(); | 348 | const s2 = c_ret_med_struct_mixed(); |
| 349 | try expect(s2.a == 1234); | 349 | try expect(s2.a == 1234); |
| 350 | try expect(s2.b == 100.0); | 350 | try expect(s2.b == 100.0); |
| 351 | try expect(s2.c == 1337.0); | 351 | try expect(s2.c == 1337.0); |
| ... | @@ -372,14 +372,14 @@ test "C ABI small struct of ints" { | ... | @@ -372,14 +372,14 @@ test "C ABI small struct of ints" { |
| 372 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 372 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 373 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 373 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 374 | | 374 | |
| 375 | var s = SmallStructInts{ | 375 | const s = SmallStructInts{ |
| 376 | .a = 1, | 376 | .a = 1, |
| 377 | .b = 2, | 377 | .b = 2, |
| 378 | .c = 3, | 378 | .c = 3, |
| 379 | .d = 4, | 379 | .d = 4, |
| 380 | }; | 380 | }; |
| 381 | c_small_struct_ints(s); | 381 | c_small_struct_ints(s); |
| 382 | var s2 = c_ret_small_struct_ints(); | 382 | const s2 = c_ret_small_struct_ints(); |
| 383 | try expect(s2.a == 1); | 383 | try expect(s2.a == 1); |
| 384 | try expect(s2.b == 2); | 384 | try expect(s2.b == 2); |
| 385 | try expect(s2.c == 3); | 385 | try expect(s2.c == 3); |
| ... | @@ -407,13 +407,13 @@ test "C ABI medium struct of ints" { | ... | @@ -407,13 +407,13 @@ test "C ABI medium struct of ints" { |
| 407 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 407 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 408 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 408 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 409 | | 409 | |
| 410 | var s = MedStructInts{ | 410 | const s = MedStructInts{ |
| 411 | .x = 1, | 411 | .x = 1, |
| 412 | .y = 2, | 412 | .y = 2, |
| 413 | .z = 3, | 413 | .z = 3, |
| 414 | }; | 414 | }; |
| 415 | c_med_struct_ints(s); | 415 | c_med_struct_ints(s); |
| 416 | var s2 = c_ret_med_struct_ints(); | 416 | const s2 = c_ret_med_struct_ints(); |
| 417 | try expect(s2.x == 1); | 417 | try expect(s2.x == 1); |
| 418 | try expect(s2.y == 2); | 418 | try expect(s2.y == 2); |
| 419 | try expect(s2.z == 3); | 419 | try expect(s2.z == 3); |
| ... | @@ -442,9 +442,9 @@ export fn zig_small_packed_struct(x: SmallPackedStruct) void { | ... | @@ -442,9 +442,9 @@ export fn zig_small_packed_struct(x: SmallPackedStruct) void { |
| 442 | } | 442 | } |
| 443 | | 443 | |
| 444 | test "C ABI small packed struct" { | 444 | test "C ABI small packed struct" { |
| 445 | var s = SmallPackedStruct{ .a = 0, .b = 1, .c = 2, .d = 3 }; | 445 | const s = SmallPackedStruct{ .a = 0, .b = 1, .c = 2, .d = 3 }; |
| 446 | c_small_packed_struct(s); | 446 | c_small_packed_struct(s); |
| 447 | var s2 = c_ret_small_packed_struct(); | 447 | const s2 = c_ret_small_packed_struct(); |
| 448 | try expect(s2.a == 0); | 448 | try expect(s2.a == 0); |
| 449 | try expect(s2.b == 1); | 449 | try expect(s2.b == 1); |
| 450 | try expect(s2.c == 2); | 450 | try expect(s2.c == 2); |
| ... | @@ -466,9 +466,9 @@ export fn zig_big_packed_struct(x: BigPackedStruct) void { | ... | @@ -466,9 +466,9 @@ export fn zig_big_packed_struct(x: BigPackedStruct) void { |
| 466 | test "C ABI big packed struct" { | 466 | test "C ABI big packed struct" { |
| 467 | if (!has_i128) return error.SkipZigTest; | 467 | if (!has_i128) return error.SkipZigTest; |
| 468 | | 468 | |
| 469 | var s = BigPackedStruct{ .a = 1, .b = 2 }; | 469 | const s = BigPackedStruct{ .a = 1, .b = 2 }; |
| 470 | c_big_packed_struct(s); | 470 | c_big_packed_struct(s); |
| 471 | var s2 = c_ret_big_packed_struct(); | 471 | const s2 = c_ret_big_packed_struct(); |
| 472 | try expect(s2.a == 1); | 472 | try expect(s2.a == 1); |
| 473 | try expect(s2.b == 2); | 473 | try expect(s2.b == 2); |
| 474 | } | 474 | } |
| ... | @@ -486,7 +486,7 @@ test "C ABI split struct of ints" { | ... | @@ -486,7 +486,7 @@ test "C ABI split struct of ints" { |
| 486 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 486 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 487 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 487 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 488 | | 488 | |
| 489 | var s = SplitStructInt{ | 489 | const s = SplitStructInt{ |
| 490 | .a = 1234, | 490 | .a = 1234, |
| 491 | .b = 100, | 491 | .b = 100, |
| 492 | .c = 1337, | 492 | .c = 1337, |
| ... | @@ -514,13 +514,13 @@ test "C ABI split struct of ints and floats" { | ... | @@ -514,13 +514,13 @@ test "C ABI split struct of ints and floats" { |
| 514 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 514 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 515 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 515 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 516 | | 516 | |
| 517 | var s = SplitStructMixed{ | 517 | const s = SplitStructMixed{ |
| 518 | .a = 1234, | 518 | .a = 1234, |
| 519 | .b = 100, | 519 | .b = 100, |
| 520 | .c = 1337.0, | 520 | .c = 1337.0, |
| 521 | }; | 521 | }; |
| 522 | c_split_struct_mixed(s); | 522 | c_split_struct_mixed(s); |
| 523 | var s2 = c_ret_split_struct_mixed(); | 523 | const s2 = c_ret_split_struct_mixed(); |
| 524 | try expect(s2.a == 1234); | 524 | try expect(s2.a == 1234); |
| 525 | try expect(s2.b == 100); | 525 | try expect(s2.b == 100); |
| 526 | try expect(s2.c == 1337.0); | 526 | try expect(s2.c == 1337.0); |
| ... | @@ -541,14 +541,14 @@ test "C ABI sret and byval together" { | ... | @@ -541,14 +541,14 @@ test "C ABI sret and byval together" { |
| 541 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; | 541 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 542 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 542 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 543 | | 543 | |
| 544 | var s = BigStruct{ | 544 | const s = BigStruct{ |
| 545 | .a = 1, | 545 | .a = 1, |
| 546 | .b = 2, | 546 | .b = 2, |
| 547 | .c = 3, | 547 | .c = 3, |
| 548 | .d = 4, | 548 | .d = 4, |
| 549 | .e = 5, | 549 | .e = 5, |
| 550 | }; | 550 | }; |
| 551 | var y = c_big_struct_both(s); | 551 | const y = c_big_struct_both(s); |
| 552 | try expect(y.a == 10); | 552 | try expect(y.a == 10); |
| 553 | try expect(y.b == 11); | 553 | try expect(y.b == 11); |
| 554 | try expect(y.c == 12); | 554 | try expect(y.c == 12); |
| ... | @@ -562,7 +562,7 @@ export fn zig_big_struct_both(x: BigStruct) BigStruct { | ... | @@ -562,7 +562,7 @@ export fn zig_big_struct_both(x: BigStruct) BigStruct { |
| 562 | expect(x.c == 32) catch @panic("test failure"); | 562 | expect(x.c == 32) catch @panic("test failure"); |
| 563 | expect(x.d == 33) catch @panic("test failure"); | 563 | expect(x.d == 33) catch @panic("test failure"); |
| 564 | expect(x.e == 34) catch @panic("test failure"); | 564 | expect(x.e == 34) catch @panic("test failure"); |
| 565 | var s = BigStruct{ | 565 | const s = BigStruct{ |
| 566 | .a = 20, | 566 | .a = 20, |
| 567 | .b = 21, | 567 | .b = 21, |
| 568 | .c = 22, | 568 | .c = 22, |
| ... | @@ -594,7 +594,7 @@ test "C ABI structs of floats as parameter" { | ... | @@ -594,7 +594,7 @@ test "C ABI structs of floats as parameter" { |
| 594 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 594 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 595 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 595 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 596 | | 596 | |
| 597 | var v3 = Vector3{ | 597 | const v3 = Vector3{ |
| 598 | .x = 3.0, | 598 | .x = 3.0, |
| 599 | .y = 6.0, | 599 | .y = 6.0, |
| 600 | .z = 12.0, | 600 | .z = 12.0, |
| ... | @@ -602,7 +602,7 @@ test "C ABI structs of floats as parameter" { | ... | @@ -602,7 +602,7 @@ test "C ABI structs of floats as parameter" { |
| 602 | c_small_struct_floats(v3); | 602 | c_small_struct_floats(v3); |
| 603 | c_small_struct_floats_extra(v3, "hello"); | 603 | c_small_struct_floats_extra(v3, "hello"); |
| 604 | | 604 | |
| 605 | var v5 = Vector5{ | 605 | const v5 = Vector5{ |
| 606 | .x = 76.0, | 606 | .x = 76.0, |
| 607 | .y = -1.0, | 607 | .y = -1.0, |
| 608 | .z = -12.0, | 608 | .z = -12.0, |
| ... | @@ -634,13 +634,13 @@ test "C ABI structs of ints as multiple parameters" { | ... | @@ -634,13 +634,13 @@ test "C ABI structs of ints as multiple parameters" { |
| 634 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 634 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 635 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; | 635 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 636 | | 636 | |
| 637 | var r1 = Rect{ | 637 | const r1 = Rect{ |
| 638 | .left = 1, | 638 | .left = 1, |
| 639 | .right = 21, | 639 | .right = 21, |
| 640 | .top = 16, | 640 | .top = 16, |
| 641 | .bottom = 4, | 641 | .bottom = 4, |
| 642 | }; | 642 | }; |
| 643 | var r2 = Rect{ | 643 | const r2 = Rect{ |
| 644 | .left = 178, | 644 | .left = 178, |
| 645 | .right = 189, | 645 | .right = 189, |
| 646 | .top = 21, | 646 | .top = 21, |
| ... | @@ -671,13 +671,13 @@ test "C ABI structs of floats as multiple parameters" { | ... | @@ -671,13 +671,13 @@ test "C ABI structs of floats as multiple parameters" { |
| 671 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; | 671 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 672 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 672 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 673 | | 673 | |
| 674 | var r1 = FloatRect{ | 674 | const r1 = FloatRect{ |
| 675 | .left = 1, | 675 | .left = 1, |
| 676 | .right = 21, | 676 | .right = 21, |
| 677 | .top = 16, | 677 | .top = 16, |
| 678 | .bottom = 4, | 678 | .bottom = 4, |
| 679 | }; | 679 | }; |
| 680 | var r2 = FloatRect{ | 680 | const r2 = FloatRect{ |
| 681 | .left = 178, | 681 | .left = 178, |
| 682 | .right = 189, | 682 | .right = 189, |
| 683 | .top = 21, | 683 | .top = 21, |
| ... | @@ -787,7 +787,7 @@ test "Struct with array as padding." { | ... | @@ -787,7 +787,7 @@ test "Struct with array as padding." { |
| 787 | | 787 | |
| 788 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); | 788 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); |
| 789 | | 789 | |
| 790 | var x = c_ret_struct_with_array(); | 790 | const x = c_ret_struct_with_array(); |
| 791 | try expect(x.a == 4); | 791 | try expect(x.a == 4); |
| 792 | try expect(x.b == 155); | 792 | try expect(x.b == 155); |
| 793 | } | 793 | } |
| ... | @@ -822,7 +822,7 @@ test "Float array like struct" { | ... | @@ -822,7 +822,7 @@ test "Float array like struct" { |
| 822 | }, | 822 | }, |
| 823 | }); | 823 | }); |
| 824 | | 824 | |
| 825 | var x = c_ret_float_array_struct(); | 825 | const x = c_ret_float_array_struct(); |
| 826 | try expect(x.origin.x == 1); | 826 | try expect(x.origin.x == 1); |
| 827 | try expect(x.origin.y == 2); | 827 | try expect(x.origin.y == 2); |
| 828 | try expect(x.size.width == 3); | 828 | try expect(x.size.width == 3); |
| ... | @@ -840,7 +840,7 @@ test "small simd vector" { | ... | @@ -840,7 +840,7 @@ test "small simd vector" { |
| 840 | | 840 | |
| 841 | c_small_vec(.{ 1, 2 }); | 841 | c_small_vec(.{ 1, 2 }); |
| 842 | | 842 | |
| 843 | var x = c_ret_small_vec(); | 843 | const x = c_ret_small_vec(); |
| 844 | try expect(x[0] == 3); | 844 | try expect(x[0] == 3); |
| 845 | try expect(x[1] == 4); | 845 | try expect(x[1] == 4); |
| 846 | } | 846 | } |
| ... | @@ -858,7 +858,7 @@ test "medium simd vector" { | ... | @@ -858,7 +858,7 @@ test "medium simd vector" { |
| 858 | | 858 | |
| 859 | c_medium_vec(.{ 1, 2, 3, 4 }); | 859 | c_medium_vec(.{ 1, 2, 3, 4 }); |
| 860 | | 860 | |
| 861 | var x = c_ret_medium_vec(); | 861 | const x = c_ret_medium_vec(); |
| 862 | try expect(x[0] == 5); | 862 | try expect(x[0] == 5); |
| 863 | try expect(x[1] == 6); | 863 | try expect(x[1] == 6); |
| 864 | try expect(x[2] == 7); | 864 | try expect(x[2] == 7); |
| ... | @@ -879,7 +879,7 @@ test "big simd vector" { | ... | @@ -879,7 +879,7 @@ test "big simd vector" { |
| 879 | | 879 | |
| 880 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); | 880 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); |
| 881 | | 881 | |
| 882 | var x = c_ret_big_vec(); | 882 | const x = c_ret_big_vec(); |
| 883 | try expect(x[0] == 9); | 883 | try expect(x[0] == 9); |
| 884 | try expect(x[1] == 10); | 884 | try expect(x[1] == 10); |
| 885 | try expect(x[2] == 11); | 885 | try expect(x[2] == 11); |
| ... | @@ -903,7 +903,7 @@ test "C ABI pointer sized float struct" { | ... | @@ -903,7 +903,7 @@ test "C ABI pointer sized float struct" { |
| 903 | | 903 | |
| 904 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); | 904 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); |
| 905 | | 905 | |
| 906 | var x = c_ret_ptr_size_float_struct(); | 906 | const x = c_ret_ptr_size_float_struct(); |
| 907 | try expect(x.x == 3); | 907 | try expect(x.x == 3); |
| 908 | try expect(x.y == 4); | 908 | try expect(x.y == 4); |
| 909 | } | 909 | } |
| ... | @@ -1102,6 +1102,7 @@ test "C function that takes byval struct called via function pointer" { | ... | @@ -1102,6 +1102,7 @@ test "C function that takes byval struct called via function pointer" { |
| 1102 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 1102 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 1103 | | 1103 | |
| 1104 | var fn_ptr = &c_func_ptr_byval; | 1104 | var fn_ptr = &c_func_ptr_byval; |
| | 1105 | _ = &fn_ptr; |
| 1105 | fn_ptr( | 1106 | fn_ptr( |
| 1106 | @as(*anyopaque, @ptrFromInt(1)), | 1107 | @as(*anyopaque, @ptrFromInt(1)), |
| 1107 | @as(*anyopaque, @ptrFromInt(2)), | 1108 | @as(*anyopaque, @ptrFromInt(2)), |
| ... | @@ -1224,7 +1225,7 @@ extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void; | ... | @@ -1224,7 +1225,7 @@ extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void; |
| 1224 | test "Stdcall ABI big union" { | 1225 | test "Stdcall ABI big union" { |
| 1225 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; | 1226 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 1226 | | 1227 | |
| 1227 | var x = BigUnion{ | 1228 | const x = BigUnion{ |
| 1228 | .a = BigStruct{ | 1229 | .a = BigStruct{ |
| 1229 | .a = 1, | 1230 | .a = 1, |
| 1230 | .b = 2, | 1231 | .b = 2, |