This patch fixes a bug in which a spurious error is given on an
aggregate of a type derived from a subtype with a constrained
discriminant.
2019-08-14 Bob Duff <duff@adacore.com>
gcc/ada/
* exp_aggr.adb (Init_Hidden_Discriminants): Avoid processing the
wrong discriminant, which could be of the wrong type.
gcc/testsuite/
* gnat.dg/discr57.adb: New testcase.
From-SVN: r274458
+2019-08-14 Bob Duff <duff@adacore.com>
+
+ * exp_aggr.adb (Init_Hidden_Discriminants): Avoid processing the
+ wrong discriminant, which could be of the wrong type.
+
2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset
Discr_Constr :=
First_Elmt (Stored_Constraint (Full_View (Base_Typ)));
+ -- Otherwise, no discriminant to process
+
else
- Discr_Constr := First_Elmt (Stored_Constraint (Typ));
+ Discr_Constr := No_Elmt;
end if;
while Present (Discr) and then Present (Discr_Constr) loop
+2019-08-14 Bob Duff <duff@adacore.com>
+
+ * gnat.dg/discr57.adb: New testcase.
+
2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb,
--- /dev/null
+-- { dg-do compile }
+
+procedure Discr57 is
+
+ type T1(Scalar : Boolean) is abstract tagged null record;
+
+ subtype S1 is T1 (Scalar => False);
+
+ type T2(Lower_Bound : Natural) is new
+ S1 with null record;
+
+ Obj : constant T2 :=
+ (Lower_Bound => 123);
+
+begin
+ null;
+end Discr57;