mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
@@ -534,7 +534,15 @@ proc initLocExpr(p: BProc, e: PNode, result: var TLoc) =
|
||||
|
||||
proc initLocExprSingleUse(p: BProc, e: PNode, result: var TLoc) =
|
||||
initLoc(result, locNone, e, OnUnknown)
|
||||
result.flags.incl lfSingleUse
|
||||
if e.kind in nkCallKinds and (e[0].kind != nkSym or e[0].sym.magic == mNone):
|
||||
# We cannot check for tfNoSideEffect here because of mutable parameters.
|
||||
discard "bug #8202; enforce evaluation order for nested calls for C++ too"
|
||||
# We may need to consider that 'f(g())' cannot be rewritten to 'tmp = g(); f(tmp)'
|
||||
# if 'tmp' lacks a move/assignment operator.
|
||||
if e[0].kind == nkSym and sfConstructor in e[0].sym.flags:
|
||||
result.flags.incl lfSingleUse
|
||||
else:
|
||||
result.flags.incl lfSingleUse
|
||||
expr(p, e, result)
|
||||
|
||||
include ccgcalls, "ccgstmts.nim"
|
||||
|
||||
18
tests/cpp/tevalorder.nim
Normal file
18
tests/cpp/tevalorder.nim
Normal file
@@ -0,0 +1,18 @@
|
||||
discard """
|
||||
output: '''0
|
||||
1
|
||||
2'''
|
||||
target: "cpp"
|
||||
"""
|
||||
|
||||
# bug #8202
|
||||
var current: int = 0
|
||||
|
||||
proc gen(): string = current.inc; $(current - 1)
|
||||
|
||||
proc allOut(a, b, c: string) =
|
||||
echo a
|
||||
echo b
|
||||
echo c
|
||||
|
||||
allOut(gen(), gen(), gen())
|
||||
Reference in New Issue
Block a user