From patchwork Tue May 2 09:06:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 757479 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wHFmV6ym4z9s5L for ; Tue, 2 May 2017 19:07:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="i8pu+sJ8"; dkim-atps=neutral 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=qm15n2mj/KBRUrj19WFXCMxCNNO/N6WCrx0Xknne9iRFtCdOGn KdIjiIQjwCyZBwNiuE60EduMQnozRQlADTGdQfMGe4UnIma+rtUVbnA0iS1Tq1lw 9V7uv/GQoie21wwTC2AMv3ld+piULJsbt54XG+KdVrAD0v/M3uU/ldw1o= 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=xCV+DlI3UhCL4uNhw/ntP5/8H34=; b=i8pu+sJ8iU51Aocp5s2A 7tKdSnkxEG0bBQW3LhPhJhhCcijyvpJgBKAMHB65svSzAmpO2OCbaYAyBFcV10+d 2HhCsioGZp24DjgkE/iKkLbx2lpyoxOB1CEwv80eRwEpIxfjw+D+BJcs9zpPMp9y lwn7MGFom0pNX5zyTt4pC6o= Received: (qmail 95320 invoked by alias); 2 May 2017 09:06:58 -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 95005 invoked by uid 89); 2 May 2017 09:06:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, FILL_THIS_FORM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_LOAN autolearn=ham version=3.3.2 spammy=aux 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, 02 May 2017 09:06:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F2CEC9EDD; Tue, 2 May 2017 05:06:55 -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 ZqlrzJcd1cU8; Tue, 2 May 2017 05:06:55 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E27A69ED8; Tue, 2 May 2017 05:06:55 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id E15734FF; Tue, 2 May 2017 05:06:55 -0400 (EDT) Date: Tue, 2 May 2017 05:06:55 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Bug in handling of library-level freeze actions Message-ID: <20170502090655.GA75357@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes an error in the handling of freeze actions generated for a generic package that is a compilation unit, whose entities carry iterable aspects. The following must compile quietly: --- generic type Data_Type (<>) is limited private; package Data_Streams is type Root_Data_Stream_Type is abstract tagged limited null record; function Has_Data (Stream : Root_Data_Stream_Type) return Boolean is abstract; function Consume (Stream : not null access Root_Data_Stream_Type) return Data_Type is abstract; generic type Data_Stream_Type is new Root_Data_Stream_Type with private; package Add_Iteration is type Iterable_Data_Stream_Type is new Data_Stream_Type with private with Iterable => (First => First, Next => Next, Has_Element => Has_Element, Element => Element); type Cursor is private; function First (Stream : Iterable_Data_Stream_Type) return Cursor; function Next ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Cursor; function Has_Element ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Boolean; function Element ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Data_Type; private type Reference_Type (Stream : not null access Iterable_Data_Stream_Type) is null record; type Iterable_Data_Stream_Type is new Data_Stream_Type with record Self : Reference_Type (Iterable_Data_Stream_Type'Access); end record; type Cursor is null record; end Add_Iteration; end Data_Streams; --- package body Data_Streams is package body Add_Iteration is function First (Stream : Iterable_Data_Stream_Type) return Cursor is begin return (null record); end First; function Has_Element ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Boolean is begin return Has_Data (Stream); end Has_Element; function Next ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Cursor is begin return (null record); end Next; function Element ( Stream : Iterable_Data_Stream_Type; Position : Cursor ) return Data_Type is begin return Consume (Stream.Self.Stream); end Element; end Add_Iteration; end Data_Streams; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-05-02 Ed Schonberg * exp_util.adb (Insert_Library_Level_Action): Use proper scope to analyze generated actions. If the main unit is a body, the required scope is that of the corresponding unit declaration. Index: exp_util.adb =================================================================== --- exp_util.adb (revision 247461) +++ exp_util.adb (working copy) @@ -7491,8 +7491,10 @@ Aux : constant Node_Id := Aux_Decls_Node (Cunit (Main_Unit)); begin - Push_Scope (Cunit_Entity (Main_Unit)); - -- ??? should this be Current_Sem_Unit instead of Main_Unit? + Push_Scope (Cunit_Entity (Current_Sem_Unit)); + -- And not Main_Unit as previously. If the main unit is a body, + -- the scope needed to analyze the actions is the entity of the + -- corresponding declaration. if No (Actions (Aux)) then Set_Actions (Aux, New_List (N));