diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c10f7fffa79a..ff666826090a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-09-19 Eric Botcazou <ebotcazou@adacore.com> + + * exp_aggr.adb (Has_Mutable_Components): Look at the underlying + type of components to find out whether they are mutable. + 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> * sem_ch12.adb (Instantiate_Package_Body): Check that the body diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 63f9d1a512a5..3d3dd1b83416 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -8162,13 +8162,15 @@ package body Exp_Aggr is function Has_Mutable_Components (Typ : Entity_Id) return Boolean is Comp : Entity_Id; + Ctyp : Entity_Id; begin Comp := First_Component (Typ); while Present (Comp) loop - if Is_Record_Type (Etype (Comp)) - and then Has_Discriminants (Etype (Comp)) - and then not Is_Constrained (Etype (Comp)) + Ctyp := Underlying_Type (Etype (Comp)); + if Is_Record_Type (Ctyp) + and then Has_Discriminants (Ctyp) + and then not Is_Constrained (Ctyp) then return True; end if;