From patchwork Mon Oct 18 10:35:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 68166 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]) by ozlabs.org (Postfix) with SMTP id 6FAAEB70E9 for ; Mon, 18 Oct 2010 21:35:14 +1100 (EST) Received: (qmail 27136 invoked by alias); 18 Oct 2010 10:35:12 -0000 Received: (qmail 27017 invoked by uid 22791); 18 Oct 2010 10:35:11 -0000 X-SWARE-Spam-Status: No, hits=4.5 required=5.0 tests=AWL, BAYES_00, BOTNET, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Oct 2010 10:35:07 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 6D5CECB0340; Mon, 18 Oct 2010 12:35:05 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QDdsBuYCRkjA; Mon, 18 Oct 2010 12:35:05 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 4CCD8CB0269; Mon, 18 Oct 2010 12:35:05 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 2AC38D9BB4; Mon, 18 Oct 2010 12:35:05 +0200 (CEST) Date: Mon, 18 Oct 2010 12:35:05 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Implement No_Default_Stream_Attributes restriction (AI05-0161-1/02) Message-ID: <20101018103505.GA14111@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 This patch implements the No_Default_Stream_Attributes restriction as described in Ada 2012 AI 161. The following shows the restriction in action: 1. pragma Ada_2012; 2. pragma Restrictions (No_Default_Stream_Attributes); 3. with Ada.Streams; use Ada.Streams; 4. with Ada.Streams.Stream_IO; 5. use Ada.Streams.Stream_IO; 6. procedure Ndstrattr is 7. type T1 is range 1 .. 5; 8. type T2 is range 1 .. 5 with 9. Write => T2_Write; 10. procedure T2_Write 11. (Stream : not null access Root_Stream_Type'Class; 12. Item : T2); 13. procedure T2_Write 14. (Stream : not null access Root_Stream_Type'Class; 15. Item : T2) 16. is 17. begin 18. null; 19. end; 20. 21. File : File_Type; 22. V1 : T1 := 3; 23. V2 : T2 := 4; 24. 25. begin 26. T1'Write (Stream (File), V1); | >>> violation of restriction "No_Default_Stream_Attributes" at line 2 27. T2'Write (Stream (File), V2); 28. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-18 Robert Dewar * exp_strm.adb (Build_Elementary_Input_Call): Check No_Default_Stream_Attributes. (Build_Elementary_Write_Call): Check No_Default_Stream_Attributes * s-rident.ads: Add restriction No_Default_Stream_Attributes Put restriction No_Allocators_After_Elaboration in alpha order Index: s-rident.ads =================================================================== --- s-rident.ads (revision 165610) +++ s-rident.ads (working copy) @@ -62,16 +62,17 @@ package System.Rident is No_Abort_Statements, -- (RM D.7(5), H.4(3)) No_Access_Subprograms, -- (RM H.4(17)) No_Allocators, -- (RM H.4(7)) - No_Anonymous_Allocators, -- Ada 2012 + No_Allocators_After_Elaboration, -- Ada 2012 (RM D.7(19.1/2)) + No_Anonymous_Allocators, -- Ada 2012 (RM H.4(8/1)) No_Asynchronous_Control, -- (RM D.7(10)) No_Calendar, -- GNAT + No_Default_Stream_Attributes, -- Ada 2012 (RM 13.12.1(4/2)) No_Delay, -- (RM H.4(21)) No_Direct_Boolean_Operators, -- GNAT No_Dispatch, -- (RM H.4(19)) No_Dispatching_Calls, -- GNAT No_Dynamic_Attachment, -- GNAT No_Dynamic_Priorities, -- (RM D.9(9)) - No_Allocators_After_Elaboration, -- Ada 2012 No_Enumeration_Maps, -- GNAT No_Entry_Calls_In_Elaboration_Code, -- GNAT No_Entry_Queue, -- GNAT (Ravenscar) Index: exp_strm.adb =================================================================== --- exp_strm.adb (revision 165610) +++ exp_strm.adb (working copy) @@ -29,6 +29,8 @@ with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; +with Restrict; use Restrict; +with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem_Aux; use Sem_Aux; with Sem_Util; use Sem_Util; @@ -455,6 +457,8 @@ package body Exp_Strm is Lib_RE : RE_Id; begin + Check_Restriction (No_Default_Stream_Attributes, N); + -- Compute the size of the stream element. This is either the size of -- the first subtype or if given the size of the Stream_Size attribute. @@ -667,6 +671,8 @@ package body Exp_Strm is Libent : Entity_Id; begin + Check_Restriction (No_Default_Stream_Attributes, N); + -- Compute the size of the stream element. This is either the size of -- the first subtype or if given the size of the Stream_Size attribute.