]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix assertion failure on VSS library
authorJavier Miranda <miranda@adacore.com>
Mon, 6 Mar 2023 10:43:28 +0000 (11:43 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 6 Mar 2023 10:45:24 +0000 (11:45 +0100)
gcc/ada/
PR ada/108858
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): For functions with
separate spec, if their return type was visible through a limited-
with context clause, their extra formals were not added when the
spec was analyzed.  Now the full view must be available, and the
extra formals can be created and Returns_By_Ref computed.

gcc/ada/sem_ch6.adb

index 944e63810720103f820ca54a4533a1b8de417bc2..d4701aed0f7a9aabb7ea91b561c0e056724bd43c 100644 (file)
@@ -3836,6 +3836,21 @@ package body Sem_Ch6 is
          Spec_Decl := Unit_Declaration_Node (Spec_Id);
          Verify_Overriding_Indicator;
 
+         --  For functions with separate spec, if their return type was visible
+         --  through a limited-with context clause, their extra formals were
+         --  not added when the spec was frozen. Now the full view must be
+         --  available, and the extra formals can be created and Returns_By_Ref
+         --  computed (required to generate its return statements).
+
+         if Ekind (Spec_Id) = E_Function
+           and then From_Limited_With (Etype (Spec_Id))
+           and then Is_Build_In_Place_Function (Spec_Id)
+           and then not Has_BIP_Formals (Spec_Id)
+         then
+            Create_Extra_Formals (Spec_Id);
+            Compute_Returns_By_Ref (Spec_Id);
+         end if;
+
          --  In general, the spec will be frozen when we start analyzing the
          --  body. However, for internally generated operations, such as
          --  wrapper functions for inherited operations with controlling