diff --git a/compiler/msgidx.inc b/compiler/msgidx.inc index 358f57564c..ba438e7200 100644 --- a/compiler/msgidx.inc +++ b/compiler/msgidx.inc @@ -192,7 +192,7 @@ type tmsgconst=( sym_e_forward_not_resolved, sym_f_id_already_typed, sym_e_error_in_type_def, - sym_e_type_id_not_defined, + sym_e_forward_type_not_resolved, sym_e_only_static_in_static, sym_e_invalid_call_tvarsymmangledname, sym_f_type_must_be_rec_or_class, diff --git a/compiler/msgtxt.inc b/compiler/msgtxt.inc index a17e1631af..2b679779e6 100644 --- a/compiler/msgtxt.inc +++ b/compiler/msgtxt.inc @@ -196,10 +196,10 @@ const msgtxt : array[0..00088,1..240] of char=(+ 'F_Internal Error in SymTableStack()'#000+ 'E_Duplicate identifier $1'#000+ 'E_Unknown identifier $1'#000+ - 'E_Forward declaration not solved: $1'#000+ + 'E_Forward declaration not solved $1'#000+ 'F_Identifier type already defined as type'#000+ - 'E_Error in type defeni','tion'#000+ - 'E_Type identifier not defined'#000+ + 'E_Error in type definit','ion'#000+ + 'E_Forward type not resolved $1'#000+ 'E_Only static variables can be used in static methods or outside metho'+ 'ds'#000+ 'E_Invalid call to tvarsym.mangledname()'#000+ diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index 25974c7e4c..60c200344c 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -1462,31 +1462,38 @@ unit pdecl; record_dec:=new(precdef,init(symtable)); end; + { search in symtablestack used, but not defined type } procedure testforward_types(p : psym);{$ifndef FPC}far;{$endif} - var - recsymtable : psymtable; - + recsymtable : psymtable; + oldaktfilepos : tfileposinfo; begin - if (p^.typ=typesym) then + if not(p^.typ=typesym) then + exit; if ((p^.properties and sp_forwarddef)<>0) then - Message(sym_e_type_id_not_defined) - else if (ptypesym(p)^.definition^.deftype=recorddef) or - (ptypesym(p)^.definition^.deftype=objectdef) then begin - if (ptypesym(p)^.definition^.deftype=recorddef) then - recsymtable:=precdef(ptypesym(p)^.definition)^.symtable - else - recsymtable:=pobjectdef(ptypesym(p)^.definition)^.publicsyms; -{$ifdef tp} - recsymtable^.foreach(testforward_types); -{$else} - recsymtable^.foreach(@testforward_types); -{$endif} - end; + oldaktfilepos:=aktfilepos; + aktfilepos:=p^.fileinfo; + Message1(sym_e_forward_type_not_resolved,p^.name); + aktfilepos:=oldaktfilepos; + end + else + if (ptypesym(p)^.definition^.deftype in [recorddef,objectdef]) then + begin + if (ptypesym(p)^.definition^.deftype=recorddef) then + recsymtable:=precdef(ptypesym(p)^.definition)^.symtable + else + recsymtable:=pobjectdef(ptypesym(p)^.definition)^.publicsyms; + {$ifdef tp} + recsymtable^.foreach(testforward_types); + {$else} + recsymtable^.foreach(@testforward_types); + {$endif} + end; end; + { reads a type definition and returns a pointer to it } function read_type(const name : stringid) : pdef; @@ -2041,7 +2048,10 @@ unit pdecl; end. { $Log$ - Revision 1.61 1998-10-02 09:23:24 peter + Revision 1.62 1998-10-02 17:06:02 peter + * better error message for unresolved forward types + + Revision 1.61 1998/10/02 09:23:24 peter * fixed error msg with type l= * block_type bt_const is now set in read_const_dec