aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-07-22 13:57:55 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-22 13:57:55 +0000
commitca305a848c4f1cc493e61083a14b77df226ac8af (patch)
tree58bdeb17cbd35fe3c890f57c972bcd7be4210481 /gcc/testsuite
parent8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9 (diff)
downloadgcc-ca305a848c4f1cc493e61083a14b77df226ac8af.zip
gcc-ca305a848c4f1cc493e61083a14b77df226ac8af.tar.gz
gcc-ca305a848c4f1cc493e61083a14b77df226ac8af.tar.bz2
[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
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/opt80.adb15
2 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c9679c7..acc6063 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2019-07-22 Ed Schonberg <schonberg@adacore.com>
+ * gnat.dg/opt80.adb: New testcase.
+
+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
* gnat.dg/warn25.adb: New testcase.
2019-07-22 Yannick Moy <moy@adacore.com>
diff --git a/gcc/testsuite/gnat.dg/opt80.adb b/gcc/testsuite/gnat.dg/opt80.adb
new file mode 100644
index 0000000..39c6cef
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt80.adb
@@ -0,0 +1,15 @@
+-- { dg-do run }
+-- { dg-options "-O2" }
+
+with Ada.Text_IO; use Ada.Text_IO;
+
+procedure Opt80 is
+ Item : Integer;
+begin
+ Item := Integer'Value ("zzz");
+ Put_Line (Boolean'Image (Item'Valid));
+ raise Program_Error;
+exception
+ when Constraint_Error =>
+ null;
+end;