From patchwork Mon May 22 08:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 97198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1304983vqo; Mon, 22 May 2023 02:03:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dqZIpiThLVG0/6blp/BL+T+YNMUtExIIaQa2OYAeTs140mfhtjipIroojEpQKdFFjJmYC X-Received: by 2002:a17:907:9606:b0:96f:e5af:ac5f with SMTP id gb6-20020a170907960600b0096fe5afac5fmr2021943ejc.47.1684746218798; Mon, 22 May 2023 02:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684746218; cv=none; d=google.com; s=arc-20160816; b=ENleLF8Hk+eltuyisP1DWNd/0/cJSkocb27xCpVgUIcLcJ047yyVQVxT1IGQNqS9ph FMiMXItlhiqcV2VV7PMN42E05dpaJM6Aj2JWQhAxi82f6M14sfjKz0QkT+eFPYVvCnGb kAC8vt9qu1f0NY+RxQM80wzmBJVPVqjie+s5zrbMj38QCEzaTExhvFv2vxuJj/UwH9lv KpociCE7H/e4MUoIS+u5GCmzpNpb6ROGorHePo0Nm2Cpuy+bRSvoulRqi4LW+WW7WgAh kIa3pVaLkqpaAgRXc2RbLZe09a6gmRI0yBH3j6rISDH9JwbljZHOFhBGb8Tn5K24ODdf UjOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=67bJX/XKYL60smVPDlCopiaK8msQv9FIeu0HmAoY7JA=; b=QSk5NFvNKlevuB4Y0WkRZGx6ip8c42PlsyUHeDyGkLOku3rraCn/6kYNo1/01/3kIU TrH+GMIlbTyAteLc0gbuY3aJXP4zQG9Dcw8B1GmxFGLIi1Ub+Zhy7mqjlhsV1fYm0GB9 A1O84US1MaA6hr5Uj5DI1p6se7Nyxq5gbVMwf1r6/HbOucGEPNRl2n3uGZ7sl3F/isTp u+kd/e4KxHbE8bgKrPfp3hzfJ4FTfoNUFw+deTomOSZjHTX6K/F8R0YmGggrsZkLo6lT nYCB/M9hxWVHxvEbYtrUIekv+VQA9+GtAhqV2ncgduFNZ+bQsDzklLLIz2vvdi1pgqLD NlJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=w8Wnra+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id io13-20020a17090780cd00b0096ace683f1fsi3469007ejc.804.2023.05.22.02.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 02:03:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=w8Wnra+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50B463815FEA for ; Mon, 22 May 2023 08:56:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50B463815FEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684745770; bh=67bJX/XKYL60smVPDlCopiaK8msQv9FIeu0HmAoY7JA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=w8Wnra+MMNUkOmMCYLYGJUjNkLnfANK42W9blMeZr15SB72ZrffEgxmh6rqTXGx48 ZZWo5oD0+QnbrawcQHSYuYdmCzSrzFwdgoFJrlY65T3KBFGNzpxMmTdx5TIV34Vlmt iy7/mxjYUUS+NQ8PhuwrwOUJ241i5U2uvqFcvaEY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 3137A3856DF1 for ; Mon, 22 May 2023 08:50:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3137A3856DF1 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-30950eecc1eso3521680f8f.0 for ; Mon, 22 May 2023 01:50:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684745416; x=1687337416; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=67bJX/XKYL60smVPDlCopiaK8msQv9FIeu0HmAoY7JA=; b=Uw3HD8Deav3XeJmxmxfEI/VGFsEhhrJf98j2Wd5Jc4nc/8PF4atZr66mFlek7kgHQy C7V/ppKtebZSO3SJN2FHQjUmugfwSYkvmPsd6s2SDKGR82MPjMG1A3KLqftAv2jDSsCe hWlGWk+fLa3xiycNzgE2y4DvpZeWsMxE+BbYk8VIPbiuMeUSZZd/rpkCvjC25tb4TfjE 5497m9aEjsMFEfPsMDkVL48Vx2HBaoJ1UZcpo3E1OPUhqrVCTirZMfYuDLEo4VLcUfPB dh66XJV4Mi8N+3iz3oWHhlqoTYskcgTL0kFX4FhnMj29bDNvPpnBUPW3pdB3ZGnzTxuY 9U3A== X-Gm-Message-State: AC+VfDzSPk+YZC9rDMx7j3E8j81ygdsgW71MoyzlDLd2xO3TbU7ct0Tf r3l7mMIOEtYs631iK5YVsl99hfd7kWBuxeqAbSgDfQ== X-Received: by 2002:a5d:4952:0:b0:307:818e:de61 with SMTP id r18-20020a5d4952000000b00307818ede61mr7139101wrs.26.1684745416040; Mon, 22 May 2023 01:50:16 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id q20-20020a1ce914000000b003f18b942338sm7605300wmc.3.2023.05.22.01.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 01:50:15 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Claire Dross Subject: [COMMITTED] ada: Support calls through dereferences in Find_Actual Date: Mon, 22 May 2023 10:50:13 +0200 Message-Id: <20230522085013.1726162-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766584451112896075?= X-GMAIL-MSGID: =?utf-8?q?1766584451112896075?= From: Claire Dross Return the corresponding formal in the designated subprogram profile in that case. gcc/ada/ * sem_util.adb (Find_Actual): On calls through dereferences, return the corresponding formal in the designated subprogram profile. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 46 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ef591c935eb..3ea7ef506df 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -8604,6 +8604,7 @@ package body Sem_Util is Context : constant Node_Id := Parent (N); Actual : Node_Id; Call_Nam : Node_Id; + Call_Ent : Node_Id := Empty; begin if Nkind (Context) in N_Indexed_Component | N_Selected_Component @@ -8652,13 +8653,42 @@ package body Sem_Util is Call_Nam := Selector_Name (Call_Nam); end if; - if Is_Entity_Name (Call_Nam) - and then Present (Entity (Call_Nam)) - and then (Is_Generic_Subprogram (Entity (Call_Nam)) - or else Is_Overloadable (Entity (Call_Nam)) - or else Ekind (Entity (Call_Nam)) in E_Entry_Family - | E_Subprogram_Body - | E_Subprogram_Type) + -- If Call_Nam is an entity name, get its entity + + if Is_Entity_Name (Call_Nam) then + Call_Ent := Entity (Call_Nam); + + -- If it is a dereference, get the designated subprogram type + + elsif Nkind (Call_Nam) = N_Explicit_Dereference then + declare + Typ : Entity_Id := Etype (Prefix (Call_Nam)); + begin + if Present (Full_View (Typ)) then + Typ := Full_View (Typ); + elsif Is_Private_Type (Typ) + and then Present (Underlying_Full_View (Typ)) + then + Typ := Underlying_Full_View (Typ); + end if; + + if Is_Access_Type (Typ) then + Call_Ent := Directly_Designated_Type (Typ); + else + pragma Assert (Has_Implicit_Dereference (Typ)); + Formal := Empty; + Call := Empty; + return; + end if; + end; + end if; + + if Present (Call_Ent) + and then (Is_Generic_Subprogram (Call_Ent) + or else Is_Overloadable (Call_Ent) + or else Ekind (Call_Ent) in E_Entry_Family + | E_Subprogram_Body + | E_Subprogram_Type) and then not Is_Overloaded (Call_Nam) then -- If node is name in call it is not an actual @@ -8672,7 +8702,7 @@ package body Sem_Util is -- Fall here if we are definitely a parameter Actual := First_Actual (Call); - Formal := First_Formal (Entity (Call_Nam)); + Formal := First_Formal (Call_Ent); while Present (Formal) and then Present (Actual) loop if Actual = N then return;