]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix for resolution of overloaded subprogram for Iterable aspect
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 20 May 2022 20:29:51 +0000 (22:29 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 4 Jul 2022 07:45:51 +0000 (07:45 +0000)
When resolving the Iterable aspect we look for a functions that are
declared in the same scope as the annotated type and that have the
required number and types formal parameters. However, we didn't guard
against functions that have no formal parameter at all.

gcc/ada/

* sem_ch13.adb (Resolve_Iterable_Operation): Add guard to
prevent crash when the examined function has no formal
parameters and Etype is called on Empty entity.

gcc/ada/sem_ch13.adb

index 0b8911b8dcd6adb9170285184cb5f8ad0030c051..27f325049993c35e7d0cecc6c7b10822e25c4294 100644 (file)
@@ -15943,6 +15943,7 @@ package body Sem_Ch13 is
             while Present (It.Typ) loop
                if Ekind (It.Nam) = E_Function
                   and then Scope (It.Nam) = Scope (Typ)
+                  and then Present (First_Formal (It.Nam))
                   and then Etype (First_Formal (It.Nam)) = Typ
                then
                   F1 := First_Formal (It.Nam);