[Ada] Access to uninitialized memory by predicate check
authorEd Schonberg <schonberg@adacore.com>
Tue, 9 Jul 2019 07:55:38 +0000 (07:55 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 9 Jul 2019 07:55:38 +0000 (07:55 +0000)
commit5e0f7ab2fb33372f298ad9333dd2dd2e44cf01cc
treece93a484c8270a63ed5a2a499fd930e8c764db03
parent924e3532dcdabde43f5b49f1ef1a95656f4e37dc
[Ada] Access to uninitialized memory by predicate check

This patch fixes an exception or erroneous execution, when the
declaration for an object of a composite type that has a dynanic
predicate is initialized with an aggregate that requires expansion into
individual components. Prior to this patch the predicate check for the
object appeared before intialization was performed, thus accessing
uninitialized memory.

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

gcc/ada/

* sem_ch3.adb (Analyze_Object_Declaration): If the object type
is a composite type that has a dynamic predicate and, the
expression in the declaration is an aggregate, the generated
predicate check must appear after the expanded code for the
aggregate, which will appear after the rewritten object
declarastion.

gcc/testsuite/

* gnat.dg/predicate10.adb, gnat.dg/predicate10_pkg.adb,
gnat.dg/predicate10_pkg.ads: New testcase.

From-SVN: r273293
gcc/ada/ChangeLog
gcc/ada/sem_ch3.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/predicate10.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/predicate10_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/predicate10_pkg.ads [new file with mode: 0644]