From: Alexandre Oliva Date: Wed, 1 Oct 2025 14:59:18 +0000 (-0300) Subject: ada: Add ctor call after address clause X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77691b9ff59fbf87ad70c3f2b6fad41ee469f078;p=thirdparty%2Fgcc.git 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 --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));