]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix bogus error in instantiation with formal package
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 11 Sep 2024 17:42:03 +0000 (19:42 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 8 Oct 2024 08:37:15 +0000 (10:37 +0200)
The compiler reports that an actual does not match the formal when there
is a defaulted formal discrete type because Check_Formal_Package_Instance
fails to skip the implicit base type generated by the compiler.

gcc/ada/ChangeLog:
PR ada/114636
* sem_ch12.adb (Check_Formal_Package_Instance): For a defaulted
formal discrete type, skip the generated implicit base type.

gcc/ada/sem_ch12.adb

index b406cfce3b3285019711fadfb883df1322deb4a3..33f6f18c50b20fa8d67a7d768161f4b24f126050 100644 (file)
@@ -7337,8 +7337,12 @@ package body Sem_Ch12 is
          then
             --  If the formal is a tagged type the corresponding class-wide
             --  type has been generated as well, and it must be skipped.
+            --  Likewise, for a formal discrete type, the base type has been
+            --  generated as well (see Analyze_Formal_Discrete_Type).
 
-            if Is_Type (E2) and then Is_Tagged_Type (E2) then
+            if Is_Type (E2)
+              and then (Is_Tagged_Type (E2) or else Is_Enumeration_Type (E2))
+            then
                Next_Entity (E2);
             end if;