+2008-04-15 Ed Schonberg <schonberg@adacore.com>
+
+ PR ada/22387
+ * exp_ch5.adb (Expand_Assign_Record): Within an initialization
+ procedure for a derived type retrieve the discriminant values from
+ the parent using the corresponding discriminant.
+
2008-04-15 Samuel Tardieu <sam@rfc1149.net>
Gary Dismukes <dismukes@adacore.com>
F := First_Discriminant (R_Typ);
while Present (F) loop
- if Is_Unchecked_Union (Base_Type (R_Typ)) then
- Insert_Action (N, Make_Field_Assign (F, True));
- else
- Insert_Action (N, Make_Field_Assign (F));
- end if;
+ -- If we are expanding the initialization of a derived record
+ -- that constrains or renames discriminants of the parent, we
+ -- must use the corresponding discriminant in the parent.
+
+ declare
+ CF : Entity_Id;
- Next_Discriminant (F);
+ begin
+ if Inside_Init_Proc
+ and then Present (Corresponding_Discriminant (F))
+ then
+ CF := Corresponding_Discriminant (F);
+ else
+ CF := F;
+ end if;
+
+ if Is_Unchecked_Union (Base_Type (R_Typ)) then
+ Insert_Action (N, Make_Field_Assign (CF, True));
+ else
+ Insert_Action (N, Make_Field_Assign (CF));
+ end if;
+
+ Next_Discriminant (F);
+ end;
end loop;
end if;
+2008-04-15 Samuel Tardieu <sam@rfc1149.net>
+
+ PR ada/22387
+ * gnat.dg/specs/corr_discr.ads: New.
+
2008-04-15 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/string_slice2.adb: New test.