From patchwork Wed Dec 1 10:25:17 2021 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: 48325 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 C8618385843F for ; Wed, 1 Dec 2021 10:26:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8618385843F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638354408; bh=z4FALnxuzYSqG932MFojunI3G/QSN5wOGHxCn+5ptYM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ytth7XFZEtJnBWeHuDa1mXqeGi5SKz3aV66Q3aZxLcJiP3tVZj4lbOQ6/sk1ll3g7 hFKOqiyDAv42ES4+6MEhnkL6ga5Uw15in38/1WSV7PcEeydzZ2n+9VNaV7JtJqmgBY 2yoXaetJ7vXrdChSmJ/L/lRCg0z7eFb7+5u795qY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 8F1973858002 for ; Wed, 1 Dec 2021 10:25:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F1973858002 Received: by mail-wr1-x429.google.com with SMTP id a18so51135613wrn.6 for ; Wed, 01 Dec 2021 02:25:20 -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=z4FALnxuzYSqG932MFojunI3G/QSN5wOGHxCn+5ptYM=; b=w4tBlKLJt0YHrZmrDLIT4EvpJw4oyjL7jeaGUqP0BmMQU9h/kQ2QIgcTs2anjUdv7g n9mns0sjisSieyFrdMB5GBPaIHsVfOFWyfsGTGVcbcpovY2+nzEQBzgx3uokosmW6kHF fBRWfEHxYJ2cxPxdpHhRwB6Quxqf8olZ0361NXn3a7ZBFbWYPIivYF7FD7isP+LUz1g0 SRw1gQAg2i8YiXMjxvKuIXffJeg6pGa/iV7ZwbomKqLsoql+w0CMO+eu/BZje1rJNxTJ FxT5KXvOEUUrFxt7689p05Uc6WErNyp9Fg3Xda3zC75C8Iy3gH+9xTCD4yTv3KntSWp8 joWw== X-Gm-Message-State: AOAM532v9DCPmJaj/IGLVjDEgsMmg0R9f2x3T2xjDqE1sakiT+6A9j6Y qGAS+MiB1hf5hpABmTsZOA4r4JN5fNO3uo/x X-Google-Smtp-Source: ABdhPJxYVgARzX31E/4HH5dJ/GAsmJvseRMIIK7yC3/AIAmPvtVBNlwyMGpIp7SKqMJ+RRmCNg9g1A== X-Received: by 2002:adf:ea90:: with SMTP id s16mr5578956wrm.288.1638354319687; Wed, 01 Dec 2021 02:25:19 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o4sm23179374wry.80.2021.12.01.02.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 02:25:18 -0800 (PST) Date: Wed, 1 Dec 2021 10:25:17 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Simplify building of inequality function body Message-ID: <20211201102517.GA1634987@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.3 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" Code cleanup related to expansion of equality for GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch3.adb (Make_Eq_Body): Refactor to avoid appending to an empty list; also, when exiting early we will not create any list; fix style in comment. 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 @@ -10138,7 +10138,6 @@ package body Exp_Ch3 is -- Local variables Loc : constant Source_Ptr := Sloc (Parent (Tag_Typ)); - Stmts : constant List_Id := New_List; Decl : Node_Id; Eq_Prim : Entity_Id; Left_Op : Entity_Id; @@ -10154,7 +10153,7 @@ package body Exp_Ch3 is -- the body executed is that of the overriding declaration, even if the -- overriding declaration is not visible at the place of the renaming; -- otherwise, the inherited or predefined subprogram is called, see - -- (RM 8.5.4(8)) + -- (RM 8.5.4(8)). -- Stage 1: Search for a renaming of the inequality primitive and also -- search for an overriding of the equality primitive located before the @@ -10264,18 +10263,18 @@ package body Exp_Ch3 is end; end if; - Append_To (Stmts, - Make_Simple_Return_Statement (Loc, - Expression => - Make_Op_Not (Loc, - Make_Function_Call (Loc, - Name => New_Occurrence_Of (Target, Loc), - Parameter_Associations => New_List ( - Make_Identifier (Loc, Chars (Left_Op)), - Make_Identifier (Loc, Chars (Right_Op))))))); - Set_Handled_Statement_Sequence - (Decl, Make_Handled_Sequence_Of_Statements (Loc, Stmts)); + (Decl, + Make_Handled_Sequence_Of_Statements (Loc, New_List ( + Make_Simple_Return_Statement (Loc, + Expression => + Make_Op_Not (Loc, + Make_Function_Call (Loc, + Name => New_Occurrence_Of (Target, Loc), + Parameter_Associations => New_List ( + Make_Identifier (Loc, Chars (Left_Op)), + Make_Identifier (Loc, Chars (Right_Op))))))))); + return Decl; end Make_Neq_Body;