parent
94675c2378
commit
e1b1759439
5 changed files with 47 additions and 14 deletions
|
|
@ -153,7 +153,11 @@ proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
|
||||||
err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " &
|
err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " &
|
||||||
toFullPath(c.config, c.graph.importStack[i+1])
|
toFullPath(c.config, c.graph.importStack[i+1])
|
||||||
c.recursiveDep = err
|
c.recursiveDep = err
|
||||||
|
|
||||||
|
discard pushOptionEntry(c)
|
||||||
result = importModuleAs(c, n, c.graph.importModuleCallback(c.graph, c.module, f))
|
result = importModuleAs(c, n, c.graph.importModuleCallback(c.graph, c.module, f))
|
||||||
|
popOptionEntry(c)
|
||||||
|
|
||||||
#echo "set back to ", L
|
#echo "set back to ", L
|
||||||
c.graph.importStack.setLen(L)
|
c.graph.importStack.setLen(L)
|
||||||
# we cannot perform this check reliably because of
|
# we cannot perform this check reliably because of
|
||||||
|
|
|
||||||
|
|
@ -418,14 +418,7 @@ proc processOption(c: PContext, n: PNode, resOptions: var TOptions) =
|
||||||
proc processPush(c: PContext, n: PNode, start: int) =
|
proc processPush(c: PContext, n: PNode, start: int) =
|
||||||
if n.sons[start-1].kind in nkPragmaCallKinds:
|
if n.sons[start-1].kind in nkPragmaCallKinds:
|
||||||
localError(c.config, n.info, "'push' cannot have arguments")
|
localError(c.config, n.info, "'push' cannot have arguments")
|
||||||
var x = newOptionEntry(c.config)
|
var x = pushOptionEntry(c)
|
||||||
var y = c.optionStack[^1]
|
|
||||||
x.options = c.config.options
|
|
||||||
x.defaultCC = y.defaultCC
|
|
||||||
x.dynlib = y.dynlib
|
|
||||||
x.notes = c.config.notes
|
|
||||||
x.features = c.features
|
|
||||||
c.optionStack.add(x)
|
|
||||||
for i in start ..< len(n):
|
for i in start ..< len(n):
|
||||||
if not tryProcessOption(c, n.sons[i], c.config.options):
|
if not tryProcessOption(c, n.sons[i], c.config.options):
|
||||||
# simply store it somewhere:
|
# simply store it somewhere:
|
||||||
|
|
@ -444,10 +437,7 @@ proc processPop(c: PContext, n: PNode) =
|
||||||
if c.optionStack.len <= 1:
|
if c.optionStack.len <= 1:
|
||||||
localError(c.config, n.info, "{.pop.} without a corresponding {.push.}")
|
localError(c.config, n.info, "{.pop.} without a corresponding {.push.}")
|
||||||
else:
|
else:
|
||||||
c.config.options = c.optionStack[^1].options
|
popOptionEntry(c)
|
||||||
c.config.notes = c.optionStack[^1].notes
|
|
||||||
c.features = c.optionStack[^1].features
|
|
||||||
c.optionStack.setLen(c.optionStack.len - 1)
|
|
||||||
when defined(debugOptions):
|
when defined(debugOptions):
|
||||||
echo c.config $ n.info, " POP config is now ", c.config.options
|
echo c.config $ n.info, " POP config is now ", c.config.options
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,13 +212,28 @@ proc newOptionEntry*(conf: ConfigRef): POptionEntry =
|
||||||
result.dynlib = nil
|
result.dynlib = nil
|
||||||
result.notes = conf.notes
|
result.notes = conf.notes
|
||||||
|
|
||||||
|
proc pushOptionEntry*(c: PContext): POptionEntry =
|
||||||
|
new(result)
|
||||||
|
var prev = c.optionStack[^1]
|
||||||
|
result.options = c.config.options
|
||||||
|
result.defaultCC = prev.defaultCC
|
||||||
|
result.dynlib = prev.dynlib
|
||||||
|
result.notes = c.config.notes
|
||||||
|
result.features = c.features
|
||||||
|
c.optionStack.add(result)
|
||||||
|
|
||||||
|
proc popOptionEntry*(c: PContext) =
|
||||||
|
c.config.options = c.optionStack[^1].options
|
||||||
|
c.config.notes = c.optionStack[^1].notes
|
||||||
|
c.features = c.optionStack[^1].features
|
||||||
|
c.optionStack.setLen(c.optionStack.len - 1)
|
||||||
|
|
||||||
proc newContext*(graph: ModuleGraph; module: PSym): PContext =
|
proc newContext*(graph: ModuleGraph; module: PSym): PContext =
|
||||||
new(result)
|
new(result)
|
||||||
result.enforceVoidContext = PType(kind: tyTyped)
|
result.enforceVoidContext = PType(kind: tyTyped)
|
||||||
result.ambiguousSymbols = initIntSet()
|
result.ambiguousSymbols = initIntSet()
|
||||||
result.optionStack = @[]
|
result.optionStack = @[newOptionEntry(graph.config)]
|
||||||
result.libs = @[]
|
result.libs = @[]
|
||||||
result.optionStack.add(newOptionEntry(graph.config))
|
|
||||||
result.module = module
|
result.module = module
|
||||||
result.friendModules = @[module]
|
result.friendModules = @[module]
|
||||||
result.converters = @[]
|
result.converters = @[]
|
||||||
|
|
|
||||||
17
tests/pragmas/twarning_off.nim
Normal file
17
tests/pragmas/twarning_off.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
discard """
|
||||||
|
nimout: '''
|
||||||
|
compile start
|
||||||
|
Hint: warn_module [Processing]
|
||||||
|
Hint: hashes [Processing]
|
||||||
|
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
||||||
|
compile end
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
static:
|
||||||
|
echo "compile start"
|
||||||
|
|
||||||
|
import warn_module
|
||||||
|
|
||||||
|
static:
|
||||||
|
echo "compile end"
|
||||||
7
tests/pragmas/warn_module.nim
Normal file
7
tests/pragmas/warn_module.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
{.warning[UnusedImport]: off.}
|
||||||
|
|
||||||
|
import hashes
|
||||||
|
|
||||||
|
proc test(a: float): float =
|
||||||
|
a
|
||||||
Loading…
Add table
Add a link
Reference in a new issue