[Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities

Message ID 20210616084355.GA95401@adacore.com
State New
Headers show
Series
  • [Ada] Non-static Interrupt_Priority allowed with restriction Static_Priorities
Related show

Commit Message

Pierre-Marie de Rodat June 16, 2021, 8:43 a.m.
This patch fixes an issue in the compiler whereby a non-static
expression is allowed as an argument to aspect Interrupt_Priority
despite restriction Static_Priorities being in effect.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch13.adb (Make_Aitem_Pragma): Check for static expressions
	in Priority aspect arguments for restriction Static_Priorities.

Patch

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -3382,6 +3382,13 @@  package body Sem_Ch13 is
                   | Aspect_Interrupt_Priority
                   | Aspect_Priority
                =>
+                  --  Verify the expression is static when Static_Priorities is
+                  --  enabled.
+
+                  if not Is_OK_Static_Expression (Expr) then
+                     Check_Restriction (Static_Priorities, Expr);
+                  end if;
+
                   if Nkind (N) in N_Subprogram_Body | N_Subprogram_Declaration
                   then
                      --  Analyze the aspect expression