From patchwork Mon Sep 25 09:26:13 2017 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: 818146 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-462860-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="inFbssSk"; 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 3y0zH51Rsrz9sNr for ; Mon, 25 Sep 2017 19:26:25 +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=wRr2og1bJ4L0cw35kFTIj9yg1wYs7gfm4TtwBcWIPAIVlSKfhX NSr3z6SNF2ig/u5JEmKghqmhjytXT0NVBBtSvqObksrdbVtZM6m9gO8jfzccn09u 2g2qYrxmYd4UVTMC8psr3RawGg4IAdDkwvQcsQ2zt6FLfCGPvemHiFpVY= 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=7UgdTeoj/IW5JRKnzQMKhBQMqYo=; b=inFbssSkgIZhh7CrA8WV D6ZdFdZYfjNzSXoajh4Hy8pRbQqcn92CHaCdcIDIqW+8zNuVIdetpHKUbuepzMhD PXYNfeKi7K3S1+N/HIC8Kitpx4R+bxmeZWylWi1t8GsrKJMqU7xIRUpZWrw/hJah ZP30q4vhO653hbPy0FRUiHM= Received: (qmail 24657 invoked by alias); 25 Sep 2017 09:26:17 -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 24638 invoked by uid 89); 25 Sep 2017 09:26:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=frozen 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; Mon, 25 Sep 2017 09:26:15 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B39B956058; Mon, 25 Sep 2017 05:26: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 IY5ruOJce-1h; Mon, 25 Sep 2017 05:26:13 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id A34975602A; Mon, 25 Sep 2017 05:26:13 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id A249E518; Mon, 25 Sep 2017 05:26:13 -0400 (EDT) Date: Mon, 25 Sep 2017 05:26:13 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Crash on instantiation with renamed formal package. Message-ID: <20170925092613.GA123703@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch fixes a compiler abort on a package instantiation when the corresponding generic has a formal package, and the instantiation has an actual that renames the desired package instance. The following must compile quietly: gcc -c mc.adb --- package MC is procedure Dump_States; end MC; --- with Configurations; with UCTL; package body MC is package MyConfigurations is new Configurations; package Configurations renames MyConfigurations; package MyUCTL0 is new UCTL(MYConfigurations); package MyUCTL is new UCTL(Configurations); procedure Dump_States is begin MyUCTL.Doit; end Dump_States; begin null; end MC; --- generic package Configurations is procedure Doit; end Configurations; --- package body Configurations is procedure Doit is begin null; end; begin null; end Configurations; --- with Configurations; generic with package MyConfigurations is new Configurations(<>); package UCTL is procedure Doit; end UCTL; --- package body UCTL is procedure Doit is begin MyConfigurations.Doit; end; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-25 Ed Schonberg * sem_ch12.adb (Analyze_Associations, case N_Formal_Package): If the actual is a renaming, indicate that it is the renamed package that must be frozen before the instantiation. Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 253135) +++ sem_ch12.adb (working copy) @@ -1980,8 +1980,22 @@ if Needs_Freezing then Check_Generic_Parent; - Set_Has_Delayed_Freeze (Actual); - Append_Elmt (Actual, Actuals_To_Freeze); + + -- If the actual is a renaming of a proper + -- instance of the formal package, indicate + -- that it is the instance that must be frozen. + + if Nkind (Parent (Actual)) = + N_Package_Renaming_Declaration + then + Set_Has_Delayed_Freeze + (Renamed_Entity (Actual)); + Append_Elmt + (Renamed_Entity (Actual), Actuals_To_Freeze); + else + Set_Has_Delayed_Freeze (Actual); + Append_Elmt (Actual, Actuals_To_Freeze); + end if; end if; end if; end Explicit_Freeze_Check;