summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-06-22 14:11:13 +0200
committerGitHub <noreply@github.com>2020-06-22 14:11:13 +0200
commit451129de4213805b74b1635565d998904d705458 (patch)
tree539b5d215873f99e2e628c178599be042a03209f /compiler
parent8df20276c9e7f714aacfad7b20f9308233f6bfdd (diff)
downloadNim-451129de4213805b74b1635565d998904d705458.tar.gz
fixes #14240 [backport:1.2] (#14757)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgstmts.nim17
-rw-r--r--compiler/cgen.nim1
-rw-r--r--compiler/cgendata.nim3
3 files changed, 12 insertions, 9 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim
index ca6e51f29..82f1caadc 100644
--- a/compiler/ccgstmts.nim
+++ b/compiler/ccgstmts.nim
@@ -688,14 +688,15 @@ proc genBreakStmt(p: BProc, t: PNode) =
 
 proc raiseExit(p: BProc) =
   assert p.config.exc == excGoto
-  p.flags.incl nimErrorFlagAccessed
-  if p.nestedTryStmts.len == 0:
-    p.flags.incl beforeRetNeeded
-    # easy case, simply goto 'ret':
-    lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", [])
-  else:
-    lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
-      [p.nestedTryStmts[^1].label])
+  if nimErrorFlagDisabled notin p.flags:
+    p.flags.incl nimErrorFlagAccessed
+    if p.nestedTryStmts.len == 0:
+      p.flags.incl beforeRetNeeded
+      # easy case, simply goto 'ret':
+      lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;$n", [])
+    else:
+      lineCg(p, cpsStmts, "if (NIM_UNLIKELY(*nimErr_)) goto LA$1_;$n",
+        [p.nestedTryStmts[^1].label])
 
 proc finallyActions(p: BProc) =
   if p.config.exc != excGoto and p.nestedTryStmts.len > 0 and p.nestedTryStmts[^1].inExcept:
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 417acf178..cd02ba9b1 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -682,6 +682,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) =
     else:
       var p = newProc(nil, m)
       p.options = p.options - {optStackTrace}
+      p.flags.incl nimErrorFlagDisabled
       var dest: TLoc
       initLoc(dest, locTemp, lib.path, OnStack)
       dest.r = getTempName(m)
diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim
index 96e382873..ce74963e2 100644
--- a/compiler/cgendata.nim
+++ b/compiler/cgendata.nim
@@ -70,7 +70,8 @@ type
     hasCurFramePointer,
     noSafePoints,
     nimErrorFlagAccessed,
-    nimErrorFlagDeclared
+    nimErrorFlagDeclared,
+    nimErrorFlagDisabled
 
   TCProc = object             # represents C proc that is currently generated
     prc*: PSym                # the Nim proc that this C proc belongs to