Skip to content

Commit

Permalink
fixes #19977; rework inlining of 'var openarray' iterators for C++ (#…
Browse files Browse the repository at this point in the history
…23258)

fixes #19977

(cherry picked from commit f7c6e04)
  • Loading branch information
ringabout authored and narimiran committed Jul 2, 2024
1 parent 3788aa0 commit 2114414
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ proc transformYield(c: PTransf, n: PNode): PNode =

proc transformAddrDeref(c: PTransf, n: PNode, kinds: TNodeKinds): PNode =
result = transformSons(c, n)
if c.graph.config.backend == backendCpp or sfCompileToCpp in c.module.flags: return
# inlining of 'var openarray' iterators; bug #19977
if n.typ.kind != tyOpenArray and (c.graph.config.backend == backendCpp or sfCompileToCpp in c.module.flags): return
var n = result
case n[0].kind
of nkObjUpConv, nkObjDownConv, nkChckRange, nkChckRangeF, nkChckRange64:
Expand Down
2 changes: 1 addition & 1 deletion tests/iter/titervaropenarray.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
output: "123"
targets: "c"
targets: "c cpp"
"""
# Try to break the transformation pass:
iterator iterAndZero(a: var openArray[int]): int =
Expand Down

0 comments on commit 2114414

Please sign in to comment.