diff --git a/compiler/aarch64/cpupara.pas b/compiler/aarch64/cpupara.pas index c0f811aaab..0983a65ca2 100644 --- a/compiler/aarch64/cpupara.pas +++ b/compiler/aarch64/cpupara.pas @@ -270,7 +270,8 @@ unit cpupara; then indexed beyond its bounds) } arraydef: result:= - (calloption in cdecl_pocalls) or + ((calloption in cdecl_pocalls) and + not is_dynamic_array(def)) or is_open_array(def) or is_array_of_const(def) or is_array_constructor(def) or @@ -556,7 +557,10 @@ unit cpupara; (side=callerside) and is_ordinal(paradef) and (paradef.size<4) then - paraloc^.size:=OS_32; + begin + paraloc^.size:=OS_32; + paraloc^.def:=u32inttype; + end; { in case it's a composite, "The argument is passed as though it had been loaded into the registers from a double-word- @@ -567,7 +571,7 @@ unit cpupara; if (target_info.endian=endian_big) and not(paraloc^.size in [OS_64,OS_S64]) and (paradef.typ in [setdef,recorddef,arraydef,objectdef]) then - paraloc^.shiftval:=-(8-tcgsize2size[paraloc^.size]); + paraloc^.shiftval:=-(8-tcgsize2size[paraloc^.size])*8; end; LOC_MMREGISTER: begin @@ -581,7 +585,7 @@ unit cpupara; paraloc^.loc:=LOC_REFERENCE; { the current stack offset may not be properly aligned in - case we're on Darwin have allocated a non-variadic argument + case we're on Darwin and have allocated a non-variadic argument < 8 bytes previously } if target_info.abi=abi_aarch64_darwin then curstackoffset:=align(curstackoffset,paraloc^.def.alignment); diff --git a/compiler/aarch64/hlcgcpu.pas b/compiler/aarch64/hlcgcpu.pas index d7a61331be..4fe1e342be 100644 --- a/compiler/aarch64/hlcgcpu.pas +++ b/compiler/aarch64/hlcgcpu.pas @@ -64,7 +64,10 @@ implementation begin tocgsize:=def_cgsize(tosize); if (sreg.startbit<>0) or - not(sreg.bitlen in [32,64]) then + not((sreg.subsetregsize in [OS_32,OS_S32]) and + (sreg.bitlen=32)) or + not((sreg.subsetregsize in [OS_64,OS_S64]) and + (sreg.bitlen=64)) then begin if is_signed(subsetsize) then op:=A_SBFX diff --git a/compiler/jvm/njvminl.pas b/compiler/jvm/njvminl.pas index 006d7f750a..036f5d24a4 100644 --- a/compiler/jvm/njvminl.pas +++ b/compiler/jvm/njvminl.pas @@ -521,7 +521,7 @@ implementation function tjvminlinenode.first_setlength: tnode; begin { reverse the parameter order so we can process them more easily } - left:=reverseparameters(tcallparanode(left)); + reverseparameters(tcallparanode(left)); { treat setlength(x,0) specially: used to init uninitialised locations } if not is_shortstring(left.resultdef) and not assigned(tcallparanode(tcallparanode(left).right).right) and @@ -535,7 +535,7 @@ implementation { strings are handled the same as on other platforms } if left.resultdef.typ=stringdef then begin - left:=reverseparameters(tcallparanode(left)); + reverseparameters(tcallparanode(left)); result:=inherited first_setlength; exit; end; diff --git a/compiler/llvm/nllvmcnv.pas b/compiler/llvm/nllvmcnv.pas index 27e815de8c..1d9dccc1d0 100644 --- a/compiler/llvm/nllvmcnv.pas +++ b/compiler/llvm/nllvmcnv.pas @@ -80,7 +80,7 @@ class function tllvmtypeconvnode.target_specific_need_equal_typeconv(fromdef, to result:= (fromdef<>todef) and { two procdefs that are structurally the same but semantically different - still need a convertion } + still need a conversion } ( ((fromdef.typ=procvardef) and (todef.typ=procvardef)) diff --git a/compiler/ncal.pas b/compiler/ncal.pas index eadfb76406..3303f25590 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -290,7 +290,7 @@ interface dct_propput ); - function reverseparameters(p: tcallparanode): tcallparanode; + procedure reverseparameters(var p: tcallparanode); function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring; dispid : longint;resultdef : tdef) : tnode; @@ -331,21 +331,23 @@ implementation HELPERS ****************************************************************************} - function reverseparameters(p: tcallparanode): tcallparanode; + procedure reverseparameters(var p: tcallparanode); var + tmpp, hp1, hp2: tcallparanode; begin hp1:=nil; - while assigned(p) do + tmpp:=p; + while assigned(tmpp) do begin { pull out } - hp2:=p; - p:=tcallparanode(p.right); + hp2:=tmpp; + tmpp:=tcallparanode(tmpp.right); { pull in } hp2.right:=hp1; hp1:=hp2; end; - reverseparameters:=hp1; + p:=hp1; end; function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring; diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 31135872da..04ba524466 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -350,7 +350,8 @@ implementation if equal_defs(p.resultdef,def) and (p.resultdef.typ=def.typ) and not is_bitpacked_access(p) and - not ctypeconvnode.target_specific_need_equal_typeconv(p.resultdef,def) then + ((p.blocktype=bt_const) or + not ctypeconvnode.target_specific_need_equal_typeconv(p.resultdef,def)) then begin { don't replace encoded string constants to rawbytestring encoding. preserve the codepage } @@ -2440,7 +2441,8 @@ implementation {$ifdef llvm} { we still may have to insert a type conversion at the llvm level } - if (left.resultdef<>resultdef) and + if (blocktype<>bt_const) and + (left.resultdef<>resultdef) and { if unspecialised generic -> we won't generate any code for this, and keeping the type conversion node will cause valid_for_assign to fail because the typecast will be from/to something of 0 diff --git a/compiler/ncon.pas b/compiler/ncon.pas index ae94637c28..6a048420ff 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -982,6 +982,7 @@ implementation Message1(option_code_page_not_available,IntToStr(cp1)); initwidestring(pw); setlengthwidestring(pw,len); + { returns room for terminating 0 } l:=Utf8ToUnicode(PUnicodeChar(pw^.data),len,value_str,len); if (l<>getlengthwidestring(pw)) then begin @@ -989,6 +990,7 @@ implementation ReAllocMem(value_str,l); end; unicode2ascii(pw,value_str,cp1); + len:=l-1; donewidestring(pw); end else @@ -1000,6 +1002,7 @@ implementation initwidestring(pw); setlengthwidestring(pw,len); ascii2unicode(value_str,len,cp2,pw); + { returns room for terminating 0 } l:=UnicodeToUtf8(nil,0,PUnicodeChar(pw^.data),len); if l<>len then ReAllocMem(value_str,l); diff --git a/compiler/ninl.pas b/compiler/ninl.pas index d8cb4985c4..25a9ac2598 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -1239,7 +1239,7 @@ implementation { reverse the parameters (needed to get the colon parameters in the } { correct order when processing write(ln) } - left := reverseparameters(tcallparanode(left)); + reverseparameters(tcallparanode(left)); if is_rwstr then begin @@ -1525,7 +1525,7 @@ implementation valsinttype:=search_system_type('VALSINT').typedef; { reverse parameters for easier processing } - left := reverseparameters(tcallparanode(left)); + reverseparameters(tcallparanode(left)); { get the parameters } tempcode := nil;