]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Support fixed-lower-bound array types as generic actual parameters
authorGary Dismukes <dismukes@adacore.com>
Mon, 17 Mar 2025 18:30:00 +0000 (18:30 +0000)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 9 Jun 2025 08:24:22 +0000 (10:24 +0200)
commitd96603a48d338a92b78628016d00cbf11576621e
treeaa75c07fe07b4af46d2c585b0529e9f2023b2270
parent6cc5c01aa77a1f01057a963cc5061bad4b0cc270
ada: Support fixed-lower-bound array types as generic actual parameters

Attempting to use a fixed-lower-bound array type (or subtype) as
an actual parameter for a formal unconstrained array type was being
rejected by the compiler (complaining about the index type of the
actual not matching the index type of the formal type).  The compiler
was improperly testing the actual's FLB range and finding that it didn't
statically match the index type of the formal array type; it should
instead test the underlying index type of the FLB type or subtype.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index): In the case of a fixed-lower-bound index,
set Etype of the newly created itype's Scalar_Range from the index's Etype.
* sem_ch12.adb (Validate_Array_Type_Instance): If the actual subtype is
a fixed-lower-bound type, then check again the Etype of its Scalar_Range.
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb