From patchwork Mon May 22 08:49:53 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: 97189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1302358vqo; Mon, 22 May 2023 01:58:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M025bsC3XDj9ooDtXDMgzZ0YC0XiOXJFIZPdgL/iXWRN2spkaP5VeBTt40fABvjYY3SbX X-Received: by 2002:a17:906:6a28:b0:966:2aab:ae51 with SMTP id qw40-20020a1709066a2800b009662aabae51mr8723108ejc.11.1684745938190; Mon, 22 May 2023 01:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684745938; cv=none; d=google.com; s=arc-20160816; b=VBWsPx4MROJ52z8JfneSqgj4jHkuNr4LeCSUUPz+StU9dJp7JSCuugl83GloSjTrZd wKaQry4onr5ssZUbm5sae4vMQVcFmpMl2sWlTtoNIJsH69eR0mqrIVbsdAV961825syi pSmF07sEVuMHttpnNAhpFefnnMB5UCvLhqEtSaZyz8+GO3jvB0OQzuC+vN2P3cQeXjF4 M5S8yZYdWclTXYZjnwCAGHAYo8jjbm9ht9D8oGFA4L/0BEf7hbLuRI8bbAaZDotUQnX7 2p9NzsG5dNdoGAyABBHHmKRrV+9Y3BMtskT2SPY43BqRx7L5uLDmzan+D+v4g7Zsi0Nr 6i7Q== 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=n3rrxzwW4sE3ejzIdU89T7MsjcZMi7Ci8DfZ6uDxYYs=; b=byYPnY5VkNU4ir9LxyMzMsT+NwLUTAs2b2kAANH17ClGRgOkx0gARLmDSNoB5i9Wll KeoO7M8VLCwI+j/JEsKjdhLFWR0dMpBaW95vn+nOjhSwGKTRzsHLnscmIJhaBYTCLx7+ 0A7o+/d8XjwNwPRzsVOZ3ZCQktCsAyXO9jgwHJIdI2NS3+dTyqVDreMUAb5Y7dqqYFkG OKs4iH4uYK5Id2ebx3oJw42uZlXLIqpj1Dzn3juVTzRe6fIsba4f59w5cuUxP0B1vAhd ba4E0zsWpTm7wiXBd+vLLDj8UGu4Tv4fg/CxrVvMCO7J8pTnBcBTmpU8grBXAGTGzPYj rp4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=u8pEcIld; 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 if20-20020a170906df5400b0096f803afe77si2803508ejc.95.2023.05.22.01.58.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 01:58:58 -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=u8pEcIld; 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 EA80E3882118 for ; Mon, 22 May 2023 08:53:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA80E3882118 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684745634; bh=n3rrxzwW4sE3ejzIdU89T7MsjcZMi7Ci8DfZ6uDxYYs=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=u8pEcIldDF2R2wQwXc3mnOH+3yWh551OoeTXgk6p7Tw+Nu136cA/nw1aq+aLXbHzd MKRk1rc48n4megQte8UOwp7jTyE4BKVJAlyHy/ftJ9hQW7VjzhxDjCKGbkhnqL05vZ gHX9YbwzoCYcNhfrIYbiypCO0zelqwN/gRF9BZYc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 9D0A0384B81B for ; Mon, 22 May 2023 08:49:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D0A0384B81B Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-309d3e8777cso1349570f8f.0 for ; Mon, 22 May 2023 01:49:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684745395; x=1687337395; 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=n3rrxzwW4sE3ejzIdU89T7MsjcZMi7Ci8DfZ6uDxYYs=; b=PQ9FB4yOA+qO5LO6XzIuPhK8SgiqyWVoT7RmG1fKi4Lkaofz8vy4tNSJPXZE9UvtWT zBUAungCbC/JVpCAyxlZlyCJQ4+w1cxJ97wRugSmdicMZQ/0l4iZ/srStXB2IR74LOZj 5su30UeaZ0vjmCJEhOaWQ+4NJtffsBXrvzZ8GdJdi75mEkzWvsF6FFWWjpzi6ANIKX+G IWy4myEmP+lQCZPmZXp3QOc907zg/ERIKoSBTgAZJy/Y4SqKGckIpbkEeIFeRLdrroNy MU2USEH9JlweYqDquQhDmqPv4BZPU3stVfZTbQ1I+1f+ojDuAskZGZ8ziScCAx/CbGjS X+SA== X-Gm-Message-State: AC+VfDwoEZZXC/fUZYwatN5NG7kEynaPdWp+qyfWvENMsHVA1Qkgkpjh PFnkCR2TV93Ybntx/62okYFtKvyGcpOWEogQ+n1QfA== X-Received: by 2002:a5d:448d:0:b0:30a:8ce6:d306 with SMTP id j13-20020a5d448d000000b0030a8ce6d306mr2623618wrq.6.1684745395489; Mon, 22 May 2023 01:49:55 -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 c17-20020a7bc011000000b003f31cb7a203sm7587467wmb.14.2023.05.22.01.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 01:49:55 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix error and crash on imported function with precondition and 'Base Date: Mon, 22 May 2023 10:49:53 +0200 Message-Id: <20230522084953.1725838-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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?1766584156643471718?= X-GMAIL-MSGID: =?utf-8?q?1766584156643471718?= From: Eric Botcazou This fixes a spurious error on an imported function with a precondition and a parameter declared with a 'Base formal type, and even a crash in the case where this function is declared in a generic package. gcc/ada/ * freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec to copy the spec from the subprogram to the generated subprogram body. (Freeze_Entity): Do not wrap imported subprograms inside generics. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index f54ae0503a1..df3b5ec944e 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -6127,8 +6127,7 @@ package body Freeze is Bod := Make_Subprogram_Body (Loc, - Specification => - Copy_Separate_Tree (Spec), + Specification => Copy_Subprogram_Spec (Spec), Declarations => New_List ( Make_Subprogram_Declaration (Loc, Specification => Copy_Separate_Tree (Spec)), @@ -6438,7 +6437,9 @@ package body Freeze is -- Check for needing to wrap imported subprogram - Wrap_Imported_Subprogram (E); + if not Inside_A_Generic then + Wrap_Imported_Subprogram (E); + end if; -- Freeze all parameter types and the return type (RM 13.14(14)). -- However skip this for internal subprograms. This is also where