From patchwork Tue Dec 6 14:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 61565 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B07D3834C39 for ; Tue, 6 Dec 2022 14:03:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B07D3834C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670335392; bh=lNKqAK15yAGs1ef1xUHZamx5IPPGEkIrlqX+64OuRH8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=EQ9AkR2F68nQo/CE3xJ+1o1sBr24sDy+95BZNisLAwi2AvON/6sk5OoYo6PJGo+NZ X/g9ZWF10HwoldAIYCCu2dhFqBO5d3uqf4gnkPZ+qNS1ZQXbEg3zidI/HXQojd9YZc S6axAEUvxfTwEnTDVG8mY+fXM9Ttqi5YCs3hvLxI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 6AA2C384C92C for ; Tue, 6 Dec 2022 14:02:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6AA2C384C92C Received: by mail-wr1-x430.google.com with SMTP id bx10so23656471wrb.0 for ; Tue, 06 Dec 2022 06:02:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lNKqAK15yAGs1ef1xUHZamx5IPPGEkIrlqX+64OuRH8=; b=vyv6A6etIZ2CIZ24iRP94TGTNW01/ctMN1esbFV8isUp4qP05ugLuUZdN6v3XIFdq2 bUzN9NgbC7FHydBodAxyoR7rDGwfWueLY+eJoPTMteKqh3xFhpSg3tlKfMNcCxiPNOR2 pGzNlD543CEb4fvvAEi8shIY9dIHVDLp1vFvsOhBMWSN0nD0pkYG22WBMaj8Sdw5eL3/ 1/x2/7z5LDnPj/nv/GWcmjOM5eNEE5GPjZ3w0R5/Os3wBH6dNKvRfmTrW1gHjoM1pXHH LWu6biezibobQfLOzIIF7oeV3W905cy88IphwHNBO/aHNY+blxcFncZiShtb9m5SI2D8 MCUQ== X-Gm-Message-State: ANoB5pnq0rO67CLDvcE/yMiOenPYU8XZhcFyvsGX2LvKwz7noryHRvHz QihaXB5P8liGZ+87E4GaRm/ljT39J1dSVgvK X-Google-Smtp-Source: AA0mqf4RhVaiZUfE7JjNJPnLA1YhBwyO5LAMVPsEPuzxNEdEeMi6JL5/frBoujiAKKe/MCP8vDi+lw== X-Received: by 2002:a5d:5e8e:0:b0:242:7594:c2ef with SMTP id ck14-20020a5d5e8e000000b002427594c2efmr1939007wrb.357.1670335320974; Tue, 06 Dec 2022 06:02:00 -0800 (PST) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id o16-20020adfead0000000b00241cfa9333fsm17088281wrn.5.2022.12.06.06.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 06:02:00 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Small adjustment to special resolution of membership test Date: Tue, 6 Dec 2022 15:01:58 +0100 Message-Id: <20221206140158.717193-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Eric Botcazou 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. Tested on x86_64-pc-linux-gnu, committed on master. --- 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);