diff options
author | Justin Squirek <squirek@adacore.com> | 2022-09-06 15:59:59 +0000 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2022-09-26 11:02:30 +0200 |
commit | 63055635797e98d9cc67e53c3de44bae2f4c9939 (patch) | |
tree | 2654e515ace9165363ccf9093e7266fa3fff14f0 /gcc/ada | |
parent | 9677984d7b230f4fbf22e5cd1f14ca4c976ab1ec (diff) | |
download | gcc-63055635797e98d9cc67e53c3de44bae2f4c9939.zip gcc-63055635797e98d9cc67e53c3de44bae2f4c9939.tar.gz gcc-63055635797e98d9cc67e53c3de44bae2f4c9939.tar.bz2 |
ada: Improve accessibility check generation
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.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_util.adb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index b0babeb..c43a008 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 |