diff mbox series

[Ada] Crash on build of Initialization procedure for derived container

Message ID 20210921152624.GA3094833@adacore.com
State New
Headers show
Series [Ada] Crash on build of Initialization procedure for derived container | expand

Commit Message

Pierre-Marie de Rodat Sept. 21, 2021, 3:26 p.m. UTC
This patch fixes a compiler abort on the construction of the
initialization procedure for a private type completed by a derived
container type whose element type is another container with controlled
components with trivial initializations,

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

gcc/ada/

	* exp_ch7.adb (Make_Init_Call): Add guard to protect against a
	missing initialization procedure for a type.
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -9555,8 +9555,11 @@  package body Exp_Ch7 is
 
       --  If initialization procedure for an array of controlled objects is
       --  trivial, do not generate a useless call to it.
+      --  The initialization procedure may be missing altogether in the case
+      --  of a derived container whose components have trivial initialization.
 
-      if (Is_Array_Type (Utyp) and then Is_Trivial_Subprogram (Proc))
+      if No (Proc)
+        or else (Is_Array_Type (Utyp) and then Is_Trivial_Subprogram (Proc))
         or else
           (not Comes_From_Source (Proc)
             and then Present (Alias (Proc))