[Ada] Optimization loses exception in improper use of 'Value
authorEd Schonberg <schonberg@adacore.com>
Mon, 22 Jul 2019 13:57:55 +0000 (13:57 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 22 Jul 2019 13:57:55 +0000 (13:57 +0000)
commitca305a848c4f1cc493e61083a14b77df226ac8af
tree58bdeb17cbd35fe3c890f57c972bcd7be4210481
parent8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9
[Ada] Optimization loses exception in improper use of 'Value

This patch prevents an improper removal of an evaluation of attribute
'Value on an illegal input that will raise Constraint_Error, when a
subsequent use of this evaluation might be optimized away by the
back-end.

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

gcc/ada/

* libgnat/s-valboo.ads, libgnat/s-valcha.ads,
libgnat/s-valdec.ads, libgnat/s-valenu.ads,
libgnat/s-valint.ads, libgnat/s-vallld.ads,
libgnat/s-vallli.ads, libgnat/s-valllu.ads,
libgnat/s-valrea.ads, libgnat/s-valuns.ads,
libgnat/s-valwch.ads: Change categorization of packages that
implement attribute 'Value from Pure to Preelaborate, to prevent
undesirable optimizations when the evaluation of the attribute
raises Constraint_Error, but subsequent use of the result of
this evsaluation is removed by a subsequent optimization.

gcc/testsuite/

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

From-SVN: r273687
14 files changed:
gcc/ada/ChangeLog
gcc/ada/libgnat/s-valboo.ads
gcc/ada/libgnat/s-valcha.ads
gcc/ada/libgnat/s-valdec.ads
gcc/ada/libgnat/s-valenu.ads
gcc/ada/libgnat/s-valint.ads
gcc/ada/libgnat/s-vallld.ads
gcc/ada/libgnat/s-vallli.ads
gcc/ada/libgnat/s-valllu.ads
gcc/ada/libgnat/s-valrea.ads
gcc/ada/libgnat/s-valuns.ads
gcc/ada/libgnat/s-valwch.ads
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt80.adb [new file with mode: 0644]