diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index 2d4ccd83cd..277d0630f9 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -654,9 +654,8 @@ implementation tstoreddef(hdef).generictokenbuf:=generictokenbuf; { Generic is never a type renaming } hdef.typesym:=newtype; + generictypelist.free; end; - if assigned(generictypelist) then - generictypelist.free; until (token<>_ID)or(in_structure and (idtoken in [_PRIVATE,_PROTECTED,_PUBLIC,_PUBLISHED,_STRICT])); { resolve type block forward declarations and restore a unit container for them } diff --git a/compiler/pdecobj.pas b/compiler/pdecobj.pas index a1a19b32af..7da97bf491 100644 --- a/compiler/pdecobj.pas +++ b/compiler/pdecobj.pas @@ -306,7 +306,7 @@ implementation while try_to_consume(_COMMA) do begin { use single_type instead of id_type for specialize support } - single_type(hdef,[stoAllowTypeDef,stoParseClassParent]); + single_type(hdef,[stoAllowSpecialization,stoParseClassParent]); if (hdef.typ<>objectdef) then begin if intf then @@ -442,7 +442,7 @@ implementation begin consume(_LKLAMMER); { use single_type instead of id_type for specialize support } - single_type(hdef,[stoAllowTypeDef, stoParseClassParent]); + single_type(hdef,[stoAllowSpecialization, stoParseClassParent]); if (not assigned(hdef)) or (hdef.typ<>objectdef) then begin diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index 22dfc612b7..b4c6b0142e 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -655,7 +655,7 @@ implementation else begin block_type:=bt_var_type; - single_type(hdef,[]); + single_type(hdef,[stoAllowSpecialization]); block_type:=bt_var; end; @@ -1271,7 +1271,7 @@ implementation if assigned(current_structdef) and (df_specialization in current_structdef.defoptions) then current_specializedef:=current_structdef; end; - single_type(pd.returndef,[]); + single_type(pd.returndef,[stoAllowSpecialization]); if is_dispinterface(pd.struct) and not is_automatable(pd.returndef) then Message1(type_e_not_automatable,pd.returndef.typename); diff --git a/compiler/ptype.pas b/compiler/ptype.pas index dd091dd415..855f934ae3 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -30,7 +30,12 @@ interface symtype,symdef,symbase; type - TSingleTypeOption=(stoIsForwardDef,stoAllowTypeDef,stoParseClassParent); + TSingleTypeOption=( + stoIsForwardDef, { foward declaration } + stoAllowTypeDef, { allow type definitions } + stoAllowSpecialization, { allow type specialization } + stoParseClassParent { parse of parent class type } + ); TSingleTypeOptions=set of TSingleTypeOption; procedure resolve_forward_types; @@ -497,7 +502,7 @@ implementation begin if try_to_consume(_SPECIALIZE) then begin - if not(stoAllowTypeDef in options) then + if ([stoAllowSpecialization,stoAllowTypeDef] * options = []) then begin Message(parser_e_no_local_para_def); @@ -544,7 +549,8 @@ implementation end; end; until not again; - if (stoAllowTypeDef in options)and(m_delphi in current_settings.modeswitches) then + if ([stoAllowSpecialization,stoAllowTypeDef] * options <> []) and + (m_delphi in current_settings.modeswitches) then dospecialize:=token=_LSHARPBRACKET; if dospecialize then generate_specialization(def,stoParseClassParent in options)