diff --git a/.gitattributes b/.gitattributes index 2057c3f850..9dbee97e7f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15015,6 +15015,7 @@ tests/webtbs/tw2976.pp svneol=native#text/plain tests/webtbs/tw29792.pp svneol=native#text/pascal tests/webtbs/tw2983.pp svneol=native#text/plain tests/webtbs/tw2984.pp svneol=native#text/plain +tests/webtbs/tw29891.pp svneol=native#text/plain tests/webtbs/tw29893.pp svneol=native#text/pascal tests/webtbs/tw29912.pp svneol=native#text/plain tests/webtbs/tw29923.pp svneol=native#text/plain diff --git a/compiler/ncal.pas b/compiler/ncal.pas index b970cc55f7..e6292dfb6a 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -3027,8 +3027,24 @@ implementation begin if not assigned(funcretnode) then internalerror(200709083); - para.left:=funcretnode; - funcretnode:=nil; + { if funcretnode is a temprefnode, we have to keep it intact + if it may have been created in maybe_create_funcret_node(), + because then it will also be destroyed by a + ctempdeletenode.create_normal_temp() in the cleanup code + for this call code. In that case we have to copy this + ttemprefnode after the tempdeletenode to reset its + tempinfo^.hookoncopy. This is done by copying funcretnode + in tcallnode.getcopy(), but for that to work we can't reset + funcretnode to nil here. } + if (funcretnode.nodetype<>temprefn) or + (not(cnf_return_value_used in callnodeflags) and + (cnf_do_inline in callnodeflags)) then + begin + para.left:=funcretnode; + funcretnode:=nil; + end + else + para.left:=funcretnode.getcopy; end else if vo_is_self in para.parasym.varoptions then diff --git a/tests/webtbs/tw29891.pp b/tests/webtbs/tw29891.pp new file mode 100644 index 0000000000..53c45f275b --- /dev/null +++ b/tests/webtbs/tw29891.pp @@ -0,0 +1,26 @@ +{ %NORUN } + +program tinterr; + +{$mode objfpc}{$H+} + +type + TALVector3f = array[0..2] of Single; + +function alGetSource3f: TALVector3f; +begin + +end; + +function VectorToNiceStr(const v: array of Single): string; +begin + +end; + + function SampleSourceState:string; + begin + result := 'POSITION : '+ VectorToNiceStr(alGetSource3f) + LineEnding; + end; + +begin +end.