mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-27 09:43:58 +00:00
fixes #19603; some pragmas were really only supported as top level statements. Now this is enforced properly. (#19646)
(cherry picked from commit 51df9ff1c7)
This commit is contained in:
@@ -44,18 +44,21 @@ const
|
|||||||
wDiscardable, wGensym, wInject, wRaises, wEffectsOf,
|
wDiscardable, wGensym, wInject, wRaises, wEffectsOf,
|
||||||
wTags, wLocks, wGcSafe, wRequires, wEnsures}
|
wTags, wLocks, wGcSafe, wRequires, wEnsures}
|
||||||
exprPragmas* = {wLine, wLocks, wNoRewrite, wGcSafe, wNoSideEffect}
|
exprPragmas* = {wLine, wLocks, wNoRewrite, wGcSafe, wNoSideEffect}
|
||||||
stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangeChecks,
|
stmtPragmas* = {
|
||||||
wBoundChecks, wOverflowChecks, wNilChecks, wStaticBoundchecks,
|
wHint, wWarning, wError,
|
||||||
wStyleChecks, wAssertions,
|
|
||||||
wWarnings, wHints,
|
|
||||||
wLineDir, wStackTrace, wLineTrace, wOptimization, wHint, wWarning, wError,
|
|
||||||
wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop,
|
wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop,
|
||||||
wPassl, wPassc, wLocalPassc,
|
wPassl, wPassc, wLocalPassc,
|
||||||
wDeadCodeElimUnused, # deprecated, always on
|
wDeadCodeElimUnused, # deprecated, always on
|
||||||
wDeprecated,
|
wDeprecated,
|
||||||
wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll,
|
wPragma, wEmit, wUnroll,
|
||||||
wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto,
|
wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto,
|
||||||
wExperimental, wThis, wUsed, wInvariant, wAssume, wAssert}
|
wExperimental, wThis, wUsed, wInvariant, wAssume, wAssert}
|
||||||
|
stmtPragmasTopLevel* = {wChecks, wObjChecks, wFieldChecks, wRangeChecks,
|
||||||
|
wBoundChecks, wOverflowChecks, wNilChecks, wStaticBoundchecks,
|
||||||
|
wStyleChecks, wAssertions,
|
||||||
|
wWarnings, wHints,
|
||||||
|
wLineDir, wStackTrace, wLineTrace, wOptimization,
|
||||||
|
wFloatChecks, wInfChecks, wNanChecks}
|
||||||
lambdaPragmas* = {FirstCallConv..LastCallConv,
|
lambdaPragmas* = {FirstCallConv..LastCallConv,
|
||||||
wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader,
|
wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader,
|
||||||
wThread, wAsmNoStackFrame,
|
wThread, wAsmNoStackFrame,
|
||||||
|
|||||||
@@ -2786,6 +2786,12 @@ proc enumFieldSymChoice(c: PContext, n: PNode, s: PSym): PNode =
|
|||||||
onUse(info, a)
|
onUse(info, a)
|
||||||
a = nextOverloadIter(o, c, n)
|
a = nextOverloadIter(o, c, n)
|
||||||
|
|
||||||
|
proc semPragmaStmt(c: PContext; n: PNode) =
|
||||||
|
if c.p.owner.kind == skModule:
|
||||||
|
pragma(c, c.p.owner, n, stmtPragmas+stmtPragmasTopLevel, true)
|
||||||
|
else:
|
||||||
|
pragma(c, c.p.owner, n, stmtPragmas, true)
|
||||||
|
|
||||||
proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
when defined(nimCompilerStacktraceHints):
|
when defined(nimCompilerStacktraceHints):
|
||||||
setFrameMsg c.config$n.info & " " & $n.kind
|
setFrameMsg c.config$n.info & " " & $n.kind
|
||||||
@@ -3047,7 +3053,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
|||||||
of nkUsingStmt: result = semUsing(c, n)
|
of nkUsingStmt: result = semUsing(c, n)
|
||||||
of nkAsmStmt: result = semAsm(c, n)
|
of nkAsmStmt: result = semAsm(c, n)
|
||||||
of nkYieldStmt: result = semYield(c, n)
|
of nkYieldStmt: result = semYield(c, n)
|
||||||
of nkPragma: pragma(c, c.p.owner, n, stmtPragmas, true)
|
of nkPragma: semPragmaStmt(c, n)
|
||||||
of nkIteratorDef: result = semIterator(c, n)
|
of nkIteratorDef: result = semIterator(c, n)
|
||||||
of nkProcDef: result = semProc(c, n)
|
of nkProcDef: result = semProc(c, n)
|
||||||
of nkFuncDef: result = semFunc(c, n)
|
of nkFuncDef: result = semFunc(c, n)
|
||||||
|
|||||||
Reference in New Issue
Block a user