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: 171801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp281518vqy; Thu, 30 Nov 2023 02:19:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHF28j2Gm2FlLE7kE7DIJKblOeDxLhfUjoLlf+7AQwvE3VOkk7OS1MbF92/MwFs7Mj1nbKJ X-Received: by 2002:a05:622a:1148:b0:423:a675:b190 with SMTP id f8-20020a05622a114800b00423a675b190mr20991066qty.29.1701339586439; Thu, 30 Nov 2023 02:19:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701339586; cv=pass; d=google.com; s=arc-20160816; b=kLw1T0jc940zua6ssAJIOVj1BQWOTJuOj4EcYlQANDL8ezr5eSDgV9CoJrW6Ba6NSB 8SmoicPgyy7b4pbsjHIrAq19/rFPSZxaOce/AFt/7j9cwmT0GDeXKMpTBih09/VlbvUl 4YqjEyt9yDkVXbUIu5fM8qH/saF6+UBozcNa8anuUdc4okU1zh/x2AjKqZI3zqpJCEKH WCXnq2ybK9oXmwTVf0lK5y/XdeJkDDM2xEDZzujamRoBdloRSNBjdeOh5YsVWfX3YeCk iCuFBNwX0b2ZqdjMv+qAK8fWhKtcbeUDxK3oa/PF3ebmaoq2u+joIjBUzR3dLIr8PBOC q+Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=1V5u6OdNZUBvMxXCkigwa1cDVA2zklEYAk06BIQueQc=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=mULTLocjZ0u/JDm4jDZur6f6zDyPKy7XMOVCCR/yBopRyTBAYy3z+DNHM4vPsWaMNC gp5CA35+Mog7MkBzMhispvfDtda2u2EBeYiwj5FY+IGI00TqKc6A+m7DMCiceHBv3N69 fWYi0ArqTaf5rlvW1r2wObjSaxQcnf+O/hySUF4EbbFEcUQDXDsVWfwP0gSo1VI4j1iw BIX52PS2vnNixjCvdsx2LZxGHRYkUADUeGg283wc8rB5jwBY045UVWO6ar0ViqSRpV0P iyQ/ymLFn40PM1AtrTaYAjrlEIvpuBrAfXRiMCmzD3QwoolX072qJNtMtmuh1xZUDydA uKJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GGoNtRin; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fz7-20020a05622a5a8700b00417f4c0115asi779422qtb.509.2023.11.30.02.19.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:19:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GGoNtRin; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E80D7384F98A for ; Thu, 30 Nov 2023 10:19:38 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783983858127707019 X-GMAIL-MSGID: 1783983858127707019 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