From patchwork Thu May 25 08:05:43 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: 98856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp199332vqr; Thu, 25 May 2023 01:18:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6FSQ/KzgtxhYVnxZ6zaLocAIQ6g6YXULN4Q2Grcaoc0b6Nap7PPmAQbWO37gq2UPVboEp6 X-Received: by 2002:a17:907:2d8b:b0:96f:8b64:c0 with SMTP id gt11-20020a1709072d8b00b0096f8b6400c0mr754218ejc.39.1685002686132; Thu, 25 May 2023 01:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685002686; cv=none; d=google.com; s=arc-20160816; b=JnoLjNUt2i+UdFRt5LDypN9tWob+KeDYF3rlvZKgFm+y+tdxU7oLRmUpmoqr+X6RN9 8z1cs4AntdVOqSWPEQySFKebqUqjQU6JlA8YUtg7hcHZahj5rHqvAtLlDbKB3hOnXvzf y8cSYTDLl6wD0AhZhyRgZP+Ifz8sM0dAnwK2W8HKWvd7tn6S6JvEK72chOekig+0x5Zx TIQMwem1MNGb+Sb5DVK4cEkEvu9kfH2+/boVlh9QGE2pGFXRRfr35dUZUIfXotbkeYST nW4pQqnGIK6R7MkjeqeypI5NBwW8n/d8dlS5Oj5aAdfy9Pc38tR+/+IN3CrIllzwUIUD l8tQ== 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=vbx08LEZjoUf9YxzF7IZFZwhosKJ0CnsaUQweV/xM+Y=; b=QxRRGD1ZlgpjRTh2awLX5vohnThoJwaeqfZEol/C11dKKc2lyq2JHbUvKuS2XRWD0M Y4w1XkIzDr50OL9tHg2763SJtkw+ockxAuyglXtZSq5NQFjNpVnpa+Elows2HLHyDAA4 J5cfPicjEesKiM6jk3pGs8uB1dIT5zrdEdKLIZRQtQf462NUE1ZOyOSkc70pbJ6r+0fq +iFLEkjokLIjZm0Oa8YY58zeBGqx0BuJhiN3tg9uJloH0kiUm77p96hPA5luEul3T87U 65pmZkdQV0dze9UoYcxmGEqap0no7VavoTzJZ0C6aImDRmCnwr1Oy2fk3MZuBAbM+uCu YEJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=U4CeaneI; 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 mf23-20020a170906cb9700b0096f8c9e7e1esi690070ejb.930.2023.05.25.01.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:18:06 -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=U4CeaneI; 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 5FDEA389838E for ; Thu, 25 May 2023 08:12:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FDEA389838E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002325; bh=vbx08LEZjoUf9YxzF7IZFZwhosKJ0CnsaUQweV/xM+Y=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=U4CeaneI9xS0aoIxme2vVA0m+aEZ4i974i1kX3g+6xxy64k5ecWeEo+0t6vRPDfEQ XTE4Oja8yrVMVXAM+N4MAOpOK0BaGsRew/2/i3Vem7vrWcozqiPan47IM3c4NrUeG0 17fLucuNus/9Y9kGhV5/NBcEE4/dbwbaBVsuOrI8= 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 6D0213857734 for ; Thu, 25 May 2023 08:05:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D0213857734 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3093eb8cd1fso1227503f8f.1 for ; Thu, 25 May 2023 01:05:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001945; x=1687593945; 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=vbx08LEZjoUf9YxzF7IZFZwhosKJ0CnsaUQweV/xM+Y=; b=XO8u3+Rh8NMQab6mVOt1Ub9pg5GCfPpiefwynd4Br975AIJ9R+1uNY181gy1i4xIjf HLs6DtWHr7cEjAJiF8VXHb0XQQgHDlgY64ibg1GfP/SwKivtuwjN+P/ZOnG7PaUiD8P0 r78C4DHbus63QIJdnefYVPdm0Rh2e0Gv6u0UTWXmmqgJ470vf39VEX4blhxHyVutdAw8 Z5j3yLRwSkHFeP7Yc/mTUi+rBNjJ4rgoGL1wdmlmLL2xgcrVrekSiY458Ch9qlO4Xzd3 doMQR7Nkht+1tMKBrxWZPh3uSgijhSyOoO8AIds2LjbMGspXNxBTFGcvhw0ALnWlwyZ3 xCpA== X-Gm-Message-State: AC+VfDyPUhtzpgFrZcQJoPSj45WZ1SwPzihXBagtecDstL2xySe0A06f 5N34DmM0CU0ilhq8LwE51gqlIuFF6ZmlhVIUpsYdEA== X-Received: by 2002:adf:f182:0:b0:306:2656:66d4 with SMTP id h2-20020adff182000000b00306265666d4mr1401982wro.58.1685001945334; Thu, 25 May 2023 01:05:45 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id z17-20020adfdf91000000b00304832cd960sm892024wrl.10.2023.05.25.01.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:05:44 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Small tweak to implementation of by-copy semantics for storage models Date: Thu, 25 May 2023 10:05:43 +0200 Message-Id: <20230525080543.1956286-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?1766853376702209427?= X-GMAIL-MSGID: =?utf-8?q?1766853376702209427?= From: Eric Botcazou Get_Actual_Subtype can be used to access the Actual_Designated_Subtype of explicit dereferences with a storage model. As a side effect, this also handles the case where the prefix of the dereference is a formal parameter. gcc/ada/ * exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Use Get_Actual_Subtype to retrieve the actual subtype for all actuals and do it in only one place for all unconstrained composite formal types. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index fce10d5e946..b2408140bef 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -1969,21 +1969,12 @@ package body Exp_Ch6 is F_Typ := Non_Limited_View (F_Typ); end if; - -- Use the actual designated subtype for a dereference, if any - - if Nkind (Actual) = N_Explicit_Dereference - and then Present (Actual_Designated_Subtype (Actual)) - then - Indic := - New_Occurrence_Of (Actual_Designated_Subtype (Actual), Loc); - -- Use formal type for temp, unless formal type is an unconstrained - -- array, in which case we don't have to worry about bounds checks, - -- and we use the actual type, since that has appropriate bounds. - - elsif Is_Array_Type (F_Typ) and then not Is_Constrained (F_Typ) then - Indic := New_Occurrence_Of (Etype (Actual), Loc); + -- composite, in which case we don't have to worry about checks and + -- we can use the actual type, since that has appropriate bounds. + if Is_Composite_Type (F_Typ) and then not Is_Constrained (F_Typ) then + Indic := New_Occurrence_Of (Get_Actual_Subtype (Actual), Loc); else Indic := New_Occurrence_Of (F_Typ, Loc); end if; @@ -1999,21 +1990,9 @@ package body Exp_Ch6 is -- with the input parameter unless we have an OUT formal or -- this is an initialization call. - -- If the formal is an out parameter with discriminants, the - -- discriminants must be captured even if the rest of the object - -- is in principle uninitialized, because the discriminants may - -- be read by the called subprogram. - if Ekind (Formal) = E_Out_Parameter then Incod := Empty; - if Has_Discriminants (F_Typ) - and then (Nkind (Actual) /= N_Explicit_Dereference - or else No (Actual_Designated_Subtype (Actual))) - then - Indic := New_Occurrence_Of (Etype (Actual), Loc); - end if; - elsif Inside_Init_Proc then -- Skip using the actual as the expression in Decl if we are in