Selaa lähdekoodia

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

git-svn-id: trunk@47926 -
florian 4 vuotta sitten
vanhempi
commit
b4a6c22234
2 muutettua tiedostoa jossa 18 lisäystä ja 10 poistoa
  1. 5 2
      compiler/optdfa.pas
  2. 13 8
      tests/webtbs/tw38259.pp

+ 5 - 2
compiler/optdfa.pas

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

+ 13 - 8
tests/webtbs/tw38259.pp

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