For an allocator in the subtype mark case, the constraints of the subtype
must be checked against the designated subtype, except in the case where
the No_Initialization flag is set on the allocator node.

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

gcc/ada/

        * exp_ch4.adb (Expand_N_Allocator): In the subtype mark case, do
        not apply constraint checks if the No_Initialization flag is set.
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -4847,10 +4847,11 @@ package body Exp_Ch4 is
          Temp_Type : Entity_Id;
 
       begin
-         --  Apply constraint checks against designated subtype (RM 4.8(10/2)).
+         --  Apply constraint checks against designated subtype (RM 4.8(10/2))
+         --  but ignore the expression if the No_Initialization flag is set.
          --  Discriminant checks will be generated by the expansion below.
 
-         if Is_Array_Type (Dtyp) then
+         if Is_Array_Type (Dtyp) and then not No_Initialization (N) then
             Apply_Constraint_Check (Expression (N), Dtyp, No_Sliding => True);
 
             Apply_Predicate_Check (Expression (N), Dtyp);


Reply via email to