parent
767524d62a
commit
da1293c405
2 changed files with 28 additions and 2 deletions
|
|
@ -30,7 +30,7 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
|
||||||
if d.k in {locTemp, locNone} or not leftAppearsOnRightSide(le, ri):
|
if d.k in {locTemp, locNone} or not leftAppearsOnRightSide(le, ri):
|
||||||
# Great, we can use 'd':
|
# Great, we can use 'd':
|
||||||
if d.k == locNone: getTemp(p, typ.sons[0], d, needsInit=true)
|
if d.k == locNone: getTemp(p, typ.sons[0], d, needsInit=true)
|
||||||
elif d.k notin {locExpr, locTemp} and not hasNoInit(ri):
|
elif d.k notin {locTemp} and not hasNoInit(ri):
|
||||||
# reset before pass as 'result' var:
|
# reset before pass as 'result' var:
|
||||||
resetLoc(p, d)
|
resetLoc(p, d)
|
||||||
add(pl, addrLoc(d))
|
add(pl, addrLoc(d))
|
||||||
|
|
@ -226,7 +226,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
# Great, we can use 'd':
|
# Great, we can use 'd':
|
||||||
if d.k == locNone:
|
if d.k == locNone:
|
||||||
getTemp(p, typ.sons[0], d, needsInit=true)
|
getTemp(p, typ.sons[0], d, needsInit=true)
|
||||||
elif d.k notin {locExpr, locTemp} and not hasNoInit(ri):
|
elif d.k notin {locTemp} and not hasNoInit(ri):
|
||||||
# reset before pass as 'result' var:
|
# reset before pass as 'result' var:
|
||||||
resetLoc(p, d)
|
resetLoc(p, d)
|
||||||
add(pl, addrLoc(d))
|
add(pl, addrLoc(d))
|
||||||
|
|
|
||||||
26
tests/ccgbugs/tret_arg_init.nim
Normal file
26
tests/ccgbugs/tret_arg_init.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
discard """
|
||||||
|
output: '''nil
|
||||||
|
nil
|
||||||
|
nil'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type Bar = object
|
||||||
|
s1, s2: string
|
||||||
|
|
||||||
|
proc initBar(): Bar = discard
|
||||||
|
|
||||||
|
var a: array[5, Bar]
|
||||||
|
a[0].s1 = "hey"
|
||||||
|
a[0] = initBar()
|
||||||
|
echo a[0].s1
|
||||||
|
|
||||||
|
type Foo = object
|
||||||
|
b: Bar
|
||||||
|
var f: Foo
|
||||||
|
f.b.s1 = "hi"
|
||||||
|
f.b = initBar()
|
||||||
|
echo f.b.s1
|
||||||
|
|
||||||
|
var ad = addr f.b
|
||||||
|
ad[] = initBar()
|
||||||
|
echo ad[].s1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue