mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 21:12:42 +00:00
Fixes discard bug in cpp codegen (#9747) [backport]
Fixes discard bug in cpp codegen
(cherry picked from commit 9b9f5dee0b)
This commit is contained in:
@@ -2394,15 +2394,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
|
||||
Reference in New Issue
Block a user