From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 CD89E3858430 for ; Mon, 16 Jan 2023 14:49:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD89E3858430 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x435.google.com with SMTP id b5so6541680wrn.0 for ; Mon, 16 Jan 2023 06:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y16ydppFVSjJ+bFYM2i7uY6sTQy8JWdDJLwQiDdLcLs=; b=Fbqw4jYzD9f0d3dvZ3irJenFGxlbicBKeObm8EqhZF45RHH/qIQbyOQo/rQxYXVnpC FnO5CMbAmGzIHCZhf/SrH/FCh9HeH4Tbuf5gBjdd0g/yUT4rcHLEqVu4BJdGE3UpQZ/B cZV5iIuKRqQJDIN/BFm59pszJRzlgzak/DlPVJgcsPhuWV3OXuKsn48K2Ky/+8oQCQqK qnGNdq6KC3wZGXxmB1e/+RCxgzk1KaNuFt06PVTEhrY/mfObhJLmZfNl6iEfNsOEtYhx fkY4P0EcX17CTh5vgQqW+UosFhAhnjEJcqMF7+972Ehe1K+w4X3CUT9JwOzGzmeW2yZK dKuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=y16ydppFVSjJ+bFYM2i7uY6sTQy8JWdDJLwQiDdLcLs=; b=CFEGHuyD3dZWlMHisxYx2aWGQ78956Ce0AwFp8Q5SCNHv+CVGHlpgs83KASbS193yq pYGhJGCNmXifXOWGLowbO4BMsAe4rOe+g1yGGBtbemA749+jnKv+LrrFysO+CA1Zhkt7 bLCPpPMsEh4EJJVPX6y3CkLUTzCGd6CGRVitVvQPVQk9MTUuysqSRpKzySo4wBd6+6cM e/ByUD2Hh0N68TePnaVt9iz7YXfW/8q3aZwx1/KavsGVzNZUzvk9Od/nCysBUzsEJlDX cCdKHm5pzy8IolmC8BLH+0M73if5/KPO1zPQeP0nbzrw6KJVvzvCh9YnD/sik4QKa/ZE F1FA== X-Gm-Message-State: AFqh2kpml9NQEN7waUm/Ma9Vg1lNb/LB8mZ3GxFCkasmBjyiyMDfJmqj au0kH1ubUcW5FdbnqVJP0NqeFQ8aGWfnREMM X-Google-Smtp-Source: AMrXdXt+BFiSIDOO3XS5J5DRtna+xMTRyVJAUAraZ3+XoJ/gB3jun+A/gDVLkFwmr+agoYGJQNB4GA== X-Received: by 2002:adf:fb08:0:b0:29a:375d:4c41 with SMTP id c8-20020adffb08000000b0029a375d4c41mr34696269wrr.14.1673880565728; Mon, 16 Jan 2023 06:49:25 -0800 (PST) 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 g1-20020a5d46c1000000b00241cfe6e286sm26172248wrs.98.2023.01.16.06.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 06:49:25 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix latent bug exposed by recent work on extended return statements Date: Mon, 16 Jan 2023 15:49:23 +0100 Message-Id: <20230116144923.3171796-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Eric Botcazou When the type of the return object is a constrained array, there may be an implicit sliding that needs to be preserved during the expansion. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_Return): Convert the expression to the return object's type in the constrained array case as well. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch3.adb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 6886bde7bd1..daa96df4b32 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -7181,11 +7181,13 @@ package body Exp_Ch3 is Alloc_Expr := New_Copy_Tree (Expr); + -- In the constrained array case, deal with a potential sliding. -- In the interface case, put back a conversion that we may have - -- remove earlier in the processing. + -- removed earlier in the processing. - if Is_Interface (Typ) - and then Is_Class_Wide_Type (Etype (Alloc_Expr)) + if (Ekind (Typ) = E_Array_Subtype + or else (Is_Interface (Typ) + and then Is_Class_Wide_Type (Etype (Alloc_Expr)))) and then Typ /= Etype (Alloc_Expr) then Alloc_Expr := Convert_To (Typ, Alloc_Expr); -- 2.34.1