public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix invalid expanded code for entry families
@ 2022-05-19 14:16 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-19 14:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

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.

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

gcc/ada/

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

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 723 bytes --]

diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -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;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-19 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:16 [Ada] Fix invalid expanded code for entry families Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).