mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-24 07:02:13 +01:00
+ funcret setting in underproc testing
compile with _dTEST_FUNCRET
This commit is contained in:
parent
2d3551267d
commit
2d9cbf7fde
@ -532,22 +532,22 @@ implementation
|
|||||||
hr:=getregister32;
|
hr:=getregister32;
|
||||||
hr_valid:=false;
|
hr_valid:=false;
|
||||||
hp:=new_reference(procinfo.framepointer,
|
hp:=new_reference(procinfo.framepointer,
|
||||||
pprocinfo(procinfo.framepointer_offset);
|
procinfo.framepointer_offset);
|
||||||
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,hp,hr)));
|
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,hp,hr)));
|
||||||
pp:=procinfo.parent;
|
pp:=procinfo.parent;
|
||||||
|
{ walk up the stack frame }
|
||||||
while pp<>pprocinfo(p^.funcretprocinfo) do
|
while pp<>pprocinfo(p^.funcretprocinfo) do
|
||||||
begin
|
begin
|
||||||
hp:=new_reference(hr,
|
hp:=new_reference(hr,
|
||||||
pprocinfo(pp^.framepointer_offset);
|
pp^.framepointer_offset);
|
||||||
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,hp,hr)));
|
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,hp,hr)));
|
||||||
|
pp:=pp^.parent;
|
||||||
end;
|
end;
|
||||||
p^.location.reference.base:=hr;
|
p^.location.reference.base:=hr;
|
||||||
{ walk up the stack frame }
|
|
||||||
{ not done yet !! }
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
p^.location.reference.base:=procinfo.framepointer;
|
p^.location.reference.base:=procinfo.framepointer;
|
||||||
p^.location.reference.offset:=pprocinfo(p^.funcretprocinfo)^.retoffset;
|
p^.location.reference.offset:=procinfo.retoffset;
|
||||||
if ret_in_param(p^.retdef) then
|
if ret_in_param(p^.retdef) then
|
||||||
{$endif TEST_FUNCRET}
|
{$endif TEST_FUNCRET}
|
||||||
begin
|
begin
|
||||||
@ -565,7 +565,11 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.8 1998-08-10 14:49:48 peter
|
Revision 1.9 1998-08-20 09:26:37 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.8 1998/08/10 14:49:48 peter
|
||||||
+ localswitches, moduleswitches, globalswitches splitting
|
+ localswitches, moduleswitches, globalswitches splitting
|
||||||
|
|
||||||
Revision 1.7 1998/07/30 13:30:33 florian
|
Revision 1.7 1998/07/30 13:30:33 florian
|
||||||
|
|||||||
@ -54,6 +54,10 @@ unit hcodegen;
|
|||||||
retdef : pdef;
|
retdef : pdef;
|
||||||
{ return type }
|
{ return type }
|
||||||
sym : pprocsym;
|
sym : pprocsym;
|
||||||
|
{$ifdef TEST_FUNCRET }
|
||||||
|
{ symbol of the function }
|
||||||
|
funcretsym : pfuncretsym;
|
||||||
|
{$endif TEST_FUNCRET }
|
||||||
{ the definition of the proc itself }
|
{ the definition of the proc itself }
|
||||||
{ why was this a pdef only ?? PM }
|
{ why was this a pdef only ?? PM }
|
||||||
def : pprocdef;
|
def : pprocdef;
|
||||||
@ -405,7 +409,11 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.12 1998-08-10 14:50:01 peter
|
Revision 1.13 1998-08-20 09:26:38 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.12 1998/08/10 14:50:01 peter
|
||||||
+ localswitches, moduleswitches, globalswitches splitting
|
+ localswitches, moduleswitches, globalswitches splitting
|
||||||
|
|
||||||
Revision 1.11 1998/07/28 21:52:51 florian
|
Revision 1.11 1998/07/28 21:52:51 florian
|
||||||
|
|||||||
@ -3629,8 +3629,9 @@ unit pass_1;
|
|||||||
if must_be_valid and
|
if must_be_valid and
|
||||||
(@procinfo=pprocinfo(p^.funcretprocinfo)) and
|
(@procinfo=pprocinfo(p^.funcretprocinfo)) and
|
||||||
not procinfo.funcret_is_valid then
|
not procinfo.funcret_is_valid then
|
||||||
note(uninitialized_function_return);
|
Message(sym_w_function_result_not_set);
|
||||||
if count_ref then pprocinfo(p^.funcretprocinfo)^.funcret_is_valid:=true;
|
if count_ref then
|
||||||
|
pprocinfo(p^.funcretprocinfo)^.funcret_is_valid:=true;
|
||||||
{$else TEST_FUNCRET}
|
{$else TEST_FUNCRET}
|
||||||
p^.resulttype:=procinfo.retdef;
|
p^.resulttype:=procinfo.retdef;
|
||||||
p^.location.loc:=LOC_REFERENCE;
|
p^.location.loc:=LOC_REFERENCE;
|
||||||
@ -5258,7 +5259,11 @@ unit pass_1;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.58 1998-08-19 16:07:51 jonas
|
Revision 1.59 1998-08-20 09:26:39 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.58 1998/08/19 16:07:51 jonas
|
||||||
* changed optimizer switches + cleanup of DestroyRefs in daopt386.pas
|
* changed optimizer switches + cleanup of DestroyRefs in daopt386.pas
|
||||||
|
|
||||||
Revision 1.57 1998/08/19 00:42:39 peter
|
Revision 1.57 1998/08/19 00:42:39 peter
|
||||||
|
|||||||
@ -1066,16 +1066,20 @@ unit pexpr;
|
|||||||
function is_func_ret(sym : psym) : boolean;
|
function is_func_ret(sym : psym) : boolean;
|
||||||
var
|
var
|
||||||
p : pprocinfo;
|
p : pprocinfo;
|
||||||
|
storesymtablestack : psymtable;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
p:=@procinfo;
|
|
||||||
is_func_ret:=false;
|
is_func_ret:=false;
|
||||||
|
if (sym^.typ<>funcretsym) and ((procinfo.flags and pi_operator)=0) then
|
||||||
|
exit;
|
||||||
|
p:=@procinfo;
|
||||||
while assigned(p) do
|
while assigned(p) do
|
||||||
begin
|
begin
|
||||||
{ is this an access to a function result ? }
|
{ is this an access to a function result ? }
|
||||||
if assigned(aktprocsym) and
|
if assigned(p^.funcretsym) and
|
||||||
((sym^.name=aktprocsym^.name){ or
|
((sym=p^.funcretsym) or
|
||||||
((pvarsym(srsym)=opsym) and
|
((pvarsym(sym)=opsym) and
|
||||||
((p^.flags and pi_operator)<>0))}) and
|
((p^.flags and pi_operator)<>0))) and
|
||||||
(p^.retdef<>pdef(voiddef)) and
|
(p^.retdef<>pdef(voiddef)) and
|
||||||
(token<>LKLAMMER) and
|
(token<>LKLAMMER) and
|
||||||
(not ((cs_tp_compatible in aktmoduleswitches) and
|
(not ((cs_tp_compatible in aktmoduleswitches) and
|
||||||
@ -1090,6 +1094,16 @@ unit pexpr;
|
|||||||
end;
|
end;
|
||||||
p:=p^.parent;
|
p:=p^.parent;
|
||||||
end;
|
end;
|
||||||
|
{ we must use the function call }
|
||||||
|
if(sym^.typ=funcretsym) then
|
||||||
|
begin
|
||||||
|
storesymtablestack:=symtablestack;
|
||||||
|
symtablestack:=srsymtable^.next;
|
||||||
|
getsym(sym^.name,true);
|
||||||
|
if srsym^.typ<>procsym then
|
||||||
|
Message(cg_e_illegal_expression);
|
||||||
|
symtablestack:=storesymtablestack;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{$endif TEST_FUNCRET}
|
{$endif TEST_FUNCRET}
|
||||||
|
|
||||||
@ -1841,7 +1855,11 @@ unit pexpr;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.39 1998-08-18 16:48:48 pierre
|
Revision 1.40 1998-08-20 09:26:41 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.39 1998/08/18 16:48:48 pierre
|
||||||
* bug for -So proc assignment to p^rocvar fixed
|
* bug for -So proc assignment to p^rocvar fixed
|
||||||
|
|
||||||
Revision 1.38 1998/08/18 14:17:09 pierre
|
Revision 1.38 1998/08/18 14:17:09 pierre
|
||||||
|
|||||||
@ -39,7 +39,7 @@ unit pstatmnt;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
cobjects,globals,files,verbose,systems,
|
strings,cobjects,globals,files,verbose,systems,
|
||||||
symtable,aasm,pass_1,types,scanner,hcodegen,ppu
|
symtable,aasm,pass_1,types,scanner,hcodegen,ppu
|
||||||
,pbase,pexpr,pdecl
|
,pbase,pexpr,pdecl
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
@ -1092,10 +1092,12 @@ unit pstatmnt;
|
|||||||
begin
|
begin
|
||||||
{ if the current is a function aktprocsym is non nil }
|
{ if the current is a function aktprocsym is non nil }
|
||||||
{ and there is a local symtable set }
|
{ and there is a local symtable set }
|
||||||
funcretsym:=new(pfuncretsym,init(aktprocsym^.name),@procinfo);
|
funcretsym:=new(pfuncretsym,init(aktprocsym^.name,@procinfo));
|
||||||
procinfo.retoffset:=-funcretsym^.address;
|
|
||||||
{ insert in local symtable }
|
{ insert in local symtable }
|
||||||
symtablestack^.insert(funcretsym);
|
symtablestack^.insert(funcretsym);
|
||||||
|
if ret_in_acc(procinfo.retdef) or (procinfo.retdef^.deftype=floatdef) then
|
||||||
|
procinfo.retoffset:=-funcretsym^.address;
|
||||||
|
procinfo.funcretsym:=funcretsym;
|
||||||
end;
|
end;
|
||||||
{$endif TEST_FUNCRET }
|
{$endif TEST_FUNCRET }
|
||||||
read_declarations(islibrary);
|
read_declarations(islibrary);
|
||||||
@ -1125,10 +1127,6 @@ unit pstatmnt;
|
|||||||
{$ifdef TEST_FUNCRET }
|
{$ifdef TEST_FUNCRET }
|
||||||
{ the space has been set in the local symtable }
|
{ the space has been set in the local symtable }
|
||||||
procinfo.retoffset:=-funcretsym^.address;
|
procinfo.retoffset:=-funcretsym^.address;
|
||||||
strdispose(funcretsym^._name);
|
|
||||||
{ lowercase name unreachable }
|
|
||||||
{ as it is handled differently }
|
|
||||||
funcretsym^._name:=strpnew('func_result');
|
|
||||||
{$else TEST_FUNCRET }
|
{$else TEST_FUNCRET }
|
||||||
{ align func result at 4 byte }
|
{ align func result at 4 byte }
|
||||||
procinfo.retoffset:=
|
procinfo.retoffset:=
|
||||||
@ -1238,7 +1236,11 @@ unit pstatmnt;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.34 1998-08-17 10:10:09 peter
|
Revision 1.35 1998-08-20 09:26:42 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.34 1998/08/17 10:10:09 peter
|
||||||
- removed OLDPPU
|
- removed OLDPPU
|
||||||
|
|
||||||
Revision 1.33 1998/08/12 19:39:30 peter
|
Revision 1.33 1998/08/12 19:39:30 peter
|
||||||
|
|||||||
@ -570,10 +570,17 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
procedure tscannerfile.inc_comment_level;
|
procedure tscannerfile.inc_comment_level;
|
||||||
|
var
|
||||||
|
oldaktfilepos : tfileposinfo;
|
||||||
begin
|
begin
|
||||||
inc(comment_level);
|
inc(comment_level);
|
||||||
if (comment_level>1) then
|
if (comment_level>1) then
|
||||||
Message1(scan_w_comment_level,tostr(comment_level));
|
begin
|
||||||
|
oldaktfilepos:=aktfilepos;
|
||||||
|
gettokenpos; { update for warning }
|
||||||
|
Message1(scan_w_comment_level,tostr(comment_level));
|
||||||
|
aktfilepos:=oldaktfilepos;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1552,7 +1559,11 @@ exit_label:
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.42 1998-08-19 14:57:51 peter
|
Revision 1.43 1998-08-20 09:26:45 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.42 1998/08/19 14:57:51 peter
|
||||||
* small fix for aktfilepos
|
* small fix for aktfilepos
|
||||||
|
|
||||||
Revision 1.41 1998/08/18 14:17:10 pierre
|
Revision 1.41 1998/08/18 14:17:10 pierre
|
||||||
|
|||||||
@ -600,12 +600,21 @@
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
tsym.init(n);
|
tsym.init(n);
|
||||||
|
typ:=funcretsym;
|
||||||
funcretprocinfo:=approcinfo;
|
funcretprocinfo:=approcinfo;
|
||||||
funcretdef:=pprocinfo(approcinfo)^.retdef;
|
funcretdef:=pprocinfo(approcinfo)^.retdef;
|
||||||
{ address valid for ret in param only }
|
{ address valid for ret in param only }
|
||||||
{ otherwise set by insert }
|
{ otherwise set by insert }
|
||||||
address:=pprocinfo(approcinfo)^.retoffset;
|
address:=pprocinfo(approcinfo)^.retoffset;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef GDB}
|
||||||
|
procedure tfuncretsym.concatstabto(asmlist : paasmoutput);
|
||||||
|
begin
|
||||||
|
{ Nothing to do here, it is done in genexitcode }
|
||||||
|
end;
|
||||||
|
{$endif GDB}
|
||||||
|
|
||||||
{$endif TEST_FUNCRET}
|
{$endif TEST_FUNCRET}
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
@ -1544,7 +1553,11 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.31 1998-08-17 10:10:12 peter
|
Revision 1.32 1998-08-20 09:26:46 pierre
|
||||||
|
+ funcret setting in underproc testing
|
||||||
|
compile with _dTEST_FUNCRET
|
||||||
|
|
||||||
|
Revision 1.31 1998/08/17 10:10:12 peter
|
||||||
- removed OLDPPU
|
- removed OLDPPU
|
||||||
|
|
||||||
Revision 1.30 1998/08/13 10:57:29 peter
|
Revision 1.30 1998/08/13 10:57:29 peter
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user