From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Justin Squirek <squirek@adacore.com>
Subject: [COMMITED] ada: Improve accessibility check generation
Date: Mon, 26 Sep 2022 11:14:37 +0200 [thread overview]
Message-ID: <20220926091437.272873-1-poulhies@adacore.com> (raw)
From: Justin Squirek <squirek@adacore.com>
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
reply other threads:[~2022-09-26 9:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220926091437.272873-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=squirek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).