* [COMMITTED] ada: Cope with Sem_Util.Enclosing_Declaration oddness.
@ 2023-12-19 14:30 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-12-19 14:30 UTC (permalink / raw)
To: gcc-patches; +Cc: Steve Baird
From: Steve Baird <baird@adacore.com>
Sem_Util.Enclosing_Declaration can return a non-empty result which is not
a declaration; clients may need to compensate for the case where an
N_Subprogram_Specification node is returned. One such client is the function
Is_Actual_Subp_Of_Inst.
gcc/ada/
* sem_ch8.adb (Is_Actual_Subp_Of_Inst): After calling
Enclosing_Declaration, add a check for the case where one more
Parent call is needed to get the enclosing declaration.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch8.adb | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index c5bf0864671..2e6b1b6d785 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -2691,7 +2691,7 @@ package body Sem_Ch8 is
-- Each attempt to find a suitable primitive of a particular
-- type operates on its own copy of the original renaming.
-- As a result the original renaming is kept decoration and
- -- side-effect-free.
+ -- side-effect free.
-- Inherit the overloaded status of the renamed subprogram name
@@ -6550,6 +6550,16 @@ package body Sem_Ch8 is
Decl := Enclosing_Declaration (E);
+ -- Enclosing_Declaration does not always return a
+ -- declaration; cope with this irregularity.
+ if Decl in N_Subprogram_Specification_Id
+ and then Nkind (Parent (Decl)) in
+ N_Subprogram_Body | N_Subprogram_Declaration
+ | N_Subprogram_Renaming_Declaration
+ then
+ Decl := Parent (Decl);
+ end if;
+
-- Look for the suprogram renaming declaration built
-- for a generic actual subprogram. Unclear why
-- Original_Node call is needed, but sometimes it is.
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-19 14:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 14:30 [COMMITTED] ada: Cope with Sem_Util.Enclosing_Declaration oddness Marc Poulhiès
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).