From 92392296c19de59d12558eedb9a5966a138454a7 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 1 May 2020 00:27:12 +0200 Subject: [PATCH] [Ada] Fix internal error on component of class-wide parameter in instance body 2020-06-19 Eric Botcazou gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): In an instance body, also invoke Find_Component_In_Instance on the parent subtype of a derived tagged type immediately visible. Remove obsolete case. --- gcc/ada/sem_ch4.adb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 0f59b40c62a..58e8058ee02 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5268,25 +5268,21 @@ package body Sem_Ch4 is end loop; -- Another special case: the type is an extension of a private - -- type T, is an actual in an instance, and we are in the body - -- of the instance, so the generic body had a full view of the - -- type declaration for T or of some ancestor that defines the - -- component in question. + -- type T, either is an actual in an instance or is immediately + -- visible, and we are in the body of the instance, which means + -- the generic body had a full view of the type declaration for + -- T or some ancestor that defines the component in question. + -- This happens because Is_Visible_Component returned False on + -- this component, as T or the ancestor is still private since + -- the Has_Private_View mechanism is bypassed because T or the + -- ancestor is not directly referenced in the generic body. elsif Is_Derived_Type (Type_To_Use) - and then Used_As_Generic_Actual (Type_To_Use) + and then (Used_As_Generic_Actual (Type_To_Use) + or else Is_Immediately_Visible (Type_To_Use)) and then In_Instance_Body then Find_Component_In_Instance (Parent_Subtype (Type_To_Use)); - - -- In ASIS mode the generic parent type may be absent. Examine - -- the parent type directly for a component that may have been - -- visible in a parent generic unit. - -- ??? Revisit now that ASIS mode is gone - - elsif Is_Derived_Type (Prefix_Type) then - Par := Etype (Prefix_Type); - Find_Component_In_Instance (Par); end if; end; -- 2.30.2