From patchwork Thu Sep 11 09:18:57 2025 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: 120053 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 6CA473858C30 for ; Thu, 11 Sep 2025 09:44:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CA473858C30 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WVG9vnm/ X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id D06373858421 for ; Thu, 11 Sep 2025 09:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D06373858421 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 D06373858421 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582377; cv=none; b=GZDpH0h8fvZ+NhwwBqn101Saq8K0P7pMnZXzoLrJR0AySIKifHF2J7TTUodh8Rm3uf7k6pdfUPq0rkNhqZgcqJH5qFjX5BqHsNun3orTwD3nf9dNdCkqPEqpCKdPT/FvYPLJUQ/nk83TQz+n/56FQ0fG0YB/dNIKMmuSFBcT1Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582377; c=relaxed/simple; bh=IpAxEjQuu2rXLLorP7DI0Psbk0B810ga47bb2LTfq1c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZZDGYR6JKIZpuqcvxxftdGExU0/SjMwM0cBzk08x6/4y8oUopA2ll+UCv+letl3p9TarziZIjYbDrG6IIUsBc0gxnJFKrt3lh4OStl7P/Jdn42adqtpkEcRSW10rMEPvEA3bfvktq+loDLnlpCnXVRASmnkvgn3cQ8MvtIBU/Ng= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D06373858421 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3e7428c4cbdso363374f8f.0 for ; Thu, 11 Sep 2025 02:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582375; x=1758187175; 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=60ZF9IO4VoV8Gj0aF71IcKsYPG71AtX6hsAy95QL4cc=; b=WVG9vnm/r+vL8cNddpUPtDIpvng7HuxRLEmuSQBfWNnbkfkFxuZ8FG+pfMDqwoz2GQ udHalkh7izGWVDWSznpZyuX7LJ28ZNkSEZRogmjMBTYZ39wHDE6uV4yOk2PSQuAf7daO KW5dhqU+KPGXUR93ZcyEuDzn+agEgp50xSHm9PvBdaM7abUVwlr2oRe1igLNhXInBWkH 7NT7iDOEAh2+ujpoOoF+d0lm4dE9pNDb6A79/SJv/O2Kix6IiJw15foj1JaJCozUuG1o mYlBroKO1/8iXTNMdlcGe5x2Um4ee5kTs2TtSWEUxzhdrMzI7exPplWZ7ZQbmjnd2Sj8 2YRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582375; x=1758187175; 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-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HT+IG+yguO1disAD/JQ0zlAyAj18riMp39UhXpIxpBSHKNWxq2FhtLY1c2LTuTdCBM1/cNGOr7sg== X-Received: by 2002:a5d:5d0e:0:b0:3cf:3f1:acd8 with SMTP id ffacd0b85a97d-3e75e10651amr3273815f8f.28.1757582375474; Thu, 11 Sep 2025 02:19:35 -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-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 25/31] ada: Perform predicate check before, not after, parameter copy back. Date: Thu, 11 Sep 2025 11:18:57 +0200 Message-ID: <20250911091904.1505690-25-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Steve Baird In the case of a call to a subprogram that has an out (or in-out) parameter that is passed by copy, the caller performs copy-back after the call returns. If the actual parameter is a view conversion to a subtype that has an enabled predicate, then the predicate check performed at that point should be performed before, not after, the operand of the view conversion is updated. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_Actuals): After building the tree for a predicate check, call Prepend_To instead of Append_To so that the check is performed before, instead of after, the corresponding parameter copy-back. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 18551d4899e3..1a9002ce3a8b 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2946,7 +2946,11 @@ package body Exp_Ch6 is and then Predicate_Tests_On_Arguments (Subp) then - Append_To (Post_Call, + -- If Actual is a view conversion to a by-copy subtype + -- that is subject to a predicate, then the predicate + -- check must precede copy-back. So Prepend. + + Prepend_To (Post_Call, Make_Predicate_Check (Atyp, Actual)); end if; end By_Ref_Predicate_Check;