diff options
Diffstat (limited to 'gcc/ada/exp_ch7.adb')
-rw-r--r-- | gcc/ada/exp_ch7.adb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 43920993ff9..615cc4137c0 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -9037,6 +9037,24 @@ package body Exp_Ch7 is elsif Is_Tagged_Type (Utyp) then Fin_Id := Find_Optional_Prim_Op (Utyp, TSS_Deep_Finalize); + -- Protected types: these also require finalization even though they + -- are not marked controlled explicitly. + + elsif Is_Protected_Type (Typ) then + -- Protected objects do not need to be finalized on restricted + -- runtimes. + + if Restricted_Profile then + return Empty; + + -- ??? Only handle the simple case for now. Will not support a record + -- or array containing protected objects. + + elsif Is_Simple_Protected_Type (Typ) then + Fin_Id := RTE (RE_Finalize_Protection); + else + raise Program_Error; + end if; else raise Program_Error; end if; @@ -9477,8 +9495,11 @@ package body Exp_Ch7 is -- The underlying type may not be present due to a missing full view. -- In this case freezing did not take place and there is no suitable -- [Deep_]Initialize primitive to call. + -- If Typ is protected then no additional processing is needed either. - if No (Utyp) then + if No (Utyp) + or else Is_Protected_Type (Typ) + then return Empty; end if; @@ -9500,7 +9521,7 @@ package body Exp_Ch7 is and then Present (Alias (Proc)) and then Is_Trivial_Subprogram (Alias (Proc))) then - return Make_Null_Statement (Loc); + return Empty; end if; -- The object reference may need another conversion depending on the |