https://gcc.gnu.org/g:b0b81e8e205035056b71c3f5c4daf00720958355

commit r16-3687-gb0b81e8e205035056b71c3f5c4daf00720958355
Author: Viljar Indus <[email protected]>
Date:   Tue Jul 29 11:20:39 2025 +0300

    ada: Add special handling for Runtime and Static in Policy_In_Effect
    
    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.

Diff:
---
 gcc/ada/sem_util.adb | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 1e855150673e..aeae589dcad4 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -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)

Reply via email to