Commit f056076f by Bob Duff Committed by Pierre-Marie de Rodat

[Ada] Spurious error in discriminated aggregate

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
parent 2a127979
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> 2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset * sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset
......
...@@ -2689,8 +2689,10 @@ package body Exp_Aggr is ...@@ -2689,8 +2689,10 @@ package body Exp_Aggr is
Discr_Constr := Discr_Constr :=
First_Elmt (Stored_Constraint (Full_View (Base_Typ))); First_Elmt (Stored_Constraint (Full_View (Base_Typ)));
-- Otherwise, no discriminant to process
else else
Discr_Constr := First_Elmt (Stored_Constraint (Typ)); Discr_Constr := No_Elmt;
end if; end if;
while Present (Discr) and then Present (Discr_Constr) loop 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> 2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb, * gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb,
......
-- { 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment