From patchwork Mon Jul 8 07:44:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 257478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BA62C2C0040 for ; Mon, 8 Jul 2013 17:44:18 +1000 (EST) 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=xxo8W9WL858LFJuyj0gOmG68xo5Hzxxi5B4sVF8pz2SAkUWaBX dwrGWp5SPcYlNkXEM+gLxrjDQYg0cST9jtodD37/8MY/tyRF1wW2Ab7ueaLJoK1h P6FXy6LJAAVmkL/z62EaFQd3tbrJLl2z/hZyesen6zozjktCN0Xo37EOs= 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=6T11IeWoOd8T4klj23OmWGXGIZo=; b=K9CkYWTAy/bwj1arDUs7 p2dvQq8RYdD5l04YRRo5EJs+8k8McekUmpL3m4X9S7oui2fwrTTGzsofVi+u5JrU RtK1S880AW6EBWfT7YgnTh+yhzWbsQQsDy0V9C7z/RiUpCxxj2nORd9Q1MQm+Acm Nsn/mJ8bDHWD7GDaPsavB1Y= Received: (qmail 11352 invoked by alias); 8 Jul 2013 07:44:12 -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 11343 invoked by uid 89); 8 Jul 2013 07:44:12 -0000 X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 08 Jul 2013 07:44:11 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2607F1C667B; Mon, 8 Jul 2013 03:44:10 -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 lc3mq7N4abky; Mon, 8 Jul 2013 03:44:10 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 069241C6677; Mon, 8 Jul 2013 03:44:10 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 060D63FB31; Mon, 8 Jul 2013 03:44:10 -0400 (EDT) Date: Mon, 8 Jul 2013 03:44:10 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Missing master for incomplete views Message-ID: <20130708074410.GA28681@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Found: No This patch fixes a compiler bug that caused the master of incomplete views to be missing, which caused a crash when allocating an object of the type, if the full type contains tasks. The following example must compile quietly: gcc -c -gnat05 lim_view_example.adb lim_view_example-child.adb limited with Lim_View_Example.Child; package Lim_View_Example is type Acc is access Child.Child_T; procedure P (X : out Acc); end Lim_View_Example; package Lim_View_Example.Child is task type Task_Type; type Child_T is record A_Task : Task_Type; end record; end Lim_View_Example.Child; with Lim_View_Example.Child; package body Lim_View_Example is procedure P (X : out Acc) is begin X := new Child.Child_T; end P; end Lim_View_Example; package body Lim_View_Example.Child is task body Task_Type is begin null; end Task_Type; end Lim_View_Example.Child; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-07-08 Bob Duff * exp_ch3.adb (Build_Master): If Desig_Type is an incomplete view coming from a limited-with'ed package, use the nonlimited view in case it has tasks. Index: exp_ch3.adb =================================================================== --- exp_ch3.adb (revision 200709) +++ exp_ch3.adb (working copy) @@ -4632,9 +4632,19 @@ ------------------ procedure Build_Master (Ptr_Typ : Entity_Id) is - Desig_Typ : constant Entity_Id := Designated_Type (Ptr_Typ); + Desig_Typ : Entity_Id := Designated_Type (Ptr_Typ); begin + -- If the designated type is an incomplete view coming from a + -- limited-with'ed package, we need to use the nonlimited view in + -- case it has tasks. + + if Ekind (Desig_Typ) in Incomplete_Kind + and then Present (Non_Limited_View (Desig_Typ)) + then + Desig_Typ := Non_Limited_View (Desig_Typ); + end if; + -- Anonymous access types are created for the components of the -- record parameter for an entry declaration. No master is created -- for such a type.