[Ada] Crash on aggregate with dscriminant in if-expression as default
authorEd Schonberg <schonberg@adacore.com>
Wed, 18 Sep 2019 08:33:27 +0000 (08:33 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 18 Sep 2019 08:33:27 +0000 (08:33 +0000)
commitb8411279b0674cd76850b0fa8266e8db21724e0e
tree870d33909d2ed5dd5c09ae3ed6934a9e4fb96314
parent483af72e4bf2499fdbbf6b6e061318eaa9ba2b2d
[Ada] Crash on aggregate with dscriminant in if-expression as default

This patch fixes a crash on a an aggregate for a discriminated type,
when a component of the aggregate is also a discriminated type
constrained by a discriminant of the enclosing object, and the default
value for the component is a conditional expression that includes
references to that outer discriminant.

2019-09-18  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_aggr.adb (Expand_Record_Aggregate, Rewrite_Discriminant):
After rewriting a reference to an outer discriminant as a
selected component of the enclosing object, analyze the selected
component to ensure that the entity of the selector name is
properly set. This is necessary when the aggregate appears
within an expression that may have been analyzed already.

gcc/testsuite/

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

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