fixes #19977; rework inlining of 'var openarray' iterators for C++ (#23258)

fixes #19977

(cherry picked from commit f7c6e04cfb)
This commit is contained in:
ringabout
2024-01-26 19:46:39 +08:00
committed by narimiran
parent 3788aa0a99
commit 2114414099
2 changed files with 3 additions and 2 deletions

View File

@@ -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:

View File

@@ -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 =