ada: Fix internal error on instantiation with private component type
commit518f93c17983623107ff2091728c93b02fc0eeb2
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 5 Aug 2023 12:43:41 +0000 (5 14:43 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:12 +0000 (5 13:05 +0200)
treea518434eb791c92ee0c02789861f9847bfae7979
parentf9a68b454743fffe07fb51ed735510c2178ba14c
ada: Fix internal error on instantiation with private component type

First, this fixes an internal error on the instantiation of a nested generic
package taking an array type whose component type is a private type declared
in the parent package as formal type parameter. In the body of the instance,
the full view of the private type is visible and must be restored by means
of the Check_Generic_Actuals mechanism.

Second, this fixes the same internal error in the case where the component
type itself is an array type whose component type is a private type declared
in the parent package, i.e. when the formal type parameter is an array of
array type, by naturally extending the Has_Secondary_Private_View mechanism
to the array of array case.

gcc/ada/

* sem_ch12.adb (Component_Type_For_Private_View): New function.
(Check_Generic_Actuals): For an actual type parameter, also check
its component type if it is an array type.
(Check_Private_View): Use Component_Type_For_Private_View in the
case of an array type.
(Instantiate_Type): Likewise.
(Save_Global_References.Set_Global_Type): Likewise.
gcc/ada/sem_ch12.adb