diff --git a/.gitattributes b/.gitattributes index 3479b3e08e..83c49bd15b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8096,6 +8096,7 @@ tests/webtbf/tw11295b.pp svneol=native#text/plain tests/webtbf/tw1157a.pp svneol=native#text/plain tests/webtbf/tw11619b.pp svneol=native#text/plain tests/webtbf/tw11632.pp svneol=native#text/plain +tests/webtbf/tw11848a.pp svneol=native#text/plain tests/webtbf/tw1238.pp svneol=native#text/plain tests/webtbf/tw1251a.pp svneol=native#text/plain tests/webtbf/tw1270.pp svneol=native#text/plain @@ -8531,6 +8532,7 @@ tests/webtbs/tw1157.pp svneol=native#text/plain tests/webtbs/tw1157b.pp svneol=native#text/plain tests/webtbs/tw11619.pp svneol=native#text/plain tests/webtbs/tw1181.pp svneol=native#text/plain +tests/webtbs/tw11848.pp svneol=native#text/plain tests/webtbs/tw1203.pp svneol=native#text/plain tests/webtbs/tw1204.pp svneol=native#text/plain tests/webtbs/tw1207.pp svneol=native#text/plain diff --git a/compiler/optdfa.pas b/compiler/optdfa.pas index d96ae9dee3..5eac4ad4cf 100644 --- a/compiler/optdfa.pas +++ b/compiler/optdfa.pas @@ -403,9 +403,26 @@ unit optdfa; if not(is_void(current_procinfo.procdef.returndef)) and not(current_procinfo.procdef.proctypeoption=potype_constructor) then begin - { get info from faked resultnode } - node.optinfo^.use:=resultnode.optinfo^.use; - node.optinfo^.life:=node.optinfo^.use; + if not(assigned(node.optinfo^.def)) and + not(assigned(node.optinfo^.use)) then + begin + if assigned(texitnode(node).left) then + begin + node.optinfo^.def:=resultnode.optinfo^.def; + + dfainfo.use:=@node.optinfo^.use; + dfainfo.def:=@node.optinfo^.def; + dfainfo.map:=map; + foreachnodestatic(pm_postprocess,texitnode(node).left,@AddDefUse,@dfainfo); + calclife(node); + end + else + begin + { get info from faked resultnode } + node.optinfo^.use:=resultnode.optinfo^.use; + node.optinfo^.life:=node.optinfo^.use; + end; + end; end; end; diff --git a/tests/webtbf/tw11848a.pp b/tests/webtbf/tw11848a.pp new file mode 100644 index 0000000000..88195187de --- /dev/null +++ b/tests/webtbf/tw11848a.pp @@ -0,0 +1,20 @@ +{ %OPT=-Sew -Oodfa } +{ %FAIL } +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +function Test(a: integer): integer; +var + i : integer; +begin + if a>0 then + i:=1 + else + exit(i); +end; + +begin +end. + diff --git a/tests/webtbs/tw11848.pp b/tests/webtbs/tw11848.pp new file mode 100644 index 0000000000..8d3c30b29e --- /dev/null +++ b/tests/webtbs/tw11848.pp @@ -0,0 +1,23 @@ +{ %OPT=-Sew -Oodfa } +{ %NORUN } +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +function Test(a: integer): integer; +var + HashItem: Pointer; +begin + HashItem:=nil; + while HashItem<>nil do begin + if (HashItem<>nil) then + exit(-1); + HashItem:=HashItem; + end; + Result:=0; +end; + +begin +end. +