From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id C491F38582AC for ; Tue, 13 Jun 2023 07:38:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C491F38582AC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4f61b45ee0dso6286986e87.0 for ; Tue, 13 Jun 2023 00:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686641891; x=1689233891; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tMpWcjIG81Ls0x+LhmoIA+dARKQidFXgvJfNL13eDd4=; b=YgyMgxppjhwtwJEPMJ0sP93qRQNofiRTdI9jhWehMQBERceNU9FUlC/xYl7x7nAWJW g+ixEHCHaj3AA+91nyC8xaPHgYkDLBJozYDhVx5KgvzUAYkD0lJtk8eFu+1cG/iqwssS ZFkF50I3KodV0K9J/eLyXT+WUmpiPLGxuMIjBlqe3U1Y27dVfKL6zy427mARUHQTnkVG KNVecOrHrzjY6WtYK2Q5iU6mR67431+MOSB64Colb/7/+/Bz2sjZcEKC0uACPKoJWbBm JcT9NtQo3IdZgZuXbNfQQKYEBGFg/OdiATxA9MFgji84M9f5xmP2/meDwGZlQ2bGyztx AJdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641891; x=1689233891; 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=tMpWcjIG81Ls0x+LhmoIA+dARKQidFXgvJfNL13eDd4=; b=NhitlQ/Y/wu72g84YURxcs9gnCesXtUivSRHSKxi9FjLbCNz/TM/iL+KVpTHWiTZYx RLcOkAv1FizTs18nFy6jTBzX9u+94d0Z9heVFeDnBX+b8A/5FyMcR7zIdjK81rYt//Oj HERmLDY7Kf41aoLExKG3lWGLXUeUu0R9ftXGnx6omtx8qIVeksVPUqY5QMeYtvjJ8YoZ YsxndD7nibR0gOeIYw3S2IfQeIrjNt/gH6Yro2DAYTkJR4buy9ATH3GNGX0E4651P8LP YTW215C6aU3hJkLN9s4jDrky3YnUYOzYcmbSzk2yQONqwB8aHzwQBOkQ/GkjmRjtFFJ/ j0Ng== X-Gm-Message-State: AC+VfDwptXOtnq5dQkSVB3DDBWUAj5clyG+cwWa8uc3f4o4jWDYOUoWD bXweFdq44l4X3p/zjzbLQVWWCL63v9nJEk6TgakUxw== X-Google-Smtp-Source: ACHHUZ5/lvxau+mOuvYlfSy7MMtIdQdFTO1jvCa9CDHkIOJCLK4VLEouTswydbId67oySBOehegKaw== X-Received: by 2002:a19:8c0f:0:b0:4f3:792c:289d with SMTP id o15-20020a198c0f000000b004f3792c289dmr6240218lfd.20.1686641891309; Tue, 13 Jun 2023 00:38:11 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:bfa8:5d29:40e5:cc66]) by smtp.gmail.com with ESMTPSA id u9-20020a5d4349000000b003079c402762sm14427076wrr.19.2023.06.13.00.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:38:10 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Small housekeeping work in expansion of extension aggregates Date: Tue, 13 Jun 2023 09:38:09 +0200 Message-Id: <20230613073809.239731-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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: Eric Botcazou This avoids repeatedly calling Unqualify on the same node, removes a dead call to Generate_Finalization_Actions, a redundant setting of Assignment_OK and reuses a local variable more consistently. No functional changes. gcc/ada/ * exp_aggr.adb (Build_Record_Aggr_Code): Add new variable Ancestor_Q to store the result of Unqualify on Ancestor. Remove the dead call to Generate_Finalization_Actions in the case of another aggregate as ancestor part. Remove the redundant setting of Assignment_OK. Use Init_Typ in lieu of Etype (Ancestor) more consistently. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 15230571123..dcbf2c4981d 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2907,12 +2907,14 @@ package body Exp_Aggr is if Nkind (N) = N_Extension_Aggregate then declare - Ancestor : constant Node_Id := Ancestor_Part (N); + Ancestor : constant Node_Id := Ancestor_Part (N); + Ancestor_Q : constant Node_Id := Unqualify (Ancestor); + Adj_Call : Node_Id; Assign : List_Id; begin - -- If the ancestor part is a subtype mark "T", we generate + -- If the ancestor part is a subtype mark T, we generate -- init-proc (T (tmp)); if T is constrained and -- init-proc (S (tmp)); where S applies an appropriate @@ -3036,28 +3038,22 @@ package body Exp_Aggr is -- qualified). elsif Is_Limited_Type (Etype (Ancestor)) - and then Nkind (Unqualify (Ancestor)) in - N_Aggregate | N_Extension_Aggregate + and then Nkind (Ancestor_Q) in N_Aggregate + | N_Extension_Aggregate then - -- Set up finalization data for enclosing record, because - -- controlled subcomponents of the ancestor part will be - -- attached to it. - - Generate_Finalization_Actions; - Append_List_To (L, Build_Record_Aggr_Code - (N => Unqualify (Ancestor), - Typ => Etype (Unqualify (Ancestor)), + (N => Ancestor_Q, + Typ => Etype (Ancestor_Q), Lhs => Target)); - -- If the ancestor part is an expression "E", we generate + -- If the ancestor part is an expression E of type T, we generate -- T (tmp) := E; -- In Ada 2005, this includes the case of a (possibly qualified) - -- limited function call. The assignment will turn into a - -- build-in-place function call (for further details, see + -- limited function call. The assignment will later be turned into + -- a build-in-place function call (for further details, see -- Make_Build_In_Place_Call_In_Assignment). else @@ -3067,15 +3063,13 @@ package body Exp_Aggr is -- If the ancestor part is an aggregate, force its full -- expansion, which was delayed. - if Nkind (Unqualify (Ancestor)) in - N_Aggregate | N_Extension_Aggregate + if Nkind (Ancestor_Q) in N_Aggregate | N_Extension_Aggregate then Set_Analyzed (Ancestor, False); Set_Analyzed (Expression (Ancestor), False); end if; Ref := Convert_To (Init_Typ, New_Copy_Tree (Target)); - Set_Assignment_OK (Ref); -- Make the assignment without usual controlled actions, since -- we only want to Adjust afterwards, but not to Finalize @@ -3112,14 +3106,14 @@ package body Exp_Aggr is -- Call Adjust manually - if Needs_Finalization (Etype (Ancestor)) - and then not Is_Limited_Type (Etype (Ancestor)) + if Needs_Finalization (Init_Typ) + and then not Is_Limited_Type (Init_Typ) and then not Is_Build_In_Place_Function_Call (Ancestor) then Adj_Call := Make_Adjust_Call (Obj_Ref => New_Copy_Tree (Ref), - Typ => Etype (Ancestor)); + Typ => Init_Typ); -- Guard against a missing [Deep_]Adjust when the ancestor -- type was not properly frozen. -- 2.40.0