[Ada] Fix spurious error on derived record passed as Out parameter
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 9 Oct 2018 15:06:35 +0000 (15:06 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 9 Oct 2018 15:06:35 +0000 (15:06 +0000)
commite693ddbec3e38aeff2e229785b9037ba0caa17c8
treec2982d7ce8279b96ff13045aa674032b22d111e4
parent38c2f655ffa5cf2f335c2772ec484702d891a7c3
[Ada] Fix spurious error on derived record passed as Out parameter

This fixlet gets rid of a spurious error issued in the specific case of
a call to a subprogram taking an Out parameter of a discriminated record
type without default discriminants, if the actual parameter is the
result of the conversion to the record type of a variable whose type is
derived from the record and has a representation clause.

The compiler was failing to initialize the temporary made around the
call because of the representation clause, but this is required for a
type with discriminants because discriminants may be read by the called
subprogram.

2018-10-09  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch6.adb (Add_Call_By_Copy_Code): Initialize the temporary
made for an Out parameter if the formal type has discriminants.

gcc/testsuite/

* gnat.dg/derived_type5.adb, gnat.dg/derived_type5_pkg.ads: New
testcase.

From-SVN: r264980
gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/derived_type5.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/derived_type5_pkg.ads [new file with mode: 0644]