mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 02:30:41 +01:00
+ add a new symtable option sto_has_non_trivial_init that is true if the symtable contains a symbol with an
Initialize() operator (like sto_needs_init_final this flag is calculated on demand) * increase PPU version git-svn-id: trunk@39252 -
This commit is contained in:
parent
80ed66f349
commit
cc153176f3
@ -635,8 +635,11 @@ type
|
||||
sto_has_helper, { contains at least one helper symbol }
|
||||
sto_has_generic, { contains at least one generic symbol }
|
||||
sto_has_operator, { contains at least one operator overload }
|
||||
sto_needs_init_final { the symtable needs initialization and/or
|
||||
sto_needs_init_final, { the symtable needs initialization and/or
|
||||
finalization of variables/constants }
|
||||
sto_has_non_trivial_init { contains at least on managed type that is not
|
||||
initialized to zero (e.g. a record with management
|
||||
operators }
|
||||
);
|
||||
tsymtableoptions = set of tsymtableoption;
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ interface
|
||||
procedure check_forwards;
|
||||
procedure checklabels;
|
||||
function needs_init_final : boolean; virtual;
|
||||
function has_non_trivial_init:boolean;virtual;
|
||||
procedure testfordefaultproperty(sym:TObject;arg:pointer);
|
||||
procedure register_children;
|
||||
end;
|
||||
@ -1070,7 +1071,7 @@ implementation
|
||||
|
||||
procedure TStoredSymtable._needs_init_final(sym:TObject;arg:pointer);
|
||||
begin
|
||||
if sto_needs_init_final in tableoptions then
|
||||
if [sto_needs_init_final,sto_has_non_trivial_init] <= tableoptions then
|
||||
exit;
|
||||
{ don't check static symbols - they can be present in structures only and
|
||||
always have a reference to a symbol defined on unit level }
|
||||
@ -1085,6 +1086,9 @@ implementation
|
||||
if assigned(tabstractvarsym(sym).vardef) and
|
||||
is_managed_type(tabstractvarsym(sym).vardef) then
|
||||
include(tableoptions,sto_needs_init_final);
|
||||
if is_record((tabstractvarsym(sym).vardef)) and
|
||||
(mop_initialize in trecordsymtable(trecorddef(tabstractvarsym(sym).vardef).symtable).managementoperators) then
|
||||
include(tableoptions,sto_has_non_trivial_init);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1095,6 +1099,7 @@ implementation
|
||||
if not init_final_check_done then
|
||||
begin
|
||||
exclude(tableoptions,sto_needs_init_final);
|
||||
exclude(tableoptions,sto_has_non_trivial_init);
|
||||
SymList.ForEachCall(@_needs_init_final,nil);
|
||||
init_final_check_done:=true;
|
||||
end;
|
||||
@ -1108,6 +1113,13 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function tstoredsymtable.has_non_trivial_init:boolean;
|
||||
begin
|
||||
do_init_final_check;
|
||||
result:=sto_has_non_trivial_init in tableoptions;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
TAbstractRecordSymtable
|
||||
****************************************************************************}
|
||||
|
||||
@ -683,7 +683,8 @@ const
|
||||
(mask:sto_has_helper; str:'Has helper'),
|
||||
(mask:sto_has_generic; str:'Has generic'),
|
||||
(mask:sto_has_operator; str:'Has operator'),
|
||||
(mask:sto_needs_init_final;str:'Needs init final table')
|
||||
(mask:sto_needs_init_final;str:'Needs init final table'),
|
||||
(mask:sto_has_non_trivial_init;str:'Has non trivial init')
|
||||
);
|
||||
var
|
||||
options : tsymtableoptions;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user