From 77691b9ff59fbf87ad70c3f2b6fad41ee469f078 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 1 Oct 2025 11:59:18 -0300 Subject: [PATCH] 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. --- 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 60224c19b19..482084cdebc 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)); -- 2.47.3