mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-03 01:09:40 +01:00
compiler: fix tgeneric11 test:
- add stoAllowSpecialization to TSingleTypeOption enum to differentiate between any new type definition and only generic specialization - allow only specializations for class parents (not any other type definition) - allow specialization for method arguments and return types (maybe this must be allowed only in delphi mode but in this case tgeneric11 must fail) git-svn-id: trunk@16738 -
This commit is contained in:
parent
a40fe9c078
commit
86482658a8
@ -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 }
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user