diff --git a/.gitattributes b/.gitattributes index 06f611b132..8ef735a518 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8148,6 +8148,7 @@ tests/webtbs/tw8513.pp svneol=native#text/plain tests/webtbs/tw8525.pp svneol=native#text/plain tests/webtbs/tw8573.pp svneol=native#text/plain tests/webtbs/tw8615.pp svneol=native#text/plain +tests/webtbs/tw8664.pp svneol=native#text/plain tests/webtbs/ub1873.pp svneol=native#text/plain tests/webtbs/ub1883.pp svneol=native#text/plain tests/webtbs/uw0555.pp svneol=native#text/plain diff --git a/compiler/i386/cgcpu.pas b/compiler/i386/cgcpu.pas index 60fadc797a..c84653e93f 100644 --- a/compiler/i386/cgcpu.pas +++ b/compiler/i386/cgcpu.pas @@ -46,6 +46,7 @@ unit cgcpu; procedure g_proc_exit(list : TAsmList;parasize:longint;nostackframe:boolean);override; procedure g_copyvaluepara_openarray(list : TAsmList;const ref:treference;const lenloc:tlocation;elesize:aint;destreg:tregister);override; + procedure g_releasevaluepara_openarray(list : TAsmList;const l:tlocation);override; procedure g_exception_reason_save(list : TAsmList; const href : treference);override; procedure g_exception_reason_save_const(list : TAsmList; const href : treference; a: aint);override; @@ -444,6 +445,17 @@ unit cgcpu; end; + procedure tcg386.g_releasevaluepara_openarray(list : TAsmList;const l:tlocation); + begin + if use_fixed_stack then + begin + inherited g_releasevaluepara_openarray(list,l); + exit; + end; + { Nothing to release } + end; + + procedure tcg386.g_exception_reason_save(list : TAsmList; const href : treference); begin if not use_fixed_stack then diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index 8d5d8edd75..00a263d924 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -1222,17 +1222,17 @@ implementation location_get_data_ref(list,tparavarsym(p).localloc,href,is_open_array(tparavarsym(p).vardef)); cg.g_decrrefcount(list,tparavarsym(p).vardef,href); end; - end - else - if (tparavarsym(p).varspez=vs_value) and - (is_open_array(tparavarsym(p).vardef) or - is_array_of_const(tparavarsym(p).vardef)) then - begin - { cdecl functions don't have a high pointer so it is not possible to generate - a local copy } - if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then - cg.g_releasevaluepara_openarray(list,tparavarsym(p).localloc); - end; + end; + { open arrays can contain elements requiring init/final code, so the else has been removed here } + if (tparavarsym(p).varspez=vs_value) and + (is_open_array(tparavarsym(p).vardef) or + is_array_of_const(tparavarsym(p).vardef)) then + begin + { cdecl functions don't have a high pointer so it is not possible to generate + a local copy } + if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then + cg.g_releasevaluepara_openarray(list,tparavarsym(p).localloc); + end; end; diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index e0a3342631..da0680000a 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -102,7 +102,6 @@ unit cgx86; procedure g_concatcopy(list : TAsmList;const source,dest : treference;len : aint);override; { entry/exit code helpers } - procedure g_releasevaluepara_openarray(list : TAsmList;const l:tlocation);override; procedure g_profilecode(list : TAsmList);override; procedure g_stackpointer_alloc(list : TAsmList;localsize : longint);override; procedure g_proc_entry(list : TAsmList;localsize : longint;nostackframe:boolean);override; @@ -491,7 +490,7 @@ unit cgx86; end; OS_F80 : begin - op:=A_FSTP; + op:=A_FSTP; s:=S_FX; end; OS_C64 : @@ -1713,17 +1712,6 @@ unit cgx86; Entry/Exit Code Helpers ****************************************************************************} - procedure tcgx86.g_releasevaluepara_openarray(list : TAsmList;const l:tlocation); - begin - if (use_fixed_stack) then - begin - inherited g_releasevaluepara_openarray(list,l); - exit; - end; - { Nothing to release } - end; - - procedure tcgx86.g_profilecode(list : TAsmList); var diff --git a/tests/webtbs/tw8664.pp b/tests/webtbs/tw8664.pp new file mode 100644 index 0000000000..ddd2aa9379 --- /dev/null +++ b/tests/webtbs/tw8664.pp @@ -0,0 +1,13 @@ +{ %OPT=-gh } +program project1; + +{$mode objfpc}{$H+} + +procedure TLResourceListAdd(Values: array of string); +begin +end; + + +begin + TLResourceListAdd(['Value1']); +end.