effects: exclude swap() from "indirect calls" assumption (#15504)
swap() will never call any procs passed to it, and so it can be safely excluded from the "assume indirect calls are taken" effects tracking rule.
This commit is contained in:
parent
695f955f70
commit
fa84121421
2 changed files with 13 additions and 1 deletions
|
|
@ -552,7 +552,7 @@ proc isNoEffectList(n: PNode): bool {.inline.} =
|
||||||
n.len == 0 or (n[tagEffects] == nil and n[exceptionEffects] == nil)
|
n.len == 0 or (n[tagEffects] == nil and n[exceptionEffects] == nil)
|
||||||
|
|
||||||
proc isTrival(caller: PNode): bool {.inline.} =
|
proc isTrival(caller: PNode): bool {.inline.} =
|
||||||
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved}
|
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved, mSwap}
|
||||||
|
|
||||||
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) =
|
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) =
|
||||||
let a = skipConvAndClosure(n)
|
let a = skipConvAndClosure(n)
|
||||||
|
|
|
||||||
12
tests/effects/teffects10.nim
Normal file
12
tests/effects/teffects10.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
action: compile
|
||||||
|
"""
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/issues/15495
|
||||||
|
|
||||||
|
proc f() {.raises: [].} =
|
||||||
|
var a: proc ()
|
||||||
|
var b: proc ()
|
||||||
|
swap(a, b)
|
||||||
|
|
||||||
|
f()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue