From patchwork Tue Dec 19 14:30:43 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: 181004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1979940dyi; Tue, 19 Dec 2023 06:34:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjp6fj2QjW2Ug3/BuUafWkbkO4X2VT92zRkM3raRFeHIPUKFQ5omH7Kj0G5NfVkaAhOtnn X-Received: by 2002:a05:6870:4341:b0:203:de70:48e4 with SMTP id x1-20020a056870434100b00203de7048e4mr2558751oah.27.1702996479657; Tue, 19 Dec 2023 06:34:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702996479; cv=pass; d=google.com; s=arc-20160816; b=q+8K8LCCtdV9RJZ8x+Euh0D/3e7HFRWEXVix8fzQ/WMe0R9yPX3SsVjShVbbrruzVE pHL9ouYAN87/QbKT4LPO8YQf4va4J3rR2CAuws2OPrhH3/6J7UhYBJCZHw1iAv1YXfWG HIfXLzgqVPHiRXu0fezgq8Q8413fzgVG9LhDFzymoOm6Kwi2S0UjWzXVipdITcfCqpLC 7iYAI1W8OeJR2d6xEfedTjnTpCMgpr7gEkC3NlaSOVIH3E/AZ8nhj/lLI3trzglN4fkP hayuef1Cs+hx13yYp5+Pkh3E2ZYXIvZH/ebO1xL9cvF6rVPd+YKTK/9PahmnAn/Ne+Tx l/vw== 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=DUyJ5hHIDCdBYINFEOsF2AHX5P0g14ryD2Ca9eiM5oI=; fh=V2ESt2iOnc3j0XBl1MndBBqKzaDAGaCUOycRYtMlkRM=; b=zUHqZRiz5i/bHu2k6OY7KHgoDD/3BhyR08iaqmn81ppbW/NrcaVPNm3eMX1Jtpfr1+ DjuOHpMLQYeN+mw1eG7lfykITEkRfBcahN5mRqEcVV6mL2DtHrMMMm8lZclYbPSUgcHe 9GToR8EXynSyEBOMtcXmvpaTGiFuNxPpAdsbGojOs9UW4KJB37H5IO+CHzdicLP+waFP aUzhLM/dw2kUAI+fijO0UDR3gmS556y/I1rpfLLW8cte9Ys+5O3Keuq6SewwLsLOuHiz 7A60lNTTRXlW2emzFhwpSDXh2YQUfLX1yG9KM2QL9V8BOcv06EDKyG4g7WY2dyDZYZDY leZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=eH0sgrrp; 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 s25-20020a67e359000000b004668b91b789si853285vsm.797.2023.12.19.06.34.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:34:39 -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=eH0sgrrp; 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 CCA9C389247B for ; Tue, 19 Dec 2023 14:32:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 3BC1A3870C1C for ; Tue, 19 Dec 2023 14:30:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BC1A3870C1C 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 3BC1A3870C1C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996247; cv=none; b=iv9f1eGgM6UtmbsDWc39umDOf7awjDPjBE/F7JCbCukRa8u6cO8mI8ESoF1t8H8YRvySIlga7+6X47+THxUx6HaBVCj9TjZiUk3XXWWrPZpAMGSMBqCn2jUkhKBYRQkLYNo56H5Rs+eLRzfhl5DKneD9ppKx7FwZ7qNFBDwxkr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996247; c=relaxed/simple; bh=8dqfvVD50fk70aHzJahnLePLG0K9H3ljOBoxNrZD028=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TIwJe7XtYQxmxpYhqch5n+3j/aZr1k+18MFlSCKae50qpB/DCx8GxPHl21LtPbEirhINQwm07g2F1Lt/UHC6Q7+hcxoUnLpTLPaMOecxa6BKnzJVf7RUcVeFWETKJryb5i7bvCGcI84keQ2/p9FnJOrJll+xYjkWLhYuxa4zz5g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40c2308faedso55006035e9.1 for ; Tue, 19 Dec 2023 06:30:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702996245; x=1703601045; 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=DUyJ5hHIDCdBYINFEOsF2AHX5P0g14ryD2Ca9eiM5oI=; b=eH0sgrrpMrUlYRAoXqzZmG9dTGO0yq8lsCKQ+xzE1qB6ZAnfGE0ZlAtTOVqeQDDeMC 8ntnc8lal308/V9Ct1bCE4xADIsDthg7BBFJYn+iAs/RLETgFRtVXcRibZu2OPKL3OyF FXhXuvDf4mxbj7ATpNP3+Rv7eXT0HMQyvHldhsEDxWFiOoX/Mov0x2DyjWi7bwGCYdtw tJroMJ25sIlq5Pg36mfw/MhzF7AKwat4SRvs2gGOXk1FIkPshXgAq9YR0S699mtFjPMG 2yQVyd1kXzBdWN/G7rJ4sfIpU1SdIDgkvlknb6M88Qm68nsxZdGjc71svRbOKO+d8A1f eakw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702996245; x=1703601045; 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=DUyJ5hHIDCdBYINFEOsF2AHX5P0g14ryD2Ca9eiM5oI=; b=OzPPXgDqy5o27yKG/yoglUKT8G7gybEXzAEX6w9y5ZoXBQFnZ+vWATtYJf6w5gYh5e lQ0SBcJCRR9C3g/R7BPxXb4hIm6kVDREYzRguce9nX/Ap/C+3xIDO9hAXoZwpspFRfsf DKfrtjifVjcME0DfCgLI5sjiXb7Tnhe1Mm33natov59AUdF7P0vd+hH3Gr+ee6eEZnJr RDvF56W0t1MzfNTl7YpEQPsRe4dQhzJFBIEWNFmGZByUoGM2US2GrLfbJEohxre9B1XV OIF4Ekd9w+1JFs7Y2vOhYp1HHRlue51odkFrD09N+JjDoy5MI6+FS0JNNTwmcG6acE5Y K3GA== X-Gm-Message-State: AOJu0Yz/nIdl0aZ827wkeDljyTPji3dFYm1fSfje8Vv/FmVswBTIjn69 KGFtoC57VvNF51ulkLxZyIwJwnoXRX6K7YVT5Rk= X-Received: by 2002:a05:600c:54c7:b0:40c:3f11:e501 with SMTP id iw7-20020a05600c54c700b0040c3f11e501mr9498488wmb.126.1702996245156; Tue, 19 Dec 2023 06:30:45 -0800 (PST) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:fe1e:443:c34f:edaa]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b004094e565e71sm3139155wmg.23.2023.12.19.06.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:30:44 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques , Javier Miranda Subject: [COMMITTED] ada: Fix crash on concurrent type aggregate Date: Tue, 19 Dec 2023 15:30:43 +0100 Message-ID: <20231219143043.455234-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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 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: 1785721236792908450 X-GMAIL-MSGID: 1785721236792908450 From: Ronan Desplanques Before this patch, the compiler would fail to examine the corresponding record types of concurrent types when building aggregate components. This patch fixes this, and adds a precondition and additional documentation on the subprogram that triggered the crash, as it never makes sense to call it with a concurrent type. gcc/ada/ * exp_aggr.adb (Initialize_Component): Use corresponding record types of concurrent types. * exp_util.ads (Make_Tag_Assignment_From_Type): Add precondition and extend documentation. Co-authored-by: Javier Miranda Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 15 ++++++++++++--- gcc/ada/exp_util.ads | 8 ++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index d61fbbc8c73..50063ed819e 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -8509,9 +8509,18 @@ package body Exp_Aggr is Set_No_Ctrl_Actions (Init_Stmt); if Tagged_Type_Expansion and then Is_Tagged_Type (Comp_Typ) then - Append_To (Blk_Stmts, - Make_Tag_Assignment_From_Type - (Loc, New_Copy_Tree (Comp), Underlying_Type (Comp_Typ))); + declare + Typ : Entity_Id := Underlying_Type (Comp_Typ); + + begin + if Is_Concurrent_Type (Typ) then + Typ := Corresponding_Record_Type (Typ); + end if; + + Append_To (Blk_Stmts, + Make_Tag_Assignment_From_Type + (Loc, New_Copy_Tree (Comp), Typ)); + end; end if; end if; diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 267a127ec5e..d15e4f90865 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -941,9 +941,13 @@ package Exp_Util is function Make_Tag_Assignment_From_Type (Loc : Source_Ptr; Target : Node_Id; - Typ : Entity_Id) return Node_Id; + Typ : Entity_Id) return Node_Id + with + Pre => (not Is_Concurrent_Type (Typ)); -- Return an assignment of the tag of tagged type Typ to prefix Target, - -- which must be a record object of a descendant of Typ. + -- which must be a record object of a descendant of Typ. Typ cannot be a + -- concurrent type; for concurrent types, the corresponding record types + -- should be passed to this function instead. function Make_Variant_Comparison (Loc : Source_Ptr;