]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Do not remove side-effects in an others_clause with function calls
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:08:22 +0000 (08:08 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Aug 2019 08:08:22 +0000 (08:08 +0000)
commitea791f8e9224c9e36d40adf2b80854602778396e
treec2d08692c744bd2726cb6c50d40e0988ce4c5e50
parentda8cdc914eae2b057a4c4cb1db343a0ba35bb4d5
[Ada] Do not remove side-effects in an others_clause with function calls

An aggregate can be handled by the backend if it consists of static
constants of an elementary type, or null. If a component is a type
conversion we must preanalyze and resolve it to determine whether the
ultimate value is in one of these categories.  Previously we did a full
analysis and resolution of the expression for the component, which could
lead to a removal of side-effects, which is semantically incorrect if
the expression includes functions with side-effects (e.g. a call to a
random generator).

2019-08-13  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_aggr.adb (Aggr_Assignment_OK_For_Backend):  Preanalyze
expression, rather do a full analysis, to prevent unwanted
removal of side effects which mask the intent of the expression.

gcc/testsuite/

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274355 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/aggr27.adb [new file with mode: 0644]