mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-08 06:39:39 +02:00
* fixed overload checking for delphi. Empty parameters are only
allowed in implementation and not when the forward declaration contains overload directive
This commit is contained in:
parent
ea060c924d
commit
7321b8436e
@ -1676,13 +1676,23 @@ const
|
|||||||
begin
|
begin
|
||||||
hd:=pd.nextoverloaded;
|
hd:=pd.nextoverloaded;
|
||||||
|
|
||||||
{ check the parameters }
|
{ check the parameters, for delphi/tp it is possible to
|
||||||
if (not(m_repeat_forward in aktmodeswitches) and
|
leave the parameters away in the implementation (forwarddef=false).
|
||||||
(aktprocsym.definition.maxparacount=0)) or
|
But for an overload declared function this is not allowed }
|
||||||
(equal_paras(aktprocsym.definition.para,hd.para,cp_none) and
|
if { check if empty implementation arguments match is allowed }
|
||||||
{ for operators equal_paras is not enough !! }
|
(
|
||||||
((aktprocsym.definition.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
|
not(m_repeat_forward in aktmodeswitches) and
|
||||||
is_equal(hd.rettype.def,aktprocsym.definition.rettype.def))) then
|
(aktprocsym.definition.maxparacount=0) and
|
||||||
|
not(aktprocsym.definition.forwarddef) and
|
||||||
|
not(po_overload in hd.procoptions)
|
||||||
|
) or
|
||||||
|
{ check arguments }
|
||||||
|
(
|
||||||
|
equal_paras(aktprocsym.definition.para,hd.para,cp_none) and
|
||||||
|
{ for operators equal_paras is not enough !! }
|
||||||
|
((aktprocsym.definition.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
|
||||||
|
is_equal(hd.rettype.def,aktprocsym.definition.rettype.def))
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
if not equal_paras(aktprocsym.definition.para,hd.para,cp_all) and
|
if not equal_paras(aktprocsym.definition.para,hd.para,cp_all) and
|
||||||
((m_repeat_forward in aktmodeswitches) or
|
((m_repeat_forward in aktmodeswitches) or
|
||||||
@ -1796,34 +1806,22 @@ const
|
|||||||
{ copy all aliasnames }
|
{ copy all aliasnames }
|
||||||
while not aktprocsym.definition.aliasnames.empty do
|
while not aktprocsym.definition.aliasnames.empty do
|
||||||
hd.aliasnames.insert(aktprocsym.definition.aliasnames.getfirst);
|
hd.aliasnames.insert(aktprocsym.definition.aliasnames.getfirst);
|
||||||
{ switch parast for warning in implementation PM
|
|
||||||
This can't be done, because the parasymtable is also
|
|
||||||
stored in the ppu and loaded when only the interface
|
|
||||||
units are loaded. Using the implementation parast can
|
|
||||||
cause problems with redefined types in units only included
|
|
||||||
in the implementation uses (PFV) }
|
|
||||||
{if (m_repeat_forward in aktmodeswitches) or
|
|
||||||
aktprocsym.definition.haspara then
|
|
||||||
begin
|
|
||||||
storeparast:=hd.parast;
|
|
||||||
hd.parast:=aktprocsym.definition.parast;
|
|
||||||
aktprocsym.definition.parast:=storeparast;
|
|
||||||
end;}
|
|
||||||
if pd=aktprocsym.definition then
|
if pd=aktprocsym.definition then
|
||||||
p:=nil
|
p:=nil
|
||||||
else
|
else
|
||||||
p:=pd;
|
p:=pd;
|
||||||
aktprocsym.definition:=hd;
|
aktprocsym.definition:=hd;
|
||||||
check_identical_proc:=true;
|
check_identical_proc:=true;
|
||||||
|
break;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ abstract methods aren't forward defined, but this }
|
{ abstract methods aren't forward defined, but this }
|
||||||
{ needs another error message }
|
{ needs another error message }
|
||||||
if not(po_abstractmethod in pd.nextoverloaded.procoptions) then
|
if (po_abstractmethod in pd.nextoverloaded.procoptions) then
|
||||||
MessagePos(aktprocsym.definition.fileinfo,parser_e_overloaded_have_same_parameters)
|
MessagePos(aktprocsym.definition.fileinfo,parser_e_abstract_no_definition)
|
||||||
else
|
else
|
||||||
MessagePos(aktprocsym.definition.fileinfo,parser_e_abstract_no_definition);
|
MessagePos(aktprocsym.definition.fileinfo,parser_e_overloaded_have_same_parameters);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ check for allowing overload directive }
|
{ check for allowing overload directive }
|
||||||
@ -1831,14 +1829,14 @@ const
|
|||||||
begin
|
begin
|
||||||
{ overload directive turns on overloading }
|
{ overload directive turns on overloading }
|
||||||
if ((po_overload in aktprocsym.definition.procoptions) or
|
if ((po_overload in aktprocsym.definition.procoptions) or
|
||||||
((po_overload in hd.procoptions))) then
|
(po_overload in hd.procoptions)) then
|
||||||
begin
|
begin
|
||||||
{ check if all procs have overloading, but not if the proc was
|
{ check if all procs have overloading, but not if the proc was
|
||||||
already declared forward, then the check is already done }
|
already declared forward, then the check is already done }
|
||||||
if not(hd.hasforward) and
|
if not(hd.hasforward or
|
||||||
(aktprocsym.definition.forwarddef=hd.forwarddef) and
|
(aktprocsym.definition.forwarddef<>hd.forwarddef) or
|
||||||
not((po_overload in aktprocsym.definition.procoptions) and
|
((po_overload in aktprocsym.definition.procoptions) and
|
||||||
((po_overload in hd.procoptions))) then
|
(po_overload in hd.procoptions))) then
|
||||||
begin
|
begin
|
||||||
MessagePos1(aktprocsym.definition.fileinfo,parser_e_no_overload_for_all_procs,aktprocsym.realname);
|
MessagePos1(aktprocsym.definition.fileinfo,parser_e_no_overload_for_all_procs,aktprocsym.realname);
|
||||||
break;
|
break;
|
||||||
@ -1888,7 +1886,12 @@ const
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.28 2001-07-01 20:16:16 peter
|
Revision 1.29 2001-07-09 21:11:14 peter
|
||||||
|
* fixed overload checking for delphi. Empty parameters are only
|
||||||
|
allowed in implementation and not when the forward declaration
|
||||||
|
contains overload directive
|
||||||
|
|
||||||
|
Revision 1.28 2001/07/01 20:16:16 peter
|
||||||
* alignmentinfo record added
|
* alignmentinfo record added
|
||||||
* -Oa argument supports more alignment settings that can be specified
|
* -Oa argument supports more alignment settings that can be specified
|
||||||
per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
|
per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
|
||||||
|
Loading…
Reference in New Issue
Block a user