From patchwork Fri May 26 07:35:57 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: 99339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp291044vqr; Fri, 26 May 2023 00:42:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ760fsebE4jqMQOXIKKcnVyopzvAtiZB8sRSztm8GlbHWBdVEVFlAxCwzTXxJOOYm04n8rp X-Received: by 2002:a17:906:9753:b0:96a:ee54:9f19 with SMTP id o19-20020a170906975300b0096aee549f19mr1423435ejy.48.1685086929255; Fri, 26 May 2023 00:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685086929; cv=none; d=google.com; s=arc-20160816; b=a4TQizGA4TYRClE2KgO1HIRFqwKbvRPubTaMZW9B8cmBOBrC/VCQWlWNhC9yw4w7Ek cbr4dASrvBywgrycKX/GHGDaIjSvZCJWJo6KWuKU22v6IArJYssgVC1RDCxH1/1tAT7B dg3rYLjVmsOPhfC5AtvRD5UXhYgycQhfQvT67AGui8vhV1bSqKuOwt1juuHEYDySdkQG Y5Ew8ei628fVgEykP5TPomT7ut7YAD4+J1v99SScpDmp5KGHI6/tdpVEDIeJpSnOL1Cs jOLNzi5akP46wlpfoPvjkpGq2nyT6IAtc7vyG7UumgSbBeKOEjJjWQyPK2bBYb7fjzrA S05Q== 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=F6Y7lIEQtMkIocFekrvgG/UfeVZUOyi18PL/nJJilvY=; b=cS7w1YlkKPgB3O4LDrDQWUcfaMv0URka70xJw3A6mn71un6bpEDTo7P14xXNqW45Bo 63kPOVMSuktQqV4Xz2sBgODmLYbSDT3jjVsl9OIIRIPa1FbfmJeE6ta2ms0rdrqfrgtT vo2gA1nyI3wXapJyrzcg0j2hTzzfVhIbAM9fBI3p6MeWOiv8PfnGmAKGfg/8M5CydCSC RVGlES91FSMWLhJH8wU1EmfMRYvKX8we6EgN0ek4HgglFfzdOKYudaS/YGe0HOidE/3m N9Gf+8HlwJFWSBYCyDh1vFXN9D2sPdeAUG9lofH9eLscqjrZZb0P5LkZxoiZ9xgD8eqQ asnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MnfGCEuA; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id sh13-20020a1709076e8d00b0094f34d90a75si3304911ejc.437.2023.05.26.00.42.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:42:09 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=MnfGCEuA; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 58B99389942B for ; Fri, 26 May 2023 07:38:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58B99389942B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086725; bh=F6Y7lIEQtMkIocFekrvgG/UfeVZUOyi18PL/nJJilvY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MnfGCEuAvVI7bN3KFeoLnkCiv7qQfUJKq1kZ7jR8NwzU3QsSR4Ozu9xKwF3l4mBVn Mia7AL/4LDZ1e4WP4Ovoc6/NveRr76+SXln8rSWjhDbI2SfKo1ylQghm4rVEtOZ+mC yY8L9fjlSUKD8KE8laLX8txy+wD9J22GAn9iIcW4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f603ff9c02so2728625e9.2 for ; Fri, 26 May 2023 00:36:00 -0700 (PDT) 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-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) 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 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.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?1766941712028721823?= X-GMAIL-MSGID: =?utf-8?q?1766941712028721823?= 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;