From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 7B739384C908; Tue, 6 Dec 2022 14:01:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B739384C908 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670335269; bh=N5zMSCeix2wRHUbd0DoM1g/eaFi7ki+XWTTkNR5rBag=; h=From:To:Subject:Date:From; b=HHsO0s04593KFAbIM4s99wEEd6JcNRiTt/9oa3YRNASuD+jEgTw3NFcjVxByQlTu8 Aqikg5rwer3sF6WakXp84qk4LcYmsc7iFDFkI/jQL5A+dMOlHr1lLUS4RHjWXCobJS JkiKRfPB5NREEVDEChVF7piEgOk4STuwddzjR3sc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4510] ada: Small adjustment to special resolution of membership test X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: d1ab8eddca918f342b06a66fedb8fbc06c5532ab X-Git-Newrev: a444c05623faa2b6bd1bbc8f7908b8ea3d83b475 Message-Id: <20221206140109.7B739384C908@sourceware.org> Date: Tue, 6 Dec 2022 14:01:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a444c05623faa2b6bd1bbc8f7908b8ea3d83b475 commit r13-4510-ga444c05623faa2b6bd1bbc8f7908b8ea3d83b475 Author: Eric Botcazou Date: Sun Dec 4 14:53:26 2022 +0100 ada: Small adjustment to special resolution of membership test It's needed because, in GNAT, universal_integer does not cover all the values of all the supported integer types. gcc/ada/ * sem_res.adb (Resolve_Membership_Op): Adjust latest change. Diff: --- gcc/ada/sem_res.adb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 3574afd19ac..4bbec65d6a0 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10105,11 +10105,11 @@ package body Sem_Res is then T := Etype (R); - -- If the left operand is of a universal numeric type and the right - -- operand is not, we do not resolve the operands to the tested type - -- but to the universal type instead. If not conforming to the letter, - -- it's conforming to the spirit of the specification of membership - -- tests, which are typically used to guard a specific operation and + -- If the type of the left operand is universal_integer and that of the + -- right operand is smaller, then we do not resolve the operands to the + -- tested type but to universal_integer instead. If not conforming to + -- the letter, it's conforming to the spirit of the specification of + -- membership tests, which are typically used to guard an operation and -- ought not to fail a check in doing so. Without this, in the case of -- type Small_Length is range 1 .. 16; @@ -10122,10 +10122,14 @@ package body Sem_Res is -- the function Is_Small_String would fail a range check for strings -- larger than 127 characters. + -- The test on the size is required in GNAT because universal_integer + -- does not cover all the values of all the supported integer types, + -- for example the large values of Long_Long_Long_Unsigned. + elsif not Is_Overloaded (L) - and then Is_Universal_Numeric_Type (Etype (L)) + and then Etype (L) = Universal_Integer and then (Is_Overloaded (R) - or else not Is_Universal_Numeric_Type (Etype (R))) + or else RM_Size (Etype (R)) < RM_Size (Universal_Integer)) then T := Etype (L);