From a3d1ca0127cf4ca6bb8d0da5a525d17dfc58cbc9 Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Thu, 11 Jul 2019 08:01:39 +0000 Subject: [Ada] Missing finalization of private protected type This patch updates the analysis of protected types to properly mark the type as having controlled components when it contains at least one such component. This in turn marks a potential partial view as requiring finalization actions. ------------ -- Source -- ------------ -- types.ads with Ada.Finalization; use Ada.Finalization; package Types is type Ctrl_Typ is new Controlled with null record; procedure Finalize (Obj : in out Ctrl_Typ); type Prot_Typ is limited private; private protected type Prot_Typ is private Comp : Ctrl_Typ; end Prot_Typ; end Types; -- types.adb with Ada.Text_IO; use Ada.Text_IO; package body Types is procedure Finalize (Obj : in out Ctrl_Typ) is begin Put_Line ("finalize"); end Finalize; protected body Prot_Typ is end Prot_Typ; end Types; -- main.adb with Types; use Types; procedure Main is Obj : Prot_Typ; begin null; end Main; 2019-07-11 Hristian Kirtchev gcc/ada/ * exp_util.ads, exp_util.adb (Needs_Finalization): Move to Sem_Util. * sem_ch9.adb (Analyze_Protected_Definition): Code cleanup. Mark the protected type as having controlled components when it contains at least one such component. * sem_util.ads, sem_util.adb (Needs_Finalization): New function. From-SVN: r273383 --- gcc/ada/exp_util.ads | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gcc/ada/exp_util.ads') diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 7cb9d2d..c0848c7 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -944,10 +944,6 @@ package Exp_Util is -- consist of constants, when the object has a nontrivial initialization -- or is controlled. - function Needs_Finalization (Typ : Entity_Id) return Boolean; - -- Determine whether type Typ is controlled and this requires finalization - -- actions. - function Non_Limited_Designated_Type (T : Entity_Id) return Entity_Id; -- An anonymous access type may designate a limited view. Check whether -- non-limited view is available during expansion, to examine components -- cgit v1.1