From patchwork Thu Nov 30 10:19:02 2023 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: 81009 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 9AE3638618FD for ; Thu, 30 Nov 2023 10:19:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id C04ED3858298 for ; Thu, 30 Nov 2023 10:19:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C04ED3858298 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 C04ED3858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339546; cv=none; b=GyvVxhMPI3J5SltUUn7SqFKHWMbjm+1gBPeTGiexlZCuHIuFg2/Y7wUyMNWUQGFo+q7KgmyFgKCxP8s4f3fbVkJQ7lSsU9VaOTt+VTt2Hiu2vERFJ60rG9LPTYCkhPFFOrzSBfLCfN/EL0dlf+SZv+9VEA+pAQnL8Gc4836mK3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701339546; c=relaxed/simple; bh=wDZMGfwZS4YFq8GPYWuGVf8M2EmHhut/ODVpvQdUGEo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wpAbig1Tmksd+2MNZ+7J4VaLAEBnpDXomVAUXseAgd7tEuoZC5s5uwlQnwkMn0n72tJSODrD5SpXXOiaZ30oTPCzD15XsQMVlAFujQsNP7/cbA73X4kdsScjDyMrQNkOqaC3U4ayouGX+0KN7+QXeRyHCZTBB5f7YUBx78vIX0U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40b4c2ef5cdso5639715e9.2 for ; Thu, 30 Nov 2023 02:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701339543; x=1701944343; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1V5u6OdNZUBvMxXCkigwa1cDVA2zklEYAk06BIQueQc=; b=GGoNtRin1pMvkPyS8UIvRbcxEKwh3+aVRMq4nqI0/NlpwYvZ5lf07EvNeGbWDUuPOO 7GwMTF14MFOMOwEXqTmOdEZjfhtX/moRcXanbi5oIccrukfPJix3VPwlNxKM87iLyrdW aYEuhk8UazCONSqdapOZ1eSoi6+5TAJVEoUj+tSa551x8/zvh2KSxyuij5j60BxzF1fM rM5O82LBr6zkLZsrOzpBau2xjB/BbYXHVHa/EBqAXC5VsItIEeiwWCfJvNvLuH9GcQKE iVvht3iA+0WeRLsITRbmZgBEsq4fn8isGcEecHSTw28AakLpA79L9nF9hyeFnMl0sAN9 y4iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339543; x=1701944343; 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=1V5u6OdNZUBvMxXCkigwa1cDVA2zklEYAk06BIQueQc=; b=hR65jHioUORLWyq56l/601FU5reTbOa780J3a2w8FO0zs/92jbu0DIYhb+gZIVjdKw wtmsnyvtlM1VIs0yiBBMCZRNpswoYaORggEH4WFVIfTjk0wOPTMPGUqdLxIOSh8nlvsX LhC/UI0XIGP9NgjpmNjfrVWNh/ERcBwEsLZS1RvvdZdMZqcj9dZJAccmKVQImSF+AX3E R0weC8MflYXQp84ay74Xr5mfeh+EJdOzQYZplejXFarKrWQTBGs+hpy6C+mVLMARSS/b rA70DNuv1lpRp3+X3N31HL4/ksMxj6ieAK6z/OyqQnKimyIrhIwS/MUQk04p3w2L+dZo s2TQ== X-Gm-Message-State: AOJu0Yz+iGoQtJsLGuVK2Nml9Ti+QzIYUKN8mNrHv2azVA/yTIrKgykV Hof05hgfJQzRO/KqL84bH6dBCA+o98SjmYsD6350pA== X-Google-Smtp-Source: AGHT+IEFT2BjZNMHSQqkTmz5CR/UPHM3U6KHE0KrWPhesmJtaaitOo9am5a8keIqodgO+qLPfv2QOA== X-Received: by 2002:a05:600c:468a:b0:40b:56f7:b359 with SMTP id p10-20020a05600c468a00b0040b56f7b359mr1459657wmo.22.1701339543512; Thu, 30 Nov 2023 02:19:03 -0800 (PST) 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 v21-20020a05600c471500b0040836519dd9sm1466275wmo.25.2023.11.30.02.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:19:03 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix predicate check failure in Expand_Allocator_Expression Date: Thu, 30 Nov 2023 11:19:02 +0100 Message-ID: <20231130101902.3093945-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 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+patchwork=sourceware.org@gcc.gnu.org From: Eric Botcazou The For_Special_Return_Object flag needs to be accessed on entry of the procedure in case the allocator is rewritten during the processing. gcc/ada/ * exp_ch4.adb (Expand_Allocator_Expression): Add Special_Return boolean constant to hold the value of For_Special_Return_Object for the allocator and use it throughout the procedure. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index f04ac615be9..e708ed350d1 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -555,15 +555,16 @@ package body Exp_Ch4 is --------------------------------- procedure Expand_Allocator_Expression (N : Node_Id) is - Loc : constant Source_Ptr := Sloc (N); - Exp : constant Node_Id := Expression (Expression (N)); - PtrT : constant Entity_Id := Etype (N); - DesigT : constant Entity_Id := Designated_Type (PtrT); + Loc : constant Source_Ptr := Sloc (N); + Exp : constant Node_Id := Expression (Expression (N)); + Indic : constant Node_Id := Subtype_Mark (Expression (N)); + T : constant Entity_Id := Entity (Indic); + PtrT : constant Entity_Id := Etype (N); + DesigT : constant Entity_Id := Designated_Type (PtrT); + Special_Return : constant Boolean := For_Special_Return_Object (N); -- Local variables - Indic : constant Node_Id := Subtype_Mark (Expression (N)); - T : constant Entity_Id := Entity (Indic); Adj_Call : Node_Id; Aggr_In_Place : Boolean; Node : Node_Id; @@ -902,7 +903,7 @@ package body Exp_Ch4 is -- Likewise if the allocator is made for a special return object - elsif For_Special_Return_Object (N) then + elsif Special_Return then null; elsif Is_Tagged_Type (T) and then not Is_Class_Wide_Type (T) then @@ -944,7 +945,7 @@ package body Exp_Ch4 is and then not Is_Inherently_Limited_Type (T) and then not Aggr_In_Place and then Nkind (Exp) /= N_Function_Call - and then not For_Special_Return_Object (N) + and then not Special_Return then -- An unchecked conversion is needed in the classwide case because -- the designated type can be an ancestor of the subtype mark of