瀏覽代碼

* the function result of constructors always is self, always is valid and is
not stored in procdef.funcretsym -> fix check so that SSA is not performed
on it in constructors when exit is used

git-svn-id: trunk@26650 -

Jonas Maebe 11 年之前
父節點
當前提交
4e9c54278e
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      compiler/ncgutil.pas

+ 7 - 5
compiler/ncgutil.pas

@@ -1945,13 +1945,15 @@ implementation
             exit;
             exit;
         end;
         end;
 
 
-        if not is_void(current_procinfo.procdef.returndef) and
+        { self is implicitly returned from constructors, even if there are no
+          references to it; additionally, funcretsym is not set for constructor
+          procdefs }
+        if (current_procinfo.procdef.proctypeoption=potype_constructor) then
+          rr.ressym:=tsym(current_procinfo.procdef.parast.Find('self'))
+        else if not is_void(current_procinfo.procdef.returndef) and
            assigned(current_procinfo.procdef.funcretsym) and
            assigned(current_procinfo.procdef.funcretsym) and
            (tabstractvarsym(current_procinfo.procdef.funcretsym).refs <> 0) then
            (tabstractvarsym(current_procinfo.procdef.funcretsym).refs <> 0) then
-          if (current_procinfo.procdef.proctypeoption=potype_constructor) then
-            rr.ressym:=tsym(current_procinfo.procdef.parast.Find('self'))
-         else
-            rr.ressym:=current_procinfo.procdef.funcretsym;
+          rr.ressym:=current_procinfo.procdef.funcretsym;
 
 
         if not foreachnodestatic(n,@doreplace,@rr) then
         if not foreachnodestatic(n,@doreplace,@rr) then
           exit;
           exit;