diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-02-26 13:13:34 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2024-02-26 13:19:53 +0100 |
commit | 39c07c5a3bf4a865175727bf60d5758372543b87 (patch) | |
tree | 1de920befefdbb9e2893ed2bd5b0500cc2f39d12 /gcc/ada/sem_res.adb | |
parent | bb98f71bac8aace4e685e648a81dfaf365123833 (diff) | |
download | gcc-39c07c5a3bf4a865175727bf60d5758372543b87.zip gcc-39c07c5a3bf4a865175727bf60d5758372543b87.tar.gz gcc-39c07c5a3bf4a865175727bf60d5758372543b87.tar.bz2 |
Finalization of object allocated by anonymous access designating local type
The finalization of objects dynamically allocated through an anonymous
access type is deferred to the enclosing library unit in the current
implementation and a warning is given on each of them.
However this cannot be done if the designated type is local, because this
would generate dangling references to the local finalization routine, so
the finalization needs to be dropped in this case and the warning adjusted.
gcc/ada/
PR ada/113893
* exp_ch7.adb (Build_Anonymous_Master): Do not build the master
for a local designated type.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Force Needs_Fin
to false if no finalization master is attached to an access type
and assert that it is anonymous in this case.
* sem_res.adb (Resolve_Allocator): Mention that the object might
not be finalized at all in the warning given when the type is an
anonymous access-to-controlled type.
gcc/testsuite/
* gnat.dg/access10.adb: New test.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 8e9714c..075c0d8 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -5679,19 +5679,19 @@ package body Sem_Res is Set_Is_Dynamic_Coextension (N, False); Set_Is_Static_Coextension (N, False); - -- Anonymous access-to-controlled objects are not finalized on - -- time because this involves run-time ownership and currently - -- this property is not available. In rare cases the object may - -- not be finalized at all. Warn on potential issues involving - -- anonymous access-to-controlled objects. + -- Objects allocated through anonymous access types are not + -- finalized on time because this involves run-time ownership + -- and currently this property is not available. In rare cases + -- the object might not be finalized at all. Warn on potential + -- issues involving anonymous access-to-controlled types. if Ekind (Typ) = E_Anonymous_Access_Type and then Is_Controlled_Active (Desig_T) then Error_Msg_N - ("??object designated by anonymous access object might " + ("??object designated by anonymous access value might " & "not be finalized until its enclosing library unit " - & "goes out of scope", N); + & "goes out of scope, or not be finalized at all", N); Error_Msg_N ("\use named access type instead", N); end if; end if; |