| author | |
| committer | |
| log | f4fa32a63219917e8fb26f43cbd2d97b17e0aeee |
| tree | 6d5e038f63591104b437c663e86c6ef3a7d6c6a6 |
| parent | 1678825c1450b29a1016bba62511388b3e539cd8 |
3 files changed, 7 insertions(+), 12 deletions(-)
src/Sema.zig+6-1| ... | @@ -9651,6 +9651,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9651,6 +9651,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9651 | }, | 9651 | }, |
| 9652 | .Pointer => { | 9652 | .Pointer => { |
| 9653 | const info = ty.ptrInfo().data; | 9653 | const info = ty.ptrInfo().data; |
| 9654 | const alignment = if (info.@"align" != 0) | ||
| 9655 | info.@"align" | ||
| 9656 | else | ||
| 9657 | info.pointee_type.abiAlignment(target); | ||
| 9658 | |||
| 9654 | const field_values = try sema.arena.alloc(Value, 8); | 9659 | const field_values = try sema.arena.alloc(Value, 8); |
| 9655 | // size: Size, | 9660 | // size: Size, |
| 9656 | field_values[0] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.size)); | 9661 | field_values[0] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.size)); |
| ... | @@ -9659,7 +9664,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9659,7 +9664,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9659 | // is_volatile: bool, | 9664 | // is_volatile: bool, |
| 9660 | field_values[2] = if (info.@"volatile") Value.@"true" else Value.@"false"; | 9665 | field_values[2] = if (info.@"volatile") Value.@"true" else Value.@"false"; |
| 9661 | // alignment: comptime_int, | 9666 | // alignment: comptime_int, |
| 9662 | field_values[3] = try Value.Tag.int_u64.create(sema.arena, info.@"align"); | 9667 | field_values[3] = try Value.Tag.int_u64.create(sema.arena, alignment); |
| 9663 | // address_space: AddressSpace | 9668 | // address_space: AddressSpace |
| 9664 | field_values[4] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.@"addrspace")); | 9669 | field_values[4] = try Value.Tag.enum_field_index.create(sema.arena, @enumToInt(info.@"addrspace")); |
| 9665 | // child: type, | 9670 | // child: type, |
src/type.zig+1-1| ... | @@ -4687,7 +4687,7 @@ pub const Type = extern union { | ... | @@ -4687,7 +4687,7 @@ pub const Type = extern union { |
| 4687 | pub const Data = struct { | 4687 | pub const Data = struct { |
| 4688 | pointee_type: Type, | 4688 | pointee_type: Type, |
| 4689 | sentinel: ?Value = null, | 4689 | sentinel: ?Value = null, |
| 4690 | /// If zero use pointee_type.AbiAlign() | 4690 | /// If zero use pointee_type.abiAlignment() |
| 4691 | @"align": u32 = 0, | 4691 | @"align": u32 = 0, |
| 4692 | /// See src/target.zig defaultAddressSpace function for how to obtain | 4692 | /// See src/target.zig defaultAddressSpace function for how to obtain |
| 4693 | /// an appropriate value for this field. | 4693 | /// an appropriate value for this field. |
test/behavior/type_info.zig-10| ... | @@ -71,8 +71,6 @@ fn testBasic() !void { | ... | @@ -71,8 +71,6 @@ fn testBasic() !void { |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | test "type info: pointer type info" { | 73 | test "type info: pointer type info" { |
| 74 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 75 | |||
| 76 | try testPointer(); | 74 | try testPointer(); |
| 77 | comptime try testPointer(); | 75 | comptime try testPointer(); |
| 78 | } | 76 | } |
| ... | @@ -89,8 +87,6 @@ fn testPointer() !void { | ... | @@ -89,8 +87,6 @@ fn testPointer() !void { |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | test "type info: unknown length pointer type info" { | 89 | test "type info: unknown length pointer type info" { |
| 92 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 93 | |||
| 94 | try testUnknownLenPtr(); | 90 | try testUnknownLenPtr(); |
| 95 | comptime try testUnknownLenPtr(); | 91 | comptime try testUnknownLenPtr(); |
| 96 | } | 92 | } |
| ... | @@ -125,8 +121,6 @@ fn testNullTerminatedPtr() !void { | ... | @@ -125,8 +121,6 @@ fn testNullTerminatedPtr() !void { |
| 125 | } | 121 | } |
| 126 | 122 | ||
| 127 | test "type info: slice type info" { | 123 | test "type info: slice type info" { |
| 128 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 129 | |||
| 130 | try testSlice(); | 124 | try testSlice(); |
| 131 | comptime try testSlice(); | 125 | comptime try testSlice(); |
| 132 | } | 126 | } |
| ... | @@ -306,8 +300,6 @@ const TestStruct = packed struct { | ... | @@ -306,8 +300,6 @@ const TestStruct = packed struct { |
| 306 | }; | 300 | }; |
| 307 | 301 | ||
| 308 | test "type info: opaque info" { | 302 | test "type info: opaque info" { |
| 309 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 310 | |||
| 311 | try testOpaque(); | 303 | try testOpaque(); |
| 312 | comptime try testOpaque(); | 304 | comptime try testOpaque(); |
| 313 | } | 305 | } |
| ... | @@ -417,8 +409,6 @@ test "type info: TypeId -> TypeInfo impl cast" { | ... | @@ -417,8 +409,6 @@ test "type info: TypeId -> TypeInfo impl cast" { |
| 417 | } | 409 | } |
| 418 | 410 | ||
| 419 | test "sentinel of opaque pointer type" { | 411 | test "sentinel of opaque pointer type" { |
| 420 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 421 | |||
| 422 | const c_void_info = @typeInfo(*anyopaque); | 412 | const c_void_info = @typeInfo(*anyopaque); |
| 423 | try expect(c_void_info.Pointer.sentinel == null); | 413 | try expect(c_void_info.Pointer.sentinel == null); |
| 424 | } | 414 | } |