mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 09:54:45 +00:00
Fix defer on explicit return of a procedure with no return values for llvm-api
This commit is contained in:
@@ -4219,6 +4219,9 @@ void lb_build_stmt(lbProcedure *p, Ast *node) {
|
||||
|
||||
if (return_count == 0) {
|
||||
// No return values
|
||||
|
||||
lb_emit_defer_stmts(p, lbDeferExit_Return, nullptr);
|
||||
|
||||
LLVMBuildRetVoid(p->builder);
|
||||
return;
|
||||
} else if (return_count == 1) {
|
||||
@@ -6906,6 +6909,10 @@ void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block) {
|
||||
while (i --> 0) {
|
||||
lbDefer d = p->defer_stmts[i];
|
||||
|
||||
isize prev_context_stack_count = p->context_stack.count;
|
||||
defer (p->context_stack.count = prev_context_stack_count);
|
||||
p->context_stack.count = d.context_stack_count;
|
||||
|
||||
if (kind == lbDeferExit_Default) {
|
||||
if (p->scope_index == d.scope_index &&
|
||||
d.scope_index > 0) { // TODO(bill): Which is correct: > 0 or > 1?
|
||||
|
||||
Reference in New Issue
Block a user