public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Giuliano Belinassi <giulianob@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/autopar_devel] [Ada] Use pragma Unsuppress in Time_IO Date: Sat, 22 Aug 2020 23:21:27 +0000 (GMT) [thread overview] Message-ID: <20200822232127.BF731393C85A@sourceware.org> (raw) https://gcc.gnu.org/g:bb06a4318c07aa012e9d84140f6de84fb97d4008 commit bb06a4318c07aa012e9d84140f6de84fb97d4008 Author: Bob Duff <duff@adacore.com> Date: Tue May 12 11:07:36 2020 -0400 [Ada] Use pragma Unsuppress in Time_IO gcc/ada/ * libgnat/g-catiio.adb (Value, Parse_ISO_8601): Unsuppress checks, and don't rely on 'Valid. Diff: --- gcc/ada/libgnat/g-catiio.adb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gcc/ada/libgnat/g-catiio.adb b/gcc/ada/libgnat/g-catiio.adb index ad1babfb826..cd2df6a438b 100644 --- a/gcc/ada/libgnat/g-catiio.adb +++ b/gcc/ada/libgnat/g-catiio.adb @@ -654,6 +654,12 @@ package body GNAT.Calendar.Time_IO is Time : out Ada.Calendar.Time; Success : out Boolean) is + pragma Unsuppress (All_Checks); + -- This is necessary because the run-time library is usually compiled + -- with checks suppressed, and we are relying on constraint checks in + -- this code to catch syntax errors in the Date string (e.g. out of + -- bounds slices). + Index : Positive := Date'First; -- The current character scan index. After a call to Advance, Index -- points to the next character. @@ -1021,7 +1027,10 @@ package body GNAT.Calendar.Time_IO is Success := True; exception - when Wrong_Syntax => + when Wrong_Syntax | Constraint_Error => + -- If constraint check fails, we want to behave the same as + -- Wrong_Syntax; we want the caller (Value) to try other + -- allowed syntaxes. Time := Time_Of (Year_Number'First, Month_Number'First, Day_Number'First); Success := False; @@ -1032,6 +1041,8 @@ package body GNAT.Calendar.Time_IO is ----------- function Value (Date : String) return Ada.Calendar.Time is + pragma Unsuppress (All_Checks); -- see comment in Parse_ISO_8601 + D : String (1 .. 21); D_Length : constant Natural := Date'Length; @@ -1281,18 +1292,6 @@ package body GNAT.Calendar.Time_IO is Extract_Time (1, Hour, Minute, Second, Check_Space => False); end if; - -- Sanity checks - - if not Year'Valid - or else not Month'Valid - or else not Day'Valid - or else not Hour'Valid - or else not Minute'Valid - or else not Second'Valid - then - raise Constraint_Error; - end if; - return Time_Of (Year, Month, Day, Hour, Minute, Second); end Value;
reply other threads:[~2020-08-22 23:21 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200822232127.BF731393C85A@sourceware.org \ --to=giulianob@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).