From b1c66a106ef846790d35e11caabcb357875b8c51 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 7 Feb 2006 07:58:37 +0000 Subject: [PATCH] * more dup id fixes git-svn-id: trunk@2465 - --- compiler/pdecl.pas | 2 +- compiler/ptype.pas | 57 ++++++++++++++++++++++++++----------------- compiler/scanner.pas | 2 +- compiler/symtable.pas | 25 +++++++++++++------ 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index e8abe9f848..48e59b9785 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -301,7 +301,7 @@ implementation classrefdef : begin { classrefdef inherits from pointerdef } - hpd:=tpointerdef(pd).pointertype.def; + hpd:=tabstractpointerdef(pd).pointertype.def; { still a forward def ? } if hpd.deftype=forwarddef then begin diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 3dacd55f17..52842ec3b7 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -248,33 +248,44 @@ implementation procedure single_type(var tt:ttype;isforwarddef:boolean); var t2 : ttype; + again : boolean; begin - case token of - _STRING: - string_dec(tt); + repeat + again:=false; + case token of + _STRING: + string_dec(tt); - _FILE: - begin - consume(_FILE); - if token=_OF then - begin - consume(_OF); - single_type(t2,false); - tt.setdef(tfiledef.createtyped(t2)); - end - else - tt:=cfiletype; - end; + _FILE: + begin + consume(_FILE); + if try_to_consume(_OF) then + begin + single_type(t2,false); + tt.setdef(tfiledef.createtyped(t2)); + end + else + tt:=cfiletype; + end; - _ID: - id_type(tt,isforwarddef); + _ID: + begin + if try_to_consume(_SPECIALIZE) then + begin + block_type:=bt_specialize; + again:=true; + end + else + id_type(tt,isforwarddef); + end; - else - begin - message(type_e_type_id_expected); - tt:=generrortype; - end; - end; + else + begin + message(type_e_type_id_expected); + tt:=generrortype; + end; + end; + until not again; end; { reads a record declaration } diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 97728b4615..3b6df7de27 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -3365,7 +3365,7 @@ In case not, the value returned can be arbitrary. begin readchar; c:=upcase(c); - if (block_type=bt_type) or + if (block_type in [bt_type,bt_specialize]) or (lasttoken=_ID) or (lasttoken=_NIL) or (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then begin diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 49f7efe992..c9ca0d151e 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -1069,14 +1069,17 @@ implementation var hsym : tsym; begin - result:=inherited checkduplicate(sym); - if result then + result:=false; + if not assigned(defowner) then + internalerror(200602061); + + if (m_duplicate_names in aktmodeswitches) and + (sym.typ in [paravarsym,localvarsym]) then exit; { check for duplicate field, parameter or local names also in inherited classes } if (sym.typ in [fieldvarsym,paravarsym,localvarsym]) and - assigned(defowner) and ( not(m_delphi in aktmodeswitches) or is_object(tdef(defowner)) @@ -1090,6 +1093,12 @@ implementation DuplicateSym(sym,hsym); result:=true; end; + end + else + begin + result:=inherited checkduplicate(sym); + if result then + exit; end; end; @@ -1173,7 +1182,8 @@ implementation { check objectsymtable, skip this for funcret sym because that will always be positive because it has the same name as the procsym } - if not is_funcret_sym(sym) and + if not(m_duplicate_names in aktmodeswitches) and + not is_funcret_sym(sym) and (defowner.deftype=procdef) and assigned(tprocdef(defowner)._class) and (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then @@ -1198,9 +1208,10 @@ implementation result:=inherited checkduplicate(sym); if result then exit; - if (defowner.deftype=procdef) and - assigned(tprocdef(defowner)._class) and - (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then + if not(m_duplicate_names in aktmodeswitches) and + (defowner.deftype=procdef) and + assigned(tprocdef(defowner)._class) and + (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then result:=tprocdef(defowner)._class.symtable.checkduplicate(sym); end;