From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32c.google.com with SMTP id l8so4030757wmi.2 for ; Mon, 26 Sep 2022 02:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=gpvMIlF4fh9NtYP8B2lNi2D3nQ+XhSaFvorI2a32Kkw=; b=OE6ifUGSFEgZV1VXx8B3tS6sFQMM660nLQSB7uw/7HLaReLiKph6zQR5IIfzgLD5wt RAoqFbNoErEUexETxsej4JIxigbLdyRc+0684n8E9X+ZcjqQbF2ccW9xDcuin2aUNENN 1zH8TExkYUGzemmHvuPJR8ySVzzSS/FEI9YP+fw6KE1Pu7WLaSzr5NJ2kfeuOlsdM/F3 tSHjBeACMajGiuJTuzcXXhMkGVm16r3fG0fuavz2diH8/Ja+ZbAG7bNLFFUDgln+4Tpa 1su2R7mnwQCZR+JKFw4IYaE4Z5bzIDDOChXn/SrPbuAJAmg1nExwjPPKAABs7TJSk6gv bolw== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.25.1