public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3744] [Ada] Add assertions to Uintp (UI_Is_In_Int_Range) Date: Tue, 21 Sep 2021 15:27:15 +0000 (GMT) [thread overview] Message-ID: <20210921152715.515803857C52@sourceware.org> (raw) https://gcc.gnu.org/g:b6bb60b2414b6cdfc8f24b3b50bbbdfc8090c443 commit r12-3744-gb6bb60b2414b6cdfc8f24b3b50bbbdfc8090c443 Author: Bob Duff <duff@adacore.com> Date: Tue Jul 6 17:12:32 2021 -0400 [Ada] Add assertions to Uintp (UI_Is_In_Int_Range) gcc/ada/ * uintp.ads, uintp.adb (UI_Is_In_Int_Range): Change the type of the formal parameter to Valid_Uint. Remove code that preserved the previous behavior, and replace it with an assertion. The previous behavior is no longer needed given the recent change to gigi. (No, Present): Add comment. Diff: --- gcc/ada/uintp.adb | 9 ++++----- gcc/ada/uintp.ads | 7 +++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb index dad4e9bcf89..29d409b49e1 100644 --- a/gcc/ada/uintp.adb +++ b/gcc/ada/uintp.adb @@ -1693,16 +1693,15 @@ package body Uintp is -- UI_Is_In_Int_Range -- ------------------------- - function UI_Is_In_Int_Range (Input : Uint) return Boolean is + function UI_Is_In_Int_Range (Input : Valid_Uint) return Boolean is + pragma Assert (Present (Input)); + -- Assertion is here in case we're called from C++ code, which does + -- not check the predicates. begin -- Make sure we don't get called before Initialize pragma Assert (Uint_Int_First /= Uint_0); - if No (Input) then -- Preserve old behavior - return True; - end if; - if Direct (Input) then return True; else diff --git a/gcc/ada/uintp.ads b/gcc/ada/uintp.ads index 75bc5581fb5..d9f1f8f70fb 100644 --- a/gcc/ada/uintp.ads +++ b/gcc/ada/uintp.ads @@ -90,6 +90,10 @@ package Uintp is Uint_Minus_127 : constant Uint; Uint_Minus_128 : constant Uint; + -- Functions for detecting No_Uint. Note that clients of this package + -- cannot use "=" and "/=" to compare with No_Uint; they must use No + -- and Present instead. + function No (X : Uint) return Boolean is (X = No_Uint); -- Note that this is using the predefined "=", not the "=" declared below, -- which would blow up on No_Uint. @@ -169,10 +173,9 @@ package Uintp is pragma Inline (UI_Gt); -- Compares integer values for greater than - function UI_Is_In_Int_Range (Input : Uint) return Boolean; + function UI_Is_In_Int_Range (Input : Valid_Uint) return Boolean; pragma Inline (UI_Is_In_Int_Range); -- Determines if universal integer is in Int range. - -- Input should probably be of type Valid_Uint. function UI_Le (Left : Valid_Uint; Right : Valid_Uint) return Boolean; function UI_Le (Left : Int; Right : Valid_Uint) return Boolean;
reply other threads:[~2021-09-21 15:27 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=20210921152715.515803857C52@sourceware.org \ --to=pmderodat@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).