From: Denis Mazzucato <[email protected]>

This patch stops the propagation of by-constructor indication from composition.
Only derived tagged types should propagate this indication.

gcc/ada/ChangeLog:

        * sem_ch3.adb (Build_Derived_Type): Propagate by-constructor indication
        only for derived tagged types, not for composition.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch3.adb | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 6bf7e308f1c..63ae1147a4f 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -10454,6 +10454,12 @@ package body Sem_Ch3 is
       if Is_Tagged_Type (Derived_Type) then
          Set_No_Tagged_Streams_Pragma
            (Derived_Type, No_Tagged_Streams_Pragma (Parent_Type));
+
+         --  Propagate information about constructor dependence from parent
+
+         Set_Needs_Construction
+           (Derived_Type,
+            Needs_Construction (Parent_Type));
       end if;
 
       --  If the parent has primitive routines and may have not-seen-yet aspect
@@ -23474,14 +23480,6 @@ package body Sem_Ch3 is
 
          Propagate_Concurrent_Flags (T, Etype (Component));
 
-         --  Propagate information about constructor dependence
-
-         if Ekind (Etype (Component)) /= E_Void
-           and then Needs_Construction (Etype (Component))
-         then
-            Set_Needs_Construction (T);
-         end if;
-
          if Ekind (Component) /= E_Component then
             null;
 
-- 
2.53.0

Reply via email to