]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Fix invalid expanded code for entry families
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 12 Apr 2022 20:22:40 +0000 (22:22 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:30 +0000 (14:05 +0000)
Expansion of entry families created a slightly illegal AST with
Elsif_Parts being an empty list. Cleanup uncovered by the work on
detection of uninitialized scalars.

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove empty Elsif_Parts
from the constructed IF statement.

gcc/ada/exp_ch9.adb

index f9bdaf80c94cb9f8e67579fae43bbfef93ff07b1..be791c3a3388252c27fb039f5844565de8ba5041 100644 (file)
@@ -2800,6 +2800,15 @@ package body Exp_Ch9 is
             begin
                Remove (Nod);
                Set_Else_Statements (Ret, Then_Statements (Nod));
+
+               --  If Elsif_Parts becomes empty then remove it entirely, as
+               --  otherwise we would violate the invariant of If_Statement
+               --  node described in Sinfo.
+
+               if Is_Empty_List (Elsif_Parts (Ret)) then
+                  pragma Assert (Elsif_Parts (Ret) /= No_List);
+                  Set_Elsif_Parts (Ret, No_List);
+               end if;
             end;
          end if;
       end if;
This page took 0.075218 seconds and 5 git commands to generate.