authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-01 00:44:26+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-01 02:10:18+03:00
loga73895339a3f28268873fc4c86cc0da729392b0d
treeaf2c0b3acadc151096c1492a0459a679f7d2d6e5
parentf2626a3d8ecddf48a08982ca78bff03e9d39d321

Sema: handle bitcasts produced by `coerce_result_ptr` in `validate{Array,Struct}Init`


1 files changed, 17 insertions(+), 2 deletions(-)

src/Sema.zig+17-2
......@@ -3444,7 +3444,15 @@ fn validateStructInit(
34443444 }
34453445 if (air_tags[store_inst] != .store) continue;
34463446 const bin_op = air_datas[store_inst].bin_op;
3447 if (bin_op.lhs != field_ptr_air_ref) continue;
3447 var lhs = bin_op.lhs;
3448 {
3449 const lhs_index = Air.refToIndex(lhs) orelse continue;
3450 if (air_tags[lhs_index] == .bitcast) {
3451 lhs = air_datas[lhs_index].ty_op.operand;
3452 block_index -= 1;
3453 }
3454 }
3455 if (lhs != field_ptr_air_ref) continue;
34483456 if (block_index > 0 and
34493457 field_ptr_air_inst == block.instructions.items[block_index - 1])
34503458 {
......@@ -3603,7 +3611,14 @@ fn zirValidateArrayInit(
36033611 switch (air_tags[next_air_inst]) {
36043612 .store => {
36053613 const bin_op = air_datas[next_air_inst].bin_op;
3606 if (bin_op.lhs != elem_ptr_air_ref) {
3614 var lhs = bin_op.lhs;
3615 if (Air.refToIndex(lhs)) |lhs_index| {
3616 if (air_tags[lhs_index] == .bitcast) {
3617 lhs = air_datas[lhs_index].ty_op.operand;
3618 block_index -= 1;
3619 }
3620 }
3621 if (lhs != elem_ptr_air_ref) {
36073622 array_is_comptime = false;
36083623 continue;
36093624 }