From patchwork Mon Sep 26 09:14:37 2022 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: 58022 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC98A385734E for ; Mon, 26 Sep 2022 09:15:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC98A385734E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664183724; bh=gpvMIlF4fh9NtYP8B2lNi2D3nQ+XhSaFvorI2a32Kkw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eZkmfSzou0ioJPDxuPC6bCDUCmTGNkxBbBmOloo1uN/ZuLUhzNTzTqy5zCmL9biJh WlaBk9lf9VzzGxkFMpjevacQ0w30aJat2UeAR+3T8FGiXmaX3lasUbfNrlmi3l4JeU 2hajR69bNDgNubVS7bkNGxWZ/VE7uL5CF+q3XlSo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 6EB023858412 for ; Mon, 26 Sep 2022 09:14:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6EB023858412 Received: by mail-wm1-x32c.google.com with SMTP id l8so4030757wmi.2 for ; Mon, 26 Sep 2022 02:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=gpvMIlF4fh9NtYP8B2lNi2D3nQ+XhSaFvorI2a32Kkw=; b=iyv0Zws0XNhbQ6uyA9gxW9mfB/W8C+6V9xKJ2a8Zn0VvvwG6/34gv8QjGDJPmFCDm/ /N3L1A+inNWxuEKtBz1Pcgu8euBfmRyaIC9ecSI4DGlsWqqMvGSBzCQLljv8NjbPLjZ1 3j+6G5iRlFFUc+2ZhtYNJDyCSB5T4oW0w3EFJmYNNbJcQXNmZ2FCW5iAA4Kh5KJk3D5N BzyDJvfopH63d032aaL4ZULOckJAcZDCPCkoU7wQOfcLBx5u4IxLdPCLYlp2G9MTJJkx syJBbsQiGJ0Fb2oFVJwaRFNVepjHVDFKPcv/VGJGQfumHbhwjgNdkLin8whQLxUodk3w Nl/g== X-Gm-Message-State: ACrzQf16CTiXUsOj/vmJxvZHRz2CfUl6SqbQ9xwqoWsyvW5go7AuZWNV lpRtF5mvDZzklcSFfGiMKnGSURGWZPVd3g== X-Google-Smtp-Source: AMsMyM4W77JmS5nMxYpL5bNJI48ijymkiXc/o3NB55Jpt8MJkjyzVHHYZ2X5j9WVuFu3xBY2eui2Pw== X-Received: by 2002:a05:600c:21c2:b0:3b4:7272:bfd3 with SMTP id x2-20020a05600c21c200b003b47272bfd3mr20563864wmj.148.1664183690188; Mon, 26 Sep 2022 02:14:50 -0700 (PDT) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id r64-20020a1c4443000000b003b4935f04a4sm12852130wma.5.2022.09.26.02.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 02:14:49 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [COMMITED] ada: Improve accessibility check generation Date: Mon, 26 Sep 2022 11:14:37 +0200 Message-Id: <20220926091437.272873-1-poulhies@adacore.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 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 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?= Cc: Justin Squirek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Justin Squirek Improve accessibility check generation by more precisely identifying cases in which an Original_Node call is needed. Instead of grabbing the Original_Node of a prefix in all cases (since this can cause issues where unanalyzed instance names get referenced) we only obtain the original node when said prefix comes as a result of expanding function calls. gcc/ada/ * sem_util.adb (Accessibility_Level): Modify indexed and selected components case by reducing the scope where Original_Node gets used. --- gcc/ada/sem_util.adb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index b0babeb9d6f..c43a008ae5d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -531,7 +531,7 @@ package body Sem_Util is -- Local variables - E : Entity_Id := Original_Node (Expr); + E : Node_Id := Original_Node (Expr); Pre : Node_Id; -- Start of processing for Accessibility_Level @@ -777,8 +777,18 @@ package body Sem_Util is -- We don't handle function calls in prefix notation correctly ??? - when N_Indexed_Component | N_Selected_Component => - Pre := Original_Node (Prefix (E)); + when N_Indexed_Component | N_Selected_Component | N_Slice => + Pre := Prefix (E); + + -- Fetch the original node when the prefix comes from the result + -- of expanding a function call since we want to find the level + -- of the original source call. + + if not Comes_From_Source (Pre) + and then Nkind (Original_Node (Pre)) = N_Function_Call + then + Pre := Original_Node (Pre); + end if; -- When E is an indexed component or selected component and -- the current Expr is a function call, we know that we are