From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IFUlyrJWMTULeJRjl9oOcn+WJOcvxIsd5GlIwQOb/ml12BQ4g2Nm85EhYSRxpAy43fO50me/g== 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=20Poulhi=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 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: 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; -- 2.43.0