[Ada] Cleanup expansion of protected entry families
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 12 Apr 2022 19:46:36 +0000 (21:46 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:30 +0000 (14:05 +0000)
Expansion of entry families contained a condition that was always true.
Cleanup related to detection of uninitialized scalar objects (which
uncovered that expansion of entry families creates a slightly illegal
AST with Elsif_Parts being an empty list).

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove IF statement whose
condition was true-by-construction; remove excessive assertion
(since the call to Elsif_Parts will check that Nod is present
and it is an if-statement).

gcc/ada/exp_ch9.adb

index 0e551ab..f9bdaf8 100644 (file)
@@ -2793,20 +2793,14 @@ package body Exp_Ch9 is
                 Expression => Make_Integer_Literal (Loc, 1));
 
          else
-            pragma Assert (Present (Ret));
+            --  Ranges are in increasing order, so last one doesn't need guard
 
-            if Nkind (Ret) = N_If_Statement then
-
-               --  Ranges are in increasing order, so last one doesn't need
-               --  guard.
-
-               declare
-                  Nod : constant Node_Id := Last (Elsif_Parts (Ret));
-               begin
-                  Remove (Nod);
-                  Set_Else_Statements (Ret, Then_Statements (Nod));
-               end;
-            end if;
+            declare
+               Nod : constant Node_Id := Last (Elsif_Parts (Ret));
+            begin
+               Remove (Nod);
+               Set_Else_Statements (Ret, Then_Statements (Nod));
+            end;
          end if;
       end if;