diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d0eba383343..9ad5b1be173 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2011-12-02 Thomas Quinot + + * sem_ch10.adb (Analyze_Compilation_Unit): For a library subprogram + body that acts as spec, do not create a shallow copy of the context + clause for the synthetized spec (instead, use the same list as + in the body). + 2011-12-02 Bob Duff * gnat_ugn.texi: Clarify usage of -p binder switch. diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 4913b13e00e..27d9e45b93b 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -807,9 +807,20 @@ package body Sem_Ch10 is begin Set_Comes_From_Source_Default (False); + + -- Checks for redundant USE TYPE clauses have a special + -- exception for the synthetic spec we create here. This + -- special case relies on the two compilation units + -- sharing the same context clause. + + -- Note: We used to do a shallow copy (New_Copy_List), + -- which defeated those checks and also created malformed + -- trees (subtype mark shared by two distinct + -- N_Use_Type_Clause nodes) which crashed the compiler. + Lib_Unit := Make_Compilation_Unit (Loc, - Context_Items => New_Copy_List (Context_Items (N)), + Context_Items => Context_Items (N), Unit => Make_Subprogram_Declaration (Sloc (N), Specification =>