[Ada] Crash on case expression in build-in-place function
authorHristian Kirtchev <kirtchev@adacore.com>
Tue, 17 Jul 2018 08:03:44 +0000 (08:03 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 17 Jul 2018 08:03:44 +0000 (08:03 +0000)
commit6a4f3b312e2aa6016963a6befc986b93465be968
treef1fb95d6b8c3299b2d69dba33e5faea1fa90d1c1
parent5a3c20f80eb2ca30c721fcab728529589c80c414
[Ada] Crash on case expression in build-in-place function

This patch modifies the recursive tree replication routine New_Copy_Tree to
create new entities and remap old entities to the new ones for constructs in
N_Expression_With_Actions nodes when requested by a caller. This in turn allows
the build-in-place mechanism to avoid sharing entities between the 4 variants
of returns it generates.

2018-07-17  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

* exp_ch6.adb (Build_Heap_Or_Pool_Allocator): Ensure that scoping
constructs and entities within receive new entities when replicating a
tree.
(Expand_N_Extended_Return_Statement): Ensure that scoping constructs
and entities within receive new entities when replicating a tree.
* sem_util.adb (New_Copy_Tree): Add new formal Scopes_In_EWA_OK.
(Visit_Entity): Visit entities within scoping constructs inside
expression with actions nodes when requested by the caller. Add blocks,
labels, and procedures to the list of entities which need replication.
* sem_util.ads (New_Copy_Tree): Add new formal Scopes_In_EWA_OK. Update
the comment on usage.

gcc/testsuite/

* gnat.dg/bip_case_expr.adb, gnat.dg/bip_case_expr_pkg.ads: New testcase.

From-SVN: r262766
gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/bip_case_expr.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/bip_case_expr_pkg.ads [new file with mode: 0644]