From patchwork Wed Aug 14 09:53:12 2019 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: 1146904 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-506917-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="wEpjCkuq"; 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 467lNf0RtBz9sDB for ; Wed, 14 Aug 2019 19:56:49 +1000 (AEST) 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=ni7urS3/DHzd2x2hb9Ga4g6njjqjzXta7xgGvpdlA6PRL+dqVq G7Gfci9H0RBs0puv1QABdL5XO5NOSPooIWCJPP7SQ6J3Ll5lP3uubICvCnMgzX9H WMsCIOMD576ckmHH4p7iAs67yevjMoYf7zd+1yiMuPHWXbh90dDhuqdyc= 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=NyBvHtM2zwnGIFpZB2b5QmRHMBQ=; b=wEpjCkuquD1wcMkF5FsW o6QLaK1C45JyJO1V5G9Q5vFzkh3QcKqqsGRASFcKa9U6cRDasAbw3aSPi+2L18Uw VleQQOFbEpcEaT6V/rH+rA51LldDD30GXmBCeB0evtG293suxWUZSc87R9WGJqCT tPlnjqM7azgaKGbJtDPRCUM= Received: (qmail 76403 invoked by alias); 14 Aug 2019 09:53:37 -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 74849 invoked by uid 89); 14 Aug 2019 09:53:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=Sem_Ch12, sem_ch12 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 09:53:24 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxpy1-0007xJ-G3 for gcc-patches@gcc.gnu.org; Wed, 14 Aug 2019 05:53:18 -0400 Received: from rock.gnat.com ([2620:20:4000:0:a9e:1ff:fe9b:1d1]:36990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxpy1-0007vS-9s for gcc-patches@gcc.gnu.org; Wed, 14 Aug 2019 05:53:17 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0E40856108; Wed, 14 Aug 2019 05:53:13 -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 H5v208HI5Z1j; Wed, 14 Aug 2019 05:53:12 -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 EE89411626C; Wed, 14 Aug 2019 05:53:12 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id ED4896CC; Wed, 14 Aug 2019 05:53:12 -0400 (EDT) Date: Wed, 14 Aug 2019 05:53:12 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix internal error on inlined subprogram instance Message-ID: <20190814095312.GA52166@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2620:20:4000:0:a9e:1ff:fe9b:1d1 X-IsSubscribed: yes This fixes a long-standing oddity in the procedure analyzing the instantiation of a generic subprogram, which would set the Is_Generic_Instance flag on the enclosing package generated for the instantiation but only to reset it a few lines below. Now this flag is relied upon by the machinery which computes the set of public entities to be exposed by a package. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-14 Eric Botcazou gcc/ada/ * sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset the Is_Generic_Instance flag previously set on the package generated for the instantiation of a generic subprogram. gcc/testsuite/ * gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb, gnat.dg/generic_inst11_pkg.ads: New testcase. --- gcc/ada/sem_ch12.adb +++ gcc/ada/sem_ch12.adb @@ -5264,10 +5264,6 @@ package body Sem_Ch12 is Analyze (Pack_Decl); Check_Formal_Packages (Pack_Id); - Set_Is_Generic_Instance (Pack_Id, False); - - -- Why do we clear Is_Generic_Instance??? We set it 20 lines - -- above??? -- Body of the enclosing package is supplied when instantiating the -- subprogram body, after semantic analysis is completed. --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/generic_inst11.adb @@ -0,0 +1,9 @@ +-- { dg-do compile } +-- { dg-options "-O -gnatn" } + +with Generic_Inst11_Pkg; + +procedure Generic_Inst11 is +begin + Generic_Inst11_Pkg.Proc; +end; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/generic_inst11_pkg.adb @@ -0,0 +1,21 @@ +with System; + +package body Generic_Inst11_Pkg is + + Data : Integer; + + generic + Reg_Address : System.Address; + procedure Inner_G with Inline; + + procedure Inner_G is + Reg : Integer with Address => Reg_Address; + begin + null; + end; + + procedure My_Inner_G is new Inner_G (Data'Address); + + procedure Proc renames My_Inner_G; + +end Generic_Inst11_Pkg; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/generic_inst11_pkg.ads @@ -0,0 +1,5 @@ +package Generic_Inst11_Pkg is + + procedure Proc with Inline; + +end Generic_Inst11_Pkg;