From patchwork Mon Jun 10 09:07:34 2024 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: 1945777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=LVYaNeHk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VyQz35rhcz20Tk for ; Mon, 10 Jun 2024 19:11:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D8CD385DDE1 for ; Mon, 10 Jun 2024 09:11:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 5C9CF3858288 for ; Mon, 10 Jun 2024 09:08:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9CF3858288 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C9CF3858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010499; cv=none; b=F3AnL1ZagMvv3SgsS09bLhBV2/VngySUCCs/gdegjuid0jI36YyD3+R5GySzSDOujmFFykhSeM4gGz1IXItm4dKXo/0ociKs/qEU0SN6oWxHVIENkc+UUyEOXaRNL+W2Z/fEz7WSphvgbPbGBR2DG593BW/HhwKBFqTPb7iN8r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010499; c=relaxed/simple; bh=X/0X+AZf5t37LtHy7JMtJQlWj20oGqeQ1ErK+DZhjrM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qmQFm6Z6Vkf4jnWEXsRNan+FSXeIfe9PA/PGKT/prKKJz1f+at3pvN68EPBT8tzz5RYfpN2cTIQkZm6ffABB++q/chc9fUFxIJ6SveKDDqcEWxYfs+PL7TIobzEvyqjiA8H/L0qO7fN+DmPLYRsxoSAj2LGwofjuqG6g71dt4n8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a6266ffdba8so319591966b.1 for ; Mon, 10 Jun 2024 02:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718010496; x=1718615296; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zMoLNwpXziCP4AOaUYuwgtHy5qLwjA6ZY7q1LTr5WGg=; b=LVYaNeHkIMm84WdehGA7u3H8ZX9Xn+dEOyisRpBpsOQ/sK6gxGdAd+6sYpENOS5I/H ZoI3HPWhRSBzoHD7BtHMkLscEPrX/UhxSO+x9bd872rZDk0jILpdUHUJOCDWpGgbVim1 F1OQq9d82GOttgY5Jt2CltYjHSikwy6/iFNiqW9W1neAnBzYS14HkgLX7yQYFK613Rz3 mwfBoUVY1GlceF4e189XKVhadJmMJM6VJww5tW89C/xS/BR33fv1b2cNONLLn/gg+8ku iOMcy8GAhPlYs7rvUi9CqkSInx6ZG0Hbv4zMR2c7iLTX74vyqOpsAzcV7kVPKyL1IT6W v6CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718010496; x=1718615296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zMoLNwpXziCP4AOaUYuwgtHy5qLwjA6ZY7q1LTr5WGg=; b=Pb5SRdKrDzJaCkkMX3L8fG6So0ggxvsJBTwGLYo0JpmzuluACmTX3YCV+NME5M8dbs 4P40Eaeo0dOJi33uNpGN6iUyfBrJcbHAHcinZGyBug9qgV+8w/x5hZRuEtV7EonRHZ7c MBdlVBUtfa7rXyoHVqBTiAibgUZ49uJfuWNbgY7ykntMvvrJpWh/dhTFxG3q4/9en188 Hrwk7Q2Z1lp48+wv00YggU0Luidpg5yPXNSzIjKJkRAaYDxuIxGXtQHJzfrKF/XSFs1D z9FPFMJ3dFEVdOkU+2IBvMCdUntGGayOHpYDHvzIl+cUCBFLMLKq3SHHqul32u3/AkIw aSQA== X-Gm-Message-State: AOJu0YwPeayx9P2zVIJvQK4gxPzLcB873+v0yXAW/nT8NAn3RoBhCOMs utLQ8obOTRlZcq8omGaK11u9zTpBtK/UH88dSiN+eNJj+RSqfUgSArpCRTGDBxLLNk/lpCtFRtE = X-Google-Smtp-Source: AGHT+IFxWUre/oAAaDgX2pu/BLpfgcqhLTpazx9qnEB/PH0DdZ4DSpU6qqjgcDmWL/fXxo1qd1qt4w== X-Received: by 2002:a17:907:9618:b0:a6f:270b:28fd with SMTP id a640c23a62f3a-a6f270b2d45mr75756766b.10.1718010495949; Mon, 10 Jun 2024 02:08:15 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0f551c20sm6454970f8f.69.2024.06.10.02.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:08:15 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 18/30] ada: Tune code related to potentially unevaluated expressions Date: Mon, 10 Jun 2024 11:07:34 +0200 Message-ID: <20240610090747.1557638-18-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240610090747.1557638-1-poulhies@adacore.com> References: <20240610090747.1557638-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (Immediate_Context_Implies_Is_Potentially_Unevaluated): Use collective subtypes in membership tests. (Is_Known_On_Entry): Require all alternatives in a case statement to return; this change could prevent a recently fixed glitch, where one of the alternatives relied on the return statement afterwards (also, the new code is shorter). * sem_util.ads (Is_Potentially_Unevaluated): Clarify that this routine applies to Ada 2012. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 8 +++----- gcc/ada/sem_util.ads | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 241be3d2957..5bea088c44e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -19485,10 +19485,10 @@ package body Sem_Util is elsif Nkind (Par) = N_Case_Expression then return Expr /= Expression (Par); - elsif Nkind (Par) in N_And_Then | N_Or_Else then + elsif Nkind (Par) in N_Short_Circuit then return Expr = Right_Opnd (Par); - elsif Nkind (Par) in N_In | N_Not_In then + elsif Nkind (Par) in N_Membership_Test then -- If the membership includes several alternatives, only the first -- is definitely evaluated. @@ -30880,10 +30880,8 @@ package body Sem_Util is return True; when others => - null; + return False; end case; - - return False; end Is_Known_On_Entry; end Conditional_Evaluation; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 4fef8966380..f282d1fad99 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -2219,7 +2219,7 @@ package Sem_Util is -- type be partially initialized. function Is_Potentially_Unevaluated (N : Node_Id) return Boolean; - -- Predicate to implement definition given in RM 6.1.1 (20/3) + -- Predicate to implement definition given in RM 2012 6.1.1 (20/3) function Is_Potentially_Persistent_Type (T : Entity_Id) return Boolean; -- Determines if type T is a potentially persistent type. A potentially