diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-08-25 07:56:05 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-25 07:56:05 +0200 |
commit | 6f13184e40b21956f53e407888ac2730a5e5e58c (patch) | |
tree | 8197c3bf4e52d87e3716a076ae3fcb436c10d892 /compiler/pragmas.nim | |
parent | 56de4c81b271cf878502d44d8f8f46e6c082a548 (diff) | |
download | Nim-6f13184e40b21956f53e407888ac2730a5e5e58c.tar.gz |
More checks for custom pragmas placement (#8765)
We're not interested in custom pragmas attached to certain node kinds so the compiler silently ignored them.
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r-- | compiler/pragmas.nim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 66682650d..c0de1edca 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -96,7 +96,9 @@ const errIntLiteralExpected = "integer literal expected" proc invalidPragma*(c: PContext; n: PNode) = - localError(c.config, n.info, "invalid pragma: " % renderTree(n, {renderNoComments})) + localError(c.config, n.info, "invalid pragma: " & renderTree(n, {renderNoComments})) +proc illegalCustomPragma*(c: PContext, n: PNode, s: PSym) = + localError(c.config, n.info, "cannot attach a custom pragma to '" & s.name.s & "'") proc pragmaAsm*(c: PContext, n: PNode): char = result = '\0' @@ -1094,9 +1096,10 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, else: sym.flags.incl sfUsed of wLiftLocals: discard else: invalidPragma(c, it) - else: + elif sym.kind in {skField,skProc,skFunc,skConverter,skMethod,skType}: n.sons[i] = semCustomPragma(c, it) - + else: + illegalCustomPragma(c, it, sym) proc implicitPragmas*(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) = |