]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix visibility issue in nested instance with use clause for formal package
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 6 Oct 2025 19:36:56 +0000 (21:36 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 3 Nov 2025 14:15:15 +0000 (15:15 +0100)
commite95656d98401f820227a194de20233256c511f85
treeab2ccb1b827164f037b81b451b209da33ab2199c
parent65dec7e0e4d7987e9fe18065928cf80195784cc0
ada: Fix visibility issue in nested instance with use clause for formal package

The compiler gives a spurious visibility error for a formal object parameter
of a formal package with a use clause, present in a parent instance, when an
instance of a child generic unit is compiled, while this does not happen in
the same circumstances for a formal type parameter.

The discrepancy comes from the Check_Generic_Actuals procedure, which clears
the Is_Hidden flag on all the actuals of a generic instance, but only sets
the Is_Potentially_Use_Visible flag on the actuals for formal types.

The change also contains a fix for a pasto in Restore_Private_Views, which
is responsible for undoing the changes made by Check_Generic_Actuals.

gcc/ada/ChangeLog:

PR ada/122161
* sem_ch12.adb (Check_Generic_Actuals): Consistently set the
Is_Potentially_Use_Visible flag on actuals whenever the Is_Hidden
flag is cleared.
(Restore_Private_Views): Clear the Is_Potentially_Use_Visible flag
explicitly on the entities of an actual package.
gcc/ada/sem_ch12.adb