https://gcc.gnu.org/g:77691b9ff59fbf87ad70c3f2b6fad41ee469f078
commit r16-4975-g77691b9ff59fbf87ad70c3f2b6fad41ee469f078 Author: Alexandre Oliva <[email protected]> Date: Wed Oct 1 11:59:18 2025 -0300 ada: Add ctor call after address clause An object initialized by a C++-imported constructor call has the constructor function call transformed into a procedure call, and the call is inserted after the object declaration. If the object has say an address clause, that transformation separates the declaration from the address clause, causing the translation of the call to fail. Keep such clauses next to the declaration by inserting the constructor procedure call after them. gcc/ada/ChangeLog: * exp_ch3.adb (Expand_N_Object_Declaration): Insert ctor call after representation clauses. Diff: --- gcc/ada/exp_ch3.adb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 60224c19b19b..482084cdebc3 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -8286,6 +8286,16 @@ package body Exp_Ch3 is Set_Must_Not_Freeze (Id_Ref); Set_Assignment_OK (Id_Ref); + -- Avoid separating an object declaration from + -- its representation clauses. + + while Present (Next (Init_After)) + and then Nkind (Next (Init_After)) in + N_Attribute_Definition_Clause + loop + Init_After := Next (Init_After); + end loop; + Insert_Actions_After (Init_After, Build_Initialization_Call (N, Id_Ref, Typ, Constructor_Ref => Expr));
