From ca305a848c4f1cc493e61083a14b77df226ac8af Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 22 Jul 2019 13:57:55 +0000 Subject: [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 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 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/opt80.adb | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/opt80.adb (limited to 'gcc/testsuite') 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 + * gnat.dg/opt80.adb: New testcase. + +2019-07-22 Ed Schonberg + * gnat.dg/warn25.adb: New testcase. 2019-07-22 Yannick Moy 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; -- cgit v1.1