]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Do not overwrite limited view of result type
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 19 Feb 2022 11:30:47 +0000 (12:30 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 13 May 2022 08:04:34 +0000 (08:04 +0000)
This removes obsolete code that overwrites a limited view present as the
result type of a function during the tentative analysis of prefixed
views for function calls involving tagged types. The original view is
necessary for the code generator to break the circularity present in
this setup.

The change also adds a couple of guards for the illegal case where the
limited view is the only view available when the function is invoked.

gcc/ada/

* aspects.adb (Find_Value_Of_Aspect): Add guard.
* sem_ch4.adb (Complete_Object_Operation): Remove obsolete code.
* sem_ch5.adb (Has_Sec_Stack_Default_Iterator): Add guard.

gcc/ada/aspects.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch5.adb

index 62603d6b4ba818d07a4a2e7dc2a1eebedadd649a..3471a81f1766c76c4c7d979e488f18e12693f6a3 100644 (file)
@@ -285,7 +285,9 @@ package body Aspects is
 
    begin
       if Present (Spec) then
-         if A = Aspect_Default_Iterator then
+         if A = Aspect_Default_Iterator
+           and then Present (Aspect_Rep_Item (Spec))
+         then
             return Expression (Aspect_Rep_Item (Spec));
          else
             return Expression (Spec);
index 5987b796ae2ab60dc2c4398774d65d1963b65be7..ad7448fedb5f007c36ba6ac85bb532f65badfcc9 100644 (file)
@@ -9248,19 +9248,6 @@ package body Sem_Ch4 is
             Save_Interps (Subprog, Node_To_Replace);
 
          else
-            --  The type of the subprogram may be a limited view obtained
-            --  transitively from another unit. If full view is available,
-            --  use it to analyze call. If there is no nonlimited view, then
-            --  this is diagnosed when analyzing the rewritten call.
-
-            declare
-               T : constant Entity_Id := Etype (Subprog);
-            begin
-               if From_Limited_With (T) then
-                  Set_Etype (Entity (Subprog), Available_View (T));
-               end if;
-            end;
-
             Analyze (Node_To_Replace);
 
             --  If the operation has been rewritten into a call, which may get
index a0f22060007cc29c37f80990bb032698547e3668..0a836089d9535358925b2ade48e36bd234068653 100644 (file)
@@ -3675,6 +3675,7 @@ package body Sem_Ch5 is
          begin
             return
               Present (Def_Iter)
+                and then Present (Etype (Def_Iter))
                 and then Requires_Transient_Scope (Etype (Def_Iter));
          end Has_Sec_Stack_Default_Iterator;