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.
This commit is contained in:
parent
56de4c81b2
commit
6f13184e40
2 changed files with 7 additions and 4 deletions
|
|
@ -96,7 +96,9 @@ const
|
||||||
errIntLiteralExpected = "integer literal expected"
|
errIntLiteralExpected = "integer literal expected"
|
||||||
|
|
||||||
proc invalidPragma*(c: PContext; n: PNode) =
|
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 =
|
proc pragmaAsm*(c: PContext, n: PNode): char =
|
||||||
result = '\0'
|
result = '\0'
|
||||||
|
|
@ -1094,9 +1096,10 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
else: sym.flags.incl sfUsed
|
else: sym.flags.incl sfUsed
|
||||||
of wLiftLocals: discard
|
of wLiftLocals: discard
|
||||||
else: invalidPragma(c, it)
|
else: invalidPragma(c, it)
|
||||||
else:
|
elif sym.kind in {skField,skProc,skFunc,skConverter,skMethod,skType}:
|
||||||
n.sons[i] = semCustomPragma(c, it)
|
n.sons[i] = semCustomPragma(c, it)
|
||||||
|
else:
|
||||||
|
illegalCustomPragma(c, it, sym)
|
||||||
|
|
||||||
proc implicitPragmas*(c: PContext, sym: PSym, n: PNode,
|
proc implicitPragmas*(c: PContext, sym: PSym, n: PNode,
|
||||||
validPragmas: TSpecialWords) =
|
validPragmas: TSpecialWords) =
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
line: 9
|
line: 9
|
||||||
errormsg: "attempting to call undeclared routine: 'foobar'"
|
errormsg: "cannot attach a custom pragma to 'a'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for a {.gensym, inject.} in @[1,2,3]:
|
for a {.gensym, inject.} in @[1,2,3]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue