From: Alexandre Oliva <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
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.51.0