From patchwork Mon Jul 4 07:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1651816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Sf3LT73p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lbydz6R2Zz9sFr for ; Mon, 4 Jul 2022 17:50:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C29583851A80 for ; Mon, 4 Jul 2022 07:50:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C29583851A80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656921029; bh=fpj9dg6rm+oF1QDrjnv5T0Rd20E2tn8s8PBPtiMNdx0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Sf3LT73pnNif+j7ErT5/+QddtXalBHVepRWY3m5SpNDYpZUYGeox/H6joe7JroFso LjlQe40fiWab1nKMoYAiodkeelORunhIqhpcyqzhGvESjVpBlmp0zhw4Q2MFB/q1oe LFnNce8DUax2gBUbu+QI7F2gv6qW5LHVFSqxRhmk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix for resolution of overloaded subprogram for Iterable aspect Message-ID: <20220704075001.GA98915@adacore.com> MIME-Version: 1.0 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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);