[Ada] Hang on loop in generic with subtype indication specifying a range
authorGary Dismukes <dismukes@adacore.com>
Mon, 12 Aug 2019 09:01:04 +0000 (09:01 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 12 Aug 2019 09:01:04 +0000 (09:01 +0000)
commitecb2f4fe0078a1439b80356459ce0c97edfbc30a
tree4cc6365c441bc719c4f9725021309fec59337545
parent6ab24ed7528b0375c49e4416f825a90bdca63454
[Ada] Hang on loop in generic with subtype indication specifying a range

The compiler may hang when a for loop expanded in a generic
instantiation has a range specified by a subtype indication with an
explicit range that has a bound that is an attribute applied to a
discriminant-dependent array component. The Parent field of the bound
may not be set, which can lead to endless looping when an actual subtype
created for the array component is passed to Insert_Actions. This is
fixed by setting the Parent fields of the copied bounds before
Preanalyze is called on them.

2019-08-12  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* sem_ch5.adb (Prepare_Param_Spec_Loop): Set the parents of the
copied low and high bounds in the case where the loop range is
given by a discrete_subtype_indication, to prevent hanging (or
Assert_Failure) in Insert_Actions.

gcc/testsuite/

* gnat.dg/generic_inst7.adb, gnat.dg/generic_inst7_pkg.adb,
gnat.dg/generic_inst7_pkg.ads, gnat.dg/generic_inst7_types.ads:
New testcase.

From-SVN: r274298
gcc/ada/ChangeLog
gcc/ada/sem_ch5.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/generic_inst7.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst7_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst7_pkg.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst7_types.ads [new file with mode: 0644]