===================================================================
@@ -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)
===================================================================
@@ -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.
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 <dewar@adacore.com> * 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