summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-05-16 22:07:44 +0200
committerAraq <rumpf_a@web.de>2017-05-16 22:07:44 +0200
commitac3e7edfe43a6353da286fa9606319efaf8d60d3 (patch)
tree601b884c34ef5d3bccabd721c91d32e9c427fd93 /compiler/semstmts.nim
parent0f2648c56dec3681bb6e3b0d53c8a75f901c6b96 (diff)
downloadNim-ac3e7edfe43a6353da286fa9606319efaf8d60d3.tar.gz
weaken the rules for proc definition pragmas that have been forwarded
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index c7f27f0a2..3d70e7295 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1325,8 +1325,16 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
       implicitPragmas(c, s, n, validPragmas)
   else:
     if n.sons[pragmasPos].kind != nkEmpty:
-      localError(n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProcX,
-        "'" & proto.name.s & "' from " & $proto.info)
+      pragma(c, s, n.sons[pragmasPos], validPragmas)
+      # To ease macro generation that produce forwarded .async procs we now
+      # allow a bit redudancy in the pragma declarations. The rule is
+      # a prototype's pragma list must be a superset of the current pragma
+      # list.
+      # XXX This needs more checks eventually, for example that external
+      # linking names do agree:
+      if proto.typ.callConv != s.typ.callConv or proto.typ.flags < s.typ.flags:
+        localError(n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProcX,
+          "'" & proto.name.s & "' from " & $proto.info)
     if sfForward notin proto.flags:
       wrongRedefinition(n.info, proto.name.s)
     excl(proto.flags, sfForward)