diff mbox series

[Ada] Compiler crash on limited conditional expressions

Message ID 20201130141711.GA117839@adacore.com
State New
Headers show
Series [Ada] Compiler crash on limited conditional expressions | expand

Commit Message

Pierre-Marie de Rodat Nov. 30, 2020, 2:17 p.m. UTC
This patch fixes a bug in which if the expression of an expression
function is a conditional expression of limited type, the compiler

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


	* exp_ch3.adb (Expand_N_Object_Declaration): Avoid crash in case
	of conditional expression.
diff mbox series


diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -7403,12 +7403,12 @@  package body Exp_Ch3 is
                --  If we cannot convert the expression into a renaming we must
                --  consider it an internal error because the backend does not
-               --  have support to handle it. Also, when a raise expression is
-               --  encountered we ignore it since it doesn't return a value and
-               --  thus cannot trigger a copy.
+               --  have support to handle it. But avoid crashing on a raise
+               --  expression or conditional expression.
-               elsif Nkind (Original_Node (Expr_Q)) /= N_Raise_Expression then
-                  pragma Assert (False);
+               elsif Nkind (Original_Node (Expr_Q)) not in
+                 N_Raise_Expression | N_If_Expression | N_Case_Expression
+               then
                   raise Program_Error;
                end if;