From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id C2B1F385BACD for ; Mon, 4 Jul 2022 07:50:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2B1F385BACD Received: by mail-ed1-x536.google.com with SMTP id k30so2479439edk.8 for ; Mon, 04 Jul 2022 00:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=fpj9dg6rm+oF1QDrjnv5T0Rd20E2tn8s8PBPtiMNdx0=; b=S67iwr8ChVzOyIobmZSBraJtUuQ5V0KSX4BjG/Sryyf2QTsP1u/vdWYAWZd0e+vTWk ukeMJmQf2vgTukQ9Jg/1HMyQJp45Rf7xXhAZpmany7bPRWeA4TZh2cWPgYS1qh3Yjus0 ZCFH1mWjTNipUa/gciZpXHcPbjmUkCG4pGKTbPsj03RxEU+3XbesbAYyloFDgZbA+UEm l/f5Zh1LhYcXx+EaBYi4KLQ8R/zQzdKeo1RddxjZ3X77Qz0DMMCxhY+iCJ+7GkeoIwk4 7sUM4KHX++GYBrmC+GAJeVZhH6675LmZngFkrxvq5E+PS8pJEBt1gScg4GSbRtLe4z1m YjeQ== X-Gm-Message-State: AJIora/no3BaQnSpAzhIvg4jq4U0G7+lgR2CGux1OUxbXAg4t8Bm9elo CamxTp+pQc3dHMYmRccm4YR9bi8G4r2/bA== X-Google-Smtp-Source: AGRyM1vpCSd/Usdn8SHQYel67o9C4GQxdGM/FtbjShJS4L12GRVY40h+JJGEa3ZNZyDUidr2dgw0nw== X-Received: by 2002:a05:6402:358c:b0:435:9daf:e825 with SMTP id y12-20020a056402358c00b004359dafe825mr36990673edc.375.1656921002497; Mon, 04 Jul 2022 00:50:02 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id l23-20020aa7cad7000000b004356afc7009sm20175834edt.59.2022.07.04.00.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 00:50:01 -0700 (PDT) Date: Mon, 4 Jul 2022 07:50:01 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Fix for resolution of overloaded subprogram for Iterable aspect Message-ID: <20220704075001.GA98915@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 07:50:05 -0000 --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Tested on x86_64-pc-linux-gnu, committed on trunk 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. --opJtzjQTFsWo+cga Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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); --opJtzjQTFsWo+cga--