From d46b330ddc1dc1c16e9638e144db64df7365a820 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 20 Jan 2020 11:24:07 +0100 Subject: [PATCH] [Ada] Small tweak to special handling of private index types 2020-06-04 Eric Botcazou gcc/ada/ * sem_ch3.adb (Array_Type_Declaration): Apply special handling of private index types to generic packages and restrict it to index types defined in the current scope. --- gcc/ada/sem_ch3.adb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 29e8964a725..dcf07015e1c 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6137,7 +6137,7 @@ package body Sem_Ch3 is end if; -- Add a subtype declaration for each index of private array type - -- declaration whose etype is also private. For example: + -- declaration whose type is also private. For example: -- package Pkg is -- type Index is private; @@ -6147,11 +6147,14 @@ package body Sem_Ch3 is -- This is currently required by the expander for the internally -- generated equality subprogram of records with variant parts in - -- which the etype of some component is such private type. + -- which the type of some component is such a private type. And it + -- also helps semantic analysis in peculiar cases where the array + -- type is referenced from an instance but not the index directly. - if Ekind (Current_Scope) = E_Package + if Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) and then Has_Private_Declaration (Etype (Index)) + and then Scope (Etype (Index)) = Current_Scope then declare Loc : constant Source_Ptr := Sloc (Def); -- 2.30.2