From 3baddff71e3e04ee92cb792b904c9b9f5a4e4043 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 26 Oct 2020 22:18:03 +0000 Subject: [PATCH] + inline subroutines with formal parameters as well git-svn-id: trunk@47214 - --- compiler/ncal.pas | 11 +++++++---- compiler/psub.pas | 8 -------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/ncal.pas b/compiler/ncal.pas index 1cbebfd6b0..cc22ac8e70 100644 --- a/compiler/ncal.pas +++ b/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; diff --git a/compiler/psub.pas b/compiler/psub.pas index 979038b796..e30f1d3ba3 100644 --- a/compiler/psub.pas +++ b/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