mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
compiler: don't allow generic object types (interfaces,dispinterfaces,objclasses,...) to have type,var,const sections if regular object types don't have them. currently only objects, classes and records are allowed to have nested type,var,const sections.
git-svn-id: trunk@16669 -
This commit is contained in:
parent
b7f1ea0a93
commit
101f545ad0
@ -1117,9 +1117,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed Array-Elemente und Record-Fel
|
||||
% (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
|
||||
% be packed at the bit level. For performance reasons, they cannot be
|
||||
% used as loop variables.
|
||||
parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb "generics" und Klassen erlaubt
|
||||
parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb records, objects und Klassen erlaubt
|
||||
% The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
|
||||
% generics and classes.
|
||||
% records, objects and classes.
|
||||
parser_e_cant_create_generics_of_this_type=03225_E_Dieser Typ kann nicht "generic" sein
|
||||
% Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
|
||||
parser_w_no_lineinfo_use_switch=03226_W_Die LINEINFO Unit nicht manuell laden. Verwende statt dessen den Compilerschalter -gl
|
||||
|
@ -1117,9 +1117,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed Array-Elemente und Record-Fel
|
||||
% (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
|
||||
% be packed at the bit level. For performance reasons, they cannot be
|
||||
% used as loop variables.
|
||||
parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb "generics" und Klassen erlaubt
|
||||
parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb records, objects und Klassen erlaubt
|
||||
% The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
|
||||
% generics and classes.
|
||||
% records, objects and classes.
|
||||
parser_e_cant_create_generics_of_this_type=03225_E_Dieser Typ kann nicht "generic" sein
|
||||
% Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
|
||||
parser_w_no_lineinfo_use_switch=03226_W_Die LINEINFO Unit nicht manuell laden. Verwende statt dessen den Compilerschalter -gl
|
||||
|
@ -1106,9 +1106,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed array elements and record fie
|
||||
% (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
|
||||
% be packed at the bit level. For performance reasons, they cannot be
|
||||
% used as loop variables.
|
||||
parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE and CONST are allowed only in generics and classes
|
||||
parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE and CONST are allowed only in records, objects and classes
|
||||
% The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
|
||||
% generics and classes.
|
||||
% records, objects and classes.
|
||||
parser_e_cant_create_generics_of_this_type=03225_E_This type can't be a generic
|
||||
% Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
|
||||
parser_w_no_lineinfo_use_switch=03226_W_Don't load LINEINFO unit manually, Use the -gl compiler switch instead
|
||||
|
@ -313,7 +313,7 @@ const
|
||||
parser_e_packed_element_no_var_addr=03221;
|
||||
parser_e_packed_dynamic_open_array=03222;
|
||||
parser_e_packed_element_no_loop=03223;
|
||||
parser_e_type_var_const_only_in_generics_and_classes=03224;
|
||||
parser_e_type_var_const_only_in_records_and_classes=03224;
|
||||
parser_e_cant_create_generics_of_this_type=03225;
|
||||
parser_w_no_lineinfo_use_switch=03226;
|
||||
parser_e_no_funcret_specified=03227;
|
||||
@ -877,7 +877,7 @@ const
|
||||
option_info=11024;
|
||||
option_help_pages=11025;
|
||||
|
||||
MsgTxtSize = 58270;
|
||||
MsgTxtSize = 58278;
|
||||
|
||||
MsgIdxMax : array[1..20] of longint=(
|
||||
24,88,304,97,82,54,111,22,202,63,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -618,17 +618,15 @@ implementation
|
||||
case token of
|
||||
_TYPE :
|
||||
begin
|
||||
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||
consume(_TYPE);
|
||||
object_member_blocktype:=bt_type;
|
||||
if not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_records_and_classes);
|
||||
consume(_TYPE);
|
||||
object_member_blocktype:=bt_type;
|
||||
end;
|
||||
_VAR :
|
||||
begin
|
||||
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||
if not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_records_and_classes);
|
||||
consume(_VAR);
|
||||
fields_allowed:=true;
|
||||
object_member_blocktype:=bt_general;
|
||||
@ -637,9 +635,8 @@ implementation
|
||||
end;
|
||||
_CONST:
|
||||
begin
|
||||
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||
if not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||
Message(parser_e_type_var_const_only_in_records_and_classes);
|
||||
consume(_CONST);
|
||||
object_member_blocktype:=bt_const;
|
||||
end;
|
||||
|
@ -1428,21 +1428,15 @@ implementation
|
||||
until not try_to_consume(_COMMA);
|
||||
consume(_COLON);
|
||||
|
||||
{ Don't search in the recordsymtable for types (can be nested!) }
|
||||
{ Don't search for types where they can't be:
|
||||
types can be only in objects, classes and records.
|
||||
This just speedup the search a bit. }
|
||||
recstlist.count:=0;
|
||||
if ([df_generic,df_specialization]*tdef(recst.defowner).defoptions=[]) and
|
||||
not is_class_or_object(tdef(recst.defowner)) and
|
||||
not is_record(tdef(recst.defowner)) then
|
||||
if not is_class_or_object(tdef(recst.defowner)) and
|
||||
not is_record(tdef(recst.defowner)) then
|
||||
begin
|
||||
recstlist.add(recst);
|
||||
symtablestack.pop(recst);
|
||||
while (symtablestack.top.symtabletype=recordsymtable) and
|
||||
([df_generic,df_specialization]*tdef(symtablestack.top.defowner).defoptions=[]) do
|
||||
begin
|
||||
recst:=tabstractrecordsymtable(symtablestack.top);
|
||||
recstlist.add(recst);
|
||||
symtablestack.pop(recst);
|
||||
end;
|
||||
end;
|
||||
read_anon_type(hdef,false);
|
||||
{ allow only static fields reference to struct where they are declared }
|
||||
|
Loading…
Reference in New Issue
Block a user