2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-03-21 23:41:13 +08:00

[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
This commit is contained in:
Bob Duff 2019-08-14 09:51:43 +00:00 committed by Pierre-Marie de Rodat
parent 2a127979d9
commit f056076f5f
4 changed files with 29 additions and 1 deletions

@ -1,3 +1,8 @@
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

@ -2689,8 +2689,10 @@ package body Exp_Aggr is
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

@ -1,3 +1,7 @@
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,

@ -0,0 +1,17 @@
-- { 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;