From patchwork Tue Oct 9 15:09:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 981353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487209-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WRd+xdgA"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42V0yT3pBYz9s55 for ; Wed, 10 Oct 2018 02:09:53 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=Kbr9jeELOLrS46cF/NKk0R04A8dFm7AxYonvm1tPPDQXFWnol2 IFMf+7PUIurueTsHNYujHN5QE0UCjca/1BFNNX4UBvAK5CUzlWY9SlFp2sQzbKd4 aUbZrYruG/vHS9Lv9PFBrVHhw+jhf+NbGhTDRF/5BDmzx2+RkMzn0ukK4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=aXgnJPr+i0+HgHP5V9RQO/n5Bo4=; b=WRd+xdgASFmC3qXeBSrz ma0DX1RoUxgXSfHOoMVYusX+jisspyrgIXEAJDGiPWhgwo68kbfOilQn2Sy3RcO7 8PqoYJUNRQv4BIn7RK8sWQJCccUm4pIlHaSb45WAjoYiCsdlBBobmZZfWHoUJS/9 XoD5434vPqJA9CNAp/bGOsk= Received: (qmail 28995 invoked by alias); 9 Oct 2018 15:09:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28852 invoked by uid 89); 9 Oct 2018 15:09:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=entities, Inner X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Oct 2018 15:09:20 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 325C756013; Tue, 9 Oct 2018 11:09:19 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id t6nOqW85Tb5r; Tue, 9 Oct 2018 11:09:19 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 2184C56012; Tue, 9 Oct 2018 11:09:19 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 1D7AE34B3; Tue, 9 Oct 2018 11:09:19 -0400 (EDT) Date: Tue, 9 Oct 2018 11:09:19 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Internal error on inlined renaming of subprogram instance Message-ID: <20181009150919.GA123299@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This fixes a recent regression introduced in the compiler for the inlined renaming of a subprogram instantiated in a package body. It was wrongly clearing the Is_Public flag on the entity associated with the body. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-10-09 Eric Botcazou gcc/ada/ * sem_ch7.adb (Has_Referencer): Add comment for the N_Freeze_Entity case. Do not rely on Has_Referencer_Of_Non_Subprograms to clear the Is_Public flag on subprogram entities. gcc/testsuite/ * gnat.dg/inline14.adb, gnat.dg/inline14_pkg.adb, gnat.dg/inline14_pkg.ads: New testcase. --- gcc/ada/sem_ch7.adb +++ gcc/ada/sem_ch7.adb @@ -441,7 +441,13 @@ package body Sem_Ch7 is Discard : Boolean; pragma Unreferenced (Discard); begin - -- Inspect the actions to find references to subprograms + -- Inspect the actions to find references to subprograms. + -- We assume that the actions do not contain other kinds + -- of references and, therefore, we do not stop the scan + -- or set Has_Referencer_Of_Non_Subprograms here. Doing + -- it would pessimize common cases for which the actions + -- contain the declaration of an init procedure, since + -- such a procedure is automatically marked inline. Discard := Has_Referencer (Actions (Decl), @@ -470,7 +476,8 @@ package body Sem_Ch7 is and then not Is_Exported (Decl_Id) and then No (Interface_Name (Decl_Id)) and then - (not Has_Referencer_Of_Non_Subprograms + ((Nkind (Decl) /= N_Subprogram_Declaration + and then not Has_Referencer_Of_Non_Subprograms) or else (Nkind (Decl) = N_Subprogram_Declaration and then not Subprogram_Table.Get (Decl_Id))) then --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/inline14.adb @@ -0,0 +1,9 @@ +-- { dg-do compile } +-- { dg-options "-O -gnatn" } + +with Inline14_Pkg; use Inline14_Pkg; + +procedure Inline14 is +begin + Proc; +end; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/inline14_pkg.adb @@ -0,0 +1,16 @@ +package body Inline14_Pkg is + + I : Integer; + + generic procedure Inner; + + procedure Inner is + begin + I := 0; + end; + + procedure My_Inner is new Inner; + + procedure Proc renames My_Inner; + +end Inline14_Pkg; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/inline14_pkg.ads @@ -0,0 +1,6 @@ +package Inline14_Pkg is + + procedure Proc; + pragma Inline (Proc); + +end Inline14_Pkg;