diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-07 10:56:37 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-07 10:56:37 -0400 |
| commit | e11cafbd4f11fa5eae0cbdf03854291834b4cd77 (patch) | |
| tree | 92587f54fbc5aebb46f5081e5086c76c0284cac0 /src/ir.cpp | |
| parent | f587fa1cd73c3c0382e1bd2da2e24a7473421a2c (diff) | |
| download | zig-e11cafbd4f11fa5eae0cbdf03854291834b4cd77.tar.gz zig-e11cafbd4f11fa5eae0cbdf03854291834b4cd77.zip | |
cancel works on non-pointers
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 853cf4daa1..76e8c91f39 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7845,7 +7845,7 @@ static IrInstruction *ir_gen_cancel(IrBuilder *irb, Scope *scope, AstNode *node) return irb->codegen->invalid_instruction; } - IrInstruction *operand = ir_gen_node(irb, node->data.cancel_expr.expr, scope); + IrInstruction *operand = ir_gen_node_extra(irb, node->data.cancel_expr.expr, scope, LValPtr, nullptr); if (operand == irb->codegen->invalid_instruction) return irb->codegen->invalid_instruction; @@ -24496,10 +24496,20 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, } static IrInstruction *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) { - IrInstruction *frame = instruction->frame->child; - if (type_is_invalid(frame->value.type)) + IrInstruction *frame_ptr = instruction->frame->child; + if (type_is_invalid(frame_ptr->value.type)) return ira->codegen->invalid_instruction; + IrInstruction *frame; + if (frame_ptr->value.type->id == ZigTypeIdPointer && + frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && + frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdCoroFrame) + { + frame = frame_ptr; + } else { + frame = ir_get_deref(ira, &instruction->base, frame_ptr, nullptr); + } + ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); if (type_is_invalid(casted_frame->value.type)) |
