]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Do not attempt to generate finalization actions with restricted profile
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 22 Dec 2023 11:46:29 +0000 (12:46 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 6 May 2024 09:11:31 +0000 (11:11 +0200)
These actions are not supported with this profile, but we were nevertheless
attempting to generate them for protected objects.

gcc/ada/

* exp_ch7.adb (Build_Finalizer.Process_Declarations): Do not call
Processing_Actions for simple protected objects if the profile is
restricted.
* exp_util.adb (Requires_Cleanup_Actions): Do not return True for
simple protected objects if the profile is restricted.

gcc/ada/exp_ch7.adb
gcc/ada/exp_util.adb

index 7a8457683c5c30ea6acf9d3b46d0a9c216ddf333..99142a527faa0238236416174e4b5ba994434bd3 100644 (file)
@@ -2526,9 +2526,12 @@ package body Exp_Ch7 is
                then
                   Processing_Actions (Decl);
 
-               --  Simple protected objects which use type System.Tasking.
+               --  Simple protected objects which use the type System.Tasking.
                --  Protected_Objects.Protection to manage their locks should
                --  be treated as controlled since they require manual cleanup.
+               --  but not for restricted run-time libraries (Ravenscar), see
+               --  also Cleanup_Protected_Object.
+
                --  The only exception is illustrated in the following example:
 
                --     package Pkg is
@@ -2561,6 +2564,7 @@ package body Exp_Ch7 is
                elsif Ekind (Obj_Id) = E_Variable
                  and then not In_Library_Level_Package_Body (Obj_Id)
                  and then Has_Simple_Protected_Object (Obj_Typ)
+                 and then not Restricted_Profile
                then
                   Processing_Actions (Decl, Is_Protected => True);
                end if;
index 732a02fc5d826633b97e07cf1963cefae55bc073..533127f26c2e1a3cc07e859797678d0d7597e2ed 100644 (file)
@@ -12999,9 +12999,12 @@ package body Exp_Util is
             then
                return True;
 
-            --  Simple protected objects which use type System.Tasking.
+            --  Simple protected objects which use the type System.Tasking.
             --  Protected_Objects.Protection to manage their locks should be
-            --  treated as controlled since they require manual cleanup.
+            --  treated as controlled since they require manual cleanup, but
+            --  not for restricted run-time libraries (Ravenscar), see also
+            --  Cleanup_Protected_Object in Exp_Ch7.
+
             --  The only exception is illustrated in the following example:
 
             --     package Pkg is
@@ -13034,6 +13037,7 @@ package body Exp_Util is
             elsif Ekind (Obj_Id) = E_Variable
               and then not In_Library_Level_Package_Body (Obj_Id)
               and then Has_Simple_Protected_Object (Obj_Typ)
+              and then not Restricted_Profile
             then
                return True;
             end if;