https://gcc.gnu.org/g:82475d549ed72edb5ec79e0cad22234ac56b4786

commit r17-787-g82475d549ed72edb5ec79e0cad22234ac56b4786
Author: Eric Botcazou <[email protected]>
Date:   Mon Feb 9 09:09:36 2026 +0100

    ada: Fix internal error on access to function as component via limited with
    
    The code generator cannot translate the specification of a package because
    it contains a circularity created by the presence of a limited_with clause
    for it in a withed package, and of a function call made through an access-
    to-function type declared in the latter package returning a type declared
    in the former package.
    
    gcc/ada/ChangeLog:
    
            PR ada/89609
            * sem_res.adb (Resolve_Call): Do not override the Etype of the Name
            entity when it denotes a function that returns the limited view of a
            type coming from a limited_with clause.

Diff:
---
 gcc/ada/sem_res.adb | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 1da3ac8413ae..8c0d970da962 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -6815,23 +6815,12 @@ package body Sem_Res is
 
       else
          --  If the called function is not declared in the main unit and it
-         --  returns the limited view of type then use the available view (as
-         --  is done in Try_Object_Operation) to prevent back-end confusion;
-         --  for the function entity itself. The call must appear in a context
-         --  where the nonlimited view is available. If the function entity is
-         --  in the extended main unit then no action is needed, because the
-         --  back end handles this case. In either case the type of the call
-         --  is the nonlimited view.
-
-         if From_Limited_With (Etype (Nam))
-           and then Present (Available_View (Etype (Nam)))
-         then
-            Set_Etype (N, Available_View (Etype (Nam)));
-
-            if not In_Extended_Main_Code_Unit (Nam) then
-               Set_Etype (Nam, Available_View (Etype (Nam)));
-            end if;
+         --  returns the limited view of a type, then use the available view
+         --  to prevent back-end confusion. The function call must appear in
+         --  a context where the nonlimited view is available.
 
+         if From_Limited_With (Etype (Nam)) then
+            Set_Etype (N, Available_View (Etype (Nam)));
          else
             Set_Etype (N, Etype (Nam));
          end if;

Reply via email to