diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-11-20 00:52:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 17:52:42 +0100 |
commit | 5dafcf4957a225b1f015d131299e51735e7bb1d3 (patch) | |
tree | 8a65d81d0ac090abf2af634d63f6f7aec89e4cc9 /compiler | |
parent | 6c5283b194ec238c765c2e0a8f252db003643557 (diff) | |
download | Nim-5dafcf4957a225b1f015d131299e51735e7bb1d3.tar.gz |
fixes #22913; fixes #12985 differently push-ing pragma exportc genera… (#22941)
…tes invalid C identifiers fixes #22913 fixes #12985 differently `{.push.} now does not apply to generic instantiations`
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/pragmas.nim | 2 | ||||
-rw-r--r-- | compiler/seminst.nim | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 53b4f53a8..d4817ce7a 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -1313,7 +1313,7 @@ proc implicitPragmas*(c: PContext, sym: PSym, info: TLineInfo, if sym != nil and sym.kind != skModule: for it in c.optionStack: let o = it.otherPragmas - if not o.isNil and sfFromGeneric notin sym.flags: # see issue #12985 + if not o.isNil: pushInfoContext(c.config, info) var i = 0 while i < o.len: diff --git a/compiler/seminst.nim b/compiler/seminst.nim index dc25230c2..085769bdd 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -400,11 +400,17 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, entry.compilesId = c.compilesContextId addToGenericProcCache(c, fn, entry) c.generics.add(makeInstPair(fn, entry)) + # bug #12985 bug #22913 + # TODO: use the context of the declaration of generic functions instead + # TODO: consider fixing options as well + let otherPragmas = c.optionStack[^1].otherPragmas + c.optionStack[^1].otherPragmas = nil if n[pragmasPos].kind != nkEmpty: pragma(c, result, n[pragmasPos], allRoutinePragmas) if isNil(n[bodyPos]): n[bodyPos] = copyTree(getBody(c.graph, fn)) instantiateBody(c, n, fn.typ.n, result, fn) + c.optionStack[^1].otherPragmas = otherPragmas sideEffectsCheck(c, result) if result.magic notin {mSlice, mTypeOf}: # 'toOpenArray' is special and it is allowed to return 'openArray': |