[Ada] Hang on conditional expression as actual
authorJustin Squirek <squirek@adacore.com>
Wed, 13 May 2020 22:59:29 +0000 (18:59 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 7 Jul 2020 09:26:58 +0000 (05:26 -0400)
gcc/ada/

* exp_ch6.adb (Expand_Branch): Verify the original node is a
conditional expression before recursing further.
(Insert_Level_Assign): Transform assertion into an explicit
raise.

gcc/ada/exp_ch6.adb

index fb1998377346890bc717af17d83c2dcf227e55b3..3ccf0c386c83d878071aba0aeeb9c8b709d1b635 100644 (file)
@@ -3947,6 +3947,11 @@ package body Exp_Ch6 is
 
                                  if Nkind (Expression (Assn)) =
                                       N_Expression_With_Actions
+                                   and then
+                                     Nkind_In
+                                       (Original_Node (Expression (Assn)),
+                                         N_Case_Expression,
+                                         N_If_Expression)
                                  then
                                     Insert_Level_Assign (Expression (Assn));
 
@@ -3983,7 +3988,10 @@ package body Exp_Ch6 is
                                                            N_If_Statement);
 
                                  Next (Cond);
-                                 pragma Assert (Present (Cond));
+
+                                 if No (Cond) then
+                                    raise Program_Error;
+                                 end if;
                               end loop;
 
                               --  Iterate through if expression branches