The No_Tagged_Streams pragma (and aspect) provides a method for selectively inhibiting the generation of stream routines for tagged types. It can be used either in a form naming a specific tagged type, or in a sequence of declarations to apply to all subsequent declarations. The following tests show the use of the pragma and the rejection of attempts to use stream operations on affected types. 1. with Ada.Text_IO; use Ada.Text_IO; 2. with Ada.Text_IO.Text_Streams; 3. use Ada.Text_IO.Text_Streams; 4. procedure NTS1 is 5. f : File_Type; 6. type R is tagged null record; 7. pragma No_Tagged_Streams (R); 8. RV : R; 9. begin 10. R'Write (Stream (f), RV); | >>> no stream operations for "R" (No_Tagged_Streams at line 7) 11. end; 1. with Ada.Text_IO; use Ada.Text_IO; 2. with Ada.Text_IO.Text_Streams; 3. use Ada.Text_IO.Text_Streams; 4. procedure NTS2 is 5. pragma No_Tagged_Streams; 6. f : File_Type; 7. type R is tagged null record; 8. RV : R; 9. begin 10. R'Write (Stream (f), RV); | >>> no stream operations for "R" (No_Tagged_Streams at line 5) 11. end; 1. with Ada.Text_IO; use Ada.Text_IO; 2. with Ada.Text_IO.Text_Streams; 3. use Ada.Text_IO.Text_Streams; 4. procedure NTS3 is 5. f : File_Type; 6. pragma No_Tagged_Streams; 7. type R is tagged null record; 8. RV : R; 9. begin 10. R'Write (Stream (f), RV); | >>> no stream operations for "R" (No_Tagged_Streams at line 6) 11. end; 1. package NTS4 is 2. pragma No_Tagged_Streams; 3. type R is tagged null record; 4. end; 1. with Ada.Text_IO; use Ada.Text_IO; 2. with Ada.Text_IO.Text_Streams; 3. use Ada.Text_IO.Text_Streams; 4. with NTS4; use NTS4; 5. procedure NTS4M is 6. f : File_Type; 7. RV : R; 8. begin 9. R'Write (Stream (f), RV); | >>> no stream operations for "R" (No_Tagged_Streams at nts4.ads:2) 10. end; 1. with Ada.Text_IO; use Ada.Text_IO; 2. with Ada.Text_IO.Text_Streams; 3. use Ada.Text_IO.Text_Streams; 4. procedure NTS5 is 5. f : File_Type; 6. type R is tagged null record 7. with No_Tagged_Streams => True; 8. type R1 is new R with 9. record F : Integer; end record; 10. RV : R1; 11. begin 12. R1'Write (Stream (f), RV); | >>> no stream operations for "R1" (No_Tagged_Streams at line 7) 13. end; The following test shows the rejection of incorrect usage 1. pragma No_Tagged_Streams; | >>> pragma "NO_TAGGED_STREAMS" is not in declarative part or package spec 2. procedure NTS6 is 3. type R is new Integer; 4. pragma No_Tagged_Streams (Entity => R); | >>> argument for pragma "NO_TAGGED_STREAMS" must be root tagged type 5. begin 6. null; 7. end; 2014-10-20 Robert Dewar * gnat_rm.texi: Document No_Tagged_Streams pragma and aspect. * snames.ads-tmpl: Add entry for pragma No_Tagged_Streams. * aspects.ads, aspects.adb: Add aspect No_Tagged_Streams. * einfo.adb (No_Tagged_Streams_Pragma): New field. * einfo.ads: Minor reformatting (reorder entries). (No_Tagged_Streams_Pragma): New field. * exp_ch3.adb: Minor comment update. * opt.ads (No_Tagged_Streams): New variable. * par-prag.adb: Add dummy entry for pragma No_Tagged_Streams. * sem.ads (Save_No_Tagged_Streams): New field in scope record. * sem_attr.adb (Check_Stream_Attribute): Check stream ops prohibited by No_Tagged_Streams. * sem_ch3.adb (Analyze_Full_Type_Declaration): Set No_Tagged_Streams_Pragma. (Analyze_Subtype_Declaration): ditto. (Build_Derived_Record_Type): ditto. (Record_Type_Declaration): ditto. * sem_ch8.adb (Pop_Scope): Restore No_Tagged_Streams. (Push_Scope): Save No_Tagged_Streams. * sem_prag.adb (Analyze_Pragma, case No_Tagged_Streams): Implement new pragma.