1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
30 @settitle GNAT Reference Manual
32 @setchapternewpage odd
35 @include gcc-common.texi
37 @dircategory GNU Ada tools
39 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
43 @title GNAT Reference Manual
44 @subtitle GNAT, The GNU Ada Compiler
48 @vskip 0pt plus 1filll
55 @node Top, About This Guide, (dir), (dir)
56 @top GNAT Reference Manual
62 GNAT, The GNU Ada Compiler@*
63 GCC version @value{version-GCC}@*
70 * Implementation Defined Pragmas::
71 * Implementation Defined Aspects::
72 * Implementation Defined Attributes::
73 * Standard and Implementation Defined Restrictions::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
99 * Pragma Abstract_State::
106 * Pragma Allow_Integer_Address::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Attribute_Definition::
115 * Pragma C_Pass_By_Copy::
117 * Pragma Check_Float_Overflow::
118 * Pragma Check_Name::
119 * Pragma Check_Policy::
120 * Pragma CIL_Constructor::
122 * Pragma Common_Object::
123 * Pragma Compile_Time_Error::
124 * Pragma Compile_Time_Warning::
125 * Pragma Compiler_Unit::
126 * Pragma Complete_Representation::
127 * Pragma Complex_Representation::
128 * Pragma Component_Alignment::
129 * Pragma Contract_Cases::
130 * Pragma Convention_Identifier::
132 * Pragma CPP_Constructor::
133 * Pragma CPP_Virtual::
134 * Pragma CPP_Vtable::
137 * Pragma Debug_Policy::
138 * Pragma Default_Storage_Pool::
140 * Pragma Detect_Blocking::
141 * Pragma Disable_Atomic_Synchronization::
142 * Pragma Dispatching_Domain::
143 * Pragma Elaboration_Checks::
145 * Pragma Enable_Atomic_Synchronization::
146 * Pragma Export_Exception::
147 * Pragma Export_Function::
148 * Pragma Export_Object::
149 * Pragma Export_Procedure::
150 * Pragma Export_Value::
151 * Pragma Export_Valued_Procedure::
152 * Pragma Extend_System::
153 * Pragma Extensions_Allowed::
155 * Pragma External_Name_Casing::
157 * Pragma Favor_Top_Level::
158 * Pragma Finalize_Storage_Only::
159 * Pragma Float_Representation::
162 * Pragma Implementation_Defined::
163 * Pragma Implemented::
164 * Pragma Implicit_Packing::
165 * Pragma Import_Exception::
166 * Pragma Import_Function::
167 * Pragma Import_Object::
168 * Pragma Import_Procedure::
169 * Pragma Import_Valued_Procedure::
170 * Pragma Independent::
171 * Pragma Independent_Components::
172 * Pragma Initial_Condition::
173 * Pragma Initialize_Scalars::
174 * Pragma Initializes::
175 * Pragma Inline_Always::
176 * Pragma Inline_Generic::
178 * Pragma Interface_Name::
179 * Pragma Interrupt_Handler::
180 * Pragma Interrupt_State::
182 * Pragma Java_Constructor::
183 * Pragma Java_Interface::
184 * Pragma Keep_Names::
187 * Pragma Linker_Alias::
188 * Pragma Linker_Constructor::
189 * Pragma Linker_Destructor::
190 * Pragma Linker_Section::
191 * Pragma Long_Float::
192 * Pragma Loop_Invariant::
193 * Pragma Loop_Optimize::
194 * Pragma Loop_Variant::
195 * Pragma Machine_Attribute::
197 * Pragma Main_Storage::
201 * Pragma No_Run_Time::
202 * Pragma No_Strict_Aliasing ::
203 * Pragma Normalize_Scalars::
204 * Pragma Obsolescent::
205 * Pragma Optimize_Alignment::
207 * Pragma Overflow_Mode::
208 * Pragma Overriding_Renamings::
209 * Pragma Partition_Elaboration_Policy::
211 * Pragma Persistent_BSS::
214 * Pragma Postcondition::
215 * Pragma Post_Class::
217 * Pragma Precondition::
219 * Pragma Preelaborable_Initialization::
220 * Pragma Preelaborate_05::
222 * Pragma Priority_Specific_Dispatching::
224 * Pragma Profile_Warnings::
225 * Pragma Propagate_Exceptions::
226 * Pragma Psect_Object::
229 * Pragma Pure_Function::
231 * Pragma Refined_State::
232 * Pragma Relative_Deadline::
233 * Pragma Remote_Access_Type::
234 * Pragma Restricted_Run_Time::
235 * Pragma Restriction_Warnings::
236 * Pragma Share_Generic::
238 * Pragma Short_Circuit_And_Or::
239 * Pragma Short_Descriptors::
240 * Pragma Simple_Storage_Pool_Type::
241 * Pragma Source_File_Name::
242 * Pragma Source_File_Name_Project::
243 * Pragma Source_Reference::
244 * Pragma SPARK_Mode::
245 * Pragma Static_Elaboration_Desired::
246 * Pragma Stream_Convert::
247 * Pragma Style_Checks::
250 * Pragma Suppress_All::
251 * Pragma Suppress_Debug_Info::
252 * Pragma Suppress_Exception_Locations::
253 * Pragma Suppress_Initialization::
256 * Pragma Task_Storage::
258 * Pragma Thread_Local_Storage::
259 * Pragma Time_Slice::
261 * Pragma Type_Invariant::
262 * Pragma Type_Invariant_Class::
263 * Pragma Unchecked_Union::
264 * Pragma Unimplemented_Unit::
265 * Pragma Universal_Aliasing ::
266 * Pragma Universal_Data::
267 * Pragma Unmodified::
268 * Pragma Unreferenced::
269 * Pragma Unreferenced_Objects::
270 * Pragma Unreserve_All_Interrupts::
271 * Pragma Unsuppress::
272 * Pragma Use_VADS_Size::
273 * Pragma Validity_Checks::
276 * Pragma Weak_External::
277 * Pragma Wide_Character_Encoding::
279 Implementation Defined Aspects
281 * Aspect Abstract_State::
284 * Aspect Compiler_Unit::
285 * Aspect Contract_Cases::
288 * Aspect Dimension_System::
289 * Aspect Favor_Top_Level::
291 * Aspect Initial_Condition::
292 * Aspect Initializes::
293 * Aspect Inline_Always::
295 * Aspect Linker_Section::
296 * Aspect Object_Size::
297 * Aspect Persistent_BSS::
299 * Aspect Preelaborate_05::
302 * Aspect Pure_Function::
303 * Aspect Refined_State::
304 * Aspect Remote_Access_Type::
305 * Aspect Scalar_Storage_Order::
307 * Aspect Simple_Storage_Pool::
308 * Aspect Simple_Storage_Pool_Type::
309 * Aspect SPARK_Mode::
310 * Aspect Suppress_Debug_Info::
312 * Aspect Universal_Aliasing::
313 * Aspect Universal_Data::
314 * Aspect Unmodified::
315 * Aspect Unreferenced::
316 * Aspect Unreferenced_Objects::
317 * Aspect Value_Size::
320 Implementation Defined Attributes
322 * Attribute Abort_Signal::
323 * Attribute Address_Size::
324 * Attribute Asm_Input::
325 * Attribute Asm_Output::
326 * Attribute AST_Entry::
328 * Attribute Bit_Position::
329 * Attribute Compiler_Version::
330 * Attribute Code_Address::
331 * Attribute Default_Bit_Order::
332 * Attribute Descriptor_Size::
333 * Attribute Elaborated::
334 * Attribute Elab_Body::
335 * Attribute Elab_Spec::
336 * Attribute Elab_Subp_Body::
338 * Attribute Enabled::
339 * Attribute Enum_Rep::
340 * Attribute Enum_Val::
341 * Attribute Epsilon::
342 * Attribute Fixed_Value::
343 * Attribute Has_Access_Values::
344 * Attribute Has_Discriminants::
346 * Attribute Integer_Value::
347 * Attribute Invalid_Value::
349 * Attribute Library_Level::
350 * Attribute Loop_Entry::
351 * Attribute Machine_Size::
352 * Attribute Mantissa::
353 * Attribute Max_Interrupt_Priority::
354 * Attribute Max_Priority::
355 * Attribute Maximum_Alignment::
356 * Attribute Mechanism_Code::
357 * Attribute Null_Parameter::
358 * Attribute Object_Size::
359 * Attribute Passed_By_Reference::
360 * Attribute Pool_Address::
361 * Attribute Range_Length::
363 * Attribute Restriction_Set::
365 * Attribute Safe_Emax::
366 * Attribute Safe_Large::
367 * Attribute Scalar_Storage_Order::
368 * Attribute Simple_Storage_Pool::
370 * Attribute Storage_Unit::
371 * Attribute Stub_Type::
372 * Attribute System_Allocator_Alignment::
373 * Attribute Target_Name::
375 * Attribute To_Address::
376 * Attribute Type_Class::
377 * Attribute UET_Address::
378 * Attribute Unconstrained_Array::
379 * Attribute Universal_Literal_String::
380 * Attribute Unrestricted_Access::
382 * Attribute Valid_Scalars::
383 * Attribute VADS_Size::
384 * Attribute Value_Size::
385 * Attribute Wchar_T_Size::
386 * Attribute Word_Size::
388 Standard and Implementation Defined Restrictions
390 * Partition-Wide Restrictions::
391 * Program Unit Level Restrictions::
393 Partition-Wide Restrictions
395 * Immediate_Reclamation::
396 * Max_Asynchronous_Select_Nesting::
397 * Max_Entry_Queue_Length::
398 * Max_Protected_Entries::
399 * Max_Select_Alternatives::
400 * Max_Storage_At_Blocking::
403 * No_Abort_Statements::
404 * No_Access_Parameter_Allocators::
405 * No_Access_Subprograms::
407 * No_Anonymous_Allocators::
410 * No_Default_Initialization::
413 * No_Direct_Boolean_Operators::
415 * No_Dispatching_Calls::
416 * No_Dynamic_Attachment::
417 * No_Dynamic_Priorities::
418 * No_Entry_Calls_In_Elaboration_Code::
419 * No_Enumeration_Maps::
420 * No_Exception_Handlers::
421 * No_Exception_Propagation::
422 * No_Exception_Registration::
426 * No_Floating_Point::
427 * No_Implicit_Conditionals::
428 * No_Implicit_Dynamic_Code::
429 * No_Implicit_Heap_Allocations::
430 * No_Implicit_Loops::
431 * No_Initialize_Scalars::
433 * No_Local_Allocators::
434 * No_Local_Protected_Objects::
435 * No_Local_Timing_Events::
436 * No_Nested_Finalization::
437 * No_Protected_Type_Allocators::
438 * No_Protected_Types::
441 * No_Relative_Delay::
442 * No_Requeue_Statements::
443 * No_Secondary_Stack::
444 * No_Select_Statements::
445 * No_Specific_Termination_Handlers::
446 * No_Specification_of_Aspect::
447 * No_Standard_Allocators_After_Elaboration::
448 * No_Standard_Storage_Pools::
449 * No_Stream_Optimizations::
451 * No_Task_Allocators::
452 * No_Task_Attributes_Package::
453 * No_Task_Hierarchy::
454 * No_Task_Termination::
456 * No_Terminate_Alternatives::
457 * No_Unchecked_Access::
459 * Static_Priorities::
460 * Static_Storage_Size::
462 Program Unit Level Restrictions
464 * No_Elaboration_Code::
466 * No_Implementation_Aspect_Specifications::
467 * No_Implementation_Attributes::
468 * No_Implementation_Identifiers::
469 * No_Implementation_Pragmas::
470 * No_Implementation_Restrictions::
471 * No_Implementation_Units::
472 * No_Implicit_Aliasing::
473 * No_Obsolescent_Features::
474 * No_Wide_Characters::
477 The Implementation of Standard I/O
479 * Standard I/O Packages::
485 * Wide_Wide_Text_IO::
489 * Filenames encoding::
491 * Operations on C Streams::
492 * Interfacing to C Streams::
496 * Ada.Characters.Latin_9 (a-chlat9.ads)::
497 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
498 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
499 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
500 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
501 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
502 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
503 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
504 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
505 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
506 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
507 * Ada.Command_Line.Environment (a-colien.ads)::
508 * Ada.Command_Line.Remove (a-colire.ads)::
509 * Ada.Command_Line.Response_File (a-clrefi.ads)::
510 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
511 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
512 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
513 * Ada.Exceptions.Traceback (a-exctra.ads)::
514 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
515 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
516 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
517 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
518 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
519 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
520 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
521 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
522 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
523 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
524 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
525 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
526 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
527 * GNAT.Altivec (g-altive.ads)::
528 * GNAT.Altivec.Conversions (g-altcon.ads)::
529 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
530 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
531 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
532 * GNAT.Array_Split (g-arrspl.ads)::
533 * GNAT.AWK (g-awk.ads)::
534 * GNAT.Bounded_Buffers (g-boubuf.ads)::
535 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
536 * GNAT.Bubble_Sort (g-bubsor.ads)::
537 * GNAT.Bubble_Sort_A (g-busora.ads)::
538 * GNAT.Bubble_Sort_G (g-busorg.ads)::
539 * GNAT.Byte_Order_Mark (g-byorma.ads)::
540 * GNAT.Byte_Swapping (g-bytswa.ads)::
541 * GNAT.Calendar (g-calend.ads)::
542 * GNAT.Calendar.Time_IO (g-catiio.ads)::
543 * GNAT.Case_Util (g-casuti.ads)::
544 * GNAT.CGI (g-cgi.ads)::
545 * GNAT.CGI.Cookie (g-cgicoo.ads)::
546 * GNAT.CGI.Debug (g-cgideb.ads)::
547 * GNAT.Command_Line (g-comlin.ads)::
548 * GNAT.Compiler_Version (g-comver.ads)::
549 * GNAT.Ctrl_C (g-ctrl_c.ads)::
550 * GNAT.CRC32 (g-crc32.ads)::
551 * GNAT.Current_Exception (g-curexc.ads)::
552 * GNAT.Debug_Pools (g-debpoo.ads)::
553 * GNAT.Debug_Utilities (g-debuti.ads)::
554 * GNAT.Decode_String (g-decstr.ads)::
555 * GNAT.Decode_UTF8_String (g-deutst.ads)::
556 * GNAT.Directory_Operations (g-dirope.ads)::
557 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
558 * GNAT.Dynamic_HTables (g-dynhta.ads)::
559 * GNAT.Dynamic_Tables (g-dyntab.ads)::
560 * GNAT.Encode_String (g-encstr.ads)::
561 * GNAT.Encode_UTF8_String (g-enutst.ads)::
562 * GNAT.Exception_Actions (g-excact.ads)::
563 * GNAT.Exception_Traces (g-exctra.ads)::
564 * GNAT.Exceptions (g-except.ads)::
565 * GNAT.Expect (g-expect.ads)::
566 * GNAT.Expect.TTY (g-exptty.ads)::
567 * GNAT.Float_Control (g-flocon.ads)::
568 * GNAT.Heap_Sort (g-heasor.ads)::
569 * GNAT.Heap_Sort_A (g-hesora.ads)::
570 * GNAT.Heap_Sort_G (g-hesorg.ads)::
571 * GNAT.HTable (g-htable.ads)::
572 * GNAT.IO (g-io.ads)::
573 * GNAT.IO_Aux (g-io_aux.ads)::
574 * GNAT.Lock_Files (g-locfil.ads)::
575 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
576 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
577 * GNAT.MD5 (g-md5.ads)::
578 * GNAT.Memory_Dump (g-memdum.ads)::
579 * GNAT.Most_Recent_Exception (g-moreex.ads)::
580 * GNAT.OS_Lib (g-os_lib.ads)::
581 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
582 * GNAT.Random_Numbers (g-rannum.ads)::
583 * GNAT.Regexp (g-regexp.ads)::
584 * GNAT.Registry (g-regist.ads)::
585 * GNAT.Regpat (g-regpat.ads)::
586 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
587 * GNAT.Semaphores (g-semaph.ads)::
588 * GNAT.Serial_Communications (g-sercom.ads)::
589 * GNAT.SHA1 (g-sha1.ads)::
590 * GNAT.SHA224 (g-sha224.ads)::
591 * GNAT.SHA256 (g-sha256.ads)::
592 * GNAT.SHA384 (g-sha384.ads)::
593 * GNAT.SHA512 (g-sha512.ads)::
594 * GNAT.Signals (g-signal.ads)::
595 * GNAT.Sockets (g-socket.ads)::
596 * GNAT.Source_Info (g-souinf.ads)::
597 * GNAT.Spelling_Checker (g-speche.ads)::
598 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
599 * GNAT.Spitbol.Patterns (g-spipat.ads)::
600 * GNAT.Spitbol (g-spitbo.ads)::
601 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
602 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
603 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
604 * GNAT.SSE (g-sse.ads)::
605 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
606 * GNAT.Strings (g-string.ads)::
607 * GNAT.String_Split (g-strspl.ads)::
608 * GNAT.Table (g-table.ads)::
609 * GNAT.Task_Lock (g-tasloc.ads)::
610 * GNAT.Threads (g-thread.ads)::
611 * GNAT.Time_Stamp (g-timsta.ads)::
612 * GNAT.Traceback (g-traceb.ads)::
613 * GNAT.Traceback.Symbolic (g-trasym.ads)::
614 * GNAT.UTF_32 (g-utf_32.ads)::
615 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
616 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
617 * GNAT.Wide_String_Split (g-wistsp.ads)::
618 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
619 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
620 * Interfaces.C.Extensions (i-cexten.ads)::
621 * Interfaces.C.Streams (i-cstrea.ads)::
622 * Interfaces.CPP (i-cpp.ads)::
623 * Interfaces.Packed_Decimal (i-pacdec.ads)::
624 * Interfaces.VxWorks (i-vxwork.ads)::
625 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
626 * System.Address_Image (s-addima.ads)::
627 * System.Assertions (s-assert.ads)::
628 * System.Memory (s-memory.ads)::
629 * System.Multiprocessors (s-multip.ads)::
630 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
631 * System.Partition_Interface (s-parint.ads)::
632 * System.Pool_Global (s-pooglo.ads)::
633 * System.Pool_Local (s-pooloc.ads)::
634 * System.Restrictions (s-restri.ads)::
635 * System.Rident (s-rident.ads)::
636 * System.Strings.Stream_Ops (s-ststop.ads)::
637 * System.Task_Info (s-tasinf.ads)::
638 * System.Wch_Cnv (s-wchcnv.ads)::
639 * System.Wch_Con (s-wchcon.ads)::
643 * Text_IO Stream Pointer Positioning::
644 * Text_IO Reading and Writing Non-Regular Files::
646 * Treating Text_IO Files as Streams::
647 * Text_IO Extensions::
648 * Text_IO Facilities for Unbounded Strings::
652 * Wide_Text_IO Stream Pointer Positioning::
653 * Wide_Text_IO Reading and Writing Non-Regular Files::
657 * Wide_Wide_Text_IO Stream Pointer Positioning::
658 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
660 Interfacing to Other Languages
663 * Interfacing to C++::
664 * Interfacing to COBOL::
665 * Interfacing to Fortran::
666 * Interfacing to non-GNAT Ada code::
668 Specialized Needs Annexes
670 Implementation of Specific Ada Features
671 * Machine Code Insertions::
672 * GNAT Implementation of Tasking::
673 * GNAT Implementation of Shared Passive Packages::
674 * Code Generation for Array Aggregates::
675 * The Size of Discriminated Records with Default Discriminants::
676 * Strict Conformance to the Ada Reference Manual::
678 Implementation of Ada 2012 Features
682 GNU Free Documentation License
689 @node About This Guide
690 @unnumbered About This Guide
693 This manual contains useful information in writing programs using the
694 @value{EDITION} compiler. It includes information on implementation dependent
695 characteristics of @value{EDITION}, including all the information required by
696 Annex M of the Ada language standard.
698 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
699 invoked in Ada 83 compatibility mode.
700 By default, @value{EDITION} assumes Ada 2012,
701 but you can override with a compiler switch
702 to explicitly specify the language version.
703 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
704 @value{EDITION} User's Guide}, for details on these switches.)
705 Throughout this manual, references to ``Ada'' without a year suffix
706 apply to all the Ada versions of the language.
708 Ada is designed to be highly portable.
709 In general, a program will have the same effect even when compiled by
710 different compilers on different platforms.
711 However, since Ada is designed to be used in a
712 wide variety of applications, it also contains a number of system
713 dependent features to be used in interfacing to the external world.
714 @cindex Implementation-dependent features
717 Note: Any program that makes use of implementation-dependent features
718 may be non-portable. You should follow good programming practice and
719 isolate and clearly document any sections of your program that make use
720 of these features in a non-portable manner.
723 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
724 ``GNAT'' in the remainder of this document.
728 * What This Reference Manual Contains::
730 * Related Information::
733 @node What This Reference Manual Contains
734 @unnumberedsec What This Reference Manual Contains
737 This reference manual contains the following chapters:
741 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
742 pragmas, which can be used to extend and enhance the functionality of the
746 @ref{Implementation Defined Attributes}, lists GNAT
747 implementation-dependent attributes, which can be used to extend and
748 enhance the functionality of the compiler.
751 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
752 implementation-dependent restrictions, which can be used to extend and
753 enhance the functionality of the compiler.
756 @ref{Implementation Advice}, provides information on generally
757 desirable behavior which are not requirements that all compilers must
758 follow since it cannot be provided on all systems, or which may be
759 undesirable on some systems.
762 @ref{Implementation Defined Characteristics}, provides a guide to
763 minimizing implementation dependent features.
766 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
767 implemented by GNAT, and how they can be imported into user
768 application programs.
771 @ref{Representation Clauses and Pragmas}, describes in detail the
772 way that GNAT represents data, and in particular the exact set
773 of representation clauses and pragmas that is accepted.
776 @ref{Standard Library Routines}, provides a listing of packages and a
777 brief description of the functionality that is provided by Ada's
778 extensive set of standard library routines as implemented by GNAT@.
781 @ref{The Implementation of Standard I/O}, details how the GNAT
782 implementation of the input-output facilities.
785 @ref{The GNAT Library}, is a catalog of packages that complement
786 the Ada predefined library.
789 @ref{Interfacing to Other Languages}, describes how programs
790 written in Ada using GNAT can be interfaced to other programming
793 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
794 of the specialized needs annexes.
797 @ref{Implementation of Specific Ada Features}, discusses issues related
798 to GNAT's implementation of machine code insertions, tasking, and several
802 @ref{Implementation of Ada 2012 Features}, describes the status of the
803 GNAT implementation of the Ada 2012 language standard.
806 @ref{Obsolescent Features} documents implementation dependent features,
807 including pragmas and attributes, which are considered obsolescent, since
808 there are other preferred ways of achieving the same results. These
809 obsolescent forms are retained for backwards compatibility.
813 @cindex Ada 95 Language Reference Manual
814 @cindex Ada 2005 Language Reference Manual
816 This reference manual assumes a basic familiarity with the Ada 95 language, as
817 described in the International Standard ANSI/ISO/IEC-8652:1995,
819 It does not require knowledge of the new features introduced by Ada 2005,
820 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
822 Both reference manuals are included in the GNAT documentation
826 @unnumberedsec Conventions
827 @cindex Conventions, typographical
828 @cindex Typographical conventions
831 Following are examples of the typographical and graphic conventions used
836 @code{Functions}, @code{utility program names}, @code{standard names},
843 @file{File names}, @samp{button names}, and @samp{field names}.
846 @code{Variables}, @env{environment variables}, and @var{metasyntactic
853 [optional information or parameters]
856 Examples are described by text
858 and then shown this way.
863 Commands that are entered by the user are preceded in this manual by the
864 characters @samp{$ } (dollar sign followed by space). If your system uses this
865 sequence as a prompt, then the commands will appear exactly as you see them
866 in the manual. If your system uses some other prompt, then the command will
867 appear with the @samp{$} replaced by whatever prompt character you are using.
869 @node Related Information
870 @unnumberedsec Related Information
872 See the following documents for further information on GNAT:
876 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
877 @value{EDITION} User's Guide}, which provides information on how to use the
878 GNAT compiler system.
881 @cite{Ada 95 Reference Manual}, which contains all reference
882 material for the Ada 95 programming language.
885 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
886 of the Ada 95 standard. The annotations describe
887 detailed aspects of the design decision, and in particular contain useful
888 sections on Ada 83 compatibility.
891 @cite{Ada 2005 Reference Manual}, which contains all reference
892 material for the Ada 2005 programming language.
895 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
896 of the Ada 2005 standard. The annotations describe
897 detailed aspects of the design decision, and in particular contain useful
898 sections on Ada 83 and Ada 95 compatibility.
901 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
902 which contains specific information on compatibility between GNAT and
906 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
907 describes in detail the pragmas and attributes provided by the DEC Ada 83
912 @node Implementation Defined Pragmas
913 @chapter Implementation Defined Pragmas
916 Ada defines a set of pragmas that can be used to supply additional
917 information to the compiler. These language defined pragmas are
918 implemented in GNAT and work as described in the Ada Reference Manual.
920 In addition, Ada allows implementations to define additional pragmas
921 whose meaning is defined by the implementation. GNAT provides a number
922 of these implementation-defined pragmas, which can be used to extend
923 and enhance the functionality of the compiler. This section of the GNAT
924 Reference Manual describes these additional pragmas.
926 Note that any program using these pragmas might not be portable to other
927 compilers (although GNAT implements this set of pragmas on all
928 platforms). Therefore if portability to other compilers is an important
929 consideration, the use of these pragmas should be minimized.
932 * Pragma Abort_Defer::
933 * Pragma Abstract_State::
940 * Pragma Allow_Integer_Address::
943 * Pragma Assert_And_Cut::
944 * Pragma Assertion_Policy::
946 * Pragma Assume_No_Invalid_Values::
947 * Pragma Attribute_Definition::
949 * Pragma C_Pass_By_Copy::
951 * Pragma Check_Float_Overflow::
952 * Pragma Check_Name::
953 * Pragma Check_Policy::
954 * Pragma CIL_Constructor::
956 * Pragma Common_Object::
957 * Pragma Compile_Time_Error::
958 * Pragma Compile_Time_Warning::
959 * Pragma Compiler_Unit::
960 * Pragma Complete_Representation::
961 * Pragma Complex_Representation::
962 * Pragma Component_Alignment::
963 * Pragma Contract_Cases::
964 * Pragma Convention_Identifier::
966 * Pragma CPP_Constructor::
967 * Pragma CPP_Virtual::
968 * Pragma CPP_Vtable::
971 * Pragma Debug_Policy::
972 * Pragma Default_Storage_Pool::
974 * Pragma Detect_Blocking::
975 * Pragma Disable_Atomic_Synchronization::
976 * Pragma Dispatching_Domain::
977 * Pragma Elaboration_Checks::
979 * Pragma Enable_Atomic_Synchronization::
980 * Pragma Export_Exception::
981 * Pragma Export_Function::
982 * Pragma Export_Object::
983 * Pragma Export_Procedure::
984 * Pragma Export_Value::
985 * Pragma Export_Valued_Procedure::
986 * Pragma Extend_System::
987 * Pragma Extensions_Allowed::
989 * Pragma External_Name_Casing::
991 * Pragma Favor_Top_Level::
992 * Pragma Finalize_Storage_Only::
993 * Pragma Float_Representation::
996 * Pragma Implementation_Defined::
997 * Pragma Implemented::
998 * Pragma Implicit_Packing::
999 * Pragma Import_Exception::
1000 * Pragma Import_Function::
1001 * Pragma Import_Object::
1002 * Pragma Import_Procedure::
1003 * Pragma Import_Valued_Procedure::
1004 * Pragma Independent::
1005 * Pragma Independent_Components::
1006 * Pragma Initial_Condition::
1007 * Pragma Initialize_Scalars::
1008 * Pragma Initializes::
1009 * Pragma Inline_Always::
1010 * Pragma Inline_Generic::
1011 * Pragma Interface::
1012 * Pragma Interface_Name::
1013 * Pragma Interrupt_Handler::
1014 * Pragma Interrupt_State::
1015 * Pragma Invariant::
1016 * Pragma Java_Constructor::
1017 * Pragma Java_Interface::
1018 * Pragma Keep_Names::
1020 * Pragma Link_With::
1021 * Pragma Linker_Alias::
1022 * Pragma Linker_Constructor::
1023 * Pragma Linker_Destructor::
1024 * Pragma Linker_Section::
1025 * Pragma Long_Float::
1026 * Pragma Loop_Invariant::
1027 * Pragma Loop_Optimize::
1028 * Pragma Loop_Variant::
1029 * Pragma Machine_Attribute::
1031 * Pragma Main_Storage::
1033 * Pragma No_Inline::
1034 * Pragma No_Return::
1035 * Pragma No_Run_Time::
1036 * Pragma No_Strict_Aliasing::
1037 * Pragma Normalize_Scalars::
1038 * Pragma Obsolescent::
1039 * Pragma Optimize_Alignment::
1041 * Pragma Overflow_Mode::
1042 * Pragma Overriding_Renamings::
1043 * Pragma Partition_Elaboration_Policy::
1045 * Pragma Persistent_BSS::
1048 * Pragma Postcondition::
1049 * Pragma Post_Class::
1051 * Pragma Precondition::
1052 * Pragma Predicate::
1053 * Pragma Preelaborable_Initialization::
1054 * Pragma Preelaborate_05::
1055 * Pragma Pre_Class::
1056 * Pragma Priority_Specific_Dispatching::
1058 * Pragma Profile_Warnings::
1059 * Pragma Propagate_Exceptions::
1060 * Pragma Psect_Object::
1063 * Pragma Pure_Function::
1064 * Pragma Ravenscar::
1065 * Pragma Refined_State::
1066 * Pragma Relative_Deadline::
1067 * Pragma Remote_Access_Type::
1068 * Pragma Restricted_Run_Time::
1069 * Pragma Restriction_Warnings::
1070 * Pragma Share_Generic::
1072 * Pragma Short_Circuit_And_Or::
1073 * Pragma Short_Descriptors::
1074 * Pragma Simple_Storage_Pool_Type::
1075 * Pragma Source_File_Name::
1076 * Pragma Source_File_Name_Project::
1077 * Pragma Source_Reference::
1078 * Pragma SPARK_Mode::
1079 * Pragma Static_Elaboration_Desired::
1080 * Pragma Stream_Convert::
1081 * Pragma Style_Checks::
1084 * Pragma Suppress_All::
1085 * Pragma Suppress_Debug_Info::
1086 * Pragma Suppress_Exception_Locations::
1087 * Pragma Suppress_Initialization::
1088 * Pragma Task_Info::
1089 * Pragma Task_Name::
1090 * Pragma Task_Storage::
1091 * Pragma Test_Case::
1092 * Pragma Thread_Local_Storage::
1093 * Pragma Time_Slice::
1095 * Pragma Type_Invariant::
1096 * Pragma Type_Invariant_Class::
1097 * Pragma Unchecked_Union::
1098 * Pragma Unimplemented_Unit::
1099 * Pragma Universal_Aliasing ::
1100 * Pragma Universal_Data::
1101 * Pragma Unmodified::
1102 * Pragma Unreferenced::
1103 * Pragma Unreferenced_Objects::
1104 * Pragma Unreserve_All_Interrupts::
1105 * Pragma Unsuppress::
1106 * Pragma Use_VADS_Size::
1107 * Pragma Validity_Checks::
1110 * Pragma Weak_External::
1111 * Pragma Wide_Character_Encoding::
1114 @node Pragma Abort_Defer
1115 @unnumberedsec Pragma Abort_Defer
1117 @cindex Deferring aborts
1125 This pragma must appear at the start of the statement sequence of a
1126 handled sequence of statements (right after the @code{begin}). It has
1127 the effect of deferring aborts for the sequence of statements (but not
1128 for the declarations or handlers, if any, associated with this statement
1131 @node Pragma Abstract_State
1132 @unnumberedsec Pragma Abstract_State
1133 @findex Abstract_State
1135 For the description of this pragma, see SPARK 2014 Reference Manual,
1139 @unnumberedsec Pragma Ada_83
1143 @smallexample @c ada
1148 A configuration pragma that establishes Ada 83 mode for the unit to
1149 which it applies, regardless of the mode set by the command line
1150 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1151 the syntax and semantics of Ada 83, as defined in the original Ada
1152 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1153 and Ada 2005 are not recognized, optional package bodies are allowed,
1154 and generics may name types with unknown discriminants without using
1155 the @code{(<>)} notation. In addition, some but not all of the additional
1156 restrictions of Ada 83 are enforced.
1158 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1159 Ada 83 code to be compiled and adapted to GNAT with less effort.
1160 Secondly, it aids in keeping code backwards compatible with Ada 83.
1161 However, there is no guarantee that code that is processed correctly
1162 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1163 83 compiler, since GNAT does not enforce all the additional checks
1167 @unnumberedsec Pragma Ada_95
1171 @smallexample @c ada
1176 A configuration pragma that establishes Ada 95 mode for the unit to which
1177 it applies, regardless of the mode set by the command line switches.
1178 This mode is set automatically for the @code{Ada} and @code{System}
1179 packages and their children, so you need not specify it in these
1180 contexts. This pragma is useful when writing a reusable component that
1181 itself uses Ada 95 features, but which is intended to be usable from
1182 either Ada 83 or Ada 95 programs.
1185 @unnumberedsec Pragma Ada_05
1189 @smallexample @c ada
1194 A configuration pragma that establishes Ada 2005 mode for the unit to which
1195 it applies, regardless of the mode set by the command line switches.
1196 This pragma is useful when writing a reusable component that
1197 itself uses Ada 2005 features, but which is intended to be usable from
1198 either Ada 83 or Ada 95 programs.
1200 @node Pragma Ada_2005
1201 @unnumberedsec Pragma Ada_2005
1205 @smallexample @c ada
1210 This configuration pragma is a synonym for pragma Ada_05 and has the
1211 same syntax and effect.
1214 @unnumberedsec Pragma Ada_12
1218 @smallexample @c ada
1223 A configuration pragma that establishes Ada 2012 mode for the unit to which
1224 it applies, regardless of the mode set by the command line switches.
1225 This mode is set automatically for the @code{Ada} and @code{System}
1226 packages and their children, so you need not specify it in these
1227 contexts. This pragma is useful when writing a reusable component that
1228 itself uses Ada 2012 features, but which is intended to be usable from
1229 Ada 83, Ada 95, or Ada 2005 programs.
1231 @node Pragma Ada_2012
1232 @unnumberedsec Pragma Ada_2012
1236 @smallexample @c ada
1241 This configuration pragma is a synonym for pragma Ada_12 and has the
1242 same syntax and effect.
1244 @node Pragma Allow_Integer_Address
1245 @unnumberedsec Pragma Allow_Integer_Address
1246 @findex Allow_Integer_Address
1249 @smallexample @c ada
1250 pragma Allow_Integer_Address;
1254 In almost all versions of GNAT, @code{System.Address} is a private
1255 type in accordance with the implementation advice in the RM. This
1256 means that integer values,
1257 in particular integer literals, are not allowed as address values.
1258 If the configuration pragma
1259 @code{Allow_Integer_Address} is given, then integer expressions may
1260 be used anywhere a value of type @code{System.Address} is required.
1261 The effect is to introduce an implicit unchecked conversion from the
1262 integer value to type @code{System.Address}. The reverse case of using
1263 an address where an integer type is required is handled analogously.
1264 The following example compiles without errors:
1266 @smallexample @c ada
1267 pragma Allow_Integer_Address;
1268 with System; use System;
1269 package AddrAsInt is
1272 for X'Address use 16#1240#;
1273 for Y use at 16#3230#;
1274 m : Address := 16#4000#;
1275 n : constant Address := 4000;
1276 p : constant Address := Address (X + Y);
1277 v : Integer := y'Address;
1278 w : constant Integer := Integer (Y'Address);
1279 type R is new integer;
1282 for Z'Address use RR;
1287 Note that pragma @code{Allow_Integer_Address} is ignored if
1288 @code{System.Address}
1289 is not a private type. In implementations of @code{GNAT} where
1290 System.Address is a visible integer type (notably the implementations
1291 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1292 rather than rejected to allow common sets of sources to be used
1293 in the two situations.
1295 @node Pragma Annotate
1296 @unnumberedsec Pragma Annotate
1300 @smallexample @c ada
1301 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1303 ARG ::= NAME | EXPRESSION
1307 This pragma is used to annotate programs. @var{identifier} identifies
1308 the type of annotation. GNAT verifies that it is an identifier, but does
1309 not otherwise analyze it. The second optional identifier is also left
1310 unanalyzed, and by convention is used to control the action of the tool to
1311 which the annotation is addressed. The remaining @var{arg} arguments
1312 can be either string literals or more generally expressions.
1313 String literals are assumed to be either of type
1314 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1315 depending on the character literals they contain.
1316 All other kinds of arguments are analyzed as expressions, and must be
1319 The analyzed pragma is retained in the tree, but not otherwise processed
1320 by any part of the GNAT compiler, except to generate corresponding note
1321 lines in the generated ALI file. For the format of these note lines, see
1322 the compiler source file lib-writ.ads. This pragma is intended for use by
1323 external tools, including ASIS@. The use of pragma Annotate does not
1324 affect the compilation process in any way. This pragma may be used as
1325 a configuration pragma.
1328 @unnumberedsec Pragma Assert
1332 @smallexample @c ada
1335 [, string_EXPRESSION]);
1339 The effect of this pragma depends on whether the corresponding command
1340 line switch is set to activate assertions. The pragma expands into code
1341 equivalent to the following:
1343 @smallexample @c ada
1344 if assertions-enabled then
1345 if not boolean_EXPRESSION then
1346 System.Assertions.Raise_Assert_Failure
1347 (string_EXPRESSION);
1353 The string argument, if given, is the message that will be associated
1354 with the exception occurrence if the exception is raised. If no second
1355 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1356 where @var{file} is the name of the source file containing the assert,
1357 and @var{nnn} is the line number of the assert. A pragma is not a
1358 statement, so if a statement sequence contains nothing but a pragma
1359 assert, then a null statement is required in addition, as in:
1361 @smallexample @c ada
1364 pragma Assert (K > 3, "Bad value for K");
1370 Note that, as with the @code{if} statement to which it is equivalent, the
1371 type of the expression is either @code{Standard.Boolean}, or any type derived
1372 from this standard type.
1374 Assert checks can be either checked or ignored. By default they are ignored.
1375 They will be checked if either the command line switch @option{-gnata} is
1376 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1377 to enable @code{Assert_Checks}.
1379 If assertions are ignored, then there
1380 is no run-time effect (and in particular, any side effects from the
1381 expression will not occur at run time). (The expression is still
1382 analyzed at compile time, and may cause types to be frozen if they are
1383 mentioned here for the first time).
1385 If assertions are checked, then the given expression is tested, and if
1386 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1387 which results in the raising of @code{Assert_Failure} with the given message.
1389 You should generally avoid side effects in the expression arguments of
1390 this pragma, because these side effects will turn on and off with the
1391 setting of the assertions mode, resulting in assertions that have an
1392 effect on the program. However, the expressions are analyzed for
1393 semantic correctness whether or not assertions are enabled, so turning
1394 assertions on and off cannot affect the legality of a program.
1396 Note that the implementation defined policy @code{DISABLE}, given in a
1397 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1399 Note: this is a standard language-defined pragma in versions
1400 of Ada from 2005 on. In GNAT, it is implemented in all versions
1401 of Ada, and the DISABLE policy is an implementation-defined
1404 @node Pragma Assert_And_Cut
1405 @unnumberedsec Pragma Assert_And_Cut
1406 @findex Assert_And_Cut
1409 @smallexample @c ada
1410 pragma Assert_And_Cut (
1412 [, string_EXPRESSION]);
1416 The effect of this pragma is identical to that of pragma @code{Assert},
1417 except that in an @code{Assertion_Policy} pragma, the identifier
1418 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1421 The intention is that this be used within a subprogram when the
1422 given test expresion sums up all the work done so far in the
1423 subprogram, so that the rest of the subprogram can be verified
1424 (informally or formally) using only the entry preconditions,
1425 and the expression in this pragma. This allows dividing up
1426 a subprogram into sections for the purposes of testing or
1427 formal verification. The pragma also serves as useful
1430 @node Pragma Assertion_Policy
1431 @unnumberedsec Pragma Assertion_Policy
1432 @findex Assertion_Policy
1435 @smallexample @c ada
1436 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1438 pragma Assertion_Policy (
1439 ASSERTION_KIND => POLICY_IDENTIFIER
1440 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1442 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1444 RM_ASSERTION_KIND ::= Assert |
1452 Type_Invariant'Class
1454 ID_ASSERTION_KIND ::= Assertions |
1467 Statement_Assertions
1469 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1473 This is a standard Ada 2012 pragma that is available as an
1474 implementation-defined pragma in earlier versions of Ada.
1475 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1476 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1477 are implementation defined additions recognized by the GNAT compiler.
1479 The pragma applies in both cases to pragmas and aspects with matching
1480 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1481 applies to both the @code{Precondition} pragma
1482 and the aspect @code{Precondition}. Note that the identifiers for
1483 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1484 Pre_Class and Post_Class), since these pragmas are intended to be
1485 identical to the corresponding aspects).
1487 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1488 the corresponding pragma or aspect is activated.
1489 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1490 the corresponding pragma or aspect is deactivated.
1491 This pragma overrides the effect of the @option{-gnata} switch on the
1494 The implementation defined policy @code{DISABLE} is like
1495 @code{IGNORE} except that it completely disables semantic
1496 checking of the corresponding pragma or aspect. This is
1497 useful when the pragma or aspect argument references subprograms
1498 in a with'ed package which is replaced by a dummy package
1499 for the final build.
1501 The implementation defined policy @code{Assertions} applies to all
1502 assertion kinds. The form with no assertion kind given implies this
1503 choice, so it applies to all assertion kinds (RM defined, and
1504 implementation defined).
1506 The implementation defined policy @code{Statement_Assertions}
1507 applies to @code{Assert}, @code{Assert_And_Cut},
1508 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1511 @unnumberedsec Pragma Assume
1515 @smallexample @c ada
1518 [, string_EXPRESSION]);
1522 The effect of this pragma is identical to that of pragma @code{Assert},
1523 except that in an @code{Assertion_Policy} pragma, the identifier
1524 @code{Assume} is used to control whether it is ignored or checked
1527 The intention is that this be used for assumptions about the
1528 external environment. So you cannot expect to verify formally
1529 or informally that the condition is met, this must be
1530 established by examining things outside the program itself.
1531 For example, we may have code that depends on the size of
1532 @code{Long_Long_Integer} being at least 64. So we could write:
1534 @smallexample @c ada
1535 pragma Assume (Long_Long_Integer'Size >= 64);
1539 This assumption cannot be proved from the program itself,
1540 but it acts as a useful run-time check that the assumption
1541 is met, and documents the need to ensure that it is met by
1542 reference to information outside the program.
1544 @node Pragma Assume_No_Invalid_Values
1545 @unnumberedsec Pragma Assume_No_Invalid_Values
1546 @findex Assume_No_Invalid_Values
1547 @cindex Invalid representations
1548 @cindex Invalid values
1551 @smallexample @c ada
1552 pragma Assume_No_Invalid_Values (On | Off);
1556 This is a configuration pragma that controls the assumptions made by the
1557 compiler about the occurrence of invalid representations (invalid values)
1560 The default behavior (corresponding to an Off argument for this pragma), is
1561 to assume that values may in general be invalid unless the compiler can
1562 prove they are valid. Consider the following example:
1564 @smallexample @c ada
1565 V1 : Integer range 1 .. 10;
1566 V2 : Integer range 11 .. 20;
1568 for J in V2 .. V1 loop
1574 if V1 and V2 have valid values, then the loop is known at compile
1575 time not to execute since the lower bound must be greater than the
1576 upper bound. However in default mode, no such assumption is made,
1577 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1578 is given, the compiler will assume that any occurrence of a variable
1579 other than in an explicit @code{'Valid} test always has a valid
1580 value, and the loop above will be optimized away.
1582 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1583 you know your code is free of uninitialized variables and other
1584 possible sources of invalid representations, and may result in
1585 more efficient code. A program that accesses an invalid representation
1586 with this pragma in effect is erroneous, so no guarantees can be made
1589 It is peculiar though permissible to use this pragma in conjunction
1590 with validity checking (-gnatVa). In such cases, accessing invalid
1591 values will generally give an exception, though formally the program
1592 is erroneous so there are no guarantees that this will always be the
1593 case, and it is recommended that these two options not be used together.
1595 @node Pragma Ast_Entry
1596 @unnumberedsec Pragma Ast_Entry
1601 @smallexample @c ada
1602 pragma AST_Entry (entry_IDENTIFIER);
1606 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1607 argument is the simple name of a single entry; at most one @code{AST_Entry}
1608 pragma is allowed for any given entry. This pragma must be used in
1609 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1610 the entry declaration and in the same task type specification or single task
1611 as the entry to which it applies. This pragma specifies that the given entry
1612 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1613 resulting from an OpenVMS system service call. The pragma does not affect
1614 normal use of the entry. For further details on this pragma, see the
1615 DEC Ada Language Reference Manual, section 9.12a.
1617 @node Pragma Attribute_Definition
1618 @unnumberedsec Pragma Attribute_Definition
1619 @findex Attribute_Definition
1622 @smallexample @c ada
1623 pragma Attribute_Definition
1624 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1625 [Entity =>] LOCAL_NAME,
1626 [Expression =>] EXPRESSION | NAME);
1630 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1631 the attribute definition clause:
1633 @smallexample @c ada
1634 for Entity'Attribute use Expression;
1637 If @code{Attribute} is not a recognized attribute name, the pragma is
1638 ignored, and a warning is emitted. This allows source
1639 code to be written that takes advantage of some new attribute, while remaining
1640 compilable with earlier compilers.
1642 @node Pragma C_Pass_By_Copy
1643 @unnumberedsec Pragma C_Pass_By_Copy
1644 @cindex Passing by copy
1645 @findex C_Pass_By_Copy
1648 @smallexample @c ada
1649 pragma C_Pass_By_Copy
1650 ([Max_Size =>] static_integer_EXPRESSION);
1654 Normally the default mechanism for passing C convention records to C
1655 convention subprograms is to pass them by reference, as suggested by RM
1656 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1657 this default, by requiring that record formal parameters be passed by
1658 copy if all of the following conditions are met:
1662 The size of the record type does not exceed the value specified for
1665 The record type has @code{Convention C}.
1667 The formal parameter has this record type, and the subprogram has a
1668 foreign (non-Ada) convention.
1672 If these conditions are met the argument is passed by copy, i.e.@: in a
1673 manner consistent with what C expects if the corresponding formal in the
1674 C prototype is a struct (rather than a pointer to a struct).
1676 You can also pass records by copy by specifying the convention
1677 @code{C_Pass_By_Copy} for the record type, or by using the extended
1678 @code{Import} and @code{Export} pragmas, which allow specification of
1679 passing mechanisms on a parameter by parameter basis.
1682 @unnumberedsec Pragma Check
1684 @cindex Named assertions
1688 @smallexample @c ada
1690 [Name =>] CHECK_KIND,
1691 [Check =>] Boolean_EXPRESSION
1692 [, [Message =>] string_EXPRESSION] );
1694 CHECK_KIND ::= IDENTIFIER |
1697 Type_Invariant'Class |
1702 This pragma is similar to the predefined pragma @code{Assert} except that an
1703 extra identifier argument is present. In conjunction with pragma
1704 @code{Check_Policy}, this can be used to define groups of assertions that can
1705 be independently controlled. The identifier @code{Assertion} is special, it
1706 refers to the normal set of pragma @code{Assert} statements.
1708 Checks introduced by this pragma are normally deactivated by default. They can
1709 be activated either by the command line option @option{-gnata}, which turns on
1710 all checks, or individually controlled using pragma @code{Check_Policy}.
1712 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1713 permitted as check kinds, since this would cause confusion with the use
1714 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1715 pragmas, where they are used to refer to sets of assertions.
1717 @node Pragma Check_Float_Overflow
1718 @unnumberedsec Pragma Check_Float_Overflow
1719 @cindex Floating-point overflow
1720 @findex Check_Float_Overflow
1723 @smallexample @c ada
1724 pragma Check_Float_Overflow;
1728 In Ada, the predefined floating-point types (@code{Short_Float},
1729 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1730 defined to be @emph{unconstrained}. This means that even though each
1731 has a well-defined base range, an operation that delivers a result
1732 outside this base range is not required to raise an exception.
1733 This implementation permission accommodates the notion
1734 of infinities in IEEE floating-point, and corresponds to the
1735 efficient execution mode on most machines. GNAT will not raise
1736 overflow exceptions on these machines; instead it will generate
1737 infinities and NaN's as defined in the IEEE standard.
1739 Generating infinities, although efficient, is not always desirable.
1740 Often the preferable approach is to check for overflow, even at the
1741 (perhaps considerable) expense of run-time performance.
1742 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1743 range constraints -- and indeed such a subtype
1744 can have the same base range as its base type. For example:
1746 @smallexample @c ada
1747 subtype My_Float is Float range Float'Range;
1751 Here @code{My_Float} has the same range as
1752 @code{Float} but is constrained, so operations on
1753 @code{My_Float} values will be checked for overflow
1756 This style will achieve the desired goal, but
1757 it is often more convenient to be able to simply use
1758 the standard predefined floating-point types as long
1759 as overflow checking could be guaranteed.
1760 The @code{Check_Float_Overflow}
1761 configuration pragma achieves this effect. If a unit is compiled
1762 subject to this configuration pragma, then all operations
1763 on predefined floating-point types will be treated as
1764 though those types were constrained, and overflow checks
1765 will be generated. The @code{Constraint_Error}
1766 exception is raised if the result is out of range.
1768 This mode can also be set by use of the compiler
1769 switch @option{-gnateF}.
1771 @node Pragma Check_Name
1772 @unnumberedsec Pragma Check_Name
1773 @cindex Defining check names
1774 @cindex Check names, defining
1778 @smallexample @c ada
1779 pragma Check_Name (check_name_IDENTIFIER);
1783 This is a configuration pragma that defines a new implementation
1784 defined check name (unless IDENTIFIER matches one of the predefined
1785 check names, in which case the pragma has no effect). Check names
1786 are global to a partition, so if two or more configuration pragmas
1787 are present in a partition mentioning the same name, only one new
1788 check name is introduced.
1790 An implementation defined check name introduced with this pragma may
1791 be used in only three contexts: @code{pragma Suppress},
1792 @code{pragma Unsuppress},
1793 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1794 any of these three cases, the check name must be visible. A check
1795 name is visible if it is in the configuration pragmas applying to
1796 the current unit, or if it appears at the start of any unit that
1797 is part of the dependency set of the current unit (e.g., units that
1798 are mentioned in @code{with} clauses).
1800 Check names introduced by this pragma are subject to control by compiler
1801 switches (in particular -gnatp) in the usual manner.
1803 @node Pragma Check_Policy
1804 @unnumberedsec Pragma Check_Policy
1805 @cindex Controlling assertions
1806 @cindex Assertions, control
1807 @cindex Check pragma control
1808 @cindex Named assertions
1812 @smallexample @c ada
1814 ([Name =>] CHECK_KIND,
1815 [Policy =>] POLICY_IDENTIFIER);
1817 pragma Check_Policy (
1818 CHECK_KIND => POLICY_IDENTIFIER
1819 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1821 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1823 CHECK_KIND ::= IDENTIFIER |
1826 Type_Invariant'Class |
1829 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1830 avoids confusion between the two possible syntax forms for this pragma.
1832 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1836 This pragma is used to set the checking policy for assertions (specified
1837 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1838 to be checked using the @code{Check} pragma. It may appear either as
1839 a configuration pragma, or within a declarative part of package. In the
1840 latter case, it applies from the point where it appears to the end of
1841 the declarative region (like pragma @code{Suppress}).
1843 The @code{Check_Policy} pragma is similar to the
1844 predefined @code{Assertion_Policy} pragma,
1845 and if the check kind corresponds to one of the assertion kinds that
1846 are allowed by @code{Assertion_Policy}, then the effect is identical.
1848 If the first argument is Debug, then the policy applies to Debug pragmas,
1849 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1850 @code{IGNORE}, and allowing them to execute with normal semantics if
1851 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1852 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1853 be totally ignored and not analyzed semantically.
1855 Finally the first argument may be some other identifier than the above
1856 possibilities, in which case it controls a set of named assertions
1857 that can be checked using pragma @code{Check}. For example, if the pragma:
1859 @smallexample @c ada
1860 pragma Check_Policy (Critical_Error, OFF);
1864 is given, then subsequent @code{Check} pragmas whose first argument is also
1865 @code{Critical_Error} will be disabled.
1867 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1868 to turn on corresponding checks. The default for a set of checks for which no
1869 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1870 @option{-gnata} is given, which turns on all checks by default.
1872 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1873 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1874 compatibility with the standard @code{Assertion_Policy} pragma. The check
1875 policy setting @code{DISABLE} causes the second argument of a corresponding
1876 @code{Check} pragma to be completely ignored and not analyzed.
1878 @node Pragma CIL_Constructor
1879 @unnumberedsec Pragma CIL_Constructor
1880 @findex CIL_Constructor
1884 @smallexample @c ada
1885 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1889 This pragma is used to assert that the specified Ada function should be
1890 mapped to the .NET constructor for some Ada tagged record type.
1892 See section 4.1 of the
1893 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1894 for related information.
1896 @node Pragma Comment
1897 @unnumberedsec Pragma Comment
1902 @smallexample @c ada
1903 pragma Comment (static_string_EXPRESSION);
1907 This is almost identical in effect to pragma @code{Ident}. It allows the
1908 placement of a comment into the object file and hence into the
1909 executable file if the operating system permits such usage. The
1910 difference is that @code{Comment}, unlike @code{Ident}, has
1911 no limitations on placement of the pragma (it can be placed
1912 anywhere in the main source unit), and if more than one pragma
1913 is used, all comments are retained.
1915 @node Pragma Common_Object
1916 @unnumberedsec Pragma Common_Object
1917 @findex Common_Object
1921 @smallexample @c ada
1922 pragma Common_Object (
1923 [Internal =>] LOCAL_NAME
1924 [, [External =>] EXTERNAL_SYMBOL]
1925 [, [Size =>] EXTERNAL_SYMBOL] );
1929 | static_string_EXPRESSION
1933 This pragma enables the shared use of variables stored in overlaid
1934 linker areas corresponding to the use of @code{COMMON}
1935 in Fortran. The single
1936 object @var{LOCAL_NAME} is assigned to the area designated by
1937 the @var{External} argument.
1938 You may define a record to correspond to a series
1939 of fields. The @var{Size} argument
1940 is syntax checked in GNAT, but otherwise ignored.
1942 @code{Common_Object} is not supported on all platforms. If no
1943 support is available, then the code generator will issue a message
1944 indicating that the necessary attribute for implementation of this
1945 pragma is not available.
1947 @node Pragma Compile_Time_Error
1948 @unnumberedsec Pragma Compile_Time_Error
1949 @findex Compile_Time_Error
1953 @smallexample @c ada
1954 pragma Compile_Time_Error
1955 (boolean_EXPRESSION, static_string_EXPRESSION);
1959 This pragma can be used to generate additional compile time
1961 is particularly useful in generics, where errors can be issued for
1962 specific problematic instantiations. The first parameter is a boolean
1963 expression. The pragma is effective only if the value of this expression
1964 is known at compile time, and has the value True. The set of expressions
1965 whose values are known at compile time includes all static boolean
1966 expressions, and also other values which the compiler can determine
1967 at compile time (e.g., the size of a record type set by an explicit
1968 size representation clause, or the value of a variable which was
1969 initialized to a constant and is known not to have been modified).
1970 If these conditions are met, an error message is generated using
1971 the value given as the second argument. This string value may contain
1972 embedded ASCII.LF characters to break the message into multiple lines.
1974 @node Pragma Compile_Time_Warning
1975 @unnumberedsec Pragma Compile_Time_Warning
1976 @findex Compile_Time_Warning
1980 @smallexample @c ada
1981 pragma Compile_Time_Warning
1982 (boolean_EXPRESSION, static_string_EXPRESSION);
1986 Same as pragma Compile_Time_Error, except a warning is issued instead
1987 of an error message. Note that if this pragma is used in a package that
1988 is with'ed by a client, the client will get the warning even though it
1989 is issued by a with'ed package (normally warnings in with'ed units are
1990 suppressed, but this is a special exception to that rule).
1992 One typical use is within a generic where compile time known characteristics
1993 of formal parameters are tested, and warnings given appropriately. Another use
1994 with a first parameter of True is to warn a client about use of a package,
1995 for example that it is not fully implemented.
1997 @node Pragma Compiler_Unit
1998 @unnumberedsec Pragma Compiler_Unit
1999 @findex Compiler_Unit
2003 @smallexample @c ada
2004 pragma Compiler_Unit;
2008 This pragma is intended only for internal use in the GNAT run-time library.
2009 It indicates that the unit is used as part of the compiler build. The effect
2010 is to disallow constructs (raise with message, conditional expressions etc)
2011 that would cause trouble when bootstrapping using an older version of GNAT.
2012 For the exact list of restrictions, see the compiler sources and references
2013 to Is_Compiler_Unit.
2015 @node Pragma Complete_Representation
2016 @unnumberedsec Pragma Complete_Representation
2017 @findex Complete_Representation
2021 @smallexample @c ada
2022 pragma Complete_Representation;
2026 This pragma must appear immediately within a record representation
2027 clause. Typical placements are before the first component clause
2028 or after the last component clause. The effect is to give an error
2029 message if any component is missing a component clause. This pragma
2030 may be used to ensure that a record representation clause is
2031 complete, and that this invariant is maintained if fields are
2032 added to the record in the future.
2034 @node Pragma Complex_Representation
2035 @unnumberedsec Pragma Complex_Representation
2036 @findex Complex_Representation
2040 @smallexample @c ada
2041 pragma Complex_Representation
2042 ([Entity =>] LOCAL_NAME);
2046 The @var{Entity} argument must be the name of a record type which has
2047 two fields of the same floating-point type. The effect of this pragma is
2048 to force gcc to use the special internal complex representation form for
2049 this record, which may be more efficient. Note that this may result in
2050 the code for this type not conforming to standard ABI (application
2051 binary interface) requirements for the handling of record types. For
2052 example, in some environments, there is a requirement for passing
2053 records by pointer, and the use of this pragma may result in passing
2054 this type in floating-point registers.
2056 @node Pragma Component_Alignment
2057 @unnumberedsec Pragma Component_Alignment
2058 @cindex Alignments of components
2059 @findex Component_Alignment
2063 @smallexample @c ada
2064 pragma Component_Alignment (
2065 [Form =>] ALIGNMENT_CHOICE
2066 [, [Name =>] type_LOCAL_NAME]);
2068 ALIGNMENT_CHOICE ::=
2076 Specifies the alignment of components in array or record types.
2077 The meaning of the @var{Form} argument is as follows:
2080 @findex Component_Size
2081 @item Component_Size
2082 Aligns scalar components and subcomponents of the array or record type
2083 on boundaries appropriate to their inherent size (naturally
2084 aligned). For example, 1-byte components are aligned on byte boundaries,
2085 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2086 integer components are aligned on 4-byte boundaries and so on. These
2087 alignment rules correspond to the normal rules for C compilers on all
2088 machines except the VAX@.
2090 @findex Component_Size_4
2091 @item Component_Size_4
2092 Naturally aligns components with a size of four or fewer
2093 bytes. Components that are larger than 4 bytes are placed on the next
2096 @findex Storage_Unit
2098 Specifies that array or record components are byte aligned, i.e.@:
2099 aligned on boundaries determined by the value of the constant
2100 @code{System.Storage_Unit}.
2104 Specifies that array or record components are aligned on default
2105 boundaries, appropriate to the underlying hardware or operating system or
2106 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2107 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2108 the @code{Default} choice is the same as @code{Component_Size} (natural
2113 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2114 refer to a local record or array type, and the specified alignment
2115 choice applies to the specified type. The use of
2116 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2117 @code{Component_Alignment} pragma to be ignored. The use of
2118 @code{Component_Alignment} together with a record representation clause
2119 is only effective for fields not specified by the representation clause.
2121 If the @code{Name} parameter is absent, the pragma can be used as either
2122 a configuration pragma, in which case it applies to one or more units in
2123 accordance with the normal rules for configuration pragmas, or it can be
2124 used within a declarative part, in which case it applies to types that
2125 are declared within this declarative part, or within any nested scope
2126 within this declarative part. In either case it specifies the alignment
2127 to be applied to any record or array type which has otherwise standard
2130 If the alignment for a record or array type is not specified (using
2131 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2132 clause), the GNAT uses the default alignment as described previously.
2134 @node Pragma Contract_Cases
2135 @unnumberedsec Pragma Contract_Cases
2136 @cindex Contract cases
2137 @findex Contract_Cases
2141 @smallexample @c ada
2142 pragma Contract_Cases (
2143 Condition => Consequence
2144 @{,Condition => Consequence@});
2148 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2149 that can complement or replace the contract given by a precondition and a
2150 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2151 by testing and formal verification tools. The compiler checks its validity and,
2152 depending on the assertion policy at the point of declaration of the pragma,
2153 it may insert a check in the executable. For code generation, the contract
2156 @smallexample @c ada
2157 pragma Contract_Cases (
2165 @smallexample @c ada
2166 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2167 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2168 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2169 pragma Postcondition (if C1 then Pred1);
2170 pragma Postcondition (if C2 then Pred2);
2174 The precondition ensures that one and only one of the conditions is
2175 satisfied on entry to the subprogram.
2176 The postcondition ensures that for the condition that was True on entry,
2177 the corrresponding consequence is True on exit. Other consequence expressions
2180 A precondition @code{P} and postcondition @code{Q} can also be
2181 expressed as contract cases:
2183 @smallexample @c ada
2184 pragma Contract_Cases (P => Q);
2187 The placement and visibility rules for @code{Contract_Cases} pragmas are
2188 identical to those described for preconditions and postconditions.
2190 The compiler checks that boolean expressions given in conditions and
2191 consequences are valid, where the rules for conditions are the same as
2192 the rule for an expression in @code{Precondition} and the rules for
2193 consequences are the same as the rule for an expression in
2194 @code{Postcondition}. In particular, attributes @code{'Old} and
2195 @code{'Result} can only be used within consequence expressions.
2196 The condition for the last contract case may be @code{others}, to denote
2197 any case not captured by the previous cases. The
2198 following is an example of use within a package spec:
2200 @smallexample @c ada
2201 package Math_Functions is
2203 function Sqrt (Arg : Float) return Float;
2204 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2205 Arg >= 100 => Sqrt'Result >= 10,
2206 others => Sqrt'Result = 0);
2212 The meaning of contract cases is that only one case should apply at each
2213 call, as determined by the corresponding condition evaluating to True,
2214 and that the consequence for this case should hold when the subprogram
2217 @node Pragma Convention_Identifier
2218 @unnumberedsec Pragma Convention_Identifier
2219 @findex Convention_Identifier
2220 @cindex Conventions, synonyms
2224 @smallexample @c ada
2225 pragma Convention_Identifier (
2226 [Name =>] IDENTIFIER,
2227 [Convention =>] convention_IDENTIFIER);
2231 This pragma provides a mechanism for supplying synonyms for existing
2232 convention identifiers. The @code{Name} identifier can subsequently
2233 be used as a synonym for the given convention in other pragmas (including
2234 for example pragma @code{Import} or another @code{Convention_Identifier}
2235 pragma). As an example of the use of this, suppose you had legacy code
2236 which used Fortran77 as the identifier for Fortran. Then the pragma:
2238 @smallexample @c ada
2239 pragma Convention_Identifier (Fortran77, Fortran);
2243 would allow the use of the convention identifier @code{Fortran77} in
2244 subsequent code, avoiding the need to modify the sources. As another
2245 example, you could use this to parameterize convention requirements
2246 according to systems. Suppose you needed to use @code{Stdcall} on
2247 windows systems, and @code{C} on some other system, then you could
2248 define a convention identifier @code{Library} and use a single
2249 @code{Convention_Identifier} pragma to specify which convention
2250 would be used system-wide.
2252 @node Pragma CPP_Class
2253 @unnumberedsec Pragma CPP_Class
2255 @cindex Interfacing with C++
2259 @smallexample @c ada
2260 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2264 The argument denotes an entity in the current declarative region that is
2265 declared as a record type. It indicates that the type corresponds to an
2266 externally declared C++ class type, and is to be laid out the same way
2267 that C++ would lay out the type. If the C++ class has virtual primitives
2268 then the record must be declared as a tagged record type.
2270 Types for which @code{CPP_Class} is specified do not have assignment or
2271 equality operators defined (such operations can be imported or declared
2272 as subprograms as required). Initialization is allowed only by constructor
2273 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2274 limited if not explicitly declared as limited or derived from a limited
2275 type, and an error is issued in that case.
2277 See @ref{Interfacing to C++} for related information.
2279 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2280 for backward compatibility but its functionality is available
2281 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2283 @node Pragma CPP_Constructor
2284 @unnumberedsec Pragma CPP_Constructor
2285 @cindex Interfacing with C++
2286 @findex CPP_Constructor
2290 @smallexample @c ada
2291 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2292 [, [External_Name =>] static_string_EXPRESSION ]
2293 [, [Link_Name =>] static_string_EXPRESSION ]);
2297 This pragma identifies an imported function (imported in the usual way
2298 with pragma @code{Import}) as corresponding to a C++ constructor. If
2299 @code{External_Name} and @code{Link_Name} are not specified then the
2300 @code{Entity} argument is a name that must have been previously mentioned
2301 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2302 must be of one of the following forms:
2306 @code{function @var{Fname} return @var{T}}
2310 @code{function @var{Fname} return @var{T}'Class}
2313 @code{function @var{Fname} (@dots{}) return @var{T}}
2317 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2321 where @var{T} is a limited record type imported from C++ with pragma
2322 @code{Import} and @code{Convention} = @code{CPP}.
2324 The first two forms import the default constructor, used when an object
2325 of type @var{T} is created on the Ada side with no explicit constructor.
2326 The latter two forms cover all the non-default constructors of the type.
2327 See the @value{EDITION} User's Guide for details.
2329 If no constructors are imported, it is impossible to create any objects
2330 on the Ada side and the type is implicitly declared abstract.
2332 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2333 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2335 See @ref{Interfacing to C++} for more related information.
2337 Note: The use of functions returning class-wide types for constructors is
2338 currently obsolete. They are supported for backward compatibility. The
2339 use of functions returning the type T leave the Ada sources more clear
2340 because the imported C++ constructors always return an object of type T;
2341 that is, they never return an object whose type is a descendant of type T.
2343 @node Pragma CPP_Virtual
2344 @unnumberedsec Pragma CPP_Virtual
2345 @cindex Interfacing to C++
2348 This pragma is now obsolete and, other than generating a warning if warnings
2349 on obsolescent features are enabled, is completely ignored.
2350 It is retained for compatibility
2351 purposes. It used to be required to ensure compoatibility with C++, but
2352 is no longer required for that purpose because GNAT generates
2353 the same object layout as the G++ compiler by default.
2355 See @ref{Interfacing to C++} for related information.
2357 @node Pragma CPP_Vtable
2358 @unnumberedsec Pragma CPP_Vtable
2359 @cindex Interfacing with C++
2362 This pragma is now obsolete and, other than generating a warning if warnings
2363 on obsolescent features are enabled, is completely ignored.
2364 It used to be required to ensure compatibility with C++, but
2365 is no longer required for that purpose because GNAT generates
2366 the same object layout than the G++ compiler by default.
2368 See @ref{Interfacing to C++} for related information.
2371 @unnumberedsec Pragma CPU
2376 @smallexample @c ada
2377 pragma CPU (EXPRESSION);
2381 This pragma is standard in Ada 2012, but is available in all earlier
2382 versions of Ada as an implementation-defined pragma.
2383 See Ada 2012 Reference Manual for details.
2386 @unnumberedsec Pragma Debug
2391 @smallexample @c ada
2392 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2394 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2396 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2400 The procedure call argument has the syntactic form of an expression, meeting
2401 the syntactic requirements for pragmas.
2403 If debug pragmas are not enabled or if the condition is present and evaluates
2404 to False, this pragma has no effect. If debug pragmas are enabled, the
2405 semantics of the pragma is exactly equivalent to the procedure call statement
2406 corresponding to the argument with a terminating semicolon. Pragmas are
2407 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2408 intersperse calls to debug procedures in the middle of declarations. Debug
2409 pragmas can be enabled either by use of the command line switch @option{-gnata}
2410 or by use of the pragma @code{Check_Policy} with a first argument of
2413 @node Pragma Debug_Policy
2414 @unnumberedsec Pragma Debug_Policy
2415 @findex Debug_Policy
2419 @smallexample @c ada
2420 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2424 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2425 with a first argument of @code{Debug}. It is retained for historical
2426 compatibility reasons.
2428 @node Pragma Default_Storage_Pool
2429 @unnumberedsec Pragma Default_Storage_Pool
2430 @findex Default_Storage_Pool
2434 @smallexample @c ada
2435 pragma Default_Storage_Pool (storage_pool_NAME | null);
2439 This pragma is standard in Ada 2012, but is available in all earlier
2440 versions of Ada as an implementation-defined pragma.
2441 See Ada 2012 Reference Manual for details.
2443 @node Pragma Depends
2444 @unnumberedsec Pragma Depends
2447 For the description of this pragma, see SPARK 2014 Reference Manual,
2450 @node Pragma Detect_Blocking
2451 @unnumberedsec Pragma Detect_Blocking
2452 @findex Detect_Blocking
2456 @smallexample @c ada
2457 pragma Detect_Blocking;
2461 This is a standard pragma in Ada 2005, that is available in all earlier
2462 versions of Ada as an implementation-defined pragma.
2464 This is a configuration pragma that forces the detection of potentially
2465 blocking operations within a protected operation, and to raise Program_Error
2468 @node Pragma Disable_Atomic_Synchronization
2469 @unnumberedsec Pragma Disable_Atomic_Synchronization
2470 @cindex Atomic Synchronization
2471 @findex Disable_Atomic_Synchronization
2475 @smallexample @c ada
2476 pragma Disable_Atomic_Synchronization [(Entity)];
2480 Ada requires that accesses (reads or writes) of an atomic variable be
2481 regarded as synchronization points in the case of multiple tasks.
2482 Particularly in the case of multi-processors this may require special
2483 handling, e.g. the generation of memory barriers. This capability may
2484 be turned off using this pragma in cases where it is known not to be
2487 The placement and scope rules for this pragma are the same as those
2488 for @code{pragma Suppress}. In particular it can be used as a
2489 configuration pragma, or in a declaration sequence where it applies
2490 till the end of the scope. If an @code{Entity} argument is present,
2491 the action applies only to that entity.
2493 @node Pragma Dispatching_Domain
2494 @unnumberedsec Pragma Dispatching_Domain
2495 @findex Dispatching_Domain
2499 @smallexample @c ada
2500 pragma Dispatching_Domain (EXPRESSION);
2504 This pragma is standard in Ada 2012, but is available in all earlier
2505 versions of Ada as an implementation-defined pragma.
2506 See Ada 2012 Reference Manual for details.
2508 @node Pragma Elaboration_Checks
2509 @unnumberedsec Pragma Elaboration_Checks
2510 @cindex Elaboration control
2511 @findex Elaboration_Checks
2515 @smallexample @c ada
2516 pragma Elaboration_Checks (Dynamic | Static);
2520 This is a configuration pragma that provides control over the
2521 elaboration model used by the compilation affected by the
2522 pragma. If the parameter is @code{Dynamic},
2523 then the dynamic elaboration
2524 model described in the Ada Reference Manual is used, as though
2525 the @option{-gnatE} switch had been specified on the command
2526 line. If the parameter is @code{Static}, then the default GNAT static
2527 model is used. This configuration pragma overrides the setting
2528 of the command line. For full details on the elaboration models
2529 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2530 gnat_ugn, @value{EDITION} User's Guide}.
2532 @node Pragma Eliminate
2533 @unnumberedsec Pragma Eliminate
2534 @cindex Elimination of unused subprograms
2539 @smallexample @c ada
2540 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2541 [Source_Location =>] STRING_LITERAL);
2545 The string literal given for the source location is a string which
2546 specifies the line number of the occurrence of the entity, using
2547 the syntax for SOURCE_TRACE given below:
2549 @smallexample @c ada
2550 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2555 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2557 LINE_NUMBER ::= DIGIT @{DIGIT@}
2561 Spaces around the colon in a @code{Source_Reference} are optional.
2563 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2564 explicit subprogram declaration, where the @code{entity} name in this
2565 designator appears on the source line specified by the source location.
2567 The source trace that is given as the @code{Source_Location} shall obey the
2568 following rules. The @code{FILE_NAME} is the short name (with no directory
2569 information) of an Ada source file, given using exactly the required syntax
2570 for the underlying file system (e.g. case is important if the underlying
2571 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2572 number of the occurrence of the @code{entity}
2573 as a decimal literal without an exponent or point. If an @code{entity} is not
2574 declared in a generic instantiation (this includes generic subprogram
2575 instances), the source trace includes only one source reference. If an entity
2576 is declared inside a generic instantiation, its source trace (when parsing
2577 from left to right) starts with the source location of the declaration of the
2578 entity in the generic unit and ends with the source location of the
2579 instantiation (it is given in square brackets). This approach is recursively
2580 used in case of nested instantiations: the rightmost (nested most deeply in
2581 square brackets) element of the source trace is the location of the outermost
2582 instantiation, the next to left element is the location of the next (first
2583 nested) instantiation in the code of the corresponding generic unit, and so
2584 on, and the leftmost element (that is out of any square brackets) is the
2585 location of the declaration of the entity to eliminate in a generic unit.
2587 Note that the @code{Source_Location} argument specifies which of a set of
2588 similarly named entities is being eliminated, dealing both with overloading,
2589 and also appearance of the same entity name in different scopes.
2591 This pragma indicates that the given entity is not used in the program to be
2592 compiled and built. The effect of the pragma is to allow the compiler to
2593 eliminate the code or data associated with the named entity. Any reference to
2594 an eliminated entity causes a compile-time or link-time error.
2596 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2597 in a system-independent manner, with unused entities eliminated, without
2598 needing to modify the source text. Normally the required set of
2599 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2601 Any source file change that removes, splits, or
2602 adds lines may make the set of Eliminate pragmas invalid because their
2603 @code{Source_Location} argument values may get out of date.
2605 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2606 operation. In this case all the subprograms to which the given operation can
2607 dispatch are considered to be unused (are never called as a result of a direct
2608 or a dispatching call).
2610 @node Pragma Enable_Atomic_Synchronization
2611 @unnumberedsec Pragma Enable_Atomic_Synchronization
2612 @cindex Atomic Synchronization
2613 @findex Enable_Atomic_Synchronization
2617 @smallexample @c ada
2618 pragma Enable_Atomic_Synchronization [(Entity)];
2622 Ada requires that accesses (reads or writes) of an atomic variable be
2623 regarded as synchronization points in the case of multiple tasks.
2624 Particularly in the case of multi-processors this may require special
2625 handling, e.g. the generation of memory barriers. This synchronization
2626 is performed by default, but can be turned off using
2627 @code{pragma Disable_Atomic_Synchronization}. The
2628 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2631 The placement and scope rules for this pragma are the same as those
2632 for @code{pragma Unsuppress}. In particular it can be used as a
2633 configuration pragma, or in a declaration sequence where it applies
2634 till the end of the scope. If an @code{Entity} argument is present,
2635 the action applies only to that entity.
2637 @node Pragma Export_Exception
2638 @unnumberedsec Pragma Export_Exception
2640 @findex Export_Exception
2644 @smallexample @c ada
2645 pragma Export_Exception (
2646 [Internal =>] LOCAL_NAME
2647 [, [External =>] EXTERNAL_SYMBOL]
2648 [, [Form =>] Ada | VMS]
2649 [, [Code =>] static_integer_EXPRESSION]);
2653 | static_string_EXPRESSION
2657 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2658 causes the specified exception to be propagated outside of the Ada program,
2659 so that it can be handled by programs written in other OpenVMS languages.
2660 This pragma establishes an external name for an Ada exception and makes the
2661 name available to the OpenVMS Linker as a global symbol. For further details
2662 on this pragma, see the
2663 DEC Ada Language Reference Manual, section 13.9a3.2.
2665 @node Pragma Export_Function
2666 @unnumberedsec Pragma Export_Function
2667 @cindex Argument passing mechanisms
2668 @findex Export_Function
2673 @smallexample @c ada
2674 pragma Export_Function (
2675 [Internal =>] LOCAL_NAME
2676 [, [External =>] EXTERNAL_SYMBOL]
2677 [, [Parameter_Types =>] PARAMETER_TYPES]
2678 [, [Result_Type =>] result_SUBTYPE_MARK]
2679 [, [Mechanism =>] MECHANISM]
2680 [, [Result_Mechanism =>] MECHANISM_NAME]);
2684 | static_string_EXPRESSION
2689 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2693 | subtype_Name ' Access
2697 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2699 MECHANISM_ASSOCIATION ::=
2700 [formal_parameter_NAME =>] MECHANISM_NAME
2705 | Descriptor [([Class =>] CLASS_NAME)]
2706 | Short_Descriptor [([Class =>] CLASS_NAME)]
2708 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2712 Use this pragma to make a function externally callable and optionally
2713 provide information on mechanisms to be used for passing parameter and
2714 result values. We recommend, for the purposes of improving portability,
2715 this pragma always be used in conjunction with a separate pragma
2716 @code{Export}, which must precede the pragma @code{Export_Function}.
2717 GNAT does not require a separate pragma @code{Export}, but if none is
2718 present, @code{Convention Ada} is assumed, which is usually
2719 not what is wanted, so it is usually appropriate to use this
2720 pragma in conjunction with a @code{Export} or @code{Convention}
2721 pragma that specifies the desired foreign convention.
2722 Pragma @code{Export_Function}
2723 (and @code{Export}, if present) must appear in the same declarative
2724 region as the function to which they apply.
2726 @var{internal_name} must uniquely designate the function to which the
2727 pragma applies. If more than one function name exists of this name in
2728 the declarative part you must use the @code{Parameter_Types} and
2729 @code{Result_Type} parameters is mandatory to achieve the required
2730 unique designation. @var{subtype_mark}s in these parameters must
2731 exactly match the subtypes in the corresponding function specification,
2732 using positional notation to match parameters with subtype marks.
2733 The form with an @code{'Access} attribute can be used to match an
2734 anonymous access parameter.
2737 @cindex Passing by descriptor
2738 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2739 The default behavior for Export_Function is to accept either 64bit or
2740 32bit descriptors unless short_descriptor is specified, then only 32bit
2741 descriptors are accepted.
2743 @cindex Suppressing external name
2744 Special treatment is given if the EXTERNAL is an explicit null
2745 string or a static string expressions that evaluates to the null
2746 string. In this case, no external name is generated. This form
2747 still allows the specification of parameter mechanisms.
2749 @node Pragma Export_Object
2750 @unnumberedsec Pragma Export_Object
2751 @findex Export_Object
2755 @smallexample @c ada
2756 pragma Export_Object
2757 [Internal =>] LOCAL_NAME
2758 [, [External =>] EXTERNAL_SYMBOL]
2759 [, [Size =>] EXTERNAL_SYMBOL]
2763 | static_string_EXPRESSION
2767 This pragma designates an object as exported, and apart from the
2768 extended rules for external symbols, is identical in effect to the use of
2769 the normal @code{Export} pragma applied to an object. You may use a
2770 separate Export pragma (and you probably should from the point of view
2771 of portability), but it is not required. @var{Size} is syntax checked,
2772 but otherwise ignored by GNAT@.
2774 @node Pragma Export_Procedure
2775 @unnumberedsec Pragma Export_Procedure
2776 @findex Export_Procedure
2780 @smallexample @c ada
2781 pragma Export_Procedure (
2782 [Internal =>] LOCAL_NAME
2783 [, [External =>] EXTERNAL_SYMBOL]
2784 [, [Parameter_Types =>] PARAMETER_TYPES]
2785 [, [Mechanism =>] MECHANISM]);
2789 | static_string_EXPRESSION
2794 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2798 | subtype_Name ' Access
2802 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2804 MECHANISM_ASSOCIATION ::=
2805 [formal_parameter_NAME =>] MECHANISM_NAME
2810 | Descriptor [([Class =>] CLASS_NAME)]
2811 | Short_Descriptor [([Class =>] CLASS_NAME)]
2813 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2817 This pragma is identical to @code{Export_Function} except that it
2818 applies to a procedure rather than a function and the parameters
2819 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2820 GNAT does not require a separate pragma @code{Export}, but if none is
2821 present, @code{Convention Ada} is assumed, which is usually
2822 not what is wanted, so it is usually appropriate to use this
2823 pragma in conjunction with a @code{Export} or @code{Convention}
2824 pragma that specifies the desired foreign convention.
2827 @cindex Passing by descriptor
2828 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2829 The default behavior for Export_Procedure is to accept either 64bit or
2830 32bit descriptors unless short_descriptor is specified, then only 32bit
2831 descriptors are accepted.
2833 @cindex Suppressing external name
2834 Special treatment is given if the EXTERNAL is an explicit null
2835 string or a static string expressions that evaluates to the null
2836 string. In this case, no external name is generated. This form
2837 still allows the specification of parameter mechanisms.
2839 @node Pragma Export_Value
2840 @unnumberedsec Pragma Export_Value
2841 @findex Export_Value
2845 @smallexample @c ada
2846 pragma Export_Value (
2847 [Value =>] static_integer_EXPRESSION,
2848 [Link_Name =>] static_string_EXPRESSION);
2852 This pragma serves to export a static integer value for external use.
2853 The first argument specifies the value to be exported. The Link_Name
2854 argument specifies the symbolic name to be associated with the integer
2855 value. This pragma is useful for defining a named static value in Ada
2856 that can be referenced in assembly language units to be linked with
2857 the application. This pragma is currently supported only for the
2858 AAMP target and is ignored for other targets.
2860 @node Pragma Export_Valued_Procedure
2861 @unnumberedsec Pragma Export_Valued_Procedure
2862 @findex Export_Valued_Procedure
2866 @smallexample @c ada
2867 pragma Export_Valued_Procedure (
2868 [Internal =>] LOCAL_NAME
2869 [, [External =>] EXTERNAL_SYMBOL]
2870 [, [Parameter_Types =>] PARAMETER_TYPES]
2871 [, [Mechanism =>] MECHANISM]);
2875 | static_string_EXPRESSION
2880 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2884 | subtype_Name ' Access
2888 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2890 MECHANISM_ASSOCIATION ::=
2891 [formal_parameter_NAME =>] MECHANISM_NAME
2896 | Descriptor [([Class =>] CLASS_NAME)]
2897 | Short_Descriptor [([Class =>] CLASS_NAME)]
2899 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2903 This pragma is identical to @code{Export_Procedure} except that the
2904 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2905 mode @code{OUT}, and externally the subprogram is treated as a function
2906 with this parameter as the result of the function. GNAT provides for
2907 this capability to allow the use of @code{OUT} and @code{IN OUT}
2908 parameters in interfacing to external functions (which are not permitted
2910 GNAT does not require a separate pragma @code{Export}, but if none is
2911 present, @code{Convention Ada} is assumed, which is almost certainly
2912 not what is wanted since the whole point of this pragma is to interface
2913 with foreign language functions, so it is usually appropriate to use this
2914 pragma in conjunction with a @code{Export} or @code{Convention}
2915 pragma that specifies the desired foreign convention.
2918 @cindex Passing by descriptor
2919 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2920 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2921 32bit descriptors unless short_descriptor is specified, then only 32bit
2922 descriptors are accepted.
2924 @cindex Suppressing external name
2925 Special treatment is given if the EXTERNAL is an explicit null
2926 string or a static string expressions that evaluates to the null
2927 string. In this case, no external name is generated. This form
2928 still allows the specification of parameter mechanisms.
2930 @node Pragma Extend_System
2931 @unnumberedsec Pragma Extend_System
2932 @cindex @code{system}, extending
2934 @findex Extend_System
2938 @smallexample @c ada
2939 pragma Extend_System ([Name =>] IDENTIFIER);
2943 This pragma is used to provide backwards compatibility with other
2944 implementations that extend the facilities of package @code{System}. In
2945 GNAT, @code{System} contains only the definitions that are present in
2946 the Ada RM@. However, other implementations, notably the DEC Ada 83
2947 implementation, provide many extensions to package @code{System}.
2949 For each such implementation accommodated by this pragma, GNAT provides a
2950 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2951 implementation, which provides the required additional definitions. You
2952 can use this package in two ways. You can @code{with} it in the normal
2953 way and access entities either by selection or using a @code{use}
2954 clause. In this case no special processing is required.
2956 However, if existing code contains references such as
2957 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2958 definitions provided in package @code{System}, you may use this pragma
2959 to extend visibility in @code{System} in a non-standard way that
2960 provides greater compatibility with the existing code. Pragma
2961 @code{Extend_System} is a configuration pragma whose single argument is
2962 the name of the package containing the extended definition
2963 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2964 control of this pragma will be processed using special visibility
2965 processing that looks in package @code{System.Aux_@var{xxx}} where
2966 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2967 package @code{System}, but not found in package @code{System}.
2969 You can use this pragma either to access a predefined @code{System}
2970 extension supplied with the compiler, for example @code{Aux_DEC} or
2971 you can construct your own extension unit following the above
2972 definition. Note that such a package is a child of @code{System}
2973 and thus is considered part of the implementation.
2974 To compile it you will have to use the @option{-gnatg} switch,
2975 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
2976 for compiling System units, as explained in the
2977 @value{EDITION} User's Guide.
2979 @node Pragma Extensions_Allowed
2980 @unnumberedsec Pragma Extensions_Allowed
2981 @cindex Ada Extensions
2982 @cindex GNAT Extensions
2983 @findex Extensions_Allowed
2987 @smallexample @c ada
2988 pragma Extensions_Allowed (On | Off);
2992 This configuration pragma enables or disables the implementation
2993 extension mode (the use of Off as a parameter cancels the effect
2994 of the @option{-gnatX} command switch).
2996 In extension mode, the latest version of the Ada language is
2997 implemented (currently Ada 2012), and in addition a small number
2998 of GNAT specific extensions are recognized as follows:
3001 @item Constrained attribute for generic objects
3002 The @code{Constrained} attribute is permitted for objects of
3003 generic types. The result indicates if the corresponding actual
3008 @node Pragma External
3009 @unnumberedsec Pragma External
3014 @smallexample @c ada
3016 [ Convention =>] convention_IDENTIFIER,
3017 [ Entity =>] LOCAL_NAME
3018 [, [External_Name =>] static_string_EXPRESSION ]
3019 [, [Link_Name =>] static_string_EXPRESSION ]);
3023 This pragma is identical in syntax and semantics to pragma
3024 @code{Export} as defined in the Ada Reference Manual. It is
3025 provided for compatibility with some Ada 83 compilers that
3026 used this pragma for exactly the same purposes as pragma
3027 @code{Export} before the latter was standardized.
3029 @node Pragma External_Name_Casing
3030 @unnumberedsec Pragma External_Name_Casing
3031 @cindex Dec Ada 83 casing compatibility
3032 @cindex External Names, casing
3033 @cindex Casing of External names
3034 @findex External_Name_Casing
3038 @smallexample @c ada
3039 pragma External_Name_Casing (
3040 Uppercase | Lowercase
3041 [, Uppercase | Lowercase | As_Is]);
3045 This pragma provides control over the casing of external names associated
3046 with Import and Export pragmas. There are two cases to consider:
3049 @item Implicit external names
3050 Implicit external names are derived from identifiers. The most common case
3051 arises when a standard Ada Import or Export pragma is used with only two
3054 @smallexample @c ada
3055 pragma Import (C, C_Routine);
3059 Since Ada is a case-insensitive language, the spelling of the identifier in
3060 the Ada source program does not provide any information on the desired
3061 casing of the external name, and so a convention is needed. In GNAT the
3062 default treatment is that such names are converted to all lower case
3063 letters. This corresponds to the normal C style in many environments.
3064 The first argument of pragma @code{External_Name_Casing} can be used to
3065 control this treatment. If @code{Uppercase} is specified, then the name
3066 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3067 then the normal default of all lower case letters will be used.
3069 This same implicit treatment is also used in the case of extended DEC Ada 83
3070 compatible Import and Export pragmas where an external name is explicitly
3071 specified using an identifier rather than a string.
3073 @item Explicit external names
3074 Explicit external names are given as string literals. The most common case
3075 arises when a standard Ada Import or Export pragma is used with three
3078 @smallexample @c ada
3079 pragma Import (C, C_Routine, "C_routine");
3083 In this case, the string literal normally provides the exact casing required
3084 for the external name. The second argument of pragma
3085 @code{External_Name_Casing} may be used to modify this behavior.
3086 If @code{Uppercase} is specified, then the name
3087 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3088 then the name will be forced to all lowercase letters. A specification of
3089 @code{As_Is} provides the normal default behavior in which the casing is
3090 taken from the string provided.
3094 This pragma may appear anywhere that a pragma is valid. In particular, it
3095 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3096 case it applies to all subsequent compilations, or it can be used as a program
3097 unit pragma, in which case it only applies to the current unit, or it can
3098 be used more locally to control individual Import/Export pragmas.
3100 It is primarily intended for use with OpenVMS systems, where many
3101 compilers convert all symbols to upper case by default. For interfacing to
3102 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3105 @smallexample @c ada
3106 pragma External_Name_Casing (Uppercase, Uppercase);
3110 to enforce the upper casing of all external symbols.
3112 @node Pragma Fast_Math
3113 @unnumberedsec Pragma Fast_Math
3118 @smallexample @c ada
3123 This is a configuration pragma which activates a mode in which speed is
3124 considered more important for floating-point operations than absolutely
3125 accurate adherence to the requirements of the standard. Currently the
3126 following operations are affected:
3129 @item Complex Multiplication
3130 The normal simple formula for complex multiplication can result in intermediate
3131 overflows for numbers near the end of the range. The Ada standard requires that
3132 this situation be detected and corrected by scaling, but in Fast_Math mode such
3133 cases will simply result in overflow. Note that to take advantage of this you
3134 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3135 under control of the pragma, rather than use the preinstantiated versions.
3138 @node Pragma Favor_Top_Level
3139 @unnumberedsec Pragma Favor_Top_Level
3140 @findex Favor_Top_Level
3144 @smallexample @c ada
3145 pragma Favor_Top_Level (type_NAME);
3149 The named type must be an access-to-subprogram type. This pragma is an
3150 efficiency hint to the compiler, regarding the use of 'Access or
3151 'Unrestricted_Access on nested (non-library-level) subprograms. The
3152 pragma means that nested subprograms are not used with this type, or
3153 are rare, so that the generated code should be efficient in the
3154 top-level case. When this pragma is used, dynamically generated
3155 trampolines may be used on some targets for nested subprograms.
3156 See also the No_Implicit_Dynamic_Code restriction.
3158 @node Pragma Finalize_Storage_Only
3159 @unnumberedsec Pragma Finalize_Storage_Only
3160 @findex Finalize_Storage_Only
3164 @smallexample @c ada
3165 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3169 This pragma allows the compiler not to emit a Finalize call for objects
3170 defined at the library level. This is mostly useful for types where
3171 finalization is only used to deal with storage reclamation since in most
3172 environments it is not necessary to reclaim memory just before terminating
3173 execution, hence the name.
3175 @node Pragma Float_Representation
3176 @unnumberedsec Pragma Float_Representation
3178 @findex Float_Representation
3182 @smallexample @c ada
3183 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3185 FLOAT_REP ::= VAX_Float | IEEE_Float
3189 In the one argument form, this pragma is a configuration pragma which
3190 allows control over the internal representation chosen for the predefined
3191 floating point types declared in the packages @code{Standard} and
3192 @code{System}. On all systems other than OpenVMS, the argument must
3193 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3194 argument may be @code{VAX_Float} to specify the use of the VAX float
3195 format for the floating-point types in Standard. This requires that
3196 the standard runtime libraries be recompiled.
3198 The two argument form specifies the representation to be used for
3199 the specified floating-point type. On all systems other than OpenVMS,
3201 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3205 For a digits value of 6, 32-bit IEEE short format will be used.
3207 For a digits value of 15, 64-bit IEEE long format will be used.
3209 No other value of digits is permitted.
3213 argument may be @code{VAX_Float} to specify the use of the VAX float
3218 For digits values up to 6, F float format will be used.
3220 For digits values from 7 to 9, D float format will be used.
3222 For digits values from 10 to 15, G float format will be used.
3224 Digits values above 15 are not allowed.
3228 @unnumberedsec Pragma Global
3231 For the description of this pragma, see SPARK 2014 Reference Manual,
3235 @unnumberedsec Pragma Ident
3240 @smallexample @c ada
3241 pragma Ident (static_string_EXPRESSION);
3245 This pragma provides a string identification in the generated object file,
3246 if the system supports the concept of this kind of identification string.
3247 This pragma is allowed only in the outermost declarative part or
3248 declarative items of a compilation unit. If more than one @code{Ident}
3249 pragma is given, only the last one processed is effective.
3251 On OpenVMS systems, the effect of the pragma is identical to the effect of
3252 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3253 maximum allowed length is 31 characters, so if it is important to
3254 maintain compatibility with this compiler, you should obey this length
3257 @node Pragma Implementation_Defined
3258 @unnumberedsec Pragma Implementation_Defined
3259 @findex Implementation_Defined
3263 @smallexample @c ada
3264 pragma Implementation_Defined (local_NAME);
3268 This pragma marks a previously declared entioty as implementation-defined.
3269 For an overloaded entity, applies to the most recent homonym.
3271 @smallexample @c ada
3272 pragma Implementation_Defined;
3276 The form with no arguments appears anywhere within a scope, most
3277 typically a package spec, and indicates that all entities that are
3278 defined within the package spec are Implementation_Defined.
3280 This pragma is used within the GNAT runtime library to identify
3281 implementation-defined entities introduced in language-defined units,
3282 for the purpose of implementing the No_Implementation_Identifiers
3285 @node Pragma Implemented
3286 @unnumberedsec Pragma Implemented
3291 @smallexample @c ada
3292 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3294 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3298 This is an Ada 2012 representation pragma which applies to protected, task
3299 and synchronized interface primitives. The use of pragma Implemented provides
3300 a way to impose a static requirement on the overriding operation by adhering
3301 to one of the three implementation kinds: entry, protected procedure or any of
3302 the above. This pragma is available in all earlier versions of Ada as an
3303 implementation-defined pragma.
3305 @smallexample @c ada
3306 type Synch_Iface is synchronized interface;
3307 procedure Prim_Op (Obj : in out Iface) is abstract;
3308 pragma Implemented (Prim_Op, By_Protected_Procedure);
3310 protected type Prot_1 is new Synch_Iface with
3311 procedure Prim_Op; -- Legal
3314 protected type Prot_2 is new Synch_Iface with
3315 entry Prim_Op; -- Illegal
3318 task type Task_Typ is new Synch_Iface with
3319 entry Prim_Op; -- Illegal
3324 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3325 Implemented determines the runtime behavior of the requeue. Implementation kind
3326 By_Entry guarantees that the action of requeueing will proceed from an entry to
3327 another entry. Implementation kind By_Protected_Procedure transforms the
3328 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3329 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3330 the target's overriding subprogram kind.
3332 @node Pragma Implicit_Packing
3333 @unnumberedsec Pragma Implicit_Packing
3334 @findex Implicit_Packing
3335 @cindex Rational Profile
3339 @smallexample @c ada
3340 pragma Implicit_Packing;
3344 This is a configuration pragma that requests implicit packing for packed
3345 arrays for which a size clause is given but no explicit pragma Pack or
3346 specification of Component_Size is present. It also applies to records
3347 where no record representation clause is present. Consider this example:
3349 @smallexample @c ada
3350 type R is array (0 .. 7) of Boolean;
3355 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3356 does not change the layout of a composite object. So the Size clause in the
3357 above example is normally rejected, since the default layout of the array uses
3358 8-bit components, and thus the array requires a minimum of 64 bits.
3360 If this declaration is compiled in a region of code covered by an occurrence
3361 of the configuration pragma Implicit_Packing, then the Size clause in this
3362 and similar examples will cause implicit packing and thus be accepted. For
3363 this implicit packing to occur, the type in question must be an array of small
3364 components whose size is known at compile time, and the Size clause must
3365 specify the exact size that corresponds to the number of elements in the array
3366 multiplied by the size in bits of the component type (both single and
3367 multi-dimensioned arrays can be controlled with this pragma).
3369 @cindex Array packing
3371 Similarly, the following example shows the use in the record case
3373 @smallexample @c ada
3375 a, b, c, d, e, f, g, h : boolean;
3382 Without a pragma Pack, each Boolean field requires 8 bits, so the
3383 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3384 sufficient. The use of pragma Implicit_Packing allows this record
3385 declaration to compile without an explicit pragma Pack.
3386 @node Pragma Import_Exception
3387 @unnumberedsec Pragma Import_Exception
3389 @findex Import_Exception
3393 @smallexample @c ada
3394 pragma Import_Exception (
3395 [Internal =>] LOCAL_NAME
3396 [, [External =>] EXTERNAL_SYMBOL]
3397 [, [Form =>] Ada | VMS]
3398 [, [Code =>] static_integer_EXPRESSION]);
3402 | static_string_EXPRESSION
3406 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3407 It allows OpenVMS conditions (for example, from OpenVMS system services or
3408 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3409 The pragma specifies that the exception associated with an exception
3410 declaration in an Ada program be defined externally (in non-Ada code).
3411 For further details on this pragma, see the
3412 DEC Ada Language Reference Manual, section 13.9a.3.1.
3414 @node Pragma Import_Function
3415 @unnumberedsec Pragma Import_Function
3416 @findex Import_Function
3420 @smallexample @c ada
3421 pragma Import_Function (
3422 [Internal =>] LOCAL_NAME,
3423 [, [External =>] EXTERNAL_SYMBOL]
3424 [, [Parameter_Types =>] PARAMETER_TYPES]
3425 [, [Result_Type =>] SUBTYPE_MARK]
3426 [, [Mechanism =>] MECHANISM]
3427 [, [Result_Mechanism =>] MECHANISM_NAME]
3428 [, [First_Optional_Parameter =>] IDENTIFIER]);
3432 | static_string_EXPRESSION
3436 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3440 | subtype_Name ' Access
3444 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3446 MECHANISM_ASSOCIATION ::=
3447 [formal_parameter_NAME =>] MECHANISM_NAME
3452 | Descriptor [([Class =>] CLASS_NAME)]
3453 | Short_Descriptor [([Class =>] CLASS_NAME)]
3455 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3459 This pragma is used in conjunction with a pragma @code{Import} to
3460 specify additional information for an imported function. The pragma
3461 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3462 @code{Import_Function} pragma and both must appear in the same
3463 declarative part as the function specification.
3465 The @var{Internal} argument must uniquely designate
3466 the function to which the
3467 pragma applies. If more than one function name exists of this name in
3468 the declarative part you must use the @code{Parameter_Types} and
3469 @var{Result_Type} parameters to achieve the required unique
3470 designation. Subtype marks in these parameters must exactly match the
3471 subtypes in the corresponding function specification, using positional
3472 notation to match parameters with subtype marks.
3473 The form with an @code{'Access} attribute can be used to match an
3474 anonymous access parameter.
3476 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3477 parameters to specify passing mechanisms for the
3478 parameters and result. If you specify a single mechanism name, it
3479 applies to all parameters. Otherwise you may specify a mechanism on a
3480 parameter by parameter basis using either positional or named
3481 notation. If the mechanism is not specified, the default mechanism
3485 @cindex Passing by descriptor
3486 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3487 The default behavior for Import_Function is to pass a 64bit descriptor
3488 unless short_descriptor is specified, then a 32bit descriptor is passed.
3490 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3491 It specifies that the designated parameter and all following parameters
3492 are optional, meaning that they are not passed at the generated code
3493 level (this is distinct from the notion of optional parameters in Ada
3494 where the parameters are passed anyway with the designated optional
3495 parameters). All optional parameters must be of mode @code{IN} and have
3496 default parameter values that are either known at compile time
3497 expressions, or uses of the @code{'Null_Parameter} attribute.
3499 @node Pragma Import_Object
3500 @unnumberedsec Pragma Import_Object
3501 @findex Import_Object
3505 @smallexample @c ada
3506 pragma Import_Object
3507 [Internal =>] LOCAL_NAME
3508 [, [External =>] EXTERNAL_SYMBOL]
3509 [, [Size =>] EXTERNAL_SYMBOL]);
3513 | static_string_EXPRESSION
3517 This pragma designates an object as imported, and apart from the
3518 extended rules for external symbols, is identical in effect to the use of
3519 the normal @code{Import} pragma applied to an object. Unlike the
3520 subprogram case, you need not use a separate @code{Import} pragma,
3521 although you may do so (and probably should do so from a portability
3522 point of view). @var{size} is syntax checked, but otherwise ignored by
3525 @node Pragma Import_Procedure
3526 @unnumberedsec Pragma Import_Procedure
3527 @findex Import_Procedure
3531 @smallexample @c ada
3532 pragma Import_Procedure (
3533 [Internal =>] LOCAL_NAME
3534 [, [External =>] EXTERNAL_SYMBOL]
3535 [, [Parameter_Types =>] PARAMETER_TYPES]
3536 [, [Mechanism =>] MECHANISM]
3537 [, [First_Optional_Parameter =>] IDENTIFIER]);
3541 | static_string_EXPRESSION
3545 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3549 | subtype_Name ' Access
3553 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3555 MECHANISM_ASSOCIATION ::=
3556 [formal_parameter_NAME =>] MECHANISM_NAME
3561 | Descriptor [([Class =>] CLASS_NAME)]
3562 | Short_Descriptor [([Class =>] CLASS_NAME)]
3564 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3568 This pragma is identical to @code{Import_Function} except that it
3569 applies to a procedure rather than a function and the parameters
3570 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3572 @node Pragma Import_Valued_Procedure
3573 @unnumberedsec Pragma Import_Valued_Procedure
3574 @findex Import_Valued_Procedure
3578 @smallexample @c ada
3579 pragma Import_Valued_Procedure (
3580 [Internal =>] LOCAL_NAME
3581 [, [External =>] EXTERNAL_SYMBOL]
3582 [, [Parameter_Types =>] PARAMETER_TYPES]
3583 [, [Mechanism =>] MECHANISM]
3584 [, [First_Optional_Parameter =>] IDENTIFIER]);
3588 | static_string_EXPRESSION
3592 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3596 | subtype_Name ' Access
3600 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3602 MECHANISM_ASSOCIATION ::=
3603 [formal_parameter_NAME =>] MECHANISM_NAME
3608 | Descriptor [([Class =>] CLASS_NAME)]
3609 | Short_Descriptor [([Class =>] CLASS_NAME)]
3611 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3615 This pragma is identical to @code{Import_Procedure} except that the
3616 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3617 mode @code{OUT}, and externally the subprogram is treated as a function
3618 with this parameter as the result of the function. The purpose of this
3619 capability is to allow the use of @code{OUT} and @code{IN OUT}
3620 parameters in interfacing to external functions (which are not permitted
3621 in Ada functions). You may optionally use the @code{Mechanism}
3622 parameters to specify passing mechanisms for the parameters.
3623 If you specify a single mechanism name, it applies to all parameters.
3624 Otherwise you may specify a mechanism on a parameter by parameter
3625 basis using either positional or named notation. If the mechanism is not
3626 specified, the default mechanism is used.
3628 Note that it is important to use this pragma in conjunction with a separate
3629 pragma Import that specifies the desired convention, since otherwise the
3630 default convention is Ada, which is almost certainly not what is required.
3632 @node Pragma Independent
3633 @unnumberedsec Pragma Independent
3638 @smallexample @c ada
3639 pragma Independent (Local_NAME);
3643 This pragma is standard in Ada 2012 mode (which also provides an aspect
3644 of the same name). It is also available as an implementation-defined
3645 pragma in all earlier versions. It specifies that the
3646 designated object or all objects of the designated type must be
3647 independently addressable. This means that separate tasks can safely
3648 manipulate such objects. For example, if two components of a record are
3649 independent, then two separate tasks may access these two components.
3651 constraints on the representation of the object (for instance prohibiting
3654 @node Pragma Independent_Components
3655 @unnumberedsec Pragma Independent_Components
3656 @findex Independent_Components
3660 @smallexample @c ada
3661 pragma Independent_Components (Local_NAME);
3665 This pragma is standard in Ada 2012 mode (which also provides an aspect
3666 of the same name). It is also available as an implementation-defined
3667 pragma in all earlier versions. It specifies that the components of the
3668 designated object, or the components of each object of the designated
3670 independently addressable. This means that separate tasks can safely
3671 manipulate separate components in the composite object. This may place
3672 constraints on the representation of the object (for instance prohibiting
3675 @node Pragma Initial_Condition
3676 @unnumberedsec Pragma Initial_Condition
3677 @findex Initial_Condition
3679 For the description of this pragma, see SPARK 2014 Reference Manual,
3682 @node Pragma Initialize_Scalars
3683 @unnumberedsec Pragma Initialize_Scalars
3684 @findex Initialize_Scalars
3685 @cindex debugging with Initialize_Scalars
3689 @smallexample @c ada
3690 pragma Initialize_Scalars;
3694 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3695 two important differences. First, there is no requirement for the pragma
3696 to be used uniformly in all units of a partition, in particular, it is fine
3697 to use this just for some or all of the application units of a partition,
3698 without needing to recompile the run-time library.
3700 In the case where some units are compiled with the pragma, and some without,
3701 then a declaration of a variable where the type is defined in package
3702 Standard or is locally declared will always be subject to initialization,
3703 as will any declaration of a scalar variable. For composite variables,
3704 whether the variable is initialized may also depend on whether the package
3705 in which the type of the variable is declared is compiled with the pragma.
3707 The other important difference is that you can control the value used
3708 for initializing scalar objects. At bind time, you can select several
3709 options for initialization. You can
3710 initialize with invalid values (similar to Normalize_Scalars, though for
3711 Initialize_Scalars it is not always possible to determine the invalid
3712 values in complex cases like signed component fields with non-standard
3713 sizes). You can also initialize with high or
3714 low values, or with a specified bit pattern. See the @value{EDITION}
3715 User's Guide for binder options for specifying these cases.
3717 This means that you can compile a program, and then without having to
3718 recompile the program, you can run it with different values being used
3719 for initializing otherwise uninitialized values, to test if your program
3720 behavior depends on the choice. Of course the behavior should not change,
3721 and if it does, then most likely you have an incorrect reference to an
3722 uninitialized value.
3724 It is even possible to change the value at execution time eliminating even
3725 the need to rebind with a different switch using an environment variable.
3726 See the @value{EDITION} User's Guide for details.
3728 Note that pragma @code{Initialize_Scalars} is particularly useful in
3729 conjunction with the enhanced validity checking that is now provided
3730 in GNAT, which checks for invalid values under more conditions.
3731 Using this feature (see description of the @option{-gnatV} flag in the
3732 @value{EDITION} User's Guide) in conjunction with
3733 pragma @code{Initialize_Scalars}
3734 provides a powerful new tool to assist in the detection of problems
3735 caused by uninitialized variables.
3737 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3738 effect on the generated code. This may cause your code to be
3739 substantially larger. It may also cause an increase in the amount
3740 of stack required, so it is probably a good idea to turn on stack
3741 checking (see description of stack checking in the @value{EDITION}
3742 User's Guide) when using this pragma.
3744 @node Pragma Initializes
3745 @unnumberedsec Pragma Initializes
3748 For the description of this pragma, see SPARK 2014 Reference Manual,
3751 @node Pragma Inline_Always
3752 @unnumberedsec Pragma Inline_Always
3753 @findex Inline_Always
3757 @smallexample @c ada
3758 pragma Inline_Always (NAME [, NAME]);
3762 Similar to pragma @code{Inline} except that inlining is not subject to
3763 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3764 happens regardless of whether these options are used.
3766 @node Pragma Inline_Generic
3767 @unnumberedsec Pragma Inline_Generic
3768 @findex Inline_Generic
3772 @smallexample @c ada
3773 pragma Inline_Generic (GNAME @{, GNAME@});
3775 GNAME ::= generic_unit_NAME | generic_instance_NAME
3779 This pragma is provided for compatibility with Dec Ada 83. It has
3780 no effect in @code{GNAT} (which always inlines generics), other
3781 than to check that the given names are all names of generic units or
3784 @node Pragma Interface
3785 @unnumberedsec Pragma Interface
3790 @smallexample @c ada
3792 [Convention =>] convention_identifier,
3793 [Entity =>] local_NAME
3794 [, [External_Name =>] static_string_expression]
3795 [, [Link_Name =>] static_string_expression]);
3799 This pragma is identical in syntax and semantics to
3800 the standard Ada pragma @code{Import}. It is provided for compatibility
3801 with Ada 83. The definition is upwards compatible both with pragma
3802 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3803 with some extended implementations of this pragma in certain Ada 83
3804 implementations. The only difference between pragma @code{Interface}
3805 and pragma @code{Import} is that there is special circuitry to allow
3806 both pragmas to appear for the same subprogram entity (normally it
3807 is illegal to have multiple @code{Import} pragmas. This is useful in
3808 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3811 @node Pragma Interface_Name
3812 @unnumberedsec Pragma Interface_Name
3813 @findex Interface_Name
3817 @smallexample @c ada
3818 pragma Interface_Name (
3819 [Entity =>] LOCAL_NAME
3820 [, [External_Name =>] static_string_EXPRESSION]
3821 [, [Link_Name =>] static_string_EXPRESSION]);
3825 This pragma provides an alternative way of specifying the interface name
3826 for an interfaced subprogram, and is provided for compatibility with Ada
3827 83 compilers that use the pragma for this purpose. You must provide at
3828 least one of @var{External_Name} or @var{Link_Name}.
3830 @node Pragma Interrupt_Handler
3831 @unnumberedsec Pragma Interrupt_Handler
3832 @findex Interrupt_Handler
3836 @smallexample @c ada
3837 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3841 This program unit pragma is supported for parameterless protected procedures
3842 as described in Annex C of the Ada Reference Manual. On the AAMP target
3843 the pragma can also be specified for nonprotected parameterless procedures
3844 that are declared at the library level (which includes procedures
3845 declared at the top level of a library package). In the case of AAMP,
3846 when this pragma is applied to a nonprotected procedure, the instruction
3847 @code{IERET} is generated for returns from the procedure, enabling
3848 maskable interrupts, in place of the normal return instruction.
3850 @node Pragma Interrupt_State
3851 @unnumberedsec Pragma Interrupt_State
3852 @findex Interrupt_State
3856 @smallexample @c ada
3857 pragma Interrupt_State
3859 [State =>] SYSTEM | RUNTIME | USER);
3863 Normally certain interrupts are reserved to the implementation. Any attempt
3864 to attach an interrupt causes Program_Error to be raised, as described in
3865 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3866 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3867 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3868 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3869 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3870 Ada exceptions, or used to implement run-time functions such as the
3871 @code{abort} statement and stack overflow checking.
3873 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3874 such uses of interrupts. It subsumes the functionality of pragma
3875 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3876 available on Windows or VMS. On all other platforms than VxWorks,
3877 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3878 and may be used to mark interrupts required by the board support package
3881 Interrupts can be in one of three states:
3885 The interrupt is reserved (no Ada handler can be installed), and the
3886 Ada run-time may not install a handler. As a result you are guaranteed
3887 standard system default action if this interrupt is raised.
3891 The interrupt is reserved (no Ada handler can be installed). The run time
3892 is allowed to install a handler for internal control purposes, but is
3893 not required to do so.
3897 The interrupt is unreserved. The user may install a handler to provide
3902 These states are the allowed values of the @code{State} parameter of the
3903 pragma. The @code{Name} parameter is a value of the type
3904 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3905 @code{Ada.Interrupts.Names}.
3907 This is a configuration pragma, and the binder will check that there
3908 are no inconsistencies between different units in a partition in how a
3909 given interrupt is specified. It may appear anywhere a pragma is legal.
3911 The effect is to move the interrupt to the specified state.
3913 By declaring interrupts to be SYSTEM, you guarantee the standard system
3914 action, such as a core dump.
3916 By declaring interrupts to be USER, you guarantee that you can install
3919 Note that certain signals on many operating systems cannot be caught and
3920 handled by applications. In such cases, the pragma is ignored. See the
3921 operating system documentation, or the value of the array @code{Reserved}
3922 declared in the spec of package @code{System.OS_Interface}.
3924 Overriding the default state of signals used by the Ada runtime may interfere
3925 with an application's runtime behavior in the cases of the synchronous signals,
3926 and in the case of the signal used to implement the @code{abort} statement.
3928 @node Pragma Invariant
3929 @unnumberedsec Pragma Invariant
3934 @smallexample @c ada
3936 ([Entity =>] private_type_LOCAL_NAME,
3937 [Check =>] EXPRESSION
3938 [,[Message =>] String_Expression]);
3942 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3943 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3944 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3945 requires the use of the aspect syntax, which is not available except in 2012
3946 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3947 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3948 note that the aspect Invariant is a synonym in GNAT for the aspect
3949 Type_Invariant, but there is no pragma Type_Invariant.
3951 The pragma must appear within the visible part of the package specification,
3952 after the type to which its Entity argument appears. As with the Invariant
3953 aspect, the Check expression is not analyzed until the end of the visible
3954 part of the package, so it may contain forward references. The Message
3955 argument, if present, provides the exception message used if the invariant
3956 is violated. If no Message parameter is provided, a default message that
3957 identifies the line on which the pragma appears is used.
3959 It is permissible to have multiple Invariants for the same type entity, in
3960 which case they are and'ed together. It is permissible to use this pragma
3961 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3962 invariant pragma for the same entity.
3964 For further details on the use of this pragma, see the Ada 2012 documentation
3965 of the Type_Invariant aspect.
3967 @node Pragma Java_Constructor
3968 @unnumberedsec Pragma Java_Constructor
3969 @findex Java_Constructor
3973 @smallexample @c ada
3974 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3978 This pragma is used to assert that the specified Ada function should be
3979 mapped to the Java constructor for some Ada tagged record type.
3981 See section 7.3.2 of the
3982 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3983 for related information.
3985 @node Pragma Java_Interface
3986 @unnumberedsec Pragma Java_Interface
3987 @findex Java_Interface
3991 @smallexample @c ada
3992 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3996 This pragma is used to assert that the specified Ada abstract tagged type
3997 is to be mapped to a Java interface name.
3999 See sections 7.1 and 7.2 of the
4000 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4001 for related information.
4003 @node Pragma Keep_Names
4004 @unnumberedsec Pragma Keep_Names
4009 @smallexample @c ada
4010 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4014 The @var{LOCAL_NAME} argument
4015 must refer to an enumeration first subtype
4016 in the current declarative part. The effect is to retain the enumeration
4017 literal names for use by @code{Image} and @code{Value} even if a global
4018 @code{Discard_Names} pragma applies. This is useful when you want to
4019 generally suppress enumeration literal names and for example you therefore
4020 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4021 want to retain the names for specific enumeration types.
4023 @node Pragma License
4024 @unnumberedsec Pragma License
4026 @cindex License checking
4030 @smallexample @c ada
4031 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4035 This pragma is provided to allow automated checking for appropriate license
4036 conditions with respect to the standard and modified GPL@. A pragma
4037 @code{License}, which is a configuration pragma that typically appears at
4038 the start of a source file or in a separate @file{gnat.adc} file, specifies
4039 the licensing conditions of a unit as follows:
4043 This is used for a unit that can be freely used with no license restrictions.
4044 Examples of such units are public domain units, and units from the Ada
4048 This is used for a unit that is licensed under the unmodified GPL, and which
4049 therefore cannot be @code{with}'ed by a restricted unit.
4052 This is used for a unit licensed under the GNAT modified GPL that includes
4053 a special exception paragraph that specifically permits the inclusion of
4054 the unit in programs without requiring the entire program to be released
4058 This is used for a unit that is restricted in that it is not permitted to
4059 depend on units that are licensed under the GPL@. Typical examples are
4060 proprietary code that is to be released under more restrictive license
4061 conditions. Note that restricted units are permitted to @code{with} units
4062 which are licensed under the modified GPL (this is the whole point of the
4068 Normally a unit with no @code{License} pragma is considered to have an
4069 unknown license, and no checking is done. However, standard GNAT headers
4070 are recognized, and license information is derived from them as follows.
4074 A GNAT license header starts with a line containing 78 hyphens. The following
4075 comment text is searched for the appearance of any of the following strings.
4077 If the string ``GNU General Public License'' is found, then the unit is assumed
4078 to have GPL license, unless the string ``As a special exception'' follows, in
4079 which case the license is assumed to be modified GPL@.
4081 If one of the strings
4082 ``This specification is adapted from the Ada Semantic Interface'' or
4083 ``This specification is derived from the Ada Reference Manual'' is found
4084 then the unit is assumed to be unrestricted.
4088 These default actions means that a program with a restricted license pragma
4089 will automatically get warnings if a GPL unit is inappropriately
4090 @code{with}'ed. For example, the program:
4092 @smallexample @c ada
4095 procedure Secret_Stuff is
4101 if compiled with pragma @code{License} (@code{Restricted}) in a
4102 @file{gnat.adc} file will generate the warning:
4107 >>> license of withed unit "Sem_Ch3" is incompatible
4109 2. with GNAT.Sockets;
4110 3. procedure Secret_Stuff is
4114 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4115 compiler and is licensed under the
4116 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4117 run time, and is therefore licensed under the modified GPL@.
4119 @node Pragma Link_With
4120 @unnumberedsec Pragma Link_With
4125 @smallexample @c ada
4126 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4130 This pragma is provided for compatibility with certain Ada 83 compilers.
4131 It has exactly the same effect as pragma @code{Linker_Options} except
4132 that spaces occurring within one of the string expressions are treated
4133 as separators. For example, in the following case:
4135 @smallexample @c ada
4136 pragma Link_With ("-labc -ldef");
4140 results in passing the strings @code{-labc} and @code{-ldef} as two
4141 separate arguments to the linker. In addition pragma Link_With allows
4142 multiple arguments, with the same effect as successive pragmas.
4144 @node Pragma Linker_Alias
4145 @unnumberedsec Pragma Linker_Alias
4146 @findex Linker_Alias
4150 @smallexample @c ada
4151 pragma Linker_Alias (
4152 [Entity =>] LOCAL_NAME,
4153 [Target =>] static_string_EXPRESSION);
4157 @var{LOCAL_NAME} must refer to an object that is declared at the library
4158 level. This pragma establishes the given entity as a linker alias for the
4159 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4160 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4161 @var{static_string_EXPRESSION} in the object file, that is to say no space
4162 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4163 to the same address as @var{static_string_EXPRESSION} by the linker.
4165 The actual linker name for the target must be used (e.g.@: the fully
4166 encoded name with qualification in Ada, or the mangled name in C++),
4167 or it must be declared using the C convention with @code{pragma Import}
4168 or @code{pragma Export}.
4170 Not all target machines support this pragma. On some of them it is accepted
4171 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4173 @smallexample @c ada
4174 -- Example of the use of pragma Linker_Alias
4178 pragma Export (C, i);
4180 new_name_for_i : Integer;
4181 pragma Linker_Alias (new_name_for_i, "i");
4185 @node Pragma Linker_Constructor
4186 @unnumberedsec Pragma Linker_Constructor
4187 @findex Linker_Constructor
4191 @smallexample @c ada
4192 pragma Linker_Constructor (procedure_LOCAL_NAME);
4196 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4197 is declared at the library level. A procedure to which this pragma is
4198 applied will be treated as an initialization routine by the linker.
4199 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4200 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4201 of the executable is called (or immediately after the shared library is
4202 loaded if the procedure is linked in a shared library), in particular
4203 before the Ada run-time environment is set up.
4205 Because of these specific contexts, the set of operations such a procedure
4206 can perform is very limited and the type of objects it can manipulate is
4207 essentially restricted to the elementary types. In particular, it must only
4208 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4210 This pragma is used by GNAT to implement auto-initialization of shared Stand
4211 Alone Libraries, which provides a related capability without the restrictions
4212 listed above. Where possible, the use of Stand Alone Libraries is preferable
4213 to the use of this pragma.
4215 @node Pragma Linker_Destructor
4216 @unnumberedsec Pragma Linker_Destructor
4217 @findex Linker_Destructor
4221 @smallexample @c ada
4222 pragma Linker_Destructor (procedure_LOCAL_NAME);
4226 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4227 is declared at the library level. A procedure to which this pragma is
4228 applied will be treated as a finalization routine by the linker.
4229 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4230 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4231 of the executable has exited (or immediately before the shared library
4232 is unloaded if the procedure is linked in a shared library), in particular
4233 after the Ada run-time environment is shut down.
4235 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4236 because of these specific contexts.
4238 @node Pragma Linker_Section
4239 @unnumberedsec Pragma Linker_Section
4240 @findex Linker_Section
4244 @smallexample @c ada
4245 pragma Linker_Section (
4246 [Entity =>] LOCAL_NAME,
4247 [Section =>] static_string_EXPRESSION);
4251 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4252 declared at the library level. This pragma specifies the name of the
4253 linker section for the given entity. It is equivalent to
4254 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4255 be placed in the @var{static_string_EXPRESSION} section of the
4256 executable (assuming the linker doesn't rename the section).
4257 GNAT also provides an implementation defined aspect of the same name.
4259 In the case of specifying this aspect for a type, the effect is to
4260 specify the corresponding for all library level objects of the type which
4261 do not have an explicit linker section set. Note that this only applies to
4262 whole objects, not to components of composite objects.
4264 In the case of a subprogram, the linker section applies to all previously
4265 declared matching overloaded subprograms in the current declarative part
4266 which do not already have a linker section assigned. The linker section
4267 aspect is useful in this case for specifying different linker sections
4268 for different elements of such an overloaded set.
4270 Note that an empty string specifies that no linker section is specified.
4271 This is not quite the same as omitting the pragma or aspect, since it
4272 can be used to specify that one element of an overloaded set of subprograms
4273 has the default linker section, or that one object of a type for which a
4274 linker section is specified should has the default linker section.
4276 The compiler normally places library-level entities in standard sections
4277 depending on the class: procedures and functions generally go in the
4278 @code{.text} section, initialized variables in the @code{.data} section
4279 and uninitialized variables in the @code{.bss} section.
4281 Other, special sections may exist on given target machines to map special
4282 hardware, for example I/O ports or flash memory. This pragma is a means to
4283 defer the final layout of the executable to the linker, thus fully working
4284 at the symbolic level with the compiler.
4286 Some file formats do not support arbitrary sections so not all target
4287 machines support this pragma. The use of this pragma may cause a program
4288 execution to be erroneous if it is used to place an entity into an
4289 inappropriate section (e.g.@: a modified variable into the @code{.text}
4290 section). See also @code{pragma Persistent_BSS}.
4292 @smallexample @c ada
4293 -- Example of the use of pragma Linker_Section
4297 pragma Volatile (Port_A);
4298 pragma Linker_Section (Port_A, ".bss.port_a");
4301 pragma Volatile (Port_B);
4302 pragma Linker_Section (Port_B, ".bss.port_b");
4304 type Port_Type is new Integer with Linker_Section => ".bss";
4305 PA : Port_Type with Linker_Section => ".bss.PA";
4306 PB : Port_Type; -- ends up in linker section ".bss"
4308 procedure Q with Linker_Section => "Qsection";
4312 @node Pragma Long_Float
4313 @unnumberedsec Pragma Long_Float
4319 @smallexample @c ada
4320 pragma Long_Float (FLOAT_FORMAT);
4322 FLOAT_FORMAT ::= D_Float | G_Float
4326 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4327 It allows control over the internal representation chosen for the predefined
4328 type @code{Long_Float} and for floating point type representations with
4329 @code{digits} specified in the range 7 through 15.
4330 For further details on this pragma, see the
4331 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4332 this pragma, the standard runtime libraries must be recompiled.
4334 @node Pragma Loop_Invariant
4335 @unnumberedsec Pragma Loop_Invariant
4336 @findex Loop_Invariant
4340 @smallexample @c ada
4341 pragma Loop_Invariant ( boolean_EXPRESSION );
4345 The effect of this pragma is similar to that of pragma @code{Assert},
4346 except that in an @code{Assertion_Policy} pragma, the identifier
4347 @code{Loop_Invariant} is used to control whether it is ignored or checked
4350 @code{Loop_Invariant} can only appear as one of the items in the sequence
4351 of statements of a loop body, or nested inside block statements that
4352 appear in the sequence of statements of a loop body.
4353 The intention is that it be used to
4354 represent a "loop invariant" assertion, i.e. something that is true each
4355 time through the loop, and which can be used to show that the loop is
4356 achieving its purpose.
4358 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4359 apply to the same loop should be grouped in the same sequence of
4362 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4363 may be used to refer to the value of an expression on entry to the loop. This
4364 attribute can only be used within the expression of a @code{Loop_Invariant}
4365 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4367 @node Pragma Loop_Optimize
4368 @unnumberedsec Pragma Loop_Optimize
4369 @findex Loop_Optimize
4373 @smallexample @c ada
4374 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4376 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4380 This pragma must appear immediately within a loop statement. It allows the
4381 programmer to specify optimization hints for the enclosing loop. The hints
4382 are not mutually exclusive and can be freely mixed, but not all combinations
4383 will yield a sensible outcome.
4385 There are four supported optimization hints for a loop:
4389 The loop must not be unrolled. This is a strong hint: the compiler will not
4390 unroll a loop marked with this hint.
4394 The loop should be unrolled. This is a weak hint: the compiler will try to
4395 apply unrolling to this loop preferably to other optimizations, notably
4396 vectorization, but there is no guarantee that the loop will be unrolled.
4400 The loop must not be vectorized. This is a strong hint: the compiler will not
4401 vectorize a loop marked with this hint.
4405 The loop should be vectorized. This is a weak hint: the compiler will try to
4406 apply vectorization to this loop preferably to other optimizations, notably
4407 unrolling, but there is no guarantee that the loop will be vectorized.
4411 These hints do not void the need to pass the appropriate switches to the
4412 compiler in order to enable the relevant optimizations, that is to say
4413 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4416 @node Pragma Loop_Variant
4417 @unnumberedsec Pragma Loop_Variant
4418 @findex Loop_Variant
4422 @smallexample @c ada
4423 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4424 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4425 CHANGE_DIRECTION ::= Increases | Decreases
4429 @code{Loop_Variant} can only appear as one of the items in the sequence
4430 of statements of a loop body, or nested inside block statements that
4431 appear in the sequence of statements of a loop body.
4432 It allows the specification of quantities which must always
4433 decrease or increase in successive iterations of the loop. In its simplest
4434 form, just one expression is specified, whose value must increase or decrease
4435 on each iteration of the loop.
4437 In a more complex form, multiple arguments can be given which are intepreted
4438 in a nesting lexicographic manner. For example:
4440 @smallexample @c ada
4441 pragma Loop_Variant (Increases => X, Decreases => Y);
4445 specifies that each time through the loop either X increases, or X stays
4446 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4447 loop is making progress. It can be useful in helping to show informally
4448 or prove formally that the loop always terminates.
4450 @code{Loop_Variant} is an assertion whose effect can be controlled using
4451 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4452 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4453 to ignore the check (in which case the pragma has no effect on the program),
4454 or @code{Disable} in which case the pragma is not even checked for correct
4457 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4458 apply to the same loop should be grouped in the same sequence of
4461 The @code{Loop_Entry} attribute may be used within the expressions of the
4462 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4464 @node Pragma Machine_Attribute
4465 @unnumberedsec Pragma Machine_Attribute
4466 @findex Machine_Attribute
4470 @smallexample @c ada
4471 pragma Machine_Attribute (
4472 [Entity =>] LOCAL_NAME,
4473 [Attribute_Name =>] static_string_EXPRESSION
4474 [, [Info =>] static_EXPRESSION] );
4478 Machine-dependent attributes can be specified for types and/or
4479 declarations. This pragma is semantically equivalent to
4480 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4481 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4482 in GNU C, where @code{@var{attribute_name}} is recognized by the
4483 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4484 specific macro. A string literal for the optional parameter @var{info}
4485 is transformed into an identifier, which may make this pragma unusable
4486 for some attributes. @xref{Target Attributes,, Defining target-specific
4487 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4488 Internals}, further information.
4491 @unnumberedsec Pragma Main
4497 @smallexample @c ada
4499 (MAIN_OPTION [, MAIN_OPTION]);
4502 [Stack_Size =>] static_integer_EXPRESSION
4503 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4504 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4508 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4509 no effect in GNAT, other than being syntax checked.
4511 @node Pragma Main_Storage
4512 @unnumberedsec Pragma Main_Storage
4514 @findex Main_Storage
4518 @smallexample @c ada
4520 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4522 MAIN_STORAGE_OPTION ::=
4523 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4524 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4528 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4529 no effect in GNAT, other than being syntax checked. Note that the pragma
4530 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4532 @node Pragma No_Body
4533 @unnumberedsec Pragma No_Body
4538 @smallexample @c ada
4543 There are a number of cases in which a package spec does not require a body,
4544 and in fact a body is not permitted. GNAT will not permit the spec to be
4545 compiled if there is a body around. The pragma No_Body allows you to provide
4546 a body file, even in a case where no body is allowed. The body file must
4547 contain only comments and a single No_Body pragma. This is recognized by
4548 the compiler as indicating that no body is logically present.
4550 This is particularly useful during maintenance when a package is modified in
4551 such a way that a body needed before is no longer needed. The provision of a
4552 dummy body with a No_Body pragma ensures that there is no interference from
4553 earlier versions of the package body.
4555 @node Pragma No_Inline
4556 @unnumberedsec Pragma No_Inline
4561 @smallexample @c ada
4562 pragma No_Inline (NAME @{, NAME@});
4566 This pragma suppresses inlining for the callable entity or the instances of
4567 the generic subprogram designated by @var{NAME}, including inlining that
4568 results from the use of pragma @code{Inline}. This pragma is always active,
4569 in particular it is not subject to the use of option @option{-gnatn} or
4570 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4571 pragma @code{Inline_Always} for the same @var{NAME}.
4573 @node Pragma No_Return
4574 @unnumberedsec Pragma No_Return
4579 @smallexample @c ada
4580 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4584 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4585 declarations in the current declarative part. A procedure to which this
4586 pragma is applied may not contain any explicit @code{return} statements.
4587 In addition, if the procedure contains any implicit returns from falling
4588 off the end of a statement sequence, then execution of that implicit
4589 return will cause Program_Error to be raised.
4591 One use of this pragma is to identify procedures whose only purpose is to raise
4592 an exception. Another use of this pragma is to suppress incorrect warnings
4593 about missing returns in functions, where the last statement of a function
4594 statement sequence is a call to such a procedure.
4596 Note that in Ada 2005 mode, this pragma is part of the language. It is
4597 available in all earlier versions of Ada as an implementation-defined
4600 @node Pragma No_Run_Time
4601 @unnumberedsec Pragma No_Run_Time
4606 @smallexample @c ada
4611 This is an obsolete configuration pragma that historically was used to
4612 setup what is now called the "zero footprint" library. It causes any
4613 library units outside this basic library to be ignored. The use of
4614 this pragma has been superseded by the general configurable run-time
4615 capability of @code{GNAT} where the compiler takes into account whatever
4616 units happen to be accessible in the library.
4618 @node Pragma No_Strict_Aliasing
4619 @unnumberedsec Pragma No_Strict_Aliasing
4620 @findex No_Strict_Aliasing
4624 @smallexample @c ada
4625 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4629 @var{type_LOCAL_NAME} must refer to an access type
4630 declaration in the current declarative part. The effect is to inhibit
4631 strict aliasing optimization for the given type. The form with no
4632 arguments is a configuration pragma which applies to all access types
4633 declared in units to which the pragma applies. For a detailed
4634 description of the strict aliasing optimization, and the situations
4635 in which it must be suppressed, see @ref{Optimization and Strict
4636 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4638 This pragma currently has no effects on access to unconstrained array types.
4640 @node Pragma Normalize_Scalars
4641 @unnumberedsec Pragma Normalize_Scalars
4642 @findex Normalize_Scalars
4646 @smallexample @c ada
4647 pragma Normalize_Scalars;
4651 This is a language defined pragma which is fully implemented in GNAT@. The
4652 effect is to cause all scalar objects that are not otherwise initialized
4653 to be initialized. The initial values are implementation dependent and
4657 @item Standard.Character
4659 Objects whose root type is Standard.Character are initialized to
4660 Character'Last unless the subtype range excludes NUL (in which case
4661 NUL is used). This choice will always generate an invalid value if
4664 @item Standard.Wide_Character
4666 Objects whose root type is Standard.Wide_Character are initialized to
4667 Wide_Character'Last unless the subtype range excludes NUL (in which case
4668 NUL is used). This choice will always generate an invalid value if
4671 @item Standard.Wide_Wide_Character
4673 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4674 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4675 which case NUL is used). This choice will always generate an invalid value if
4680 Objects of an integer type are treated differently depending on whether
4681 negative values are present in the subtype. If no negative values are
4682 present, then all one bits is used as the initial value except in the
4683 special case where zero is excluded from the subtype, in which case
4684 all zero bits are used. This choice will always generate an invalid
4685 value if one exists.
4687 For subtypes with negative values present, the largest negative number
4688 is used, except in the unusual case where this largest negative number
4689 is in the subtype, and the largest positive number is not, in which case
4690 the largest positive value is used. This choice will always generate
4691 an invalid value if one exists.
4693 @item Floating-Point Types
4694 Objects of all floating-point types are initialized to all 1-bits. For
4695 standard IEEE format, this corresponds to a NaN (not a number) which is
4696 indeed an invalid value.
4698 @item Fixed-Point Types
4699 Objects of all fixed-point types are treated as described above for integers,
4700 with the rules applying to the underlying integer value used to represent
4701 the fixed-point value.
4704 Objects of a modular type are initialized to all one bits, except in
4705 the special case where zero is excluded from the subtype, in which
4706 case all zero bits are used. This choice will always generate an
4707 invalid value if one exists.
4709 @item Enumeration types
4710 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4711 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4712 whose Pos value is zero, in which case a code of zero is used. This choice
4713 will always generate an invalid value if one exists.
4717 @node Pragma Obsolescent
4718 @unnumberedsec Pragma Obsolescent
4723 @smallexample @c ada
4726 pragma Obsolescent (
4727 [Message =>] static_string_EXPRESSION
4728 [,[Version =>] Ada_05]]);
4730 pragma Obsolescent (
4732 [,[Message =>] static_string_EXPRESSION
4733 [,[Version =>] Ada_05]] );
4737 This pragma can occur immediately following a declaration of an entity,
4738 including the case of a record component. If no Entity argument is present,
4739 then this declaration is the one to which the pragma applies. If an Entity
4740 parameter is present, it must either match the name of the entity in this
4741 declaration, or alternatively, the pragma can immediately follow an enumeration
4742 type declaration, where the Entity argument names one of the enumeration
4745 This pragma is used to indicate that the named entity
4746 is considered obsolescent and should not be used. Typically this is
4747 used when an API must be modified by eventually removing or modifying
4748 existing subprograms or other entities. The pragma can be used at an
4749 intermediate stage when the entity is still present, but will be
4752 The effect of this pragma is to output a warning message on a reference to
4753 an entity thus marked that the subprogram is obsolescent if the appropriate
4754 warning option in the compiler is activated. If the Message parameter is
4755 present, then a second warning message is given containing this text. In
4756 addition, a reference to the entity is considered to be a violation of pragma
4757 Restrictions (No_Obsolescent_Features).
4759 This pragma can also be used as a program unit pragma for a package,
4760 in which case the entity name is the name of the package, and the
4761 pragma indicates that the entire package is considered
4762 obsolescent. In this case a client @code{with}'ing such a package
4763 violates the restriction, and the @code{with} statement is
4764 flagged with warnings if the warning option is set.
4766 If the Version parameter is present (which must be exactly
4767 the identifier Ada_05, no other argument is allowed), then the
4768 indication of obsolescence applies only when compiling in Ada 2005
4769 mode. This is primarily intended for dealing with the situations
4770 in the predefined library where subprograms or packages
4771 have become defined as obsolescent in Ada 2005
4772 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4774 The following examples show typical uses of this pragma:
4776 @smallexample @c ada
4778 pragma Obsolescent (p, Message => "use pp instead of p");
4783 pragma Obsolescent ("use q2new instead");
4785 type R is new integer;
4788 Message => "use RR in Ada 2005",
4798 type E is (a, bc, 'd', quack);
4799 pragma Obsolescent (Entity => bc)
4800 pragma Obsolescent (Entity => 'd')
4803 (a, b : character) return character;
4804 pragma Obsolescent (Entity => "+");
4809 Note that, as for all pragmas, if you use a pragma argument identifier,
4810 then all subsequent parameters must also use a pragma argument identifier.
4811 So if you specify "Entity =>" for the Entity argument, and a Message
4812 argument is present, it must be preceded by "Message =>".
4814 @node Pragma Optimize_Alignment
4815 @unnumberedsec Pragma Optimize_Alignment
4816 @findex Optimize_Alignment
4817 @cindex Alignment, default settings
4821 @smallexample @c ada
4822 pragma Optimize_Alignment (TIME | SPACE | OFF);
4826 This is a configuration pragma which affects the choice of default alignments
4827 for types and objects where no alignment is explicitly specified. There is a
4828 time/space trade-off in the selection of these values. Large alignments result
4829 in more efficient code, at the expense of larger data space, since sizes have
4830 to be increased to match these alignments. Smaller alignments save space, but
4831 the access code is slower. The normal choice of default alignments for types
4832 and individual alignment promotions for objects (which is what you get if you
4833 do not use this pragma, or if you use an argument of OFF), tries to balance
4834 these two requirements.
4836 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4837 First any packed record is given an alignment of 1. Second, if a size is given
4838 for the type, then the alignment is chosen to avoid increasing this size. For
4841 @smallexample @c ada
4851 In the default mode, this type gets an alignment of 4, so that access to the
4852 Integer field X are efficient. But this means that objects of the type end up
4853 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4854 allowed to be bigger than the size of the type, but it can waste space if for
4855 example fields of type R appear in an enclosing record. If the above type is
4856 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4858 However, there is one case in which SPACE is ignored. If a variable length
4859 record (that is a discriminated record with a component which is an array
4860 whose length depends on a discriminant), has a pragma Pack, then it is not
4861 in general possible to set the alignment of such a record to one, so the
4862 pragma is ignored in this case (with a warning).
4864 Specifying SPACE also disables alignment promotions for standalone objects,
4865 which occur when the compiler increases the alignment of a specific object
4866 without changing the alignment of its type.
4868 Specifying TIME causes larger default alignments to be chosen in the case of
4869 small types with sizes that are not a power of 2. For example, consider:
4871 @smallexample @c ada
4883 The default alignment for this record is normally 1, but if this type is
4884 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4885 to 4, which wastes space for objects of the type, since they are now 4 bytes
4886 long, but results in more efficient access when the whole record is referenced.
4888 As noted above, this is a configuration pragma, and there is a requirement
4889 that all units in a partition be compiled with a consistent setting of the
4890 optimization setting. This would normally be achieved by use of a configuration
4891 pragma file containing the appropriate setting. The exception to this rule is
4892 that units with an explicit configuration pragma in the same file as the source
4893 unit are excluded from the consistency check, as are all predefined units. The
4894 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4895 pragma appears at the start of the file.
4897 @node Pragma Ordered
4898 @unnumberedsec Pragma Ordered
4900 @findex pragma @code{Ordered}
4904 @smallexample @c ada
4905 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4909 Most enumeration types are from a conceptual point of view unordered.
4910 For example, consider:
4912 @smallexample @c ada
4913 type Color is (Red, Blue, Green, Yellow);
4917 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4918 but really these relations make no sense; the enumeration type merely
4919 specifies a set of possible colors, and the order is unimportant.
4921 For unordered enumeration types, it is generally a good idea if
4922 clients avoid comparisons (other than equality or inequality) and
4923 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4924 other than the unit where the type is declared, its body, and its subunits.)
4925 For example, if code buried in some client says:
4927 @smallexample @c ada
4928 if Current_Color < Yellow then ...
4929 if Current_Color in Blue .. Green then ...
4933 then the client code is relying on the order, which is undesirable.
4934 It makes the code hard to read and creates maintenance difficulties if
4935 entries have to be added to the enumeration type. Instead,
4936 the code in the client should list the possibilities, or an
4937 appropriate subtype should be declared in the unit that declares
4938 the original enumeration type. E.g., the following subtype could
4939 be declared along with the type @code{Color}:
4941 @smallexample @c ada
4942 subtype RBG is Color range Red .. Green;
4946 and then the client could write:
4948 @smallexample @c ada
4949 if Current_Color in RBG then ...
4950 if Current_Color = Blue or Current_Color = Green then ...
4954 However, some enumeration types are legitimately ordered from a conceptual
4955 point of view. For example, if you declare:
4957 @smallexample @c ada
4958 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4962 then the ordering imposed by the language is reasonable, and
4963 clients can depend on it, writing for example:
4965 @smallexample @c ada
4966 if D in Mon .. Fri then ...
4971 The pragma @option{Ordered} is provided to mark enumeration types that
4972 are conceptually ordered, alerting the reader that clients may depend
4973 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4974 rather than one to mark them as unordered, since in our experience,
4975 the great majority of enumeration types are conceptually unordered.
4977 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4978 and @code{Wide_Wide_Character}
4979 are considered to be ordered types, so each is declared with a
4980 pragma @code{Ordered} in package @code{Standard}.
4982 Normally pragma @code{Ordered} serves only as documentation and a guide for
4983 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4984 requests warnings for inappropriate uses (comparisons and explicit
4985 subranges) for unordered types. If this switch is used, then any
4986 enumeration type not marked with pragma @code{Ordered} will be considered
4987 as unordered, and will generate warnings for inappropriate uses.
4989 For additional information please refer to the description of the
4990 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4992 @node Pragma Overflow_Mode
4993 @unnumberedsec Pragma Overflow_Mode
4994 @findex Overflow checks
4995 @findex Overflow mode
4996 @findex pragma @code{Overflow_Mode}
5000 @smallexample @c ada
5001 pragma Overflow_Mode
5003 [,[Assertions =>] MODE]);
5005 MODE ::= STRICT | MINIMIZED | ELIMINATED
5009 This pragma sets the current overflow mode to the given setting. For details
5010 of the meaning of these modes, please refer to the
5011 ``Overflow Check Handling in GNAT'' appendix in the
5012 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5013 the given mode applies to all expressions. If both parameters are present,
5014 the @code{General} mode applies to expressions outside assertions, and
5015 the @code{Eliminated} mode applies to expressions within assertions.
5017 The case of the @code{MODE} parameter is ignored,
5018 so @code{MINIMIZED}, @code{Minimized} and
5019 @code{minimized} all have the same effect.
5021 The @code{Overflow_Mode} pragma has the same scoping and placement
5022 rules as pragma @code{Suppress}, so it can occur either as a
5023 configuration pragma, specifying a default for the whole
5024 program, or in a declarative scope, where it applies to the
5025 remaining declarations and statements in that scope.
5027 The pragma @code{Suppress (Overflow_Check)} suppresses
5028 overflow checking, but does not affect the overflow mode.
5030 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5031 overflow checking, but does not affect the overflow mode.
5033 @node Pragma Overriding_Renamings
5034 @unnumberedsec Pragma Overriding_Renamings
5035 @findex Overriding_Renamings
5036 @cindex Rational profile
5037 @cindex Rational compatibility
5041 @smallexample @c ada
5042 pragma Overriding_Renamings;
5046 This is a GNAT configuration pragma to simplify porting
5047 legacy code accepted by the Rational
5048 Ada compiler. In the presence of this pragma, a renaming declaration that
5049 renames an inherited operation declared in the same scope is legal if selected
5050 notation is used as in:
5052 @smallexample @c ada
5053 pragma Overriding_Renamings;
5058 function F (..) renames R.F;
5063 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5064 declaration of the overriding operation.
5066 @node Pragma Partition_Elaboration_Policy
5067 @unnumberedsec Pragma Partition_Elaboration_Policy
5068 @findex Partition_Elaboration_Policy
5072 @smallexample @c ada
5073 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5075 POLICY_IDENTIFIER ::= Concurrent | Sequential
5079 This pragma is standard in Ada 2005, but is available in all earlier
5080 versions of Ada as an implementation-defined pragma.
5081 See Ada 2012 Reference Manual for details.
5083 @node Pragma Passive
5084 @unnumberedsec Pragma Passive
5089 @smallexample @c ada
5090 pragma Passive [(Semaphore | No)];
5094 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
5095 compatibility with DEC Ada 83 implementations, where it is used within a
5096 task definition to request that a task be made passive. If the argument
5097 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5098 treats the pragma as an assertion that the containing task is passive
5099 and that optimization of context switch with this task is permitted and
5100 desired. If the argument @code{No} is present, the task must not be
5101 optimized. GNAT does not attempt to optimize any tasks in this manner
5102 (since protected objects are available in place of passive tasks).
5104 For more information on the subject of passive tasks, see the section
5105 ``Passive Task Optimization'' in the GNAT Users Guide.
5107 @node Pragma Persistent_BSS
5108 @unnumberedsec Pragma Persistent_BSS
5109 @findex Persistent_BSS
5113 @smallexample @c ada
5114 pragma Persistent_BSS [(LOCAL_NAME)]
5118 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5119 section. On some targets the linker and loader provide for special
5120 treatment of this section, allowing a program to be reloaded without
5121 affecting the contents of this data (hence the name persistent).
5123 There are two forms of usage. If an argument is given, it must be the
5124 local name of a library level object, with no explicit initialization
5125 and whose type is potentially persistent. If no argument is given, then
5126 the pragma is a configuration pragma, and applies to all library level
5127 objects with no explicit initialization of potentially persistent types.
5129 A potentially persistent type is a scalar type, or a non-tagged,
5130 non-discriminated record, all of whose components have no explicit
5131 initialization and are themselves of a potentially persistent type,
5132 or an array, all of whose constraints are static, and whose component
5133 type is potentially persistent.
5135 If this pragma is used on a target where this feature is not supported,
5136 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5138 @node Pragma Polling
5139 @unnumberedsec Pragma Polling
5144 @smallexample @c ada
5145 pragma Polling (ON | OFF);
5149 This pragma controls the generation of polling code. This is normally off.
5150 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5151 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
5152 runtime library, and can be found in file @file{a-excpol.adb}.
5154 Pragma @code{Polling} can appear as a configuration pragma (for example it
5155 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5156 can be used in the statement or declaration sequence to control polling
5159 A call to the polling routine is generated at the start of every loop and
5160 at the start of every subprogram call. This guarantees that the @code{Poll}
5161 routine is called frequently, and places an upper bound (determined by
5162 the complexity of the code) on the period between two @code{Poll} calls.
5164 The primary purpose of the polling interface is to enable asynchronous
5165 aborts on targets that cannot otherwise support it (for example Windows
5166 NT), but it may be used for any other purpose requiring periodic polling.
5167 The standard version is null, and can be replaced by a user program. This
5168 will require re-compilation of the @code{Ada.Exceptions} package that can
5169 be found in files @file{a-except.ads} and @file{a-except.adb}.
5171 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5172 distribution) is used to enable the asynchronous abort capability on
5173 targets that do not normally support the capability. The version of
5174 @code{Poll} in this file makes a call to the appropriate runtime routine
5175 to test for an abort condition.
5177 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5178 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5182 @unnumberedsec Pragma Post
5184 @cindex Checks, postconditions
5185 @findex Postconditions
5189 @smallexample @c ada
5190 pragma Post (Boolean_Expression);
5194 The @code{Post} pragma is intended to be an exact replacement for
5195 the language-defined
5196 @code{Post} aspect, and shares its restrictions and semantics.
5197 It must appear either immediately following the corresponding
5198 subprogram declaration (only other pragmas may intervene), or
5199 if there is no separate subprogram declaration, then it can
5200 appear at the start of the declarations in a subprogram body
5201 (preceded only by other pragmas).
5203 @node Pragma Postcondition
5204 @unnumberedsec Pragma Postcondition
5205 @cindex Postcondition
5206 @cindex Checks, postconditions
5207 @findex Postconditions
5211 @smallexample @c ada
5212 pragma Postcondition (
5213 [Check =>] Boolean_Expression
5214 [,[Message =>] String_Expression]);
5218 The @code{Postcondition} pragma allows specification of automatic
5219 postcondition checks for subprograms. These checks are similar to
5220 assertions, but are automatically inserted just prior to the return
5221 statements of the subprogram with which they are associated (including
5222 implicit returns at the end of procedure bodies and associated
5223 exception handlers).
5225 In addition, the boolean expression which is the condition which
5226 must be true may contain references to function'Result in the case
5227 of a function to refer to the returned value.
5229 @code{Postcondition} pragmas may appear either immediately following the
5230 (separate) declaration of a subprogram, or at the start of the
5231 declarations of a subprogram body. Only other pragmas may intervene
5232 (that is appear between the subprogram declaration and its
5233 postconditions, or appear before the postcondition in the
5234 declaration sequence in a subprogram body). In the case of a
5235 postcondition appearing after a subprogram declaration, the
5236 formal arguments of the subprogram are visible, and can be
5237 referenced in the postcondition expressions.
5239 The postconditions are collected and automatically tested just
5240 before any return (implicit or explicit) in the subprogram body.
5241 A postcondition is only recognized if postconditions are active
5242 at the time the pragma is encountered. The compiler switch @option{gnata}
5243 turns on all postconditions by default, and pragma @code{Check_Policy}
5244 with an identifier of @code{Postcondition} can also be used to
5245 control whether postconditions are active.
5247 The general approach is that postconditions are placed in the spec
5248 if they represent functional aspects which make sense to the client.
5249 For example we might have:
5251 @smallexample @c ada
5252 function Direction return Integer;
5253 pragma Postcondition
5254 (Direction'Result = +1
5256 Direction'Result = -1);
5260 which serves to document that the result must be +1 or -1, and
5261 will test that this is the case at run time if postcondition
5264 Postconditions within the subprogram body can be used to
5265 check that some internal aspect of the implementation,
5266 not visible to the client, is operating as expected.
5267 For instance if a square root routine keeps an internal
5268 counter of the number of times it is called, then we
5269 might have the following postcondition:
5271 @smallexample @c ada
5272 Sqrt_Calls : Natural := 0;
5274 function Sqrt (Arg : Float) return Float is
5275 pragma Postcondition
5276 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5282 As this example, shows, the use of the @code{Old} attribute
5283 is often useful in postconditions to refer to the state on
5284 entry to the subprogram.
5286 Note that postconditions are only checked on normal returns
5287 from the subprogram. If an abnormal return results from
5288 raising an exception, then the postconditions are not checked.
5290 If a postcondition fails, then the exception
5291 @code{System.Assertions.Assert_Failure} is raised. If
5292 a message argument was supplied, then the given string
5293 will be used as the exception message. If no message
5294 argument was supplied, then the default message has
5295 the form "Postcondition failed at file:line". The
5296 exception is raised in the context of the subprogram
5297 body, so it is possible to catch postcondition failures
5298 within the subprogram body itself.
5300 Within a package spec, normal visibility rules
5301 in Ada would prevent forward references within a
5302 postcondition pragma to functions defined later in
5303 the same package. This would introduce undesirable
5304 ordering constraints. To avoid this problem, all
5305 postcondition pragmas are analyzed at the end of
5306 the package spec, allowing forward references.
5308 The following example shows that this even allows
5309 mutually recursive postconditions as in:
5311 @smallexample @c ada
5312 package Parity_Functions is
5313 function Odd (X : Natural) return Boolean;
5314 pragma Postcondition
5318 (x /= 0 and then Even (X - 1))));
5320 function Even (X : Natural) return Boolean;
5321 pragma Postcondition
5325 (x /= 1 and then Odd (X - 1))));
5327 end Parity_Functions;
5331 There are no restrictions on the complexity or form of
5332 conditions used within @code{Postcondition} pragmas.
5333 The following example shows that it is even possible
5334 to verify performance behavior.
5336 @smallexample @c ada
5339 Performance : constant Float;
5340 -- Performance constant set by implementation
5341 -- to match target architecture behavior.
5343 procedure Treesort (Arg : String);
5344 -- Sorts characters of argument using N*logN sort
5345 pragma Postcondition
5346 (Float (Clock - Clock'Old) <=
5347 Float (Arg'Length) *
5348 log (Float (Arg'Length)) *
5354 Note: postcondition pragmas associated with subprograms that are
5355 marked as Inline_Always, or those marked as Inline with front-end
5356 inlining (-gnatN option set) are accepted and legality-checked
5357 by the compiler, but are ignored at run-time even if postcondition
5358 checking is enabled.
5360 Note that pragma @code{Postcondition} differs from the language-defined
5361 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5362 multiple occurrences, allowing occurences in the body even if there
5363 is a separate spec, and allowing a second string parameter, and the
5364 use of the pragma identifier @code{Check}. Historically, pragma
5365 @code{Postcondition} was implemented prior to the development of
5366 Ada 2012, and has been retained in its original form for
5367 compatibility purposes.
5369 @node Pragma Post_Class
5370 @unnumberedsec Pragma Post_Class
5372 @cindex Checks, postconditions
5373 @findex Postconditions
5377 @smallexample @c ada
5378 pragma Post_Class (Boolean_Expression);
5382 The @code{Post_Class} pragma is intended to be an exact replacement for
5383 the language-defined
5384 @code{Post'Class} aspect, and shares its restrictions and semantics.
5385 It must appear either immediately following the corresponding
5386 subprogram declaration (only other pragmas may intervene), or
5387 if there is no separate subprogram declaration, then it can
5388 appear at the start of the declarations in a subprogram body
5389 (preceded only by other pragmas).
5391 Note: This pragma is called @code{Post_Class} rather than
5392 @code{Post'Class} because the latter would not be strictly
5393 conforming to the allowed syntax for pragmas. The motivation
5394 for provinding pragmas equivalent to the aspects is to allow a program
5395 to be written using the pragmas, and then compiled if necessary
5396 using an Ada compiler that does not recognize the pragmas or
5397 aspects, but is prepared to ignore the pragmas. The assertion
5398 policy that controls this pragma is @code{Post'Class}, not
5402 @unnumberedsec Pragma Pre
5404 @cindex Checks, preconditions
5405 @findex Preconditions
5409 @smallexample @c ada
5410 pragma Pre (Boolean_Expression);
5414 The @code{Pre} pragma is intended to be an exact replacement for
5415 the language-defined
5416 @code{Pre} aspect, and shares its restrictions and semantics.
5417 It must appear either immediately following the corresponding
5418 subprogram declaration (only other pragmas may intervene), or
5419 if there is no separate subprogram declaration, then it can
5420 appear at the start of the declarations in a subprogram body
5421 (preceded only by other pragmas).
5423 @node Pragma Precondition
5424 @unnumberedsec Pragma Precondition
5425 @cindex Preconditions
5426 @cindex Checks, preconditions
5427 @findex Preconditions
5431 @smallexample @c ada
5432 pragma Precondition (
5433 [Check =>] Boolean_Expression
5434 [,[Message =>] String_Expression]);
5438 The @code{Precondition} pragma is similar to @code{Postcondition}
5439 except that the corresponding checks take place immediately upon
5440 entry to the subprogram, and if a precondition fails, the exception
5441 is raised in the context of the caller, and the attribute 'Result
5442 cannot be used within the precondition expression.
5444 Otherwise, the placement and visibility rules are identical to those
5445 described for postconditions. The following is an example of use
5446 within a package spec:
5448 @smallexample @c ada
5449 package Math_Functions is
5451 function Sqrt (Arg : Float) return Float;
5452 pragma Precondition (Arg >= 0.0)
5458 @code{Precondition} pragmas may appear either immediately following the
5459 (separate) declaration of a subprogram, or at the start of the
5460 declarations of a subprogram body. Only other pragmas may intervene
5461 (that is appear between the subprogram declaration and its
5462 postconditions, or appear before the postcondition in the
5463 declaration sequence in a subprogram body).
5465 Note: precondition pragmas associated with subprograms that are
5466 marked as Inline_Always, or those marked as Inline with front-end
5467 inlining (-gnatN option set) are accepted and legality-checked
5468 by the compiler, but are ignored at run-time even if precondition
5469 checking is enabled.
5471 Note that pragma @code{Precondition} differs from the language-defined
5472 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5473 multiple occurrences, allowing occurences in the body even if there
5474 is a separate spec, and allowing a second string parameter, and the
5475 use of the pragma identifier @code{Check}. Historically, pragma
5476 @code{Precondition} was implemented prior to the development of
5477 Ada 2012, and has been retained in its original form for
5478 compatibility purposes.
5480 @node Pragma Predicate
5481 @unnumberedsec Pragma Predicate
5483 @findex Predicate pragma
5487 @smallexample @c ada
5489 ([Entity =>] type_LOCAL_NAME,
5490 [Check =>] EXPRESSION);
5494 This pragma (available in all versions of Ada in GNAT) encompasses both
5495 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5496 Ada 2012. A predicate is regarded as static if it has an allowed form
5497 for @code{Static_Predicate} and is otherwise treated as a
5498 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5499 pragma behave exactly as described in the Ada 2012 reference manual.
5500 For example, if we have
5502 @smallexample @c ada
5503 type R is range 1 .. 10;
5505 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5507 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5511 the effect is identical to the following Ada 2012 code:
5513 @smallexample @c ada
5514 type R is range 1 .. 10;
5516 Static_Predicate => S not in 4 .. 6;
5518 Dynamic_Predicate => F(Q) or G(Q);
5521 Note that there is are no pragmas @code{Dynamic_Predicate}
5522 or @code{Static_Predicate}. That is
5523 because these pragmas would affect legality and semantics of
5524 the program and thus do not have a neutral effect if ignored.
5525 The motivation behind providing pragmas equivalent to
5526 corresponding aspects is to allow a program to be written
5527 using the pragmas, and then compiled with a compiler that
5528 will ignore the pragmas. That doesn't work in the case of
5529 static and dynamic predicates, since if the corresponding
5530 pragmas are ignored, then the behavior of the program is
5531 fundamentally changed (for example a membership test
5532 @code{A in B} would not take into account a predicate
5533 defined for subtype B). When following this approach, the
5534 use of predicates should be avoided.
5536 @node Pragma Preelaborable_Initialization
5537 @unnumberedsec Pragma Preelaborable_Initialization
5538 @findex Preelaborable_Initialization
5542 @smallexample @c ada
5543 pragma Preelaborable_Initialization (DIRECT_NAME);
5547 This pragma is standard in Ada 2005, but is available in all earlier
5548 versions of Ada as an implementation-defined pragma.
5549 See Ada 2012 Reference Manual for details.
5551 @node Pragma Preelaborate_05
5552 @unnumberedsec Pragma Preelaborate_05
5553 @findex Preelaborate_05
5557 @smallexample @c ada
5558 pragma Preelaborate_05 [(library_unit_NAME)];
5562 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5563 and is intended for use in the standard run-time library only. It has
5564 no effect in Ada 83 or Ada 95 mode, but is
5565 equivalent to @code{pragma Prelaborate} when operating in later
5566 Ada versions. This is used to handle some cases where packages
5567 not previously preelaborable became so in Ada 2005.
5569 @node Pragma Pre_Class
5570 @unnumberedsec Pragma Pre_Class
5572 @cindex Checks, preconditions
5573 @findex Preconditions
5577 @smallexample @c ada
5578 pragma Pre_Class (Boolean_Expression);
5582 The @code{Pre_Class} pragma is intended to be an exact replacement for
5583 the language-defined
5584 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5585 It must appear either immediately following the corresponding
5586 subprogram declaration (only other pragmas may intervene), or
5587 if there is no separate subprogram declaration, then it can
5588 appear at the start of the declarations in a subprogram body
5589 (preceded only by other pragmas).
5591 Note: This pragma is called @code{Pre_Class} rather than
5592 @code{Pre'Class} because the latter would not be strictly
5593 conforming to the allowed syntax for pragmas. The motivation
5594 for providing pragmas equivalent to the aspects is to allow a program
5595 to be written using the pragmas, and then compiled if necessary
5596 using an Ada compiler that does not recognize the pragmas or
5597 aspects, but is prepared to ignore the pragmas. The assertion
5598 policy that controls this pragma is @code{Pre'Class}, not
5601 @node Pragma Priority_Specific_Dispatching
5602 @unnumberedsec Pragma Priority_Specific_Dispatching
5603 @findex Priority_Specific_Dispatching
5607 @smallexample @c ada
5608 pragma Priority_Specific_Dispatching (
5610 first_priority_EXPRESSION,
5611 last_priority_EXPRESSION)
5613 POLICY_IDENTIFIER ::=
5614 EDF_Across_Priorities |
5615 FIFO_Within_Priorities |
5616 Non_Preemptive_Within_Priorities |
5617 Round_Robin_Within_Priorities
5621 This pragma is standard in Ada 2005, but is available in all earlier
5622 versions of Ada as an implementation-defined pragma.
5623 See Ada 2012 Reference Manual for details.
5625 @node Pragma Profile
5626 @unnumberedsec Pragma Profile
5631 @smallexample @c ada
5632 pragma Profile (Ravenscar | Restricted | Rational);
5636 This pragma is standard in Ada 2005, but is available in all earlier
5637 versions of Ada as an implementation-defined pragma. This is a
5638 configuration pragma that establishes a set of configiuration pragmas
5639 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5640 The other two possibilities (@code{Restricted} or @code{Rational})
5641 are implementation-defined. The set of configuration pragmas
5642 is defined in the following sections.
5646 @item Pragma Profile (Ravenscar)
5650 The @code{Ravenscar} profile is standard in Ada 2005,
5651 but is available in all earlier
5652 versions of Ada as an implementation-defined pragma. This profile
5653 establishes the following set of configuration pragmas:
5656 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5657 [RM D.2.2] Tasks are dispatched following a preemptive
5658 priority-ordered scheduling policy.
5660 @item Locking_Policy (Ceiling_Locking)
5661 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5662 the ceiling priority of the corresponding protected object.
5664 @item Detect_Blocking
5665 This pragma forces the detection of potentially blocking operations within a
5666 protected operation, and to raise Program_Error if that happens.
5670 plus the following set of restrictions:
5673 @item Max_Entry_Queue_Length => 1
5674 No task can be queued on a protected entry.
5675 @item Max_Protected_Entries => 1
5676 @item Max_Task_Entries => 0
5677 No rendezvous statements are allowed.
5678 @item No_Abort_Statements
5679 @item No_Dynamic_Attachment
5680 @item No_Dynamic_Priorities
5681 @item No_Implicit_Heap_Allocations
5682 @item No_Local_Protected_Objects
5683 @item No_Local_Timing_Events
5684 @item No_Protected_Type_Allocators
5685 @item No_Relative_Delay
5686 @item No_Requeue_Statements
5687 @item No_Select_Statements
5688 @item No_Specific_Termination_Handlers
5689 @item No_Task_Allocators
5690 @item No_Task_Hierarchy
5691 @item No_Task_Termination
5692 @item Simple_Barriers
5696 The Ravenscar profile also includes the following restrictions that specify
5697 that there are no semantic dependences on the corresponding predefined
5701 @item No_Dependence => Ada.Asynchronous_Task_Control
5702 @item No_Dependence => Ada.Calendar
5703 @item No_Dependence => Ada.Execution_Time.Group_Budget
5704 @item No_Dependence => Ada.Execution_Time.Timers
5705 @item No_Dependence => Ada.Task_Attributes
5706 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5711 This set of configuration pragmas and restrictions correspond to the
5712 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5713 published by the @cite{International Real-Time Ada Workshop}, 1997,
5714 and whose most recent description is available at
5715 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5717 The original definition of the profile was revised at subsequent IRTAW
5718 meetings. It has been included in the ISO
5719 @cite{Guide for the Use of the Ada Programming Language in High
5720 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5721 the next revision of the standard. The formal definition given by
5722 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5723 AI-305) available at
5724 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5725 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5727 The above set is a superset of the restrictions provided by pragma
5728 @code{Profile (Restricted)}, it includes six additional restrictions
5729 (@code{Simple_Barriers}, @code{No_Select_Statements},
5730 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5731 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5732 that pragma @code{Profile (Ravenscar)}, like the pragma
5733 @code{Profile (Restricted)},
5734 automatically causes the use of a simplified,
5735 more efficient version of the tasking run-time system.
5737 @item Pragma Profile (Restricted)
5738 @findex Restricted Run Time
5740 This profile corresponds to the GNAT restricted run time. It
5741 establishes the following set of restrictions:
5744 @item No_Abort_Statements
5745 @item No_Entry_Queue
5746 @item No_Task_Hierarchy
5747 @item No_Task_Allocators
5748 @item No_Dynamic_Priorities
5749 @item No_Terminate_Alternatives
5750 @item No_Dynamic_Attachment
5751 @item No_Protected_Type_Allocators
5752 @item No_Local_Protected_Objects
5753 @item No_Requeue_Statements
5754 @item No_Task_Attributes_Package
5755 @item Max_Asynchronous_Select_Nesting = 0
5756 @item Max_Task_Entries = 0
5757 @item Max_Protected_Entries = 1
5758 @item Max_Select_Alternatives = 0
5762 This set of restrictions causes the automatic selection of a simplified
5763 version of the run time that provides improved performance for the
5764 limited set of tasking functionality permitted by this set of restrictions.
5766 @item Pragma Profile (Rational)
5767 @findex Rational compatibility mode
5769 The Rational profile is intended to facilitate porting legacy code that
5770 compiles with the Rational APEX compiler, even when the code includes non-
5771 conforming Ada constructs. The profile enables the following three pragmas:
5774 @item pragma Implicit_Packing
5775 @item pragma Overriding_Renamings
5776 @item pragma Use_VADS_Size
5781 @node Pragma Profile_Warnings
5782 @unnumberedsec Pragma Profile_Warnings
5783 @findex Profile_Warnings
5787 @smallexample @c ada
5788 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5792 This is an implementation-defined pragma that is similar in
5793 effect to @code{pragma Profile} except that instead of
5794 generating @code{Restrictions} pragmas, it generates
5795 @code{Restriction_Warnings} pragmas. The result is that
5796 violations of the profile generate warning messages instead
5799 @node Pragma Propagate_Exceptions
5800 @unnumberedsec Pragma Propagate_Exceptions
5801 @cindex Interfacing to C++
5802 @findex Propagate_Exceptions
5806 @smallexample @c ada
5807 pragma Propagate_Exceptions;
5811 This pragma is now obsolete and, other than generating a warning if warnings
5812 on obsolescent features are enabled, is ignored.
5813 It is retained for compatibility
5814 purposes. It used to be used in connection with optimization of
5815 a now-obsolete mechanism for implementation of exceptions.
5817 @node Pragma Psect_Object
5818 @unnumberedsec Pragma Psect_Object
5819 @findex Psect_Object
5823 @smallexample @c ada
5824 pragma Psect_Object (
5825 [Internal =>] LOCAL_NAME,
5826 [, [External =>] EXTERNAL_SYMBOL]
5827 [, [Size =>] EXTERNAL_SYMBOL]);
5831 | static_string_EXPRESSION
5835 This pragma is identical in effect to pragma @code{Common_Object}.
5837 @node Pragma Pure_05
5838 @unnumberedsec Pragma Pure_05
5843 @smallexample @c ada
5844 pragma Pure_05 [(library_unit_NAME)];
5848 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5849 and is intended for use in the standard run-time library only. It has
5850 no effect in Ada 83 or Ada 95 mode, but is
5851 equivalent to @code{pragma Pure} when operating in later
5852 Ada versions. This is used to handle some cases where packages
5853 not previously pure became so in Ada 2005.
5855 @node Pragma Pure_12
5856 @unnumberedsec Pragma Pure_12
5861 @smallexample @c ada
5862 pragma Pure_12 [(library_unit_NAME)];
5866 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5867 and is intended for use in the standard run-time library only. It has
5868 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5869 equivalent to @code{pragma Pure} when operating in later
5870 Ada versions. This is used to handle some cases where packages
5871 not previously pure became so in Ada 2012.
5873 @node Pragma Pure_Function
5874 @unnumberedsec Pragma Pure_Function
5875 @findex Pure_Function
5879 @smallexample @c ada
5880 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5884 This pragma appears in the same declarative part as a function
5885 declaration (or a set of function declarations if more than one
5886 overloaded declaration exists, in which case the pragma applies
5887 to all entities). It specifies that the function @code{Entity} is
5888 to be considered pure for the purposes of code generation. This means
5889 that the compiler can assume that there are no side effects, and
5890 in particular that two calls with identical arguments produce the
5891 same result. It also means that the function can be used in an
5894 Note that, quite deliberately, there are no static checks to try
5895 to ensure that this promise is met, so @code{Pure_Function} can be used
5896 with functions that are conceptually pure, even if they do modify
5897 global variables. For example, a square root function that is
5898 instrumented to count the number of times it is called is still
5899 conceptually pure, and can still be optimized, even though it
5900 modifies a global variable (the count). Memo functions are another
5901 example (where a table of previous calls is kept and consulted to
5902 avoid re-computation).
5904 Note also that the normal rules excluding optimization of subprograms
5905 in pure units (when parameter types are descended from System.Address,
5906 or when the full view of a parameter type is limited), do not apply
5907 for the Pure_Function case. If you explicitly specify Pure_Function,
5908 the compiler may optimize away calls with identical arguments, and
5909 if that results in unexpected behavior, the proper action is not to
5910 use the pragma for subprograms that are not (conceptually) pure.
5913 Note: Most functions in a @code{Pure} package are automatically pure, and
5914 there is no need to use pragma @code{Pure_Function} for such functions. One
5915 exception is any function that has at least one formal of type
5916 @code{System.Address} or a type derived from it. Such functions are not
5917 considered pure by default, since the compiler assumes that the
5918 @code{Address} parameter may be functioning as a pointer and that the
5919 referenced data may change even if the address value does not.
5920 Similarly, imported functions are not considered to be pure by default,
5921 since there is no way of checking that they are in fact pure. The use
5922 of pragma @code{Pure_Function} for such a function will override these default
5923 assumption, and cause the compiler to treat a designated subprogram as pure
5926 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5927 applies to the underlying renamed function. This can be used to
5928 disambiguate cases of overloading where some but not all functions
5929 in a set of overloaded functions are to be designated as pure.
5931 If pragma @code{Pure_Function} is applied to a library level function, the
5932 function is also considered pure from an optimization point of view, but the
5933 unit is not a Pure unit in the categorization sense. So for example, a function
5934 thus marked is free to @code{with} non-pure units.
5936 @node Pragma Ravenscar
5937 @unnumberedsec Pragma Ravenscar
5938 @findex Pragma Ravenscar
5942 @smallexample @c ada
5947 This pragma is considered obsolescent, but is retained for
5948 compatibility purposes. It is equivalent to:
5950 @smallexample @c ada
5951 pragma Profile (Ravenscar);
5955 which is the preferred method of setting the @code{Ravenscar} profile.
5957 @node Pragma Refined_State
5958 @unnumberedsec Pragma Refined_State
5959 @findex Refined_State
5961 For the description of this pragma, see SPARK 2014 Reference Manual,
5964 @node Pragma Relative_Deadline
5965 @unnumberedsec Pragma Relative_Deadline
5966 @findex Relative_Deadline
5970 @smallexample @c ada
5971 pragma Relative_Deadline (time_span_EXPRESSION);
5975 This pragma is standard in Ada 2005, but is available in all earlier
5976 versions of Ada as an implementation-defined pragma.
5977 See Ada 2012 Reference Manual for details.
5979 @node Pragma Remote_Access_Type
5980 @unnumberedsec Pragma Remote_Access_Type
5981 @findex Remote_Access_Type
5985 @smallexample @c ada
5986 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5990 This pragma appears in the formal part of a generic declaration.
5991 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5992 the use of a remote access to class-wide type as actual for a formal
5995 When this pragma applies to a formal access type @code{Entity}, that
5996 type is treated as a remote access to class-wide type in the generic.
5997 It must be a formal general access type, and its designated type must
5998 be the class-wide type of a formal tagged limited private type from the
5999 same generic declaration.
6001 In the generic unit, the formal type is subject to all restrictions
6002 pertaining to remote access to class-wide types. At instantiation, the
6003 actual type must be a remote access to class-wide type.
6005 @node Pragma Restricted_Run_Time
6006 @unnumberedsec Pragma Restricted_Run_Time
6007 @findex Pragma Restricted_Run_Time
6011 @smallexample @c ada
6012 pragma Restricted_Run_Time;
6016 This pragma is considered obsolescent, but is retained for
6017 compatibility purposes. It is equivalent to:
6019 @smallexample @c ada
6020 pragma Profile (Restricted);
6024 which is the preferred method of setting the restricted run time
6027 @node Pragma Restriction_Warnings
6028 @unnumberedsec Pragma Restriction_Warnings
6029 @findex Restriction_Warnings
6033 @smallexample @c ada
6034 pragma Restriction_Warnings
6035 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6039 This pragma allows a series of restriction identifiers to be
6040 specified (the list of allowed identifiers is the same as for
6041 pragma @code{Restrictions}). For each of these identifiers
6042 the compiler checks for violations of the restriction, but
6043 generates a warning message rather than an error message
6044 if the restriction is violated.
6046 One use of this is in situations where you want to know
6047 about violations of a restriction, but you want to ignore some of
6048 these violations. Consider this example, where you want to set
6049 Ada_95 mode and enable style checks, but you want to know about
6050 any other use of implementation pragmas:
6052 @smallexample @c ada
6053 pragma Restriction_Warnings (No_Implementation_Pragmas);
6054 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6056 pragma Style_Checks ("2bfhkM160");
6057 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6061 By including the above lines in a configuration pragmas file,
6062 the Ada_95 and Style_Checks pragmas are accepted without
6063 generating a warning, but any other use of implementation
6064 defined pragmas will cause a warning to be generated.
6066 @node Pragma Share_Generic
6067 @unnumberedsec Pragma Share_Generic
6068 @findex Share_Generic
6072 @smallexample @c ada
6073 pragma Share_Generic (GNAME @{, GNAME@});
6075 GNAME ::= generic_unit_NAME | generic_instance_NAME
6079 This pragma is provided for compatibility with Dec Ada 83. It has
6080 no effect in @code{GNAT} (which does not implement shared generics), other
6081 than to check that the given names are all names of generic units or
6085 @unnumberedsec Pragma Shared
6089 This pragma is provided for compatibility with Ada 83. The syntax and
6090 semantics are identical to pragma Atomic.
6092 @node Pragma Short_Circuit_And_Or
6093 @unnumberedsec Pragma Short_Circuit_And_Or
6094 @findex Short_Circuit_And_Or
6098 @smallexample @c ada
6099 pragma Short_Circuit_And_Or;
6103 This configuration pragma causes any occurrence of the AND operator applied to
6104 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6105 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6106 may be useful in the context of certification protocols requiring the use of
6107 short-circuited logical operators. If this configuration pragma occurs locally
6108 within the file being compiled, it applies only to the file being compiled.
6109 There is no requirement that all units in a partition use this option.
6111 @node Pragma Short_Descriptors
6112 @unnumberedsec Pragma Short_Descriptors
6113 @findex Short_Descriptors
6117 @smallexample @c ada
6118 pragma Short_Descriptors
6122 In VMS versions of the compiler, this configuration pragma causes all
6123 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6124 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6125 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6128 @node Pragma Simple_Storage_Pool_Type
6129 @unnumberedsec Pragma Simple_Storage_Pool_Type
6130 @findex Simple_Storage_Pool_Type
6131 @cindex Storage pool, simple
6132 @cindex Simple storage pool
6136 @smallexample @c ada
6137 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6141 A type can be established as a ``simple storage pool type'' by applying
6142 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6143 A type named in the pragma must be a library-level immutably limited record
6144 type or limited tagged type declared immediately within a package declaration.
6145 The type can also be a limited private type whose full type is allowed as
6146 a simple storage pool type.
6148 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6149 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6150 are subtype conformant with the following subprogram declarations:
6152 @smallexample @c ada
6155 Storage_Address : out System.Address;
6156 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6157 Alignment : System.Storage_Elements.Storage_Count);
6159 procedure Deallocate
6161 Storage_Address : System.Address;
6162 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6163 Alignment : System.Storage_Elements.Storage_Count);
6165 function Storage_Size (Pool : SSP)
6166 return System.Storage_Elements.Storage_Count;
6170 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6171 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6172 applying an unchecked deallocation has no effect other than to set its actual
6173 parameter to null. If @code{Storage_Size} is not declared, then the
6174 @code{Storage_Size} attribute applied to an access type associated with
6175 a pool object of type SSP returns zero. Additional operations can be declared
6176 for a simple storage pool type (such as for supporting a mark/release
6177 storage-management discipline).
6179 An object of a simple storage pool type can be associated with an access
6180 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6182 @smallexample @c ada
6184 My_Pool : My_Simple_Storage_Pool_Type;
6186 type Acc is access My_Data_Type;
6188 for Acc'Simple_Storage_Pool use My_Pool;
6193 See attribute @code{Simple_Storage_Pool} for further details.
6195 @node Pragma Source_File_Name
6196 @unnumberedsec Pragma Source_File_Name
6197 @findex Source_File_Name
6201 @smallexample @c ada
6202 pragma Source_File_Name (
6203 [Unit_Name =>] unit_NAME,
6204 Spec_File_Name => STRING_LITERAL,
6205 [Index => INTEGER_LITERAL]);
6207 pragma Source_File_Name (
6208 [Unit_Name =>] unit_NAME,
6209 Body_File_Name => STRING_LITERAL,
6210 [Index => INTEGER_LITERAL]);
6214 Use this to override the normal naming convention. It is a configuration
6215 pragma, and so has the usual applicability of configuration pragmas
6216 (i.e.@: it applies to either an entire partition, or to all units in a
6217 compilation, or to a single unit, depending on how it is used.
6218 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
6219 the second argument is required, and indicates whether this is the file
6220 name for the spec or for the body.
6222 The optional Index argument should be used when a file contains multiple
6223 units, and when you do not want to use @code{gnatchop} to separate then
6224 into multiple files (which is the recommended procedure to limit the
6225 number of recompilations that are needed when some sources change).
6226 For instance, if the source file @file{source.ada} contains
6228 @smallexample @c ada
6240 you could use the following configuration pragmas:
6242 @smallexample @c ada
6243 pragma Source_File_Name
6244 (B, Spec_File_Name => "source.ada", Index => 1);
6245 pragma Source_File_Name
6246 (A, Body_File_Name => "source.ada", Index => 2);
6249 Note that the @code{gnatname} utility can also be used to generate those
6250 configuration pragmas.
6252 Another form of the @code{Source_File_Name} pragma allows
6253 the specification of patterns defining alternative file naming schemes
6254 to apply to all files.
6256 @smallexample @c ada
6257 pragma Source_File_Name
6258 ( [Spec_File_Name =>] STRING_LITERAL
6259 [,[Casing =>] CASING_SPEC]
6260 [,[Dot_Replacement =>] STRING_LITERAL]);
6262 pragma Source_File_Name
6263 ( [Body_File_Name =>] STRING_LITERAL
6264 [,[Casing =>] CASING_SPEC]
6265 [,[Dot_Replacement =>] STRING_LITERAL]);
6267 pragma Source_File_Name
6268 ( [Subunit_File_Name =>] STRING_LITERAL
6269 [,[Casing =>] CASING_SPEC]
6270 [,[Dot_Replacement =>] STRING_LITERAL]);
6272 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6276 The first argument is a pattern that contains a single asterisk indicating
6277 the point at which the unit name is to be inserted in the pattern string
6278 to form the file name. The second argument is optional. If present it
6279 specifies the casing of the unit name in the resulting file name string.
6280 The default is lower case. Finally the third argument allows for systematic
6281 replacement of any dots in the unit name by the specified string literal.
6283 Note that Source_File_Name pragmas should not be used if you are using
6284 project files. The reason for this rule is that the project manager is not
6285 aware of these pragmas, and so other tools that use the projet file would not
6286 be aware of the intended naming conventions. If you are using project files,
6287 file naming is controlled by Source_File_Name_Project pragmas, which are
6288 usually supplied automatically by the project manager. A pragma
6289 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6291 For more details on the use of the @code{Source_File_Name} pragma,
6292 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6293 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6296 @node Pragma Source_File_Name_Project
6297 @unnumberedsec Pragma Source_File_Name_Project
6298 @findex Source_File_Name_Project
6301 This pragma has the same syntax and semantics as pragma Source_File_Name.
6302 It is only allowed as a stand alone configuration pragma.
6303 It cannot appear after a @ref{Pragma Source_File_Name}, and
6304 most importantly, once pragma Source_File_Name_Project appears,
6305 no further Source_File_Name pragmas are allowed.
6307 The intention is that Source_File_Name_Project pragmas are always
6308 generated by the Project Manager in a manner consistent with the naming
6309 specified in a project file, and when naming is controlled in this manner,
6310 it is not permissible to attempt to modify this naming scheme using
6311 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6312 known to the project manager).
6314 @node Pragma Source_Reference
6315 @unnumberedsec Pragma Source_Reference
6316 @findex Source_Reference
6320 @smallexample @c ada
6321 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6325 This pragma must appear as the first line of a source file.
6326 @var{integer_literal} is the logical line number of the line following
6327 the pragma line (for use in error messages and debugging
6328 information). @var{string_literal} is a static string constant that
6329 specifies the file name to be used in error messages and debugging
6330 information. This is most notably used for the output of @code{gnatchop}
6331 with the @option{-r} switch, to make sure that the original unchopped
6332 source file is the one referred to.
6334 The second argument must be a string literal, it cannot be a static
6335 string expression other than a string literal. This is because its value
6336 is needed for error messages issued by all phases of the compiler.
6338 @node Pragma SPARK_Mode
6339 @unnumberedsec Pragma SPARK_Mode
6344 @smallexample @c ada
6345 pragma SPARK_Mode [(On | Off)] ;
6349 In general a program can have some parts that are in SPARK 2014 (and
6350 follow all the rules in the SPARK Reference Manual), and some parts
6351 that are full Ada 2012.
6353 The SPARK_Mode pragma is used to identify which parts are in SPARK
6354 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6355 be used in the following places:
6360 As a configuration pragma, in which case it sets the default mode for
6361 all units compiled with this pragma.
6364 Immediately following a library-level subprogram spec
6367 Immediately within a library-level package body
6370 Immediately following the @code{private} keyword of a library-level
6374 Immediately following the @code{begin} keyword of a library-level
6378 Immediately within a library-level subprogram body
6383 Normally a subprogram or package spec/body inherits the current mode
6384 that is active at the point it is declared. But this can be overridden
6385 by pragma within the spec or body as above.
6387 The basic consistency rule is that you can't turn SPARK_Mode back
6388 @code{On}, once you have explicitly (with a pragma) turned if
6389 @code{Off}. So the following rules apply:
6392 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6393 also have SPARK_Mode @code{Off}.
6396 For a package, we have four parts:
6400 the package public declarations
6402 the package private part
6404 the body of the package
6406 the elaboration code after @code{begin}
6410 For a package, the rule is that if you explicitly turn SPARK_Mode
6411 @code{Off} for any part, then all the following parts must have
6412 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6413 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6414 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6415 default everywhere, and one particular package spec has pragma
6416 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6419 @node Pragma Static_Elaboration_Desired
6420 @unnumberedsec Pragma Static_Elaboration_Desired
6421 @findex Static_Elaboration_Desired
6425 @smallexample @c ada
6426 pragma Static_Elaboration_Desired;
6430 This pragma is used to indicate that the compiler should attempt to initialize
6431 statically the objects declared in the library unit to which the pragma applies,
6432 when these objects are initialized (explicitly or implicitly) by an aggregate.
6433 In the absence of this pragma, aggregates in object declarations are expanded
6434 into assignments and loops, even when the aggregate components are static
6435 constants. When the aggregate is present the compiler builds a static expression
6436 that requires no run-time code, so that the initialized object can be placed in
6437 read-only data space. If the components are not static, or the aggregate has
6438 more that 100 components, the compiler emits a warning that the pragma cannot
6439 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6440 construction of larger aggregates with static components that include an others
6443 @node Pragma Stream_Convert
6444 @unnumberedsec Pragma Stream_Convert
6445 @findex Stream_Convert
6449 @smallexample @c ada
6450 pragma Stream_Convert (
6451 [Entity =>] type_LOCAL_NAME,
6452 [Read =>] function_NAME,
6453 [Write =>] function_NAME);
6457 This pragma provides an efficient way of providing user-defined stream
6458 attributes. Not only is it simpler to use than specifying the attributes
6459 directly, but more importantly, it allows the specification to be made in such
6460 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6461 needed (i.e. unless the stream attributes are actually used); the use of
6462 the Stream_Convert pragma adds no overhead at all, unless the stream
6463 attributes are actually used on the designated type.
6465 The first argument specifies the type for which stream functions are
6466 provided. The second parameter provides a function used to read values
6467 of this type. It must name a function whose argument type may be any
6468 subtype, and whose returned type must be the type given as the first
6469 argument to the pragma.
6471 The meaning of the @var{Read} parameter is that if a stream attribute directly
6472 or indirectly specifies reading of the type given as the first parameter,
6473 then a value of the type given as the argument to the Read function is
6474 read from the stream, and then the Read function is used to convert this
6475 to the required target type.
6477 Similarly the @var{Write} parameter specifies how to treat write attributes
6478 that directly or indirectly apply to the type given as the first parameter.
6479 It must have an input parameter of the type specified by the first parameter,
6480 and the return type must be the same as the input type of the Read function.
6481 The effect is to first call the Write function to convert to the given stream
6482 type, and then write the result type to the stream.
6484 The Read and Write functions must not be overloaded subprograms. If necessary
6485 renamings can be supplied to meet this requirement.
6486 The usage of this attribute is best illustrated by a simple example, taken
6487 from the GNAT implementation of package Ada.Strings.Unbounded:
6489 @smallexample @c ada
6490 function To_Unbounded (S : String)
6491 return Unbounded_String
6492 renames To_Unbounded_String;
6494 pragma Stream_Convert
6495 (Unbounded_String, To_Unbounded, To_String);
6499 The specifications of the referenced functions, as given in the Ada
6500 Reference Manual are:
6502 @smallexample @c ada
6503 function To_Unbounded_String (Source : String)
6504 return Unbounded_String;
6506 function To_String (Source : Unbounded_String)
6511 The effect is that if the value of an unbounded string is written to a stream,
6512 then the representation of the item in the stream is in the same format that
6513 would be used for @code{Standard.String'Output}, and this same representation
6514 is expected when a value of this type is read from the stream. Note that the
6515 value written always includes the bounds, even for Unbounded_String'Write,
6516 since Unbounded_String is not an array type.
6518 @node Pragma Style_Checks
6519 @unnumberedsec Pragma Style_Checks
6520 @findex Style_Checks
6524 @smallexample @c ada
6525 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6526 On | Off [, LOCAL_NAME]);
6530 This pragma is used in conjunction with compiler switches to control the
6531 built in style checking provided by GNAT@. The compiler switches, if set,
6532 provide an initial setting for the switches, and this pragma may be used
6533 to modify these settings, or the settings may be provided entirely by
6534 the use of the pragma. This pragma can be used anywhere that a pragma
6535 is legal, including use as a configuration pragma (including use in
6536 the @file{gnat.adc} file).
6538 The form with a string literal specifies which style options are to be
6539 activated. These are additive, so they apply in addition to any previously
6540 set style check options. The codes for the options are the same as those
6541 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6542 For example the following two methods can be used to enable
6547 @smallexample @c ada
6548 pragma Style_Checks ("l");
6553 gcc -c -gnatyl @dots{}
6558 The form ALL_CHECKS activates all standard checks (its use is equivalent
6559 to the use of the @code{gnaty} switch with no options. @xref{Top,
6560 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6561 @value{EDITION} User's Guide}, for details.)
6563 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6564 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6565 options (i.e. equivalent to -gnatyg).
6567 The forms with @code{Off} and @code{On}
6568 can be used to temporarily disable style checks
6569 as shown in the following example:
6571 @smallexample @c ada
6575 pragma Style_Checks ("k"); -- requires keywords in lower case
6576 pragma Style_Checks (Off); -- turn off style checks
6577 NULL; -- this will not generate an error message
6578 pragma Style_Checks (On); -- turn style checks back on
6579 NULL; -- this will generate an error message
6583 Finally the two argument form is allowed only if the first argument is
6584 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6585 for the specified entity, as shown in the following example:
6587 @smallexample @c ada
6591 pragma Style_Checks ("r"); -- require consistency of identifier casing
6593 Rf1 : Integer := ARG; -- incorrect, wrong case
6594 pragma Style_Checks (Off, Arg);
6595 Rf2 : Integer := ARG; -- OK, no error
6598 @node Pragma Subtitle
6599 @unnumberedsec Pragma Subtitle
6604 @smallexample @c ada
6605 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6609 This pragma is recognized for compatibility with other Ada compilers
6610 but is ignored by GNAT@.
6612 @node Pragma Suppress
6613 @unnumberedsec Pragma Suppress
6618 @smallexample @c ada
6619 pragma Suppress (Identifier [, [On =>] Name]);
6623 This is a standard pragma, and supports all the check names required in
6624 the RM. It is included here because GNAT recognizes some additional check
6625 names that are implementation defined (as permitted by the RM):
6630 @code{Alignment_Check} can be used to suppress alignment checks
6631 on addresses used in address clauses. Such checks can also be suppressed
6632 by suppressing range checks, but the specific use of @code{Alignment_Check}
6633 allows suppression of alignment checks without suppressing other range checks.
6636 @code{Predicate_Check} can be used to control whether predicate checks are
6637 active. It is applicable only to predicates for which the policy is
6638 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6639 predicate is ignored or checked for the whole program, the use of
6640 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6641 predicate to be turned on and off at specific points in the program.
6644 @code{Validity_Check} can be used specifically to control validity checks.
6645 If @code{Suppress} is used to suppress validity checks, then no validity
6646 checks are performed, including those specified by the appropriate compiler
6647 switch or the @code{Validity_Checks} pragma.
6650 Additional check names previously introduced by use of the @code{Check_Name}
6651 pragma are also allowed.
6656 Note that pragma Suppress gives the compiler permission to omit
6657 checks, but does not require the compiler to omit checks. The compiler
6658 will generate checks if they are essentially free, even when they are
6659 suppressed. In particular, if the compiler can prove that a certain
6660 check will necessarily fail, it will generate code to do an
6661 unconditional ``raise'', even if checks are suppressed. The compiler
6664 Of course, run-time checks are omitted whenever the compiler can prove
6665 that they will not fail, whether or not checks are suppressed.
6667 @node Pragma Suppress_All
6668 @unnumberedsec Pragma Suppress_All
6669 @findex Suppress_All
6673 @smallexample @c ada
6674 pragma Suppress_All;
6678 This pragma can appear anywhere within a unit.
6679 The effect is to apply @code{Suppress (All_Checks)} to the unit
6680 in which it appears. This pragma is implemented for compatibility with DEC
6681 Ada 83 usage where it appears at the end of a unit, and for compatibility
6682 with Rational Ada, where it appears as a program unit pragma.
6683 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6684 as a normal configuration pragma is the preferred usage in GNAT@.
6686 @node Pragma Suppress_Debug_Info
6687 @unnumberedsec Pragma Suppress_Debug_Info
6688 @findex Suppress_Debug_Info
6692 @smallexample @c ada
6693 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6697 This pragma can be used to suppress generation of debug information
6698 for the specified entity. It is intended primarily for use in debugging
6699 the debugger, and navigating around debugger problems.
6701 @node Pragma Suppress_Exception_Locations
6702 @unnumberedsec Pragma Suppress_Exception_Locations
6703 @findex Suppress_Exception_Locations
6707 @smallexample @c ada
6708 pragma Suppress_Exception_Locations;
6712 In normal mode, a raise statement for an exception by default generates
6713 an exception message giving the file name and line number for the location
6714 of the raise. This is useful for debugging and logging purposes, but this
6715 entails extra space for the strings for the messages. The configuration
6716 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6717 generation of these strings, with the result that space is saved, but the
6718 exception message for such raises is null. This configuration pragma may
6719 appear in a global configuration pragma file, or in a specific unit as
6720 usual. It is not required that this pragma be used consistently within
6721 a partition, so it is fine to have some units within a partition compiled
6722 with this pragma and others compiled in normal mode without it.
6724 @node Pragma Suppress_Initialization
6725 @unnumberedsec Pragma Suppress_Initialization
6726 @findex Suppress_Initialization
6727 @cindex Suppressing initialization
6728 @cindex Initialization, suppression of
6732 @smallexample @c ada
6733 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6737 Here subtype_Name is the name introduced by a type declaration
6738 or subtype declaration.
6739 This pragma suppresses any implicit or explicit initialization
6740 for all variables of the given type or subtype,
6741 including initialization resulting from the use of pragmas
6742 Normalize_Scalars or Initialize_Scalars.
6744 This is considered a representation item, so it cannot be given after
6745 the type is frozen. It applies to all subsequent object declarations,
6746 and also any allocator that creates objects of the type.
6748 If the pragma is given for the first subtype, then it is considered
6749 to apply to the base type and all its subtypes. If the pragma is given
6750 for other than a first subtype, then it applies only to the given subtype.
6751 The pragma may not be given after the type is frozen.
6753 @node Pragma Task_Info
6754 @unnumberedsec Pragma Task_Info
6759 @smallexample @c ada
6760 pragma Task_Info (EXPRESSION);
6764 This pragma appears within a task definition (like pragma
6765 @code{Priority}) and applies to the task in which it appears. The
6766 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6767 The @code{Task_Info} pragma provides system dependent control over
6768 aspects of tasking implementation, for example, the ability to map
6769 tasks to specific processors. For details on the facilities available
6770 for the version of GNAT that you are using, see the documentation
6771 in the spec of package System.Task_Info in the runtime
6774 @node Pragma Task_Name
6775 @unnumberedsec Pragma Task_Name
6780 @smallexample @c ada
6781 pragma Task_Name (string_EXPRESSION);
6785 This pragma appears within a task definition (like pragma
6786 @code{Priority}) and applies to the task in which it appears. The
6787 argument must be of type String, and provides a name to be used for
6788 the task instance when the task is created. Note that this expression
6789 is not required to be static, and in particular, it can contain
6790 references to task discriminants. This facility can be used to
6791 provide different names for different tasks as they are created,
6792 as illustrated in the example below.
6794 The task name is recorded internally in the run-time structures
6795 and is accessible to tools like the debugger. In addition the
6796 routine @code{Ada.Task_Identification.Image} will return this
6797 string, with a unique task address appended.
6799 @smallexample @c ada
6800 -- Example of the use of pragma Task_Name
6802 with Ada.Task_Identification;
6803 use Ada.Task_Identification;
6804 with Text_IO; use Text_IO;
6807 type Astring is access String;
6809 task type Task_Typ (Name : access String) is
6810 pragma Task_Name (Name.all);
6813 task body Task_Typ is
6814 Nam : constant String := Image (Current_Task);
6816 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6819 type Ptr_Task is access Task_Typ;
6820 Task_Var : Ptr_Task;
6824 new Task_Typ (new String'("This is task 1"));
6826 new Task_Typ (new String'("This is task 2"));
6830 @node Pragma Task_Storage
6831 @unnumberedsec Pragma Task_Storage
6832 @findex Task_Storage
6835 @smallexample @c ada
6836 pragma Task_Storage (
6837 [Task_Type =>] LOCAL_NAME,
6838 [Top_Guard =>] static_integer_EXPRESSION);
6842 This pragma specifies the length of the guard area for tasks. The guard
6843 area is an additional storage area allocated to a task. A value of zero
6844 means that either no guard area is created or a minimal guard area is
6845 created, depending on the target. This pragma can appear anywhere a
6846 @code{Storage_Size} attribute definition clause is allowed for a task
6849 @node Pragma Test_Case
6850 @unnumberedsec Pragma Test_Case
6856 @smallexample @c ada
6858 [Name =>] static_string_Expression
6859 ,[Mode =>] (Nominal | Robustness)
6860 [, Requires => Boolean_Expression]
6861 [, Ensures => Boolean_Expression]);
6865 The @code{Test_Case} pragma allows defining fine-grain specifications
6866 for use by testing tools.
6867 The compiler checks the validity of the @code{Test_Case} pragma, but its
6868 presence does not lead to any modification of the code generated by the
6871 @code{Test_Case} pragmas may only appear immediately following the
6872 (separate) declaration of a subprogram in a package declaration, inside
6873 a package spec unit. Only other pragmas may intervene (that is appear
6874 between the subprogram declaration and a test case).
6876 The compiler checks that boolean expressions given in @code{Requires} and
6877 @code{Ensures} are valid, where the rules for @code{Requires} are the
6878 same as the rule for an expression in @code{Precondition} and the rules
6879 for @code{Ensures} are the same as the rule for an expression in
6880 @code{Postcondition}. In particular, attributes @code{'Old} and
6881 @code{'Result} can only be used within the @code{Ensures}
6882 expression. The following is an example of use within a package spec:
6884 @smallexample @c ada
6885 package Math_Functions is
6887 function Sqrt (Arg : Float) return Float;
6888 pragma Test_Case (Name => "Test 1",
6890 Requires => Arg < 10000,
6891 Ensures => Sqrt'Result < 10);
6897 The meaning of a test case is that there is at least one context where
6898 @code{Requires} holds such that, if the associated subprogram is executed in
6899 that context, then @code{Ensures} holds when the subprogram returns.
6900 Mode @code{Nominal} indicates that the input context should also satisfy the
6901 precondition of the subprogram, and the output context should also satisfy its
6902 postcondition. More @code{Robustness} indicates that the precondition and
6903 postcondition of the subprogram should be ignored for this test case.
6905 @node Pragma Thread_Local_Storage
6906 @unnumberedsec Pragma Thread_Local_Storage
6907 @findex Thread_Local_Storage
6908 @cindex Task specific storage
6909 @cindex TLS (Thread Local Storage)
6910 @cindex Task_Attributes
6913 @smallexample @c ada
6914 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6918 This pragma specifies that the specified entity, which must be
6919 a variable declared in a library level package, is to be marked as
6920 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6921 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6922 (and hence each Ada task) to see a distinct copy of the variable.
6924 The variable may not have default initialization, and if there is
6925 an explicit initialization, it must be either @code{null} for an
6926 access variable, or a static expression for a scalar variable.
6927 This provides a low level mechanism similar to that provided by
6928 the @code{Ada.Task_Attributes} package, but much more efficient
6929 and is also useful in writing interface code that will interact
6930 with foreign threads.
6932 If this pragma is used on a system where @code{TLS} is not supported,
6933 then an error message will be generated and the program will be rejected.
6935 @node Pragma Time_Slice
6936 @unnumberedsec Pragma Time_Slice
6941 @smallexample @c ada
6942 pragma Time_Slice (static_duration_EXPRESSION);
6946 For implementations of GNAT on operating systems where it is possible
6947 to supply a time slice value, this pragma may be used for this purpose.
6948 It is ignored if it is used in a system that does not allow this control,
6949 or if it appears in other than the main program unit.
6951 Note that the effect of this pragma is identical to the effect of the
6952 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6955 @unnumberedsec Pragma Title
6960 @smallexample @c ada
6961 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6964 [Title =>] STRING_LITERAL,
6965 | [Subtitle =>] STRING_LITERAL
6969 Syntax checked but otherwise ignored by GNAT@. This is a listing control
6970 pragma used in DEC Ada 83 implementations to provide a title and/or
6971 subtitle for the program listing. The program listing generated by GNAT
6972 does not have titles or subtitles.
6974 Unlike other pragmas, the full flexibility of named notation is allowed
6975 for this pragma, i.e.@: the parameters may be given in any order if named
6976 notation is used, and named and positional notation can be mixed
6977 following the normal rules for procedure calls in Ada.
6979 @node Pragma Type_Invariant
6980 @unnumberedsec Pragma Type_Invariant
6982 @findex Type_Invariant pragma
6986 @smallexample @c ada
6987 pragma Type_Invariant
6988 ([Entity =>] type_LOCAL_NAME,
6989 [Check =>] EXPRESSION);
6993 The @code{Type_Invariant} pragma is intended to be an exact
6994 replacement for the language-defined @code{Type_Invariant}
6995 aspect, and shares its restrictions and semantics. It differs
6996 from the language defined @code{Invariant} pragma in that it
6997 does not permit a string parameter, and it is
6998 controlled by the assertion identifier @code{Type_Invariant}
6999 rather than @code{Invariant}.
7001 @node Pragma Type_Invariant_Class
7002 @unnumberedsec Pragma Type_Invariant_Class
7004 @findex Type_Invariant_Class pragma
7008 @smallexample @c ada
7009 pragma Type_Invariant_Class
7010 ([Entity =>] type_LOCAL_NAME,
7011 [Check =>] EXPRESSION);
7015 The @code{Type_Invariant_Class} pragma is intended to be an exact
7016 replacement for the language-defined @code{Type_Invariant'Class}
7017 aspect, and shares its restrictions and semantics.
7019 Note: This pragma is called @code{Type_Invariant_Class} rather than
7020 @code{Type_Invariant'Class} because the latter would not be strictly
7021 conforming to the allowed syntax for pragmas. The motivation
7022 for providing pragmas equivalent to the aspects is to allow a program
7023 to be written using the pragmas, and then compiled if necessary
7024 using an Ada compiler that does not recognize the pragmas or
7025 aspects, but is prepared to ignore the pragmas. The assertion
7026 policy that controls this pragma is @code{Type_Invariant'Class},
7027 not @code{Type_Invariant_Class}.
7029 @node Pragma Unchecked_Union
7030 @unnumberedsec Pragma Unchecked_Union
7032 @findex Unchecked_Union
7036 @smallexample @c ada
7037 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7041 This pragma is used to specify a representation of a record type that is
7042 equivalent to a C union. It was introduced as a GNAT implementation defined
7043 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7044 pragma, making it language defined, and GNAT fully implements this extended
7045 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7046 details, consult the Ada 2012 Reference Manual, section B.3.3.
7048 @node Pragma Unimplemented_Unit
7049 @unnumberedsec Pragma Unimplemented_Unit
7050 @findex Unimplemented_Unit
7054 @smallexample @c ada
7055 pragma Unimplemented_Unit;
7059 If this pragma occurs in a unit that is processed by the compiler, GNAT
7060 aborts with the message @samp{@var{xxx} not implemented}, where
7061 @var{xxx} is the name of the current compilation unit. This pragma is
7062 intended to allow the compiler to handle unimplemented library units in
7065 The abort only happens if code is being generated. Thus you can use
7066 specs of unimplemented packages in syntax or semantic checking mode.
7068 @node Pragma Universal_Aliasing
7069 @unnumberedsec Pragma Universal_Aliasing
7070 @findex Universal_Aliasing
7074 @smallexample @c ada
7075 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7079 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7080 declarative part. The effect is to inhibit strict type-based aliasing
7081 optimization for the given type. In other words, the effect is as though
7082 access types designating this type were subject to pragma No_Strict_Aliasing.
7083 For a detailed description of the strict aliasing optimization, and the
7084 situations in which it must be suppressed, @xref{Optimization and Strict
7085 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7087 @node Pragma Universal_Data
7088 @unnumberedsec Pragma Universal_Data
7089 @findex Universal_Data
7093 @smallexample @c ada
7094 pragma Universal_Data [(library_unit_Name)];
7098 This pragma is supported only for the AAMP target and is ignored for
7099 other targets. The pragma specifies that all library-level objects
7100 (Counter 0 data) associated with the library unit are to be accessed
7101 and updated using universal addressing (24-bit addresses for AAMP5)
7102 rather than the default of 16-bit Data Environment (DENV) addressing.
7103 Use of this pragma will generally result in less efficient code for
7104 references to global data associated with the library unit, but
7105 allows such data to be located anywhere in memory. This pragma is
7106 a library unit pragma, but can also be used as a configuration pragma
7107 (including use in the @file{gnat.adc} file). The functionality
7108 of this pragma is also available by applying the -univ switch on the
7109 compilations of units where universal addressing of the data is desired.
7111 @node Pragma Unmodified
7112 @unnumberedsec Pragma Unmodified
7114 @cindex Warnings, unmodified
7118 @smallexample @c ada
7119 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7123 This pragma signals that the assignable entities (variables,
7124 @code{out} parameters, @code{in out} parameters) whose names are listed are
7125 deliberately not assigned in the current source unit. This
7126 suppresses warnings about the
7127 entities being referenced but not assigned, and in addition a warning will be
7128 generated if one of these entities is in fact assigned in the
7129 same unit as the pragma (or in the corresponding body, or one
7132 This is particularly useful for clearly signaling that a particular
7133 parameter is not modified, even though the spec suggests that it might
7136 @node Pragma Unreferenced
7137 @unnumberedsec Pragma Unreferenced
7138 @findex Unreferenced
7139 @cindex Warnings, unreferenced
7143 @smallexample @c ada
7144 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7145 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7149 This pragma signals that the entities whose names are listed are
7150 deliberately not referenced in the current source unit. This
7151 suppresses warnings about the
7152 entities being unreferenced, and in addition a warning will be
7153 generated if one of these entities is in fact subsequently referenced in the
7154 same unit as the pragma (or in the corresponding body, or one
7157 This is particularly useful for clearly signaling that a particular
7158 parameter is not referenced in some particular subprogram implementation
7159 and that this is deliberate. It can also be useful in the case of
7160 objects declared only for their initialization or finalization side
7163 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7164 current scope, then the entity most recently declared is the one to which
7165 the pragma applies. Note that in the case of accept formals, the pragma
7166 Unreferenced may appear immediately after the keyword @code{do} which
7167 allows the indication of whether or not accept formals are referenced
7168 or not to be given individually for each accept statement.
7170 The left hand side of an assignment does not count as a reference for the
7171 purpose of this pragma. Thus it is fine to assign to an entity for which
7172 pragma Unreferenced is given.
7174 Note that if a warning is desired for all calls to a given subprogram,
7175 regardless of whether they occur in the same unit as the subprogram
7176 declaration, then this pragma should not be used (calls from another
7177 unit would not be flagged); pragma Obsolescent can be used instead
7178 for this purpose, see @xref{Pragma Obsolescent}.
7180 The second form of pragma @code{Unreferenced} is used within a context
7181 clause. In this case the arguments must be unit names of units previously
7182 mentioned in @code{with} clauses (similar to the usage of pragma
7183 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7184 units and unreferenced entities within these units.
7186 @node Pragma Unreferenced_Objects
7187 @unnumberedsec Pragma Unreferenced_Objects
7188 @findex Unreferenced_Objects
7189 @cindex Warnings, unreferenced
7193 @smallexample @c ada
7194 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7198 This pragma signals that for the types or subtypes whose names are
7199 listed, objects which are declared with one of these types or subtypes may
7200 not be referenced, and if no references appear, no warnings are given.
7202 This is particularly useful for objects which are declared solely for their
7203 initialization and finalization effect. Such variables are sometimes referred
7204 to as RAII variables (Resource Acquisition Is Initialization). Using this
7205 pragma on the relevant type (most typically a limited controlled type), the
7206 compiler will automatically suppress unwanted warnings about these variables
7207 not being referenced.
7209 @node Pragma Unreserve_All_Interrupts
7210 @unnumberedsec Pragma Unreserve_All_Interrupts
7211 @findex Unreserve_All_Interrupts
7215 @smallexample @c ada
7216 pragma Unreserve_All_Interrupts;
7220 Normally certain interrupts are reserved to the implementation. Any attempt
7221 to attach an interrupt causes Program_Error to be raised, as described in
7222 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
7223 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
7224 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7225 interrupt execution.
7227 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7228 a program, then all such interrupts are unreserved. This allows the
7229 program to handle these interrupts, but disables their standard
7230 functions. For example, if this pragma is used, then pressing
7231 @kbd{Ctrl-C} will not automatically interrupt execution. However,
7232 a program can then handle the @code{SIGINT} interrupt as it chooses.
7234 For a full list of the interrupts handled in a specific implementation,
7235 see the source code for the spec of @code{Ada.Interrupts.Names} in
7236 file @file{a-intnam.ads}. This is a target dependent file that contains the
7237 list of interrupts recognized for a given target. The documentation in
7238 this file also specifies what interrupts are affected by the use of
7239 the @code{Unreserve_All_Interrupts} pragma.
7241 For a more general facility for controlling what interrupts can be
7242 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7243 of the @code{Unreserve_All_Interrupts} pragma.
7245 @node Pragma Unsuppress
7246 @unnumberedsec Pragma Unsuppress
7251 @smallexample @c ada
7252 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7256 This pragma undoes the effect of a previous pragma @code{Suppress}. If
7257 there is no corresponding pragma @code{Suppress} in effect, it has no
7258 effect. The range of the effect is the same as for pragma
7259 @code{Suppress}. The meaning of the arguments is identical to that used
7260 in pragma @code{Suppress}.
7262 One important application is to ensure that checks are on in cases where
7263 code depends on the checks for its correct functioning, so that the code
7264 will compile correctly even if the compiler switches are set to suppress
7267 This pragma is standard in Ada 2005. It is available in all earlier versions
7268 of Ada as an implementation-defined pragma.
7270 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7271 a number of implementation-defined check names. See description of pragma
7272 @code{Suppress} for full details.
7274 @node Pragma Use_VADS_Size
7275 @unnumberedsec Pragma Use_VADS_Size
7276 @cindex @code{Size}, VADS compatibility
7277 @cindex Rational profile
7278 @findex Use_VADS_Size
7282 @smallexample @c ada
7283 pragma Use_VADS_Size;
7287 This is a configuration pragma. In a unit to which it applies, any use
7288 of the 'Size attribute is automatically interpreted as a use of the
7289 'VADS_Size attribute. Note that this may result in incorrect semantic
7290 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7291 the handling of existing code which depends on the interpretation of Size
7292 as implemented in the VADS compiler. See description of the VADS_Size
7293 attribute for further details.
7295 @node Pragma Validity_Checks
7296 @unnumberedsec Pragma Validity_Checks
7297 @findex Validity_Checks
7301 @smallexample @c ada
7302 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7306 This pragma is used in conjunction with compiler switches to control the
7307 built-in validity checking provided by GNAT@. The compiler switches, if set
7308 provide an initial setting for the switches, and this pragma may be used
7309 to modify these settings, or the settings may be provided entirely by
7310 the use of the pragma. This pragma can be used anywhere that a pragma
7311 is legal, including use as a configuration pragma (including use in
7312 the @file{gnat.adc} file).
7314 The form with a string literal specifies which validity options are to be
7315 activated. The validity checks are first set to include only the default
7316 reference manual settings, and then a string of letters in the string
7317 specifies the exact set of options required. The form of this string
7318 is exactly as described for the @option{-gnatVx} compiler switch (see the
7319 @value{EDITION} User's Guide for details). For example the following two
7320 methods can be used to enable validity checking for mode @code{in} and
7321 @code{in out} subprogram parameters:
7325 @smallexample @c ada
7326 pragma Validity_Checks ("im");
7331 gcc -c -gnatVim @dots{}
7336 The form ALL_CHECKS activates all standard checks (its use is equivalent
7337 to the use of the @code{gnatva} switch.
7339 The forms with @code{Off} and @code{On}
7340 can be used to temporarily disable validity checks
7341 as shown in the following example:
7343 @smallexample @c ada
7347 pragma Validity_Checks ("c"); -- validity checks for copies
7348 pragma Validity_Checks (Off); -- turn off validity checks
7349 A := B; -- B will not be validity checked
7350 pragma Validity_Checks (On); -- turn validity checks back on
7351 A := C; -- C will be validity checked
7354 @node Pragma Volatile
7355 @unnumberedsec Pragma Volatile
7360 @smallexample @c ada
7361 pragma Volatile (LOCAL_NAME);
7365 This pragma is defined by the Ada Reference Manual, and the GNAT
7366 implementation is fully conformant with this definition. The reason it
7367 is mentioned in this section is that a pragma of the same name was supplied
7368 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7369 implementation of pragma Volatile is upwards compatible with the
7370 implementation in DEC Ada 83.
7372 @node Pragma Warnings
7373 @unnumberedsec Pragma Warnings
7378 @smallexample @c ada
7379 pragma Warnings (On | Off [,REASON]);
7380 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7381 pragma Warnings (static_string_EXPRESSION [,REASON]);
7382 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7384 REASON ::= Reason => static_string_EXPRESSION
7388 Normally warnings are enabled, with the output being controlled by
7389 the command line switch. Warnings (@code{Off}) turns off generation of
7390 warnings until a Warnings (@code{On}) is encountered or the end of the
7391 current unit. If generation of warnings is turned off using this
7392 pragma, then some or all of the warning messages are suppressed,
7393 regardless of the setting of the command line switches.
7395 The @code{Reason} parameter may optionally appear as the last argument
7396 in any of the forms of this pragma. It is intended purely for the
7397 purposes of documenting the reason for the @code{Warnings} pragma.
7398 The compiler will check that the argument is a static string but
7399 otherwise ignore this argument. Other tools may provide specialized
7400 processing for this string.
7402 The form with a single argument (or two arguments if Reason present),
7403 where the first argument is @code{ON} or @code{OFF}
7404 may be used as a configuration pragma.
7406 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7407 the specified entity. This suppression is effective from the point where
7408 it occurs till the end of the extended scope of the variable (similar to
7409 the scope of @code{Suppress}). This form cannot be used as a configuration
7412 The form with a single static_string_EXPRESSION argument (and possible
7413 reason) provides more precise
7414 control over which warnings are active. The string is a list of letters
7415 specifying which warnings are to be activated and which deactivated. The
7416 code for these letters is the same as the string used in the command
7417 line switch controlling warnings. For a brief summary, use the gnatmake
7418 command with no arguments, which will generate usage information containing
7419 the list of warnings switches supported. For
7420 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7421 User's Guide}. This form can also be used as a configuration pragma.
7424 The warnings controlled by the `-gnatw' switch are generated by the front end
7425 of the compiler. The `GCC' back end can provide additional warnings and they
7426 are controlled by the `-W' switch.
7427 The form with a single static_string_EXPRESSION argument also works for the
7428 latters, but the string must be a single full `-W' switch in this case.
7429 The above reference lists a few examples of these additional warnings.
7432 The specified warnings will be in effect until the end of the program
7433 or another pragma Warnings is encountered. The effect of the pragma is
7434 cumulative. Initially the set of warnings is the standard default set
7435 as possibly modified by compiler switches. Then each pragma Warning
7436 modifies this set of warnings as specified. This form of the pragma may
7437 also be used as a configuration pragma.
7439 The fourth form, with an @code{On|Off} parameter and a string, is used to
7440 control individual messages, based on their text. The string argument
7441 is a pattern that is used to match against the text of individual
7442 warning messages (not including the initial "warning: " tag).
7444 The pattern may contain asterisks, which match zero or more characters in
7445 the message. For example, you can use
7446 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
7447 message @code{warning: 960 bits of "a" unused}. No other regular
7448 expression notations are permitted. All characters other than asterisk in
7449 these three specific cases are treated as literal characters in the match.
7450 The match is case insensitive, for example XYZ matches xyz.
7452 The above use of patterns to match the message applies only to warning
7453 messages generated by the front end. This form of the pragma with a
7454 string argument can also be used to control back end warnings controlled
7455 by a "-Wxxx" switch. Such warnings can be identified by the appearance
7456 of a string of the form "[-Wxxx]" in the message which identifies the
7457 "-W" switch that controls the message. By using the text of the
7458 "-W" switch in the pragma, such back end warnings can be turned on and off.
7460 There are two ways to use the pragma in this form. The OFF form can be used as a
7461 configuration pragma. The effect is to suppress all warnings (if any)
7462 that match the pattern string throughout the compilation (or match the
7463 -W switch in the back end case).
7465 The second usage is to suppress a warning locally, and in this case, two
7466 pragmas must appear in sequence:
7468 @smallexample @c ada
7469 pragma Warnings (Off, Pattern);
7470 @dots{} code where given warning is to be suppressed
7471 pragma Warnings (On, Pattern);
7475 In this usage, the pattern string must match in the Off and On pragmas,
7476 and at least one matching warning must be suppressed.
7478 Note: to write a string that will match any warning, use the string
7479 @code{"***"}. It will not work to use a single asterisk or two asterisks
7480 since this looks like an operator name. This form with three asterisks
7481 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7482 matching @code{pragma Warnings (On, "***")} will be required. This can be
7483 helpful in avoiding forgetting to turn warnings back on.
7485 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7486 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7487 be useful in checking whether obsolete pragmas in existing programs are hiding
7490 Note: pragma Warnings does not affect the processing of style messages. See
7491 separate entry for pragma Style_Checks for control of style messages.
7493 @node Pragma Weak_External
7494 @unnumberedsec Pragma Weak_External
7495 @findex Weak_External
7499 @smallexample @c ada
7500 pragma Weak_External ([Entity =>] LOCAL_NAME);
7504 @var{LOCAL_NAME} must refer to an object that is declared at the library
7505 level. This pragma specifies that the given entity should be marked as a
7506 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7507 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7508 of a regular symbol, that is to say a symbol that does not have to be
7509 resolved by the linker if used in conjunction with a pragma Import.
7511 When a weak symbol is not resolved by the linker, its address is set to
7512 zero. This is useful in writing interfaces to external modules that may
7513 or may not be linked in the final executable, for example depending on
7514 configuration settings.
7516 If a program references at run time an entity to which this pragma has been
7517 applied, and the corresponding symbol was not resolved at link time, then
7518 the execution of the program is erroneous. It is not erroneous to take the
7519 Address of such an entity, for example to guard potential references,
7520 as shown in the example below.
7522 Some file formats do not support weak symbols so not all target machines
7523 support this pragma.
7525 @smallexample @c ada
7526 -- Example of the use of pragma Weak_External
7528 package External_Module is
7530 pragma Import (C, key);
7531 pragma Weak_External (key);
7532 function Present return boolean;
7533 end External_Module;
7535 with System; use System;
7536 package body External_Module is
7537 function Present return boolean is
7539 return key'Address /= System.Null_Address;
7541 end External_Module;
7544 @node Pragma Wide_Character_Encoding
7545 @unnumberedsec Pragma Wide_Character_Encoding
7546 @findex Wide_Character_Encoding
7550 @smallexample @c ada
7551 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7555 This pragma specifies the wide character encoding to be used in program
7556 source text appearing subsequently. It is a configuration pragma, but may
7557 also be used at any point that a pragma is allowed, and it is permissible
7558 to have more than one such pragma in a file, allowing multiple encodings
7559 to appear within the same file.
7561 The argument can be an identifier or a character literal. In the identifier
7562 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7563 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7564 case it is correspondingly one of the characters @samp{h}, @samp{u},
7565 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7567 Note that when the pragma is used within a file, it affects only the
7568 encoding within that file, and does not affect withed units, specs,
7571 @node Implementation Defined Aspects
7572 @chapter Implementation Defined Aspects
7573 Ada defines (throughout the Ada 2012 reference manual, summarized
7574 in annex K) a set of aspects that can be specified for certain entities.
7575 These language defined aspects are implemented in GNAT in Ada 2012 mode
7576 and work as described in the Ada 2012 Reference Manual.
7578 In addition, Ada 2012 allows implementations to define additional aspects
7579 whose meaning is defined by the implementation. GNAT provides
7580 a number of these implementation-dependent aspects which can be used
7581 to extend and enhance the functionality of the compiler. This section of
7582 the GNAT reference manual describes these additional attributes.
7584 Note that any program using these aspects may not be portable to
7585 other compilers (although GNAT implements this set of aspects on all
7586 platforms). Therefore if portability to other compilers is an important
7587 consideration, you should minimize the use of these aspects.
7589 Note that for many of these aspects, the effect is essentially similar
7590 to the use of a pragma or attribute specification with the same name
7591 applied to the entity. For example, if we write:
7593 @smallexample @c ada
7594 type R is range 1 .. 100
7595 with Value_Size => 10;
7599 then the effect is the same as:
7601 @smallexample @c ada
7602 type R is range 1 .. 100;
7603 for R'Value_Size use 10;
7609 @smallexample @c ada
7610 type R is new Integer
7611 with Shared => True;
7615 then the effect is the same as:
7617 @smallexample @c ada
7618 type R is new Integer;
7623 In the documentation sections that follow, such cases are simply marked
7624 as being equivalent to the corresponding pragma or attribute definition
7628 * Aspect Abstract_State::
7631 * Aspect Compiler_Unit::
7632 * Aspect Contract_Cases::
7634 * Aspect Dimension::
7635 * Aspect Dimension_System::
7636 * Aspect Favor_Top_Level::
7638 * Aspect Initial_Condition::
7639 * Aspect Initializes::
7640 * Aspect Inline_Always::
7641 * Aspect Invariant::
7642 * Aspect Linker_Section::
7643 * Aspect Lock_Free::
7644 * Aspect Object_Size::
7645 * Aspect Persistent_BSS::
7646 * Aspect Predicate::
7647 * Aspect Preelaborate_05::
7650 * Aspect Pure_Function::
7651 * Aspect Refined_State::
7652 * Aspect Remote_Access_Type::
7653 * Aspect Scalar_Storage_Order::
7655 * Aspect Simple_Storage_Pool::
7656 * Aspect Simple_Storage_Pool_Type::
7657 * Aspect SPARK_Mode::
7658 * Aspect Suppress_Debug_Info::
7659 * Aspect Test_Case::
7660 * Aspect Universal_Aliasing::
7661 * Aspect Universal_Data::
7662 * Aspect Unmodified::
7663 * Aspect Unreferenced::
7664 * Aspect Unreferenced_Objects::
7665 * Aspect Value_Size::
7669 @node Aspect Abstract_State
7670 @unnumberedsec Aspect Abstract_State
7671 @findex Abstract_State
7673 This aspect is equivalent to pragma @code{Abstract_State}.
7675 @node Aspect Ada_2005
7676 @unnumberedsec Aspect Ada_2005
7679 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7681 @node Aspect Ada_2012
7682 @unnumberedsec Aspect Ada_2012
7685 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7687 @node Aspect Compiler_Unit
7688 @unnumberedsec Aspect Compiler_Unit
7689 @findex Compiler_Unit
7691 This aspect is equivalent to pragma @code{Compiler_Unit}.
7693 @node Aspect Contract_Cases
7694 @unnumberedsec Aspect Contract_Cases
7695 @findex Contract_Cases
7697 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7698 of clauses being enclosed in parentheses so that syntactically it is an
7701 @node Aspect Depends
7702 @unnumberedsec Aspect Depends
7705 This aspect is equivalent to pragma @code{Depends}.
7709 @node Aspect Dimension
7710 @unnumberedsec Aspect Dimension
7713 The @code{Dimension} aspect is used to specify the dimensions of a given
7714 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7715 used when doing formatted output of dimensioned quantities. The syntax is:
7717 @smallexample @c ada
7719 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7721 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7725 | others => RATIONAL
7726 | DISCRETE_CHOICE_LIST => RATIONAL
7728 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7732 This aspect can only be applied to a subtype whose parent type has
7733 a @code{Dimension_Systen} aspect. The aspect must specify values for
7734 all dimensions of the system. The rational values are the powers of the
7735 corresponding dimensions that are used by the compiler to verify that
7736 physical (numeric) computations are dimensionally consistent. For example,
7737 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7738 For further examples of the usage
7739 of this aspect, see package @code{System.Dim.Mks}.
7740 Note that when the dimensioned type is an integer type, then any
7741 dimension value must be an integer literal.
7743 @node Aspect Dimension_System
7744 @unnumberedsec Aspect Dimension_System
7745 @findex Dimension_System
7747 The @code{Dimension_System} aspect is used to define a system of
7748 dimensions that will be used in subsequent subtype declarations with
7749 @code{Dimension} aspects that reference this system. The syntax is:
7751 @smallexample @c ada
7752 with Dimension_System => (DIMENSION @{, DIMENSION@});
7754 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
7755 [Unit_Symbol =>] SYMBOL,
7756 [Dim_Symbol =>] SYMBOL)
7758 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7762 This aspect is applied to a type, which must be a numeric derived type
7763 (typically a floating-point type), that
7764 will represent values within the dimension system. Each @code{DIMENSION}
7765 corresponds to one particular dimension. A maximum of 7 dimensions may
7766 be specified. @code{Unit_Name} is the name of the dimension (for example
7767 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7768 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7769 the identification within the dimension system (typically this is a
7770 single letter, e.g. 'L' standing for length for unit name Meter). The
7771 Unit_Smbol is used in formatted output of dimensioned quantities. The
7772 Dim_Symbol is used in error messages when numeric operations have
7773 inconsistent dimensions.
7775 GNAT provides the standard definition of the International MKS system in
7776 the run-time package @code{System.Dim.Mks}. You can easily define
7777 similar packages for cgs units or British units, and define conversion factors
7778 between values in different systems. The MKS system is characterized by the
7781 @smallexample @c ada
7782 type Mks_Type is new Long_Long_Float
7784 Dimension_System => (
7785 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
7786 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
7787 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
7788 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
7789 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
7790 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
7791 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
7795 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7796 Guide for detailed examples of use of the dimension system.
7798 @node Aspect Favor_Top_Level
7799 @unnumberedsec Aspect Favor_Top_Level
7800 @findex Favor_Top_Level
7802 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7805 @unnumberedsec Aspect Global
7808 This aspect is equivalent to pragma @code{Global}.
7810 @node Aspect Initial_Condition
7811 @unnumberedsec Aspect Initial_Condition
7812 @findex Initial_Condition
7814 This aspect is equivalent to pragma @code{Initial_Condition}.
7816 @node Aspect Initializes
7817 @unnumberedsec Aspect Initializes
7820 This aspect is equivalent to pragma @code{Initializes}.
7822 @node Aspect Inline_Always
7823 @unnumberedsec Aspect Inline_Always
7824 @findex Inline_Always
7826 This aspect is equivalent to pragma @code{Inline_Always}.
7828 @node Aspect Invariant
7829 @unnumberedsec Aspect Invariant
7832 This aspect is equivalent to pragma @code{Invariant}. It is a
7833 synonym for the language defined aspect @code{Type_Invariant} except
7834 that it is separately controllable using pragma @code{Assertion_Policy}.
7836 @node Aspect Linker_Section
7837 @unnumberedsec Aspect Linker_Section
7838 @findex Linker_Section
7840 This aspect is equivalent to an @code{Linker_Section} pragma.
7842 @node Aspect Lock_Free
7843 @unnumberedsec Aspect Lock_Free
7846 This aspect is equivalent to pragma @code{Lock_Free}.
7848 @node Aspect Object_Size
7849 @unnumberedsec Aspect Object_Size
7852 This aspect is equivalent to an @code{Object_Size} attribute definition
7855 @node Aspect Persistent_BSS
7856 @unnumberedsec Aspect Persistent_BSS
7857 @findex Persistent_BSS
7859 This aspect is equivalent to pragma @code{Persistent_BSS}.
7861 @node Aspect Predicate
7862 @unnumberedsec Aspect Predicate
7865 This aspect is equivalent to pragma @code{Predicate}. It is thus
7866 similar to the language defined aspects @code{Dynamic_Predicate}
7867 and @code{Static_Predicate} except that whether the resulting
7868 predicate is static or dynamic is controlled by the form of the
7869 expression. It is also separately controllable using pragma
7870 @code{Assertion_Policy}.
7872 @node Aspect Preelaborate_05
7873 @unnumberedsec Aspect Preelaborate_05
7874 @findex Preelaborate_05
7876 This aspect is equivalent to pragma @code{Preelaborate_05}.
7878 @node Aspect Pure_05
7879 @unnumberedsec Aspect Pure_05
7882 This aspect is equivalent to pragma @code{Pure_05}.
7884 @node Aspect Pure_12
7885 @unnumberedsec Aspect Pure_12
7888 This aspect is equivalent to pragma @code{Pure_12}.
7890 @node Aspect Pure_Function
7891 @unnumberedsec Aspect Pure_Function
7892 @findex Pure_Function
7894 This aspect is equivalent to pragma @code{Pure_Function}.
7896 @node Aspect Refined_State
7897 @unnumberedsec Aspect Refined_State
7898 @findex Refined_State
7900 This aspect is equivalent to pragma @code{Refined_State}.
7902 @node Aspect Remote_Access_Type
7903 @unnumberedsec Aspect Remote_Access_Type
7904 @findex Remote_Access_Type
7906 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7908 @node Aspect Scalar_Storage_Order
7909 @unnumberedsec Aspect Scalar_Storage_Order
7910 @findex Scalar_Storage_Order
7912 This aspect is equivalent to a @code{Scalar_Storage_Order}
7913 attribute definition clause.
7916 @unnumberedsec Aspect Shared
7919 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7920 for aspect @code{Atomic}.
7922 @node Aspect Simple_Storage_Pool
7923 @unnumberedsec Aspect Simple_Storage_Pool
7924 @findex Simple_Storage_Pool
7926 This aspect is equivalent to a @code{Simple_Storage_Pool}
7927 attribute definition clause.
7929 @node Aspect Simple_Storage_Pool_Type
7930 @unnumberedsec Aspect Simple_Storage_Pool_Type
7931 @findex Simple_Storage_Pool_Type
7933 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7935 @node Aspect SPARK_Mode
7936 @unnumberedsec Aspect SPARK_Mode
7939 This aspect is equivalent to pragma @code{SPARK_Mode} and
7940 may be specified for either or both of the specification and body
7941 of a subprogram or package.
7943 @node Aspect Suppress_Debug_Info
7944 @unnumberedsec Aspect Suppress_Debug_Info
7945 @findex Suppress_Debug_Info
7947 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7949 @node Aspect Test_Case
7950 @unnumberedsec Aspect Test_Case
7953 This aspect is equivalent to pragma @code{Test_Case}.
7955 @node Aspect Universal_Aliasing
7956 @unnumberedsec Aspect Universal_Aliasing
7957 @findex Universal_Aliasing
7959 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7961 @node Aspect Universal_Data
7962 @unnumberedsec Aspect Universal_Data
7963 @findex Universal_Data
7965 This aspect is equivalent to pragma @code{Universal_Data}.
7967 @node Aspect Unmodified
7968 @unnumberedsec Aspect Unmodified
7971 This aspect is equivalent to pragma @code{Unmodified}.
7973 @node Aspect Unreferenced
7974 @unnumberedsec Aspect Unreferenced
7975 @findex Unreferenced
7977 This aspect is equivalent to pragma @code{Unreferenced}.
7979 @node Aspect Unreferenced_Objects
7980 @unnumberedsec Aspect Unreferenced_Objects
7981 @findex Unreferenced_Objects
7983 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7985 @node Aspect Value_Size
7986 @unnumberedsec Aspect Value_Size
7989 This aspect is equivalent to a @code{Value_Size}
7990 attribute definition clause.
7992 @node Aspect Warnings
7993 @unnumberedsec Aspect Warnings
7996 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7997 where the first argument is @code{ON} or @code{OFF} and the second argument
8000 @node Implementation Defined Attributes
8001 @chapter Implementation Defined Attributes
8002 Ada defines (throughout the Ada reference manual,
8003 summarized in Annex K),
8004 a set of attributes that provide useful additional functionality in all
8005 areas of the language. These language defined attributes are implemented
8006 in GNAT and work as described in the Ada Reference Manual.
8008 In addition, Ada allows implementations to define additional
8009 attributes whose meaning is defined by the implementation. GNAT provides
8010 a number of these implementation-dependent attributes which can be used
8011 to extend and enhance the functionality of the compiler. This section of
8012 the GNAT reference manual describes these additional attributes.
8014 Note that any program using these attributes may not be portable to
8015 other compilers (although GNAT implements this set of attributes on all
8016 platforms). Therefore if portability to other compilers is an important
8017 consideration, you should minimize the use of these attributes.
8020 * Attribute Abort_Signal::
8021 * Attribute Address_Size::
8022 * Attribute Asm_Input::
8023 * Attribute Asm_Output::
8024 * Attribute AST_Entry::
8026 * Attribute Bit_Position::
8027 * Attribute Compiler_Version::
8028 * Attribute Code_Address::
8029 * Attribute Default_Bit_Order::
8030 * Attribute Descriptor_Size::
8031 * Attribute Elaborated::
8032 * Attribute Elab_Body::
8033 * Attribute Elab_Spec::
8034 * Attribute Elab_Subp_Body::
8036 * Attribute Enabled::
8037 * Attribute Enum_Rep::
8038 * Attribute Enum_Val::
8039 * Attribute Epsilon::
8040 * Attribute Fixed_Value::
8041 * Attribute Has_Access_Values::
8042 * Attribute Has_Discriminants::
8044 * Attribute Integer_Value::
8045 * Attribute Invalid_Value::
8047 * Attribute Library_Level::
8048 * Attribute Loop_Entry::
8049 * Attribute Machine_Size::
8050 * Attribute Mantissa::
8051 * Attribute Max_Interrupt_Priority::
8052 * Attribute Max_Priority::
8053 * Attribute Maximum_Alignment::
8054 * Attribute Mechanism_Code::
8055 * Attribute Null_Parameter::
8056 * Attribute Object_Size::
8057 * Attribute Passed_By_Reference::
8058 * Attribute Pool_Address::
8059 * Attribute Range_Length::
8061 * Attribute Restriction_Set::
8062 * Attribute Result::
8063 * Attribute Safe_Emax::
8064 * Attribute Safe_Large::
8065 * Attribute Scalar_Storage_Order::
8066 * Attribute Simple_Storage_Pool::
8068 * Attribute Storage_Unit::
8069 * Attribute Stub_Type::
8070 * Attribute System_Allocator_Alignment::
8071 * Attribute Target_Name::
8073 * Attribute To_Address::
8074 * Attribute Type_Class::
8075 * Attribute UET_Address::
8076 * Attribute Unconstrained_Array::
8077 * Attribute Universal_Literal_String::
8078 * Attribute Unrestricted_Access::
8079 * Attribute Update::
8080 * Attribute Valid_Scalars::
8081 * Attribute VADS_Size::
8082 * Attribute Value_Size::
8083 * Attribute Wchar_T_Size::
8084 * Attribute Word_Size::
8087 @node Attribute Abort_Signal
8088 @unnumberedsec Attribute Abort_Signal
8089 @findex Abort_Signal
8091 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8092 prefix) provides the entity for the special exception used to signal
8093 task abort or asynchronous transfer of control. Normally this attribute
8094 should only be used in the tasking runtime (it is highly peculiar, and
8095 completely outside the normal semantics of Ada, for a user program to
8096 intercept the abort exception).
8098 @node Attribute Address_Size
8099 @unnumberedsec Attribute Address_Size
8100 @cindex Size of @code{Address}
8101 @findex Address_Size
8103 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8104 prefix) is a static constant giving the number of bits in an
8105 @code{Address}. It is the same value as System.Address'Size,
8106 but has the advantage of being static, while a direct
8107 reference to System.Address'Size is non-static because Address
8110 @node Attribute Asm_Input
8111 @unnumberedsec Attribute Asm_Input
8114 The @code{Asm_Input} attribute denotes a function that takes two
8115 parameters. The first is a string, the second is an expression of the
8116 type designated by the prefix. The first (string) argument is required
8117 to be a static expression, and is the constraint for the parameter,
8118 (e.g.@: what kind of register is required). The second argument is the
8119 value to be used as the input argument. The possible values for the
8120 constant are the same as those used in the RTL, and are dependent on
8121 the configuration file used to built the GCC back end.
8122 @ref{Machine Code Insertions}
8124 @node Attribute Asm_Output
8125 @unnumberedsec Attribute Asm_Output
8128 The @code{Asm_Output} attribute denotes a function that takes two
8129 parameters. The first is a string, the second is the name of a variable
8130 of the type designated by the attribute prefix. The first (string)
8131 argument is required to be a static expression and designates the
8132 constraint for the parameter (e.g.@: what kind of register is
8133 required). The second argument is the variable to be updated with the
8134 result. The possible values for constraint are the same as those used in
8135 the RTL, and are dependent on the configuration file used to build the
8136 GCC back end. If there are no output operands, then this argument may
8137 either be omitted, or explicitly given as @code{No_Output_Operands}.
8138 @ref{Machine Code Insertions}
8140 @node Attribute AST_Entry
8141 @unnumberedsec Attribute AST_Entry
8145 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
8146 the name of an entry, it yields a value of the predefined type AST_Handler
8147 (declared in the predefined package System, as extended by the use of
8148 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
8149 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
8150 Language Reference Manual}, section 9.12a.
8153 @unnumberedsec Attribute Bit
8155 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8156 offset within the storage unit (byte) that contains the first bit of
8157 storage allocated for the object. The value of this attribute is of the
8158 type @code{Universal_Integer}, and is always a non-negative number not
8159 exceeding the value of @code{System.Storage_Unit}.
8161 For an object that is a variable or a constant allocated in a register,
8162 the value is zero. (The use of this attribute does not force the
8163 allocation of a variable to memory).
8165 For an object that is a formal parameter, this attribute applies
8166 to either the matching actual parameter or to a copy of the
8167 matching actual parameter.
8169 For an access object the value is zero. Note that
8170 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8171 designated object. Similarly for a record component
8172 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8173 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8174 are subject to index checks.
8176 This attribute is designed to be compatible with the DEC Ada 83 definition
8177 and implementation of the @code{Bit} attribute.
8179 @node Attribute Bit_Position
8180 @unnumberedsec Attribute Bit_Position
8181 @findex Bit_Position
8183 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8184 of the fields of the record type, yields the bit
8185 offset within the record contains the first bit of
8186 storage allocated for the object. The value of this attribute is of the
8187 type @code{Universal_Integer}. The value depends only on the field
8188 @var{C} and is independent of the alignment of
8189 the containing record @var{R}.
8191 @node Attribute Compiler_Version
8192 @unnumberedsec Attribute Compiler_Version
8193 @findex Compiler_Version
8195 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8196 prefix) yields a static string identifying the version of the compiler
8197 being used to compile the unit containing the attribute reference. A
8198 typical result would be something like "@value{EDITION} @i{version} (20090221)".
8200 @node Attribute Code_Address
8201 @unnumberedsec Attribute Code_Address
8202 @findex Code_Address
8203 @cindex Subprogram address
8204 @cindex Address of subprogram code
8207 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8208 intended effect seems to be to provide
8209 an address value which can be used to call the subprogram by means of
8210 an address clause as in the following example:
8212 @smallexample @c ada
8213 procedure K is @dots{}
8216 for L'Address use K'Address;
8217 pragma Import (Ada, L);
8221 A call to @code{L} is then expected to result in a call to @code{K}@.
8222 In Ada 83, where there were no access-to-subprogram values, this was
8223 a common work-around for getting the effect of an indirect call.
8224 GNAT implements the above use of @code{Address} and the technique
8225 illustrated by the example code works correctly.
8227 However, for some purposes, it is useful to have the address of the start
8228 of the generated code for the subprogram. On some architectures, this is
8229 not necessarily the same as the @code{Address} value described above.
8230 For example, the @code{Address} value may reference a subprogram
8231 descriptor rather than the subprogram itself.
8233 The @code{'Code_Address} attribute, which can only be applied to
8234 subprogram entities, always returns the address of the start of the
8235 generated code of the specified subprogram, which may or may not be
8236 the same value as is returned by the corresponding @code{'Address}
8239 @node Attribute Default_Bit_Order
8240 @unnumberedsec Attribute Default_Bit_Order
8242 @cindex Little endian
8243 @findex Default_Bit_Order
8245 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8246 permissible prefix), provides the value @code{System.Default_Bit_Order}
8247 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8248 @code{Low_Order_First}). This is used to construct the definition of
8249 @code{Default_Bit_Order} in package @code{System}.
8251 @node Attribute Descriptor_Size
8252 @unnumberedsec Attribute Descriptor_Size
8255 @findex Descriptor_Size
8257 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8258 descriptor allocated for a type. The result is non-zero only for unconstrained
8259 array types and the returned value is of type universal integer. In GNAT, an
8260 array descriptor contains bounds information and is located immediately before
8261 the first element of the array.
8263 @smallexample @c ada
8264 type Unconstr_Array is array (Positive range <>) of Boolean;
8265 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8269 The attribute takes into account any additional padding due to type alignment.
8270 In the example above, the descriptor contains two values of type
8271 @code{Positive} representing the low and high bound. Since @code{Positive} has
8272 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8273 Positive'Size + 2} or 64 bits.
8275 @node Attribute Elaborated
8276 @unnumberedsec Attribute Elaborated
8279 The prefix of the @code{'Elaborated} attribute must be a unit name. The
8280 value is a Boolean which indicates whether or not the given unit has been
8281 elaborated. This attribute is primarily intended for internal use by the
8282 generated code for dynamic elaboration checking, but it can also be used
8283 in user programs. The value will always be True once elaboration of all
8284 units has been completed. An exception is for units which need no
8285 elaboration, the value is always False for such units.
8287 @node Attribute Elab_Body
8288 @unnumberedsec Attribute Elab_Body
8291 This attribute can only be applied to a program unit name. It returns
8292 the entity for the corresponding elaboration procedure for elaborating
8293 the body of the referenced unit. This is used in the main generated
8294 elaboration procedure by the binder and is not normally used in any
8295 other context. However, there may be specialized situations in which it
8296 is useful to be able to call this elaboration procedure from Ada code,
8297 e.g.@: if it is necessary to do selective re-elaboration to fix some
8300 @node Attribute Elab_Spec
8301 @unnumberedsec Attribute Elab_Spec
8304 This attribute can only be applied to a program unit name. It returns
8305 the entity for the corresponding elaboration procedure for elaborating
8306 the spec of the referenced unit. This is used in the main
8307 generated elaboration procedure by the binder and is not normally used
8308 in any other context. However, there may be specialized situations in
8309 which it is useful to be able to call this elaboration procedure from
8310 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8313 @node Attribute Elab_Subp_Body
8314 @unnumberedsec Attribute Elab_Subp_Body
8315 @findex Elab_Subp_Body
8317 This attribute can only be applied to a library level subprogram
8318 name and is only allowed in CodePeer mode. It returns the entity
8319 for the corresponding elaboration procedure for elaborating the body
8320 of the referenced subprogram unit. This is used in the main generated
8321 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8324 @node Attribute Emax
8325 @unnumberedsec Attribute Emax
8326 @cindex Ada 83 attributes
8329 The @code{Emax} attribute is provided for compatibility with Ada 83. See
8330 the Ada 83 reference manual for an exact description of the semantics of
8333 @node Attribute Enabled
8334 @unnumberedsec Attribute Enabled
8337 The @code{Enabled} attribute allows an application program to check at compile
8338 time to see if the designated check is currently enabled. The prefix is a
8339 simple identifier, referencing any predefined check name (other than
8340 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8341 no argument is given for the attribute, the check is for the general state
8342 of the check, if an argument is given, then it is an entity name, and the
8343 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8344 given naming the entity (if not, then the argument is ignored).
8346 Note that instantiations inherit the check status at the point of the
8347 instantiation, so a useful idiom is to have a library package that
8348 introduces a check name with @code{pragma Check_Name}, and then contains
8349 generic packages or subprograms which use the @code{Enabled} attribute
8350 to see if the check is enabled. A user of this package can then issue
8351 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8352 the package or subprogram, controlling whether the check will be present.
8354 @node Attribute Enum_Rep
8355 @unnumberedsec Attribute Enum_Rep
8356 @cindex Representation of enums
8359 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8360 function with the following spec:
8362 @smallexample @c ada
8363 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8364 return @i{Universal_Integer};
8368 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8369 enumeration type or to a non-overloaded enumeration
8370 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
8371 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8372 enumeration literal or object.
8374 The function returns the representation value for the given enumeration
8375 value. This will be equal to value of the @code{Pos} attribute in the
8376 absence of an enumeration representation clause. This is a static
8377 attribute (i.e.@: the result is static if the argument is static).
8379 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8380 in which case it simply returns the integer value. The reason for this
8381 is to allow it to be used for @code{(<>)} discrete formal arguments in
8382 a generic unit that can be instantiated with either enumeration types
8383 or integer types. Note that if @code{Enum_Rep} is used on a modular
8384 type whose upper bound exceeds the upper bound of the largest signed
8385 integer type, and the argument is a variable, so that the universal
8386 integer calculation is done at run time, then the call to @code{Enum_Rep}
8387 may raise @code{Constraint_Error}.
8389 @node Attribute Enum_Val
8390 @unnumberedsec Attribute Enum_Val
8391 @cindex Representation of enums
8394 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8395 function with the following spec:
8397 @smallexample @c ada
8398 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8399 return @var{S}'Base};
8403 The function returns the enumeration value whose representation matches the
8404 argument, or raises Constraint_Error if no enumeration literal of the type
8405 has the matching value.
8406 This will be equal to value of the @code{Val} attribute in the
8407 absence of an enumeration representation clause. This is a static
8408 attribute (i.e.@: the result is static if the argument is static).
8410 @node Attribute Epsilon
8411 @unnumberedsec Attribute Epsilon
8412 @cindex Ada 83 attributes
8415 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
8416 the Ada 83 reference manual for an exact description of the semantics of
8419 @node Attribute Fixed_Value
8420 @unnumberedsec Attribute Fixed_Value
8423 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8424 function with the following specification:
8426 @smallexample @c ada
8427 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8432 The value returned is the fixed-point value @var{V} such that
8434 @smallexample @c ada
8435 @var{V} = Arg * @var{S}'Small
8439 The effect is thus similar to first converting the argument to the
8440 integer type used to represent @var{S}, and then doing an unchecked
8441 conversion to the fixed-point type. The difference is
8442 that there are full range checks, to ensure that the result is in range.
8443 This attribute is primarily intended for use in implementation of the
8444 input-output functions for fixed-point values.
8446 @node Attribute Has_Access_Values
8447 @unnumberedsec Attribute Has_Access_Values
8448 @cindex Access values, testing for
8449 @findex Has_Access_Values
8451 The prefix of the @code{Has_Access_Values} attribute is a type. The result
8452 is a Boolean value which is True if the is an access type, or is a composite
8453 type with a component (at any nesting depth) that is an access type, and is
8455 The intended use of this attribute is in conjunction with generic
8456 definitions. If the attribute is applied to a generic private type, it
8457 indicates whether or not the corresponding actual type has access values.
8459 @node Attribute Has_Discriminants
8460 @unnumberedsec Attribute Has_Discriminants
8461 @cindex Discriminants, testing for
8462 @findex Has_Discriminants
8464 The prefix of the @code{Has_Discriminants} attribute is a type. The result
8465 is a Boolean value which is True if the type has discriminants, and False
8466 otherwise. The intended use of this attribute is in conjunction with generic
8467 definitions. If the attribute is applied to a generic private type, it
8468 indicates whether or not the corresponding actual type has discriminants.
8471 @unnumberedsec Attribute Img
8474 The @code{Img} attribute differs from @code{Image} in that it is applied
8475 directly to an object, and yields the same result as
8476 @code{Image} for the subtype of the object. This is convenient for
8479 @smallexample @c ada
8480 Put_Line ("X = " & X'Img);
8484 has the same meaning as the more verbose:
8486 @smallexample @c ada
8487 Put_Line ("X = " & @var{T}'Image (X));
8491 where @var{T} is the (sub)type of the object @code{X}.
8493 Note that technically, in analogy to @code{Image},
8494 @code{X'Img} returns a parameterless function
8495 that returns the appropriate string when called. This means that
8496 @code{X'Img} can be renamed as a function-returning-string, or used
8497 in an instantiation as a function parameter.
8499 @node Attribute Integer_Value
8500 @unnumberedsec Attribute Integer_Value
8501 @findex Integer_Value
8503 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8504 function with the following spec:
8506 @smallexample @c ada
8507 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8512 The value returned is the integer value @var{V}, such that
8514 @smallexample @c ada
8515 Arg = @var{V} * @var{T}'Small
8519 where @var{T} is the type of @code{Arg}.
8520 The effect is thus similar to first doing an unchecked conversion from
8521 the fixed-point type to its corresponding implementation type, and then
8522 converting the result to the target integer type. The difference is
8523 that there are full range checks, to ensure that the result is in range.
8524 This attribute is primarily intended for use in implementation of the
8525 standard input-output functions for fixed-point values.
8527 @node Attribute Invalid_Value
8528 @unnumberedsec Attribute Invalid_Value
8529 @findex Invalid_Value
8531 For every scalar type S, S'Invalid_Value returns an undefined value of the
8532 type. If possible this value is an invalid representation for the type. The
8533 value returned is identical to the value used to initialize an otherwise
8534 uninitialized value of the type if pragma Initialize_Scalars is used,
8535 including the ability to modify the value with the binder -Sxx flag and
8536 relevant environment variables at run time.
8538 @node Attribute Large
8539 @unnumberedsec Attribute Large
8540 @cindex Ada 83 attributes
8543 The @code{Large} attribute is provided for compatibility with Ada 83. See
8544 the Ada 83 reference manual for an exact description of the semantics of
8547 @node Attribute Library_Level
8548 @unnumberedsec Attribute Library_Level
8549 @findex Library_Level
8552 @code{P'Library_Level}, where P is an entity name,
8553 returns a Boolean value which is True if the entity is declared
8554 at the library level, and False otherwise. Note that within a
8555 generic instantition, the name of the generic unit denotes the
8556 instance, which means that this attribute can be used to test
8557 if a generic is instantiated at the library level, as shown
8560 @smallexample @c ada
8564 pragma Compile_Time_Error
8565 (not Gen'Library_Level,
8566 "Gen can only be instantiated at library level");
8571 @node Attribute Loop_Entry
8572 @unnumberedsec Attribute Loop_Entry
8577 @smallexample @c ada
8578 X'Loop_Entry [(loop_name)]
8582 The @code{Loop_Entry} attribute is used to refer to the value that an
8583 expression had upon entry to a given loop in much the same way that the
8584 @code{Old} attribute in a subprogram postcondition can be used to refer
8585 to the value an expression had upon entry to the subprogram. The
8586 relevant loop is either identified by the given loop name, or it is the
8587 innermost enclosing loop when no loop name is given.
8590 A @code{Loop_Entry} attribute can only occur within a
8591 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8592 @code{Loop_Entry} is to compare the current value of objects with their
8593 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8596 The effect of using @code{X'Loop_Entry} is the same as declaring
8597 a constant initialized with the initial value of @code{X} at loop
8598 entry. This copy is not performed if the loop is not entered, or if the
8599 corresponding pragmas are ignored or disabled.
8601 @node Attribute Machine_Size
8602 @unnumberedsec Attribute Machine_Size
8603 @findex Machine_Size
8605 This attribute is identical to the @code{Object_Size} attribute. It is
8606 provided for compatibility with the DEC Ada 83 attribute of this name.
8608 @node Attribute Mantissa
8609 @unnumberedsec Attribute Mantissa
8610 @cindex Ada 83 attributes
8613 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8614 the Ada 83 reference manual for an exact description of the semantics of
8617 @node Attribute Max_Interrupt_Priority
8618 @unnumberedsec Attribute Max_Interrupt_Priority
8619 @cindex Interrupt priority, maximum
8620 @findex Max_Interrupt_Priority
8622 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8623 permissible prefix), provides the same value as
8624 @code{System.Max_Interrupt_Priority}.
8626 @node Attribute Max_Priority
8627 @unnumberedsec Attribute Max_Priority
8628 @cindex Priority, maximum
8629 @findex Max_Priority
8631 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8632 prefix) provides the same value as @code{System.Max_Priority}.
8634 @node Attribute Maximum_Alignment
8635 @unnumberedsec Attribute Maximum_Alignment
8636 @cindex Alignment, maximum
8637 @findex Maximum_Alignment
8639 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8640 permissible prefix) provides the maximum useful alignment value for the
8641 target. This is a static value that can be used to specify the alignment
8642 for an object, guaranteeing that it is properly aligned in all
8645 @node Attribute Mechanism_Code
8646 @unnumberedsec Attribute Mechanism_Code
8647 @cindex Return values, passing mechanism
8648 @cindex Parameters, passing mechanism
8649 @findex Mechanism_Code
8651 @code{@var{function}'Mechanism_Code} yields an integer code for the
8652 mechanism used for the result of function, and
8653 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8654 used for formal parameter number @var{n} (a static integer value with 1
8655 meaning the first parameter) of @var{subprogram}. The code returned is:
8663 by descriptor (default descriptor class)
8665 by descriptor (UBS: unaligned bit string)
8667 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8669 by descriptor (UBA: unaligned bit array)
8671 by descriptor (S: string, also scalar access type parameter)
8673 by descriptor (SB: string with arbitrary bounds)
8675 by descriptor (A: contiguous array)
8677 by descriptor (NCA: non-contiguous array)
8681 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8684 @node Attribute Null_Parameter
8685 @unnumberedsec Attribute Null_Parameter
8686 @cindex Zero address, passing
8687 @findex Null_Parameter
8689 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8690 type or subtype @var{T} allocated at machine address zero. The attribute
8691 is allowed only as the default expression of a formal parameter, or as
8692 an actual expression of a subprogram call. In either case, the
8693 subprogram must be imported.
8695 The identity of the object is represented by the address zero in the
8696 argument list, independent of the passing mechanism (explicit or
8699 This capability is needed to specify that a zero address should be
8700 passed for a record or other composite object passed by reference.
8701 There is no way of indicating this without the @code{Null_Parameter}
8704 @node Attribute Object_Size
8705 @unnumberedsec Attribute Object_Size
8706 @cindex Size, used for objects
8709 The size of an object is not necessarily the same as the size of the type
8710 of an object. This is because by default object sizes are increased to be
8711 a multiple of the alignment of the object. For example,
8712 @code{Natural'Size} is
8713 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8714 Similarly, a record containing an integer and a character:
8716 @smallexample @c ada
8724 will have a size of 40 (that is @code{Rec'Size} will be 40). The
8725 alignment will be 4, because of the
8726 integer field, and so the default size of record objects for this type
8727 will be 64 (8 bytes).
8729 A consequence of this capability is that different object sizes can be
8730 given to subtypes that would otherwise be considered in Ada to be
8731 statically matching. But it makes no sense to consider such subtypes
8732 as statically matching. Consequently, in @code{GNAT} we add a rule
8733 to the static matching rules that requires object sizes to match.
8734 Consider this example:
8736 @smallexample @c ada
8737 1. procedure BadAVConvert is
8738 2. type R is new Integer;
8739 3. subtype R1 is R range 1 .. 10;
8740 4. subtype R2 is R range 1 .. 10;
8741 5. for R1'Object_Size use 8;
8742 6. for R2'Object_Size use 16;
8743 7. type R1P is access all R1;
8744 8. type R2P is access all R2;
8745 9. R1PV : R1P := new R1'(4);
8748 12. R2PV := R2P (R1PV);
8750 >>> target designated subtype not compatible with
8751 type "R1" defined at line 3
8757 In the absence of lines 5 and 6,
8758 types @code{R1} and @code{R2} statically match and
8759 hence the conversion on line 12 is legal. But since lines 5 and 6
8760 cause the object sizes to differ, @code{GNAT} considers that types
8761 @code{R1} and @code{R2} are not statically matching, and line 12
8762 generates the diagnostic shown above.
8765 Similar additional checks are performed in other contexts requiring
8766 statically matching subtypes.
8768 @node Attribute Passed_By_Reference
8769 @unnumberedsec Attribute Passed_By_Reference
8770 @cindex Parameters, when passed by reference
8771 @findex Passed_By_Reference
8773 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8774 a value of type @code{Boolean} value that is @code{True} if the type is
8775 normally passed by reference and @code{False} if the type is normally
8776 passed by copy in calls. For scalar types, the result is always @code{False}
8777 and is static. For non-scalar types, the result is non-static.
8779 @node Attribute Pool_Address
8780 @unnumberedsec Attribute Pool_Address
8781 @cindex Parameters, when passed by reference
8782 @findex Pool_Address
8784 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8785 of X within its storage pool. This is the same as
8786 @code{@var{X}'Address}, except that for an unconstrained array whose
8787 bounds are allocated just before the first component,
8788 @code{@var{X}'Pool_Address} returns the address of those bounds,
8789 whereas @code{@var{X}'Address} returns the address of the first
8792 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8793 the object is allocated'', which could be a user-defined storage pool,
8794 the global heap, on the stack, or in a static memory area. For an
8795 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8796 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8798 @node Attribute Range_Length
8799 @unnumberedsec Attribute Range_Length
8800 @findex Range_Length
8802 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8803 the number of values represented by the subtype (zero for a null
8804 range). The result is static for static subtypes. @code{Range_Length}
8805 applied to the index subtype of a one dimensional array always gives the
8806 same result as @code{Length} applied to the array itself.
8809 @unnumberedsec Attribute Ref
8814 @node Attribute Restriction_Set
8815 @unnumberedsec Attribute Restriction_Set
8816 @findex Restriction_Set
8817 @cindex Restrictions
8819 This attribute allows compile time testing of restrictions that
8820 are currently in effect. It is primarily intended for specializing
8821 code in the run-time based on restrictions that are active (e.g.
8822 don't need to save fpt registers if restriction No_Floating_Point
8823 is known to be in effect), but can be used anywhere.
8825 There are two forms:
8827 @smallexample @c ada
8828 System'Restriction_Set (partition_boolean_restriction_NAME)
8829 System'Restriction_Set (No_Dependence => library_unit_NAME);
8833 In the case of the first form, the only restriction names
8834 allowed are parameterless restrictions that are checked
8835 for consistency at bind time. For a complete list see the
8836 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
8838 The result returned is True if the restriction is known to
8839 be in effect, and False if the restriction is known not to
8840 be in effect. An important guarantee is that the value of
8841 a Restriction_Set attribute is known to be consistent throughout
8842 all the code of a partition.
8844 This is trivially achieved if the entire partition is compiled
8845 with a consistent set of restriction pragmas. However, the
8846 compilation model does not require this. It is possible to
8847 compile one set of units with one set of pragmas, and another
8848 set of units with another set of pragmas. It is even possible
8849 to compile a spec with one set of pragmas, and then WITH the
8850 same spec with a different set of pragmas. Inconsistencies
8851 in the actual use of the restriction are checked at bind time.
8853 In order to achieve the guarantee of consistency for the
8854 Restriction_Set pragma, we consider that a use of the pragma
8855 that yields False is equivalent to a violation of the
8858 So for example if you write
8860 @smallexample @c ada
8861 if System'Restriction_Set (No_Floating_Point) then
8869 And the result is False, so that the else branch is executed,
8870 you can assume that this restriction is not set for any unit
8871 in the partition. This is checked by considering this use of
8872 the restriction pragma to be a violation of the restriction
8873 No_Floating_Point. This means that no other unit can attempt
8874 to set this restriction (if some unit does attempt to set it,
8875 the binder will refuse to bind the partition).
8877 Technical note: The restriction name and the unit name are
8878 intepreted entirely syntactically, as in the corresponding
8879 Restrictions pragma, they are not analyzed semantically,
8880 so they do not have a type.
8882 @node Attribute Result
8883 @unnumberedsec Attribute Result
8886 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8887 for a function. The prefix must be the name of the corresponding function. This
8888 is used to refer to the result of the function in the postcondition expression.
8889 For a further discussion of the use of this attribute and examples of its use,
8890 see the description of pragma Postcondition.
8892 @node Attribute Safe_Emax
8893 @unnumberedsec Attribute Safe_Emax
8894 @cindex Ada 83 attributes
8897 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
8898 the Ada 83 reference manual for an exact description of the semantics of
8901 @node Attribute Safe_Large
8902 @unnumberedsec Attribute Safe_Large
8903 @cindex Ada 83 attributes
8906 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
8907 the Ada 83 reference manual for an exact description of the semantics of
8910 @node Attribute Scalar_Storage_Order
8911 @unnumberedsec Attribute Scalar_Storage_Order
8913 @cindex Scalar storage order
8914 @findex Scalar_Storage_Order
8916 For every array or record type @var{S}, the representation attribute
8917 @code{Scalar_Storage_Order} denotes the order in which storage elements
8918 that make up scalar components are ordered within S:
8920 @smallexample @c ada
8921 -- Component type definitions
8923 subtype Yr_Type is Natural range 0 .. 127;
8924 subtype Mo_Type is Natural range 1 .. 12;
8925 subtype Da_Type is Natural range 1 .. 31;
8927 -- Record declaration
8930 Years_Since_1980 : Yr_Type;
8932 Day_Of_Month : Da_Type;
8935 -- Record representation clause
8938 Years_Since_1980 at 0 range 0 .. 6;
8939 Month at 0 range 7 .. 10;
8940 Day_Of_Month at 0 range 11 .. 15;
8943 -- Attribute definition clauses
8945 for Date'Bit_Order use System.High_Order_First;
8946 for Date'Scalar_Storage_Order use System.High_Order_First;
8947 -- If Scalar_Storage_Order is specified, it must be consistent with
8948 -- Bit_Order, so it's best to always define the latter explicitly if
8949 -- the former is used.
8952 Other properties are
8953 as for standard representation attribute @code{Bit_Order}, as defined by
8954 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8956 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8957 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8958 this means that if a @code{Scalar_Storage_Order} attribute definition
8959 clause is not confirming, then the type's @code{Bit_Order} shall be
8960 specified explicitly and set to the same value.
8962 For a record extension, the derived type shall have the same scalar storage
8963 order as the parent type.
8965 If a component of @var{S} has itself a record or array type, then it shall also
8966 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8967 if the component is a packed array, or does not start on a byte boundary, then
8968 the scalar storage order specified for S and for the nested component type shall
8971 If @var{S} appears as the type of a record or array component, the enclosing
8972 record or array shall also have a @code{Scalar_Storage_Order} attribute
8975 No component of a type that has a @code{Scalar_Storage_Order} attribute
8976 definition may be aliased.
8978 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8979 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8981 If the opposite storage order is specified, then whenever the value of
8982 a scalar component of an object of type @var{S} is read, the storage
8983 elements of the enclosing machine scalar are first reversed (before
8984 retrieving the component value, possibly applying some shift and mask
8985 operatings on the enclosing machine scalar), and the opposite operation
8988 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8989 are relaxed. Instead, the following rules apply:
8992 @item the underlying storage elements are those at positions
8993 @code{(position + first_bit / storage_element_size) ..
8994 (position + (last_bit + storage_element_size - 1) /
8995 storage_element_size)}
8996 @item the sequence of underlying storage elements shall have
8997 a size no greater than the largest machine scalar
8998 @item the enclosing machine scalar is defined as the smallest machine
8999 scalar starting at a position no greater than
9000 @code{position + first_bit / storage_element_size} and covering
9001 storage elements at least up to @code{position + (last_bit +
9002 storage_element_size - 1) / storage_element_size}
9003 @item the position of the component is interpreted relative to that machine
9008 @node Attribute Simple_Storage_Pool
9009 @unnumberedsec Attribute Simple_Storage_Pool
9010 @cindex Storage pool, simple
9011 @cindex Simple storage pool
9012 @findex Simple_Storage_Pool
9014 For every nonformal, nonderived access-to-object type @var{Acc}, the
9015 representation attribute @code{Simple_Storage_Pool} may be specified
9016 via an attribute_definition_clause (or by specifying the equivalent aspect):
9018 @smallexample @c ada
9020 My_Pool : My_Simple_Storage_Pool_Type;
9022 type Acc is access My_Data_Type;
9024 for Acc'Simple_Storage_Pool use My_Pool;
9029 The name given in an attribute_definition_clause for the
9030 @code{Simple_Storage_Pool} attribute shall denote a variable of
9031 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9033 The use of this attribute is only allowed for a prefix denoting a type
9034 for which it has been specified. The type of the attribute is the type
9035 of the variable specified as the simple storage pool of the access type,
9036 and the attribute denotes that variable.
9038 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9039 for the same access type.
9041 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9042 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9043 with a warning and its evaluation raises the exception @code{Program_Error}.
9045 If the Simple_Storage_Pool attribute has been specified for an access
9046 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9047 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9048 which is intended to indicate the number of storage elements reserved for
9049 the simple storage pool. If the Storage_Size function has not been defined
9050 for the simple storage pool type, then this attribute returns zero.
9052 If an access type @var{S} has a specified simple storage pool of type
9053 @var{SSP}, then the evaluation of an allocator for that access type calls
9054 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9055 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9056 semantics of such allocators is the same as those defined for allocators
9057 in section 13.11 of the Ada Reference Manual, with the term
9058 ``simple storage pool'' substituted for ``storage pool''.
9060 If an access type @var{S} has a specified simple storage pool of type
9061 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9062 for that access type invokes the primitive @code{Deallocate} procedure
9063 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9064 parameter. The detailed semantics of such unchecked deallocations is the same
9065 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9066 term ``simple storage pool'' is substituted for ``storage pool''.
9068 @node Attribute Small
9069 @unnumberedsec Attribute Small
9070 @cindex Ada 83 attributes
9073 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9075 GNAT also allows this attribute to be applied to floating-point types
9076 for compatibility with Ada 83. See
9077 the Ada 83 reference manual for an exact description of the semantics of
9078 this attribute when applied to floating-point types.
9080 @node Attribute Storage_Unit
9081 @unnumberedsec Attribute Storage_Unit
9082 @findex Storage_Unit
9084 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9085 prefix) provides the same value as @code{System.Storage_Unit}.
9087 @node Attribute Stub_Type
9088 @unnumberedsec Attribute Stub_Type
9091 The GNAT implementation of remote access-to-classwide types is
9092 organized as described in AARM section E.4 (20.t): a value of an RACW type
9093 (designating a remote object) is represented as a normal access
9094 value, pointing to a "stub" object which in turn contains the
9095 necessary information to contact the designated remote object. A
9096 call on any dispatching operation of such a stub object does the
9097 remote call, if necessary, using the information in the stub object
9098 to locate the target partition, etc.
9100 For a prefix @code{T} that denotes a remote access-to-classwide type,
9101 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9103 By construction, the layout of @code{T'Stub_Type} is identical to that of
9104 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9105 unit @code{System.Partition_Interface}. Use of this attribute will create
9106 an implicit dependency on this unit.
9108 @node Attribute System_Allocator_Alignment
9109 @unnumberedsec Attribute System_Allocator_Alignment
9110 @cindex Alignment, allocator
9111 @findex System_Allocator_Alignment
9113 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9114 permissible prefix) provides the observable guaranted to be honored by
9115 the system allocator (malloc). This is a static value that can be used
9116 in user storage pools based on malloc either to reject allocation
9117 with alignment too large or to enable a realignment circuitry if the
9118 alignment request is larger than this value.
9120 @node Attribute Target_Name
9121 @unnumberedsec Attribute Target_Name
9124 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9125 prefix) provides a static string value that identifies the target
9126 for the current compilation. For GCC implementations, this is the
9127 standard gcc target name without the terminating slash (for
9128 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9130 @node Attribute Tick
9131 @unnumberedsec Attribute Tick
9134 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
9135 provides the same value as @code{System.Tick},
9137 @node Attribute To_Address
9138 @unnumberedsec Attribute To_Address
9141 The @code{System'To_Address}
9142 (@code{System} is the only permissible prefix)
9143 denotes a function identical to
9144 @code{System.Storage_Elements.To_Address} except that
9145 it is a static attribute. This means that if its argument is
9146 a static expression, then the result of the attribute is a
9147 static expression. This means that such an expression can be
9148 used in contexts (e.g.@: preelaborable packages) which require a
9149 static expression and where the function call could not be used
9150 (since the function call is always non-static, even if its
9151 argument is static). The argument must be in the range
9152 -(2**(m-1) .. 2**m-1, where m is the memory size
9153 (typically 32 or 64). Negative values are intepreted in a
9154 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9157 @node Attribute Type_Class
9158 @unnumberedsec Attribute Type_Class
9161 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9162 the value of the type class for the full type of @var{type}. If
9163 @var{type} is a generic formal type, the value is the value for the
9164 corresponding actual subtype. The value of this attribute is of type
9165 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9167 @smallexample @c ada
9169 (Type_Class_Enumeration,
9171 Type_Class_Fixed_Point,
9172 Type_Class_Floating_Point,
9177 Type_Class_Address);
9181 Protected types yield the value @code{Type_Class_Task}, which thus
9182 applies to all concurrent types. This attribute is designed to
9183 be compatible with the DEC Ada 83 attribute of the same name.
9185 @node Attribute UET_Address
9186 @unnumberedsec Attribute UET_Address
9189 The @code{UET_Address} attribute can only be used for a prefix which
9190 denotes a library package. It yields the address of the unit exception
9191 table when zero cost exception handling is used. This attribute is
9192 intended only for use within the GNAT implementation. See the unit
9193 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9194 for details on how this attribute is used in the implementation.
9196 @node Attribute Unconstrained_Array
9197 @unnumberedsec Attribute Unconstrained_Array
9198 @findex Unconstrained_Array
9200 The @code{Unconstrained_Array} attribute can be used with a prefix that
9201 denotes any type or subtype. It is a static attribute that yields
9202 @code{True} if the prefix designates an unconstrained array,
9203 and @code{False} otherwise. In a generic instance, the result is
9204 still static, and yields the result of applying this test to the
9207 @node Attribute Universal_Literal_String
9208 @unnumberedsec Attribute Universal_Literal_String
9209 @cindex Named numbers, representation of
9210 @findex Universal_Literal_String
9212 The prefix of @code{Universal_Literal_String} must be a named
9213 number. The static result is the string consisting of the characters of
9214 the number as defined in the original source. This allows the user
9215 program to access the actual text of named numbers without intermediate
9216 conversions and without the need to enclose the strings in quotes (which
9217 would preclude their use as numbers).
9219 For example, the following program prints the first 50 digits of pi:
9221 @smallexample @c ada
9222 with Text_IO; use Text_IO;
9226 Put (Ada.Numerics.Pi'Universal_Literal_String);
9230 @node Attribute Unrestricted_Access
9231 @unnumberedsec Attribute Unrestricted_Access
9232 @cindex @code{Access}, unrestricted
9233 @findex Unrestricted_Access
9235 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9236 except that all accessibility and aliased view checks are omitted. This
9237 is a user-beware attribute. It is similar to
9238 @code{Address}, for which it is a desirable replacement where the value
9239 desired is an access type. In other words, its effect is identical to
9240 first applying the @code{Address} attribute and then doing an unchecked
9241 conversion to a desired access type. In GNAT, but not necessarily in
9242 other implementations, the use of static chains for inner level
9243 subprograms means that @code{Unrestricted_Access} applied to a
9244 subprogram yields a value that can be called as long as the subprogram
9245 is in scope (normal Ada accessibility rules restrict this usage).
9247 It is possible to use @code{Unrestricted_Access} for any type, but care
9248 must be exercised if it is used to create pointers to unconstrained
9249 objects. In this case, the resulting pointer has the same scope as the
9250 context of the attribute, and may not be returned to some enclosing
9251 scope. For instance, a function cannot use @code{Unrestricted_Access}
9252 to create a unconstrained pointer and then return that value to the
9255 @node Attribute Update
9256 @unnumberedsec Attribute Update
9259 The @code{Update} attribute creates a copy of an array or record value
9260 with one or more modified components. The syntax is:
9262 @smallexample @c ada
9263 PREFIX'Update (AGGREGATE)
9267 where @code{PREFIX} is the name of an array or record object, and
9268 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
9269 choice. The effect is to yield a copy of the array or record value which
9270 is unchanged apart from the components mentioned in the aggregate, which
9271 are changed to the indicated value. The original value of the array or
9272 record value is not affected. For example:
9274 @smallexample @c ada
9275 type Arr is Array (1 .. 5) of Integer;
9277 Avar1 : Arr := (1,2,3,4,5);
9278 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
9282 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9283 begin unmodified. Similarly:
9285 @smallexample @c ada
9286 type Rec is A, B, C : Integer;
9288 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9289 Rvar2 : Rec := Rvar1'Update ((B => 20));
9293 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9294 with @code{Rvar1} being unmodifed.
9295 Note that the value of the attribute reference is computed
9296 completely before it is used. This means that if you write:
9298 @smallexample @c ada
9299 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
9303 then the value of @code{Avar1} is not modified if @code{Function_Call}
9304 raises an exception, unlike the effect of a series of direct assignments
9305 to elements of @code{Avar1}. In general this requires that
9306 two extra complete copies of the object are required, which should be
9307 kept in mind when considering efficiency.
9309 The @code{Update} attribute cannot be applied to prefixes of a limited
9310 type, and cannot reference discriminants in the case of a record type.
9311 The accessibility level of an Update attribute result object is defined
9312 as for an aggregate.
9314 In the record case, no component can be mentioned more than once. In
9315 the array case, two overlapping ranges can appear in the aggregate,
9316 in which case the modifications are processed left to right.
9318 Multi-dimensional arrays can be modified, as shown by this example:
9320 @smallexample @c ada
9321 A : array (1 .. 10, 1 .. 10) of Integer;
9323 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
9327 which changes element (1,2) to 20 and (3,4) to 30.
9329 @node Attribute Valid_Scalars
9330 @unnumberedsec Attribute Valid_Scalars
9331 @findex Valid_Scalars
9333 The @code{'Valid_Scalars} attribute is intended to make it easier to
9334 check the validity of scalar subcomponents of composite objects. It
9335 is defined for any prefix @code{X} that denotes an object.
9336 The value of this attribute is of the predefined type Boolean.
9337 @code{X'Valid_Scalars} yields True if and only if evaluation of
9338 @code{P'Valid} yields True for every scalar part P of X or if X has
9339 no scalar parts. It is not specified in what order the scalar parts
9340 are checked, nor whether any more are checked after any one of them
9341 is determined to be invalid. If the prefix @code{X} is of a class-wide
9342 type @code{T'Class} (where @code{T} is the associated specific type),
9343 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9344 only the scalar parts of components of @code{T} are traversed; in other
9345 words, components of extensions of @code{T} are not traversed even if
9346 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9347 be determined at compile time that the prefix of the attribute has no
9348 scalar parts (e.g., if the prefix is of an access type, an interface type,
9349 an undiscriminated task type, or an undiscriminated protected type).
9351 @node Attribute VADS_Size
9352 @unnumberedsec Attribute VADS_Size
9353 @cindex @code{Size}, VADS compatibility
9356 The @code{'VADS_Size} attribute is intended to make it easier to port
9357 legacy code which relies on the semantics of @code{'Size} as implemented
9358 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
9359 same semantic interpretation. In particular, @code{'VADS_Size} applied
9360 to a predefined or other primitive type with no Size clause yields the
9361 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9362 typical machines). In addition @code{'VADS_Size} applied to an object
9363 gives the result that would be obtained by applying the attribute to
9364 the corresponding type.
9366 @node Attribute Value_Size
9367 @unnumberedsec Attribute Value_Size
9368 @cindex @code{Size}, setting for not-first subtype
9370 @code{@var{type}'Value_Size} is the number of bits required to represent
9371 a value of the given subtype. It is the same as @code{@var{type}'Size},
9372 but, unlike @code{Size}, may be set for non-first subtypes.
9374 @node Attribute Wchar_T_Size
9375 @unnumberedsec Attribute Wchar_T_Size
9376 @findex Wchar_T_Size
9377 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9378 prefix) provides the size in bits of the C @code{wchar_t} type
9379 primarily for constructing the definition of this type in
9380 package @code{Interfaces.C}.
9382 @node Attribute Word_Size
9383 @unnumberedsec Attribute Word_Size
9385 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9386 prefix) provides the value @code{System.Word_Size}.
9388 @node Standard and Implementation Defined Restrictions
9389 @chapter Standard and Implementation Defined Restrictions
9392 All RM defined Restriction identifiers are implemented:
9395 @item language-defined restrictions (see 13.12.1)
9396 @item tasking restrictions (see D.7)
9397 @item high integrity restrictions (see H.4)
9401 GNAT implements additional restriction identifiers. All restrictions, whether
9402 language defined or GNAT-specific, are listed in the following.
9405 * Partition-Wide Restrictions::
9406 * Program Unit Level Restrictions::
9409 @node Partition-Wide Restrictions
9410 @section Partition-Wide Restrictions
9412 There are two separate lists of restriction identifiers. The first
9413 set requires consistency throughout a partition (in other words, if the
9414 restriction identifier is used for any compilation unit in the partition,
9415 then all compilation units in the partition must obey the restriction).
9418 * Immediate_Reclamation::
9419 * Max_Asynchronous_Select_Nesting::
9420 * Max_Entry_Queue_Length::
9421 * Max_Protected_Entries::
9422 * Max_Select_Alternatives::
9423 * Max_Storage_At_Blocking::
9424 * Max_Task_Entries::
9426 * No_Abort_Statements::
9427 * No_Access_Parameter_Allocators::
9428 * No_Access_Subprograms::
9430 * No_Anonymous_Allocators::
9433 * No_Default_Initialization::
9436 * No_Direct_Boolean_Operators::
9438 * No_Dispatching_Calls::
9439 * No_Dynamic_Attachment::
9440 * No_Dynamic_Priorities::
9441 * No_Entry_Calls_In_Elaboration_Code::
9442 * No_Enumeration_Maps::
9443 * No_Exception_Handlers::
9444 * No_Exception_Propagation::
9445 * No_Exception_Registration::
9449 * No_Floating_Point::
9450 * No_Implicit_Conditionals::
9451 * No_Implicit_Dynamic_Code::
9452 * No_Implicit_Heap_Allocations::
9453 * No_Implicit_Loops::
9454 * No_Initialize_Scalars::
9456 * No_Local_Allocators::
9457 * No_Local_Protected_Objects::
9458 * No_Local_Timing_Events::
9459 * No_Nested_Finalization::
9460 * No_Protected_Type_Allocators::
9461 * No_Protected_Types::
9464 * No_Relative_Delay::
9465 * No_Requeue_Statements::
9466 * No_Secondary_Stack::
9467 * No_Select_Statements::
9468 * No_Specific_Termination_Handlers::
9469 * No_Specification_of_Aspect::
9470 * No_Standard_Allocators_After_Elaboration::
9471 * No_Standard_Storage_Pools::
9472 * No_Stream_Optimizations::
9474 * No_Task_Allocators::
9475 * No_Task_Attributes_Package::
9476 * No_Task_Hierarchy::
9477 * No_Task_Termination::
9479 * No_Terminate_Alternatives::
9480 * No_Unchecked_Access::
9482 * Static_Priorities::
9483 * Static_Storage_Size::
9486 @node Immediate_Reclamation
9487 @unnumberedsubsec Immediate_Reclamation
9488 @findex Immediate_Reclamation
9489 [RM H.4] This restriction ensures that, except for storage occupied by
9490 objects created by allocators and not deallocated via unchecked
9491 deallocation, any storage reserved at run time for an object is
9492 immediately reclaimed when the object no longer exists.
9494 @node Max_Asynchronous_Select_Nesting
9495 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9496 @findex Max_Asynchronous_Select_Nesting
9497 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9498 selects. Violations of this restriction with a value of zero are
9499 detected at compile time. Violations of this restriction with values
9500 other than zero cause Storage_Error to be raised.
9502 @node Max_Entry_Queue_Length
9503 @unnumberedsubsec Max_Entry_Queue_Length
9504 @findex Max_Entry_Queue_Length
9505 [RM D.7] This restriction is a declaration that any protected entry compiled in
9506 the scope of the restriction has at most the specified number of
9507 tasks waiting on the entry at any one time, and so no queue is required.
9508 Note that this restriction is checked at run time. Violation of this
9509 restriction results in the raising of Program_Error exception at the point of
9512 @findex Max_Entry_Queue_Depth
9513 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9514 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9515 compatibility purposes (and a warning will be generated for its use if
9516 warnings on obsolescent features are activated).
9518 @node Max_Protected_Entries
9519 @unnumberedsubsec Max_Protected_Entries
9520 @findex Max_Protected_Entries
9521 [RM D.7] Specifies the maximum number of entries per protected type. The
9522 bounds of every entry family of a protected unit shall be static, or shall be
9523 defined by a discriminant of a subtype whose corresponding bound is static.
9525 @node Max_Select_Alternatives
9526 @unnumberedsubsec Max_Select_Alternatives
9527 @findex Max_Select_Alternatives
9528 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9530 @node Max_Storage_At_Blocking
9531 @unnumberedsubsec Max_Storage_At_Blocking
9532 @findex Max_Storage_At_Blocking
9533 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9534 Storage_Size that can be retained by a blocked task. A violation of this
9535 restriction causes Storage_Error to be raised.
9537 @node Max_Task_Entries
9538 @unnumberedsubsec Max_Task_Entries
9539 @findex Max_Task_Entries
9540 [RM D.7] Specifies the maximum number of entries
9541 per task. The bounds of every entry family
9542 of a task unit shall be static, or shall be
9543 defined by a discriminant of a subtype whose
9544 corresponding bound is static.
9547 @unnumberedsubsec Max_Tasks
9549 [RM D.7] Specifies the maximum number of task that may be created, not
9550 counting the creation of the environment task. Violations of this
9551 restriction with a value of zero are detected at compile
9552 time. Violations of this restriction with values other than zero cause
9553 Storage_Error to be raised.
9555 @node No_Abort_Statements
9556 @unnumberedsubsec No_Abort_Statements
9557 @findex No_Abort_Statements
9558 [RM D.7] There are no abort_statements, and there are
9559 no calls to Task_Identification.Abort_Task.
9561 @node No_Access_Parameter_Allocators
9562 @unnumberedsubsec No_Access_Parameter_Allocators
9563 @findex No_Access_Parameter_Allocators
9564 [RM H.4] This restriction ensures at compile time that there are no
9565 occurrences of an allocator as the actual parameter to an access
9568 @node No_Access_Subprograms
9569 @unnumberedsubsec No_Access_Subprograms
9570 @findex No_Access_Subprograms
9571 [RM H.4] This restriction ensures at compile time that there are no
9572 declarations of access-to-subprogram types.
9575 @unnumberedsubsec No_Allocators
9576 @findex No_Allocators
9577 [RM H.4] This restriction ensures at compile time that there are no
9578 occurrences of an allocator.
9580 @node No_Anonymous_Allocators
9581 @unnumberedsubsec No_Anonymous_Allocators
9582 @findex No_Anonymous_Allocators
9583 [RM H.4] This restriction ensures at compile time that there are no
9584 occurrences of an allocator of anonymous access type.
9587 @unnumberedsubsec No_Calendar
9589 [GNAT] This restriction ensures at compile time that there is no implicit or
9590 explicit dependence on the package @code{Ada.Calendar}.
9592 @node No_Coextensions
9593 @unnumberedsubsec No_Coextensions
9594 @findex No_Coextensions
9595 [RM H.4] This restriction ensures at compile time that there are no
9596 coextensions. See 3.10.2.
9598 @node No_Default_Initialization
9599 @unnumberedsubsec No_Default_Initialization
9600 @findex No_Default_Initialization
9602 [GNAT] This restriction prohibits any instance of default initialization
9603 of variables. The binder implements a consistency rule which prevents
9604 any unit compiled without the restriction from with'ing a unit with the
9605 restriction (this allows the generation of initialization procedures to
9606 be skipped, since you can be sure that no call is ever generated to an
9607 initialization procedure in a unit with the restriction active). If used
9608 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
9609 is to prohibit all cases of variables declared without a specific
9610 initializer (including the case of OUT scalar parameters).
9613 @unnumberedsubsec No_Delay
9615 [RM H.4] This restriction ensures at compile time that there are no
9616 delay statements and no dependences on package Calendar.
9619 @unnumberedsubsec No_Dependence
9620 @findex No_Dependence
9621 [RM 13.12.1] This restriction checks at compile time that there are no
9622 dependence on a library unit.
9624 @node No_Direct_Boolean_Operators
9625 @unnumberedsubsec No_Direct_Boolean_Operators
9626 @findex No_Direct_Boolean_Operators
9627 [GNAT] This restriction ensures that no logical operators (and/or/xor)
9628 are used on operands of type Boolean (or any type derived from Boolean).
9629 This is intended for use in safety critical programs where the certification
9630 protocol requires the use of short-circuit (and then, or else) forms for all
9631 composite boolean operations.
9634 @unnumberedsubsec No_Dispatch
9636 [RM H.4] This restriction ensures at compile time that there are no
9637 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
9639 @node No_Dispatching_Calls
9640 @unnumberedsubsec No_Dispatching_Calls
9641 @findex No_Dispatching_Calls
9642 [GNAT] This restriction ensures at compile time that the code generated by the
9643 compiler involves no dispatching calls. The use of this restriction allows the
9644 safe use of record extensions, classwide membership tests and other classwide
9645 features not involving implicit dispatching. This restriction ensures that
9646 the code contains no indirect calls through a dispatching mechanism. Note that
9647 this includes internally-generated calls created by the compiler, for example
9648 in the implementation of class-wide objects assignments. The
9649 membership test is allowed in the presence of this restriction, because its
9650 implementation requires no dispatching.
9651 This restriction is comparable to the official Ada restriction
9652 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
9653 all classwide constructs that do not imply dispatching.
9654 The following example indicates constructs that violate this restriction.
9658 type T is tagged record
9661 procedure P (X : T);
9663 type DT is new T with record
9664 More_Data : Natural;
9666 procedure Q (X : DT);
9670 procedure Example is
9671 procedure Test (O : T'Class) is
9672 N : Natural := O'Size;-- Error: Dispatching call
9673 C : T'Class := O; -- Error: implicit Dispatching Call
9675 if O in DT'Class then -- OK : Membership test
9676 Q (DT (O)); -- OK : Type conversion plus direct call
9678 P (O); -- Error: Dispatching call
9684 P (Obj); -- OK : Direct call
9685 P (T (Obj)); -- OK : Type conversion plus direct call
9686 P (T'Class (Obj)); -- Error: Dispatching call
9688 Test (Obj); -- OK : Type conversion
9690 if Obj in T'Class then -- OK : Membership test
9696 @node No_Dynamic_Attachment
9697 @unnumberedsubsec No_Dynamic_Attachment
9698 @findex No_Dynamic_Attachment
9699 [RM D.7] This restriction ensures that there is no call to any of the
9700 operations defined in package Ada.Interrupts
9701 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9702 Detach_Handler, and Reference).
9704 @findex No_Dynamic_Interrupts
9705 The restriction @code{No_Dynamic_Interrupts} is recognized as a
9706 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
9707 compatibility purposes (and a warning will be generated for its use if
9708 warnings on obsolescent features are activated).
9710 @node No_Dynamic_Priorities
9711 @unnumberedsubsec No_Dynamic_Priorities
9712 @findex No_Dynamic_Priorities
9713 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9715 @node No_Entry_Calls_In_Elaboration_Code
9716 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9717 @findex No_Entry_Calls_In_Elaboration_Code
9718 [GNAT] This restriction ensures at compile time that no task or protected entry
9719 calls are made during elaboration code. As a result of the use of this
9720 restriction, the compiler can assume that no code past an accept statement
9721 in a task can be executed at elaboration time.
9723 @node No_Enumeration_Maps
9724 @unnumberedsubsec No_Enumeration_Maps
9725 @findex No_Enumeration_Maps
9726 [GNAT] This restriction ensures at compile time that no operations requiring
9727 enumeration maps are used (that is Image and Value attributes applied
9728 to enumeration types).
9730 @node No_Exception_Handlers
9731 @unnumberedsubsec No_Exception_Handlers
9732 @findex No_Exception_Handlers
9733 [GNAT] This restriction ensures at compile time that there are no explicit
9734 exception handlers. It also indicates that no exception propagation will
9735 be provided. In this mode, exceptions may be raised but will result in
9736 an immediate call to the last chance handler, a routine that the user
9737 must define with the following profile:
9739 @smallexample @c ada
9740 procedure Last_Chance_Handler
9741 (Source_Location : System.Address; Line : Integer);
9742 pragma Export (C, Last_Chance_Handler,
9743 "__gnat_last_chance_handler");
9746 The parameter is a C null-terminated string representing a message to be
9747 associated with the exception (typically the source location of the raise
9748 statement generated by the compiler). The Line parameter when nonzero
9749 represents the line number in the source program where the raise occurs.
9751 @node No_Exception_Propagation
9752 @unnumberedsubsec No_Exception_Propagation
9753 @findex No_Exception_Propagation
9754 [GNAT] This restriction guarantees that exceptions are never propagated
9755 to an outer subprogram scope. The only case in which an exception may
9756 be raised is when the handler is statically in the same subprogram, so
9757 that the effect of a raise is essentially like a goto statement. Any
9758 other raise statement (implicit or explicit) will be considered
9759 unhandled. Exception handlers are allowed, but may not contain an
9760 exception occurrence identifier (exception choice). In addition, use of
9761 the package GNAT.Current_Exception is not permitted, and reraise
9762 statements (raise with no operand) are not permitted.
9764 @node No_Exception_Registration
9765 @unnumberedsubsec No_Exception_Registration
9766 @findex No_Exception_Registration
9767 [GNAT] This restriction ensures at compile time that no stream operations for
9768 types Exception_Id or Exception_Occurrence are used. This also makes it
9769 impossible to pass exceptions to or from a partition with this restriction
9770 in a distributed environment. If this exception is active, then the generated
9771 code is simplified by omitting the otherwise-required global registration
9772 of exceptions when they are declared.
9775 @unnumberedsubsec No_Exceptions
9776 @findex No_Exceptions
9777 [RM H.4] This restriction ensures at compile time that there are no
9778 raise statements and no exception handlers.
9780 @node No_Finalization
9781 @unnumberedsubsec No_Finalization
9782 @findex No_Finalization
9783 [GNAT] This restriction disables the language features described in
9784 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9785 performed by the compiler to support these features. The following types
9786 are no longer considered controlled when this restriction is in effect:
9789 @code{Ada.Finalization.Controlled}
9791 @code{Ada.Finalization.Limited_Controlled}
9793 Derivations from @code{Controlled} or @code{Limited_Controlled}
9801 Array and record types with controlled components
9803 The compiler no longer generates code to initialize, finalize or adjust an
9804 object or a nested component, either declared on the stack or on the heap. The
9805 deallocation of a controlled object no longer finalizes its contents.
9807 @node No_Fixed_Point
9808 @unnumberedsubsec No_Fixed_Point
9809 @findex No_Fixed_Point
9810 [RM H.4] This restriction ensures at compile time that there are no
9811 occurrences of fixed point types and operations.
9813 @node No_Floating_Point
9814 @unnumberedsubsec No_Floating_Point
9815 @findex No_Floating_Point
9816 [RM H.4] This restriction ensures at compile time that there are no
9817 occurrences of floating point types and operations.
9819 @node No_Implicit_Conditionals
9820 @unnumberedsubsec No_Implicit_Conditionals
9821 @findex No_Implicit_Conditionals
9822 [GNAT] This restriction ensures that the generated code does not contain any
9823 implicit conditionals, either by modifying the generated code where possible,
9824 or by rejecting any construct that would otherwise generate an implicit
9825 conditional. Note that this check does not include run time constraint
9826 checks, which on some targets may generate implicit conditionals as
9827 well. To control the latter, constraint checks can be suppressed in the
9828 normal manner. Constructs generating implicit conditionals include comparisons
9829 of composite objects and the Max/Min attributes.
9831 @node No_Implicit_Dynamic_Code
9832 @unnumberedsubsec No_Implicit_Dynamic_Code
9833 @findex No_Implicit_Dynamic_Code
9835 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9836 This is a structure that is built on the stack and contains dynamic
9837 code to be executed at run time. On some targets, a trampoline is
9838 built for the following features: @code{Access},
9839 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9840 nested task bodies; primitive operations of nested tagged types.
9841 Trampolines do not work on machines that prevent execution of stack
9842 data. For example, on windows systems, enabling DEP (data execution
9843 protection) will cause trampolines to raise an exception.
9844 Trampolines are also quite slow at run time.
9846 On many targets, trampolines have been largely eliminated. Look at the
9847 version of system.ads for your target --- if it has
9848 Always_Compatible_Rep equal to False, then trampolines are largely
9849 eliminated. In particular, a trampoline is built for the following
9850 features: @code{Address} of a nested subprogram;
9851 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9852 but only if pragma Favor_Top_Level applies, or the access type has a
9853 foreign-language convention; primitive operations of nested tagged
9856 @node No_Implicit_Heap_Allocations
9857 @unnumberedsubsec No_Implicit_Heap_Allocations
9858 @findex No_Implicit_Heap_Allocations
9859 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9861 @node No_Implicit_Loops
9862 @unnumberedsubsec No_Implicit_Loops
9863 @findex No_Implicit_Loops
9864 [GNAT] This restriction ensures that the generated code does not contain any
9865 implicit @code{for} loops, either by modifying
9866 the generated code where possible,
9867 or by rejecting any construct that would otherwise generate an implicit
9868 @code{for} loop. If this restriction is active, it is possible to build
9869 large array aggregates with all static components without generating an
9870 intermediate temporary, and without generating a loop to initialize individual
9871 components. Otherwise, a loop is created for arrays larger than about 5000
9874 @node No_Initialize_Scalars
9875 @unnumberedsubsec No_Initialize_Scalars
9876 @findex No_Initialize_Scalars
9877 [GNAT] This restriction ensures that no unit in the partition is compiled with
9878 pragma Initialize_Scalars. This allows the generation of more efficient
9879 code, and in particular eliminates dummy null initialization routines that
9880 are otherwise generated for some record and array types.
9883 @unnumberedsubsec No_IO
9885 [RM H.4] This restriction ensures at compile time that there are no
9886 dependences on any of the library units Sequential_IO, Direct_IO,
9887 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9889 @node No_Local_Allocators
9890 @unnumberedsubsec No_Local_Allocators
9891 @findex No_Local_Allocators
9892 [RM H.4] This restriction ensures at compile time that there are no
9893 occurrences of an allocator in subprograms, generic subprograms, tasks,
9896 @node No_Local_Protected_Objects
9897 @unnumberedsubsec No_Local_Protected_Objects
9898 @findex No_Local_Protected_Objects
9899 [RM D.7] This restriction ensures at compile time that protected objects are
9900 only declared at the library level.
9902 @node No_Local_Timing_Events
9903 @unnumberedsubsec No_Local_Timing_Events
9904 @findex No_Local_Timing_Events
9905 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9906 declared at the library level.
9908 @node No_Nested_Finalization
9909 @unnumberedsubsec No_Nested_Finalization
9910 @findex No_Nested_Finalization
9911 [RM D.7] All objects requiring finalization are declared at the library level.
9913 @node No_Protected_Type_Allocators
9914 @unnumberedsubsec No_Protected_Type_Allocators
9915 @findex No_Protected_Type_Allocators
9916 [RM D.7] This restriction ensures at compile time that there are no allocator
9917 expressions that attempt to allocate protected objects.
9919 @node No_Protected_Types
9920 @unnumberedsubsec No_Protected_Types
9921 @findex No_Protected_Types
9922 [RM H.4] This restriction ensures at compile time that there are no
9923 declarations of protected types or protected objects.
9926 @unnumberedsubsec No_Recursion
9927 @findex No_Recursion
9928 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9929 part of its execution.
9932 @unnumberedsubsec No_Reentrancy
9933 @findex No_Reentrancy
9934 [RM H.4] A program execution is erroneous if a subprogram is executed by
9935 two tasks at the same time.
9937 @node No_Relative_Delay
9938 @unnumberedsubsec No_Relative_Delay
9939 @findex No_Relative_Delay
9940 [RM D.7] This restriction ensures at compile time that there are no delay
9941 relative statements and prevents expressions such as @code{delay 1.23;} from
9942 appearing in source code.
9944 @node No_Requeue_Statements
9945 @unnumberedsubsec No_Requeue_Statements
9946 @findex No_Requeue_Statements
9947 [RM D.7] This restriction ensures at compile time that no requeue statements
9948 are permitted and prevents keyword @code{requeue} from being used in source
9952 The restriction @code{No_Requeue} is recognized as a
9953 synonym for @code{No_Requeue_Statements}. This is retained for historical
9954 compatibility purposes (and a warning will be generated for its use if
9955 warnings on oNobsolescent features are activated).
9957 @node No_Secondary_Stack
9958 @unnumberedsubsec No_Secondary_Stack
9959 @findex No_Secondary_Stack
9960 [GNAT] This restriction ensures at compile time that the generated code
9961 does not contain any reference to the secondary stack. The secondary
9962 stack is used to implement functions returning unconstrained objects
9963 (arrays or records) on some targets.
9965 @node No_Select_Statements
9966 @unnumberedsubsec No_Select_Statements
9967 @findex No_Select_Statements
9968 [RM D.7] This restriction ensures at compile time no select statements of any
9969 kind are permitted, that is the keyword @code{select} may not appear.
9971 @node No_Specific_Termination_Handlers
9972 @unnumberedsubsec No_Specific_Termination_Handlers
9973 @findex No_Specific_Termination_Handlers
9974 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9975 or to Ada.Task_Termination.Specific_Handler.
9977 @node No_Specification_of_Aspect
9978 @unnumberedsubsec No_Specification_of_Aspect
9979 @findex No_Specification_of_Aspect
9980 [RM 13.12.1] This restriction checks at compile time that no aspect
9981 specification, attribute definition clause, or pragma is given for a
9984 @node No_Standard_Allocators_After_Elaboration
9985 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9986 @findex No_Standard_Allocators_After_Elaboration
9987 [RM D.7] Specifies that an allocator using a standard storage pool
9988 should never be evaluated at run time after the elaboration of the
9989 library items of the partition has completed. Otherwise, Storage_Error
9992 @node No_Standard_Storage_Pools
9993 @unnumberedsubsec No_Standard_Storage_Pools
9994 @findex No_Standard_Storage_Pools
9995 [GNAT] This restriction ensures at compile time that no access types
9996 use the standard default storage pool. Any access type declared must
9997 have an explicit Storage_Pool attribute defined specifying a
9998 user-defined storage pool.
10000 @node No_Stream_Optimizations
10001 @unnumberedsubsec No_Stream_Optimizations
10002 @findex No_Stream_Optimizations
10003 [GNAT] This restriction affects the performance of stream operations on types
10004 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10005 compiler uses block reads and writes when manipulating @code{String} objects
10006 due to their supperior performance. When this restriction is in effect, the
10007 compiler performs all IO operations on a per-character basis.
10010 @unnumberedsubsec No_Streams
10012 [GNAT] This restriction ensures at compile/bind time that there are no
10013 stream objects created and no use of stream attributes.
10014 This restriction does not forbid dependences on the package
10015 @code{Ada.Streams}. So it is permissible to with
10016 @code{Ada.Streams} (or another package that does so itself)
10017 as long as no actual stream objects are created and no
10018 stream attributes are used.
10020 Note that the use of restriction allows optimization of tagged types,
10021 since they do not need to worry about dispatching stream operations.
10022 To take maximum advantage of this space-saving optimization, any
10023 unit declaring a tagged type should be compiled with the restriction,
10024 though this is not required.
10026 @node No_Task_Allocators
10027 @unnumberedsubsec No_Task_Allocators
10028 @findex No_Task_Allocators
10029 [RM D.7] There are no allocators for task types
10030 or types containing task subcomponents.
10032 @node No_Task_Attributes_Package
10033 @unnumberedsubsec No_Task_Attributes_Package
10034 @findex No_Task_Attributes_Package
10035 [GNAT] This restriction ensures at compile time that there are no implicit or
10036 explicit dependencies on the package @code{Ada.Task_Attributes}.
10038 @findex No_Task_Attributes
10039 The restriction @code{No_Task_Attributes} is recognized as a synonym
10040 for @code{No_Task_Attributes_Package}. This is retained for historical
10041 compatibility purposes (and a warning will be generated for its use if
10042 warnings on obsolescent features are activated).
10044 @node No_Task_Hierarchy
10045 @unnumberedsubsec No_Task_Hierarchy
10046 @findex No_Task_Hierarchy
10047 [RM D.7] All (non-environment) tasks depend
10048 directly on the environment task of the partition.
10050 @node No_Task_Termination
10051 @unnumberedsubsec No_Task_Termination
10052 @findex No_Task_Termination
10053 [RM D.7] Tasks which terminate are erroneous.
10056 @unnumberedsubsec No_Tasking
10058 [GNAT] This restriction prevents the declaration of tasks or task types
10059 throughout the partition. It is similar in effect to the use of
10060 @code{Max_Tasks => 0} except that violations are caught at compile time
10061 and cause an error message to be output either by the compiler or
10064 @node No_Terminate_Alternatives
10065 @unnumberedsubsec No_Terminate_Alternatives
10066 @findex No_Terminate_Alternatives
10067 [RM D.7] There are no selective accepts with terminate alternatives.
10069 @node No_Unchecked_Access
10070 @unnumberedsubsec No_Unchecked_Access
10071 @findex No_Unchecked_Access
10072 [RM H.4] This restriction ensures at compile time that there are no
10073 occurrences of the Unchecked_Access attribute.
10075 @node Simple_Barriers
10076 @unnumberedsubsec Simple_Barriers
10077 @findex Simple_Barriers
10078 [RM D.7] This restriction ensures at compile time that barriers in entry
10079 declarations for protected types are restricted to either static boolean
10080 expressions or references to simple boolean variables defined in the private
10081 part of the protected type. No other form of entry barriers is permitted.
10083 @findex Boolean_Entry_Barriers
10084 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10085 synonym for @code{Simple_Barriers}. This is retained for historical
10086 compatibility purposes (and a warning will be generated for its use if
10087 warnings on obsolescent features are activated).
10089 @node Static_Priorities
10090 @unnumberedsubsec Static_Priorities
10091 @findex Static_Priorities
10092 [GNAT] This restriction ensures at compile time that all priority expressions
10093 are static, and that there are no dependences on the package
10094 @code{Ada.Dynamic_Priorities}.
10096 @node Static_Storage_Size
10097 @unnumberedsubsec Static_Storage_Size
10098 @findex Static_Storage_Size
10099 [GNAT] This restriction ensures at compile time that any expression appearing
10100 in a Storage_Size pragma or attribute definition clause is static.
10102 @node Program Unit Level Restrictions
10103 @section Program Unit Level Restrictions
10106 The second set of restriction identifiers
10107 does not require partition-wide consistency.
10108 The restriction may be enforced for a single
10109 compilation unit without any effect on any of the
10110 other compilation units in the partition.
10113 * No_Elaboration_Code::
10115 * No_Implementation_Aspect_Specifications::
10116 * No_Implementation_Attributes::
10117 * No_Implementation_Identifiers::
10118 * No_Implementation_Pragmas::
10119 * No_Implementation_Restrictions::
10120 * No_Implementation_Units::
10121 * No_Implicit_Aliasing::
10122 * No_Obsolescent_Features::
10123 * No_Wide_Characters::
10127 @node No_Elaboration_Code
10128 @unnumberedsubsec No_Elaboration_Code
10129 @findex No_Elaboration_Code
10130 [GNAT] This restriction ensures at compile time that no elaboration code is
10131 generated. Note that this is not the same condition as is enforced
10132 by pragma @code{Preelaborate}. There are cases in which pragma
10133 @code{Preelaborate} still permits code to be generated (e.g.@: code
10134 to initialize a large array to all zeroes), and there are cases of units
10135 which do not meet the requirements for pragma @code{Preelaborate},
10136 but for which no elaboration code is generated. Generally, it is
10137 the case that preelaborable units will meet the restrictions, with
10138 the exception of large aggregates initialized with an others_clause,
10139 and exception declarations (which generate calls to a run-time
10140 registry procedure). This restriction is enforced on
10141 a unit by unit basis, it need not be obeyed consistently
10142 throughout a partition.
10144 In the case of aggregates with others, if the aggregate has a dynamic
10145 size, there is no way to eliminate the elaboration code (such dynamic
10146 bounds would be incompatible with @code{Preelaborate} in any case). If
10147 the bounds are static, then use of this restriction actually modifies
10148 the code choice of the compiler to avoid generating a loop, and instead
10149 generate the aggregate statically if possible, no matter how many times
10150 the data for the others clause must be repeatedly generated.
10152 It is not possible to precisely document
10153 the constructs which are compatible with this restriction, since,
10154 unlike most other restrictions, this is not a restriction on the
10155 source code, but a restriction on the generated object code. For
10156 example, if the source contains a declaration:
10159 Val : constant Integer := X;
10163 where X is not a static constant, it may be possible, depending
10164 on complex optimization circuitry, for the compiler to figure
10165 out the value of X at compile time, in which case this initialization
10166 can be done by the loader, and requires no initialization code. It
10167 is not possible to document the precise conditions under which the
10168 optimizer can figure this out.
10170 Note that this the implementation of this restriction requires full
10171 code generation. If it is used in conjunction with "semantics only"
10172 checking, then some cases of violations may be missed.
10174 @node No_Entry_Queue
10175 @unnumberedsubsec No_Entry_Queue
10176 @findex No_Entry_Queue
10177 [GNAT] This restriction is a declaration that any protected entry compiled in
10178 the scope of the restriction has at most one task waiting on the entry
10179 at any one time, and so no queue is required. This restriction is not
10180 checked at compile time. A program execution is erroneous if an attempt
10181 is made to queue a second task on such an entry.
10183 @node No_Implementation_Aspect_Specifications
10184 @unnumberedsubsec No_Implementation_Aspect_Specifications
10185 @findex No_Implementation_Aspect_Specifications
10186 [RM 13.12.1] This restriction checks at compile time that no
10187 GNAT-defined aspects are present. With this restriction, the only
10188 aspects that can be used are those defined in the Ada Reference Manual.
10190 @node No_Implementation_Attributes
10191 @unnumberedsubsec No_Implementation_Attributes
10192 @findex No_Implementation_Attributes
10193 [RM 13.12.1] This restriction checks at compile time that no
10194 GNAT-defined attributes are present. With this restriction, the only
10195 attributes that can be used are those defined in the Ada Reference
10198 @node No_Implementation_Identifiers
10199 @unnumberedsubsec No_Implementation_Identifiers
10200 @findex No_Implementation_Identifiers
10201 [RM 13.12.1] This restriction checks at compile time that no
10202 implementation-defined identifiers (marked with pragma Implementation_Defined)
10203 occur within language-defined packages.
10205 @node No_Implementation_Pragmas
10206 @unnumberedsubsec No_Implementation_Pragmas
10207 @findex No_Implementation_Pragmas
10208 [RM 13.12.1] This restriction checks at compile time that no
10209 GNAT-defined pragmas are present. With this restriction, the only
10210 pragmas that can be used are those defined in the Ada Reference Manual.
10212 @node No_Implementation_Restrictions
10213 @unnumberedsubsec No_Implementation_Restrictions
10214 @findex No_Implementation_Restrictions
10215 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
10216 identifiers (other than @code{No_Implementation_Restrictions} itself)
10217 are present. With this restriction, the only other restriction identifiers
10218 that can be used are those defined in the Ada Reference Manual.
10220 @node No_Implementation_Units
10221 @unnumberedsubsec No_Implementation_Units
10222 @findex No_Implementation_Units
10223 [RM 13.12.1] This restriction checks at compile time that there is no
10224 mention in the context clause of any implementation-defined descendants
10225 of packages Ada, Interfaces, or System.
10227 @node No_Implicit_Aliasing
10228 @unnumberedsubsec No_Implicit_Aliasing
10229 @findex No_Implicit_Aliasing
10230 [GNAT] This restriction, which is not required to be partition-wide consistent,
10231 requires an explicit aliased keyword for an object to which 'Access,
10232 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
10233 the 'Unrestricted_Access attribute for objects. Note: the reason that
10234 Unrestricted_Access is forbidden is that it would require the prefix
10235 to be aliased, and in such cases, it can always be replaced by
10236 the standard attribute Unchecked_Access which is preferable.
10238 @node No_Obsolescent_Features
10239 @unnumberedsubsec No_Obsolescent_Features
10240 @findex No_Obsolescent_Features
10241 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10242 features are used, as defined in Annex J of the Ada Reference Manual.
10244 @node No_Wide_Characters
10245 @unnumberedsubsec No_Wide_Characters
10246 @findex No_Wide_Characters
10247 [GNAT] This restriction ensures at compile time that no uses of the types
10248 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10250 appear, and that no wide or wide wide string or character literals
10251 appear in the program (that is literals representing characters not in
10252 type @code{Character}).
10255 @unnumberedsubsec SPARK_05
10257 [GNAT] This restriction checks at compile time that some constructs
10258 forbidden in SPARK 2005 are not present. Error messages related to
10259 SPARK restriction have the form:
10262 The restriction @code{SPARK} is recognized as a
10263 synonym for @code{SPARK_05}. This is retained for historical
10264 compatibility purposes (and an unconditional warning will be generated
10265 for its use, advising replacement by @code{SPARK}.
10268 violation of restriction "SPARK" at <file>
10272 This is not a replacement for the semantic checks performed by the
10273 SPARK Examiner tool, as the compiler only deals currently with code,
10274 not at all with SPARK 2005 annotations and does not guarantee catching all
10275 cases of constructs forbidden by SPARK 2005.
10277 Thus it may well be the case that code which passes the compiler with
10278 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10279 the different visibility rules of the Examiner based on SPARK 2005
10280 @code{inherit} annotations.
10282 This restriction can be useful in providing an initial filter for code
10283 developed using SPARK 2005, or in examining legacy code to see how far
10284 it is from meeting SPARK restrictions.
10286 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
10287 violations will be reported for constructs forbidden in SPARK 95,
10288 instead of SPARK 2005.
10290 @c ------------------------
10291 @node Implementation Advice
10292 @chapter Implementation Advice
10294 The main text of the Ada Reference Manual describes the required
10295 behavior of all Ada compilers, and the GNAT compiler conforms to
10296 these requirements.
10298 In addition, there are sections throughout the Ada Reference Manual headed
10299 by the phrase ``Implementation advice''. These sections are not normative,
10300 i.e., they do not specify requirements that all compilers must
10301 follow. Rather they provide advice on generally desirable behavior. You
10302 may wonder why they are not requirements. The most typical answer is
10303 that they describe behavior that seems generally desirable, but cannot
10304 be provided on all systems, or which may be undesirable on some systems.
10306 As far as practical, GNAT follows the implementation advice sections in
10307 the Ada Reference Manual. This chapter contains a table giving the
10308 reference manual section number, paragraph number and several keywords
10309 for each advice. Each entry consists of the text of the advice followed
10310 by the GNAT interpretation of this advice. Most often, this simply says
10311 ``followed'', which means that GNAT follows the advice. However, in a
10312 number of cases, GNAT deliberately deviates from this advice, in which
10313 case the text describes what GNAT does and why.
10315 @cindex Error detection
10316 @unnumberedsec 1.1.3(20): Error Detection
10319 If an implementation detects the use of an unsupported Specialized Needs
10320 Annex feature at run time, it should raise @code{Program_Error} if
10323 Not relevant. All specialized needs annex features are either supported,
10324 or diagnosed at compile time.
10326 @cindex Child Units
10327 @unnumberedsec 1.1.3(31): Child Units
10330 If an implementation wishes to provide implementation-defined
10331 extensions to the functionality of a language-defined library unit, it
10332 should normally do so by adding children to the library unit.
10336 @cindex Bounded errors
10337 @unnumberedsec 1.1.5(12): Bounded Errors
10340 If an implementation detects a bounded error or erroneous
10341 execution, it should raise @code{Program_Error}.
10343 Followed in all cases in which the implementation detects a bounded
10344 error or erroneous execution. Not all such situations are detected at
10348 @unnumberedsec 2.8(16): Pragmas
10351 Normally, implementation-defined pragmas should have no semantic effect
10352 for error-free programs; that is, if the implementation-defined pragmas
10353 are removed from a working program, the program should still be legal,
10354 and should still have the same semantics.
10356 The following implementation defined pragmas are exceptions to this
10368 @item CPP_Constructor
10372 @item Interface_Name
10374 @item Machine_Attribute
10376 @item Unimplemented_Unit
10378 @item Unchecked_Union
10383 In each of the above cases, it is essential to the purpose of the pragma
10384 that this advice not be followed. For details see the separate section
10385 on implementation defined pragmas.
10387 @unnumberedsec 2.8(17-19): Pragmas
10390 Normally, an implementation should not define pragmas that can
10391 make an illegal program legal, except as follows:
10395 A pragma used to complete a declaration, such as a pragma @code{Import};
10399 A pragma used to configure the environment by adding, removing, or
10400 replacing @code{library_items}.
10402 See response to paragraph 16 of this same section.
10404 @cindex Character Sets
10405 @cindex Alternative Character Sets
10406 @unnumberedsec 3.5.2(5): Alternative Character Sets
10409 If an implementation supports a mode with alternative interpretations
10410 for @code{Character} and @code{Wide_Character}, the set of graphic
10411 characters of @code{Character} should nevertheless remain a proper
10412 subset of the set of graphic characters of @code{Wide_Character}. Any
10413 character set ``localizations'' should be reflected in the results of
10414 the subprograms defined in the language-defined package
10415 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
10416 an alternative interpretation of @code{Character}, the implementation should
10417 also support a corresponding change in what is a legal
10418 @code{identifier_letter}.
10420 Not all wide character modes follow this advice, in particular the JIS
10421 and IEC modes reflect standard usage in Japan, and in these encoding,
10422 the upper half of the Latin-1 set is not part of the wide-character
10423 subset, since the most significant bit is used for wide character
10424 encoding. However, this only applies to the external forms. Internally
10425 there is no such restriction.
10427 @cindex Integer types
10428 @unnumberedsec 3.5.4(28): Integer Types
10432 An implementation should support @code{Long_Integer} in addition to
10433 @code{Integer} if the target machine supports 32-bit (or longer)
10434 arithmetic. No other named integer subtypes are recommended for package
10435 @code{Standard}. Instead, appropriate named integer subtypes should be
10436 provided in the library package @code{Interfaces} (see B.2).
10438 @code{Long_Integer} is supported. Other standard integer types are supported
10439 so this advice is not fully followed. These types
10440 are supported for convenient interface to C, and so that all hardware
10441 types of the machine are easily available.
10442 @unnumberedsec 3.5.4(29): Integer Types
10446 An implementation for a two's complement machine should support
10447 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
10448 implementation should support a non-binary modules up to @code{Integer'Last}.
10452 @cindex Enumeration values
10453 @unnumberedsec 3.5.5(8): Enumeration Values
10456 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
10457 subtype, if the value of the operand does not correspond to the internal
10458 code for any enumeration literal of its type (perhaps due to an
10459 un-initialized variable), then the implementation should raise
10460 @code{Program_Error}. This is particularly important for enumeration
10461 types with noncontiguous internal codes specified by an
10462 enumeration_representation_clause.
10466 @cindex Float types
10467 @unnumberedsec 3.5.7(17): Float Types
10470 An implementation should support @code{Long_Float} in addition to
10471 @code{Float} if the target machine supports 11 or more digits of
10472 precision. No other named floating point subtypes are recommended for
10473 package @code{Standard}. Instead, appropriate named floating point subtypes
10474 should be provided in the library package @code{Interfaces} (see B.2).
10476 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
10477 former provides improved compatibility with other implementations
10478 supporting this type. The latter corresponds to the highest precision
10479 floating-point type supported by the hardware. On most machines, this
10480 will be the same as @code{Long_Float}, but on some machines, it will
10481 correspond to the IEEE extended form. The notable case is all ia32
10482 (x86) implementations, where @code{Long_Long_Float} corresponds to
10483 the 80-bit extended precision format supported in hardware on this
10484 processor. Note that the 128-bit format on SPARC is not supported,
10485 since this is a software rather than a hardware format.
10487 @cindex Multidimensional arrays
10488 @cindex Arrays, multidimensional
10489 @unnumberedsec 3.6.2(11): Multidimensional Arrays
10492 An implementation should normally represent multidimensional arrays in
10493 row-major order, consistent with the notation used for multidimensional
10494 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
10495 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
10496 column-major order should be used instead (see B.5, ``Interfacing with
10501 @findex Duration'Small
10502 @unnumberedsec 9.6(30-31): Duration'Small
10505 Whenever possible in an implementation, the value of @code{Duration'Small}
10506 should be no greater than 100 microseconds.
10508 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
10512 The time base for @code{delay_relative_statements} should be monotonic;
10513 it need not be the same time base as used for @code{Calendar.Clock}.
10517 @unnumberedsec 10.2.1(12): Consistent Representation
10520 In an implementation, a type declared in a pre-elaborated package should
10521 have the same representation in every elaboration of a given version of
10522 the package, whether the elaborations occur in distinct executions of
10523 the same program, or in executions of distinct programs or partitions
10524 that include the given version.
10526 Followed, except in the case of tagged types. Tagged types involve
10527 implicit pointers to a local copy of a dispatch table, and these pointers
10528 have representations which thus depend on a particular elaboration of the
10529 package. It is not easy to see how it would be possible to follow this
10530 advice without severely impacting efficiency of execution.
10532 @cindex Exception information
10533 @unnumberedsec 11.4.1(19): Exception Information
10536 @code{Exception_Message} by default and @code{Exception_Information}
10537 should produce information useful for
10538 debugging. @code{Exception_Message} should be short, about one
10539 line. @code{Exception_Information} can be long. @code{Exception_Message}
10540 should not include the
10541 @code{Exception_Name}. @code{Exception_Information} should include both
10542 the @code{Exception_Name} and the @code{Exception_Message}.
10544 Followed. For each exception that doesn't have a specified
10545 @code{Exception_Message}, the compiler generates one containing the location
10546 of the raise statement. This location has the form ``file:line'', where
10547 file is the short file name (without path information) and line is the line
10548 number in the file. Note that in the case of the Zero Cost Exception
10549 mechanism, these messages become redundant with the Exception_Information that
10550 contains a full backtrace of the calling sequence, so they are disabled.
10551 To disable explicitly the generation of the source location message, use the
10552 Pragma @code{Discard_Names}.
10554 @cindex Suppression of checks
10555 @cindex Checks, suppression of
10556 @unnumberedsec 11.5(28): Suppression of Checks
10559 The implementation should minimize the code executed for checks that
10560 have been suppressed.
10564 @cindex Representation clauses
10565 @unnumberedsec 13.1 (21-24): Representation Clauses
10568 The recommended level of support for all representation items is
10569 qualified as follows:
10573 An implementation need not support representation items containing
10574 non-static expressions, except that an implementation should support a
10575 representation item for a given entity if each non-static expression in
10576 the representation item is a name that statically denotes a constant
10577 declared before the entity.
10579 Followed. In fact, GNAT goes beyond the recommended level of support
10580 by allowing nonstatic expressions in some representation clauses even
10581 without the need to declare constants initialized with the values of
10585 @smallexample @c ada
10588 for Y'Address use X'Address;>>
10593 An implementation need not support a specification for the @code{Size}
10594 for a given composite subtype, nor the size or storage place for an
10595 object (including a component) of a given composite subtype, unless the
10596 constraints on the subtype and its composite subcomponents (if any) are
10597 all static constraints.
10599 Followed. Size Clauses are not permitted on non-static components, as
10604 An aliased component, or a component whose type is by-reference, should
10605 always be allocated at an addressable location.
10609 @cindex Packed types
10610 @unnumberedsec 13.2(6-8): Packed Types
10613 If a type is packed, then the implementation should try to minimize
10614 storage allocated to objects of the type, possibly at the expense of
10615 speed of accessing components, subject to reasonable complexity in
10616 addressing calculations.
10620 The recommended level of support pragma @code{Pack} is:
10622 For a packed record type, the components should be packed as tightly as
10623 possible subject to the Sizes of the component subtypes, and subject to
10624 any @code{record_representation_clause} that applies to the type; the
10625 implementation may, but need not, reorder components or cross aligned
10626 word boundaries to improve the packing. A component whose @code{Size} is
10627 greater than the word size may be allocated an integral number of words.
10629 Followed. Tight packing of arrays is supported for all component sizes
10630 up to 64-bits. If the array component size is 1 (that is to say, if
10631 the component is a boolean type or an enumeration type with two values)
10632 then values of the type are implicitly initialized to zero. This
10633 happens both for objects of the packed type, and for objects that have a
10634 subcomponent of the packed type.
10638 An implementation should support Address clauses for imported
10642 @cindex @code{Address} clauses
10643 @unnumberedsec 13.3(14-19): Address Clauses
10647 For an array @var{X}, @code{@var{X}'Address} should point at the first
10648 component of the array, and not at the array bounds.
10654 The recommended level of support for the @code{Address} attribute is:
10656 @code{@var{X}'Address} should produce a useful result if @var{X} is an
10657 object that is aliased or of a by-reference type, or is an entity whose
10658 @code{Address} has been specified.
10660 Followed. A valid address will be produced even if none of those
10661 conditions have been met. If necessary, the object is forced into
10662 memory to ensure the address is valid.
10666 An implementation should support @code{Address} clauses for imported
10673 Objects (including subcomponents) that are aliased or of a by-reference
10674 type should be allocated on storage element boundaries.
10680 If the @code{Address} of an object is specified, or it is imported or exported,
10681 then the implementation should not perform optimizations based on
10682 assumptions of no aliases.
10686 @cindex @code{Alignment} clauses
10687 @unnumberedsec 13.3(29-35): Alignment Clauses
10690 The recommended level of support for the @code{Alignment} attribute for
10693 An implementation should support specified Alignments that are factors
10694 and multiples of the number of storage elements per word, subject to the
10701 An implementation need not support specified @code{Alignment}s for
10702 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10703 loaded and stored by available machine instructions.
10709 An implementation need not support specified @code{Alignment}s that are
10710 greater than the maximum @code{Alignment} the implementation ever returns by
10717 The recommended level of support for the @code{Alignment} attribute for
10720 Same as above, for subtypes, but in addition:
10726 For stand-alone library-level objects of statically constrained
10727 subtypes, the implementation should support all @code{Alignment}s
10728 supported by the target linker. For example, page alignment is likely to
10729 be supported for such objects, but not for subtypes.
10733 @cindex @code{Size} clauses
10734 @unnumberedsec 13.3(42-43): Size Clauses
10737 The recommended level of support for the @code{Size} attribute of
10740 A @code{Size} clause should be supported for an object if the specified
10741 @code{Size} is at least as large as its subtype's @code{Size}, and
10742 corresponds to a size in storage elements that is a multiple of the
10743 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10747 @unnumberedsec 13.3(50-56): Size Clauses
10750 If the @code{Size} of a subtype is specified, and allows for efficient
10751 independent addressability (see 9.10) on the target architecture, then
10752 the @code{Size} of the following objects of the subtype should equal the
10753 @code{Size} of the subtype:
10755 Aliased objects (including components).
10761 @code{Size} clause on a composite subtype should not affect the
10762 internal layout of components.
10764 Followed. But note that this can be overridden by use of the implementation
10765 pragma Implicit_Packing in the case of packed arrays.
10769 The recommended level of support for the @code{Size} attribute of subtypes is:
10773 The @code{Size} (if not specified) of a static discrete or fixed point
10774 subtype should be the number of bits needed to represent each value
10775 belonging to the subtype using an unbiased representation, leaving space
10776 for a sign bit only if the subtype contains negative values. If such a
10777 subtype is a first subtype, then an implementation should support a
10778 specified @code{Size} for it that reflects this representation.
10784 For a subtype implemented with levels of indirection, the @code{Size}
10785 should include the size of the pointers, but not the size of what they
10790 @cindex @code{Component_Size} clauses
10791 @unnumberedsec 13.3(71-73): Component Size Clauses
10794 The recommended level of support for the @code{Component_Size}
10799 An implementation need not support specified @code{Component_Sizes} that are
10800 less than the @code{Size} of the component subtype.
10806 An implementation should support specified @code{Component_Size}s that
10807 are factors and multiples of the word size. For such
10808 @code{Component_Size}s, the array should contain no gaps between
10809 components. For other @code{Component_Size}s (if supported), the array
10810 should contain no gaps between components when packing is also
10811 specified; the implementation should forbid this combination in cases
10812 where it cannot support a no-gaps representation.
10816 @cindex Enumeration representation clauses
10817 @cindex Representation clauses, enumeration
10818 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10821 The recommended level of support for enumeration representation clauses
10824 An implementation need not support enumeration representation clauses
10825 for boolean types, but should at minimum support the internal codes in
10826 the range @code{System.Min_Int.System.Max_Int}.
10830 @cindex Record representation clauses
10831 @cindex Representation clauses, records
10832 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10835 The recommended level of support for
10836 @*@code{record_representation_clauses} is:
10838 An implementation should support storage places that can be extracted
10839 with a load, mask, shift sequence of machine code, and set with a load,
10840 shift, mask, store sequence, given the available machine instructions
10841 and run-time model.
10847 A storage place should be supported if its size is equal to the
10848 @code{Size} of the component subtype, and it starts and ends on a
10849 boundary that obeys the @code{Alignment} of the component subtype.
10855 If the default bit ordering applies to the declaration of a given type,
10856 then for a component whose subtype's @code{Size} is less than the word
10857 size, any storage place that does not cross an aligned word boundary
10858 should be supported.
10864 An implementation may reserve a storage place for the tag field of a
10865 tagged type, and disallow other components from overlapping that place.
10867 Followed. The storage place for the tag field is the beginning of the tagged
10868 record, and its size is Address'Size. GNAT will reject an explicit component
10869 clause for the tag field.
10873 An implementation need not support a @code{component_clause} for a
10874 component of an extension part if the storage place is not after the
10875 storage places of all components of the parent type, whether or not
10876 those storage places had been specified.
10878 Followed. The above advice on record representation clauses is followed,
10879 and all mentioned features are implemented.
10881 @cindex Storage place attributes
10882 @unnumberedsec 13.5.2(5): Storage Place Attributes
10885 If a component is represented using some form of pointer (such as an
10886 offset) to the actual data of the component, and this data is contiguous
10887 with the rest of the object, then the storage place attributes should
10888 reflect the place of the actual data, not the pointer. If a component is
10889 allocated discontinuously from the rest of the object, then a warning
10890 should be generated upon reference to one of its storage place
10893 Followed. There are no such components in GNAT@.
10895 @cindex Bit ordering
10896 @unnumberedsec 13.5.3(7-8): Bit Ordering
10899 The recommended level of support for the non-default bit ordering is:
10903 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10904 should support the non-default bit ordering in addition to the default
10907 Followed. Word size does not equal storage size in this implementation.
10908 Thus non-default bit ordering is not supported.
10910 @cindex @code{Address}, as private type
10911 @unnumberedsec 13.7(37): Address as Private
10914 @code{Address} should be of a private type.
10918 @cindex Operations, on @code{Address}
10919 @cindex @code{Address}, operations of
10920 @unnumberedsec 13.7.1(16): Address Operations
10923 Operations in @code{System} and its children should reflect the target
10924 environment semantics as closely as is reasonable. For example, on most
10925 machines, it makes sense for address arithmetic to ``wrap around''.
10926 Operations that do not make sense should raise @code{Program_Error}.
10928 Followed. Address arithmetic is modular arithmetic that wraps around. No
10929 operation raises @code{Program_Error}, since all operations make sense.
10931 @cindex Unchecked conversion
10932 @unnumberedsec 13.9(14-17): Unchecked Conversion
10935 The @code{Size} of an array object should not include its bounds; hence,
10936 the bounds should not be part of the converted data.
10942 The implementation should not generate unnecessary run-time checks to
10943 ensure that the representation of @var{S} is a representation of the
10944 target type. It should take advantage of the permission to return by
10945 reference when possible. Restrictions on unchecked conversions should be
10946 avoided unless required by the target environment.
10948 Followed. There are no restrictions on unchecked conversion. A warning is
10949 generated if the source and target types do not have the same size since
10950 the semantics in this case may be target dependent.
10954 The recommended level of support for unchecked conversions is:
10958 Unchecked conversions should be supported and should be reversible in
10959 the cases where this clause defines the result. To enable meaningful use
10960 of unchecked conversion, a contiguous representation should be used for
10961 elementary subtypes, for statically constrained array subtypes whose
10962 component subtype is one of the subtypes described in this paragraph,
10963 and for record subtypes without discriminants whose component subtypes
10964 are described in this paragraph.
10968 @cindex Heap usage, implicit
10969 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10972 An implementation should document any cases in which it dynamically
10973 allocates heap storage for a purpose other than the evaluation of an
10976 Followed, the only other points at which heap storage is dynamically
10977 allocated are as follows:
10981 At initial elaboration time, to allocate dynamically sized global
10985 To allocate space for a task when a task is created.
10988 To extend the secondary stack dynamically when needed. The secondary
10989 stack is used for returning variable length results.
10994 A default (implementation-provided) storage pool for an
10995 access-to-constant type should not have overhead to support deallocation of
10996 individual objects.
11002 A storage pool for an anonymous access type should be created at the
11003 point of an allocator for the type, and be reclaimed when the designated
11004 object becomes inaccessible.
11008 @cindex Unchecked deallocation
11009 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11012 For a standard storage pool, @code{Free} should actually reclaim the
11017 @cindex Stream oriented attributes
11018 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11021 If a stream element is the same size as a storage element, then the
11022 normal in-memory representation should be used by @code{Read} and
11023 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
11024 should use the smallest number of stream elements needed to represent
11025 all values in the base range of the scalar type.
11028 Followed. By default, GNAT uses the interpretation suggested by AI-195,
11029 which specifies using the size of the first subtype.
11030 However, such an implementation is based on direct binary
11031 representations and is therefore target- and endianness-dependent.
11032 To address this issue, GNAT also supplies an alternate implementation
11033 of the stream attributes @code{Read} and @code{Write},
11034 which uses the target-independent XDR standard representation
11036 @cindex XDR representation
11037 @cindex @code{Read} attribute
11038 @cindex @code{Write} attribute
11039 @cindex Stream oriented attributes
11040 The XDR implementation is provided as an alternative body of the
11041 @code{System.Stream_Attributes} package, in the file
11042 @file{s-stratt-xdr.adb} in the GNAT library.
11043 There is no @file{s-stratt-xdr.ads} file.
11044 In order to install the XDR implementation, do the following:
11046 @item Replace the default implementation of the
11047 @code{System.Stream_Attributes} package with the XDR implementation.
11048 For example on a Unix platform issue the commands:
11050 $ mv s-stratt.adb s-stratt-default.adb
11051 $ mv s-stratt-xdr.adb s-stratt.adb
11055 Rebuild the GNAT run-time library as documented in
11056 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11059 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11062 If an implementation provides additional named predefined integer types,
11063 then the names should end with @samp{Integer} as in
11064 @samp{Long_Integer}. If an implementation provides additional named
11065 predefined floating point types, then the names should end with
11066 @samp{Float} as in @samp{Long_Float}.
11070 @findex Ada.Characters.Handling
11071 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11074 If an implementation provides a localized definition of @code{Character}
11075 or @code{Wide_Character}, then the effects of the subprograms in
11076 @code{Characters.Handling} should reflect the localizations. See also
11079 Followed. GNAT provides no such localized definitions.
11081 @cindex Bounded-length strings
11082 @unnumberedsec A.4.4(106): Bounded-Length String Handling
11085 Bounded string objects should not be implemented by implicit pointers
11086 and dynamic allocation.
11088 Followed. No implicit pointers or dynamic allocation are used.
11090 @cindex Random number generation
11091 @unnumberedsec A.5.2(46-47): Random Number Generation
11094 Any storage associated with an object of type @code{Generator} should be
11095 reclaimed on exit from the scope of the object.
11101 If the generator period is sufficiently long in relation to the number
11102 of distinct initiator values, then each possible value of
11103 @code{Initiator} passed to @code{Reset} should initiate a sequence of
11104 random numbers that does not, in a practical sense, overlap the sequence
11105 initiated by any other value. If this is not possible, then the mapping
11106 between initiator values and generator states should be a rapidly
11107 varying function of the initiator value.
11109 Followed. The generator period is sufficiently long for the first
11110 condition here to hold true.
11112 @findex Get_Immediate
11113 @unnumberedsec A.10.7(23): @code{Get_Immediate}
11116 The @code{Get_Immediate} procedures should be implemented with
11117 unbuffered input. For a device such as a keyboard, input should be
11118 @dfn{available} if a key has already been typed, whereas for a disk
11119 file, input should always be available except at end of file. For a file
11120 associated with a keyboard-like device, any line-editing features of the
11121 underlying operating system should be disabled during the execution of
11122 @code{Get_Immediate}.
11124 Followed on all targets except VxWorks. For VxWorks, there is no way to
11125 provide this functionality that does not result in the input buffer being
11126 flushed before the @code{Get_Immediate} call. A special unit
11127 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
11128 this functionality.
11131 @unnumberedsec B.1(39-41): Pragma @code{Export}
11134 If an implementation supports pragma @code{Export} to a given language,
11135 then it should also allow the main subprogram to be written in that
11136 language. It should support some mechanism for invoking the elaboration
11137 of the Ada library units included in the system, and for invoking the
11138 finalization of the environment task. On typical systems, the
11139 recommended mechanism is to provide two subprograms whose link names are
11140 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
11141 elaboration code for library units. @code{adafinal} should contain the
11142 finalization code. These subprograms should have no effect the second
11143 and subsequent time they are called.
11149 Automatic elaboration of pre-elaborated packages should be
11150 provided when pragma @code{Export} is supported.
11152 Followed when the main program is in Ada. If the main program is in a
11153 foreign language, then
11154 @code{adainit} must be called to elaborate pre-elaborated
11159 For each supported convention @var{L} other than @code{Intrinsic}, an
11160 implementation should support @code{Import} and @code{Export} pragmas
11161 for objects of @var{L}-compatible types and for subprograms, and pragma
11162 @code{Convention} for @var{L}-eligible types and for subprograms,
11163 presuming the other language has corresponding features. Pragma
11164 @code{Convention} need not be supported for scalar types.
11168 @cindex Package @code{Interfaces}
11170 @unnumberedsec B.2(12-13): Package @code{Interfaces}
11173 For each implementation-defined convention identifier, there should be a
11174 child package of package Interfaces with the corresponding name. This
11175 package should contain any declarations that would be useful for
11176 interfacing to the language (implementation) represented by the
11177 convention. Any declarations useful for interfacing to any language on
11178 the given hardware architecture should be provided directly in
11181 Followed. An additional package not defined
11182 in the Ada Reference Manual is @code{Interfaces.CPP}, used
11183 for interfacing to C++.
11187 An implementation supporting an interface to C, COBOL, or Fortran should
11188 provide the corresponding package or packages described in the following
11191 Followed. GNAT provides all the packages described in this section.
11193 @cindex C, interfacing with
11194 @unnumberedsec B.3(63-71): Interfacing with C
11197 An implementation should support the following interface correspondences
11198 between Ada and C@.
11204 An Ada procedure corresponds to a void-returning C function.
11210 An Ada function corresponds to a non-void C function.
11216 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
11223 An Ada @code{in} parameter of an access-to-object type with designated
11224 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
11225 where @var{t} is the C type corresponding to the Ada type @var{T}.
11231 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
11232 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
11233 argument to a C function, where @var{t} is the C type corresponding to
11234 the Ada type @var{T}. In the case of an elementary @code{out} or
11235 @code{in out} parameter, a pointer to a temporary copy is used to
11236 preserve by-copy semantics.
11242 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11243 @code{@var{t}*} argument to a C function, where @var{t} is the C
11244 structure corresponding to the Ada type @var{T}.
11246 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
11247 pragma, or Convention, or by explicitly specifying the mechanism for a given
11248 call using an extended import or export pragma.
11252 An Ada parameter of an array type with component type @var{T}, of any
11253 mode, is passed as a @code{@var{t}*} argument to a C function, where
11254 @var{t} is the C type corresponding to the Ada type @var{T}.
11260 An Ada parameter of an access-to-subprogram type is passed as a pointer
11261 to a C function whose prototype corresponds to the designated
11262 subprogram's specification.
11266 @cindex COBOL, interfacing with
11267 @unnumberedsec B.4(95-98): Interfacing with COBOL
11270 An Ada implementation should support the following interface
11271 correspondences between Ada and COBOL@.
11277 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11278 the COBOL type corresponding to @var{T}.
11284 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11285 the corresponding COBOL type.
11291 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11292 COBOL type corresponding to the Ada parameter type; for scalars, a local
11293 copy is used if necessary to ensure by-copy semantics.
11297 @cindex Fortran, interfacing with
11298 @unnumberedsec B.5(22-26): Interfacing with Fortran
11301 An Ada implementation should support the following interface
11302 correspondences between Ada and Fortran:
11308 An Ada procedure corresponds to a Fortran subroutine.
11314 An Ada function corresponds to a Fortran function.
11320 An Ada parameter of an elementary, array, or record type @var{T} is
11321 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11322 the Fortran type corresponding to the Ada type @var{T}, and where the
11323 INTENT attribute of the corresponding dummy argument matches the Ada
11324 formal parameter mode; the Fortran implementation's parameter passing
11325 conventions are used. For elementary types, a local copy is used if
11326 necessary to ensure by-copy semantics.
11332 An Ada parameter of an access-to-subprogram type is passed as a
11333 reference to a Fortran procedure whose interface corresponds to the
11334 designated subprogram's specification.
11338 @cindex Machine operations
11339 @unnumberedsec C.1(3-5): Access to Machine Operations
11342 The machine code or intrinsic support should allow access to all
11343 operations normally available to assembly language programmers for the
11344 target environment, including privileged instructions, if any.
11350 The interfacing pragmas (see Annex B) should support interface to
11351 assembler; the default assembler should be associated with the
11352 convention identifier @code{Assembler}.
11358 If an entity is exported to assembly language, then the implementation
11359 should allocate it at an addressable location, and should ensure that it
11360 is retained by the linking process, even if not otherwise referenced
11361 from the Ada code. The implementation should assume that any call to a
11362 machine code or assembler subprogram is allowed to read or update every
11363 object that is specified as exported.
11367 @unnumberedsec C.1(10-16): Access to Machine Operations
11370 The implementation should ensure that little or no overhead is
11371 associated with calling intrinsic and machine-code subprograms.
11373 Followed for both intrinsics and machine-code subprograms.
11377 It is recommended that intrinsic subprograms be provided for convenient
11378 access to any machine operations that provide special capabilities or
11379 efficiency and that are not otherwise available through the language
11382 Followed. A full set of machine operation intrinsic subprograms is provided.
11386 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11387 swap, decrement and test, enqueue/dequeue.
11389 Followed on any target supporting such operations.
11393 Standard numeric functions---e.g.@:, sin, log.
11395 Followed on any target supporting such operations.
11399 String manipulation operations---e.g.@:, translate and test.
11401 Followed on any target supporting such operations.
11405 Vector operations---e.g.@:, compare vector against thresholds.
11407 Followed on any target supporting such operations.
11411 Direct operations on I/O ports.
11413 Followed on any target supporting such operations.
11415 @cindex Interrupt support
11416 @unnumberedsec C.3(28): Interrupt Support
11419 If the @code{Ceiling_Locking} policy is not in effect, the
11420 implementation should provide means for the application to specify which
11421 interrupts are to be blocked during protected actions, if the underlying
11422 system allows for a finer-grain control of interrupt blocking.
11424 Followed. The underlying system does not allow for finer-grain control
11425 of interrupt blocking.
11427 @cindex Protected procedure handlers
11428 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
11431 Whenever possible, the implementation should allow interrupt handlers to
11432 be called directly by the hardware.
11434 Followed on any target where the underlying operating system permits
11439 Whenever practical, violations of any
11440 implementation-defined restrictions should be detected before run time.
11442 Followed. Compile time warnings are given when possible.
11444 @cindex Package @code{Interrupts}
11446 @unnumberedsec C.3.2(25): Package @code{Interrupts}
11450 If implementation-defined forms of interrupt handler procedures are
11451 supported, such as protected procedures with parameters, then for each
11452 such form of a handler, a type analogous to @code{Parameterless_Handler}
11453 should be specified in a child package of @code{Interrupts}, with the
11454 same operations as in the predefined package Interrupts.
11458 @cindex Pre-elaboration requirements
11459 @unnumberedsec C.4(14): Pre-elaboration Requirements
11462 It is recommended that pre-elaborated packages be implemented in such a
11463 way that there should be little or no code executed at run time for the
11464 elaboration of entities not already covered by the Implementation
11467 Followed. Executable code is generated in some cases, e.g.@: loops
11468 to initialize large arrays.
11470 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
11473 If the pragma applies to an entity, then the implementation should
11474 reduce the amount of storage used for storing names associated with that
11479 @cindex Package @code{Task_Attributes}
11480 @findex Task_Attributes
11481 @unnumberedsec C.7.2(30): The Package Task_Attributes
11484 Some implementations are targeted to domains in which memory use at run
11485 time must be completely deterministic. For such implementations, it is
11486 recommended that the storage for task attributes will be pre-allocated
11487 statically and not from the heap. This can be accomplished by either
11488 placing restrictions on the number and the size of the task's
11489 attributes, or by using the pre-allocated storage for the first @var{N}
11490 attribute objects, and the heap for the others. In the latter case,
11491 @var{N} should be documented.
11493 Not followed. This implementation is not targeted to such a domain.
11495 @cindex Locking Policies
11496 @unnumberedsec D.3(17): Locking Policies
11500 The implementation should use names that end with @samp{_Locking} for
11501 locking policies defined by the implementation.
11503 Followed. Two implementation-defined locking policies are defined,
11504 whose names (@code{Inheritance_Locking} and
11505 @code{Concurrent_Readers_Locking}) follow this suggestion.
11507 @cindex Entry queuing policies
11508 @unnumberedsec D.4(16): Entry Queuing Policies
11511 Names that end with @samp{_Queuing} should be used
11512 for all implementation-defined queuing policies.
11514 Followed. No such implementation-defined queuing policies exist.
11516 @cindex Preemptive abort
11517 @unnumberedsec D.6(9-10): Preemptive Abort
11520 Even though the @code{abort_statement} is included in the list of
11521 potentially blocking operations (see 9.5.1), it is recommended that this
11522 statement be implemented in a way that never requires the task executing
11523 the @code{abort_statement} to block.
11529 On a multi-processor, the delay associated with aborting a task on
11530 another processor should be bounded; the implementation should use
11531 periodic polling, if necessary, to achieve this.
11535 @cindex Tasking restrictions
11536 @unnumberedsec D.7(21): Tasking Restrictions
11539 When feasible, the implementation should take advantage of the specified
11540 restrictions to produce a more efficient implementation.
11542 GNAT currently takes advantage of these restrictions by providing an optimized
11543 run time when the Ravenscar profile and the GNAT restricted run time set
11544 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
11545 pragma @code{Profile (Restricted)} for more details.
11547 @cindex Time, monotonic
11548 @unnumberedsec D.8(47-49): Monotonic Time
11551 When appropriate, implementations should provide configuration
11552 mechanisms to change the value of @code{Tick}.
11554 Such configuration mechanisms are not appropriate to this implementation
11555 and are thus not supported.
11559 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
11560 be implemented as transformations of the same time base.
11566 It is recommended that the @dfn{best} time base which exists in
11567 the underlying system be available to the application through
11568 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
11572 @cindex Partition communication subsystem
11574 @unnumberedsec E.5(28-29): Partition Communication Subsystem
11577 Whenever possible, the PCS on the called partition should allow for
11578 multiple tasks to call the RPC-receiver with different messages and
11579 should allow them to block until the corresponding subprogram body
11582 Followed by GLADE, a separately supplied PCS that can be used with
11587 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
11588 should raise @code{Storage_Error} if it runs out of space trying to
11589 write the @code{Item} into the stream.
11591 Followed by GLADE, a separately supplied PCS that can be used with
11594 @cindex COBOL support
11595 @unnumberedsec F(7): COBOL Support
11598 If COBOL (respectively, C) is widely supported in the target
11599 environment, implementations supporting the Information Systems Annex
11600 should provide the child package @code{Interfaces.COBOL} (respectively,
11601 @code{Interfaces.C}) specified in Annex B and should support a
11602 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
11603 pragmas (see Annex B), thus allowing Ada programs to interface with
11604 programs written in that language.
11608 @cindex Decimal radix support
11609 @unnumberedsec F.1(2): Decimal Radix Support
11612 Packed decimal should be used as the internal representation for objects
11613 of subtype @var{S} when @var{S}'Machine_Radix = 10.
11615 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
11619 @unnumberedsec G: Numerics
11622 If Fortran (respectively, C) is widely supported in the target
11623 environment, implementations supporting the Numerics Annex
11624 should provide the child package @code{Interfaces.Fortran} (respectively,
11625 @code{Interfaces.C}) specified in Annex B and should support a
11626 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
11627 pragmas (see Annex B), thus allowing Ada programs to interface with
11628 programs written in that language.
11632 @cindex Complex types
11633 @unnumberedsec G.1.1(56-58): Complex Types
11636 Because the usual mathematical meaning of multiplication of a complex
11637 operand and a real operand is that of the scaling of both components of
11638 the former by the latter, an implementation should not perform this
11639 operation by first promoting the real operand to complex type and then
11640 performing a full complex multiplication. In systems that, in the
11641 future, support an Ada binding to IEC 559:1989, the latter technique
11642 will not generate the required result when one of the components of the
11643 complex operand is infinite. (Explicit multiplication of the infinite
11644 component by the zero component obtained during promotion yields a NaN
11645 that propagates into the final result.) Analogous advice applies in the
11646 case of multiplication of a complex operand and a pure-imaginary
11647 operand, and in the case of division of a complex operand by a real or
11648 pure-imaginary operand.
11654 Similarly, because the usual mathematical meaning of addition of a
11655 complex operand and a real operand is that the imaginary operand remains
11656 unchanged, an implementation should not perform this operation by first
11657 promoting the real operand to complex type and then performing a full
11658 complex addition. In implementations in which the @code{Signed_Zeros}
11659 attribute of the component type is @code{True} (and which therefore
11660 conform to IEC 559:1989 in regard to the handling of the sign of zero in
11661 predefined arithmetic operations), the latter technique will not
11662 generate the required result when the imaginary component of the complex
11663 operand is a negatively signed zero. (Explicit addition of the negative
11664 zero to the zero obtained during promotion yields a positive zero.)
11665 Analogous advice applies in the case of addition of a complex operand
11666 and a pure-imaginary operand, and in the case of subtraction of a
11667 complex operand and a real or pure-imaginary operand.
11673 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
11674 attempt to provide a rational treatment of the signs of zero results and
11675 result components. As one example, the result of the @code{Argument}
11676 function should have the sign of the imaginary component of the
11677 parameter @code{X} when the point represented by that parameter lies on
11678 the positive real axis; as another, the sign of the imaginary component
11679 of the @code{Compose_From_Polar} function should be the same as
11680 (respectively, the opposite of) that of the @code{Argument} parameter when that
11681 parameter has a value of zero and the @code{Modulus} parameter has a
11682 nonnegative (respectively, negative) value.
11686 @cindex Complex elementary functions
11687 @unnumberedsec G.1.2(49): Complex Elementary Functions
11690 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11691 @code{True} should attempt to provide a rational treatment of the signs
11692 of zero results and result components. For example, many of the complex
11693 elementary functions have components that are odd functions of one of
11694 the parameter components; in these cases, the result component should
11695 have the sign of the parameter component at the origin. Other complex
11696 elementary functions have zero components whose sign is opposite that of
11697 a parameter component at the origin, or is always positive or always
11702 @cindex Accuracy requirements
11703 @unnumberedsec G.2.4(19): Accuracy Requirements
11706 The versions of the forward trigonometric functions without a
11707 @code{Cycle} parameter should not be implemented by calling the
11708 corresponding version with a @code{Cycle} parameter of
11709 @code{2.0*Numerics.Pi}, since this will not provide the required
11710 accuracy in some portions of the domain. For the same reason, the
11711 version of @code{Log} without a @code{Base} parameter should not be
11712 implemented by calling the corresponding version with a @code{Base}
11713 parameter of @code{Numerics.e}.
11717 @cindex Complex arithmetic accuracy
11718 @cindex Accuracy, complex arithmetic
11719 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11723 The version of the @code{Compose_From_Polar} function without a
11724 @code{Cycle} parameter should not be implemented by calling the
11725 corresponding version with a @code{Cycle} parameter of
11726 @code{2.0*Numerics.Pi}, since this will not provide the required
11727 accuracy in some portions of the domain.
11731 @cindex Sequential elaboration policy
11732 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11736 If the partition elaboration policy is @code{Sequential} and the
11737 Environment task becomes permanently blocked during elaboration then the
11738 partition is deadlocked and it is recommended that the partition be
11739 immediately terminated.
11743 @c -----------------------------------------
11744 @node Implementation Defined Characteristics
11745 @chapter Implementation Defined Characteristics
11748 In addition to the implementation dependent pragmas and attributes, and the
11749 implementation advice, there are a number of other Ada features that are
11750 potentially implementation dependent and are designated as
11751 implementation-defined. These are mentioned throughout the Ada Reference
11752 Manual, and are summarized in Annex M@.
11754 A requirement for conforming Ada compilers is that they provide
11755 documentation describing how the implementation deals with each of these
11756 issues. In this chapter, you will find each point in Annex M listed
11757 followed by a description in italic font of how GNAT
11758 handles the implementation dependence.
11760 You can use this chapter as a guide to minimizing implementation
11761 dependent features in your programs if portability to other compilers
11762 and other operating systems is an important consideration. The numbers
11763 in each section below correspond to the paragraph number in the Ada
11769 @strong{2}. Whether or not each recommendation given in Implementation
11770 Advice is followed. See 1.1.2(37).
11773 @xref{Implementation Advice}.
11778 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
11781 The complexity of programs that can be processed is limited only by the
11782 total amount of available virtual memory, and disk space for the
11783 generated object files.
11788 @strong{4}. Variations from the standard that are impractical to avoid
11789 given the implementation's execution environment. See 1.1.3(6).
11792 There are no variations from the standard.
11797 @strong{5}. Which @code{code_statement}s cause external
11798 interactions. See 1.1.3(10).
11801 Any @code{code_statement} can potentially cause external interactions.
11806 @strong{6}. The coded representation for the text of an Ada
11807 program. See 2.1(4).
11810 See separate section on source representation.
11815 @strong{7}. The control functions allowed in comments. See 2.1(14).
11818 See separate section on source representation.
11823 @strong{8}. The representation for an end of line. See 2.2(2).
11826 See separate section on source representation.
11831 @strong{9}. Maximum supported line length and lexical element
11832 length. See 2.2(15).
11835 The maximum line length is 255 characters and the maximum length of
11836 a lexical element is also 255 characters. This is the default setting
11837 if not overridden by the use of compiler switch @option{-gnaty} (which
11838 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11839 line length to be specified to be any value up to 32767. The maximum
11840 length of a lexical element is the same as the maximum line length.
11845 @strong{10}. Implementation defined pragmas. See 2.8(14).
11849 @xref{Implementation Defined Pragmas}.
11854 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
11857 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11858 parameter, checks that the optimization flag is set, and aborts if it is
11864 @strong{12}. The sequence of characters of the value returned by
11865 @code{@var{S}'Image} when some of the graphic characters of
11866 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
11870 The sequence of characters is as defined by the wide character encoding
11871 method used for the source. See section on source representation for
11877 @strong{13}. The predefined integer types declared in
11878 @code{Standard}. See 3.5.4(25).
11882 @item Short_Short_Integer
11884 @item Short_Integer
11885 (Short) 16 bit signed
11889 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11890 32 bit signed (all other targets)
11891 @item Long_Long_Integer
11898 @strong{14}. Any nonstandard integer types and the operators defined
11899 for them. See 3.5.4(26).
11902 There are no nonstandard integer types.
11907 @strong{15}. Any nonstandard real types and the operators defined for
11908 them. See 3.5.6(8).
11911 There are no nonstandard real types.
11916 @strong{16}. What combinations of requested decimal precision and range
11917 are supported for floating point types. See 3.5.7(7).
11920 The precision and range is as defined by the IEEE standard.
11925 @strong{17}. The predefined floating point types declared in
11926 @code{Standard}. See 3.5.7(16).
11933 (Short) 32 bit IEEE short
11936 @item Long_Long_Float
11937 64 bit IEEE long (80 bit IEEE long on x86 processors)
11943 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
11946 @code{Fine_Delta} is 2**(@minus{}63)
11951 @strong{19}. What combinations of small, range, and digits are
11952 supported for fixed point types. See 3.5.9(10).
11955 Any combinations are permitted that do not result in a small less than
11956 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11957 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11958 is 64 bits (true of all architectures except ia32), then the output from
11959 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
11960 is because floating-point conversions are used to convert fixed point.
11965 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
11966 within an unnamed @code{block_statement}. See 3.9(10).
11969 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11970 decimal integer are allocated.
11975 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
11978 @xref{Implementation Defined Attributes}.
11983 @strong{22}. Any implementation-defined time types. See 9.6(6).
11986 There are no implementation-defined time types.
11991 @strong{23}. The time base associated with relative delays.
11994 See 9.6(20). The time base used is that provided by the C library
11995 function @code{gettimeofday}.
12000 @strong{24}. The time base of the type @code{Calendar.Time}. See
12004 The time base used is that provided by the C library function
12005 @code{gettimeofday}.
12010 @strong{25}. The time zone used for package @code{Calendar}
12011 operations. See 9.6(24).
12014 The time zone used by package @code{Calendar} is the current system time zone
12015 setting for local time, as accessed by the C library function
12021 @strong{26}. Any limit on @code{delay_until_statements} of
12022 @code{select_statements}. See 9.6(29).
12025 There are no such limits.
12030 @strong{27}. Whether or not two non-overlapping parts of a composite
12031 object are independently addressable, in the case where packing, record
12032 layout, or @code{Component_Size} is specified for the object. See
12036 Separate components are independently addressable if they do not share
12037 overlapping storage units.
12042 @strong{28}. The representation for a compilation. See 10.1(2).
12045 A compilation is represented by a sequence of files presented to the
12046 compiler in a single invocation of the @command{gcc} command.
12051 @strong{29}. Any restrictions on compilations that contain multiple
12052 compilation_units. See 10.1(4).
12055 No single file can contain more than one compilation unit, but any
12056 sequence of files can be presented to the compiler as a single
12062 @strong{30}. The mechanisms for creating an environment and for adding
12063 and replacing compilation units. See 10.1.4(3).
12066 See separate section on compilation model.
12071 @strong{31}. The manner of explicitly assigning library units to a
12072 partition. See 10.2(2).
12075 If a unit contains an Ada main program, then the Ada units for the partition
12076 are determined by recursive application of the rules in the Ada Reference
12077 Manual section 10.2(2-6). In other words, the Ada units will be those that
12078 are needed by the main program, and then this definition of need is applied
12079 recursively to those units, and the partition contains the transitive
12080 closure determined by this relationship. In short, all the necessary units
12081 are included, with no need to explicitly specify the list. If additional
12082 units are required, e.g.@: by foreign language units, then all units must be
12083 mentioned in the context clause of one of the needed Ada units.
12085 If the partition contains no main program, or if the main program is in
12086 a language other than Ada, then GNAT
12087 provides the binder options @option{-z} and @option{-n} respectively, and in
12088 this case a list of units can be explicitly supplied to the binder for
12089 inclusion in the partition (all units needed by these units will also
12090 be included automatically). For full details on the use of these
12091 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
12092 @value{EDITION} User's Guide}.
12097 @strong{32}. The implementation-defined means, if any, of specifying
12098 which compilation units are needed by a given compilation unit. See
12102 The units needed by a given compilation unit are as defined in
12103 the Ada Reference Manual section 10.2(2-6). There are no
12104 implementation-defined pragmas or other implementation-defined
12105 means for specifying needed units.
12110 @strong{33}. The manner of designating the main subprogram of a
12111 partition. See 10.2(7).
12114 The main program is designated by providing the name of the
12115 corresponding @file{ALI} file as the input parameter to the binder.
12120 @strong{34}. The order of elaboration of @code{library_items}. See
12124 The first constraint on ordering is that it meets the requirements of
12125 Chapter 10 of the Ada Reference Manual. This still leaves some
12126 implementation dependent choices, which are resolved by first
12127 elaborating bodies as early as possible (i.e., in preference to specs
12128 where there is a choice), and second by evaluating the immediate with
12129 clauses of a unit to determine the probably best choice, and
12130 third by elaborating in alphabetical order of unit names
12131 where a choice still remains.
12136 @strong{35}. Parameter passing and function return for the main
12137 subprogram. See 10.2(21).
12140 The main program has no parameters. It may be a procedure, or a function
12141 returning an integer type. In the latter case, the returned integer
12142 value is the return code of the program (overriding any value that
12143 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
12148 @strong{36}. The mechanisms for building and running partitions. See
12152 GNAT itself supports programs with only a single partition. The GNATDIST
12153 tool provided with the GLADE package (which also includes an implementation
12154 of the PCS) provides a completely flexible method for building and running
12155 programs consisting of multiple partitions. See the separate GLADE manual
12161 @strong{37}. The details of program execution, including program
12162 termination. See 10.2(25).
12165 See separate section on compilation model.
12170 @strong{38}. The semantics of any non-active partitions supported by the
12171 implementation. See 10.2(28).
12174 Passive partitions are supported on targets where shared memory is
12175 provided by the operating system. See the GLADE reference manual for
12181 @strong{39}. The information returned by @code{Exception_Message}. See
12185 Exception message returns the null string unless a specific message has
12186 been passed by the program.
12191 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
12192 declared within an unnamed @code{block_statement}. See 11.4.1(12).
12195 Blocks have implementation defined names of the form @code{B@var{nnn}}
12196 where @var{nnn} is an integer.
12201 @strong{41}. The information returned by
12202 @code{Exception_Information}. See 11.4.1(13).
12205 @code{Exception_Information} returns a string in the following format:
12208 @emph{Exception_Name:} nnnnn
12209 @emph{Message:} mmmmm
12211 @emph{Load address:} 0xhhhh
12212 @emph{Call stack traceback locations:}
12213 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
12221 @code{nnnn} is the fully qualified name of the exception in all upper
12222 case letters. This line is always present.
12225 @code{mmmm} is the message (this line present only if message is non-null)
12228 @code{ppp} is the Process Id value as a decimal integer (this line is
12229 present only if the Process Id is nonzero). Currently we are
12230 not making use of this field.
12233 The Load address line, the Call stack traceback locations line and the
12234 following values are present only if at least one traceback location was
12235 recorded. The Load address indicates the address at which the main executable
12236 was loaded; this line may not be present if operating system hasn't relocated
12237 the main executable. The values are given in C style format, with lower case
12238 letters for a-f, and only as many digits present as are necessary.
12242 The line terminator sequence at the end of each line, including
12243 the last line is a single @code{LF} character (@code{16#0A#}).
12248 @strong{42}. Implementation-defined check names. See 11.5(27).
12251 The implementation defined check name Alignment_Check controls checking of
12252 address clause values for proper alignment (that is, the address supplied
12253 must be consistent with the alignment of the type).
12255 The implementation defined check name Predicate_Check controls whether
12256 predicate checks are generated.
12258 The implementation defined check name Validity_Check controls whether
12259 validity checks are generated.
12261 In addition, a user program can add implementation-defined check names
12262 by means of the pragma Check_Name.
12267 @strong{43}. The interpretation of each aspect of representation. See
12271 See separate section on data representations.
12276 @strong{44}. Any restrictions placed upon representation items. See
12280 See separate section on data representations.
12285 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
12289 Size for an indefinite subtype is the maximum possible size, except that
12290 for the case of a subprogram parameter, the size of the parameter object
12291 is the actual size.
12296 @strong{46}. The default external representation for a type tag. See
12300 The default external representation for a type tag is the fully expanded
12301 name of the type in upper case letters.
12306 @strong{47}. What determines whether a compilation unit is the same in
12307 two different partitions. See 13.3(76).
12310 A compilation unit is the same in two different partitions if and only
12311 if it derives from the same source file.
12316 @strong{48}. Implementation-defined components. See 13.5.1(15).
12319 The only implementation defined component is the tag for a tagged type,
12320 which contains a pointer to the dispatching table.
12325 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
12326 ordering. See 13.5.3(5).
12329 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12330 implementation, so no non-default bit ordering is supported. The default
12331 bit ordering corresponds to the natural endianness of the target architecture.
12336 @strong{50}. The contents of the visible part of package @code{System}
12337 and its language-defined children. See 13.7(2).
12340 See the definition of these packages in files @file{system.ads} and
12341 @file{s-stoele.ads}.
12346 @strong{51}. The contents of the visible part of package
12347 @code{System.Machine_Code}, and the meaning of
12348 @code{code_statements}. See 13.8(7).
12351 See the definition and documentation in file @file{s-maccod.ads}.
12356 @strong{52}. The effect of unchecked conversion. See 13.9(11).
12359 Unchecked conversion between types of the same size
12360 results in an uninterpreted transmission of the bits from one type
12361 to the other. If the types are of unequal sizes, then in the case of
12362 discrete types, a shorter source is first zero or sign extended as
12363 necessary, and a shorter target is simply truncated on the left.
12364 For all non-discrete types, the source is first copied if necessary
12365 to ensure that the alignment requirements of the target are met, then
12366 a pointer is constructed to the source value, and the result is obtained
12367 by dereferencing this pointer after converting it to be a pointer to the
12368 target type. Unchecked conversions where the target subtype is an
12369 unconstrained array are not permitted. If the target alignment is
12370 greater than the source alignment, then a copy of the result is
12371 made with appropriate alignment
12376 @strong{53}. The semantics of operations on invalid representations.
12380 For assignments and other operations where the use of invalid values cannot
12381 result in erroneous behavior, the compiler ignores the possibility of invalid
12382 values. An exception is raised at the point where an invalid value would
12383 result in erroneous behavior. For example executing:
12385 @smallexample @c ada
12386 procedure invalidvals is
12388 Y : Natural range 1 .. 10;
12389 for Y'Address use X'Address;
12390 Z : Natural range 1 .. 10;
12391 A : array (Natural range 1 .. 10) of Integer;
12393 Z := Y; -- no exception
12394 A (Z) := 3; -- exception raised;
12399 As indicated, an exception is raised on the array assignment, but not
12400 on the simple assignment of the invalid negative value from Y to Z.
12405 @strong{53}. The manner of choosing a storage pool for an access type
12406 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
12409 There are 3 different standard pools used by the compiler when
12410 @code{Storage_Pool} is not specified depending whether the type is local
12411 to a subprogram or defined at the library level and whether
12412 @code{Storage_Size}is specified or not. See documentation in the runtime
12413 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
12414 @code{System.Pool_Local} in files @file{s-poosiz.ads},
12415 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
12416 default pools used.
12421 @strong{54}. Whether or not the implementation provides user-accessible
12422 names for the standard pool type(s). See 13.11(17).
12426 See documentation in the sources of the run time mentioned in paragraph
12427 @strong{53} . All these pools are accessible by means of @code{with}'ing
12433 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
12436 @code{Storage_Size} is measured in storage units, and refers to the
12437 total space available for an access type collection, or to the primary
12438 stack space for a task.
12443 @strong{56}. Implementation-defined aspects of storage pools. See
12447 See documentation in the sources of the run time mentioned in paragraph
12448 @strong{53} for details on GNAT-defined aspects of storage pools.
12453 @strong{57}. The set of restrictions allowed in a pragma
12454 @code{Restrictions}. See 13.12(7).
12457 @xref{Standard and Implementation Defined Restrictions}.
12462 @strong{58}. The consequences of violating limitations on
12463 @code{Restrictions} pragmas. See 13.12(9).
12466 Restrictions that can be checked at compile time result in illegalities
12467 if violated. Currently there are no other consequences of violating
12473 @strong{59}. The representation used by the @code{Read} and
12474 @code{Write} attributes of elementary types in terms of stream
12475 elements. See 13.13.2(9).
12478 The representation is the in-memory representation of the base type of
12479 the type, using the number of bits corresponding to the
12480 @code{@var{type}'Size} value, and the natural ordering of the machine.
12485 @strong{60}. The names and characteristics of the numeric subtypes
12486 declared in the visible part of package @code{Standard}. See A.1(3).
12489 See items describing the integer and floating-point types supported.
12494 @strong{61}. The string returned by @code{Character_Set_Version}.
12498 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
12499 the string "Unicode 4.0", referring to version 4.0 of the
12500 Unicode specification.
12505 @strong{62}. The accuracy actually achieved by the elementary
12506 functions. See A.5.1(1).
12509 The elementary functions correspond to the functions available in the C
12510 library. Only fast math mode is implemented.
12515 @strong{63}. The sign of a zero result from some of the operators or
12516 functions in @code{Numerics.Generic_Elementary_Functions}, when
12517 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
12520 The sign of zeroes follows the requirements of the IEEE 754 standard on
12526 @strong{64}. The value of
12527 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
12530 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12535 @strong{65}. The value of
12536 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
12539 Maximum image width is 6864, see library file @file{s-rannum.ads}.
12544 @strong{66}. The algorithms for random number generation. See
12548 The algorithm is the Mersenne Twister, as documented in the source file
12549 @file{s-rannum.adb}. This version of the algorithm has a period of
12555 @strong{67}. The string representation of a random number generator's
12556 state. See A.5.2(38).
12559 The value returned by the Image function is the concatenation of
12560 the fixed-width decimal representations of the 624 32-bit integers
12561 of the state vector.
12566 @strong{68}. The minimum time interval between calls to the
12567 time-dependent Reset procedure that are guaranteed to initiate different
12568 random number sequences. See A.5.2(45).
12571 The minimum period between reset calls to guarantee distinct series of
12572 random numbers is one microsecond.
12577 @strong{69}. The values of the @code{Model_Mantissa},
12578 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
12579 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
12580 Annex is not supported. See A.5.3(72).
12583 Run the compiler with @option{-gnatS} to produce a listing of package
12584 @code{Standard}, has the values of all numeric attributes.
12589 @strong{70}. Any implementation-defined characteristics of the
12590 input-output packages. See A.7(14).
12593 There are no special implementation defined characteristics for these
12599 @strong{71}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
12603 All type representations are contiguous, and the @code{Buffer_Size} is
12604 the value of @code{@var{type}'Size} rounded up to the next storage unit
12610 @strong{72}. External files for standard input, standard output, and
12611 standard error See A.10(5).
12614 These files are mapped onto the files provided by the C streams
12615 libraries. See source file @file{i-cstrea.ads} for further details.
12620 @strong{73}. The accuracy of the value produced by @code{Put}. See
12624 If more digits are requested in the output than are represented by the
12625 precision of the value, zeroes are output in the corresponding least
12626 significant digit positions.
12631 @strong{74}. The meaning of @code{Argument_Count}, @code{Argument}, and
12632 @code{Command_Name}. See A.15(1).
12635 These are mapped onto the @code{argv} and @code{argc} parameters of the
12636 main program in the natural manner.
12641 @strong{75}. The interpretation of the @code{Form} parameter in procedure
12642 @code{Create_Directory}. See A.16(56).
12645 The @code{Form} parameter is not used.
12650 @strong{76}. The interpretation of the @code{Form} parameter in procedure
12651 @code{Create_Path}. See A.16(60).
12654 The @code{Form} parameter is not used.
12659 @strong{77}. The interpretation of the @code{Form} parameter in procedure
12660 @code{Copy_File}. See A.16(68).
12663 The @code{Form} parameter is case-insensitive.
12665 Two fields are recognized in the @code{Form} parameter:
12669 @item preserve=<value>
12676 <value> starts immediately after the character '=' and ends with the
12677 character immediately preceding the next comma (',') or with the last
12678 character of the parameter.
12680 The only possible values for preserve= are:
12684 @item no_attributes
12685 Do not try to preserve any file attributes. This is the default if no
12686 preserve= is found in Form.
12688 @item all_attributes
12689 Try to preserve all file attributes (timestamps, access rights).
12692 Preserve the timestamp of the copied file, but not the other file attributes.
12697 The only possible values for mode= are:
12702 Only do the copy if the destination file does not already exist. If it already
12703 exists, Copy_File fails.
12706 Copy the file in all cases. Overwrite an already existing destination file.
12709 Append the original file to the destination file. If the destination file does
12710 not exist, the destination file is a copy of the source file. When mode=append,
12711 the field preserve=, if it exists, is not taken into account.
12716 If the Form parameter includes one or both of the fields and the value or
12717 values are incorrect, Copy_file fails with Use_Error.
12719 Examples of correct Forms:
12722 Form => "preserve=no_attributes,mode=overwrite" (the default)
12723 Form => "mode=append"
12724 Form => "mode=copy, preserve=all_attributes"
12728 Examples of incorrect Forms
12731 Form => "preserve=junk"
12732 Form => "mode=internal, preserve=timestamps"
12738 @strong{78}. Implementation-defined convention names. See B.1(11).
12741 The following convention names are supported
12746 @item Ada_Pass_By_Copy
12747 Allowed for any types except by-reference types such as limited
12748 records. Compatible with convention Ada, but causes any parameters
12749 with this convention to be passed by copy.
12750 @item Ada_Pass_By_Reference
12751 Allowed for any types except by-copy types such as scalars.
12752 Compatible with convention Ada, but causes any parameters
12753 with this convention to be passed by reference.
12757 Synonym for Assembler
12759 Synonym for Assembler
12762 @item C_Pass_By_Copy
12763 Allowed only for record types, like C, but also notes that record
12764 is to be passed by copy rather than reference.
12767 @item C_Plus_Plus (or CPP)
12770 Treated the same as C
12772 Treated the same as C
12776 For support of pragma @code{Import} with convention Intrinsic, see
12777 separate section on Intrinsic Subprograms.
12779 Stdcall (used for Windows implementations only). This convention correspond
12780 to the WINAPI (previously called Pascal convention) C/C++ convention under
12781 Windows. A routine with this convention cleans the stack before
12782 exit. This pragma cannot be applied to a dispatching call.
12784 Synonym for Stdcall
12786 Synonym for Stdcall
12788 Stubbed is a special convention used to indicate that the body of the
12789 subprogram will be entirely ignored. Any call to the subprogram
12790 is converted into a raise of the @code{Program_Error} exception. If a
12791 pragma @code{Import} specifies convention @code{stubbed} then no body need
12792 be present at all. This convention is useful during development for the
12793 inclusion of subprograms whose body has not yet been written.
12797 In addition, all otherwise unrecognized convention names are also
12798 treated as being synonymous with convention C@. In all implementations
12799 except for VMS, use of such other names results in a warning. In VMS
12800 implementations, these names are accepted silently.
12805 @strong{79}. The meaning of link names. See B.1(36).
12808 Link names are the actual names used by the linker.
12813 @strong{80}. The manner of choosing link names when neither the link
12814 name nor the address of an imported or exported entity is specified. See
12818 The default linker name is that which would be assigned by the relevant
12819 external language, interpreting the Ada name as being in all lower case
12825 @strong{81}. The effect of pragma @code{Linker_Options}. See B.1(37).
12828 The string passed to @code{Linker_Options} is presented uninterpreted as
12829 an argument to the link command, unless it contains ASCII.NUL characters.
12830 NUL characters if they appear act as argument separators, so for example
12832 @smallexample @c ada
12833 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12837 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12838 linker. The order of linker options is preserved for a given unit. The final
12839 list of options passed to the linker is in reverse order of the elaboration
12840 order. For example, linker options for a body always appear before the options
12841 from the corresponding package spec.
12846 @strong{82}. The contents of the visible part of package
12847 @code{Interfaces} and its language-defined descendants. See B.2(1).
12850 See files with prefix @file{i-} in the distributed library.
12855 @strong{83}. Implementation-defined children of package
12856 @code{Interfaces}. The contents of the visible part of package
12857 @code{Interfaces}. See B.2(11).
12860 See files with prefix @file{i-} in the distributed library.
12865 @strong{84}. The types @code{Floating}, @code{Long_Floating},
12866 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12867 @code{COBOL_Character}; and the initialization of the variables
12868 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12869 @code{Interfaces.COBOL}. See B.4(50).
12875 @item Long_Floating
12876 (Floating) Long_Float
12881 @item Decimal_Element
12883 @item COBOL_Character
12888 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12893 @strong{85}. Support for access to machine instructions. See C.1(1).
12896 See documentation in file @file{s-maccod.ads} in the distributed library.
12901 @strong{86}. Implementation-defined aspects of access to machine
12902 operations. See C.1(9).
12905 See documentation in file @file{s-maccod.ads} in the distributed library.
12910 @strong{87}. Implementation-defined aspects of interrupts. See C.3(2).
12913 Interrupts are mapped to signals or conditions as appropriate. See
12915 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12916 on the interrupts supported on a particular target.
12921 @strong{88}. Implementation-defined aspects of pre-elaboration. See
12925 GNAT does not permit a partition to be restarted without reloading,
12926 except under control of the debugger.
12931 @strong{89}. The semantics of pragma @code{Discard_Names}. See C.5(7).
12934 Pragma @code{Discard_Names} causes names of enumeration literals to
12935 be suppressed. In the presence of this pragma, the Image attribute
12936 provides the image of the Pos of the literal, and Value accepts
12942 @strong{90}. The result of the @code{Task_Identification.Image}
12943 attribute. See C.7.1(7).
12946 The result of this attribute is a string that identifies
12947 the object or component that denotes a given task. If a variable @code{Var}
12948 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12950 is the hexadecimal representation of the virtual address of the corresponding
12951 task control block. If the variable is an array of tasks, the image of each
12952 task will have the form of an indexed component indicating the position of a
12953 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12954 component of a record, the image of the task will have the form of a selected
12955 component. These rules are fully recursive, so that the image of a task that
12956 is a subcomponent of a composite object corresponds to the expression that
12957 designates this task.
12959 If a task is created by an allocator, its image depends on the context. If the
12960 allocator is part of an object declaration, the rules described above are used
12961 to construct its image, and this image is not affected by subsequent
12962 assignments. If the allocator appears within an expression, the image
12963 includes only the name of the task type.
12965 If the configuration pragma Discard_Names is present, or if the restriction
12966 No_Implicit_Heap_Allocation is in effect, the image reduces to
12967 the numeric suffix, that is to say the hexadecimal representation of the
12968 virtual address of the control block of the task.
12972 @strong{91}. The value of @code{Current_Task} when in a protected entry
12973 or interrupt handler. See C.7.1(17).
12976 Protected entries or interrupt handlers can be executed by any
12977 convenient thread, so the value of @code{Current_Task} is undefined.
12982 @strong{92}. The effect of calling @code{Current_Task} from an entry
12983 body or interrupt handler. See C.7.1(19).
12986 The effect of calling @code{Current_Task} from an entry body or
12987 interrupt handler is to return the identification of the task currently
12988 executing the code.
12993 @strong{93}. Implementation-defined aspects of
12994 @code{Task_Attributes}. See C.7.2(19).
12997 There are no implementation-defined aspects of @code{Task_Attributes}.
13002 @strong{94}. Values of all @code{Metrics}. See D(2).
13005 The metrics information for GNAT depends on the performance of the
13006 underlying operating system. The sources of the run-time for tasking
13007 implementation, together with the output from @option{-gnatG} can be
13008 used to determine the exact sequence of operating systems calls made
13009 to implement various tasking constructs. Together with appropriate
13010 information on the performance of the underlying operating system,
13011 on the exact target in use, this information can be used to determine
13012 the required metrics.
13017 @strong{95}. The declarations of @code{Any_Priority} and
13018 @code{Priority}. See D.1(11).
13021 See declarations in file @file{system.ads}.
13026 @strong{96}. Implementation-defined execution resources. See D.1(15).
13029 There are no implementation-defined execution resources.
13034 @strong{97}. Whether, on a multiprocessor, a task that is waiting for
13035 access to a protected object keeps its processor busy. See D.2.1(3).
13038 On a multi-processor, a task that is waiting for access to a protected
13039 object does not keep its processor busy.
13044 @strong{98}. The affect of implementation defined execution resources
13045 on task dispatching. See D.2.1(9).
13048 Tasks map to threads in the threads package used by GNAT@. Where possible
13049 and appropriate, these threads correspond to native threads of the
13050 underlying operating system.
13055 @strong{99}. Implementation-defined @code{policy_identifiers} allowed
13056 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
13059 There are no implementation-defined policy-identifiers allowed in this
13065 @strong{100}. Implementation-defined aspects of priority inversion. See
13069 Execution of a task cannot be preempted by the implementation processing
13070 of delay expirations for lower priority tasks.
13075 @strong{101}. Implementation-defined task dispatching. See D.2.2(18).
13078 The policy is the same as that of the underlying threads implementation.
13083 @strong{102}. Implementation-defined @code{policy_identifiers} allowed
13084 in a pragma @code{Locking_Policy}. See D.3(4).
13087 The two implementation defined policies permitted in GNAT are
13088 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
13089 targets that support the @code{Inheritance_Locking} policy, locking is
13090 implemented by inheritance, i.e.@: the task owning the lock operates
13091 at a priority equal to the highest priority of any task currently
13092 requesting the lock. On targets that support the
13093 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
13094 read/write lock allowing multiple propected object functions to enter
13100 @strong{103}. Default ceiling priorities. See D.3(10).
13103 The ceiling priority of protected objects of the type
13104 @code{System.Interrupt_Priority'Last} as described in the Ada
13105 Reference Manual D.3(10),
13110 @strong{104}. The ceiling of any protected object used internally by
13111 the implementation. See D.3(16).
13114 The ceiling priority of internal protected objects is
13115 @code{System.Priority'Last}.
13120 @strong{105}. Implementation-defined queuing policies. See D.4(1).
13123 There are no implementation-defined queuing policies.
13128 @strong{106}. On a multiprocessor, any conditions that cause the
13129 completion of an aborted construct to be delayed later than what is
13130 specified for a single processor. See D.6(3).
13133 The semantics for abort on a multi-processor is the same as on a single
13134 processor, there are no further delays.
13139 @strong{107}. Any operations that implicitly require heap storage
13140 allocation. See D.7(8).
13143 The only operation that implicitly requires heap storage allocation is
13149 @strong{108}. Implementation-defined aspects of pragma
13150 @code{Restrictions}. See D.7(20).
13153 There are no such implementation-defined aspects.
13158 @strong{109}. Implementation-defined aspects of package
13159 @code{Real_Time}. See D.8(17).
13162 There are no implementation defined aspects of package @code{Real_Time}.
13167 @strong{110}. Implementation-defined aspects of
13168 @code{delay_statements}. See D.9(8).
13171 Any difference greater than one microsecond will cause the task to be
13172 delayed (see D.9(7)).
13177 @strong{111}. The upper bound on the duration of interrupt blocking
13178 caused by the implementation. See D.12(5).
13181 The upper bound is determined by the underlying operating system. In
13182 no cases is it more than 10 milliseconds.
13187 @strong{112}. The means for creating and executing distributed
13188 programs. See E(5).
13191 The GLADE package provides a utility GNATDIST for creating and executing
13192 distributed programs. See the GLADE reference manual for further details.
13197 @strong{113}. Any events that can result in a partition becoming
13198 inaccessible. See E.1(7).
13201 See the GLADE reference manual for full details on such events.
13206 @strong{114}. The scheduling policies, treatment of priorities, and
13207 management of shared resources between partitions in certain cases. See
13211 See the GLADE reference manual for full details on these aspects of
13212 multi-partition execution.
13217 @strong{115}. Events that cause the version of a compilation unit to
13218 change. See E.3(5).
13221 Editing the source file of a compilation unit, or the source files of
13222 any units on which it is dependent in a significant way cause the version
13223 to change. No other actions cause the version number to change. All changes
13224 are significant except those which affect only layout, capitalization or
13230 @strong{116}. Whether the execution of the remote subprogram is
13231 immediately aborted as a result of cancellation. See E.4(13).
13234 See the GLADE reference manual for details on the effect of abort in
13235 a distributed application.
13240 @strong{117}. Implementation-defined aspects of the PCS@. See E.5(25).
13243 See the GLADE reference manual for a full description of all implementation
13244 defined aspects of the PCS@.
13249 @strong{118}. Implementation-defined interfaces in the PCS@. See
13253 See the GLADE reference manual for a full description of all
13254 implementation defined interfaces.
13259 @strong{119}. The values of named numbers in the package
13260 @code{Decimal}. See F.2(7).
13272 @item Max_Decimal_Digits
13279 @strong{120}. The value of @code{Max_Picture_Length} in the package
13280 @code{Text_IO.Editing}. See F.3.3(16).
13288 @strong{121}. The value of @code{Max_Picture_Length} in the package
13289 @code{Wide_Text_IO.Editing}. See F.3.4(5).
13297 @strong{122}. The accuracy actually achieved by the complex elementary
13298 functions and by other complex arithmetic operations. See G.1(1).
13301 Standard library functions are used for the complex arithmetic
13302 operations. Only fast math mode is currently supported.
13307 @strong{123}. The sign of a zero result (or a component thereof) from
13308 any operator or function in @code{Numerics.Generic_Complex_Types}, when
13309 @code{Real'Signed_Zeros} is True. See G.1.1(53).
13312 The signs of zero values are as recommended by the relevant
13313 implementation advice.
13318 @strong{124}. The sign of a zero result (or a component thereof) from
13319 any operator or function in
13320 @code{Numerics.Generic_Complex_Elementary_Functions}, when
13321 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
13324 The signs of zero values are as recommended by the relevant
13325 implementation advice.
13330 @strong{125}. Whether the strict mode or the relaxed mode is the
13331 default. See G.2(2).
13334 The strict mode is the default. There is no separate relaxed mode. GNAT
13335 provides a highly efficient implementation of strict mode.
13340 @strong{126}. The result interval in certain cases of fixed-to-float
13341 conversion. See G.2.1(10).
13344 For cases where the result interval is implementation dependent, the
13345 accuracy is that provided by performing all operations in 64-bit IEEE
13346 floating-point format.
13351 @strong{127}. The result of a floating point arithmetic operation in
13352 overflow situations, when the @code{Machine_Overflows} attribute of the
13353 result type is @code{False}. See G.2.1(13).
13356 Infinite and NaN values are produced as dictated by the IEEE
13357 floating-point standard.
13359 Note that on machines that are not fully compliant with the IEEE
13360 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
13361 must be used for achieving IEEE conforming behavior (although at the cost
13362 of a significant performance penalty), so infinite and NaN values are
13363 properly generated.
13368 @strong{128}. The result interval for division (or exponentiation by a
13369 negative exponent), when the floating point hardware implements division
13370 as multiplication by a reciprocal. See G.2.1(16).
13373 Not relevant, division is IEEE exact.
13378 @strong{129}. The definition of close result set, which determines the
13379 accuracy of certain fixed point multiplications and divisions. See
13383 Operations in the close result set are performed using IEEE long format
13384 floating-point arithmetic. The input operands are converted to
13385 floating-point, the operation is done in floating-point, and the result
13386 is converted to the target type.
13391 @strong{130}. Conditions on a @code{universal_real} operand of a fixed
13392 point multiplication or division for which the result shall be in the
13393 perfect result set. See G.2.3(22).
13396 The result is only defined to be in the perfect result set if the result
13397 can be computed by a single scaling operation involving a scale factor
13398 representable in 64-bits.
13403 @strong{131}. The result of a fixed point arithmetic operation in
13404 overflow situations, when the @code{Machine_Overflows} attribute of the
13405 result type is @code{False}. See G.2.3(27).
13408 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
13414 @strong{132}. The result of an elementary function reference in
13415 overflow situations, when the @code{Machine_Overflows} attribute of the
13416 result type is @code{False}. See G.2.4(4).
13419 IEEE infinite and Nan values are produced as appropriate.
13424 @strong{133}. The value of the angle threshold, within which certain
13425 elementary functions, complex arithmetic operations, and complex
13426 elementary functions yield results conforming to a maximum relative
13427 error bound. See G.2.4(10).
13430 Information on this subject is not yet available.
13435 @strong{134}. The accuracy of certain elementary functions for
13436 parameters beyond the angle threshold. See G.2.4(10).
13439 Information on this subject is not yet available.
13444 @strong{135}. The result of a complex arithmetic operation or complex
13445 elementary function reference in overflow situations, when the
13446 @code{Machine_Overflows} attribute of the corresponding real type is
13447 @code{False}. See G.2.6(5).
13450 IEEE infinite and Nan values are produced as appropriate.
13455 @strong{136}. The accuracy of certain complex arithmetic operations and
13456 certain complex elementary functions for parameters (or components
13457 thereof) beyond the angle threshold. See G.2.6(8).
13460 Information on those subjects is not yet available.
13465 @strong{137}. Information regarding bounded errors and erroneous
13466 execution. See H.2(1).
13469 Information on this subject is not yet available.
13474 @strong{138}. Implementation-defined aspects of pragma
13475 @code{Inspection_Point}. See H.3.2(8).
13478 Pragma @code{Inspection_Point} ensures that the variable is live and can
13479 be examined by the debugger at the inspection point.
13484 @strong{139}. Implementation-defined aspects of pragma
13485 @code{Restrictions}. See H.4(25).
13488 There are no implementation-defined aspects of pragma @code{Restrictions}. The
13489 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
13490 generated code. Checks must suppressed by use of pragma @code{Suppress}.
13495 @strong{140}. Any restrictions on pragma @code{Restrictions}. See
13499 There are no restrictions on pragma @code{Restrictions}.
13501 @node Intrinsic Subprograms
13502 @chapter Intrinsic Subprograms
13503 @cindex Intrinsic Subprograms
13506 * Intrinsic Operators::
13507 * Enclosing_Entity::
13508 * Exception_Information::
13509 * Exception_Message::
13513 * Shifts and Rotates::
13514 * Source_Location::
13518 GNAT allows a user application program to write the declaration:
13520 @smallexample @c ada
13521 pragma Import (Intrinsic, name);
13525 providing that the name corresponds to one of the implemented intrinsic
13526 subprograms in GNAT, and that the parameter profile of the referenced
13527 subprogram meets the requirements. This chapter describes the set of
13528 implemented intrinsic subprograms, and the requirements on parameter profiles.
13529 Note that no body is supplied; as with other uses of pragma Import, the
13530 body is supplied elsewhere (in this case by the compiler itself). Note
13531 that any use of this feature is potentially non-portable, since the
13532 Ada standard does not require Ada compilers to implement this feature.
13534 @node Intrinsic Operators
13535 @section Intrinsic Operators
13536 @cindex Intrinsic operator
13539 All the predefined numeric operators in package Standard
13540 in @code{pragma Import (Intrinsic,..)}
13541 declarations. In the binary operator case, the operands must have the same
13542 size. The operand or operands must also be appropriate for
13543 the operator. For example, for addition, the operands must
13544 both be floating-point or both be fixed-point, and the
13545 right operand for @code{"**"} must have a root type of
13546 @code{Standard.Integer'Base}.
13547 You can use an intrinsic operator declaration as in the following example:
13549 @smallexample @c ada
13550 type Int1 is new Integer;
13551 type Int2 is new Integer;
13553 function "+" (X1 : Int1; X2 : Int2) return Int1;
13554 function "+" (X1 : Int1; X2 : Int2) return Int2;
13555 pragma Import (Intrinsic, "+");
13559 This declaration would permit ``mixed mode'' arithmetic on items
13560 of the differing types @code{Int1} and @code{Int2}.
13561 It is also possible to specify such operators for private types, if the
13562 full views are appropriate arithmetic types.
13564 @node Enclosing_Entity
13565 @section Enclosing_Entity
13566 @cindex Enclosing_Entity
13568 This intrinsic subprogram is used in the implementation of the
13569 library routine @code{GNAT.Source_Info}. The only useful use of the
13570 intrinsic import in this case is the one in this unit, so an
13571 application program should simply call the function
13572 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
13573 the current subprogram, package, task, entry, or protected subprogram.
13575 @node Exception_Information
13576 @section Exception_Information
13577 @cindex Exception_Information'
13579 This intrinsic subprogram is used in the implementation of the
13580 library routine @code{GNAT.Current_Exception}. The only useful
13581 use of the intrinsic import in this case is the one in this unit,
13582 so an application program should simply call the function
13583 @code{GNAT.Current_Exception.Exception_Information} to obtain
13584 the exception information associated with the current exception.
13586 @node Exception_Message
13587 @section Exception_Message
13588 @cindex Exception_Message
13590 This intrinsic subprogram is used in the implementation of the
13591 library routine @code{GNAT.Current_Exception}. The only useful
13592 use of the intrinsic import in this case is the one in this unit,
13593 so an application program should simply call the function
13594 @code{GNAT.Current_Exception.Exception_Message} to obtain
13595 the message associated with the current exception.
13597 @node Exception_Name
13598 @section Exception_Name
13599 @cindex Exception_Name
13601 This intrinsic subprogram is used in the implementation of the
13602 library routine @code{GNAT.Current_Exception}. The only useful
13603 use of the intrinsic import in this case is the one in this unit,
13604 so an application program should simply call the function
13605 @code{GNAT.Current_Exception.Exception_Name} to obtain
13606 the name of the current exception.
13612 This intrinsic subprogram is used in the implementation of the
13613 library routine @code{GNAT.Source_Info}. The only useful use of the
13614 intrinsic import in this case is the one in this unit, so an
13615 application program should simply call the function
13616 @code{GNAT.Source_Info.File} to obtain the name of the current
13623 This intrinsic subprogram is used in the implementation of the
13624 library routine @code{GNAT.Source_Info}. The only useful use of the
13625 intrinsic import in this case is the one in this unit, so an
13626 application program should simply call the function
13627 @code{GNAT.Source_Info.Line} to obtain the number of the current
13630 @node Shifts and Rotates
13631 @section Shifts and Rotates
13633 @cindex Shift_Right
13634 @cindex Shift_Right_Arithmetic
13635 @cindex Rotate_Left
13636 @cindex Rotate_Right
13638 In standard Ada, the shift and rotate functions are available only
13639 for the predefined modular types in package @code{Interfaces}. However, in
13640 GNAT it is possible to define these functions for any integer
13641 type (signed or modular), as in this example:
13643 @smallexample @c ada
13644 function Shift_Left
13651 The function name must be one of
13652 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
13653 Rotate_Right. T must be an integer type. T'Size must be
13654 8, 16, 32 or 64 bits; if T is modular, the modulus
13655 must be 2**8, 2**16, 2**32 or 2**64.
13656 The result type must be the same as the type of @code{Value}.
13657 The shift amount must be Natural.
13658 The formal parameter names can be anything.
13660 @node Source_Location
13661 @section Source_Location
13662 @cindex Source_Location
13664 This intrinsic subprogram is used in the implementation of the
13665 library routine @code{GNAT.Source_Info}. The only useful use of the
13666 intrinsic import in this case is the one in this unit, so an
13667 application program should simply call the function
13668 @code{GNAT.Source_Info.Source_Location} to obtain the current
13669 source file location.
13671 @node Representation Clauses and Pragmas
13672 @chapter Representation Clauses and Pragmas
13673 @cindex Representation Clauses
13676 * Alignment Clauses::
13678 * Storage_Size Clauses::
13679 * Size of Variant Record Objects::
13680 * Biased Representation ::
13681 * Value_Size and Object_Size Clauses::
13682 * Component_Size Clauses::
13683 * Bit_Order Clauses::
13684 * Effect of Bit_Order on Byte Ordering::
13685 * Pragma Pack for Arrays::
13686 * Pragma Pack for Records::
13687 * Record Representation Clauses::
13688 * Enumeration Clauses::
13689 * Address Clauses::
13690 * Effect of Convention on Representation::
13691 * Determining the Representations chosen by GNAT::
13695 @cindex Representation Clause
13696 @cindex Representation Pragma
13697 @cindex Pragma, representation
13698 This section describes the representation clauses accepted by GNAT, and
13699 their effect on the representation of corresponding data objects.
13701 GNAT fully implements Annex C (Systems Programming). This means that all
13702 the implementation advice sections in chapter 13 are fully implemented.
13703 However, these sections only require a minimal level of support for
13704 representation clauses. GNAT provides much more extensive capabilities,
13705 and this section describes the additional capabilities provided.
13707 @node Alignment Clauses
13708 @section Alignment Clauses
13709 @cindex Alignment Clause
13712 GNAT requires that all alignment clauses specify a power of 2, and all
13713 default alignments are always a power of 2. The default alignment
13714 values are as follows:
13717 @item @emph{Primitive Types}.
13718 For primitive types, the alignment is the minimum of the actual size of
13719 objects of the type divided by @code{Storage_Unit},
13720 and the maximum alignment supported by the target.
13721 (This maximum alignment is given by the GNAT-specific attribute
13722 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13723 @cindex @code{Maximum_Alignment} attribute
13724 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13725 default alignment will be 8 on any target that supports alignments
13726 this large, but on some targets, the maximum alignment may be smaller
13727 than 8, in which case objects of type @code{Long_Float} will be maximally
13730 @item @emph{Arrays}.
13731 For arrays, the alignment is equal to the alignment of the component type
13732 for the normal case where no packing or component size is given. If the
13733 array is packed, and the packing is effective (see separate section on
13734 packed arrays), then the alignment will be one for long packed arrays,
13735 or arrays whose length is not known at compile time. For short packed
13736 arrays, which are handled internally as modular types, the alignment
13737 will be as described for primitive types, e.g.@: a packed array of length
13738 31 bits will have an object size of four bytes, and an alignment of 4.
13740 @item @emph{Records}.
13741 For the normal non-packed case, the alignment of a record is equal to
13742 the maximum alignment of any of its components. For tagged records, this
13743 includes the implicit access type used for the tag. If a pragma @code{Pack}
13744 is used and all components are packable (see separate section on pragma
13745 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13746 record makes it profitable to increase it.
13748 A special case is when:
13751 the size of the record is given explicitly, or a
13752 full record representation clause is given, and
13754 the size of the record is 2, 4, or 8 bytes.
13757 In this case, an alignment is chosen to match the
13758 size of the record. For example, if we have:
13760 @smallexample @c ada
13761 type Small is record
13764 for Small'Size use 16;
13768 then the default alignment of the record type @code{Small} is 2, not 1. This
13769 leads to more efficient code when the record is treated as a unit, and also
13770 allows the type to specified as @code{Atomic} on architectures requiring
13776 An alignment clause may specify a larger alignment than the default value
13777 up to some maximum value dependent on the target (obtainable by using the
13778 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13779 a smaller alignment than the default value for enumeration, integer and
13780 fixed point types, as well as for record types, for example
13782 @smallexample @c ada
13787 for V'alignment use 1;
13791 @cindex Alignment, default
13792 The default alignment for the type @code{V} is 4, as a result of the
13793 Integer field in the record, but it is permissible, as shown, to
13794 override the default alignment of the record with a smaller value.
13796 @cindex Alignment, subtypes
13797 Note that according to the Ada standard, an alignment clause applies only
13798 to the first named subtype. If additional subtypes are declared, then the
13799 compiler is allowed to choose any alignment it likes, and there is no way
13800 to control this choice. Consider:
13802 @smallexample @c ada
13803 type R is range 1 .. 10_000;
13804 for R'Alignment use 1;
13805 subtype RS is R range 1 .. 1000;
13809 The alignment clause specifies an alignment of 1 for the first named subtype
13810 @code{R} but this does not necessarily apply to @code{RS}. When writing
13811 portable Ada code, you should avoid writing code that explicitly or
13812 implicitly relies on the alignment of such subtypes.
13814 For the GNAT compiler, if an explicit alignment clause is given, this
13815 value is also used for any subsequent subtypes. So for GNAT, in the
13816 above example, you can count on the alignment of @code{RS} being 1. But this
13817 assumption is non-portable, and other compilers may choose different
13818 alignments for the subtype @code{RS}.
13821 @section Size Clauses
13822 @cindex Size Clause
13825 The default size for a type @code{T} is obtainable through the
13826 language-defined attribute @code{T'Size} and also through the
13827 equivalent GNAT-defined attribute @code{T'Value_Size}.
13828 For objects of type @code{T}, GNAT will generally increase the type size
13829 so that the object size (obtainable through the GNAT-defined attribute
13830 @code{T'Object_Size})
13831 is a multiple of @code{T'Alignment * Storage_Unit}.
13834 @smallexample @c ada
13835 type Smallint is range 1 .. 6;
13844 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13845 as specified by the RM rules,
13846 but objects of this type will have a size of 8
13847 (@code{Smallint'Object_Size} = 8),
13848 since objects by default occupy an integral number
13849 of storage units. On some targets, notably older
13850 versions of the Digital Alpha, the size of stand
13851 alone objects of this type may be 32, reflecting
13852 the inability of the hardware to do byte load/stores.
13854 Similarly, the size of type @code{Rec} is 40 bits
13855 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13856 the alignment is 4, so objects of this type will have
13857 their size increased to 64 bits so that it is a multiple
13858 of the alignment (in bits). This decision is
13859 in accordance with the specific Implementation Advice in RM 13.3(43):
13862 A @code{Size} clause should be supported for an object if the specified
13863 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13864 to a size in storage elements that is a multiple of the object's
13865 @code{Alignment} (if the @code{Alignment} is nonzero).
13869 An explicit size clause may be used to override the default size by
13870 increasing it. For example, if we have:
13872 @smallexample @c ada
13873 type My_Boolean is new Boolean;
13874 for My_Boolean'Size use 32;
13878 then values of this type will always be 32 bits long. In the case of
13879 discrete types, the size can be increased up to 64 bits, with the effect
13880 that the entire specified field is used to hold the value, sign- or
13881 zero-extended as appropriate. If more than 64 bits is specified, then
13882 padding space is allocated after the value, and a warning is issued that
13883 there are unused bits.
13885 Similarly the size of records and arrays may be increased, and the effect
13886 is to add padding bits after the value. This also causes a warning message
13889 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
13890 Size in bits, this corresponds to an object of size 256 megabytes (minus
13891 one). This limitation is true on all targets. The reason for this
13892 limitation is that it improves the quality of the code in many cases
13893 if it is known that a Size value can be accommodated in an object of
13896 @node Storage_Size Clauses
13897 @section Storage_Size Clauses
13898 @cindex Storage_Size Clause
13901 For tasks, the @code{Storage_Size} clause specifies the amount of space
13902 to be allocated for the task stack. This cannot be extended, and if the
13903 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13904 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
13905 or a @code{Storage_Size} pragma in the task definition to set the
13906 appropriate required size. A useful technique is to include in every
13907 task definition a pragma of the form:
13909 @smallexample @c ada
13910 pragma Storage_Size (Default_Stack_Size);
13914 Then @code{Default_Stack_Size} can be defined in a global package, and
13915 modified as required. Any tasks requiring stack sizes different from the
13916 default can have an appropriate alternative reference in the pragma.
13918 You can also use the @option{-d} binder switch to modify the default stack
13921 For access types, the @code{Storage_Size} clause specifies the maximum
13922 space available for allocation of objects of the type. If this space is
13923 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13924 In the case where the access type is declared local to a subprogram, the
13925 use of a @code{Storage_Size} clause triggers automatic use of a special
13926 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13927 space for the pool is automatically reclaimed on exit from the scope in
13928 which the type is declared.
13930 A special case recognized by the compiler is the specification of a
13931 @code{Storage_Size} of zero for an access type. This means that no
13932 items can be allocated from the pool, and this is recognized at compile
13933 time, and all the overhead normally associated with maintaining a fixed
13934 size storage pool is eliminated. Consider the following example:
13936 @smallexample @c ada
13938 type R is array (Natural) of Character;
13939 type P is access all R;
13940 for P'Storage_Size use 0;
13941 -- Above access type intended only for interfacing purposes
13945 procedure g (m : P);
13946 pragma Import (C, g);
13957 As indicated in this example, these dummy storage pools are often useful in
13958 connection with interfacing where no object will ever be allocated. If you
13959 compile the above example, you get the warning:
13962 p.adb:16:09: warning: allocation from empty storage pool
13963 p.adb:16:09: warning: Storage_Error will be raised at run time
13967 Of course in practice, there will not be any explicit allocators in the
13968 case of such an access declaration.
13970 @node Size of Variant Record Objects
13971 @section Size of Variant Record Objects
13972 @cindex Size, variant record objects
13973 @cindex Variant record objects, size
13976 In the case of variant record objects, there is a question whether Size gives
13977 information about a particular variant, or the maximum size required
13978 for any variant. Consider the following program
13980 @smallexample @c ada
13981 with Text_IO; use Text_IO;
13983 type R1 (A : Boolean := False) is record
13985 when True => X : Character;
13986 when False => null;
13994 Put_Line (Integer'Image (V1'Size));
13995 Put_Line (Integer'Image (V2'Size));
14000 Here we are dealing with a variant record, where the True variant
14001 requires 16 bits, and the False variant requires 8 bits.
14002 In the above example, both V1 and V2 contain the False variant,
14003 which is only 8 bits long. However, the result of running the
14012 The reason for the difference here is that the discriminant value of
14013 V1 is fixed, and will always be False. It is not possible to assign
14014 a True variant value to V1, therefore 8 bits is sufficient. On the
14015 other hand, in the case of V2, the initial discriminant value is
14016 False (from the default), but it is possible to assign a True
14017 variant value to V2, therefore 16 bits must be allocated for V2
14018 in the general case, even fewer bits may be needed at any particular
14019 point during the program execution.
14021 As can be seen from the output of this program, the @code{'Size}
14022 attribute applied to such an object in GNAT gives the actual allocated
14023 size of the variable, which is the largest size of any of the variants.
14024 The Ada Reference Manual is not completely clear on what choice should
14025 be made here, but the GNAT behavior seems most consistent with the
14026 language in the RM@.
14028 In some cases, it may be desirable to obtain the size of the current
14029 variant, rather than the size of the largest variant. This can be
14030 achieved in GNAT by making use of the fact that in the case of a
14031 subprogram parameter, GNAT does indeed return the size of the current
14032 variant (because a subprogram has no way of knowing how much space
14033 is actually allocated for the actual).
14035 Consider the following modified version of the above program:
14037 @smallexample @c ada
14038 with Text_IO; use Text_IO;
14040 type R1 (A : Boolean := False) is record
14042 when True => X : Character;
14043 when False => null;
14049 function Size (V : R1) return Integer is
14055 Put_Line (Integer'Image (V2'Size));
14056 Put_Line (Integer'IMage (Size (V2)));
14058 Put_Line (Integer'Image (V2'Size));
14059 Put_Line (Integer'IMage (Size (V2)));
14064 The output from this program is
14074 Here we see that while the @code{'Size} attribute always returns
14075 the maximum size, regardless of the current variant value, the
14076 @code{Size} function does indeed return the size of the current
14079 @node Biased Representation
14080 @section Biased Representation
14081 @cindex Size for biased representation
14082 @cindex Biased representation
14085 In the case of scalars with a range starting at other than zero, it is
14086 possible in some cases to specify a size smaller than the default minimum
14087 value, and in such cases, GNAT uses an unsigned biased representation,
14088 in which zero is used to represent the lower bound, and successive values
14089 represent successive values of the type.
14091 For example, suppose we have the declaration:
14093 @smallexample @c ada
14094 type Small is range -7 .. -4;
14095 for Small'Size use 2;
14099 Although the default size of type @code{Small} is 4, the @code{Size}
14100 clause is accepted by GNAT and results in the following representation
14104 -7 is represented as 2#00#
14105 -6 is represented as 2#01#
14106 -5 is represented as 2#10#
14107 -4 is represented as 2#11#
14111 Biased representation is only used if the specified @code{Size} clause
14112 cannot be accepted in any other manner. These reduced sizes that force
14113 biased representation can be used for all discrete types except for
14114 enumeration types for which a representation clause is given.
14116 @node Value_Size and Object_Size Clauses
14117 @section Value_Size and Object_Size Clauses
14119 @findex Object_Size
14120 @cindex Size, of objects
14123 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
14124 number of bits required to hold values of type @code{T}.
14125 Although this interpretation was allowed in Ada 83, it was not required,
14126 and this requirement in practice can cause some significant difficulties.
14127 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
14128 However, in Ada 95 and Ada 2005,
14129 @code{Natural'Size} is
14130 typically 31. This means that code may change in behavior when moving
14131 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
14133 @smallexample @c ada
14134 type Rec is record;
14140 at 0 range 0 .. Natural'Size - 1;
14141 at 0 range Natural'Size .. 2 * Natural'Size - 1;
14146 In the above code, since the typical size of @code{Natural} objects
14147 is 32 bits and @code{Natural'Size} is 31, the above code can cause
14148 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
14149 there are cases where the fact that the object size can exceed the
14150 size of the type causes surprises.
14152 To help get around this problem GNAT provides two implementation
14153 defined attributes, @code{Value_Size} and @code{Object_Size}. When
14154 applied to a type, these attributes yield the size of the type
14155 (corresponding to the RM defined size attribute), and the size of
14156 objects of the type respectively.
14158 The @code{Object_Size} is used for determining the default size of
14159 objects and components. This size value can be referred to using the
14160 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
14161 the basis of the determination of the size. The backend is free to
14162 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
14163 character might be stored in 32 bits on a machine with no efficient
14164 byte access instructions such as the Alpha.
14166 The default rules for the value of @code{Object_Size} for
14167 discrete types are as follows:
14171 The @code{Object_Size} for base subtypes reflect the natural hardware
14172 size in bits (run the compiler with @option{-gnatS} to find those values
14173 for numeric types). Enumeration types and fixed-point base subtypes have
14174 8, 16, 32 or 64 bits for this size, depending on the range of values
14178 The @code{Object_Size} of a subtype is the same as the
14179 @code{Object_Size} of
14180 the type from which it is obtained.
14183 The @code{Object_Size} of a derived base type is copied from the parent
14184 base type, and the @code{Object_Size} of a derived first subtype is copied
14185 from the parent first subtype.
14189 The @code{Value_Size} attribute
14190 is the (minimum) number of bits required to store a value
14192 This value is used to determine how tightly to pack
14193 records or arrays with components of this type, and also affects
14194 the semantics of unchecked conversion (unchecked conversions where
14195 the @code{Value_Size} values differ generate a warning, and are potentially
14198 The default rules for the value of @code{Value_Size} are as follows:
14202 The @code{Value_Size} for a base subtype is the minimum number of bits
14203 required to store all values of the type (including the sign bit
14204 only if negative values are possible).
14207 If a subtype statically matches the first subtype of a given type, then it has
14208 by default the same @code{Value_Size} as the first subtype. This is a
14209 consequence of RM 13.1(14) (``if two subtypes statically match,
14210 then their subtype-specific aspects are the same''.)
14213 All other subtypes have a @code{Value_Size} corresponding to the minimum
14214 number of bits required to store all values of the subtype. For
14215 dynamic bounds, it is assumed that the value can range down or up
14216 to the corresponding bound of the ancestor
14220 The RM defined attribute @code{Size} corresponds to the
14221 @code{Value_Size} attribute.
14223 The @code{Size} attribute may be defined for a first-named subtype. This sets
14224 the @code{Value_Size} of
14225 the first-named subtype to the given value, and the
14226 @code{Object_Size} of this first-named subtype to the given value padded up
14227 to an appropriate boundary. It is a consequence of the default rules
14228 above that this @code{Object_Size} will apply to all further subtypes. On the
14229 other hand, @code{Value_Size} is affected only for the first subtype, any
14230 dynamic subtypes obtained from it directly, and any statically matching
14231 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
14233 @code{Value_Size} and
14234 @code{Object_Size} may be explicitly set for any subtype using
14235 an attribute definition clause. Note that the use of these attributes
14236 can cause the RM 13.1(14) rule to be violated. If two access types
14237 reference aliased objects whose subtypes have differing @code{Object_Size}
14238 values as a result of explicit attribute definition clauses, then it
14239 is illegal to convert from one access subtype to the other. For a more
14240 complete description of this additional legality rule, see the
14241 description of the @code{Object_Size} attribute.
14243 At the implementation level, Esize stores the Object_Size and the
14244 RM_Size field stores the @code{Value_Size} (and hence the value of the
14245 @code{Size} attribute,
14246 which, as noted above, is equivalent to @code{Value_Size}).
14248 To get a feel for the difference, consider the following examples (note
14249 that in each case the base is @code{Short_Short_Integer} with a size of 8):
14252 Object_Size Value_Size
14254 type x1 is range 0 .. 5; 8 3
14256 type x2 is range 0 .. 5;
14257 for x2'size use 12; 16 12
14259 subtype x3 is x2 range 0 .. 3; 16 2
14261 subtype x4 is x2'base range 0 .. 10; 8 4
14263 subtype x5 is x2 range 0 .. dynamic; 16 3*
14265 subtype x6 is x2'base range 0 .. dynamic; 8 3*
14270 Note: the entries marked ``3*'' are not actually specified by the Ada
14271 Reference Manual, but it seems in the spirit of the RM rules to allocate
14272 the minimum number of bits (here 3, given the range for @code{x2})
14273 known to be large enough to hold the given range of values.
14275 So far, so good, but GNAT has to obey the RM rules, so the question is
14276 under what conditions must the RM @code{Size} be used.
14277 The following is a list
14278 of the occasions on which the RM @code{Size} must be used:
14282 Component size for packed arrays or records
14285 Value of the attribute @code{Size} for a type
14288 Warning about sizes not matching for unchecked conversion
14292 For record types, the @code{Object_Size} is always a multiple of the
14293 alignment of the type (this is true for all types). In some cases the
14294 @code{Value_Size} can be smaller. Consider:
14304 On a typical 32-bit architecture, the X component will be four bytes, and
14305 require four-byte alignment, and the Y component will be one byte. In this
14306 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
14307 required to store a value of this type, and for example, it is permissible
14308 to have a component of type R in an outer array whose component size is
14309 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
14310 since it must be rounded up so that this value is a multiple of the
14311 alignment (4 bytes = 32 bits).
14314 For all other types, the @code{Object_Size}
14315 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
14316 Only @code{Size} may be specified for such types.
14318 Note that @code{Value_Size} can be used to force biased representation
14319 for a particular subtype. Consider this example:
14322 type R is (A, B, C, D, E, F);
14323 subtype RAB is R range A .. B;
14324 subtype REF is R range E .. F;
14328 By default, @code{RAB}
14329 has a size of 1 (sufficient to accommodate the representation
14330 of @code{A} and @code{B}, 0 and 1), and @code{REF}
14331 has a size of 3 (sufficient to accommodate the representation
14332 of @code{E} and @code{F}, 4 and 5). But if we add the
14333 following @code{Value_Size} attribute definition clause:
14336 for REF'Value_Size use 1;
14340 then biased representation is forced for @code{REF},
14341 and 0 will represent @code{E} and 1 will represent @code{F}.
14342 A warning is issued when a @code{Value_Size} attribute
14343 definition clause forces biased representation. This
14344 warning can be turned off using @code{-gnatw.B}.
14346 @node Component_Size Clauses
14347 @section Component_Size Clauses
14348 @cindex Component_Size Clause
14351 Normally, the value specified in a component size clause must be consistent
14352 with the subtype of the array component with regard to size and alignment.
14353 In other words, the value specified must be at least equal to the size
14354 of this subtype, and must be a multiple of the alignment value.
14356 In addition, component size clauses are allowed which cause the array
14357 to be packed, by specifying a smaller value. A first case is for
14358 component size values in the range 1 through 63. The value specified
14359 must not be smaller than the Size of the subtype. GNAT will accurately
14360 honor all packing requests in this range. For example, if we have:
14362 @smallexample @c ada
14363 type r is array (1 .. 8) of Natural;
14364 for r'Component_Size use 31;
14368 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
14369 Of course access to the components of such an array is considerably
14370 less efficient than if the natural component size of 32 is used.
14371 A second case is when the subtype of the component is a record type
14372 padded because of its default alignment. For example, if we have:
14374 @smallexample @c ada
14381 type a is array (1 .. 8) of r;
14382 for a'Component_Size use 72;
14386 then the resulting array has a length of 72 bytes, instead of 96 bytes
14387 if the alignment of the record (4) was obeyed.
14389 Note that there is no point in giving both a component size clause
14390 and a pragma Pack for the same array type. if such duplicate
14391 clauses are given, the pragma Pack will be ignored.
14393 @node Bit_Order Clauses
14394 @section Bit_Order Clauses
14395 @cindex Bit_Order Clause
14396 @cindex bit ordering
14397 @cindex ordering, of bits
14400 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
14401 attribute. The specification may either correspond to the default bit
14402 order for the target, in which case the specification has no effect and
14403 places no additional restrictions, or it may be for the non-standard
14404 setting (that is the opposite of the default).
14406 In the case where the non-standard value is specified, the effect is
14407 to renumber bits within each byte, but the ordering of bytes is not
14408 affected. There are certain
14409 restrictions placed on component clauses as follows:
14413 @item Components fitting within a single storage unit.
14415 These are unrestricted, and the effect is merely to renumber bits. For
14416 example if we are on a little-endian machine with @code{Low_Order_First}
14417 being the default, then the following two declarations have exactly
14420 @smallexample @c ada
14423 B : Integer range 1 .. 120;
14427 A at 0 range 0 .. 0;
14428 B at 0 range 1 .. 7;
14433 B : Integer range 1 .. 120;
14436 for R2'Bit_Order use High_Order_First;
14439 A at 0 range 7 .. 7;
14440 B at 0 range 0 .. 6;
14445 The useful application here is to write the second declaration with the
14446 @code{Bit_Order} attribute definition clause, and know that it will be treated
14447 the same, regardless of whether the target is little-endian or big-endian.
14449 @item Components occupying an integral number of bytes.
14451 These are components that exactly fit in two or more bytes. Such component
14452 declarations are allowed, but have no effect, since it is important to realize
14453 that the @code{Bit_Order} specification does not affect the ordering of bytes.
14454 In particular, the following attempt at getting an endian-independent integer
14457 @smallexample @c ada
14462 for R2'Bit_Order use High_Order_First;
14465 A at 0 range 0 .. 31;
14470 This declaration will result in a little-endian integer on a
14471 little-endian machine, and a big-endian integer on a big-endian machine.
14472 If byte flipping is required for interoperability between big- and
14473 little-endian machines, this must be explicitly programmed. This capability
14474 is not provided by @code{Bit_Order}.
14476 @item Components that are positioned across byte boundaries
14478 but do not occupy an integral number of bytes. Given that bytes are not
14479 reordered, such fields would occupy a non-contiguous sequence of bits
14480 in memory, requiring non-trivial code to reassemble. They are for this
14481 reason not permitted, and any component clause specifying such a layout
14482 will be flagged as illegal by GNAT@.
14487 Since the misconception that Bit_Order automatically deals with all
14488 endian-related incompatibilities is a common one, the specification of
14489 a component field that is an integral number of bytes will always
14490 generate a warning. This warning may be suppressed using @code{pragma
14491 Warnings (Off)} if desired. The following section contains additional
14492 details regarding the issue of byte ordering.
14494 @node Effect of Bit_Order on Byte Ordering
14495 @section Effect of Bit_Order on Byte Ordering
14496 @cindex byte ordering
14497 @cindex ordering, of bytes
14500 In this section we will review the effect of the @code{Bit_Order} attribute
14501 definition clause on byte ordering. Briefly, it has no effect at all, but
14502 a detailed example will be helpful. Before giving this
14503 example, let us review the precise
14504 definition of the effect of defining @code{Bit_Order}. The effect of a
14505 non-standard bit order is described in section 15.5.3 of the Ada
14509 2 A bit ordering is a method of interpreting the meaning of
14510 the storage place attributes.
14514 To understand the precise definition of storage place attributes in
14515 this context, we visit section 13.5.1 of the manual:
14518 13 A record_representation_clause (without the mod_clause)
14519 specifies the layout. The storage place attributes (see 13.5.2)
14520 are taken from the values of the position, first_bit, and last_bit
14521 expressions after normalizing those values so that first_bit is
14522 less than Storage_Unit.
14526 The critical point here is that storage places are taken from
14527 the values after normalization, not before. So the @code{Bit_Order}
14528 interpretation applies to normalized values. The interpretation
14529 is described in the later part of the 15.5.3 paragraph:
14532 2 A bit ordering is a method of interpreting the meaning of
14533 the storage place attributes. High_Order_First (known in the
14534 vernacular as ``big endian'') means that the first bit of a
14535 storage element (bit 0) is the most significant bit (interpreting
14536 the sequence of bits that represent a component as an unsigned
14537 integer value). Low_Order_First (known in the vernacular as
14538 ``little endian'') means the opposite: the first bit is the
14543 Note that the numbering is with respect to the bits of a storage
14544 unit. In other words, the specification affects only the numbering
14545 of bits within a single storage unit.
14547 We can make the effect clearer by giving an example.
14549 Suppose that we have an external device which presents two bytes, the first
14550 byte presented, which is the first (low addressed byte) of the two byte
14551 record is called Master, and the second byte is called Slave.
14553 The left most (most significant bit is called Control for each byte, and
14554 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
14555 (least significant) bit.
14557 On a big-endian machine, we can write the following representation clause
14559 @smallexample @c ada
14560 type Data is record
14561 Master_Control : Bit;
14569 Slave_Control : Bit;
14579 for Data use record
14580 Master_Control at 0 range 0 .. 0;
14581 Master_V1 at 0 range 1 .. 1;
14582 Master_V2 at 0 range 2 .. 2;
14583 Master_V3 at 0 range 3 .. 3;
14584 Master_V4 at 0 range 4 .. 4;
14585 Master_V5 at 0 range 5 .. 5;
14586 Master_V6 at 0 range 6 .. 6;
14587 Master_V7 at 0 range 7 .. 7;
14588 Slave_Control at 1 range 0 .. 0;
14589 Slave_V1 at 1 range 1 .. 1;
14590 Slave_V2 at 1 range 2 .. 2;
14591 Slave_V3 at 1 range 3 .. 3;
14592 Slave_V4 at 1 range 4 .. 4;
14593 Slave_V5 at 1 range 5 .. 5;
14594 Slave_V6 at 1 range 6 .. 6;
14595 Slave_V7 at 1 range 7 .. 7;
14600 Now if we move this to a little endian machine, then the bit ordering within
14601 the byte is backwards, so we have to rewrite the record rep clause as:
14603 @smallexample @c ada
14604 for Data use record
14605 Master_Control at 0 range 7 .. 7;
14606 Master_V1 at 0 range 6 .. 6;
14607 Master_V2 at 0 range 5 .. 5;
14608 Master_V3 at 0 range 4 .. 4;
14609 Master_V4 at 0 range 3 .. 3;
14610 Master_V5 at 0 range 2 .. 2;
14611 Master_V6 at 0 range 1 .. 1;
14612 Master_V7 at 0 range 0 .. 0;
14613 Slave_Control at 1 range 7 .. 7;
14614 Slave_V1 at 1 range 6 .. 6;
14615 Slave_V2 at 1 range 5 .. 5;
14616 Slave_V3 at 1 range 4 .. 4;
14617 Slave_V4 at 1 range 3 .. 3;
14618 Slave_V5 at 1 range 2 .. 2;
14619 Slave_V6 at 1 range 1 .. 1;
14620 Slave_V7 at 1 range 0 .. 0;
14625 It is a nuisance to have to rewrite the clause, especially if
14626 the code has to be maintained on both machines. However,
14627 this is a case that we can handle with the
14628 @code{Bit_Order} attribute if it is implemented.
14629 Note that the implementation is not required on byte addressed
14630 machines, but it is indeed implemented in GNAT.
14631 This means that we can simply use the
14632 first record clause, together with the declaration
14634 @smallexample @c ada
14635 for Data'Bit_Order use High_Order_First;
14639 and the effect is what is desired, namely the layout is exactly the same,
14640 independent of whether the code is compiled on a big-endian or little-endian
14643 The important point to understand is that byte ordering is not affected.
14644 A @code{Bit_Order} attribute definition never affects which byte a field
14645 ends up in, only where it ends up in that byte.
14646 To make this clear, let us rewrite the record rep clause of the previous
14649 @smallexample @c ada
14650 for Data'Bit_Order use High_Order_First;
14651 for Data use record
14652 Master_Control at 0 range 0 .. 0;
14653 Master_V1 at 0 range 1 .. 1;
14654 Master_V2 at 0 range 2 .. 2;
14655 Master_V3 at 0 range 3 .. 3;
14656 Master_V4 at 0 range 4 .. 4;
14657 Master_V5 at 0 range 5 .. 5;
14658 Master_V6 at 0 range 6 .. 6;
14659 Master_V7 at 0 range 7 .. 7;
14660 Slave_Control at 0 range 8 .. 8;
14661 Slave_V1 at 0 range 9 .. 9;
14662 Slave_V2 at 0 range 10 .. 10;
14663 Slave_V3 at 0 range 11 .. 11;
14664 Slave_V4 at 0 range 12 .. 12;
14665 Slave_V5 at 0 range 13 .. 13;
14666 Slave_V6 at 0 range 14 .. 14;
14667 Slave_V7 at 0 range 15 .. 15;
14672 This is exactly equivalent to saying (a repeat of the first example):
14674 @smallexample @c ada
14675 for Data'Bit_Order use High_Order_First;
14676 for Data use record
14677 Master_Control at 0 range 0 .. 0;
14678 Master_V1 at 0 range 1 .. 1;
14679 Master_V2 at 0 range 2 .. 2;
14680 Master_V3 at 0 range 3 .. 3;
14681 Master_V4 at 0 range 4 .. 4;
14682 Master_V5 at 0 range 5 .. 5;
14683 Master_V6 at 0 range 6 .. 6;
14684 Master_V7 at 0 range 7 .. 7;
14685 Slave_Control at 1 range 0 .. 0;
14686 Slave_V1 at 1 range 1 .. 1;
14687 Slave_V2 at 1 range 2 .. 2;
14688 Slave_V3 at 1 range 3 .. 3;
14689 Slave_V4 at 1 range 4 .. 4;
14690 Slave_V5 at 1 range 5 .. 5;
14691 Slave_V6 at 1 range 6 .. 6;
14692 Slave_V7 at 1 range 7 .. 7;
14697 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
14698 field. The storage place attributes are obtained by normalizing the
14699 values given so that the @code{First_Bit} value is less than 8. After
14700 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
14701 we specified in the other case.
14703 Now one might expect that the @code{Bit_Order} attribute might affect
14704 bit numbering within the entire record component (two bytes in this
14705 case, thus affecting which byte fields end up in), but that is not
14706 the way this feature is defined, it only affects numbering of bits,
14707 not which byte they end up in.
14709 Consequently it never makes sense to specify a starting bit number
14710 greater than 7 (for a byte addressable field) if an attribute
14711 definition for @code{Bit_Order} has been given, and indeed it
14712 may be actively confusing to specify such a value, so the compiler
14713 generates a warning for such usage.
14715 If you do need to control byte ordering then appropriate conditional
14716 values must be used. If in our example, the slave byte came first on
14717 some machines we might write:
14719 @smallexample @c ada
14720 Master_Byte_First constant Boolean := @dots{};
14722 Master_Byte : constant Natural :=
14723 1 - Boolean'Pos (Master_Byte_First);
14724 Slave_Byte : constant Natural :=
14725 Boolean'Pos (Master_Byte_First);
14727 for Data'Bit_Order use High_Order_First;
14728 for Data use record
14729 Master_Control at Master_Byte range 0 .. 0;
14730 Master_V1 at Master_Byte range 1 .. 1;
14731 Master_V2 at Master_Byte range 2 .. 2;
14732 Master_V3 at Master_Byte range 3 .. 3;
14733 Master_V4 at Master_Byte range 4 .. 4;
14734 Master_V5 at Master_Byte range 5 .. 5;
14735 Master_V6 at Master_Byte range 6 .. 6;
14736 Master_V7 at Master_Byte range 7 .. 7;
14737 Slave_Control at Slave_Byte range 0 .. 0;
14738 Slave_V1 at Slave_Byte range 1 .. 1;
14739 Slave_V2 at Slave_Byte range 2 .. 2;
14740 Slave_V3 at Slave_Byte range 3 .. 3;
14741 Slave_V4 at Slave_Byte range 4 .. 4;
14742 Slave_V5 at Slave_Byte range 5 .. 5;
14743 Slave_V6 at Slave_Byte range 6 .. 6;
14744 Slave_V7 at Slave_Byte range 7 .. 7;
14749 Now to switch between machines, all that is necessary is
14750 to set the boolean constant @code{Master_Byte_First} in
14751 an appropriate manner.
14753 @node Pragma Pack for Arrays
14754 @section Pragma Pack for Arrays
14755 @cindex Pragma Pack (for arrays)
14758 Pragma @code{Pack} applied to an array has no effect unless the component type
14759 is packable. For a component type to be packable, it must be one of the
14766 Any type whose size is specified with a size clause
14768 Any packed array type with a static size
14770 Any record type padded because of its default alignment
14774 For all these cases, if the component subtype size is in the range
14775 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14776 component size were specified giving the component subtype size.
14777 For example if we have:
14779 @smallexample @c ada
14780 type r is range 0 .. 17;
14782 type ar is array (1 .. 8) of r;
14787 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14788 and the size of the array @code{ar} will be exactly 40 bits.
14790 Note that in some cases this rather fierce approach to packing can produce
14791 unexpected effects. For example, in Ada 95 and Ada 2005,
14792 subtype @code{Natural} typically has a size of 31, meaning that if you
14793 pack an array of @code{Natural}, you get 31-bit
14794 close packing, which saves a few bits, but results in far less efficient
14795 access. Since many other Ada compilers will ignore such a packing request,
14796 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14797 might not be what is intended. You can easily remove this warning by
14798 using an explicit @code{Component_Size} setting instead, which never generates
14799 a warning, since the intention of the programmer is clear in this case.
14801 GNAT treats packed arrays in one of two ways. If the size of the array is
14802 known at compile time and is less than 64 bits, then internally the array
14803 is represented as a single modular type, of exactly the appropriate number
14804 of bits. If the length is greater than 63 bits, or is not known at compile
14805 time, then the packed array is represented as an array of bytes, and the
14806 length is always a multiple of 8 bits.
14808 Note that to represent a packed array as a modular type, the alignment must
14809 be suitable for the modular type involved. For example, on typical machines
14810 a 32-bit packed array will be represented by a 32-bit modular integer with
14811 an alignment of four bytes. If you explicitly override the default alignment
14812 with an alignment clause that is too small, the modular representation
14813 cannot be used. For example, consider the following set of declarations:
14815 @smallexample @c ada
14816 type R is range 1 .. 3;
14817 type S is array (1 .. 31) of R;
14818 for S'Component_Size use 2;
14820 for S'Alignment use 1;
14824 If the alignment clause were not present, then a 62-bit modular
14825 representation would be chosen (typically with an alignment of 4 or 8
14826 bytes depending on the target). But the default alignment is overridden
14827 with the explicit alignment clause. This means that the modular
14828 representation cannot be used, and instead the array of bytes
14829 representation must be used, meaning that the length must be a multiple
14830 of 8. Thus the above set of declarations will result in a diagnostic
14831 rejecting the size clause and noting that the minimum size allowed is 64.
14833 @cindex Pragma Pack (for type Natural)
14834 @cindex Pragma Pack warning
14836 One special case that is worth noting occurs when the base type of the
14837 component size is 8/16/32 and the subtype is one bit less. Notably this
14838 occurs with subtype @code{Natural}. Consider:
14840 @smallexample @c ada
14841 type Arr is array (1 .. 32) of Natural;
14846 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14847 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14848 Ada 83 compilers did not attempt 31 bit packing.
14850 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14851 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14852 substantial unintended performance penalty when porting legacy Ada 83 code.
14853 To help prevent this, GNAT generates a warning in such cases. If you really
14854 want 31 bit packing in a case like this, you can set the component size
14857 @smallexample @c ada
14858 type Arr is array (1 .. 32) of Natural;
14859 for Arr'Component_Size use 31;
14863 Here 31-bit packing is achieved as required, and no warning is generated,
14864 since in this case the programmer intention is clear.
14866 @node Pragma Pack for Records
14867 @section Pragma Pack for Records
14868 @cindex Pragma Pack (for records)
14871 Pragma @code{Pack} applied to a record will pack the components to reduce
14872 wasted space from alignment gaps and by reducing the amount of space
14873 taken by components. We distinguish between @emph{packable} components and
14874 @emph{non-packable} components.
14875 Components of the following types are considered packable:
14878 All primitive types are packable.
14881 Small packed arrays, whose size does not exceed 64 bits, and where the
14882 size is statically known at compile time, are represented internally
14883 as modular integers, and so they are also packable.
14888 All packable components occupy the exact number of bits corresponding to
14889 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14890 can start on an arbitrary bit boundary.
14892 All other types are non-packable, they occupy an integral number of
14894 are placed at a boundary corresponding to their alignment requirements.
14896 For example, consider the record
14898 @smallexample @c ada
14899 type Rb1 is array (1 .. 13) of Boolean;
14902 type Rb2 is array (1 .. 65) of Boolean;
14917 The representation for the record x2 is as follows:
14919 @smallexample @c ada
14920 for x2'Size use 224;
14922 l1 at 0 range 0 .. 0;
14923 l2 at 0 range 1 .. 64;
14924 l3 at 12 range 0 .. 31;
14925 l4 at 16 range 0 .. 0;
14926 l5 at 16 range 1 .. 13;
14927 l6 at 18 range 0 .. 71;
14932 Studying this example, we see that the packable fields @code{l1}
14934 of length equal to their sizes, and placed at specific bit boundaries (and
14935 not byte boundaries) to
14936 eliminate padding. But @code{l3} is of a non-packable float type, so
14937 it is on the next appropriate alignment boundary.
14939 The next two fields are fully packable, so @code{l4} and @code{l5} are
14940 minimally packed with no gaps. However, type @code{Rb2} is a packed
14941 array that is longer than 64 bits, so it is itself non-packable. Thus
14942 the @code{l6} field is aligned to the next byte boundary, and takes an
14943 integral number of bytes, i.e.@: 72 bits.
14945 @node Record Representation Clauses
14946 @section Record Representation Clauses
14947 @cindex Record Representation Clause
14950 Record representation clauses may be given for all record types, including
14951 types obtained by record extension. Component clauses are allowed for any
14952 static component. The restrictions on component clauses depend on the type
14955 @cindex Component Clause
14956 For all components of an elementary type, the only restriction on component
14957 clauses is that the size must be at least the 'Size value of the type
14958 (actually the Value_Size). There are no restrictions due to alignment,
14959 and such components may freely cross storage boundaries.
14961 Packed arrays with a size up to and including 64 bits are represented
14962 internally using a modular type with the appropriate number of bits, and
14963 thus the same lack of restriction applies. For example, if you declare:
14965 @smallexample @c ada
14966 type R is array (1 .. 49) of Boolean;
14972 then a component clause for a component of type R may start on any
14973 specified bit boundary, and may specify a value of 49 bits or greater.
14975 For packed bit arrays that are longer than 64 bits, there are two
14976 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14977 including the important case of single bits or boolean values, then
14978 there are no limitations on placement of such components, and they
14979 may start and end at arbitrary bit boundaries.
14981 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14982 an array of this type longer than 64 bits must always be placed on
14983 on a storage unit (byte) boundary and occupy an integral number
14984 of storage units (bytes). Any component clause that does not
14985 meet this requirement will be rejected.
14987 Any aliased component, or component of an aliased type, must
14988 have its normal alignment and size. A component clause that
14989 does not meet this requirement will be rejected.
14991 The tag field of a tagged type always occupies an address sized field at
14992 the start of the record. No component clause may attempt to overlay this
14993 tag. When a tagged type appears as a component, the tag field must have
14996 In the case of a record extension T1, of a type T, no component clause applied
14997 to the type T1 can specify a storage location that would overlap the first
14998 T'Size bytes of the record.
15000 For all other component types, including non-bit-packed arrays,
15001 the component can be placed at an arbitrary bit boundary,
15002 so for example, the following is permitted:
15004 @smallexample @c ada
15005 type R is array (1 .. 10) of Boolean;
15014 G at 0 range 0 .. 0;
15015 H at 0 range 1 .. 1;
15016 L at 0 range 2 .. 81;
15017 R at 0 range 82 .. 161;
15022 Note: the above rules apply to recent releases of GNAT 5.
15023 In GNAT 3, there are more severe restrictions on larger components.
15024 For non-primitive types, including packed arrays with a size greater than
15025 64 bits, component clauses must respect the alignment requirement of the
15026 type, in particular, always starting on a byte boundary, and the length
15027 must be a multiple of the storage unit.
15029 @node Enumeration Clauses
15030 @section Enumeration Clauses
15032 The only restriction on enumeration clauses is that the range of values
15033 must be representable. For the signed case, if one or more of the
15034 representation values are negative, all values must be in the range:
15036 @smallexample @c ada
15037 System.Min_Int .. System.Max_Int
15041 For the unsigned case, where all values are nonnegative, the values must
15044 @smallexample @c ada
15045 0 .. System.Max_Binary_Modulus;
15049 A @emph{confirming} representation clause is one in which the values range
15050 from 0 in sequence, i.e.@: a clause that confirms the default representation
15051 for an enumeration type.
15052 Such a confirming representation
15053 is permitted by these rules, and is specially recognized by the compiler so
15054 that no extra overhead results from the use of such a clause.
15056 If an array has an index type which is an enumeration type to which an
15057 enumeration clause has been applied, then the array is stored in a compact
15058 manner. Consider the declarations:
15060 @smallexample @c ada
15061 type r is (A, B, C);
15062 for r use (A => 1, B => 5, C => 10);
15063 type t is array (r) of Character;
15067 The array type t corresponds to a vector with exactly three elements and
15068 has a default size equal to @code{3*Character'Size}. This ensures efficient
15069 use of space, but means that accesses to elements of the array will incur
15070 the overhead of converting representation values to the corresponding
15071 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
15073 @node Address Clauses
15074 @section Address Clauses
15075 @cindex Address Clause
15077 The reference manual allows a general restriction on representation clauses,
15078 as found in RM 13.1(22):
15081 An implementation need not support representation
15082 items containing nonstatic expressions, except that
15083 an implementation should support a representation item
15084 for a given entity if each nonstatic expression in the
15085 representation item is a name that statically denotes
15086 a constant declared before the entity.
15090 In practice this is applicable only to address clauses, since this is the
15091 only case in which a non-static expression is permitted by the syntax. As
15092 the AARM notes in sections 13.1 (22.a-22.h):
15095 22.a Reason: This is to avoid the following sort of thing:
15097 22.b X : Integer := F(@dots{});
15098 Y : Address := G(@dots{});
15099 for X'Address use Y;
15101 22.c In the above, we have to evaluate the
15102 initialization expression for X before we
15103 know where to put the result. This seems
15104 like an unreasonable implementation burden.
15106 22.d The above code should instead be written
15109 22.e Y : constant Address := G(@dots{});
15110 X : Integer := F(@dots{});
15111 for X'Address use Y;
15113 22.f This allows the expression ``Y'' to be safely
15114 evaluated before X is created.
15116 22.g The constant could be a formal parameter of mode in.
15118 22.h An implementation can support other nonstatic
15119 expressions if it wants to. Expressions of type
15120 Address are hardly ever static, but their value
15121 might be known at compile time anyway in many
15126 GNAT does indeed permit many additional cases of non-static expressions. In
15127 particular, if the type involved is elementary there are no restrictions
15128 (since in this case, holding a temporary copy of the initialization value,
15129 if one is present, is inexpensive). In addition, if there is no implicit or
15130 explicit initialization, then there are no restrictions. GNAT will reject
15131 only the case where all three of these conditions hold:
15136 The type of the item is non-elementary (e.g.@: a record or array).
15139 There is explicit or implicit initialization required for the object.
15140 Note that access values are always implicitly initialized.
15143 The address value is non-static. Here GNAT is more permissive than the
15144 RM, and allows the address value to be the address of a previously declared
15145 stand-alone variable, as long as it does not itself have an address clause.
15147 @smallexample @c ada
15148 Anchor : Some_Initialized_Type;
15149 Overlay : Some_Initialized_Type;
15150 for Overlay'Address use Anchor'Address;
15154 However, the prefix of the address clause cannot be an array component, or
15155 a component of a discriminated record.
15160 As noted above in section 22.h, address values are typically non-static. In
15161 particular the To_Address function, even if applied to a literal value, is
15162 a non-static function call. To avoid this minor annoyance, GNAT provides
15163 the implementation defined attribute 'To_Address. The following two
15164 expressions have identical values:
15168 @smallexample @c ada
15169 To_Address (16#1234_0000#)
15170 System'To_Address (16#1234_0000#);
15174 except that the second form is considered to be a static expression, and
15175 thus when used as an address clause value is always permitted.
15178 Additionally, GNAT treats as static an address clause that is an
15179 unchecked_conversion of a static integer value. This simplifies the porting
15180 of legacy code, and provides a portable equivalent to the GNAT attribute
15183 Another issue with address clauses is the interaction with alignment
15184 requirements. When an address clause is given for an object, the address
15185 value must be consistent with the alignment of the object (which is usually
15186 the same as the alignment of the type of the object). If an address clause
15187 is given that specifies an inappropriately aligned address value, then the
15188 program execution is erroneous.
15190 Since this source of erroneous behavior can have unfortunate effects, GNAT
15191 checks (at compile time if possible, generating a warning, or at execution
15192 time with a run-time check) that the alignment is appropriate. If the
15193 run-time check fails, then @code{Program_Error} is raised. This run-time
15194 check is suppressed if range checks are suppressed, or if the special GNAT
15195 check Alignment_Check is suppressed, or if
15196 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
15198 Finally, GNAT does not permit overlaying of objects of controlled types or
15199 composite types containing a controlled component. In most cases, the compiler
15200 can detect an attempt at such overlays and will generate a warning at compile
15201 time and a Program_Error exception at run time.
15204 An address clause cannot be given for an exported object. More
15205 understandably the real restriction is that objects with an address
15206 clause cannot be exported. This is because such variables are not
15207 defined by the Ada program, so there is no external object to export.
15210 It is permissible to give an address clause and a pragma Import for the
15211 same object. In this case, the variable is not really defined by the
15212 Ada program, so there is no external symbol to be linked. The link name
15213 and the external name are ignored in this case. The reason that we allow this
15214 combination is that it provides a useful idiom to avoid unwanted
15215 initializations on objects with address clauses.
15217 When an address clause is given for an object that has implicit or
15218 explicit initialization, then by default initialization takes place. This
15219 means that the effect of the object declaration is to overwrite the
15220 memory at the specified address. This is almost always not what the
15221 programmer wants, so GNAT will output a warning:
15231 for Ext'Address use System'To_Address (16#1234_1234#);
15233 >>> warning: implicit initialization of "Ext" may
15234 modify overlaid storage
15235 >>> warning: use pragma Import for "Ext" to suppress
15236 initialization (RM B(24))
15242 As indicated by the warning message, the solution is to use a (dummy) pragma
15243 Import to suppress this initialization. The pragma tell the compiler that the
15244 object is declared and initialized elsewhere. The following package compiles
15245 without warnings (and the initialization is suppressed):
15247 @smallexample @c ada
15255 for Ext'Address use System'To_Address (16#1234_1234#);
15256 pragma Import (Ada, Ext);
15261 A final issue with address clauses involves their use for overlaying
15262 variables, as in the following example:
15263 @cindex Overlaying of objects
15265 @smallexample @c ada
15268 for B'Address use A'Address;
15272 or alternatively, using the form recommended by the RM:
15274 @smallexample @c ada
15276 Addr : constant Address := A'Address;
15278 for B'Address use Addr;
15282 In both of these cases, @code{A}
15283 and @code{B} become aliased to one another via the
15284 address clause. This use of address clauses to overlay
15285 variables, achieving an effect similar to unchecked
15286 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
15287 the effect is implementation defined. Furthermore, the
15288 Ada RM specifically recommends that in a situation
15289 like this, @code{B} should be subject to the following
15290 implementation advice (RM 13.3(19)):
15293 19 If the Address of an object is specified, or it is imported
15294 or exported, then the implementation should not perform
15295 optimizations based on assumptions of no aliases.
15299 GNAT follows this recommendation, and goes further by also applying
15300 this recommendation to the overlaid variable (@code{A}
15301 in the above example) in this case. This means that the overlay
15302 works "as expected", in that a modification to one of the variables
15303 will affect the value of the other.
15305 @node Effect of Convention on Representation
15306 @section Effect of Convention on Representation
15307 @cindex Convention, effect on representation
15310 Normally the specification of a foreign language convention for a type or
15311 an object has no effect on the chosen representation. In particular, the
15312 representation chosen for data in GNAT generally meets the standard system
15313 conventions, and for example records are laid out in a manner that is
15314 consistent with C@. This means that specifying convention C (for example)
15317 There are four exceptions to this general rule:
15321 @item Convention Fortran and array subtypes
15322 If pragma Convention Fortran is specified for an array subtype, then in
15323 accordance with the implementation advice in section 3.6.2(11) of the
15324 Ada Reference Manual, the array will be stored in a Fortran-compatible
15325 column-major manner, instead of the normal default row-major order.
15327 @item Convention C and enumeration types
15328 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
15329 to accommodate all values of the type. For example, for the enumeration
15332 @smallexample @c ada
15333 type Color is (Red, Green, Blue);
15337 8 bits is sufficient to store all values of the type, so by default, objects
15338 of type @code{Color} will be represented using 8 bits. However, normal C
15339 convention is to use 32 bits for all enum values in C, since enum values
15340 are essentially of type int. If pragma @code{Convention C} is specified for an
15341 Ada enumeration type, then the size is modified as necessary (usually to
15342 32 bits) to be consistent with the C convention for enum values.
15344 Note that this treatment applies only to types. If Convention C is given for
15345 an enumeration object, where the enumeration type is not Convention C, then
15346 Object_Size bits are allocated. For example, for a normal enumeration type,
15347 with less than 256 elements, only 8 bits will be allocated for the object.
15348 Since this may be a surprise in terms of what C expects, GNAT will issue a
15349 warning in this situation. The warning can be suppressed by giving an explicit
15350 size clause specifying the desired size.
15352 @item Convention C/Fortran and Boolean types
15353 In C, the usual convention for boolean values, that is values used for
15354 conditions, is that zero represents false, and nonzero values represent
15355 true. In Ada, the normal convention is that two specific values, typically
15356 0/1, are used to represent false/true respectively.
15358 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
15359 value represents true).
15361 To accommodate the Fortran and C conventions, if a pragma Convention specifies
15362 C or Fortran convention for a derived Boolean, as in the following example:
15364 @smallexample @c ada
15365 type C_Switch is new Boolean;
15366 pragma Convention (C, C_Switch);
15370 then the GNAT generated code will treat any nonzero value as true. For truth
15371 values generated by GNAT, the conventional value 1 will be used for True, but
15372 when one of these values is read, any nonzero value is treated as True.
15374 @item Access types on OpenVMS
15375 For 64-bit OpenVMS systems, access types (other than those for unconstrained
15376 arrays) are 64-bits long. An exception to this rule is for the case of
15377 C-convention access types where there is no explicit size clause present (or
15378 inherited for derived types). In this case, GNAT chooses to make these
15379 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
15380 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
15384 @node Determining the Representations chosen by GNAT
15385 @section Determining the Representations chosen by GNAT
15386 @cindex Representation, determination of
15387 @cindex @option{-gnatR} switch
15390 Although the descriptions in this section are intended to be complete, it is
15391 often easier to simply experiment to see what GNAT accepts and what the
15392 effect is on the layout of types and objects.
15394 As required by the Ada RM, if a representation clause is not accepted, then
15395 it must be rejected as illegal by the compiler. However, when a
15396 representation clause or pragma is accepted, there can still be questions
15397 of what the compiler actually does. For example, if a partial record
15398 representation clause specifies the location of some components and not
15399 others, then where are the non-specified components placed? Or if pragma
15400 @code{Pack} is used on a record, then exactly where are the resulting
15401 fields placed? The section on pragma @code{Pack} in this chapter can be
15402 used to answer the second question, but it is often easier to just see
15403 what the compiler does.
15405 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
15406 with this option, then the compiler will output information on the actual
15407 representations chosen, in a format similar to source representation
15408 clauses. For example, if we compile the package:
15410 @smallexample @c ada
15412 type r (x : boolean) is tagged record
15414 when True => S : String (1 .. 100);
15415 when False => null;
15419 type r2 is new r (false) with record
15424 y2 at 16 range 0 .. 31;
15431 type x1 is array (1 .. 10) of x;
15432 for x1'component_size use 11;
15434 type ia is access integer;
15436 type Rb1 is array (1 .. 13) of Boolean;
15439 type Rb2 is array (1 .. 65) of Boolean;
15455 using the switch @option{-gnatR} we obtain the following output:
15458 Representation information for unit q
15459 -------------------------------------
15462 for r'Alignment use 4;
15464 x at 4 range 0 .. 7;
15465 _tag at 0 range 0 .. 31;
15466 s at 5 range 0 .. 799;
15469 for r2'Size use 160;
15470 for r2'Alignment use 4;
15472 x at 4 range 0 .. 7;
15473 _tag at 0 range 0 .. 31;
15474 _parent at 0 range 0 .. 63;
15475 y2 at 16 range 0 .. 31;
15479 for x'Alignment use 1;
15481 y at 0 range 0 .. 7;
15484 for x1'Size use 112;
15485 for x1'Alignment use 1;
15486 for x1'Component_Size use 11;
15488 for rb1'Size use 13;
15489 for rb1'Alignment use 2;
15490 for rb1'Component_Size use 1;
15492 for rb2'Size use 72;
15493 for rb2'Alignment use 1;
15494 for rb2'Component_Size use 1;
15496 for x2'Size use 224;
15497 for x2'Alignment use 4;
15499 l1 at 0 range 0 .. 0;
15500 l2 at 0 range 1 .. 64;
15501 l3 at 12 range 0 .. 31;
15502 l4 at 16 range 0 .. 0;
15503 l5 at 16 range 1 .. 13;
15504 l6 at 18 range 0 .. 71;
15509 The Size values are actually the Object_Size, i.e.@: the default size that
15510 will be allocated for objects of the type.
15511 The ?? size for type r indicates that we have a variant record, and the
15512 actual size of objects will depend on the discriminant value.
15514 The Alignment values show the actual alignment chosen by the compiler
15515 for each record or array type.
15517 The record representation clause for type r shows where all fields
15518 are placed, including the compiler generated tag field (whose location
15519 cannot be controlled by the programmer).
15521 The record representation clause for the type extension r2 shows all the
15522 fields present, including the parent field, which is a copy of the fields
15523 of the parent type of r2, i.e.@: r1.
15525 The component size and size clauses for types rb1 and rb2 show
15526 the exact effect of pragma @code{Pack} on these arrays, and the record
15527 representation clause for type x2 shows how pragma @code{Pack} affects
15530 In some cases, it may be useful to cut and paste the representation clauses
15531 generated by the compiler into the original source to fix and guarantee
15532 the actual representation to be used.
15534 @node Standard Library Routines
15535 @chapter Standard Library Routines
15538 The Ada Reference Manual contains in Annex A a full description of an
15539 extensive set of standard library routines that can be used in any Ada
15540 program, and which must be provided by all Ada compilers. They are
15541 analogous to the standard C library used by C programs.
15543 GNAT implements all of the facilities described in annex A, and for most
15544 purposes the description in the Ada Reference Manual, or appropriate Ada
15545 text book, will be sufficient for making use of these facilities.
15547 In the case of the input-output facilities,
15548 @xref{The Implementation of Standard I/O},
15549 gives details on exactly how GNAT interfaces to the
15550 file system. For the remaining packages, the Ada Reference Manual
15551 should be sufficient. The following is a list of the packages included,
15552 together with a brief description of the functionality that is provided.
15554 For completeness, references are included to other predefined library
15555 routines defined in other sections of the Ada Reference Manual (these are
15556 cross-indexed from Annex A).
15560 This is a parent package for all the standard library packages. It is
15561 usually included implicitly in your program, and itself contains no
15562 useful data or routines.
15564 @item Ada.Calendar (9.6)
15565 @code{Calendar} provides time of day access, and routines for
15566 manipulating times and durations.
15568 @item Ada.Characters (A.3.1)
15569 This is a dummy parent package that contains no useful entities
15571 @item Ada.Characters.Handling (A.3.2)
15572 This package provides some basic character handling capabilities,
15573 including classification functions for classes of characters (e.g.@: test
15574 for letters, or digits).
15576 @item Ada.Characters.Latin_1 (A.3.3)
15577 This package includes a complete set of definitions of the characters
15578 that appear in type CHARACTER@. It is useful for writing programs that
15579 will run in international environments. For example, if you want an
15580 upper case E with an acute accent in a string, it is often better to use
15581 the definition of @code{UC_E_Acute} in this package. Then your program
15582 will print in an understandable manner even if your environment does not
15583 support these extended characters.
15585 @item Ada.Command_Line (A.15)
15586 This package provides access to the command line parameters and the name
15587 of the current program (analogous to the use of @code{argc} and @code{argv}
15588 in C), and also allows the exit status for the program to be set in a
15589 system-independent manner.
15591 @item Ada.Decimal (F.2)
15592 This package provides constants describing the range of decimal numbers
15593 implemented, and also a decimal divide routine (analogous to the COBOL
15594 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
15596 @item Ada.Direct_IO (A.8.4)
15597 This package provides input-output using a model of a set of records of
15598 fixed-length, containing an arbitrary definite Ada type, indexed by an
15599 integer record number.
15601 @item Ada.Dynamic_Priorities (D.5)
15602 This package allows the priorities of a task to be adjusted dynamically
15603 as the task is running.
15605 @item Ada.Exceptions (11.4.1)
15606 This package provides additional information on exceptions, and also
15607 contains facilities for treating exceptions as data objects, and raising
15608 exceptions with associated messages.
15610 @item Ada.Finalization (7.6)
15611 This package contains the declarations and subprograms to support the
15612 use of controlled types, providing for automatic initialization and
15613 finalization (analogous to the constructors and destructors of C++)
15615 @item Ada.Interrupts (C.3.2)
15616 This package provides facilities for interfacing to interrupts, which
15617 includes the set of signals or conditions that can be raised and
15618 recognized as interrupts.
15620 @item Ada.Interrupts.Names (C.3.2)
15621 This package provides the set of interrupt names (actually signal
15622 or condition names) that can be handled by GNAT@.
15624 @item Ada.IO_Exceptions (A.13)
15625 This package defines the set of exceptions that can be raised by use of
15626 the standard IO packages.
15629 This package contains some standard constants and exceptions used
15630 throughout the numerics packages. Note that the constants pi and e are
15631 defined here, and it is better to use these definitions than rolling
15634 @item Ada.Numerics.Complex_Elementary_Functions
15635 Provides the implementation of standard elementary functions (such as
15636 log and trigonometric functions) operating on complex numbers using the
15637 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
15638 created by the package @code{Numerics.Complex_Types}.
15640 @item Ada.Numerics.Complex_Types
15641 This is a predefined instantiation of
15642 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
15643 build the type @code{Complex} and @code{Imaginary}.
15645 @item Ada.Numerics.Discrete_Random
15646 This generic package provides a random number generator suitable for generating
15647 uniformly distributed values of a specified discrete subtype.
15649 @item Ada.Numerics.Float_Random
15650 This package provides a random number generator suitable for generating
15651 uniformly distributed floating point values in the unit interval.
15653 @item Ada.Numerics.Generic_Complex_Elementary_Functions
15654 This is a generic version of the package that provides the
15655 implementation of standard elementary functions (such as log and
15656 trigonometric functions) for an arbitrary complex type.
15658 The following predefined instantiations of this package are provided:
15662 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
15664 @code{Ada.Numerics.Complex_Elementary_Functions}
15666 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
15669 @item Ada.Numerics.Generic_Complex_Types
15670 This is a generic package that allows the creation of complex types,
15671 with associated complex arithmetic operations.
15673 The following predefined instantiations of this package exist
15676 @code{Ada.Numerics.Short_Complex_Complex_Types}
15678 @code{Ada.Numerics.Complex_Complex_Types}
15680 @code{Ada.Numerics.Long_Complex_Complex_Types}
15683 @item Ada.Numerics.Generic_Elementary_Functions
15684 This is a generic package that provides the implementation of standard
15685 elementary functions (such as log an trigonometric functions) for an
15686 arbitrary float type.
15688 The following predefined instantiations of this package exist
15692 @code{Ada.Numerics.Short_Elementary_Functions}
15694 @code{Ada.Numerics.Elementary_Functions}
15696 @code{Ada.Numerics.Long_Elementary_Functions}
15699 @item Ada.Real_Time (D.8)
15700 This package provides facilities similar to those of @code{Calendar}, but
15701 operating with a finer clock suitable for real time control. Note that
15702 annex D requires that there be no backward clock jumps, and GNAT generally
15703 guarantees this behavior, but of course if the external clock on which
15704 the GNAT runtime depends is deliberately reset by some external event,
15705 then such a backward jump may occur.
15707 @item Ada.Sequential_IO (A.8.1)
15708 This package provides input-output facilities for sequential files,
15709 which can contain a sequence of values of a single type, which can be
15710 any Ada type, including indefinite (unconstrained) types.
15712 @item Ada.Storage_IO (A.9)
15713 This package provides a facility for mapping arbitrary Ada types to and
15714 from a storage buffer. It is primarily intended for the creation of new
15717 @item Ada.Streams (13.13.1)
15718 This is a generic package that provides the basic support for the
15719 concept of streams as used by the stream attributes (@code{Input},
15720 @code{Output}, @code{Read} and @code{Write}).
15722 @item Ada.Streams.Stream_IO (A.12.1)
15723 This package is a specialization of the type @code{Streams} defined in
15724 package @code{Streams} together with a set of operations providing
15725 Stream_IO capability. The Stream_IO model permits both random and
15726 sequential access to a file which can contain an arbitrary set of values
15727 of one or more Ada types.
15729 @item Ada.Strings (A.4.1)
15730 This package provides some basic constants used by the string handling
15733 @item Ada.Strings.Bounded (A.4.4)
15734 This package provides facilities for handling variable length
15735 strings. The bounded model requires a maximum length. It is thus
15736 somewhat more limited than the unbounded model, but avoids the use of
15737 dynamic allocation or finalization.
15739 @item Ada.Strings.Fixed (A.4.3)
15740 This package provides facilities for handling fixed length strings.
15742 @item Ada.Strings.Maps (A.4.2)
15743 This package provides facilities for handling character mappings and
15744 arbitrarily defined subsets of characters. For instance it is useful in
15745 defining specialized translation tables.
15747 @item Ada.Strings.Maps.Constants (A.4.6)
15748 This package provides a standard set of predefined mappings and
15749 predefined character sets. For example, the standard upper to lower case
15750 conversion table is found in this package. Note that upper to lower case
15751 conversion is non-trivial if you want to take the entire set of
15752 characters, including extended characters like E with an acute accent,
15753 into account. You should use the mappings in this package (rather than
15754 adding 32 yourself) to do case mappings.
15756 @item Ada.Strings.Unbounded (A.4.5)
15757 This package provides facilities for handling variable length
15758 strings. The unbounded model allows arbitrary length strings, but
15759 requires the use of dynamic allocation and finalization.
15761 @item Ada.Strings.Wide_Bounded (A.4.7)
15762 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15763 @itemx Ada.Strings.Wide_Maps (A.4.7)
15764 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15765 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15766 These packages provide analogous capabilities to the corresponding
15767 packages without @samp{Wide_} in the name, but operate with the types
15768 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15769 and @code{Character}.
15771 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15772 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15773 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15774 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15775 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15776 These packages provide analogous capabilities to the corresponding
15777 packages without @samp{Wide_} in the name, but operate with the types
15778 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15779 of @code{String} and @code{Character}.
15781 @item Ada.Synchronous_Task_Control (D.10)
15782 This package provides some standard facilities for controlling task
15783 communication in a synchronous manner.
15786 This package contains definitions for manipulation of the tags of tagged
15789 @item Ada.Task_Attributes
15790 This package provides the capability of associating arbitrary
15791 task-specific data with separate tasks.
15794 This package provides basic text input-output capabilities for
15795 character, string and numeric data. The subpackages of this
15796 package are listed next.
15798 @item Ada.Text_IO.Decimal_IO
15799 Provides input-output facilities for decimal fixed-point types
15801 @item Ada.Text_IO.Enumeration_IO
15802 Provides input-output facilities for enumeration types.
15804 @item Ada.Text_IO.Fixed_IO
15805 Provides input-output facilities for ordinary fixed-point types.
15807 @item Ada.Text_IO.Float_IO
15808 Provides input-output facilities for float types. The following
15809 predefined instantiations of this generic package are available:
15813 @code{Short_Float_Text_IO}
15815 @code{Float_Text_IO}
15817 @code{Long_Float_Text_IO}
15820 @item Ada.Text_IO.Integer_IO
15821 Provides input-output facilities for integer types. The following
15822 predefined instantiations of this generic package are available:
15825 @item Short_Short_Integer
15826 @code{Ada.Short_Short_Integer_Text_IO}
15827 @item Short_Integer
15828 @code{Ada.Short_Integer_Text_IO}
15830 @code{Ada.Integer_Text_IO}
15832 @code{Ada.Long_Integer_Text_IO}
15833 @item Long_Long_Integer
15834 @code{Ada.Long_Long_Integer_Text_IO}
15837 @item Ada.Text_IO.Modular_IO
15838 Provides input-output facilities for modular (unsigned) types
15840 @item Ada.Text_IO.Complex_IO (G.1.3)
15841 This package provides basic text input-output capabilities for complex
15844 @item Ada.Text_IO.Editing (F.3.3)
15845 This package contains routines for edited output, analogous to the use
15846 of pictures in COBOL@. The picture formats used by this package are a
15847 close copy of the facility in COBOL@.
15849 @item Ada.Text_IO.Text_Streams (A.12.2)
15850 This package provides a facility that allows Text_IO files to be treated
15851 as streams, so that the stream attributes can be used for writing
15852 arbitrary data, including binary data, to Text_IO files.
15854 @item Ada.Unchecked_Conversion (13.9)
15855 This generic package allows arbitrary conversion from one type to
15856 another of the same size, providing for breaking the type safety in
15857 special circumstances.
15859 If the types have the same Size (more accurately the same Value_Size),
15860 then the effect is simply to transfer the bits from the source to the
15861 target type without any modification. This usage is well defined, and
15862 for simple types whose representation is typically the same across
15863 all implementations, gives a portable method of performing such
15866 If the types do not have the same size, then the result is implementation
15867 defined, and thus may be non-portable. The following describes how GNAT
15868 handles such unchecked conversion cases.
15870 If the types are of different sizes, and are both discrete types, then
15871 the effect is of a normal type conversion without any constraint checking.
15872 In particular if the result type has a larger size, the result will be
15873 zero or sign extended. If the result type has a smaller size, the result
15874 will be truncated by ignoring high order bits.
15876 If the types are of different sizes, and are not both discrete types,
15877 then the conversion works as though pointers were created to the source
15878 and target, and the pointer value is converted. The effect is that bits
15879 are copied from successive low order storage units and bits of the source
15880 up to the length of the target type.
15882 A warning is issued if the lengths differ, since the effect in this
15883 case is implementation dependent, and the above behavior may not match
15884 that of some other compiler.
15886 A pointer to one type may be converted to a pointer to another type using
15887 unchecked conversion. The only case in which the effect is undefined is
15888 when one or both pointers are pointers to unconstrained array types. In
15889 this case, the bounds information may get incorrectly transferred, and in
15890 particular, GNAT uses double size pointers for such types, and it is
15891 meaningless to convert between such pointer types. GNAT will issue a
15892 warning if the alignment of the target designated type is more strict
15893 than the alignment of the source designated type (since the result may
15894 be unaligned in this case).
15896 A pointer other than a pointer to an unconstrained array type may be
15897 converted to and from System.Address. Such usage is common in Ada 83
15898 programs, but note that Ada.Address_To_Access_Conversions is the
15899 preferred method of performing such conversions in Ada 95 and Ada 2005.
15901 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15902 used in conjunction with pointers to unconstrained objects, since
15903 the bounds information cannot be handled correctly in this case.
15905 @item Ada.Unchecked_Deallocation (13.11.2)
15906 This generic package allows explicit freeing of storage previously
15907 allocated by use of an allocator.
15909 @item Ada.Wide_Text_IO (A.11)
15910 This package is similar to @code{Ada.Text_IO}, except that the external
15911 file supports wide character representations, and the internal types are
15912 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15913 and @code{String}. It contains generic subpackages listed next.
15915 @item Ada.Wide_Text_IO.Decimal_IO
15916 Provides input-output facilities for decimal fixed-point types
15918 @item Ada.Wide_Text_IO.Enumeration_IO
15919 Provides input-output facilities for enumeration types.
15921 @item Ada.Wide_Text_IO.Fixed_IO
15922 Provides input-output facilities for ordinary fixed-point types.
15924 @item Ada.Wide_Text_IO.Float_IO
15925 Provides input-output facilities for float types. The following
15926 predefined instantiations of this generic package are available:
15930 @code{Short_Float_Wide_Text_IO}
15932 @code{Float_Wide_Text_IO}
15934 @code{Long_Float_Wide_Text_IO}
15937 @item Ada.Wide_Text_IO.Integer_IO
15938 Provides input-output facilities for integer types. The following
15939 predefined instantiations of this generic package are available:
15942 @item Short_Short_Integer
15943 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15944 @item Short_Integer
15945 @code{Ada.Short_Integer_Wide_Text_IO}
15947 @code{Ada.Integer_Wide_Text_IO}
15949 @code{Ada.Long_Integer_Wide_Text_IO}
15950 @item Long_Long_Integer
15951 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15954 @item Ada.Wide_Text_IO.Modular_IO
15955 Provides input-output facilities for modular (unsigned) types
15957 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15958 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15959 external file supports wide character representations.
15961 @item Ada.Wide_Text_IO.Editing (F.3.4)
15962 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15963 types are @code{Wide_Character} and @code{Wide_String} instead of
15964 @code{Character} and @code{String}.
15966 @item Ada.Wide_Text_IO.Streams (A.12.3)
15967 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15968 types are @code{Wide_Character} and @code{Wide_String} instead of
15969 @code{Character} and @code{String}.
15971 @item Ada.Wide_Wide_Text_IO (A.11)
15972 This package is similar to @code{Ada.Text_IO}, except that the external
15973 file supports wide character representations, and the internal types are
15974 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15975 and @code{String}. It contains generic subpackages listed next.
15977 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15978 Provides input-output facilities for decimal fixed-point types
15980 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15981 Provides input-output facilities for enumeration types.
15983 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15984 Provides input-output facilities for ordinary fixed-point types.
15986 @item Ada.Wide_Wide_Text_IO.Float_IO
15987 Provides input-output facilities for float types. The following
15988 predefined instantiations of this generic package are available:
15992 @code{Short_Float_Wide_Wide_Text_IO}
15994 @code{Float_Wide_Wide_Text_IO}
15996 @code{Long_Float_Wide_Wide_Text_IO}
15999 @item Ada.Wide_Wide_Text_IO.Integer_IO
16000 Provides input-output facilities for integer types. The following
16001 predefined instantiations of this generic package are available:
16004 @item Short_Short_Integer
16005 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
16006 @item Short_Integer
16007 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
16009 @code{Ada.Integer_Wide_Wide_Text_IO}
16011 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
16012 @item Long_Long_Integer
16013 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
16016 @item Ada.Wide_Wide_Text_IO.Modular_IO
16017 Provides input-output facilities for modular (unsigned) types
16019 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
16020 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
16021 external file supports wide character representations.
16023 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
16024 This package is similar to @code{Ada.Text_IO.Editing}, except that the
16025 types are @code{Wide_Character} and @code{Wide_String} instead of
16026 @code{Character} and @code{String}.
16028 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
16029 This package is similar to @code{Ada.Text_IO.Streams}, except that the
16030 types are @code{Wide_Character} and @code{Wide_String} instead of
16031 @code{Character} and @code{String}.
16034 @node The Implementation of Standard I/O
16035 @chapter The Implementation of Standard I/O
16038 GNAT implements all the required input-output facilities described in
16039 A.6 through A.14. These sections of the Ada Reference Manual describe the
16040 required behavior of these packages from the Ada point of view, and if
16041 you are writing a portable Ada program that does not need to know the
16042 exact manner in which Ada maps to the outside world when it comes to
16043 reading or writing external files, then you do not need to read this
16044 chapter. As long as your files are all regular files (not pipes or
16045 devices), and as long as you write and read the files only from Ada, the
16046 description in the Ada Reference Manual is sufficient.
16048 However, if you want to do input-output to pipes or other devices, such
16049 as the keyboard or screen, or if the files you are dealing with are
16050 either generated by some other language, or to be read by some other
16051 language, then you need to know more about the details of how the GNAT
16052 implementation of these input-output facilities behaves.
16054 In this chapter we give a detailed description of exactly how GNAT
16055 interfaces to the file system. As always, the sources of the system are
16056 available to you for answering questions at an even more detailed level,
16057 but for most purposes the information in this chapter will suffice.
16059 Another reason that you may need to know more about how input-output is
16060 implemented arises when you have a program written in mixed languages
16061 where, for example, files are shared between the C and Ada sections of
16062 the same program. GNAT provides some additional facilities, in the form
16063 of additional child library packages, that facilitate this sharing, and
16064 these additional facilities are also described in this chapter.
16067 * Standard I/O Packages::
16073 * Wide_Wide_Text_IO::
16075 * Text Translation::
16077 * Filenames encoding::
16079 * Operations on C Streams::
16080 * Interfacing to C Streams::
16083 @node Standard I/O Packages
16084 @section Standard I/O Packages
16087 The Standard I/O packages described in Annex A for
16093 Ada.Text_IO.Complex_IO
16095 Ada.Text_IO.Text_Streams
16099 Ada.Wide_Text_IO.Complex_IO
16101 Ada.Wide_Text_IO.Text_Streams
16103 Ada.Wide_Wide_Text_IO
16105 Ada.Wide_Wide_Text_IO.Complex_IO
16107 Ada.Wide_Wide_Text_IO.Text_Streams
16117 are implemented using the C
16118 library streams facility; where
16122 All files are opened using @code{fopen}.
16124 All input/output operations use @code{fread}/@code{fwrite}.
16128 There is no internal buffering of any kind at the Ada library level. The only
16129 buffering is that provided at the system level in the implementation of the
16130 library routines that support streams. This facilitates shared use of these
16131 streams by mixed language programs. Note though that system level buffering is
16132 explicitly enabled at elaboration of the standard I/O packages and that can
16133 have an impact on mixed language programs, in particular those using I/O before
16134 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
16135 the Ada elaboration routine before performing any I/O or when impractical,
16136 flush the common I/O streams and in particular Standard_Output before
16137 elaborating the Ada code.
16140 @section FORM Strings
16143 The format of a FORM string in GNAT is:
16146 "keyword=value,keyword=value,@dots{},keyword=value"
16150 where letters may be in upper or lower case, and there are no spaces
16151 between values. The order of the entries is not important. Currently
16152 the following keywords defined.
16155 TEXT_TRANSLATION=[YES|NO]
16157 WCEM=[n|h|u|s|e|8|b]
16158 ENCODING=[UTF8|8BITS]
16162 The use of these parameters is described later in this section. If an
16163 unrecognized keyword appears in a form string, it is silently ignored
16164 and not considered invalid.
16167 For OpenVMS additional FORM string keywords are available for use with
16168 RMS services. The syntax is:
16171 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
16175 The following RMS keywords and values are currently defined:
16178 Context=Force_Stream_Mode|Force_Record_Mode
16182 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
16183 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
16189 Direct_IO can only be instantiated for definite types. This is a
16190 restriction of the Ada language, which means that the records are fixed
16191 length (the length being determined by @code{@var{type}'Size}, rounded
16192 up to the next storage unit boundary if necessary).
16194 The records of a Direct_IO file are simply written to the file in index
16195 sequence, with the first record starting at offset zero, and subsequent
16196 records following. There is no control information of any kind. For
16197 example, if 32-bit integers are being written, each record takes
16198 4-bytes, so the record at index @var{K} starts at offset
16199 (@var{K}@minus{}1)*4.
16201 There is no limit on the size of Direct_IO files, they are expanded as
16202 necessary to accommodate whatever records are written to the file.
16204 @node Sequential_IO
16205 @section Sequential_IO
16208 Sequential_IO may be instantiated with either a definite (constrained)
16209 or indefinite (unconstrained) type.
16211 For the definite type case, the elements written to the file are simply
16212 the memory images of the data values with no control information of any
16213 kind. The resulting file should be read using the same type, no validity
16214 checking is performed on input.
16216 For the indefinite type case, the elements written consist of two
16217 parts. First is the size of the data item, written as the memory image
16218 of a @code{Interfaces.C.size_t} value, followed by the memory image of
16219 the data value. The resulting file can only be read using the same
16220 (unconstrained) type. Normal assignment checks are performed on these
16221 read operations, and if these checks fail, @code{Data_Error} is
16222 raised. In particular, in the array case, the lengths must match, and in
16223 the variant record case, if the variable for a particular read operation
16224 is constrained, the discriminants must match.
16226 Note that it is not possible to use Sequential_IO to write variable
16227 length array items, and then read the data back into different length
16228 arrays. For example, the following will raise @code{Data_Error}:
16230 @smallexample @c ada
16231 package IO is new Sequential_IO (String);
16236 IO.Write (F, "hello!")
16237 IO.Reset (F, Mode=>In_File);
16244 On some Ada implementations, this will print @code{hell}, but the program is
16245 clearly incorrect, since there is only one element in the file, and that
16246 element is the string @code{hello!}.
16248 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
16249 using Stream_IO, and this is the preferred mechanism. In particular, the
16250 above program fragment rewritten to use Stream_IO will work correctly.
16256 Text_IO files consist of a stream of characters containing the following
16257 special control characters:
16260 LF (line feed, 16#0A#) Line Mark
16261 FF (form feed, 16#0C#) Page Mark
16265 A canonical Text_IO file is defined as one in which the following
16266 conditions are met:
16270 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
16274 The character @code{FF} is used only as a page mark, i.e.@: to mark the
16275 end of a page and consequently can appear only immediately following a
16276 @code{LF} (line mark) character.
16279 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
16280 (line mark, page mark). In the former case, the page mark is implicitly
16281 assumed to be present.
16285 A file written using Text_IO will be in canonical form provided that no
16286 explicit @code{LF} or @code{FF} characters are written using @code{Put}
16287 or @code{Put_Line}. There will be no @code{FF} character at the end of
16288 the file unless an explicit @code{New_Page} operation was performed
16289 before closing the file.
16291 A canonical Text_IO file that is a regular file (i.e., not a device or a
16292 pipe) can be read using any of the routines in Text_IO@. The
16293 semantics in this case will be exactly as defined in the Ada Reference
16294 Manual, and all the routines in Text_IO are fully implemented.
16296 A text file that does not meet the requirements for a canonical Text_IO
16297 file has one of the following:
16301 The file contains @code{FF} characters not immediately following a
16302 @code{LF} character.
16305 The file contains @code{LF} or @code{FF} characters written by
16306 @code{Put} or @code{Put_Line}, which are not logically considered to be
16307 line marks or page marks.
16310 The file ends in a character other than @code{LF} or @code{FF},
16311 i.e.@: there is no explicit line mark or page mark at the end of the file.
16315 Text_IO can be used to read such non-standard text files but subprograms
16316 to do with line or page numbers do not have defined meanings. In
16317 particular, a @code{FF} character that does not follow a @code{LF}
16318 character may or may not be treated as a page mark from the point of
16319 view of page and line numbering. Every @code{LF} character is considered
16320 to end a line, and there is an implied @code{LF} character at the end of
16324 * Text_IO Stream Pointer Positioning::
16325 * Text_IO Reading and Writing Non-Regular Files::
16327 * Treating Text_IO Files as Streams::
16328 * Text_IO Extensions::
16329 * Text_IO Facilities for Unbounded Strings::
16332 @node Text_IO Stream Pointer Positioning
16333 @subsection Stream Pointer Positioning
16336 @code{Ada.Text_IO} has a definition of current position for a file that
16337 is being read. No internal buffering occurs in Text_IO, and usually the
16338 physical position in the stream used to implement the file corresponds
16339 to this logical position defined by Text_IO@. There are two exceptions:
16343 After a call to @code{End_Of_Page} that returns @code{True}, the stream
16344 is positioned past the @code{LF} (line mark) that precedes the page
16345 mark. Text_IO maintains an internal flag so that subsequent read
16346 operations properly handle the logical position which is unchanged by
16347 the @code{End_Of_Page} call.
16350 After a call to @code{End_Of_File} that returns @code{True}, if the
16351 Text_IO file was positioned before the line mark at the end of file
16352 before the call, then the logical position is unchanged, but the stream
16353 is physically positioned right at the end of file (past the line mark,
16354 and past a possible page mark following the line mark. Again Text_IO
16355 maintains internal flags so that subsequent read operations properly
16356 handle the logical position.
16360 These discrepancies have no effect on the observable behavior of
16361 Text_IO, but if a single Ada stream is shared between a C program and
16362 Ada program, or shared (using @samp{shared=yes} in the form string)
16363 between two Ada files, then the difference may be observable in some
16366 @node Text_IO Reading and Writing Non-Regular Files
16367 @subsection Reading and Writing Non-Regular Files
16370 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
16371 can be used for reading and writing. Writing is not affected and the
16372 sequence of characters output is identical to the normal file case, but
16373 for reading, the behavior of Text_IO is modified to avoid undesirable
16374 look-ahead as follows:
16376 An input file that is not a regular file is considered to have no page
16377 marks. Any @code{Ascii.FF} characters (the character normally used for a
16378 page mark) appearing in the file are considered to be data
16379 characters. In particular:
16383 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
16384 following a line mark. If a page mark appears, it will be treated as a
16388 This avoids the need to wait for an extra character to be typed or
16389 entered from the pipe to complete one of these operations.
16392 @code{End_Of_Page} always returns @code{False}
16395 @code{End_Of_File} will return @code{False} if there is a page mark at
16396 the end of the file.
16400 Output to non-regular files is the same as for regular files. Page marks
16401 may be written to non-regular files using @code{New_Page}, but as noted
16402 above they will not be treated as page marks on input if the output is
16403 piped to another Ada program.
16405 Another important discrepancy when reading non-regular files is that the end
16406 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
16407 pressing the @key{EOT} key,
16409 is signaled once (i.e.@: the test @code{End_Of_File}
16410 will yield @code{True}, or a read will
16411 raise @code{End_Error}), but then reading can resume
16412 to read data past that end of
16413 file indication, until another end of file indication is entered.
16415 @node Get_Immediate
16416 @subsection Get_Immediate
16417 @cindex Get_Immediate
16420 Get_Immediate returns the next character (including control characters)
16421 from the input file. In particular, Get_Immediate will return LF or FF
16422 characters used as line marks or page marks. Such operations leave the
16423 file positioned past the control character, and it is thus not treated
16424 as having its normal function. This means that page, line and column
16425 counts after this kind of Get_Immediate call are set as though the mark
16426 did not occur. In the case where a Get_Immediate leaves the file
16427 positioned between the line mark and page mark (which is not normally
16428 possible), it is undefined whether the FF character will be treated as a
16431 @node Treating Text_IO Files as Streams
16432 @subsection Treating Text_IO Files as Streams
16433 @cindex Stream files
16436 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
16437 as a stream. Data written to a Text_IO file in this stream mode is
16438 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
16439 16#0C# (@code{FF}), the resulting file may have non-standard
16440 format. Similarly if read operations are used to read from a Text_IO
16441 file treated as a stream, then @code{LF} and @code{FF} characters may be
16442 skipped and the effect is similar to that described above for
16443 @code{Get_Immediate}.
16445 @node Text_IO Extensions
16446 @subsection Text_IO Extensions
16447 @cindex Text_IO extensions
16450 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
16451 to the standard @code{Text_IO} package:
16454 @item function File_Exists (Name : String) return Boolean;
16455 Determines if a file of the given name exists.
16457 @item function Get_Line return String;
16458 Reads a string from the standard input file. The value returned is exactly
16459 the length of the line that was read.
16461 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
16462 Similar, except that the parameter File specifies the file from which
16463 the string is to be read.
16467 @node Text_IO Facilities for Unbounded Strings
16468 @subsection Text_IO Facilities for Unbounded Strings
16469 @cindex Text_IO for unbounded strings
16470 @cindex Unbounded_String, Text_IO operations
16473 The package @code{Ada.Strings.Unbounded.Text_IO}
16474 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
16475 subprograms useful for Text_IO operations on unbounded strings:
16479 @item function Get_Line (File : File_Type) return Unbounded_String;
16480 Reads a line from the specified file
16481 and returns the result as an unbounded string.
16483 @item procedure Put (File : File_Type; U : Unbounded_String);
16484 Writes the value of the given unbounded string to the specified file
16485 Similar to the effect of
16486 @code{Put (To_String (U))} except that an extra copy is avoided.
16488 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
16489 Writes the value of the given unbounded string to the specified file,
16490 followed by a @code{New_Line}.
16491 Similar to the effect of @code{Put_Line (To_String (U))} except
16492 that an extra copy is avoided.
16496 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
16497 and is optional. If the parameter is omitted, then the standard input or
16498 output file is referenced as appropriate.
16500 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
16501 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
16502 @code{Wide_Text_IO} functionality for unbounded wide strings.
16504 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
16505 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
16506 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
16509 @section Wide_Text_IO
16512 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
16513 both input and output files may contain special sequences that represent
16514 wide character values. The encoding scheme for a given file may be
16515 specified using a FORM parameter:
16522 as part of the FORM string (WCEM = wide character encoding method),
16523 where @var{x} is one of the following characters
16529 Upper half encoding
16541 The encoding methods match those that
16542 can be used in a source
16543 program, but there is no requirement that the encoding method used for
16544 the source program be the same as the encoding method used for files,
16545 and different files may use different encoding methods.
16547 The default encoding method for the standard files, and for opened files
16548 for which no WCEM parameter is given in the FORM string matches the
16549 wide character encoding specified for the main program (the default
16550 being brackets encoding if no coding method was specified with -gnatW).
16554 In this encoding, a wide character is represented by a five character
16562 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
16563 characters (using upper case letters) of the wide character code. For
16564 example, ESC A345 is used to represent the wide character with code
16565 16#A345#. This scheme is compatible with use of the full
16566 @code{Wide_Character} set.
16568 @item Upper Half Coding
16569 The wide character with encoding 16#abcd#, where the upper bit is on
16570 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
16571 16#cd#. The second byte may never be a format control character, but is
16572 not required to be in the upper half. This method can be also used for
16573 shift-JIS or EUC where the internal coding matches the external coding.
16575 @item Shift JIS Coding
16576 A wide character is represented by a two character sequence 16#ab# and
16577 16#cd#, with the restrictions described for upper half encoding as
16578 described above. The internal character code is the corresponding JIS
16579 character according to the standard algorithm for Shift-JIS
16580 conversion. Only characters defined in the JIS code set table can be
16581 used with this encoding method.
16584 A wide character is represented by a two character sequence 16#ab# and
16585 16#cd#, with both characters being in the upper half. The internal
16586 character code is the corresponding JIS character according to the EUC
16587 encoding algorithm. Only characters defined in the JIS code set table
16588 can be used with this encoding method.
16591 A wide character is represented using
16592 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16593 10646-1/Am.2. Depending on the character value, the representation
16594 is a one, two, or three byte sequence:
16597 16#0000#-16#007f#: 2#0xxxxxxx#
16598 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
16599 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16603 where the @var{xxx} bits correspond to the left-padded bits of the
16604 16-bit character value. Note that all lower half ASCII characters
16605 are represented as ASCII bytes and all upper half characters and
16606 other wide characters are represented as sequences of upper-half
16607 (The full UTF-8 scheme allows for encoding 31-bit characters as
16608 6-byte sequences, but in this implementation, all UTF-8 sequences
16609 of four or more bytes length will raise a Constraint_Error, as
16610 will all invalid UTF-8 sequences.)
16612 @item Brackets Coding
16613 In this encoding, a wide character is represented by the following eight
16614 character sequence:
16621 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
16622 characters (using uppercase letters) of the wide character code. For
16623 example, @code{["A345"]} is used to represent the wide character with code
16625 This scheme is compatible with use of the full Wide_Character set.
16626 On input, brackets coding can also be used for upper half characters,
16627 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16628 is only used for wide characters with a code greater than @code{16#FF#}.
16630 Note that brackets coding is not normally used in the context of
16631 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
16632 a portable way of encoding source files. In the context of Wide_Text_IO
16633 or Wide_Wide_Text_IO, it can only be used if the file does not contain
16634 any instance of the left bracket character other than to encode wide
16635 character values using the brackets encoding method. In practice it is
16636 expected that some standard wide character encoding method such
16637 as UTF-8 will be used for text input output.
16639 If brackets notation is used, then any occurrence of a left bracket
16640 in the input file which is not the start of a valid wide character
16641 sequence will cause Constraint_Error to be raised. It is possible to
16642 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
16643 input will interpret this as a left bracket.
16645 However, when a left bracket is output, it will be output as a left bracket
16646 and not as ["5B"]. We make this decision because for normal use of
16647 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
16648 brackets. For example, if we write:
16651 Put_Line ("Start of output [first run]");
16655 we really do not want to have the left bracket in this message clobbered so
16656 that the output reads:
16659 Start of output ["5B"]first run]
16663 In practice brackets encoding is reasonably useful for normal Put_Line use
16664 since we won't get confused between left brackets and wide character
16665 sequences in the output. But for input, or when files are written out
16666 and read back in, it really makes better sense to use one of the standard
16667 encoding methods such as UTF-8.
16672 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
16673 not all wide character
16674 values can be represented. An attempt to output a character that cannot
16675 be represented using the encoding scheme for the file causes
16676 Constraint_Error to be raised. An invalid wide character sequence on
16677 input also causes Constraint_Error to be raised.
16680 * Wide_Text_IO Stream Pointer Positioning::
16681 * Wide_Text_IO Reading and Writing Non-Regular Files::
16684 @node Wide_Text_IO Stream Pointer Positioning
16685 @subsection Stream Pointer Positioning
16688 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16689 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16692 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
16693 normal lower ASCII set (i.e.@: a character in the range:
16695 @smallexample @c ada
16696 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
16700 then although the logical position of the file pointer is unchanged by
16701 the @code{Look_Ahead} call, the stream is physically positioned past the
16702 wide character sequence. Again this is to avoid the need for buffering
16703 or backup, and all @code{Wide_Text_IO} routines check the internal
16704 indication that this situation has occurred so that this is not visible
16705 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
16706 can be observed if the wide text file shares a stream with another file.
16708 @node Wide_Text_IO Reading and Writing Non-Regular Files
16709 @subsection Reading and Writing Non-Regular Files
16712 As in the case of Text_IO, when a non-regular file is read, it is
16713 assumed that the file contains no page marks (any form characters are
16714 treated as data characters), and @code{End_Of_Page} always returns
16715 @code{False}. Similarly, the end of file indication is not sticky, so
16716 it is possible to read beyond an end of file.
16718 @node Wide_Wide_Text_IO
16719 @section Wide_Wide_Text_IO
16722 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
16723 both input and output files may contain special sequences that represent
16724 wide wide character values. The encoding scheme for a given file may be
16725 specified using a FORM parameter:
16732 as part of the FORM string (WCEM = wide character encoding method),
16733 where @var{x} is one of the following characters
16739 Upper half encoding
16751 The encoding methods match those that
16752 can be used in a source
16753 program, but there is no requirement that the encoding method used for
16754 the source program be the same as the encoding method used for files,
16755 and different files may use different encoding methods.
16757 The default encoding method for the standard files, and for opened files
16758 for which no WCEM parameter is given in the FORM string matches the
16759 wide character encoding specified for the main program (the default
16760 being brackets encoding if no coding method was specified with -gnatW).
16765 A wide character is represented using
16766 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16767 10646-1/Am.2. Depending on the character value, the representation
16768 is a one, two, three, or four byte sequence:
16771 16#000000#-16#00007f#: 2#0xxxxxxx#
16772 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16773 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16774 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16778 where the @var{xxx} bits correspond to the left-padded bits of the
16779 21-bit character value. Note that all lower half ASCII characters
16780 are represented as ASCII bytes and all upper half characters and
16781 other wide characters are represented as sequences of upper-half
16784 @item Brackets Coding
16785 In this encoding, a wide wide character is represented by the following eight
16786 character sequence if is in wide character range
16792 and by the following ten character sequence if not
16795 [ " a b c d e f " ]
16799 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16800 are the four or six hexadecimal
16801 characters (using uppercase letters) of the wide wide character code. For
16802 example, @code{["01A345"]} is used to represent the wide wide character
16803 with code @code{16#01A345#}.
16805 This scheme is compatible with use of the full Wide_Wide_Character set.
16806 On input, brackets coding can also be used for upper half characters,
16807 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16808 is only used for wide characters with a code greater than @code{16#FF#}.
16813 If is also possible to use the other Wide_Character encoding methods,
16814 such as Shift-JIS, but the other schemes cannot support the full range
16815 of wide wide characters.
16816 An attempt to output a character that cannot
16817 be represented using the encoding scheme for the file causes
16818 Constraint_Error to be raised. An invalid wide character sequence on
16819 input also causes Constraint_Error to be raised.
16822 * Wide_Wide_Text_IO Stream Pointer Positioning::
16823 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16826 @node Wide_Wide_Text_IO Stream Pointer Positioning
16827 @subsection Stream Pointer Positioning
16830 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16831 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16834 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16835 normal lower ASCII set (i.e.@: a character in the range:
16837 @smallexample @c ada
16838 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16842 then although the logical position of the file pointer is unchanged by
16843 the @code{Look_Ahead} call, the stream is physically positioned past the
16844 wide character sequence. Again this is to avoid the need for buffering
16845 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16846 indication that this situation has occurred so that this is not visible
16847 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
16848 can be observed if the wide text file shares a stream with another file.
16850 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16851 @subsection Reading and Writing Non-Regular Files
16854 As in the case of Text_IO, when a non-regular file is read, it is
16855 assumed that the file contains no page marks (any form characters are
16856 treated as data characters), and @code{End_Of_Page} always returns
16857 @code{False}. Similarly, the end of file indication is not sticky, so
16858 it is possible to read beyond an end of file.
16864 A stream file is a sequence of bytes, where individual elements are
16865 written to the file as described in the Ada Reference Manual. The type
16866 @code{Stream_Element} is simply a byte. There are two ways to read or
16867 write a stream file.
16871 The operations @code{Read} and @code{Write} directly read or write a
16872 sequence of stream elements with no control information.
16875 The stream attributes applied to a stream file transfer data in the
16876 manner described for stream attributes.
16879 @node Text Translation
16880 @section Text Translation
16883 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16884 passed to Text_IO.Create and Text_IO.Open:
16885 @samp{Text_Translation=@var{Yes}} is the default, which means to
16886 translate LF to/from CR/LF on Windows systems.
16887 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16888 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16889 may be used to create Unix-style files on
16890 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16894 @section Shared Files
16897 Section A.14 of the Ada Reference Manual allows implementations to
16898 provide a wide variety of behavior if an attempt is made to access the
16899 same external file with two or more internal files.
16901 To provide a full range of functionality, while at the same time
16902 minimizing the problems of portability caused by this implementation
16903 dependence, GNAT handles file sharing as follows:
16907 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16908 to open two or more files with the same full name is considered an error
16909 and is not supported. The exception @code{Use_Error} will be
16910 raised. Note that a file that is not explicitly closed by the program
16911 remains open until the program terminates.
16914 If the form parameter @samp{shared=no} appears in the form string, the
16915 file can be opened or created with its own separate stream identifier,
16916 regardless of whether other files sharing the same external file are
16917 opened. The exact effect depends on how the C stream routines handle
16918 multiple accesses to the same external files using separate streams.
16921 If the form parameter @samp{shared=yes} appears in the form string for
16922 each of two or more files opened using the same full name, the same
16923 stream is shared between these files, and the semantics are as described
16924 in Ada Reference Manual, Section A.14.
16928 When a program that opens multiple files with the same name is ported
16929 from another Ada compiler to GNAT, the effect will be that
16930 @code{Use_Error} is raised.
16932 The documentation of the original compiler and the documentation of the
16933 program should then be examined to determine if file sharing was
16934 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16935 and @code{Create} calls as required.
16937 When a program is ported from GNAT to some other Ada compiler, no
16938 special attention is required unless the @samp{shared=@var{xxx}} form
16939 parameter is used in the program. In this case, you must examine the
16940 documentation of the new compiler to see if it supports the required
16941 file sharing semantics, and form strings modified appropriately. Of
16942 course it may be the case that the program cannot be ported if the
16943 target compiler does not support the required functionality. The best
16944 approach in writing portable code is to avoid file sharing (and hence
16945 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16948 One common use of file sharing in Ada 83 is the use of instantiations of
16949 Sequential_IO on the same file with different types, to achieve
16950 heterogeneous input-output. Although this approach will work in GNAT if
16951 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16952 for this purpose (using the stream attributes)
16954 @node Filenames encoding
16955 @section Filenames encoding
16958 An encoding form parameter can be used to specify the filename
16959 encoding @samp{encoding=@var{xxx}}.
16963 If the form parameter @samp{encoding=utf8} appears in the form string, the
16964 filename must be encoded in UTF-8.
16967 If the form parameter @samp{encoding=8bits} appears in the form
16968 string, the filename must be a standard 8bits string.
16971 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16972 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16973 variable. And if not set @samp{utf8} is assumed.
16977 The current system Windows ANSI code page.
16982 This encoding form parameter is only supported on the Windows
16983 platform. On the other Operating Systems the run-time is supporting
16987 @section Open Modes
16990 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16991 using the mode shown in the following table:
16994 @center @code{Open} and @code{Create} Call Modes
16996 @b{OPEN } @b{CREATE}
16997 Append_File "r+" "w+"
16999 Out_File (Direct_IO) "r+" "w"
17000 Out_File (all other cases) "w" "w"
17001 Inout_File "r+" "w+"
17005 If text file translation is required, then either @samp{b} or @samp{t}
17006 is added to the mode, depending on the setting of Text. Text file
17007 translation refers to the mapping of CR/LF sequences in an external file
17008 to LF characters internally. This mapping only occurs in DOS and
17009 DOS-like systems, and is not relevant to other systems.
17011 A special case occurs with Stream_IO@. As shown in the above table, the
17012 file is initially opened in @samp{r} or @samp{w} mode for the
17013 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
17014 subsequently requires switching from reading to writing or vice-versa,
17015 then the file is reopened in @samp{r+} mode to permit the required operation.
17017 @node Operations on C Streams
17018 @section Operations on C Streams
17019 The package @code{Interfaces.C_Streams} provides an Ada program with direct
17020 access to the C library functions for operations on C streams:
17022 @smallexample @c adanocomment
17023 package Interfaces.C_Streams is
17024 -- Note: the reason we do not use the types that are in
17025 -- Interfaces.C is that we want to avoid dragging in the
17026 -- code in this unit if possible.
17027 subtype chars is System.Address;
17028 -- Pointer to null-terminated array of characters
17029 subtype FILEs is System.Address;
17030 -- Corresponds to the C type FILE*
17031 subtype voids is System.Address;
17032 -- Corresponds to the C type void*
17033 subtype int is Integer;
17034 subtype long is Long_Integer;
17035 -- Note: the above types are subtypes deliberately, and it
17036 -- is part of this spec that the above correspondences are
17037 -- guaranteed. This means that it is legitimate to, for
17038 -- example, use Integer instead of int. We provide these
17039 -- synonyms for clarity, but in some cases it may be
17040 -- convenient to use the underlying types (for example to
17041 -- avoid an unnecessary dependency of a spec on the spec
17043 type size_t is mod 2 ** Standard'Address_Size;
17044 NULL_Stream : constant FILEs;
17045 -- Value returned (NULL in C) to indicate an
17046 -- fdopen/fopen/tmpfile error
17047 ----------------------------------
17048 -- Constants Defined in stdio.h --
17049 ----------------------------------
17050 EOF : constant int;
17051 -- Used by a number of routines to indicate error or
17053 IOFBF : constant int;
17054 IOLBF : constant int;
17055 IONBF : constant int;
17056 -- Used to indicate buffering mode for setvbuf call
17057 SEEK_CUR : constant int;
17058 SEEK_END : constant int;
17059 SEEK_SET : constant int;
17060 -- Used to indicate origin for fseek call
17061 function stdin return FILEs;
17062 function stdout return FILEs;
17063 function stderr return FILEs;
17064 -- Streams associated with standard files
17065 --------------------------
17066 -- Standard C functions --
17067 --------------------------
17068 -- The functions selected below are ones that are
17069 -- available in UNIX (but not necessarily in ANSI C).
17070 -- These are very thin interfaces
17071 -- which copy exactly the C headers. For more
17072 -- documentation on these functions, see the Microsoft C
17073 -- "Run-Time Library Reference" (Microsoft Press, 1990,
17074 -- ISBN 1-55615-225-6), which includes useful information
17075 -- on system compatibility.
17076 procedure clearerr (stream : FILEs);
17077 function fclose (stream : FILEs) return int;
17078 function fdopen (handle : int; mode : chars) return FILEs;
17079 function feof (stream : FILEs) return int;
17080 function ferror (stream : FILEs) return int;
17081 function fflush (stream : FILEs) return int;
17082 function fgetc (stream : FILEs) return int;
17083 function fgets (strng : chars; n : int; stream : FILEs)
17085 function fileno (stream : FILEs) return int;
17086 function fopen (filename : chars; Mode : chars)
17088 -- Note: to maintain target independence, use
17089 -- text_translation_required, a boolean variable defined in
17090 -- a-sysdep.c to deal with the target dependent text
17091 -- translation requirement. If this variable is set,
17092 -- then b/t should be appended to the standard mode
17093 -- argument to set the text translation mode off or on
17095 function fputc (C : int; stream : FILEs) return int;
17096 function fputs (Strng : chars; Stream : FILEs) return int;
17113 function ftell (stream : FILEs) return long;
17120 function isatty (handle : int) return int;
17121 procedure mktemp (template : chars);
17122 -- The return value (which is just a pointer to template)
17124 procedure rewind (stream : FILEs);
17125 function rmtmp return int;
17133 function tmpfile return FILEs;
17134 function ungetc (c : int; stream : FILEs) return int;
17135 function unlink (filename : chars) return int;
17136 ---------------------
17137 -- Extra functions --
17138 ---------------------
17139 -- These functions supply slightly thicker bindings than
17140 -- those above. They are derived from functions in the
17141 -- C Run-Time Library, but may do a bit more work than
17142 -- just directly calling one of the Library functions.
17143 function is_regular_file (handle : int) return int;
17144 -- Tests if given handle is for a regular file (result 1)
17145 -- or for a non-regular file (pipe or device, result 0).
17146 ---------------------------------
17147 -- Control of Text/Binary Mode --
17148 ---------------------------------
17149 -- If text_translation_required is true, then the following
17150 -- functions may be used to dynamically switch a file from
17151 -- binary to text mode or vice versa. These functions have
17152 -- no effect if text_translation_required is false (i.e.@: in
17153 -- normal UNIX mode). Use fileno to get a stream handle.
17154 procedure set_binary_mode (handle : int);
17155 procedure set_text_mode (handle : int);
17156 ----------------------------
17157 -- Full Path Name support --
17158 ----------------------------
17159 procedure full_name (nam : chars; buffer : chars);
17160 -- Given a NUL terminated string representing a file
17161 -- name, returns in buffer a NUL terminated string
17162 -- representing the full path name for the file name.
17163 -- On systems where it is relevant the drive is also
17164 -- part of the full path name. It is the responsibility
17165 -- of the caller to pass an actual parameter for buffer
17166 -- that is big enough for any full path name. Use
17167 -- max_path_len given below as the size of buffer.
17168 max_path_len : integer;
17169 -- Maximum length of an allowable full path name on the
17170 -- system, including a terminating NUL character.
17171 end Interfaces.C_Streams;
17174 @node Interfacing to C Streams
17175 @section Interfacing to C Streams
17178 The packages in this section permit interfacing Ada files to C Stream
17181 @smallexample @c ada
17182 with Interfaces.C_Streams;
17183 package Ada.Sequential_IO.C_Streams is
17184 function C_Stream (F : File_Type)
17185 return Interfaces.C_Streams.FILEs;
17187 (File : in out File_Type;
17188 Mode : in File_Mode;
17189 C_Stream : in Interfaces.C_Streams.FILEs;
17190 Form : in String := "");
17191 end Ada.Sequential_IO.C_Streams;
17193 with Interfaces.C_Streams;
17194 package Ada.Direct_IO.C_Streams is
17195 function C_Stream (F : File_Type)
17196 return Interfaces.C_Streams.FILEs;
17198 (File : in out File_Type;
17199 Mode : in File_Mode;
17200 C_Stream : in Interfaces.C_Streams.FILEs;
17201 Form : in String := "");
17202 end Ada.Direct_IO.C_Streams;
17204 with Interfaces.C_Streams;
17205 package Ada.Text_IO.C_Streams is
17206 function C_Stream (F : File_Type)
17207 return Interfaces.C_Streams.FILEs;
17209 (File : in out File_Type;
17210 Mode : in File_Mode;
17211 C_Stream : in Interfaces.C_Streams.FILEs;
17212 Form : in String := "");
17213 end Ada.Text_IO.C_Streams;
17215 with Interfaces.C_Streams;
17216 package Ada.Wide_Text_IO.C_Streams is
17217 function C_Stream (F : File_Type)
17218 return Interfaces.C_Streams.FILEs;
17220 (File : in out File_Type;
17221 Mode : in File_Mode;
17222 C_Stream : in Interfaces.C_Streams.FILEs;
17223 Form : in String := "");
17224 end Ada.Wide_Text_IO.C_Streams;
17226 with Interfaces.C_Streams;
17227 package Ada.Wide_Wide_Text_IO.C_Streams is
17228 function C_Stream (F : File_Type)
17229 return Interfaces.C_Streams.FILEs;
17231 (File : in out File_Type;
17232 Mode : in File_Mode;
17233 C_Stream : in Interfaces.C_Streams.FILEs;
17234 Form : in String := "");
17235 end Ada.Wide_Wide_Text_IO.C_Streams;
17237 with Interfaces.C_Streams;
17238 package Ada.Stream_IO.C_Streams is
17239 function C_Stream (F : File_Type)
17240 return Interfaces.C_Streams.FILEs;
17242 (File : in out File_Type;
17243 Mode : in File_Mode;
17244 C_Stream : in Interfaces.C_Streams.FILEs;
17245 Form : in String := "");
17246 end Ada.Stream_IO.C_Streams;
17250 In each of these six packages, the @code{C_Stream} function obtains the
17251 @code{FILE} pointer from a currently opened Ada file. It is then
17252 possible to use the @code{Interfaces.C_Streams} package to operate on
17253 this stream, or the stream can be passed to a C program which can
17254 operate on it directly. Of course the program is responsible for
17255 ensuring that only appropriate sequences of operations are executed.
17257 One particular use of relevance to an Ada program is that the
17258 @code{setvbuf} function can be used to control the buffering of the
17259 stream used by an Ada file. In the absence of such a call the standard
17260 default buffering is used.
17262 The @code{Open} procedures in these packages open a file giving an
17263 existing C Stream instead of a file name. Typically this stream is
17264 imported from a C program, allowing an Ada file to operate on an
17267 @node The GNAT Library
17268 @chapter The GNAT Library
17271 The GNAT library contains a number of general and special purpose packages.
17272 It represents functionality that the GNAT developers have found useful, and
17273 which is made available to GNAT users. The packages described here are fully
17274 supported, and upwards compatibility will be maintained in future releases,
17275 so you can use these facilities with the confidence that the same functionality
17276 will be available in future releases.
17278 The chapter here simply gives a brief summary of the facilities available.
17279 The full documentation is found in the spec file for the package. The full
17280 sources of these library packages, including both spec and body, are provided
17281 with all GNAT releases. For example, to find out the full specifications of
17282 the SPITBOL pattern matching capability, including a full tutorial and
17283 extensive examples, look in the @file{g-spipat.ads} file in the library.
17285 For each entry here, the package name (as it would appear in a @code{with}
17286 clause) is given, followed by the name of the corresponding spec file in
17287 parentheses. The packages are children in four hierarchies, @code{Ada},
17288 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
17289 GNAT-specific hierarchy.
17291 Note that an application program should only use packages in one of these
17292 four hierarchies if the package is defined in the Ada Reference Manual,
17293 or is listed in this section of the GNAT Programmers Reference Manual.
17294 All other units should be considered internal implementation units and
17295 should not be directly @code{with}'ed by application code. The use of
17296 a @code{with} statement that references one of these internal implementation
17297 units makes an application potentially dependent on changes in versions
17298 of GNAT, and will generate a warning message.
17301 * Ada.Characters.Latin_9 (a-chlat9.ads)::
17302 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
17303 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
17304 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
17305 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
17306 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
17307 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
17308 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
17309 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
17310 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
17311 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
17312 * Ada.Command_Line.Environment (a-colien.ads)::
17313 * Ada.Command_Line.Remove (a-colire.ads)::
17314 * Ada.Command_Line.Response_File (a-clrefi.ads)::
17315 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
17316 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
17317 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
17318 * Ada.Exceptions.Traceback (a-exctra.ads)::
17319 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
17320 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
17321 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
17322 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
17323 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
17324 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
17325 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
17326 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
17327 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
17328 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
17329 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
17330 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
17331 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
17332 * GNAT.Altivec (g-altive.ads)::
17333 * GNAT.Altivec.Conversions (g-altcon.ads)::
17334 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
17335 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
17336 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
17337 * GNAT.Array_Split (g-arrspl.ads)::
17338 * GNAT.AWK (g-awk.ads)::
17339 * GNAT.Bounded_Buffers (g-boubuf.ads)::
17340 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
17341 * GNAT.Bubble_Sort (g-bubsor.ads)::
17342 * GNAT.Bubble_Sort_A (g-busora.ads)::
17343 * GNAT.Bubble_Sort_G (g-busorg.ads)::
17344 * GNAT.Byte_Order_Mark (g-byorma.ads)::
17345 * GNAT.Byte_Swapping (g-bytswa.ads)::
17346 * GNAT.Calendar (g-calend.ads)::
17347 * GNAT.Calendar.Time_IO (g-catiio.ads)::
17348 * GNAT.Case_Util (g-casuti.ads)::
17349 * GNAT.CGI (g-cgi.ads)::
17350 * GNAT.CGI.Cookie (g-cgicoo.ads)::
17351 * GNAT.CGI.Debug (g-cgideb.ads)::
17352 * GNAT.Command_Line (g-comlin.ads)::
17353 * GNAT.Compiler_Version (g-comver.ads)::
17354 * GNAT.Ctrl_C (g-ctrl_c.ads)::
17355 * GNAT.CRC32 (g-crc32.ads)::
17356 * GNAT.Current_Exception (g-curexc.ads)::
17357 * GNAT.Debug_Pools (g-debpoo.ads)::
17358 * GNAT.Debug_Utilities (g-debuti.ads)::
17359 * GNAT.Decode_String (g-decstr.ads)::
17360 * GNAT.Decode_UTF8_String (g-deutst.ads)::
17361 * GNAT.Directory_Operations (g-dirope.ads)::
17362 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
17363 * GNAT.Dynamic_HTables (g-dynhta.ads)::
17364 * GNAT.Dynamic_Tables (g-dyntab.ads)::
17365 * GNAT.Encode_String (g-encstr.ads)::
17366 * GNAT.Encode_UTF8_String (g-enutst.ads)::
17367 * GNAT.Exception_Actions (g-excact.ads)::
17368 * GNAT.Exception_Traces (g-exctra.ads)::
17369 * GNAT.Exceptions (g-except.ads)::
17370 * GNAT.Expect (g-expect.ads)::
17371 * GNAT.Expect.TTY (g-exptty.ads)::
17372 * GNAT.Float_Control (g-flocon.ads)::
17373 * GNAT.Heap_Sort (g-heasor.ads)::
17374 * GNAT.Heap_Sort_A (g-hesora.ads)::
17375 * GNAT.Heap_Sort_G (g-hesorg.ads)::
17376 * GNAT.HTable (g-htable.ads)::
17377 * GNAT.IO (g-io.ads)::
17378 * GNAT.IO_Aux (g-io_aux.ads)::
17379 * GNAT.Lock_Files (g-locfil.ads)::
17380 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
17381 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
17382 * GNAT.MD5 (g-md5.ads)::
17383 * GNAT.Memory_Dump (g-memdum.ads)::
17384 * GNAT.Most_Recent_Exception (g-moreex.ads)::
17385 * GNAT.OS_Lib (g-os_lib.ads)::
17386 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
17387 * GNAT.Random_Numbers (g-rannum.ads)::
17388 * GNAT.Regexp (g-regexp.ads)::
17389 * GNAT.Registry (g-regist.ads)::
17390 * GNAT.Regpat (g-regpat.ads)::
17391 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
17392 * GNAT.Semaphores (g-semaph.ads)::
17393 * GNAT.Serial_Communications (g-sercom.ads)::
17394 * GNAT.SHA1 (g-sha1.ads)::
17395 * GNAT.SHA224 (g-sha224.ads)::
17396 * GNAT.SHA256 (g-sha256.ads)::
17397 * GNAT.SHA384 (g-sha384.ads)::
17398 * GNAT.SHA512 (g-sha512.ads)::
17399 * GNAT.Signals (g-signal.ads)::
17400 * GNAT.Sockets (g-socket.ads)::
17401 * GNAT.Source_Info (g-souinf.ads)::
17402 * GNAT.Spelling_Checker (g-speche.ads)::
17403 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
17404 * GNAT.Spitbol.Patterns (g-spipat.ads)::
17405 * GNAT.Spitbol (g-spitbo.ads)::
17406 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
17407 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
17408 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
17409 * GNAT.SSE (g-sse.ads)::
17410 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
17411 * GNAT.Strings (g-string.ads)::
17412 * GNAT.String_Split (g-strspl.ads)::
17413 * GNAT.Table (g-table.ads)::
17414 * GNAT.Task_Lock (g-tasloc.ads)::
17415 * GNAT.Threads (g-thread.ads)::
17416 * GNAT.Time_Stamp (g-timsta.ads)::
17417 * GNAT.Traceback (g-traceb.ads)::
17418 * GNAT.Traceback.Symbolic (g-trasym.ads)::
17419 * GNAT.UTF_32 (g-utf_32.ads)::
17420 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
17421 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
17422 * GNAT.Wide_String_Split (g-wistsp.ads)::
17423 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
17424 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
17425 * Interfaces.C.Extensions (i-cexten.ads)::
17426 * Interfaces.C.Streams (i-cstrea.ads)::
17427 * Interfaces.CPP (i-cpp.ads)::
17428 * Interfaces.Packed_Decimal (i-pacdec.ads)::
17429 * Interfaces.VxWorks (i-vxwork.ads)::
17430 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
17431 * System.Address_Image (s-addima.ads)::
17432 * System.Assertions (s-assert.ads)::
17433 * System.Memory (s-memory.ads)::
17434 * System.Multiprocessors (s-multip.ads)::
17435 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
17436 * System.Partition_Interface (s-parint.ads)::
17437 * System.Pool_Global (s-pooglo.ads)::
17438 * System.Pool_Local (s-pooloc.ads)::
17439 * System.Restrictions (s-restri.ads)::
17440 * System.Rident (s-rident.ads)::
17441 * System.Strings.Stream_Ops (s-ststop.ads)::
17442 * System.Task_Info (s-tasinf.ads)::
17443 * System.Wch_Cnv (s-wchcnv.ads)::
17444 * System.Wch_Con (s-wchcon.ads)::
17447 @node Ada.Characters.Latin_9 (a-chlat9.ads)
17448 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17449 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
17450 @cindex Latin_9 constants for Character
17453 This child of @code{Ada.Characters}
17454 provides a set of definitions corresponding to those in the
17455 RM-defined package @code{Ada.Characters.Latin_1} but with the
17456 few modifications required for @code{Latin-9}
17457 The provision of such a package
17458 is specifically authorized by the Ada Reference Manual
17461 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
17462 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17463 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
17464 @cindex Latin_1 constants for Wide_Character
17467 This child of @code{Ada.Characters}
17468 provides a set of definitions corresponding to those in the
17469 RM-defined package @code{Ada.Characters.Latin_1} but with the
17470 types of the constants being @code{Wide_Character}
17471 instead of @code{Character}. The provision of such a package
17472 is specifically authorized by the Ada Reference Manual
17475 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
17476 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17477 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
17478 @cindex Latin_9 constants for Wide_Character
17481 This child of @code{Ada.Characters}
17482 provides a set of definitions corresponding to those in the
17483 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17484 types of the constants being @code{Wide_Character}
17485 instead of @code{Character}. The provision of such a package
17486 is specifically authorized by the Ada Reference Manual
17489 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
17490 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17491 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
17492 @cindex Latin_1 constants for Wide_Wide_Character
17495 This child of @code{Ada.Characters}
17496 provides a set of definitions corresponding to those in the
17497 RM-defined package @code{Ada.Characters.Latin_1} but with the
17498 types of the constants being @code{Wide_Wide_Character}
17499 instead of @code{Character}. The provision of such a package
17500 is specifically authorized by the Ada Reference Manual
17503 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
17504 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17505 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
17506 @cindex Latin_9 constants for Wide_Wide_Character
17509 This child of @code{Ada.Characters}
17510 provides a set of definitions corresponding to those in the
17511 GNAT defined package @code{Ada.Characters.Latin_9} but with the
17512 types of the constants being @code{Wide_Wide_Character}
17513 instead of @code{Character}. The provision of such a package
17514 is specifically authorized by the Ada Reference Manual
17517 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
17518 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17519 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
17520 @cindex Formal container for doubly linked lists
17523 This child of @code{Ada.Containers} defines a modified version of the
17524 Ada 2005 container for doubly linked lists, meant to facilitate formal
17525 verification of code using such containers. The specification of this
17526 unit is compatible with SPARK 2014.
17528 Note that although this container was designed with formal verification
17529 in mind, it may well be generally useful in that it is a simplified more
17530 efficient version than the one defined in the standard. In particular it
17531 does not have the complex overhead required to detect cursor tampering.
17533 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
17534 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17535 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
17536 @cindex Formal container for hashed maps
17539 This child of @code{Ada.Containers} defines a modified version of the
17540 Ada 2005 container for hashed maps, meant to facilitate formal
17541 verification of code using such containers. The specification of this
17542 unit is compatible with SPARK 2014.
17544 Note that although this container was designed with formal verification
17545 in mind, it may well be generally useful in that it is a simplified more
17546 efficient version than the one defined in the standard. In particular it
17547 does not have the complex overhead required to detect cursor tampering.
17549 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
17550 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17551 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
17552 @cindex Formal container for hashed sets
17555 This child of @code{Ada.Containers} defines a modified version of the
17556 Ada 2005 container for hashed sets, meant to facilitate formal
17557 verification of code using such containers. The specification of this
17558 unit is compatible with SPARK 2014.
17560 Note that although this container was designed with formal verification
17561 in mind, it may well be generally useful in that it is a simplified more
17562 efficient version than the one defined in the standard. In particular it
17563 does not have the complex overhead required to detect cursor tampering.
17565 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
17566 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17567 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
17568 @cindex Formal container for ordered maps
17571 This child of @code{Ada.Containers} defines a modified version of the
17572 Ada 2005 container for ordered maps, meant to facilitate formal
17573 verification of code using such containers. The specification of this
17574 unit is compatible with SPARK 2014.
17576 Note that although this container was designed with formal verification
17577 in mind, it may well be generally useful in that it is a simplified more
17578 efficient version than the one defined in the standard. In particular it
17579 does not have the complex overhead required to detect cursor tampering.
17581 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
17582 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17583 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
17584 @cindex Formal container for ordered sets
17587 This child of @code{Ada.Containers} defines a modified version of the
17588 Ada 2005 container for ordered sets, meant to facilitate formal
17589 verification of code using such containers. The specification of this
17590 unit is compatible with SPARK 2014.
17592 Note that although this container was designed with formal verification
17593 in mind, it may well be generally useful in that it is a simplified more
17594 efficient version than the one defined in the standard. In particular it
17595 does not have the complex overhead required to detect cursor tampering.
17597 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
17598 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17599 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
17600 @cindex Formal container for vectors
17603 This child of @code{Ada.Containers} defines a modified version of the
17604 Ada 2005 container for vectors, meant to facilitate formal
17605 verification of code using such containers. The specification of this
17606 unit is compatible with SPARK 2014.
17608 Note that although this container was designed with formal verification
17609 in mind, it may well be generally useful in that it is a simplified more
17610 efficient version than the one defined in the standard. In particular it
17611 does not have the complex overhead required to detect cursor tampering.
17613 @node Ada.Command_Line.Environment (a-colien.ads)
17614 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17615 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
17616 @cindex Environment entries
17619 This child of @code{Ada.Command_Line}
17620 provides a mechanism for obtaining environment values on systems
17621 where this concept makes sense.
17623 @node Ada.Command_Line.Remove (a-colire.ads)
17624 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17625 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
17626 @cindex Removing command line arguments
17627 @cindex Command line, argument removal
17630 This child of @code{Ada.Command_Line}
17631 provides a mechanism for logically removing
17632 arguments from the argument list. Once removed, an argument is not visible
17633 to further calls on the subprograms in @code{Ada.Command_Line} will not
17634 see the removed argument.
17636 @node Ada.Command_Line.Response_File (a-clrefi.ads)
17637 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17638 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
17639 @cindex Response file for command line
17640 @cindex Command line, response file
17641 @cindex Command line, handling long command lines
17644 This child of @code{Ada.Command_Line} provides a mechanism facilities for
17645 getting command line arguments from a text file, called a "response file".
17646 Using a response file allow passing a set of arguments to an executable longer
17647 than the maximum allowed by the system on the command line.
17649 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
17650 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17651 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
17652 @cindex C Streams, Interfacing with Direct_IO
17655 This package provides subprograms that allow interfacing between
17656 C streams and @code{Direct_IO}. The stream identifier can be
17657 extracted from a file opened on the Ada side, and an Ada file
17658 can be constructed from a stream opened on the C side.
17660 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
17661 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17662 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
17663 @cindex Null_Occurrence, testing for
17666 This child subprogram provides a way of testing for the null
17667 exception occurrence (@code{Null_Occurrence}) without raising
17670 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
17671 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17672 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
17673 @cindex Null_Occurrence, testing for
17676 This child subprogram is used for handling otherwise unhandled
17677 exceptions (hence the name last chance), and perform clean ups before
17678 terminating the program. Note that this subprogram never returns.
17680 @node Ada.Exceptions.Traceback (a-exctra.ads)
17681 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17682 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
17683 @cindex Traceback for Exception Occurrence
17686 This child package provides the subprogram (@code{Tracebacks}) to
17687 give a traceback array of addresses based on an exception
17690 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
17691 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17692 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
17693 @cindex C Streams, Interfacing with Sequential_IO
17696 This package provides subprograms that allow interfacing between
17697 C streams and @code{Sequential_IO}. The stream identifier can be
17698 extracted from a file opened on the Ada side, and an Ada file
17699 can be constructed from a stream opened on the C side.
17701 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
17702 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17703 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
17704 @cindex C Streams, Interfacing with Stream_IO
17707 This package provides subprograms that allow interfacing between
17708 C streams and @code{Stream_IO}. The stream identifier can be
17709 extracted from a file opened on the Ada side, and an Ada file
17710 can be constructed from a stream opened on the C side.
17712 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
17713 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17714 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
17715 @cindex @code{Unbounded_String}, IO support
17716 @cindex @code{Text_IO}, extensions for unbounded strings
17719 This package provides subprograms for Text_IO for unbounded
17720 strings, avoiding the necessity for an intermediate operation
17721 with ordinary strings.
17723 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
17724 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17725 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
17726 @cindex @code{Unbounded_Wide_String}, IO support
17727 @cindex @code{Text_IO}, extensions for unbounded wide strings
17730 This package provides subprograms for Text_IO for unbounded
17731 wide strings, avoiding the necessity for an intermediate operation
17732 with ordinary wide strings.
17734 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
17735 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17736 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
17737 @cindex @code{Unbounded_Wide_Wide_String}, IO support
17738 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
17741 This package provides subprograms for Text_IO for unbounded
17742 wide wide strings, avoiding the necessity for an intermediate operation
17743 with ordinary wide wide strings.
17745 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
17746 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17747 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
17748 @cindex C Streams, Interfacing with @code{Text_IO}
17751 This package provides subprograms that allow interfacing between
17752 C streams and @code{Text_IO}. The stream identifier can be
17753 extracted from a file opened on the Ada side, and an Ada file
17754 can be constructed from a stream opened on the C side.
17756 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
17757 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17758 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
17759 @cindex @code{Text_IO} resetting standard files
17762 This procedure is used to reset the status of the standard files used
17763 by Ada.Text_IO. This is useful in a situation (such as a restart in an
17764 embedded application) where the status of the files may change during
17765 execution (for example a standard input file may be redefined to be
17768 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17769 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17770 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17771 @cindex Unicode categorization, Wide_Character
17774 This package provides subprograms that allow categorization of
17775 Wide_Character values according to Unicode categories.
17777 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17778 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17779 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17780 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17783 This package provides subprograms that allow interfacing between
17784 C streams and @code{Wide_Text_IO}. The stream identifier can be
17785 extracted from a file opened on the Ada side, and an Ada file
17786 can be constructed from a stream opened on the C side.
17788 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17789 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17790 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17791 @cindex @code{Wide_Text_IO} resetting standard files
17794 This procedure is used to reset the status of the standard files used
17795 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
17796 embedded application) where the status of the files may change during
17797 execution (for example a standard input file may be redefined to be
17800 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17801 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17802 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17803 @cindex Unicode categorization, Wide_Wide_Character
17806 This package provides subprograms that allow categorization of
17807 Wide_Wide_Character values according to Unicode categories.
17809 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17810 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17811 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17812 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17815 This package provides subprograms that allow interfacing between
17816 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
17817 extracted from a file opened on the Ada side, and an Ada file
17818 can be constructed from a stream opened on the C side.
17820 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17821 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17822 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17823 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17826 This procedure is used to reset the status of the standard files used
17827 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17828 restart in an embedded application) where the status of the files may
17829 change during execution (for example a standard input file may be
17830 redefined to be interactive).
17832 @node GNAT.Altivec (g-altive.ads)
17833 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17834 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17838 This is the root package of the GNAT AltiVec binding. It provides
17839 definitions of constants and types common to all the versions of the
17842 @node GNAT.Altivec.Conversions (g-altcon.ads)
17843 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17844 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17848 This package provides the Vector/View conversion routines.
17850 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17851 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17852 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17856 This package exposes the Ada interface to the AltiVec operations on
17857 vector objects. A soft emulation is included by default in the GNAT
17858 library. The hard binding is provided as a separate package. This unit
17859 is common to both bindings.
17861 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17862 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17863 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17867 This package exposes the various vector types part of the Ada binding
17868 to AltiVec facilities.
17870 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17871 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17872 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17876 This package provides public 'View' data types from/to which private
17877 vector representations can be converted via
17878 GNAT.Altivec.Conversions. This allows convenient access to individual
17879 vector elements and provides a simple way to initialize vector
17882 @node GNAT.Array_Split (g-arrspl.ads)
17883 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17884 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17885 @cindex Array splitter
17888 Useful array-manipulation routines: given a set of separators, split
17889 an array wherever the separators appear, and provide direct access
17890 to the resulting slices.
17892 @node GNAT.AWK (g-awk.ads)
17893 @section @code{GNAT.AWK} (@file{g-awk.ads})
17894 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17899 Provides AWK-like parsing functions, with an easy interface for parsing one
17900 or more files containing formatted data. The file is viewed as a database
17901 where each record is a line and a field is a data element in this line.
17903 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17904 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17905 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17907 @cindex Bounded Buffers
17910 Provides a concurrent generic bounded buffer abstraction. Instances are
17911 useful directly or as parts of the implementations of other abstractions,
17914 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17915 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17916 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17921 Provides a thread-safe asynchronous intertask mailbox communication facility.
17923 @node GNAT.Bubble_Sort (g-bubsor.ads)
17924 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17925 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17927 @cindex Bubble sort
17930 Provides a general implementation of bubble sort usable for sorting arbitrary
17931 data items. Exchange and comparison procedures are provided by passing
17932 access-to-procedure values.
17934 @node GNAT.Bubble_Sort_A (g-busora.ads)
17935 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17936 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17938 @cindex Bubble sort
17941 Provides a general implementation of bubble sort usable for sorting arbitrary
17942 data items. Move and comparison procedures are provided by passing
17943 access-to-procedure values. This is an older version, retained for
17944 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17946 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17947 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17948 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17950 @cindex Bubble sort
17953 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17954 are provided as generic parameters, this improves efficiency, especially
17955 if the procedures can be inlined, at the expense of duplicating code for
17956 multiple instantiations.
17958 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17959 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17960 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17961 @cindex UTF-8 representation
17962 @cindex Wide characte representations
17965 Provides a routine which given a string, reads the start of the string to
17966 see whether it is one of the standard byte order marks (BOM's) which signal
17967 the encoding of the string. The routine includes detection of special XML
17968 sequences for various UCS input formats.
17970 @node GNAT.Byte_Swapping (g-bytswa.ads)
17971 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17972 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17973 @cindex Byte swapping
17977 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17978 Machine-specific implementations are available in some cases.
17980 @node GNAT.Calendar (g-calend.ads)
17981 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17982 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17983 @cindex @code{Calendar}
17986 Extends the facilities provided by @code{Ada.Calendar} to include handling
17987 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17988 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17989 C @code{timeval} format.
17991 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17992 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17993 @cindex @code{Calendar}
17995 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17997 @node GNAT.CRC32 (g-crc32.ads)
17998 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17999 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
18001 @cindex Cyclic Redundancy Check
18004 This package implements the CRC-32 algorithm. For a full description
18005 of this algorithm see
18006 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
18007 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
18008 Aug.@: 1988. Sarwate, D.V@.
18010 @node GNAT.Case_Util (g-casuti.ads)
18011 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
18012 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
18013 @cindex Casing utilities
18014 @cindex Character handling (@code{GNAT.Case_Util})
18017 A set of simple routines for handling upper and lower casing of strings
18018 without the overhead of the full casing tables
18019 in @code{Ada.Characters.Handling}.
18021 @node GNAT.CGI (g-cgi.ads)
18022 @section @code{GNAT.CGI} (@file{g-cgi.ads})
18023 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
18024 @cindex CGI (Common Gateway Interface)
18027 This is a package for interfacing a GNAT program with a Web server via the
18028 Common Gateway Interface (CGI)@. Basically this package parses the CGI
18029 parameters, which are a set of key/value pairs sent by the Web server. It
18030 builds a table whose index is the key and provides some services to deal
18033 @node GNAT.CGI.Cookie (g-cgicoo.ads)
18034 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
18035 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
18036 @cindex CGI (Common Gateway Interface) cookie support
18037 @cindex Cookie support in CGI
18040 This is a package to interface a GNAT program with a Web server via the
18041 Common Gateway Interface (CGI). It exports services to deal with Web
18042 cookies (piece of information kept in the Web client software).
18044 @node GNAT.CGI.Debug (g-cgideb.ads)
18045 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
18046 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
18047 @cindex CGI (Common Gateway Interface) debugging
18050 This is a package to help debugging CGI (Common Gateway Interface)
18051 programs written in Ada.
18053 @node GNAT.Command_Line (g-comlin.ads)
18054 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
18055 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
18056 @cindex Command line
18059 Provides a high level interface to @code{Ada.Command_Line} facilities,
18060 including the ability to scan for named switches with optional parameters
18061 and expand file names using wild card notations.
18063 @node GNAT.Compiler_Version (g-comver.ads)
18064 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
18065 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
18066 @cindex Compiler Version
18067 @cindex Version, of compiler
18070 Provides a routine for obtaining the version of the compiler used to
18071 compile the program. More accurately this is the version of the binder
18072 used to bind the program (this will normally be the same as the version
18073 of the compiler if a consistent tool set is used to compile all units
18076 @node GNAT.Ctrl_C (g-ctrl_c.ads)
18077 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
18078 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
18082 Provides a simple interface to handle Ctrl-C keyboard events.
18084 @node GNAT.Current_Exception (g-curexc.ads)
18085 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
18086 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
18087 @cindex Current exception
18088 @cindex Exception retrieval
18091 Provides access to information on the current exception that has been raised
18092 without the need for using the Ada 95 / Ada 2005 exception choice parameter
18093 specification syntax.
18094 This is particularly useful in simulating typical facilities for
18095 obtaining information about exceptions provided by Ada 83 compilers.
18097 @node GNAT.Debug_Pools (g-debpoo.ads)
18098 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
18099 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
18101 @cindex Debug pools
18102 @cindex Memory corruption debugging
18105 Provide a debugging storage pools that helps tracking memory corruption
18106 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
18107 @value{EDITION} User's Guide}.
18109 @node GNAT.Debug_Utilities (g-debuti.ads)
18110 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18111 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
18115 Provides a few useful utilities for debugging purposes, including conversion
18116 to and from string images of address values. Supports both C and Ada formats
18117 for hexadecimal literals.
18119 @node GNAT.Decode_String (g-decstr.ads)
18120 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
18121 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
18122 @cindex Decoding strings
18123 @cindex String decoding
18124 @cindex Wide character encoding
18129 A generic package providing routines for decoding wide character and wide wide
18130 character strings encoded as sequences of 8-bit characters using a specified
18131 encoding method. Includes validation routines, and also routines for stepping
18132 to next or previous encoded character in an encoded string.
18133 Useful in conjunction with Unicode character coding. Note there is a
18134 preinstantiation for UTF-8. See next entry.
18136 @node GNAT.Decode_UTF8_String (g-deutst.ads)
18137 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18138 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
18139 @cindex Decoding strings
18140 @cindex Decoding UTF-8 strings
18141 @cindex UTF-8 string decoding
18142 @cindex Wide character decoding
18147 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
18149 @node GNAT.Directory_Operations (g-dirope.ads)
18150 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18151 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
18152 @cindex Directory operations
18155 Provides a set of routines for manipulating directories, including changing
18156 the current directory, making new directories, and scanning the files in a
18159 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
18160 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18161 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
18162 @cindex Directory operations iteration
18165 A child unit of GNAT.Directory_Operations providing additional operations
18166 for iterating through directories.
18168 @node GNAT.Dynamic_HTables (g-dynhta.ads)
18169 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18170 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
18171 @cindex Hash tables
18174 A generic implementation of hash tables that can be used to hash arbitrary
18175 data. Provided in two forms, a simple form with built in hash functions,
18176 and a more complex form in which the hash function is supplied.
18179 This package provides a facility similar to that of @code{GNAT.HTable},
18180 except that this package declares a type that can be used to define
18181 dynamic instances of the hash table, while an instantiation of
18182 @code{GNAT.HTable} creates a single instance of the hash table.
18184 @node GNAT.Dynamic_Tables (g-dyntab.ads)
18185 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18186 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
18187 @cindex Table implementation
18188 @cindex Arrays, extendable
18191 A generic package providing a single dimension array abstraction where the
18192 length of the array can be dynamically modified.
18195 This package provides a facility similar to that of @code{GNAT.Table},
18196 except that this package declares a type that can be used to define
18197 dynamic instances of the table, while an instantiation of
18198 @code{GNAT.Table} creates a single instance of the table type.
18200 @node GNAT.Encode_String (g-encstr.ads)
18201 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
18202 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
18203 @cindex Encoding strings
18204 @cindex String encoding
18205 @cindex Wide character encoding
18210 A generic package providing routines for encoding wide character and wide
18211 wide character strings as sequences of 8-bit characters using a specified
18212 encoding method. Useful in conjunction with Unicode character coding.
18213 Note there is a preinstantiation for UTF-8. See next entry.
18215 @node GNAT.Encode_UTF8_String (g-enutst.ads)
18216 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18217 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
18218 @cindex Encoding strings
18219 @cindex Encoding UTF-8 strings
18220 @cindex UTF-8 string encoding
18221 @cindex Wide character encoding
18226 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
18228 @node GNAT.Exception_Actions (g-excact.ads)
18229 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18230 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
18231 @cindex Exception actions
18234 Provides callbacks when an exception is raised. Callbacks can be registered
18235 for specific exceptions, or when any exception is raised. This
18236 can be used for instance to force a core dump to ease debugging.
18238 @node GNAT.Exception_Traces (g-exctra.ads)
18239 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18240 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
18241 @cindex Exception traces
18245 Provides an interface allowing to control automatic output upon exception
18248 @node GNAT.Exceptions (g-except.ads)
18249 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
18250 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
18251 @cindex Exceptions, Pure
18252 @cindex Pure packages, exceptions
18255 Normally it is not possible to raise an exception with
18256 a message from a subprogram in a pure package, since the
18257 necessary types and subprograms are in @code{Ada.Exceptions}
18258 which is not a pure unit. @code{GNAT.Exceptions} provides a
18259 facility for getting around this limitation for a few
18260 predefined exceptions, and for example allow raising
18261 @code{Constraint_Error} with a message from a pure subprogram.
18263 @node GNAT.Expect (g-expect.ads)
18264 @section @code{GNAT.Expect} (@file{g-expect.ads})
18265 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
18268 Provides a set of subprograms similar to what is available
18269 with the standard Tcl Expect tool.
18270 It allows you to easily spawn and communicate with an external process.
18271 You can send commands or inputs to the process, and compare the output
18272 with some expected regular expression. Currently @code{GNAT.Expect}
18273 is implemented on all native GNAT ports except for OpenVMS@.
18274 It is not implemented for cross ports, and in particular is not
18275 implemented for VxWorks or LynxOS@.
18277 @node GNAT.Expect.TTY (g-exptty.ads)
18278 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18279 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
18282 As GNAT.Expect but using pseudo-terminal.
18283 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
18284 ports except for OpenVMS@. It is not implemented for cross ports, and
18285 in particular is not implemented for VxWorks or LynxOS@.
18287 @node GNAT.Float_Control (g-flocon.ads)
18288 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
18289 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
18290 @cindex Floating-Point Processor
18293 Provides an interface for resetting the floating-point processor into the
18294 mode required for correct semantic operation in Ada. Some third party
18295 library calls may cause this mode to be modified, and the Reset procedure
18296 in this package can be used to reestablish the required mode.
18298 @node GNAT.Heap_Sort (g-heasor.ads)
18299 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18300 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
18304 Provides a general implementation of heap sort usable for sorting arbitrary
18305 data items. Exchange and comparison procedures are provided by passing
18306 access-to-procedure values. The algorithm used is a modified heap sort
18307 that performs approximately N*log(N) comparisons in the worst case.
18309 @node GNAT.Heap_Sort_A (g-hesora.ads)
18310 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18311 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
18315 Provides a general implementation of heap sort usable for sorting arbitrary
18316 data items. Move and comparison procedures are provided by passing
18317 access-to-procedure values. The algorithm used is a modified heap sort
18318 that performs approximately N*log(N) comparisons in the worst case.
18319 This differs from @code{GNAT.Heap_Sort} in having a less convenient
18320 interface, but may be slightly more efficient.
18322 @node GNAT.Heap_Sort_G (g-hesorg.ads)
18323 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18324 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
18328 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
18329 are provided as generic parameters, this improves efficiency, especially
18330 if the procedures can be inlined, at the expense of duplicating code for
18331 multiple instantiations.
18333 @node GNAT.HTable (g-htable.ads)
18334 @section @code{GNAT.HTable} (@file{g-htable.ads})
18335 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
18336 @cindex Hash tables
18339 A generic implementation of hash tables that can be used to hash arbitrary
18340 data. Provides two approaches, one a simple static approach, and the other
18341 allowing arbitrary dynamic hash tables.
18343 @node GNAT.IO (g-io.ads)
18344 @section @code{GNAT.IO} (@file{g-io.ads})
18345 @cindex @code{GNAT.IO} (@file{g-io.ads})
18347 @cindex Input/Output facilities
18350 A simple preelaborable input-output package that provides a subset of
18351 simple Text_IO functions for reading characters and strings from
18352 Standard_Input, and writing characters, strings and integers to either
18353 Standard_Output or Standard_Error.
18355 @node GNAT.IO_Aux (g-io_aux.ads)
18356 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18357 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
18359 @cindex Input/Output facilities
18361 Provides some auxiliary functions for use with Text_IO, including a test
18362 for whether a file exists, and functions for reading a line of text.
18364 @node GNAT.Lock_Files (g-locfil.ads)
18365 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18366 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
18367 @cindex File locking
18368 @cindex Locking using files
18371 Provides a general interface for using files as locks. Can be used for
18372 providing program level synchronization.
18374 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
18375 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18376 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
18377 @cindex Random number generation
18380 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
18381 a modified version of the Blum-Blum-Shub generator.
18383 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
18384 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18385 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
18386 @cindex Random number generation
18389 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
18390 a modified version of the Blum-Blum-Shub generator.
18392 @node GNAT.MD5 (g-md5.ads)
18393 @section @code{GNAT.MD5} (@file{g-md5.ads})
18394 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
18395 @cindex Message Digest MD5
18398 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
18400 @node GNAT.Memory_Dump (g-memdum.ads)
18401 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18402 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
18403 @cindex Dump Memory
18406 Provides a convenient routine for dumping raw memory to either the
18407 standard output or standard error files. Uses GNAT.IO for actual
18410 @node GNAT.Most_Recent_Exception (g-moreex.ads)
18411 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18412 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
18413 @cindex Exception, obtaining most recent
18416 Provides access to the most recently raised exception. Can be used for
18417 various logging purposes, including duplicating functionality of some
18418 Ada 83 implementation dependent extensions.
18420 @node GNAT.OS_Lib (g-os_lib.ads)
18421 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18422 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
18423 @cindex Operating System interface
18424 @cindex Spawn capability
18427 Provides a range of target independent operating system interface functions,
18428 including time/date management, file operations, subprocess management,
18429 including a portable spawn procedure, and access to environment variables
18430 and error return codes.
18432 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
18433 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18434 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
18435 @cindex Hash functions
18438 Provides a generator of static minimal perfect hash functions. No
18439 collisions occur and each item can be retrieved from the table in one
18440 probe (perfect property). The hash table size corresponds to the exact
18441 size of the key set and no larger (minimal property). The key set has to
18442 be know in advance (static property). The hash functions are also order
18443 preserving. If w2 is inserted after w1 in the generator, their
18444 hashcode are in the same order. These hashing functions are very
18445 convenient for use with realtime applications.
18447 @node GNAT.Random_Numbers (g-rannum.ads)
18448 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18449 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
18450 @cindex Random number generation
18453 Provides random number capabilities which extend those available in the
18454 standard Ada library and are more convenient to use.
18456 @node GNAT.Regexp (g-regexp.ads)
18457 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
18458 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
18459 @cindex Regular expressions
18460 @cindex Pattern matching
18463 A simple implementation of regular expressions, using a subset of regular
18464 expression syntax copied from familiar Unix style utilities. This is the
18465 simples of the three pattern matching packages provided, and is particularly
18466 suitable for ``file globbing'' applications.
18468 @node GNAT.Registry (g-regist.ads)
18469 @section @code{GNAT.Registry} (@file{g-regist.ads})
18470 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
18471 @cindex Windows Registry
18474 This is a high level binding to the Windows registry. It is possible to
18475 do simple things like reading a key value, creating a new key. For full
18476 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
18477 package provided with the Win32Ada binding
18479 @node GNAT.Regpat (g-regpat.ads)
18480 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
18481 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
18482 @cindex Regular expressions
18483 @cindex Pattern matching
18486 A complete implementation of Unix-style regular expression matching, copied
18487 from the original V7 style regular expression library written in C by
18488 Henry Spencer (and binary compatible with this C library).
18490 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
18491 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18492 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
18493 @cindex Secondary Stack Info
18496 Provide the capability to query the high water mark of the current task's
18499 @node GNAT.Semaphores (g-semaph.ads)
18500 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
18501 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
18505 Provides classic counting and binary semaphores using protected types.
18507 @node GNAT.Serial_Communications (g-sercom.ads)
18508 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18509 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
18510 @cindex Serial_Communications
18513 Provides a simple interface to send and receive data over a serial
18514 port. This is only supported on GNU/Linux and Windows.
18516 @node GNAT.SHA1 (g-sha1.ads)
18517 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
18518 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
18519 @cindex Secure Hash Algorithm SHA-1
18522 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
18525 @node GNAT.SHA224 (g-sha224.ads)
18526 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
18527 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
18528 @cindex Secure Hash Algorithm SHA-224
18531 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
18533 @node GNAT.SHA256 (g-sha256.ads)
18534 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
18535 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
18536 @cindex Secure Hash Algorithm SHA-256
18539 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
18541 @node GNAT.SHA384 (g-sha384.ads)
18542 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
18543 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
18544 @cindex Secure Hash Algorithm SHA-384
18547 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
18549 @node GNAT.SHA512 (g-sha512.ads)
18550 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
18551 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
18552 @cindex Secure Hash Algorithm SHA-512
18555 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
18557 @node GNAT.Signals (g-signal.ads)
18558 @section @code{GNAT.Signals} (@file{g-signal.ads})
18559 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
18563 Provides the ability to manipulate the blocked status of signals on supported
18566 @node GNAT.Sockets (g-socket.ads)
18567 @section @code{GNAT.Sockets} (@file{g-socket.ads})
18568 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
18572 A high level and portable interface to develop sockets based applications.
18573 This package is based on the sockets thin binding found in
18574 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
18575 on all native GNAT ports except for OpenVMS@. It is not implemented
18576 for the LynxOS@ cross port.
18578 @node GNAT.Source_Info (g-souinf.ads)
18579 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
18580 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
18581 @cindex Source Information
18584 Provides subprograms that give access to source code information known at
18585 compile time, such as the current file name and line number.
18587 @node GNAT.Spelling_Checker (g-speche.ads)
18588 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18589 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
18590 @cindex Spell checking
18593 Provides a function for determining whether one string is a plausible
18594 near misspelling of another string.
18596 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
18597 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18598 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
18599 @cindex Spell checking
18602 Provides a generic function that can be instantiated with a string type for
18603 determining whether one string is a plausible near misspelling of another
18606 @node GNAT.Spitbol.Patterns (g-spipat.ads)
18607 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18608 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
18609 @cindex SPITBOL pattern matching
18610 @cindex Pattern matching
18613 A complete implementation of SNOBOL4 style pattern matching. This is the
18614 most elaborate of the pattern matching packages provided. It fully duplicates
18615 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
18616 efficient algorithm developed by Robert Dewar for the SPITBOL system.
18618 @node GNAT.Spitbol (g-spitbo.ads)
18619 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18620 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
18621 @cindex SPITBOL interface
18624 The top level package of the collection of SPITBOL-style functionality, this
18625 package provides basic SNOBOL4 string manipulation functions, such as
18626 Pad, Reverse, Trim, Substr capability, as well as a generic table function
18627 useful for constructing arbitrary mappings from strings in the style of
18628 the SNOBOL4 TABLE function.
18630 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
18631 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18632 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
18633 @cindex Sets of strings
18634 @cindex SPITBOL Tables
18637 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18638 for type @code{Standard.Boolean}, giving an implementation of sets of
18641 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
18642 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18643 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
18644 @cindex Integer maps
18646 @cindex SPITBOL Tables
18649 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
18650 for type @code{Standard.Integer}, giving an implementation of maps
18651 from string to integer values.
18653 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
18654 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18655 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
18656 @cindex String maps
18658 @cindex SPITBOL Tables
18661 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
18662 a variable length string type, giving an implementation of general
18663 maps from strings to strings.
18665 @node GNAT.SSE (g-sse.ads)
18666 @section @code{GNAT.SSE} (@file{g-sse.ads})
18667 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
18670 Root of a set of units aimed at offering Ada bindings to a subset of
18671 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
18672 targets. It exposes vector component types together with a general
18673 introduction to the binding contents and use.
18675 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
18676 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18677 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
18680 SSE vector types for use with SSE related intrinsics.
18682 @node GNAT.Strings (g-string.ads)
18683 @section @code{GNAT.Strings} (@file{g-string.ads})
18684 @cindex @code{GNAT.Strings} (@file{g-string.ads})
18687 Common String access types and related subprograms. Basically it
18688 defines a string access and an array of string access types.
18690 @node GNAT.String_Split (g-strspl.ads)
18691 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
18692 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
18693 @cindex String splitter
18696 Useful string manipulation routines: given a set of separators, split
18697 a string wherever the separators appear, and provide direct access
18698 to the resulting slices. This package is instantiated from
18699 @code{GNAT.Array_Split}.
18701 @node GNAT.Table (g-table.ads)
18702 @section @code{GNAT.Table} (@file{g-table.ads})
18703 @cindex @code{GNAT.Table} (@file{g-table.ads})
18704 @cindex Table implementation
18705 @cindex Arrays, extendable
18708 A generic package providing a single dimension array abstraction where the
18709 length of the array can be dynamically modified.
18712 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
18713 except that this package declares a single instance of the table type,
18714 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
18715 used to define dynamic instances of the table.
18717 @node GNAT.Task_Lock (g-tasloc.ads)
18718 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18719 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
18720 @cindex Task synchronization
18721 @cindex Task locking
18725 A very simple facility for locking and unlocking sections of code using a
18726 single global task lock. Appropriate for use in situations where contention
18727 between tasks is very rarely expected.
18729 @node GNAT.Time_Stamp (g-timsta.ads)
18730 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18731 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
18733 @cindex Current time
18736 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
18737 represents the current date and time in ISO 8601 format. This is a very simple
18738 routine with minimal code and there are no dependencies on any other unit.
18740 @node GNAT.Threads (g-thread.ads)
18741 @section @code{GNAT.Threads} (@file{g-thread.ads})
18742 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
18743 @cindex Foreign threads
18744 @cindex Threads, foreign
18747 Provides facilities for dealing with foreign threads which need to be known
18748 by the GNAT run-time system. Consult the documentation of this package for
18749 further details if your program has threads that are created by a non-Ada
18750 environment which then accesses Ada code.
18752 @node GNAT.Traceback (g-traceb.ads)
18753 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
18754 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
18755 @cindex Trace back facilities
18758 Provides a facility for obtaining non-symbolic traceback information, useful
18759 in various debugging situations.
18761 @node GNAT.Traceback.Symbolic (g-trasym.ads)
18762 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18763 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
18764 @cindex Trace back facilities
18766 @node GNAT.UTF_32 (g-utf_32.ads)
18767 @section @code{GNAT.UTF_32} (@file{g-table.ads})
18768 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18769 @cindex Wide character codes
18772 This is a package intended to be used in conjunction with the
18773 @code{Wide_Character} type in Ada 95 and the
18774 @code{Wide_Wide_Character} type in Ada 2005 (available
18775 in @code{GNAT} in Ada 2005 mode). This package contains
18776 Unicode categorization routines, as well as lexical
18777 categorization routines corresponding to the Ada 2005
18778 lexical rules for identifiers and strings, and also a
18779 lower case to upper case fold routine corresponding to
18780 the Ada 2005 rules for identifier equivalence.
18782 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18783 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18784 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18785 @cindex Spell checking
18788 Provides a function for determining whether one wide wide string is a plausible
18789 near misspelling of another wide wide string, where the strings are represented
18790 using the UTF_32_String type defined in System.Wch_Cnv.
18792 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18793 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18794 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18795 @cindex Spell checking
18798 Provides a function for determining whether one wide string is a plausible
18799 near misspelling of another wide string.
18801 @node GNAT.Wide_String_Split (g-wistsp.ads)
18802 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18803 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18804 @cindex Wide_String splitter
18807 Useful wide string manipulation routines: given a set of separators, split
18808 a wide string wherever the separators appear, and provide direct access
18809 to the resulting slices. This package is instantiated from
18810 @code{GNAT.Array_Split}.
18812 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18813 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18814 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18815 @cindex Spell checking
18818 Provides a function for determining whether one wide wide string is a plausible
18819 near misspelling of another wide wide string.
18821 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18822 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18823 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18824 @cindex Wide_Wide_String splitter
18827 Useful wide wide string manipulation routines: given a set of separators, split
18828 a wide wide string wherever the separators appear, and provide direct access
18829 to the resulting slices. This package is instantiated from
18830 @code{GNAT.Array_Split}.
18832 @node Interfaces.C.Extensions (i-cexten.ads)
18833 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18834 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18837 This package contains additional C-related definitions, intended
18838 for use with either manually or automatically generated bindings
18841 @node Interfaces.C.Streams (i-cstrea.ads)
18842 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18843 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18844 @cindex C streams, interfacing
18847 This package is a binding for the most commonly used operations
18850 @node Interfaces.CPP (i-cpp.ads)
18851 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18852 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18853 @cindex C++ interfacing
18854 @cindex Interfacing, to C++
18857 This package provides facilities for use in interfacing to C++. It
18858 is primarily intended to be used in connection with automated tools
18859 for the generation of C++ interfaces.
18861 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18862 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18863 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18864 @cindex IBM Packed Format
18865 @cindex Packed Decimal
18868 This package provides a set of routines for conversions to and
18869 from a packed decimal format compatible with that used on IBM
18872 @node Interfaces.VxWorks (i-vxwork.ads)
18873 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18874 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18875 @cindex Interfacing to VxWorks
18876 @cindex VxWorks, interfacing
18879 This package provides a limited binding to the VxWorks API.
18880 In particular, it interfaces with the
18881 VxWorks hardware interrupt facilities.
18883 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18884 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18885 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18886 @cindex Interfacing to VxWorks' I/O
18887 @cindex VxWorks, I/O interfacing
18888 @cindex VxWorks, Get_Immediate
18889 @cindex Get_Immediate, VxWorks
18892 This package provides a binding to the ioctl (IO/Control)
18893 function of VxWorks, defining a set of option values and
18894 function codes. A particular use of this package is
18895 to enable the use of Get_Immediate under VxWorks.
18897 @node System.Address_Image (s-addima.ads)
18898 @section @code{System.Address_Image} (@file{s-addima.ads})
18899 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18900 @cindex Address image
18901 @cindex Image, of an address
18904 This function provides a useful debugging
18905 function that gives an (implementation dependent)
18906 string which identifies an address.
18908 @node System.Assertions (s-assert.ads)
18909 @section @code{System.Assertions} (@file{s-assert.ads})
18910 @cindex @code{System.Assertions} (@file{s-assert.ads})
18912 @cindex Assert_Failure, exception
18915 This package provides the declaration of the exception raised
18916 by an run-time assertion failure, as well as the routine that
18917 is used internally to raise this assertion.
18919 @node System.Memory (s-memory.ads)
18920 @section @code{System.Memory} (@file{s-memory.ads})
18921 @cindex @code{System.Memory} (@file{s-memory.ads})
18922 @cindex Memory allocation
18925 This package provides the interface to the low level routines used
18926 by the generated code for allocation and freeing storage for the
18927 default storage pool (analogous to the C routines malloc and free.
18928 It also provides a reallocation interface analogous to the C routine
18929 realloc. The body of this unit may be modified to provide alternative
18930 allocation mechanisms for the default pool, and in addition, direct
18931 calls to this unit may be made for low level allocation uses (for
18932 example see the body of @code{GNAT.Tables}).
18934 @node System.Multiprocessors (s-multip.ads)
18935 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18936 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18937 @cindex Multiprocessor interface
18938 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18939 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18940 technically an implementation-defined addition).
18942 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18943 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18944 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18945 @cindex Multiprocessor interface
18946 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18947 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18948 technically an implementation-defined addition).
18950 @node System.Partition_Interface (s-parint.ads)
18951 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18952 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18953 @cindex Partition interfacing functions
18956 This package provides facilities for partition interfacing. It
18957 is used primarily in a distribution context when using Annex E
18960 @node System.Pool_Global (s-pooglo.ads)
18961 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18962 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18963 @cindex Storage pool, global
18964 @cindex Global storage pool
18967 This package provides a storage pool that is equivalent to the default
18968 storage pool used for access types for which no pool is specifically
18969 declared. It uses malloc/free to allocate/free and does not attempt to
18970 do any automatic reclamation.
18972 @node System.Pool_Local (s-pooloc.ads)
18973 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18974 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18975 @cindex Storage pool, local
18976 @cindex Local storage pool
18979 This package provides a storage pool that is intended for use with locally
18980 defined access types. It uses malloc/free for allocate/free, and maintains
18981 a list of allocated blocks, so that all storage allocated for the pool can
18982 be freed automatically when the pool is finalized.
18984 @node System.Restrictions (s-restri.ads)
18985 @section @code{System.Restrictions} (@file{s-restri.ads})
18986 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18987 @cindex Run-time restrictions access
18990 This package provides facilities for accessing at run time
18991 the status of restrictions specified at compile time for
18992 the partition. Information is available both with regard
18993 to actual restrictions specified, and with regard to
18994 compiler determined information on which restrictions
18995 are violated by one or more packages in the partition.
18997 @node System.Rident (s-rident.ads)
18998 @section @code{System.Rident} (@file{s-rident.ads})
18999 @cindex @code{System.Rident} (@file{s-rident.ads})
19000 @cindex Restrictions definitions
19003 This package provides definitions of the restrictions
19004 identifiers supported by GNAT, and also the format of
19005 the restrictions provided in package System.Restrictions.
19006 It is not normally necessary to @code{with} this generic package
19007 since the necessary instantiation is included in
19008 package System.Restrictions.
19010 @node System.Strings.Stream_Ops (s-ststop.ads)
19011 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
19012 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
19013 @cindex Stream operations
19014 @cindex String stream operations
19017 This package provides a set of stream subprograms for standard string types.
19018 It is intended primarily to support implicit use of such subprograms when
19019 stream attributes are applied to string types, but the subprograms in this
19020 package can be used directly by application programs.
19022 @node System.Task_Info (s-tasinf.ads)
19023 @section @code{System.Task_Info} (@file{s-tasinf.ads})
19024 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
19025 @cindex Task_Info pragma
19028 This package provides target dependent functionality that is used
19029 to support the @code{Task_Info} pragma
19031 @node System.Wch_Cnv (s-wchcnv.ads)
19032 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
19033 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
19034 @cindex Wide Character, Representation
19035 @cindex Wide String, Conversion
19036 @cindex Representation of wide characters
19039 This package provides routines for converting between
19040 wide and wide wide characters and a representation as a value of type
19041 @code{Standard.String}, using a specified wide character
19042 encoding method. It uses definitions in
19043 package @code{System.Wch_Con}.
19045 @node System.Wch_Con (s-wchcon.ads)
19046 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
19047 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
19050 This package provides definitions and descriptions of
19051 the various methods used for encoding wide characters
19052 in ordinary strings. These definitions are used by
19053 the package @code{System.Wch_Cnv}.
19055 @node Interfacing to Other Languages
19056 @chapter Interfacing to Other Languages
19058 The facilities in annex B of the Ada Reference Manual are fully
19059 implemented in GNAT, and in addition, a full interface to C++ is
19063 * Interfacing to C::
19064 * Interfacing to C++::
19065 * Interfacing to COBOL::
19066 * Interfacing to Fortran::
19067 * Interfacing to non-GNAT Ada code::
19070 @node Interfacing to C
19071 @section Interfacing to C
19074 Interfacing to C with GNAT can use one of two approaches:
19078 The types in the package @code{Interfaces.C} may be used.
19080 Standard Ada types may be used directly. This may be less portable to
19081 other compilers, but will work on all GNAT compilers, which guarantee
19082 correspondence between the C and Ada types.
19086 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
19087 effect, since this is the default. The following table shows the
19088 correspondence between Ada scalar types and the corresponding C types.
19093 @item Short_Integer
19095 @item Short_Short_Integer
19099 @item Long_Long_Integer
19107 @item Long_Long_Float
19108 This is the longest floating-point type supported by the hardware.
19112 Additionally, there are the following general correspondences between Ada
19116 Ada enumeration types map to C enumeration types directly if pragma
19117 @code{Convention C} is specified, which causes them to have int
19118 length. Without pragma @code{Convention C}, Ada enumeration types map to
19119 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
19120 @code{int}, respectively) depending on the number of values passed.
19121 This is the only case in which pragma @code{Convention C} affects the
19122 representation of an Ada type.
19125 Ada access types map to C pointers, except for the case of pointers to
19126 unconstrained types in Ada, which have no direct C equivalent.
19129 Ada arrays map directly to C arrays.
19132 Ada records map directly to C structures.
19135 Packed Ada records map to C structures where all members are bit fields
19136 of the length corresponding to the @code{@var{type}'Size} value in Ada.
19139 @node Interfacing to C++
19140 @section Interfacing to C++
19143 The interface to C++ makes use of the following pragmas, which are
19144 primarily intended to be constructed automatically using a binding generator
19145 tool, although it is possible to construct them by hand.
19147 Using these pragmas it is possible to achieve complete
19148 inter-operability between Ada tagged types and C++ class definitions.
19149 See @ref{Implementation Defined Pragmas}, for more details.
19152 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
19153 The argument denotes an entity in the current declarative region that is
19154 declared as a tagged or untagged record type. It indicates that the type
19155 corresponds to an externally declared C++ class type, and is to be laid
19156 out the same way that C++ would lay out the type.
19158 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
19159 for backward compatibility but its functionality is available
19160 using pragma @code{Import} with @code{Convention} = @code{CPP}.
19162 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
19163 This pragma identifies an imported function (imported in the usual way
19164 with pragma @code{Import}) as corresponding to a C++ constructor.
19167 A few restrictions are placed on the use of the @code{Access} attribute
19168 in conjunction with subprograms subject to convention @code{CPP}: the
19169 attribute may be used neither on primitive operations of a tagged
19170 record type with convention @code{CPP}, imported or not, nor on
19171 subprograms imported with pragma @code{CPP_Constructor}.
19173 In addition, C++ exceptions are propagated and can be handled in an
19174 @code{others} choice of an exception handler. The corresponding Ada
19175 occurrence has no message, and the simple name of the exception identity
19176 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
19177 tasks works properly when such foreign exceptions are propagated.
19179 It is also possible to import a C++ exception using the following syntax:
19181 @smallexample @c ada
19182 LOCAL_NAME : exception;
19183 pragma Import (Cpp,
19184 [Entity =>] LOCAL_NAME,
19185 [External_Name =>] static_string_EXPRESSION);
19189 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
19190 cover a specific C++ exception in an exception handler.
19192 @node Interfacing to COBOL
19193 @section Interfacing to COBOL
19196 Interfacing to COBOL is achieved as described in section B.4 of
19197 the Ada Reference Manual.
19199 @node Interfacing to Fortran
19200 @section Interfacing to Fortran
19203 Interfacing to Fortran is achieved as described in section B.5 of the
19204 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
19205 multi-dimensional array causes the array to be stored in column-major
19206 order as required for convenient interface to Fortran.
19208 @node Interfacing to non-GNAT Ada code
19209 @section Interfacing to non-GNAT Ada code
19211 It is possible to specify the convention @code{Ada} in a pragma
19212 @code{Import} or pragma @code{Export}. However this refers to
19213 the calling conventions used by GNAT, which may or may not be
19214 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
19215 compiler to allow interoperation.
19217 If arguments types are kept simple, and if the foreign compiler generally
19218 follows system calling conventions, then it may be possible to integrate
19219 files compiled by other Ada compilers, provided that the elaboration
19220 issues are adequately addressed (for example by eliminating the
19221 need for any load time elaboration).
19223 In particular, GNAT running on VMS is designed to
19224 be highly compatible with the DEC Ada 83 compiler, so this is one
19225 case in which it is possible to import foreign units of this type,
19226 provided that the data items passed are restricted to simple scalar
19227 values or simple record types without variants, or simple array
19228 types with fixed bounds.
19230 @node Specialized Needs Annexes
19231 @chapter Specialized Needs Annexes
19234 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
19235 required in all implementations. However, as described in this chapter,
19236 GNAT implements all of these annexes:
19239 @item Systems Programming (Annex C)
19240 The Systems Programming Annex is fully implemented.
19242 @item Real-Time Systems (Annex D)
19243 The Real-Time Systems Annex is fully implemented.
19245 @item Distributed Systems (Annex E)
19246 Stub generation is fully implemented in the GNAT compiler. In addition,
19247 a complete compatible PCS is available as part of the GLADE system,
19248 a separate product. When the two
19249 products are used in conjunction, this annex is fully implemented.
19251 @item Information Systems (Annex F)
19252 The Information Systems annex is fully implemented.
19254 @item Numerics (Annex G)
19255 The Numerics Annex is fully implemented.
19257 @item Safety and Security / High-Integrity Systems (Annex H)
19258 The Safety and Security Annex (termed the High-Integrity Systems Annex
19259 in Ada 2005) is fully implemented.
19262 @node Implementation of Specific Ada Features
19263 @chapter Implementation of Specific Ada Features
19266 This chapter describes the GNAT implementation of several Ada language
19270 * Machine Code Insertions::
19271 * GNAT Implementation of Tasking::
19272 * GNAT Implementation of Shared Passive Packages::
19273 * Code Generation for Array Aggregates::
19274 * The Size of Discriminated Records with Default Discriminants::
19275 * Strict Conformance to the Ada Reference Manual::
19278 @node Machine Code Insertions
19279 @section Machine Code Insertions
19280 @cindex Machine Code insertions
19283 Package @code{Machine_Code} provides machine code support as described
19284 in the Ada Reference Manual in two separate forms:
19287 Machine code statements, consisting of qualified expressions that
19288 fit the requirements of RM section 13.8.
19290 An intrinsic callable procedure, providing an alternative mechanism of
19291 including machine instructions in a subprogram.
19295 The two features are similar, and both are closely related to the mechanism
19296 provided by the asm instruction in the GNU C compiler. Full understanding
19297 and use of the facilities in this package requires understanding the asm
19298 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
19299 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
19301 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
19302 semantic restrictions and effects as described below. Both are provided so
19303 that the procedure call can be used as a statement, and the function call
19304 can be used to form a code_statement.
19306 The first example given in the GCC documentation is the C @code{asm}
19309 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
19313 The equivalent can be written for GNAT as:
19315 @smallexample @c ada
19316 Asm ("fsinx %1 %0",
19317 My_Float'Asm_Output ("=f", result),
19318 My_Float'Asm_Input ("f", angle));
19322 The first argument to @code{Asm} is the assembler template, and is
19323 identical to what is used in GNU C@. This string must be a static
19324 expression. The second argument is the output operand list. It is
19325 either a single @code{Asm_Output} attribute reference, or a list of such
19326 references enclosed in parentheses (technically an array aggregate of
19329 The @code{Asm_Output} attribute denotes a function that takes two
19330 parameters. The first is a string, the second is the name of a variable
19331 of the type designated by the attribute prefix. The first (string)
19332 argument is required to be a static expression and designates the
19333 constraint for the parameter (e.g.@: what kind of register is
19334 required). The second argument is the variable to be updated with the
19335 result. The possible values for constraint are the same as those used in
19336 the RTL, and are dependent on the configuration file used to build the
19337 GCC back end. If there are no output operands, then this argument may
19338 either be omitted, or explicitly given as @code{No_Output_Operands}.
19340 The second argument of @code{@var{my_float}'Asm_Output} functions as
19341 though it were an @code{out} parameter, which is a little curious, but
19342 all names have the form of expressions, so there is no syntactic
19343 irregularity, even though normally functions would not be permitted
19344 @code{out} parameters. The third argument is the list of input
19345 operands. It is either a single @code{Asm_Input} attribute reference, or
19346 a list of such references enclosed in parentheses (technically an array
19347 aggregate of such references).
19349 The @code{Asm_Input} attribute denotes a function that takes two
19350 parameters. The first is a string, the second is an expression of the
19351 type designated by the prefix. The first (string) argument is required
19352 to be a static expression, and is the constraint for the parameter,
19353 (e.g.@: what kind of register is required). The second argument is the
19354 value to be used as the input argument. The possible values for the
19355 constant are the same as those used in the RTL, and are dependent on
19356 the configuration file used to built the GCC back end.
19358 If there are no input operands, this argument may either be omitted, or
19359 explicitly given as @code{No_Input_Operands}. The fourth argument, not
19360 present in the above example, is a list of register names, called the
19361 @dfn{clobber} argument. This argument, if given, must be a static string
19362 expression, and is a space or comma separated list of names of registers
19363 that must be considered destroyed as a result of the @code{Asm} call. If
19364 this argument is the null string (the default value), then the code
19365 generator assumes that no additional registers are destroyed.
19367 The fifth argument, not present in the above example, called the
19368 @dfn{volatile} argument, is by default @code{False}. It can be set to
19369 the literal value @code{True} to indicate to the code generator that all
19370 optimizations with respect to the instruction specified should be
19371 suppressed, and that in particular, for an instruction that has outputs,
19372 the instruction will still be generated, even if none of the outputs are
19373 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
19374 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
19375 Generally it is strongly advisable to use Volatile for any ASM statement
19376 that is missing either input or output operands, or when two or more ASM
19377 statements appear in sequence, to avoid unwanted optimizations. A warning
19378 is generated if this advice is not followed.
19380 The @code{Asm} subprograms may be used in two ways. First the procedure
19381 forms can be used anywhere a procedure call would be valid, and
19382 correspond to what the RM calls ``intrinsic'' routines. Such calls can
19383 be used to intersperse machine instructions with other Ada statements.
19384 Second, the function forms, which return a dummy value of the limited
19385 private type @code{Asm_Insn}, can be used in code statements, and indeed
19386 this is the only context where such calls are allowed. Code statements
19387 appear as aggregates of the form:
19389 @smallexample @c ada
19390 Asm_Insn'(Asm (@dots{}));
19391 Asm_Insn'(Asm_Volatile (@dots{}));
19395 In accordance with RM rules, such code statements are allowed only
19396 within subprograms whose entire body consists of such statements. It is
19397 not permissible to intermix such statements with other Ada statements.
19399 Typically the form using intrinsic procedure calls is more convenient
19400 and more flexible. The code statement form is provided to meet the RM
19401 suggestion that such a facility should be made available. The following
19402 is the exact syntax of the call to @code{Asm}. As usual, if named notation
19403 is used, the arguments may be given in arbitrary order, following the
19404 normal rules for use of positional and named arguments)
19408 [Template =>] static_string_EXPRESSION
19409 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
19410 [,[Inputs =>] INPUT_OPERAND_LIST ]
19411 [,[Clobber =>] static_string_EXPRESSION ]
19412 [,[Volatile =>] static_boolean_EXPRESSION] )
19414 OUTPUT_OPERAND_LIST ::=
19415 [PREFIX.]No_Output_Operands
19416 | OUTPUT_OPERAND_ATTRIBUTE
19417 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
19419 OUTPUT_OPERAND_ATTRIBUTE ::=
19420 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
19422 INPUT_OPERAND_LIST ::=
19423 [PREFIX.]No_Input_Operands
19424 | INPUT_OPERAND_ATTRIBUTE
19425 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
19427 INPUT_OPERAND_ATTRIBUTE ::=
19428 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
19432 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
19433 are declared in the package @code{Machine_Code} and must be referenced
19434 according to normal visibility rules. In particular if there is no
19435 @code{use} clause for this package, then appropriate package name
19436 qualification is required.
19438 @node GNAT Implementation of Tasking
19439 @section GNAT Implementation of Tasking
19442 This chapter outlines the basic GNAT approach to tasking (in particular,
19443 a multi-layered library for portability) and discusses issues related
19444 to compliance with the Real-Time Systems Annex.
19447 * Mapping Ada Tasks onto the Underlying Kernel Threads::
19448 * Ensuring Compliance with the Real-Time Annex::
19451 @node Mapping Ada Tasks onto the Underlying Kernel Threads
19452 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
19455 GNAT's run-time support comprises two layers:
19458 @item GNARL (GNAT Run-time Layer)
19459 @item GNULL (GNAT Low-level Library)
19463 In GNAT, Ada's tasking services rely on a platform and OS independent
19464 layer known as GNARL@. This code is responsible for implementing the
19465 correct semantics of Ada's task creation, rendezvous, protected
19468 GNARL decomposes Ada's tasking semantics into simpler lower level
19469 operations such as create a thread, set the priority of a thread,
19470 yield, create a lock, lock/unlock, etc. The spec for these low-level
19471 operations constitutes GNULLI, the GNULL Interface. This interface is
19472 directly inspired from the POSIX real-time API@.
19474 If the underlying executive or OS implements the POSIX standard
19475 faithfully, the GNULL Interface maps as is to the services offered by
19476 the underlying kernel. Otherwise, some target dependent glue code maps
19477 the services offered by the underlying kernel to the semantics expected
19480 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
19481 key point is that each Ada task is mapped on a thread in the underlying
19482 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
19484 In addition Ada task priorities map onto the underlying thread priorities.
19485 Mapping Ada tasks onto the underlying kernel threads has several advantages:
19489 The underlying scheduler is used to schedule the Ada tasks. This
19490 makes Ada tasks as efficient as kernel threads from a scheduling
19494 Interaction with code written in C containing threads is eased
19495 since at the lowest level Ada tasks and C threads map onto the same
19496 underlying kernel concept.
19499 When an Ada task is blocked during I/O the remaining Ada tasks are
19503 On multiprocessor systems Ada tasks can execute in parallel.
19507 Some threads libraries offer a mechanism to fork a new process, with the
19508 child process duplicating the threads from the parent.
19510 support this functionality when the parent contains more than one task.
19511 @cindex Forking a new process
19513 @node Ensuring Compliance with the Real-Time Annex
19514 @subsection Ensuring Compliance with the Real-Time Annex
19515 @cindex Real-Time Systems Annex compliance
19518 Although mapping Ada tasks onto
19519 the underlying threads has significant advantages, it does create some
19520 complications when it comes to respecting the scheduling semantics
19521 specified in the real-time annex (Annex D).
19523 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
19524 scheduling policy states:
19527 @emph{When the active priority of a ready task that is not running
19528 changes, or the setting of its base priority takes effect, the
19529 task is removed from the ready queue for its old active priority
19530 and is added at the tail of the ready queue for its new active
19531 priority, except in the case where the active priority is lowered
19532 due to the loss of inherited priority, in which case the task is
19533 added at the head of the ready queue for its new active priority.}
19537 While most kernels do put tasks at the end of the priority queue when
19538 a task changes its priority, (which respects the main
19539 FIFO_Within_Priorities requirement), almost none keep a thread at the
19540 beginning of its priority queue when its priority drops from the loss
19541 of inherited priority.
19543 As a result most vendors have provided incomplete Annex D implementations.
19545 The GNAT run-time, has a nice cooperative solution to this problem
19546 which ensures that accurate FIFO_Within_Priorities semantics are
19549 The principle is as follows. When an Ada task T is about to start
19550 running, it checks whether some other Ada task R with the same
19551 priority as T has been suspended due to the loss of priority
19552 inheritance. If this is the case, T yields and is placed at the end of
19553 its priority queue. When R arrives at the front of the queue it
19556 Note that this simple scheme preserves the relative order of the tasks
19557 that were ready to execute in the priority queue where R has been
19560 @node GNAT Implementation of Shared Passive Packages
19561 @section GNAT Implementation of Shared Passive Packages
19562 @cindex Shared passive packages
19565 GNAT fully implements the pragma @code{Shared_Passive} for
19566 @cindex pragma @code{Shared_Passive}
19567 the purpose of designating shared passive packages.
19568 This allows the use of passive partitions in the
19569 context described in the Ada Reference Manual; i.e., for communication
19570 between separate partitions of a distributed application using the
19571 features in Annex E.
19573 @cindex Distribution Systems Annex
19575 However, the implementation approach used by GNAT provides for more
19576 extensive usage as follows:
19579 @item Communication between separate programs
19581 This allows separate programs to access the data in passive
19582 partitions, using protected objects for synchronization where
19583 needed. The only requirement is that the two programs have a
19584 common shared file system. It is even possible for programs
19585 running on different machines with different architectures
19586 (e.g.@: different endianness) to communicate via the data in
19587 a passive partition.
19589 @item Persistence between program runs
19591 The data in a passive package can persist from one run of a
19592 program to another, so that a later program sees the final
19593 values stored by a previous run of the same program.
19598 The implementation approach used is to store the data in files. A
19599 separate stream file is created for each object in the package, and
19600 an access to an object causes the corresponding file to be read or
19603 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
19604 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
19605 set to the directory to be used for these files.
19606 The files in this directory
19607 have names that correspond to their fully qualified names. For
19608 example, if we have the package
19610 @smallexample @c ada
19612 pragma Shared_Passive (X);
19619 and the environment variable is set to @code{/stemp/}, then the files created
19620 will have the names:
19628 These files are created when a value is initially written to the object, and
19629 the files are retained until manually deleted. This provides the persistence
19630 semantics. If no file exists, it means that no partition has assigned a value
19631 to the variable; in this case the initial value declared in the package
19632 will be used. This model ensures that there are no issues in synchronizing
19633 the elaboration process, since elaboration of passive packages elaborates the
19634 initial values, but does not create the files.
19636 The files are written using normal @code{Stream_IO} access.
19637 If you want to be able
19638 to communicate between programs or partitions running on different
19639 architectures, then you should use the XDR versions of the stream attribute
19640 routines, since these are architecture independent.
19642 If active synchronization is required for access to the variables in the
19643 shared passive package, then as described in the Ada Reference Manual, the
19644 package may contain protected objects used for this purpose. In this case
19645 a lock file (whose name is @file{___lock} (three underscores)
19646 is created in the shared memory directory.
19647 @cindex @file{___lock} file (for shared passive packages)
19648 This is used to provide the required locking
19649 semantics for proper protected object synchronization.
19651 As of January 2003, GNAT supports shared passive packages on all platforms
19652 except for OpenVMS.
19654 @node Code Generation for Array Aggregates
19655 @section Code Generation for Array Aggregates
19658 * Static constant aggregates with static bounds::
19659 * Constant aggregates with unconstrained nominal types::
19660 * Aggregates with static bounds::
19661 * Aggregates with non-static bounds::
19662 * Aggregates in assignment statements::
19666 Aggregates have a rich syntax and allow the user to specify the values of
19667 complex data structures by means of a single construct. As a result, the
19668 code generated for aggregates can be quite complex and involve loops, case
19669 statements and multiple assignments. In the simplest cases, however, the
19670 compiler will recognize aggregates whose components and constraints are
19671 fully static, and in those cases the compiler will generate little or no
19672 executable code. The following is an outline of the code that GNAT generates
19673 for various aggregate constructs. For further details, you will find it
19674 useful to examine the output produced by the -gnatG flag to see the expanded
19675 source that is input to the code generator. You may also want to examine
19676 the assembly code generated at various levels of optimization.
19678 The code generated for aggregates depends on the context, the component values,
19679 and the type. In the context of an object declaration the code generated is
19680 generally simpler than in the case of an assignment. As a general rule, static
19681 component values and static subtypes also lead to simpler code.
19683 @node Static constant aggregates with static bounds
19684 @subsection Static constant aggregates with static bounds
19687 For the declarations:
19688 @smallexample @c ada
19689 type One_Dim is array (1..10) of integer;
19690 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
19694 GNAT generates no executable code: the constant ar0 is placed in static memory.
19695 The same is true for constant aggregates with named associations:
19697 @smallexample @c ada
19698 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
19699 Cr3 : constant One_Dim := (others => 7777);
19703 The same is true for multidimensional constant arrays such as:
19705 @smallexample @c ada
19706 type two_dim is array (1..3, 1..3) of integer;
19707 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
19711 The same is true for arrays of one-dimensional arrays: the following are
19714 @smallexample @c ada
19715 type ar1b is array (1..3) of boolean;
19716 type ar_ar is array (1..3) of ar1b;
19717 None : constant ar1b := (others => false); -- fully static
19718 None2 : constant ar_ar := (1..3 => None); -- fully static
19722 However, for multidimensional aggregates with named associations, GNAT will
19723 generate assignments and loops, even if all associations are static. The
19724 following two declarations generate a loop for the first dimension, and
19725 individual component assignments for the second dimension:
19727 @smallexample @c ada
19728 Zero1: constant two_dim := (1..3 => (1..3 => 0));
19729 Zero2: constant two_dim := (others => (others => 0));
19732 @node Constant aggregates with unconstrained nominal types
19733 @subsection Constant aggregates with unconstrained nominal types
19736 In such cases the aggregate itself establishes the subtype, so that
19737 associations with @code{others} cannot be used. GNAT determines the
19738 bounds for the actual subtype of the aggregate, and allocates the
19739 aggregate statically as well. No code is generated for the following:
19741 @smallexample @c ada
19742 type One_Unc is array (natural range <>) of integer;
19743 Cr_Unc : constant One_Unc := (12,24,36);
19746 @node Aggregates with static bounds
19747 @subsection Aggregates with static bounds
19750 In all previous examples the aggregate was the initial (and immutable) value
19751 of a constant. If the aggregate initializes a variable, then code is generated
19752 for it as a combination of individual assignments and loops over the target
19753 object. The declarations
19755 @smallexample @c ada
19756 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
19757 Cr_Var2 : One_Dim := (others > -1);
19761 generate the equivalent of
19763 @smallexample @c ada
19769 for I in Cr_Var2'range loop
19774 @node Aggregates with non-static bounds
19775 @subsection Aggregates with non-static bounds
19778 If the bounds of the aggregate are not statically compatible with the bounds
19779 of the nominal subtype of the target, then constraint checks have to be
19780 generated on the bounds. For a multidimensional array, constraint checks may
19781 have to be applied to sub-arrays individually, if they do not have statically
19782 compatible subtypes.
19784 @node Aggregates in assignment statements
19785 @subsection Aggregates in assignment statements
19788 In general, aggregate assignment requires the construction of a temporary,
19789 and a copy from the temporary to the target of the assignment. This is because
19790 it is not always possible to convert the assignment into a series of individual
19791 component assignments. For example, consider the simple case:
19793 @smallexample @c ada
19798 This cannot be converted into:
19800 @smallexample @c ada
19806 So the aggregate has to be built first in a separate location, and then
19807 copied into the target. GNAT recognizes simple cases where this intermediate
19808 step is not required, and the assignments can be performed in place, directly
19809 into the target. The following sufficient criteria are applied:
19813 The bounds of the aggregate are static, and the associations are static.
19815 The components of the aggregate are static constants, names of
19816 simple variables that are not renamings, or expressions not involving
19817 indexed components whose operands obey these rules.
19821 If any of these conditions are violated, the aggregate will be built in
19822 a temporary (created either by the front-end or the code generator) and then
19823 that temporary will be copied onto the target.
19825 @node The Size of Discriminated Records with Default Discriminants
19826 @section The Size of Discriminated Records with Default Discriminants
19829 If a discriminated type @code{T} has discriminants with default values, it is
19830 possible to declare an object of this type without providing an explicit
19833 @smallexample @c ada
19835 type Size is range 1..100;
19837 type Rec (D : Size := 15) is record
19838 Name : String (1..D);
19846 Such an object is said to be @emph{unconstrained}.
19847 The discriminant of the object
19848 can be modified by a full assignment to the object, as long as it preserves the
19849 relation between the value of the discriminant, and the value of the components
19852 @smallexample @c ada
19854 Word := (3, "yes");
19856 Word := (5, "maybe");
19858 Word := (5, "no"); -- raises Constraint_Error
19863 In order to support this behavior efficiently, an unconstrained object is
19864 given the maximum size that any value of the type requires. In the case
19865 above, @code{Word} has storage for the discriminant and for
19866 a @code{String} of length 100.
19867 It is important to note that unconstrained objects do not require dynamic
19868 allocation. It would be an improper implementation to place on the heap those
19869 components whose size depends on discriminants. (This improper implementation
19870 was used by some Ada83 compilers, where the @code{Name} component above
19872 been stored as a pointer to a dynamic string). Following the principle that
19873 dynamic storage management should never be introduced implicitly,
19874 an Ada compiler should reserve the full size for an unconstrained declared
19875 object, and place it on the stack.
19877 This maximum size approach
19878 has been a source of surprise to some users, who expect the default
19879 values of the discriminants to determine the size reserved for an
19880 unconstrained object: ``If the default is 15, why should the object occupy
19882 The answer, of course, is that the discriminant may be later modified,
19883 and its full range of values must be taken into account. This is why the
19888 type Rec (D : Positive := 15) is record
19889 Name : String (1..D);
19897 is flagged by the compiler with a warning:
19898 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19899 because the required size includes @code{Positive'Last}
19900 bytes. As the first example indicates, the proper approach is to declare an
19901 index type of ``reasonable'' range so that unconstrained objects are not too
19904 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19905 created in the heap by means of an allocator, then it is @emph{not}
19907 it is constrained by the default values of the discriminants, and those values
19908 cannot be modified by full assignment. This is because in the presence of
19909 aliasing all views of the object (which may be manipulated by different tasks,
19910 say) must be consistent, so it is imperative that the object, once created,
19913 @node Strict Conformance to the Ada Reference Manual
19914 @section Strict Conformance to the Ada Reference Manual
19917 The dynamic semantics defined by the Ada Reference Manual impose a set of
19918 run-time checks to be generated. By default, the GNAT compiler will insert many
19919 run-time checks into the compiled code, including most of those required by the
19920 Ada Reference Manual. However, there are three checks that are not enabled
19921 in the default mode for efficiency reasons: arithmetic overflow checking for
19922 integer operations (including division by zero), checks for access before
19923 elaboration on subprogram calls, and stack overflow checking (most operating
19924 systems do not perform this check by default).
19926 Strict conformance to the Ada Reference Manual can be achieved by adding
19927 three compiler options for overflow checking for integer operations
19928 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19929 calls and generic instantiations (@option{-gnatE}), and stack overflow
19930 checking (@option{-fstack-check}).
19932 Note that the result of a floating point arithmetic operation in overflow and
19933 invalid situations, when the @code{Machine_Overflows} attribute of the result
19934 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19935 case for machines compliant with the IEEE floating-point standard, but on
19936 machines that are not fully compliant with this standard, such as Alpha, the
19937 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19938 behavior (although at the cost of a significant performance penalty), so
19939 infinite and NaN values are properly generated.
19942 @node Implementation of Ada 2012 Features
19943 @chapter Implementation of Ada 2012 Features
19944 @cindex Ada 2012 implementation status
19946 This chapter contains a complete list of Ada 2012 features that have been
19947 implemented as of GNAT version 6.4. Generally, these features are only
19948 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19949 @cindex @option{-gnat12} option
19950 or if the configuration pragma @code{Ada_2012} is used.
19951 @cindex pragma @code{Ada_2012}
19952 @cindex configuration pragma @code{Ada_2012}
19953 @cindex @code{Ada_2012} configuration pragma
19954 However, new pragmas, attributes, and restrictions are
19955 unconditionally available, since the Ada 95 standard allows the addition of
19956 new pragmas, attributes, and restrictions (there are exceptions, which are
19957 documented in the individual descriptions), and also certain packages
19958 were made available in earlier versions of Ada.
19960 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19961 This date shows the implementation date of the feature. Any wavefront
19962 subsequent to this date will contain the indicated feature, as will any
19963 subsequent releases. A date of 0000-00-00 means that GNAT has always
19964 implemented the feature, or implemented it as soon as it appeared as a
19965 binding interpretation.
19967 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19968 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19969 The features are ordered based on the relevant sections of the Ada
19970 Reference Manual (``RM''). When a given AI relates to multiple points
19971 in the RM, the earliest is used.
19973 A complete description of the AIs may be found in
19974 @url{www.ada-auth.org/ai05-summary.html}.
19979 @emph{AI-0176 Quantified expressions (2010-09-29)}
19980 @cindex AI-0176 (Ada 2012 feature)
19983 Both universally and existentially quantified expressions are implemented.
19984 They use the new syntax for iterators proposed in AI05-139-2, as well as
19985 the standard Ada loop syntax.
19988 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
19991 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19992 @cindex AI-0079 (Ada 2012 feature)
19995 Wide characters in the unicode category @i{other_format} are now allowed in
19996 source programs between tokens, but not within a token such as an identifier.
19999 RM References: 2.01 (4/2) 2.02 (7)
20002 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
20003 @cindex AI-0091 (Ada 2012 feature)
20006 Wide characters in the unicode category @i{other_format} are not permitted
20007 within an identifier, since this can be a security problem. The error
20008 message for this case has been improved to be more specific, but GNAT has
20009 never allowed such characters to appear in identifiers.
20012 RM References: 2.03 (3.1/2) 2.03 (4/2) 2.03 (5/2) 2.03 (5.1/2) 2.03 (5.2/2) 2.03 (5.3/2) 2.09 (2/2)
20015 @emph{AI-0100 Placement of pragmas (2010-07-01)}
20016 @cindex AI-0100 (Ada 2012 feature)
20019 This AI is an earlier version of AI-163. It simplifies the rules
20020 for legal placement of pragmas. In the case of lists that allow pragmas, if
20021 the list may have no elements, then the list may consist solely of pragmas.
20024 RM References: 2.08 (7)
20027 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
20028 @cindex AI-0163 (Ada 2012 feature)
20031 A statement sequence may be composed entirely of pragmas. It is no longer
20032 necessary to add a dummy @code{null} statement to make the sequence legal.
20035 RM References: 2.08 (7) 2.08 (16)
20039 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
20040 @cindex AI-0080 (Ada 2012 feature)
20043 This is an editorial change only, described as non-testable in the AI.
20046 RM References: 3.01 (7)
20050 @emph{AI-0183 Aspect specifications (2010-08-16)}
20051 @cindex AI-0183 (Ada 2012 feature)
20054 Aspect specifications have been fully implemented except for pre and post-
20055 conditions, and type invariants, which have their own separate AI's. All
20056 forms of declarations listed in the AI are supported. The following is a
20057 list of the aspects supported (with GNAT implementation aspects marked)
20059 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
20060 @item @code{Ada_2005} @tab -- GNAT
20061 @item @code{Ada_2012} @tab -- GNAT
20062 @item @code{Address} @tab
20063 @item @code{Alignment} @tab
20064 @item @code{Atomic} @tab
20065 @item @code{Atomic_Components} @tab
20066 @item @code{Bit_Order} @tab
20067 @item @code{Component_Size} @tab
20068 @item @code{Contract_Cases} @tab -- GNAT
20069 @item @code{Discard_Names} @tab
20070 @item @code{External_Tag} @tab
20071 @item @code{Favor_Top_Level} @tab -- GNAT
20072 @item @code{Inline} @tab
20073 @item @code{Inline_Always} @tab -- GNAT
20074 @item @code{Invariant} @tab -- GNAT
20075 @item @code{Machine_Radix} @tab
20076 @item @code{No_Return} @tab
20077 @item @code{Object_Size} @tab -- GNAT
20078 @item @code{Pack} @tab
20079 @item @code{Persistent_BSS} @tab -- GNAT
20080 @item @code{Post} @tab
20081 @item @code{Pre} @tab
20082 @item @code{Predicate} @tab
20083 @item @code{Preelaborable_Initialization} @tab
20084 @item @code{Pure_Function} @tab -- GNAT
20085 @item @code{Remote_Access_Type} @tab -- GNAT
20086 @item @code{Shared} @tab -- GNAT
20087 @item @code{Size} @tab
20088 @item @code{Storage_Pool} @tab
20089 @item @code{Storage_Size} @tab
20090 @item @code{Stream_Size} @tab
20091 @item @code{Suppress} @tab
20092 @item @code{Suppress_Debug_Info} @tab -- GNAT
20093 @item @code{Test_Case} @tab -- GNAT
20094 @item @code{Type_Invariant} @tab
20095 @item @code{Unchecked_Union} @tab
20096 @item @code{Universal_Aliasing} @tab -- GNAT
20097 @item @code{Unmodified} @tab -- GNAT
20098 @item @code{Unreferenced} @tab -- GNAT
20099 @item @code{Unreferenced_Objects} @tab -- GNAT
20100 @item @code{Unsuppress} @tab
20101 @item @code{Value_Size} @tab -- GNAT
20102 @item @code{Volatile} @tab
20103 @item @code{Volatile_Components}
20104 @item @code{Warnings} @tab -- GNAT
20108 Note that for aspects with an expression, e.g. @code{Size}, the expression is
20109 treated like a default expression (visibility is analyzed at the point of
20110 occurrence of the aspect, but evaluation of the expression occurs at the
20111 freeze point of the entity involved).
20114 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
20115 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
20116 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
20117 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
20118 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
20123 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
20124 @cindex AI-0128 (Ada 2012 feature)
20127 If an equality operator ("=") is declared for a type, then the implicitly
20128 declared inequality operator ("/=") is a primitive operation of the type.
20129 This is the only reasonable interpretation, and is the one always implemented
20130 by GNAT, but the RM was not entirely clear in making this point.
20133 RM References: 3.02.03 (6) 6.06 (6)
20136 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
20137 @cindex AI-0003 (Ada 2012 feature)
20140 In Ada 2012, a qualified expression is considered to be syntactically a name,
20141 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
20142 useful in disambiguating some cases of overloading.
20145 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
20149 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
20150 @cindex AI-0120 (Ada 2012 feature)
20153 This is an RM editorial change only. The section that lists objects that are
20154 constant failed to include the current instance of a protected object
20155 within a protected function. This has always been treated as a constant
20159 RM References: 3.03 (21)
20162 @emph{AI-0008 General access to constrained objects (0000-00-00)}
20163 @cindex AI-0008 (Ada 2012 feature)
20166 The wording in the RM implied that if you have a general access to a
20167 constrained object, it could be used to modify the discriminants. This was
20168 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
20169 has always done so in this situation.
20172 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
20176 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
20177 @cindex AI-0093 (Ada 2012 feature)
20180 This is an editorial change only, to make more widespread use of the Ada 2012
20181 ``immutably limited''.
20184 RM References: 3.03 (23.4/3)
20189 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
20190 @cindex AI-0096 (Ada 2012 feature)
20193 In general it is illegal for a type derived from a formal limited type to be
20194 nonlimited. This AI makes an exception to this rule: derivation is legal
20195 if it appears in the private part of the generic, and the formal type is not
20196 tagged. If the type is tagged, the legality check must be applied to the
20197 private part of the package.
20200 RM References: 3.04 (5.1/2) 6.02 (7)
20204 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
20205 @cindex AI-0181 (Ada 2012 feature)
20208 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
20209 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
20210 @code{Image} and @code{Value} attributes for the character types. Strictly
20211 speaking this is an inconsistency with Ada 95, but in practice the use of
20212 these attributes is so obscure that it will not cause problems.
20215 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
20219 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
20220 @cindex AI-0182 (Ada 2012 feature)
20223 This AI allows @code{Character'Value} to accept the string @code{'?'} where
20224 @code{?} is any character including non-graphic control characters. GNAT has
20225 always accepted such strings. It also allows strings such as
20226 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
20227 permission and raises @code{Constraint_Error}, as is certainly still
20231 RM References: 3.05 (56/2)
20235 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
20236 @cindex AI-0214 (Ada 2012 feature)
20239 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
20240 to have default expressions by allowing them when the type is limited. It
20241 is often useful to define a default value for a discriminant even though
20242 it can't be changed by assignment.
20245 RM References: 3.07 (9.1/2) 3.07.02 (3)
20249 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
20250 @cindex AI-0102 (Ada 2012 feature)
20253 It is illegal to assign an anonymous access constant to an anonymous access
20254 variable. The RM did not have a clear rule to prevent this, but GNAT has
20255 always generated an error for this usage.
20258 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
20262 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
20263 @cindex AI-0158 (Ada 2012 feature)
20266 This AI extends the syntax of membership tests to simplify complex conditions
20267 that can be expressed as membership in a subset of values of any type. It
20268 introduces syntax for a list of expressions that may be used in loop contexts
20272 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
20276 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
20277 @cindex AI-0173 (Ada 2012 feature)
20280 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
20281 with the tag of an abstract type, and @code{False} otherwise.
20284 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
20289 @emph{AI-0076 function with controlling result (0000-00-00)}
20290 @cindex AI-0076 (Ada 2012 feature)
20293 This is an editorial change only. The RM defines calls with controlling
20294 results, but uses the term ``function with controlling result'' without an
20295 explicit definition.
20298 RM References: 3.09.02 (2/2)
20302 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
20303 @cindex AI-0126 (Ada 2012 feature)
20306 This AI clarifies dispatching rules, and simply confirms that dispatching
20307 executes the operation of the parent type when there is no explicitly or
20308 implicitly declared operation for the descendant type. This has always been
20309 the case in all versions of GNAT.
20312 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
20316 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
20317 @cindex AI-0097 (Ada 2012 feature)
20320 The RM as written implied that in some cases it was possible to create an
20321 object of an abstract type, by having an abstract extension inherit a non-
20322 abstract constructor from its parent type. This mistake has been corrected
20323 in GNAT and in the RM, and this construct is now illegal.
20326 RM References: 3.09.03 (4/2)
20330 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
20331 @cindex AI-0203 (Ada 2012 feature)
20334 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
20335 permitted such usage.
20338 RM References: 3.09.03 (8/3)
20342 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
20343 @cindex AI-0198 (Ada 2012 feature)
20346 This AI resolves a conflict between two rules involving inherited abstract
20347 operations and predefined operators. If a derived numeric type inherits
20348 an abstract operator, it overrides the predefined one. This interpretation
20349 was always the one implemented in GNAT.
20352 RM References: 3.09.03 (4/3)
20355 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
20356 @cindex AI-0073 (Ada 2012 feature)
20359 This AI covers a number of issues regarding returning abstract types. In
20360 particular generic functions cannot have abstract result types or access
20361 result types designated an abstract type. There are some other cases which
20362 are detailed in the AI. Note that this binding interpretation has not been
20363 retrofitted to operate before Ada 2012 mode, since it caused a significant
20364 number of regressions.
20367 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
20371 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
20372 @cindex AI-0070 (Ada 2012 feature)
20375 This is an editorial change only, there are no testable consequences short of
20376 checking for the absence of generated code for an interface declaration.
20379 RM References: 3.09.04 (18/2)
20383 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
20384 @cindex AI-0208 (Ada 2012 feature)
20387 The wording in the Ada 2005 RM concerning characteristics of incomplete views
20388 was incorrect and implied that some programs intended to be legal were now
20389 illegal. GNAT had never considered such programs illegal, so it has always
20390 implemented the intent of this AI.
20393 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
20397 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
20398 @cindex AI-0162 (Ada 2012 feature)
20401 Incomplete types are made more useful by allowing them to be completed by
20402 private types and private extensions.
20405 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
20410 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
20411 @cindex AI-0098 (Ada 2012 feature)
20414 An unintentional omission in the RM implied some inconsistent restrictions on
20415 the use of anonymous access to subprogram values. These restrictions were not
20416 intentional, and have never been enforced by GNAT.
20419 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
20423 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
20424 @cindex AI-0199 (Ada 2012 feature)
20427 A choice list in a record aggregate can include several components of
20428 (distinct) anonymous access types as long as they have matching designated
20432 RM References: 4.03.01 (16)
20436 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
20437 @cindex AI-0220 (Ada 2012 feature)
20440 This AI addresses a wording problem in the RM that appears to permit some
20441 complex cases of aggregates with non-static discriminants. GNAT has always
20442 implemented the intended semantics.
20445 RM References: 4.03.01 (17)
20448 @emph{AI-0147 Conditional expressions (2009-03-29)}
20449 @cindex AI-0147 (Ada 2012 feature)
20452 Conditional expressions are permitted. The form of such an expression is:
20455 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
20458 The parentheses can be omitted in contexts where parentheses are present
20459 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
20460 clause is omitted, @b{else True} is assumed;
20461 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
20462 @emph{(A implies B)} in standard logic.
20465 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
20466 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
20470 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
20471 @cindex AI-0037 (Ada 2012 feature)
20474 This AI confirms that an association of the form @code{Indx => <>} in an
20475 array aggregate must raise @code{Constraint_Error} if @code{Indx}
20476 is out of range. The RM specified a range check on other associations, but
20477 not when the value of the association was defaulted. GNAT has always inserted
20478 a constraint check on the index value.
20481 RM References: 4.03.03 (29)
20485 @emph{AI-0123 Composability of equality (2010-04-13)}
20486 @cindex AI-0123 (Ada 2012 feature)
20489 Equality of untagged record composes, so that the predefined equality for a
20490 composite type that includes a component of some untagged record type
20491 @code{R} uses the equality operation of @code{R} (which may be user-defined
20492 or predefined). This makes the behavior of untagged records identical to that
20493 of tagged types in this respect.
20495 This change is an incompatibility with previous versions of Ada, but it
20496 corrects a non-uniformity that was often a source of confusion. Analysis of
20497 a large number of industrial programs indicates that in those rare cases
20498 where a composite type had an untagged record component with a user-defined
20499 equality, either there was no use of the composite equality, or else the code
20500 expected the same composability as for tagged types, and thus had a bug that
20501 would be fixed by this change.
20504 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
20509 @emph{AI-0088 The value of exponentiation (0000-00-00)}
20510 @cindex AI-0088 (Ada 2012 feature)
20513 This AI clarifies the equivalence rule given for the dynamic semantics of
20514 exponentiation: the value of the operation can be obtained by repeated
20515 multiplication, but the operation can be implemented otherwise (for example
20516 using the familiar divide-by-two-and-square algorithm, even if this is less
20517 accurate), and does not imply repeated reads of a volatile base.
20520 RM References: 4.05.06 (11)
20523 @emph{AI-0188 Case expressions (2010-01-09)}
20524 @cindex AI-0188 (Ada 2012 feature)
20527 Case expressions are permitted. This allows use of constructs such as:
20529 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
20533 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
20536 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
20537 @cindex AI-0104 (Ada 2012 feature)
20540 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
20541 @code{Constraint_Error} because the default value of the allocated object is
20542 @b{null}. This useless construct is illegal in Ada 2012.
20545 RM References: 4.08 (2)
20548 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
20549 @cindex AI-0157 (Ada 2012 feature)
20552 Allocation and Deallocation from an empty storage pool (i.e. allocation or
20553 deallocation of a pointer for which a static storage size clause of zero
20554 has been given) is now illegal and is detected as such. GNAT
20555 previously gave a warning but not an error.
20558 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
20561 @emph{AI-0179 Statement not required after label (2010-04-10)}
20562 @cindex AI-0179 (Ada 2012 feature)
20565 It is not necessary to have a statement following a label, so a label
20566 can appear at the end of a statement sequence without the need for putting a
20567 null statement afterwards, but it is not allowable to have only labels and
20568 no real statements in a statement sequence.
20571 RM References: 5.01 (2)
20575 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
20576 @cindex AI-139-2 (Ada 2012 feature)
20579 The new syntax for iterating over arrays and containers is now implemented.
20580 Iteration over containers is for now limited to read-only iterators. Only
20581 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
20584 RM References: 5.05
20587 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
20588 @cindex AI-0134 (Ada 2012 feature)
20591 For full conformance, the profiles of anonymous-access-to-subprogram
20592 parameters must match. GNAT has always enforced this rule.
20595 RM References: 6.03.01 (18)
20598 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
20599 @cindex AI-0207 (Ada 2012 feature)
20602 This AI confirms that access_to_constant indication must match for mode
20603 conformance. This was implemented in GNAT when the qualifier was originally
20604 introduced in Ada 2005.
20607 RM References: 6.03.01 (16/2)
20611 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
20612 @cindex AI-0046 (Ada 2012 feature)
20615 For full conformance, in the case of access parameters, the null exclusion
20616 must match (either both or neither must have @code{@b{not null}}).
20619 RM References: 6.03.02 (18)
20623 @emph{AI-0118 The association of parameter associations (0000-00-00)}
20624 @cindex AI-0118 (Ada 2012 feature)
20627 This AI clarifies the rules for named associations in subprogram calls and
20628 generic instantiations. The rules have been in place since Ada 83.
20631 RM References: 6.04.01 (2) 12.03 (9)
20635 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
20636 @cindex AI-0196 (Ada 2012 feature)
20639 Null exclusion checks are not made for @code{@b{out}} parameters when
20640 evaluating the actual parameters. GNAT has never generated these checks.
20643 RM References: 6.04.01 (13)
20646 @emph{AI-0015 Constant return objects (0000-00-00)}
20647 @cindex AI-0015 (Ada 2012 feature)
20650 The return object declared in an @i{extended_return_statement} may be
20651 declared constant. This was always intended, and GNAT has always allowed it.
20654 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
20659 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
20660 @cindex AI-0032 (Ada 2012 feature)
20663 If a function returns a class-wide type, the object of an extended return
20664 statement can be declared with a specific type that is covered by the class-
20665 wide type. This has been implemented in GNAT since the introduction of
20666 extended returns. Note AI-0103 complements this AI by imposing matching
20667 rules for constrained return types.
20670 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
20674 @emph{AI-0103 Static matching for extended return (2010-07-23)}
20675 @cindex AI-0103 (Ada 2012 feature)
20678 If the return subtype of a function is an elementary type or a constrained
20679 type, the subtype indication in an extended return statement must match
20680 statically this return subtype.
20683 RM References: 6.05 (5.2/2)
20687 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
20688 @cindex AI-0058 (Ada 2012 feature)
20691 The RM had some incorrect wording implying wrong treatment of abnormal
20692 completion in an extended return. GNAT has always implemented the intended
20693 correct semantics as described by this AI.
20696 RM References: 6.05 (22/2)
20700 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
20701 @cindex AI-0050 (Ada 2012 feature)
20704 The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
20705 not take advantage of these incorrect permissions in any case.
20708 RM References: 6.05 (24/2)
20712 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
20713 @cindex AI-0125 (Ada 2012 feature)
20716 In Ada 2012, the declaration of a primitive operation of a type extension
20717 or private extension can also override an inherited primitive that is not
20718 visible at the point of this declaration.
20721 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
20724 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
20725 @cindex AI-0062 (Ada 2012 feature)
20728 A full constant may have a null exclusion even if its associated deferred
20729 constant does not. GNAT has always allowed this.
20732 RM References: 7.04 (6/2) 7.04 (7.1/2)
20736 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
20737 @cindex AI-0178 (Ada 2012 feature)
20740 This AI clarifies the role of incomplete views and plugs an omission in the
20741 RM. GNAT always correctly restricted the use of incomplete views and types.
20744 RM References: 7.05 (3/2) 7.05 (6/2)
20747 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
20748 @cindex AI-0087 (Ada 2012 feature)
20751 The actual for a formal nonlimited derived type cannot be limited. In
20752 particular, a formal derived type that extends a limited interface but which
20753 is not explicitly limited cannot be instantiated with a limited type.
20756 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
20759 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
20760 @cindex AI-0099 (Ada 2012 feature)
20763 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
20764 and therefore depends on the run-time characteristics of an object (i.e. its
20765 tag) and not on its nominal type. As the AI indicates: ``we do not expect
20766 this to affect any implementation''.
20769 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
20774 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
20775 @cindex AI-0064 (Ada 2012 feature)
20778 This is an editorial change only. The intended behavior is already checked
20779 by an existing ACATS test, which GNAT has always executed correctly.
20782 RM References: 7.06.01 (17.1/1)
20785 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20786 @cindex AI-0026 (Ada 2012 feature)
20789 Record representation clauses concerning Unchecked_Union types cannot mention
20790 the discriminant of the type. The type of a component declared in the variant
20791 part of an Unchecked_Union cannot be controlled, have controlled components,
20792 nor have protected or task parts. If an Unchecked_Union type is declared
20793 within the body of a generic unit or its descendants, then the type of a
20794 component declared in the variant part cannot be a formal private type or a
20795 formal private extension declared within the same generic unit.
20798 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
20802 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20803 @cindex AI-0205 (Ada 2012 feature)
20806 This AI corrects a simple omission in the RM. Return objects have always
20807 been visible within an extended return statement.
20810 RM References: 8.03 (17)
20814 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20815 @cindex AI-0042 (Ada 2012 feature)
20818 This AI fixes a wording gap in the RM. An operation of a synchronized
20819 interface can be implemented by a protected or task entry, but the abstract
20820 operation is not being overridden in the usual sense, and it must be stated
20821 separately that this implementation is legal. This has always been the case
20825 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
20828 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20829 @cindex AI-0030 (Ada 2012 feature)
20832 Requeue is permitted to a protected, synchronized or task interface primitive
20833 providing it is known that the overriding operation is an entry. Otherwise
20834 the requeue statement has the same effect as a procedure call. Use of pragma
20835 @code{Implemented} provides a way to impose a static requirement on the
20836 overriding operation by adhering to one of the implementation kinds: entry,
20837 protected procedure or any of the above.
20840 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
20841 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
20845 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20846 @cindex AI-0201 (Ada 2012 feature)
20849 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20850 attribute, then individual components may not be addressable by independent
20851 tasks. However, if the representation clause has no effect (is confirming),
20852 then independence is not compromised. Furthermore, in GNAT, specification of
20853 other appropriately addressable component sizes (e.g. 16 for 8-bit
20854 characters) also preserves independence. GNAT now gives very clear warnings
20855 both for the declaration of such a type, and for any assignment to its components.
20858 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
20861 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20862 @cindex AI-0009 (Ada 2012 feature)
20865 This AI introduces the new pragmas @code{Independent} and
20866 @code{Independent_Components},
20867 which control guaranteeing independence of access to objects and components.
20868 The AI also requires independence not unaffected by confirming rep clauses.
20871 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
20872 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
20876 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20877 @cindex AI-0072 (Ada 2012 feature)
20880 This AI clarifies that task signalling for reading @code{'Terminated} only
20881 occurs if the result is True. GNAT semantics has always been consistent with
20882 this notion of task signalling.
20885 RM References: 9.10 (6.1/1)
20888 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20889 @cindex AI-0108 (Ada 2012 feature)
20892 This AI confirms that an incomplete type from a limited view does not have
20893 discriminants. This has always been the case in GNAT.
20896 RM References: 10.01.01 (12.3/2)
20899 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20900 @cindex AI-0129 (Ada 2012 feature)
20903 This AI clarifies the description of limited views: a limited view of a
20904 package includes only one view of a type that has an incomplete declaration
20905 and a full declaration (there is no possible ambiguity in a client package).
20906 This AI also fixes an omission: a nested package in the private part has no
20907 limited view. GNAT always implemented this correctly.
20910 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
20915 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20916 @cindex AI-0077 (Ada 2012 feature)
20919 This AI clarifies that a declaration does not include a context clause,
20920 and confirms that it is illegal to have a context in which both a limited
20921 and a nonlimited view of a package are accessible. Such double visibility
20922 was always rejected by GNAT.
20925 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
20928 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20929 @cindex AI-0122 (Ada 2012 feature)
20932 This AI clarifies the visibility of private children of generic units within
20933 instantiations of a parent. GNAT has always handled this correctly.
20936 RM References: 10.01.02 (12/2)
20941 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20942 @cindex AI-0040 (Ada 2012 feature)
20945 This AI confirms that a limited with clause in a child unit cannot name
20946 an ancestor of the unit. This has always been checked in GNAT.
20949 RM References: 10.01.02 (20/2)
20952 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20953 @cindex AI-0132 (Ada 2012 feature)
20956 This AI fills a gap in the description of library unit pragmas. The pragma
20957 clearly must apply to a library unit, even if it does not carry the name
20958 of the enclosing unit. GNAT has always enforced the required check.
20961 RM References: 10.01.05 (7)
20965 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20966 @cindex AI-0034 (Ada 2012 feature)
20969 The RM makes certain limited with clauses illegal because of categorization
20970 considerations, when the corresponding normal with would be legal. This is
20971 not intended, and GNAT has always implemented the recommended behavior.
20974 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
20978 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20979 @cindex AI-0035 (Ada 2012 feature)
20982 This AI remedies some inconsistencies in the legality rules for Pure units.
20983 Derived access types are legal in a pure unit (on the assumption that the
20984 rule for a zero storage pool size has been enforced on the ancestor type).
20985 The rules are enforced in generic instances and in subunits. GNAT has always
20986 implemented the recommended behavior.
20989 RM References: 10.02.01 (15.1/2) 10.02.01 (15.4/2) 10.02.01 (15.5/2) 10.02.01 (17/2)
20993 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20994 @cindex AI-0219 (Ada 2012 feature)
20997 This AI refines the rules for the cases with limited parameters which do not
20998 allow the implementations to omit ``redundant''. GNAT now properly conforms
20999 to the requirements of this binding interpretation.
21002 RM References: 10.02.01 (18/2)
21005 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
21006 @cindex AI-0043 (Ada 2012 feature)
21009 This AI covers various omissions in the RM regarding the raising of
21010 exceptions. GNAT has always implemented the intended semantics.
21013 RM References: 11.04.01 (10.1/2) 11 (2)
21017 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
21018 @cindex AI-0200 (Ada 2012 feature)
21021 This AI plugs a gap in the RM which appeared to allow some obviously intended
21022 illegal instantiations. GNAT has never allowed these instantiations.
21025 RM References: 12.07 (16)
21029 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
21030 @cindex AI-0112 (Ada 2012 feature)
21033 This AI concerns giving names to various representation aspects, but the
21034 practical effect is simply to make the use of duplicate
21035 @code{Atomic}[@code{_Components}],
21036 @code{Volatile}[@code{_Components}] and
21037 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
21038 now performs this required check.
21041 RM References: 13.01 (8)
21044 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
21045 @cindex AI-0106 (Ada 2012 feature)
21048 The RM appeared to allow representation pragmas on generic formal parameters,
21049 but this was not intended, and GNAT has never permitted this usage.
21052 RM References: 13.01 (9.1/1)
21056 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
21057 @cindex AI-0012 (Ada 2012 feature)
21060 It is now illegal to give an inappropriate component size or a pragma
21061 @code{Pack} that attempts to change the component size in the case of atomic
21062 or aliased components. Previously GNAT ignored such an attempt with a
21066 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
21070 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
21071 @cindex AI-0039 (Ada 2012 feature)
21074 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
21075 for stream attributes, but these were never useful and are now illegal. GNAT
21076 has always regarded such expressions as illegal.
21079 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
21083 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
21084 @cindex AI-0095 (Ada 2012 feature)
21087 The prefix of @code{'Address} cannot statically denote a subprogram with
21088 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
21089 @code{Program_Error} if the prefix denotes a subprogram with convention
21093 RM References: 13.03 (11/1)
21097 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
21098 @cindex AI-0116 (Ada 2012 feature)
21101 This AI requires that the alignment of a class-wide object be no greater
21102 than the alignment of any type in the class. GNAT has always followed this
21106 RM References: 13.03 (29) 13.11 (16)
21110 @emph{AI-0146 Type invariants (2009-09-21)}
21111 @cindex AI-0146 (Ada 2012 feature)
21114 Type invariants may be specified for private types using the aspect notation.
21115 Aspect @code{Type_Invariant} may be specified for any private type,
21116 @code{Type_Invariant'Class} can
21117 only be specified for tagged types, and is inherited by any descendent of the
21118 tagged types. The invariant is a boolean expression that is tested for being
21119 true in the following situations: conversions to the private type, object
21120 declarations for the private type that are default initialized, and
21122 parameters and returned result on return from any primitive operation for
21123 the type that is visible to a client.
21124 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
21125 @code{Invariant'Class} for @code{Type_Invariant'Class}.
21128 RM References: 13.03.03 (00)
21131 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
21132 @cindex AI-0078 (Ada 2012 feature)
21135 In Ada 2012, compilers are required to support unchecked conversion where the
21136 target alignment is a multiple of the source alignment. GNAT always supported
21137 this case (and indeed all cases of differing alignments, doing copies where
21138 required if the alignment was reduced).
21141 RM References: 13.09 (7)
21145 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
21146 @cindex AI-0195 (Ada 2012 feature)
21149 The handling of invalid values is now designated to be implementation
21150 defined. This is a documentation change only, requiring Annex M in the GNAT
21151 Reference Manual to document this handling.
21152 In GNAT, checks for invalid values are made
21153 only when necessary to avoid erroneous behavior. Operations like assignments
21154 which cannot cause erroneous behavior ignore the possibility of invalid
21155 values and do not do a check. The date given above applies only to the
21156 documentation change, this behavior has always been implemented by GNAT.
21159 RM References: 13.09.01 (10)
21162 @emph{AI-0193 Alignment of allocators (2010-09-16)}
21163 @cindex AI-0193 (Ada 2012 feature)
21166 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
21167 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
21171 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
21172 13.11.01 (2) 13.11.01 (3)
21176 @emph{AI-0177 Parameterized expressions (2010-07-10)}
21177 @cindex AI-0177 (Ada 2012 feature)
21180 The new Ada 2012 notion of parameterized expressions is implemented. The form
21183 @i{function specification} @b{is} (@i{expression})
21187 This is exactly equivalent to the
21188 corresponding function body that returns the expression, but it can appear
21189 in a package spec. Note that the expression must be parenthesized.
21192 RM References: 13.11.01 (3/2)
21195 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
21196 @cindex AI-0033 (Ada 2012 feature)
21199 Neither of these two pragmas may appear within a generic template, because
21200 the generic might be instantiated at other than the library level.
21203 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
21207 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
21208 @cindex AI-0161 (Ada 2012 feature)
21211 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
21212 of the default stream attributes for elementary types. If this restriction is
21213 in force, then it is necessary to provide explicit subprograms for any
21214 stream attributes used.
21217 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
21220 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
21221 @cindex AI-0194 (Ada 2012 feature)
21224 The @code{Stream_Size} attribute returns the default number of bits in the
21225 stream representation of the given type.
21226 This value is not affected by the presence
21227 of stream subprogram attributes for the type. GNAT has always implemented
21228 this interpretation.
21231 RM References: 13.13.02 (1.2/2)
21234 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
21235 @cindex AI-0109 (Ada 2012 feature)
21238 This AI is an editorial change only. It removes the need for a tag check
21239 that can never fail.
21242 RM References: 13.13.02 (34/2)
21245 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
21246 @cindex AI-0007 (Ada 2012 feature)
21249 The RM as written appeared to limit the possibilities of declaring read
21250 attribute procedures for private scalar types. This limitation was not
21251 intended, and has never been enforced by GNAT.
21254 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
21258 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
21259 @cindex AI-0065 (Ada 2012 feature)
21262 This AI clarifies the fact that all remote access types support external
21263 streaming. This fixes an obvious oversight in the definition of the
21264 language, and GNAT always implemented the intended correct rules.
21267 RM References: 13.13.02 (52/2)
21270 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
21271 @cindex AI-0019 (Ada 2012 feature)
21274 The RM suggests that primitive subprograms of a specific tagged type are
21275 frozen when the tagged type is frozen. This would be an incompatible change
21276 and is not intended. GNAT has never attempted this kind of freezing and its
21277 behavior is consistent with the recommendation of this AI.
21280 RM References: 13.14 (2) 13.14 (3/1) 13.14 (8.1/1) 13.14 (10) 13.14 (14) 13.14 (15.1/2)
21283 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
21284 @cindex AI-0017 (Ada 2012 feature)
21287 So-called ``Taft-amendment types'' (i.e., types that are completed in package
21288 bodies) are not frozen by the occurrence of bodies in the
21289 enclosing declarative part. GNAT always implemented this properly.
21292 RM References: 13.14 (3/1)
21296 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
21297 @cindex AI-0060 (Ada 2012 feature)
21300 This AI extends the definition of remote access types to include access
21301 to limited, synchronized, protected or task class-wide interface types.
21302 GNAT already implemented this extension.
21305 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
21308 @emph{AI-0114 Classification of letters (0000-00-00)}
21309 @cindex AI-0114 (Ada 2012 feature)
21312 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
21313 181 (@code{MICRO SIGN}), and
21314 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
21315 lower case letters by Unicode.
21316 However, they are not allowed in identifiers, and they
21317 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
21318 This behavior is consistent with that defined in Ada 95.
21321 RM References: A.03.02 (59) A.04.06 (7)
21325 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
21326 @cindex AI-0185 (Ada 2012 feature)
21329 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
21330 classification functions for @code{Wide_Character} and
21331 @code{Wide_Wide_Character}, as well as providing
21332 case folding routines for @code{Wide_[Wide_]Character} and
21333 @code{Wide_[Wide_]String}.
21336 RM References: A.03.05 (0) A.03.06 (0)
21340 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
21341 @cindex AI-0031 (Ada 2012 feature)
21344 A new version of @code{Find_Token} is added to all relevant string packages,
21345 with an extra parameter @code{From}. Instead of starting at the first
21346 character of the string, the search for a matching Token starts at the
21347 character indexed by the value of @code{From}.
21348 These procedures are available in all versions of Ada
21349 but if used in versions earlier than Ada 2012 they will generate a warning
21350 that an Ada 2012 subprogram is being used.
21353 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
21358 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
21359 @cindex AI-0056 (Ada 2012 feature)
21362 The wording in the Ada 2005 RM implied an incompatible handling of the
21363 @code{Index} functions, resulting in raising an exception instead of
21364 returning zero in some situations.
21365 This was not intended and has been corrected.
21366 GNAT always returned zero, and is thus consistent with this AI.
21369 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
21373 @emph{AI-0137 String encoding package (2010-03-25)}
21374 @cindex AI-0137 (Ada 2012 feature)
21377 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
21378 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
21379 and @code{Wide_Wide_Strings} have been
21380 implemented. These packages (whose documentation can be found in the spec
21381 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
21382 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
21383 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
21384 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
21385 UTF-16), as well as conversions between the different UTF encodings. With
21386 the exception of @code{Wide_Wide_Strings}, these packages are available in
21387 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
21388 The @code{Wide_Wide_Strings package}
21389 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
21390 mode since it uses @code{Wide_Wide_Character}).
21393 RM References: A.04.11
21396 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
21397 @cindex AI-0038 (Ada 2012 feature)
21400 These are minor errors in the description on three points. The intent on
21401 all these points has always been clear, and GNAT has always implemented the
21402 correct intended semantics.
21405 RM References: A.10.05 (37) A.10.07 (8/1) A.10.07 (10) A.10.07 (12) A.10.08 (10) A.10.08 (24)
21408 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
21409 @cindex AI-0044 (Ada 2012 feature)
21412 This AI places restrictions on allowed instantiations of generic containers.
21413 These restrictions are not checked by the compiler, so there is nothing to
21414 change in the implementation. This affects only the RM documentation.
21417 RM References: A.18 (4/2) A.18.02 (231/2) A.18.03 (145/2) A.18.06 (56/2) A.18.08 (66/2) A.18.09 (79/2) A.18.26 (5/2) A.18.26 (9/2)
21420 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
21421 @cindex AI-0127 (Ada 2012 feature)
21424 This package provides an interface for identifying the current locale.
21427 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
21428 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
21433 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
21434 @cindex AI-0002 (Ada 2012 feature)
21437 The compiler is not required to support exporting an Ada subprogram with
21438 convention C if there are parameters or a return type of an unconstrained
21439 array type (such as @code{String}). GNAT allows such declarations but
21440 generates warnings. It is possible, but complicated, to write the
21441 corresponding C code and certainly such code would be specific to GNAT and
21445 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
21449 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
21450 @cindex AI05-0216 (Ada 2012 feature)
21453 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
21454 forbid tasks declared locally within subprograms, or functions returning task
21455 objects, and that is the implementation that GNAT has always provided.
21456 However the language in the RM was not sufficiently clear on this point.
21457 Thus this is a documentation change in the RM only.
21460 RM References: D.07 (3/3)
21463 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
21464 @cindex AI-0211 (Ada 2012 feature)
21467 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
21468 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
21471 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
21474 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
21475 @cindex AI-0190 (Ada 2012 feature)
21478 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
21479 used to control storage pools globally.
21480 In particular, you can force every access
21481 type that is used for allocation (@b{new}) to have an explicit storage pool,
21482 or you can declare a pool globally to be used for all access types that lack
21486 RM References: D.07 (8)
21489 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
21490 @cindex AI-0189 (Ada 2012 feature)
21493 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
21494 which says that no dynamic allocation will occur once elaboration is
21496 In general this requires a run-time check, which is not required, and which
21497 GNAT does not attempt. But the static cases of allocators in a task body or
21498 in the body of the main program are detected and flagged at compile or bind
21502 RM References: D.07 (19.1/2) H.04 (23.3/2)
21505 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
21506 @cindex AI-0171 (Ada 2012 feature)
21509 A new package @code{System.Multiprocessors} is added, together with the
21510 definition of pragma @code{CPU} for controlling task affinity. A new no
21511 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
21512 is added to the Ravenscar profile.
21515 RM References: D.13.01 (4/2) D.16
21519 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
21520 @cindex AI-0210 (Ada 2012 feature)
21523 This is a documentation only issue regarding wording of metric requirements,
21524 that does not affect the implementation of the compiler.
21527 RM References: D.15 (24/2)
21531 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
21532 @cindex AI-0206 (Ada 2012 feature)
21535 Remote types packages are now allowed to depend on preelaborated packages.
21536 This was formerly considered illegal.
21539 RM References: E.02.02 (6)
21544 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
21545 @cindex AI-0152 (Ada 2012 feature)
21548 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
21549 where the type of the returned value is an anonymous access type.
21552 RM References: H.04 (8/1)
21556 @node Obsolescent Features
21557 @chapter Obsolescent Features
21560 This chapter describes features that are provided by GNAT, but are
21561 considered obsolescent since there are preferred ways of achieving
21562 the same effect. These features are provided solely for historical
21563 compatibility purposes.
21566 * pragma No_Run_Time::
21567 * pragma Ravenscar::
21568 * pragma Restricted_Run_Time::
21571 @node pragma No_Run_Time
21572 @section pragma No_Run_Time
21574 The pragma @code{No_Run_Time} is used to achieve an affect similar
21575 to the use of the "Zero Foot Print" configurable run time, but without
21576 requiring a specially configured run time. The result of using this
21577 pragma, which must be used for all units in a partition, is to restrict
21578 the use of any language features requiring run-time support code. The
21579 preferred usage is to use an appropriately configured run-time that
21580 includes just those features that are to be made accessible.
21582 @node pragma Ravenscar
21583 @section pragma Ravenscar
21585 The pragma @code{Ravenscar} has exactly the same effect as pragma
21586 @code{Profile (Ravenscar)}. The latter usage is preferred since it
21587 is part of the new Ada 2005 standard.
21589 @node pragma Restricted_Run_Time
21590 @section pragma Restricted_Run_Time
21592 The pragma @code{Restricted_Run_Time} has exactly the same effect as
21593 pragma @code{Profile (Restricted)}. The latter usage is
21594 preferred since the Ada 2005 pragma @code{Profile} is intended for
21595 this kind of implementation dependent addition.
21598 @c GNU Free Documentation License
21600 @node Index,,GNU Free Documentation License, Top
21608 tablishes the following set of restrictions: