From patchwork Wed Jan 5 11:33:57 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: 1575622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=m4dW6wBo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JTSn30ML7z9sPC for ; Wed, 5 Jan 2022 23:03:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1F9F385843D for ; Wed, 5 Jan 2022 12:03:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1F9F385843D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641384210; bh=5aPLUUDEjgQiLAFvdWe8aFysuwhtdtxuLARt6aKPX0w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=m4dW6wBoQ0YgHsnLlv6qYTfW6MfL6uoYdYrebVGmp1dKLi+BT9v2JKUsJESE87sw4 VNNOfHpzQSHTVyyZlgPp75TzycxH7Q3nVOIwyRDxRvckH91lnCu33EBRtbRINoVqFG iy05qCCAi1XEbGvxuTFD/ZxYrXejcah2UphanEf4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 5F66B3858438 for ; Wed, 5 Jan 2022 11:33:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F66B3858438 Received: by mail-wr1-x435.google.com with SMTP id q8so1749408wra.12 for ; Wed, 05 Jan 2022 03:33:59 -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=5aPLUUDEjgQiLAFvdWe8aFysuwhtdtxuLARt6aKPX0w=; b=dtfDbyKhfH840e1d6XYYUq/897ontitv8GGEWwPubGhmNhELqNIB3/IybPXMyWC1Wt i02hSWrQlAfMIR2/Ilrf6suYRiP4xvbUm74E9VDku/CoZDsCRE2faGiihIVm+9Da04MS oetiadxUfEw4ujhfenzPOvss6vC5xBlhhpuuyYm3sRqkpcftq/E94NLDg3THU8hv3ZMp CgG6GT5SSRsVB//L449fBqYm7gbND2v3fH8aqahoDAEa5on+YTy1F8wD9RGnFwx9N0R8 OIEzP9hJHmJ37mA5MMgEQ5YQLVEb8usneIn6rRL5nt5DjBYfVg0z9Vj+P+cPik8aAijx n2bQ== X-Gm-Message-State: AOAM533ebUjl6QNZNAqsZjVyFd0wJyE3Cm5LK25xhBrM6fOhQu6UOTS7 xv765V7utHw5To/o4HBnvFb0Y1LQyRL09w== X-Google-Smtp-Source: ABdhPJzLQlbh+6FDYIhy1c8lhIBZkWOxH3hbj/V8KjEp0md4YfdWxLdWqc7GtWXdIBpIIHQfjrB/MQ== X-Received: by 2002:adf:efd0:: with SMTP id i16mr46751048wrp.86.1641382438467; Wed, 05 Jan 2022 03:33:58 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id l13sm45639922wrs.73.2022.01.05.03.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 03:33:57 -0800 (PST) Date: Wed, 5 Jan 2022 11:33:57 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Improve support for casing on types with controlled parts Message-ID: <20220105113357.GA2716373@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: Steve Baird Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" INOX allows casing on composite values. In some cases of bindings for subcomponents, the compiler introduced copying which led to compiler failures associated with finalizing those copies. In such cases a bound object now provides a constant view of the appropriate subcomponent of the selector object, not a copy thereof. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch5.adb (Finish_Binding_Object_Declaration): Fix a bug that was introduced in the previous commit. The previous version initialized a Boolean constant Declare_Copy before the variable Decl had been initialized properly. 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 @@ -3392,12 +3392,12 @@ package body Exp_Ch5 is Decl : Node_Id := First (Declarations (Block_Stmt)); Def_Id : Node_Id := Empty; + function Declare_Copy (Decl : Node_Id) return Boolean is + (Nkind (Decl) = N_Object_Declaration); -- Declare_Copy indicates which of the two approaches -- was chosen during analysis: declare (and initialize) -- a new variable, or use access values to declare a renaming -- of the appropriate subcomponent of the selector value. - Declare_Copy : constant Boolean := - Nkind (Decl) = N_Object_Declaration; function Make_Conditional (Stmt : Node_Id) return Node_Id; -- If there is only one choice for this alternative, then @@ -3443,7 +3443,7 @@ package body Exp_Ch5 is end loop; -- For a binding object, we sometimes make a copy and - -- sometimes introduce a renaming. That decision is made + -- sometimes introduce a renaming. That decision is made -- elsewhere. The renaming case involves dereferencing an -- access value because of the possibility of multiple -- choices (with multiple binding definitions) for a single @@ -3452,7 +3452,7 @@ package body Exp_Ch5 is -- renaming case, we initialize (again, maybe conditionally) -- the access value. - if Declare_Copy then + if Declare_Copy (Decl) then declare Assign_Value : constant Node_Id := Make_Assignment_Statement (Loc,