summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-08-21 15:07:44 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-21 15:07:44 +0200
commitcf20c4460c5b495a97b3f1f1d091f77832b89384 (patch)
tree3b47a9728d6acbce68ca360ffe203f05f0074914 /compiler/pragmas.nim
parentbbe5e8326b9f307e857b28d4b27fe9b1ec6a08c0 (diff)
downloadNim-cf20c4460c5b495a97b3f1f1d091f77832b89384.tar.gz
More robust handling of deprecated pragmas (#8696)
Prevent `deprecated` annotations to "slip" up to the parent module and
warn about unsupported annotations.

Accidentally fixes #7867
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r--compiler/pragmas.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index a067f2074..263068344 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -868,11 +868,17 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
       of wExplain:
         sym.flags.incl sfExplain
       of wDeprecated:
-        if sym != nil and sym.kind in routineKinds:
+        if sym != nil and sym.kind in routineKinds + {skType}:
           if it.kind in nkPragmaCallKinds: discard getStrLitNode(c, it)
           incl(sym.flags, sfDeprecated)
+        elif sym != nil and sym.kind != skModule:
+          # We don't support the extra annotation field
+          if it.kind in nkPragmaCallKinds:
+            localError(c.config, it.info, "annotation to deprecated not supported here")
+          incl(sym.flags, sfDeprecated)
+        # At this point we're quite sure this is a statement and applies to the
+        # whole module
         elif it.kind in nkPragmaCallKinds: deprecatedStmt(c, it)
-        elif sym != nil: incl(sym.flags, sfDeprecated)
         else: incl(c.module.flags, sfDeprecated)
       of wVarargs:
         noVal(c, it)