From: Viljar Indus <in...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- 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 1e855150673..aeae589dcad 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) -- 2.43.0