From 2977a316542ee71f31aaedcc38eb0494f2f5ff23 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 4 May 2020 07:43:22 +0200 Subject: [PATCH] destructors: don't produce stupid code for 'cast' (#14208) [backport:1.2] * destructors: don't produce stupid code for 'cast' * fixes #14207 (cherry picked from commit b6fb609e0d263a209c6db48dd367f13eb7f4ff87) --- compiler/dfa.nim | 4 ++-- compiler/injectdestructors.nim | 4 ++++ tests/arc/tarcmisc.nim | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 0cefec2858d1d..7db5f5f65af50 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -541,8 +541,8 @@ template genNoReturn(c: var Con; n: PNode) = c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len) proc genRaise(c: var Con; n: PNode) = - genJoins(c, n) gen(c, n[0]) + genJoins(c, n) if c.inTryStmt > 0: c.tryStmtFixups.add c.gotoI(n) else: @@ -553,11 +553,11 @@ proc genImplicitReturn(c: var Con) = gen(c, c.owner.ast[resultPos]) proc genReturn(c: var Con; n: PNode) = - genJoins(c, n) if n[0].kind != nkEmpty: gen(c, n[0]) else: genImplicitReturn(c) + genJoins(c, n) genNoReturn(c, n) const diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 29199aa415b44..5aec088aa4bda 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -910,6 +910,10 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode = for i in 0..