From 99914b427931330a22b9fe9210ea44acc6ee8101 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 12 Jul 2019 22:06:41 +0000 Subject: [PATCH] * instead of collecting the raw parameters we need to collect the parameters as passed to the call as there might be type conversions involved git-svn-id: trunk@42384 - --- compiler/pdecl.pas | 60 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index d7613ea32d..fd1b771c68 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -453,29 +453,6 @@ implementation paran:=read_attr_paras; - paras:=nil; - if assigned(paran) then - begin - ptmp:=paran; - pcount:=0; - while assigned(ptmp) do - begin - inc(pcount); - ptmp:=tcallparanode(ptmp).right; - end; - setlength(paras,pcount); - ptmp:=paran; - pcount:=0; - while assigned(ptmp) do - begin - if not is_constnode(tcallparanode(ptmp).left) then - internalerror(2019070601); - paras[high(paras)-pcount]:=tcallparanode(ptmp).left.getcopy; - inc(pcount); - ptmp:=tcallparanode(ptmp).right; - end; - end; - { Search the tprocdef of the constructor which has to be called. } constrsym:=find_create_constructor(od); if constrsym.typ<>procsym then @@ -487,6 +464,43 @@ implementation if pcalln.nodetype<>errorn then begin + if pcalln.nodetype<>calln then + internalerror(2019070701); + { collect the parameters of the call node as there might be + compile time type conversions (e.g. a Byte parameter being + passed a value > 255) } + paran:=tcallnode(pcalln).left; + + { only count visible parameters (thankfully open arrays are not + supported, otherwise we'd need to handle those as well) } + paras:=nil; + if assigned(paran) then + begin + ptmp:=paran; + pcount:=0; + while assigned(ptmp) do + begin + if not (vo_is_hidden_para in tcallparanode(ptmp).parasym.varoptions) then + inc(pcount); + ptmp:=tcallparanode(ptmp).right; + end; + setlength(paras,pcount); + ptmp:=paran; + pcount:=0; + while assigned(ptmp) do + begin + if not (vo_is_hidden_para in tcallparanode(ptmp).parasym.varoptions) then + begin + if not is_constnode(tcallparanode(ptmp).left) then + internalerror(2019070601); + paras[high(paras)-pcount]:=tcallparanode(ptmp).left.getcopy; + inc(pcount); + end; + ptmp:=tcallparanode(ptmp).right; + end; + end; + + { Add attribute to attribute list which will be added to the property which is defined next. } if not assigned(rtti_attrs_def) then