* do not check inlined exit nodes for unset results, resolves #38259

git-svn-id: trunk@47926 -
This commit is contained in:
florian 2020-12-31 15:52:02 +00:00
parent 3482121831
commit b4a6c22234
2 changed files with 18 additions and 10 deletions

View File

@ -940,8 +940,11 @@ unit optdfa;
MaybeSearchIn(texitnode(node).left);
{ exit uses the resultnode implicitly, so searching for a matching node is
useless, if we reach the exit node and found the living node not in left, then
it can be only the resultnode }
if not(Result) and not(is_void(current_procinfo.procdef.returndef)) and
it can be only the resultnode
successor might be assigned in case of an inlined exit node, in this case we do not warn about an unassigned
result as this had happened already when the routine has been compiled }
if not(assigned(node.successor)) and not(Result) and not(is_void(current_procinfo.procdef.returndef)) and
not(assigned(texitnode(node).resultexpr)) and
{ don't warn about constructors }
not(current_procinfo.procdef.proctypeoption in [potype_class_constructor,potype_constructor]) then

View File

@ -1,16 +1,21 @@
{ %OPT=-O3 -Sew -vw }
{$mode objfpc}
{$inline on}
procedure test; inline;
begin
exit;
end;
procedure mymove(var src,dst; len: ptrint); inline;
begin
if len<=0 then
exit;
end;
function f: longint;
function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
var
p : pchar;
begin
test; // tt.pp(11,3) Warning: Function result variable does not seem to be initialized
result:=4;
getmem(p,length1+length2+1);
mymove(p1[0],p[0],length1);
mymove(p2[0],p[length1],length2+1);
concatansistrings:=p;
end;
begin