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:
parent
2a127979d9
commit
f056076f5f
gcc
@ -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,
|
||||
|
17
gcc/testsuite/gnat.dg/discr57.adb
Normal file
17
gcc/testsuite/gnat.dg/discr57.adb
Normal file
@ -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;
|
Loading…
x
Reference in New Issue
Block a user