diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-03-01 21:57:06 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-03-02 12:26:04 +0200 |
| commit | 403a1fe5d767e801b58fc706eaa54f1171ae27de (patch) | |
| tree | cba681d1d2a81d83a323b444bf1135860e4f9354 /src/type.zig | |
| parent | 58530c17364d2525655c90e97fd2cdd2937e5c19 (diff) | |
| download | zig-403a1fe5d767e801b58fc706eaa54f1171ae27de.tar.gz zig-403a1fe5d767e801b58fc706eaa54f1171ae27de.zip | |
stage2: add cast from ?*T to ?*anyopaque
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/type.zig b/src/type.zig index 6e58f7a42f..3c08ed5b63 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2168,7 +2168,14 @@ pub const Type = extern union { .mut_slice, .optional_single_const_pointer, .optional_single_mut_pointer, - => return self.cast(Payload.ElemType).?.data.abiAlignment(target), + => { + const child_type = self.cast(Payload.ElemType).?.data; + if (child_type.zigTypeTag() == .Opaque) { + return 1; + } else { + return child_type.abiAlignment(target); + } + }, .manyptr_u8, .manyptr_const_u8, @@ -2181,10 +2188,13 @@ pub const Type = extern union { const ptr_info = self.castTag(.pointer).?.data; if (ptr_info.@"align" != 0) { return ptr_info.@"align"; + } else if (ptr_info.pointee_type.zigTypeTag() == .Opaque) { + return 1; } else { return ptr_info.pointee_type.abiAlignment(target); } }, + .optional => return self.castTag(.optional).?.data.ptrAlignment(target), else => unreachable, } @@ -3235,8 +3245,9 @@ pub const Type = extern union { return child_ty; } }, - - // TODO handle optionals + .optional => ty.castTag(.optional).?.data.childType(), + .optional_single_mut_pointer => ty.castPointer().?.data, + .optional_single_const_pointer => ty.castPointer().?.data, else => unreachable, }; |
