mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 03:50:36 +02:00
* return cnothingn and give error when the operator is not overloaded
This commit is contained in:
parent
cd76bf8ded
commit
61f824e259
@ -117,6 +117,7 @@ interface
|
|||||||
allow_array_constructor : boolean = false;
|
allow_array_constructor : boolean = false;
|
||||||
|
|
||||||
{ check operator args and result type }
|
{ check operator args and result type }
|
||||||
|
function isbinaryoperatoroverloadable(treetyp:tnodetype;ld:tdef;lt:tnodetype;rd:tdef;rt:tnodetype) : boolean;
|
||||||
function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
|
function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
|
||||||
function isunaryoverloaded(var t : tnode) : boolean;
|
function isunaryoverloaded(var t : tnode) : boolean;
|
||||||
function isbinaryoverloaded(var t : tnode) : boolean;
|
function isbinaryoverloaded(var t : tnode) : boolean;
|
||||||
@ -149,7 +150,7 @@ implementation
|
|||||||
cutils,verbose,globals,
|
cutils,verbose,globals,
|
||||||
symtable,
|
symtable,
|
||||||
defutil,defcmp,
|
defutil,defcmp,
|
||||||
pass_1,ncnv,nld,nmem,ncal,nmat,nutils,
|
pass_1,nbas,ncnv,nld,nmem,ncal,nmat,nutils,
|
||||||
cgbase,procinfo
|
cgbase,procinfo
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -389,18 +390,26 @@ implementation
|
|||||||
begin
|
begin
|
||||||
result:=false;
|
result:=false;
|
||||||
operpd:=nil;
|
operpd:=nil;
|
||||||
|
|
||||||
{ load easier access variables }
|
{ load easier access variables }
|
||||||
ld:=tunarynode(t).left.resulttype.def;
|
ld:=tunarynode(t).left.resulttype.def;
|
||||||
if not isunaryoperatoroverloadable(t.nodetype,ld) then
|
if not isunaryoperatoroverloadable(t.nodetype,ld) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
{ operator overload is possible }
|
||||||
|
result:=true;
|
||||||
|
|
||||||
case t.nodetype of
|
case t.nodetype of
|
||||||
notn:
|
notn:
|
||||||
optoken:=_OP_NOT;
|
optoken:=_OP_NOT;
|
||||||
unaryminusn:
|
unaryminusn:
|
||||||
optoken:=_MINUS;
|
optoken:=_MINUS;
|
||||||
else
|
else
|
||||||
exit;
|
begin
|
||||||
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
|
t:=cnothingnode.create;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ generate parameter nodes }
|
{ generate parameter nodes }
|
||||||
@ -414,6 +423,7 @@ implementation
|
|||||||
CGMessage(parser_e_operator_not_overloaded);
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
candidates.free;
|
candidates.free;
|
||||||
ppn.free;
|
ppn.free;
|
||||||
|
t:=cnothingnode.create;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -428,9 +438,10 @@ implementation
|
|||||||
{ exit when no overloads are found }
|
{ exit when no overloads are found }
|
||||||
if cand_cnt=0 then
|
if cand_cnt=0 then
|
||||||
begin
|
begin
|
||||||
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
candidates.free;
|
candidates.free;
|
||||||
ppn.free;
|
ppn.free;
|
||||||
result:=false;
|
t:=cnothingnode.create;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -457,8 +468,6 @@ implementation
|
|||||||
{ we already know the procdef to use, so it can
|
{ we already know the procdef to use, so it can
|
||||||
skip the overload choosing in callnode.det_resulttype }
|
skip the overload choosing in callnode.det_resulttype }
|
||||||
tcallnode(t).procdefinition:=operpd;
|
tcallnode(t).procdefinition:=operpd;
|
||||||
|
|
||||||
result:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -480,7 +489,9 @@ implementation
|
|||||||
if not isbinaryoperatoroverloadable(t.nodetype,ld,tbinarynode(t).left.nodetype,rd,tbinarynode(t).right.nodetype) then
|
if not isbinaryoperatoroverloadable(t.nodetype,ld,tbinarynode(t).left.nodetype,rd,tbinarynode(t).right.nodetype) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
isbinaryoverloaded:=true;
|
{ operator overload is possible }
|
||||||
|
result:=true;
|
||||||
|
|
||||||
case t.nodetype of
|
case t.nodetype of
|
||||||
equaln,
|
equaln,
|
||||||
unequaln :
|
unequaln :
|
||||||
@ -520,7 +531,11 @@ implementation
|
|||||||
shrn :
|
shrn :
|
||||||
optoken:=_OP_SHR;
|
optoken:=_OP_SHR;
|
||||||
else
|
else
|
||||||
exit;
|
begin
|
||||||
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
|
t:=cnothingnode.create;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ generate parameter nodes }
|
{ generate parameter nodes }
|
||||||
@ -554,7 +569,7 @@ implementation
|
|||||||
CGMessage(parser_e_operator_not_overloaded);
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
candidates.free;
|
candidates.free;
|
||||||
ppn.free;
|
ppn.free;
|
||||||
result:=false;
|
t:=cnothingnode.create;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -569,9 +584,10 @@ implementation
|
|||||||
{ exit when no overloads are found }
|
{ exit when no overloads are found }
|
||||||
if cand_cnt=0 then
|
if cand_cnt=0 then
|
||||||
begin
|
begin
|
||||||
|
CGMessage(parser_e_operator_not_overloaded);
|
||||||
candidates.free;
|
candidates.free;
|
||||||
ppn.free;
|
ppn.free;
|
||||||
result:=false;
|
t:=cnothingnode.create;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1896,7 +1912,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.81 2004-02-24 16:12:39 peter
|
Revision 1.82 2004-02-26 16:11:09 peter
|
||||||
|
* return cnothingn and give error when the operator is not overloaded
|
||||||
|
|
||||||
|
Revision 1.81 2004/02/24 16:12:39 peter
|
||||||
* operator overload chooses rewrite
|
* operator overload chooses rewrite
|
||||||
* overload choosing is now generic and moved to htypechk
|
* overload choosing is now generic and moved to htypechk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user