From: Piotr Trojanek <troja...@adacore.com>

When rewriting N_Subprogram_Instantiation into wrapper packages we must move
the original aspect specifications to the wrapper packages, as otherwise they
will be only accessible via Original_Node. This is similar to how we move
aspect specifications for expression functions and many other constructs.

gcc/ada/ChangeLog:

        * sem_ch12.adb (Analyze_Subprogram_Instantiation): Move aspects when
        instantiating subprogram as a library unit.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch12.adb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 062251f15a9..f492b236857 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -6704,6 +6704,7 @@ package body Sem_Ch12 is
 
             elsif Nkind (Parent (N)) = N_Compilation_Unit then
                Rewrite (N, Unit (Parent (N)));
+               Move_Aspects (From => Original_Node (N), To => N);
                Set_Unit (Parent (N), N);
             end if;
 
@@ -6712,6 +6713,7 @@ package body Sem_Ch12 is
 
          elsif Nkind (Parent (N)) = N_Compilation_Unit then
             Rewrite (N, Unit (Parent (N)));
+            Move_Aspects (From => Original_Node (N), To => N);
             Set_Unit (Parent (N), N);
          end if;
 
-- 
2.43.0

Reply via email to