diff options
-rw-r--r-- | compiler/ccgexprs.nim | 11 | ||||
-rw-r--r-- | tests/cpp/tcasts.nim | 12 |
2 files changed, 13 insertions, 10 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 1633dd3cc..1b70ee41b 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -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: diff --git a/tests/cpp/tcasts.nim b/tests/cpp/tcasts.nim index 24ebb8f62..d968d87db 100644 --- a/tests/cpp/tcasts.nim +++ b/tests/cpp/tcasts.nim @@ -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 \ No newline at end of file |