mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-24 06:44:38 +02:00
* proc-procvar crash fixed (tw2277)
This commit is contained in:
parent
41cd59e0e2
commit
54d8b64899
@ -93,7 +93,6 @@ interface
|
|||||||
|
|
||||||
{ subroutine handling }
|
{ subroutine handling }
|
||||||
function is_procsym_load(p:tnode):boolean;
|
function is_procsym_load(p:tnode):boolean;
|
||||||
function is_procsym_call(p:tnode):boolean;
|
|
||||||
procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
|
procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -648,16 +647,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ change a proc call to a procload for assignment to a procvar }
|
|
||||||
{ this can only happen for proc/function without arguments }
|
|
||||||
function is_procsym_call(p:tnode):boolean;
|
|
||||||
begin
|
|
||||||
is_procsym_call:=(p.nodetype=calln) and (tcallnode(p).left=nil) and
|
|
||||||
(((tcallnode(p).symtableprocentry.typ=procsym) and (tcallnode(p).right=nil)) or
|
|
||||||
(assigned(tcallnode(p).right) and (tcallnode(tcallnode(p).right).symtableprocentry.typ=varsym)));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ local routines can't be assigned to procvars }
|
{ local routines can't be assigned to procvars }
|
||||||
procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
|
procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
|
||||||
begin
|
begin
|
||||||
@ -1128,7 +1117,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.53 2002-12-11 22:39:24 peter
|
Revision 1.54 2002-12-22 16:34:49 peter
|
||||||
|
* proc-procvar crash fixed (tw2277)
|
||||||
|
|
||||||
|
Revision 1.53 2002/12/11 22:39:24 peter
|
||||||
* better error message when no operator is found for equal
|
* better error message when no operator is found for equal
|
||||||
|
|
||||||
Revision 1.52 2002/11/27 22:11:59 peter
|
Revision 1.52 2002/11/27 22:11:59 peter
|
||||||
|
|||||||
@ -1087,41 +1087,48 @@ implementation
|
|||||||
own resulttype.def. They will therefore always be incompatible with
|
own resulttype.def. They will therefore always be incompatible with
|
||||||
a procvar. Because isconvertable cannot check for procedures we
|
a procvar. Because isconvertable cannot check for procedures we
|
||||||
use an extra check for them.}
|
use an extra check for them.}
|
||||||
if (m_tp_procvar in aktmodeswitches) then
|
if (m_tp_procvar in aktmodeswitches) and
|
||||||
|
(resulttype.def.deftype=procvardef) then
|
||||||
begin
|
begin
|
||||||
if (resulttype.def.deftype=procvardef) and
|
if is_procsym_load(left) then
|
||||||
(is_procsym_load(left) or is_procsym_call(left)) then
|
|
||||||
begin
|
begin
|
||||||
if is_procsym_call(left) then
|
if (left.nodetype<>addrn) then
|
||||||
begin
|
begin
|
||||||
currprocdef:=Tprocsym(Tcallnode(left).symtableprocentry).search_procdef_byprocvardef(Tprocvardef(resulttype.def));
|
convtype:=tc_proc_2_procvar;
|
||||||
hp:=cloadnode.create_procvar(tprocsym(tcallnode(left).symtableprocentry),
|
{ Now check if the procedure we are going to assign to
|
||||||
currprocdef,tcallnode(left).symtableproc);
|
the procvar, is compatible with the procvar's type }
|
||||||
if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
|
if proc_to_procvar_equal(tprocsym(tloadnode(left).symtableentry).first_procdef,
|
||||||
assigned(tcallnode(left).methodpointer) then
|
tprocvardef(resulttype.def))=te_incompatible then
|
||||||
tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
|
CGMessage2(type_e_incompatible_types,tprocsym(tloadnode(left).symtableentry).first_procdef.typename,resulttype.def.typename);
|
||||||
resulttypepass(hp);
|
exit;
|
||||||
left.free;
|
|
||||||
left:=hp;
|
|
||||||
aprocdef:=tprocdef(left.resulttype.def);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if (left.nodetype<>addrn) then
|
|
||||||
aprocdef:=tprocsym(tloadnode(left).symtableentry).first_procdef;
|
|
||||||
end;
|
end;
|
||||||
convtype:=tc_proc_2_procvar;
|
end
|
||||||
{ Now check if the procedure we are going to assign to
|
else
|
||||||
the procvar, is compatible with the procvar's type }
|
if (left.nodetype=calln) and
|
||||||
if assigned(aprocdef) then
|
not assigned(tcallnode(left).left) then
|
||||||
begin
|
begin
|
||||||
if proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def))=te_incompatible then
|
if assigned(tcallnode(left).right) then
|
||||||
CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
|
hp:=tcallnode(left).right.getcopy
|
||||||
end
|
else
|
||||||
else
|
begin
|
||||||
CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
|
currprocdef:=Tprocsym(Tcallnode(left).symtableprocentry).search_procdef_byprocvardef(Tprocvardef(resulttype.def));
|
||||||
exit;
|
hp:=cloadnode.create_procvar(tprocsym(tcallnode(left).symtableprocentry),
|
||||||
end;
|
currprocdef,tcallnode(left).symtableproc);
|
||||||
|
if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
|
||||||
|
assigned(tcallnode(left).methodpointer) then
|
||||||
|
tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
|
||||||
|
end;
|
||||||
|
resulttypepass(hp);
|
||||||
|
left.free;
|
||||||
|
left:=hp;
|
||||||
|
convtype:=tc_proc_2_procvar;
|
||||||
|
{ Now check if the procedure we are going to assign to
|
||||||
|
the procvar, is compatible with the procvar's type }
|
||||||
|
if proc_to_procvar_equal(tprocdef(left.resulttype.def),
|
||||||
|
tprocvardef(resulttype.def))=te_incompatible then
|
||||||
|
CGMessage2(type_e_incompatible_types,tprocdef(left.resulttype.def).typename,resulttype.def.typename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Handle explicit type conversions }
|
{ Handle explicit type conversions }
|
||||||
@ -2015,7 +2022,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.95 2002-12-20 16:01:26 peter
|
Revision 1.96 2002-12-22 16:34:49 peter
|
||||||
|
* proc-procvar crash fixed (tw2277)
|
||||||
|
|
||||||
|
Revision 1.95 2002/12/20 16:01:26 peter
|
||||||
* don't allow class(classref) conversion
|
* don't allow class(classref) conversion
|
||||||
|
|
||||||
Revision 1.94 2002/12/05 14:27:26 florian
|
Revision 1.94 2002/12/05 14:27:26 florian
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user