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: 30307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2838868wrr; Tue, 6 Dec 2022 06:05:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Sw6GyISOK2/A0ux0xG6/bU9+ZSuwHOQJBBeFFH8GyxGPhU5e+B8ybDVHmouxVXytZRCHF X-Received: by 2002:a17:907:d006:b0:7bc:ad2d:879d with SMTP id va6-20020a170907d00600b007bcad2d879dmr41787193ejc.603.1670335528329; Tue, 06 Dec 2022 06:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670335528; cv=none; d=google.com; s=arc-20160816; b=GSyX1JGoMaFU1oM3xqWrCweR6m/Ub2hsdVuYYmNEFjOI26r2goCNMz2RHvX1boNuGF RKW6+mHZHWcWKv+Uuj+7WVGcwGYuOSGLlCgHtcl2mYQyEtUs47zIrGiHM1uHpdPkIYtK ORyNYEbGHYKDkfrTLQQawzFqghxBZ/Hjwj8GvdC+D7kVnv7FRWKP0NPXjaigniSaT5lg IzVEcMwt6jil4fA4u4LynAW2+oKeNpG4Jg/5iKUiyDAnScuUBTGqDT3w5bwiDR/Pt6i9 W5A7rlu9xQ9gY/sN+BTTLs9i0L2FpWtfQq2tZwMAAlytMgwx1EW013aA+iyuz7NaKTq0 BTNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=lNKqAK15yAGs1ef1xUHZamx5IPPGEkIrlqX+64OuRH8=; b=MauDSUDcfe+8rnV1UXxn8pA+m7EUg/AMFXewwwrC/ggv9W3+2++cBmzQ0JaBctUxGu hLKdKoDHHqxyIsr3An5vljlGyWOefhoEijahGyD1QnvMmrIAOLmGHaDghPejwqn0B2ae nXAXM0ZbOIyM1doKsKE/7ovpasS1KU8PulhChlFFx1lolYgCNJwuSuImoD9lR162rGlv TttdCDQmG2kUwXT21sS3O5IULzFkcbclpVBRwhqBot5wqQuqOtR5NfG1gLb7XZ0x/L7R yBUzLWGbs2p97xwmf8gdepgNJ3Ks93ilqW59qFtflpGUNCWpls/FEX89zqmCaOU+sUuQ g1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lSYDWCL8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b19-20020a056402279300b0046abb9e43a8si2283755ede.321.2022.12.06.06.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 06:05:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lSYDWCL8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE594382E44C for ; Tue, 6 Dec 2022 14:03:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE594382E44C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670335407; 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=lSYDWCL8Cgu3llcMahMeAwJw3fPIZsRZzk1GXdqQuXckAdLA1Q1OO1C12ZK3eifO/ A8fGwIJlY4rJZ8YMY73amgBy+zv4UY4yv67EHOFfK3VmwT9bh/NSCk+vrz35UvQu10 G9kkn3inUvCuX/hbdyAJSLeGqXN8+DUnQ1Rf6e6c= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751473747036659876?= X-GMAIL-MSGID: =?utf-8?q?1751473747036659876?= 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);