From patchwork Fri Jan 7 16:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 49703 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0DC253858C39 for ; Fri, 7 Jan 2022 16:36:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DC253858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641573385; bh=Yoack6iujWr/o2kaeXoFT8G9mOEaGlDJI/lkKBYFzbA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tKmj56pnrkye3Q0CT+AsHFl9PBk3iqoIx41NOD7YxN9q0nRjv+JjO6gkBVDT+gOlt BdI5ffQQDTPsQyIgw0wgDfr0kQYowrNa6mxuYxPIrN6JU0o9gRC+xe2zbFZcGVrSqe 0mtmv/NUfFeOlb4vGl7Rb1ZFx6P5w3KlC3rBSWGs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 6EC7E3857C70 for ; Fri, 7 Jan 2022 16:27:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6EC7E3857C70 Received: by mail-wm1-x331.google.com with SMTP id l4so4277780wmq.3 for ; Fri, 07 Jan 2022 08:27:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=Yoack6iujWr/o2kaeXoFT8G9mOEaGlDJI/lkKBYFzbA=; b=bI7L5y1T7uFsWQMOjDdS2TnQh78TagiSEilqqD6Xpshi/GTjC4xIFJ99f2dbxPkSzy okhWpfH81IOSEDoAQJrZMaRc7M34S8OfSBqsX3lRQKJh5TXKgElbqgL34OT3XsIe9egT +vMDVptCRfsJKle7VFhXs1y3DfAGGhG0RWMaWEcXjAFL0FRH5caetRofItA8eRpttrxe GWNZXAIiKfCRvNTA4J6irWmu/H+kaOJgv578UAGgZOxr4rMTResLKNcm4m2JyQapjsl8 0MhHevxteWzIrR2KDacDvZWU4I1iOvGE2ZRKkMNhWRiikxVLnkGQyPxBYcXFPn69L39s jdKg== X-Gm-Message-State: AOAM530xaTGA84t4E/LbgQvlDKlxzG35fp5OGyXiGOndyZDzD84hS+1m 4L7x3gTPQT6N0o3+EiFcbomDpLSStZhD4w== X-Google-Smtp-Source: ABdhPJwbhDHftMG4/OGZS94YYTxMktLj/NJmR7ghTvON7eoONEhHSzjjvqpCmttTmjWfSOrgiljiYA== X-Received: by 2002:a1c:1d17:: with SMTP id d23mr4981021wmd.46.1641572824519; Fri, 07 Jan 2022 08:27:04 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id l12sm9719129wmq.2.2022.01.07.08.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 08:27:03 -0800 (PST) Date: Fri, 7 Jan 2022 16:27:03 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Remove unnecessary guard for inserting non-empty list Message-ID: <20220107162703.GA948229@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Calls to Insert_List_After and Insert_List_Before applied to empty lists do nothing, so there is no need to explicitly guard against such calls. Code cleanup; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Remove unnecessary guards. * exp_ch4.adb (Expand_N_If_Expression): Likewise; clarify comment. * exp_ch5.adb (Expand_N_If_Statement, Expand_Iterator_Loop_Over_Container): Likewise. * exp_ch9.adb (Expand_N_Task_Type_Declaration): Remove redundant guard. * freeze.adb (Freeze_All_Ent): Reduce scope of a local variable. diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -6908,9 +6908,7 @@ package body Exp_Ch3 is New_Nodes := Make_DT (Base_Typ, N); end if; - if not Is_Empty_List (New_Nodes) then - Insert_List_Before (N, New_Nodes); - end if; + Insert_List_Before (N, New_Nodes); end; end if; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -6198,18 +6198,10 @@ package body Exp_Ch4 is Set_Sloc (Parent (N), Loc); end if; - -- Make sure Then_Actions and Else_Actions are appropriately moved - -- to the new if statement. + -- Move Then_Actions and Else_Actions, if any, to the new if statement - if Present (Then_Actions (N)) then - Insert_List_Before - (First (Then_Statements (New_If)), Then_Actions (N)); - end if; - - if Present (Else_Actions (N)) then - Insert_List_Before - (First (Else_Statements (New_If)), Else_Actions (N)); - end if; + Insert_List_Before (First (Then_Statements (New_If)), Then_Actions (N)); + Insert_List_Before (First (Else_Statements (New_If)), Else_Actions (N)); Insert_Action (N, Decl); Insert_Action (N, New_If); diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -4559,9 +4559,7 @@ package body Exp_Ch5 is Set_Else_Statements (N, New_List (New_If)); - if Present (Condition_Actions (E)) then - Insert_List_Before (New_If, Condition_Actions (E)); - end if; + Insert_List_Before (New_If, Condition_Actions (E)); Remove (E); @@ -5455,9 +5453,7 @@ package body Exp_Ch5 is -- Condition_Actions of the iterator. Insert them now at the head of -- the loop. - if Present (Condition_Actions (Isc)) then - Insert_List_Before (N, Condition_Actions (Isc)); - end if; + Insert_List_Before (N, Condition_Actions (Isc)); Rewrite (N, New_Loop); Analyze (N); diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -12516,13 +12516,7 @@ package body Exp_Ch9 is -- procedure for this corresponding record type and we won't get it -- in time if we don't freeze now. - declare - L : constant List_Id := Freeze_Entity (Rec_Ent, N); - begin - if Is_Non_Empty_List (L) then - Insert_List_After (Body_Decl, L); - end if; - end; + Insert_List_After (Body_Decl, List => Freeze_Entity (Rec_Ent, N)); end if; -- Complete the expansion of access types to the current task type, if diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2354,7 +2354,6 @@ package body Freeze is procedure Freeze_All_Ent (From : Entity_Id; After : in out Node_Id) is E : Entity_Id; Flist : List_Id; - Lastn : Node_Id; procedure Process_Flist; -- If freeze nodes are present, insert and analyze, and reset cursor @@ -2365,6 +2364,7 @@ package body Freeze is ------------------- procedure Process_Flist is + Lastn : Node_Id; begin if Is_Non_Empty_List (Flist) then Lastn := Next (After);