diff options
author | Bob Duff <duff@adacore.com> | 2019-08-14 09:51:43 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-08-14 09:51:43 +0000 |
commit | f056076f5fe77fe8b13050eb3affc4c8ac700722 (patch) | |
tree | cfb611395dd402c4b53b85d431cb642a3aea0e39 | |
parent | 2a127979d92caafe31a2c9be5d9f5bb70e1f4d98 (diff) | |
download | gcc-f056076f5fe77fe8b13050eb3affc4c8ac700722.zip gcc-f056076f5fe77fe8b13050eb3affc4c8ac700722.tar.gz gcc-f056076f5fe77fe8b13050eb3affc4c8ac700722.tar.bz2 |
[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
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_aggr.adb | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/discr57.adb | 17 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a36a83a..785d9d8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -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 diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 174da6e..6a756fd 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89a92fa..dadeb4f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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, diff --git a/gcc/testsuite/gnat.dg/discr57.adb b/gcc/testsuite/gnat.dg/discr57.adb new file mode 100644 index 0000000..cb5cecc --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr57.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; |