https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123185
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Eric Botcazou <[email protected]>: https://gcc.gnu.org/g:0f5462343444cbd6ff8e0692c8035eee3a7d9749 commit r16-6336-g0f5462343444cbd6ff8e0692c8035eee3a7d9749 Author: Eric Botcazou <[email protected]> Date: Mon Dec 22 18:50:59 2025 +0100 Ada: Fix bogus component visibility error for class-wide type in generic The problem is that Analyze_Overloaded_Selected_Component does: -- If the prefix is a class-wide type, the visible components -- are those of the base type. if Is_Class_Wide_Type (T) then T := Etype (T); end if; and Resolve_Selected_Component does: -- The visible components of a class-wide type are those of -- the root type. if Is_Class_Wide_Type (T) then T := Etype (T); end if; while Analyze_Selected_Component does: -- For class-wide types, use the entity list of the root type if Is_Class_Wide_Type (Prefix_Type) then Type_To_Use := Root_Type (Prefix_Type); end if; when faced with a selected component. So the 3rd goes to the root type, the 1st to the base type, and the 2nd wants to do like the 3rd but ends up doing like the 1st! This does not change anything for the class-wide type itself, but does for its class-wide subtypes. The correct processing is the 3rd. gcc/ada/ PR ada/123185 * sem_ch4.adb (Analyze_Overloaded_Selected_Component): Go to the root when the prefix has a class-wide type. * sem_res.adb (Resolve_Selected_Component): Likewise. gcc/testsuite/ * gnat.dg/specs/class_wide1.ads: New test.
