GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada: Fix bogus visibility error for inherited operator of null extension.

The compiler no longer incorrectly flags visibility errors for inherited operators in null extensions.

The Ada compiler incorrectly flagged visibility errors when an inherited operator of a null extension had a heterogeneous profile and the extension was declared in the same scope as the type of a non-controlling parameter. The fix involves correcting how Find_Dispatching_Type determines the dispatching type and manually setting the Has_Controlling_Result flag on wrappers, ensuring correct visibility checking for inherited operators.

In Details

This patch addresses an issue in exp_ch3.adb and sem_disp.adb related to dispatching and visibility of inherited operators in null extensions. The Find_Dispatching_Type function was incorrectly returning a type, leading to the bogus visibility error. The fix involves returning the controlling result type for a controlling function wrapper and manually setting the Has_Controlling_Result flag on the wrappers.

For Context

Ada supports inheritance and extension of data types, including 'null extensions' which add no new fields. When an operator (like +, *, etc.) is inherited, the compiler needs to ensure it's used correctly, including visibility checks. This commit fixes a bug where the compiler incorrectly flagged a visibility error for inherited operators in specific scenarios involving null extensions.

Filed Under: adainheritancevisibilitybugfix