From patchwork Wed Oct 20 19:27:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1544019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NHo9m3ha; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZLM173gJz9sNH for ; Thu, 21 Oct 2021 06:31:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C40143857C58 for ; Wed, 20 Oct 2021 19:31:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C40143857C58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634758267; bh=bVeypIpM31Ij70x3u6gmkE84e01wNQ1FP242hrOR5/E=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NHo9m3haSjja3Q4M42hZjH3pniXrgC2BeJmJaxxt5RXZcEU5Gd/HwQvejclZBJA1P ncNqjrplThG8SnWIJl70Rfub3DEzdEhM+qvR1hBYw9xsWbIVcVwf1+rafo4pF76JSN egURsu7ZGsb/AhIWoEFyucY6AjNU/WisngfXN46k= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 47EA13857C67 for ; Wed, 20 Oct 2021 19:27:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 47EA13857C67 Received: by mail-lf1-x12f.google.com with SMTP id t9so83081lfd.1 for ; Wed, 20 Oct 2021 12:27:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=bVeypIpM31Ij70x3u6gmkE84e01wNQ1FP242hrOR5/E=; b=uVjWGbfT6PXZ9zUAYeQuDE8Sy23i+/qtZxlQOOhqg2uAHOL1cv+KS7SlEna/ED1c9Q Uc+BVWFMeGUiijoVP4id+D9Iv+aMjnjq4qV+670rcfMHETxfIQ7v13Q1gc25K6+sQ7ZG x3MPsjPOIHo2gM41om9Ba/UPXDnkZgN5cPVBhsYaSc1VDqZm24zK5U6QbPKM5ZJLrIf7 MHLauiatFuvBKoNBkA8LNEnupuwJx+2pqWFaG6rEZL93Kj15kA9HZxeoNTnPtvC1r5sd wqjlGP9mINS9Vbkkjdcuxbw0ukFwxvcDbST021htN8g+5ejfZRZxSok4h7/FLqTPYKXp LbLA== X-Gm-Message-State: AOAM530nBn4rvpJmbEYl/oXC9KFT/hFCdnIQfhNUw6qBqD26DnzMZJLU mEvpHiIR4kYqWAPd9ZEHX7Vl54PvurBb5yjW X-Google-Smtp-Source: ABdhPJwtVgTxVYIu/baouc+NIJ/14yBQ7KCOJdvBJO2EF3YchbfIA+e7m5BvakIZvvVFeE718vvHvQ== X-Received: by 2002:a05:6512:3f8b:: with SMTP id x11mr1152464lfa.486.1634758054162; Wed, 20 Oct 2021 12:27:34 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id k19sm261385lfv.109.2021.10.20.12.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 12:27:33 -0700 (PDT) Date: Wed, 20 Oct 2021 19:27:32 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Small cleanup in Eval_Integer_Literal Message-ID: <20211020192732.GA3154105@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This removes an unreachable case in a nested predicate function as well as trims down a verbose condition. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.ads (Check_Non_Static_Context): Update documentation. * sem_eval.adb (In_Any_Integer_Context): Change parameter type, adjust accordingly and remove unreachable case. (Eval_Integer_Literal): Consider the node kind throughout and trim down verbose condition. diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -2845,7 +2845,7 @@ package body Sem_Eval is -- the expander that do not correspond to static expressions. procedure Eval_Integer_Literal (N : Node_Id) is - function In_Any_Integer_Context (Context : Node_Id) return Boolean; + function In_Any_Integer_Context (K : Node_Kind) return Boolean; -- If the literal is resolved with a specific type in a context where -- the expected type is Any_Integer, there are no range checks on the -- literal. By the time the literal is evaluated, it carries the type @@ -2856,23 +2856,21 @@ package body Sem_Eval is -- In_Any_Integer_Context -- ---------------------------- - function In_Any_Integer_Context (Context : Node_Id) return Boolean is + function In_Any_Integer_Context (K : Node_Kind) return Boolean is begin -- Any_Integer also appears in digits specifications for real types, -- but those have bounds smaller that those of any integer base type, -- so we can safely ignore these cases. - return - Nkind (Context) in N_Attribute_Definition_Clause - | N_Attribute_Reference - | N_Modular_Type_Definition - | N_Number_Declaration - | N_Signed_Integer_Type_Definition; + return K in N_Attribute_Definition_Clause + | N_Modular_Type_Definition + | N_Number_Declaration + | N_Signed_Integer_Type_Definition; end In_Any_Integer_Context; -- Local variables - Par : constant Node_Id := Parent (N); + PK : constant Node_Kind := Nkind (Parent (N)); Typ : constant Entity_Id := Etype (N); -- Start of processing for Eval_Integer_Literal @@ -2890,12 +2888,11 @@ package body Sem_Eval is -- Check_Non_Static_Context on an expanded literal may lead to spurious -- and misleading warnings. - if (Nkind (Par) in N_Case_Expression_Alternative | N_If_Expression - or else Nkind (Par) not in N_Subexpr) - and then (Nkind (Par) not in N_Case_Expression_Alternative - | N_If_Expression - or else Comes_From_Source (N)) - and then not In_Any_Integer_Context (Par) + if (PK not in N_Subexpr + or else (PK in N_Case_Expression_Alternative | N_If_Expression + and then + Comes_From_Source (N))) + and then not In_Any_Integer_Context (PK) then Check_Non_Static_Context (N); end if; diff --git a/gcc/ada/sem_eval.ads b/gcc/ada/sem_eval.ads --- a/gcc/ada/sem_eval.ads +++ b/gcc/ada/sem_eval.ads @@ -149,10 +149,9 @@ package Sem_Eval is -- -- Note: most cases of non-static context checks are handled within -- Sem_Eval itself, including all cases of expressions at the outer level - -- (i.e. those that are not a subexpression). Currently the only outside - -- customer for this procedure is Sem_Attr (because Eval_Attribute is - -- there). There is also one special case arising from ranges (see body of - -- Resolve_Range). + -- (i.e. those that are not a subexpression). The outside customers for + -- this procedure are Sem_Aggr, Sem_Attr (because Eval_Attribute is there) + -- and Sem_Res (for a special case arising from ranges, see Resolve_Range). -- -- Note: this procedure is also called by GNATprove on real literals -- that are not sub-expressions of static expressions, to convert them to