From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 83C7C385734D for ; Fri, 26 May 2023 07:36:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83C7C385734D 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-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f603ff9c02so2728625e9.2 for ; Fri, 26 May 2023 00:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1685086559; x=1687678559; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=F6Y7lIEQtMkIocFekrvgG/UfeVZUOyi18PL/nJJilvY=; b=COjgrTUuHugFpetuz83PnSFSCRWAIw96ob0LAGaEFXwvDG6l+87Kl+1SSuWpYlNzz8 p0Tqpe+TsO6/dDDv2LEpz/Zq08+ATaDl0Tcm3Sqn3fNhOFfGpNk2Phw/k41UUyE8Bm4W yVimL5qb0tJ7JtKC8wuY+NRsFZ6HcPZPjp6VXGZJr4f+MNkxDu9aBWwylo5E5ewW9Aas mkWax2fXGmxHRbnBoy9IWlsOiZkMRLgSq2j2yqDsEdB5SHzElYQD/rPZZEfH+2LAdCzg mx5iPHA3pPpGYwOA3uLnR0kajse+am8xaKucuuWx42OCILZvzdpjT+fmtdP7OOZY/gZz CpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086559; x=1687678559; 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=F6Y7lIEQtMkIocFekrvgG/UfeVZUOyi18PL/nJJilvY=; b=RkZCXB8C/sQ9poT01/UipTZcHrnLJc2+mJMTvi6ByLDHH8ny5kB6+AqZooSsstr3JL Cd9m2HOp3pigAyoEPxHFQB9aTGvT57u0FtYtbzX3+tuWxYo2Bwo/M2QcGPKfhFe8mG7V a9taH1BovYGgPK1sWxZNjJ5wLxwDJGd92zXJHInVRH4b6NW8izQxPlyut5zzj5XGDLU5 wmlaGfsmB9Lil6iP5vmNKjze5DxMfchI/YywqWV+zJHSsmfS90h9PZzXbMMT2DVSIxdY GKlr+Bf1vq6rg86fLkP7O/tHJdlnkUZA2aduA/227nqcmIzc686kmyzCImcowNVUNV8o xJWA== X-Gm-Message-State: AC+VfDw3sJN/bswPjo30NmdyKf5+RR1NbXYru9M77E6fO7KVaXbrVAkH GqEV06P9cKeDmI21LAEqggayf3FWstcnf0ZpO6nG4w== X-Google-Smtp-Source: ACHHUZ5oRdywz796qiX7mWq1qfBhoaHevLUkZ/RAqJXfqH7DS8knyoL0HZDuvRKYYBDUEq+beaavEw== X-Received: by 2002:a7b:cbc5:0:b0:3f6:2ce:caa8 with SMTP id n5-20020a7bcbc5000000b003f602cecaa8mr869787wmi.29.1685086559354; Fri, 26 May 2023 00:35:59 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id 20-20020a05600c22d400b003f180d5b145sm4301451wmg.40.2023.05.26.00.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:35:58 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Use context variables in expansion of aggregates Date: Fri, 26 May 2023 09:35:57 +0200 Message-Id: <20230526073557.2068222-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: Piotr Trojanek Code cleanup; semantics is unaffected. gcc/ada/ * exp_aggr.adb (Build_Constrained_Type): Remove local constants that were shadowing equivalent global constants; replace a wrapper that calls Make_Integer_Literal with a numeric literal; remove explicit Aliased_Present parameter which is equivalent to the default value. (Check_Bounds): Remove unused initial value. (Expand_Array_Aggregate): Use aggregate type from the context. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 60449fbeb2d..1dcbfade86c 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -5835,11 +5835,9 @@ package body Exp_Aggr is ---------------------------- procedure Build_Constrained_Type (Positional : Boolean) is - Loc : constant Source_Ptr := Sloc (N); - Agg_Type : constant Entity_Id := Make_Temporary (Loc, 'A'); + Agg_Type : constant Entity_Id := Make_Temporary (Loc, 'A'); Decl : Node_Id; - Typ : constant Entity_Id := Etype (N); - Indexes : constant List_Id := New_List; + Indexes : constant List_Id := New_List; Num : Nat; Sub_Agg : Node_Id; @@ -5851,12 +5849,12 @@ package body Exp_Aggr is if Positional then Sub_Agg := N; - for D in 1 .. Number_Dimensions (Typ) loop + for D in 1 .. Aggr_Dimension loop Num := List_Length (Expressions (Sub_Agg)); Append_To (Indexes, Make_Range (Loc, - Low_Bound => Make_Integer_Literal (Loc, 1), + Low_Bound => Make_Integer_Literal (Loc, Uint_1), High_Bound => Make_Integer_Literal (Loc, Num))); Sub_Agg := First (Expressions (Sub_Agg)); @@ -5867,7 +5865,7 @@ package body Exp_Aggr is -- is not processable by the back end, therefore not necessarily -- positional. Retrieve each dimension bounds (computed earlier). - for D in 1 .. Number_Dimensions (Typ) loop + for D in 1 .. Aggr_Dimension loop Append_To (Indexes, Make_Range (Loc, Low_Bound => Aggr_Low (D), @@ -5883,7 +5881,6 @@ package body Exp_Aggr is Discrete_Subtype_Definitions => Indexes, Component_Definition => Make_Component_Definition (Loc, - Aliased_Present => False, Subtype_Indication => New_Occurrence_Of (Component_Type (Typ), Loc)))); @@ -5904,7 +5901,7 @@ package body Exp_Aggr is Ind_Bounds : constant Range_Nodes := Get_Index_Bounds (Index_Bounds_Node); - Cond : Node_Id := Empty; + Cond : Node_Id; begin -- For a null array aggregate check that high bound (i.e., low @@ -6954,7 +6951,7 @@ package body Exp_Aggr is -- If this is an array of tasks, it will be expanded into build-in-place -- assignments. Build an activation chain for the tasks now. - if Has_Task (Etype (N)) then + if Has_Task (Typ) then Build_Activation_Chain_Entity (N); end if; -- 2.40.0