From patchwork Mon May 29 08:29:21 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: 100150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1363377vqr; Mon, 29 May 2023 01:37:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+Ti7PVLiw7e99Cesfj0VPWPjQe/QQRMV8z2Z+uKHWB71WwfiTG9zKlaUdPnbJTwpA1Duy X-Received: by 2002:a17:907:a0d:b0:973:70a8:483 with SMTP id bb13-20020a1709070a0d00b0097370a80483mr6454783ejc.24.1685349453803; Mon, 29 May 2023 01:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685349453; cv=none; d=google.com; s=arc-20160816; b=Unrqsxi/lIaSgmCtyPr/PvL2Y/KICR/YKjn/JyNnVcPxzOTdAVmDVXmQxrO5xL3KKo hEFPSAuT3UmSxp5eK/I8C2S61K+AKJVVFZSOcrAcLLDOP9MPIs5KlsZlvk6vzfoku9uI 6JZIYbodQq2st7QzbWzl99QMZXBbtVn+8aw1b7gVsBboMDL2tk3x2b/ESfdkeHw+hvnP 9QLoJyLPLY2e8oQmOFZwHfT4kzpz9t4sriFVd+MDXxiWok0HY5Oec9moOpT8FCQHxqMm yQq41P08RsViW7o7vQAnEedo2E4SlBWjpNvFUEA79AbBB056Gfge9lwVRdM1MJQjw5mZ qORQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=FMp7KAU3vkD4mQmreC7NFeAu9ckqMfh7PfTNzX5byew=; b=KlD8+RMRII6dLIo+JNlB1o+sOhPgfnDjbRFIl9KqP3FYb9b+BA376+Is0pnXYRi5Eo Ll3G+vWGkpITknQvEupe3m3XeSXi2sGkiK56VRzt3BR8odVvqxNR3dBj86/r322HlMKt X15hKSrqGNo7EL7OkXHOagwBpPctua1rQSRTdHbGuGjBGeCPALZvVISm0jOaNhH/VJy6 qgjjx0PK2ES3ONM/Eo5JdeCM7CbG6h0GpOLl7sMY3Hdetpt9LTI20pS8j4NifaQM94g5 RR2xgrSACBntM531v7+Uv8MVMwIAYVTms651REWty8vqvQhsYgnjwYCX8dyzkYm4LDbF Dvvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=n8m8fWqm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id vu9-20020a170907a64900b00965f6753b2csi767601ejc.352.2023.05.29.01.37.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=n8m8fWqm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9381B38323DE for ; Mon, 29 May 2023 08:33:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9381B38323DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349226; bh=FMp7KAU3vkD4mQmreC7NFeAu9ckqMfh7PfTNzX5byew=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=n8m8fWqmeS/3GxzAc2H2k4eHrt631XU4Cl5091r4x11ADaRAe0jGsrviY0bTRx7Bq dOk9/1kTzxnAPmizYK0cKTV8jBrC5SPLPE4c9o/TQ5ZKenWdke+6t7ZmnN1vbne6KN T2Q3ZcJ25UoSBQBBdPTcdIp8/8GpXrabd7vLa3fo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 40C96384DA5B for ; Mon, 29 May 2023 08:29:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40C96384DA5B Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-30ad458f085so1931508f8f.0 for ; Mon, 29 May 2023 01:29:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348963; x=1687940963; 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=FMp7KAU3vkD4mQmreC7NFeAu9ckqMfh7PfTNzX5byew=; b=QuonCWQcrLJsfeXbOPeYRzF66yQBsOV60aQ6dyqWk3DQyoufVCeIP77pI6tUkZTN+g 21L0FksjkoIEi4sQp1zcEUqN50QnrRHsRO1wVjNRyyAyCjSpI+vB95m/T64/cq1l8UYQ lQyC5cxeCXg6uNd6kWSUx5HVzwznDq46Cj3gT9zDcn1dtfaEq7e51Wkp+jWlSFv8mY44 zgvyNftoJvs/VL8vPwM5lNFsUfHLMjrj+qvl5Behd+TdBolyPtIngP9gvuqCPu7G7eKE PwNExbdaGxrw0w7gUSfBf0OCMZMQObGLB55vy7U3FAlYKx1q68CBNzQs5NX45INb9RLc 69jA== X-Gm-Message-State: AC+VfDxWj2WaCcg+BLYEWU1+QYVZ9dhL/n7SXcPH8ylZkBe8DM+Yk5bS zsnPJYob2K8TmgJj0ILfbjBZn9rZjpC7bnBafTX0Eg== X-Received: by 2002:a5d:63ce:0:b0:30a:8999:3b9 with SMTP id c14-20020a5d63ce000000b0030a899903b9mr6307306wrw.28.1685348963065; Mon, 29 May 2023 01:29:23 -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 f10-20020a7bc8ca000000b003f42ceb3bf4sm13320910wml.32.2023.05.29.01.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:22 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED] ada: Fix crash on vector initialization Date: Mon, 29 May 2023 10:29:21 +0200 Message-Id: <20230529082921.2410077-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767216988768787658?= X-GMAIL-MSGID: =?utf-8?q?1767216988768787658?= Initializing a vector using Vec : V.Vector := [Some_Type'(Some_Abstract_Type with F => 0)]; may crash the compiler. The expander marks the N_Extension_Aggregate for delayed expansion which never happens and incorrectly ends up in gigi. The delayed expansion is needed for nested aggregates, which the original code is testing for, but container aggregates are handled differently. Such assignments to container aggregates are later transformed into procedure calls to the procedures named in the Aggregate aspect definition, for which the delayed expansion is not required/expected. gcc/ada/ * exp_aggr.adb (Convert_To_Assignments): Do not mark node for delayed expansion if parent type has the Aggregate aspect. * sem_util.adb (Is_Container_Aggregate): Move... * sem_util.ads (Is_Container_Aggregate): ... here and make it public. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 7 +++++-- gcc/ada/sem_util.adb | 3 --- gcc/ada/sem_util.ads | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index a6a7d810185..75e5e1402df 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -5000,9 +5000,12 @@ package body Exp_Aggr is if -- Internal aggregate (transformed when expanding the parent) + -- excluding the Container aggregate as these are transformed to + -- procedure call later. - Parent_Kind in - N_Aggregate | N_Extension_Aggregate | N_Component_Association + (Parent_Kind in + N_Component_Association | N_Aggregate | N_Extension_Aggregate + and then not Is_Container_Aggregate (Parent_Node)) -- Allocator (see Convert_Aggr_In_Allocator) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 64abfb11ce5..a42b2dff60f 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -132,9 +132,6 @@ package body Sem_Util is -- Determine whether arbitrary entity Id denotes an atomic object as per -- RM C.6(7). - function Is_Container_Aggregate (Exp : Node_Id) return Boolean; - -- Is the given expression a container aggregate? - generic with function Is_Effectively_Volatile_Entity (Id : Entity_Id) return Boolean; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index b5bcd267e33..d1bbc6af0e8 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1475,6 +1475,9 @@ package Sem_Util is -- Return True if the loop has no side effect and can therefore be -- marked for removal. Return False if N is not a N_Loop_Statement. + function Is_Container_Aggregate (Exp : Node_Id) return Boolean; + -- Is the given expression a container aggregate? + function Is_Newly_Constructed (Exp : Node_Id; Context_Requires_NC : Boolean) return Boolean; -- Indicates whether a given expression is "newly constructed" (RM 4.4).