+ Fix for bug #3207 from Peter

This commit is contained in:
michael 2004-07-12 10:47:42 +00:00
parent 1563d986c5
commit 04a69ced17

View File

@ -495,6 +495,7 @@ implementation
begin begin
resultloc:=procdefinition.funcret_paraloc[callerside]; resultloc:=procdefinition.funcret_paraloc[callerside];
cgsize:=resultloc.size; cgsize:=resultloc.size;
{ structured results are easy to handle.... { structured results are easy to handle....
needed also when result_no_used !! } needed also when result_no_used !! }
if (procdefinition.proctypeoption<>potype_constructor) and if (procdefinition.proctypeoption<>potype_constructor) and
@ -504,8 +505,9 @@ implementation
if location.loc<>LOC_REFERENCE then if location.loc<>LOC_REFERENCE then
internalerror(200304241); internalerror(200304241);
end end
else
{ ansi/widestrings must be registered, so we can dispose them } { ansi/widestrings must be registered, so we can dispose them }
else if resulttype.def.needs_inittable then if resulttype.def.needs_inittable then
begin begin
{ the FUNCTION_RESULT_REG is already allocated } { the FUNCTION_RESULT_REG is already allocated }
if not assigned(funcretnode) then if not assigned(funcretnode) then
@ -532,9 +534,20 @@ implementation
cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference); cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
cg.ungetregister(exprasmlist,hregister); cg.ungetregister(exprasmlist,hregister);
end; end;
{ When the result is not used we need to finalize the result and
can release the temp }
if not(cnf_return_value_used in callnodeflags) then
begin
cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
tg.ungetiftemp(exprasmlist,location.reference)
end;
end end
else
{ normal (ordinal,float,pointer) result value }
begin
{ we have only to handle the result if it is used } { we have only to handle the result if it is used }
else if (cnf_return_value_used in callnodeflags) then if (cnf_return_value_used in callnodeflags) then
begin begin
location.loc:=resultloc.loc; location.loc:=resultloc.loc;
case resultloc.loc of case resultloc.loc of
@ -608,11 +621,17 @@ implementation
end end
else else
begin begin
{$ifdef x86}
{ release FPU stack }
if resultloc.loc=LOC_FPUREGISTER then
emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
{$endif x86}
if cgsize<>OS_NO then if cgsize<>OS_NO then
paramanager.freeparaloc(exprasmlist,resultloc); paramanager.freeparaloc(exprasmlist,resultloc);
location_reset(location,LOC_VOID,OS_NO); location_reset(location,LOC_VOID,OS_NO);
end; end;
end; end;
end;
procedure tcgcallnode.release_para_temps; procedure tcgcallnode.release_para_temps;
@ -1024,26 +1043,6 @@ implementation
{ release temps of paras } { release temps of paras }
release_para_temps; release_para_temps;
{ if return value is not used }
if (not(cnf_return_value_used in callnodeflags)) and (not is_void(resulttype.def)) then
begin
if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
begin
{ data which must be finalized ? }
if (resulttype.def.needs_inittable) then
cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
{ release unused temp }
tg.ungetiftemp(exprasmlist,location.reference)
end
else if location.loc=LOC_FPUREGISTER then
begin
{$ifdef x86}
{ release FPU stack }
emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
{$endif x86}
end;
end;
end; end;
@ -1264,7 +1263,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.172 2004-07-11 19:01:13 peter Revision 1.173 2004-07-12 10:47:42 michael
+ Fix for bug 3207 from Peter
Revision 1.172 2004/07/11 19:01:13 peter
* comps are passed in int registers * comps are passed in int registers
Revision 1.171 2004/07/09 23:41:04 jonas Revision 1.171 2004/07/09 23:41:04 jonas