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