]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add special handling for Runtime and Static in Policy_In_Effect
authorViljar Indus <indus@adacore.com>
Tue, 29 Jul 2025 08:20:39 +0000 (11:20 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 9 Sep 2025 12:39:51 +0000 (14:39 +0200)
When one of those levels is present then we should not look
for the policy in the policy stack but rather determine the
policy immidiately like we do in Check_Applicable_Policy.

gcc/ada/ChangeLog:

* sem_util.adb (Policy_In_Effect): Add special handling
for Runtime and Static values.

gcc/ada/sem_util.adb

index 1e855150673eaf82f79dd879d00b713005b4ba40..aeae589dcad496b4eb740055a1a192b3f8c4fd08 100644 (file)
@@ -26574,6 +26574,8 @@ package body Sem_Util is
 
       Kind : Name_Id;
 
+      Level_Id : Entity_Id;
+
    --  Start of processing for Policy_In_Effect
 
    begin
@@ -26581,10 +26583,19 @@ package body Sem_Util is
          raise Program_Error;
       end if;
 
-      if Present (Level)
-        and then not Is_Valid_Assertion_Level (Level)
-      then
-         raise Program_Error;
+      if Present (Level) then
+         Level_Id := Get_Assertion_Level (Level);
+         if No (Level_Id) then
+            raise Program_Error;
+         end if;
+
+         if Level_Id = Standard_Level_Runtime then
+            return Name_Check;
+         elsif Level_Id = Standard_Level_Static
+           or else Depends_On_Level (Level_Id, Standard_Level_Static)
+         then
+            return Name_Ignore;
+         end if;
       end if;
 
       --  Inspect all policy pragmas that appear within scopes (if any)