| author | |
| committer | |
| log | 64563e2fffd0e304019c343a32f31c925be20ea2 |
| tree | 10e996625fab88c9a6231616e7ec1a6b5fb9e647 |
| parent | bed99e1ecd6c919f4c8a974e598302773db10b8a |
| signature |
10 files changed, 38 insertions(+), 0 deletions(-)
test/behavior/align.zig+2| ... | @@ -561,6 +561,8 @@ test "function pointer @intFromPtr/@ptrFromInt roundtrip" { | ... | @@ -561,6 +561,8 @@ test "function pointer @intFromPtr/@ptrFromInt roundtrip" { |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | test "function pointer align mask" { | 563 | test "function pointer align mask" { |
| 564 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 565 | |||
| 564 | const int = if (builtin.cpu.arch.isArm() or builtin.cpu.arch.isMIPS()) 0x20202021 else 0x20202020; | 566 | const int = if (builtin.cpu.arch.isArm() or builtin.cpu.arch.isMIPS()) 0x20202021 else 0x20202020; |
| 565 | const unaligned: *const fn () callconv(.c) void = @ptrFromInt(int); | 567 | const unaligned: *const fn () callconv(.c) void = @ptrFromInt(int); |
| 566 | const aligned: *align(16) const fn () callconv(.c) void = @alignCast(unaligned); | 568 | const aligned: *align(16) const fn () callconv(.c) void = @alignCast(unaligned); |
test/behavior/array.zig+2| ... | @@ -1088,6 +1088,8 @@ test "pass pointer to empty array initializer to anytype parameter" { | ... | @@ -1088,6 +1088,8 @@ test "pass pointer to empty array initializer to anytype parameter" { |
| 1088 | } | 1088 | } |
| 1089 | 1089 | ||
| 1090 | test "initialize pointer to anyopaque with reference to empty array initializer" { | 1090 | test "initialize pointer to anyopaque with reference to empty array initializer" { |
| 1091 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1092 | |||
| 1091 | const ptr: *const anyopaque = &.{}; | 1093 | const ptr: *const anyopaque = &.{}; |
| 1092 | // The above acts like an untyped initializer, since the `.{}` has no result type. | 1094 | // The above acts like an untyped initializer, since the `.{}` has no result type. |
| 1093 | // So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`). | 1095 | // So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`). |
test/behavior/cast.zig+10| ... | @@ -9,6 +9,8 @@ const maxInt = std.math.maxInt; | ... | @@ -9,6 +9,8 @@ const maxInt = std.math.maxInt; |
| 9 | const native_endian = builtin.target.cpu.arch.endian(); | 9 | const native_endian = builtin.target.cpu.arch.endian(); |
| 10 | 10 | ||
| 11 | test "int to ptr cast" { | 11 | test "int to ptr cast" { |
| 12 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 13 | |||
| 12 | const x = @as(usize, 13); | 14 | const x = @as(usize, 13); |
| 13 | const y = @as(*u8, @ptrFromInt(x)); | 15 | const y = @as(*u8, @ptrFromInt(x)); |
| 14 | const z = @intFromPtr(y); | 16 | const z = @intFromPtr(y); |
| ... | @@ -16,6 +18,8 @@ test "int to ptr cast" { | ... | @@ -16,6 +18,8 @@ test "int to ptr cast" { |
| 16 | } | 18 | } |
| 17 | 19 | ||
| 18 | test "integer literal to pointer cast" { | 20 | test "integer literal to pointer cast" { |
| 21 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 22 | |||
| 19 | const vga_mem = @as(*u16, @ptrFromInt(0xB8000)); | 23 | const vga_mem = @as(*u16, @ptrFromInt(0xB8000)); |
| 20 | try expect(@intFromPtr(vga_mem) == 0xB8000); | 24 | try expect(@intFromPtr(vga_mem) == 0xB8000); |
| 21 | } | 25 | } |
| ... | @@ -269,6 +273,8 @@ test "implicit cast from *[N]T to [*c]T" { | ... | @@ -269,6 +273,8 @@ test "implicit cast from *[N]T to [*c]T" { |
| 269 | } | 273 | } |
| 270 | 274 | ||
| 271 | test "*usize to *void" { | 275 | test "*usize to *void" { |
| 276 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 277 | |||
| 272 | var i = @as(usize, 0); | 278 | var i = @as(usize, 0); |
| 273 | const v: *void = @ptrCast(&i); | 279 | const v: *void = @ptrCast(&i); |
| 274 | v.* = {}; | 280 | v.* = {}; |
| ... | @@ -1481,6 +1487,8 @@ test "coerce between pointers of compatible differently-named floats" { | ... | @@ -1481,6 +1487,8 @@ test "coerce between pointers of compatible differently-named floats" { |
| 1481 | } | 1487 | } |
| 1482 | 1488 | ||
| 1483 | test "peer type resolution of const and non-const pointer to array" { | 1489 | test "peer type resolution of const and non-const pointer to array" { |
| 1490 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1491 | |||
| 1484 | const a = @as(*[1024]u8, @ptrFromInt(42)); | 1492 | const a = @as(*[1024]u8, @ptrFromInt(42)); |
| 1485 | const b = @as(*const [1024]u8, @ptrFromInt(42)); | 1493 | const b = @as(*const [1024]u8, @ptrFromInt(42)); |
| 1486 | try std.testing.expect(@TypeOf(a, b) == *const [1024]u8); | 1494 | try std.testing.expect(@TypeOf(a, b) == *const [1024]u8); |
| ... | @@ -1543,6 +1551,8 @@ test "optional pointer coerced to optional allowzero pointer" { | ... | @@ -1543,6 +1551,8 @@ test "optional pointer coerced to optional allowzero pointer" { |
| 1543 | } | 1551 | } |
| 1544 | 1552 | ||
| 1545 | test "optional slice coerced to allowzero many pointer" { | 1553 | test "optional slice coerced to allowzero many pointer" { |
| 1554 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1555 | |||
| 1546 | const a: ?[]const u32 = null; | 1556 | const a: ?[]const u32 = null; |
| 1547 | const b: [*]allowzero const u8 = @ptrCast(a); | 1557 | const b: [*]allowzero const u8 = @ptrCast(a); |
| 1548 | const c = @intFromPtr(b); | 1558 | const c = @intFromPtr(b); |
test/behavior/comptime_memory.zig+6| ... | @@ -406,6 +406,8 @@ test "mutate entire slice at comptime" { | ... | @@ -406,6 +406,8 @@ test "mutate entire slice at comptime" { |
| 406 | } | 406 | } |
| 407 | 407 | ||
| 408 | test "dereference undefined pointer to zero-bit type" { | 408 | test "dereference undefined pointer to zero-bit type" { |
| 409 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 410 | |||
| 409 | const p0: *void = undefined; | 411 | const p0: *void = undefined; |
| 410 | try testing.expectEqual({}, p0.*); | 412 | try testing.expectEqual({}, p0.*); |
| 411 | 413 | ||
| ... | @@ -421,6 +423,8 @@ test "type pun extern struct" { | ... | @@ -421,6 +423,8 @@ test "type pun extern struct" { |
| 421 | } | 423 | } |
| 422 | 424 | ||
| 423 | test "type pun @ptrFromInt" { | 425 | test "type pun @ptrFromInt" { |
| 426 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 427 | |||
| 424 | const p: *u8 = @ptrFromInt(42); | 428 | const p: *u8 = @ptrFromInt(42); |
| 425 | // note that expectEqual hides the bug | 429 | // note that expectEqual hides the bug |
| 426 | try testing.expect(@as(*const [*]u8, @ptrCast(&p)).* == @as([*]u8, @ptrFromInt(42))); | 430 | try testing.expect(@as(*const [*]u8, @ptrCast(&p)).* == @as([*]u8, @ptrFromInt(42))); |
| ... | @@ -511,6 +515,8 @@ fn fieldPtrTest() u32 { | ... | @@ -511,6 +515,8 @@ fn fieldPtrTest() u32 { |
| 511 | return a.value; | 515 | return a.value; |
| 512 | } | 516 | } |
| 513 | test "pointer in aggregate field can mutate comptime state" { | 517 | test "pointer in aggregate field can mutate comptime state" { |
| 518 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 519 | |||
| 514 | try comptime std.testing.expect(fieldPtrTest() == 2); | 520 | try comptime std.testing.expect(fieldPtrTest() == 2); |
| 515 | } | 521 | } |
| 516 | 522 |
test/behavior/generics.zig+1| ... | @@ -169,6 +169,7 @@ test "generic fn keeps non-generic parameter types" { | ... | @@ -169,6 +169,7 @@ test "generic fn keeps non-generic parameter types" { |
| 169 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 169 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 170 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 170 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 171 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | 171 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 172 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 172 | 173 | ||
| 173 | const A = 128; | 174 | const A = 128; |
| 174 | 175 |
test/behavior/pointers.zig+8| ... | @@ -267,6 +267,8 @@ test "implicit cast error unions with non-optional to optional pointer" { | ... | @@ -267,6 +267,8 @@ test "implicit cast error unions with non-optional to optional pointer" { |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | test "compare equality of optional and non-optional pointer" { | 269 | test "compare equality of optional and non-optional pointer" { |
| 270 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 271 | |||
| 270 | const a = @as(*const usize, @ptrFromInt(0x12345678)); | 272 | const a = @as(*const usize, @ptrFromInt(0x12345678)); |
| 271 | const b = @as(?*usize, @ptrFromInt(0x12345678)); | 273 | const b = @as(?*usize, @ptrFromInt(0x12345678)); |
| 272 | try expect(a == b); | 274 | try expect(a == b); |
| ... | @@ -453,6 +455,8 @@ test "pointer sentinel with +inf" { | ... | @@ -453,6 +455,8 @@ test "pointer sentinel with +inf" { |
| 453 | } | 455 | } |
| 454 | 456 | ||
| 455 | test "pointer to array at fixed address" { | 457 | test "pointer to array at fixed address" { |
| 458 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 459 | |||
| 456 | const array = @as(*volatile [2]u32, @ptrFromInt(0x10)); | 460 | const array = @as(*volatile [2]u32, @ptrFromInt(0x10)); |
| 457 | // Silly check just to reference `array` | 461 | // Silly check just to reference `array` |
| 458 | try expect(@intFromPtr(&array[0]) == 0x10); | 462 | try expect(@intFromPtr(&array[0]) == 0x10); |
| ... | @@ -494,6 +498,8 @@ test "pointer-integer arithmetic affects the alignment" { | ... | @@ -494,6 +498,8 @@ test "pointer-integer arithmetic affects the alignment" { |
| 494 | } | 498 | } |
| 495 | 499 | ||
| 496 | test "@intFromPtr on null optional at comptime" { | 500 | test "@intFromPtr on null optional at comptime" { |
| 501 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 502 | |||
| 497 | { | 503 | { |
| 498 | const pointer = @as(?*u8, @ptrFromInt(0x000)); | 504 | const pointer = @as(?*u8, @ptrFromInt(0x000)); |
| 499 | const x = @intFromPtr(pointer); | 505 | const x = @intFromPtr(pointer); |
| ... | @@ -704,6 +710,8 @@ test "pointer-to-array constness for zero-size elements, const" { | ... | @@ -704,6 +710,8 @@ test "pointer-to-array constness for zero-size elements, const" { |
| 704 | } | 710 | } |
| 705 | 711 | ||
| 706 | test "cast pointers with zero sized elements" { | 712 | test "cast pointers with zero sized elements" { |
| 713 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 714 | |||
| 707 | const a: *void = undefined; | 715 | const a: *void = undefined; |
| 708 | const b: *[1]void = a; | 716 | const b: *[1]void = a; |
| 709 | _ = b; | 717 | _ = b; |
test/behavior/ptrfromint.zig+1| ... | @@ -44,6 +44,7 @@ test "@ptrFromInt creates null pointer" { | ... | @@ -44,6 +44,7 @@ test "@ptrFromInt creates null pointer" { |
| 44 | test "@ptrFromInt creates allowzero zero pointer" { | 44 | test "@ptrFromInt creates allowzero zero pointer" { |
| 45 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 45 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 46 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 46 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 47 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 47 | 48 | ||
| 48 | const ptr = @as(*allowzero u32, @ptrFromInt(0)); | 49 | const ptr = @as(*allowzero u32, @ptrFromInt(0)); |
| 49 | try expectEqual(@as(usize, 0), @intFromPtr(ptr)); | 50 | try expectEqual(@as(usize, 0), @intFromPtr(ptr)); |
test/behavior/slice.zig+2| ... | @@ -238,6 +238,8 @@ test "slicing pointer by length" { | ... | @@ -238,6 +238,8 @@ test "slicing pointer by length" { |
| 238 | const x = @as([*]i32, @ptrFromInt(0x1000))[0..0x500]; | 238 | const x = @as([*]i32, @ptrFromInt(0x1000))[0..0x500]; |
| 239 | const y = x[0x100..]; | 239 | const y = x[0x100..]; |
| 240 | test "compile time slice of pointer to hard coded address" { | 240 | test "compile time slice of pointer to hard coded address" { |
| 241 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 242 | |||
| 241 | try expect(@intFromPtr(x) == 0x1000); | 243 | try expect(@intFromPtr(x) == 0x1000); |
| 242 | try expect(x.len == 0x500); | 244 | try expect(x.len == 0x500); |
| 243 | 245 |
test/behavior/struct.zig+4| ... | @@ -1347,6 +1347,8 @@ test "struct field has a pointer to an aligned version of itself" { | ... | @@ -1347,6 +1347,8 @@ test "struct field has a pointer to an aligned version of itself" { |
| 1347 | } | 1347 | } |
| 1348 | 1348 | ||
| 1349 | test "struct has only one reference" { | 1349 | test "struct has only one reference" { |
| 1350 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1351 | |||
| 1350 | const S = struct { | 1352 | const S = struct { |
| 1351 | fn optionalStructParam(_: ?struct { x: u8 }) void {} | 1353 | fn optionalStructParam(_: ?struct { x: u8 }) void {} |
| 1352 | fn errorUnionStructParam(_: error{}!struct { x: u8 }) void {} | 1354 | fn errorUnionStructParam(_: error{}!struct { x: u8 }) void {} |
| ... | @@ -1553,6 +1555,7 @@ test "struct field pointer has correct alignment" { | ... | @@ -1553,6 +1555,7 @@ test "struct field pointer has correct alignment" { |
| 1553 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 1555 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 1554 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1556 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1555 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1557 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1558 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1556 | 1559 | ||
| 1557 | const S = struct { | 1560 | const S = struct { |
| 1558 | fn doTheTest() !void { | 1561 | fn doTheTest() !void { |
| ... | @@ -1582,6 +1585,7 @@ test "extern struct field pointer has correct alignment" { | ... | @@ -1582,6 +1585,7 @@ test "extern struct field pointer has correct alignment" { |
| 1582 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 1585 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 1583 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1586 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1584 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1587 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1588 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1585 | 1589 | ||
| 1586 | const S = struct { | 1590 | const S = struct { |
| 1587 | fn doTheTest() !void { | 1591 | fn doTheTest() !void { |
test/behavior/union.zig+2| ... | @@ -1481,6 +1481,7 @@ test "defined-layout union field pointer has correct alignment" { | ... | @@ -1481,6 +1481,7 @@ test "defined-layout union field pointer has correct alignment" { |
| 1481 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 1481 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 1482 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1482 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1483 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1483 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1484 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1484 | 1485 | ||
| 1485 | const S = struct { | 1486 | const S = struct { |
| 1486 | fn doTheTest(comptime U: type) !void { | 1487 | fn doTheTest(comptime U: type) !void { |
| ... | @@ -1515,6 +1516,7 @@ test "undefined-layout union field pointer has correct alignment" { | ... | @@ -1515,6 +1516,7 @@ test "undefined-layout union field pointer has correct alignment" { |
| 1515 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 1516 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 1516 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1517 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1517 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1518 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1519 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 1518 | 1520 | ||
| 1519 | const S = struct { | 1521 | const S = struct { |
| 1520 | fn doTheTest(comptime U: type) !void { | 1522 | fn doTheTest(comptime U: type) !void { |