Fix uninitialized variable with nested variant record types
commit71465223b95af43951c423ad77391e706f02901d
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 10 Sep 2020 15:47:32 +0000 (10 17:47 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 10 Sep 2020 16:00:57 +0000 (10 18:00 +0200)
tree708ff979248ddb6daebc0a49eed834903174c78a
parent66a204a6567385638f633732bb61e2ac26b2eb02
Fix uninitialized variable with nested variant record types

This fixes a wrong code issue with nested variant record types: the
compiler generates move instructions that depend on an uninitialized
variable, which was initially a SAVE_EXPR not instantiated early enough.

gcc/ada/ChangeLog:
* gcc-interface/decl.c (build_subst_list): For a definition, make
sure to instantiate the SAVE_EXPRs generated by the elaboration of
the constraints in front of the elaboration of the type itself.

gcc/testsuite/ChangeLog:
* gnat.dg/discr59.adb: New test.
* gnat.dg/discr59_pkg1.ads: New helper.
* gnat.dg/discr59_pkg2.ads: Likewise.
gcc/ada/gcc-interface/decl.c
gcc/testsuite/gnat.dg/discr59.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr59_pkg1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr59_pkg2.ads [new file with mode: 0644]