From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id C3A6A3858288; Mon, 16 Jan 2023 14:48:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3A6A3858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673880527; bh=hLhJHNuGXcNk8Y+/TQU84zLjAu0eiQQ2uiKL6xH3QlE=; h=From:To:Subject:Date:From; b=Jy1mb2aIKk904mLSmKBybX8YNDAjyrjH0xgx96/v7QrOJvppnBZe6LG9yngctW+yG NZ5oMHbSk2zrJs7zAv148yhDzIwe7oinBWGSyFnLGd7sxgLXmLfkEpjBndckaM4Bld UpHbJHVis5z6IC8cqDI8QaiMN7DU7T9ilhpU4OFM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5211] ada: Fix latent bug exposed by recent work on extended return statements X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 3b4c6e67710b09beccb7d0acf7f7257564d8a6f5 X-Git-Newrev: 9cfa7d7e3c3d7144a7b6079e7dc65a38a5327e70 Message-Id: <20230116144847.C3A6A3858288@sourceware.org> Date: Mon, 16 Jan 2023 14:48:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9cfa7d7e3c3d7144a7b6079e7dc65a38a5327e70 commit r13-5211-g9cfa7d7e3c3d7144a7b6079e7dc65a38a5327e70 Author: Eric Botcazou Date: Fri Jan 13 00:55:51 2023 +0100 ada: Fix latent bug exposed by recent work on extended return statements 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. Diff: --- 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);