]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Default_Component_Value trumps Initialize/Normalize_Scalars
authorSteve Baird <baird@adacore.com>
Thu, 30 Mar 2023 20:22:01 +0000 (13:22 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:19 +0000 (10:23 +0200)
If the Default_Component_Value aspect is specified for an array type, then
specifying Initialize_Scalars or Normalize_Scalars should have no effect
on the default initialization of an object of the array type.

gcc/ada/

* exp_ch3.adb
(Expand_N_Object_Declaration.Default_Initialize_Object): Add test for
specified Default_Component_Value aspect when deciding whether
either Initialize_Scalars or Normalize_Scalars impacts default
initialization of an array object.

gcc/ada/exp_ch3.adb

index e23a3fde15cf4fef255a3810312d8f377a14a408..5f651bacafb1bbc048d3cd36b26caeee4bddf61e 100644 (file)
@@ -6897,6 +6897,12 @@ package body Exp_Ch3 is
 
                  and then not Has_Predicates (Component_Type (Typ))
 
+                 --  Array default component value takes precedence over
+                 --  Init_Or_Norm_Scalars.
+
+                 and then No (Find_Aspect (Typ,
+                                           Aspect_Default_Component_Value))
+
                  --  The component type must have a single initialization value
 
                  and then Simple_Initialization_OK (Component_Type (Typ))