[Ada] Crash on partial initialization of controlled component
authorHristian Kirtchev <kirtchev@adacore.com>
Tue, 22 May 2018 13:26:55 +0000 (13:26 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 22 May 2018 13:26:55 +0000 (13:26 +0000)
commit02db8169939bb489abb6c7025395a3fc671b79b6
treecbfa4d2c52a3d0d3df46656e51a945aa39790347
parent9820b3897803c38f66f8515dc15cdb3e10c7ad20
[Ada] Crash on partial initialization of controlled component

This patch modifies the late expansion of record aggregates to ensure that the
generated code which handles a controlled component initialized by a function
call is inserted in line with the rest of the initialization code, rather than
before the record aggregate. This way the function call has proper access to
the discriminants of the object being created.

2018-05-22  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

* exp_aggr.adb (Initialize_Ctrl_Record_Component): Insert the generated
code for a transient component in line with the rest of the
initialization code, rather than before the aggregate. This ensures
that the component has proper visibility of the discriminants.

gcc/testsuite/

* gnat.dg/controlled8.adb: New testcase.

From-SVN: r260532
gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/controlled8.adb [new file with mode: 0644]