Explorar o código

+ inline subroutines with formal parameters as well

git-svn-id: trunk@47214 -
florian %!s(int64=4) %!d(string=hai) anos
pai
achega
3baddff71e
Modificáronse 2 ficheiros con 7 adicións e 12 borrados
  1. 7 4
      compiler/ncal.pas
  2. 0 8
      compiler/psub.pas

+ 7 - 4
compiler/ncal.pas

@@ -4734,6 +4734,10 @@ implementation
         if para.parasym.varspez in [vs_var,vs_out] then
           exit(false);
 
+        { We cannot create a formaldef temp and assign something to it }
+        if para.parasym.vardef.typ=formaldef then
+          exit(false);
+
         { We don't need temps for parameters that are already temps, except if
           the passed temp could be put in a regvar while the parameter inside
           the routine cannot be (e.g., because its address is taken in the
@@ -4751,10 +4755,6 @@ implementation
            not(para.left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE]) then
           exit(true);
 
-        { We cannot create a formaldef temp and assign something to it }
-        if para.parasym.vardef.typ=formaldef then
-          exit(false);
-
         { We try to handle complex expressions later by taking their address
           and storing this address in a temp (which is then dereferenced when
           the value is used; that doesn't work if we cannot take the address
@@ -4912,6 +4912,9 @@ implementation
 
             result:=true;
           end
+        { for formaldefs, we do not need a temp., but it must be inherited if they are not regable }
+        else if (para.parasym.vardef.typ=formaldef) and not(tparavarsym(para.parasym).is_regvar(false)) then
+          make_not_regable(para.left,[ra_addr_regable]);
       end;
 
 

+ 0 - 8
compiler/psub.pas

@@ -237,14 +237,6 @@ implementation
           begin
             currpara:=tparavarsym(procdef.paras[i]);
             case currpara.vardef.typ of
-              formaldef :
-                begin
-                  if (currpara.varspez in [vs_out,vs_var,vs_const,vs_constref]) then
-                    begin
-                      _no_inline('formal parameter');
-                      exit;
-                    end;
-                end;
               arraydef :
                 begin
                   if is_array_of_const(currpara.vardef) or