From patchwork Mon May 15 09:41:45 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: 94017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6790238vqo; Mon, 15 May 2023 02:43:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LVByzgEP3XMBgVa9qYnhVJPzzxhNMfRAD419koz04TmIBtiuk5CyWJsneO4mBab30zTqB X-Received: by 2002:a17:907:74c:b0:965:6aff:4f02 with SMTP id xc12-20020a170907074c00b009656aff4f02mr28430871ejb.41.1684143800975; Mon, 15 May 2023 02:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684143800; cv=none; d=google.com; s=arc-20160816; b=YUZRi/4fjnps0swgl1FcAgaLev7iNwF9k/Vf42OKsoWSBfvsQRxoiZBwiVm4ndj73D 5axdcHx1FjpjBMpFj8++38rUslOYp/PVf7f088f1HTq8ixMq6zdGQfx+aNAnNhJ6PcU9 4BHgYxUrpkuu9r1aYm7KRz6im8vChPOGhUVS/tHEawy8D1KmewCP1zBR1hc09CrkcIEj vGkaWRK7AG5EWixpJXHoKJK9dSaIsgpOuxSpOthiwFtjOPv5iSvUtxMHGZQjhxbfR52+ Hifl5jXCdyCegjpCF+PwL2wfRFrNFJKukn4y5hX8BSL2PlukocJHsryuvT6dnepaINc0 sO1Q== 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=OezZMtE3tKhVhx/BxM5ecyU76XmpQm7UXxTofRkZq8A=; b=KHwcPjqJklToD5HdUnaq8XpM7PRScXlSdc3Y29cIzRi3ODE4z6t6khUM+9y7PJigUW RH8OPXjZchz2VtNYcqZBsf6TB6z0s1hhaDN7zwHhxlmuDjbGwleAl4KHc6I+qrMPuB0T PNtXUzkG98bABz4OhhG2n1r4mnCVENV6wecMIn4JeiFAVYlfydBEd4v/M15SULcr1op2 i6KYXbSaqDNOWmRsaS7L58zD6hs42+xOnh1CoGO/VAH5OXeO0jGYHLN+fPnTdYu7+C00 XmlKM7794jimgcgTfW8hWPitoEliuy9lAo1gxPGhTPefstufnKnZwgVnHUCt1wGO4WOK wnbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VytkzWCv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xo21-20020a170907bb9500b0095725e2907dsi12463921ejc.276.2023.05.15.02.43.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:43:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VytkzWCv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 249003854169 for ; Mon, 15 May 2023 09:42:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 249003854169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684143766; bh=OezZMtE3tKhVhx/BxM5ecyU76XmpQm7UXxTofRkZq8A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=VytkzWCv810qMWBK51uXuRCsmA+4pHqUBX/fuTxolGmD1ztlFKjLbdPIs3uStBqTm 94bH3Bbwilunsma0rkSUazgqqLpCZuLLb+ER5PtswZzIoZc481esOcLQzm9KuGVSQJ L2tBu05yYGCWIK/2nfua1hyi6GiTL0zo3Z9GIAwM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id D266A38555A8 for ; Mon, 15 May 2023 09:41:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D266A38555A8 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-30626f4d74aso8101604f8f.0 for ; Mon, 15 May 2023 02:41:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143710; x=1686735710; 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=OezZMtE3tKhVhx/BxM5ecyU76XmpQm7UXxTofRkZq8A=; b=achpTlsAiuo6EPnGu22WZIf/Py7sGLd0QehdX7iNAN+531H30O6QWYBJW9qsyvBxLG nwiEy6D07n5Pvhj7GFA6ZCvBIfmL5DbsS19imq+xd7ZniTDR211OBF1EAqFWDwSPjbqo bHcRJvHXSAJc1JkTJPt7/zbUGnBkUAiiNsrF7We6zqDFgIxuoNJzGNPhhdQaDGRgvZ28 dmrtdMX14v/wBjXsk43Y88WfP8gX1imFIGLnUIbFjOemfh3E/leB8E3/Vcv3XE+ns4j5 QrvFdLxTKkqfstJuAzNNHJzwlQCNhWn8k36kldKbVGEe1qocxI6pHSlS8ycunnJK4dLm 7z9Q== X-Gm-Message-State: AC+VfDxD3trnTVu02xik6VTqZShhOQR5dExXLJjUXBvJ2ekFzQwZpRiR dFeAY3WlJhnkoXiIRPJcWttn//3CMQQoyM7bX6fwRQ== X-Received: by 2002:a5d:4cc6:0:b0:306:37a5:447a with SMTP id c6-20020a5d4cc6000000b0030637a5447amr22083968wrt.60.1684143710553; Mon, 15 May 2023 02:41:50 -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 k4-20020a5d5184000000b0030903371ef9sm9281476wrv.22.2023.05.15.02.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:41:49 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED] ada: Fix Unchecked_Conversion in edge case Date: Mon, 15 May 2023 11:41:45 +0200 Message-Id: <20230515094145.1407307-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 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, 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?1765952770539154605?= X-GMAIL-MSGID: =?utf-8?q?1765952770539154605?= From: Ronan Desplanques Before this patch, Set_Can_Use_Internal_Rep was called on access to subprogram subtypes when instantiating Unchecked_Conversion from System.Address to an access to subprogram subtype (or the reverse). This was incorrect and caused an assertion failure. This patch fixes that by modifying the Can_Use_Internal_Rep attribute of the base type of the subtype instead. gcc/ada/ * sem_ch13.adb (Validate_Unchecked_Conversion): Fix behavior on System.Address to access to subprogram subtype conversion. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 0d311ca80b4..82345eca09e 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -17742,12 +17742,12 @@ package body Sem_Ch13 is and then Is_Descendant_Of_Address (Source) and then In_Same_Source_Unit (Target, N) then - Set_Can_Use_Internal_Rep (Target, False); + Set_Can_Use_Internal_Rep (Base_Type (Target), False); elsif Is_Access_Subprogram_Type (Source) and then Is_Descendant_Of_Address (Target) and then In_Same_Source_Unit (Source, N) then - Set_Can_Use_Internal_Rep (Source, False); + Set_Can_Use_Internal_Rep (Base_Type (Source), False); end if; -- Generate N_Validate_Unchecked_Conversion node for back end in case