mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-24 02:39:11 +02:00
* if an operator overload in a structured type is invalid print an error only for the declaration and not the implementation as well
This fixes Mantis #31634 as far as I see it useful to; anything further would probably require extension of the message generation system by a context or such so that the compiler could write "Error in TFoo<Integer>: ..." instead of merely "Error: ..." or something like that. No test added due to the nature of the bug. git-svn-id: trunk@35748 -
This commit is contained in:
parent
199574c7c6
commit
8024fcd7ec
compiler
@ -79,7 +79,7 @@ interface
|
||||
procedure parse_record_proc_directives(pd:tabstractprocdef);
|
||||
function parse_proc_head(astruct:tabstractrecorddef;potype:tproctypeoption;isgeneric:boolean;genericdef:tdef;generictypelist:tfphashobjectlist;out pd:tprocdef):boolean;
|
||||
function parse_proc_dec(isclassmethod:boolean;astruct:tabstractrecorddef;isgeneric:boolean):tprocdef;
|
||||
procedure parse_proc_dec_finish(pd:tprocdef;isclassmethod:boolean);
|
||||
procedure parse_proc_dec_finish(pd:tprocdef;isclassmethod:boolean;astruct:tabstractrecorddef);
|
||||
|
||||
{ parse a record method declaration (not a (class) constructor/destructor) }
|
||||
function parse_record_method_dec(astruct: tabstractrecorddef; is_classdef: boolean;hadgeneric:boolean): tprocdef;
|
||||
@ -1254,7 +1254,7 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure parse_proc_dec_finish(pd:tprocdef;isclassmethod:boolean);
|
||||
procedure parse_proc_dec_finish(pd:tprocdef;isclassmethod:boolean;astruct:tabstractrecorddef);
|
||||
var
|
||||
locationstr: string;
|
||||
i: integer;
|
||||
@ -1494,12 +1494,15 @@ implementation
|
||||
else
|
||||
MessagePos(pd.fileinfo,type_e_type_id_expected);
|
||||
end;
|
||||
if (optoken in [_ASSIGNMENT,_OP_EXPLICIT]) and
|
||||
equal_defs(pd.returndef,tparavarsym(pd.parast.SymList[0]).vardef) and
|
||||
(pd.returndef.typ<>undefineddef) and (tparavarsym(pd.parast.SymList[0]).vardef.typ<>undefineddef) then
|
||||
message(parser_e_no_such_assignment)
|
||||
else if not isoperatoracceptable(pd,optoken) then
|
||||
Message(parser_e_overload_impossible);
|
||||
if not assigned(pd.struct) or assigned(astruct) then
|
||||
begin
|
||||
if (optoken in [_ASSIGNMENT,_OP_EXPLICIT]) and
|
||||
equal_defs(pd.returndef,tparavarsym(pd.parast.SymList[0]).vardef) and
|
||||
(pd.returndef.typ<>undefineddef) and (tparavarsym(pd.parast.SymList[0]).vardef.typ<>undefineddef) then
|
||||
message(parser_e_no_such_assignment)
|
||||
else if not isoperatoracceptable(pd,optoken) then
|
||||
Message(parser_e_overload_impossible);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
else
|
||||
@ -1556,7 +1559,7 @@ implementation
|
||||
begin
|
||||
{ pd=nil when it is a interface mapping }
|
||||
if assigned(pd) then
|
||||
parse_proc_dec_finish(pd,isclassmethod)
|
||||
parse_proc_dec_finish(pd,isclassmethod,astruct)
|
||||
else
|
||||
finish_intf_mapping;
|
||||
end
|
||||
@ -1576,7 +1579,7 @@ implementation
|
||||
begin
|
||||
{ pd=nil when it is an interface mapping }
|
||||
if assigned(pd) then
|
||||
parse_proc_dec_finish(pd,isclassmethod)
|
||||
parse_proc_dec_finish(pd,isclassmethod,astruct)
|
||||
else
|
||||
finish_intf_mapping;
|
||||
end
|
||||
@ -1592,7 +1595,7 @@ implementation
|
||||
else
|
||||
recover:=not parse_proc_head(astruct,potype_constructor,false,nil,nil,pd);
|
||||
if not recover then
|
||||
parse_proc_dec_finish(pd,isclassmethod);
|
||||
parse_proc_dec_finish(pd,isclassmethod,astruct);
|
||||
end;
|
||||
|
||||
_DESTRUCTOR :
|
||||
@ -1603,7 +1606,7 @@ implementation
|
||||
else
|
||||
recover:=not parse_proc_head(astruct,potype_destructor,false,nil,nil,pd);
|
||||
if not recover then
|
||||
parse_proc_dec_finish(pd,isclassmethod);
|
||||
parse_proc_dec_finish(pd,isclassmethod,astruct);
|
||||
end;
|
||||
else
|
||||
if (token=_OPERATOR) or
|
||||
@ -1618,7 +1621,7 @@ implementation
|
||||
parse_proc_head(astruct,potype_operator,false,nil,nil,pd);
|
||||
block_type:=old_block_type;
|
||||
if assigned(pd) then
|
||||
parse_proc_dec_finish(pd,isclassmethod)
|
||||
parse_proc_dec_finish(pd,isclassmethod,astruct)
|
||||
else
|
||||
begin
|
||||
{ recover }
|
||||
|
@ -1018,7 +1018,7 @@ uses
|
||||
pd.procsym:=psym
|
||||
else
|
||||
pd.procsym:=srsym;
|
||||
parse_proc_dec_finish(pd,po_classmethod in tprocdef(genericdef).procoptions);
|
||||
parse_proc_dec_finish(pd,po_classmethod in tprocdef(genericdef).procoptions,tprocdef(genericdef).struct);
|
||||
end;
|
||||
result:=pd;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user