]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Bug in Indefinite_Holders instance passed to formal package
authorBob Duff <duff@adacore.com>
Wed, 16 Jul 2025 14:29:01 +0000 (10:29 -0400)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 25 Jul 2025 10:20:50 +0000 (12:20 +0200)
Fix bug when an instance of Indefinite_Holders with a class-wide type is
passed as a generic formal package; Program_Error was raised when
dealing with the implicit "=" function.

The fix is to disable legality checks in formal packages when the
entity is an E_Subprogram_Body, because these are implicitly generated
for class-wide predefined functions when passed to generics.

gcc/ada/ChangeLog:

* sem_ch12.adb (Check_Formal_Package_Instance):
Do nothing in case of E_Subprogram_Body.

gcc/ada/sem_ch12.adb

index 02c7c3696e82fede791d9b0e822fffb4e522f4e3..e00f5140588d451d1507b2dcc74b76ff21d099d9 100644 (file)
@@ -7542,6 +7542,12 @@ package body Sem_Ch12 is
                     or else not Same_Instantiated_Function (E1, E2));
             end if;
 
+         --  No check is needed if this is the body of a subprogram that is
+         --  implicitly created in the case of class-wide predefined functions.
+
+         elsif Ekind (E1) = E_Subprogram_Body then
+            null;
+
          else
             raise Program_Error;
          end if;