|
@@ -585,7 +585,10 @@ implementation
|
|
procedure tcallparanode.insert_typeconv(do_count : boolean);
|
|
procedure tcallparanode.insert_typeconv(do_count : boolean);
|
|
var
|
|
var
|
|
olddef : tdef;
|
|
olddef : tdef;
|
|
- hp : tnode;
|
|
|
|
|
|
+ hp : tnode;
|
|
|
|
+ block : tblocknode;
|
|
|
|
+ statements : tstatementnode;
|
|
|
|
+ temp : ttempcreatenode;
|
|
begin
|
|
begin
|
|
{ Be sure to have the resultdef }
|
|
{ Be sure to have the resultdef }
|
|
if not assigned(left.resultdef) then
|
|
if not assigned(left.resultdef) then
|
|
@@ -688,7 +691,33 @@ implementation
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
check_ranges(left.fileinfo,left,parasym.vardef);
|
|
check_ranges(left.fileinfo,left,parasym.vardef);
|
|
- inserttypeconv(left,parasym.vardef);
|
|
|
|
|
|
+ { truncate shortstring value parameters at the caller side if }
|
|
|
|
+ { they are passed by value (if passed by reference, then the }
|
|
|
|
+ { callee will truncate when copying in the string) }
|
|
|
|
+ { This happens e.g. on x86_64 for small strings }
|
|
|
|
+ if (parasym.varspez=vs_value) and
|
|
|
|
+ not paramanager.push_addr_param(parasym.varspez,parasym.vardef,
|
|
|
|
+ aktcallnode.procdefinition.proccalloption) and
|
|
|
|
+ (tstringdef(parasym.vardef).len<tstringdef(left.resultdef).len) then
|
|
|
|
+ begin
|
|
|
|
+ block:=internalstatements(statements);
|
|
|
|
+ { temp for the new string }
|
|
|
|
+ temp:=ctempcreatenode.create(parasym.vardef,parasym.vardef.size,
|
|
|
|
+ tt_persistent,true);
|
|
|
|
+ addstatement(statements,temp);
|
|
|
|
+ { assign parameter to temp }
|
|
|
|
+ addstatement(statements,cassignmentnode.create(ctemprefnode.create(temp),left));
|
|
|
|
+ left:=nil;
|
|
|
|
+ { release temp after next use }
|
|
|
|
+ addstatement(statements,ctempdeletenode.create_normal_temp(temp));
|
|
|
|
+ addstatement(statements,ctemprefnode.create(temp));
|
|
|
|
+ typecheckpass(block);
|
|
|
|
+ left:=block;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ { type conversions perform no truncation for constant strings, }
|
|
|
|
+ { which is TP/Delphi compatible }
|
|
|
|
+ inserttypeconv(left,parasym.vardef);
|
|
end;
|
|
end;
|
|
if codegenerror then
|
|
if codegenerror then
|
|
exit;
|
|
exit;
|