summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-03 21:52:24 +0200
committerGitHub <noreply@github.com>2021-09-03 21:52:24 +0200
commitcddf8ec6f684e5636a114e0e286bc6609e01f228 (patch)
treedda219b3560479c8efde6c6e90b425c1d56e51d4 /compiler/semstmts.nim
parentc2b20516d33520b1d339b447ece32ade8625fefc (diff)
downloadNim-cddf8ec6f684e5636a114e0e286bc6609e01f228.tar.gz
implements https://github.com/nim-lang/RFCs/issues/407 (#18793)
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index df0e2778b..2c5f3ba54 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -2223,7 +2223,21 @@ proc semPragmaBlock(c: PContext, n: PNode): PNode =
   checkSonsLen(n, 2, c.config)
   let pragmaList = n[0]
   pragma(c, nil, pragmaList, exprPragmas, isStatement = true)
+
+  var inUncheckedAssignSection = 0
+  for p in pragmaList:
+    if whichPragma(p) == wCast:
+      case whichPragma(p[1])
+      of wGcSafe, wNoSideEffect, wTags, wRaises:
+        discard "handled in sempass2"
+      of wUncheckedAssign:
+        inUncheckedAssignSection = 1
+      else:
+        localError(c.config, p.info, "invalid pragma block: " & $p)
+
+  inc c.inUncheckedAssignSection, inUncheckedAssignSection
   n[1] = semExpr(c, n[1])
+  dec c.inUncheckedAssignSection, inUncheckedAssignSection
   result = n
   result.typ = n[1].typ
   for i in 0..<pragmaList.len: