]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Implement representation aspect Max_Entry_Queue_Length
authorJose Ruiz <ruiz@adacore.com>
Thu, 7 Mar 2024 10:20:03 +0000 (11:20 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 20 May 2024 07:47:02 +0000 (09:47 +0200)
Enforce Max_Entry_Queue_Length (and its
synonym Max_Entry_Queue_Depth) when applied to individual
protected entries.

gcc/ada/

* exp_ch9.adb (Expand_N_Protected_Type_Declaration): Clarify
comments.
* sem_prag.adb (Analyze_Pragma): Check for duplicates
Max_Entry_Queue_Length, Max_Entry_Queue_Depth and Max_Queue_Length
for the same protected entry.
* sem_util.adb (Get_Max_Queue_Length): Take into account all three
representation aspects that can be used to set this restriction.
(Has_Max_Queue_Length): Likewise.
* doc/gnat_rm/implementation_defined_pragmas.rst:
(pragma Max_Queue_Length): Fix pragma in example.
* gnat_rm.texi: Regenerate.

gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
gcc/ada/exp_ch9.adb
gcc/ada/gnat_rm.texi
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb

index bcbd85984dc07e5ccd26cae3bc0d70963f91eec2..0661670e0475159d104ce997896e4011a6bb75f7 100644 (file)
@@ -3771,7 +3771,7 @@ Pragma Max_Queue_Length
 
 Syntax::
 
-   pragma Max_Entry_Queue (static_integer_EXPRESSION);
+   pragma Max_Queue_Length (static_integer_EXPRESSION);
 
 
 This pragma is used to specify the maximum callers per entry queue for
index 051b1df060f89c89f806a7ef9b26d8f2f8d63458..4de253ab6e83983b2dd6b8004285b55052b03666 100644 (file)
@@ -9405,7 +9405,8 @@ package body Exp_Ch9 is
       end loop;
 
       --  Create the declaration of an array object which contains the values
-      --  of aspect/pragma Max_Queue_Length for all entries of the protected
+      --  of any aspect/pragma Max_Queue_Length, Max_Entry_Queue_Length or
+      --  Max_EntryQueue_Depth for all entries of the protected
       --  type. This object is later passed to the appropriate protected object
       --  initialization routine.
 
@@ -9422,7 +9423,8 @@ package body Exp_Ch9 is
             Need_Array : Boolean := False;
 
          begin
-            --  First check if there is any Max_Queue_Length pragma
+            --  First check if there is any Max_Queue_Length,
+            --  Max_Entry_Queue_Length or Max_Entry_Queue_Depth pragma.
 
             Item := First_Entity (Prot_Typ);
             while Present (Item) loop
index 40516121b7abedb64fd099b4ea6740a04ab90a5d..4dbbb036a259e2cdde76009b5a2ece615f01d873 100644 (file)
@@ -5312,7 +5312,7 @@ no effect in GNAT, other than being syntax checked.
 Syntax:
 
 @example
-pragma Max_Entry_Queue (static_integer_EXPRESSION);
+pragma Max_Queue_Length (static_integer_EXPRESSION);
 @end example
 
 This pragma is used to specify the maximum callers per entry queue for
index f27e40edcbbff019daaa74410a782cad36d310fc..0e2ce9de4b53f5c85b93bbc572a020276e8052f5 100644 (file)
@@ -20388,6 +20388,17 @@ package body Sem_Prag is
                  ("pragma % must apply to a protected entry declaration");
             end if;
 
+            --  Check for duplicates
+
+            if Has_Rep_Pragma (Entry_Id, Name_Max_Entry_Queue_Length)
+                 or else
+               Has_Rep_Pragma (Entry_Id, Name_Max_Entry_Queue_Depth)
+                 or else
+               Has_Rep_Pragma (Entry_Id, Name_Max_Queue_Length)
+            then
+               Error_Msg_N ("??duplicate Max_Entry_Queue_Length pragma", N);
+            end if;
+
             --  Mark the pragma as Ghost if the related subprogram is also
             --  Ghost. This also ensures that any expansion performed further
             --  below will produce Ghost nodes.
index d512d462b443981bc14b9df64376d9dc8ef6c2ea..09358278210eabd39cfd95cbbcd29cf8ab504c36 100644 (file)
@@ -10714,26 +10714,38 @@ package body Sem_Util is
 
    function Get_Max_Queue_Length (Id : Entity_Id) return Uint is
       pragma Assert (Is_Entry (Id));
-      Prag : constant Entity_Id := Get_Pragma (Id, Pragma_Max_Queue_Length);
-      Max  : Uint;
+      PMQL  : constant Entity_Id := Get_Pragma (Id, Pragma_Max_Queue_Length);
+      PMEQD : constant Entity_Id :=
+         Get_Pragma (Id, Pragma_Max_Entry_Queue_Depth);
+      PMEQL : constant Entity_Id :=
+         Get_Pragma (Id, Pragma_Max_Entry_Queue_Length);
+      Max   : Uint;
 
    begin
       --  A value of 0 or -1 represents no maximum specified, and entries and
       --  entry families with no Max_Queue_Length aspect or pragma default to
       --  it.
 
-      if No (Prag) then
-         return Uint_0;
+      --  We have already checked that there is at most one of these pragmas
+
+      if Present (PMQL) then
+         Max := Expr_Value
+            (Expression (First (Pragma_Argument_Associations (PMQL))));
+      elsif Present (PMEQD) then
+         Max := Expr_Value
+            (Expression (First (Pragma_Argument_Associations (PMEQD))));
+      elsif Present (PMEQL) then
+         Max := Expr_Value
+            (Expression (First (Pragma_Argument_Associations (PMEQL))));
+      else
+         Max := Uint_0;
       end if;
 
-      Max := Expr_Value
-        (Expression (First (Pragma_Argument_Associations (Prag))));
-
       --  Since -1 and 0 are equivalent, return 0 for instances of -1 for
       --  uniformity.
 
       if Max = -1 then
-         return Uint_0;
+         Max := Uint_0;
       end if;
 
       return Max;
@@ -12217,7 +12229,10 @@ package body Sem_Util is
    begin
       return
         Ekind (Id) = E_Entry
-          and then Present (Get_Pragma (Id, Pragma_Max_Queue_Length));
+          and then
+        (Present (Get_Pragma (Id, Pragma_Max_Queue_Length)) or else
+         Present (Get_Pragma (Id, Pragma_Max_Entry_Queue_Depth)) or else
+         Present (Get_Pragma (Id, Pragma_Max_Entry_Queue_Length)));
    end Has_Max_Queue_Length;
 
    ---------------------------------