From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 3B4A13858418 for ; Tue, 13 Jun 2023 07:38:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B4A13858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f8c65020dfso5537615e9.2 for ; Tue, 13 Jun 2023 00:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686641917; x=1689233917; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0Eyh6AdItNAaMpRquuNQnZa4QqWoZCO9kWbKheoq5vw=; b=bMSWRt3DZcsNJqsE4CFbnR668xwNj2Epb54izM3LrIgjw8KebRRUDU8eHX//QWCtgk VUAPNd8CwtEEmuXnTLAzqHb4nO/gCdgOTThQ85+/FAoO3f/Ug9DLyQQ5DPbUFo9HzavY fa/MfZIQErIVO+LqVTo+PrXcAuaIOtNV31Hg4/RQ4/zUnaO9zr34FgiopqEuQblKG0jf vAq5AVhtWoRvj9/WjxB9JcnVL1J5o2WQBQ4wun2UJGKzB36tPSdyWmp8LWAAbURljmb6 JvUp1FbbWgrz+waw/qUdgaudvjKNpE61INkosXoO+s89D4eODeBT+ft0cukkJIKniAJy 3h2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641917; x=1689233917; 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=0Eyh6AdItNAaMpRquuNQnZa4QqWoZCO9kWbKheoq5vw=; b=UBg/sbw5vu1nuJqV/BpriV3UJxe2Ii6taCeUVdB1ZC9v0j6S2EEuUxNB0rWOQntDkr AChm6u6i3VlcSN1lFfl5dlm/Gi3tobo3WGJdH0PbOCEQIpUxo4UFYxEcgQ6RyLQ1++6x 0RJIgdtwpC7ctwhjapYc4pBfvfKpRJk/mNMV3QTa55CnCCoPLcTyE4990itsPRlHUxpq ol45dKdbhMicaPBr+1m8ATciQ6zlaD+csDbAaSI01Q3zhTKYARYKMfpMA8RfaMSYSafm UJHijLLHCcADJfuqBOYG8BHrbdDLd5Xjm4vWNOEFnGEapb8RZxIn4WnFVC2Ld4XFS0u5 iQgA== X-Gm-Message-State: AC+VfDzeOVUGbju6I4a42DH2d0mx+yZnl2uIQ6dUMsSzGsG7kFT+VAJY c0h1EMYyCe5kyGu3oiCoPAJbe4+WtNj513hl8HDePw== X-Google-Smtp-Source: ACHHUZ6xXygROl2+0g8ry+/Ec9f36yvOqPrEjvo201KqCVhN8V70qhvyl4uclS77rH2wwmawUbg/Fg== X-Received: by 2002:a5d:4533:0:b0:30f:ce68:87ea with SMTP id j19-20020a5d4533000000b0030fce6887eamr612156wra.30.1686641917003; Tue, 13 Jun 2023 00:38:37 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:bfa8:5d29:40e5:cc66]) by smtp.gmail.com with ESMTPSA id q7-20020adff947000000b0030af72bca98sm14445215wrr.103.2023.06.13.00.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:38:36 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Disable inlining in potentially unevaluated contexts Date: Tue, 13 Jun 2023 09:38:35 +0200 Message-Id: <20230613073835.240455-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 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 List-Id: From: Piotr Trojanek Instead of explicitly disabling inlining in quantified expressions, (which happen to be only preanalysed) and then disabling inlining in potentially unevaluated contexts that are fully analysed (which happen to include quantified expressions), we now simply disable inlining in all potentially unevaluated contexts, regardless of the full analysis mode. This also disables inlining in iterated component associations, which can be both preanalysed or fully analysed depending on their expression, but nevertheless are potentially unevaluated. gcc/ada/ * sem_res.adb (Resolve_Call): Replace early call to In_Quantified_Expression with a call to Is_Potentially_Unevaluated that was only done when Full_Analysis is true. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index c2a4bcb58cd..41787f3d2bc 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7290,14 +7290,14 @@ package body Sem_Res is Cannot_Inline ("cannot inline & (in default expression)?", N, Nam_UA); - -- Calls cannot be inlined inside quantified expressions, which - -- are left in expression form for GNATprove. Since these - -- expressions are only preanalyzed, we need to detect the failure - -- to inline outside of the case for Full_Analysis below. + -- Calls cannot be inlined inside potentially unevaluated + -- expressions, as this would create complex actions inside + -- expressions, that are not handled by GNATprove. - elsif In_Quantified_Expression (N) then + elsif Is_Potentially_Unevaluated (N) then Cannot_Inline - ("cannot inline & (in quantified expression)?", N, Nam_UA); + ("cannot inline & (in potentially unevaluated context)?", + N, Nam_UA); -- Inlining should not be performed during preanalysis @@ -7365,15 +7365,6 @@ package body Sem_Res is elsif No (Body_To_Inline (Nam_Decl)) then null; - -- Calls cannot be inlined inside potentially unevaluated - -- expressions, as this would create complex actions inside - -- expressions, that are not handled by GNATprove. - - elsif Is_Potentially_Unevaluated (N) then - Cannot_Inline - ("cannot inline & (in potentially unevaluated context)?", - N, Nam_UA); - -- Calls cannot be inlined inside the conditions of while -- loops, as this would create complex actions inside -- the condition, that are not handled by GNATprove. -- 2.40.0