[Bug ada/123185] bogus component visibility error for class-wide type in generic package
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 25 17:49:55 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123185
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:
https://gcc.gnu.org/g:1d26b1b37aac4bd898abf4425ffd6310d29db234
commit r15-10633-g1d26b1b37aac4bd898abf4425ffd6310d29db234
Author: Eric Botcazou <ebotcazou@adacore.com>
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.
More information about the Gcc-bugs
mailing list