]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Error on instantiation with defaulted formal type referencing other formal type
authorGary Dismukes <dismukes@adacore.com>
Fri, 13 Dec 2024 23:36:05 +0000 (23:36 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 7 Jan 2025 12:33:32 +0000 (13:33 +0100)
commitf409c452883011c93a91f8057d301920dbc9bbb2
treef0ac2ad27a3937a735b7b6beb7d887638c3fd71e
parent90f504df6f22c1a28831875b79783e0718330528
ada: Error on instantiation with defaulted formal type referencing other formal type

The compiler wasn't accounting for default subtypes on generic formal types
that reference other formal types of the same generic, leading to errors
about invalid subtypes. Several other problems that could lead to blowups
or incorrect errors were noticed through testing related cases and fixed
along the way.

gcc/ada/ChangeLog:

* sem_ch12.adb (Analyze_One_Association): In the case of a formal type
that has a Default_Subtype_Mark that does not have its Entity field set,
this means the default refers to another formal type of the same generic
formal part, so locate the matching subtype in the Result_Renamings and
set Match's Entity to that subtype prior to the call to Instantiate_Type.
(Validate_Formal_TypeDefault.Reference_Formal): Add test of Entity being
Present, to prevent blowups on End_Label ids (which don't have Entity set).
(Validate_Formal_Type_Default.Validate_Derived_Type_Default): Apply
Base_Type to Formal.
(Validate_Formal_Type_Default): Guard interface-related semantic checks
with a test of Is_Tagged_Type.
gcc/ada/sem_ch12.adb