| author | |
| committer | |
| log | 62f54aa39cb3dca3055033a57bc4626e94061aec |
| tree | bb358aa300f71f548f3ac8847ff8130d44bed9fb |
| parent | 9213aa789b4b44711f2747e5ab053a2b1f57a15b |
which have the same number of bits and the same signedness.2 files changed, 14 insertions(+), 1 deletions(-)
src/Sema.zig+11| ... | @@ -18458,6 +18458,17 @@ fn coerceInMemoryAllowed( | ... | @@ -18458,6 +18458,17 @@ fn coerceInMemoryAllowed( |
| 18458 | if (dest_ty.eql(src_ty, target)) | 18458 | if (dest_ty.eql(src_ty, target)) |
| 18459 | return .ok; | 18459 | return .ok; |
| 18460 | 18460 | ||
| 18461 | // Differently-named integers with the same number of bits. | ||
| 18462 | if (dest_ty.zigTypeTag() == .Int and src_ty.zigTypeTag() == .Int) { | ||
| 18463 | const dest_info = dest_ty.intInfo(target); | ||
| 18464 | const src_info = src_ty.intInfo(target); | ||
| 18465 | if (dest_info.signedness == src_info.signedness and | ||
| 18466 | dest_info.bits == src_info.bits) | ||
| 18467 | { | ||
| 18468 | return .ok; | ||
| 18469 | } | ||
| 18470 | } | ||
| 18471 | |||
| 18461 | // Pointers / Pointer-like Optionals | 18472 | // Pointers / Pointer-like Optionals |
| 18462 | var dest_buf: Type.Payload.ElemType = undefined; | 18473 | var dest_buf: Type.Payload.ElemType = undefined; |
| 18463 | var src_buf: Type.Payload.ElemType = undefined; | 18474 | var src_buf: Type.Payload.ElemType = undefined; |
test/behavior/cast.zig+3-1| ... | @@ -973,7 +973,8 @@ test "variable initialization uses result locations properly with regards to the | ... | @@ -973,7 +973,8 @@ test "variable initialization uses result locations properly with regards to the |
| 973 | } | 973 | } |
| 974 | 974 | ||
| 975 | test "cast between C pointer with different but compatible types" { | 975 | test "cast between C pointer with different but compatible types" { |
| 976 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 976 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 977 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 977 | 978 | ||
| 978 | const S = struct { | 979 | const S = struct { |
| 979 | fn foo(arg: [*]c_ushort) u16 { | 980 | fn foo(arg: [*]c_ushort) u16 { |
| ... | @@ -985,6 +986,7 @@ test "cast between C pointer with different but compatible types" { | ... | @@ -985,6 +986,7 @@ test "cast between C pointer with different but compatible types" { |
| 985 | } | 986 | } |
| 986 | }; | 987 | }; |
| 987 | try S.doTheTest(); | 988 | try S.doTheTest(); |
| 989 | comptime try S.doTheTest(); | ||
| 988 | } | 990 | } |
| 989 | 991 | ||
| 990 | test "peer type resolve string lit with sentinel-terminated mutable slice" { | 992 | test "peer type resolve string lit with sentinel-terminated mutable slice" { |