Fix crash on array component with nonstandard index type
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 11 Sep 2020 08:41:28 +0000 (10:41 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 11 Sep 2020 08:43:38 +0000 (10:43 +0200)
commit7c919c12be147c72e5d7ef2f9436adadcf2c2f24
tree9bc31f147ed1158535d5d72e82926865f8c38833
parente898facaf3cceb6c31bd34511b117c907b18a3e9
Fix crash on array component with nonstandard index type

This is a regression present on mainline, 10 and 9 branches: the compiler
goes into an infinite recursion eventually exhausting the stack for the
declaration of a discriminated record type with an array component having
a discriminant as bound and an index type that is an enumeration type with
a non-standard representation clause.

gcc/ada/ChangeLog:
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Only
create extra subtypes for discriminants if the RM size of the base
type of the index type is lower than that of the index type.

gcc/testsuite/ChangeLog:
* gnat.dg/specs/discr7.ads: New test.
gcc/ada/gcc-interface/decl.c
gcc/testsuite/gnat.dg/specs/discr7.ads [new file with mode: 0644]