Fixes discard bug in cpp codegen (#9747) [backport]
Fixes discard bug in cpp codegen
This commit is contained in:
parent
ebcf9406be
commit
9b9f5dee0b
2 changed files with 13 additions and 10 deletions
|
|
@ -2441,15 +2441,8 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
|
|||
if ex.kind != nkEmpty:
|
||||
genLineDir(p, n)
|
||||
var a: TLoc
|
||||
if ex.kind in nkCallKinds and (ex[0].kind != nkSym or
|
||||
ex[0].sym.magic == mNone):
|
||||
# bug #6037: do not assign to a temp in C++ mode:
|
||||
incl a.flags, lfSingleUse
|
||||
genCall(p, ex, a)
|
||||
if lfSingleUse notin a.flags:
|
||||
line(p, cpsStmts, a.r & ";\L")
|
||||
else:
|
||||
initLocExpr(p, ex, a)
|
||||
initLocExprSingleUse(p, ex, a)
|
||||
line(p, cpsStmts, "(void)(" & a.r & ");\L")
|
||||
of nkAsmStmt: genAsmStmt(p, n)
|
||||
of nkTryStmt:
|
||||
if p.module.compileToCpp and optNoCppExceptions notin p.config.globalOptions:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
discard """
|
||||
cmd: "nim cpp $file"
|
||||
output: ""
|
||||
output: '''{"vas": "kas", "123": "123"}'''
|
||||
targets: "cpp"
|
||||
"""
|
||||
|
||||
|
|
@ -9,3 +9,13 @@ block: #5979
|
|||
var p: pointer = cast[pointer](a)
|
||||
var c = cast[char](p)
|
||||
doAssert(c == 'a')
|
||||
|
||||
|
||||
#----------------------------------------------------
|
||||
# bug #9739
|
||||
import tables
|
||||
|
||||
var t = initTable[string, string]()
|
||||
discard t.hasKeyOrPut("123", "123")
|
||||
discard t.mgetOrPut("vas", "kas")
|
||||
echo t
|
||||
Loading…
Add table
Add a link
Reference in a new issue