aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_tss.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-12-05 22:31:50 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-01-03 10:29:52 +0100
commite1e2b0070302169fbf3f3fd95a13ec819e71e2a5 (patch)
tree673a5901734022780dec8ae59d78801f889968aa /gcc/ada/exp_tss.adb
parentfee53a3194c0d8b747486b23980f1214cc1355b9 (diff)
downloadgcc-e1e2b0070302169fbf3f3fd95a13ec819e71e2a5.zip
gcc-e1e2b0070302169fbf3f3fd95a13ec819e71e2a5.tar.gz
gcc-e1e2b0070302169fbf3f3fd95a13ec819e71e2a5.tar.bz2
ada: Fix support of Default_Component_Value aspect on derived types
The support of the Default_Component_Value aspect on derived constrained array types is broken because of a couple of issues: 1) the derived types incorrectly inherit the initialization procedure of the ancestor types and 2) the propagation of the aspect does not work for constrained array types (unlike for unconstrained array types). gcc/ada/ * exp_tss.adb (Base_Init_Proc): Do not return the Init_Proc of the ancestor type for a derived array type. * sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Factor out the common processing done on representation items. For Default_Component_Value and Default_Value, look into the first subtype to find out the representation items.
Diffstat (limited to 'gcc/ada/exp_tss.adb')
-rw-r--r--gcc/ada/exp_tss.adb5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/ada/exp_tss.adb b/gcc/ada/exp_tss.adb
index 09bb133..23ee349 100644
--- a/gcc/ada/exp_tss.adb
+++ b/gcc/ada/exp_tss.adb
@@ -78,8 +78,11 @@ package body Exp_Tss is
else
Proc := Init_Proc (Base_Type (Full_Type), Ref);
+ -- For derived record types, if the base type does not have one,
+ -- we use the Init_Proc of the ancestor type.
+
if No (Proc)
- and then Is_Composite_Type (Full_Type)
+ and then Is_Record_Type (Full_Type)
and then Is_Derived_Type (Full_Type)
then
return Init_Proc (Root_Type (Full_Type), Ref);