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''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Aspects::
74 * Implementation Defined Attributes::
75 * Standard and Implementation Defined Restrictions::
76 * Implementation Advice::
77 * Implementation Defined Characteristics::
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::
81 * The Implementation of Standard I/O::
83 * Interfacing to Other Languages::
84 * Specialized Needs Annexes::
85 * Implementation of Specific Ada Features::
86 * Implementation of Ada 2012 Features::
87 * Obsolescent Features::
88 * GNU Free Documentation License::
91 --- The Detailed Node Listing ---
95 * What This Reference Manual Contains::
96 * Related Information::
98 Implementation Defined Pragmas
100 * Pragma Abort_Defer::
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::
139 * Pragma Detect_Blocking::
140 * Pragma Disable_Atomic_Synchronization::
141 * Pragma Dispatching_Domain::
142 * Pragma Elaboration_Checks::
144 * Pragma Enable_Atomic_Synchronization::
145 * Pragma Export_Exception::
146 * Pragma Export_Function::
147 * Pragma Export_Object::
148 * Pragma Export_Procedure::
149 * Pragma Export_Value::
150 * Pragma Export_Valued_Procedure::
151 * Pragma Extend_System::
152 * Pragma Extensions_Allowed::
154 * Pragma External_Name_Casing::
156 * Pragma Favor_Top_Level::
157 * Pragma Finalize_Storage_Only::
158 * Pragma Float_Representation::
160 * Pragma Implementation_Defined::
161 * Pragma Implemented::
162 * Pragma Implicit_Packing::
163 * Pragma Import_Exception::
164 * Pragma Import_Function::
165 * Pragma Import_Object::
166 * Pragma Import_Procedure::
167 * Pragma Import_Valued_Procedure::
168 * Pragma Independent::
169 * Pragma Independent_Components::
170 * Pragma Initialize_Scalars::
171 * Pragma Inline_Always::
172 * Pragma Inline_Generic::
174 * Pragma Interface_Name::
175 * Pragma Interrupt_Handler::
176 * Pragma Interrupt_State::
178 * Pragma Java_Constructor::
179 * Pragma Java_Interface::
180 * Pragma Keep_Names::
183 * Pragma Linker_Alias::
184 * Pragma Linker_Constructor::
185 * Pragma Linker_Destructor::
186 * Pragma Linker_Section::
187 * Pragma Long_Float::
188 * Pragma Loop_Invariant::
189 * Pragma Loop_Optimize::
190 * Pragma Loop_Variant::
191 * Pragma Machine_Attribute::
193 * Pragma Main_Storage::
197 * Pragma No_Run_Time::
198 * Pragma No_Strict_Aliasing ::
199 * Pragma Normalize_Scalars::
200 * Pragma Obsolescent::
201 * Pragma Optimize_Alignment::
203 * Pragma Overflow_Mode::
204 * Pragma Overriding_Renamings::
205 * Pragma Partition_Elaboration_Policy::
207 * Pragma Persistent_BSS::
209 * Pragma Postcondition::
210 * Pragma Precondition::
212 * Pragma Preelaborable_Initialization::
213 * Pragma Preelaborate_05::
214 * Pragma Priority_Specific_Dispatching::
216 * Pragma Profile_Warnings::
217 * Pragma Propagate_Exceptions::
218 * Pragma Psect_Object::
221 * Pragma Pure_Function::
223 * Pragma Relative_Deadline::
224 * Pragma Remote_Access_Type::
225 * Pragma Restricted_Run_Time::
226 * Pragma Restriction_Warnings::
227 * Pragma Share_Generic::
229 * Pragma Short_Circuit_And_Or::
230 * Pragma Short_Descriptors::
231 * Pragma Simple_Storage_Pool_Type::
232 * Pragma Source_File_Name::
233 * Pragma Source_File_Name_Project::
234 * Pragma Source_Reference::
235 * Pragma Static_Elaboration_Desired::
236 * Pragma Stream_Convert::
237 * Pragma Style_Checks::
240 * Pragma Suppress_All::
241 * Pragma Suppress_Debug_Info::
242 * Pragma Suppress_Exception_Locations::
243 * Pragma Suppress_Initialization::
246 * Pragma Task_Storage::
248 * Pragma Thread_Local_Storage::
249 * Pragma Time_Slice::
251 * Pragma Unchecked_Union::
252 * Pragma Unimplemented_Unit::
253 * Pragma Universal_Aliasing ::
254 * Pragma Universal_Data::
255 * Pragma Unmodified::
256 * Pragma Unreferenced::
257 * Pragma Unreferenced_Objects::
258 * Pragma Unreserve_All_Interrupts::
259 * Pragma Unsuppress::
260 * Pragma Use_VADS_Size::
261 * Pragma Validity_Checks::
264 * Pragma Weak_External::
265 * Pragma Wide_Character_Encoding::
267 Implementation Defined Aspects
269 * Aspect Abstract_State::
272 * Aspect Compiler_Unit::
273 * Aspect Contract_Cases::
276 * Aspect Dimension_System::
277 * Aspect Favor_Top_Level::
279 * Aspect Inline_Always::
281 * Aspect Object_Size::
282 * Aspect Persistent_BSS::
284 * Aspect Preelaborate_05::
287 * Aspect Pure_Function::
288 * Aspect Remote_Access_Type::
289 * Aspect Scalar_Storage_Order::
291 * Aspect Simple_Storage_Pool::
292 * Aspect Simple_Storage_Pool_Type::
293 * Aspect Suppress_Debug_Info::
295 * Aspect Universal_Aliasing::
296 * Aspect Universal_Data::
297 * Aspect Unmodified::
298 * Aspect Unreferenced::
299 * Aspect Unreferenced_Objects::
300 * Aspect Value_Size::
303 Implementation Defined Attributes
305 * Attribute Abort_Signal::
306 * Attribute Address_Size::
307 * Attribute Asm_Input::
308 * Attribute Asm_Output::
309 * Attribute AST_Entry::
311 * Attribute Bit_Position::
312 * Attribute Compiler_Version::
313 * Attribute Code_Address::
314 * Attribute Default_Bit_Order::
315 * Attribute Descriptor_Size::
316 * Attribute Elaborated::
317 * Attribute Elab_Body::
318 * Attribute Elab_Spec::
319 * Attribute Elab_Subp_Body::
321 * Attribute Enabled::
322 * Attribute Enum_Rep::
323 * Attribute Enum_Val::
324 * Attribute Epsilon::
325 * Attribute Fixed_Value::
326 * Attribute Has_Access_Values::
327 * Attribute Has_Discriminants::
329 * Attribute Integer_Value::
330 * Attribute Invalid_Value::
332 * Attribute Loop_Entry::
333 * Attribute Machine_Size::
334 * Attribute Mantissa::
335 * Attribute Max_Interrupt_Priority::
336 * Attribute Max_Priority::
337 * Attribute Maximum_Alignment::
338 * Attribute Mechanism_Code::
339 * Attribute Null_Parameter::
340 * Attribute Object_Size::
341 * Attribute Passed_By_Reference::
342 * Attribute Pool_Address::
343 * Attribute Range_Length::
345 * Attribute Safe_Emax::
346 * Attribute Safe_Large::
347 * Attribute Scalar_Storage_Order::
348 * Attribute Simple_Storage_Pool::
350 * Attribute Storage_Unit::
351 * Attribute Stub_Type::
352 * Attribute System_Allocator_Alignment::
353 * Attribute Target_Name::
355 * Attribute To_Address::
356 * Attribute Type_Class::
357 * Attribute UET_Address::
358 * Attribute Unconstrained_Array::
359 * Attribute Universal_Literal_String::
360 * Attribute Unrestricted_Access::
362 * Attribute Valid_Scalars::
363 * Attribute VADS_Size::
364 * Attribute Value_Size::
365 * Attribute Wchar_T_Size::
366 * Attribute Word_Size::
368 Standard and Implementation Defined Restrictions
370 * Partition-Wide Restrictions::
371 * Program Unit Level Restrictions::
373 Partition-Wide Restrictions
375 * Immediate_Reclamation::
376 * Max_Asynchronous_Select_Nesting::
377 * Max_Entry_Queue_Length::
378 * Max_Protected_Entries::
379 * Max_Select_Alternatives::
380 * Max_Storage_At_Blocking::
383 * No_Abort_Statements::
384 * No_Access_Parameter_Allocators::
385 * No_Access_Subprograms::
387 * No_Anonymous_Allocators::
390 * No_Default_Initialization::
393 * No_Direct_Boolean_Operators::
395 * No_Dispatching_Calls::
396 * No_Dynamic_Attachment::
397 * No_Dynamic_Priorities::
398 * No_Entry_Calls_In_Elaboration_Code::
399 * No_Enumeration_Maps::
400 * No_Exception_Handlers::
401 * No_Exception_Propagation::
402 * No_Exception_Registration::
406 * No_Floating_Point::
407 * No_Implicit_Conditionals::
408 * No_Implicit_Dynamic_Code::
409 * No_Implicit_Heap_Allocations::
410 * No_Implicit_Loops::
411 * No_Initialize_Scalars::
413 * No_Local_Allocators::
414 * No_Local_Protected_Objects::
415 * No_Local_Timing_Events::
416 * No_Nested_Finalization::
417 * No_Protected_Type_Allocators::
418 * No_Protected_Types::
421 * No_Relative_Delay::
422 * No_Requeue_Statements::
423 * No_Secondary_Stack::
424 * No_Select_Statements::
425 * No_Specific_Termination_Handlers::
426 * No_Specification_of_Aspect::
427 * No_Standard_Allocators_After_Elaboration::
428 * No_Standard_Storage_Pools::
429 * No_Stream_Optimizations::
431 * No_Task_Allocators::
432 * No_Task_Attributes_Package::
433 * No_Task_Hierarchy::
434 * No_Task_Termination::
436 * No_Terminate_Alternatives::
437 * No_Unchecked_Access::
439 * Static_Priorities::
440 * Static_Storage_Size::
442 Program Unit Level Restrictions
444 * No_Elaboration_Code::
446 * No_Implementation_Aspect_Specifications::
447 * No_Implementation_Attributes::
448 * No_Implementation_Identifiers::
449 * No_Implementation_Pragmas::
450 * No_Implementation_Restrictions::
451 * No_Implementation_Units::
452 * No_Implicit_Aliasing::
453 * No_Obsolescent_Features::
454 * No_Wide_Characters::
457 The Implementation of Standard I/O
459 * Standard I/O Packages::
465 * Wide_Wide_Text_IO::
469 * Filenames encoding::
471 * Operations on C Streams::
472 * Interfacing to C Streams::
476 * Ada.Characters.Latin_9 (a-chlat9.ads)::
477 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
478 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
479 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
480 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
481 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
482 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
483 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
484 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
485 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
486 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
487 * Ada.Command_Line.Environment (a-colien.ads)::
488 * Ada.Command_Line.Remove (a-colire.ads)::
489 * Ada.Command_Line.Response_File (a-clrefi.ads)::
490 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
491 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
492 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
493 * Ada.Exceptions.Traceback (a-exctra.ads)::
494 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
495 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
496 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
497 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
498 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
499 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
500 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
501 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
502 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
503 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
504 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
505 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
506 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
507 * GNAT.Altivec (g-altive.ads)::
508 * GNAT.Altivec.Conversions (g-altcon.ads)::
509 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
510 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
511 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
512 * GNAT.Array_Split (g-arrspl.ads)::
513 * GNAT.AWK (g-awk.ads)::
514 * GNAT.Bounded_Buffers (g-boubuf.ads)::
515 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
516 * GNAT.Bubble_Sort (g-bubsor.ads)::
517 * GNAT.Bubble_Sort_A (g-busora.ads)::
518 * GNAT.Bubble_Sort_G (g-busorg.ads)::
519 * GNAT.Byte_Order_Mark (g-byorma.ads)::
520 * GNAT.Byte_Swapping (g-bytswa.ads)::
521 * GNAT.Calendar (g-calend.ads)::
522 * GNAT.Calendar.Time_IO (g-catiio.ads)::
523 * GNAT.Case_Util (g-casuti.ads)::
524 * GNAT.CGI (g-cgi.ads)::
525 * GNAT.CGI.Cookie (g-cgicoo.ads)::
526 * GNAT.CGI.Debug (g-cgideb.ads)::
527 * GNAT.Command_Line (g-comlin.ads)::
528 * GNAT.Compiler_Version (g-comver.ads)::
529 * GNAT.Ctrl_C (g-ctrl_c.ads)::
530 * GNAT.CRC32 (g-crc32.ads)::
531 * GNAT.Current_Exception (g-curexc.ads)::
532 * GNAT.Debug_Pools (g-debpoo.ads)::
533 * GNAT.Debug_Utilities (g-debuti.ads)::
534 * GNAT.Decode_String (g-decstr.ads)::
535 * GNAT.Decode_UTF8_String (g-deutst.ads)::
536 * GNAT.Directory_Operations (g-dirope.ads)::
537 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
538 * GNAT.Dynamic_HTables (g-dynhta.ads)::
539 * GNAT.Dynamic_Tables (g-dyntab.ads)::
540 * GNAT.Encode_String (g-encstr.ads)::
541 * GNAT.Encode_UTF8_String (g-enutst.ads)::
542 * GNAT.Exception_Actions (g-excact.ads)::
543 * GNAT.Exception_Traces (g-exctra.ads)::
544 * GNAT.Exceptions (g-except.ads)::
545 * GNAT.Expect (g-expect.ads)::
546 * GNAT.Expect.TTY (g-exptty.ads)::
547 * GNAT.Float_Control (g-flocon.ads)::
548 * GNAT.Heap_Sort (g-heasor.ads)::
549 * GNAT.Heap_Sort_A (g-hesora.ads)::
550 * GNAT.Heap_Sort_G (g-hesorg.ads)::
551 * GNAT.HTable (g-htable.ads)::
552 * GNAT.IO (g-io.ads)::
553 * GNAT.IO_Aux (g-io_aux.ads)::
554 * GNAT.Lock_Files (g-locfil.ads)::
555 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
556 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
557 * GNAT.MD5 (g-md5.ads)::
558 * GNAT.Memory_Dump (g-memdum.ads)::
559 * GNAT.Most_Recent_Exception (g-moreex.ads)::
560 * GNAT.OS_Lib (g-os_lib.ads)::
561 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
562 * GNAT.Random_Numbers (g-rannum.ads)::
563 * GNAT.Regexp (g-regexp.ads)::
564 * GNAT.Registry (g-regist.ads)::
565 * GNAT.Regpat (g-regpat.ads)::
566 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
567 * GNAT.Semaphores (g-semaph.ads)::
568 * GNAT.Serial_Communications (g-sercom.ads)::
569 * GNAT.SHA1 (g-sha1.ads)::
570 * GNAT.SHA224 (g-sha224.ads)::
571 * GNAT.SHA256 (g-sha256.ads)::
572 * GNAT.SHA384 (g-sha384.ads)::
573 * GNAT.SHA512 (g-sha512.ads)::
574 * GNAT.Signals (g-signal.ads)::
575 * GNAT.Sockets (g-socket.ads)::
576 * GNAT.Source_Info (g-souinf.ads)::
577 * GNAT.Spelling_Checker (g-speche.ads)::
578 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
579 * GNAT.Spitbol.Patterns (g-spipat.ads)::
580 * GNAT.Spitbol (g-spitbo.ads)::
581 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
582 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
583 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
584 * GNAT.SSE (g-sse.ads)::
585 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
586 * GNAT.Strings (g-string.ads)::
587 * GNAT.String_Split (g-strspl.ads)::
588 * GNAT.Table (g-table.ads)::
589 * GNAT.Task_Lock (g-tasloc.ads)::
590 * GNAT.Threads (g-thread.ads)::
591 * GNAT.Time_Stamp (g-timsta.ads)::
592 * GNAT.Traceback (g-traceb.ads)::
593 * GNAT.Traceback.Symbolic (g-trasym.ads)::
594 * GNAT.UTF_32 (g-utf_32.ads)::
595 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
596 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
597 * GNAT.Wide_String_Split (g-wistsp.ads)::
598 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
599 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
600 * Interfaces.C.Extensions (i-cexten.ads)::
601 * Interfaces.C.Streams (i-cstrea.ads)::
602 * Interfaces.CPP (i-cpp.ads)::
603 * Interfaces.Packed_Decimal (i-pacdec.ads)::
604 * Interfaces.VxWorks (i-vxwork.ads)::
605 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
606 * System.Address_Image (s-addima.ads)::
607 * System.Assertions (s-assert.ads)::
608 * System.Memory (s-memory.ads)::
609 * System.Multiprocessors (s-multip.ads)::
610 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
611 * System.Partition_Interface (s-parint.ads)::
612 * System.Pool_Global (s-pooglo.ads)::
613 * System.Pool_Local (s-pooloc.ads)::
614 * System.Restrictions (s-restri.ads)::
615 * System.Rident (s-rident.ads)::
616 * System.Strings.Stream_Ops (s-ststop.ads)::
617 * System.Task_Info (s-tasinf.ads)::
618 * System.Wch_Cnv (s-wchcnv.ads)::
619 * System.Wch_Con (s-wchcon.ads)::
623 * Text_IO Stream Pointer Positioning::
624 * Text_IO Reading and Writing Non-Regular Files::
626 * Treating Text_IO Files as Streams::
627 * Text_IO Extensions::
628 * Text_IO Facilities for Unbounded Strings::
632 * Wide_Text_IO Stream Pointer Positioning::
633 * Wide_Text_IO Reading and Writing Non-Regular Files::
637 * Wide_Wide_Text_IO Stream Pointer Positioning::
638 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
640 Interfacing to Other Languages
643 * Interfacing to C++::
644 * Interfacing to COBOL::
645 * Interfacing to Fortran::
646 * Interfacing to non-GNAT Ada code::
648 Specialized Needs Annexes
650 Implementation of Specific Ada Features
651 * Machine Code Insertions::
652 * GNAT Implementation of Tasking::
653 * GNAT Implementation of Shared Passive Packages::
654 * Code Generation for Array Aggregates::
655 * The Size of Discriminated Records with Default Discriminants::
656 * Strict Conformance to the Ada Reference Manual::
658 Implementation of Ada 2012 Features
662 GNU Free Documentation License
669 @node About This Guide
670 @unnumbered About This Guide
673 This manual contains useful information in writing programs using the
674 @value{EDITION} compiler. It includes information on implementation dependent
675 characteristics of @value{EDITION}, including all the information required by
676 Annex M of the Ada language standard.
678 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
679 Ada 83 compatibility mode.
680 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
681 but you can override with a compiler switch
682 to explicitly specify the language version.
683 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
684 @value{EDITION} User's Guide}, for details on these switches.)
685 Throughout this manual, references to ``Ada'' without a year suffix
686 apply to both the Ada 95 and Ada 2005 versions of the language.
688 Ada is designed to be highly portable.
689 In general, a program will have the same effect even when compiled by
690 different compilers on different platforms.
691 However, since Ada is designed to be used in a
692 wide variety of applications, it also contains a number of system
693 dependent features to be used in interfacing to the external world.
694 @cindex Implementation-dependent features
697 Note: Any program that makes use of implementation-dependent features
698 may be non-portable. You should follow good programming practice and
699 isolate and clearly document any sections of your program that make use
700 of these features in a non-portable manner.
703 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
704 ``GNAT'' in the remainder of this document.
708 * What This Reference Manual Contains::
710 * Related Information::
713 @node What This Reference Manual Contains
714 @unnumberedsec What This Reference Manual Contains
717 This reference manual contains the following chapters:
721 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
722 pragmas, which can be used to extend and enhance the functionality of the
726 @ref{Implementation Defined Attributes}, lists GNAT
727 implementation-dependent attributes, which can be used to extend and
728 enhance the functionality of the compiler.
731 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
732 implementation-dependent restrictions, which can be used to extend and
733 enhance the functionality of the compiler.
736 @ref{Implementation Advice}, provides information on generally
737 desirable behavior which are not requirements that all compilers must
738 follow since it cannot be provided on all systems, or which may be
739 undesirable on some systems.
742 @ref{Implementation Defined Characteristics}, provides a guide to
743 minimizing implementation dependent features.
746 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
747 implemented by GNAT, and how they can be imported into user
748 application programs.
751 @ref{Representation Clauses and Pragmas}, describes in detail the
752 way that GNAT represents data, and in particular the exact set
753 of representation clauses and pragmas that is accepted.
756 @ref{Standard Library Routines}, provides a listing of packages and a
757 brief description of the functionality that is provided by Ada's
758 extensive set of standard library routines as implemented by GNAT@.
761 @ref{The Implementation of Standard I/O}, details how the GNAT
762 implementation of the input-output facilities.
765 @ref{The GNAT Library}, is a catalog of packages that complement
766 the Ada predefined library.
769 @ref{Interfacing to Other Languages}, describes how programs
770 written in Ada using GNAT can be interfaced to other programming
773 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
774 of the specialized needs annexes.
777 @ref{Implementation of Specific Ada Features}, discusses issues related
778 to GNAT's implementation of machine code insertions, tasking, and several
782 @ref{Implementation of Ada 2012 Features}, describes the status of the
783 GNAT implementation of the Ada 2012 language standard.
786 @ref{Obsolescent Features} documents implementation dependent features,
787 including pragmas and attributes, which are considered obsolescent, since
788 there are other preferred ways of achieving the same results. These
789 obsolescent forms are retained for backwards compatibility.
793 @cindex Ada 95 Language Reference Manual
794 @cindex Ada 2005 Language Reference Manual
796 This reference manual assumes a basic familiarity with the Ada 95 language, as
797 described in the International Standard ANSI/ISO/IEC-8652:1995,
799 It does not require knowledge of the new features introduced by Ada 2005,
800 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
802 Both reference manuals are included in the GNAT documentation
806 @unnumberedsec Conventions
807 @cindex Conventions, typographical
808 @cindex Typographical conventions
811 Following are examples of the typographical and graphic conventions used
816 @code{Functions}, @code{utility program names}, @code{standard names},
823 @file{File names}, @samp{button names}, and @samp{field names}.
826 @code{Variables}, @env{environment variables}, and @var{metasyntactic
833 [optional information or parameters]
836 Examples are described by text
838 and then shown this way.
843 Commands that are entered by the user are preceded in this manual by the
844 characters @samp{$ } (dollar sign followed by space). If your system uses this
845 sequence as a prompt, then the commands will appear exactly as you see them
846 in the manual. If your system uses some other prompt, then the command will
847 appear with the @samp{$} replaced by whatever prompt character you are using.
849 @node Related Information
850 @unnumberedsec Related Information
852 See the following documents for further information on GNAT:
856 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
857 @value{EDITION} User's Guide}, which provides information on how to use the
858 GNAT compiler system.
861 @cite{Ada 95 Reference Manual}, which contains all reference
862 material for the Ada 95 programming language.
865 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
866 of the Ada 95 standard. The annotations describe
867 detailed aspects of the design decision, and in particular contain useful
868 sections on Ada 83 compatibility.
871 @cite{Ada 2005 Reference Manual}, which contains all reference
872 material for the Ada 2005 programming language.
875 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
876 of the Ada 2005 standard. The annotations describe
877 detailed aspects of the design decision, and in particular contain useful
878 sections on Ada 83 and Ada 95 compatibility.
881 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
882 which contains specific information on compatibility between GNAT and
886 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
887 describes in detail the pragmas and attributes provided by the DEC Ada 83
892 @node Implementation Defined Pragmas
893 @chapter Implementation Defined Pragmas
896 Ada defines a set of pragmas that can be used to supply additional
897 information to the compiler. These language defined pragmas are
898 implemented in GNAT and work as described in the Ada Reference Manual.
900 In addition, Ada allows implementations to define additional pragmas
901 whose meaning is defined by the implementation. GNAT provides a number
902 of these implementation-defined pragmas, which can be used to extend
903 and enhance the functionality of the compiler. This section of the GNAT
904 Reference Manual describes these additional pragmas.
906 Note that any program using these pragmas might not be portable to other
907 compilers (although GNAT implements this set of pragmas on all
908 platforms). Therefore if portability to other compilers is an important
909 consideration, the use of these pragmas should be minimized.
912 * Pragma Abort_Defer::
921 * Pragma Assert_And_Cut::
922 * Pragma Assertion_Policy::
924 * Pragma Assume_No_Invalid_Values::
925 * Pragma Attribute_Definition::
927 * Pragma C_Pass_By_Copy::
929 * Pragma Check_Float_Overflow::
930 * Pragma Check_Name::
931 * Pragma Check_Policy::
932 * Pragma CIL_Constructor::
934 * Pragma Common_Object::
935 * Pragma Compile_Time_Error::
936 * Pragma Compile_Time_Warning::
937 * Pragma Compiler_Unit::
938 * Pragma Complete_Representation::
939 * Pragma Complex_Representation::
940 * Pragma Component_Alignment::
941 * Pragma Contract_Cases::
942 * Pragma Convention_Identifier::
944 * Pragma CPP_Constructor::
945 * Pragma CPP_Virtual::
946 * Pragma CPP_Vtable::
949 * Pragma Debug_Policy::
950 * Pragma Default_Storage_Pool::
951 * Pragma Detect_Blocking::
952 * Pragma Disable_Atomic_Synchronization::
953 * Pragma Dispatching_Domain::
954 * Pragma Elaboration_Checks::
956 * Pragma Enable_Atomic_Synchronization::
957 * Pragma Export_Exception::
958 * Pragma Export_Function::
959 * Pragma Export_Object::
960 * Pragma Export_Procedure::
961 * Pragma Export_Value::
962 * Pragma Export_Valued_Procedure::
963 * Pragma Extend_System::
964 * Pragma Extensions_Allowed::
966 * Pragma External_Name_Casing::
968 * Pragma Favor_Top_Level::
969 * Pragma Finalize_Storage_Only::
970 * Pragma Float_Representation::
972 * Pragma Implementation_Defined::
973 * Pragma Implemented::
974 * Pragma Implicit_Packing::
975 * Pragma Import_Exception::
976 * Pragma Import_Function::
977 * Pragma Import_Object::
978 * Pragma Import_Procedure::
979 * Pragma Import_Valued_Procedure::
980 * Pragma Independent::
981 * Pragma Independent_Components::
982 * Pragma Initialize_Scalars::
983 * Pragma Inline_Always::
984 * Pragma Inline_Generic::
986 * Pragma Interface_Name::
987 * Pragma Interrupt_Handler::
988 * Pragma Interrupt_State::
990 * Pragma Java_Constructor::
991 * Pragma Java_Interface::
992 * Pragma Keep_Names::
995 * Pragma Linker_Alias::
996 * Pragma Linker_Constructor::
997 * Pragma Linker_Destructor::
998 * Pragma Linker_Section::
999 * Pragma Long_Float::
1000 * Pragma Loop_Invariant::
1001 * Pragma Loop_Optimize::
1002 * Pragma Loop_Variant::
1003 * Pragma Machine_Attribute::
1005 * Pragma Main_Storage::
1007 * Pragma No_Inline::
1008 * Pragma No_Return::
1009 * Pragma No_Run_Time::
1010 * Pragma No_Strict_Aliasing::
1011 * Pragma Normalize_Scalars::
1012 * Pragma Obsolescent::
1013 * Pragma Optimize_Alignment::
1015 * Pragma Overflow_Mode::
1016 * Pragma Overriding_Renamings::
1017 * Pragma Partition_Elaboration_Policy::
1019 * Pragma Persistent_BSS::
1021 * Pragma Postcondition::
1022 * Pragma Precondition::
1023 * Pragma Predicate::
1024 * Pragma Preelaborable_Initialization::
1025 * Pragma Preelaborate_05::
1026 * Pragma Priority_Specific_Dispatching::
1028 * Pragma Profile_Warnings::
1029 * Pragma Propagate_Exceptions::
1030 * Pragma Psect_Object::
1033 * Pragma Pure_Function::
1034 * Pragma Ravenscar::
1035 * Pragma Relative_Deadline::
1036 * Pragma Remote_Access_Type::
1037 * Pragma Restricted_Run_Time::
1038 * Pragma Restriction_Warnings::
1039 * Pragma Share_Generic::
1041 * Pragma Short_Circuit_And_Or::
1042 * Pragma Short_Descriptors::
1043 * Pragma Simple_Storage_Pool_Type::
1044 * Pragma Source_File_Name::
1045 * Pragma Source_File_Name_Project::
1046 * Pragma Source_Reference::
1047 * Pragma Static_Elaboration_Desired::
1048 * Pragma Stream_Convert::
1049 * Pragma Style_Checks::
1052 * Pragma Suppress_All::
1053 * Pragma Suppress_Debug_Info::
1054 * Pragma Suppress_Exception_Locations::
1055 * Pragma Suppress_Initialization::
1056 * Pragma Task_Info::
1057 * Pragma Task_Name::
1058 * Pragma Task_Storage::
1059 * Pragma Test_Case::
1060 * Pragma Thread_Local_Storage::
1061 * Pragma Time_Slice::
1063 * Pragma Unchecked_Union::
1064 * Pragma Unimplemented_Unit::
1065 * Pragma Universal_Aliasing ::
1066 * Pragma Universal_Data::
1067 * Pragma Unmodified::
1068 * Pragma Unreferenced::
1069 * Pragma Unreferenced_Objects::
1070 * Pragma Unreserve_All_Interrupts::
1071 * Pragma Unsuppress::
1072 * Pragma Use_VADS_Size::
1073 * Pragma Validity_Checks::
1076 * Pragma Weak_External::
1077 * Pragma Wide_Character_Encoding::
1080 @node Pragma Abort_Defer
1081 @unnumberedsec Pragma Abort_Defer
1083 @cindex Deferring aborts
1091 This pragma must appear at the start of the statement sequence of a
1092 handled sequence of statements (right after the @code{begin}). It has
1093 the effect of deferring aborts for the sequence of statements (but not
1094 for the declarations or handlers, if any, associated with this statement
1098 @unnumberedsec Pragma Ada_83
1102 @smallexample @c ada
1107 A configuration pragma that establishes Ada 83 mode for the unit to
1108 which it applies, regardless of the mode set by the command line
1109 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1110 the syntax and semantics of Ada 83, as defined in the original Ada
1111 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1112 and Ada 2005 are not recognized, optional package bodies are allowed,
1113 and generics may name types with unknown discriminants without using
1114 the @code{(<>)} notation. In addition, some but not all of the additional
1115 restrictions of Ada 83 are enforced.
1117 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1118 Ada 83 code to be compiled and adapted to GNAT with less effort.
1119 Secondly, it aids in keeping code backwards compatible with Ada 83.
1120 However, there is no guarantee that code that is processed correctly
1121 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1122 83 compiler, since GNAT does not enforce all the additional checks
1126 @unnumberedsec Pragma Ada_95
1130 @smallexample @c ada
1135 A configuration pragma that establishes Ada 95 mode for the unit to which
1136 it applies, regardless of the mode set by the command line switches.
1137 This mode is set automatically for the @code{Ada} and @code{System}
1138 packages and their children, so you need not specify it in these
1139 contexts. This pragma is useful when writing a reusable component that
1140 itself uses Ada 95 features, but which is intended to be usable from
1141 either Ada 83 or Ada 95 programs.
1144 @unnumberedsec Pragma Ada_05
1148 @smallexample @c ada
1153 A configuration pragma that establishes Ada 2005 mode for the unit to which
1154 it applies, regardless of the mode set by the command line switches.
1155 This pragma is useful when writing a reusable component that
1156 itself uses Ada 2005 features, but which is intended to be usable from
1157 either Ada 83 or Ada 95 programs.
1159 @node Pragma Ada_2005
1160 @unnumberedsec Pragma Ada_2005
1164 @smallexample @c ada
1169 This configuration pragma is a synonym for pragma Ada_05 and has the
1170 same syntax and effect.
1173 @unnumberedsec Pragma Ada_12
1177 @smallexample @c ada
1182 A configuration pragma that establishes Ada 2012 mode for the unit to which
1183 it applies, regardless of the mode set by the command line switches.
1184 This mode is set automatically for the @code{Ada} and @code{System}
1185 packages and their children, so you need not specify it in these
1186 contexts. This pragma is useful when writing a reusable component that
1187 itself uses Ada 2012 features, but which is intended to be usable from
1188 Ada 83, Ada 95, or Ada 2005 programs.
1190 @node Pragma Ada_2012
1191 @unnumberedsec Pragma Ada_2012
1195 @smallexample @c ada
1200 This configuration pragma is a synonym for pragma Ada_12 and has the
1201 same syntax and effect.
1203 @node Pragma Annotate
1204 @unnumberedsec Pragma Annotate
1208 @smallexample @c ada
1209 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1211 ARG ::= NAME | EXPRESSION
1215 This pragma is used to annotate programs. @var{identifier} identifies
1216 the type of annotation. GNAT verifies that it is an identifier, but does
1217 not otherwise analyze it. The second optional identifier is also left
1218 unanalyzed, and by convention is used to control the action of the tool to
1219 which the annotation is addressed. The remaining @var{arg} arguments
1220 can be either string literals or more generally expressions.
1221 String literals are assumed to be either of type
1222 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1223 depending on the character literals they contain.
1224 All other kinds of arguments are analyzed as expressions, and must be
1227 The analyzed pragma is retained in the tree, but not otherwise processed
1228 by any part of the GNAT compiler, except to generate corresponding note
1229 lines in the generated ALI file. For the format of these note lines, see
1230 the compiler source file lib-writ.ads. This pragma is intended for use by
1231 external tools, including ASIS@. The use of pragma Annotate does not
1232 affect the compilation process in any way. This pragma may be used as
1233 a configuration pragma.
1236 @unnumberedsec Pragma Assert
1240 @smallexample @c ada
1243 [, string_EXPRESSION]);
1247 The effect of this pragma depends on whether the corresponding command
1248 line switch is set to activate assertions. The pragma expands into code
1249 equivalent to the following:
1251 @smallexample @c ada
1252 if assertions-enabled then
1253 if not boolean_EXPRESSION then
1254 System.Assertions.Raise_Assert_Failure
1255 (string_EXPRESSION);
1261 The string argument, if given, is the message that will be associated
1262 with the exception occurrence if the exception is raised. If no second
1263 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1264 where @var{file} is the name of the source file containing the assert,
1265 and @var{nnn} is the line number of the assert. A pragma is not a
1266 statement, so if a statement sequence contains nothing but a pragma
1267 assert, then a null statement is required in addition, as in:
1269 @smallexample @c ada
1272 pragma Assert (K > 3, "Bad value for K");
1278 Note that, as with the @code{if} statement to which it is equivalent, the
1279 type of the expression is either @code{Standard.Boolean}, or any type derived
1280 from this standard type.
1282 Assert checks can be either checked or ignored. By default they are ignored.
1283 They will be checked if either the command line switch @option{-gnata} is
1284 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1285 to enable @code{Assert_Checks}.
1287 If assertions are ignored, then there
1288 is no run-time effect (and in particular, any side effects from the
1289 expression will not occur at run time). (The expression is still
1290 analyzed at compile time, and may cause types to be frozen if they are
1291 mentioned here for the first time).
1293 If assertions are checked, then the given expression is tested, and if
1294 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1295 which results in the raising of @code{Assert_Failure} with the given message.
1297 You should generally avoid side effects in the expression arguments of
1298 this pragma, because these side effects will turn on and off with the
1299 setting of the assertions mode, resulting in assertions that have an
1300 effect on the program. However, the expressions are analyzed for
1301 semantic correctness whether or not assertions are enabled, so turning
1302 assertions on and off cannot affect the legality of a program.
1304 Note that the implementation defined policy @code{DISABLE}, given in a
1305 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1307 Note: this is a standard language-defined pragma in versions
1308 of Ada from 2005 on. In GNAT, it is implemented in all versions
1309 of Ada, and the DISABLE policy is an implementation-defined
1312 @node Pragma Assert_And_Cut
1313 @unnumberedsec Pragma Assert_And_Cut
1314 @findex Assert_And_Cut
1317 @smallexample @c ada
1318 pragma Assert_And_Cut (
1320 [, string_EXPRESSION]);
1324 The effect of this pragma is identical to that of pragma @code{Assert},
1325 except that in an @code{Assertion_Policy} pragma, the identifier
1326 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1329 The intention is that this be used within a subprogram when the
1330 given test expresion sums up all the work done so far in the
1331 subprogram, so that the rest of the subprogram can be verified
1332 (informally or formally) using only the entry preconditions,
1333 and the expression in this pragma. This allows dividing up
1334 a subprogram into sections for the purposes of testing or
1335 formal verification. The pragma also serves as useful
1338 @node Pragma Assertion_Policy
1339 @unnumberedsec Pragma Assertion_Policy
1340 @findex Assertion_Policy
1343 @smallexample @c ada
1344 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1346 pragma Assertion_Policy (
1347 ASSERTION_KIND => POLICY_IDENTIFIER
1348 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1350 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1352 RM_ASSERTION_KIND ::= Assert |
1360 Type_Invariant'Class
1362 ID_ASSERTION_KIND ::= Assertions |
1374 Statement_Assertions
1376 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1380 This is a standard Ada 2012 pragma that is available as an
1381 implementation-defined pragma in earlier versions of Ada.
1382 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1383 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1384 are implementation defined additions recognized by the GNAT compiler.
1386 The pragma applies in both cases to pragmas and aspects with matching
1387 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1388 applies to both the @code{Precondition} pragma
1389 and the aspect @code{Precondition}.
1391 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1392 the corresponding pragma or aspect is activated.
1393 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1394 the corresponding pragma or aspect is deactivated.
1395 This pragma overrides the effect of the @option{-gnata} switch on the
1398 The implementation defined policy @code{DISABLE} is like
1399 @code{IGNORE} except that it completely disables semantic
1400 checking of the corresponding pragma or aspect. This is
1401 useful when the pragma or aspect argument references subprograms
1402 in a with'ed package which is replaced by a dummy package
1403 for the final build.
1405 The implementation defined policy @code{Assertions} applies to all
1406 assertion kinds. The form with no assertion kind given implies this
1407 choice, so it applies to all assertion kinds (RM defined, and
1408 implementation defined).
1410 The implementation defined policy @code{Statement_Assertions}
1411 applies to @code{Assert}, @code{Assert_And_Cut},
1412 @code{Assume}, and @code{Loop_Invariant}.
1415 @unnumberedsec Pragma Assume
1419 @smallexample @c ada
1422 [, string_EXPRESSION]);
1426 The effect of this pragma is identical to that of pragma @code{Assert},
1427 except that in an @code{Assertion_Policy} pragma, the identifier
1428 @code{Assume} is used to control whether it is ignored or checked
1431 The intention is that this be used for assumptions about the
1432 external environment. So you cannot expect to verify formally
1433 or informally that the condition is met, this must be
1434 established by examining things outside the program itself.
1435 For example, we may have code that depends on the size of
1436 @code{Long_Long_Integer} being at least 64. So we could write:
1438 @smallexample @c ada
1439 pragma Assume (Long_Long_Integer'Size >= 64);
1443 This assumption cannot be proved from the program itself,
1444 but it acts as a useful run-time check that the assumption
1445 is met, and documents the need to ensure that it is met by
1446 reference to information outside the program.
1448 @node Pragma Assume_No_Invalid_Values
1449 @unnumberedsec Pragma Assume_No_Invalid_Values
1450 @findex Assume_No_Invalid_Values
1451 @cindex Invalid representations
1452 @cindex Invalid values
1455 @smallexample @c ada
1456 pragma Assume_No_Invalid_Values (On | Off);
1460 This is a configuration pragma that controls the assumptions made by the
1461 compiler about the occurrence of invalid representations (invalid values)
1464 The default behavior (corresponding to an Off argument for this pragma), is
1465 to assume that values may in general be invalid unless the compiler can
1466 prove they are valid. Consider the following example:
1468 @smallexample @c ada
1469 V1 : Integer range 1 .. 10;
1470 V2 : Integer range 11 .. 20;
1472 for J in V2 .. V1 loop
1478 if V1 and V2 have valid values, then the loop is known at compile
1479 time not to execute since the lower bound must be greater than the
1480 upper bound. However in default mode, no such assumption is made,
1481 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1482 is given, the compiler will assume that any occurrence of a variable
1483 other than in an explicit @code{'Valid} test always has a valid
1484 value, and the loop above will be optimized away.
1486 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1487 you know your code is free of uninitialized variables and other
1488 possible sources of invalid representations, and may result in
1489 more efficient code. A program that accesses an invalid representation
1490 with this pragma in effect is erroneous, so no guarantees can be made
1493 It is peculiar though permissible to use this pragma in conjunction
1494 with validity checking (-gnatVa). In such cases, accessing invalid
1495 values will generally give an exception, though formally the program
1496 is erroneous so there are no guarantees that this will always be the
1497 case, and it is recommended that these two options not be used together.
1499 @node Pragma Ast_Entry
1500 @unnumberedsec Pragma Ast_Entry
1505 @smallexample @c ada
1506 pragma AST_Entry (entry_IDENTIFIER);
1510 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1511 argument is the simple name of a single entry; at most one @code{AST_Entry}
1512 pragma is allowed for any given entry. This pragma must be used in
1513 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1514 the entry declaration and in the same task type specification or single task
1515 as the entry to which it applies. This pragma specifies that the given entry
1516 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1517 resulting from an OpenVMS system service call. The pragma does not affect
1518 normal use of the entry. For further details on this pragma, see the
1519 DEC Ada Language Reference Manual, section 9.12a.
1521 @node Pragma Attribute_Definition
1522 @unnumberedsec Pragma Attribute_Definition
1523 @findex Attribute_Definition
1526 @smallexample @c ada
1527 pragma Attribute_Definition
1528 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1529 [Entity =>] LOCAL_NAME,
1530 [Expression =>] EXPRESSION | NAME);
1534 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1535 the attribute definition clause:
1537 @smallexample @c ada
1538 for Entity'Attribute use Expression;
1541 If @code{Attribute} is not a recognized attribute name, the pragma is
1542 ignored, and a warning is emitted. This allows source
1543 code to be written that takes advantage of some new attribute, while remaining
1544 compilable with earlier compilers.
1546 @node Pragma C_Pass_By_Copy
1547 @unnumberedsec Pragma C_Pass_By_Copy
1548 @cindex Passing by copy
1549 @findex C_Pass_By_Copy
1552 @smallexample @c ada
1553 pragma C_Pass_By_Copy
1554 ([Max_Size =>] static_integer_EXPRESSION);
1558 Normally the default mechanism for passing C convention records to C
1559 convention subprograms is to pass them by reference, as suggested by RM
1560 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1561 this default, by requiring that record formal parameters be passed by
1562 copy if all of the following conditions are met:
1566 The size of the record type does not exceed the value specified for
1569 The record type has @code{Convention C}.
1571 The formal parameter has this record type, and the subprogram has a
1572 foreign (non-Ada) convention.
1576 If these conditions are met the argument is passed by copy, i.e.@: in a
1577 manner consistent with what C expects if the corresponding formal in the
1578 C prototype is a struct (rather than a pointer to a struct).
1580 You can also pass records by copy by specifying the convention
1581 @code{C_Pass_By_Copy} for the record type, or by using the extended
1582 @code{Import} and @code{Export} pragmas, which allow specification of
1583 passing mechanisms on a parameter by parameter basis.
1586 @unnumberedsec Pragma Check
1588 @cindex Named assertions
1592 @smallexample @c ada
1594 [Name =>] CHECK_KIND,
1595 [Check =>] Boolean_EXPRESSION
1596 [, [Message =>] string_EXPRESSION] );
1598 CHECK_KIND ::= IDENTIFIER |
1601 Type_Invariant'Class |
1606 This pragma is similar to the predefined pragma @code{Assert} except that an
1607 extra identifier argument is present. In conjunction with pragma
1608 @code{Check_Policy}, this can be used to define groups of assertions that can
1609 be independently controlled. The identifier @code{Assertion} is special, it
1610 refers to the normal set of pragma @code{Assert} statements.
1612 Checks introduced by this pragma are normally deactivated by default. They can
1613 be activated either by the command line option @option{-gnata}, which turns on
1614 all checks, or individually controlled using pragma @code{Check_Policy}.
1616 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1617 permitted as check kinds, since this would cause confusion with the use
1618 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1619 pragmas, where they are used to refer to sets of assertions.
1621 @node Pragma Check_Float_Overflow
1622 @unnumberedsec Pragma Check_Float_Overflow
1623 @cindex Floating-point overflow
1624 @findex Check_Float_Overflow
1627 @smallexample @c ada
1628 pragma Check_Float_Overflow;
1632 In Ada, the predefined floating-point types (@code{Short_Float},
1633 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1634 defined to be @emph{unconstrained}. This means that even though each
1635 has a well-defined base range, an operation that delivers a result
1636 outside this base range is not required to raise an exception.
1637 This implementation permission accommodates the notion
1638 of infinities in IEEE floating-point, and corresponds to the
1639 efficient execution mode on most machines. GNAT will not raise
1640 overflow exceptions on these machines; instead it will generate
1641 infinities and NaN's as defined in the IEEE standard.
1643 Generating infinities, although efficient, is not always desirable.
1644 Often the preferable approach is to check for overflow, even at the
1645 (perhaps considerable) expense of run-time performance.
1646 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1647 range constraints -- and indeed such a subtype
1648 can have the same base range as its base type. For example:
1650 @smallexample @c ada
1651 subtype My_Float is Float range Float'Range;
1655 Here @code{My_Float} has the same range as
1656 @code{Float} but is constrained, so operations on
1657 @code{My_Float} values will be checked for overflow
1660 This style will achieve the desired goal, but
1661 it is often more convenient to be able to simply use
1662 the standard predefined floating-point types as long
1663 as overflow checking could be guaranteed.
1664 The @code{Check_Float_Overflow}
1665 configuration pragma achieves this effect. If a unit is compiled
1666 subject to this configuration pragma, then all operations
1667 on predefined floating-point types will be treated as
1668 though those types were constrained, and overflow checks
1669 will be generated. The @code{Constraint_Error}
1670 exception is raised if the result is out of range.
1672 This mode can also be set by use of the compiler
1673 switch @option{-gnateF}.
1675 @node Pragma Check_Name
1676 @unnumberedsec Pragma Check_Name
1677 @cindex Defining check names
1678 @cindex Check names, defining
1682 @smallexample @c ada
1683 pragma Check_Name (check_name_IDENTIFIER);
1687 This is a configuration pragma that defines a new implementation
1688 defined check name (unless IDENTIFIER matches one of the predefined
1689 check names, in which case the pragma has no effect). Check names
1690 are global to a partition, so if two or more configuration pragmas
1691 are present in a partition mentioning the same name, only one new
1692 check name is introduced.
1694 An implementation defined check name introduced with this pragma may
1695 be used in only three contexts: @code{pragma Suppress},
1696 @code{pragma Unsuppress},
1697 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1698 any of these three cases, the check name must be visible. A check
1699 name is visible if it is in the configuration pragmas applying to
1700 the current unit, or if it appears at the start of any unit that
1701 is part of the dependency set of the current unit (e.g., units that
1702 are mentioned in @code{with} clauses).
1704 Check names introduced by this pragma are subject to control by compiler
1705 switches (in particular -gnatp) in the usual manner.
1707 @node Pragma Check_Policy
1708 @unnumberedsec Pragma Check_Policy
1709 @cindex Controlling assertions
1710 @cindex Assertions, control
1711 @cindex Check pragma control
1712 @cindex Named assertions
1716 @smallexample @c ada
1718 ([Name =>] CHECK_KIND,
1719 [Policy =>] POLICY_IDENTIFIER);
1721 pragma Check_Policy (
1722 CHECK_KIND => POLICY_IDENTIFIER
1723 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1725 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1727 CHECK_KIND ::= IDENTIFIER |
1730 Type_Invariant'Class |
1733 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1734 avoids confusion between the two possible syntax forms for this pragma.
1736 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1740 This pragma is used to set the checking policy for assertions (specified
1741 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1742 to be checked using the @code{Check} pragma. It may appear either as
1743 a configuration pragma, or within a declarative part of package. In the
1744 latter case, it applies from the point where it appears to the end of
1745 the declarative region (like pragma @code{Suppress}).
1747 The @code{Check_Policy} pragma is similar to the
1748 predefined @code{Assertion_Policy} pragma,
1749 and if the check kind corresponds to one of the assertion kinds that
1750 are allowed by @code{Assertion_Policy}, then the effect is identical.
1752 If the first argument is Debug, then the policy applies to Debug pragmas,
1753 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1754 @code{IGNORE}, and allowing them to execute with normal semantics if
1755 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1756 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1757 be totally ignored and not analyzed semantically.
1759 Finally the first argument may be some other identifier than the above
1760 possibilities, in which case it controls a set of named assertions
1761 that can be checked using pragma @code{Check}. For example, if the pragma:
1763 @smallexample @c ada
1764 pragma Check_Policy (Critical_Error, OFF);
1768 is given, then subsequent @code{Check} pragmas whose first argument is also
1769 @code{Critical_Error} will be disabled.
1771 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1772 to turn on corresponding checks. The default for a set of checks for which no
1773 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1774 @option{-gnata} is given, which turns on all checks by default.
1776 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1777 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1778 compatibility with the standard @code{Assertion_Policy} pragma. The check
1779 policy setting @code{DISABLE} causes the second argument of a corresponding
1780 @code{Check} pragma to be completely ignored and not analyzed.
1782 @node Pragma CIL_Constructor
1783 @unnumberedsec Pragma CIL_Constructor
1784 @findex CIL_Constructor
1788 @smallexample @c ada
1789 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1793 This pragma is used to assert that the specified Ada function should be
1794 mapped to the .NET constructor for some Ada tagged record type.
1796 See section 4.1 of the
1797 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1798 for related information.
1800 @node Pragma Comment
1801 @unnumberedsec Pragma Comment
1806 @smallexample @c ada
1807 pragma Comment (static_string_EXPRESSION);
1811 This is almost identical in effect to pragma @code{Ident}. It allows the
1812 placement of a comment into the object file and hence into the
1813 executable file if the operating system permits such usage. The
1814 difference is that @code{Comment}, unlike @code{Ident}, has
1815 no limitations on placement of the pragma (it can be placed
1816 anywhere in the main source unit), and if more than one pragma
1817 is used, all comments are retained.
1819 @node Pragma Common_Object
1820 @unnumberedsec Pragma Common_Object
1821 @findex Common_Object
1825 @smallexample @c ada
1826 pragma Common_Object (
1827 [Internal =>] LOCAL_NAME
1828 [, [External =>] EXTERNAL_SYMBOL]
1829 [, [Size =>] EXTERNAL_SYMBOL] );
1833 | static_string_EXPRESSION
1837 This pragma enables the shared use of variables stored in overlaid
1838 linker areas corresponding to the use of @code{COMMON}
1839 in Fortran. The single
1840 object @var{LOCAL_NAME} is assigned to the area designated by
1841 the @var{External} argument.
1842 You may define a record to correspond to a series
1843 of fields. The @var{Size} argument
1844 is syntax checked in GNAT, but otherwise ignored.
1846 @code{Common_Object} is not supported on all platforms. If no
1847 support is available, then the code generator will issue a message
1848 indicating that the necessary attribute for implementation of this
1849 pragma is not available.
1851 @node Pragma Compile_Time_Error
1852 @unnumberedsec Pragma Compile_Time_Error
1853 @findex Compile_Time_Error
1857 @smallexample @c ada
1858 pragma Compile_Time_Error
1859 (boolean_EXPRESSION, static_string_EXPRESSION);
1863 This pragma can be used to generate additional compile time
1865 is particularly useful in generics, where errors can be issued for
1866 specific problematic instantiations. The first parameter is a boolean
1867 expression. The pragma is effective only if the value of this expression
1868 is known at compile time, and has the value True. The set of expressions
1869 whose values are known at compile time includes all static boolean
1870 expressions, and also other values which the compiler can determine
1871 at compile time (e.g., the size of a record type set by an explicit
1872 size representation clause, or the value of a variable which was
1873 initialized to a constant and is known not to have been modified).
1874 If these conditions are met, an error message is generated using
1875 the value given as the second argument. This string value may contain
1876 embedded ASCII.LF characters to break the message into multiple lines.
1878 @node Pragma Compile_Time_Warning
1879 @unnumberedsec Pragma Compile_Time_Warning
1880 @findex Compile_Time_Warning
1884 @smallexample @c ada
1885 pragma Compile_Time_Warning
1886 (boolean_EXPRESSION, static_string_EXPRESSION);
1890 Same as pragma Compile_Time_Error, except a warning is issued instead
1891 of an error message. Note that if this pragma is used in a package that
1892 is with'ed by a client, the client will get the warning even though it
1893 is issued by a with'ed package (normally warnings in with'ed units are
1894 suppressed, but this is a special exception to that rule).
1896 One typical use is within a generic where compile time known characteristics
1897 of formal parameters are tested, and warnings given appropriately. Another use
1898 with a first parameter of True is to warn a client about use of a package,
1899 for example that it is not fully implemented.
1901 @node Pragma Compiler_Unit
1902 @unnumberedsec Pragma Compiler_Unit
1903 @findex Compiler_Unit
1907 @smallexample @c ada
1908 pragma Compiler_Unit;
1912 This pragma is intended only for internal use in the GNAT run-time library.
1913 It indicates that the unit is used as part of the compiler build. The effect
1914 is to disallow constructs (raise with message, conditional expressions etc)
1915 that would cause trouble when bootstrapping using an older version of GNAT.
1916 For the exact list of restrictions, see the compiler sources and references
1917 to Is_Compiler_Unit.
1919 @node Pragma Complete_Representation
1920 @unnumberedsec Pragma Complete_Representation
1921 @findex Complete_Representation
1925 @smallexample @c ada
1926 pragma Complete_Representation;
1930 This pragma must appear immediately within a record representation
1931 clause. Typical placements are before the first component clause
1932 or after the last component clause. The effect is to give an error
1933 message if any component is missing a component clause. This pragma
1934 may be used to ensure that a record representation clause is
1935 complete, and that this invariant is maintained if fields are
1936 added to the record in the future.
1938 @node Pragma Complex_Representation
1939 @unnumberedsec Pragma Complex_Representation
1940 @findex Complex_Representation
1944 @smallexample @c ada
1945 pragma Complex_Representation
1946 ([Entity =>] LOCAL_NAME);
1950 The @var{Entity} argument must be the name of a record type which has
1951 two fields of the same floating-point type. The effect of this pragma is
1952 to force gcc to use the special internal complex representation form for
1953 this record, which may be more efficient. Note that this may result in
1954 the code for this type not conforming to standard ABI (application
1955 binary interface) requirements for the handling of record types. For
1956 example, in some environments, there is a requirement for passing
1957 records by pointer, and the use of this pragma may result in passing
1958 this type in floating-point registers.
1960 @node Pragma Component_Alignment
1961 @unnumberedsec Pragma Component_Alignment
1962 @cindex Alignments of components
1963 @findex Component_Alignment
1967 @smallexample @c ada
1968 pragma Component_Alignment (
1969 [Form =>] ALIGNMENT_CHOICE
1970 [, [Name =>] type_LOCAL_NAME]);
1972 ALIGNMENT_CHOICE ::=
1980 Specifies the alignment of components in array or record types.
1981 The meaning of the @var{Form} argument is as follows:
1984 @findex Component_Size
1985 @item Component_Size
1986 Aligns scalar components and subcomponents of the array or record type
1987 on boundaries appropriate to their inherent size (naturally
1988 aligned). For example, 1-byte components are aligned on byte boundaries,
1989 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1990 integer components are aligned on 4-byte boundaries and so on. These
1991 alignment rules correspond to the normal rules for C compilers on all
1992 machines except the VAX@.
1994 @findex Component_Size_4
1995 @item Component_Size_4
1996 Naturally aligns components with a size of four or fewer
1997 bytes. Components that are larger than 4 bytes are placed on the next
2000 @findex Storage_Unit
2002 Specifies that array or record components are byte aligned, i.e.@:
2003 aligned on boundaries determined by the value of the constant
2004 @code{System.Storage_Unit}.
2008 Specifies that array or record components are aligned on default
2009 boundaries, appropriate to the underlying hardware or operating system or
2010 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2011 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2012 the @code{Default} choice is the same as @code{Component_Size} (natural
2017 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2018 refer to a local record or array type, and the specified alignment
2019 choice applies to the specified type. The use of
2020 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2021 @code{Component_Alignment} pragma to be ignored. The use of
2022 @code{Component_Alignment} together with a record representation clause
2023 is only effective for fields not specified by the representation clause.
2025 If the @code{Name} parameter is absent, the pragma can be used as either
2026 a configuration pragma, in which case it applies to one or more units in
2027 accordance with the normal rules for configuration pragmas, or it can be
2028 used within a declarative part, in which case it applies to types that
2029 are declared within this declarative part, or within any nested scope
2030 within this declarative part. In either case it specifies the alignment
2031 to be applied to any record or array type which has otherwise standard
2034 If the alignment for a record or array type is not specified (using
2035 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2036 clause), the GNAT uses the default alignment as described previously.
2038 @node Pragma Contract_Cases
2039 @unnumberedsec Pragma Contract_Cases
2040 @cindex Contract cases
2041 @findex Contract_Cases
2045 @smallexample @c ada
2046 pragma Contract_Cases (
2047 Condition => Consequence
2048 @{,Condition => Consequence@});
2052 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2053 that can complement or replace the contract given by a precondition and a
2054 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2055 by testing and formal verification tools. The compiler checks its validity and,
2056 depending on the assertion policy at the point of declaration of the pragma,
2057 it may insert a check in the executable. For code generation, the contract
2060 @smallexample @c ada
2061 pragma Contract_Cases (
2069 @smallexample @c ada
2070 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2071 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2072 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2073 pragma Postcondition (if C1 then Pred1);
2074 pragma Postcondition (if C2 then Pred2);
2078 The precondition ensures that one and only one of the conditions is
2079 satisfied on entry to the subprogram.
2080 The postcondition ensures that for the condition that was True on entry,
2081 the corrresponding consequence is True on exit. Other consequence expressions
2084 A precondition @code{P} and postcondition @code{Q} can also be
2085 expressed as contract cases:
2087 @smallexample @c ada
2088 pragma Contract_Cases (P => Q);
2091 The placement and visibility rules for @code{Contract_Cases} pragmas are
2092 identical to those described for preconditions and postconditions.
2094 The compiler checks that boolean expressions given in conditions and
2095 consequences are valid, where the rules for conditions are the same as
2096 the rule for an expression in @code{Precondition} and the rules for
2097 consequences are the same as the rule for an expression in
2098 @code{Postcondition}. In particular, attributes @code{'Old} and
2099 @code{'Result} can only be used within consequence expressions.
2100 The condition for the last contract case may be @code{others}, to denote
2101 any case not captured by the previous cases. The
2102 following is an example of use within a package spec:
2104 @smallexample @c ada
2105 package Math_Functions is
2107 function Sqrt (Arg : Float) return Float;
2108 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2109 Arg >= 100 => Sqrt'Result >= 10,
2110 others => Sqrt'Result = 0);
2116 The meaning of contract cases is that only one case should apply at each
2117 call, as determined by the corresponding condition evaluating to True,
2118 and that the consequence for this case should hold when the subprogram
2121 @node Pragma Convention_Identifier
2122 @unnumberedsec Pragma Convention_Identifier
2123 @findex Convention_Identifier
2124 @cindex Conventions, synonyms
2128 @smallexample @c ada
2129 pragma Convention_Identifier (
2130 [Name =>] IDENTIFIER,
2131 [Convention =>] convention_IDENTIFIER);
2135 This pragma provides a mechanism for supplying synonyms for existing
2136 convention identifiers. The @code{Name} identifier can subsequently
2137 be used as a synonym for the given convention in other pragmas (including
2138 for example pragma @code{Import} or another @code{Convention_Identifier}
2139 pragma). As an example of the use of this, suppose you had legacy code
2140 which used Fortran77 as the identifier for Fortran. Then the pragma:
2142 @smallexample @c ada
2143 pragma Convention_Identifier (Fortran77, Fortran);
2147 would allow the use of the convention identifier @code{Fortran77} in
2148 subsequent code, avoiding the need to modify the sources. As another
2149 example, you could use this to parameterize convention requirements
2150 according to systems. Suppose you needed to use @code{Stdcall} on
2151 windows systems, and @code{C} on some other system, then you could
2152 define a convention identifier @code{Library} and use a single
2153 @code{Convention_Identifier} pragma to specify which convention
2154 would be used system-wide.
2156 @node Pragma CPP_Class
2157 @unnumberedsec Pragma CPP_Class
2159 @cindex Interfacing with C++
2163 @smallexample @c ada
2164 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2168 The argument denotes an entity in the current declarative region that is
2169 declared as a record type. It indicates that the type corresponds to an
2170 externally declared C++ class type, and is to be laid out the same way
2171 that C++ would lay out the type. If the C++ class has virtual primitives
2172 then the record must be declared as a tagged record type.
2174 Types for which @code{CPP_Class} is specified do not have assignment or
2175 equality operators defined (such operations can be imported or declared
2176 as subprograms as required). Initialization is allowed only by constructor
2177 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2178 limited if not explicitly declared as limited or derived from a limited
2179 type, and an error is issued in that case.
2181 See @ref{Interfacing to C++} for related information.
2183 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2184 for backward compatibility but its functionality is available
2185 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2187 @node Pragma CPP_Constructor
2188 @unnumberedsec Pragma CPP_Constructor
2189 @cindex Interfacing with C++
2190 @findex CPP_Constructor
2194 @smallexample @c ada
2195 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2196 [, [External_Name =>] static_string_EXPRESSION ]
2197 [, [Link_Name =>] static_string_EXPRESSION ]);
2201 This pragma identifies an imported function (imported in the usual way
2202 with pragma @code{Import}) as corresponding to a C++ constructor. If
2203 @code{External_Name} and @code{Link_Name} are not specified then the
2204 @code{Entity} argument is a name that must have been previously mentioned
2205 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2206 must be of one of the following forms:
2210 @code{function @var{Fname} return @var{T}}
2214 @code{function @var{Fname} return @var{T}'Class}
2217 @code{function @var{Fname} (@dots{}) return @var{T}}
2221 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2225 where @var{T} is a limited record type imported from C++ with pragma
2226 @code{Import} and @code{Convention} = @code{CPP}.
2228 The first two forms import the default constructor, used when an object
2229 of type @var{T} is created on the Ada side with no explicit constructor.
2230 The latter two forms cover all the non-default constructors of the type.
2231 See the @value{EDITION} User's Guide for details.
2233 If no constructors are imported, it is impossible to create any objects
2234 on the Ada side and the type is implicitly declared abstract.
2236 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2237 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2239 See @ref{Interfacing to C++} for more related information.
2241 Note: The use of functions returning class-wide types for constructors is
2242 currently obsolete. They are supported for backward compatibility. The
2243 use of functions returning the type T leave the Ada sources more clear
2244 because the imported C++ constructors always return an object of type T;
2245 that is, they never return an object whose type is a descendant of type T.
2247 @node Pragma CPP_Virtual
2248 @unnumberedsec Pragma CPP_Virtual
2249 @cindex Interfacing to C++
2252 This pragma is now obsolete and, other than generating a warning if warnings
2253 on obsolescent features are enabled, is completely ignored.
2254 It is retained for compatibility
2255 purposes. It used to be required to ensure compoatibility with C++, but
2256 is no longer required for that purpose because GNAT generates
2257 the same object layout as the G++ compiler by default.
2259 See @ref{Interfacing to C++} for related information.
2261 @node Pragma CPP_Vtable
2262 @unnumberedsec Pragma CPP_Vtable
2263 @cindex Interfacing with C++
2266 This pragma is now obsolete and, other than generating a warning if warnings
2267 on obsolescent features are enabled, is completely ignored.
2268 It used to be required to ensure compatibility with C++, but
2269 is no longer required for that purpose because GNAT generates
2270 the same object layout than the G++ compiler by default.
2272 See @ref{Interfacing to C++} for related information.
2275 @unnumberedsec Pragma CPU
2280 @smallexample @c ada
2281 pragma CPU (EXPRESSSION);
2285 This pragma is standard in Ada 2012, but is available in all earlier
2286 versions of Ada as an implementation-defined pragma.
2287 See Ada 2012 Reference Manual for details.
2290 @unnumberedsec Pragma Debug
2295 @smallexample @c ada
2296 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2298 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2300 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2304 The procedure call argument has the syntactic form of an expression, meeting
2305 the syntactic requirements for pragmas.
2307 If debug pragmas are not enabled or if the condition is present and evaluates
2308 to False, this pragma has no effect. If debug pragmas are enabled, the
2309 semantics of the pragma is exactly equivalent to the procedure call statement
2310 corresponding to the argument with a terminating semicolon. Pragmas are
2311 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2312 intersperse calls to debug procedures in the middle of declarations. Debug
2313 pragmas can be enabled either by use of the command line switch @option{-gnata}
2314 or by use of the pragma @code{Check_Policy} with a first argument of
2317 @node Pragma Debug_Policy
2318 @unnumberedsec Pragma Debug_Policy
2319 @findex Debug_Policy
2323 @smallexample @c ada
2324 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2328 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2329 with a first argument of @code{Debug}. It is retained for historical
2330 compatibility reasons.
2332 @node Pragma Default_Storage_Pool
2333 @unnumberedsec Pragma Default_Storage_Pool
2334 @findex Default_Storage_Pool
2338 @smallexample @c ada
2339 pragma Default_Storage_Pool (storage_pool_NAME | null);
2343 This pragma is standard in Ada 2012, but is available in all earlier
2344 versions of Ada as an implementation-defined pragma.
2345 See Ada 2012 Reference Manual for details.
2347 @node Pragma Detect_Blocking
2348 @unnumberedsec Pragma Detect_Blocking
2349 @findex Detect_Blocking
2353 @smallexample @c ada
2354 pragma Detect_Blocking;
2358 This is a standard pragma in Ada 2005, that is available in all earlier
2359 versions of Ada as an implementation-defined pragma.
2361 This is a configuration pragma that forces the detection of potentially
2362 blocking operations within a protected operation, and to raise Program_Error
2365 @node Pragma Disable_Atomic_Synchronization
2366 @unnumberedsec Pragma Disable_Atomic_Synchronization
2367 @cindex Atomic Synchronization
2368 @findex Disable_Atomic_Synchronization
2372 @smallexample @c ada
2373 pragma Disable_Atomic_Synchronization [(Entity)];
2377 Ada requires that accesses (reads or writes) of an atomic variable be
2378 regarded as synchronization points in the case of multiple tasks.
2379 Particularly in the case of multi-processors this may require special
2380 handling, e.g. the generation of memory barriers. This capability may
2381 be turned off using this pragma in cases where it is known not to be
2384 The placement and scope rules for this pragma are the same as those
2385 for @code{pragma Suppress}. In particular it can be used as a
2386 configuration pragma, or in a declaration sequence where it applies
2387 till the end of the scope. If an @code{Entity} argument is present,
2388 the action applies only to that entity.
2390 @node Pragma Dispatching_Domain
2391 @unnumberedsec Pragma Dispatching_Domain
2392 @findex Dispatching_Domain
2396 @smallexample @c ada
2397 pragma Dispatching_Domain (EXPRESSION);
2401 This pragma is standard in Ada 2012, but is available in all earlier
2402 versions of Ada as an implementation-defined pragma.
2403 See Ada 2012 Reference Manual for details.
2405 @node Pragma Elaboration_Checks
2406 @unnumberedsec Pragma Elaboration_Checks
2407 @cindex Elaboration control
2408 @findex Elaboration_Checks
2412 @smallexample @c ada
2413 pragma Elaboration_Checks (Dynamic | Static);
2417 This is a configuration pragma that provides control over the
2418 elaboration model used by the compilation affected by the
2419 pragma. If the parameter is @code{Dynamic},
2420 then the dynamic elaboration
2421 model described in the Ada Reference Manual is used, as though
2422 the @option{-gnatE} switch had been specified on the command
2423 line. If the parameter is @code{Static}, then the default GNAT static
2424 model is used. This configuration pragma overrides the setting
2425 of the command line. For full details on the elaboration models
2426 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2427 gnat_ugn, @value{EDITION} User's Guide}.
2429 @node Pragma Eliminate
2430 @unnumberedsec Pragma Eliminate
2431 @cindex Elimination of unused subprograms
2436 @smallexample @c ada
2437 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2438 [Source_Location =>] STRING_LITERAL);
2442 The string literal given for the source location is a string which
2443 specifies the line number of the occurrence of the entity, using
2444 the syntax for SOURCE_TRACE given below:
2446 @smallexample @c ada
2447 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2452 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2454 LINE_NUMBER ::= DIGIT @{DIGIT@}
2458 Spaces around the colon in a @code{Source_Reference} are optional.
2460 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2461 explicit subprogram declaration, where the @code{entity} name in this
2462 designator appears on the source line specified by the source location.
2464 The source trace that is given as the @code{Source_Location} shall obey the
2465 following rules. The @code{FILE_NAME} is the short name (with no directory
2466 information) of an Ada source file, given using exactly the required syntax
2467 for the underlying file system (e.g. case is important if the underlying
2468 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2469 number of the occurrence of the @code{entity}
2470 as a decimal literal without an exponent or point. If an @code{entity} is not
2471 declared in a generic instantiation (this includes generic subprogram
2472 instances), the source trace includes only one source reference. If an entity
2473 is declared inside a generic instantiation, its source trace (when parsing
2474 from left to right) starts with the source location of the declaration of the
2475 entity in the generic unit and ends with the source location of the
2476 instantiation (it is given in square brackets). This approach is recursively
2477 used in case of nested instantiations: the rightmost (nested most deeply in
2478 square brackets) element of the source trace is the location of the outermost
2479 instantiation, the next to left element is the location of the next (first
2480 nested) instantiation in the code of the corresponding generic unit, and so
2481 on, and the leftmost element (that is out of any square brackets) is the
2482 location of the declaration of the entity to eliminate in a generic unit.
2484 Note that the @code{Source_Location} argument specifies which of a set of
2485 similarly named entities is being eliminated, dealing both with overloading,
2486 and also appearence of the same entity name in different scopes.
2488 This pragma indicates that the given entity is not used in the program to be
2489 compiled and built. The effect of the pragma is to allow the compiler to
2490 eliminate the code or data associated with the named entity. Any reference to
2491 an eliminated entity causes a compile-time or link-time error.
2493 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2494 in a system-independent manner, with unused entities eliminated, without
2495 needing to modify the source text. Normally the required set of
2496 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2498 Any source file change that removes, splits, or
2499 adds lines may make the set of Eliminate pragmas invalid because their
2500 @code{Source_Location} argument values may get out of date.
2502 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2503 operation. In this case all the subprograms to which the given operation can
2504 dispatch are considered to be unused (are never called as a result of a direct
2505 or a dispatching call).
2507 @node Pragma Enable_Atomic_Synchronization
2508 @unnumberedsec Pragma Enable_Atomic_Synchronization
2509 @cindex Atomic Synchronization
2510 @findex Enable_Atomic_Synchronization
2514 @smallexample @c ada
2515 pragma Enable_Atomic_Synchronization [(Entity)];
2519 Ada requires that accesses (reads or writes) of an atomic variable be
2520 regarded as synchronization points in the case of multiple tasks.
2521 Particularly in the case of multi-processors this may require special
2522 handling, e.g. the generation of memory barriers. This synchronization
2523 is performed by default, but can be turned off using
2524 @code{pragma Disable_Atomic_Synchronization}. The
2525 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2528 The placement and scope rules for this pragma are the same as those
2529 for @code{pragma Unsuppress}. In particular it can be used as a
2530 configuration pragma, or in a declaration sequence where it applies
2531 till the end of the scope. If an @code{Entity} argument is present,
2532 the action applies only to that entity.
2534 @node Pragma Export_Exception
2535 @unnumberedsec Pragma Export_Exception
2537 @findex Export_Exception
2541 @smallexample @c ada
2542 pragma Export_Exception (
2543 [Internal =>] LOCAL_NAME
2544 [, [External =>] EXTERNAL_SYMBOL]
2545 [, [Form =>] Ada | VMS]
2546 [, [Code =>] static_integer_EXPRESSION]);
2550 | static_string_EXPRESSION
2554 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2555 causes the specified exception to be propagated outside of the Ada program,
2556 so that it can be handled by programs written in other OpenVMS languages.
2557 This pragma establishes an external name for an Ada exception and makes the
2558 name available to the OpenVMS Linker as a global symbol. For further details
2559 on this pragma, see the
2560 DEC Ada Language Reference Manual, section 13.9a3.2.
2562 @node Pragma Export_Function
2563 @unnumberedsec Pragma Export_Function
2564 @cindex Argument passing mechanisms
2565 @findex Export_Function
2570 @smallexample @c ada
2571 pragma Export_Function (
2572 [Internal =>] LOCAL_NAME
2573 [, [External =>] EXTERNAL_SYMBOL]
2574 [, [Parameter_Types =>] PARAMETER_TYPES]
2575 [, [Result_Type =>] result_SUBTYPE_MARK]
2576 [, [Mechanism =>] MECHANISM]
2577 [, [Result_Mechanism =>] MECHANISM_NAME]);
2581 | static_string_EXPRESSION
2586 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2590 | subtype_Name ' Access
2594 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2596 MECHANISM_ASSOCIATION ::=
2597 [formal_parameter_NAME =>] MECHANISM_NAME
2602 | Descriptor [([Class =>] CLASS_NAME)]
2603 | Short_Descriptor [([Class =>] CLASS_NAME)]
2605 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2609 Use this pragma to make a function externally callable and optionally
2610 provide information on mechanisms to be used for passing parameter and
2611 result values. We recommend, for the purposes of improving portability,
2612 this pragma always be used in conjunction with a separate pragma
2613 @code{Export}, which must precede the pragma @code{Export_Function}.
2614 GNAT does not require a separate pragma @code{Export}, but if none is
2615 present, @code{Convention Ada} is assumed, which is usually
2616 not what is wanted, so it is usually appropriate to use this
2617 pragma in conjunction with a @code{Export} or @code{Convention}
2618 pragma that specifies the desired foreign convention.
2619 Pragma @code{Export_Function}
2620 (and @code{Export}, if present) must appear in the same declarative
2621 region as the function to which they apply.
2623 @var{internal_name} must uniquely designate the function to which the
2624 pragma applies. If more than one function name exists of this name in
2625 the declarative part you must use the @code{Parameter_Types} and
2626 @code{Result_Type} parameters is mandatory to achieve the required
2627 unique designation. @var{subtype_mark}s in these parameters must
2628 exactly match the subtypes in the corresponding function specification,
2629 using positional notation to match parameters with subtype marks.
2630 The form with an @code{'Access} attribute can be used to match an
2631 anonymous access parameter.
2634 @cindex Passing by descriptor
2635 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2636 The default behavior for Export_Function is to accept either 64bit or
2637 32bit descriptors unless short_descriptor is specified, then only 32bit
2638 descriptors are accepted.
2640 @cindex Suppressing external name
2641 Special treatment is given if the EXTERNAL is an explicit null
2642 string or a static string expressions that evaluates to the null
2643 string. In this case, no external name is generated. This form
2644 still allows the specification of parameter mechanisms.
2646 @node Pragma Export_Object
2647 @unnumberedsec Pragma Export_Object
2648 @findex Export_Object
2652 @smallexample @c ada
2653 pragma Export_Object
2654 [Internal =>] LOCAL_NAME
2655 [, [External =>] EXTERNAL_SYMBOL]
2656 [, [Size =>] EXTERNAL_SYMBOL]
2660 | static_string_EXPRESSION
2664 This pragma designates an object as exported, and apart from the
2665 extended rules for external symbols, is identical in effect to the use of
2666 the normal @code{Export} pragma applied to an object. You may use a
2667 separate Export pragma (and you probably should from the point of view
2668 of portability), but it is not required. @var{Size} is syntax checked,
2669 but otherwise ignored by GNAT@.
2671 @node Pragma Export_Procedure
2672 @unnumberedsec Pragma Export_Procedure
2673 @findex Export_Procedure
2677 @smallexample @c ada
2678 pragma Export_Procedure (
2679 [Internal =>] LOCAL_NAME
2680 [, [External =>] EXTERNAL_SYMBOL]
2681 [, [Parameter_Types =>] PARAMETER_TYPES]
2682 [, [Mechanism =>] MECHANISM]);
2686 | static_string_EXPRESSION
2691 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2695 | subtype_Name ' Access
2699 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2701 MECHANISM_ASSOCIATION ::=
2702 [formal_parameter_NAME =>] MECHANISM_NAME
2707 | Descriptor [([Class =>] CLASS_NAME)]
2708 | Short_Descriptor [([Class =>] CLASS_NAME)]
2710 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2714 This pragma is identical to @code{Export_Function} except that it
2715 applies to a procedure rather than a function and the parameters
2716 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
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.
2724 @cindex Passing by descriptor
2725 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2726 The default behavior for Export_Procedure is to accept either 64bit or
2727 32bit descriptors unless short_descriptor is specified, then only 32bit
2728 descriptors are accepted.
2730 @cindex Suppressing external name
2731 Special treatment is given if the EXTERNAL is an explicit null
2732 string or a static string expressions that evaluates to the null
2733 string. In this case, no external name is generated. This form
2734 still allows the specification of parameter mechanisms.
2736 @node Pragma Export_Value
2737 @unnumberedsec Pragma Export_Value
2738 @findex Export_Value
2742 @smallexample @c ada
2743 pragma Export_Value (
2744 [Value =>] static_integer_EXPRESSION,
2745 [Link_Name =>] static_string_EXPRESSION);
2749 This pragma serves to export a static integer value for external use.
2750 The first argument specifies the value to be exported. The Link_Name
2751 argument specifies the symbolic name to be associated with the integer
2752 value. This pragma is useful for defining a named static value in Ada
2753 that can be referenced in assembly language units to be linked with
2754 the application. This pragma is currently supported only for the
2755 AAMP target and is ignored for other targets.
2757 @node Pragma Export_Valued_Procedure
2758 @unnumberedsec Pragma Export_Valued_Procedure
2759 @findex Export_Valued_Procedure
2763 @smallexample @c ada
2764 pragma Export_Valued_Procedure (
2765 [Internal =>] LOCAL_NAME
2766 [, [External =>] EXTERNAL_SYMBOL]
2767 [, [Parameter_Types =>] PARAMETER_TYPES]
2768 [, [Mechanism =>] MECHANISM]);
2772 | static_string_EXPRESSION
2777 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2781 | subtype_Name ' Access
2785 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2787 MECHANISM_ASSOCIATION ::=
2788 [formal_parameter_NAME =>] MECHANISM_NAME
2793 | Descriptor [([Class =>] CLASS_NAME)]
2794 | Short_Descriptor [([Class =>] CLASS_NAME)]
2796 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2800 This pragma is identical to @code{Export_Procedure} except that the
2801 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2802 mode @code{OUT}, and externally the subprogram is treated as a function
2803 with this parameter as the result of the function. GNAT provides for
2804 this capability to allow the use of @code{OUT} and @code{IN OUT}
2805 parameters in interfacing to external functions (which are not permitted
2807 GNAT does not require a separate pragma @code{Export}, but if none is
2808 present, @code{Convention Ada} is assumed, which is almost certainly
2809 not what is wanted since the whole point of this pragma is to interface
2810 with foreign language functions, so it is usually appropriate to use this
2811 pragma in conjunction with a @code{Export} or @code{Convention}
2812 pragma that specifies the desired foreign convention.
2815 @cindex Passing by descriptor
2816 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2817 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2818 32bit descriptors unless short_descriptor is specified, then only 32bit
2819 descriptors are accepted.
2821 @cindex Suppressing external name
2822 Special treatment is given if the EXTERNAL is an explicit null
2823 string or a static string expressions that evaluates to the null
2824 string. In this case, no external name is generated. This form
2825 still allows the specification of parameter mechanisms.
2827 @node Pragma Extend_System
2828 @unnumberedsec Pragma Extend_System
2829 @cindex @code{system}, extending
2831 @findex Extend_System
2835 @smallexample @c ada
2836 pragma Extend_System ([Name =>] IDENTIFIER);
2840 This pragma is used to provide backwards compatibility with other
2841 implementations that extend the facilities of package @code{System}. In
2842 GNAT, @code{System} contains only the definitions that are present in
2843 the Ada RM@. However, other implementations, notably the DEC Ada 83
2844 implementation, provide many extensions to package @code{System}.
2846 For each such implementation accommodated by this pragma, GNAT provides a
2847 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2848 implementation, which provides the required additional definitions. You
2849 can use this package in two ways. You can @code{with} it in the normal
2850 way and access entities either by selection or using a @code{use}
2851 clause. In this case no special processing is required.
2853 However, if existing code contains references such as
2854 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2855 definitions provided in package @code{System}, you may use this pragma
2856 to extend visibility in @code{System} in a non-standard way that
2857 provides greater compatibility with the existing code. Pragma
2858 @code{Extend_System} is a configuration pragma whose single argument is
2859 the name of the package containing the extended definition
2860 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2861 control of this pragma will be processed using special visibility
2862 processing that looks in package @code{System.Aux_@var{xxx}} where
2863 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2864 package @code{System}, but not found in package @code{System}.
2866 You can use this pragma either to access a predefined @code{System}
2867 extension supplied with the compiler, for example @code{Aux_DEC} or
2868 you can construct your own extension unit following the above
2869 definition. Note that such a package is a child of @code{System}
2870 and thus is considered part of the implementation. To compile
2871 it you will have to use the appropriate switch for compiling
2873 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2876 @node Pragma Extensions_Allowed
2877 @unnumberedsec Pragma Extensions_Allowed
2878 @cindex Ada Extensions
2879 @cindex GNAT Extensions
2880 @findex Extensions_Allowed
2884 @smallexample @c ada
2885 pragma Extensions_Allowed (On | Off);
2889 This configuration pragma enables or disables the implementation
2890 extension mode (the use of Off as a parameter cancels the effect
2891 of the @option{-gnatX} command switch).
2893 In extension mode, the latest version of the Ada language is
2894 implemented (currently Ada 2012), and in addition a small number
2895 of GNAT specific extensions are recognized as follows:
2898 @item Constrained attribute for generic objects
2899 The @code{Constrained} attribute is permitted for objects of
2900 generic types. The result indicates if the corresponding actual
2905 @node Pragma External
2906 @unnumberedsec Pragma External
2911 @smallexample @c ada
2913 [ Convention =>] convention_IDENTIFIER,
2914 [ Entity =>] LOCAL_NAME
2915 [, [External_Name =>] static_string_EXPRESSION ]
2916 [, [Link_Name =>] static_string_EXPRESSION ]);
2920 This pragma is identical in syntax and semantics to pragma
2921 @code{Export} as defined in the Ada Reference Manual. It is
2922 provided for compatibility with some Ada 83 compilers that
2923 used this pragma for exactly the same purposes as pragma
2924 @code{Export} before the latter was standardized.
2926 @node Pragma External_Name_Casing
2927 @unnumberedsec Pragma External_Name_Casing
2928 @cindex Dec Ada 83 casing compatibility
2929 @cindex External Names, casing
2930 @cindex Casing of External names
2931 @findex External_Name_Casing
2935 @smallexample @c ada
2936 pragma External_Name_Casing (
2937 Uppercase | Lowercase
2938 [, Uppercase | Lowercase | As_Is]);
2942 This pragma provides control over the casing of external names associated
2943 with Import and Export pragmas. There are two cases to consider:
2946 @item Implicit external names
2947 Implicit external names are derived from identifiers. The most common case
2948 arises when a standard Ada Import or Export pragma is used with only two
2951 @smallexample @c ada
2952 pragma Import (C, C_Routine);
2956 Since Ada is a case-insensitive language, the spelling of the identifier in
2957 the Ada source program does not provide any information on the desired
2958 casing of the external name, and so a convention is needed. In GNAT the
2959 default treatment is that such names are converted to all lower case
2960 letters. This corresponds to the normal C style in many environments.
2961 The first argument of pragma @code{External_Name_Casing} can be used to
2962 control this treatment. If @code{Uppercase} is specified, then the name
2963 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2964 then the normal default of all lower case letters will be used.
2966 This same implicit treatment is also used in the case of extended DEC Ada 83
2967 compatible Import and Export pragmas where an external name is explicitly
2968 specified using an identifier rather than a string.
2970 @item Explicit external names
2971 Explicit external names are given as string literals. The most common case
2972 arises when a standard Ada Import or Export pragma is used with three
2975 @smallexample @c ada
2976 pragma Import (C, C_Routine, "C_routine");
2980 In this case, the string literal normally provides the exact casing required
2981 for the external name. The second argument of pragma
2982 @code{External_Name_Casing} may be used to modify this behavior.
2983 If @code{Uppercase} is specified, then the name
2984 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2985 then the name will be forced to all lowercase letters. A specification of
2986 @code{As_Is} provides the normal default behavior in which the casing is
2987 taken from the string provided.
2991 This pragma may appear anywhere that a pragma is valid. In particular, it
2992 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2993 case it applies to all subsequent compilations, or it can be used as a program
2994 unit pragma, in which case it only applies to the current unit, or it can
2995 be used more locally to control individual Import/Export pragmas.
2997 It is primarily intended for use with OpenVMS systems, where many
2998 compilers convert all symbols to upper case by default. For interfacing to
2999 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3002 @smallexample @c ada
3003 pragma External_Name_Casing (Uppercase, Uppercase);
3007 to enforce the upper casing of all external symbols.
3009 @node Pragma Fast_Math
3010 @unnumberedsec Pragma Fast_Math
3015 @smallexample @c ada
3020 This is a configuration pragma which activates a mode in which speed is
3021 considered more important for floating-point operations than absolutely
3022 accurate adherence to the requirements of the standard. Currently the
3023 following operations are affected:
3026 @item Complex Multiplication
3027 The normal simple formula for complex multiplication can result in intermediate
3028 overflows for numbers near the end of the range. The Ada standard requires that
3029 this situation be detected and corrected by scaling, but in Fast_Math mode such
3030 cases will simply result in overflow. Note that to take advantage of this you
3031 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3032 under control of the pragma, rather than use the preinstantiated versions.
3035 @node Pragma Favor_Top_Level
3036 @unnumberedsec Pragma Favor_Top_Level
3037 @findex Favor_Top_Level
3041 @smallexample @c ada
3042 pragma Favor_Top_Level (type_NAME);
3046 The named type must be an access-to-subprogram type. This pragma is an
3047 efficiency hint to the compiler, regarding the use of 'Access or
3048 'Unrestricted_Access on nested (non-library-level) subprograms. The
3049 pragma means that nested subprograms are not used with this type, or
3050 are rare, so that the generated code should be efficient in the
3051 top-level case. When this pragma is used, dynamically generated
3052 trampolines may be used on some targets for nested subprograms.
3053 See also the No_Implicit_Dynamic_Code restriction.
3055 @node Pragma Finalize_Storage_Only
3056 @unnumberedsec Pragma Finalize_Storage_Only
3057 @findex Finalize_Storage_Only
3061 @smallexample @c ada
3062 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3066 This pragma allows the compiler not to emit a Finalize call for objects
3067 defined at the library level. This is mostly useful for types where
3068 finalization is only used to deal with storage reclamation since in most
3069 environments it is not necessary to reclaim memory just before terminating
3070 execution, hence the name.
3072 @node Pragma Float_Representation
3073 @unnumberedsec Pragma Float_Representation
3075 @findex Float_Representation
3079 @smallexample @c ada
3080 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3082 FLOAT_REP ::= VAX_Float | IEEE_Float
3086 In the one argument form, this pragma is a configuration pragma which
3087 allows control over the internal representation chosen for the predefined
3088 floating point types declared in the packages @code{Standard} and
3089 @code{System}. On all systems other than OpenVMS, the argument must
3090 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3091 argument may be @code{VAX_Float} to specify the use of the VAX float
3092 format for the floating-point types in Standard. This requires that
3093 the standard runtime libraries be recompiled.
3095 The two argument form specifies the representation to be used for
3096 the specified floating-point type. On all systems other than OpenVMS,
3098 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3102 For a digits value of 6, 32-bit IEEE short format will be used.
3104 For a digits value of 15, 64-bit IEEE long format will be used.
3106 No other value of digits is permitted.
3110 argument may be @code{VAX_Float} to specify the use of the VAX float
3115 For digits values up to 6, F float format will be used.
3117 For digits values from 7 to 9, D float format will be used.
3119 For digits values from 10 to 15, G float format will be used.
3121 Digits values above 15 are not allowed.
3125 @unnumberedsec Pragma Ident
3130 @smallexample @c ada
3131 pragma Ident (static_string_EXPRESSION);
3135 This pragma provides a string identification in the generated object file,
3136 if the system supports the concept of this kind of identification string.
3137 This pragma is allowed only in the outermost declarative part or
3138 declarative items of a compilation unit. If more than one @code{Ident}
3139 pragma is given, only the last one processed is effective.
3141 On OpenVMS systems, the effect of the pragma is identical to the effect of
3142 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3143 maximum allowed length is 31 characters, so if it is important to
3144 maintain compatibility with this compiler, you should obey this length
3147 @node Pragma Implementation_Defined
3148 @unnumberedsec Pragma Implementation_Defined
3149 @findex Implementation_Defined
3153 @smallexample @c ada
3154 pragma Implementation_Defined (local_NAME);
3158 This pragma marks a previously declared entioty as implementation-defined.
3159 For an overloaded entity, applies to the most recent homonym.
3161 @smallexample @c ada
3162 pragma Implementation_Defined;
3166 The form with no arguments appears anywhere within a scope, most
3167 typically a package spec, and indicates that all entities that are
3168 defined within the package spec are Implementation_Defined.
3170 This pragma is used within the GNAT runtime library to identify
3171 implementation-defined entities introduced in language-defined units,
3172 for the purpose of implementing the No_Implementation_Identifiers
3175 @node Pragma Implemented
3176 @unnumberedsec Pragma Implemented
3181 @smallexample @c ada
3182 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3184 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3188 This is an Ada 2012 representation pragma which applies to protected, task
3189 and synchronized interface primitives. The use of pragma Implemented provides
3190 a way to impose a static requirement on the overriding operation by adhering
3191 to one of the three implementation kinds: entry, protected procedure or any of
3192 the above. This pragma is available in all earlier versions of Ada as an
3193 implementation-defined pragma.
3195 @smallexample @c ada
3196 type Synch_Iface is synchronized interface;
3197 procedure Prim_Op (Obj : in out Iface) is abstract;
3198 pragma Implemented (Prim_Op, By_Protected_Procedure);
3200 protected type Prot_1 is new Synch_Iface with
3201 procedure Prim_Op; -- Legal
3204 protected type Prot_2 is new Synch_Iface with
3205 entry Prim_Op; -- Illegal
3208 task type Task_Typ is new Synch_Iface with
3209 entry Prim_Op; -- Illegal
3214 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3215 Implemented determines the runtime behavior of the requeue. Implementation kind
3216 By_Entry guarantees that the action of requeueing will proceed from an entry to
3217 another entry. Implementation kind By_Protected_Procedure transforms the
3218 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3219 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3220 the target's overriding subprogram kind.
3222 @node Pragma Implicit_Packing
3223 @unnumberedsec Pragma Implicit_Packing
3224 @findex Implicit_Packing
3225 @cindex Rational Profile
3229 @smallexample @c ada
3230 pragma Implicit_Packing;
3234 This is a configuration pragma that requests implicit packing for packed
3235 arrays for which a size clause is given but no explicit pragma Pack or
3236 specification of Component_Size is present. It also applies to records
3237 where no record representation clause is present. Consider this example:
3239 @smallexample @c ada
3240 type R is array (0 .. 7) of Boolean;
3245 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3246 does not change the layout of a composite object. So the Size clause in the
3247 above example is normally rejected, since the default layout of the array uses
3248 8-bit components, and thus the array requires a minimum of 64 bits.
3250 If this declaration is compiled in a region of code covered by an occurrence
3251 of the configuration pragma Implicit_Packing, then the Size clause in this
3252 and similar examples will cause implicit packing and thus be accepted. For
3253 this implicit packing to occur, the type in question must be an array of small
3254 components whose size is known at compile time, and the Size clause must
3255 specify the exact size that corresponds to the length of the array multiplied
3256 by the size in bits of the component type.
3257 @cindex Array packing
3259 Similarly, the following example shows the use in the record case
3261 @smallexample @c ada
3263 a, b, c, d, e, f, g, h : boolean;
3270 Without a pragma Pack, each Boolean field requires 8 bits, so the
3271 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3272 sufficient. The use of pragma Implicit_Packing allows this record
3273 declaration to compile without an explicit pragma Pack.
3274 @node Pragma Import_Exception
3275 @unnumberedsec Pragma Import_Exception
3277 @findex Import_Exception
3281 @smallexample @c ada
3282 pragma Import_Exception (
3283 [Internal =>] LOCAL_NAME
3284 [, [External =>] EXTERNAL_SYMBOL]
3285 [, [Form =>] Ada | VMS]
3286 [, [Code =>] static_integer_EXPRESSION]);
3290 | static_string_EXPRESSION
3294 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3295 It allows OpenVMS conditions (for example, from OpenVMS system services or
3296 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3297 The pragma specifies that the exception associated with an exception
3298 declaration in an Ada program be defined externally (in non-Ada code).
3299 For further details on this pragma, see the
3300 DEC Ada Language Reference Manual, section 13.9a.3.1.
3302 @node Pragma Import_Function
3303 @unnumberedsec Pragma Import_Function
3304 @findex Import_Function
3308 @smallexample @c ada
3309 pragma Import_Function (
3310 [Internal =>] LOCAL_NAME,
3311 [, [External =>] EXTERNAL_SYMBOL]
3312 [, [Parameter_Types =>] PARAMETER_TYPES]
3313 [, [Result_Type =>] SUBTYPE_MARK]
3314 [, [Mechanism =>] MECHANISM]
3315 [, [Result_Mechanism =>] MECHANISM_NAME]
3316 [, [First_Optional_Parameter =>] IDENTIFIER]);
3320 | static_string_EXPRESSION
3324 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3328 | subtype_Name ' Access
3332 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3334 MECHANISM_ASSOCIATION ::=
3335 [formal_parameter_NAME =>] MECHANISM_NAME
3340 | Descriptor [([Class =>] CLASS_NAME)]
3341 | Short_Descriptor [([Class =>] CLASS_NAME)]
3343 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3347 This pragma is used in conjunction with a pragma @code{Import} to
3348 specify additional information for an imported function. The pragma
3349 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3350 @code{Import_Function} pragma and both must appear in the same
3351 declarative part as the function specification.
3353 The @var{Internal} argument must uniquely designate
3354 the function to which the
3355 pragma applies. If more than one function name exists of this name in
3356 the declarative part you must use the @code{Parameter_Types} and
3357 @var{Result_Type} parameters to achieve the required unique
3358 designation. Subtype marks in these parameters must exactly match the
3359 subtypes in the corresponding function specification, using positional
3360 notation to match parameters with subtype marks.
3361 The form with an @code{'Access} attribute can be used to match an
3362 anonymous access parameter.
3364 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3365 parameters to specify passing mechanisms for the
3366 parameters and result. If you specify a single mechanism name, it
3367 applies to all parameters. Otherwise you may specify a mechanism on a
3368 parameter by parameter basis using either positional or named
3369 notation. If the mechanism is not specified, the default mechanism
3373 @cindex Passing by descriptor
3374 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3375 The default behavior for Import_Function is to pass a 64bit descriptor
3376 unless short_descriptor is specified, then a 32bit descriptor is passed.
3378 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3379 It specifies that the designated parameter and all following parameters
3380 are optional, meaning that they are not passed at the generated code
3381 level (this is distinct from the notion of optional parameters in Ada
3382 where the parameters are passed anyway with the designated optional
3383 parameters). All optional parameters must be of mode @code{IN} and have
3384 default parameter values that are either known at compile time
3385 expressions, or uses of the @code{'Null_Parameter} attribute.
3387 @node Pragma Import_Object
3388 @unnumberedsec Pragma Import_Object
3389 @findex Import_Object
3393 @smallexample @c ada
3394 pragma Import_Object
3395 [Internal =>] LOCAL_NAME
3396 [, [External =>] EXTERNAL_SYMBOL]
3397 [, [Size =>] EXTERNAL_SYMBOL]);
3401 | static_string_EXPRESSION
3405 This pragma designates an object as imported, and apart from the
3406 extended rules for external symbols, is identical in effect to the use of
3407 the normal @code{Import} pragma applied to an object. Unlike the
3408 subprogram case, you need not use a separate @code{Import} pragma,
3409 although you may do so (and probably should do so from a portability
3410 point of view). @var{size} is syntax checked, but otherwise ignored by
3413 @node Pragma Import_Procedure
3414 @unnumberedsec Pragma Import_Procedure
3415 @findex Import_Procedure
3419 @smallexample @c ada
3420 pragma Import_Procedure (
3421 [Internal =>] LOCAL_NAME
3422 [, [External =>] EXTERNAL_SYMBOL]
3423 [, [Parameter_Types =>] PARAMETER_TYPES]
3424 [, [Mechanism =>] MECHANISM]
3425 [, [First_Optional_Parameter =>] IDENTIFIER]);
3429 | static_string_EXPRESSION
3433 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3437 | subtype_Name ' Access
3441 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3443 MECHANISM_ASSOCIATION ::=
3444 [formal_parameter_NAME =>] MECHANISM_NAME
3449 | Descriptor [([Class =>] CLASS_NAME)]
3450 | Short_Descriptor [([Class =>] CLASS_NAME)]
3452 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3456 This pragma is identical to @code{Import_Function} except that it
3457 applies to a procedure rather than a function and the parameters
3458 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3460 @node Pragma Import_Valued_Procedure
3461 @unnumberedsec Pragma Import_Valued_Procedure
3462 @findex Import_Valued_Procedure
3466 @smallexample @c ada
3467 pragma Import_Valued_Procedure (
3468 [Internal =>] LOCAL_NAME
3469 [, [External =>] EXTERNAL_SYMBOL]
3470 [, [Parameter_Types =>] PARAMETER_TYPES]
3471 [, [Mechanism =>] MECHANISM]
3472 [, [First_Optional_Parameter =>] IDENTIFIER]);
3476 | static_string_EXPRESSION
3480 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3484 | subtype_Name ' Access
3488 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3490 MECHANISM_ASSOCIATION ::=
3491 [formal_parameter_NAME =>] MECHANISM_NAME
3496 | Descriptor [([Class =>] CLASS_NAME)]
3497 | Short_Descriptor [([Class =>] CLASS_NAME)]
3499 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3503 This pragma is identical to @code{Import_Procedure} except that the
3504 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3505 mode @code{OUT}, and externally the subprogram is treated as a function
3506 with this parameter as the result of the function. The purpose of this
3507 capability is to allow the use of @code{OUT} and @code{IN OUT}
3508 parameters in interfacing to external functions (which are not permitted
3509 in Ada functions). You may optionally use the @code{Mechanism}
3510 parameters to specify passing mechanisms for the parameters.
3511 If you specify a single mechanism name, it applies to all parameters.
3512 Otherwise you may specify a mechanism on a parameter by parameter
3513 basis using either positional or named notation. If the mechanism is not
3514 specified, the default mechanism is used.
3516 Note that it is important to use this pragma in conjunction with a separate
3517 pragma Import that specifies the desired convention, since otherwise the
3518 default convention is Ada, which is almost certainly not what is required.
3520 @node Pragma Independent
3521 @unnumberedsec Pragma Independent
3526 @smallexample @c ada
3527 pragma Independent (Local_NAME);
3531 This pragma is standard in Ada 2012 mode (which also provides an aspect
3532 of the same name). It is also available as an implementation-defined
3533 pragma in all earlier versions. It specifies that the
3534 designated object or all objects of the designated type must be
3535 independently addressable. This means that separate tasks can safely
3536 manipulate such objects. For example, if two components of a record are
3537 independent, then two separate tasks may access these two components.
3539 constraints on the representation of the object (for instance prohibiting
3542 @node Pragma Independent_Components
3543 @unnumberedsec Pragma Independent_Components
3544 @findex Independent_Components
3548 @smallexample @c ada
3549 pragma Independent_Components (Local_NAME);
3553 This pragma is standard in Ada 2012 mode (which also provides an aspect
3554 of the same name). It is also available as an implementation-defined
3555 pragma in all earlier versions. It specifies that the components of the
3556 designated object, or the components of each object of the designated
3558 independently addressable. This means that separate tasks can safely
3559 manipulate separate components in the composite object. This may place
3560 constraints on the representation of the object (for instance prohibiting
3563 @node Pragma Initialize_Scalars
3564 @unnumberedsec Pragma Initialize_Scalars
3565 @findex Initialize_Scalars
3566 @cindex debugging with Initialize_Scalars
3570 @smallexample @c ada
3571 pragma Initialize_Scalars;
3575 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3576 two important differences. First, there is no requirement for the pragma
3577 to be used uniformly in all units of a partition, in particular, it is fine
3578 to use this just for some or all of the application units of a partition,
3579 without needing to recompile the run-time library.
3581 In the case where some units are compiled with the pragma, and some without,
3582 then a declaration of a variable where the type is defined in package
3583 Standard or is locally declared will always be subject to initialization,
3584 as will any declaration of a scalar variable. For composite variables,
3585 whether the variable is initialized may also depend on whether the package
3586 in which the type of the variable is declared is compiled with the pragma.
3588 The other important difference is that you can control the value used
3589 for initializing scalar objects. At bind time, you can select several
3590 options for initialization. You can
3591 initialize with invalid values (similar to Normalize_Scalars, though for
3592 Initialize_Scalars it is not always possible to determine the invalid
3593 values in complex cases like signed component fields with non-standard
3594 sizes). You can also initialize with high or
3595 low values, or with a specified bit pattern. See the @value{EDITION}
3596 User's Guide for binder options for specifying these cases.
3598 This means that you can compile a program, and then without having to
3599 recompile the program, you can run it with different values being used
3600 for initializing otherwise uninitialized values, to test if your program
3601 behavior depends on the choice. Of course the behavior should not change,
3602 and if it does, then most likely you have an erroneous reference to an
3603 uninitialized value.
3605 It is even possible to change the value at execution time eliminating even
3606 the need to rebind with a different switch using an environment variable.
3607 See the @value{EDITION} User's Guide for details.
3609 Note that pragma @code{Initialize_Scalars} is particularly useful in
3610 conjunction with the enhanced validity checking that is now provided
3611 in GNAT, which checks for invalid values under more conditions.
3612 Using this feature (see description of the @option{-gnatV} flag in the
3613 @value{EDITION} User's Guide) in conjunction with
3614 pragma @code{Initialize_Scalars}
3615 provides a powerful new tool to assist in the detection of problems
3616 caused by uninitialized variables.
3618 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3619 effect on the generated code. This may cause your code to be
3620 substantially larger. It may also cause an increase in the amount
3621 of stack required, so it is probably a good idea to turn on stack
3622 checking (see description of stack checking in the @value{EDITION}
3623 User's Guide) when using this pragma.
3625 @node Pragma Inline_Always
3626 @unnumberedsec Pragma Inline_Always
3627 @findex Inline_Always
3631 @smallexample @c ada
3632 pragma Inline_Always (NAME [, NAME]);
3636 Similar to pragma @code{Inline} except that inlining is not subject to
3637 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3638 happens regardless of whether these options are used.
3640 @node Pragma Inline_Generic
3641 @unnumberedsec Pragma Inline_Generic
3642 @findex Inline_Generic
3646 @smallexample @c ada
3647 pragma Inline_Generic (GNAME @{, GNAME@});
3649 GNAME ::= generic_unit_NAME | generic_instance_NAME
3653 This pragma is provided for compatibility with Dec Ada 83. It has
3654 no effect in @code{GNAT} (which always inlines generics), other
3655 than to check that the given names are all names of generic units or
3658 @node Pragma Interface
3659 @unnumberedsec Pragma Interface
3664 @smallexample @c ada
3666 [Convention =>] convention_identifier,
3667 [Entity =>] local_NAME
3668 [, [External_Name =>] static_string_expression]
3669 [, [Link_Name =>] static_string_expression]);
3673 This pragma is identical in syntax and semantics to
3674 the standard Ada pragma @code{Import}. It is provided for compatibility
3675 with Ada 83. The definition is upwards compatible both with pragma
3676 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3677 with some extended implementations of this pragma in certain Ada 83
3678 implementations. The only difference between pragma @code{Interface}
3679 and pragma @code{Import} is that there is special circuitry to allow
3680 both pragmas to appear for the same subprogram entity (normally it
3681 is illegal to have multiple @code{Import} pragmas. This is useful in
3682 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3685 @node Pragma Interface_Name
3686 @unnumberedsec Pragma Interface_Name
3687 @findex Interface_Name
3691 @smallexample @c ada
3692 pragma Interface_Name (
3693 [Entity =>] LOCAL_NAME
3694 [, [External_Name =>] static_string_EXPRESSION]
3695 [, [Link_Name =>] static_string_EXPRESSION]);
3699 This pragma provides an alternative way of specifying the interface name
3700 for an interfaced subprogram, and is provided for compatibility with Ada
3701 83 compilers that use the pragma for this purpose. You must provide at
3702 least one of @var{External_Name} or @var{Link_Name}.
3704 @node Pragma Interrupt_Handler
3705 @unnumberedsec Pragma Interrupt_Handler
3706 @findex Interrupt_Handler
3710 @smallexample @c ada
3711 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3715 This program unit pragma is supported for parameterless protected procedures
3716 as described in Annex C of the Ada Reference Manual. On the AAMP target
3717 the pragma can also be specified for nonprotected parameterless procedures
3718 that are declared at the library level (which includes procedures
3719 declared at the top level of a library package). In the case of AAMP,
3720 when this pragma is applied to a nonprotected procedure, the instruction
3721 @code{IERET} is generated for returns from the procedure, enabling
3722 maskable interrupts, in place of the normal return instruction.
3724 @node Pragma Interrupt_State
3725 @unnumberedsec Pragma Interrupt_State
3726 @findex Interrupt_State
3730 @smallexample @c ada
3731 pragma Interrupt_State
3733 [State =>] SYSTEM | RUNTIME | USER);
3737 Normally certain interrupts are reserved to the implementation. Any attempt
3738 to attach an interrupt causes Program_Error to be raised, as described in
3739 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3740 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3741 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3742 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3743 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3744 Ada exceptions, or used to implement run-time functions such as the
3745 @code{abort} statement and stack overflow checking.
3747 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3748 such uses of interrupts. It subsumes the functionality of pragma
3749 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3750 available on Windows or VMS. On all other platforms than VxWorks,
3751 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3752 and may be used to mark interrupts required by the board support package
3755 Interrupts can be in one of three states:
3759 The interrupt is reserved (no Ada handler can be installed), and the
3760 Ada run-time may not install a handler. As a result you are guaranteed
3761 standard system default action if this interrupt is raised.
3765 The interrupt is reserved (no Ada handler can be installed). The run time
3766 is allowed to install a handler for internal control purposes, but is
3767 not required to do so.
3771 The interrupt is unreserved. The user may install a handler to provide
3776 These states are the allowed values of the @code{State} parameter of the
3777 pragma. The @code{Name} parameter is a value of the type
3778 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3779 @code{Ada.Interrupts.Names}.
3781 This is a configuration pragma, and the binder will check that there
3782 are no inconsistencies between different units in a partition in how a
3783 given interrupt is specified. It may appear anywhere a pragma is legal.
3785 The effect is to move the interrupt to the specified state.
3787 By declaring interrupts to be SYSTEM, you guarantee the standard system
3788 action, such as a core dump.
3790 By declaring interrupts to be USER, you guarantee that you can install
3793 Note that certain signals on many operating systems cannot be caught and
3794 handled by applications. In such cases, the pragma is ignored. See the
3795 operating system documentation, or the value of the array @code{Reserved}
3796 declared in the spec of package @code{System.OS_Interface}.
3798 Overriding the default state of signals used by the Ada runtime may interfere
3799 with an application's runtime behavior in the cases of the synchronous signals,
3800 and in the case of the signal used to implement the @code{abort} statement.
3802 @node Pragma Invariant
3803 @unnumberedsec Pragma Invariant
3808 @smallexample @c ada
3810 ([Entity =>] private_type_LOCAL_NAME,
3811 [Check =>] EXPRESSION
3812 [,[Message =>] String_Expression]);
3816 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3817 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3818 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3819 requires the use of the aspect syntax, which is not available except in 2012
3820 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3821 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3822 note that the aspect Invariant is a synonym in GNAT for the aspect
3823 Type_Invariant, but there is no pragma Type_Invariant.
3825 The pragma must appear within the visible part of the package specification,
3826 after the type to which its Entity argument appears. As with the Invariant
3827 aspect, the Check expression is not analyzed until the end of the visible
3828 part of the package, so it may contain forward references. The Message
3829 argument, if present, provides the exception message used if the invariant
3830 is violated. If no Message parameter is provided, a default message that
3831 identifies the line on which the pragma appears is used.
3833 It is permissible to have multiple Invariants for the same type entity, in
3834 which case they are and'ed together. It is permissible to use this pragma
3835 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3836 invariant pragma for the same entity.
3838 For further details on the use of this pragma, see the Ada 2012 documentation
3839 of the Type_Invariant aspect.
3841 @node Pragma Java_Constructor
3842 @unnumberedsec Pragma Java_Constructor
3843 @findex Java_Constructor
3847 @smallexample @c ada
3848 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3852 This pragma is used to assert that the specified Ada function should be
3853 mapped to the Java constructor for some Ada tagged record type.
3855 See section 7.3.2 of the
3856 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3857 for related information.
3859 @node Pragma Java_Interface
3860 @unnumberedsec Pragma Java_Interface
3861 @findex Java_Interface
3865 @smallexample @c ada
3866 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3870 This pragma is used to assert that the specified Ada abstract tagged type
3871 is to be mapped to a Java interface name.
3873 See sections 7.1 and 7.2 of the
3874 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3875 for related information.
3877 @node Pragma Keep_Names
3878 @unnumberedsec Pragma Keep_Names
3883 @smallexample @c ada
3884 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3888 The @var{LOCAL_NAME} argument
3889 must refer to an enumeration first subtype
3890 in the current declarative part. The effect is to retain the enumeration
3891 literal names for use by @code{Image} and @code{Value} even if a global
3892 @code{Discard_Names} pragma applies. This is useful when you want to
3893 generally suppress enumeration literal names and for example you therefore
3894 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3895 want to retain the names for specific enumeration types.
3897 @node Pragma License
3898 @unnumberedsec Pragma License
3900 @cindex License checking
3904 @smallexample @c ada
3905 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3909 This pragma is provided to allow automated checking for appropriate license
3910 conditions with respect to the standard and modified GPL@. A pragma
3911 @code{License}, which is a configuration pragma that typically appears at
3912 the start of a source file or in a separate @file{gnat.adc} file, specifies
3913 the licensing conditions of a unit as follows:
3917 This is used for a unit that can be freely used with no license restrictions.
3918 Examples of such units are public domain units, and units from the Ada
3922 This is used for a unit that is licensed under the unmodified GPL, and which
3923 therefore cannot be @code{with}'ed by a restricted unit.
3926 This is used for a unit licensed under the GNAT modified GPL that includes
3927 a special exception paragraph that specifically permits the inclusion of
3928 the unit in programs without requiring the entire program to be released
3932 This is used for a unit that is restricted in that it is not permitted to
3933 depend on units that are licensed under the GPL@. Typical examples are
3934 proprietary code that is to be released under more restrictive license
3935 conditions. Note that restricted units are permitted to @code{with} units
3936 which are licensed under the modified GPL (this is the whole point of the
3942 Normally a unit with no @code{License} pragma is considered to have an
3943 unknown license, and no checking is done. However, standard GNAT headers
3944 are recognized, and license information is derived from them as follows.
3948 A GNAT license header starts with a line containing 78 hyphens. The following
3949 comment text is searched for the appearance of any of the following strings.
3951 If the string ``GNU General Public License'' is found, then the unit is assumed
3952 to have GPL license, unless the string ``As a special exception'' follows, in
3953 which case the license is assumed to be modified GPL@.
3955 If one of the strings
3956 ``This specification is adapted from the Ada Semantic Interface'' or
3957 ``This specification is derived from the Ada Reference Manual'' is found
3958 then the unit is assumed to be unrestricted.
3962 These default actions means that a program with a restricted license pragma
3963 will automatically get warnings if a GPL unit is inappropriately
3964 @code{with}'ed. For example, the program:
3966 @smallexample @c ada
3969 procedure Secret_Stuff is
3975 if compiled with pragma @code{License} (@code{Restricted}) in a
3976 @file{gnat.adc} file will generate the warning:
3981 >>> license of withed unit "Sem_Ch3" is incompatible
3983 2. with GNAT.Sockets;
3984 3. procedure Secret_Stuff is
3988 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3989 compiler and is licensed under the
3990 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3991 run time, and is therefore licensed under the modified GPL@.
3993 @node Pragma Link_With
3994 @unnumberedsec Pragma Link_With
3999 @smallexample @c ada
4000 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4004 This pragma is provided for compatibility with certain Ada 83 compilers.
4005 It has exactly the same effect as pragma @code{Linker_Options} except
4006 that spaces occurring within one of the string expressions are treated
4007 as separators. For example, in the following case:
4009 @smallexample @c ada
4010 pragma Link_With ("-labc -ldef");
4014 results in passing the strings @code{-labc} and @code{-ldef} as two
4015 separate arguments to the linker. In addition pragma Link_With allows
4016 multiple arguments, with the same effect as successive pragmas.
4018 @node Pragma Linker_Alias
4019 @unnumberedsec Pragma Linker_Alias
4020 @findex Linker_Alias
4024 @smallexample @c ada
4025 pragma Linker_Alias (
4026 [Entity =>] LOCAL_NAME,
4027 [Target =>] static_string_EXPRESSION);
4031 @var{LOCAL_NAME} must refer to an object that is declared at the library
4032 level. This pragma establishes the given entity as a linker alias for the
4033 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4034 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4035 @var{static_string_EXPRESSION} in the object file, that is to say no space
4036 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4037 to the same address as @var{static_string_EXPRESSION} by the linker.
4039 The actual linker name for the target must be used (e.g.@: the fully
4040 encoded name with qualification in Ada, or the mangled name in C++),
4041 or it must be declared using the C convention with @code{pragma Import}
4042 or @code{pragma Export}.
4044 Not all target machines support this pragma. On some of them it is accepted
4045 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4047 @smallexample @c ada
4048 -- Example of the use of pragma Linker_Alias
4052 pragma Export (C, i);
4054 new_name_for_i : Integer;
4055 pragma Linker_Alias (new_name_for_i, "i");
4059 @node Pragma Linker_Constructor
4060 @unnumberedsec Pragma Linker_Constructor
4061 @findex Linker_Constructor
4065 @smallexample @c ada
4066 pragma Linker_Constructor (procedure_LOCAL_NAME);
4070 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4071 is declared at the library level. A procedure to which this pragma is
4072 applied will be treated as an initialization routine by the linker.
4073 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4074 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4075 of the executable is called (or immediately after the shared library is
4076 loaded if the procedure is linked in a shared library), in particular
4077 before the Ada run-time environment is set up.
4079 Because of these specific contexts, the set of operations such a procedure
4080 can perform is very limited and the type of objects it can manipulate is
4081 essentially restricted to the elementary types. In particular, it must only
4082 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4084 This pragma is used by GNAT to implement auto-initialization of shared Stand
4085 Alone Libraries, which provides a related capability without the restrictions
4086 listed above. Where possible, the use of Stand Alone Libraries is preferable
4087 to the use of this pragma.
4089 @node Pragma Linker_Destructor
4090 @unnumberedsec Pragma Linker_Destructor
4091 @findex Linker_Destructor
4095 @smallexample @c ada
4096 pragma Linker_Destructor (procedure_LOCAL_NAME);
4100 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4101 is declared at the library level. A procedure to which this pragma is
4102 applied will be treated as a finalization routine by the linker.
4103 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4104 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4105 of the executable has exited (or immediately before the shared library
4106 is unloaded if the procedure is linked in a shared library), in particular
4107 after the Ada run-time environment is shut down.
4109 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4110 because of these specific contexts.
4112 @node Pragma Linker_Section
4113 @unnumberedsec Pragma Linker_Section
4114 @findex Linker_Section
4118 @smallexample @c ada
4119 pragma Linker_Section (
4120 [Entity =>] LOCAL_NAME,
4121 [Section =>] static_string_EXPRESSION);
4125 @var{LOCAL_NAME} must refer to an object that is declared at the library
4126 level. This pragma specifies the name of the linker section for the given
4127 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
4128 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
4129 section of the executable (assuming the linker doesn't rename the section).
4131 The compiler normally places library-level objects in standard sections
4132 depending on their type: procedures and functions generally go in the
4133 @code{.text} section, initialized variables in the @code{.data} section
4134 and uninitialized variables in the @code{.bss} section.
4136 Other, special sections may exist on given target machines to map special
4137 hardware, for example I/O ports or flash memory. This pragma is a means to
4138 defer the final layout of the executable to the linker, thus fully working
4139 at the symbolic level with the compiler.
4141 Some file formats do not support arbitrary sections so not all target
4142 machines support this pragma. The use of this pragma may cause a program
4143 execution to be erroneous if it is used to place an entity into an
4144 inappropriate section (e.g.@: a modified variable into the @code{.text}
4145 section). See also @code{pragma Persistent_BSS}.
4147 @smallexample @c ada
4148 -- Example of the use of pragma Linker_Section
4152 pragma Volatile (Port_A);
4153 pragma Linker_Section (Port_A, ".bss.port_a");
4156 pragma Volatile (Port_B);
4157 pragma Linker_Section (Port_B, ".bss.port_b");
4161 @node Pragma Long_Float
4162 @unnumberedsec Pragma Long_Float
4168 @smallexample @c ada
4169 pragma Long_Float (FLOAT_FORMAT);
4171 FLOAT_FORMAT ::= D_Float | G_Float
4175 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4176 It allows control over the internal representation chosen for the predefined
4177 type @code{Long_Float} and for floating point type representations with
4178 @code{digits} specified in the range 7 through 15.
4179 For further details on this pragma, see the
4180 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4181 this pragma, the standard runtime libraries must be recompiled.
4183 @node Pragma Loop_Invariant
4184 @unnumberedsec Pragma Loop_Invariant
4185 @findex Loop_Invariant
4189 @smallexample @c ada
4190 pragma Loop_Invariant ( boolean_EXPRESSION );
4194 The effect of this pragma is similar to that of pragma @code{Assert},
4195 except that in an @code{Assertion_Policy} pragma, the identifier
4196 @code{Loop_Invariant} is used to control whether it is ignored or checked
4199 @code{Loop_Invariant} can only appear as one of the items in the sequence
4200 of statements of a loop body. The intention is that it be used to
4201 represent a "loop invariant" assertion, i.e. something that is true each
4202 time through the loop, and which can be used to show that the loop is
4203 achieving its purpose.
4205 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4206 may be used to refer to the value of an expression on entry to the loop. This
4207 attribute can only be used within the expression of a @code{Loop_Invariant}
4208 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4210 @node Pragma Loop_Optimize
4211 @unnumberedsec Pragma Loop_Optimize
4212 @findex Loop_Optimize
4216 @smallexample @c ada
4217 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4219 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4223 This pragma must appear immediately within a loop statement. It allows the
4224 programmer to specify optimization hints for the enclosing loop. The hints
4225 are not mutually exclusive and can be freely mixed, but not all combinations
4226 will yield a sensible outcome.
4228 There are four supported optimization hints for a loop:
4232 The loop must not be unrolled. This is a strong hint: the compiler will not
4233 unroll a loop marked with this hint.
4237 The loop should be unrolled. This is a weak hint: the compiler will try to
4238 apply unrolling to this loop preferably to other optimizations, notably
4239 vectorization, but there is no guarantee that the loop will be unrolled.
4243 The loop must not be vectorized. This is a strong hint: the compiler will not
4244 vectorize a loop marked with this hint.
4248 The loop should be vectorized. This is a weak hint: the compiler will try to
4249 apply vectorization to this loop preferably to other optimizations, notably
4250 unrolling, but there is no guarantee that the loop will be vectorized.
4254 These hints do not void the need to pass the appropriate switches to the
4255 compiler in order to enable the relevant optimizations, that is to say
4256 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4259 @node Pragma Loop_Variant
4260 @unnumberedsec Pragma Loop_Variant
4261 @findex Loop_Variant
4265 @smallexample @c ada
4266 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4267 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4268 CHANGE_DIRECTION ::= Increases | Decreases
4272 This pragma must appear immediately within the sequence of statements of a
4273 loop statement. It allows the specification of quantities which must always
4274 decrease or increase in successive iterations of the loop. In its simplest
4275 form, just one expression is specified, whose value must increase or decrease
4276 on each iteration of the loop.
4278 In a more complex form, multiple arguments can be given which are intepreted
4279 in a nesting lexicographic manner. For example:
4281 @smallexample @c ada
4282 pragma Loop_Variant (Increases => X, Decreases => Y);
4286 specifies that each time through the loop either X increases, or X stays
4287 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4288 loop is making progress. It can be useful in helping to show informally
4289 or prove formally that the loop always terminates.
4291 @code{Loop_Variant} is an assertion whose effect can be controlled using
4292 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4293 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4294 to ignore the check (in which case the pragma has no effect on the program),
4295 or @code{Disable} in which case the pragma is not even checked for correct
4298 The @code{Loop_Entry} attribute may be used within the expressions of the
4299 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4301 @node Pragma Machine_Attribute
4302 @unnumberedsec Pragma Machine_Attribute
4303 @findex Machine_Attribute
4307 @smallexample @c ada
4308 pragma Machine_Attribute (
4309 [Entity =>] LOCAL_NAME,
4310 [Attribute_Name =>] static_string_EXPRESSION
4311 [, [Info =>] static_EXPRESSION] );
4315 Machine-dependent attributes can be specified for types and/or
4316 declarations. This pragma is semantically equivalent to
4317 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4318 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4319 in GNU C, where @code{@var{attribute_name}} is recognized by the
4320 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4321 specific macro. A string literal for the optional parameter @var{info}
4322 is transformed into an identifier, which may make this pragma unusable
4323 for some attributes. @xref{Target Attributes,, Defining target-specific
4324 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4325 Internals}, further information.
4328 @unnumberedsec Pragma Main
4334 @smallexample @c ada
4336 (MAIN_OPTION [, MAIN_OPTION]);
4339 [Stack_Size =>] static_integer_EXPRESSION
4340 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4341 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4345 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4346 no effect in GNAT, other than being syntax checked.
4348 @node Pragma Main_Storage
4349 @unnumberedsec Pragma Main_Storage
4351 @findex Main_Storage
4355 @smallexample @c ada
4357 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4359 MAIN_STORAGE_OPTION ::=
4360 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4361 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4365 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4366 no effect in GNAT, other than being syntax checked. Note that the pragma
4367 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4369 @node Pragma No_Body
4370 @unnumberedsec Pragma No_Body
4375 @smallexample @c ada
4380 There are a number of cases in which a package spec does not require a body,
4381 and in fact a body is not permitted. GNAT will not permit the spec to be
4382 compiled if there is a body around. The pragma No_Body allows you to provide
4383 a body file, even in a case where no body is allowed. The body file must
4384 contain only comments and a single No_Body pragma. This is recognized by
4385 the compiler as indicating that no body is logically present.
4387 This is particularly useful during maintenance when a package is modified in
4388 such a way that a body needed before is no longer needed. The provision of a
4389 dummy body with a No_Body pragma ensures that there is no interference from
4390 earlier versions of the package body.
4392 @node Pragma No_Inline
4393 @unnumberedsec Pragma No_Inline
4398 @smallexample @c ada
4399 pragma No_Inline (NAME @{, NAME@});
4403 This pragma suppresses inlining for the callable entity or the instances of
4404 the generic subprogram designated by @var{NAME}, including inlining that
4405 results from the use of pragma @code{Inline}. This pragma is always active,
4406 in particular it is not subject to the use of option @option{-gnatn} or
4407 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4408 pragma @code{Inline_Always} for the same @var{NAME}.
4410 @node Pragma No_Return
4411 @unnumberedsec Pragma No_Return
4416 @smallexample @c ada
4417 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4421 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4422 declarations in the current declarative part. A procedure to which this
4423 pragma is applied may not contain any explicit @code{return} statements.
4424 In addition, if the procedure contains any implicit returns from falling
4425 off the end of a statement sequence, then execution of that implicit
4426 return will cause Program_Error to be raised.
4428 One use of this pragma is to identify procedures whose only purpose is to raise
4429 an exception. Another use of this pragma is to suppress incorrect warnings
4430 about missing returns in functions, where the last statement of a function
4431 statement sequence is a call to such a procedure.
4433 Note that in Ada 2005 mode, this pragma is part of the language. It is
4434 available in all earlier versions of Ada as an implementation-defined
4437 @node Pragma No_Run_Time
4438 @unnumberedsec Pragma No_Run_Time
4443 @smallexample @c ada
4448 This is an obsolete configuration pragma that historically was used to
4449 setup what is now called the "zero footprint" library. It causes any
4450 library units outside this basic library to be ignored. The use of
4451 this pragma has been superseded by the general configurable run-time
4452 capability of @code{GNAT} where the compiler takes into account whatever
4453 units happen to be accessible in the library.
4455 @node Pragma No_Strict_Aliasing
4456 @unnumberedsec Pragma No_Strict_Aliasing
4457 @findex No_Strict_Aliasing
4461 @smallexample @c ada
4462 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4466 @var{type_LOCAL_NAME} must refer to an access type
4467 declaration in the current declarative part. The effect is to inhibit
4468 strict aliasing optimization for the given type. The form with no
4469 arguments is a configuration pragma which applies to all access types
4470 declared in units to which the pragma applies. For a detailed
4471 description of the strict aliasing optimization, and the situations
4472 in which it must be suppressed, see @ref{Optimization and Strict
4473 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4475 This pragma currently has no effects on access to unconstrained array types.
4477 @node Pragma Normalize_Scalars
4478 @unnumberedsec Pragma Normalize_Scalars
4479 @findex Normalize_Scalars
4483 @smallexample @c ada
4484 pragma Normalize_Scalars;
4488 This is a language defined pragma which is fully implemented in GNAT@. The
4489 effect is to cause all scalar objects that are not otherwise initialized
4490 to be initialized. The initial values are implementation dependent and
4494 @item Standard.Character
4496 Objects whose root type is Standard.Character are initialized to
4497 Character'Last unless the subtype range excludes NUL (in which case
4498 NUL is used). This choice will always generate an invalid value if
4501 @item Standard.Wide_Character
4503 Objects whose root type is Standard.Wide_Character are initialized to
4504 Wide_Character'Last unless the subtype range excludes NUL (in which case
4505 NUL is used). This choice will always generate an invalid value if
4508 @item Standard.Wide_Wide_Character
4510 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4511 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4512 which case NUL is used). This choice will always generate an invalid value if
4517 Objects of an integer type are treated differently depending on whether
4518 negative values are present in the subtype. If no negative values are
4519 present, then all one bits is used as the initial value except in the
4520 special case where zero is excluded from the subtype, in which case
4521 all zero bits are used. This choice will always generate an invalid
4522 value if one exists.
4524 For subtypes with negative values present, the largest negative number
4525 is used, except in the unusual case where this largest negative number
4526 is in the subtype, and the largest positive number is not, in which case
4527 the largest positive value is used. This choice will always generate
4528 an invalid value if one exists.
4530 @item Floating-Point Types
4531 Objects of all floating-point types are initialized to all 1-bits. For
4532 standard IEEE format, this corresponds to a NaN (not a number) which is
4533 indeed an invalid value.
4535 @item Fixed-Point Types
4536 Objects of all fixed-point types are treated as described above for integers,
4537 with the rules applying to the underlying integer value used to represent
4538 the fixed-point value.
4541 Objects of a modular type are initialized to all one bits, except in
4542 the special case where zero is excluded from the subtype, in which
4543 case all zero bits are used. This choice will always generate an
4544 invalid value if one exists.
4546 @item Enumeration types
4547 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4548 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4549 whose Pos value is zero, in which case a code of zero is used. This choice
4550 will always generate an invalid value if one exists.
4554 @node Pragma Obsolescent
4555 @unnumberedsec Pragma Obsolescent
4560 @smallexample @c ada
4563 pragma Obsolescent (
4564 [Message =>] static_string_EXPRESSION
4565 [,[Version =>] Ada_05]]);
4567 pragma Obsolescent (
4569 [,[Message =>] static_string_EXPRESSION
4570 [,[Version =>] Ada_05]] );
4574 This pragma can occur immediately following a declaration of an entity,
4575 including the case of a record component. If no Entity argument is present,
4576 then this declaration is the one to which the pragma applies. If an Entity
4577 parameter is present, it must either match the name of the entity in this
4578 declaration, or alternatively, the pragma can immediately follow an enumeration
4579 type declaration, where the Entity argument names one of the enumeration
4582 This pragma is used to indicate that the named entity
4583 is considered obsolescent and should not be used. Typically this is
4584 used when an API must be modified by eventually removing or modifying
4585 existing subprograms or other entities. The pragma can be used at an
4586 intermediate stage when the entity is still present, but will be
4589 The effect of this pragma is to output a warning message on a reference to
4590 an entity thus marked that the subprogram is obsolescent if the appropriate
4591 warning option in the compiler is activated. If the Message parameter is
4592 present, then a second warning message is given containing this text. In
4593 addition, a reference to the entity is considered to be a violation of pragma
4594 Restrictions (No_Obsolescent_Features).
4596 This pragma can also be used as a program unit pragma for a package,
4597 in which case the entity name is the name of the package, and the
4598 pragma indicates that the entire package is considered
4599 obsolescent. In this case a client @code{with}'ing such a package
4600 violates the restriction, and the @code{with} statement is
4601 flagged with warnings if the warning option is set.
4603 If the Version parameter is present (which must be exactly
4604 the identifier Ada_05, no other argument is allowed), then the
4605 indication of obsolescence applies only when compiling in Ada 2005
4606 mode. This is primarily intended for dealing with the situations
4607 in the predefined library where subprograms or packages
4608 have become defined as obsolescent in Ada 2005
4609 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4611 The following examples show typical uses of this pragma:
4613 @smallexample @c ada
4615 pragma Obsolescent (p, Message => "use pp instead of p");
4620 pragma Obsolescent ("use q2new instead");
4622 type R is new integer;
4625 Message => "use RR in Ada 2005",
4635 type E is (a, bc, 'd', quack);
4636 pragma Obsolescent (Entity => bc)
4637 pragma Obsolescent (Entity => 'd')
4640 (a, b : character) return character;
4641 pragma Obsolescent (Entity => "+");
4646 Note that, as for all pragmas, if you use a pragma argument identifier,
4647 then all subsequent parameters must also use a pragma argument identifier.
4648 So if you specify "Entity =>" for the Entity argument, and a Message
4649 argument is present, it must be preceded by "Message =>".
4651 @node Pragma Optimize_Alignment
4652 @unnumberedsec Pragma Optimize_Alignment
4653 @findex Optimize_Alignment
4654 @cindex Alignment, default settings
4658 @smallexample @c ada
4659 pragma Optimize_Alignment (TIME | SPACE | OFF);
4663 This is a configuration pragma which affects the choice of default alignments
4664 for types where no alignment is explicitly specified. There is a time/space
4665 trade-off in the selection of these values. Large alignments result in more
4666 efficient code, at the expense of larger data space, since sizes have to be
4667 increased to match these alignments. Smaller alignments save space, but the
4668 access code is slower. The normal choice of default alignments (which is what
4669 you get if you do not use this pragma, or if you use an argument of OFF),
4670 tries to balance these two requirements.
4672 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4673 First any packed record is given an alignment of 1. Second, if a size is given
4674 for the type, then the alignment is chosen to avoid increasing this size. For
4677 @smallexample @c ada
4687 In the default mode, this type gets an alignment of 4, so that access to the
4688 Integer field X are efficient. But this means that objects of the type end up
4689 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4690 allowed to be bigger than the size of the type, but it can waste space if for
4691 example fields of type R appear in an enclosing record. If the above type is
4692 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4694 However, there is one case in which SPACE is ignored. If a variable length
4695 record (that is a discriminated record with a component which is an array
4696 whose length depends on a discriminant), has a pragma Pack, then it is not
4697 in general possible to set the alignment of such a record to one, so the
4698 pragma is ignored in this case (with a warning).
4700 Specifying TIME causes larger default alignments to be chosen in the case of
4701 small types with sizes that are not a power of 2. For example, consider:
4703 @smallexample @c ada
4715 The default alignment for this record is normally 1, but if this type is
4716 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4717 to 4, which wastes space for objects of the type, since they are now 4 bytes
4718 long, but results in more efficient access when the whole record is referenced.
4720 As noted above, this is a configuration pragma, and there is a requirement
4721 that all units in a partition be compiled with a consistent setting of the
4722 optimization setting. This would normally be achieved by use of a configuration
4723 pragma file containing the appropriate setting. The exception to this rule is
4724 that units with an explicit configuration pragma in the same file as the source
4725 unit are excluded from the consistency check, as are all predefined units. The
4726 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4727 pragma appears at the start of the file.
4729 @node Pragma Ordered
4730 @unnumberedsec Pragma Ordered
4732 @findex pragma @code{Ordered}
4736 @smallexample @c ada
4737 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4741 Most enumeration types are from a conceptual point of view unordered.
4742 For example, consider:
4744 @smallexample @c ada
4745 type Color is (Red, Blue, Green, Yellow);
4749 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4750 but really these relations make no sense; the enumeration type merely
4751 specifies a set of possible colors, and the order is unimportant.
4753 For unordered enumeration types, it is generally a good idea if
4754 clients avoid comparisons (other than equality or inequality) and
4755 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4756 other than the unit where the type is declared, its body, and its subunits.)
4757 For example, if code buried in some client says:
4759 @smallexample @c ada
4760 if Current_Color < Yellow then ...
4761 if Current_Color in Blue .. Green then ...
4765 then the client code is relying on the order, which is undesirable.
4766 It makes the code hard to read and creates maintenance difficulties if
4767 entries have to be added to the enumeration type. Instead,
4768 the code in the client should list the possibilities, or an
4769 appropriate subtype should be declared in the unit that declares
4770 the original enumeration type. E.g., the following subtype could
4771 be declared along with the type @code{Color}:
4773 @smallexample @c ada
4774 subtype RBG is Color range Red .. Green;
4778 and then the client could write:
4780 @smallexample @c ada
4781 if Current_Color in RBG then ...
4782 if Current_Color = Blue or Current_Color = Green then ...
4786 However, some enumeration types are legitimately ordered from a conceptual
4787 point of view. For example, if you declare:
4789 @smallexample @c ada
4790 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4794 then the ordering imposed by the language is reasonable, and
4795 clients can depend on it, writing for example:
4797 @smallexample @c ada
4798 if D in Mon .. Fri then ...
4803 The pragma @option{Ordered} is provided to mark enumeration types that
4804 are conceptually ordered, alerting the reader that clients may depend
4805 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4806 rather than one to mark them as unordered, since in our experience,
4807 the great majority of enumeration types are conceptually unordered.
4809 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4810 and @code{Wide_Wide_Character}
4811 are considered to be ordered types, so each is declared with a
4812 pragma @code{Ordered} in package @code{Standard}.
4814 Normally pragma @code{Ordered} serves only as documentation and a guide for
4815 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4816 requests warnings for inappropriate uses (comparisons and explicit
4817 subranges) for unordered types. If this switch is used, then any
4818 enumeration type not marked with pragma @code{Ordered} will be considered
4819 as unordered, and will generate warnings for inappropriate uses.
4821 For additional information please refer to the description of the
4822 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4824 @node Pragma Overflow_Mode
4825 @unnumberedsec Pragma Overflow_Mode
4826 @findex Overflow checks
4827 @findex Overflow mode
4828 @findex pragma @code{Overflow_Mode}
4832 @smallexample @c ada
4833 pragma Overflow_Mode
4835 [,[Assertions =>] MODE]);
4837 MODE ::= STRICT | MINIMIZED | ELIMINATED
4841 This pragma sets the current overflow mode to the given setting. For details
4842 of the meaning of these modes, please refer to the
4843 ``Overflow Check Handling in GNAT'' appendix in the
4844 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4845 the given mode applies to all expressions. If both parameters are present,
4846 the @code{General} mode applies to expressions outside assertions, and
4847 the @code{Eliminated} mode applies to expressions within assertions.
4849 The case of the @code{MODE} parameter is ignored,
4850 so @code{MINIMIZED}, @code{Minimized} and
4851 @code{minimized} all have the same effect.
4853 The @code{Overflow_Mode} pragma has the same scoping and placement
4854 rules as pragma @code{Suppress}, so it can occur either as a
4855 configuration pragma, specifying a default for the whole
4856 program, or in a declarative scope, where it applies to the
4857 remaining declarations and statements in that scope.
4859 The pragma @code{Suppress (Overflow_Check)} suppresses
4860 overflow checking, but does not affect the overflow mode.
4862 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4863 overflow checking, but does not affect the overflow mode.
4865 @node Pragma Overriding_Renamings
4866 @unnumberedsec Pragma Overriding_Renamings
4867 @findex Overriding_Renamings
4868 @cindex Rational profile
4869 @cindex Rational compatibility
4873 @smallexample @c ada
4874 pragma Overriding_Renamings;
4878 This is a GNAT configuration pragma to simplify porting
4879 legacy code accepted by the Rational
4880 Ada compiler. In the presence of this pragma, a renaming declaration that
4881 renames an inherited operation declared in the same scope is legal if selected
4882 notation is used as in:
4884 @smallexample @c ada
4885 pragma Overriding_Renamings;
4890 function F (..) renames R.F;
4895 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4896 declaration of the overriding operation.
4898 @node Pragma Partition_Elaboration_Policy
4899 @unnumberedsec Pragma Partition_Elaboration_Policy
4900 @findex Partition_Elaboration_Policy
4904 @smallexample @c ada
4905 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4907 POLICY_IDENTIFIER ::= Concurrent | Sequential
4911 This pragma is standard in Ada 2005, but is available in all earlier
4912 versions of Ada as an implementation-defined pragma.
4913 See Ada 2012 Reference Manual for details.
4915 @node Pragma Passive
4916 @unnumberedsec Pragma Passive
4921 @smallexample @c ada
4922 pragma Passive [(Semaphore | No)];
4926 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4927 compatibility with DEC Ada 83 implementations, where it is used within a
4928 task definition to request that a task be made passive. If the argument
4929 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4930 treats the pragma as an assertion that the containing task is passive
4931 and that optimization of context switch with this task is permitted and
4932 desired. If the argument @code{No} is present, the task must not be
4933 optimized. GNAT does not attempt to optimize any tasks in this manner
4934 (since protected objects are available in place of passive tasks).
4936 @node Pragma Persistent_BSS
4937 @unnumberedsec Pragma Persistent_BSS
4938 @findex Persistent_BSS
4942 @smallexample @c ada
4943 pragma Persistent_BSS [(LOCAL_NAME)]
4947 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4948 section. On some targets the linker and loader provide for special
4949 treatment of this section, allowing a program to be reloaded without
4950 affecting the contents of this data (hence the name persistent).
4952 There are two forms of usage. If an argument is given, it must be the
4953 local name of a library level object, with no explicit initialization
4954 and whose type is potentially persistent. If no argument is given, then
4955 the pragma is a configuration pragma, and applies to all library level
4956 objects with no explicit initialization of potentially persistent types.
4958 A potentially persistent type is a scalar type, or a non-tagged,
4959 non-discriminated record, all of whose components have no explicit
4960 initialization and are themselves of a potentially persistent type,
4961 or an array, all of whose constraints are static, and whose component
4962 type is potentially persistent.
4964 If this pragma is used on a target where this feature is not supported,
4965 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4967 @node Pragma Polling
4968 @unnumberedsec Pragma Polling
4973 @smallexample @c ada
4974 pragma Polling (ON | OFF);
4978 This pragma controls the generation of polling code. This is normally off.
4979 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4980 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4981 runtime library, and can be found in file @file{a-excpol.adb}.
4983 Pragma @code{Polling} can appear as a configuration pragma (for example it
4984 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4985 can be used in the statement or declaration sequence to control polling
4988 A call to the polling routine is generated at the start of every loop and
4989 at the start of every subprogram call. This guarantees that the @code{Poll}
4990 routine is called frequently, and places an upper bound (determined by
4991 the complexity of the code) on the period between two @code{Poll} calls.
4993 The primary purpose of the polling interface is to enable asynchronous
4994 aborts on targets that cannot otherwise support it (for example Windows
4995 NT), but it may be used for any other purpose requiring periodic polling.
4996 The standard version is null, and can be replaced by a user program. This
4997 will require re-compilation of the @code{Ada.Exceptions} package that can
4998 be found in files @file{a-except.ads} and @file{a-except.adb}.
5000 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5001 distribution) is used to enable the asynchronous abort capability on
5002 targets that do not normally support the capability. The version of
5003 @code{Poll} in this file makes a call to the appropriate runtime routine
5004 to test for an abort condition.
5006 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5007 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5010 @node Pragma Postcondition
5011 @unnumberedsec Pragma Postcondition
5012 @cindex Postcondition
5013 @cindex Checks, postconditions
5014 @findex Postconditions
5018 @smallexample @c ada
5019 pragma Postcondition (
5020 [Check =>] Boolean_Expression
5021 [,[Message =>] String_Expression]);
5025 The @code{Postcondition} pragma allows specification of automatic
5026 postcondition checks for subprograms. These checks are similar to
5027 assertions, but are automatically inserted just prior to the return
5028 statements of the subprogram with which they are associated (including
5029 implicit returns at the end of procedure bodies and associated
5030 exception handlers).
5032 In addition, the boolean expression which is the condition which
5033 must be true may contain references to function'Result in the case
5034 of a function to refer to the returned value.
5036 @code{Postcondition} pragmas may appear either immediately following the
5037 (separate) declaration of a subprogram, or at the start of the
5038 declarations of a subprogram body. Only other pragmas may intervene
5039 (that is appear between the subprogram declaration and its
5040 postconditions, or appear before the postcondition in the
5041 declaration sequence in a subprogram body). In the case of a
5042 postcondition appearing after a subprogram declaration, the
5043 formal arguments of the subprogram are visible, and can be
5044 referenced in the postcondition expressions.
5046 The postconditions are collected and automatically tested just
5047 before any return (implicit or explicit) in the subprogram body.
5048 A postcondition is only recognized if postconditions are active
5049 at the time the pragma is encountered. The compiler switch @option{gnata}
5050 turns on all postconditions by default, and pragma @code{Check_Policy}
5051 with an identifier of @code{Postcondition} can also be used to
5052 control whether postconditions are active.
5054 The general approach is that postconditions are placed in the spec
5055 if they represent functional aspects which make sense to the client.
5056 For example we might have:
5058 @smallexample @c ada
5059 function Direction return Integer;
5060 pragma Postcondition
5061 (Direction'Result = +1
5063 Direction'Result = -1);
5067 which serves to document that the result must be +1 or -1, and
5068 will test that this is the case at run time if postcondition
5071 Postconditions within the subprogram body can be used to
5072 check that some internal aspect of the implementation,
5073 not visible to the client, is operating as expected.
5074 For instance if a square root routine keeps an internal
5075 counter of the number of times it is called, then we
5076 might have the following postcondition:
5078 @smallexample @c ada
5079 Sqrt_Calls : Natural := 0;
5081 function Sqrt (Arg : Float) return Float is
5082 pragma Postcondition
5083 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5089 As this example, shows, the use of the @code{Old} attribute
5090 is often useful in postconditions to refer to the state on
5091 entry to the subprogram.
5093 Note that postconditions are only checked on normal returns
5094 from the subprogram. If an abnormal return results from
5095 raising an exception, then the postconditions are not checked.
5097 If a postcondition fails, then the exception
5098 @code{System.Assertions.Assert_Failure} is raised. If
5099 a message argument was supplied, then the given string
5100 will be used as the exception message. If no message
5101 argument was supplied, then the default message has
5102 the form "Postcondition failed at file:line". The
5103 exception is raised in the context of the subprogram
5104 body, so it is possible to catch postcondition failures
5105 within the subprogram body itself.
5107 Within a package spec, normal visibility rules
5108 in Ada would prevent forward references within a
5109 postcondition pragma to functions defined later in
5110 the same package. This would introduce undesirable
5111 ordering constraints. To avoid this problem, all
5112 postcondition pragmas are analyzed at the end of
5113 the package spec, allowing forward references.
5115 The following example shows that this even allows
5116 mutually recursive postconditions as in:
5118 @smallexample @c ada
5119 package Parity_Functions is
5120 function Odd (X : Natural) return Boolean;
5121 pragma Postcondition
5125 (x /= 0 and then Even (X - 1))));
5127 function Even (X : Natural) return Boolean;
5128 pragma Postcondition
5132 (x /= 1 and then Odd (X - 1))));
5134 end Parity_Functions;
5138 There are no restrictions on the complexity or form of
5139 conditions used within @code{Postcondition} pragmas.
5140 The following example shows that it is even possible
5141 to verify performance behavior.
5143 @smallexample @c ada
5146 Performance : constant Float;
5147 -- Performance constant set by implementation
5148 -- to match target architecture behavior.
5150 procedure Treesort (Arg : String);
5151 -- Sorts characters of argument using N*logN sort
5152 pragma Postcondition
5153 (Float (Clock - Clock'Old) <=
5154 Float (Arg'Length) *
5155 log (Float (Arg'Length)) *
5161 Note: postcondition pragmas associated with subprograms that are
5162 marked as Inline_Always, or those marked as Inline with front-end
5163 inlining (-gnatN option set) are accepted and legality-checked
5164 by the compiler, but are ignored at run-time even if postcondition
5165 checking is enabled.
5167 @node Pragma Precondition
5168 @unnumberedsec Pragma Precondition
5169 @cindex Preconditions
5170 @cindex Checks, preconditions
5171 @findex Preconditions
5175 @smallexample @c ada
5176 pragma Precondition (
5177 [Check =>] Boolean_Expression
5178 [,[Message =>] String_Expression]);
5182 The @code{Precondition} pragma is similar to @code{Postcondition}
5183 except that the corresponding checks take place immediately upon
5184 entry to the subprogram, and if a precondition fails, the exception
5185 is raised in the context of the caller, and the attribute 'Result
5186 cannot be used within the precondition expression.
5188 Otherwise, the placement and visibility rules are identical to those
5189 described for postconditions. The following is an example of use
5190 within a package spec:
5192 @smallexample @c ada
5193 package Math_Functions is
5195 function Sqrt (Arg : Float) return Float;
5196 pragma Precondition (Arg >= 0.0)
5202 @code{Precondition} pragmas may appear either immediately following the
5203 (separate) declaration of a subprogram, or at the start of the
5204 declarations of a subprogram body. Only other pragmas may intervene
5205 (that is appear between the subprogram declaration and its
5206 postconditions, or appear before the postcondition in the
5207 declaration sequence in a subprogram body).
5209 Note: precondition pragmas associated with subprograms that are
5210 marked as Inline_Always, or those marked as Inline with front-end
5211 inlining (-gnatN option set) are accepted and legality-checked
5212 by the compiler, but are ignored at run-time even if precondition
5213 checking is enabled.
5215 @node Pragma Predicate
5216 @unnumberedsec Pragma Predicate
5218 @findex Predicate pragma
5222 @smallexample @c ada
5224 ([Entity =>] type_LOCAL_NAME,
5225 [Check =>] EXPRESSION);
5229 This pragma (available in all versions of Ada in GNAT) encompasses both
5230 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5231 Ada 2012. A predicate is regarded as static if it has an allowed form
5232 for @code{Static_Predicate} and is otherwise treated as a
5233 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5234 pragma behave exactly as described in the Ada 2012 reference manual.
5235 For example, if we have
5237 @smallexample @c ada
5238 type R is range 1 .. 10;
5240 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5242 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5246 the effect is identical to the following Ada 2012 code:
5248 @smallexample @c ada
5249 type R is range 1 .. 10;
5251 Static_Predicate => S not in 4 .. 6;
5253 Dynamic_Predicate => F(Q) or G(Q);
5256 @node Pragma Preelaborable_Initialization
5257 @unnumberedsec Pragma Preelaborable_Initialization
5258 @findex Preelaborable_Initialization
5262 @smallexample @c ada
5263 pragma Preelaborable_Initialization (DIRECT_NAME);
5267 This pragma is standard in Ada 2005, but is available in all earlier
5268 versions of Ada as an implementation-defined pragma.
5269 See Ada 2012 Reference Manual for details.
5271 @node Pragma Preelaborate_05
5272 @unnumberedsec Pragma Preelaborate_05
5273 @findex Preelaborate_05
5277 @smallexample @c ada
5278 pragma Preelaborate_05 [(library_unit_NAME)];
5282 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5283 and is intended for use in the standard run-time library only. It has
5284 no effect in Ada 83 or Ada 95 mode, but is
5285 equivalent to @code{pragma Prelaborate} when operating in later
5286 Ada versions. This is used to handle some cases where packages
5287 not previously preelaborable became so in Ada 2005.
5289 @node Pragma Priority_Specific_Dispatching
5290 @unnumberedsec Pragma Priority_Specific_Dispatching
5291 @findex Priority_Specific_Dispatching
5295 @smallexample @c ada
5296 pragma Priority_Specific_Dispatching (
5298 first_priority_EXPRESSION,
5299 last_priority_EXPRESSION)
5301 POLICY_IDENTIFIER ::=
5302 EDF_Across_Priorities |
5303 FIFO_Within_Priorities |
5304 Non_Preemptive_Within_Priorities |
5305 Round_Robin_Within_Priorities
5309 This pragma is standard in Ada 2005, but is available in all earlier
5310 versions of Ada as an implementation-defined pragma.
5311 See Ada 2012 Reference Manual for details.
5313 @node Pragma Profile
5314 @unnumberedsec Pragma Profile
5319 @smallexample @c ada
5320 pragma Profile (Ravenscar | Restricted | Rational);
5324 This pragma is standard in Ada 2005, but is available in all earlier
5325 versions of Ada as an implementation-defined pragma. This is a
5326 configuration pragma that establishes a set of configiuration pragmas
5327 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5328 The other two possibilities (@code{Restricted} or @code{Rational})
5329 are implementation-defined. The set of configuration pragmas
5330 is defined in the following sections.
5334 @item Pragma Profile (Ravenscar)
5338 The @code{Ravenscar} profile is standard in Ada 2005,
5339 but is available in all earlier
5340 versions of Ada as an implementation-defined pragma. This profile
5341 establishes the following set of configuration pragmas:
5344 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5345 [RM D.2.2] Tasks are dispatched following a preemptive
5346 priority-ordered scheduling policy.
5348 @item Locking_Policy (Ceiling_Locking)
5349 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5350 the ceiling priority of the corresponding protected object.
5352 @item Detect_Blocking
5353 This pragma forces the detection of potentially blocking operations within a
5354 protected operation, and to raise Program_Error if that happens.
5358 plus the following set of restrictions:
5361 @item Max_Entry_Queue_Length => 1
5362 No task can be queued on a protected entry.
5363 @item Max_Protected_Entries => 1
5364 @item Max_Task_Entries => 0
5365 No rendezvous statements are allowed.
5366 @item No_Abort_Statements
5367 @item No_Dynamic_Attachment
5368 @item No_Dynamic_Priorities
5369 @item No_Implicit_Heap_Allocations
5370 @item No_Local_Protected_Objects
5371 @item No_Local_Timing_Events
5372 @item No_Protected_Type_Allocators
5373 @item No_Relative_Delay
5374 @item No_Requeue_Statements
5375 @item No_Select_Statements
5376 @item No_Specific_Termination_Handlers
5377 @item No_Task_Allocators
5378 @item No_Task_Hierarchy
5379 @item No_Task_Termination
5380 @item Simple_Barriers
5384 The Ravenscar profile also includes the following restrictions that specify
5385 that there are no semantic dependences on the corresponding predefined
5389 @item No_Dependence => Ada.Asynchronous_Task_Control
5390 @item No_Dependence => Ada.Calendar
5391 @item No_Dependence => Ada.Execution_Time.Group_Budget
5392 @item No_Dependence => Ada.Execution_Time.Timers
5393 @item No_Dependence => Ada.Task_Attributes
5394 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5399 This set of configuration pragmas and restrictions correspond to the
5400 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5401 published by the @cite{International Real-Time Ada Workshop}, 1997,
5402 and whose most recent description is available at
5403 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5405 The original definition of the profile was revised at subsequent IRTAW
5406 meetings. It has been included in the ISO
5407 @cite{Guide for the Use of the Ada Programming Language in High
5408 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5409 the next revision of the standard. The formal definition given by
5410 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5411 AI-305) available at
5412 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5413 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5415 The above set is a superset of the restrictions provided by pragma
5416 @code{Profile (Restricted)}, it includes six additional restrictions
5417 (@code{Simple_Barriers}, @code{No_Select_Statements},
5418 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5419 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5420 that pragma @code{Profile (Ravenscar)}, like the pragma
5421 @code{Profile (Restricted)},
5422 automatically causes the use of a simplified,
5423 more efficient version of the tasking run-time system.
5425 @item Pragma Profile (Restricted)
5426 @findex Restricted Run Time
5428 This profile corresponds to the GNAT restricted run time. It
5429 establishes the following set of restrictions:
5432 @item No_Abort_Statements
5433 @item No_Entry_Queue
5434 @item No_Task_Hierarchy
5435 @item No_Task_Allocators
5436 @item No_Dynamic_Priorities
5437 @item No_Terminate_Alternatives
5438 @item No_Dynamic_Attachment
5439 @item No_Protected_Type_Allocators
5440 @item No_Local_Protected_Objects
5441 @item No_Requeue_Statements
5442 @item No_Task_Attributes_Package
5443 @item Max_Asynchronous_Select_Nesting = 0
5444 @item Max_Task_Entries = 0
5445 @item Max_Protected_Entries = 1
5446 @item Max_Select_Alternatives = 0
5450 This set of restrictions causes the automatic selection of a simplified
5451 version of the run time that provides improved performance for the
5452 limited set of tasking functionality permitted by this set of restrictions.
5454 @item Pragma Profile (Rational)
5455 @findex Rational compatibility mode
5457 The Rational profile is intended to facilitate porting legacy code that
5458 compiles with the Rational APEX compiler, even when the code includes non-
5459 conforming Ada constructs. The profile enables the following three pragmas:
5462 @item pragma Implicit_Packing
5463 @item pragma Overriding_Renamings
5464 @item pragma Use_VADS_Size
5469 @node Pragma Profile_Warnings
5470 @unnumberedsec Pragma Profile_Warnings
5471 @findex Profile_Warnings
5475 @smallexample @c ada
5476 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5480 This is an implementation-defined pragma that is similar in
5481 effect to @code{pragma Profile} except that instead of
5482 generating @code{Restrictions} pragmas, it generates
5483 @code{Restriction_Warnings} pragmas. The result is that
5484 violations of the profile generate warning messages instead
5487 @node Pragma Propagate_Exceptions
5488 @unnumberedsec Pragma Propagate_Exceptions
5489 @cindex Interfacing to C++
5490 @findex Propagate_Exceptions
5494 @smallexample @c ada
5495 pragma Propagate_Exceptions;
5499 This pragma is now obsolete and, other than generating a warning if warnings
5500 on obsolescent features are enabled, is ignored.
5501 It is retained for compatibility
5502 purposes. It used to be used in connection with optimization of
5503 a now-obsolete mechanism for implementation of exceptions.
5505 @node Pragma Psect_Object
5506 @unnumberedsec Pragma Psect_Object
5507 @findex Psect_Object
5511 @smallexample @c ada
5512 pragma Psect_Object (
5513 [Internal =>] LOCAL_NAME,
5514 [, [External =>] EXTERNAL_SYMBOL]
5515 [, [Size =>] EXTERNAL_SYMBOL]);
5519 | static_string_EXPRESSION
5523 This pragma is identical in effect to pragma @code{Common_Object}.
5525 @node Pragma Pure_05
5526 @unnumberedsec Pragma Pure_05
5531 @smallexample @c ada
5532 pragma Pure_05 [(library_unit_NAME)];
5536 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5537 and is intended for use in the standard run-time library only. It has
5538 no effect in Ada 83 or Ada 95 mode, but is
5539 equivalent to @code{pragma Pure} when operating in later
5540 Ada versions. This is used to handle some cases where packages
5541 not previously pure became so in Ada 2005.
5543 @node Pragma Pure_12
5544 @unnumberedsec Pragma Pure_12
5549 @smallexample @c ada
5550 pragma Pure_12 [(library_unit_NAME)];
5554 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5555 and is intended for use in the standard run-time library only. It has
5556 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5557 equivalent to @code{pragma Pure} when operating in later
5558 Ada versions. This is used to handle some cases where packages
5559 not previously pure became so in Ada 2012.
5561 @node Pragma Pure_Function
5562 @unnumberedsec Pragma Pure_Function
5563 @findex Pure_Function
5567 @smallexample @c ada
5568 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5572 This pragma appears in the same declarative part as a function
5573 declaration (or a set of function declarations if more than one
5574 overloaded declaration exists, in which case the pragma applies
5575 to all entities). It specifies that the function @code{Entity} is
5576 to be considered pure for the purposes of code generation. This means
5577 that the compiler can assume that there are no side effects, and
5578 in particular that two calls with identical arguments produce the
5579 same result. It also means that the function can be used in an
5582 Note that, quite deliberately, there are no static checks to try
5583 to ensure that this promise is met, so @code{Pure_Function} can be used
5584 with functions that are conceptually pure, even if they do modify
5585 global variables. For example, a square root function that is
5586 instrumented to count the number of times it is called is still
5587 conceptually pure, and can still be optimized, even though it
5588 modifies a global variable (the count). Memo functions are another
5589 example (where a table of previous calls is kept and consulted to
5590 avoid re-computation).
5592 Note also that the normal rules excluding optimization of subprograms
5593 in pure units (when parameter types are descended from System.Address,
5594 or when the full view of a parameter type is limited), do not apply
5595 for the Pure_Function case. If you explicitly specify Pure_Function,
5596 the compiler may optimize away calls with identical arguments, and
5597 if that results in unexpected behavior, the proper action is not to
5598 use the pragma for subprograms that are not (conceptually) pure.
5601 Note: Most functions in a @code{Pure} package are automatically pure, and
5602 there is no need to use pragma @code{Pure_Function} for such functions. One
5603 exception is any function that has at least one formal of type
5604 @code{System.Address} or a type derived from it. Such functions are not
5605 considered pure by default, since the compiler assumes that the
5606 @code{Address} parameter may be functioning as a pointer and that the
5607 referenced data may change even if the address value does not.
5608 Similarly, imported functions are not considered to be pure by default,
5609 since there is no way of checking that they are in fact pure. The use
5610 of pragma @code{Pure_Function} for such a function will override these default
5611 assumption, and cause the compiler to treat a designated subprogram as pure
5614 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5615 applies to the underlying renamed function. This can be used to
5616 disambiguate cases of overloading where some but not all functions
5617 in a set of overloaded functions are to be designated as pure.
5619 If pragma @code{Pure_Function} is applied to a library level function, the
5620 function is also considered pure from an optimization point of view, but the
5621 unit is not a Pure unit in the categorization sense. So for example, a function
5622 thus marked is free to @code{with} non-pure units.
5624 @node Pragma Ravenscar
5625 @unnumberedsec Pragma Ravenscar
5626 @findex Pragma Ravenscar
5630 @smallexample @c ada
5635 This pragma is considered obsolescent, but is retained for
5636 compatibility purposes. It is equivalent to:
5638 @smallexample @c ada
5639 pragma Profile (Ravenscar);
5643 which is the preferred method of setting the @code{Ravenscar} profile.
5645 @node Pragma Relative_Deadline
5646 @unnumberedsec Pragma Relative_Deadline
5647 @findex Relative_Deadline
5651 @smallexample @c ada
5652 pragma Relative_Deadline (time_span_EXPRESSSION);
5656 This pragma is standard in Ada 2005, but is available in all earlier
5657 versions of Ada as an implementation-defined pragma.
5658 See Ada 2012 Reference Manual for details.
5660 @node Pragma Remote_Access_Type
5661 @unnumberedsec Pragma Remote_Access_Type
5662 @findex Remote_Access_Type
5666 @smallexample @c ada
5667 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5671 This pragma appears in the formal part of a generic declaration.
5672 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5673 the use of a remote access to class-wide type as actual for a formal
5676 When this pragma applies to a formal access type @code{Entity}, that
5677 type is treated as a remote access to class-wide type in the generic.
5678 It must be a formal general access type, and its designated type must
5679 be the class-wide type of a formal tagged limited private type from the
5680 same generic declaration.
5682 In the generic unit, the formal type is subject to all restrictions
5683 pertaining to remote access to class-wide types. At instantiation, the
5684 actual type must be a remote access to class-wide type.
5686 @node Pragma Restricted_Run_Time
5687 @unnumberedsec Pragma Restricted_Run_Time
5688 @findex Pragma Restricted_Run_Time
5692 @smallexample @c ada
5693 pragma Restricted_Run_Time;
5697 This pragma is considered obsolescent, but is retained for
5698 compatibility purposes. It is equivalent to:
5700 @smallexample @c ada
5701 pragma Profile (Restricted);
5705 which is the preferred method of setting the restricted run time
5708 @node Pragma Restriction_Warnings
5709 @unnumberedsec Pragma Restriction_Warnings
5710 @findex Restriction_Warnings
5714 @smallexample @c ada
5715 pragma Restriction_Warnings
5716 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5720 This pragma allows a series of restriction identifiers to be
5721 specified (the list of allowed identifiers is the same as for
5722 pragma @code{Restrictions}). For each of these identifiers
5723 the compiler checks for violations of the restriction, but
5724 generates a warning message rather than an error message
5725 if the restriction is violated.
5727 @node Pragma Share_Generic
5728 @unnumberedsec Pragma Share_Generic
5729 @findex Share_Generic
5733 @smallexample @c ada
5734 pragma Share_Generic (GNAME @{, GNAME@});
5736 GNAME ::= generic_unit_NAME | generic_instance_NAME
5740 This pragma is provided for compatibility with Dec Ada 83. It has
5741 no effect in @code{GNAT} (which does not implement shared generics), other
5742 than to check that the given names are all names of generic units or
5746 @unnumberedsec Pragma Shared
5750 This pragma is provided for compatibility with Ada 83. The syntax and
5751 semantics are identical to pragma Atomic.
5753 @node Pragma Short_Circuit_And_Or
5754 @unnumberedsec Pragma Short_Circuit_And_Or
5755 @findex Short_Circuit_And_Or
5759 @smallexample @c ada
5760 pragma Short_Circuit_And_Or;
5764 This configuration pragma causes any occurrence of the AND operator applied to
5765 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5766 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5767 may be useful in the context of certification protocols requiring the use of
5768 short-circuited logical operators. If this configuration pragma occurs locally
5769 within the file being compiled, it applies only to the file being compiled.
5770 There is no requirement that all units in a partition use this option.
5772 @node Pragma Short_Descriptors
5773 @unnumberedsec Pragma Short_Descriptors
5774 @findex Short_Descriptors
5778 @smallexample @c ada
5779 pragma Short_Descriptors
5783 In VMS versions of the compiler, this configuration pragma causes all
5784 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5785 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5786 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5789 @node Pragma Simple_Storage_Pool_Type
5790 @unnumberedsec Pragma Simple_Storage_Pool_Type
5791 @findex Simple_Storage_Pool_Type
5792 @cindex Storage pool, simple
5793 @cindex Simple storage pool
5797 @smallexample @c ada
5798 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5802 A type can be established as a ``simple storage pool type'' by applying
5803 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5804 A type named in the pragma must be a library-level immutably limited record
5805 type or limited tagged type declared immediately within a package declaration.
5806 The type can also be a limited private type whose full type is allowed as
5807 a simple storage pool type.
5809 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5810 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5811 are subtype conformant with the following subprogram declarations:
5813 @smallexample @c ada
5816 Storage_Address : out System.Address;
5817 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5818 Alignment : System.Storage_Elements.Storage_Count);
5820 procedure Deallocate
5822 Storage_Address : System.Address;
5823 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5824 Alignment : System.Storage_Elements.Storage_Count);
5826 function Storage_Size (Pool : SSP)
5827 return System.Storage_Elements.Storage_Count;
5831 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5832 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5833 applying an unchecked deallocation has no effect other than to set its actual
5834 parameter to null. If @code{Storage_Size} is not declared, then the
5835 @code{Storage_Size} attribute applied to an access type associated with
5836 a pool object of type SSP returns zero. Additional operations can be declared
5837 for a simple storage pool type (such as for supporting a mark/release
5838 storage-management discipline).
5840 An object of a simple storage pool type can be associated with an access
5841 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5843 @smallexample @c ada
5845 My_Pool : My_Simple_Storage_Pool_Type;
5847 type Acc is access My_Data_Type;
5849 for Acc'Simple_Storage_Pool use My_Pool;
5854 See attribute @code{Simple_Storage_Pool} for further details.
5856 @node Pragma Source_File_Name
5857 @unnumberedsec Pragma Source_File_Name
5858 @findex Source_File_Name
5862 @smallexample @c ada
5863 pragma Source_File_Name (
5864 [Unit_Name =>] unit_NAME,
5865 Spec_File_Name => STRING_LITERAL,
5866 [Index => INTEGER_LITERAL]);
5868 pragma Source_File_Name (
5869 [Unit_Name =>] unit_NAME,
5870 Body_File_Name => STRING_LITERAL,
5871 [Index => INTEGER_LITERAL]);
5875 Use this to override the normal naming convention. It is a configuration
5876 pragma, and so has the usual applicability of configuration pragmas
5877 (i.e.@: it applies to either an entire partition, or to all units in a
5878 compilation, or to a single unit, depending on how it is used.
5879 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5880 the second argument is required, and indicates whether this is the file
5881 name for the spec or for the body.
5883 The optional Index argument should be used when a file contains multiple
5884 units, and when you do not want to use @code{gnatchop} to separate then
5885 into multiple files (which is the recommended procedure to limit the
5886 number of recompilations that are needed when some sources change).
5887 For instance, if the source file @file{source.ada} contains
5889 @smallexample @c ada
5901 you could use the following configuration pragmas:
5903 @smallexample @c ada
5904 pragma Source_File_Name
5905 (B, Spec_File_Name => "source.ada", Index => 1);
5906 pragma Source_File_Name
5907 (A, Body_File_Name => "source.ada", Index => 2);
5910 Note that the @code{gnatname} utility can also be used to generate those
5911 configuration pragmas.
5913 Another form of the @code{Source_File_Name} pragma allows
5914 the specification of patterns defining alternative file naming schemes
5915 to apply to all files.
5917 @smallexample @c ada
5918 pragma Source_File_Name
5919 ( [Spec_File_Name =>] STRING_LITERAL
5920 [,[Casing =>] CASING_SPEC]
5921 [,[Dot_Replacement =>] STRING_LITERAL]);
5923 pragma Source_File_Name
5924 ( [Body_File_Name =>] STRING_LITERAL
5925 [,[Casing =>] CASING_SPEC]
5926 [,[Dot_Replacement =>] STRING_LITERAL]);
5928 pragma Source_File_Name
5929 ( [Subunit_File_Name =>] STRING_LITERAL
5930 [,[Casing =>] CASING_SPEC]
5931 [,[Dot_Replacement =>] STRING_LITERAL]);
5933 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5937 The first argument is a pattern that contains a single asterisk indicating
5938 the point at which the unit name is to be inserted in the pattern string
5939 to form the file name. The second argument is optional. If present it
5940 specifies the casing of the unit name in the resulting file name string.
5941 The default is lower case. Finally the third argument allows for systematic
5942 replacement of any dots in the unit name by the specified string literal.
5944 Note that Source_File_Name pragmas should not be used if you are using
5945 project files. The reason for this rule is that the project manager is not
5946 aware of these pragmas, and so other tools that use the projet file would not
5947 be aware of the intended naming conventions. If you are using project files,
5948 file naming is controlled by Source_File_Name_Project pragmas, which are
5949 usually supplied automatically by the project manager. A pragma
5950 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5952 For more details on the use of the @code{Source_File_Name} pragma,
5953 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5954 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5957 @node Pragma Source_File_Name_Project
5958 @unnumberedsec Pragma Source_File_Name_Project
5959 @findex Source_File_Name_Project
5962 This pragma has the same syntax and semantics as pragma Source_File_Name.
5963 It is only allowed as a stand alone configuration pragma.
5964 It cannot appear after a @ref{Pragma Source_File_Name}, and
5965 most importantly, once pragma Source_File_Name_Project appears,
5966 no further Source_File_Name pragmas are allowed.
5968 The intention is that Source_File_Name_Project pragmas are always
5969 generated by the Project Manager in a manner consistent with the naming
5970 specified in a project file, and when naming is controlled in this manner,
5971 it is not permissible to attempt to modify this naming scheme using
5972 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5973 known to the project manager).
5975 @node Pragma Source_Reference
5976 @unnumberedsec Pragma Source_Reference
5977 @findex Source_Reference
5981 @smallexample @c ada
5982 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5986 This pragma must appear as the first line of a source file.
5987 @var{integer_literal} is the logical line number of the line following
5988 the pragma line (for use in error messages and debugging
5989 information). @var{string_literal} is a static string constant that
5990 specifies the file name to be used in error messages and debugging
5991 information. This is most notably used for the output of @code{gnatchop}
5992 with the @option{-r} switch, to make sure that the original unchopped
5993 source file is the one referred to.
5995 The second argument must be a string literal, it cannot be a static
5996 string expression other than a string literal. This is because its value
5997 is needed for error messages issued by all phases of the compiler.
5999 @node Pragma Static_Elaboration_Desired
6000 @unnumberedsec Pragma Static_Elaboration_Desired
6001 @findex Static_Elaboration_Desired
6005 @smallexample @c ada
6006 pragma Static_Elaboration_Desired;
6010 This pragma is used to indicate that the compiler should attempt to initialize
6011 statically the objects declared in the library unit to which the pragma applies,
6012 when these objects are initialized (explicitly or implicitly) by an aggregate.
6013 In the absence of this pragma, aggregates in object declarations are expanded
6014 into assignments and loops, even when the aggregate components are static
6015 constants. When the aggregate is present the compiler builds a static expression
6016 that requires no run-time code, so that the initialized object can be placed in
6017 read-only data space. If the components are not static, or the aggregate has
6018 more that 100 components, the compiler emits a warning that the pragma cannot
6019 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6020 construction of larger aggregates with static components that include an others
6023 @node Pragma Stream_Convert
6024 @unnumberedsec Pragma Stream_Convert
6025 @findex Stream_Convert
6029 @smallexample @c ada
6030 pragma Stream_Convert (
6031 [Entity =>] type_LOCAL_NAME,
6032 [Read =>] function_NAME,
6033 [Write =>] function_NAME);
6037 This pragma provides an efficient way of providing stream functions for
6038 types defined in packages. Not only is it simpler to use than declaring
6039 the necessary functions with attribute representation clauses, but more
6040 significantly, it allows the declaration to made in such a way that the
6041 stream packages are not loaded unless they are needed. The use of
6042 the Stream_Convert pragma adds no overhead at all, unless the stream
6043 attributes are actually used on the designated type.
6045 The first argument specifies the type for which stream functions are
6046 provided. The second parameter provides a function used to read values
6047 of this type. It must name a function whose argument type may be any
6048 subtype, and whose returned type must be the type given as the first
6049 argument to the pragma.
6051 The meaning of the @var{Read}
6052 parameter is that if a stream attribute directly
6053 or indirectly specifies reading of the type given as the first parameter,
6054 then a value of the type given as the argument to the Read function is
6055 read from the stream, and then the Read function is used to convert this
6056 to the required target type.
6058 Similarly the @var{Write} parameter specifies how to treat write attributes
6059 that directly or indirectly apply to the type given as the first parameter.
6060 It must have an input parameter of the type specified by the first parameter,
6061 and the return type must be the same as the input type of the Read function.
6062 The effect is to first call the Write function to convert to the given stream
6063 type, and then write the result type to the stream.
6065 The Read and Write functions must not be overloaded subprograms. If necessary
6066 renamings can be supplied to meet this requirement.
6067 The usage of this attribute is best illustrated by a simple example, taken
6068 from the GNAT implementation of package Ada.Strings.Unbounded:
6070 @smallexample @c ada
6071 function To_Unbounded (S : String)
6072 return Unbounded_String
6073 renames To_Unbounded_String;
6075 pragma Stream_Convert
6076 (Unbounded_String, To_Unbounded, To_String);
6080 The specifications of the referenced functions, as given in the Ada
6081 Reference Manual are:
6083 @smallexample @c ada
6084 function To_Unbounded_String (Source : String)
6085 return Unbounded_String;
6087 function To_String (Source : Unbounded_String)
6092 The effect is that if the value of an unbounded string is written to a stream,
6093 then the representation of the item in the stream is in the same format that
6094 would be used for @code{Standard.String'Output}, and this same representation
6095 is expected when a value of this type is read from the stream. Note that the
6096 value written always includes the bounds, even for Unbounded_String'Write,
6097 since Unbounded_String is not an array type.
6099 @node Pragma Style_Checks
6100 @unnumberedsec Pragma Style_Checks
6101 @findex Style_Checks
6105 @smallexample @c ada
6106 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6107 On | Off [, LOCAL_NAME]);
6111 This pragma is used in conjunction with compiler switches to control the
6112 built in style checking provided by GNAT@. The compiler switches, if set,
6113 provide an initial setting for the switches, and this pragma may be used
6114 to modify these settings, or the settings may be provided entirely by
6115 the use of the pragma. This pragma can be used anywhere that a pragma
6116 is legal, including use as a configuration pragma (including use in
6117 the @file{gnat.adc} file).
6119 The form with a string literal specifies which style options are to be
6120 activated. These are additive, so they apply in addition to any previously
6121 set style check options. The codes for the options are the same as those
6122 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6123 For example the following two methods can be used to enable
6128 @smallexample @c ada
6129 pragma Style_Checks ("l");
6134 gcc -c -gnatyl @dots{}
6139 The form ALL_CHECKS activates all standard checks (its use is equivalent
6140 to the use of the @code{gnaty} switch with no options. @xref{Top,
6141 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6142 @value{EDITION} User's Guide}, for details.)
6144 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6145 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6146 options (i.e. equivalent to -gnatyg).
6148 The forms with @code{Off} and @code{On}
6149 can be used to temporarily disable style checks
6150 as shown in the following example:
6152 @smallexample @c ada
6156 pragma Style_Checks ("k"); -- requires keywords in lower case
6157 pragma Style_Checks (Off); -- turn off style checks
6158 NULL; -- this will not generate an error message
6159 pragma Style_Checks (On); -- turn style checks back on
6160 NULL; -- this will generate an error message
6164 Finally the two argument form is allowed only if the first argument is
6165 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6166 for the specified entity, as shown in the following example:
6168 @smallexample @c ada
6172 pragma Style_Checks ("r"); -- require consistency of identifier casing
6174 Rf1 : Integer := ARG; -- incorrect, wrong case
6175 pragma Style_Checks (Off, Arg);
6176 Rf2 : Integer := ARG; -- OK, no error
6179 @node Pragma Subtitle
6180 @unnumberedsec Pragma Subtitle
6185 @smallexample @c ada
6186 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6190 This pragma is recognized for compatibility with other Ada compilers
6191 but is ignored by GNAT@.
6193 @node Pragma Suppress
6194 @unnumberedsec Pragma Suppress
6199 @smallexample @c ada
6200 pragma Suppress (Identifier [, [On =>] Name]);
6204 This is a standard pragma, and supports all the check names required in
6205 the RM. It is included here because GNAT recognizes some additional check
6206 names that are implementation defined (as permitted by the RM):
6211 @code{Alignment_Check} can be used to suppress alignment checks
6212 on addresses used in address clauses. Such checks can also be suppressed
6213 by suppressing range checks, but the specific use of @code{Alignment_Check}
6214 allows suppression of alignment checks without suppressing other range checks.
6217 @code{Predicate_Check} can be used to control whether predicate checks are
6218 active. It is applicable only to predicates for which the policy is
6219 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6220 predicate is ignored or checked for the whole program, the use of
6221 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6222 predicate to be turned on and off at specific points in the program.
6225 @code{Validity_Check} can be used specifically to control validity checks.
6226 If @code{Suppress} is used to suppress validity checks, then no validity
6227 checks are performed, including those specified by the appropriate compiler
6228 switch or the @code{Validity_Checks} pragma.
6231 Additional check names previously introduced by use of the @code{Check_Name}
6232 pragma are also allowed.
6237 Note that pragma Suppress gives the compiler permission to omit
6238 checks, but does not require the compiler to omit checks. The compiler
6239 will generate checks if they are essentially free, even when they are
6240 suppressed. In particular, if the compiler can prove that a certain
6241 check will necessarily fail, it will generate code to do an
6242 unconditional ``raise'', even if checks are suppressed. The compiler
6245 Of course, run-time checks are omitted whenever the compiler can prove
6246 that they will not fail, whether or not checks are suppressed.
6248 @node Pragma Suppress_All
6249 @unnumberedsec Pragma Suppress_All
6250 @findex Suppress_All
6254 @smallexample @c ada
6255 pragma Suppress_All;
6259 This pragma can appear anywhere within a unit.
6260 The effect is to apply @code{Suppress (All_Checks)} to the unit
6261 in which it appears. This pragma is implemented for compatibility with DEC
6262 Ada 83 usage where it appears at the end of a unit, and for compatibility
6263 with Rational Ada, where it appears as a program unit pragma.
6264 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6265 as a normal configuration pragma is the preferred usage in GNAT@.
6267 @node Pragma Suppress_Debug_Info
6268 @unnumberedsec Pragma Suppress_Debug_Info
6269 @findex Suppress_Debug_Info
6273 @smallexample @c ada
6274 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6278 This pragma can be used to suppress generation of debug information
6279 for the specified entity. It is intended primarily for use in debugging
6280 the debugger, and navigating around debugger problems.
6282 @node Pragma Suppress_Exception_Locations
6283 @unnumberedsec Pragma Suppress_Exception_Locations
6284 @findex Suppress_Exception_Locations
6288 @smallexample @c ada
6289 pragma Suppress_Exception_Locations;
6293 In normal mode, a raise statement for an exception by default generates
6294 an exception message giving the file name and line number for the location
6295 of the raise. This is useful for debugging and logging purposes, but this
6296 entails extra space for the strings for the messages. The configuration
6297 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6298 generation of these strings, with the result that space is saved, but the
6299 exception message for such raises is null. This configuration pragma may
6300 appear in a global configuration pragma file, or in a specific unit as
6301 usual. It is not required that this pragma be used consistently within
6302 a partition, so it is fine to have some units within a partition compiled
6303 with this pragma and others compiled in normal mode without it.
6305 @node Pragma Suppress_Initialization
6306 @unnumberedsec Pragma Suppress_Initialization
6307 @findex Suppress_Initialization
6308 @cindex Suppressing initialization
6309 @cindex Initialization, suppression of
6313 @smallexample @c ada
6314 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6318 Here subtype_Name is the name introduced by a type declaration
6319 or subtype declaration.
6320 This pragma suppresses any implicit or explicit initialization
6321 for all variables of the given type or subtype,
6322 including initialization resulting from the use of pragmas
6323 Normalize_Scalars or Initialize_Scalars.
6325 This is considered a representation item, so it cannot be given after
6326 the type is frozen. It applies to all subsequent object declarations,
6327 and also any allocator that creates objects of the type.
6329 If the pragma is given for the first subtype, then it is considered
6330 to apply to the base type and all its subtypes. If the pragma is given
6331 for other than a first subtype, then it applies only to the given subtype.
6332 The pragma may not be given after the type is frozen.
6334 @node Pragma Task_Info
6335 @unnumberedsec Pragma Task_Info
6340 @smallexample @c ada
6341 pragma Task_Info (EXPRESSION);
6345 This pragma appears within a task definition (like pragma
6346 @code{Priority}) and applies to the task in which it appears. The
6347 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6348 The @code{Task_Info} pragma provides system dependent control over
6349 aspects of tasking implementation, for example, the ability to map
6350 tasks to specific processors. For details on the facilities available
6351 for the version of GNAT that you are using, see the documentation
6352 in the spec of package System.Task_Info in the runtime
6355 @node Pragma Task_Name
6356 @unnumberedsec Pragma Task_Name
6361 @smallexample @c ada
6362 pragma Task_Name (string_EXPRESSION);
6366 This pragma appears within a task definition (like pragma
6367 @code{Priority}) and applies to the task in which it appears. The
6368 argument must be of type String, and provides a name to be used for
6369 the task instance when the task is created. Note that this expression
6370 is not required to be static, and in particular, it can contain
6371 references to task discriminants. This facility can be used to
6372 provide different names for different tasks as they are created,
6373 as illustrated in the example below.
6375 The task name is recorded internally in the run-time structures
6376 and is accessible to tools like the debugger. In addition the
6377 routine @code{Ada.Task_Identification.Image} will return this
6378 string, with a unique task address appended.
6380 @smallexample @c ada
6381 -- Example of the use of pragma Task_Name
6383 with Ada.Task_Identification;
6384 use Ada.Task_Identification;
6385 with Text_IO; use Text_IO;
6388 type Astring is access String;
6390 task type Task_Typ (Name : access String) is
6391 pragma Task_Name (Name.all);
6394 task body Task_Typ is
6395 Nam : constant String := Image (Current_Task);
6397 Put_Line ("-->" & Nam (1 .. 14) & "<--");
6400 type Ptr_Task is access Task_Typ;
6401 Task_Var : Ptr_Task;
6405 new Task_Typ (new String'("This is task 1"));
6407 new Task_Typ (new String'("This is task 2"));
6411 @node Pragma Task_Storage
6412 @unnumberedsec Pragma Task_Storage
6413 @findex Task_Storage
6416 @smallexample @c ada
6417 pragma Task_Storage (
6418 [Task_Type =>] LOCAL_NAME,
6419 [Top_Guard =>] static_integer_EXPRESSION);
6423 This pragma specifies the length of the guard area for tasks. The guard
6424 area is an additional storage area allocated to a task. A value of zero
6425 means that either no guard area is created or a minimal guard area is
6426 created, depending on the target. This pragma can appear anywhere a
6427 @code{Storage_Size} attribute definition clause is allowed for a task
6430 @node Pragma Test_Case
6431 @unnumberedsec Pragma Test_Case
6437 @smallexample @c ada
6439 [Name =>] static_string_Expression
6440 ,[Mode =>] (Nominal | Robustness)
6441 [, Requires => Boolean_Expression]
6442 [, Ensures => Boolean_Expression]);
6446 The @code{Test_Case} pragma allows defining fine-grain specifications
6447 for use by testing tools.
6448 The compiler checks the validity of the @code{Test_Case} pragma, but its
6449 presence does not lead to any modification of the code generated by the
6452 @code{Test_Case} pragmas may only appear immediately following the
6453 (separate) declaration of a subprogram in a package declaration, inside
6454 a package spec unit. Only other pragmas may intervene (that is appear
6455 between the subprogram declaration and a test case).
6457 The compiler checks that boolean expressions given in @code{Requires} and
6458 @code{Ensures} are valid, where the rules for @code{Requires} are the
6459 same as the rule for an expression in @code{Precondition} and the rules
6460 for @code{Ensures} are the same as the rule for an expression in
6461 @code{Postcondition}. In particular, attributes @code{'Old} and
6462 @code{'Result} can only be used within the @code{Ensures}
6463 expression. The following is an example of use within a package spec:
6465 @smallexample @c ada
6466 package Math_Functions is
6468 function Sqrt (Arg : Float) return Float;
6469 pragma Test_Case (Name => "Test 1",
6471 Requires => Arg < 10000,
6472 Ensures => Sqrt'Result < 10);
6478 The meaning of a test case is that there is at least one context where
6479 @code{Requires} holds such that, if the associated subprogram is executed in
6480 that context, then @code{Ensures} holds when the subprogram returns.
6481 Mode @code{Nominal} indicates that the input context should also satisfy the
6482 precondition of the subprogram, and the output context should also satisfy its
6483 postcondition. More @code{Robustness} indicates that the precondition and
6484 postcondition of the subprogram should be ignored for this test case.
6486 @node Pragma Thread_Local_Storage
6487 @unnumberedsec Pragma Thread_Local_Storage
6488 @findex Thread_Local_Storage
6489 @cindex Task specific storage
6490 @cindex TLS (Thread Local Storage)
6491 @cindex Task_Attributes
6494 @smallexample @c ada
6495 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6499 This pragma specifies that the specified entity, which must be
6500 a variable declared in a library level package, is to be marked as
6501 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6502 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6503 (and hence each Ada task) to see a distinct copy of the variable.
6505 The variable may not have default initialization, and if there is
6506 an explicit initialization, it must be either @code{null} for an
6507 access variable, or a static expression for a scalar variable.
6508 This provides a low level mechanism similar to that provided by
6509 the @code{Ada.Task_Attributes} package, but much more efficient
6510 and is also useful in writing interface code that will interact
6511 with foreign threads.
6513 If this pragma is used on a system where @code{TLS} is not supported,
6514 then an error message will be generated and the program will be rejected.
6516 @node Pragma Time_Slice
6517 @unnumberedsec Pragma Time_Slice
6522 @smallexample @c ada
6523 pragma Time_Slice (static_duration_EXPRESSION);
6527 For implementations of GNAT on operating systems where it is possible
6528 to supply a time slice value, this pragma may be used for this purpose.
6529 It is ignored if it is used in a system that does not allow this control,
6530 or if it appears in other than the main program unit.
6532 Note that the effect of this pragma is identical to the effect of the
6533 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6536 @unnumberedsec Pragma Title
6541 @smallexample @c ada
6542 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6545 [Title =>] STRING_LITERAL,
6546 | [Subtitle =>] STRING_LITERAL
6550 Syntax checked but otherwise ignored by GNAT@. This is a listing control
6551 pragma used in DEC Ada 83 implementations to provide a title and/or
6552 subtitle for the program listing. The program listing generated by GNAT
6553 does not have titles or subtitles.
6555 Unlike other pragmas, the full flexibility of named notation is allowed
6556 for this pragma, i.e.@: the parameters may be given in any order if named
6557 notation is used, and named and positional notation can be mixed
6558 following the normal rules for procedure calls in Ada.
6560 @node Pragma Unchecked_Union
6561 @unnumberedsec Pragma Unchecked_Union
6563 @findex Unchecked_Union
6567 @smallexample @c ada
6568 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6572 This pragma is used to specify a representation of a record type that is
6573 equivalent to a C union. It was introduced as a GNAT implementation defined
6574 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6575 pragma, making it language defined, and GNAT fully implements this extended
6576 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6577 details, consult the Ada 2012 Reference Manual, section B.3.3.
6579 @node Pragma Unimplemented_Unit
6580 @unnumberedsec Pragma Unimplemented_Unit
6581 @findex Unimplemented_Unit
6585 @smallexample @c ada
6586 pragma Unimplemented_Unit;
6590 If this pragma occurs in a unit that is processed by the compiler, GNAT
6591 aborts with the message @samp{@var{xxx} not implemented}, where
6592 @var{xxx} is the name of the current compilation unit. This pragma is
6593 intended to allow the compiler to handle unimplemented library units in
6596 The abort only happens if code is being generated. Thus you can use
6597 specs of unimplemented packages in syntax or semantic checking mode.
6599 @node Pragma Universal_Aliasing
6600 @unnumberedsec Pragma Universal_Aliasing
6601 @findex Universal_Aliasing
6605 @smallexample @c ada
6606 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6610 @var{type_LOCAL_NAME} must refer to a type declaration in the current
6611 declarative part. The effect is to inhibit strict type-based aliasing
6612 optimization for the given type. In other words, the effect is as though
6613 access types designating this type were subject to pragma No_Strict_Aliasing.
6614 For a detailed description of the strict aliasing optimization, and the
6615 situations in which it must be suppressed, @xref{Optimization and Strict
6616 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
6618 @node Pragma Universal_Data
6619 @unnumberedsec Pragma Universal_Data
6620 @findex Universal_Data
6624 @smallexample @c ada
6625 pragma Universal_Data [(library_unit_Name)];
6629 This pragma is supported only for the AAMP target and is ignored for
6630 other targets. The pragma specifies that all library-level objects
6631 (Counter 0 data) associated with the library unit are to be accessed
6632 and updated using universal addressing (24-bit addresses for AAMP5)
6633 rather than the default of 16-bit Data Environment (DENV) addressing.
6634 Use of this pragma will generally result in less efficient code for
6635 references to global data associated with the library unit, but
6636 allows such data to be located anywhere in memory. This pragma is
6637 a library unit pragma, but can also be used as a configuration pragma
6638 (including use in the @file{gnat.adc} file). The functionality
6639 of this pragma is also available by applying the -univ switch on the
6640 compilations of units where universal addressing of the data is desired.
6642 @node Pragma Unmodified
6643 @unnumberedsec Pragma Unmodified
6645 @cindex Warnings, unmodified
6649 @smallexample @c ada
6650 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6654 This pragma signals that the assignable entities (variables,
6655 @code{out} parameters, @code{in out} parameters) whose names are listed are
6656 deliberately not assigned in the current source unit. This
6657 suppresses warnings about the
6658 entities being referenced but not assigned, and in addition a warning will be
6659 generated if one of these entities is in fact assigned in the
6660 same unit as the pragma (or in the corresponding body, or one
6663 This is particularly useful for clearly signaling that a particular
6664 parameter is not modified, even though the spec suggests that it might
6667 @node Pragma Unreferenced
6668 @unnumberedsec Pragma Unreferenced
6669 @findex Unreferenced
6670 @cindex Warnings, unreferenced
6674 @smallexample @c ada
6675 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6676 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6680 This pragma signals that the entities whose names are listed are
6681 deliberately not referenced in the current source unit. This
6682 suppresses warnings about the
6683 entities being unreferenced, and in addition a warning will be
6684 generated if one of these entities is in fact subsequently referenced in the
6685 same unit as the pragma (or in the corresponding body, or one
6688 This is particularly useful for clearly signaling that a particular
6689 parameter is not referenced in some particular subprogram implementation
6690 and that this is deliberate. It can also be useful in the case of
6691 objects declared only for their initialization or finalization side
6694 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6695 current scope, then the entity most recently declared is the one to which
6696 the pragma applies. Note that in the case of accept formals, the pragma
6697 Unreferenced may appear immediately after the keyword @code{do} which
6698 allows the indication of whether or not accept formals are referenced
6699 or not to be given individually for each accept statement.
6701 The left hand side of an assignment does not count as a reference for the
6702 purpose of this pragma. Thus it is fine to assign to an entity for which
6703 pragma Unreferenced is given.
6705 Note that if a warning is desired for all calls to a given subprogram,
6706 regardless of whether they occur in the same unit as the subprogram
6707 declaration, then this pragma should not be used (calls from another
6708 unit would not be flagged); pragma Obsolescent can be used instead
6709 for this purpose, see @xref{Pragma Obsolescent}.
6711 The second form of pragma @code{Unreferenced} is used within a context
6712 clause. In this case the arguments must be unit names of units previously
6713 mentioned in @code{with} clauses (similar to the usage of pragma
6714 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6715 units and unreferenced entities within these units.
6717 @node Pragma Unreferenced_Objects
6718 @unnumberedsec Pragma Unreferenced_Objects
6719 @findex Unreferenced_Objects
6720 @cindex Warnings, unreferenced
6724 @smallexample @c ada
6725 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6729 This pragma signals that for the types or subtypes whose names are
6730 listed, objects which are declared with one of these types or subtypes may
6731 not be referenced, and if no references appear, no warnings are given.
6733 This is particularly useful for objects which are declared solely for their
6734 initialization and finalization effect. Such variables are sometimes referred
6735 to as RAII variables (Resource Acquisition Is Initialization). Using this
6736 pragma on the relevant type (most typically a limited controlled type), the
6737 compiler will automatically suppress unwanted warnings about these variables
6738 not being referenced.
6740 @node Pragma Unreserve_All_Interrupts
6741 @unnumberedsec Pragma Unreserve_All_Interrupts
6742 @findex Unreserve_All_Interrupts
6746 @smallexample @c ada
6747 pragma Unreserve_All_Interrupts;
6751 Normally certain interrupts are reserved to the implementation. Any attempt
6752 to attach an interrupt causes Program_Error to be raised, as described in
6753 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6754 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6755 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6756 interrupt execution.
6758 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6759 a program, then all such interrupts are unreserved. This allows the
6760 program to handle these interrupts, but disables their standard
6761 functions. For example, if this pragma is used, then pressing
6762 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6763 a program can then handle the @code{SIGINT} interrupt as it chooses.
6765 For a full list of the interrupts handled in a specific implementation,
6766 see the source code for the spec of @code{Ada.Interrupts.Names} in
6767 file @file{a-intnam.ads}. This is a target dependent file that contains the
6768 list of interrupts recognized for a given target. The documentation in
6769 this file also specifies what interrupts are affected by the use of
6770 the @code{Unreserve_All_Interrupts} pragma.
6772 For a more general facility for controlling what interrupts can be
6773 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6774 of the @code{Unreserve_All_Interrupts} pragma.
6776 @node Pragma Unsuppress
6777 @unnumberedsec Pragma Unsuppress
6782 @smallexample @c ada
6783 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6787 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6788 there is no corresponding pragma @code{Suppress} in effect, it has no
6789 effect. The range of the effect is the same as for pragma
6790 @code{Suppress}. The meaning of the arguments is identical to that used
6791 in pragma @code{Suppress}.
6793 One important application is to ensure that checks are on in cases where
6794 code depends on the checks for its correct functioning, so that the code
6795 will compile correctly even if the compiler switches are set to suppress
6798 This pragma is standard in Ada 2005. It is available in all earlier versions
6799 of Ada as an implementation-defined pragma.
6801 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6802 a number of implementation-defined check names. See description of pragma
6803 @code{Suppress} for full details.
6805 @node Pragma Use_VADS_Size
6806 @unnumberedsec Pragma Use_VADS_Size
6807 @cindex @code{Size}, VADS compatibility
6808 @cindex Rational profile
6809 @findex Use_VADS_Size
6813 @smallexample @c ada
6814 pragma Use_VADS_Size;
6818 This is a configuration pragma. In a unit to which it applies, any use
6819 of the 'Size attribute is automatically interpreted as a use of the
6820 'VADS_Size attribute. Note that this may result in incorrect semantic
6821 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6822 the handling of existing code which depends on the interpretation of Size
6823 as implemented in the VADS compiler. See description of the VADS_Size
6824 attribute for further details.
6826 @node Pragma Validity_Checks
6827 @unnumberedsec Pragma Validity_Checks
6828 @findex Validity_Checks
6832 @smallexample @c ada
6833 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6837 This pragma is used in conjunction with compiler switches to control the
6838 built-in validity checking provided by GNAT@. The compiler switches, if set
6839 provide an initial setting for the switches, and this pragma may be used
6840 to modify these settings, or the settings may be provided entirely by
6841 the use of the pragma. This pragma can be used anywhere that a pragma
6842 is legal, including use as a configuration pragma (including use in
6843 the @file{gnat.adc} file).
6845 The form with a string literal specifies which validity options are to be
6846 activated. The validity checks are first set to include only the default
6847 reference manual settings, and then a string of letters in the string
6848 specifies the exact set of options required. The form of this string
6849 is exactly as described for the @option{-gnatVx} compiler switch (see the
6850 @value{EDITION} User's Guide for details). For example the following two
6851 methods can be used to enable validity checking for mode @code{in} and
6852 @code{in out} subprogram parameters:
6856 @smallexample @c ada
6857 pragma Validity_Checks ("im");
6862 gcc -c -gnatVim @dots{}
6867 The form ALL_CHECKS activates all standard checks (its use is equivalent
6868 to the use of the @code{gnatva} switch.
6870 The forms with @code{Off} and @code{On}
6871 can be used to temporarily disable validity checks
6872 as shown in the following example:
6874 @smallexample @c ada
6878 pragma Validity_Checks ("c"); -- validity checks for copies
6879 pragma Validity_Checks (Off); -- turn off validity checks
6880 A := B; -- B will not be validity checked
6881 pragma Validity_Checks (On); -- turn validity checks back on
6882 A := C; -- C will be validity checked
6885 @node Pragma Volatile
6886 @unnumberedsec Pragma Volatile
6891 @smallexample @c ada
6892 pragma Volatile (LOCAL_NAME);
6896 This pragma is defined by the Ada Reference Manual, and the GNAT
6897 implementation is fully conformant with this definition. The reason it
6898 is mentioned in this section is that a pragma of the same name was supplied
6899 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6900 implementation of pragma Volatile is upwards compatible with the
6901 implementation in DEC Ada 83.
6903 @node Pragma Warnings
6904 @unnumberedsec Pragma Warnings
6909 @smallexample @c ada
6910 pragma Warnings (On | Off [,REASON]);
6911 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
6912 pragma Warnings (static_string_EXPRESSION [,REASON]);
6913 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
6915 REASON ::= Reason => static_string_EXPRESSION
6919 Normally warnings are enabled, with the output being controlled by
6920 the command line switch. Warnings (@code{Off}) turns off generation of
6921 warnings until a Warnings (@code{On}) is encountered or the end of the
6922 current unit. If generation of warnings is turned off using this
6923 pragma, then some or all of the warning messages are suppressed,
6924 regardless of the setting of the command line switches.
6926 The @code{Reason} parameter may optionally appear as the last argument
6927 in any of the forms of this pragma. It is intended purely for the
6928 purposes of documenting the reason for the @code{Warnings} pragma.
6929 The compiler will check that the argument is a static string but
6930 otherwise ignore this argument. Other tools may provide specialized
6931 processing for this string.
6933 The form with a single argument (or two arguments if Reason present),
6934 where the first argument is @code{ON} or @code{OFF}
6935 may be used as a configuration pragma.
6937 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6938 the specified entity. This suppression is effective from the point where
6939 it occurs till the end of the extended scope of the variable (similar to
6940 the scope of @code{Suppress}). This form cannot be used as a configuration
6943 The form with a single static_string_EXPRESSION argument (and possible
6944 reason) provides more precise
6945 control over which warnings are active. The string is a list of letters
6946 specifying which warnings are to be activated and which deactivated. The
6947 code for these letters is the same as the string used in the command
6948 line switch controlling warnings. For a brief summary, use the gnatmake
6949 command with no arguments, which will generate usage information containing
6950 the list of warnings switches supported. For
6951 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6952 User's Guide}. This form can also be used as a configuration pragma.
6955 The warnings controlled by the `-gnatw' switch are generated by the front end
6956 of the compiler. The `GCC' back end can provide additional warnings and they
6957 are controlled by the `-W' switch.
6958 The form with a single static_string_EXPRESSION argument also works for the
6959 latters, but the string must be a single full `-W' switch in this case.
6960 The above reference lists a few examples of these additional warnings.
6963 The specified warnings will be in effect until the end of the program
6964 or another pragma Warnings is encountered. The effect of the pragma is
6965 cumulative. Initially the set of warnings is the standard default set
6966 as possibly modified by compiler switches. Then each pragma Warning
6967 modifies this set of warnings as specified. This form of the pragma may
6968 also be used as a configuration pragma.
6970 The fourth form, with an @code{On|Off} parameter and a string, is used to
6971 control individual messages, based on their text. The string argument
6972 is a pattern that is used to match against the text of individual
6973 warning messages (not including the initial "warning: " tag).
6975 The pattern may contain asterisks, which match zero or more characters in
6976 the message. For example, you can use
6977 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6978 message @code{warning: 960 bits of "a" unused}. No other regular
6979 expression notations are permitted. All characters other than asterisk in
6980 these three specific cases are treated as literal characters in the match.
6982 The above use of patterns to match the message applies only to warning
6983 messages generated by the front end. This form of the pragma with a
6984 string argument can also be used to control back end warnings controlled
6985 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6986 of a string of the form "[-Wxxx]" in the message which identifies the
6987 "-W" switch that controls the message. By using the text of the
6988 "-W" switch in the pragma, such back end warnings can be turned on and off.
6990 There are two ways to use the pragma in this form. The OFF form can be used as a
6991 configuration pragma. The effect is to suppress all warnings (if any)
6992 that match the pattern string throughout the compilation (or match the
6993 -W switch in the back end case).
6995 The second usage is to suppress a warning locally, and in this case, two
6996 pragmas must appear in sequence:
6998 @smallexample @c ada
6999 pragma Warnings (Off, Pattern);
7000 @dots{} code where given warning is to be suppressed
7001 pragma Warnings (On, Pattern);
7005 In this usage, the pattern string must match in the Off and On pragmas,
7006 and at least one matching warning must be suppressed.
7008 Note: to write a string that will match any warning, use the string
7009 @code{"***"}. It will not work to use a single asterisk or two asterisks
7010 since this looks like an operator name. This form with three asterisks
7011 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7012 matching @code{pragma Warnings (On, "***")} will be required. This can be
7013 helpful in avoiding forgetting to turn warnings back on.
7015 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7016 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7017 be useful in checking whether obsolete pragmas in existing programs are hiding
7020 Note: pragma Warnings does not affect the processing of style messages. See
7021 separate entry for pragma Style_Checks for control of style messages.
7023 @node Pragma Weak_External
7024 @unnumberedsec Pragma Weak_External
7025 @findex Weak_External
7029 @smallexample @c ada
7030 pragma Weak_External ([Entity =>] LOCAL_NAME);
7034 @var{LOCAL_NAME} must refer to an object that is declared at the library
7035 level. This pragma specifies that the given entity should be marked as a
7036 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7037 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7038 of a regular symbol, that is to say a symbol that does not have to be
7039 resolved by the linker if used in conjunction with a pragma Import.
7041 When a weak symbol is not resolved by the linker, its address is set to
7042 zero. This is useful in writing interfaces to external modules that may
7043 or may not be linked in the final executable, for example depending on
7044 configuration settings.
7046 If a program references at run time an entity to which this pragma has been
7047 applied, and the corresponding symbol was not resolved at link time, then
7048 the execution of the program is erroneous. It is not erroneous to take the
7049 Address of such an entity, for example to guard potential references,
7050 as shown in the example below.
7052 Some file formats do not support weak symbols so not all target machines
7053 support this pragma.
7055 @smallexample @c ada
7056 -- Example of the use of pragma Weak_External
7058 package External_Module is
7060 pragma Import (C, key);
7061 pragma Weak_External (key);
7062 function Present return boolean;
7063 end External_Module;
7065 with System; use System;
7066 package body External_Module is
7067 function Present return boolean is
7069 return key'Address /= System.Null_Address;
7071 end External_Module;
7074 @node Pragma Wide_Character_Encoding
7075 @unnumberedsec Pragma Wide_Character_Encoding
7076 @findex Wide_Character_Encoding
7080 @smallexample @c ada
7081 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7085 This pragma specifies the wide character encoding to be used in program
7086 source text appearing subsequently. It is a configuration pragma, but may
7087 also be used at any point that a pragma is allowed, and it is permissible
7088 to have more than one such pragma in a file, allowing multiple encodings
7089 to appear within the same file.
7091 The argument can be an identifier or a character literal. In the identifier
7092 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7093 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7094 case it is correspondingly one of the characters @samp{h}, @samp{u},
7095 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7097 Note that when the pragma is used within a file, it affects only the
7098 encoding within that file, and does not affect withed units, specs,
7101 @node Implementation Defined Aspects
7102 @chapter Implementation Defined Aspects
7103 Ada defines (throughout the Ada 2012 reference manual, summarized
7104 in annex K) a set of aspects that can be specified for certain entities.
7105 These language defined aspects are implemented in GNAT in Ada 2012 mode
7106 and work as described in the Ada 2012 Reference Manual.
7108 In addition, Ada 2012 allows implementations to define additional aspects
7109 whose meaning is defined by the implementation. GNAT provides
7110 a number of these implementation-dependent aspects which can be used
7111 to extend and enhance the functionality of the compiler. This section of
7112 the GNAT reference manual describes these additional attributes.
7114 Note that any program using these aspects may not be portable to
7115 other compilers (although GNAT implements this set of aspects on all
7116 platforms). Therefore if portability to other compilers is an important
7117 consideration, you should minimize the use of these aspects.
7119 Note that for many of these aspects, the effect is essentially similar
7120 to the use of a pragma or attribute specification with the same name
7121 applied to the entity. For example, if we write:
7123 @smallexample @c ada
7124 type R is range 1 .. 100
7125 with Value_Size => 10;
7129 then the effect is the same as:
7131 @smallexample @c ada
7132 type R is range 1 .. 100;
7133 for R'Value_Size use 10;
7139 @smallexample @c ada
7140 type R is new Integer
7141 with Shared => True;
7145 then the effect is the same as:
7147 @smallexample @c ada
7148 type R is new Integer;
7153 In the documentation sections that follow, such cases are simply marked
7154 as being equivalent to the corresponding pragma or attribute definition
7158 * Aspect Abstract_State::
7161 * Aspect Compiler_Unit::
7162 * Aspect Contract_Cases::
7164 * Aspect Dimension::
7165 * Aspect Dimension_System::
7166 * Aspect Favor_Top_Level::
7168 * Aspect Inline_Always::
7169 * Aspect Invariant::
7170 * Aspect Lock_Free::
7171 * Aspect Object_Size::
7172 * Aspect Persistent_BSS::
7173 * Aspect Predicate::
7174 * Aspect Preelaborate_05::
7177 * Aspect Pure_Function::
7178 * Aspect Remote_Access_Type::
7179 * Aspect Scalar_Storage_Order::
7181 * Aspect Simple_Storage_Pool::
7182 * Aspect Simple_Storage_Pool_Type::
7183 * Aspect Suppress_Debug_Info::
7184 * Aspect Test_Case::
7185 * Aspect Universal_Aliasing::
7186 * Aspect Universal_Data::
7187 * Aspect Unmodified::
7188 * Aspect Unreferenced::
7189 * Aspect Unreferenced_Objects::
7190 * Aspect Value_Size::
7194 @node Aspect Abstract_State
7195 @unnumberedsec Aspect Abstract_State
7196 @findex Abstract_State
7198 This aspect is equivalent to pragma @code{Abstract_State}.
7200 @node Aspect Ada_2005
7201 @unnumberedsec Aspect Ada_2005
7204 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7206 @node Aspect Ada_2012
7207 @unnumberedsec Aspect Ada_2012
7210 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7212 @node Aspect Compiler_Unit
7213 @unnumberedsec Aspect Compiler_Unit
7214 @findex Compiler_Unit
7216 This aspect is equivalent to pragma @code{Compiler_Unit}.
7218 @node Aspect Contract_Cases
7219 @unnumberedsec Aspect Contract_Cases
7220 @findex Contract_Cases
7222 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7223 of clauses being enclosed in parentheses so that syntactically it is an
7226 @node Aspect Depends
7227 @unnumberedsec Aspect Depends
7230 This aspect is equivalent to pragma @code{Depends}.
7234 @node Aspect Dimension
7235 @unnumberedsec Aspect Dimension
7238 The @code{Dimension} aspect is used to specify the dimensions of a given
7239 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7240 used when doing formatted output of dimensioned quantities. The syntax is:
7242 @smallexample @c ada
7244 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7246 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7250 | others => RATIONAL
7251 | DISCRETE_CHOICE_LIST => RATIONAL
7253 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7257 This aspect can only be applied to a subtype whose parent type has
7258 a @code{Dimension_Systen} aspect. The aspect must specify values for
7259 all dimensions of the system. The rational values are the powers of the
7260 corresponding dimensions that are used by the compiler to verify that
7261 physical (numeric) computations are dimensionally consistent. For example,
7262 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7263 For further examples of the usage
7264 of this aspect, see package @code{System.Dim.Mks}.
7265 Note that when the dimensioned type is an integer type, then any
7266 dimension value must be an integer literal.
7268 @node Aspect Dimension_System
7269 @unnumberedsec Aspect Dimension_System
7270 @findex Dimension_System
7272 The @code{Dimension_System} aspect is used to define a system of
7273 dimensions that will be used in subsequent subtype declarations with
7274 @code{Dimension} aspects that reference this system. The syntax is:
7276 @smallexample @c ada
7277 with Dimension_System => (DIMENSION @{, DIMENSION@});
7279 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
7280 [Unit_Symbol =>] SYMBOL,
7281 [Dim_Symbol =>] SYMBOL)
7283 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7287 This aspect is applied to a type, which must be a numeric derived type
7288 (typically a floating-point type), that
7289 will represent values within the dimension system. Each @code{DIMENSION}
7290 corresponds to one particular dimension. A maximum of 7 dimensions may
7291 be specified. @code{Unit_Name} is the name of the dimension (for example
7292 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7293 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7294 the identification within the dimension system (typically this is a
7295 single letter, e.g. 'L' standing for length for unit name Meter). The
7296 Unit_Smbol is used in formatted output of dimensioned quantities. The
7297 Dim_Symbol is used in error messages when numeric operations have
7298 inconsistent dimensions.
7300 GNAT provides the standard definition of the International MKS system in
7301 the run-time package @code{System.Dim.Mks}. You can easily define
7302 similar packages for cgs units or British units, and define conversion factors
7303 between values in different systems. The MKS system is characterized by the
7306 @smallexample @c ada
7307 type Mks_Type is new Long_Long_Float
7309 Dimension_System => (
7310 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
7311 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
7312 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
7313 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
7314 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
7315 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
7316 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
7320 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7321 Guide for detailed examples of use of the dimension system.
7323 @node Aspect Favor_Top_Level
7324 @unnumberedsec Aspect Favor_Top_Level
7325 @findex Favor_Top_Level
7327 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7330 @unnumberedsec Aspect Global
7333 This aspect is equivalent pragma @code{Global}.
7335 @node Aspect Inline_Always
7336 @unnumberedsec Aspect Inline_Always
7337 @findex Inline_Always
7339 This aspect is equivalent to pragma @code{Inline_Always}.
7341 @node Aspect Invariant
7342 @unnumberedsec Aspect Invariant
7345 This aspect is equivalent to pragma @code{Invariant}. It is a
7346 synonym for the language defined aspect @code{Type_Invariant} except
7347 that it is separately controllable using pragma @code{Assertion_Policy}.
7349 @node Aspect Lock_Free
7350 @unnumberedsec Aspect Lock_Free
7353 This aspect is equivalent to pragma @code{Lock_Free}.
7355 @node Aspect Object_Size
7356 @unnumberedsec Aspect Object_Size
7359 This aspect is equivalent to an @code{Object_Size} attribute definition
7362 @node Aspect Persistent_BSS
7363 @unnumberedsec Aspect Persistent_BSS
7364 @findex Persistent_BSS
7366 This aspect is equivalent to pragma @code{Persistent_BSS}.
7368 @node Aspect Predicate
7369 @unnumberedsec Aspect Predicate
7372 This aspect is equivalent to pragma @code{Predicate}. It is thus
7373 similar to the language defined aspects @code{Dynamic_Predicate}
7374 and @code{Static_Predicate} except that whether the resulting
7375 predicate is static or dynamic is controlled by the form of the
7376 expression. It is also separately controllable using pragma
7377 @code{Assertion_Policy}.
7379 @node Aspect Preelaborate_05
7380 @unnumberedsec Aspect Preelaborate_05
7381 @findex Preelaborate_05
7383 This aspect is equivalent to pragma @code{Preelaborate_05}.
7385 @node Aspect Pure_05
7386 @unnumberedsec Aspect Pure_05
7389 This aspect is equivalent to pragma @code{Pure_05}.
7391 @node Aspect Pure_12
7392 @unnumberedsec Aspect Pure_12
7395 This aspect is equivalent to pragma @code{Pure_12}.
7397 @node Aspect Pure_Function
7398 @unnumberedsec Aspect Pure_Function
7399 @findex Pure_Function
7401 This aspect is equivalent to pragma @code{Pure_Function}.
7403 @node Aspect Remote_Access_Type
7404 @unnumberedsec Aspect Remote_Access_Type
7405 @findex Remote_Access_Type
7407 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7409 @node Aspect Scalar_Storage_Order
7410 @unnumberedsec Aspect Scalar_Storage_Order
7411 @findex Scalar_Storage_Order
7413 This aspect is equivalent to a @code{Scalar_Storage_Order}
7414 attribute definition clause.
7417 @unnumberedsec Aspect Shared
7420 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7421 for aspect @code{Atomic}.
7423 @node Aspect Simple_Storage_Pool
7424 @unnumberedsec Aspect Simple_Storage_Pool
7425 @findex Simple_Storage_Pool
7427 This aspect is equivalent to a @code{Simple_Storage_Pool}
7428 attribute definition clause.
7430 @node Aspect Simple_Storage_Pool_Type
7431 @unnumberedsec Aspect Simple_Storage_Pool_Type
7432 @findex Simple_Storage_Pool_Type
7434 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7436 @node Aspect Suppress_Debug_Info
7437 @unnumberedsec Aspect Suppress_Debug_Info
7438 @findex Suppress_Debug_Info
7440 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7442 @node Aspect Test_Case
7443 @unnumberedsec Aspect Test_Case
7446 This aspect is equivalent to pragma @code{Test_Case}.
7448 @node Aspect Universal_Aliasing
7449 @unnumberedsec Aspect Universal_Aliasing
7450 @findex Universal_Aliasing
7452 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7454 @node Aspect Universal_Data
7455 @unnumberedsec Aspect Universal_Data
7456 @findex Universal_Data
7458 This aspect is equivalent to pragma @code{Universal_Data}.
7460 @node Aspect Unmodified
7461 @unnumberedsec Aspect Unmodified
7464 This aspect is equivalent to pragma @code{Unmodified}.
7466 @node Aspect Unreferenced
7467 @unnumberedsec Aspect Unreferenced
7468 @findex Unreferenced
7470 This aspect is equivalent to pragma @code{Unreferenced}.
7472 @node Aspect Unreferenced_Objects
7473 @unnumberedsec Aspect Unreferenced_Objects
7474 @findex Unreferenced_Objects
7476 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7478 @node Aspect Value_Size
7479 @unnumberedsec Aspect Value_Size
7482 This aspect is equivalent to a @code{Value_Size}
7483 attribute definition clause.
7485 @node Aspect Warnings
7486 @unnumberedsec Aspect Warnings
7489 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7490 where the first argument is @code{ON} or @code{OFF} and the second argument
7493 @node Implementation Defined Attributes
7494 @chapter Implementation Defined Attributes
7495 Ada defines (throughout the Ada reference manual,
7496 summarized in Annex K),
7497 a set of attributes that provide useful additional functionality in all
7498 areas of the language. These language defined attributes are implemented
7499 in GNAT and work as described in the Ada Reference Manual.
7501 In addition, Ada allows implementations to define additional
7502 attributes whose meaning is defined by the implementation. GNAT provides
7503 a number of these implementation-dependent attributes which can be used
7504 to extend and enhance the functionality of the compiler. This section of
7505 the GNAT reference manual describes these additional attributes.
7507 Note that any program using these attributes may not be portable to
7508 other compilers (although GNAT implements this set of attributes on all
7509 platforms). Therefore if portability to other compilers is an important
7510 consideration, you should minimize the use of these attributes.
7513 * Attribute Abort_Signal::
7514 * Attribute Address_Size::
7515 * Attribute Asm_Input::
7516 * Attribute Asm_Output::
7517 * Attribute AST_Entry::
7519 * Attribute Bit_Position::
7520 * Attribute Compiler_Version::
7521 * Attribute Code_Address::
7522 * Attribute Default_Bit_Order::
7523 * Attribute Descriptor_Size::
7524 * Attribute Elaborated::
7525 * Attribute Elab_Body::
7526 * Attribute Elab_Spec::
7527 * Attribute Elab_Subp_Body::
7529 * Attribute Enabled::
7530 * Attribute Enum_Rep::
7531 * Attribute Enum_Val::
7532 * Attribute Epsilon::
7533 * Attribute Fixed_Value::
7534 * Attribute Has_Access_Values::
7535 * Attribute Has_Discriminants::
7537 * Attribute Integer_Value::
7538 * Attribute Invalid_Value::
7540 * Attribute Loop_Entry::
7541 * Attribute Machine_Size::
7542 * Attribute Mantissa::
7543 * Attribute Max_Interrupt_Priority::
7544 * Attribute Max_Priority::
7545 * Attribute Maximum_Alignment::
7546 * Attribute Mechanism_Code::
7547 * Attribute Null_Parameter::
7548 * Attribute Object_Size::
7549 * Attribute Passed_By_Reference::
7550 * Attribute Pool_Address::
7551 * Attribute Range_Length::
7553 * Attribute Result::
7554 * Attribute Safe_Emax::
7555 * Attribute Safe_Large::
7556 * Attribute Scalar_Storage_Order::
7557 * Attribute Simple_Storage_Pool::
7559 * Attribute Storage_Unit::
7560 * Attribute Stub_Type::
7561 * Attribute System_Allocator_Alignment::
7562 * Attribute Target_Name::
7564 * Attribute To_Address::
7565 * Attribute Type_Class::
7566 * Attribute UET_Address::
7567 * Attribute Unconstrained_Array::
7568 * Attribute Universal_Literal_String::
7569 * Attribute Unrestricted_Access::
7570 * Attribute Update::
7571 * Attribute Valid_Scalars::
7572 * Attribute VADS_Size::
7573 * Attribute Value_Size::
7574 * Attribute Wchar_T_Size::
7575 * Attribute Word_Size::
7578 @node Attribute Abort_Signal
7579 @unnumberedsec Attribute Abort_Signal
7580 @findex Abort_Signal
7582 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
7583 prefix) provides the entity for the special exception used to signal
7584 task abort or asynchronous transfer of control. Normally this attribute
7585 should only be used in the tasking runtime (it is highly peculiar, and
7586 completely outside the normal semantics of Ada, for a user program to
7587 intercept the abort exception).
7589 @node Attribute Address_Size
7590 @unnumberedsec Attribute Address_Size
7591 @cindex Size of @code{Address}
7592 @findex Address_Size
7594 @code{Standard'Address_Size} (@code{Standard} is the only allowed
7595 prefix) is a static constant giving the number of bits in an
7596 @code{Address}. It is the same value as System.Address'Size,
7597 but has the advantage of being static, while a direct
7598 reference to System.Address'Size is non-static because Address
7601 @node Attribute Asm_Input
7602 @unnumberedsec Attribute Asm_Input
7605 The @code{Asm_Input} attribute denotes a function that takes two
7606 parameters. The first is a string, the second is an expression of the
7607 type designated by the prefix. The first (string) argument is required
7608 to be a static expression, and is the constraint for the parameter,
7609 (e.g.@: what kind of register is required). The second argument is the
7610 value to be used as the input argument. The possible values for the
7611 constant are the same as those used in the RTL, and are dependent on
7612 the configuration file used to built the GCC back end.
7613 @ref{Machine Code Insertions}
7615 @node Attribute Asm_Output
7616 @unnumberedsec Attribute Asm_Output
7619 The @code{Asm_Output} attribute denotes a function that takes two
7620 parameters. The first is a string, the second is the name of a variable
7621 of the type designated by the attribute prefix. The first (string)
7622 argument is required to be a static expression and designates the
7623 constraint for the parameter (e.g.@: what kind of register is
7624 required). The second argument is the variable to be updated with the
7625 result. The possible values for constraint are the same as those used in
7626 the RTL, and are dependent on the configuration file used to build the
7627 GCC back end. If there are no output operands, then this argument may
7628 either be omitted, or explicitly given as @code{No_Output_Operands}.
7629 @ref{Machine Code Insertions}
7631 @node Attribute AST_Entry
7632 @unnumberedsec Attribute AST_Entry
7636 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
7637 the name of an entry, it yields a value of the predefined type AST_Handler
7638 (declared in the predefined package System, as extended by the use of
7639 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
7640 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
7641 Language Reference Manual}, section 9.12a.
7644 @unnumberedsec Attribute Bit
7646 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
7647 offset within the storage unit (byte) that contains the first bit of
7648 storage allocated for the object. The value of this attribute is of the
7649 type @code{Universal_Integer}, and is always a non-negative number not
7650 exceeding the value of @code{System.Storage_Unit}.
7652 For an object that is a variable or a constant allocated in a register,
7653 the value is zero. (The use of this attribute does not force the
7654 allocation of a variable to memory).
7656 For an object that is a formal parameter, this attribute applies
7657 to either the matching actual parameter or to a copy of the
7658 matching actual parameter.
7660 For an access object the value is zero. Note that
7661 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
7662 designated object. Similarly for a record component
7663 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
7664 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
7665 are subject to index checks.
7667 This attribute is designed to be compatible with the DEC Ada 83 definition
7668 and implementation of the @code{Bit} attribute.
7670 @node Attribute Bit_Position
7671 @unnumberedsec Attribute Bit_Position
7672 @findex Bit_Position
7674 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
7675 of the fields of the record type, yields the bit
7676 offset within the record contains the first bit of
7677 storage allocated for the object. The value of this attribute is of the
7678 type @code{Universal_Integer}. The value depends only on the field
7679 @var{C} and is independent of the alignment of
7680 the containing record @var{R}.
7682 @node Attribute Compiler_Version
7683 @unnumberedsec Attribute Compiler_Version
7684 @findex Compiler_Version
7686 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
7687 prefix) yields a static string identifying the version of the compiler
7688 being used to compile the unit containing the attribute reference. A
7689 typical result would be something like "@value{EDITION} @i{version} (20090221)".
7691 @node Attribute Code_Address
7692 @unnumberedsec Attribute Code_Address
7693 @findex Code_Address
7694 @cindex Subprogram address
7695 @cindex Address of subprogram code
7698 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
7699 intended effect seems to be to provide
7700 an address value which can be used to call the subprogram by means of
7701 an address clause as in the following example:
7703 @smallexample @c ada
7704 procedure K is @dots{}
7707 for L'Address use K'Address;
7708 pragma Import (Ada, L);
7712 A call to @code{L} is then expected to result in a call to @code{K}@.
7713 In Ada 83, where there were no access-to-subprogram values, this was
7714 a common work-around for getting the effect of an indirect call.
7715 GNAT implements the above use of @code{Address} and the technique
7716 illustrated by the example code works correctly.
7718 However, for some purposes, it is useful to have the address of the start
7719 of the generated code for the subprogram. On some architectures, this is
7720 not necessarily the same as the @code{Address} value described above.
7721 For example, the @code{Address} value may reference a subprogram
7722 descriptor rather than the subprogram itself.
7724 The @code{'Code_Address} attribute, which can only be applied to
7725 subprogram entities, always returns the address of the start of the
7726 generated code of the specified subprogram, which may or may not be
7727 the same value as is returned by the corresponding @code{'Address}
7730 @node Attribute Default_Bit_Order
7731 @unnumberedsec Attribute Default_Bit_Order
7733 @cindex Little endian
7734 @findex Default_Bit_Order
7736 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
7737 permissible prefix), provides the value @code{System.Default_Bit_Order}
7738 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
7739 @code{Low_Order_First}). This is used to construct the definition of
7740 @code{Default_Bit_Order} in package @code{System}.
7742 @node Attribute Descriptor_Size
7743 @unnumberedsec Attribute Descriptor_Size
7746 @findex Descriptor_Size
7748 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
7749 descriptor allocated for a type. The result is non-zero only for unconstrained
7750 array types and the returned value is of type universal integer. In GNAT, an
7751 array descriptor contains bounds information and is located immediately before
7752 the first element of the array.
7754 @smallexample @c ada
7755 type Unconstr_Array is array (Positive range <>) of Boolean;
7756 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
7760 The attribute takes into account any additional padding due to type alignment.
7761 In the example above, the descriptor contains two values of type
7762 @code{Positive} representing the low and high bound. Since @code{Positive} has
7763 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
7764 Positive'Size + 2} or 64 bits.
7766 @node Attribute Elaborated
7767 @unnumberedsec Attribute Elaborated
7770 The prefix of the @code{'Elaborated} attribute must be a unit name. The
7771 value is a Boolean which indicates whether or not the given unit has been
7772 elaborated. This attribute is primarily intended for internal use by the
7773 generated code for dynamic elaboration checking, but it can also be used
7774 in user programs. The value will always be True once elaboration of all
7775 units has been completed. An exception is for units which need no
7776 elaboration, the value is always False for such units.
7778 @node Attribute Elab_Body
7779 @unnumberedsec Attribute Elab_Body
7782 This attribute can only be applied to a program unit name. It returns
7783 the entity for the corresponding elaboration procedure for elaborating
7784 the body of the referenced unit. This is used in the main generated
7785 elaboration procedure by the binder and is not normally used in any
7786 other context. However, there may be specialized situations in which it
7787 is useful to be able to call this elaboration procedure from Ada code,
7788 e.g.@: if it is necessary to do selective re-elaboration to fix some
7791 @node Attribute Elab_Spec
7792 @unnumberedsec Attribute Elab_Spec
7795 This attribute can only be applied to a program unit name. It returns
7796 the entity for the corresponding elaboration procedure for elaborating
7797 the spec of the referenced unit. This is used in the main
7798 generated elaboration procedure by the binder and is not normally used
7799 in any other context. However, there may be specialized situations in
7800 which it is useful to be able to call this elaboration procedure from
7801 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
7804 @node Attribute Elab_Subp_Body
7805 @unnumberedsec Attribute Elab_Subp_Body
7806 @findex Elab_Subp_Body
7808 This attribute can only be applied to a library level subprogram
7809 name and is only allowed in CodePeer mode. It returns the entity
7810 for the corresponding elaboration procedure for elaborating the body
7811 of the referenced subprogram unit. This is used in the main generated
7812 elaboration procedure by the binder in CodePeer mode only and is unrecognized
7815 @node Attribute Emax
7816 @unnumberedsec Attribute Emax
7817 @cindex Ada 83 attributes
7820 The @code{Emax} attribute is provided for compatibility with Ada 83. See
7821 the Ada 83 reference manual for an exact description of the semantics of
7824 @node Attribute Enabled
7825 @unnumberedsec Attribute Enabled
7828 The @code{Enabled} attribute allows an application program to check at compile
7829 time to see if the designated check is currently enabled. The prefix is a
7830 simple identifier, referencing any predefined check name (other than
7831 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
7832 no argument is given for the attribute, the check is for the general state
7833 of the check, if an argument is given, then it is an entity name, and the
7834 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
7835 given naming the entity (if not, then the argument is ignored).
7837 Note that instantiations inherit the check status at the point of the
7838 instantiation, so a useful idiom is to have a library package that
7839 introduces a check name with @code{pragma Check_Name}, and then contains
7840 generic packages or subprograms which use the @code{Enabled} attribute
7841 to see if the check is enabled. A user of this package can then issue
7842 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
7843 the package or subprogram, controlling whether the check will be present.
7845 @node Attribute Enum_Rep
7846 @unnumberedsec Attribute Enum_Rep
7847 @cindex Representation of enums
7850 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
7851 function with the following spec:
7853 @smallexample @c ada
7854 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
7855 return @i{Universal_Integer};
7859 It is also allowable to apply @code{Enum_Rep} directly to an object of an
7860 enumeration type or to a non-overloaded enumeration
7861 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
7862 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
7863 enumeration literal or object.
7865 The function returns the representation value for the given enumeration
7866 value. This will be equal to value of the @code{Pos} attribute in the
7867 absence of an enumeration representation clause. This is a static
7868 attribute (i.e.@: the result is static if the argument is static).
7870 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
7871 in which case it simply returns the integer value. The reason for this
7872 is to allow it to be used for @code{(<>)} discrete formal arguments in
7873 a generic unit that can be instantiated with either enumeration types
7874 or integer types. Note that if @code{Enum_Rep} is used on a modular
7875 type whose upper bound exceeds the upper bound of the largest signed
7876 integer type, and the argument is a variable, so that the universal
7877 integer calculation is done at run time, then the call to @code{Enum_Rep}
7878 may raise @code{Constraint_Error}.
7880 @node Attribute Enum_Val
7881 @unnumberedsec Attribute Enum_Val
7882 @cindex Representation of enums
7885 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
7886 function with the following spec:
7888 @smallexample @c ada
7889 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
7890 return @var{S}'Base};
7894 The function returns the enumeration value whose representation matches the
7895 argument, or raises Constraint_Error if no enumeration literal of the type
7896 has the matching value.
7897 This will be equal to value of the @code{Val} attribute in the
7898 absence of an enumeration representation clause. This is a static
7899 attribute (i.e.@: the result is static if the argument is static).
7901 @node Attribute Epsilon
7902 @unnumberedsec Attribute Epsilon
7903 @cindex Ada 83 attributes
7906 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
7907 the Ada 83 reference manual for an exact description of the semantics of
7910 @node Attribute Fixed_Value
7911 @unnumberedsec Attribute Fixed_Value
7914 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
7915 function with the following specification:
7917 @smallexample @c ada
7918 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
7923 The value returned is the fixed-point value @var{V} such that
7925 @smallexample @c ada
7926 @var{V} = Arg * @var{S}'Small
7930 The effect is thus similar to first converting the argument to the
7931 integer type used to represent @var{S}, and then doing an unchecked
7932 conversion to the fixed-point type. The difference is
7933 that there are full range checks, to ensure that the result is in range.
7934 This attribute is primarily intended for use in implementation of the
7935 input-output functions for fixed-point values.
7937 @node Attribute Has_Access_Values
7938 @unnumberedsec Attribute Has_Access_Values
7939 @cindex Access values, testing for
7940 @findex Has_Access_Values
7942 The prefix of the @code{Has_Access_Values} attribute is a type. The result
7943 is a Boolean value which is True if the is an access type, or is a composite
7944 type with a component (at any nesting depth) that is an access type, and is
7946 The intended use of this attribute is in conjunction with generic
7947 definitions. If the attribute is applied to a generic private type, it
7948 indicates whether or not the corresponding actual type has access values.
7950 @node Attribute Has_Discriminants
7951 @unnumberedsec Attribute Has_Discriminants
7952 @cindex Discriminants, testing for
7953 @findex Has_Discriminants
7955 The prefix of the @code{Has_Discriminants} attribute is a type. The result
7956 is a Boolean value which is True if the type has discriminants, and False
7957 otherwise. The intended use of this attribute is in conjunction with generic
7958 definitions. If the attribute is applied to a generic private type, it
7959 indicates whether or not the corresponding actual type has discriminants.
7962 @unnumberedsec Attribute Img
7965 The @code{Img} attribute differs from @code{Image} in that it may be
7966 applied to objects as well as types, in which case it gives the
7967 @code{Image} for the subtype of the object. This is convenient for
7970 @smallexample @c ada
7971 Put_Line ("X = " & X'Img);
7975 has the same meaning as the more verbose:
7977 @smallexample @c ada
7978 Put_Line ("X = " & @var{T}'Image (X));
7982 where @var{T} is the (sub)type of the object @code{X}.
7984 @node Attribute Integer_Value
7985 @unnumberedsec Attribute Integer_Value
7986 @findex Integer_Value
7988 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
7989 function with the following spec:
7991 @smallexample @c ada
7992 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
7997 The value returned is the integer value @var{V}, such that
7999 @smallexample @c ada
8000 Arg = @var{V} * @var{T}'Small
8004 where @var{T} is the type of @code{Arg}.
8005 The effect is thus similar to first doing an unchecked conversion from
8006 the fixed-point type to its corresponding implementation type, and then
8007 converting the result to the target integer type. The difference is
8008 that there are full range checks, to ensure that the result is in range.
8009 This attribute is primarily intended for use in implementation of the
8010 standard input-output functions for fixed-point values.
8012 @node Attribute Invalid_Value
8013 @unnumberedsec Attribute Invalid_Value
8014 @findex Invalid_Value
8016 For every scalar type S, S'Invalid_Value returns an undefined value of the
8017 type. If possible this value is an invalid representation for the type. The
8018 value returned is identical to the value used to initialize an otherwise
8019 uninitialized value of the type if pragma Initialize_Scalars is used,
8020 including the ability to modify the value with the binder -Sxx flag and
8021 relevant environment variables at run time.
8023 @node Attribute Large
8024 @unnumberedsec Attribute Large
8025 @cindex Ada 83 attributes
8028 The @code{Large} attribute is provided for compatibility with Ada 83. See
8029 the Ada 83 reference manual for an exact description of the semantics of
8032 @node Attribute Loop_Entry
8033 @unnumberedsec Attribute Loop_Entry
8038 @smallexample @c ada
8039 X'Loop_Entry [(loop_name)]
8043 The @code{Loop_Entry} attribute is used to refer to the value that an
8044 expression had upon entry to a given loop in much the same way that the
8045 @code{Old} attribute in a subprogram postcondition can be used to refer
8046 to the value an expression had upon entry to the subprogram. The
8047 relevant loop is either identified by the given loop name, or it is the
8048 innermost enclosing loop when no loop name is given.
8051 A @code{Loop_Entry} attribute can only occur within a
8052 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8053 @code{Loop_Entry} is to compare the current value of objects with their
8054 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8057 The effect of using @code{X'Loop_Entry} is the same as declaring
8058 a constant initialized with the initial value of @code{X} at loop
8059 entry. This copy is not performed if the loop is not entered, or if the
8060 corresponding pragmas are ignored or disabled.
8062 @node Attribute Machine_Size
8063 @unnumberedsec Attribute Machine_Size
8064 @findex Machine_Size
8066 This attribute is identical to the @code{Object_Size} attribute. It is
8067 provided for compatibility with the DEC Ada 83 attribute of this name.
8069 @node Attribute Mantissa
8070 @unnumberedsec Attribute Mantissa
8071 @cindex Ada 83 attributes
8074 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8075 the Ada 83 reference manual for an exact description of the semantics of
8078 @node Attribute Max_Interrupt_Priority
8079 @unnumberedsec Attribute Max_Interrupt_Priority
8080 @cindex Interrupt priority, maximum
8081 @findex Max_Interrupt_Priority
8083 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8084 permissible prefix), provides the same value as
8085 @code{System.Max_Interrupt_Priority}.
8087 @node Attribute Max_Priority
8088 @unnumberedsec Attribute Max_Priority
8089 @cindex Priority, maximum
8090 @findex Max_Priority
8092 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8093 prefix) provides the same value as @code{System.Max_Priority}.
8095 @node Attribute Maximum_Alignment
8096 @unnumberedsec Attribute Maximum_Alignment
8097 @cindex Alignment, maximum
8098 @findex Maximum_Alignment
8100 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8101 permissible prefix) provides the maximum useful alignment value for the
8102 target. This is a static value that can be used to specify the alignment
8103 for an object, guaranteeing that it is properly aligned in all
8106 @node Attribute Mechanism_Code
8107 @unnumberedsec Attribute Mechanism_Code
8108 @cindex Return values, passing mechanism
8109 @cindex Parameters, passing mechanism
8110 @findex Mechanism_Code
8112 @code{@var{function}'Mechanism_Code} yields an integer code for the
8113 mechanism used for the result of function, and
8114 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8115 used for formal parameter number @var{n} (a static integer value with 1
8116 meaning the first parameter) of @var{subprogram}. The code returned is:
8124 by descriptor (default descriptor class)
8126 by descriptor (UBS: unaligned bit string)
8128 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8130 by descriptor (UBA: unaligned bit array)
8132 by descriptor (S: string, also scalar access type parameter)
8134 by descriptor (SB: string with arbitrary bounds)
8136 by descriptor (A: contiguous array)
8138 by descriptor (NCA: non-contiguous array)
8142 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8145 @node Attribute Null_Parameter
8146 @unnumberedsec Attribute Null_Parameter
8147 @cindex Zero address, passing
8148 @findex Null_Parameter
8150 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8151 type or subtype @var{T} allocated at machine address zero. The attribute
8152 is allowed only as the default expression of a formal parameter, or as
8153 an actual expression of a subprogram call. In either case, the
8154 subprogram must be imported.
8156 The identity of the object is represented by the address zero in the
8157 argument list, independent of the passing mechanism (explicit or
8160 This capability is needed to specify that a zero address should be
8161 passed for a record or other composite object passed by reference.
8162 There is no way of indicating this without the @code{Null_Parameter}
8165 @node Attribute Object_Size
8166 @unnumberedsec Attribute Object_Size
8167 @cindex Size, used for objects
8170 The size of an object is not necessarily the same as the size of the type
8171 of an object. This is because by default object sizes are increased to be
8172 a multiple of the alignment of the object. For example,
8173 @code{Natural'Size} is
8174 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8175 Similarly, a record containing an integer and a character:
8177 @smallexample @c ada
8185 will have a size of 40 (that is @code{Rec'Size} will be 40). The
8186 alignment will be 4, because of the
8187 integer field, and so the default size of record objects for this type
8188 will be 64 (8 bytes).
8190 @node Attribute Passed_By_Reference
8191 @unnumberedsec Attribute Passed_By_Reference
8192 @cindex Parameters, when passed by reference
8193 @findex Passed_By_Reference
8195 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8196 a value of type @code{Boolean} value that is @code{True} if the type is
8197 normally passed by reference and @code{False} if the type is normally
8198 passed by copy in calls. For scalar types, the result is always @code{False}
8199 and is static. For non-scalar types, the result is non-static.
8201 @node Attribute Pool_Address
8202 @unnumberedsec Attribute Pool_Address
8203 @cindex Parameters, when passed by reference
8204 @findex Pool_Address
8206 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8207 of X within its storage pool. This is the same as
8208 @code{@var{X}'Address}, except that for an unconstrained array whose
8209 bounds are allocated just before the first component,
8210 @code{@var{X}'Pool_Address} returns the address of those bounds,
8211 whereas @code{@var{X}'Address} returns the address of the first
8214 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8215 the object is allocated'', which could be a user-defined storage pool,
8216 the global heap, on the stack, or in a static memory area. For an
8217 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8218 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8220 @node Attribute Range_Length
8221 @unnumberedsec Attribute Range_Length
8222 @findex Range_Length
8224 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8225 the number of values represented by the subtype (zero for a null
8226 range). The result is static for static subtypes. @code{Range_Length}
8227 applied to the index subtype of a one dimensional array always gives the
8228 same result as @code{Length} applied to the array itself.
8231 @unnumberedsec Attribute Ref
8234 The @code{System.Address'Ref}
8235 (@code{System.Address} is the only permissible prefix)
8236 denotes a function identical to
8237 @code{System.Storage_Elements.To_Address} except that
8238 it is a static attribute. See @ref{Attribute To_Address} for more details.
8240 @node Attribute Result
8241 @unnumberedsec Attribute Result
8244 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8245 for a function. The prefix must be the name of the corresponding function. This
8246 is used to refer to the result of the function in the postcondition expression.
8247 For a further discussion of the use of this attribute and examples of its use,
8248 see the description of pragma Postcondition.
8250 @node Attribute Safe_Emax
8251 @unnumberedsec Attribute Safe_Emax
8252 @cindex Ada 83 attributes
8255 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
8256 the Ada 83 reference manual for an exact description of the semantics of
8259 @node Attribute Safe_Large
8260 @unnumberedsec Attribute Safe_Large
8261 @cindex Ada 83 attributes
8264 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
8265 the Ada 83 reference manual for an exact description of the semantics of
8268 @node Attribute Scalar_Storage_Order
8269 @unnumberedsec Attribute Scalar_Storage_Order
8271 @cindex Scalar storage order
8272 @findex Scalar_Storage_Order
8274 For every array or record type @var{S}, the representation attribute
8275 @code{Scalar_Storage_Order} denotes the order in which storage elements
8276 that make up scalar components are ordered within S:
8278 @smallexample @c ada
8279 -- Component type definitions
8281 subtype Yr_Type is Natural range 0 .. 127;
8282 subtype Mo_Type is Natural range 1 .. 12;
8283 subtype Da_Type is Natural range 1 .. 31;
8285 -- Record declaration
8288 Years_Since_1980 : Yr_Type;
8290 Day_Of_Month : Da_Type;
8293 -- Record representation clause
8296 Years_Since_1980 at 0 range 0 .. 6;
8297 Month at 0 range 7 .. 10;
8298 Day_Of_Month at 0 range 11 .. 15;
8301 -- Attribute definition clauses
8303 for Date'Bit_Order use System.High_Order_First;
8304 for Date'Scalar_Storage_Order use System.High_Order_First;
8305 -- If Scalar_Storage_Order is specified, it must be consistent with
8306 -- Bit_Order, so it's best to always define the latter explicitly if
8307 -- the former is used.
8310 Other properties are
8311 as for standard representation attribute @code{Bit_Order}, as defined by
8312 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8314 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8315 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8316 this means that if a @code{Scalar_Storage_Order} attribute definition
8317 clause is not confirming, then the type's @code{Bit_Order} shall be
8318 specified explicitly and set to the same value.
8320 For a record extension, the derived type shall have the same scalar storage
8321 order as the parent type.
8323 If a component of @var{S} has itself a record or array type, then it shall also
8324 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8325 if the component does not start on a byte boundary, then the scalar storage
8326 order specified for S and for the nested component type shall be identical.
8328 No component of a type that has a @code{Scalar_Storage_Order} attribute
8329 definition may be aliased.
8331 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8332 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8334 If the opposite storage order is specified, then whenever the value of
8335 a scalar component of an object of type @var{S} is read, the storage
8336 elements of the enclosing machine scalar are first reversed (before
8337 retrieving the component value, possibly applying some shift and mask
8338 operatings on the enclosing machine scalar), and the opposite operation
8341 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8342 are relaxed. Instead, the following rules apply:
8345 @item the underlying storage elements are those at positions
8346 @code{(position + first_bit / storage_element_size) ..
8347 (position + (last_bit + storage_element_size - 1) /
8348 storage_element_size)}
8349 @item the sequence of underlying storage elements shall have
8350 a size no greater than the largest machine scalar
8351 @item the enclosing machine scalar is defined as the smallest machine
8352 scalar starting at a position no greater than
8353 @code{position + first_bit / storage_element_size} and covering
8354 storage elements at least up to @code{position + (last_bit +
8355 storage_element_size - 1) / storage_element_size}
8356 @item the position of the component is interpreted relative to that machine
8361 @node Attribute Simple_Storage_Pool
8362 @unnumberedsec Attribute Simple_Storage_Pool
8363 @cindex Storage pool, simple
8364 @cindex Simple storage pool
8365 @findex Simple_Storage_Pool
8367 For every nonformal, nonderived access-to-object type @var{Acc}, the
8368 representation attribute @code{Simple_Storage_Pool} may be specified
8369 via an attribute_definition_clause (or by specifying the equivalent aspect):
8371 @smallexample @c ada
8373 My_Pool : My_Simple_Storage_Pool_Type;
8375 type Acc is access My_Data_Type;
8377 for Acc'Simple_Storage_Pool use My_Pool;
8382 The name given in an attribute_definition_clause for the
8383 @code{Simple_Storage_Pool} attribute shall denote a variable of
8384 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
8386 The use of this attribute is only allowed for a prefix denoting a type
8387 for which it has been specified. The type of the attribute is the type
8388 of the variable specified as the simple storage pool of the access type,
8389 and the attribute denotes that variable.
8391 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8392 for the same access type.
8394 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8395 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8396 with a warning and its evaluation raises the exception @code{Program_Error}.
8398 If the Simple_Storage_Pool attribute has been specified for an access
8399 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8400 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8401 which is intended to indicate the number of storage elements reserved for
8402 the simple storage pool. If the Storage_Size function has not been defined
8403 for the simple storage pool type, then this attribute returns zero.
8405 If an access type @var{S} has a specified simple storage pool of type
8406 @var{SSP}, then the evaluation of an allocator for that access type calls
8407 the primitive @code{Allocate} procedure for type @var{SSP}, passing
8408 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
8409 semantics of such allocators is the same as those defined for allocators
8410 in section 13.11 of the Ada Reference Manual, with the term
8411 ``simple storage pool'' substituted for ``storage pool''.
8413 If an access type @var{S} has a specified simple storage pool of type
8414 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
8415 for that access type invokes the primitive @code{Deallocate} procedure
8416 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
8417 parameter. The detailed semantics of such unchecked deallocations is the same
8418 as defined in section 13.11.2 of the Ada Reference Manual, except that the
8419 term ``simple storage pool'' is substituted for ``storage pool''.
8421 @node Attribute Small
8422 @unnumberedsec Attribute Small
8423 @cindex Ada 83 attributes
8426 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
8428 GNAT also allows this attribute to be applied to floating-point types
8429 for compatibility with Ada 83. See
8430 the Ada 83 reference manual for an exact description of the semantics of
8431 this attribute when applied to floating-point types.
8433 @node Attribute Storage_Unit
8434 @unnumberedsec Attribute Storage_Unit
8435 @findex Storage_Unit
8437 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
8438 prefix) provides the same value as @code{System.Storage_Unit}.
8440 @node Attribute Stub_Type
8441 @unnumberedsec Attribute Stub_Type
8444 The GNAT implementation of remote access-to-classwide types is
8445 organized as described in AARM section E.4 (20.t): a value of an RACW type
8446 (designating a remote object) is represented as a normal access
8447 value, pointing to a "stub" object which in turn contains the
8448 necessary information to contact the designated remote object. A
8449 call on any dispatching operation of such a stub object does the
8450 remote call, if necessary, using the information in the stub object
8451 to locate the target partition, etc.
8453 For a prefix @code{T} that denotes a remote access-to-classwide type,
8454 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
8456 By construction, the layout of @code{T'Stub_Type} is identical to that of
8457 type @code{RACW_Stub_Type} declared in the internal implementation-defined
8458 unit @code{System.Partition_Interface}. Use of this attribute will create
8459 an implicit dependency on this unit.
8461 @node Attribute System_Allocator_Alignment
8462 @unnumberedsec Attribute System_Allocator_Alignment
8463 @cindex Alignment, allocator
8464 @findex System_Allocator_Alignment
8466 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
8467 permissible prefix) provides the observable guaranted to be honored by
8468 the system allocator (malloc). This is a static value that can be used
8469 in user storage pools based on malloc either to reject allocation
8470 with alignment too large or to enable a realignment circuitry if the
8471 alignment request is larger than this value.
8473 @node Attribute Target_Name
8474 @unnumberedsec Attribute Target_Name
8477 @code{Standard'Target_Name} (@code{Standard} is the only permissible
8478 prefix) provides a static string value that identifies the target
8479 for the current compilation. For GCC implementations, this is the
8480 standard gcc target name without the terminating slash (for
8481 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
8483 @node Attribute Tick
8484 @unnumberedsec Attribute Tick
8487 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
8488 provides the same value as @code{System.Tick},
8490 @node Attribute To_Address
8491 @unnumberedsec Attribute To_Address
8494 The @code{System'To_Address}
8495 (@code{System} is the only permissible prefix)
8496 denotes a function identical to
8497 @code{System.Storage_Elements.To_Address} except that
8498 it is a static attribute. This means that if its argument is
8499 a static expression, then the result of the attribute is a
8500 static expression. The result is that such an expression can be
8501 used in contexts (e.g.@: preelaborable packages) which require a
8502 static expression and where the function call could not be used
8503 (since the function call is always non-static, even if its
8504 argument is static).
8506 @node Attribute Type_Class
8507 @unnumberedsec Attribute Type_Class
8510 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
8511 the value of the type class for the full type of @var{type}. If
8512 @var{type} is a generic formal type, the value is the value for the
8513 corresponding actual subtype. The value of this attribute is of type
8514 @code{System.Aux_DEC.Type_Class}, which has the following definition:
8516 @smallexample @c ada
8518 (Type_Class_Enumeration,
8520 Type_Class_Fixed_Point,
8521 Type_Class_Floating_Point,
8526 Type_Class_Address);
8530 Protected types yield the value @code{Type_Class_Task}, which thus
8531 applies to all concurrent types. This attribute is designed to
8532 be compatible with the DEC Ada 83 attribute of the same name.
8534 @node Attribute UET_Address
8535 @unnumberedsec Attribute UET_Address
8538 The @code{UET_Address} attribute can only be used for a prefix which
8539 denotes a library package. It yields the address of the unit exception
8540 table when zero cost exception handling is used. This attribute is
8541 intended only for use within the GNAT implementation. See the unit
8542 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
8543 for details on how this attribute is used in the implementation.
8545 @node Attribute Unconstrained_Array
8546 @unnumberedsec Attribute Unconstrained_Array
8547 @findex Unconstrained_Array
8549 The @code{Unconstrained_Array} attribute can be used with a prefix that
8550 denotes any type or subtype. It is a static attribute that yields
8551 @code{True} if the prefix designates an unconstrained array,
8552 and @code{False} otherwise. In a generic instance, the result is
8553 still static, and yields the result of applying this test to the
8556 @node Attribute Universal_Literal_String
8557 @unnumberedsec Attribute Universal_Literal_String
8558 @cindex Named numbers, representation of
8559 @findex Universal_Literal_String
8561 The prefix of @code{Universal_Literal_String} must be a named
8562 number. The static result is the string consisting of the characters of
8563 the number as defined in the original source. This allows the user
8564 program to access the actual text of named numbers without intermediate
8565 conversions and without the need to enclose the strings in quotes (which
8566 would preclude their use as numbers).
8568 For example, the following program prints the first 50 digits of pi:
8570 @smallexample @c ada
8571 with Text_IO; use Text_IO;
8575 Put (Ada.Numerics.Pi'Universal_Literal_String);
8579 @node Attribute Unrestricted_Access
8580 @unnumberedsec Attribute Unrestricted_Access
8581 @cindex @code{Access}, unrestricted
8582 @findex Unrestricted_Access
8584 The @code{Unrestricted_Access} attribute is similar to @code{Access}
8585 except that all accessibility and aliased view checks are omitted. This
8586 is a user-beware attribute. It is similar to
8587 @code{Address}, for which it is a desirable replacement where the value
8588 desired is an access type. In other words, its effect is identical to
8589 first applying the @code{Address} attribute and then doing an unchecked
8590 conversion to a desired access type. In GNAT, but not necessarily in
8591 other implementations, the use of static chains for inner level
8592 subprograms means that @code{Unrestricted_Access} applied to a
8593 subprogram yields a value that can be called as long as the subprogram
8594 is in scope (normal Ada accessibility rules restrict this usage).
8596 It is possible to use @code{Unrestricted_Access} for any type, but care
8597 must be exercised if it is used to create pointers to unconstrained
8598 objects. In this case, the resulting pointer has the same scope as the
8599 context of the attribute, and may not be returned to some enclosing
8600 scope. For instance, a function cannot use @code{Unrestricted_Access}
8601 to create a unconstrained pointer and then return that value to the
8604 @node Attribute Update
8605 @unnumberedsec Attribute Update
8608 The @code{Update} attribute creates a copy of an array or record value
8609 with one or more modified components. The syntax is:
8611 @smallexample @c ada
8612 PREFIX'Update (AGGREGATE);
8616 where @code{PREFIX} is the name of an array or record object, and
8617 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
8618 choice. The effect is to yield a copy of the array or record value which
8619 is unchanged apart from the components mentioned in the aggregate, which
8620 are changed to the indicated value. The original value of the array or
8621 record value is not affected. For example:
8623 @smallexample @c ada
8624 type Arr is Array (1 .. 5) of Integer;
8626 Avar1 : Arr := (1,2,3,4,5);
8627 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
8631 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
8632 begin unmodified. Similarly:
8634 @smallexample @c ada
8635 type Rec is A, B, C : Integer;
8637 Rvar1 : Rec := (A => 1, B => 2, C => 3);
8638 Rvar2 : Rec := Rvar1'Update ((B => 20));
8642 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
8643 with @code{Rvar1} being unmodifed.
8644 Note that the value of the attribute reference is computed
8645 completely before it is used. This means that if you write:
8647 @smallexample @c ada
8648 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
8652 then the value of @code{Avar1} is not modified if @code{Function_Call}
8653 raises an exception, unlike the effect of a series of direct assignments
8654 to elements of @code{Avar1}. In general this requires that
8655 two extra complete copies of the object are required, which should be
8656 kept in mind when considering efficiency.
8658 The @code{Update} attribute cannot be applied to prefixes of a limited
8659 type, and cannot reference discriminants in the case of a record type.
8661 In the record case, no component can be mentioned more than once. In
8662 the array case, two overlapping ranges can appear in the aggregate,
8663 in which case the modifications are processed left to right.
8665 Multi-dimensional arrays can be modified, as shown by this example:
8667 @smallexample @c ada
8668 A : array (1 .. 10, 1 .. 10) of Integer;
8670 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
8674 which changes element (1,2) to 20 and (3,4) to 30.
8676 @node Attribute Valid_Scalars
8677 @unnumberedsec Attribute Valid_Scalars
8678 @findex Valid_Scalars
8680 The @code{'Valid_Scalars} attribute is intended to make it easier to
8681 check the validity of scalar subcomponents of composite objects. It
8682 is defined for any prefix @code{X} that denotes an object.
8683 The value of this attribute is of the predefined type Boolean.
8684 @code{X'Valid_Scalars} yields True if and only if evaluation of
8685 @code{P'Valid} yields True for every scalar part P of X or if X has
8686 no scalar parts. It is not specified in what order the scalar parts
8687 are checked, nor whether any more are checked after any one of them
8688 is determined to be invalid. If the prefix @code{X} is of a class-wide
8689 type @code{T'Class} (where @code{T} is the associated specific type),
8690 or if the prefix @code{X} is of a specific tagged type @code{T}, then
8691 only the scalar parts of components of @code{T} are traversed; in other
8692 words, components of extensions of @code{T} are not traversed even if
8693 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
8694 be determined at compile time that the prefix of the attribute has no
8695 scalar parts (e.g., if the prefix is of an access type, an interface type,
8696 an undiscriminated task type, or an undiscriminated protected type).
8698 @node Attribute VADS_Size
8699 @unnumberedsec Attribute VADS_Size
8700 @cindex @code{Size}, VADS compatibility
8703 The @code{'VADS_Size} attribute is intended to make it easier to port
8704 legacy code which relies on the semantics of @code{'Size} as implemented
8705 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
8706 same semantic interpretation. In particular, @code{'VADS_Size} applied
8707 to a predefined or other primitive type with no Size clause yields the
8708 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
8709 typical machines). In addition @code{'VADS_Size} applied to an object
8710 gives the result that would be obtained by applying the attribute to
8711 the corresponding type.
8713 @node Attribute Value_Size
8714 @unnumberedsec Attribute Value_Size
8715 @cindex @code{Size}, setting for not-first subtype
8717 @code{@var{type}'Value_Size} is the number of bits required to represent
8718 a value of the given subtype. It is the same as @code{@var{type}'Size},
8719 but, unlike @code{Size}, may be set for non-first subtypes.
8721 @node Attribute Wchar_T_Size
8722 @unnumberedsec Attribute Wchar_T_Size
8723 @findex Wchar_T_Size
8724 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
8725 prefix) provides the size in bits of the C @code{wchar_t} type
8726 primarily for constructing the definition of this type in
8727 package @code{Interfaces.C}.
8729 @node Attribute Word_Size
8730 @unnumberedsec Attribute Word_Size
8732 @code{Standard'Word_Size} (@code{Standard} is the only permissible
8733 prefix) provides the value @code{System.Word_Size}.
8735 @node Standard and Implementation Defined Restrictions
8736 @chapter Standard and Implementation Defined Restrictions
8739 All RM defined Restriction identifiers are implemented:
8742 @item language-defined restrictions (see 13.12.1)
8743 @item tasking restrictions (see D.7)
8744 @item high integrity restrictions (see H.4)
8748 GNAT implements additional restriction identifiers. All restrictions, whether
8749 language defined or GNAT-specific, are listed in the following.
8752 * Partition-Wide Restrictions::
8753 * Program Unit Level Restrictions::
8756 @node Partition-Wide Restrictions
8757 @section Partition-Wide Restrictions
8759 There are two separate lists of restriction identifiers. The first
8760 set requires consistency throughout a partition (in other words, if the
8761 restriction identifier is used for any compilation unit in the partition,
8762 then all compilation units in the partition must obey the restriction).
8765 * Immediate_Reclamation::
8766 * Max_Asynchronous_Select_Nesting::
8767 * Max_Entry_Queue_Length::
8768 * Max_Protected_Entries::
8769 * Max_Select_Alternatives::
8770 * Max_Storage_At_Blocking::
8771 * Max_Task_Entries::
8773 * No_Abort_Statements::
8774 * No_Access_Parameter_Allocators::
8775 * No_Access_Subprograms::
8777 * No_Anonymous_Allocators::
8780 * No_Default_Initialization::
8783 * No_Direct_Boolean_Operators::
8785 * No_Dispatching_Calls::
8786 * No_Dynamic_Attachment::
8787 * No_Dynamic_Priorities::
8788 * No_Entry_Calls_In_Elaboration_Code::
8789 * No_Enumeration_Maps::
8790 * No_Exception_Handlers::
8791 * No_Exception_Propagation::
8792 * No_Exception_Registration::
8796 * No_Floating_Point::
8797 * No_Implicit_Conditionals::
8798 * No_Implicit_Dynamic_Code::
8799 * No_Implicit_Heap_Allocations::
8800 * No_Implicit_Loops::
8801 * No_Initialize_Scalars::
8803 * No_Local_Allocators::
8804 * No_Local_Protected_Objects::
8805 * No_Local_Timing_Events::
8806 * No_Nested_Finalization::
8807 * No_Protected_Type_Allocators::
8808 * No_Protected_Types::
8811 * No_Relative_Delay::
8812 * No_Requeue_Statements::
8813 * No_Secondary_Stack::
8814 * No_Select_Statements::
8815 * No_Specific_Termination_Handlers::
8816 * No_Specification_of_Aspect::
8817 * No_Standard_Allocators_After_Elaboration::
8818 * No_Standard_Storage_Pools::
8819 * No_Stream_Optimizations::
8821 * No_Task_Allocators::
8822 * No_Task_Attributes_Package::
8823 * No_Task_Hierarchy::
8824 * No_Task_Termination::
8826 * No_Terminate_Alternatives::
8827 * No_Unchecked_Access::
8829 * Static_Priorities::
8830 * Static_Storage_Size::
8833 @node Immediate_Reclamation
8834 @unnumberedsubsec Immediate_Reclamation
8835 @findex Immediate_Reclamation
8836 [RM H.4] This restriction ensures that, except for storage occupied by
8837 objects created by allocators and not deallocated via unchecked
8838 deallocation, any storage reserved at run time for an object is
8839 immediately reclaimed when the object no longer exists.
8841 @node Max_Asynchronous_Select_Nesting
8842 @unnumberedsubsec Max_Asynchronous_Select_Nesting
8843 @findex Max_Asynchronous_Select_Nesting
8844 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
8845 selects. Violations of this restriction with a value of zero are
8846 detected at compile time. Violations of this restriction with values
8847 other than zero cause Storage_Error to be raised.
8849 @node Max_Entry_Queue_Length
8850 @unnumberedsubsec Max_Entry_Queue_Length
8851 @findex Max_Entry_Queue_Length
8852 [RM D.7] This restriction is a declaration that any protected entry compiled in
8853 the scope of the restriction has at most the specified number of
8854 tasks waiting on the entry at any one time, and so no queue is required.
8855 Note that this restriction is checked at run time. Violation of this
8856 restriction results in the raising of Program_Error exception at the point of
8859 @node Max_Protected_Entries
8860 @unnumberedsubsec Max_Protected_Entries
8861 @findex Max_Protected_Entries
8862 [RM D.7] Specifies the maximum number of entries per protected type. The
8863 bounds of every entry family of a protected unit shall be static, or shall be
8864 defined by a discriminant of a subtype whose corresponding bound is static.
8866 @node Max_Select_Alternatives
8867 @unnumberedsubsec Max_Select_Alternatives
8868 @findex Max_Select_Alternatives
8869 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
8871 @node Max_Storage_At_Blocking
8872 @unnumberedsubsec Max_Storage_At_Blocking
8873 @findex Max_Storage_At_Blocking
8874 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
8875 Storage_Size that can be retained by a blocked task. A violation of this
8876 restriction causes Storage_Error to be raised.
8878 @node Max_Task_Entries
8879 @unnumberedsubsec Max_Task_Entries
8880 @findex Max_Task_Entries
8881 [RM D.7] Specifies the maximum number of entries
8882 per task. The bounds of every entry family
8883 of a task unit shall be static, or shall be
8884 defined by a discriminant of a subtype whose
8885 corresponding bound is static.
8888 @unnumberedsubsec Max_Tasks
8890 [RM D.7] Specifies the maximum number of task that may be created, not
8891 counting the creation of the environment task. Violations of this
8892 restriction with a value of zero are detected at compile
8893 time. Violations of this restriction with values other than zero cause
8894 Storage_Error to be raised.
8896 @node No_Abort_Statements
8897 @unnumberedsubsec No_Abort_Statements
8898 @findex No_Abort_Statements
8899 [RM D.7] There are no abort_statements, and there are
8900 no calls to Task_Identification.Abort_Task.
8902 @node No_Access_Parameter_Allocators
8903 @unnumberedsubsec No_Access_Parameter_Allocators
8904 @findex No_Access_Parameter_Allocators
8905 [RM H.4] This restriction ensures at compile time that there are no
8906 occurrences of an allocator as the actual parameter to an access
8909 @node No_Access_Subprograms
8910 @unnumberedsubsec No_Access_Subprograms
8911 @findex No_Access_Subprograms
8912 [RM H.4] This restriction ensures at compile time that there are no
8913 declarations of access-to-subprogram types.
8916 @unnumberedsubsec No_Allocators
8917 @findex No_Allocators
8918 [RM H.4] This restriction ensures at compile time that there are no
8919 occurrences of an allocator.
8921 @node No_Anonymous_Allocators
8922 @unnumberedsubsec No_Anonymous_Allocators
8923 @findex No_Anonymous_Allocators
8924 [RM H.4] This restriction ensures at compile time that there are no
8925 occurrences of an allocator of anonymous access type.
8928 @unnumberedsubsec No_Calendar
8930 [GNAT] This restriction ensures at compile time that there is no implicit or
8931 explicit dependence on the package @code{Ada.Calendar}.
8933 @node No_Coextensions
8934 @unnumberedsubsec No_Coextensions
8935 @findex No_Coextensions
8936 [RM H.4] This restriction ensures at compile time that there are no
8937 coextensions. See 3.10.2.
8939 @node No_Default_Initialization
8940 @unnumberedsubsec No_Default_Initialization
8941 @findex No_Default_Initialization
8943 [GNAT] This restriction prohibits any instance of default initialization
8944 of variables. The binder implements a consistency rule which prevents
8945 any unit compiled without the restriction from with'ing a unit with the
8946 restriction (this allows the generation of initialization procedures to
8947 be skipped, since you can be sure that no call is ever generated to an
8948 initialization procedure in a unit with the restriction active). If used
8949 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
8950 is to prohibit all cases of variables declared without a specific
8951 initializer (including the case of OUT scalar parameters).
8954 @unnumberedsubsec No_Delay
8956 [RM H.4] This restriction ensures at compile time that there are no
8957 delay statements and no dependences on package Calendar.
8960 @unnumberedsubsec No_Dependence
8961 @findex No_Dependence
8962 [RM 13.12.1] This restriction checks at compile time that there are no
8963 dependence on a library unit.
8965 @node No_Direct_Boolean_Operators
8966 @unnumberedsubsec No_Direct_Boolean_Operators
8967 @findex No_Direct_Boolean_Operators
8968 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
8969 operands of type Boolean (or any type derived
8970 from Boolean). This is intended for use in safety critical programs
8971 where the certification protocol requires the use of short-circuit
8972 (and then, or else) forms for all composite boolean operations.
8975 @unnumberedsubsec No_Dispatch
8977 [RM H.4] This restriction ensures at compile time that there are no
8978 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
8980 @node No_Dispatching_Calls
8981 @unnumberedsubsec No_Dispatching_Calls
8982 @findex No_Dispatching_Calls
8983 [GNAT] This restriction ensures at compile time that the code generated by the
8984 compiler involves no dispatching calls. The use of this restriction allows the
8985 safe use of record extensions, classwide membership tests and other classwide
8986 features not involving implicit dispatching. This restriction ensures that
8987 the code contains no indirect calls through a dispatching mechanism. Note that
8988 this includes internally-generated calls created by the compiler, for example
8989 in the implementation of class-wide objects assignments. The
8990 membership test is allowed in the presence of this restriction, because its
8991 implementation requires no dispatching.
8992 This restriction is comparable to the official Ada restriction
8993 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8994 all classwide constructs that do not imply dispatching.
8995 The following example indicates constructs that violate this restriction.
8999 type T is tagged record
9002 procedure P (X : T);
9004 type DT is new T with record
9005 More_Data : Natural;
9007 procedure Q (X : DT);
9011 procedure Example is
9012 procedure Test (O : T'Class) is
9013 N : Natural := O'Size;-- Error: Dispatching call
9014 C : T'Class := O; -- Error: implicit Dispatching Call
9016 if O in DT'Class then -- OK : Membership test
9017 Q (DT (O)); -- OK : Type conversion plus direct call
9019 P (O); -- Error: Dispatching call
9025 P (Obj); -- OK : Direct call
9026 P (T (Obj)); -- OK : Type conversion plus direct call
9027 P (T'Class (Obj)); -- Error: Dispatching call
9029 Test (Obj); -- OK : Type conversion
9031 if Obj in T'Class then -- OK : Membership test
9037 @node No_Dynamic_Attachment
9038 @unnumberedsubsec No_Dynamic_Attachment
9039 @findex No_Dynamic_Attachment
9040 [RM D.7] This restriction ensures that there is no call to any of the
9041 operations defined in package Ada.Interrupts
9042 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9043 Detach_Handler, and Reference).
9045 @node No_Dynamic_Priorities
9046 @unnumberedsubsec No_Dynamic_Priorities
9047 @findex No_Dynamic_Priorities
9048 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9050 @node No_Entry_Calls_In_Elaboration_Code
9051 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9052 @findex No_Entry_Calls_In_Elaboration_Code
9053 [GNAT] This restriction ensures at compile time that no task or protected entry
9054 calls are made during elaboration code. As a result of the use of this
9055 restriction, the compiler can assume that no code past an accept statement
9056 in a task can be executed at elaboration time.
9058 @node No_Enumeration_Maps
9059 @unnumberedsubsec No_Enumeration_Maps
9060 @findex No_Enumeration_Maps
9061 [GNAT] This restriction ensures at compile time that no operations requiring
9062 enumeration maps are used (that is Image and Value attributes applied
9063 to enumeration types).
9065 @node No_Exception_Handlers
9066 @unnumberedsubsec No_Exception_Handlers
9067 @findex No_Exception_Handlers
9068 [GNAT] This restriction ensures at compile time that there are no explicit
9069 exception handlers. It also indicates that no exception propagation will
9070 be provided. In this mode, exceptions may be raised but will result in
9071 an immediate call to the last chance handler, a routine that the user
9072 must define with the following profile:
9074 @smallexample @c ada
9075 procedure Last_Chance_Handler
9076 (Source_Location : System.Address; Line : Integer);
9077 pragma Export (C, Last_Chance_Handler,
9078 "__gnat_last_chance_handler");
9081 The parameter is a C null-terminated string representing a message to be
9082 associated with the exception (typically the source location of the raise
9083 statement generated by the compiler). The Line parameter when nonzero
9084 represents the line number in the source program where the raise occurs.
9086 @node No_Exception_Propagation
9087 @unnumberedsubsec No_Exception_Propagation
9088 @findex No_Exception_Propagation
9089 [GNAT] This restriction guarantees that exceptions are never propagated
9090 to an outer subprogram scope. The only case in which an exception may
9091 be raised is when the handler is statically in the same subprogram, so
9092 that the effect of a raise is essentially like a goto statement. Any
9093 other raise statement (implicit or explicit) will be considered
9094 unhandled. Exception handlers are allowed, but may not contain an
9095 exception occurrence identifier (exception choice). In addition, use of
9096 the package GNAT.Current_Exception is not permitted, and reraise
9097 statements (raise with no operand) are not permitted.
9099 @node No_Exception_Registration
9100 @unnumberedsubsec No_Exception_Registration
9101 @findex No_Exception_Registration
9102 [GNAT] This restriction ensures at compile time that no stream operations for
9103 types Exception_Id or Exception_Occurrence are used. This also makes it
9104 impossible to pass exceptions to or from a partition with this restriction
9105 in a distributed environment. If this exception is active, then the generated
9106 code is simplified by omitting the otherwise-required global registration
9107 of exceptions when they are declared.
9110 @unnumberedsubsec No_Exceptions
9111 @findex No_Exceptions
9112 [RM H.4] This restriction ensures at compile time that there are no
9113 raise statements and no exception handlers.
9115 @node No_Finalization
9116 @unnumberedsubsec No_Finalization
9117 @findex No_Finalization
9118 [GNAT] This restriction disables the language features described in
9119 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9120 performed by the compiler to support these features. The following types
9121 are no longer considered controlled when this restriction is in effect:
9124 @code{Ada.Finalization.Controlled}
9126 @code{Ada.Finalization.Limited_Controlled}
9128 Derivations from @code{Controlled} or @code{Limited_Controlled}
9136 Array and record types with controlled components
9138 The compiler no longer generates code to initialize, finalize or adjust an
9139 object or a nested component, either declared on the stack or on the heap. The
9140 deallocation of a controlled object no longer finalizes its contents.
9142 @node No_Fixed_Point
9143 @unnumberedsubsec No_Fixed_Point
9144 @findex No_Fixed_Point
9145 [RM H.4] This restriction ensures at compile time that there are no
9146 occurrences of fixed point types and operations.
9148 @node No_Floating_Point
9149 @unnumberedsubsec No_Floating_Point
9150 @findex No_Floating_Point
9151 [RM H.4] This restriction ensures at compile time that there are no
9152 occurrences of floating point types and operations.
9154 @node No_Implicit_Conditionals
9155 @unnumberedsubsec No_Implicit_Conditionals
9156 @findex No_Implicit_Conditionals
9157 [GNAT] This restriction ensures that the generated code does not contain any
9158 implicit conditionals, either by modifying the generated code where possible,
9159 or by rejecting any construct that would otherwise generate an implicit
9160 conditional. Note that this check does not include run time constraint
9161 checks, which on some targets may generate implicit conditionals as
9162 well. To control the latter, constraint checks can be suppressed in the
9163 normal manner. Constructs generating implicit conditionals include comparisons
9164 of composite objects and the Max/Min attributes.
9166 @node No_Implicit_Dynamic_Code
9167 @unnumberedsubsec No_Implicit_Dynamic_Code
9168 @findex No_Implicit_Dynamic_Code
9170 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9171 This is a structure that is built on the stack and contains dynamic
9172 code to be executed at run time. On some targets, a trampoline is
9173 built for the following features: @code{Access},
9174 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9175 nested task bodies; primitive operations of nested tagged types.
9176 Trampolines do not work on machines that prevent execution of stack
9177 data. For example, on windows systems, enabling DEP (data execution
9178 protection) will cause trampolines to raise an exception.
9179 Trampolines are also quite slow at run time.
9181 On many targets, trampolines have been largely eliminated. Look at the
9182 version of system.ads for your target --- if it has
9183 Always_Compatible_Rep equal to False, then trampolines are largely
9184 eliminated. In particular, a trampoline is built for the following
9185 features: @code{Address} of a nested subprogram;
9186 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9187 but only if pragma Favor_Top_Level applies, or the access type has a
9188 foreign-language convention; primitive operations of nested tagged
9191 @node No_Implicit_Heap_Allocations
9192 @unnumberedsubsec No_Implicit_Heap_Allocations
9193 @findex No_Implicit_Heap_Allocations
9194 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9196 @node No_Implicit_Loops
9197 @unnumberedsubsec No_Implicit_Loops
9198 @findex No_Implicit_Loops
9199 [GNAT] This restriction ensures that the generated code does not contain any
9200 implicit @code{for} loops, either by modifying
9201 the generated code where possible,
9202 or by rejecting any construct that would otherwise generate an implicit
9203 @code{for} loop. If this restriction is active, it is possible to build
9204 large array aggregates with all static components without generating an
9205 intermediate temporary, and without generating a loop to initialize individual
9206 components. Otherwise, a loop is created for arrays larger than about 5000
9209 @node No_Initialize_Scalars
9210 @unnumberedsubsec No_Initialize_Scalars
9211 @findex No_Initialize_Scalars
9212 [GNAT] This restriction ensures that no unit in the partition is compiled with
9213 pragma Initialize_Scalars. This allows the generation of more efficient
9214 code, and in particular eliminates dummy null initialization routines that
9215 are otherwise generated for some record and array types.
9218 @unnumberedsubsec No_IO
9220 [RM H.4] This restriction ensures at compile time that there are no
9221 dependences on any of the library units Sequential_IO, Direct_IO,
9222 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9224 @node No_Local_Allocators
9225 @unnumberedsubsec No_Local_Allocators
9226 @findex No_Local_Allocators
9227 [RM H.4] This restriction ensures at compile time that there are no
9228 occurrences of an allocator in subprograms, generic subprograms, tasks,
9231 @node No_Local_Protected_Objects
9232 @unnumberedsubsec No_Local_Protected_Objects
9233 @findex No_Local_Protected_Objects
9234 [RM D.7] This restriction ensures at compile time that protected objects are
9235 only declared at the library level.
9237 @node No_Local_Timing_Events
9238 @unnumberedsubsec No_Local_Timing_Events
9239 @findex No_Local_Timing_Events
9240 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9241 declared at the library level.
9243 @node No_Nested_Finalization
9244 @unnumberedsubsec No_Nested_Finalization
9245 @findex No_Nested_Finalization
9246 [RM D.7] All objects requiring finalization are declared at the library level.
9248 @node No_Protected_Type_Allocators
9249 @unnumberedsubsec No_Protected_Type_Allocators
9250 @findex No_Protected_Type_Allocators
9251 [RM D.7] This restriction ensures at compile time that there are no allocator
9252 expressions that attempt to allocate protected objects.
9254 @node No_Protected_Types
9255 @unnumberedsubsec No_Protected_Types
9256 @findex No_Protected_Types
9257 [RM H.4] This restriction ensures at compile time that there are no
9258 declarations of protected types or protected objects.
9261 @unnumberedsubsec No_Recursion
9262 @findex No_Recursion
9263 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9264 part of its execution.
9267 @unnumberedsubsec No_Reentrancy
9268 @findex No_Reentrancy
9269 [RM H.4] A program execution is erroneous if a subprogram is executed by
9270 two tasks at the same time.
9272 @node No_Relative_Delay
9273 @unnumberedsubsec No_Relative_Delay
9274 @findex No_Relative_Delay
9275 [RM D.7] This restriction ensures at compile time that there are no delay
9276 relative statements and prevents expressions such as @code{delay 1.23;} from
9277 appearing in source code.
9279 @node No_Requeue_Statements
9280 @unnumberedsubsec No_Requeue_Statements
9281 @findex No_Requeue_Statements
9282 [RM D.7] This restriction ensures at compile time that no requeue statements
9283 are permitted and prevents keyword @code{requeue} from being used in source
9286 @node No_Secondary_Stack
9287 @unnumberedsubsec No_Secondary_Stack
9288 @findex No_Secondary_Stack
9289 [GNAT] This restriction ensures at compile time that the generated code
9290 does not contain any reference to the secondary stack. The secondary
9291 stack is used to implement functions returning unconstrained objects
9292 (arrays or records) on some targets.
9294 @node No_Select_Statements
9295 @unnumberedsubsec No_Select_Statements
9296 @findex No_Select_Statements
9297 [RM D.7] This restriction ensures at compile time no select statements of any
9298 kind are permitted, that is the keyword @code{select} may not appear.
9300 @node No_Specific_Termination_Handlers
9301 @unnumberedsubsec No_Specific_Termination_Handlers
9302 @findex No_Specific_Termination_Handlers
9303 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9304 or to Ada.Task_Termination.Specific_Handler.
9306 @node No_Specification_of_Aspect
9307 @unnumberedsubsec No_Specification_of_Aspect
9308 @findex No_Specification_of_Aspect
9309 [RM 13.12.1] This restriction checks at compile time that no aspect
9310 specification, attribute definition clause, or pragma is given for a
9313 @node No_Standard_Allocators_After_Elaboration
9314 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9315 @findex No_Standard_Allocators_After_Elaboration
9316 [RM D.7] Specifies that an allocator using a standard storage pool
9317 should never be evaluated at run time after the elaboration of the
9318 library items of the partition has completed. Otherwise, Storage_Error
9321 @node No_Standard_Storage_Pools
9322 @unnumberedsubsec No_Standard_Storage_Pools
9323 @findex No_Standard_Storage_Pools
9324 [GNAT] This restriction ensures at compile time that no access types
9325 use the standard default storage pool. Any access type declared must
9326 have an explicit Storage_Pool attribute defined specifying a
9327 user-defined storage pool.
9329 @node No_Stream_Optimizations
9330 @unnumberedsubsec No_Stream_Optimizations
9331 @findex No_Stream_Optimizations
9332 [GNAT] This restriction affects the performance of stream operations on types
9333 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9334 compiler uses block reads and writes when manipulating @code{String} objects
9335 due to their supperior performance. When this restriction is in effect, the
9336 compiler performs all IO operations on a per-character basis.
9339 @unnumberedsubsec No_Streams
9341 [GNAT] This restriction ensures at compile/bind time that there are no
9342 stream objects created and no use of stream attributes.
9343 This restriction does not forbid dependences on the package
9344 @code{Ada.Streams}. So it is permissible to with
9345 @code{Ada.Streams} (or another package that does so itself)
9346 as long as no actual stream objects are created and no
9347 stream attributes are used.
9349 Note that the use of restriction allows optimization of tagged types,
9350 since they do not need to worry about dispatching stream operations.
9351 To take maximum advantage of this space-saving optimization, any
9352 unit declaring a tagged type should be compiled with the restriction,
9353 though this is not required.
9355 @node No_Task_Allocators
9356 @unnumberedsubsec No_Task_Allocators
9357 @findex No_Task_Allocators
9358 [RM D.7] There are no allocators for task types
9359 or types containing task subcomponents.
9361 @node No_Task_Attributes_Package
9362 @unnumberedsubsec No_Task_Attributes_Package
9363 @findex No_Task_Attributes_Package
9364 [GNAT] This restriction ensures at compile time that there are no implicit or
9365 explicit dependencies on the package @code{Ada.Task_Attributes}.
9367 @node No_Task_Hierarchy
9368 @unnumberedsubsec No_Task_Hierarchy
9369 @findex No_Task_Hierarchy
9370 [RM D.7] All (non-environment) tasks depend
9371 directly on the environment task of the partition.
9373 @node No_Task_Termination
9374 @unnumberedsubsec No_Task_Termination
9375 @findex No_Task_Termination
9376 [RM D.7] Tasks which terminate are erroneous.
9379 @unnumberedsubsec No_Tasking
9381 [GNAT] This restriction prevents the declaration of tasks or task types
9382 throughout the partition. It is similar in effect to the use of
9383 @code{Max_Tasks => 0} except that violations are caught at compile time
9384 and cause an error message to be output either by the compiler or
9387 @node No_Terminate_Alternatives
9388 @unnumberedsubsec No_Terminate_Alternatives
9389 @findex No_Terminate_Alternatives
9390 [RM D.7] There are no selective accepts with terminate alternatives.
9392 @node No_Unchecked_Access
9393 @unnumberedsubsec No_Unchecked_Access
9394 @findex No_Unchecked_Access
9395 [RM H.4] This restriction ensures at compile time that there are no
9396 occurrences of the Unchecked_Access attribute.
9398 @node Simple_Barriers
9399 @unnumberedsubsec Simple_Barriers
9400 @findex Simple_Barriers
9401 [RM D.7] This restriction ensures at compile time that barriers in entry
9402 declarations for protected types are restricted to either static boolean
9403 expressions or references to simple boolean variables defined in the private
9404 part of the protected type. No other form of entry barriers is permitted.
9406 @node Static_Priorities
9407 @unnumberedsubsec Static_Priorities
9408 @findex Static_Priorities
9409 [GNAT] This restriction ensures at compile time that all priority expressions
9410 are static, and that there are no dependences on the package
9411 @code{Ada.Dynamic_Priorities}.
9413 @node Static_Storage_Size
9414 @unnumberedsubsec Static_Storage_Size
9415 @findex Static_Storage_Size
9416 [GNAT] This restriction ensures at compile time that any expression appearing
9417 in a Storage_Size pragma or attribute definition clause is static.
9419 @node Program Unit Level Restrictions
9420 @section Program Unit Level Restrictions
9423 The second set of restriction identifiers
9424 does not require partition-wide consistency.
9425 The restriction may be enforced for a single
9426 compilation unit without any effect on any of the
9427 other compilation units in the partition.
9430 * No_Elaboration_Code::
9432 * No_Implementation_Aspect_Specifications::
9433 * No_Implementation_Attributes::
9434 * No_Implementation_Identifiers::
9435 * No_Implementation_Pragmas::
9436 * No_Implementation_Restrictions::
9437 * No_Implementation_Units::
9438 * No_Implicit_Aliasing::
9439 * No_Obsolescent_Features::
9440 * No_Wide_Characters::
9444 @node No_Elaboration_Code
9445 @unnumberedsubsec No_Elaboration_Code
9446 @findex No_Elaboration_Code
9447 [GNAT] This restriction ensures at compile time that no elaboration code is
9448 generated. Note that this is not the same condition as is enforced
9449 by pragma @code{Preelaborate}. There are cases in which pragma
9450 @code{Preelaborate} still permits code to be generated (e.g.@: code
9451 to initialize a large array to all zeroes), and there are cases of units
9452 which do not meet the requirements for pragma @code{Preelaborate},
9453 but for which no elaboration code is generated. Generally, it is
9454 the case that preelaborable units will meet the restrictions, with
9455 the exception of large aggregates initialized with an others_clause,
9456 and exception declarations (which generate calls to a run-time
9457 registry procedure). This restriction is enforced on
9458 a unit by unit basis, it need not be obeyed consistently
9459 throughout a partition.
9461 In the case of aggregates with others, if the aggregate has a dynamic
9462 size, there is no way to eliminate the elaboration code (such dynamic
9463 bounds would be incompatible with @code{Preelaborate} in any case). If
9464 the bounds are static, then use of this restriction actually modifies
9465 the code choice of the compiler to avoid generating a loop, and instead
9466 generate the aggregate statically if possible, no matter how many times
9467 the data for the others clause must be repeatedly generated.
9469 It is not possible to precisely document
9470 the constructs which are compatible with this restriction, since,
9471 unlike most other restrictions, this is not a restriction on the
9472 source code, but a restriction on the generated object code. For
9473 example, if the source contains a declaration:
9476 Val : constant Integer := X;
9480 where X is not a static constant, it may be possible, depending
9481 on complex optimization circuitry, for the compiler to figure
9482 out the value of X at compile time, in which case this initialization
9483 can be done by the loader, and requires no initialization code. It
9484 is not possible to document the precise conditions under which the
9485 optimizer can figure this out.
9487 Note that this the implementation of this restriction requires full
9488 code generation. If it is used in conjunction with "semantics only"
9489 checking, then some cases of violations may be missed.
9491 @node No_Entry_Queue
9492 @unnumberedsubsec No_Entry_Queue
9493 @findex No_Entry_Queue
9494 [GNAT] This restriction is a declaration that any protected entry compiled in
9495 the scope of the restriction has at most one task waiting on the entry
9496 at any one time, and so no queue is required. This restriction is not
9497 checked at compile time. A program execution is erroneous if an attempt
9498 is made to queue a second task on such an entry.
9500 @node No_Implementation_Aspect_Specifications
9501 @unnumberedsubsec No_Implementation_Aspect_Specifications
9502 @findex No_Implementation_Aspect_Specifications
9503 [RM 13.12.1] This restriction checks at compile time that no
9504 GNAT-defined aspects are present. With this restriction, the only
9505 aspects that can be used are those defined in the Ada Reference Manual.
9507 @node No_Implementation_Attributes
9508 @unnumberedsubsec No_Implementation_Attributes
9509 @findex No_Implementation_Attributes
9510 [RM 13.12.1] This restriction checks at compile time that no
9511 GNAT-defined attributes are present. With this restriction, the only
9512 attributes that can be used are those defined in the Ada Reference
9515 @node No_Implementation_Identifiers
9516 @unnumberedsubsec No_Implementation_Identifiers
9517 @findex No_Implementation_Identifiers
9518 [RM 13.12.1] This restriction checks at compile time that no
9519 implementation-defined identifiers (marked with pragma Implementation_Defined)
9520 occur within language-defined packages.
9522 @node No_Implementation_Pragmas
9523 @unnumberedsubsec No_Implementation_Pragmas
9524 @findex No_Implementation_Pragmas
9525 [RM 13.12.1] This restriction checks at compile time that no
9526 GNAT-defined pragmas are present. With this restriction, the only
9527 pragmas that can be used are those defined in the Ada Reference Manual.
9529 @node No_Implementation_Restrictions
9530 @unnumberedsubsec No_Implementation_Restrictions
9531 @findex No_Implementation_Restrictions
9532 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
9533 identifiers (other than @code{No_Implementation_Restrictions} itself)
9534 are present. With this restriction, the only other restriction identifiers
9535 that can be used are those defined in the Ada Reference Manual.
9537 @node No_Implementation_Units
9538 @unnumberedsubsec No_Implementation_Units
9539 @findex No_Implementation_Units
9540 [RM 13.12.1] This restriction checks at compile time that there is no
9541 mention in the context clause of any implementation-defined descendants
9542 of packages Ada, Interfaces, or System.
9544 @node No_Implicit_Aliasing
9545 @unnumberedsubsec No_Implicit_Aliasing
9546 @findex No_Implicit_Aliasing
9547 [GNAT] This restriction, which is not required to be partition-wide consistent,
9548 requires an explicit aliased keyword for an object to which 'Access,
9549 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9550 the 'Unrestricted_Access attribute for objects. Note: the reason that
9551 Unrestricted_Access is forbidden is that it would require the prefix
9552 to be aliased, and in such cases, it can always be replaced by
9553 the standard attribute Unchecked_Access which is preferable.
9555 @node No_Obsolescent_Features
9556 @unnumberedsubsec No_Obsolescent_Features
9557 @findex No_Obsolescent_Features
9558 [RM 13.12.1] This restriction checks at compile time that no obsolescent
9559 features are used, as defined in Annex J of the Ada Reference Manual.
9561 @node No_Wide_Characters
9562 @unnumberedsubsec No_Wide_Characters
9563 @findex No_Wide_Characters
9564 [GNAT] This restriction ensures at compile time that no uses of the types
9565 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9567 appear, and that no wide or wide wide string or character literals
9568 appear in the program (that is literals representing characters not in
9569 type @code{Character}).
9572 @unnumberedsubsec SPARK
9574 [GNAT] This restriction checks at compile time that some constructs
9575 forbidden in SPARK 2005 are not present. Error messages related to
9576 SPARK restriction have the form:
9579 violation of restriction "SPARK" at <file>
9583 This is not a replacement for the semantic checks performed by the
9584 SPARK Examiner tool, as the compiler only deals currently with code,
9585 not at all with SPARK 2005 annotations and does not guarantee catching all
9586 cases of constructs forbidden by SPARK 2005.
9588 Thus it may well be the case that code which passes the compiler with
9589 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
9590 the different visibility rules of the Examiner based on SPARK 2005
9591 @code{inherit} annotations.
9593 This restriction can be useful in providing an initial filter for code
9594 developed using SPARK 2005, or in examining legacy code to see how far
9595 it is from meeting SPARK restrictions.
9597 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
9598 violations will be reported for constructs forbidden in SPARK 95,
9599 instead of SPARK 2005.
9601 @c ------------------------
9602 @node Implementation Advice
9603 @chapter Implementation Advice
9605 The main text of the Ada Reference Manual describes the required
9606 behavior of all Ada compilers, and the GNAT compiler conforms to
9609 In addition, there are sections throughout the Ada Reference Manual headed
9610 by the phrase ``Implementation advice''. These sections are not normative,
9611 i.e., they do not specify requirements that all compilers must
9612 follow. Rather they provide advice on generally desirable behavior. You
9613 may wonder why they are not requirements. The most typical answer is
9614 that they describe behavior that seems generally desirable, but cannot
9615 be provided on all systems, or which may be undesirable on some systems.
9617 As far as practical, GNAT follows the implementation advice sections in
9618 the Ada Reference Manual. This chapter contains a table giving the
9619 reference manual section number, paragraph number and several keywords
9620 for each advice. Each entry consists of the text of the advice followed
9621 by the GNAT interpretation of this advice. Most often, this simply says
9622 ``followed'', which means that GNAT follows the advice. However, in a
9623 number of cases, GNAT deliberately deviates from this advice, in which
9624 case the text describes what GNAT does and why.
9626 @cindex Error detection
9627 @unnumberedsec 1.1.3(20): Error Detection
9630 If an implementation detects the use of an unsupported Specialized Needs
9631 Annex feature at run time, it should raise @code{Program_Error} if
9634 Not relevant. All specialized needs annex features are either supported,
9635 or diagnosed at compile time.
9638 @unnumberedsec 1.1.3(31): Child Units
9641 If an implementation wishes to provide implementation-defined
9642 extensions to the functionality of a language-defined library unit, it
9643 should normally do so by adding children to the library unit.
9647 @cindex Bounded errors
9648 @unnumberedsec 1.1.5(12): Bounded Errors
9651 If an implementation detects a bounded error or erroneous
9652 execution, it should raise @code{Program_Error}.
9654 Followed in all cases in which the implementation detects a bounded
9655 error or erroneous execution. Not all such situations are detected at
9659 @unnumberedsec 2.8(16): Pragmas
9662 Normally, implementation-defined pragmas should have no semantic effect
9663 for error-free programs; that is, if the implementation-defined pragmas
9664 are removed from a working program, the program should still be legal,
9665 and should still have the same semantics.
9667 The following implementation defined pragmas are exceptions to this
9679 @item CPP_Constructor
9683 @item Interface_Name
9685 @item Machine_Attribute
9687 @item Unimplemented_Unit
9689 @item Unchecked_Union
9694 In each of the above cases, it is essential to the purpose of the pragma
9695 that this advice not be followed. For details see the separate section
9696 on implementation defined pragmas.
9698 @unnumberedsec 2.8(17-19): Pragmas
9701 Normally, an implementation should not define pragmas that can
9702 make an illegal program legal, except as follows:
9706 A pragma used to complete a declaration, such as a pragma @code{Import};
9710 A pragma used to configure the environment by adding, removing, or
9711 replacing @code{library_items}.
9713 See response to paragraph 16 of this same section.
9715 @cindex Character Sets
9716 @cindex Alternative Character Sets
9717 @unnumberedsec 3.5.2(5): Alternative Character Sets
9720 If an implementation supports a mode with alternative interpretations
9721 for @code{Character} and @code{Wide_Character}, the set of graphic
9722 characters of @code{Character} should nevertheless remain a proper
9723 subset of the set of graphic characters of @code{Wide_Character}. Any
9724 character set ``localizations'' should be reflected in the results of
9725 the subprograms defined in the language-defined package
9726 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
9727 an alternative interpretation of @code{Character}, the implementation should
9728 also support a corresponding change in what is a legal
9729 @code{identifier_letter}.
9731 Not all wide character modes follow this advice, in particular the JIS
9732 and IEC modes reflect standard usage in Japan, and in these encoding,
9733 the upper half of the Latin-1 set is not part of the wide-character
9734 subset, since the most significant bit is used for wide character
9735 encoding. However, this only applies to the external forms. Internally
9736 there is no such restriction.
9738 @cindex Integer types
9739 @unnumberedsec 3.5.4(28): Integer Types
9743 An implementation should support @code{Long_Integer} in addition to
9744 @code{Integer} if the target machine supports 32-bit (or longer)
9745 arithmetic. No other named integer subtypes are recommended for package
9746 @code{Standard}. Instead, appropriate named integer subtypes should be
9747 provided in the library package @code{Interfaces} (see B.2).
9749 @code{Long_Integer} is supported. Other standard integer types are supported
9750 so this advice is not fully followed. These types
9751 are supported for convenient interface to C, and so that all hardware
9752 types of the machine are easily available.
9753 @unnumberedsec 3.5.4(29): Integer Types
9757 An implementation for a two's complement machine should support
9758 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
9759 implementation should support a non-binary modules up to @code{Integer'Last}.
9763 @cindex Enumeration values
9764 @unnumberedsec 3.5.5(8): Enumeration Values
9767 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
9768 subtype, if the value of the operand does not correspond to the internal
9769 code for any enumeration literal of its type (perhaps due to an
9770 un-initialized variable), then the implementation should raise
9771 @code{Program_Error}. This is particularly important for enumeration
9772 types with noncontiguous internal codes specified by an
9773 enumeration_representation_clause.
9778 @unnumberedsec 3.5.7(17): Float Types
9781 An implementation should support @code{Long_Float} in addition to
9782 @code{Float} if the target machine supports 11 or more digits of
9783 precision. No other named floating point subtypes are recommended for
9784 package @code{Standard}. Instead, appropriate named floating point subtypes
9785 should be provided in the library package @code{Interfaces} (see B.2).
9787 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
9788 former provides improved compatibility with other implementations
9789 supporting this type. The latter corresponds to the highest precision
9790 floating-point type supported by the hardware. On most machines, this
9791 will be the same as @code{Long_Float}, but on some machines, it will
9792 correspond to the IEEE extended form. The notable case is all ia32
9793 (x86) implementations, where @code{Long_Long_Float} corresponds to
9794 the 80-bit extended precision format supported in hardware on this
9795 processor. Note that the 128-bit format on SPARC is not supported,
9796 since this is a software rather than a hardware format.
9798 @cindex Multidimensional arrays
9799 @cindex Arrays, multidimensional
9800 @unnumberedsec 3.6.2(11): Multidimensional Arrays
9803 An implementation should normally represent multidimensional arrays in
9804 row-major order, consistent with the notation used for multidimensional
9805 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
9806 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
9807 column-major order should be used instead (see B.5, ``Interfacing with
9812 @findex Duration'Small
9813 @unnumberedsec 9.6(30-31): Duration'Small
9816 Whenever possible in an implementation, the value of @code{Duration'Small}
9817 should be no greater than 100 microseconds.
9819 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
9823 The time base for @code{delay_relative_statements} should be monotonic;
9824 it need not be the same time base as used for @code{Calendar.Clock}.
9828 @unnumberedsec 10.2.1(12): Consistent Representation
9831 In an implementation, a type declared in a pre-elaborated package should
9832 have the same representation in every elaboration of a given version of
9833 the package, whether the elaborations occur in distinct executions of
9834 the same program, or in executions of distinct programs or partitions
9835 that include the given version.
9837 Followed, except in the case of tagged types. Tagged types involve
9838 implicit pointers to a local copy of a dispatch table, and these pointers
9839 have representations which thus depend on a particular elaboration of the
9840 package. It is not easy to see how it would be possible to follow this
9841 advice without severely impacting efficiency of execution.
9843 @cindex Exception information
9844 @unnumberedsec 11.4.1(19): Exception Information
9847 @code{Exception_Message} by default and @code{Exception_Information}
9848 should produce information useful for
9849 debugging. @code{Exception_Message} should be short, about one
9850 line. @code{Exception_Information} can be long. @code{Exception_Message}
9851 should not include the
9852 @code{Exception_Name}. @code{Exception_Information} should include both
9853 the @code{Exception_Name} and the @code{Exception_Message}.
9855 Followed. For each exception that doesn't have a specified
9856 @code{Exception_Message}, the compiler generates one containing the location
9857 of the raise statement. This location has the form ``file:line'', where
9858 file is the short file name (without path information) and line is the line
9859 number in the file. Note that in the case of the Zero Cost Exception
9860 mechanism, these messages become redundant with the Exception_Information that
9861 contains a full backtrace of the calling sequence, so they are disabled.
9862 To disable explicitly the generation of the source location message, use the
9863 Pragma @code{Discard_Names}.
9865 @cindex Suppression of checks
9866 @cindex Checks, suppression of
9867 @unnumberedsec 11.5(28): Suppression of Checks
9870 The implementation should minimize the code executed for checks that
9871 have been suppressed.
9875 @cindex Representation clauses
9876 @unnumberedsec 13.1 (21-24): Representation Clauses
9879 The recommended level of support for all representation items is
9880 qualified as follows:
9884 An implementation need not support representation items containing
9885 non-static expressions, except that an implementation should support a
9886 representation item for a given entity if each non-static expression in
9887 the representation item is a name that statically denotes a constant
9888 declared before the entity.
9890 Followed. In fact, GNAT goes beyond the recommended level of support
9891 by allowing nonstatic expressions in some representation clauses even
9892 without the need to declare constants initialized with the values of
9896 @smallexample @c ada
9899 for Y'Address use X'Address;>>
9904 An implementation need not support a specification for the @code{Size}
9905 for a given composite subtype, nor the size or storage place for an
9906 object (including a component) of a given composite subtype, unless the
9907 constraints on the subtype and its composite subcomponents (if any) are
9908 all static constraints.
9910 Followed. Size Clauses are not permitted on non-static components, as
9915 An aliased component, or a component whose type is by-reference, should
9916 always be allocated at an addressable location.
9920 @cindex Packed types
9921 @unnumberedsec 13.2(6-8): Packed Types
9924 If a type is packed, then the implementation should try to minimize
9925 storage allocated to objects of the type, possibly at the expense of
9926 speed of accessing components, subject to reasonable complexity in
9927 addressing calculations.
9931 The recommended level of support pragma @code{Pack} is:
9933 For a packed record type, the components should be packed as tightly as
9934 possible subject to the Sizes of the component subtypes, and subject to
9935 any @code{record_representation_clause} that applies to the type; the
9936 implementation may, but need not, reorder components or cross aligned
9937 word boundaries to improve the packing. A component whose @code{Size} is
9938 greater than the word size may be allocated an integral number of words.
9940 Followed. Tight packing of arrays is supported for all component sizes
9941 up to 64-bits. If the array component size is 1 (that is to say, if
9942 the component is a boolean type or an enumeration type with two values)
9943 then values of the type are implicitly initialized to zero. This
9944 happens both for objects of the packed type, and for objects that have a
9945 subcomponent of the packed type.
9949 An implementation should support Address clauses for imported
9953 @cindex @code{Address} clauses
9954 @unnumberedsec 13.3(14-19): Address Clauses
9958 For an array @var{X}, @code{@var{X}'Address} should point at the first
9959 component of the array, and not at the array bounds.
9965 The recommended level of support for the @code{Address} attribute is:
9967 @code{@var{X}'Address} should produce a useful result if @var{X} is an
9968 object that is aliased or of a by-reference type, or is an entity whose
9969 @code{Address} has been specified.
9971 Followed. A valid address will be produced even if none of those
9972 conditions have been met. If necessary, the object is forced into
9973 memory to ensure the address is valid.
9977 An implementation should support @code{Address} clauses for imported
9984 Objects (including subcomponents) that are aliased or of a by-reference
9985 type should be allocated on storage element boundaries.
9991 If the @code{Address} of an object is specified, or it is imported or exported,
9992 then the implementation should not perform optimizations based on
9993 assumptions of no aliases.
9997 @cindex @code{Alignment} clauses
9998 @unnumberedsec 13.3(29-35): Alignment Clauses
10001 The recommended level of support for the @code{Alignment} attribute for
10004 An implementation should support specified Alignments that are factors
10005 and multiples of the number of storage elements per word, subject to the
10012 An implementation need not support specified @code{Alignment}s for
10013 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10014 loaded and stored by available machine instructions.
10020 An implementation need not support specified @code{Alignment}s that are
10021 greater than the maximum @code{Alignment} the implementation ever returns by
10028 The recommended level of support for the @code{Alignment} attribute for
10031 Same as above, for subtypes, but in addition:
10037 For stand-alone library-level objects of statically constrained
10038 subtypes, the implementation should support all @code{Alignment}s
10039 supported by the target linker. For example, page alignment is likely to
10040 be supported for such objects, but not for subtypes.
10044 @cindex @code{Size} clauses
10045 @unnumberedsec 13.3(42-43): Size Clauses
10048 The recommended level of support for the @code{Size} attribute of
10051 A @code{Size} clause should be supported for an object if the specified
10052 @code{Size} is at least as large as its subtype's @code{Size}, and
10053 corresponds to a size in storage elements that is a multiple of the
10054 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10058 @unnumberedsec 13.3(50-56): Size Clauses
10061 If the @code{Size} of a subtype is specified, and allows for efficient
10062 independent addressability (see 9.10) on the target architecture, then
10063 the @code{Size} of the following objects of the subtype should equal the
10064 @code{Size} of the subtype:
10066 Aliased objects (including components).
10072 @code{Size} clause on a composite subtype should not affect the
10073 internal layout of components.
10075 Followed. But note that this can be overridden by use of the implementation
10076 pragma Implicit_Packing in the case of packed arrays.
10080 The recommended level of support for the @code{Size} attribute of subtypes is:
10084 The @code{Size} (if not specified) of a static discrete or fixed point
10085 subtype should be the number of bits needed to represent each value
10086 belonging to the subtype using an unbiased representation, leaving space
10087 for a sign bit only if the subtype contains negative values. If such a
10088 subtype is a first subtype, then an implementation should support a
10089 specified @code{Size} for it that reflects this representation.
10095 For a subtype implemented with levels of indirection, the @code{Size}
10096 should include the size of the pointers, but not the size of what they
10101 @cindex @code{Component_Size} clauses
10102 @unnumberedsec 13.3(71-73): Component Size Clauses
10105 The recommended level of support for the @code{Component_Size}
10110 An implementation need not support specified @code{Component_Sizes} that are
10111 less than the @code{Size} of the component subtype.
10117 An implementation should support specified @code{Component_Size}s that
10118 are factors and multiples of the word size. For such
10119 @code{Component_Size}s, the array should contain no gaps between
10120 components. For other @code{Component_Size}s (if supported), the array
10121 should contain no gaps between components when packing is also
10122 specified; the implementation should forbid this combination in cases
10123 where it cannot support a no-gaps representation.
10127 @cindex Enumeration representation clauses
10128 @cindex Representation clauses, enumeration
10129 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10132 The recommended level of support for enumeration representation clauses
10135 An implementation need not support enumeration representation clauses
10136 for boolean types, but should at minimum support the internal codes in
10137 the range @code{System.Min_Int.System.Max_Int}.
10141 @cindex Record representation clauses
10142 @cindex Representation clauses, records
10143 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10146 The recommended level of support for
10147 @*@code{record_representation_clauses} is:
10149 An implementation should support storage places that can be extracted
10150 with a load, mask, shift sequence of machine code, and set with a load,
10151 shift, mask, store sequence, given the available machine instructions
10152 and run-time model.
10158 A storage place should be supported if its size is equal to the
10159 @code{Size} of the component subtype, and it starts and ends on a
10160 boundary that obeys the @code{Alignment} of the component subtype.
10166 If the default bit ordering applies to the declaration of a given type,
10167 then for a component whose subtype's @code{Size} is less than the word
10168 size, any storage place that does not cross an aligned word boundary
10169 should be supported.
10175 An implementation may reserve a storage place for the tag field of a
10176 tagged type, and disallow other components from overlapping that place.
10178 Followed. The storage place for the tag field is the beginning of the tagged
10179 record, and its size is Address'Size. GNAT will reject an explicit component
10180 clause for the tag field.
10184 An implementation need not support a @code{component_clause} for a
10185 component of an extension part if the storage place is not after the
10186 storage places of all components of the parent type, whether or not
10187 those storage places had been specified.
10189 Followed. The above advice on record representation clauses is followed,
10190 and all mentioned features are implemented.
10192 @cindex Storage place attributes
10193 @unnumberedsec 13.5.2(5): Storage Place Attributes
10196 If a component is represented using some form of pointer (such as an
10197 offset) to the actual data of the component, and this data is contiguous
10198 with the rest of the object, then the storage place attributes should
10199 reflect the place of the actual data, not the pointer. If a component is
10200 allocated discontinuously from the rest of the object, then a warning
10201 should be generated upon reference to one of its storage place
10204 Followed. There are no such components in GNAT@.
10206 @cindex Bit ordering
10207 @unnumberedsec 13.5.3(7-8): Bit Ordering
10210 The recommended level of support for the non-default bit ordering is:
10214 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10215 should support the non-default bit ordering in addition to the default
10218 Followed. Word size does not equal storage size in this implementation.
10219 Thus non-default bit ordering is not supported.
10221 @cindex @code{Address}, as private type
10222 @unnumberedsec 13.7(37): Address as Private
10225 @code{Address} should be of a private type.
10229 @cindex Operations, on @code{Address}
10230 @cindex @code{Address}, operations of
10231 @unnumberedsec 13.7.1(16): Address Operations
10234 Operations in @code{System} and its children should reflect the target
10235 environment semantics as closely as is reasonable. For example, on most
10236 machines, it makes sense for address arithmetic to ``wrap around''.
10237 Operations that do not make sense should raise @code{Program_Error}.
10239 Followed. Address arithmetic is modular arithmetic that wraps around. No
10240 operation raises @code{Program_Error}, since all operations make sense.
10242 @cindex Unchecked conversion
10243 @unnumberedsec 13.9(14-17): Unchecked Conversion
10246 The @code{Size} of an array object should not include its bounds; hence,
10247 the bounds should not be part of the converted data.
10253 The implementation should not generate unnecessary run-time checks to
10254 ensure that the representation of @var{S} is a representation of the
10255 target type. It should take advantage of the permission to return by
10256 reference when possible. Restrictions on unchecked conversions should be
10257 avoided unless required by the target environment.
10259 Followed. There are no restrictions on unchecked conversion. A warning is
10260 generated if the source and target types do not have the same size since
10261 the semantics in this case may be target dependent.
10265 The recommended level of support for unchecked conversions is:
10269 Unchecked conversions should be supported and should be reversible in
10270 the cases where this clause defines the result. To enable meaningful use
10271 of unchecked conversion, a contiguous representation should be used for
10272 elementary subtypes, for statically constrained array subtypes whose
10273 component subtype is one of the subtypes described in this paragraph,
10274 and for record subtypes without discriminants whose component subtypes
10275 are described in this paragraph.
10279 @cindex Heap usage, implicit
10280 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10283 An implementation should document any cases in which it dynamically
10284 allocates heap storage for a purpose other than the evaluation of an
10287 Followed, the only other points at which heap storage is dynamically
10288 allocated are as follows:
10292 At initial elaboration time, to allocate dynamically sized global
10296 To allocate space for a task when a task is created.
10299 To extend the secondary stack dynamically when needed. The secondary
10300 stack is used for returning variable length results.
10305 A default (implementation-provided) storage pool for an
10306 access-to-constant type should not have overhead to support deallocation of
10307 individual objects.
10313 A storage pool for an anonymous access type should be created at the
10314 point of an allocator for the type, and be reclaimed when the designated
10315 object becomes inaccessible.
10319 @cindex Unchecked deallocation
10320 @unnumberedsec 13.11.2(17): Unchecked De-allocation
10323 For a standard storage pool, @code{Free} should actually reclaim the
10328 @cindex Stream oriented attributes
10329 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
10332 If a stream element is the same size as a storage element, then the
10333 normal in-memory representation should be used by @code{Read} and
10334 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
10335 should use the smallest number of stream elements needed to represent
10336 all values in the base range of the scalar type.
10339 Followed. By default, GNAT uses the interpretation suggested by AI-195,
10340 which specifies using the size of the first subtype.
10341 However, such an implementation is based on direct binary
10342 representations and is therefore target- and endianness-dependent.
10343 To address this issue, GNAT also supplies an alternate implementation
10344 of the stream attributes @code{Read} and @code{Write},
10345 which uses the target-independent XDR standard representation
10347 @cindex XDR representation
10348 @cindex @code{Read} attribute
10349 @cindex @code{Write} attribute
10350 @cindex Stream oriented attributes
10351 The XDR implementation is provided as an alternative body of the
10352 @code{System.Stream_Attributes} package, in the file
10353 @file{s-stratt-xdr.adb} in the GNAT library.
10354 There is no @file{s-stratt-xdr.ads} file.
10355 In order to install the XDR implementation, do the following:
10357 @item Replace the default implementation of the
10358 @code{System.Stream_Attributes} package with the XDR implementation.
10359 For example on a Unix platform issue the commands:
10361 $ mv s-stratt.adb s-stratt-default.adb
10362 $ mv s-stratt-xdr.adb s-stratt.adb
10366 Rebuild the GNAT run-time library as documented in
10367 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
10370 @unnumberedsec A.1(52): Names of Predefined Numeric Types
10373 If an implementation provides additional named predefined integer types,
10374 then the names should end with @samp{Integer} as in
10375 @samp{Long_Integer}. If an implementation provides additional named
10376 predefined floating point types, then the names should end with
10377 @samp{Float} as in @samp{Long_Float}.
10381 @findex Ada.Characters.Handling
10382 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
10385 If an implementation provides a localized definition of @code{Character}
10386 or @code{Wide_Character}, then the effects of the subprograms in
10387 @code{Characters.Handling} should reflect the localizations. See also
10390 Followed. GNAT provides no such localized definitions.
10392 @cindex Bounded-length strings
10393 @unnumberedsec A.4.4(106): Bounded-Length String Handling
10396 Bounded string objects should not be implemented by implicit pointers
10397 and dynamic allocation.
10399 Followed. No implicit pointers or dynamic allocation are used.
10401 @cindex Random number generation
10402 @unnumberedsec A.5.2(46-47): Random Number Generation
10405 Any storage associated with an object of type @code{Generator} should be
10406 reclaimed on exit from the scope of the object.
10412 If the generator period is sufficiently long in relation to the number
10413 of distinct initiator values, then each possible value of
10414 @code{Initiator} passed to @code{Reset} should initiate a sequence of
10415 random numbers that does not, in a practical sense, overlap the sequence
10416 initiated by any other value. If this is not possible, then the mapping
10417 between initiator values and generator states should be a rapidly
10418 varying function of the initiator value.
10420 Followed. The generator period is sufficiently long for the first
10421 condition here to hold true.
10423 @findex Get_Immediate
10424 @unnumberedsec A.10.7(23): @code{Get_Immediate}
10427 The @code{Get_Immediate} procedures should be implemented with
10428 unbuffered input. For a device such as a keyboard, input should be
10429 @dfn{available} if a key has already been typed, whereas for a disk
10430 file, input should always be available except at end of file. For a file
10431 associated with a keyboard-like device, any line-editing features of the
10432 underlying operating system should be disabled during the execution of
10433 @code{Get_Immediate}.
10435 Followed on all targets except VxWorks. For VxWorks, there is no way to
10436 provide this functionality that does not result in the input buffer being
10437 flushed before the @code{Get_Immediate} call. A special unit
10438 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
10439 this functionality.
10442 @unnumberedsec B.1(39-41): Pragma @code{Export}
10445 If an implementation supports pragma @code{Export} to a given language,
10446 then it should also allow the main subprogram to be written in that
10447 language. It should support some mechanism for invoking the elaboration
10448 of the Ada library units included in the system, and for invoking the
10449 finalization of the environment task. On typical systems, the
10450 recommended mechanism is to provide two subprograms whose link names are
10451 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
10452 elaboration code for library units. @code{adafinal} should contain the
10453 finalization code. These subprograms should have no effect the second
10454 and subsequent time they are called.
10460 Automatic elaboration of pre-elaborated packages should be
10461 provided when pragma @code{Export} is supported.
10463 Followed when the main program is in Ada. If the main program is in a
10464 foreign language, then
10465 @code{adainit} must be called to elaborate pre-elaborated
10470 For each supported convention @var{L} other than @code{Intrinsic}, an
10471 implementation should support @code{Import} and @code{Export} pragmas
10472 for objects of @var{L}-compatible types and for subprograms, and pragma
10473 @code{Convention} for @var{L}-eligible types and for subprograms,
10474 presuming the other language has corresponding features. Pragma
10475 @code{Convention} need not be supported for scalar types.
10479 @cindex Package @code{Interfaces}
10481 @unnumberedsec B.2(12-13): Package @code{Interfaces}
10484 For each implementation-defined convention identifier, there should be a
10485 child package of package Interfaces with the corresponding name. This
10486 package should contain any declarations that would be useful for
10487 interfacing to the language (implementation) represented by the
10488 convention. Any declarations useful for interfacing to any language on
10489 the given hardware architecture should be provided directly in
10492 Followed. An additional package not defined
10493 in the Ada Reference Manual is @code{Interfaces.CPP}, used
10494 for interfacing to C++.
10498 An implementation supporting an interface to C, COBOL, or Fortran should
10499 provide the corresponding package or packages described in the following
10502 Followed. GNAT provides all the packages described in this section.
10504 @cindex C, interfacing with
10505 @unnumberedsec B.3(63-71): Interfacing with C
10508 An implementation should support the following interface correspondences
10509 between Ada and C@.
10515 An Ada procedure corresponds to a void-returning C function.
10521 An Ada function corresponds to a non-void C function.
10527 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
10534 An Ada @code{in} parameter of an access-to-object type with designated
10535 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
10536 where @var{t} is the C type corresponding to the Ada type @var{T}.
10542 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
10543 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
10544 argument to a C function, where @var{t} is the C type corresponding to
10545 the Ada type @var{T}. In the case of an elementary @code{out} or
10546 @code{in out} parameter, a pointer to a temporary copy is used to
10547 preserve by-copy semantics.
10553 An Ada parameter of a record type @var{T}, of any mode, is passed as a
10554 @code{@var{t}*} argument to a C function, where @var{t} is the C
10555 structure corresponding to the Ada type @var{T}.
10557 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
10558 pragma, or Convention, or by explicitly specifying the mechanism for a given
10559 call using an extended import or export pragma.
10563 An Ada parameter of an array type with component type @var{T}, of any
10564 mode, is passed as a @code{@var{t}*} argument to a C function, where
10565 @var{t} is the C type corresponding to the Ada type @var{T}.
10571 An Ada parameter of an access-to-subprogram type is passed as a pointer
10572 to a C function whose prototype corresponds to the designated
10573 subprogram's specification.
10577 @cindex COBOL, interfacing with
10578 @unnumberedsec B.4(95-98): Interfacing with COBOL
10581 An Ada implementation should support the following interface
10582 correspondences between Ada and COBOL@.
10588 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
10589 the COBOL type corresponding to @var{T}.
10595 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
10596 the corresponding COBOL type.
10602 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
10603 COBOL type corresponding to the Ada parameter type; for scalars, a local
10604 copy is used if necessary to ensure by-copy semantics.
10608 @cindex Fortran, interfacing with
10609 @unnumberedsec B.5(22-26): Interfacing with Fortran
10612 An Ada implementation should support the following interface
10613 correspondences between Ada and Fortran:
10619 An Ada procedure corresponds to a Fortran subroutine.
10625 An Ada function corresponds to a Fortran function.
10631 An Ada parameter of an elementary, array, or record type @var{T} is
10632 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
10633 the Fortran type corresponding to the Ada type @var{T}, and where the
10634 INTENT attribute of the corresponding dummy argument matches the Ada
10635 formal parameter mode; the Fortran implementation's parameter passing
10636 conventions are used. For elementary types, a local copy is used if
10637 necessary to ensure by-copy semantics.
10643 An Ada parameter of an access-to-subprogram type is passed as a
10644 reference to a Fortran procedure whose interface corresponds to the
10645 designated subprogram's specification.
10649 @cindex Machine operations
10650 @unnumberedsec C.1(3-5): Access to Machine Operations
10653 The machine code or intrinsic support should allow access to all
10654 operations normally available to assembly language programmers for the
10655 target environment, including privileged instructions, if any.
10661 The interfacing pragmas (see Annex B) should support interface to
10662 assembler; the default assembler should be associated with the
10663 convention identifier @code{Assembler}.
10669 If an entity is exported to assembly language, then the implementation
10670 should allocate it at an addressable location, and should ensure that it
10671 is retained by the linking process, even if not otherwise referenced
10672 from the Ada code. The implementation should assume that any call to a
10673 machine code or assembler subprogram is allowed to read or update every
10674 object that is specified as exported.
10678 @unnumberedsec C.1(10-16): Access to Machine Operations
10681 The implementation should ensure that little or no overhead is
10682 associated with calling intrinsic and machine-code subprograms.
10684 Followed for both intrinsics and machine-code subprograms.
10688 It is recommended that intrinsic subprograms be provided for convenient
10689 access to any machine operations that provide special capabilities or
10690 efficiency and that are not otherwise available through the language
10693 Followed. A full set of machine operation intrinsic subprograms is provided.
10697 Atomic read-modify-write operations---e.g.@:, test and set, compare and
10698 swap, decrement and test, enqueue/dequeue.
10700 Followed on any target supporting such operations.
10704 Standard numeric functions---e.g.@:, sin, log.
10706 Followed on any target supporting such operations.
10710 String manipulation operations---e.g.@:, translate and test.
10712 Followed on any target supporting such operations.
10716 Vector operations---e.g.@:, compare vector against thresholds.
10718 Followed on any target supporting such operations.
10722 Direct operations on I/O ports.
10724 Followed on any target supporting such operations.
10726 @cindex Interrupt support
10727 @unnumberedsec C.3(28): Interrupt Support
10730 If the @code{Ceiling_Locking} policy is not in effect, the
10731 implementation should provide means for the application to specify which
10732 interrupts are to be blocked during protected actions, if the underlying
10733 system allows for a finer-grain control of interrupt blocking.
10735 Followed. The underlying system does not allow for finer-grain control
10736 of interrupt blocking.
10738 @cindex Protected procedure handlers
10739 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
10742 Whenever possible, the implementation should allow interrupt handlers to
10743 be called directly by the hardware.
10745 Followed on any target where the underlying operating system permits
10750 Whenever practical, violations of any
10751 implementation-defined restrictions should be detected before run time.
10753 Followed. Compile time warnings are given when possible.
10755 @cindex Package @code{Interrupts}
10757 @unnumberedsec C.3.2(25): Package @code{Interrupts}
10761 If implementation-defined forms of interrupt handler procedures are
10762 supported, such as protected procedures with parameters, then for each
10763 such form of a handler, a type analogous to @code{Parameterless_Handler}
10764 should be specified in a child package of @code{Interrupts}, with the
10765 same operations as in the predefined package Interrupts.
10769 @cindex Pre-elaboration requirements
10770 @unnumberedsec C.4(14): Pre-elaboration Requirements
10773 It is recommended that pre-elaborated packages be implemented in such a
10774 way that there should be little or no code executed at run time for the
10775 elaboration of entities not already covered by the Implementation
10778 Followed. Executable code is generated in some cases, e.g.@: loops
10779 to initialize large arrays.
10781 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
10784 If the pragma applies to an entity, then the implementation should
10785 reduce the amount of storage used for storing names associated with that
10790 @cindex Package @code{Task_Attributes}
10791 @findex Task_Attributes
10792 @unnumberedsec C.7.2(30): The Package Task_Attributes
10795 Some implementations are targeted to domains in which memory use at run
10796 time must be completely deterministic. For such implementations, it is
10797 recommended that the storage for task attributes will be pre-allocated
10798 statically and not from the heap. This can be accomplished by either
10799 placing restrictions on the number and the size of the task's
10800 attributes, or by using the pre-allocated storage for the first @var{N}
10801 attribute objects, and the heap for the others. In the latter case,
10802 @var{N} should be documented.
10804 Not followed. This implementation is not targeted to such a domain.
10806 @cindex Locking Policies
10807 @unnumberedsec D.3(17): Locking Policies
10811 The implementation should use names that end with @samp{_Locking} for
10812 locking policies defined by the implementation.
10814 Followed. Two implementation-defined locking policies are defined,
10815 whose names (@code{Inheritance_Locking} and
10816 @code{Concurrent_Readers_Locking}) follow this suggestion.
10818 @cindex Entry queuing policies
10819 @unnumberedsec D.4(16): Entry Queuing Policies
10822 Names that end with @samp{_Queuing} should be used
10823 for all implementation-defined queuing policies.
10825 Followed. No such implementation-defined queuing policies exist.
10827 @cindex Preemptive abort
10828 @unnumberedsec D.6(9-10): Preemptive Abort
10831 Even though the @code{abort_statement} is included in the list of
10832 potentially blocking operations (see 9.5.1), it is recommended that this
10833 statement be implemented in a way that never requires the task executing
10834 the @code{abort_statement} to block.
10840 On a multi-processor, the delay associated with aborting a task on
10841 another processor should be bounded; the implementation should use
10842 periodic polling, if necessary, to achieve this.
10846 @cindex Tasking restrictions
10847 @unnumberedsec D.7(21): Tasking Restrictions
10850 When feasible, the implementation should take advantage of the specified
10851 restrictions to produce a more efficient implementation.
10853 GNAT currently takes advantage of these restrictions by providing an optimized
10854 run time when the Ravenscar profile and the GNAT restricted run time set
10855 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
10856 pragma @code{Profile (Restricted)} for more details.
10858 @cindex Time, monotonic
10859 @unnumberedsec D.8(47-49): Monotonic Time
10862 When appropriate, implementations should provide configuration
10863 mechanisms to change the value of @code{Tick}.
10865 Such configuration mechanisms are not appropriate to this implementation
10866 and are thus not supported.
10870 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
10871 be implemented as transformations of the same time base.
10877 It is recommended that the @dfn{best} time base which exists in
10878 the underlying system be available to the application through
10879 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
10883 @cindex Partition communication subsystem
10885 @unnumberedsec E.5(28-29): Partition Communication Subsystem
10888 Whenever possible, the PCS on the called partition should allow for
10889 multiple tasks to call the RPC-receiver with different messages and
10890 should allow them to block until the corresponding subprogram body
10893 Followed by GLADE, a separately supplied PCS that can be used with
10898 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
10899 should raise @code{Storage_Error} if it runs out of space trying to
10900 write the @code{Item} into the stream.
10902 Followed by GLADE, a separately supplied PCS that can be used with
10905 @cindex COBOL support
10906 @unnumberedsec F(7): COBOL Support
10909 If COBOL (respectively, C) is widely supported in the target
10910 environment, implementations supporting the Information Systems Annex
10911 should provide the child package @code{Interfaces.COBOL} (respectively,
10912 @code{Interfaces.C}) specified in Annex B and should support a
10913 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
10914 pragmas (see Annex B), thus allowing Ada programs to interface with
10915 programs written in that language.
10919 @cindex Decimal radix support
10920 @unnumberedsec F.1(2): Decimal Radix Support
10923 Packed decimal should be used as the internal representation for objects
10924 of subtype @var{S} when @var{S}'Machine_Radix = 10.
10926 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
10930 @unnumberedsec G: Numerics
10933 If Fortran (respectively, C) is widely supported in the target
10934 environment, implementations supporting the Numerics Annex
10935 should provide the child package @code{Interfaces.Fortran} (respectively,
10936 @code{Interfaces.C}) specified in Annex B and should support a
10937 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
10938 pragmas (see Annex B), thus allowing Ada programs to interface with
10939 programs written in that language.
10943 @cindex Complex types
10944 @unnumberedsec G.1.1(56-58): Complex Types
10947 Because the usual mathematical meaning of multiplication of a complex
10948 operand and a real operand is that of the scaling of both components of
10949 the former by the latter, an implementation should not perform this
10950 operation by first promoting the real operand to complex type and then
10951 performing a full complex multiplication. In systems that, in the
10952 future, support an Ada binding to IEC 559:1989, the latter technique
10953 will not generate the required result when one of the components of the
10954 complex operand is infinite. (Explicit multiplication of the infinite
10955 component by the zero component obtained during promotion yields a NaN
10956 that propagates into the final result.) Analogous advice applies in the
10957 case of multiplication of a complex operand and a pure-imaginary
10958 operand, and in the case of division of a complex operand by a real or
10959 pure-imaginary operand.
10965 Similarly, because the usual mathematical meaning of addition of a
10966 complex operand and a real operand is that the imaginary operand remains
10967 unchanged, an implementation should not perform this operation by first
10968 promoting the real operand to complex type and then performing a full
10969 complex addition. In implementations in which the @code{Signed_Zeros}
10970 attribute of the component type is @code{True} (and which therefore
10971 conform to IEC 559:1989 in regard to the handling of the sign of zero in
10972 predefined arithmetic operations), the latter technique will not
10973 generate the required result when the imaginary component of the complex
10974 operand is a negatively signed zero. (Explicit addition of the negative
10975 zero to the zero obtained during promotion yields a positive zero.)
10976 Analogous advice applies in the case of addition of a complex operand
10977 and a pure-imaginary operand, and in the case of subtraction of a
10978 complex operand and a real or pure-imaginary operand.
10984 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
10985 attempt to provide a rational treatment of the signs of zero results and
10986 result components. As one example, the result of the @code{Argument}
10987 function should have the sign of the imaginary component of the
10988 parameter @code{X} when the point represented by that parameter lies on
10989 the positive real axis; as another, the sign of the imaginary component
10990 of the @code{Compose_From_Polar} function should be the same as
10991 (respectively, the opposite of) that of the @code{Argument} parameter when that
10992 parameter has a value of zero and the @code{Modulus} parameter has a
10993 nonnegative (respectively, negative) value.
10997 @cindex Complex elementary functions
10998 @unnumberedsec G.1.2(49): Complex Elementary Functions
11001 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11002 @code{True} should attempt to provide a rational treatment of the signs
11003 of zero results and result components. For example, many of the complex
11004 elementary functions have components that are odd functions of one of
11005 the parameter components; in these cases, the result component should
11006 have the sign of the parameter component at the origin. Other complex
11007 elementary functions have zero components whose sign is opposite that of
11008 a parameter component at the origin, or is always positive or always
11013 @cindex Accuracy requirements
11014 @unnumberedsec G.2.4(19): Accuracy Requirements
11017 The versions of the forward trigonometric functions without a
11018 @code{Cycle} parameter should not be implemented by calling the
11019 corresponding version with a @code{Cycle} parameter of
11020 @code{2.0*Numerics.Pi}, since this will not provide the required
11021 accuracy in some portions of the domain. For the same reason, the
11022 version of @code{Log} without a @code{Base} parameter should not be
11023 implemented by calling the corresponding version with a @code{Base}
11024 parameter of @code{Numerics.e}.
11028 @cindex Complex arithmetic accuracy
11029 @cindex Accuracy, complex arithmetic
11030 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11034 The version of the @code{Compose_From_Polar} function without a
11035 @code{Cycle} parameter should not be implemented by calling the
11036 corresponding version with a @code{Cycle} parameter of
11037 @code{2.0*Numerics.Pi}, since this will not provide the required
11038 accuracy in some portions of the domain.
11042 @cindex Sequential elaboration policy
11043 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11047 If the partition elaboration policy is @code{Sequential} and the
11048 Environment task becomes permanently blocked during elaboration then the
11049 partition is deadlocked and it is recommended that the partition be
11050 immediately terminated.
11054 @c -----------------------------------------
11055 @node Implementation Defined Characteristics
11056 @chapter Implementation Defined Characteristics
11059 In addition to the implementation dependent pragmas and attributes, and the
11060 implementation advice, there are a number of other Ada features that are
11061 potentially implementation dependent and are designated as
11062 implementation-defined. These are mentioned throughout the Ada Reference
11063 Manual, and are summarized in Annex M@.
11065 A requirement for conforming Ada compilers is that they provide
11066 documentation describing how the implementation deals with each of these
11067 issues. In this chapter, you will find each point in Annex M listed
11068 followed by a description in italic font of how GNAT
11069 handles the implementation dependence.
11071 You can use this chapter as a guide to minimizing implementation
11072 dependent features in your programs if portability to other compilers
11073 and other operating systems is an important consideration. The numbers
11074 in each section below correspond to the paragraph number in the Ada
11080 @strong{2}. Whether or not each recommendation given in Implementation
11081 Advice is followed. See 1.1.2(37).
11084 @xref{Implementation Advice}.
11089 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
11092 The complexity of programs that can be processed is limited only by the
11093 total amount of available virtual memory, and disk space for the
11094 generated object files.
11099 @strong{4}. Variations from the standard that are impractical to avoid
11100 given the implementation's execution environment. See 1.1.3(6).
11103 There are no variations from the standard.
11108 @strong{5}. Which @code{code_statement}s cause external
11109 interactions. See 1.1.3(10).
11112 Any @code{code_statement} can potentially cause external interactions.
11117 @strong{6}. The coded representation for the text of an Ada
11118 program. See 2.1(4).
11121 See separate section on source representation.
11126 @strong{7}. The control functions allowed in comments. See 2.1(14).
11129 See separate section on source representation.
11134 @strong{8}. The representation for an end of line. See 2.2(2).
11137 See separate section on source representation.
11142 @strong{9}. Maximum supported line length and lexical element
11143 length. See 2.2(15).
11146 The maximum line length is 255 characters and the maximum length of
11147 a lexical element is also 255 characters. This is the default setting
11148 if not overridden by the use of compiler switch @option{-gnaty} (which
11149 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11150 line length to be specified to be any value up to 32767. The maximum
11151 length of a lexical element is the same as the maximum line length.
11156 @strong{10}. Implementation defined pragmas. See 2.8(14).
11160 @xref{Implementation Defined Pragmas}.
11165 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
11168 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11169 parameter, checks that the optimization flag is set, and aborts if it is
11175 @strong{12}. The sequence of characters of the value returned by
11176 @code{@var{S}'Image} when some of the graphic characters of
11177 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
11181 The sequence of characters is as defined by the wide character encoding
11182 method used for the source. See section on source representation for
11188 @strong{13}. The predefined integer types declared in
11189 @code{Standard}. See 3.5.4(25).
11193 @item Short_Short_Integer
11195 @item Short_Integer
11196 (Short) 16 bit signed
11200 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11201 32 bit signed (all other targets)
11202 @item Long_Long_Integer
11209 @strong{14}. Any nonstandard integer types and the operators defined
11210 for them. See 3.5.4(26).
11213 There are no nonstandard integer types.
11218 @strong{15}. Any nonstandard real types and the operators defined for
11219 them. See 3.5.6(8).
11222 There are no nonstandard real types.
11227 @strong{16}. What combinations of requested decimal precision and range
11228 are supported for floating point types. See 3.5.7(7).
11231 The precision and range is as defined by the IEEE standard.
11236 @strong{17}. The predefined floating point types declared in
11237 @code{Standard}. See 3.5.7(16).
11244 (Short) 32 bit IEEE short
11247 @item Long_Long_Float
11248 64 bit IEEE long (80 bit IEEE long on x86 processors)
11254 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
11257 @code{Fine_Delta} is 2**(@minus{}63)
11262 @strong{19}. What combinations of small, range, and digits are
11263 supported for fixed point types. See 3.5.9(10).
11266 Any combinations are permitted that do not result in a small less than
11267 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11268 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11269 is 64 bits (true of all architectures except ia32), then the output from
11270 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
11271 is because floating-point conversions are used to convert fixed point.
11276 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
11277 within an unnamed @code{block_statement}. See 3.9(10).
11280 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11281 decimal integer are allocated.
11286 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
11289 @xref{Implementation Defined Attributes}.
11294 @strong{22}. Any implementation-defined time types. See 9.6(6).
11297 There are no implementation-defined time types.
11302 @strong{23}. The time base associated with relative delays.
11305 See 9.6(20). The time base used is that provided by the C library
11306 function @code{gettimeofday}.
11311 @strong{24}. The time base of the type @code{Calendar.Time}. See
11315 The time base used is that provided by the C library function
11316 @code{gettimeofday}.
11321 @strong{25}. The time zone used for package @code{Calendar}
11322 operations. See 9.6(24).
11325 The time zone used by package @code{Calendar} is the current system time zone
11326 setting for local time, as accessed by the C library function
11332 @strong{26}. Any limit on @code{delay_until_statements} of
11333 @code{select_statements}. See 9.6(29).
11336 There are no such limits.
11341 @strong{27}. Whether or not two non-overlapping parts of a composite
11342 object are independently addressable, in the case where packing, record
11343 layout, or @code{Component_Size} is specified for the object. See
11347 Separate components are independently addressable if they do not share
11348 overlapping storage units.
11353 @strong{28}. The representation for a compilation. See 10.1(2).
11356 A compilation is represented by a sequence of files presented to the
11357 compiler in a single invocation of the @command{gcc} command.
11362 @strong{29}. Any restrictions on compilations that contain multiple
11363 compilation_units. See 10.1(4).
11366 No single file can contain more than one compilation unit, but any
11367 sequence of files can be presented to the compiler as a single
11373 @strong{30}. The mechanisms for creating an environment and for adding
11374 and replacing compilation units. See 10.1.4(3).
11377 See separate section on compilation model.
11382 @strong{31}. The manner of explicitly assigning library units to a
11383 partition. See 10.2(2).
11386 If a unit contains an Ada main program, then the Ada units for the partition
11387 are determined by recursive application of the rules in the Ada Reference
11388 Manual section 10.2(2-6). In other words, the Ada units will be those that
11389 are needed by the main program, and then this definition of need is applied
11390 recursively to those units, and the partition contains the transitive
11391 closure determined by this relationship. In short, all the necessary units
11392 are included, with no need to explicitly specify the list. If additional
11393 units are required, e.g.@: by foreign language units, then all units must be
11394 mentioned in the context clause of one of the needed Ada units.
11396 If the partition contains no main program, or if the main program is in
11397 a language other than Ada, then GNAT
11398 provides the binder options @option{-z} and @option{-n} respectively, and in
11399 this case a list of units can be explicitly supplied to the binder for
11400 inclusion in the partition (all units needed by these units will also
11401 be included automatically). For full details on the use of these
11402 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
11403 @value{EDITION} User's Guide}.
11408 @strong{32}. The implementation-defined means, if any, of specifying
11409 which compilation units are needed by a given compilation unit. See
11413 The units needed by a given compilation unit are as defined in
11414 the Ada Reference Manual section 10.2(2-6). There are no
11415 implementation-defined pragmas or other implementation-defined
11416 means for specifying needed units.
11421 @strong{33}. The manner of designating the main subprogram of a
11422 partition. See 10.2(7).
11425 The main program is designated by providing the name of the
11426 corresponding @file{ALI} file as the input parameter to the binder.
11431 @strong{34}. The order of elaboration of @code{library_items}. See
11435 The first constraint on ordering is that it meets the requirements of
11436 Chapter 10 of the Ada Reference Manual. This still leaves some
11437 implementation dependent choices, which are resolved by first
11438 elaborating bodies as early as possible (i.e., in preference to specs
11439 where there is a choice), and second by evaluating the immediate with
11440 clauses of a unit to determine the probably best choice, and
11441 third by elaborating in alphabetical order of unit names
11442 where a choice still remains.
11447 @strong{35}. Parameter passing and function return for the main
11448 subprogram. See 10.2(21).
11451 The main program has no parameters. It may be a procedure, or a function
11452 returning an integer type. In the latter case, the returned integer
11453 value is the return code of the program (overriding any value that
11454 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
11459 @strong{36}. The mechanisms for building and running partitions. See
11463 GNAT itself supports programs with only a single partition. The GNATDIST
11464 tool provided with the GLADE package (which also includes an implementation
11465 of the PCS) provides a completely flexible method for building and running
11466 programs consisting of multiple partitions. See the separate GLADE manual
11472 @strong{37}. The details of program execution, including program
11473 termination. See 10.2(25).
11476 See separate section on compilation model.
11481 @strong{38}. The semantics of any non-active partitions supported by the
11482 implementation. See 10.2(28).
11485 Passive partitions are supported on targets where shared memory is
11486 provided by the operating system. See the GLADE reference manual for
11492 @strong{39}. The information returned by @code{Exception_Message}. See
11496 Exception message returns the null string unless a specific message has
11497 been passed by the program.
11502 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
11503 declared within an unnamed @code{block_statement}. See 11.4.1(12).
11506 Blocks have implementation defined names of the form @code{B@var{nnn}}
11507 where @var{nnn} is an integer.
11512 @strong{41}. The information returned by
11513 @code{Exception_Information}. See 11.4.1(13).
11516 @code{Exception_Information} returns a string in the following format:
11519 @emph{Exception_Name:} nnnnn
11520 @emph{Message:} mmmmm
11522 @emph{Call stack traceback locations:}
11523 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
11531 @code{nnnn} is the fully qualified name of the exception in all upper
11532 case letters. This line is always present.
11535 @code{mmmm} is the message (this line present only if message is non-null)
11538 @code{ppp} is the Process Id value as a decimal integer (this line is
11539 present only if the Process Id is nonzero). Currently we are
11540 not making use of this field.
11543 The Call stack traceback locations line and the following values
11544 are present only if at least one traceback location was recorded.
11545 The values are given in C style format, with lower case letters
11546 for a-f, and only as many digits present as are necessary.
11550 The line terminator sequence at the end of each line, including
11551 the last line is a single @code{LF} character (@code{16#0A#}).
11556 @strong{42}. Implementation-defined check names. See 11.5(27).
11559 The implementation defined check name Alignment_Check controls checking of
11560 address clause values for proper alignment (that is, the address supplied
11561 must be consistent with the alignment of the type).
11563 The implementation defined check name Predicate_Check controls whether
11564 predicate checks are generated.
11566 The implementation defined check name Validity_Check controls whether
11567 validity checks are generated.
11569 In addition, a user program can add implementation-defined check names
11570 by means of the pragma Check_Name.
11575 @strong{43}. The interpretation of each aspect of representation. See
11579 See separate section on data representations.
11584 @strong{44}. Any restrictions placed upon representation items. See
11588 See separate section on data representations.
11593 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
11597 Size for an indefinite subtype is the maximum possible size, except that
11598 for the case of a subprogram parameter, the size of the parameter object
11599 is the actual size.
11604 @strong{46}. The default external representation for a type tag. See
11608 The default external representation for a type tag is the fully expanded
11609 name of the type in upper case letters.
11614 @strong{47}. What determines whether a compilation unit is the same in
11615 two different partitions. See 13.3(76).
11618 A compilation unit is the same in two different partitions if and only
11619 if it derives from the same source file.
11624 @strong{48}. Implementation-defined components. See 13.5.1(15).
11627 The only implementation defined component is the tag for a tagged type,
11628 which contains a pointer to the dispatching table.
11633 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
11634 ordering. See 13.5.3(5).
11637 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
11638 implementation, so no non-default bit ordering is supported. The default
11639 bit ordering corresponds to the natural endianness of the target architecture.
11644 @strong{50}. The contents of the visible part of package @code{System}
11645 and its language-defined children. See 13.7(2).
11648 See the definition of these packages in files @file{system.ads} and
11649 @file{s-stoele.ads}.
11654 @strong{51}. The contents of the visible part of package
11655 @code{System.Machine_Code}, and the meaning of
11656 @code{code_statements}. See 13.8(7).
11659 See the definition and documentation in file @file{s-maccod.ads}.
11664 @strong{52}. The effect of unchecked conversion. See 13.9(11).
11667 Unchecked conversion between types of the same size
11668 results in an uninterpreted transmission of the bits from one type
11669 to the other. If the types are of unequal sizes, then in the case of
11670 discrete types, a shorter source is first zero or sign extended as
11671 necessary, and a shorter target is simply truncated on the left.
11672 For all non-discrete types, the source is first copied if necessary
11673 to ensure that the alignment requirements of the target are met, then
11674 a pointer is constructed to the source value, and the result is obtained
11675 by dereferencing this pointer after converting it to be a pointer to the
11676 target type. Unchecked conversions where the target subtype is an
11677 unconstrained array are not permitted. If the target alignment is
11678 greater than the source alignment, then a copy of the result is
11679 made with appropriate alignment
11684 @strong{53}. The semantics of operations on invalid representations.
11688 For assignments and other operations where the use of invalid values cannot
11689 result in erroneous behavior, the compiler ignores the possibility of invalid
11690 values. An exception is raised at the point where an invalid value would
11691 result in erroneous behavior. For example executing:
11693 @smallexample @c ada
11694 procedure invalidvals is
11696 Y : Natural range 1 .. 10;
11697 for Y'Address use X'Address;
11698 Z : Natural range 1 .. 10;
11699 A : array (Natural range 1 .. 10) of Integer;
11701 Z := Y; -- no exception
11702 A (Z) := 3; -- exception raised;
11707 As indicated, an exception is raised on the array assignment, but not
11708 on the simple assignment of the invalid negative value from Y to Z.
11713 @strong{53}. The manner of choosing a storage pool for an access type
11714 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
11717 There are 3 different standard pools used by the compiler when
11718 @code{Storage_Pool} is not specified depending whether the type is local
11719 to a subprogram or defined at the library level and whether
11720 @code{Storage_Size}is specified or not. See documentation in the runtime
11721 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
11722 @code{System.Pool_Local} in files @file{s-poosiz.ads},
11723 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
11724 default pools used.
11729 @strong{54}. Whether or not the implementation provides user-accessible
11730 names for the standard pool type(s). See 13.11(17).
11734 See documentation in the sources of the run time mentioned in paragraph
11735 @strong{53} . All these pools are accessible by means of @code{with}'ing
11741 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
11744 @code{Storage_Size} is measured in storage units, and refers to the
11745 total space available for an access type collection, or to the primary
11746 stack space for a task.
11751 @strong{56}. Implementation-defined aspects of storage pools. See
11755 See documentation in the sources of the run time mentioned in paragraph
11756 @strong{53} for details on GNAT-defined aspects of storage pools.
11761 @strong{57}. The set of restrictions allowed in a pragma
11762 @code{Restrictions}. See 13.12(7).
11765 @xref{Standard and Implementation Defined Restrictions}.
11770 @strong{58}. The consequences of violating limitations on
11771 @code{Restrictions} pragmas. See 13.12(9).
11774 Restrictions that can be checked at compile time result in illegalities
11775 if violated. Currently there are no other consequences of violating
11781 @strong{59}. The representation used by the @code{Read} and
11782 @code{Write} attributes of elementary types in terms of stream
11783 elements. See 13.13.2(9).
11786 The representation is the in-memory representation of the base type of
11787 the type, using the number of bits corresponding to the
11788 @code{@var{type}'Size} value, and the natural ordering of the machine.
11793 @strong{60}. The names and characteristics of the numeric subtypes
11794 declared in the visible part of package @code{Standard}. See A.1(3).
11797 See items describing the integer and floating-point types supported.
11802 @strong{61}. The accuracy actually achieved by the elementary
11803 functions. See A.5.1(1).
11806 The elementary functions correspond to the functions available in the C
11807 library. Only fast math mode is implemented.
11812 @strong{62}. The sign of a zero result from some of the operators or
11813 functions in @code{Numerics.Generic_Elementary_Functions}, when
11814 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
11817 The sign of zeroes follows the requirements of the IEEE 754 standard on
11823 @strong{63}. The value of
11824 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
11827 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11832 @strong{64}. The value of
11833 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
11836 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11841 @strong{65}. The algorithms for random number generation. See
11845 The algorithm is the Mersenne Twister, as documented in the source file
11846 @file{s-rannum.adb}. This version of the algorithm has a period of
11852 @strong{66}. The string representation of a random number generator's
11853 state. See A.5.2(38).
11856 The value returned by the Image function is the concatenation of
11857 the fixed-width decimal representations of the 624 32-bit integers
11858 of the state vector.
11863 @strong{67}. The minimum time interval between calls to the
11864 time-dependent Reset procedure that are guaranteed to initiate different
11865 random number sequences. See A.5.2(45).
11868 The minimum period between reset calls to guarantee distinct series of
11869 random numbers is one microsecond.
11874 @strong{68}. The values of the @code{Model_Mantissa},
11875 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
11876 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
11877 Annex is not supported. See A.5.3(72).
11880 Run the compiler with @option{-gnatS} to produce a listing of package
11881 @code{Standard}, has the values of all numeric attributes.
11886 @strong{69}. Any implementation-defined characteristics of the
11887 input-output packages. See A.7(14).
11890 There are no special implementation defined characteristics for these
11896 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
11900 All type representations are contiguous, and the @code{Buffer_Size} is
11901 the value of @code{@var{type}'Size} rounded up to the next storage unit
11907 @strong{71}. External files for standard input, standard output, and
11908 standard error See A.10(5).
11911 These files are mapped onto the files provided by the C streams
11912 libraries. See source file @file{i-cstrea.ads} for further details.
11917 @strong{72}. The accuracy of the value produced by @code{Put}. See
11921 If more digits are requested in the output than are represented by the
11922 precision of the value, zeroes are output in the corresponding least
11923 significant digit positions.
11928 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
11929 @code{Command_Name}. See A.15(1).
11932 These are mapped onto the @code{argv} and @code{argc} parameters of the
11933 main program in the natural manner.
11938 @strong{74}. The interpretation of the @code{Form} parameter in procedure
11939 @code{Create_Directory}. See A.16(56).
11942 The @code{Form} parameter is not used.
11947 @strong{75}. The interpretation of the @code{Form} parameter in procedure
11948 @code{Create_Path}. See A.16(60).
11951 The @code{Form} parameter is not used.
11956 @strong{76}. The interpretation of the @code{Form} parameter in procedure
11957 @code{Copy_File}. See A.16(68).
11960 The @code{Form} parameter is case-insensitive.
11962 Two fields are recognized in the @code{Form} parameter:
11966 @item preserve=<value>
11973 <value> starts immediately after the character '=' and ends with the
11974 character immediately preceding the next comma (',') or with the last
11975 character of the parameter.
11977 The only possible values for preserve= are:
11981 @item no_attributes
11982 Do not try to preserve any file attributes. This is the default if no
11983 preserve= is found in Form.
11985 @item all_attributes
11986 Try to preserve all file attributes (timestamps, access rights).
11989 Preserve the timestamp of the copied file, but not the other file attributes.
11994 The only possible values for mode= are:
11999 Only do the copy if the destination file does not already exist. If it already
12000 exists, Copy_File fails.
12003 Copy the file in all cases. Overwrite an already existing destination file.
12006 Append the original file to the destination file. If the destination file does
12007 not exist, the destination file is a copy of the source file. When mode=append,
12008 the field preserve=, if it exists, is not taken into account.
12013 If the Form parameter includes one or both of the fields and the value or
12014 values are incorrect, Copy_file fails with Use_Error.
12016 Examples of correct Forms:
12019 Form => "preserve=no_attributes,mode=overwrite" (the default)
12020 Form => "mode=append"
12021 Form => "mode=copy, preserve=all_attributes"
12025 Examples of incorrect Forms
12028 Form => "preserve=junk"
12029 Form => "mode=internal, preserve=timestamps"
12035 @strong{77}. Implementation-defined convention names. See B.1(11).
12038 The following convention names are supported
12043 @item Ada_Pass_By_Copy
12044 Allowed for any types except by-reference types such as limited
12045 records. Compatible with convention Ada, but causes any parameters
12046 with this convention to be passed by copy.
12047 @item Ada_Pass_By_Reference
12048 Allowed for any types except by-copy types such as scalars.
12049 Compatible with convention Ada, but causes any parameters
12050 with this convention to be passed by reference.
12054 Synonym for Assembler
12056 Synonym for Assembler
12059 @item C_Pass_By_Copy
12060 Allowed only for record types, like C, but also notes that record
12061 is to be passed by copy rather than reference.
12064 @item C_Plus_Plus (or CPP)
12067 Treated the same as C
12069 Treated the same as C
12073 For support of pragma @code{Import} with convention Intrinsic, see
12074 separate section on Intrinsic Subprograms.
12076 Stdcall (used for Windows implementations only). This convention correspond
12077 to the WINAPI (previously called Pascal convention) C/C++ convention under
12078 Windows. A routine with this convention cleans the stack before
12079 exit. This pragma cannot be applied to a dispatching call.
12081 Synonym for Stdcall
12083 Synonym for Stdcall
12085 Stubbed is a special convention used to indicate that the body of the
12086 subprogram will be entirely ignored. Any call to the subprogram
12087 is converted into a raise of the @code{Program_Error} exception. If a
12088 pragma @code{Import} specifies convention @code{stubbed} then no body need
12089 be present at all. This convention is useful during development for the
12090 inclusion of subprograms whose body has not yet been written.
12094 In addition, all otherwise unrecognized convention names are also
12095 treated as being synonymous with convention C@. In all implementations
12096 except for VMS, use of such other names results in a warning. In VMS
12097 implementations, these names are accepted silently.
12102 @strong{78}. The meaning of link names. See B.1(36).
12105 Link names are the actual names used by the linker.
12110 @strong{79}. The manner of choosing link names when neither the link
12111 name nor the address of an imported or exported entity is specified. See
12115 The default linker name is that which would be assigned by the relevant
12116 external language, interpreting the Ada name as being in all lower case
12122 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
12125 The string passed to @code{Linker_Options} is presented uninterpreted as
12126 an argument to the link command, unless it contains ASCII.NUL characters.
12127 NUL characters if they appear act as argument separators, so for example
12129 @smallexample @c ada
12130 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12134 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12135 linker. The order of linker options is preserved for a given unit. The final
12136 list of options passed to the linker is in reverse order of the elaboration
12137 order. For example, linker options for a body always appear before the options
12138 from the corresponding package spec.
12143 @strong{81}. The contents of the visible part of package
12144 @code{Interfaces} and its language-defined descendants. See B.2(1).
12147 See files with prefix @file{i-} in the distributed library.
12152 @strong{82}. Implementation-defined children of package
12153 @code{Interfaces}. The contents of the visible part of package
12154 @code{Interfaces}. See B.2(11).
12157 See files with prefix @file{i-} in the distributed library.
12162 @strong{83}. The types @code{Floating}, @code{Long_Floating},
12163 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12164 @code{COBOL_Character}; and the initialization of the variables
12165 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12166 @code{Interfaces.COBOL}. See B.4(50).
12172 @item Long_Floating
12173 (Floating) Long_Float
12178 @item Decimal_Element
12180 @item COBOL_Character
12185 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12190 @strong{84}. Support for access to machine instructions. See C.1(1).
12193 See documentation in file @file{s-maccod.ads} in the distributed library.
12198 @strong{85}. Implementation-defined aspects of access to machine
12199 operations. See C.1(9).
12202 See documentation in file @file{s-maccod.ads} in the distributed library.
12207 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
12210 Interrupts are mapped to signals or conditions as appropriate. See
12212 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12213 on the interrupts supported on a particular target.
12218 @strong{87}. Implementation-defined aspects of pre-elaboration. See
12222 GNAT does not permit a partition to be restarted without reloading,
12223 except under control of the debugger.
12228 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
12231 Pragma @code{Discard_Names} causes names of enumeration literals to
12232 be suppressed. In the presence of this pragma, the Image attribute
12233 provides the image of the Pos of the literal, and Value accepts
12239 @strong{89}. The result of the @code{Task_Identification.Image}
12240 attribute. See C.7.1(7).
12243 The result of this attribute is a string that identifies
12244 the object or component that denotes a given task. If a variable @code{Var}
12245 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12247 is the hexadecimal representation of the virtual address of the corresponding
12248 task control block. If the variable is an array of tasks, the image of each
12249 task will have the form of an indexed component indicating the position of a
12250 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12251 component of a record, the image of the task will have the form of a selected
12252 component. These rules are fully recursive, so that the image of a task that
12253 is a subcomponent of a composite object corresponds to the expression that
12254 designates this task.
12256 If a task is created by an allocator, its image depends on the context. If the
12257 allocator is part of an object declaration, the rules described above are used
12258 to construct its image, and this image is not affected by subsequent
12259 assignments. If the allocator appears within an expression, the image
12260 includes only the name of the task type.
12262 If the configuration pragma Discard_Names is present, or if the restriction
12263 No_Implicit_Heap_Allocation is in effect, the image reduces to
12264 the numeric suffix, that is to say the hexadecimal representation of the
12265 virtual address of the control block of the task.
12269 @strong{90}. The value of @code{Current_Task} when in a protected entry
12270 or interrupt handler. See C.7.1(17).
12273 Protected entries or interrupt handlers can be executed by any
12274 convenient thread, so the value of @code{Current_Task} is undefined.
12279 @strong{91}. The effect of calling @code{Current_Task} from an entry
12280 body or interrupt handler. See C.7.1(19).
12283 The effect of calling @code{Current_Task} from an entry body or
12284 interrupt handler is to return the identification of the task currently
12285 executing the code.
12290 @strong{92}. Implementation-defined aspects of
12291 @code{Task_Attributes}. See C.7.2(19).
12294 There are no implementation-defined aspects of @code{Task_Attributes}.
12299 @strong{93}. Values of all @code{Metrics}. See D(2).
12302 The metrics information for GNAT depends on the performance of the
12303 underlying operating system. The sources of the run-time for tasking
12304 implementation, together with the output from @option{-gnatG} can be
12305 used to determine the exact sequence of operating systems calls made
12306 to implement various tasking constructs. Together with appropriate
12307 information on the performance of the underlying operating system,
12308 on the exact target in use, this information can be used to determine
12309 the required metrics.
12314 @strong{94}. The declarations of @code{Any_Priority} and
12315 @code{Priority}. See D.1(11).
12318 See declarations in file @file{system.ads}.
12323 @strong{95}. Implementation-defined execution resources. See D.1(15).
12326 There are no implementation-defined execution resources.
12331 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
12332 access to a protected object keeps its processor busy. See D.2.1(3).
12335 On a multi-processor, a task that is waiting for access to a protected
12336 object does not keep its processor busy.
12341 @strong{97}. The affect of implementation defined execution resources
12342 on task dispatching. See D.2.1(9).
12345 Tasks map to threads in the threads package used by GNAT@. Where possible
12346 and appropriate, these threads correspond to native threads of the
12347 underlying operating system.
12352 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
12353 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
12356 There are no implementation-defined policy-identifiers allowed in this
12362 @strong{99}. Implementation-defined aspects of priority inversion. See
12366 Execution of a task cannot be preempted by the implementation processing
12367 of delay expirations for lower priority tasks.
12372 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
12375 The policy is the same as that of the underlying threads implementation.
12380 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
12381 in a pragma @code{Locking_Policy}. See D.3(4).
12384 The two implementation defined policies permitted in GNAT are
12385 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
12386 targets that support the @code{Inheritance_Locking} policy, locking is
12387 implemented by inheritance, i.e.@: the task owning the lock operates
12388 at a priority equal to the highest priority of any task currently
12389 requesting the lock. On targets that support the
12390 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
12391 read/write lock allowing multiple propected object functions to enter
12397 @strong{102}. Default ceiling priorities. See D.3(10).
12400 The ceiling priority of protected objects of the type
12401 @code{System.Interrupt_Priority'Last} as described in the Ada
12402 Reference Manual D.3(10),
12407 @strong{103}. The ceiling of any protected object used internally by
12408 the implementation. See D.3(16).
12411 The ceiling priority of internal protected objects is
12412 @code{System.Priority'Last}.
12417 @strong{104}. Implementation-defined queuing policies. See D.4(1).
12420 There are no implementation-defined queuing policies.
12425 @strong{105}. On a multiprocessor, any conditions that cause the
12426 completion of an aborted construct to be delayed later than what is
12427 specified for a single processor. See D.6(3).
12430 The semantics for abort on a multi-processor is the same as on a single
12431 processor, there are no further delays.
12436 @strong{106}. Any operations that implicitly require heap storage
12437 allocation. See D.7(8).
12440 The only operation that implicitly requires heap storage allocation is
12446 @strong{107}. Implementation-defined aspects of pragma
12447 @code{Restrictions}. See D.7(20).
12450 There are no such implementation-defined aspects.
12455 @strong{108}. Implementation-defined aspects of package
12456 @code{Real_Time}. See D.8(17).
12459 There are no implementation defined aspects of package @code{Real_Time}.
12464 @strong{109}. Implementation-defined aspects of
12465 @code{delay_statements}. See D.9(8).
12468 Any difference greater than one microsecond will cause the task to be
12469 delayed (see D.9(7)).
12474 @strong{110}. The upper bound on the duration of interrupt blocking
12475 caused by the implementation. See D.12(5).
12478 The upper bound is determined by the underlying operating system. In
12479 no cases is it more than 10 milliseconds.
12484 @strong{111}. The means for creating and executing distributed
12485 programs. See E(5).
12488 The GLADE package provides a utility GNATDIST for creating and executing
12489 distributed programs. See the GLADE reference manual for further details.
12494 @strong{112}. Any events that can result in a partition becoming
12495 inaccessible. See E.1(7).
12498 See the GLADE reference manual for full details on such events.
12503 @strong{113}. The scheduling policies, treatment of priorities, and
12504 management of shared resources between partitions in certain cases. See
12508 See the GLADE reference manual for full details on these aspects of
12509 multi-partition execution.
12514 @strong{114}. Events that cause the version of a compilation unit to
12515 change. See E.3(5).
12518 Editing the source file of a compilation unit, or the source files of
12519 any units on which it is dependent in a significant way cause the version
12520 to change. No other actions cause the version number to change. All changes
12521 are significant except those which affect only layout, capitalization or
12527 @strong{115}. Whether the execution of the remote subprogram is
12528 immediately aborted as a result of cancellation. See E.4(13).
12531 See the GLADE reference manual for details on the effect of abort in
12532 a distributed application.
12537 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
12540 See the GLADE reference manual for a full description of all implementation
12541 defined aspects of the PCS@.
12546 @strong{117}. Implementation-defined interfaces in the PCS@. See
12550 See the GLADE reference manual for a full description of all
12551 implementation defined interfaces.
12556 @strong{118}. The values of named numbers in the package
12557 @code{Decimal}. See F.2(7).
12569 @item Max_Decimal_Digits
12576 @strong{119}. The value of @code{Max_Picture_Length} in the package
12577 @code{Text_IO.Editing}. See F.3.3(16).
12585 @strong{120}. The value of @code{Max_Picture_Length} in the package
12586 @code{Wide_Text_IO.Editing}. See F.3.4(5).
12594 @strong{121}. The accuracy actually achieved by the complex elementary
12595 functions and by other complex arithmetic operations. See G.1(1).
12598 Standard library functions are used for the complex arithmetic
12599 operations. Only fast math mode is currently supported.
12604 @strong{122}. The sign of a zero result (or a component thereof) from
12605 any operator or function in @code{Numerics.Generic_Complex_Types}, when
12606 @code{Real'Signed_Zeros} is True. See G.1.1(53).
12609 The signs of zero values are as recommended by the relevant
12610 implementation advice.
12615 @strong{123}. The sign of a zero result (or a component thereof) from
12616 any operator or function in
12617 @code{Numerics.Generic_Complex_Elementary_Functions}, when
12618 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
12621 The signs of zero values are as recommended by the relevant
12622 implementation advice.
12627 @strong{124}. Whether the strict mode or the relaxed mode is the
12628 default. See G.2(2).
12631 The strict mode is the default. There is no separate relaxed mode. GNAT
12632 provides a highly efficient implementation of strict mode.
12637 @strong{125}. The result interval in certain cases of fixed-to-float
12638 conversion. See G.2.1(10).
12641 For cases where the result interval is implementation dependent, the
12642 accuracy is that provided by performing all operations in 64-bit IEEE
12643 floating-point format.
12648 @strong{126}. The result of a floating point arithmetic operation in
12649 overflow situations, when the @code{Machine_Overflows} attribute of the
12650 result type is @code{False}. See G.2.1(13).
12653 Infinite and NaN values are produced as dictated by the IEEE
12654 floating-point standard.
12656 Note that on machines that are not fully compliant with the IEEE
12657 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
12658 must be used for achieving IEEE conforming behavior (although at the cost
12659 of a significant performance penalty), so infinite and NaN values are
12660 properly generated.
12665 @strong{127}. The result interval for division (or exponentiation by a
12666 negative exponent), when the floating point hardware implements division
12667 as multiplication by a reciprocal. See G.2.1(16).
12670 Not relevant, division is IEEE exact.
12675 @strong{128}. The definition of close result set, which determines the
12676 accuracy of certain fixed point multiplications and divisions. See
12680 Operations in the close result set are performed using IEEE long format
12681 floating-point arithmetic. The input operands are converted to
12682 floating-point, the operation is done in floating-point, and the result
12683 is converted to the target type.
12688 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
12689 point multiplication or division for which the result shall be in the
12690 perfect result set. See G.2.3(22).
12693 The result is only defined to be in the perfect result set if the result
12694 can be computed by a single scaling operation involving a scale factor
12695 representable in 64-bits.
12700 @strong{130}. The result of a fixed point arithmetic operation in
12701 overflow situations, when the @code{Machine_Overflows} attribute of the
12702 result type is @code{False}. See G.2.3(27).
12705 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
12711 @strong{131}. The result of an elementary function reference in
12712 overflow situations, when the @code{Machine_Overflows} attribute of the
12713 result type is @code{False}. See G.2.4(4).
12716 IEEE infinite and Nan values are produced as appropriate.
12721 @strong{132}. The value of the angle threshold, within which certain
12722 elementary functions, complex arithmetic operations, and complex
12723 elementary functions yield results conforming to a maximum relative
12724 error bound. See G.2.4(10).
12727 Information on this subject is not yet available.
12732 @strong{133}. The accuracy of certain elementary functions for
12733 parameters beyond the angle threshold. See G.2.4(10).
12736 Information on this subject is not yet available.
12741 @strong{134}. The result of a complex arithmetic operation or complex
12742 elementary function reference in overflow situations, when the
12743 @code{Machine_Overflows} attribute of the corresponding real type is
12744 @code{False}. See G.2.6(5).
12747 IEEE infinite and Nan values are produced as appropriate.
12752 @strong{135}. The accuracy of certain complex arithmetic operations and
12753 certain complex elementary functions for parameters (or components
12754 thereof) beyond the angle threshold. See G.2.6(8).
12757 Information on those subjects is not yet available.
12762 @strong{136}. Information regarding bounded errors and erroneous
12763 execution. See H.2(1).
12766 Information on this subject is not yet available.
12771 @strong{137}. Implementation-defined aspects of pragma
12772 @code{Inspection_Point}. See H.3.2(8).
12775 Pragma @code{Inspection_Point} ensures that the variable is live and can
12776 be examined by the debugger at the inspection point.
12781 @strong{138}. Implementation-defined aspects of pragma
12782 @code{Restrictions}. See H.4(25).
12785 There are no implementation-defined aspects of pragma @code{Restrictions}. The
12786 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
12787 generated code. Checks must suppressed by use of pragma @code{Suppress}.
12792 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
12796 There are no restrictions on pragma @code{Restrictions}.
12798 @node Intrinsic Subprograms
12799 @chapter Intrinsic Subprograms
12800 @cindex Intrinsic Subprograms
12803 * Intrinsic Operators::
12804 * Enclosing_Entity::
12805 * Exception_Information::
12806 * Exception_Message::
12810 * Shifts and Rotates::
12811 * Source_Location::
12815 GNAT allows a user application program to write the declaration:
12817 @smallexample @c ada
12818 pragma Import (Intrinsic, name);
12822 providing that the name corresponds to one of the implemented intrinsic
12823 subprograms in GNAT, and that the parameter profile of the referenced
12824 subprogram meets the requirements. This chapter describes the set of
12825 implemented intrinsic subprograms, and the requirements on parameter profiles.
12826 Note that no body is supplied; as with other uses of pragma Import, the
12827 body is supplied elsewhere (in this case by the compiler itself). Note
12828 that any use of this feature is potentially non-portable, since the
12829 Ada standard does not require Ada compilers to implement this feature.
12831 @node Intrinsic Operators
12832 @section Intrinsic Operators
12833 @cindex Intrinsic operator
12836 All the predefined numeric operators in package Standard
12837 in @code{pragma Import (Intrinsic,..)}
12838 declarations. In the binary operator case, the operands must have the same
12839 size. The operand or operands must also be appropriate for
12840 the operator. For example, for addition, the operands must
12841 both be floating-point or both be fixed-point, and the
12842 right operand for @code{"**"} must have a root type of
12843 @code{Standard.Integer'Base}.
12844 You can use an intrinsic operator declaration as in the following example:
12846 @smallexample @c ada
12847 type Int1 is new Integer;
12848 type Int2 is new Integer;
12850 function "+" (X1 : Int1; X2 : Int2) return Int1;
12851 function "+" (X1 : Int1; X2 : Int2) return Int2;
12852 pragma Import (Intrinsic, "+");
12856 This declaration would permit ``mixed mode'' arithmetic on items
12857 of the differing types @code{Int1} and @code{Int2}.
12858 It is also possible to specify such operators for private types, if the
12859 full views are appropriate arithmetic types.
12861 @node Enclosing_Entity
12862 @section Enclosing_Entity
12863 @cindex Enclosing_Entity
12865 This intrinsic subprogram is used in the implementation of the
12866 library routine @code{GNAT.Source_Info}. The only useful use of the
12867 intrinsic import in this case is the one in this unit, so an
12868 application program should simply call the function
12869 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
12870 the current subprogram, package, task, entry, or protected subprogram.
12872 @node Exception_Information
12873 @section Exception_Information
12874 @cindex Exception_Information'
12876 This intrinsic subprogram is used in the implementation of the
12877 library routine @code{GNAT.Current_Exception}. The only useful
12878 use of the intrinsic import in this case is the one in this unit,
12879 so an application program should simply call the function
12880 @code{GNAT.Current_Exception.Exception_Information} to obtain
12881 the exception information associated with the current exception.
12883 @node Exception_Message
12884 @section Exception_Message
12885 @cindex Exception_Message
12887 This intrinsic subprogram is used in the implementation of the
12888 library routine @code{GNAT.Current_Exception}. The only useful
12889 use of the intrinsic import in this case is the one in this unit,
12890 so an application program should simply call the function
12891 @code{GNAT.Current_Exception.Exception_Message} to obtain
12892 the message associated with the current exception.
12894 @node Exception_Name
12895 @section Exception_Name
12896 @cindex Exception_Name
12898 This intrinsic subprogram is used in the implementation of the
12899 library routine @code{GNAT.Current_Exception}. The only useful
12900 use of the intrinsic import in this case is the one in this unit,
12901 so an application program should simply call the function
12902 @code{GNAT.Current_Exception.Exception_Name} to obtain
12903 the name of the current exception.
12909 This intrinsic subprogram is used in the implementation of the
12910 library routine @code{GNAT.Source_Info}. The only useful use of the
12911 intrinsic import in this case is the one in this unit, so an
12912 application program should simply call the function
12913 @code{GNAT.Source_Info.File} to obtain the name of the current
12920 This intrinsic subprogram is used in the implementation of the
12921 library routine @code{GNAT.Source_Info}. The only useful use of the
12922 intrinsic import in this case is the one in this unit, so an
12923 application program should simply call the function
12924 @code{GNAT.Source_Info.Line} to obtain the number of the current
12927 @node Shifts and Rotates
12928 @section Shifts and Rotates
12930 @cindex Shift_Right
12931 @cindex Shift_Right_Arithmetic
12932 @cindex Rotate_Left
12933 @cindex Rotate_Right
12935 In standard Ada, the shift and rotate functions are available only
12936 for the predefined modular types in package @code{Interfaces}. However, in
12937 GNAT it is possible to define these functions for any integer
12938 type (signed or modular), as in this example:
12940 @smallexample @c ada
12941 function Shift_Left
12948 The function name must be one of
12949 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
12950 Rotate_Right. T must be an integer type. T'Size must be
12951 8, 16, 32 or 64 bits; if T is modular, the modulus
12952 must be 2**8, 2**16, 2**32 or 2**64.
12953 The result type must be the same as the type of @code{Value}.
12954 The shift amount must be Natural.
12955 The formal parameter names can be anything.
12957 @node Source_Location
12958 @section Source_Location
12959 @cindex Source_Location
12961 This intrinsic subprogram is used in the implementation of the
12962 library routine @code{GNAT.Source_Info}. The only useful use of the
12963 intrinsic import in this case is the one in this unit, so an
12964 application program should simply call the function
12965 @code{GNAT.Source_Info.Source_Location} to obtain the current
12966 source file location.
12968 @node Representation Clauses and Pragmas
12969 @chapter Representation Clauses and Pragmas
12970 @cindex Representation Clauses
12973 * Alignment Clauses::
12975 * Storage_Size Clauses::
12976 * Size of Variant Record Objects::
12977 * Biased Representation ::
12978 * Value_Size and Object_Size Clauses::
12979 * Component_Size Clauses::
12980 * Bit_Order Clauses::
12981 * Effect of Bit_Order on Byte Ordering::
12982 * Pragma Pack for Arrays::
12983 * Pragma Pack for Records::
12984 * Record Representation Clauses::
12985 * Enumeration Clauses::
12986 * Address Clauses::
12987 * Effect of Convention on Representation::
12988 * Determining the Representations chosen by GNAT::
12992 @cindex Representation Clause
12993 @cindex Representation Pragma
12994 @cindex Pragma, representation
12995 This section describes the representation clauses accepted by GNAT, and
12996 their effect on the representation of corresponding data objects.
12998 GNAT fully implements Annex C (Systems Programming). This means that all
12999 the implementation advice sections in chapter 13 are fully implemented.
13000 However, these sections only require a minimal level of support for
13001 representation clauses. GNAT provides much more extensive capabilities,
13002 and this section describes the additional capabilities provided.
13004 @node Alignment Clauses
13005 @section Alignment Clauses
13006 @cindex Alignment Clause
13009 GNAT requires that all alignment clauses specify a power of 2, and all
13010 default alignments are always a power of 2. The default alignment
13011 values are as follows:
13014 @item @emph{Primitive Types}.
13015 For primitive types, the alignment is the minimum of the actual size of
13016 objects of the type divided by @code{Storage_Unit},
13017 and the maximum alignment supported by the target.
13018 (This maximum alignment is given by the GNAT-specific attribute
13019 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13020 @cindex @code{Maximum_Alignment} attribute
13021 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13022 default alignment will be 8 on any target that supports alignments
13023 this large, but on some targets, the maximum alignment may be smaller
13024 than 8, in which case objects of type @code{Long_Float} will be maximally
13027 @item @emph{Arrays}.
13028 For arrays, the alignment is equal to the alignment of the component type
13029 for the normal case where no packing or component size is given. If the
13030 array is packed, and the packing is effective (see separate section on
13031 packed arrays), then the alignment will be one for long packed arrays,
13032 or arrays whose length is not known at compile time. For short packed
13033 arrays, which are handled internally as modular types, the alignment
13034 will be as described for primitive types, e.g.@: a packed array of length
13035 31 bits will have an object size of four bytes, and an alignment of 4.
13037 @item @emph{Records}.
13038 For the normal non-packed case, the alignment of a record is equal to
13039 the maximum alignment of any of its components. For tagged records, this
13040 includes the implicit access type used for the tag. If a pragma @code{Pack}
13041 is used and all components are packable (see separate section on pragma
13042 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13043 record makes it profitable to increase it.
13045 A special case is when:
13048 the size of the record is given explicitly, or a
13049 full record representation clause is given, and
13051 the size of the record is 2, 4, or 8 bytes.
13054 In this case, an alignment is chosen to match the
13055 size of the record. For example, if we have:
13057 @smallexample @c ada
13058 type Small is record
13061 for Small'Size use 16;
13065 then the default alignment of the record type @code{Small} is 2, not 1. This
13066 leads to more efficient code when the record is treated as a unit, and also
13067 allows the type to specified as @code{Atomic} on architectures requiring
13073 An alignment clause may specify a larger alignment than the default value
13074 up to some maximum value dependent on the target (obtainable by using the
13075 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13076 a smaller alignment than the default value for enumeration, integer and
13077 fixed point types, as well as for record types, for example
13079 @smallexample @c ada
13084 for V'alignment use 1;
13088 @cindex Alignment, default
13089 The default alignment for the type @code{V} is 4, as a result of the
13090 Integer field in the record, but it is permissible, as shown, to
13091 override the default alignment of the record with a smaller value.
13093 @cindex Alignment, subtypes
13094 Note that according to the Ada standard, an alignment clause applies only
13095 to the first named subtype. If additional subtypes are declared, then the
13096 compiler is allowed to choose any alignment it likes, and there is no way
13097 to control this choice. Consider:
13099 @smallexample @c ada
13100 type R is range 1 .. 10_000;
13101 for R'Alignment use 1;
13102 subtype RS is R range 1 .. 1000;
13106 The alignment clause specifies an alignment of 1 for the first named subtype
13107 @code{R} but this does not necessarily apply to @code{RS}. When writing
13108 portable Ada code, you should avoid writing code that explicitly or
13109 implicitly relies on the alignment of such subtypes.
13111 For the GNAT compiler, if an explicit alignment clause is given, this
13112 value is also used for any subsequent subtypes. So for GNAT, in the
13113 above example, you can count on the alignment of @code{RS} being 1. But this
13114 assumption is non-portable, and other compilers may choose different
13115 alignments for the subtype @code{RS}.
13118 @section Size Clauses
13119 @cindex Size Clause
13122 The default size for a type @code{T} is obtainable through the
13123 language-defined attribute @code{T'Size} and also through the
13124 equivalent GNAT-defined attribute @code{T'Value_Size}.
13125 For objects of type @code{T}, GNAT will generally increase the type size
13126 so that the object size (obtainable through the GNAT-defined attribute
13127 @code{T'Object_Size})
13128 is a multiple of @code{T'Alignment * Storage_Unit}.
13131 @smallexample @c ada
13132 type Smallint is range 1 .. 6;
13141 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13142 as specified by the RM rules,
13143 but objects of this type will have a size of 8
13144 (@code{Smallint'Object_Size} = 8),
13145 since objects by default occupy an integral number
13146 of storage units. On some targets, notably older
13147 versions of the Digital Alpha, the size of stand
13148 alone objects of this type may be 32, reflecting
13149 the inability of the hardware to do byte load/stores.
13151 Similarly, the size of type @code{Rec} is 40 bits
13152 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13153 the alignment is 4, so objects of this type will have
13154 their size increased to 64 bits so that it is a multiple
13155 of the alignment (in bits). This decision is
13156 in accordance with the specific Implementation Advice in RM 13.3(43):
13159 A @code{Size} clause should be supported for an object if the specified
13160 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13161 to a size in storage elements that is a multiple of the object's
13162 @code{Alignment} (if the @code{Alignment} is nonzero).
13166 An explicit size clause may be used to override the default size by
13167 increasing it. For example, if we have:
13169 @smallexample @c ada
13170 type My_Boolean is new Boolean;
13171 for My_Boolean'Size use 32;
13175 then values of this type will always be 32 bits long. In the case of
13176 discrete types, the size can be increased up to 64 bits, with the effect
13177 that the entire specified field is used to hold the value, sign- or
13178 zero-extended as appropriate. If more than 64 bits is specified, then
13179 padding space is allocated after the value, and a warning is issued that
13180 there are unused bits.
13182 Similarly the size of records and arrays may be increased, and the effect
13183 is to add padding bits after the value. This also causes a warning message
13186 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
13187 Size in bits, this corresponds to an object of size 256 megabytes (minus
13188 one). This limitation is true on all targets. The reason for this
13189 limitation is that it improves the quality of the code in many cases
13190 if it is known that a Size value can be accommodated in an object of
13193 @node Storage_Size Clauses
13194 @section Storage_Size Clauses
13195 @cindex Storage_Size Clause
13198 For tasks, the @code{Storage_Size} clause specifies the amount of space
13199 to be allocated for the task stack. This cannot be extended, and if the
13200 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13201 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
13202 or a @code{Storage_Size} pragma in the task definition to set the
13203 appropriate required size. A useful technique is to include in every
13204 task definition a pragma of the form:
13206 @smallexample @c ada
13207 pragma Storage_Size (Default_Stack_Size);
13211 Then @code{Default_Stack_Size} can be defined in a global package, and
13212 modified as required. Any tasks requiring stack sizes different from the
13213 default can have an appropriate alternative reference in the pragma.
13215 You can also use the @option{-d} binder switch to modify the default stack
13218 For access types, the @code{Storage_Size} clause specifies the maximum
13219 space available for allocation of objects of the type. If this space is
13220 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13221 In the case where the access type is declared local to a subprogram, the
13222 use of a @code{Storage_Size} clause triggers automatic use of a special
13223 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13224 space for the pool is automatically reclaimed on exit from the scope in
13225 which the type is declared.
13227 A special case recognized by the compiler is the specification of a
13228 @code{Storage_Size} of zero for an access type. This means that no
13229 items can be allocated from the pool, and this is recognized at compile
13230 time, and all the overhead normally associated with maintaining a fixed
13231 size storage pool is eliminated. Consider the following example:
13233 @smallexample @c ada
13235 type R is array (Natural) of Character;
13236 type P is access all R;
13237 for P'Storage_Size use 0;
13238 -- Above access type intended only for interfacing purposes
13242 procedure g (m : P);
13243 pragma Import (C, g);
13254 As indicated in this example, these dummy storage pools are often useful in
13255 connection with interfacing where no object will ever be allocated. If you
13256 compile the above example, you get the warning:
13259 p.adb:16:09: warning: allocation from empty storage pool
13260 p.adb:16:09: warning: Storage_Error will be raised at run time
13264 Of course in practice, there will not be any explicit allocators in the
13265 case of such an access declaration.
13267 @node Size of Variant Record Objects
13268 @section Size of Variant Record Objects
13269 @cindex Size, variant record objects
13270 @cindex Variant record objects, size
13273 In the case of variant record objects, there is a question whether Size gives
13274 information about a particular variant, or the maximum size required
13275 for any variant. Consider the following program
13277 @smallexample @c ada
13278 with Text_IO; use Text_IO;
13280 type R1 (A : Boolean := False) is record
13282 when True => X : Character;
13283 when False => null;
13291 Put_Line (Integer'Image (V1'Size));
13292 Put_Line (Integer'Image (V2'Size));
13297 Here we are dealing with a variant record, where the True variant
13298 requires 16 bits, and the False variant requires 8 bits.
13299 In the above example, both V1 and V2 contain the False variant,
13300 which is only 8 bits long. However, the result of running the
13309 The reason for the difference here is that the discriminant value of
13310 V1 is fixed, and will always be False. It is not possible to assign
13311 a True variant value to V1, therefore 8 bits is sufficient. On the
13312 other hand, in the case of V2, the initial discriminant value is
13313 False (from the default), but it is possible to assign a True
13314 variant value to V2, therefore 16 bits must be allocated for V2
13315 in the general case, even fewer bits may be needed at any particular
13316 point during the program execution.
13318 As can be seen from the output of this program, the @code{'Size}
13319 attribute applied to such an object in GNAT gives the actual allocated
13320 size of the variable, which is the largest size of any of the variants.
13321 The Ada Reference Manual is not completely clear on what choice should
13322 be made here, but the GNAT behavior seems most consistent with the
13323 language in the RM@.
13325 In some cases, it may be desirable to obtain the size of the current
13326 variant, rather than the size of the largest variant. This can be
13327 achieved in GNAT by making use of the fact that in the case of a
13328 subprogram parameter, GNAT does indeed return the size of the current
13329 variant (because a subprogram has no way of knowing how much space
13330 is actually allocated for the actual).
13332 Consider the following modified version of the above program:
13334 @smallexample @c ada
13335 with Text_IO; use Text_IO;
13337 type R1 (A : Boolean := False) is record
13339 when True => X : Character;
13340 when False => null;
13346 function Size (V : R1) return Integer is
13352 Put_Line (Integer'Image (V2'Size));
13353 Put_Line (Integer'IMage (Size (V2)));
13355 Put_Line (Integer'Image (V2'Size));
13356 Put_Line (Integer'IMage (Size (V2)));
13361 The output from this program is
13371 Here we see that while the @code{'Size} attribute always returns
13372 the maximum size, regardless of the current variant value, the
13373 @code{Size} function does indeed return the size of the current
13376 @node Biased Representation
13377 @section Biased Representation
13378 @cindex Size for biased representation
13379 @cindex Biased representation
13382 In the case of scalars with a range starting at other than zero, it is
13383 possible in some cases to specify a size smaller than the default minimum
13384 value, and in such cases, GNAT uses an unsigned biased representation,
13385 in which zero is used to represent the lower bound, and successive values
13386 represent successive values of the type.
13388 For example, suppose we have the declaration:
13390 @smallexample @c ada
13391 type Small is range -7 .. -4;
13392 for Small'Size use 2;
13396 Although the default size of type @code{Small} is 4, the @code{Size}
13397 clause is accepted by GNAT and results in the following representation
13401 -7 is represented as 2#00#
13402 -6 is represented as 2#01#
13403 -5 is represented as 2#10#
13404 -4 is represented as 2#11#
13408 Biased representation is only used if the specified @code{Size} clause
13409 cannot be accepted in any other manner. These reduced sizes that force
13410 biased representation can be used for all discrete types except for
13411 enumeration types for which a representation clause is given.
13413 @node Value_Size and Object_Size Clauses
13414 @section Value_Size and Object_Size Clauses
13416 @findex Object_Size
13417 @cindex Size, of objects
13420 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
13421 number of bits required to hold values of type @code{T}.
13422 Although this interpretation was allowed in Ada 83, it was not required,
13423 and this requirement in practice can cause some significant difficulties.
13424 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
13425 However, in Ada 95 and Ada 2005,
13426 @code{Natural'Size} is
13427 typically 31. This means that code may change in behavior when moving
13428 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
13430 @smallexample @c ada
13431 type Rec is record;
13437 at 0 range 0 .. Natural'Size - 1;
13438 at 0 range Natural'Size .. 2 * Natural'Size - 1;
13443 In the above code, since the typical size of @code{Natural} objects
13444 is 32 bits and @code{Natural'Size} is 31, the above code can cause
13445 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
13446 there are cases where the fact that the object size can exceed the
13447 size of the type causes surprises.
13449 To help get around this problem GNAT provides two implementation
13450 defined attributes, @code{Value_Size} and @code{Object_Size}. When
13451 applied to a type, these attributes yield the size of the type
13452 (corresponding to the RM defined size attribute), and the size of
13453 objects of the type respectively.
13455 The @code{Object_Size} is used for determining the default size of
13456 objects and components. This size value can be referred to using the
13457 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
13458 the basis of the determination of the size. The backend is free to
13459 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
13460 character might be stored in 32 bits on a machine with no efficient
13461 byte access instructions such as the Alpha.
13463 The default rules for the value of @code{Object_Size} for
13464 discrete types are as follows:
13468 The @code{Object_Size} for base subtypes reflect the natural hardware
13469 size in bits (run the compiler with @option{-gnatS} to find those values
13470 for numeric types). Enumeration types and fixed-point base subtypes have
13471 8, 16, 32 or 64 bits for this size, depending on the range of values
13475 The @code{Object_Size} of a subtype is the same as the
13476 @code{Object_Size} of
13477 the type from which it is obtained.
13480 The @code{Object_Size} of a derived base type is copied from the parent
13481 base type, and the @code{Object_Size} of a derived first subtype is copied
13482 from the parent first subtype.
13486 The @code{Value_Size} attribute
13487 is the (minimum) number of bits required to store a value
13489 This value is used to determine how tightly to pack
13490 records or arrays with components of this type, and also affects
13491 the semantics of unchecked conversion (unchecked conversions where
13492 the @code{Value_Size} values differ generate a warning, and are potentially
13495 The default rules for the value of @code{Value_Size} are as follows:
13499 The @code{Value_Size} for a base subtype is the minimum number of bits
13500 required to store all values of the type (including the sign bit
13501 only if negative values are possible).
13504 If a subtype statically matches the first subtype of a given type, then it has
13505 by default the same @code{Value_Size} as the first subtype. This is a
13506 consequence of RM 13.1(14) (``if two subtypes statically match,
13507 then their subtype-specific aspects are the same''.)
13510 All other subtypes have a @code{Value_Size} corresponding to the minimum
13511 number of bits required to store all values of the subtype. For
13512 dynamic bounds, it is assumed that the value can range down or up
13513 to the corresponding bound of the ancestor
13517 The RM defined attribute @code{Size} corresponds to the
13518 @code{Value_Size} attribute.
13520 The @code{Size} attribute may be defined for a first-named subtype. This sets
13521 the @code{Value_Size} of
13522 the first-named subtype to the given value, and the
13523 @code{Object_Size} of this first-named subtype to the given value padded up
13524 to an appropriate boundary. It is a consequence of the default rules
13525 above that this @code{Object_Size} will apply to all further subtypes. On the
13526 other hand, @code{Value_Size} is affected only for the first subtype, any
13527 dynamic subtypes obtained from it directly, and any statically matching
13528 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
13530 @code{Value_Size} and
13531 @code{Object_Size} may be explicitly set for any subtype using
13532 an attribute definition clause. Note that the use of these attributes
13533 can cause the RM 13.1(14) rule to be violated. If two access types
13534 reference aliased objects whose subtypes have differing @code{Object_Size}
13535 values as a result of explicit attribute definition clauses, then it
13536 is erroneous to convert from one access subtype to the other.
13538 At the implementation level, Esize stores the Object_Size and the
13539 RM_Size field stores the @code{Value_Size} (and hence the value of the
13540 @code{Size} attribute,
13541 which, as noted above, is equivalent to @code{Value_Size}).
13543 To get a feel for the difference, consider the following examples (note
13544 that in each case the base is @code{Short_Short_Integer} with a size of 8):
13547 Object_Size Value_Size
13549 type x1 is range 0 .. 5; 8 3
13551 type x2 is range 0 .. 5;
13552 for x2'size use 12; 16 12
13554 subtype x3 is x2 range 0 .. 3; 16 2
13556 subtype x4 is x2'base range 0 .. 10; 8 4
13558 subtype x5 is x2 range 0 .. dynamic; 16 3*
13560 subtype x6 is x2'base range 0 .. dynamic; 8 3*
13565 Note: the entries marked ``3*'' are not actually specified by the Ada
13566 Reference Manual, but it seems in the spirit of the RM rules to allocate
13567 the minimum number of bits (here 3, given the range for @code{x2})
13568 known to be large enough to hold the given range of values.
13570 So far, so good, but GNAT has to obey the RM rules, so the question is
13571 under what conditions must the RM @code{Size} be used.
13572 The following is a list
13573 of the occasions on which the RM @code{Size} must be used:
13577 Component size for packed arrays or records
13580 Value of the attribute @code{Size} for a type
13583 Warning about sizes not matching for unchecked conversion
13587 For record types, the @code{Object_Size} is always a multiple of the
13588 alignment of the type (this is true for all types). In some cases the
13589 @code{Value_Size} can be smaller. Consider:
13599 On a typical 32-bit architecture, the X component will be four bytes, and
13600 require four-byte alignment, and the Y component will be one byte. In this
13601 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
13602 required to store a value of this type, and for example, it is permissible
13603 to have a component of type R in an outer array whose component size is
13604 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
13605 since it must be rounded up so that this value is a multiple of the
13606 alignment (4 bytes = 32 bits).
13609 For all other types, the @code{Object_Size}
13610 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
13611 Only @code{Size} may be specified for such types.
13613 @node Component_Size Clauses
13614 @section Component_Size Clauses
13615 @cindex Component_Size Clause
13618 Normally, the value specified in a component size clause must be consistent
13619 with the subtype of the array component with regard to size and alignment.
13620 In other words, the value specified must be at least equal to the size
13621 of this subtype, and must be a multiple of the alignment value.
13623 In addition, component size clauses are allowed which cause the array
13624 to be packed, by specifying a smaller value. A first case is for
13625 component size values in the range 1 through 63. The value specified
13626 must not be smaller than the Size of the subtype. GNAT will accurately
13627 honor all packing requests in this range. For example, if we have:
13629 @smallexample @c ada
13630 type r is array (1 .. 8) of Natural;
13631 for r'Component_Size use 31;
13635 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
13636 Of course access to the components of such an array is considerably
13637 less efficient than if the natural component size of 32 is used.
13638 A second case is when the subtype of the component is a record type
13639 padded because of its default alignment. For example, if we have:
13641 @smallexample @c ada
13648 type a is array (1 .. 8) of r;
13649 for a'Component_Size use 72;
13653 then the resulting array has a length of 72 bytes, instead of 96 bytes
13654 if the alignment of the record (4) was obeyed.
13656 Note that there is no point in giving both a component size clause
13657 and a pragma Pack for the same array type. if such duplicate
13658 clauses are given, the pragma Pack will be ignored.
13660 @node Bit_Order Clauses
13661 @section Bit_Order Clauses
13662 @cindex Bit_Order Clause
13663 @cindex bit ordering
13664 @cindex ordering, of bits
13667 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
13668 attribute. The specification may either correspond to the default bit
13669 order for the target, in which case the specification has no effect and
13670 places no additional restrictions, or it may be for the non-standard
13671 setting (that is the opposite of the default).
13673 In the case where the non-standard value is specified, the effect is
13674 to renumber bits within each byte, but the ordering of bytes is not
13675 affected. There are certain
13676 restrictions placed on component clauses as follows:
13680 @item Components fitting within a single storage unit.
13682 These are unrestricted, and the effect is merely to renumber bits. For
13683 example if we are on a little-endian machine with @code{Low_Order_First}
13684 being the default, then the following two declarations have exactly
13687 @smallexample @c ada
13690 B : Integer range 1 .. 120;
13694 A at 0 range 0 .. 0;
13695 B at 0 range 1 .. 7;
13700 B : Integer range 1 .. 120;
13703 for R2'Bit_Order use High_Order_First;
13706 A at 0 range 7 .. 7;
13707 B at 0 range 0 .. 6;
13712 The useful application here is to write the second declaration with the
13713 @code{Bit_Order} attribute definition clause, and know that it will be treated
13714 the same, regardless of whether the target is little-endian or big-endian.
13716 @item Components occupying an integral number of bytes.
13718 These are components that exactly fit in two or more bytes. Such component
13719 declarations are allowed, but have no effect, since it is important to realize
13720 that the @code{Bit_Order} specification does not affect the ordering of bytes.
13721 In particular, the following attempt at getting an endian-independent integer
13724 @smallexample @c ada
13729 for R2'Bit_Order use High_Order_First;
13732 A at 0 range 0 .. 31;
13737 This declaration will result in a little-endian integer on a
13738 little-endian machine, and a big-endian integer on a big-endian machine.
13739 If byte flipping is required for interoperability between big- and
13740 little-endian machines, this must be explicitly programmed. This capability
13741 is not provided by @code{Bit_Order}.
13743 @item Components that are positioned across byte boundaries
13745 but do not occupy an integral number of bytes. Given that bytes are not
13746 reordered, such fields would occupy a non-contiguous sequence of bits
13747 in memory, requiring non-trivial code to reassemble. They are for this
13748 reason not permitted, and any component clause specifying such a layout
13749 will be flagged as illegal by GNAT@.
13754 Since the misconception that Bit_Order automatically deals with all
13755 endian-related incompatibilities is a common one, the specification of
13756 a component field that is an integral number of bytes will always
13757 generate a warning. This warning may be suppressed using @code{pragma
13758 Warnings (Off)} if desired. The following section contains additional
13759 details regarding the issue of byte ordering.
13761 @node Effect of Bit_Order on Byte Ordering
13762 @section Effect of Bit_Order on Byte Ordering
13763 @cindex byte ordering
13764 @cindex ordering, of bytes
13767 In this section we will review the effect of the @code{Bit_Order} attribute
13768 definition clause on byte ordering. Briefly, it has no effect at all, but
13769 a detailed example will be helpful. Before giving this
13770 example, let us review the precise
13771 definition of the effect of defining @code{Bit_Order}. The effect of a
13772 non-standard bit order is described in section 15.5.3 of the Ada
13776 2 A bit ordering is a method of interpreting the meaning of
13777 the storage place attributes.
13781 To understand the precise definition of storage place attributes in
13782 this context, we visit section 13.5.1 of the manual:
13785 13 A record_representation_clause (without the mod_clause)
13786 specifies the layout. The storage place attributes (see 13.5.2)
13787 are taken from the values of the position, first_bit, and last_bit
13788 expressions after normalizing those values so that first_bit is
13789 less than Storage_Unit.
13793 The critical point here is that storage places are taken from
13794 the values after normalization, not before. So the @code{Bit_Order}
13795 interpretation applies to normalized values. The interpretation
13796 is described in the later part of the 15.5.3 paragraph:
13799 2 A bit ordering is a method of interpreting the meaning of
13800 the storage place attributes. High_Order_First (known in the
13801 vernacular as ``big endian'') means that the first bit of a
13802 storage element (bit 0) is the most significant bit (interpreting
13803 the sequence of bits that represent a component as an unsigned
13804 integer value). Low_Order_First (known in the vernacular as
13805 ``little endian'') means the opposite: the first bit is the
13810 Note that the numbering is with respect to the bits of a storage
13811 unit. In other words, the specification affects only the numbering
13812 of bits within a single storage unit.
13814 We can make the effect clearer by giving an example.
13816 Suppose that we have an external device which presents two bytes, the first
13817 byte presented, which is the first (low addressed byte) of the two byte
13818 record is called Master, and the second byte is called Slave.
13820 The left most (most significant bit is called Control for each byte, and
13821 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
13822 (least significant) bit.
13824 On a big-endian machine, we can write the following representation clause
13826 @smallexample @c ada
13827 type Data is record
13828 Master_Control : Bit;
13836 Slave_Control : Bit;
13846 for Data use record
13847 Master_Control at 0 range 0 .. 0;
13848 Master_V1 at 0 range 1 .. 1;
13849 Master_V2 at 0 range 2 .. 2;
13850 Master_V3 at 0 range 3 .. 3;
13851 Master_V4 at 0 range 4 .. 4;
13852 Master_V5 at 0 range 5 .. 5;
13853 Master_V6 at 0 range 6 .. 6;
13854 Master_V7 at 0 range 7 .. 7;
13855 Slave_Control at 1 range 0 .. 0;
13856 Slave_V1 at 1 range 1 .. 1;
13857 Slave_V2 at 1 range 2 .. 2;
13858 Slave_V3 at 1 range 3 .. 3;
13859 Slave_V4 at 1 range 4 .. 4;
13860 Slave_V5 at 1 range 5 .. 5;
13861 Slave_V6 at 1 range 6 .. 6;
13862 Slave_V7 at 1 range 7 .. 7;
13867 Now if we move this to a little endian machine, then the bit ordering within
13868 the byte is backwards, so we have to rewrite the record rep clause as:
13870 @smallexample @c ada
13871 for Data use record
13872 Master_Control at 0 range 7 .. 7;
13873 Master_V1 at 0 range 6 .. 6;
13874 Master_V2 at 0 range 5 .. 5;
13875 Master_V3 at 0 range 4 .. 4;
13876 Master_V4 at 0 range 3 .. 3;
13877 Master_V5 at 0 range 2 .. 2;
13878 Master_V6 at 0 range 1 .. 1;
13879 Master_V7 at 0 range 0 .. 0;
13880 Slave_Control at 1 range 7 .. 7;
13881 Slave_V1 at 1 range 6 .. 6;
13882 Slave_V2 at 1 range 5 .. 5;
13883 Slave_V3 at 1 range 4 .. 4;
13884 Slave_V4 at 1 range 3 .. 3;
13885 Slave_V5 at 1 range 2 .. 2;
13886 Slave_V6 at 1 range 1 .. 1;
13887 Slave_V7 at 1 range 0 .. 0;
13892 It is a nuisance to have to rewrite the clause, especially if
13893 the code has to be maintained on both machines. However,
13894 this is a case that we can handle with the
13895 @code{Bit_Order} attribute if it is implemented.
13896 Note that the implementation is not required on byte addressed
13897 machines, but it is indeed implemented in GNAT.
13898 This means that we can simply use the
13899 first record clause, together with the declaration
13901 @smallexample @c ada
13902 for Data'Bit_Order use High_Order_First;
13906 and the effect is what is desired, namely the layout is exactly the same,
13907 independent of whether the code is compiled on a big-endian or little-endian
13910 The important point to understand is that byte ordering is not affected.
13911 A @code{Bit_Order} attribute definition never affects which byte a field
13912 ends up in, only where it ends up in that byte.
13913 To make this clear, let us rewrite the record rep clause of the previous
13916 @smallexample @c ada
13917 for Data'Bit_Order use High_Order_First;
13918 for Data use record
13919 Master_Control at 0 range 0 .. 0;
13920 Master_V1 at 0 range 1 .. 1;
13921 Master_V2 at 0 range 2 .. 2;
13922 Master_V3 at 0 range 3 .. 3;
13923 Master_V4 at 0 range 4 .. 4;
13924 Master_V5 at 0 range 5 .. 5;
13925 Master_V6 at 0 range 6 .. 6;
13926 Master_V7 at 0 range 7 .. 7;
13927 Slave_Control at 0 range 8 .. 8;
13928 Slave_V1 at 0 range 9 .. 9;
13929 Slave_V2 at 0 range 10 .. 10;
13930 Slave_V3 at 0 range 11 .. 11;
13931 Slave_V4 at 0 range 12 .. 12;
13932 Slave_V5 at 0 range 13 .. 13;
13933 Slave_V6 at 0 range 14 .. 14;
13934 Slave_V7 at 0 range 15 .. 15;
13939 This is exactly equivalent to saying (a repeat of the first example):
13941 @smallexample @c ada
13942 for Data'Bit_Order use High_Order_First;
13943 for Data use record
13944 Master_Control at 0 range 0 .. 0;
13945 Master_V1 at 0 range 1 .. 1;
13946 Master_V2 at 0 range 2 .. 2;
13947 Master_V3 at 0 range 3 .. 3;
13948 Master_V4 at 0 range 4 .. 4;
13949 Master_V5 at 0 range 5 .. 5;
13950 Master_V6 at 0 range 6 .. 6;
13951 Master_V7 at 0 range 7 .. 7;
13952 Slave_Control at 1 range 0 .. 0;
13953 Slave_V1 at 1 range 1 .. 1;
13954 Slave_V2 at 1 range 2 .. 2;
13955 Slave_V3 at 1 range 3 .. 3;
13956 Slave_V4 at 1 range 4 .. 4;
13957 Slave_V5 at 1 range 5 .. 5;
13958 Slave_V6 at 1 range 6 .. 6;
13959 Slave_V7 at 1 range 7 .. 7;
13964 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
13965 field. The storage place attributes are obtained by normalizing the
13966 values given so that the @code{First_Bit} value is less than 8. After
13967 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
13968 we specified in the other case.
13970 Now one might expect that the @code{Bit_Order} attribute might affect
13971 bit numbering within the entire record component (two bytes in this
13972 case, thus affecting which byte fields end up in), but that is not
13973 the way this feature is defined, it only affects numbering of bits,
13974 not which byte they end up in.
13976 Consequently it never makes sense to specify a starting bit number
13977 greater than 7 (for a byte addressable field) if an attribute
13978 definition for @code{Bit_Order} has been given, and indeed it
13979 may be actively confusing to specify such a value, so the compiler
13980 generates a warning for such usage.
13982 If you do need to control byte ordering then appropriate conditional
13983 values must be used. If in our example, the slave byte came first on
13984 some machines we might write:
13986 @smallexample @c ada
13987 Master_Byte_First constant Boolean := @dots{};
13989 Master_Byte : constant Natural :=
13990 1 - Boolean'Pos (Master_Byte_First);
13991 Slave_Byte : constant Natural :=
13992 Boolean'Pos (Master_Byte_First);
13994 for Data'Bit_Order use High_Order_First;
13995 for Data use record
13996 Master_Control at Master_Byte range 0 .. 0;
13997 Master_V1 at Master_Byte range 1 .. 1;
13998 Master_V2 at Master_Byte range 2 .. 2;
13999 Master_V3 at Master_Byte range 3 .. 3;
14000 Master_V4 at Master_Byte range 4 .. 4;
14001 Master_V5 at Master_Byte range 5 .. 5;
14002 Master_V6 at Master_Byte range 6 .. 6;
14003 Master_V7 at Master_Byte range 7 .. 7;
14004 Slave_Control at Slave_Byte range 0 .. 0;
14005 Slave_V1 at Slave_Byte range 1 .. 1;
14006 Slave_V2 at Slave_Byte range 2 .. 2;
14007 Slave_V3 at Slave_Byte range 3 .. 3;
14008 Slave_V4 at Slave_Byte range 4 .. 4;
14009 Slave_V5 at Slave_Byte range 5 .. 5;
14010 Slave_V6 at Slave_Byte range 6 .. 6;
14011 Slave_V7 at Slave_Byte range 7 .. 7;
14016 Now to switch between machines, all that is necessary is
14017 to set the boolean constant @code{Master_Byte_First} in
14018 an appropriate manner.
14020 @node Pragma Pack for Arrays
14021 @section Pragma Pack for Arrays
14022 @cindex Pragma Pack (for arrays)
14025 Pragma @code{Pack} applied to an array has no effect unless the component type
14026 is packable. For a component type to be packable, it must be one of the
14033 Any type whose size is specified with a size clause
14035 Any packed array type with a static size
14037 Any record type padded because of its default alignment
14041 For all these cases, if the component subtype size is in the range
14042 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14043 component size were specified giving the component subtype size.
14044 For example if we have:
14046 @smallexample @c ada
14047 type r is range 0 .. 17;
14049 type ar is array (1 .. 8) of r;
14054 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14055 and the size of the array @code{ar} will be exactly 40 bits.
14057 Note that in some cases this rather fierce approach to packing can produce
14058 unexpected effects. For example, in Ada 95 and Ada 2005,
14059 subtype @code{Natural} typically has a size of 31, meaning that if you
14060 pack an array of @code{Natural}, you get 31-bit
14061 close packing, which saves a few bits, but results in far less efficient
14062 access. Since many other Ada compilers will ignore such a packing request,
14063 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14064 might not be what is intended. You can easily remove this warning by
14065 using an explicit @code{Component_Size} setting instead, which never generates
14066 a warning, since the intention of the programmer is clear in this case.
14068 GNAT treats packed arrays in one of two ways. If the size of the array is
14069 known at compile time and is less than 64 bits, then internally the array
14070 is represented as a single modular type, of exactly the appropriate number
14071 of bits. If the length is greater than 63 bits, or is not known at compile
14072 time, then the packed array is represented as an array of bytes, and the
14073 length is always a multiple of 8 bits.
14075 Note that to represent a packed array as a modular type, the alignment must
14076 be suitable for the modular type involved. For example, on typical machines
14077 a 32-bit packed array will be represented by a 32-bit modular integer with
14078 an alignment of four bytes. If you explicitly override the default alignment
14079 with an alignment clause that is too small, the modular representation
14080 cannot be used. For example, consider the following set of declarations:
14082 @smallexample @c ada
14083 type R is range 1 .. 3;
14084 type S is array (1 .. 31) of R;
14085 for S'Component_Size use 2;
14087 for S'Alignment use 1;
14091 If the alignment clause were not present, then a 62-bit modular
14092 representation would be chosen (typically with an alignment of 4 or 8
14093 bytes depending on the target). But the default alignment is overridden
14094 with the explicit alignment clause. This means that the modular
14095 representation cannot be used, and instead the array of bytes
14096 representation must be used, meaning that the length must be a multiple
14097 of 8. Thus the above set of declarations will result in a diagnostic
14098 rejecting the size clause and noting that the minimum size allowed is 64.
14100 @cindex Pragma Pack (for type Natural)
14101 @cindex Pragma Pack warning
14103 One special case that is worth noting occurs when the base type of the
14104 component size is 8/16/32 and the subtype is one bit less. Notably this
14105 occurs with subtype @code{Natural}. Consider:
14107 @smallexample @c ada
14108 type Arr is array (1 .. 32) of Natural;
14113 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14114 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14115 Ada 83 compilers did not attempt 31 bit packing.
14117 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14118 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14119 substantial unintended performance penalty when porting legacy Ada 83 code.
14120 To help prevent this, GNAT generates a warning in such cases. If you really
14121 want 31 bit packing in a case like this, you can set the component size
14124 @smallexample @c ada
14125 type Arr is array (1 .. 32) of Natural;
14126 for Arr'Component_Size use 31;
14130 Here 31-bit packing is achieved as required, and no warning is generated,
14131 since in this case the programmer intention is clear.
14133 @node Pragma Pack for Records
14134 @section Pragma Pack for Records
14135 @cindex Pragma Pack (for records)
14138 Pragma @code{Pack} applied to a record will pack the components to reduce
14139 wasted space from alignment gaps and by reducing the amount of space
14140 taken by components. We distinguish between @emph{packable} components and
14141 @emph{non-packable} components.
14142 Components of the following types are considered packable:
14145 All primitive types are packable.
14148 Small packed arrays, whose size does not exceed 64 bits, and where the
14149 size is statically known at compile time, are represented internally
14150 as modular integers, and so they are also packable.
14155 All packable components occupy the exact number of bits corresponding to
14156 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14157 can start on an arbitrary bit boundary.
14159 All other types are non-packable, they occupy an integral number of
14161 are placed at a boundary corresponding to their alignment requirements.
14163 For example, consider the record
14165 @smallexample @c ada
14166 type Rb1 is array (1 .. 13) of Boolean;
14169 type Rb2 is array (1 .. 65) of Boolean;
14184 The representation for the record x2 is as follows:
14186 @smallexample @c ada
14187 for x2'Size use 224;
14189 l1 at 0 range 0 .. 0;
14190 l2 at 0 range 1 .. 64;
14191 l3 at 12 range 0 .. 31;
14192 l4 at 16 range 0 .. 0;
14193 l5 at 16 range 1 .. 13;
14194 l6 at 18 range 0 .. 71;
14199 Studying this example, we see that the packable fields @code{l1}
14201 of length equal to their sizes, and placed at specific bit boundaries (and
14202 not byte boundaries) to
14203 eliminate padding. But @code{l3} is of a non-packable float type, so
14204 it is on the next appropriate alignment boundary.
14206 The next two fields are fully packable, so @code{l4} and @code{l5} are
14207 minimally packed with no gaps. However, type @code{Rb2} is a packed
14208 array that is longer than 64 bits, so it is itself non-packable. Thus
14209 the @code{l6} field is aligned to the next byte boundary, and takes an
14210 integral number of bytes, i.e.@: 72 bits.
14212 @node Record Representation Clauses
14213 @section Record Representation Clauses
14214 @cindex Record Representation Clause
14217 Record representation clauses may be given for all record types, including
14218 types obtained by record extension. Component clauses are allowed for any
14219 static component. The restrictions on component clauses depend on the type
14222 @cindex Component Clause
14223 For all components of an elementary type, the only restriction on component
14224 clauses is that the size must be at least the 'Size value of the type
14225 (actually the Value_Size). There are no restrictions due to alignment,
14226 and such components may freely cross storage boundaries.
14228 Packed arrays with a size up to and including 64 bits are represented
14229 internally using a modular type with the appropriate number of bits, and
14230 thus the same lack of restriction applies. For example, if you declare:
14232 @smallexample @c ada
14233 type R is array (1 .. 49) of Boolean;
14239 then a component clause for a component of type R may start on any
14240 specified bit boundary, and may specify a value of 49 bits or greater.
14242 For packed bit arrays that are longer than 64 bits, there are two
14243 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14244 including the important case of single bits or boolean values, then
14245 there are no limitations on placement of such components, and they
14246 may start and end at arbitrary bit boundaries.
14248 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14249 an array of this type longer than 64 bits must always be placed on
14250 on a storage unit (byte) boundary and occupy an integral number
14251 of storage units (bytes). Any component clause that does not
14252 meet this requirement will be rejected.
14254 Any aliased component, or component of an aliased type, must
14255 have its normal alignment and size. A component clause that
14256 does not meet this requirement will be rejected.
14258 The tag field of a tagged type always occupies an address sized field at
14259 the start of the record. No component clause may attempt to overlay this
14260 tag. When a tagged type appears as a component, the tag field must have
14263 In the case of a record extension T1, of a type T, no component clause applied
14264 to the type T1 can specify a storage location that would overlap the first
14265 T'Size bytes of the record.
14267 For all other component types, including non-bit-packed arrays,
14268 the component can be placed at an arbitrary bit boundary,
14269 so for example, the following is permitted:
14271 @smallexample @c ada
14272 type R is array (1 .. 10) of Boolean;
14281 G at 0 range 0 .. 0;
14282 H at 0 range 1 .. 1;
14283 L at 0 range 2 .. 81;
14284 R at 0 range 82 .. 161;
14289 Note: the above rules apply to recent releases of GNAT 5.
14290 In GNAT 3, there are more severe restrictions on larger components.
14291 For non-primitive types, including packed arrays with a size greater than
14292 64 bits, component clauses must respect the alignment requirement of the
14293 type, in particular, always starting on a byte boundary, and the length
14294 must be a multiple of the storage unit.
14296 @node Enumeration Clauses
14297 @section Enumeration Clauses
14299 The only restriction on enumeration clauses is that the range of values
14300 must be representable. For the signed case, if one or more of the
14301 representation values are negative, all values must be in the range:
14303 @smallexample @c ada
14304 System.Min_Int .. System.Max_Int
14308 For the unsigned case, where all values are nonnegative, the values must
14311 @smallexample @c ada
14312 0 .. System.Max_Binary_Modulus;
14316 A @emph{confirming} representation clause is one in which the values range
14317 from 0 in sequence, i.e.@: a clause that confirms the default representation
14318 for an enumeration type.
14319 Such a confirming representation
14320 is permitted by these rules, and is specially recognized by the compiler so
14321 that no extra overhead results from the use of such a clause.
14323 If an array has an index type which is an enumeration type to which an
14324 enumeration clause has been applied, then the array is stored in a compact
14325 manner. Consider the declarations:
14327 @smallexample @c ada
14328 type r is (A, B, C);
14329 for r use (A => 1, B => 5, C => 10);
14330 type t is array (r) of Character;
14334 The array type t corresponds to a vector with exactly three elements and
14335 has a default size equal to @code{3*Character'Size}. This ensures efficient
14336 use of space, but means that accesses to elements of the array will incur
14337 the overhead of converting representation values to the corresponding
14338 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
14340 @node Address Clauses
14341 @section Address Clauses
14342 @cindex Address Clause
14344 The reference manual allows a general restriction on representation clauses,
14345 as found in RM 13.1(22):
14348 An implementation need not support representation
14349 items containing nonstatic expressions, except that
14350 an implementation should support a representation item
14351 for a given entity if each nonstatic expression in the
14352 representation item is a name that statically denotes
14353 a constant declared before the entity.
14357 In practice this is applicable only to address clauses, since this is the
14358 only case in which a non-static expression is permitted by the syntax. As
14359 the AARM notes in sections 13.1 (22.a-22.h):
14362 22.a Reason: This is to avoid the following sort of thing:
14364 22.b X : Integer := F(@dots{});
14365 Y : Address := G(@dots{});
14366 for X'Address use Y;
14368 22.c In the above, we have to evaluate the
14369 initialization expression for X before we
14370 know where to put the result. This seems
14371 like an unreasonable implementation burden.
14373 22.d The above code should instead be written
14376 22.e Y : constant Address := G(@dots{});
14377 X : Integer := F(@dots{});
14378 for X'Address use Y;
14380 22.f This allows the expression ``Y'' to be safely
14381 evaluated before X is created.
14383 22.g The constant could be a formal parameter of mode in.
14385 22.h An implementation can support other nonstatic
14386 expressions if it wants to. Expressions of type
14387 Address are hardly ever static, but their value
14388 might be known at compile time anyway in many
14393 GNAT does indeed permit many additional cases of non-static expressions. In
14394 particular, if the type involved is elementary there are no restrictions
14395 (since in this case, holding a temporary copy of the initialization value,
14396 if one is present, is inexpensive). In addition, if there is no implicit or
14397 explicit initialization, then there are no restrictions. GNAT will reject
14398 only the case where all three of these conditions hold:
14403 The type of the item is non-elementary (e.g.@: a record or array).
14406 There is explicit or implicit initialization required for the object.
14407 Note that access values are always implicitly initialized.
14410 The address value is non-static. Here GNAT is more permissive than the
14411 RM, and allows the address value to be the address of a previously declared
14412 stand-alone variable, as long as it does not itself have an address clause.
14414 @smallexample @c ada
14415 Anchor : Some_Initialized_Type;
14416 Overlay : Some_Initialized_Type;
14417 for Overlay'Address use Anchor'Address;
14421 However, the prefix of the address clause cannot be an array component, or
14422 a component of a discriminated record.
14427 As noted above in section 22.h, address values are typically non-static. In
14428 particular the To_Address function, even if applied to a literal value, is
14429 a non-static function call. To avoid this minor annoyance, GNAT provides
14430 the implementation defined attribute 'To_Address. The following two
14431 expressions have identical values:
14435 @smallexample @c ada
14436 To_Address (16#1234_0000#)
14437 System'To_Address (16#1234_0000#);
14441 except that the second form is considered to be a static expression, and
14442 thus when used as an address clause value is always permitted.
14445 Additionally, GNAT treats as static an address clause that is an
14446 unchecked_conversion of a static integer value. This simplifies the porting
14447 of legacy code, and provides a portable equivalent to the GNAT attribute
14450 Another issue with address clauses is the interaction with alignment
14451 requirements. When an address clause is given for an object, the address
14452 value must be consistent with the alignment of the object (which is usually
14453 the same as the alignment of the type of the object). If an address clause
14454 is given that specifies an inappropriately aligned address value, then the
14455 program execution is erroneous.
14457 Since this source of erroneous behavior can have unfortunate effects, GNAT
14458 checks (at compile time if possible, generating a warning, or at execution
14459 time with a run-time check) that the alignment is appropriate. If the
14460 run-time check fails, then @code{Program_Error} is raised. This run-time
14461 check is suppressed if range checks are suppressed, or if the special GNAT
14462 check Alignment_Check is suppressed, or if
14463 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
14465 Finally, GNAT does not permit overlaying of objects of controlled types or
14466 composite types containing a controlled component. In most cases, the compiler
14467 can detect an attempt at such overlays and will generate a warning at compile
14468 time and a Program_Error exception at run time.
14471 An address clause cannot be given for an exported object. More
14472 understandably the real restriction is that objects with an address
14473 clause cannot be exported. This is because such variables are not
14474 defined by the Ada program, so there is no external object to export.
14477 It is permissible to give an address clause and a pragma Import for the
14478 same object. In this case, the variable is not really defined by the
14479 Ada program, so there is no external symbol to be linked. The link name
14480 and the external name are ignored in this case. The reason that we allow this
14481 combination is that it provides a useful idiom to avoid unwanted
14482 initializations on objects with address clauses.
14484 When an address clause is given for an object that has implicit or
14485 explicit initialization, then by default initialization takes place. This
14486 means that the effect of the object declaration is to overwrite the
14487 memory at the specified address. This is almost always not what the
14488 programmer wants, so GNAT will output a warning:
14498 for Ext'Address use System'To_Address (16#1234_1234#);
14500 >>> warning: implicit initialization of "Ext" may
14501 modify overlaid storage
14502 >>> warning: use pragma Import for "Ext" to suppress
14503 initialization (RM B(24))
14509 As indicated by the warning message, the solution is to use a (dummy) pragma
14510 Import to suppress this initialization. The pragma tell the compiler that the
14511 object is declared and initialized elsewhere. The following package compiles
14512 without warnings (and the initialization is suppressed):
14514 @smallexample @c ada
14522 for Ext'Address use System'To_Address (16#1234_1234#);
14523 pragma Import (Ada, Ext);
14528 A final issue with address clauses involves their use for overlaying
14529 variables, as in the following example:
14530 @cindex Overlaying of objects
14532 @smallexample @c ada
14535 for B'Address use A'Address;
14539 or alternatively, using the form recommended by the RM:
14541 @smallexample @c ada
14543 Addr : constant Address := A'Address;
14545 for B'Address use Addr;
14549 In both of these cases, @code{A}
14550 and @code{B} become aliased to one another via the
14551 address clause. This use of address clauses to overlay
14552 variables, achieving an effect similar to unchecked
14553 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
14554 the effect is implementation defined. Furthermore, the
14555 Ada RM specifically recommends that in a situation
14556 like this, @code{B} should be subject to the following
14557 implementation advice (RM 13.3(19)):
14560 19 If the Address of an object is specified, or it is imported
14561 or exported, then the implementation should not perform
14562 optimizations based on assumptions of no aliases.
14566 GNAT follows this recommendation, and goes further by also applying
14567 this recommendation to the overlaid variable (@code{A}
14568 in the above example) in this case. This means that the overlay
14569 works "as expected", in that a modification to one of the variables
14570 will affect the value of the other.
14572 @node Effect of Convention on Representation
14573 @section Effect of Convention on Representation
14574 @cindex Convention, effect on representation
14577 Normally the specification of a foreign language convention for a type or
14578 an object has no effect on the chosen representation. In particular, the
14579 representation chosen for data in GNAT generally meets the standard system
14580 conventions, and for example records are laid out in a manner that is
14581 consistent with C@. This means that specifying convention C (for example)
14584 There are four exceptions to this general rule:
14588 @item Convention Fortran and array subtypes
14589 If pragma Convention Fortran is specified for an array subtype, then in
14590 accordance with the implementation advice in section 3.6.2(11) of the
14591 Ada Reference Manual, the array will be stored in a Fortran-compatible
14592 column-major manner, instead of the normal default row-major order.
14594 @item Convention C and enumeration types
14595 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
14596 to accommodate all values of the type. For example, for the enumeration
14599 @smallexample @c ada
14600 type Color is (Red, Green, Blue);
14604 8 bits is sufficient to store all values of the type, so by default, objects
14605 of type @code{Color} will be represented using 8 bits. However, normal C
14606 convention is to use 32 bits for all enum values in C, since enum values
14607 are essentially of type int. If pragma @code{Convention C} is specified for an
14608 Ada enumeration type, then the size is modified as necessary (usually to
14609 32 bits) to be consistent with the C convention for enum values.
14611 Note that this treatment applies only to types. If Convention C is given for
14612 an enumeration object, where the enumeration type is not Convention C, then
14613 Object_Size bits are allocated. For example, for a normal enumeration type,
14614 with less than 256 elements, only 8 bits will be allocated for the object.
14615 Since this may be a surprise in terms of what C expects, GNAT will issue a
14616 warning in this situation. The warning can be suppressed by giving an explicit
14617 size clause specifying the desired size.
14619 @item Convention C/Fortran and Boolean types
14620 In C, the usual convention for boolean values, that is values used for
14621 conditions, is that zero represents false, and nonzero values represent
14622 true. In Ada, the normal convention is that two specific values, typically
14623 0/1, are used to represent false/true respectively.
14625 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
14626 value represents true).
14628 To accommodate the Fortran and C conventions, if a pragma Convention specifies
14629 C or Fortran convention for a derived Boolean, as in the following example:
14631 @smallexample @c ada
14632 type C_Switch is new Boolean;
14633 pragma Convention (C, C_Switch);
14637 then the GNAT generated code will treat any nonzero value as true. For truth
14638 values generated by GNAT, the conventional value 1 will be used for True, but
14639 when one of these values is read, any nonzero value is treated as True.
14641 @item Access types on OpenVMS
14642 For 64-bit OpenVMS systems, access types (other than those for unconstrained
14643 arrays) are 64-bits long. An exception to this rule is for the case of
14644 C-convention access types where there is no explicit size clause present (or
14645 inherited for derived types). In this case, GNAT chooses to make these
14646 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
14647 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
14651 @node Determining the Representations chosen by GNAT
14652 @section Determining the Representations chosen by GNAT
14653 @cindex Representation, determination of
14654 @cindex @option{-gnatR} switch
14657 Although the descriptions in this section are intended to be complete, it is
14658 often easier to simply experiment to see what GNAT accepts and what the
14659 effect is on the layout of types and objects.
14661 As required by the Ada RM, if a representation clause is not accepted, then
14662 it must be rejected as illegal by the compiler. However, when a
14663 representation clause or pragma is accepted, there can still be questions
14664 of what the compiler actually does. For example, if a partial record
14665 representation clause specifies the location of some components and not
14666 others, then where are the non-specified components placed? Or if pragma
14667 @code{Pack} is used on a record, then exactly where are the resulting
14668 fields placed? The section on pragma @code{Pack} in this chapter can be
14669 used to answer the second question, but it is often easier to just see
14670 what the compiler does.
14672 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
14673 with this option, then the compiler will output information on the actual
14674 representations chosen, in a format similar to source representation
14675 clauses. For example, if we compile the package:
14677 @smallexample @c ada
14679 type r (x : boolean) is tagged record
14681 when True => S : String (1 .. 100);
14682 when False => null;
14686 type r2 is new r (false) with record
14691 y2 at 16 range 0 .. 31;
14698 type x1 is array (1 .. 10) of x;
14699 for x1'component_size use 11;
14701 type ia is access integer;
14703 type Rb1 is array (1 .. 13) of Boolean;
14706 type Rb2 is array (1 .. 65) of Boolean;
14722 using the switch @option{-gnatR} we obtain the following output:
14725 Representation information for unit q
14726 -------------------------------------
14729 for r'Alignment use 4;
14731 x at 4 range 0 .. 7;
14732 _tag at 0 range 0 .. 31;
14733 s at 5 range 0 .. 799;
14736 for r2'Size use 160;
14737 for r2'Alignment use 4;
14739 x at 4 range 0 .. 7;
14740 _tag at 0 range 0 .. 31;
14741 _parent at 0 range 0 .. 63;
14742 y2 at 16 range 0 .. 31;
14746 for x'Alignment use 1;
14748 y at 0 range 0 .. 7;
14751 for x1'Size use 112;
14752 for x1'Alignment use 1;
14753 for x1'Component_Size use 11;
14755 for rb1'Size use 13;
14756 for rb1'Alignment use 2;
14757 for rb1'Component_Size use 1;
14759 for rb2'Size use 72;
14760 for rb2'Alignment use 1;
14761 for rb2'Component_Size use 1;
14763 for x2'Size use 224;
14764 for x2'Alignment use 4;
14766 l1 at 0 range 0 .. 0;
14767 l2 at 0 range 1 .. 64;
14768 l3 at 12 range 0 .. 31;
14769 l4 at 16 range 0 .. 0;
14770 l5 at 16 range 1 .. 13;
14771 l6 at 18 range 0 .. 71;
14776 The Size values are actually the Object_Size, i.e.@: the default size that
14777 will be allocated for objects of the type.
14778 The ?? size for type r indicates that we have a variant record, and the
14779 actual size of objects will depend on the discriminant value.
14781 The Alignment values show the actual alignment chosen by the compiler
14782 for each record or array type.
14784 The record representation clause for type r shows where all fields
14785 are placed, including the compiler generated tag field (whose location
14786 cannot be controlled by the programmer).
14788 The record representation clause for the type extension r2 shows all the
14789 fields present, including the parent field, which is a copy of the fields
14790 of the parent type of r2, i.e.@: r1.
14792 The component size and size clauses for types rb1 and rb2 show
14793 the exact effect of pragma @code{Pack} on these arrays, and the record
14794 representation clause for type x2 shows how pragma @code{Pack} affects
14797 In some cases, it may be useful to cut and paste the representation clauses
14798 generated by the compiler into the original source to fix and guarantee
14799 the actual representation to be used.
14801 @node Standard Library Routines
14802 @chapter Standard Library Routines
14805 The Ada Reference Manual contains in Annex A a full description of an
14806 extensive set of standard library routines that can be used in any Ada
14807 program, and which must be provided by all Ada compilers. They are
14808 analogous to the standard C library used by C programs.
14810 GNAT implements all of the facilities described in annex A, and for most
14811 purposes the description in the Ada Reference Manual, or appropriate Ada
14812 text book, will be sufficient for making use of these facilities.
14814 In the case of the input-output facilities,
14815 @xref{The Implementation of Standard I/O},
14816 gives details on exactly how GNAT interfaces to the
14817 file system. For the remaining packages, the Ada Reference Manual
14818 should be sufficient. The following is a list of the packages included,
14819 together with a brief description of the functionality that is provided.
14821 For completeness, references are included to other predefined library
14822 routines defined in other sections of the Ada Reference Manual (these are
14823 cross-indexed from Annex A).
14827 This is a parent package for all the standard library packages. It is
14828 usually included implicitly in your program, and itself contains no
14829 useful data or routines.
14831 @item Ada.Calendar (9.6)
14832 @code{Calendar} provides time of day access, and routines for
14833 manipulating times and durations.
14835 @item Ada.Characters (A.3.1)
14836 This is a dummy parent package that contains no useful entities
14838 @item Ada.Characters.Handling (A.3.2)
14839 This package provides some basic character handling capabilities,
14840 including classification functions for classes of characters (e.g.@: test
14841 for letters, or digits).
14843 @item Ada.Characters.Latin_1 (A.3.3)
14844 This package includes a complete set of definitions of the characters
14845 that appear in type CHARACTER@. It is useful for writing programs that
14846 will run in international environments. For example, if you want an
14847 upper case E with an acute accent in a string, it is often better to use
14848 the definition of @code{UC_E_Acute} in this package. Then your program
14849 will print in an understandable manner even if your environment does not
14850 support these extended characters.
14852 @item Ada.Command_Line (A.15)
14853 This package provides access to the command line parameters and the name
14854 of the current program (analogous to the use of @code{argc} and @code{argv}
14855 in C), and also allows the exit status for the program to be set in a
14856 system-independent manner.
14858 @item Ada.Decimal (F.2)
14859 This package provides constants describing the range of decimal numbers
14860 implemented, and also a decimal divide routine (analogous to the COBOL
14861 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
14863 @item Ada.Direct_IO (A.8.4)
14864 This package provides input-output using a model of a set of records of
14865 fixed-length, containing an arbitrary definite Ada type, indexed by an
14866 integer record number.
14868 @item Ada.Dynamic_Priorities (D.5)
14869 This package allows the priorities of a task to be adjusted dynamically
14870 as the task is running.
14872 @item Ada.Exceptions (11.4.1)
14873 This package provides additional information on exceptions, and also
14874 contains facilities for treating exceptions as data objects, and raising
14875 exceptions with associated messages.
14877 @item Ada.Finalization (7.6)
14878 This package contains the declarations and subprograms to support the
14879 use of controlled types, providing for automatic initialization and
14880 finalization (analogous to the constructors and destructors of C++)
14882 @item Ada.Interrupts (C.3.2)
14883 This package provides facilities for interfacing to interrupts, which
14884 includes the set of signals or conditions that can be raised and
14885 recognized as interrupts.
14887 @item Ada.Interrupts.Names (C.3.2)
14888 This package provides the set of interrupt names (actually signal
14889 or condition names) that can be handled by GNAT@.
14891 @item Ada.IO_Exceptions (A.13)
14892 This package defines the set of exceptions that can be raised by use of
14893 the standard IO packages.
14896 This package contains some standard constants and exceptions used
14897 throughout the numerics packages. Note that the constants pi and e are
14898 defined here, and it is better to use these definitions than rolling
14901 @item Ada.Numerics.Complex_Elementary_Functions
14902 Provides the implementation of standard elementary functions (such as
14903 log and trigonometric functions) operating on complex numbers using the
14904 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
14905 created by the package @code{Numerics.Complex_Types}.
14907 @item Ada.Numerics.Complex_Types
14908 This is a predefined instantiation of
14909 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
14910 build the type @code{Complex} and @code{Imaginary}.
14912 @item Ada.Numerics.Discrete_Random
14913 This generic package provides a random number generator suitable for generating
14914 uniformly distributed values of a specified discrete subtype.
14916 @item Ada.Numerics.Float_Random
14917 This package provides a random number generator suitable for generating
14918 uniformly distributed floating point values in the unit interval.
14920 @item Ada.Numerics.Generic_Complex_Elementary_Functions
14921 This is a generic version of the package that provides the
14922 implementation of standard elementary functions (such as log and
14923 trigonometric functions) for an arbitrary complex type.
14925 The following predefined instantiations of this package are provided:
14929 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
14931 @code{Ada.Numerics.Complex_Elementary_Functions}
14933 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
14936 @item Ada.Numerics.Generic_Complex_Types
14937 This is a generic package that allows the creation of complex types,
14938 with associated complex arithmetic operations.
14940 The following predefined instantiations of this package exist
14943 @code{Ada.Numerics.Short_Complex_Complex_Types}
14945 @code{Ada.Numerics.Complex_Complex_Types}
14947 @code{Ada.Numerics.Long_Complex_Complex_Types}
14950 @item Ada.Numerics.Generic_Elementary_Functions
14951 This is a generic package that provides the implementation of standard
14952 elementary functions (such as log an trigonometric functions) for an
14953 arbitrary float type.
14955 The following predefined instantiations of this package exist
14959 @code{Ada.Numerics.Short_Elementary_Functions}
14961 @code{Ada.Numerics.Elementary_Functions}
14963 @code{Ada.Numerics.Long_Elementary_Functions}
14966 @item Ada.Real_Time (D.8)
14967 This package provides facilities similar to those of @code{Calendar}, but
14968 operating with a finer clock suitable for real time control. Note that
14969 annex D requires that there be no backward clock jumps, and GNAT generally
14970 guarantees this behavior, but of course if the external clock on which
14971 the GNAT runtime depends is deliberately reset by some external event,
14972 then such a backward jump may occur.
14974 @item Ada.Sequential_IO (A.8.1)
14975 This package provides input-output facilities for sequential files,
14976 which can contain a sequence of values of a single type, which can be
14977 any Ada type, including indefinite (unconstrained) types.
14979 @item Ada.Storage_IO (A.9)
14980 This package provides a facility for mapping arbitrary Ada types to and
14981 from a storage buffer. It is primarily intended for the creation of new
14984 @item Ada.Streams (13.13.1)
14985 This is a generic package that provides the basic support for the
14986 concept of streams as used by the stream attributes (@code{Input},
14987 @code{Output}, @code{Read} and @code{Write}).
14989 @item Ada.Streams.Stream_IO (A.12.1)
14990 This package is a specialization of the type @code{Streams} defined in
14991 package @code{Streams} together with a set of operations providing
14992 Stream_IO capability. The Stream_IO model permits both random and
14993 sequential access to a file which can contain an arbitrary set of values
14994 of one or more Ada types.
14996 @item Ada.Strings (A.4.1)
14997 This package provides some basic constants used by the string handling
15000 @item Ada.Strings.Bounded (A.4.4)
15001 This package provides facilities for handling variable length
15002 strings. The bounded model requires a maximum length. It is thus
15003 somewhat more limited than the unbounded model, but avoids the use of
15004 dynamic allocation or finalization.
15006 @item Ada.Strings.Fixed (A.4.3)
15007 This package provides facilities for handling fixed length strings.
15009 @item Ada.Strings.Maps (A.4.2)
15010 This package provides facilities for handling character mappings and
15011 arbitrarily defined subsets of characters. For instance it is useful in
15012 defining specialized translation tables.
15014 @item Ada.Strings.Maps.Constants (A.4.6)
15015 This package provides a standard set of predefined mappings and
15016 predefined character sets. For example, the standard upper to lower case
15017 conversion table is found in this package. Note that upper to lower case
15018 conversion is non-trivial if you want to take the entire set of
15019 characters, including extended characters like E with an acute accent,
15020 into account. You should use the mappings in this package (rather than
15021 adding 32 yourself) to do case mappings.
15023 @item Ada.Strings.Unbounded (A.4.5)
15024 This package provides facilities for handling variable length
15025 strings. The unbounded model allows arbitrary length strings, but
15026 requires the use of dynamic allocation and finalization.
15028 @item Ada.Strings.Wide_Bounded (A.4.7)
15029 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15030 @itemx Ada.Strings.Wide_Maps (A.4.7)
15031 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15032 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15033 These packages provide analogous capabilities to the corresponding
15034 packages without @samp{Wide_} in the name, but operate with the types
15035 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15036 and @code{Character}.
15038 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15039 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15040 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15041 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15042 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15043 These packages provide analogous capabilities to the corresponding
15044 packages without @samp{Wide_} in the name, but operate with the types
15045 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15046 of @code{String} and @code{Character}.
15048 @item Ada.Synchronous_Task_Control (D.10)
15049 This package provides some standard facilities for controlling task
15050 communication in a synchronous manner.
15053 This package contains definitions for manipulation of the tags of tagged
15056 @item Ada.Task_Attributes
15057 This package provides the capability of associating arbitrary
15058 task-specific data with separate tasks.
15061 This package provides basic text input-output capabilities for
15062 character, string and numeric data. The subpackages of this
15063 package are listed next.
15065 @item Ada.Text_IO.Decimal_IO
15066 Provides input-output facilities for decimal fixed-point types
15068 @item Ada.Text_IO.Enumeration_IO
15069 Provides input-output facilities for enumeration types.
15071 @item Ada.Text_IO.Fixed_IO
15072 Provides input-output facilities for ordinary fixed-point types.
15074 @item Ada.Text_IO.Float_IO
15075 Provides input-output facilities for float types. The following
15076 predefined instantiations of this generic package are available:
15080 @code{Short_Float_Text_IO}
15082 @code{Float_Text_IO}
15084 @code{Long_Float_Text_IO}
15087 @item Ada.Text_IO.Integer_IO
15088 Provides input-output facilities for integer types. The following
15089 predefined instantiations of this generic package are available:
15092 @item Short_Short_Integer
15093 @code{Ada.Short_Short_Integer_Text_IO}
15094 @item Short_Integer
15095 @code{Ada.Short_Integer_Text_IO}
15097 @code{Ada.Integer_Text_IO}
15099 @code{Ada.Long_Integer_Text_IO}
15100 @item Long_Long_Integer
15101 @code{Ada.Long_Long_Integer_Text_IO}
15104 @item Ada.Text_IO.Modular_IO
15105 Provides input-output facilities for modular (unsigned) types
15107 @item Ada.Text_IO.Complex_IO (G.1.3)
15108 This package provides basic text input-output capabilities for complex
15111 @item Ada.Text_IO.Editing (F.3.3)
15112 This package contains routines for edited output, analogous to the use
15113 of pictures in COBOL@. The picture formats used by this package are a
15114 close copy of the facility in COBOL@.
15116 @item Ada.Text_IO.Text_Streams (A.12.2)
15117 This package provides a facility that allows Text_IO files to be treated
15118 as streams, so that the stream attributes can be used for writing
15119 arbitrary data, including binary data, to Text_IO files.
15121 @item Ada.Unchecked_Conversion (13.9)
15122 This generic package allows arbitrary conversion from one type to
15123 another of the same size, providing for breaking the type safety in
15124 special circumstances.
15126 If the types have the same Size (more accurately the same Value_Size),
15127 then the effect is simply to transfer the bits from the source to the
15128 target type without any modification. This usage is well defined, and
15129 for simple types whose representation is typically the same across
15130 all implementations, gives a portable method of performing such
15133 If the types do not have the same size, then the result is implementation
15134 defined, and thus may be non-portable. The following describes how GNAT
15135 handles such unchecked conversion cases.
15137 If the types are of different sizes, and are both discrete types, then
15138 the effect is of a normal type conversion without any constraint checking.
15139 In particular if the result type has a larger size, the result will be
15140 zero or sign extended. If the result type has a smaller size, the result
15141 will be truncated by ignoring high order bits.
15143 If the types are of different sizes, and are not both discrete types,
15144 then the conversion works as though pointers were created to the source
15145 and target, and the pointer value is converted. The effect is that bits
15146 are copied from successive low order storage units and bits of the source
15147 up to the length of the target type.
15149 A warning is issued if the lengths differ, since the effect in this
15150 case is implementation dependent, and the above behavior may not match
15151 that of some other compiler.
15153 A pointer to one type may be converted to a pointer to another type using
15154 unchecked conversion. The only case in which the effect is undefined is
15155 when one or both pointers are pointers to unconstrained array types. In
15156 this case, the bounds information may get incorrectly transferred, and in
15157 particular, GNAT uses double size pointers for such types, and it is
15158 meaningless to convert between such pointer types. GNAT will issue a
15159 warning if the alignment of the target designated type is more strict
15160 than the alignment of the source designated type (since the result may
15161 be unaligned in this case).
15163 A pointer other than a pointer to an unconstrained array type may be
15164 converted to and from System.Address. Such usage is common in Ada 83
15165 programs, but note that Ada.Address_To_Access_Conversions is the
15166 preferred method of performing such conversions in Ada 95 and Ada 2005.
15168 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15169 used in conjunction with pointers to unconstrained objects, since
15170 the bounds information cannot be handled correctly in this case.
15172 @item Ada.Unchecked_Deallocation (13.11.2)
15173 This generic package allows explicit freeing of storage previously
15174 allocated by use of an allocator.
15176 @item Ada.Wide_Text_IO (A.11)
15177 This package is similar to @code{Ada.Text_IO}, except that the external
15178 file supports wide character representations, and the internal types are
15179 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15180 and @code{String}. It contains generic subpackages listed next.
15182 @item Ada.Wide_Text_IO.Decimal_IO
15183 Provides input-output facilities for decimal fixed-point types
15185 @item Ada.Wide_Text_IO.Enumeration_IO
15186 Provides input-output facilities for enumeration types.
15188 @item Ada.Wide_Text_IO.Fixed_IO
15189 Provides input-output facilities for ordinary fixed-point types.
15191 @item Ada.Wide_Text_IO.Float_IO
15192 Provides input-output facilities for float types. The following
15193 predefined instantiations of this generic package are available:
15197 @code{Short_Float_Wide_Text_IO}
15199 @code{Float_Wide_Text_IO}
15201 @code{Long_Float_Wide_Text_IO}
15204 @item Ada.Wide_Text_IO.Integer_IO
15205 Provides input-output facilities for integer types. The following
15206 predefined instantiations of this generic package are available:
15209 @item Short_Short_Integer
15210 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15211 @item Short_Integer
15212 @code{Ada.Short_Integer_Wide_Text_IO}
15214 @code{Ada.Integer_Wide_Text_IO}
15216 @code{Ada.Long_Integer_Wide_Text_IO}
15217 @item Long_Long_Integer
15218 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15221 @item Ada.Wide_Text_IO.Modular_IO
15222 Provides input-output facilities for modular (unsigned) types
15224 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15225 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15226 external file supports wide character representations.
15228 @item Ada.Wide_Text_IO.Editing (F.3.4)
15229 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15230 types are @code{Wide_Character} and @code{Wide_String} instead of
15231 @code{Character} and @code{String}.
15233 @item Ada.Wide_Text_IO.Streams (A.12.3)
15234 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15235 types are @code{Wide_Character} and @code{Wide_String} instead of
15236 @code{Character} and @code{String}.
15238 @item Ada.Wide_Wide_Text_IO (A.11)
15239 This package is similar to @code{Ada.Text_IO}, except that the external
15240 file supports wide character representations, and the internal types are
15241 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15242 and @code{String}. It contains generic subpackages listed next.
15244 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15245 Provides input-output facilities for decimal fixed-point types
15247 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15248 Provides input-output facilities for enumeration types.
15250 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15251 Provides input-output facilities for ordinary fixed-point types.
15253 @item Ada.Wide_Wide_Text_IO.Float_IO
15254 Provides input-output facilities for float types. The following
15255 predefined instantiations of this generic package are available:
15259 @code{Short_Float_Wide_Wide_Text_IO}
15261 @code{Float_Wide_Wide_Text_IO}
15263 @code{Long_Float_Wide_Wide_Text_IO}
15266 @item Ada.Wide_Wide_Text_IO.Integer_IO
15267 Provides input-output facilities for integer types. The following
15268 predefined instantiations of this generic package are available:
15271 @item Short_Short_Integer
15272 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
15273 @item Short_Integer
15274 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
15276 @code{Ada.Integer_Wide_Wide_Text_IO}
15278 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
15279 @item Long_Long_Integer
15280 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
15283 @item Ada.Wide_Wide_Text_IO.Modular_IO
15284 Provides input-output facilities for modular (unsigned) types
15286 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
15287 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15288 external file supports wide character representations.
15290 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
15291 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15292 types are @code{Wide_Character} and @code{Wide_String} instead of
15293 @code{Character} and @code{String}.
15295 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
15296 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15297 types are @code{Wide_Character} and @code{Wide_String} instead of
15298 @code{Character} and @code{String}.
15301 @node The Implementation of Standard I/O
15302 @chapter The Implementation of Standard I/O
15305 GNAT implements all the required input-output facilities described in
15306 A.6 through A.14. These sections of the Ada Reference Manual describe the
15307 required behavior of these packages from the Ada point of view, and if
15308 you are writing a portable Ada program that does not need to know the
15309 exact manner in which Ada maps to the outside world when it comes to
15310 reading or writing external files, then you do not need to read this
15311 chapter. As long as your files are all regular files (not pipes or
15312 devices), and as long as you write and read the files only from Ada, the
15313 description in the Ada Reference Manual is sufficient.
15315 However, if you want to do input-output to pipes or other devices, such
15316 as the keyboard or screen, or if the files you are dealing with are
15317 either generated by some other language, or to be read by some other
15318 language, then you need to know more about the details of how the GNAT
15319 implementation of these input-output facilities behaves.
15321 In this chapter we give a detailed description of exactly how GNAT
15322 interfaces to the file system. As always, the sources of the system are
15323 available to you for answering questions at an even more detailed level,
15324 but for most purposes the information in this chapter will suffice.
15326 Another reason that you may need to know more about how input-output is
15327 implemented arises when you have a program written in mixed languages
15328 where, for example, files are shared between the C and Ada sections of
15329 the same program. GNAT provides some additional facilities, in the form
15330 of additional child library packages, that facilitate this sharing, and
15331 these additional facilities are also described in this chapter.
15334 * Standard I/O Packages::
15340 * Wide_Wide_Text_IO::
15342 * Text Translation::
15344 * Filenames encoding::
15346 * Operations on C Streams::
15347 * Interfacing to C Streams::
15350 @node Standard I/O Packages
15351 @section Standard I/O Packages
15354 The Standard I/O packages described in Annex A for
15360 Ada.Text_IO.Complex_IO
15362 Ada.Text_IO.Text_Streams
15366 Ada.Wide_Text_IO.Complex_IO
15368 Ada.Wide_Text_IO.Text_Streams
15370 Ada.Wide_Wide_Text_IO
15372 Ada.Wide_Wide_Text_IO.Complex_IO
15374 Ada.Wide_Wide_Text_IO.Text_Streams
15384 are implemented using the C
15385 library streams facility; where
15389 All files are opened using @code{fopen}.
15391 All input/output operations use @code{fread}/@code{fwrite}.
15395 There is no internal buffering of any kind at the Ada library level. The only
15396 buffering is that provided at the system level in the implementation of the
15397 library routines that support streams. This facilitates shared use of these
15398 streams by mixed language programs. Note though that system level buffering is
15399 explicitly enabled at elaboration of the standard I/O packages and that can
15400 have an impact on mixed language programs, in particular those using I/O before
15401 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
15402 the Ada elaboration routine before performing any I/O or when impractical,
15403 flush the common I/O streams and in particular Standard_Output before
15404 elaborating the Ada code.
15407 @section FORM Strings
15410 The format of a FORM string in GNAT is:
15413 "keyword=value,keyword=value,@dots{},keyword=value"
15417 where letters may be in upper or lower case, and there are no spaces
15418 between values. The order of the entries is not important. Currently
15419 the following keywords defined.
15422 TEXT_TRANSLATION=[YES|NO]
15424 WCEM=[n|h|u|s|e|8|b]
15425 ENCODING=[UTF8|8BITS]
15429 The use of these parameters is described later in this section. If an
15430 unrecognized keyword appears in a form string, it is silently ignored
15431 and not considered invalid.
15434 For OpenVMS additional FORM string keywords are available for use with
15435 RMS services. The syntax is:
15438 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
15442 The following RMS keywords and values are currently defined:
15445 Context=Force_Stream_Mode|Force_Record_Mode
15449 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
15450 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
15456 Direct_IO can only be instantiated for definite types. This is a
15457 restriction of the Ada language, which means that the records are fixed
15458 length (the length being determined by @code{@var{type}'Size}, rounded
15459 up to the next storage unit boundary if necessary).
15461 The records of a Direct_IO file are simply written to the file in index
15462 sequence, with the first record starting at offset zero, and subsequent
15463 records following. There is no control information of any kind. For
15464 example, if 32-bit integers are being written, each record takes
15465 4-bytes, so the record at index @var{K} starts at offset
15466 (@var{K}@minus{}1)*4.
15468 There is no limit on the size of Direct_IO files, they are expanded as
15469 necessary to accommodate whatever records are written to the file.
15471 @node Sequential_IO
15472 @section Sequential_IO
15475 Sequential_IO may be instantiated with either a definite (constrained)
15476 or indefinite (unconstrained) type.
15478 For the definite type case, the elements written to the file are simply
15479 the memory images of the data values with no control information of any
15480 kind. The resulting file should be read using the same type, no validity
15481 checking is performed on input.
15483 For the indefinite type case, the elements written consist of two
15484 parts. First is the size of the data item, written as the memory image
15485 of a @code{Interfaces.C.size_t} value, followed by the memory image of
15486 the data value. The resulting file can only be read using the same
15487 (unconstrained) type. Normal assignment checks are performed on these
15488 read operations, and if these checks fail, @code{Data_Error} is
15489 raised. In particular, in the array case, the lengths must match, and in
15490 the variant record case, if the variable for a particular read operation
15491 is constrained, the discriminants must match.
15493 Note that it is not possible to use Sequential_IO to write variable
15494 length array items, and then read the data back into different length
15495 arrays. For example, the following will raise @code{Data_Error}:
15497 @smallexample @c ada
15498 package IO is new Sequential_IO (String);
15503 IO.Write (F, "hello!")
15504 IO.Reset (F, Mode=>In_File);
15511 On some Ada implementations, this will print @code{hell}, but the program is
15512 clearly incorrect, since there is only one element in the file, and that
15513 element is the string @code{hello!}.
15515 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
15516 using Stream_IO, and this is the preferred mechanism. In particular, the
15517 above program fragment rewritten to use Stream_IO will work correctly.
15523 Text_IO files consist of a stream of characters containing the following
15524 special control characters:
15527 LF (line feed, 16#0A#) Line Mark
15528 FF (form feed, 16#0C#) Page Mark
15532 A canonical Text_IO file is defined as one in which the following
15533 conditions are met:
15537 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
15541 The character @code{FF} is used only as a page mark, i.e.@: to mark the
15542 end of a page and consequently can appear only immediately following a
15543 @code{LF} (line mark) character.
15546 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
15547 (line mark, page mark). In the former case, the page mark is implicitly
15548 assumed to be present.
15552 A file written using Text_IO will be in canonical form provided that no
15553 explicit @code{LF} or @code{FF} characters are written using @code{Put}
15554 or @code{Put_Line}. There will be no @code{FF} character at the end of
15555 the file unless an explicit @code{New_Page} operation was performed
15556 before closing the file.
15558 A canonical Text_IO file that is a regular file (i.e., not a device or a
15559 pipe) can be read using any of the routines in Text_IO@. The
15560 semantics in this case will be exactly as defined in the Ada Reference
15561 Manual, and all the routines in Text_IO are fully implemented.
15563 A text file that does not meet the requirements for a canonical Text_IO
15564 file has one of the following:
15568 The file contains @code{FF} characters not immediately following a
15569 @code{LF} character.
15572 The file contains @code{LF} or @code{FF} characters written by
15573 @code{Put} or @code{Put_Line}, which are not logically considered to be
15574 line marks or page marks.
15577 The file ends in a character other than @code{LF} or @code{FF},
15578 i.e.@: there is no explicit line mark or page mark at the end of the file.
15582 Text_IO can be used to read such non-standard text files but subprograms
15583 to do with line or page numbers do not have defined meanings. In
15584 particular, a @code{FF} character that does not follow a @code{LF}
15585 character may or may not be treated as a page mark from the point of
15586 view of page and line numbering. Every @code{LF} character is considered
15587 to end a line, and there is an implied @code{LF} character at the end of
15591 * Text_IO Stream Pointer Positioning::
15592 * Text_IO Reading and Writing Non-Regular Files::
15594 * Treating Text_IO Files as Streams::
15595 * Text_IO Extensions::
15596 * Text_IO Facilities for Unbounded Strings::
15599 @node Text_IO Stream Pointer Positioning
15600 @subsection Stream Pointer Positioning
15603 @code{Ada.Text_IO} has a definition of current position for a file that
15604 is being read. No internal buffering occurs in Text_IO, and usually the
15605 physical position in the stream used to implement the file corresponds
15606 to this logical position defined by Text_IO@. There are two exceptions:
15610 After a call to @code{End_Of_Page} that returns @code{True}, the stream
15611 is positioned past the @code{LF} (line mark) that precedes the page
15612 mark. Text_IO maintains an internal flag so that subsequent read
15613 operations properly handle the logical position which is unchanged by
15614 the @code{End_Of_Page} call.
15617 After a call to @code{End_Of_File} that returns @code{True}, if the
15618 Text_IO file was positioned before the line mark at the end of file
15619 before the call, then the logical position is unchanged, but the stream
15620 is physically positioned right at the end of file (past the line mark,
15621 and past a possible page mark following the line mark. Again Text_IO
15622 maintains internal flags so that subsequent read operations properly
15623 handle the logical position.
15627 These discrepancies have no effect on the observable behavior of
15628 Text_IO, but if a single Ada stream is shared between a C program and
15629 Ada program, or shared (using @samp{shared=yes} in the form string)
15630 between two Ada files, then the difference may be observable in some
15633 @node Text_IO Reading and Writing Non-Regular Files
15634 @subsection Reading and Writing Non-Regular Files
15637 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
15638 can be used for reading and writing. Writing is not affected and the
15639 sequence of characters output is identical to the normal file case, but
15640 for reading, the behavior of Text_IO is modified to avoid undesirable
15641 look-ahead as follows:
15643 An input file that is not a regular file is considered to have no page
15644 marks. Any @code{Ascii.FF} characters (the character normally used for a
15645 page mark) appearing in the file are considered to be data
15646 characters. In particular:
15650 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
15651 following a line mark. If a page mark appears, it will be treated as a
15655 This avoids the need to wait for an extra character to be typed or
15656 entered from the pipe to complete one of these operations.
15659 @code{End_Of_Page} always returns @code{False}
15662 @code{End_Of_File} will return @code{False} if there is a page mark at
15663 the end of the file.
15667 Output to non-regular files is the same as for regular files. Page marks
15668 may be written to non-regular files using @code{New_Page}, but as noted
15669 above they will not be treated as page marks on input if the output is
15670 piped to another Ada program.
15672 Another important discrepancy when reading non-regular files is that the end
15673 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
15674 pressing the @key{EOT} key,
15676 is signaled once (i.e.@: the test @code{End_Of_File}
15677 will yield @code{True}, or a read will
15678 raise @code{End_Error}), but then reading can resume
15679 to read data past that end of
15680 file indication, until another end of file indication is entered.
15682 @node Get_Immediate
15683 @subsection Get_Immediate
15684 @cindex Get_Immediate
15687 Get_Immediate returns the next character (including control characters)
15688 from the input file. In particular, Get_Immediate will return LF or FF
15689 characters used as line marks or page marks. Such operations leave the
15690 file positioned past the control character, and it is thus not treated
15691 as having its normal function. This means that page, line and column
15692 counts after this kind of Get_Immediate call are set as though the mark
15693 did not occur. In the case where a Get_Immediate leaves the file
15694 positioned between the line mark and page mark (which is not normally
15695 possible), it is undefined whether the FF character will be treated as a
15698 @node Treating Text_IO Files as Streams
15699 @subsection Treating Text_IO Files as Streams
15700 @cindex Stream files
15703 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
15704 as a stream. Data written to a Text_IO file in this stream mode is
15705 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
15706 16#0C# (@code{FF}), the resulting file may have non-standard
15707 format. Similarly if read operations are used to read from a Text_IO
15708 file treated as a stream, then @code{LF} and @code{FF} characters may be
15709 skipped and the effect is similar to that described above for
15710 @code{Get_Immediate}.
15712 @node Text_IO Extensions
15713 @subsection Text_IO Extensions
15714 @cindex Text_IO extensions
15717 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
15718 to the standard @code{Text_IO} package:
15721 @item function File_Exists (Name : String) return Boolean;
15722 Determines if a file of the given name exists.
15724 @item function Get_Line return String;
15725 Reads a string from the standard input file. The value returned is exactly
15726 the length of the line that was read.
15728 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
15729 Similar, except that the parameter File specifies the file from which
15730 the string is to be read.
15734 @node Text_IO Facilities for Unbounded Strings
15735 @subsection Text_IO Facilities for Unbounded Strings
15736 @cindex Text_IO for unbounded strings
15737 @cindex Unbounded_String, Text_IO operations
15740 The package @code{Ada.Strings.Unbounded.Text_IO}
15741 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
15742 subprograms useful for Text_IO operations on unbounded strings:
15746 @item function Get_Line (File : File_Type) return Unbounded_String;
15747 Reads a line from the specified file
15748 and returns the result as an unbounded string.
15750 @item procedure Put (File : File_Type; U : Unbounded_String);
15751 Writes the value of the given unbounded string to the specified file
15752 Similar to the effect of
15753 @code{Put (To_String (U))} except that an extra copy is avoided.
15755 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
15756 Writes the value of the given unbounded string to the specified file,
15757 followed by a @code{New_Line}.
15758 Similar to the effect of @code{Put_Line (To_String (U))} except
15759 that an extra copy is avoided.
15763 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
15764 and is optional. If the parameter is omitted, then the standard input or
15765 output file is referenced as appropriate.
15767 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
15768 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
15769 @code{Wide_Text_IO} functionality for unbounded wide strings.
15771 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
15772 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
15773 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
15776 @section Wide_Text_IO
15779 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
15780 both input and output files may contain special sequences that represent
15781 wide character values. The encoding scheme for a given file may be
15782 specified using a FORM parameter:
15789 as part of the FORM string (WCEM = wide character encoding method),
15790 where @var{x} is one of the following characters
15796 Upper half encoding
15808 The encoding methods match those that
15809 can be used in a source
15810 program, but there is no requirement that the encoding method used for
15811 the source program be the same as the encoding method used for files,
15812 and different files may use different encoding methods.
15814 The default encoding method for the standard files, and for opened files
15815 for which no WCEM parameter is given in the FORM string matches the
15816 wide character encoding specified for the main program (the default
15817 being brackets encoding if no coding method was specified with -gnatW).
15821 In this encoding, a wide character is represented by a five character
15829 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
15830 characters (using upper case letters) of the wide character code. For
15831 example, ESC A345 is used to represent the wide character with code
15832 16#A345#. This scheme is compatible with use of the full
15833 @code{Wide_Character} set.
15835 @item Upper Half Coding
15836 The wide character with encoding 16#abcd#, where the upper bit is on
15837 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
15838 16#cd#. The second byte may never be a format control character, but is
15839 not required to be in the upper half. This method can be also used for
15840 shift-JIS or EUC where the internal coding matches the external coding.
15842 @item Shift JIS Coding
15843 A wide character is represented by a two character sequence 16#ab# and
15844 16#cd#, with the restrictions described for upper half encoding as
15845 described above. The internal character code is the corresponding JIS
15846 character according to the standard algorithm for Shift-JIS
15847 conversion. Only characters defined in the JIS code set table can be
15848 used with this encoding method.
15851 A wide character is represented by a two character sequence 16#ab# and
15852 16#cd#, with both characters being in the upper half. The internal
15853 character code is the corresponding JIS character according to the EUC
15854 encoding algorithm. Only characters defined in the JIS code set table
15855 can be used with this encoding method.
15858 A wide character is represented using
15859 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
15860 10646-1/Am.2. Depending on the character value, the representation
15861 is a one, two, or three byte sequence:
15864 16#0000#-16#007f#: 2#0xxxxxxx#
15865 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
15866 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
15870 where the @var{xxx} bits correspond to the left-padded bits of the
15871 16-bit character value. Note that all lower half ASCII characters
15872 are represented as ASCII bytes and all upper half characters and
15873 other wide characters are represented as sequences of upper-half
15874 (The full UTF-8 scheme allows for encoding 31-bit characters as
15875 6-byte sequences, but in this implementation, all UTF-8 sequences
15876 of four or more bytes length will raise a Constraint_Error, as
15877 will all invalid UTF-8 sequences.)
15879 @item Brackets Coding
15880 In this encoding, a wide character is represented by the following eight
15881 character sequence:
15888 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
15889 characters (using uppercase letters) of the wide character code. For
15890 example, @code{["A345"]} is used to represent the wide character with code
15892 This scheme is compatible with use of the full Wide_Character set.
15893 On input, brackets coding can also be used for upper half characters,
15894 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
15895 is only used for wide characters with a code greater than @code{16#FF#}.
15897 Note that brackets coding is not normally used in the context of
15898 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
15899 a portable way of encoding source files. In the context of Wide_Text_IO
15900 or Wide_Wide_Text_IO, it can only be used if the file does not contain
15901 any instance of the left bracket character other than to encode wide
15902 character values using the brackets encoding method. In practice it is
15903 expected that some standard wide character encoding method such
15904 as UTF-8 will be used for text input output.
15906 If brackets notation is used, then any occurrence of a left bracket
15907 in the input file which is not the start of a valid wide character
15908 sequence will cause Constraint_Error to be raised. It is possible to
15909 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
15910 input will interpret this as a left bracket.
15912 However, when a left bracket is output, it will be output as a left bracket
15913 and not as ["5B"]. We make this decision because for normal use of
15914 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
15915 brackets. For example, if we write:
15918 Put_Line ("Start of output [first run]");
15922 we really do not want to have the left bracket in this message clobbered so
15923 that the output reads:
15926 Start of output ["5B"]first run]
15930 In practice brackets encoding is reasonably useful for normal Put_Line use
15931 since we won't get confused between left brackets and wide character
15932 sequences in the output. But for input, or when files are written out
15933 and read back in, it really makes better sense to use one of the standard
15934 encoding methods such as UTF-8.
15939 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
15940 not all wide character
15941 values can be represented. An attempt to output a character that cannot
15942 be represented using the encoding scheme for the file causes
15943 Constraint_Error to be raised. An invalid wide character sequence on
15944 input also causes Constraint_Error to be raised.
15947 * Wide_Text_IO Stream Pointer Positioning::
15948 * Wide_Text_IO Reading and Writing Non-Regular Files::
15951 @node Wide_Text_IO Stream Pointer Positioning
15952 @subsection Stream Pointer Positioning
15955 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
15956 of stream pointer positioning (@pxref{Text_IO}). There is one additional
15959 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
15960 normal lower ASCII set (i.e.@: a character in the range:
15962 @smallexample @c ada
15963 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
15967 then although the logical position of the file pointer is unchanged by
15968 the @code{Look_Ahead} call, the stream is physically positioned past the
15969 wide character sequence. Again this is to avoid the need for buffering
15970 or backup, and all @code{Wide_Text_IO} routines check the internal
15971 indication that this situation has occurred so that this is not visible
15972 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
15973 can be observed if the wide text file shares a stream with another file.
15975 @node Wide_Text_IO Reading and Writing Non-Regular Files
15976 @subsection Reading and Writing Non-Regular Files
15979 As in the case of Text_IO, when a non-regular file is read, it is
15980 assumed that the file contains no page marks (any form characters are
15981 treated as data characters), and @code{End_Of_Page} always returns
15982 @code{False}. Similarly, the end of file indication is not sticky, so
15983 it is possible to read beyond an end of file.
15985 @node Wide_Wide_Text_IO
15986 @section Wide_Wide_Text_IO
15989 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
15990 both input and output files may contain special sequences that represent
15991 wide wide character values. The encoding scheme for a given file may be
15992 specified using a FORM parameter:
15999 as part of the FORM string (WCEM = wide character encoding method),
16000 where @var{x} is one of the following characters
16006 Upper half encoding
16018 The encoding methods match those that
16019 can be used in a source
16020 program, but there is no requirement that the encoding method used for
16021 the source program be the same as the encoding method used for files,
16022 and different files may use different encoding methods.
16024 The default encoding method for the standard files, and for opened files
16025 for which no WCEM parameter is given in the FORM string matches the
16026 wide character encoding specified for the main program (the default
16027 being brackets encoding if no coding method was specified with -gnatW).
16032 A wide character is represented using
16033 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16034 10646-1/Am.2. Depending on the character value, the representation
16035 is a one, two, three, or four byte sequence:
16038 16#000000#-16#00007f#: 2#0xxxxxxx#
16039 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16040 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16041 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16045 where the @var{xxx} bits correspond to the left-padded bits of the
16046 21-bit character value. Note that all lower half ASCII characters
16047 are represented as ASCII bytes and all upper half characters and
16048 other wide characters are represented as sequences of upper-half
16051 @item Brackets Coding
16052 In this encoding, a wide wide character is represented by the following eight
16053 character sequence if is in wide character range
16059 and by the following ten character sequence if not
16062 [ " a b c d e f " ]
16066 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16067 are the four or six hexadecimal
16068 characters (using uppercase letters) of the wide wide character code. For
16069 example, @code{["01A345"]} is used to represent the wide wide character
16070 with code @code{16#01A345#}.
16072 This scheme is compatible with use of the full Wide_Wide_Character set.
16073 On input, brackets coding can also be used for upper half characters,
16074 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
16075 is only used for wide characters with a code greater than @code{16#FF#}.
16080 If is also possible to use the other Wide_Character encoding methods,
16081 such as Shift-JIS, but the other schemes cannot support the full range
16082 of wide wide characters.
16083 An attempt to output a character that cannot
16084 be represented using the encoding scheme for the file causes
16085 Constraint_Error to be raised. An invalid wide character sequence on
16086 input also causes Constraint_Error to be raised.
16089 * Wide_Wide_Text_IO Stream Pointer Positioning::
16090 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16093 @node Wide_Wide_Text_IO Stream Pointer Positioning
16094 @subsection Stream Pointer Positioning
16097 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16098 of stream pointer positioning (@pxref{Text_IO}). There is one additional
16101 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16102 normal lower ASCII set (i.e.@: a character in the range:
16104 @smallexample @c ada
16105 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16109 then although the logical position of the file pointer is unchanged by
16110 the @code{Look_Ahead} call, the stream is physically positioned past the
16111 wide character sequence. Again this is to avoid the need for buffering
16112 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16113 indication that this situation has occurred so that this is not visible
16114 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
16115 can be observed if the wide text file shares a stream with another file.
16117 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16118 @subsection Reading and Writing Non-Regular Files
16121 As in the case of Text_IO, when a non-regular file is read, it is
16122 assumed that the file contains no page marks (any form characters are
16123 treated as data characters), and @code{End_Of_Page} always returns
16124 @code{False}. Similarly, the end of file indication is not sticky, so
16125 it is possible to read beyond an end of file.
16131 A stream file is a sequence of bytes, where individual elements are
16132 written to the file as described in the Ada Reference Manual. The type
16133 @code{Stream_Element} is simply a byte. There are two ways to read or
16134 write a stream file.
16138 The operations @code{Read} and @code{Write} directly read or write a
16139 sequence of stream elements with no control information.
16142 The stream attributes applied to a stream file transfer data in the
16143 manner described for stream attributes.
16146 @node Text Translation
16147 @section Text Translation
16150 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16151 passed to Text_IO.Create and Text_IO.Open:
16152 @samp{Text_Translation=@var{Yes}} is the default, which means to
16153 translate LF to/from CR/LF on Windows systems.
16154 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16155 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16156 may be used to create Unix-style files on
16157 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16161 @section Shared Files
16164 Section A.14 of the Ada Reference Manual allows implementations to
16165 provide a wide variety of behavior if an attempt is made to access the
16166 same external file with two or more internal files.
16168 To provide a full range of functionality, while at the same time
16169 minimizing the problems of portability caused by this implementation
16170 dependence, GNAT handles file sharing as follows:
16174 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16175 to open two or more files with the same full name is considered an error
16176 and is not supported. The exception @code{Use_Error} will be
16177 raised. Note that a file that is not explicitly closed by the program
16178 remains open until the program terminates.
16181 If the form parameter @samp{shared=no} appears in the form string, the
16182 file can be opened or created with its own separate stream identifier,
16183 regardless of whether other files sharing the same external file are
16184 opened. The exact effect depends on how the C stream routines handle
16185 multiple accesses to the same external files using separate streams.
16188 If the form parameter @samp{shared=yes} appears in the form string for
16189 each of two or more files opened using the same full name, the same
16190 stream is shared between these files, and the semantics are as described
16191 in Ada Reference Manual, Section A.14.
16195 When a program that opens multiple files with the same name is ported
16196 from another Ada compiler to GNAT, the effect will be that
16197 @code{Use_Error} is raised.
16199 The documentation of the original compiler and the documentation of the
16200 program should then be examined to determine if file sharing was
16201 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16202 and @code{Create} calls as required.
16204 When a program is ported from GNAT to some other Ada compiler, no
16205 special attention is required unless the @samp{shared=@var{xxx}} form
16206 parameter is used in the program. In this case, you must examine the
16207 documentation of the new compiler to see if it supports the required
16208 file sharing semantics, and form strings modified appropriately. Of
16209 course it may be the case that the program cannot be ported if the
16210 target compiler does not support the required functionality. The best
16211 approach in writing portable code is to avoid file sharing (and hence
16212 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16215 One common use of file sharing in Ada 83 is the use of instantiations of
16216 Sequential_IO on the same file with different types, to achieve
16217 heterogeneous input-output. Although this approach will work in GNAT if
16218 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16219 for this purpose (using the stream attributes)
16221 @node Filenames encoding
16222 @section Filenames encoding
16225 An encoding form parameter can be used to specify the filename
16226 encoding @samp{encoding=@var{xxx}}.
16230 If the form parameter @samp{encoding=utf8} appears in the form string, the
16231 filename must be encoded in UTF-8.
16234 If the form parameter @samp{encoding=8bits} appears in the form
16235 string, the filename must be a standard 8bits string.
16238 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16239 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16240 variable. And if not set @samp{utf8} is assumed.
16244 The current system Windows ANSI code page.
16249 This encoding form parameter is only supported on the Windows
16250 platform. On the other Operating Systems the run-time is supporting
16254 @section Open Modes
16257 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16258 using the mode shown in the following table:
16261 @center @code{Open} and @code{Create} Call Modes
16263 @b{OPEN } @b{CREATE}
16264 Append_File "r+" "w+"
16266 Out_File (Direct_IO) "r+" "w"
16267 Out_File (all other cases) "w" "w"
16268 Inout_File "r+" "w+"
16272 If text file translation is required, then either @samp{b} or @samp{t}
16273 is added to the mode, depending on the setting of Text. Text file
16274 translation refers to the mapping of CR/LF sequences in an external file
16275 to LF characters internally. This mapping only occurs in DOS and
16276 DOS-like systems, and is not relevant to other systems.
16278 A special case occurs with Stream_IO@. As shown in the above table, the
16279 file is initially opened in @samp{r} or @samp{w} mode for the
16280 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
16281 subsequently requires switching from reading to writing or vice-versa,
16282 then the file is reopened in @samp{r+} mode to permit the required operation.
16284 @node Operations on C Streams
16285 @section Operations on C Streams
16286 The package @code{Interfaces.C_Streams} provides an Ada program with direct
16287 access to the C library functions for operations on C streams:
16289 @smallexample @c adanocomment
16290 package Interfaces.C_Streams is
16291 -- Note: the reason we do not use the types that are in
16292 -- Interfaces.C is that we want to avoid dragging in the
16293 -- code in this unit if possible.
16294 subtype chars is System.Address;
16295 -- Pointer to null-terminated array of characters
16296 subtype FILEs is System.Address;
16297 -- Corresponds to the C type FILE*
16298 subtype voids is System.Address;
16299 -- Corresponds to the C type void*
16300 subtype int is Integer;
16301 subtype long is Long_Integer;
16302 -- Note: the above types are subtypes deliberately, and it
16303 -- is part of this spec that the above correspondences are
16304 -- guaranteed. This means that it is legitimate to, for
16305 -- example, use Integer instead of int. We provide these
16306 -- synonyms for clarity, but in some cases it may be
16307 -- convenient to use the underlying types (for example to
16308 -- avoid an unnecessary dependency of a spec on the spec
16310 type size_t is mod 2 ** Standard'Address_Size;
16311 NULL_Stream : constant FILEs;
16312 -- Value returned (NULL in C) to indicate an
16313 -- fdopen/fopen/tmpfile error
16314 ----------------------------------
16315 -- Constants Defined in stdio.h --
16316 ----------------------------------
16317 EOF : constant int;
16318 -- Used by a number of routines to indicate error or
16320 IOFBF : constant int;
16321 IOLBF : constant int;
16322 IONBF : constant int;
16323 -- Used to indicate buffering mode for setvbuf call
16324 SEEK_CUR : constant int;
16325 SEEK_END : constant int;
16326 SEEK_SET : constant int;
16327 -- Used to indicate origin for fseek call
16328 function stdin return FILEs;
16329 function stdout return FILEs;
16330 function stderr return FILEs;
16331 -- Streams associated with standard files
16332 --------------------------
16333 -- Standard C functions --
16334 --------------------------
16335 -- The functions selected below are ones that are
16336 -- available in UNIX (but not necessarily in ANSI C).
16337 -- These are very thin interfaces
16338 -- which copy exactly the C headers. For more
16339 -- documentation on these functions, see the Microsoft C
16340 -- "Run-Time Library Reference" (Microsoft Press, 1990,
16341 -- ISBN 1-55615-225-6), which includes useful information
16342 -- on system compatibility.
16343 procedure clearerr (stream : FILEs);
16344 function fclose (stream : FILEs) return int;
16345 function fdopen (handle : int; mode : chars) return FILEs;
16346 function feof (stream : FILEs) return int;
16347 function ferror (stream : FILEs) return int;
16348 function fflush (stream : FILEs) return int;
16349 function fgetc (stream : FILEs) return int;
16350 function fgets (strng : chars; n : int; stream : FILEs)
16352 function fileno (stream : FILEs) return int;
16353 function fopen (filename : chars; Mode : chars)
16355 -- Note: to maintain target independence, use
16356 -- text_translation_required, a boolean variable defined in
16357 -- a-sysdep.c to deal with the target dependent text
16358 -- translation requirement. If this variable is set,
16359 -- then b/t should be appended to the standard mode
16360 -- argument to set the text translation mode off or on
16362 function fputc (C : int; stream : FILEs) return int;
16363 function fputs (Strng : chars; Stream : FILEs) return int;
16380 function ftell (stream : FILEs) return long;
16387 function isatty (handle : int) return int;
16388 procedure mktemp (template : chars);
16389 -- The return value (which is just a pointer to template)
16391 procedure rewind (stream : FILEs);
16392 function rmtmp return int;
16400 function tmpfile return FILEs;
16401 function ungetc (c : int; stream : FILEs) return int;
16402 function unlink (filename : chars) return int;
16403 ---------------------
16404 -- Extra functions --
16405 ---------------------
16406 -- These functions supply slightly thicker bindings than
16407 -- those above. They are derived from functions in the
16408 -- C Run-Time Library, but may do a bit more work than
16409 -- just directly calling one of the Library functions.
16410 function is_regular_file (handle : int) return int;
16411 -- Tests if given handle is for a regular file (result 1)
16412 -- or for a non-regular file (pipe or device, result 0).
16413 ---------------------------------
16414 -- Control of Text/Binary Mode --
16415 ---------------------------------
16416 -- If text_translation_required is true, then the following
16417 -- functions may be used to dynamically switch a file from
16418 -- binary to text mode or vice versa. These functions have
16419 -- no effect if text_translation_required is false (i.e.@: in
16420 -- normal UNIX mode). Use fileno to get a stream handle.
16421 procedure set_binary_mode (handle : int);
16422 procedure set_text_mode (handle : int);
16423 ----------------------------
16424 -- Full Path Name support --
16425 ----------------------------
16426 procedure full_name (nam : chars; buffer : chars);
16427 -- Given a NUL terminated string representing a file
16428 -- name, returns in buffer a NUL terminated string
16429 -- representing the full path name for the file name.
16430 -- On systems where it is relevant the drive is also
16431 -- part of the full path name. It is the responsibility
16432 -- of the caller to pass an actual parameter for buffer
16433 -- that is big enough for any full path name. Use
16434 -- max_path_len given below as the size of buffer.
16435 max_path_len : integer;
16436 -- Maximum length of an allowable full path name on the
16437 -- system, including a terminating NUL character.
16438 end Interfaces.C_Streams;
16441 @node Interfacing to C Streams
16442 @section Interfacing to C Streams
16445 The packages in this section permit interfacing Ada files to C Stream
16448 @smallexample @c ada
16449 with Interfaces.C_Streams;
16450 package Ada.Sequential_IO.C_Streams is
16451 function C_Stream (F : File_Type)
16452 return Interfaces.C_Streams.FILEs;
16454 (File : in out File_Type;
16455 Mode : in File_Mode;
16456 C_Stream : in Interfaces.C_Streams.FILEs;
16457 Form : in String := "");
16458 end Ada.Sequential_IO.C_Streams;
16460 with Interfaces.C_Streams;
16461 package Ada.Direct_IO.C_Streams is
16462 function C_Stream (F : File_Type)
16463 return Interfaces.C_Streams.FILEs;
16465 (File : in out File_Type;
16466 Mode : in File_Mode;
16467 C_Stream : in Interfaces.C_Streams.FILEs;
16468 Form : in String := "");
16469 end Ada.Direct_IO.C_Streams;
16471 with Interfaces.C_Streams;
16472 package Ada.Text_IO.C_Streams is
16473 function C_Stream (F : File_Type)
16474 return Interfaces.C_Streams.FILEs;
16476 (File : in out File_Type;
16477 Mode : in File_Mode;
16478 C_Stream : in Interfaces.C_Streams.FILEs;
16479 Form : in String := "");
16480 end Ada.Text_IO.C_Streams;
16482 with Interfaces.C_Streams;
16483 package Ada.Wide_Text_IO.C_Streams is
16484 function C_Stream (F : File_Type)
16485 return Interfaces.C_Streams.FILEs;
16487 (File : in out File_Type;
16488 Mode : in File_Mode;
16489 C_Stream : in Interfaces.C_Streams.FILEs;
16490 Form : in String := "");
16491 end Ada.Wide_Text_IO.C_Streams;
16493 with Interfaces.C_Streams;
16494 package Ada.Wide_Wide_Text_IO.C_Streams is
16495 function C_Stream (F : File_Type)
16496 return Interfaces.C_Streams.FILEs;
16498 (File : in out File_Type;
16499 Mode : in File_Mode;
16500 C_Stream : in Interfaces.C_Streams.FILEs;
16501 Form : in String := "");
16502 end Ada.Wide_Wide_Text_IO.C_Streams;
16504 with Interfaces.C_Streams;
16505 package Ada.Stream_IO.C_Streams is
16506 function C_Stream (F : File_Type)
16507 return Interfaces.C_Streams.FILEs;
16509 (File : in out File_Type;
16510 Mode : in File_Mode;
16511 C_Stream : in Interfaces.C_Streams.FILEs;
16512 Form : in String := "");
16513 end Ada.Stream_IO.C_Streams;
16517 In each of these six packages, the @code{C_Stream} function obtains the
16518 @code{FILE} pointer from a currently opened Ada file. It is then
16519 possible to use the @code{Interfaces.C_Streams} package to operate on
16520 this stream, or the stream can be passed to a C program which can
16521 operate on it directly. Of course the program is responsible for
16522 ensuring that only appropriate sequences of operations are executed.
16524 One particular use of relevance to an Ada program is that the
16525 @code{setvbuf} function can be used to control the buffering of the
16526 stream used by an Ada file. In the absence of such a call the standard
16527 default buffering is used.
16529 The @code{Open} procedures in these packages open a file giving an
16530 existing C Stream instead of a file name. Typically this stream is
16531 imported from a C program, allowing an Ada file to operate on an
16534 @node The GNAT Library
16535 @chapter The GNAT Library
16538 The GNAT library contains a number of general and special purpose packages.
16539 It represents functionality that the GNAT developers have found useful, and
16540 which is made available to GNAT users. The packages described here are fully
16541 supported, and upwards compatibility will be maintained in future releases,
16542 so you can use these facilities with the confidence that the same functionality
16543 will be available in future releases.
16545 The chapter here simply gives a brief summary of the facilities available.
16546 The full documentation is found in the spec file for the package. The full
16547 sources of these library packages, including both spec and body, are provided
16548 with all GNAT releases. For example, to find out the full specifications of
16549 the SPITBOL pattern matching capability, including a full tutorial and
16550 extensive examples, look in the @file{g-spipat.ads} file in the library.
16552 For each entry here, the package name (as it would appear in a @code{with}
16553 clause) is given, followed by the name of the corresponding spec file in
16554 parentheses. The packages are children in four hierarchies, @code{Ada},
16555 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
16556 GNAT-specific hierarchy.
16558 Note that an application program should only use packages in one of these
16559 four hierarchies if the package is defined in the Ada Reference Manual,
16560 or is listed in this section of the GNAT Programmers Reference Manual.
16561 All other units should be considered internal implementation units and
16562 should not be directly @code{with}'ed by application code. The use of
16563 a @code{with} statement that references one of these internal implementation
16564 units makes an application potentially dependent on changes in versions
16565 of GNAT, and will generate a warning message.
16568 * Ada.Characters.Latin_9 (a-chlat9.ads)::
16569 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
16570 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
16571 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
16572 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
16573 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
16574 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
16575 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
16576 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
16577 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
16578 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
16579 * Ada.Command_Line.Environment (a-colien.ads)::
16580 * Ada.Command_Line.Remove (a-colire.ads)::
16581 * Ada.Command_Line.Response_File (a-clrefi.ads)::
16582 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
16583 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
16584 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
16585 * Ada.Exceptions.Traceback (a-exctra.ads)::
16586 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
16587 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
16588 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
16589 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
16590 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
16591 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
16592 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
16593 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
16594 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
16595 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
16596 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
16597 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
16598 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
16599 * GNAT.Altivec (g-altive.ads)::
16600 * GNAT.Altivec.Conversions (g-altcon.ads)::
16601 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
16602 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
16603 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
16604 * GNAT.Array_Split (g-arrspl.ads)::
16605 * GNAT.AWK (g-awk.ads)::
16606 * GNAT.Bounded_Buffers (g-boubuf.ads)::
16607 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
16608 * GNAT.Bubble_Sort (g-bubsor.ads)::
16609 * GNAT.Bubble_Sort_A (g-busora.ads)::
16610 * GNAT.Bubble_Sort_G (g-busorg.ads)::
16611 * GNAT.Byte_Order_Mark (g-byorma.ads)::
16612 * GNAT.Byte_Swapping (g-bytswa.ads)::
16613 * GNAT.Calendar (g-calend.ads)::
16614 * GNAT.Calendar.Time_IO (g-catiio.ads)::
16615 * GNAT.Case_Util (g-casuti.ads)::
16616 * GNAT.CGI (g-cgi.ads)::
16617 * GNAT.CGI.Cookie (g-cgicoo.ads)::
16618 * GNAT.CGI.Debug (g-cgideb.ads)::
16619 * GNAT.Command_Line (g-comlin.ads)::
16620 * GNAT.Compiler_Version (g-comver.ads)::
16621 * GNAT.Ctrl_C (g-ctrl_c.ads)::
16622 * GNAT.CRC32 (g-crc32.ads)::
16623 * GNAT.Current_Exception (g-curexc.ads)::
16624 * GNAT.Debug_Pools (g-debpoo.ads)::
16625 * GNAT.Debug_Utilities (g-debuti.ads)::
16626 * GNAT.Decode_String (g-decstr.ads)::
16627 * GNAT.Decode_UTF8_String (g-deutst.ads)::
16628 * GNAT.Directory_Operations (g-dirope.ads)::
16629 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
16630 * GNAT.Dynamic_HTables (g-dynhta.ads)::
16631 * GNAT.Dynamic_Tables (g-dyntab.ads)::
16632 * GNAT.Encode_String (g-encstr.ads)::
16633 * GNAT.Encode_UTF8_String (g-enutst.ads)::
16634 * GNAT.Exception_Actions (g-excact.ads)::
16635 * GNAT.Exception_Traces (g-exctra.ads)::
16636 * GNAT.Exceptions (g-except.ads)::
16637 * GNAT.Expect (g-expect.ads)::
16638 * GNAT.Expect.TTY (g-exptty.ads)::
16639 * GNAT.Float_Control (g-flocon.ads)::
16640 * GNAT.Heap_Sort (g-heasor.ads)::
16641 * GNAT.Heap_Sort_A (g-hesora.ads)::
16642 * GNAT.Heap_Sort_G (g-hesorg.ads)::
16643 * GNAT.HTable (g-htable.ads)::
16644 * GNAT.IO (g-io.ads)::
16645 * GNAT.IO_Aux (g-io_aux.ads)::
16646 * GNAT.Lock_Files (g-locfil.ads)::
16647 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
16648 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
16649 * GNAT.MD5 (g-md5.ads)::
16650 * GNAT.Memory_Dump (g-memdum.ads)::
16651 * GNAT.Most_Recent_Exception (g-moreex.ads)::
16652 * GNAT.OS_Lib (g-os_lib.ads)::
16653 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
16654 * GNAT.Random_Numbers (g-rannum.ads)::
16655 * GNAT.Regexp (g-regexp.ads)::
16656 * GNAT.Registry (g-regist.ads)::
16657 * GNAT.Regpat (g-regpat.ads)::
16658 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
16659 * GNAT.Semaphores (g-semaph.ads)::
16660 * GNAT.Serial_Communications (g-sercom.ads)::
16661 * GNAT.SHA1 (g-sha1.ads)::
16662 * GNAT.SHA224 (g-sha224.ads)::
16663 * GNAT.SHA256 (g-sha256.ads)::
16664 * GNAT.SHA384 (g-sha384.ads)::
16665 * GNAT.SHA512 (g-sha512.ads)::
16666 * GNAT.Signals (g-signal.ads)::
16667 * GNAT.Sockets (g-socket.ads)::
16668 * GNAT.Source_Info (g-souinf.ads)::
16669 * GNAT.Spelling_Checker (g-speche.ads)::
16670 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
16671 * GNAT.Spitbol.Patterns (g-spipat.ads)::
16672 * GNAT.Spitbol (g-spitbo.ads)::
16673 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
16674 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
16675 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
16676 * GNAT.SSE (g-sse.ads)::
16677 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
16678 * GNAT.Strings (g-string.ads)::
16679 * GNAT.String_Split (g-strspl.ads)::
16680 * GNAT.Table (g-table.ads)::
16681 * GNAT.Task_Lock (g-tasloc.ads)::
16682 * GNAT.Threads (g-thread.ads)::
16683 * GNAT.Time_Stamp (g-timsta.ads)::
16684 * GNAT.Traceback (g-traceb.ads)::
16685 * GNAT.Traceback.Symbolic (g-trasym.ads)::
16686 * GNAT.UTF_32 (g-utf_32.ads)::
16687 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
16688 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
16689 * GNAT.Wide_String_Split (g-wistsp.ads)::
16690 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
16691 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
16692 * Interfaces.C.Extensions (i-cexten.ads)::
16693 * Interfaces.C.Streams (i-cstrea.ads)::
16694 * Interfaces.CPP (i-cpp.ads)::
16695 * Interfaces.Packed_Decimal (i-pacdec.ads)::
16696 * Interfaces.VxWorks (i-vxwork.ads)::
16697 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
16698 * System.Address_Image (s-addima.ads)::
16699 * System.Assertions (s-assert.ads)::
16700 * System.Memory (s-memory.ads)::
16701 * System.Multiprocessors (s-multip.ads)::
16702 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
16703 * System.Partition_Interface (s-parint.ads)::
16704 * System.Pool_Global (s-pooglo.ads)::
16705 * System.Pool_Local (s-pooloc.ads)::
16706 * System.Restrictions (s-restri.ads)::
16707 * System.Rident (s-rident.ads)::
16708 * System.Strings.Stream_Ops (s-ststop.ads)::
16709 * System.Task_Info (s-tasinf.ads)::
16710 * System.Wch_Cnv (s-wchcnv.ads)::
16711 * System.Wch_Con (s-wchcon.ads)::
16714 @node Ada.Characters.Latin_9 (a-chlat9.ads)
16715 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16716 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16717 @cindex Latin_9 constants for Character
16720 This child of @code{Ada.Characters}
16721 provides a set of definitions corresponding to those in the
16722 RM-defined package @code{Ada.Characters.Latin_1} but with the
16723 few modifications required for @code{Latin-9}
16724 The provision of such a package
16725 is specifically authorized by the Ada Reference Manual
16728 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
16729 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16730 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16731 @cindex Latin_1 constants for Wide_Character
16734 This child of @code{Ada.Characters}
16735 provides a set of definitions corresponding to those in the
16736 RM-defined package @code{Ada.Characters.Latin_1} but with the
16737 types of the constants being @code{Wide_Character}
16738 instead of @code{Character}. The provision of such a package
16739 is specifically authorized by the Ada Reference Manual
16742 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
16743 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16744 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16745 @cindex Latin_9 constants for Wide_Character
16748 This child of @code{Ada.Characters}
16749 provides a set of definitions corresponding to those in the
16750 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16751 types of the constants being @code{Wide_Character}
16752 instead of @code{Character}. The provision of such a package
16753 is specifically authorized by the Ada Reference Manual
16756 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
16757 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16758 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16759 @cindex Latin_1 constants for Wide_Wide_Character
16762 This child of @code{Ada.Characters}
16763 provides a set of definitions corresponding to those in the
16764 RM-defined package @code{Ada.Characters.Latin_1} but with the
16765 types of the constants being @code{Wide_Wide_Character}
16766 instead of @code{Character}. The provision of such a package
16767 is specifically authorized by the Ada Reference Manual
16770 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
16771 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16772 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16773 @cindex Latin_9 constants for Wide_Wide_Character
16776 This child of @code{Ada.Characters}
16777 provides a set of definitions corresponding to those in the
16778 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16779 types of the constants being @code{Wide_Wide_Character}
16780 instead of @code{Character}. The provision of such a package
16781 is specifically authorized by the Ada Reference Manual
16784 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
16785 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16786 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16787 @cindex Formal container for doubly linked lists
16790 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16791 container for doubly linked lists, meant to facilitate formal verification of
16792 code using such containers.
16794 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
16795 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16796 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16797 @cindex Formal container for hashed maps
16800 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16801 container for hashed maps, meant to facilitate formal verification of
16802 code using such containers.
16804 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
16805 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16806 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16807 @cindex Formal container for hashed sets
16810 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16811 container for hashed sets, meant to facilitate formal verification of
16812 code using such containers.
16814 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
16815 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16816 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16817 @cindex Formal container for ordered maps
16820 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16821 container for ordered maps, meant to facilitate formal verification of
16822 code using such containers.
16824 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
16825 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16826 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16827 @cindex Formal container for ordered sets
16830 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16831 container for ordered sets, meant to facilitate formal verification of
16832 code using such containers.
16834 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
16835 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16836 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16837 @cindex Formal container for vectors
16840 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16841 container for vectors, meant to facilitate formal verification of
16842 code using such containers.
16844 @node Ada.Command_Line.Environment (a-colien.ads)
16845 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16846 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16847 @cindex Environment entries
16850 This child of @code{Ada.Command_Line}
16851 provides a mechanism for obtaining environment values on systems
16852 where this concept makes sense.
16854 @node Ada.Command_Line.Remove (a-colire.ads)
16855 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16856 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16857 @cindex Removing command line arguments
16858 @cindex Command line, argument removal
16861 This child of @code{Ada.Command_Line}
16862 provides a mechanism for logically removing
16863 arguments from the argument list. Once removed, an argument is not visible
16864 to further calls on the subprograms in @code{Ada.Command_Line} will not
16865 see the removed argument.
16867 @node Ada.Command_Line.Response_File (a-clrefi.ads)
16868 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16869 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16870 @cindex Response file for command line
16871 @cindex Command line, response file
16872 @cindex Command line, handling long command lines
16875 This child of @code{Ada.Command_Line} provides a mechanism facilities for
16876 getting command line arguments from a text file, called a "response file".
16877 Using a response file allow passing a set of arguments to an executable longer
16878 than the maximum allowed by the system on the command line.
16880 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
16881 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16882 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16883 @cindex C Streams, Interfacing with Direct_IO
16886 This package provides subprograms that allow interfacing between
16887 C streams and @code{Direct_IO}. The stream identifier can be
16888 extracted from a file opened on the Ada side, and an Ada file
16889 can be constructed from a stream opened on the C side.
16891 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
16892 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16893 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16894 @cindex Null_Occurrence, testing for
16897 This child subprogram provides a way of testing for the null
16898 exception occurrence (@code{Null_Occurrence}) without raising
16901 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
16902 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16903 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16904 @cindex Null_Occurrence, testing for
16907 This child subprogram is used for handling otherwise unhandled
16908 exceptions (hence the name last chance), and perform clean ups before
16909 terminating the program. Note that this subprogram never returns.
16911 @node Ada.Exceptions.Traceback (a-exctra.ads)
16912 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16913 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16914 @cindex Traceback for Exception Occurrence
16917 This child package provides the subprogram (@code{Tracebacks}) to
16918 give a traceback array of addresses based on an exception
16921 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
16922 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16923 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16924 @cindex C Streams, Interfacing with Sequential_IO
16927 This package provides subprograms that allow interfacing between
16928 C streams and @code{Sequential_IO}. The stream identifier can be
16929 extracted from a file opened on the Ada side, and an Ada file
16930 can be constructed from a stream opened on the C side.
16932 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
16933 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16934 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16935 @cindex C Streams, Interfacing with Stream_IO
16938 This package provides subprograms that allow interfacing between
16939 C streams and @code{Stream_IO}. The stream identifier can be
16940 extracted from a file opened on the Ada side, and an Ada file
16941 can be constructed from a stream opened on the C side.
16943 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
16944 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16945 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16946 @cindex @code{Unbounded_String}, IO support
16947 @cindex @code{Text_IO}, extensions for unbounded strings
16950 This package provides subprograms for Text_IO for unbounded
16951 strings, avoiding the necessity for an intermediate operation
16952 with ordinary strings.
16954 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
16955 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16956 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16957 @cindex @code{Unbounded_Wide_String}, IO support
16958 @cindex @code{Text_IO}, extensions for unbounded wide strings
16961 This package provides subprograms for Text_IO for unbounded
16962 wide strings, avoiding the necessity for an intermediate operation
16963 with ordinary wide strings.
16965 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
16966 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16967 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16968 @cindex @code{Unbounded_Wide_Wide_String}, IO support
16969 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
16972 This package provides subprograms for Text_IO for unbounded
16973 wide wide strings, avoiding the necessity for an intermediate operation
16974 with ordinary wide wide strings.
16976 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
16977 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16978 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16979 @cindex C Streams, Interfacing with @code{Text_IO}
16982 This package provides subprograms that allow interfacing between
16983 C streams and @code{Text_IO}. The stream identifier can be
16984 extracted from a file opened on the Ada side, and an Ada file
16985 can be constructed from a stream opened on the C side.
16987 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
16988 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16989 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16990 @cindex @code{Text_IO} resetting standard files
16993 This procedure is used to reset the status of the standard files used
16994 by Ada.Text_IO. This is useful in a situation (such as a restart in an
16995 embedded application) where the status of the files may change during
16996 execution (for example a standard input file may be redefined to be
16999 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17000 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17001 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17002 @cindex Unicode categorization, Wide_Character
17005 This package provides subprograms that allow categorization of
17006 Wide_Character values according to Unicode categories.
17008 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17009 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17010 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17011 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17014 This package provides subprograms that allow interfacing between
17015 C streams and @code{Wide_Text_IO}. The stream identifier can be
17016 extracted from a file opened on the Ada side, and an Ada file
17017 can be constructed from a stream opened on the C side.
17019 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17020 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17021 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17022 @cindex @code{Wide_Text_IO} resetting standard files
17025 This procedure is used to reset the status of the standard files used
17026 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
17027 embedded application) where the status of the files may change during
17028 execution (for example a standard input file may be redefined to be
17031 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17032 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17033 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17034 @cindex Unicode categorization, Wide_Wide_Character
17037 This package provides subprograms that allow categorization of
17038 Wide_Wide_Character values according to Unicode categories.
17040 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17041 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17042 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17043 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17046 This package provides subprograms that allow interfacing between
17047 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
17048 extracted from a file opened on the Ada side, and an Ada file
17049 can be constructed from a stream opened on the C side.
17051 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17052 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17053 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17054 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17057 This procedure is used to reset the status of the standard files used
17058 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17059 restart in an embedded application) where the status of the files may
17060 change during execution (for example a standard input file may be
17061 redefined to be interactive).
17063 @node GNAT.Altivec (g-altive.ads)
17064 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17065 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17069 This is the root package of the GNAT AltiVec binding. It provides
17070 definitions of constants and types common to all the versions of the
17073 @node GNAT.Altivec.Conversions (g-altcon.ads)
17074 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17075 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17079 This package provides the Vector/View conversion routines.
17081 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17082 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17083 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17087 This package exposes the Ada interface to the AltiVec operations on
17088 vector objects. A soft emulation is included by default in the GNAT
17089 library. The hard binding is provided as a separate package. This unit
17090 is common to both bindings.
17092 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17093 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17094 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17098 This package exposes the various vector types part of the Ada binding
17099 to AltiVec facilities.
17101 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17102 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17103 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17107 This package provides public 'View' data types from/to which private
17108 vector representations can be converted via
17109 GNAT.Altivec.Conversions. This allows convenient access to individual
17110 vector elements and provides a simple way to initialize vector
17113 @node GNAT.Array_Split (g-arrspl.ads)
17114 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17115 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17116 @cindex Array splitter
17119 Useful array-manipulation routines: given a set of separators, split
17120 an array wherever the separators appear, and provide direct access
17121 to the resulting slices.
17123 @node GNAT.AWK (g-awk.ads)
17124 @section @code{GNAT.AWK} (@file{g-awk.ads})
17125 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17130 Provides AWK-like parsing functions, with an easy interface for parsing one
17131 or more files containing formatted data. The file is viewed as a database
17132 where each record is a line and a field is a data element in this line.
17134 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17135 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17136 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17138 @cindex Bounded Buffers
17141 Provides a concurrent generic bounded buffer abstraction. Instances are
17142 useful directly or as parts of the implementations of other abstractions,
17145 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17146 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17147 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17152 Provides a thread-safe asynchronous intertask mailbox communication facility.
17154 @node GNAT.Bubble_Sort (g-bubsor.ads)
17155 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17156 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17158 @cindex Bubble sort
17161 Provides a general implementation of bubble sort usable for sorting arbitrary
17162 data items. Exchange and comparison procedures are provided by passing
17163 access-to-procedure values.
17165 @node GNAT.Bubble_Sort_A (g-busora.ads)
17166 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17167 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17169 @cindex Bubble sort
17172 Provides a general implementation of bubble sort usable for sorting arbitrary
17173 data items. Move and comparison procedures are provided by passing
17174 access-to-procedure values. This is an older version, retained for
17175 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17177 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17178 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17179 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17181 @cindex Bubble sort
17184 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17185 are provided as generic parameters, this improves efficiency, especially
17186 if the procedures can be inlined, at the expense of duplicating code for
17187 multiple instantiations.
17189 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17190 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17191 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17192 @cindex UTF-8 representation
17193 @cindex Wide characte representations
17196 Provides a routine which given a string, reads the start of the string to
17197 see whether it is one of the standard byte order marks (BOM's) which signal
17198 the encoding of the string. The routine includes detection of special XML
17199 sequences for various UCS input formats.
17201 @node GNAT.Byte_Swapping (g-bytswa.ads)
17202 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17203 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17204 @cindex Byte swapping
17208 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17209 Machine-specific implementations are available in some cases.
17211 @node GNAT.Calendar (g-calend.ads)
17212 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17213 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17214 @cindex @code{Calendar}
17217 Extends the facilities provided by @code{Ada.Calendar} to include handling
17218 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17219 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17220 C @code{timeval} format.
17222 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17223 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17224 @cindex @code{Calendar}
17226 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17228 @node GNAT.CRC32 (g-crc32.ads)
17229 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17230 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
17232 @cindex Cyclic Redundancy Check
17235 This package implements the CRC-32 algorithm. For a full description
17236 of this algorithm see
17237 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
17238 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
17239 Aug.@: 1988. Sarwate, D.V@.
17241 @node GNAT.Case_Util (g-casuti.ads)
17242 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
17243 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
17244 @cindex Casing utilities
17245 @cindex Character handling (@code{GNAT.Case_Util})
17248 A set of simple routines for handling upper and lower casing of strings
17249 without the overhead of the full casing tables
17250 in @code{Ada.Characters.Handling}.
17252 @node GNAT.CGI (g-cgi.ads)
17253 @section @code{GNAT.CGI} (@file{g-cgi.ads})
17254 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
17255 @cindex CGI (Common Gateway Interface)
17258 This is a package for interfacing a GNAT program with a Web server via the
17259 Common Gateway Interface (CGI)@. Basically this package parses the CGI
17260 parameters, which are a set of key/value pairs sent by the Web server. It
17261 builds a table whose index is the key and provides some services to deal
17264 @node GNAT.CGI.Cookie (g-cgicoo.ads)
17265 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17266 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17267 @cindex CGI (Common Gateway Interface) cookie support
17268 @cindex Cookie support in CGI
17271 This is a package to interface a GNAT program with a Web server via the
17272 Common Gateway Interface (CGI). It exports services to deal with Web
17273 cookies (piece of information kept in the Web client software).
17275 @node GNAT.CGI.Debug (g-cgideb.ads)
17276 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17277 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17278 @cindex CGI (Common Gateway Interface) debugging
17281 This is a package to help debugging CGI (Common Gateway Interface)
17282 programs written in Ada.
17284 @node GNAT.Command_Line (g-comlin.ads)
17285 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
17286 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
17287 @cindex Command line
17290 Provides a high level interface to @code{Ada.Command_Line} facilities,
17291 including the ability to scan for named switches with optional parameters
17292 and expand file names using wild card notations.
17294 @node GNAT.Compiler_Version (g-comver.ads)
17295 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17296 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17297 @cindex Compiler Version
17298 @cindex Version, of compiler
17301 Provides a routine for obtaining the version of the compiler used to
17302 compile the program. More accurately this is the version of the binder
17303 used to bind the program (this will normally be the same as the version
17304 of the compiler if a consistent tool set is used to compile all units
17307 @node GNAT.Ctrl_C (g-ctrl_c.ads)
17308 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17309 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17313 Provides a simple interface to handle Ctrl-C keyboard events.
17315 @node GNAT.Current_Exception (g-curexc.ads)
17316 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17317 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17318 @cindex Current exception
17319 @cindex Exception retrieval
17322 Provides access to information on the current exception that has been raised
17323 without the need for using the Ada 95 / Ada 2005 exception choice parameter
17324 specification syntax.
17325 This is particularly useful in simulating typical facilities for
17326 obtaining information about exceptions provided by Ada 83 compilers.
17328 @node GNAT.Debug_Pools (g-debpoo.ads)
17329 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17330 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17332 @cindex Debug pools
17333 @cindex Memory corruption debugging
17336 Provide a debugging storage pools that helps tracking memory corruption
17337 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
17338 @value{EDITION} User's Guide}.
17340 @node GNAT.Debug_Utilities (g-debuti.ads)
17341 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17342 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17346 Provides a few useful utilities for debugging purposes, including conversion
17347 to and from string images of address values. Supports both C and Ada formats
17348 for hexadecimal literals.
17350 @node GNAT.Decode_String (g-decstr.ads)
17351 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
17352 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
17353 @cindex Decoding strings
17354 @cindex String decoding
17355 @cindex Wide character encoding
17360 A generic package providing routines for decoding wide character and wide wide
17361 character strings encoded as sequences of 8-bit characters using a specified
17362 encoding method. Includes validation routines, and also routines for stepping
17363 to next or previous encoded character in an encoded string.
17364 Useful in conjunction with Unicode character coding. Note there is a
17365 preinstantiation for UTF-8. See next entry.
17367 @node GNAT.Decode_UTF8_String (g-deutst.ads)
17368 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17369 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17370 @cindex Decoding strings
17371 @cindex Decoding UTF-8 strings
17372 @cindex UTF-8 string decoding
17373 @cindex Wide character decoding
17378 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
17380 @node GNAT.Directory_Operations (g-dirope.ads)
17381 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17382 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17383 @cindex Directory operations
17386 Provides a set of routines for manipulating directories, including changing
17387 the current directory, making new directories, and scanning the files in a
17390 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
17391 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17392 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17393 @cindex Directory operations iteration
17396 A child unit of GNAT.Directory_Operations providing additional operations
17397 for iterating through directories.
17399 @node GNAT.Dynamic_HTables (g-dynhta.ads)
17400 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17401 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17402 @cindex Hash tables
17405 A generic implementation of hash tables that can be used to hash arbitrary
17406 data. Provided in two forms, a simple form with built in hash functions,
17407 and a more complex form in which the hash function is supplied.
17410 This package provides a facility similar to that of @code{GNAT.HTable},
17411 except that this package declares a type that can be used to define
17412 dynamic instances of the hash table, while an instantiation of
17413 @code{GNAT.HTable} creates a single instance of the hash table.
17415 @node GNAT.Dynamic_Tables (g-dyntab.ads)
17416 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17417 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17418 @cindex Table implementation
17419 @cindex Arrays, extendable
17422 A generic package providing a single dimension array abstraction where the
17423 length of the array can be dynamically modified.
17426 This package provides a facility similar to that of @code{GNAT.Table},
17427 except that this package declares a type that can be used to define
17428 dynamic instances of the table, while an instantiation of
17429 @code{GNAT.Table} creates a single instance of the table type.
17431 @node GNAT.Encode_String (g-encstr.ads)
17432 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
17433 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
17434 @cindex Encoding strings
17435 @cindex String encoding
17436 @cindex Wide character encoding
17441 A generic package providing routines for encoding wide character and wide
17442 wide character strings as sequences of 8-bit characters using a specified
17443 encoding method. Useful in conjunction with Unicode character coding.
17444 Note there is a preinstantiation for UTF-8. See next entry.
17446 @node GNAT.Encode_UTF8_String (g-enutst.ads)
17447 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17448 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17449 @cindex Encoding strings
17450 @cindex Encoding UTF-8 strings
17451 @cindex UTF-8 string encoding
17452 @cindex Wide character encoding
17457 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
17459 @node GNAT.Exception_Actions (g-excact.ads)
17460 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17461 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17462 @cindex Exception actions
17465 Provides callbacks when an exception is raised. Callbacks can be registered
17466 for specific exceptions, or when any exception is raised. This
17467 can be used for instance to force a core dump to ease debugging.
17469 @node GNAT.Exception_Traces (g-exctra.ads)
17470 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17471 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17472 @cindex Exception traces
17476 Provides an interface allowing to control automatic output upon exception
17479 @node GNAT.Exceptions (g-except.ads)
17480 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
17481 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
17482 @cindex Exceptions, Pure
17483 @cindex Pure packages, exceptions
17486 Normally it is not possible to raise an exception with
17487 a message from a subprogram in a pure package, since the
17488 necessary types and subprograms are in @code{Ada.Exceptions}
17489 which is not a pure unit. @code{GNAT.Exceptions} provides a
17490 facility for getting around this limitation for a few
17491 predefined exceptions, and for example allow raising
17492 @code{Constraint_Error} with a message from a pure subprogram.
17494 @node GNAT.Expect (g-expect.ads)
17495 @section @code{GNAT.Expect} (@file{g-expect.ads})
17496 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
17499 Provides a set of subprograms similar to what is available
17500 with the standard Tcl Expect tool.
17501 It allows you to easily spawn and communicate with an external process.
17502 You can send commands or inputs to the process, and compare the output
17503 with some expected regular expression. Currently @code{GNAT.Expect}
17504 is implemented on all native GNAT ports except for OpenVMS@.
17505 It is not implemented for cross ports, and in particular is not
17506 implemented for VxWorks or LynxOS@.
17508 @node GNAT.Expect.TTY (g-exptty.ads)
17509 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17510 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17513 As GNAT.Expect but using pseudo-terminal.
17514 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
17515 ports except for OpenVMS@. It is not implemented for cross ports, and
17516 in particular is not implemented for VxWorks or LynxOS@.
17518 @node GNAT.Float_Control (g-flocon.ads)
17519 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
17520 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
17521 @cindex Floating-Point Processor
17524 Provides an interface for resetting the floating-point processor into the
17525 mode required for correct semantic operation in Ada. Some third party
17526 library calls may cause this mode to be modified, and the Reset procedure
17527 in this package can be used to reestablish the required mode.
17529 @node GNAT.Heap_Sort (g-heasor.ads)
17530 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17531 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17535 Provides a general implementation of heap sort usable for sorting arbitrary
17536 data items. Exchange and comparison procedures are provided by passing
17537 access-to-procedure values. The algorithm used is a modified heap sort
17538 that performs approximately N*log(N) comparisons in the worst case.
17540 @node GNAT.Heap_Sort_A (g-hesora.ads)
17541 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17542 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17546 Provides a general implementation of heap sort usable for sorting arbitrary
17547 data items. Move and comparison procedures are provided by passing
17548 access-to-procedure values. The algorithm used is a modified heap sort
17549 that performs approximately N*log(N) comparisons in the worst case.
17550 This differs from @code{GNAT.Heap_Sort} in having a less convenient
17551 interface, but may be slightly more efficient.
17553 @node GNAT.Heap_Sort_G (g-hesorg.ads)
17554 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17555 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17559 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
17560 are provided as generic parameters, this improves efficiency, especially
17561 if the procedures can be inlined, at the expense of duplicating code for
17562 multiple instantiations.
17564 @node GNAT.HTable (g-htable.ads)
17565 @section @code{GNAT.HTable} (@file{g-htable.ads})
17566 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
17567 @cindex Hash tables
17570 A generic implementation of hash tables that can be used to hash arbitrary
17571 data. Provides two approaches, one a simple static approach, and the other
17572 allowing arbitrary dynamic hash tables.
17574 @node GNAT.IO (g-io.ads)
17575 @section @code{GNAT.IO} (@file{g-io.ads})
17576 @cindex @code{GNAT.IO} (@file{g-io.ads})
17578 @cindex Input/Output facilities
17581 A simple preelaborable input-output package that provides a subset of
17582 simple Text_IO functions for reading characters and strings from
17583 Standard_Input, and writing characters, strings and integers to either
17584 Standard_Output or Standard_Error.
17586 @node GNAT.IO_Aux (g-io_aux.ads)
17587 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17588 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17590 @cindex Input/Output facilities
17592 Provides some auxiliary functions for use with Text_IO, including a test
17593 for whether a file exists, and functions for reading a line of text.
17595 @node GNAT.Lock_Files (g-locfil.ads)
17596 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17597 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17598 @cindex File locking
17599 @cindex Locking using files
17602 Provides a general interface for using files as locks. Can be used for
17603 providing program level synchronization.
17605 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
17606 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17607 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17608 @cindex Random number generation
17611 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
17612 a modified version of the Blum-Blum-Shub generator.
17614 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
17615 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17616 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17617 @cindex Random number generation
17620 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
17621 a modified version of the Blum-Blum-Shub generator.
17623 @node GNAT.MD5 (g-md5.ads)
17624 @section @code{GNAT.MD5} (@file{g-md5.ads})
17625 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
17626 @cindex Message Digest MD5
17629 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
17631 @node GNAT.Memory_Dump (g-memdum.ads)
17632 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17633 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17634 @cindex Dump Memory
17637 Provides a convenient routine for dumping raw memory to either the
17638 standard output or standard error files. Uses GNAT.IO for actual
17641 @node GNAT.Most_Recent_Exception (g-moreex.ads)
17642 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17643 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17644 @cindex Exception, obtaining most recent
17647 Provides access to the most recently raised exception. Can be used for
17648 various logging purposes, including duplicating functionality of some
17649 Ada 83 implementation dependent extensions.
17651 @node GNAT.OS_Lib (g-os_lib.ads)
17652 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17653 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17654 @cindex Operating System interface
17655 @cindex Spawn capability
17658 Provides a range of target independent operating system interface functions,
17659 including time/date management, file operations, subprocess management,
17660 including a portable spawn procedure, and access to environment variables
17661 and error return codes.
17663 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
17664 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17665 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17666 @cindex Hash functions
17669 Provides a generator of static minimal perfect hash functions. No
17670 collisions occur and each item can be retrieved from the table in one
17671 probe (perfect property). The hash table size corresponds to the exact
17672 size of the key set and no larger (minimal property). The key set has to
17673 be know in advance (static property). The hash functions are also order
17674 preserving. If w2 is inserted after w1 in the generator, their
17675 hashcode are in the same order. These hashing functions are very
17676 convenient for use with realtime applications.
17678 @node GNAT.Random_Numbers (g-rannum.ads)
17679 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17680 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17681 @cindex Random number generation
17684 Provides random number capabilities which extend those available in the
17685 standard Ada library and are more convenient to use.
17687 @node GNAT.Regexp (g-regexp.ads)
17688 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
17689 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
17690 @cindex Regular expressions
17691 @cindex Pattern matching
17694 A simple implementation of regular expressions, using a subset of regular
17695 expression syntax copied from familiar Unix style utilities. This is the
17696 simples of the three pattern matching packages provided, and is particularly
17697 suitable for ``file globbing'' applications.
17699 @node GNAT.Registry (g-regist.ads)
17700 @section @code{GNAT.Registry} (@file{g-regist.ads})
17701 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
17702 @cindex Windows Registry
17705 This is a high level binding to the Windows registry. It is possible to
17706 do simple things like reading a key value, creating a new key. For full
17707 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
17708 package provided with the Win32Ada binding
17710 @node GNAT.Regpat (g-regpat.ads)
17711 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
17712 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
17713 @cindex Regular expressions
17714 @cindex Pattern matching
17717 A complete implementation of Unix-style regular expression matching, copied
17718 from the original V7 style regular expression library written in C by
17719 Henry Spencer (and binary compatible with this C library).
17721 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
17722 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17723 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17724 @cindex Secondary Stack Info
17727 Provide the capability to query the high water mark of the current task's
17730 @node GNAT.Semaphores (g-semaph.ads)
17731 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
17732 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
17736 Provides classic counting and binary semaphores using protected types.
17738 @node GNAT.Serial_Communications (g-sercom.ads)
17739 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17740 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17741 @cindex Serial_Communications
17744 Provides a simple interface to send and receive data over a serial
17745 port. This is only supported on GNU/Linux and Windows.
17747 @node GNAT.SHA1 (g-sha1.ads)
17748 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
17749 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
17750 @cindex Secure Hash Algorithm SHA-1
17753 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
17756 @node GNAT.SHA224 (g-sha224.ads)
17757 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
17758 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
17759 @cindex Secure Hash Algorithm SHA-224
17762 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
17764 @node GNAT.SHA256 (g-sha256.ads)
17765 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
17766 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
17767 @cindex Secure Hash Algorithm SHA-256
17770 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
17772 @node GNAT.SHA384 (g-sha384.ads)
17773 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
17774 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
17775 @cindex Secure Hash Algorithm SHA-384
17778 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
17780 @node GNAT.SHA512 (g-sha512.ads)
17781 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
17782 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
17783 @cindex Secure Hash Algorithm SHA-512
17786 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
17788 @node GNAT.Signals (g-signal.ads)
17789 @section @code{GNAT.Signals} (@file{g-signal.ads})
17790 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
17794 Provides the ability to manipulate the blocked status of signals on supported
17797 @node GNAT.Sockets (g-socket.ads)
17798 @section @code{GNAT.Sockets} (@file{g-socket.ads})
17799 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
17803 A high level and portable interface to develop sockets based applications.
17804 This package is based on the sockets thin binding found in
17805 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
17806 on all native GNAT ports except for OpenVMS@. It is not implemented
17807 for the LynxOS@ cross port.
17809 @node GNAT.Source_Info (g-souinf.ads)
17810 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
17811 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
17812 @cindex Source Information
17815 Provides subprograms that give access to source code information known at
17816 compile time, such as the current file name and line number.
17818 @node GNAT.Spelling_Checker (g-speche.ads)
17819 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17820 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17821 @cindex Spell checking
17824 Provides a function for determining whether one string is a plausible
17825 near misspelling of another string.
17827 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
17828 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17829 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17830 @cindex Spell checking
17833 Provides a generic function that can be instantiated with a string type for
17834 determining whether one string is a plausible near misspelling of another
17837 @node GNAT.Spitbol.Patterns (g-spipat.ads)
17838 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17839 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17840 @cindex SPITBOL pattern matching
17841 @cindex Pattern matching
17844 A complete implementation of SNOBOL4 style pattern matching. This is the
17845 most elaborate of the pattern matching packages provided. It fully duplicates
17846 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
17847 efficient algorithm developed by Robert Dewar for the SPITBOL system.
17849 @node GNAT.Spitbol (g-spitbo.ads)
17850 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17851 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17852 @cindex SPITBOL interface
17855 The top level package of the collection of SPITBOL-style functionality, this
17856 package provides basic SNOBOL4 string manipulation functions, such as
17857 Pad, Reverse, Trim, Substr capability, as well as a generic table function
17858 useful for constructing arbitrary mappings from strings in the style of
17859 the SNOBOL4 TABLE function.
17861 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
17862 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17863 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17864 @cindex Sets of strings
17865 @cindex SPITBOL Tables
17868 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17869 for type @code{Standard.Boolean}, giving an implementation of sets of
17872 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
17873 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17874 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17875 @cindex Integer maps
17877 @cindex SPITBOL Tables
17880 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17881 for type @code{Standard.Integer}, giving an implementation of maps
17882 from string to integer values.
17884 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
17885 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17886 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17887 @cindex String maps
17889 @cindex SPITBOL Tables
17892 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
17893 a variable length string type, giving an implementation of general
17894 maps from strings to strings.
17896 @node GNAT.SSE (g-sse.ads)
17897 @section @code{GNAT.SSE} (@file{g-sse.ads})
17898 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
17901 Root of a set of units aimed at offering Ada bindings to a subset of
17902 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
17903 targets. It exposes vector component types together with a general
17904 introduction to the binding contents and use.
17906 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
17907 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17908 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17911 SSE vector types for use with SSE related intrinsics.
17913 @node GNAT.Strings (g-string.ads)
17914 @section @code{GNAT.Strings} (@file{g-string.ads})
17915 @cindex @code{GNAT.Strings} (@file{g-string.ads})
17918 Common String access types and related subprograms. Basically it
17919 defines a string access and an array of string access types.
17921 @node GNAT.String_Split (g-strspl.ads)
17922 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
17923 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
17924 @cindex String splitter
17927 Useful string manipulation routines: given a set of separators, split
17928 a string wherever the separators appear, and provide direct access
17929 to the resulting slices. This package is instantiated from
17930 @code{GNAT.Array_Split}.
17932 @node GNAT.Table (g-table.ads)
17933 @section @code{GNAT.Table} (@file{g-table.ads})
17934 @cindex @code{GNAT.Table} (@file{g-table.ads})
17935 @cindex Table implementation
17936 @cindex Arrays, extendable
17939 A generic package providing a single dimension array abstraction where the
17940 length of the array can be dynamically modified.
17943 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
17944 except that this package declares a single instance of the table type,
17945 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
17946 used to define dynamic instances of the table.
17948 @node GNAT.Task_Lock (g-tasloc.ads)
17949 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17950 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17951 @cindex Task synchronization
17952 @cindex Task locking
17956 A very simple facility for locking and unlocking sections of code using a
17957 single global task lock. Appropriate for use in situations where contention
17958 between tasks is very rarely expected.
17960 @node GNAT.Time_Stamp (g-timsta.ads)
17961 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17962 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17964 @cindex Current time
17967 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
17968 represents the current date and time in ISO 8601 format. This is a very simple
17969 routine with minimal code and there are no dependencies on any other unit.
17971 @node GNAT.Threads (g-thread.ads)
17972 @section @code{GNAT.Threads} (@file{g-thread.ads})
17973 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
17974 @cindex Foreign threads
17975 @cindex Threads, foreign
17978 Provides facilities for dealing with foreign threads which need to be known
17979 by the GNAT run-time system. Consult the documentation of this package for
17980 further details if your program has threads that are created by a non-Ada
17981 environment which then accesses Ada code.
17983 @node GNAT.Traceback (g-traceb.ads)
17984 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
17985 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
17986 @cindex Trace back facilities
17989 Provides a facility for obtaining non-symbolic traceback information, useful
17990 in various debugging situations.
17992 @node GNAT.Traceback.Symbolic (g-trasym.ads)
17993 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17994 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17995 @cindex Trace back facilities
17997 @node GNAT.UTF_32 (g-utf_32.ads)
17998 @section @code{GNAT.UTF_32} (@file{g-table.ads})
17999 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18000 @cindex Wide character codes
18003 This is a package intended to be used in conjunction with the
18004 @code{Wide_Character} type in Ada 95 and the
18005 @code{Wide_Wide_Character} type in Ada 2005 (available
18006 in @code{GNAT} in Ada 2005 mode). This package contains
18007 Unicode categorization routines, as well as lexical
18008 categorization routines corresponding to the Ada 2005
18009 lexical rules for identifiers and strings, and also a
18010 lower case to upper case fold routine corresponding to
18011 the Ada 2005 rules for identifier equivalence.
18013 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18014 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18015 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18016 @cindex Spell checking
18019 Provides a function for determining whether one wide wide string is a plausible
18020 near misspelling of another wide wide string, where the strings are represented
18021 using the UTF_32_String type defined in System.Wch_Cnv.
18023 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18024 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18025 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18026 @cindex Spell checking
18029 Provides a function for determining whether one wide string is a plausible
18030 near misspelling of another wide string.
18032 @node GNAT.Wide_String_Split (g-wistsp.ads)
18033 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18034 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18035 @cindex Wide_String splitter
18038 Useful wide string manipulation routines: given a set of separators, split
18039 a wide string wherever the separators appear, and provide direct access
18040 to the resulting slices. This package is instantiated from
18041 @code{GNAT.Array_Split}.
18043 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18044 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18045 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18046 @cindex Spell checking
18049 Provides a function for determining whether one wide wide string is a plausible
18050 near misspelling of another wide wide string.
18052 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18053 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18054 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18055 @cindex Wide_Wide_String splitter
18058 Useful wide wide string manipulation routines: given a set of separators, split
18059 a wide wide string wherever the separators appear, and provide direct access
18060 to the resulting slices. This package is instantiated from
18061 @code{GNAT.Array_Split}.
18063 @node Interfaces.C.Extensions (i-cexten.ads)
18064 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18065 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18068 This package contains additional C-related definitions, intended
18069 for use with either manually or automatically generated bindings
18072 @node Interfaces.C.Streams (i-cstrea.ads)
18073 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18074 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18075 @cindex C streams, interfacing
18078 This package is a binding for the most commonly used operations
18081 @node Interfaces.CPP (i-cpp.ads)
18082 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18083 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18084 @cindex C++ interfacing
18085 @cindex Interfacing, to C++
18088 This package provides facilities for use in interfacing to C++. It
18089 is primarily intended to be used in connection with automated tools
18090 for the generation of C++ interfaces.
18092 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18093 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18094 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18095 @cindex IBM Packed Format
18096 @cindex Packed Decimal
18099 This package provides a set of routines for conversions to and
18100 from a packed decimal format compatible with that used on IBM
18103 @node Interfaces.VxWorks (i-vxwork.ads)
18104 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18105 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18106 @cindex Interfacing to VxWorks
18107 @cindex VxWorks, interfacing
18110 This package provides a limited binding to the VxWorks API.
18111 In particular, it interfaces with the
18112 VxWorks hardware interrupt facilities.
18114 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18115 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18116 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18117 @cindex Interfacing to VxWorks' I/O
18118 @cindex VxWorks, I/O interfacing
18119 @cindex VxWorks, Get_Immediate
18120 @cindex Get_Immediate, VxWorks
18123 This package provides a binding to the ioctl (IO/Control)
18124 function of VxWorks, defining a set of option values and
18125 function codes. A particular use of this package is
18126 to enable the use of Get_Immediate under VxWorks.
18128 @node System.Address_Image (s-addima.ads)
18129 @section @code{System.Address_Image} (@file{s-addima.ads})
18130 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18131 @cindex Address image
18132 @cindex Image, of an address
18135 This function provides a useful debugging
18136 function that gives an (implementation dependent)
18137 string which identifies an address.
18139 @node System.Assertions (s-assert.ads)
18140 @section @code{System.Assertions} (@file{s-assert.ads})
18141 @cindex @code{System.Assertions} (@file{s-assert.ads})
18143 @cindex Assert_Failure, exception
18146 This package provides the declaration of the exception raised
18147 by an run-time assertion failure, as well as the routine that
18148 is used internally to raise this assertion.
18150 @node System.Memory (s-memory.ads)
18151 @section @code{System.Memory} (@file{s-memory.ads})
18152 @cindex @code{System.Memory} (@file{s-memory.ads})
18153 @cindex Memory allocation
18156 This package provides the interface to the low level routines used
18157 by the generated code for allocation and freeing storage for the
18158 default storage pool (analogous to the C routines malloc and free.
18159 It also provides a reallocation interface analogous to the C routine
18160 realloc. The body of this unit may be modified to provide alternative
18161 allocation mechanisms for the default pool, and in addition, direct
18162 calls to this unit may be made for low level allocation uses (for
18163 example see the body of @code{GNAT.Tables}).
18165 @node System.Multiprocessors (s-multip.ads)
18166 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18167 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18168 @cindex Multiprocessor interface
18169 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18170 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18171 technically an implementation-defined addition).
18173 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18174 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18175 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18176 @cindex Multiprocessor interface
18177 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18178 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18179 technically an implementation-defined addition).
18181 @node System.Partition_Interface (s-parint.ads)
18182 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18183 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18184 @cindex Partition interfacing functions
18187 This package provides facilities for partition interfacing. It
18188 is used primarily in a distribution context when using Annex E
18191 @node System.Pool_Global (s-pooglo.ads)
18192 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18193 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18194 @cindex Storage pool, global
18195 @cindex Global storage pool
18198 This package provides a storage pool that is equivalent to the default
18199 storage pool used for access types for which no pool is specifically
18200 declared. It uses malloc/free to allocate/free and does not attempt to
18201 do any automatic reclamation.
18203 @node System.Pool_Local (s-pooloc.ads)
18204 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18205 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18206 @cindex Storage pool, local
18207 @cindex Local storage pool
18210 This package provides a storage pool that is intended for use with locally
18211 defined access types. It uses malloc/free for allocate/free, and maintains
18212 a list of allocated blocks, so that all storage allocated for the pool can
18213 be freed automatically when the pool is finalized.
18215 @node System.Restrictions (s-restri.ads)
18216 @section @code{System.Restrictions} (@file{s-restri.ads})
18217 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18218 @cindex Run-time restrictions access
18221 This package provides facilities for accessing at run time
18222 the status of restrictions specified at compile time for
18223 the partition. Information is available both with regard
18224 to actual restrictions specified, and with regard to
18225 compiler determined information on which restrictions
18226 are violated by one or more packages in the partition.
18228 @node System.Rident (s-rident.ads)
18229 @section @code{System.Rident} (@file{s-rident.ads})
18230 @cindex @code{System.Rident} (@file{s-rident.ads})
18231 @cindex Restrictions definitions
18234 This package provides definitions of the restrictions
18235 identifiers supported by GNAT, and also the format of
18236 the restrictions provided in package System.Restrictions.
18237 It is not normally necessary to @code{with} this generic package
18238 since the necessary instantiation is included in
18239 package System.Restrictions.
18241 @node System.Strings.Stream_Ops (s-ststop.ads)
18242 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18243 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18244 @cindex Stream operations
18245 @cindex String stream operations
18248 This package provides a set of stream subprograms for standard string types.
18249 It is intended primarily to support implicit use of such subprograms when
18250 stream attributes are applied to string types, but the subprograms in this
18251 package can be used directly by application programs.
18253 @node System.Task_Info (s-tasinf.ads)
18254 @section @code{System.Task_Info} (@file{s-tasinf.ads})
18255 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
18256 @cindex Task_Info pragma
18259 This package provides target dependent functionality that is used
18260 to support the @code{Task_Info} pragma
18262 @node System.Wch_Cnv (s-wchcnv.ads)
18263 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18264 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18265 @cindex Wide Character, Representation
18266 @cindex Wide String, Conversion
18267 @cindex Representation of wide characters
18270 This package provides routines for converting between
18271 wide and wide wide characters and a representation as a value of type
18272 @code{Standard.String}, using a specified wide character
18273 encoding method. It uses definitions in
18274 package @code{System.Wch_Con}.
18276 @node System.Wch_Con (s-wchcon.ads)
18277 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
18278 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
18281 This package provides definitions and descriptions of
18282 the various methods used for encoding wide characters
18283 in ordinary strings. These definitions are used by
18284 the package @code{System.Wch_Cnv}.
18286 @node Interfacing to Other Languages
18287 @chapter Interfacing to Other Languages
18289 The facilities in annex B of the Ada Reference Manual are fully
18290 implemented in GNAT, and in addition, a full interface to C++ is
18294 * Interfacing to C::
18295 * Interfacing to C++::
18296 * Interfacing to COBOL::
18297 * Interfacing to Fortran::
18298 * Interfacing to non-GNAT Ada code::
18301 @node Interfacing to C
18302 @section Interfacing to C
18305 Interfacing to C with GNAT can use one of two approaches:
18309 The types in the package @code{Interfaces.C} may be used.
18311 Standard Ada types may be used directly. This may be less portable to
18312 other compilers, but will work on all GNAT compilers, which guarantee
18313 correspondence between the C and Ada types.
18317 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
18318 effect, since this is the default. The following table shows the
18319 correspondence between Ada scalar types and the corresponding C types.
18324 @item Short_Integer
18326 @item Short_Short_Integer
18330 @item Long_Long_Integer
18338 @item Long_Long_Float
18339 This is the longest floating-point type supported by the hardware.
18343 Additionally, there are the following general correspondences between Ada
18347 Ada enumeration types map to C enumeration types directly if pragma
18348 @code{Convention C} is specified, which causes them to have int
18349 length. Without pragma @code{Convention C}, Ada enumeration types map to
18350 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
18351 @code{int}, respectively) depending on the number of values passed.
18352 This is the only case in which pragma @code{Convention C} affects the
18353 representation of an Ada type.
18356 Ada access types map to C pointers, except for the case of pointers to
18357 unconstrained types in Ada, which have no direct C equivalent.
18360 Ada arrays map directly to C arrays.
18363 Ada records map directly to C structures.
18366 Packed Ada records map to C structures where all members are bit fields
18367 of the length corresponding to the @code{@var{type}'Size} value in Ada.
18370 @node Interfacing to C++
18371 @section Interfacing to C++
18374 The interface to C++ makes use of the following pragmas, which are
18375 primarily intended to be constructed automatically using a binding generator
18376 tool, although it is possible to construct them by hand.
18378 Using these pragmas it is possible to achieve complete
18379 inter-operability between Ada tagged types and C++ class definitions.
18380 See @ref{Implementation Defined Pragmas}, for more details.
18383 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
18384 The argument denotes an entity in the current declarative region that is
18385 declared as a tagged or untagged record type. It indicates that the type
18386 corresponds to an externally declared C++ class type, and is to be laid
18387 out the same way that C++ would lay out the type.
18389 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
18390 for backward compatibility but its functionality is available
18391 using pragma @code{Import} with @code{Convention} = @code{CPP}.
18393 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
18394 This pragma identifies an imported function (imported in the usual way
18395 with pragma @code{Import}) as corresponding to a C++ constructor.
18398 A few restrictions are placed on the use of the @code{Access} attribute
18399 in conjunction with subprograms subject to convention @code{CPP}: the
18400 attribute may be used neither on primitive operations of a tagged
18401 record type with convention @code{CPP}, imported or not, nor on
18402 subprograms imported with pragma @code{CPP_Constructor}.
18404 In addition, C++ exceptions are propagated and can be handled in an
18405 @code{others} choice of an exception handler. The corresponding Ada
18406 occurrence has no message, and the simple name of the exception identity
18407 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
18408 tasks works properly when such foreign exceptions are propagated.
18410 @node Interfacing to COBOL
18411 @section Interfacing to COBOL
18414 Interfacing to COBOL is achieved as described in section B.4 of
18415 the Ada Reference Manual.
18417 @node Interfacing to Fortran
18418 @section Interfacing to Fortran
18421 Interfacing to Fortran is achieved as described in section B.5 of the
18422 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
18423 multi-dimensional array causes the array to be stored in column-major
18424 order as required for convenient interface to Fortran.
18426 @node Interfacing to non-GNAT Ada code
18427 @section Interfacing to non-GNAT Ada code
18429 It is possible to specify the convention @code{Ada} in a pragma
18430 @code{Import} or pragma @code{Export}. However this refers to
18431 the calling conventions used by GNAT, which may or may not be
18432 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
18433 compiler to allow interoperation.
18435 If arguments types are kept simple, and if the foreign compiler generally
18436 follows system calling conventions, then it may be possible to integrate
18437 files compiled by other Ada compilers, provided that the elaboration
18438 issues are adequately addressed (for example by eliminating the
18439 need for any load time elaboration).
18441 In particular, GNAT running on VMS is designed to
18442 be highly compatible with the DEC Ada 83 compiler, so this is one
18443 case in which it is possible to import foreign units of this type,
18444 provided that the data items passed are restricted to simple scalar
18445 values or simple record types without variants, or simple array
18446 types with fixed bounds.
18448 @node Specialized Needs Annexes
18449 @chapter Specialized Needs Annexes
18452 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
18453 required in all implementations. However, as described in this chapter,
18454 GNAT implements all of these annexes:
18457 @item Systems Programming (Annex C)
18458 The Systems Programming Annex is fully implemented.
18460 @item Real-Time Systems (Annex D)
18461 The Real-Time Systems Annex is fully implemented.
18463 @item Distributed Systems (Annex E)
18464 Stub generation is fully implemented in the GNAT compiler. In addition,
18465 a complete compatible PCS is available as part of the GLADE system,
18466 a separate product. When the two
18467 products are used in conjunction, this annex is fully implemented.
18469 @item Information Systems (Annex F)
18470 The Information Systems annex is fully implemented.
18472 @item Numerics (Annex G)
18473 The Numerics Annex is fully implemented.
18475 @item Safety and Security / High-Integrity Systems (Annex H)
18476 The Safety and Security Annex (termed the High-Integrity Systems Annex
18477 in Ada 2005) is fully implemented.
18480 @node Implementation of Specific Ada Features
18481 @chapter Implementation of Specific Ada Features
18484 This chapter describes the GNAT implementation of several Ada language
18488 * Machine Code Insertions::
18489 * GNAT Implementation of Tasking::
18490 * GNAT Implementation of Shared Passive Packages::
18491 * Code Generation for Array Aggregates::
18492 * The Size of Discriminated Records with Default Discriminants::
18493 * Strict Conformance to the Ada Reference Manual::
18496 @node Machine Code Insertions
18497 @section Machine Code Insertions
18498 @cindex Machine Code insertions
18501 Package @code{Machine_Code} provides machine code support as described
18502 in the Ada Reference Manual in two separate forms:
18505 Machine code statements, consisting of qualified expressions that
18506 fit the requirements of RM section 13.8.
18508 An intrinsic callable procedure, providing an alternative mechanism of
18509 including machine instructions in a subprogram.
18513 The two features are similar, and both are closely related to the mechanism
18514 provided by the asm instruction in the GNU C compiler. Full understanding
18515 and use of the facilities in this package requires understanding the asm
18516 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
18517 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
18519 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
18520 semantic restrictions and effects as described below. Both are provided so
18521 that the procedure call can be used as a statement, and the function call
18522 can be used to form a code_statement.
18524 The first example given in the GCC documentation is the C @code{asm}
18527 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
18531 The equivalent can be written for GNAT as:
18533 @smallexample @c ada
18534 Asm ("fsinx %1 %0",
18535 My_Float'Asm_Output ("=f", result),
18536 My_Float'Asm_Input ("f", angle));
18540 The first argument to @code{Asm} is the assembler template, and is
18541 identical to what is used in GNU C@. This string must be a static
18542 expression. The second argument is the output operand list. It is
18543 either a single @code{Asm_Output} attribute reference, or a list of such
18544 references enclosed in parentheses (technically an array aggregate of
18547 The @code{Asm_Output} attribute denotes a function that takes two
18548 parameters. The first is a string, the second is the name of a variable
18549 of the type designated by the attribute prefix. The first (string)
18550 argument is required to be a static expression and designates the
18551 constraint for the parameter (e.g.@: what kind of register is
18552 required). The second argument is the variable to be updated with the
18553 result. The possible values for constraint are the same as those used in
18554 the RTL, and are dependent on the configuration file used to build the
18555 GCC back end. If there are no output operands, then this argument may
18556 either be omitted, or explicitly given as @code{No_Output_Operands}.
18558 The second argument of @code{@var{my_float}'Asm_Output} functions as
18559 though it were an @code{out} parameter, which is a little curious, but
18560 all names have the form of expressions, so there is no syntactic
18561 irregularity, even though normally functions would not be permitted
18562 @code{out} parameters. The third argument is the list of input
18563 operands. It is either a single @code{Asm_Input} attribute reference, or
18564 a list of such references enclosed in parentheses (technically an array
18565 aggregate of such references).
18567 The @code{Asm_Input} attribute denotes a function that takes two
18568 parameters. The first is a string, the second is an expression of the
18569 type designated by the prefix. The first (string) argument is required
18570 to be a static expression, and is the constraint for the parameter,
18571 (e.g.@: what kind of register is required). The second argument is the
18572 value to be used as the input argument. The possible values for the
18573 constant are the same as those used in the RTL, and are dependent on
18574 the configuration file used to built the GCC back end.
18576 If there are no input operands, this argument may either be omitted, or
18577 explicitly given as @code{No_Input_Operands}. The fourth argument, not
18578 present in the above example, is a list of register names, called the
18579 @dfn{clobber} argument. This argument, if given, must be a static string
18580 expression, and is a space or comma separated list of names of registers
18581 that must be considered destroyed as a result of the @code{Asm} call. If
18582 this argument is the null string (the default value), then the code
18583 generator assumes that no additional registers are destroyed.
18585 The fifth argument, not present in the above example, called the
18586 @dfn{volatile} argument, is by default @code{False}. It can be set to
18587 the literal value @code{True} to indicate to the code generator that all
18588 optimizations with respect to the instruction specified should be
18589 suppressed, and that in particular, for an instruction that has outputs,
18590 the instruction will still be generated, even if none of the outputs are
18591 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
18592 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
18593 Generally it is strongly advisable to use Volatile for any ASM statement
18594 that is missing either input or output operands, or when two or more ASM
18595 statements appear in sequence, to avoid unwanted optimizations. A warning
18596 is generated if this advice is not followed.
18598 The @code{Asm} subprograms may be used in two ways. First the procedure
18599 forms can be used anywhere a procedure call would be valid, and
18600 correspond to what the RM calls ``intrinsic'' routines. Such calls can
18601 be used to intersperse machine instructions with other Ada statements.
18602 Second, the function forms, which return a dummy value of the limited
18603 private type @code{Asm_Insn}, can be used in code statements, and indeed
18604 this is the only context where such calls are allowed. Code statements
18605 appear as aggregates of the form:
18607 @smallexample @c ada
18608 Asm_Insn'(Asm (@dots{}));
18609 Asm_Insn'(Asm_Volatile (@dots{}));
18613 In accordance with RM rules, such code statements are allowed only
18614 within subprograms whose entire body consists of such statements. It is
18615 not permissible to intermix such statements with other Ada statements.
18617 Typically the form using intrinsic procedure calls is more convenient
18618 and more flexible. The code statement form is provided to meet the RM
18619 suggestion that such a facility should be made available. The following
18620 is the exact syntax of the call to @code{Asm}. As usual, if named notation
18621 is used, the arguments may be given in arbitrary order, following the
18622 normal rules for use of positional and named arguments)
18626 [Template =>] static_string_EXPRESSION
18627 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
18628 [,[Inputs =>] INPUT_OPERAND_LIST ]
18629 [,[Clobber =>] static_string_EXPRESSION ]
18630 [,[Volatile =>] static_boolean_EXPRESSION] )
18632 OUTPUT_OPERAND_LIST ::=
18633 [PREFIX.]No_Output_Operands
18634 | OUTPUT_OPERAND_ATTRIBUTE
18635 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
18637 OUTPUT_OPERAND_ATTRIBUTE ::=
18638 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
18640 INPUT_OPERAND_LIST ::=
18641 [PREFIX.]No_Input_Operands
18642 | INPUT_OPERAND_ATTRIBUTE
18643 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
18645 INPUT_OPERAND_ATTRIBUTE ::=
18646 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
18650 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
18651 are declared in the package @code{Machine_Code} and must be referenced
18652 according to normal visibility rules. In particular if there is no
18653 @code{use} clause for this package, then appropriate package name
18654 qualification is required.
18656 @node GNAT Implementation of Tasking
18657 @section GNAT Implementation of Tasking
18660 This chapter outlines the basic GNAT approach to tasking (in particular,
18661 a multi-layered library for portability) and discusses issues related
18662 to compliance with the Real-Time Systems Annex.
18665 * Mapping Ada Tasks onto the Underlying Kernel Threads::
18666 * Ensuring Compliance with the Real-Time Annex::
18669 @node Mapping Ada Tasks onto the Underlying Kernel Threads
18670 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
18673 GNAT's run-time support comprises two layers:
18676 @item GNARL (GNAT Run-time Layer)
18677 @item GNULL (GNAT Low-level Library)
18681 In GNAT, Ada's tasking services rely on a platform and OS independent
18682 layer known as GNARL@. This code is responsible for implementing the
18683 correct semantics of Ada's task creation, rendezvous, protected
18686 GNARL decomposes Ada's tasking semantics into simpler lower level
18687 operations such as create a thread, set the priority of a thread,
18688 yield, create a lock, lock/unlock, etc. The spec for these low-level
18689 operations constitutes GNULLI, the GNULL Interface. This interface is
18690 directly inspired from the POSIX real-time API@.
18692 If the underlying executive or OS implements the POSIX standard
18693 faithfully, the GNULL Interface maps as is to the services offered by
18694 the underlying kernel. Otherwise, some target dependent glue code maps
18695 the services offered by the underlying kernel to the semantics expected
18698 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
18699 key point is that each Ada task is mapped on a thread in the underlying
18700 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
18702 In addition Ada task priorities map onto the underlying thread priorities.
18703 Mapping Ada tasks onto the underlying kernel threads has several advantages:
18707 The underlying scheduler is used to schedule the Ada tasks. This
18708 makes Ada tasks as efficient as kernel threads from a scheduling
18712 Interaction with code written in C containing threads is eased
18713 since at the lowest level Ada tasks and C threads map onto the same
18714 underlying kernel concept.
18717 When an Ada task is blocked during I/O the remaining Ada tasks are
18721 On multiprocessor systems Ada tasks can execute in parallel.
18725 Some threads libraries offer a mechanism to fork a new process, with the
18726 child process duplicating the threads from the parent.
18728 support this functionality when the parent contains more than one task.
18729 @cindex Forking a new process
18731 @node Ensuring Compliance with the Real-Time Annex
18732 @subsection Ensuring Compliance with the Real-Time Annex
18733 @cindex Real-Time Systems Annex compliance
18736 Although mapping Ada tasks onto
18737 the underlying threads has significant advantages, it does create some
18738 complications when it comes to respecting the scheduling semantics
18739 specified in the real-time annex (Annex D).
18741 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
18742 scheduling policy states:
18745 @emph{When the active priority of a ready task that is not running
18746 changes, or the setting of its base priority takes effect, the
18747 task is removed from the ready queue for its old active priority
18748 and is added at the tail of the ready queue for its new active
18749 priority, except in the case where the active priority is lowered
18750 due to the loss of inherited priority, in which case the task is
18751 added at the head of the ready queue for its new active priority.}
18755 While most kernels do put tasks at the end of the priority queue when
18756 a task changes its priority, (which respects the main
18757 FIFO_Within_Priorities requirement), almost none keep a thread at the
18758 beginning of its priority queue when its priority drops from the loss
18759 of inherited priority.
18761 As a result most vendors have provided incomplete Annex D implementations.
18763 The GNAT run-time, has a nice cooperative solution to this problem
18764 which ensures that accurate FIFO_Within_Priorities semantics are
18767 The principle is as follows. When an Ada task T is about to start
18768 running, it checks whether some other Ada task R with the same
18769 priority as T has been suspended due to the loss of priority
18770 inheritance. If this is the case, T yields and is placed at the end of
18771 its priority queue. When R arrives at the front of the queue it
18774 Note that this simple scheme preserves the relative order of the tasks
18775 that were ready to execute in the priority queue where R has been
18778 @node GNAT Implementation of Shared Passive Packages
18779 @section GNAT Implementation of Shared Passive Packages
18780 @cindex Shared passive packages
18783 GNAT fully implements the pragma @code{Shared_Passive} for
18784 @cindex pragma @code{Shared_Passive}
18785 the purpose of designating shared passive packages.
18786 This allows the use of passive partitions in the
18787 context described in the Ada Reference Manual; i.e., for communication
18788 between separate partitions of a distributed application using the
18789 features in Annex E.
18791 @cindex Distribution Systems Annex
18793 However, the implementation approach used by GNAT provides for more
18794 extensive usage as follows:
18797 @item Communication between separate programs
18799 This allows separate programs to access the data in passive
18800 partitions, using protected objects for synchronization where
18801 needed. The only requirement is that the two programs have a
18802 common shared file system. It is even possible for programs
18803 running on different machines with different architectures
18804 (e.g.@: different endianness) to communicate via the data in
18805 a passive partition.
18807 @item Persistence between program runs
18809 The data in a passive package can persist from one run of a
18810 program to another, so that a later program sees the final
18811 values stored by a previous run of the same program.
18816 The implementation approach used is to store the data in files. A
18817 separate stream file is created for each object in the package, and
18818 an access to an object causes the corresponding file to be read or
18821 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
18822 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
18823 set to the directory to be used for these files.
18824 The files in this directory
18825 have names that correspond to their fully qualified names. For
18826 example, if we have the package
18828 @smallexample @c ada
18830 pragma Shared_Passive (X);
18837 and the environment variable is set to @code{/stemp/}, then the files created
18838 will have the names:
18846 These files are created when a value is initially written to the object, and
18847 the files are retained until manually deleted. This provides the persistence
18848 semantics. If no file exists, it means that no partition has assigned a value
18849 to the variable; in this case the initial value declared in the package
18850 will be used. This model ensures that there are no issues in synchronizing
18851 the elaboration process, since elaboration of passive packages elaborates the
18852 initial values, but does not create the files.
18854 The files are written using normal @code{Stream_IO} access.
18855 If you want to be able
18856 to communicate between programs or partitions running on different
18857 architectures, then you should use the XDR versions of the stream attribute
18858 routines, since these are architecture independent.
18860 If active synchronization is required for access to the variables in the
18861 shared passive package, then as described in the Ada Reference Manual, the
18862 package may contain protected objects used for this purpose. In this case
18863 a lock file (whose name is @file{___lock} (three underscores)
18864 is created in the shared memory directory.
18865 @cindex @file{___lock} file (for shared passive packages)
18866 This is used to provide the required locking
18867 semantics for proper protected object synchronization.
18869 As of January 2003, GNAT supports shared passive packages on all platforms
18870 except for OpenVMS.
18872 @node Code Generation for Array Aggregates
18873 @section Code Generation for Array Aggregates
18876 * Static constant aggregates with static bounds::
18877 * Constant aggregates with unconstrained nominal types::
18878 * Aggregates with static bounds::
18879 * Aggregates with non-static bounds::
18880 * Aggregates in assignment statements::
18884 Aggregates have a rich syntax and allow the user to specify the values of
18885 complex data structures by means of a single construct. As a result, the
18886 code generated for aggregates can be quite complex and involve loops, case
18887 statements and multiple assignments. In the simplest cases, however, the
18888 compiler will recognize aggregates whose components and constraints are
18889 fully static, and in those cases the compiler will generate little or no
18890 executable code. The following is an outline of the code that GNAT generates
18891 for various aggregate constructs. For further details, you will find it
18892 useful to examine the output produced by the -gnatG flag to see the expanded
18893 source that is input to the code generator. You may also want to examine
18894 the assembly code generated at various levels of optimization.
18896 The code generated for aggregates depends on the context, the component values,
18897 and the type. In the context of an object declaration the code generated is
18898 generally simpler than in the case of an assignment. As a general rule, static
18899 component values and static subtypes also lead to simpler code.
18901 @node Static constant aggregates with static bounds
18902 @subsection Static constant aggregates with static bounds
18905 For the declarations:
18906 @smallexample @c ada
18907 type One_Dim is array (1..10) of integer;
18908 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
18912 GNAT generates no executable code: the constant ar0 is placed in static memory.
18913 The same is true for constant aggregates with named associations:
18915 @smallexample @c ada
18916 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
18917 Cr3 : constant One_Dim := (others => 7777);
18921 The same is true for multidimensional constant arrays such as:
18923 @smallexample @c ada
18924 type two_dim is array (1..3, 1..3) of integer;
18925 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
18929 The same is true for arrays of one-dimensional arrays: the following are
18932 @smallexample @c ada
18933 type ar1b is array (1..3) of boolean;
18934 type ar_ar is array (1..3) of ar1b;
18935 None : constant ar1b := (others => false); -- fully static
18936 None2 : constant ar_ar := (1..3 => None); -- fully static
18940 However, for multidimensional aggregates with named associations, GNAT will
18941 generate assignments and loops, even if all associations are static. The
18942 following two declarations generate a loop for the first dimension, and
18943 individual component assignments for the second dimension:
18945 @smallexample @c ada
18946 Zero1: constant two_dim := (1..3 => (1..3 => 0));
18947 Zero2: constant two_dim := (others => (others => 0));
18950 @node Constant aggregates with unconstrained nominal types
18951 @subsection Constant aggregates with unconstrained nominal types
18954 In such cases the aggregate itself establishes the subtype, so that
18955 associations with @code{others} cannot be used. GNAT determines the
18956 bounds for the actual subtype of the aggregate, and allocates the
18957 aggregate statically as well. No code is generated for the following:
18959 @smallexample @c ada
18960 type One_Unc is array (natural range <>) of integer;
18961 Cr_Unc : constant One_Unc := (12,24,36);
18964 @node Aggregates with static bounds
18965 @subsection Aggregates with static bounds
18968 In all previous examples the aggregate was the initial (and immutable) value
18969 of a constant. If the aggregate initializes a variable, then code is generated
18970 for it as a combination of individual assignments and loops over the target
18971 object. The declarations
18973 @smallexample @c ada
18974 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
18975 Cr_Var2 : One_Dim := (others > -1);
18979 generate the equivalent of
18981 @smallexample @c ada
18987 for I in Cr_Var2'range loop
18992 @node Aggregates with non-static bounds
18993 @subsection Aggregates with non-static bounds
18996 If the bounds of the aggregate are not statically compatible with the bounds
18997 of the nominal subtype of the target, then constraint checks have to be
18998 generated on the bounds. For a multidimensional array, constraint checks may
18999 have to be applied to sub-arrays individually, if they do not have statically
19000 compatible subtypes.
19002 @node Aggregates in assignment statements
19003 @subsection Aggregates in assignment statements
19006 In general, aggregate assignment requires the construction of a temporary,
19007 and a copy from the temporary to the target of the assignment. This is because
19008 it is not always possible to convert the assignment into a series of individual
19009 component assignments. For example, consider the simple case:
19011 @smallexample @c ada
19016 This cannot be converted into:
19018 @smallexample @c ada
19024 So the aggregate has to be built first in a separate location, and then
19025 copied into the target. GNAT recognizes simple cases where this intermediate
19026 step is not required, and the assignments can be performed in place, directly
19027 into the target. The following sufficient criteria are applied:
19031 The bounds of the aggregate are static, and the associations are static.
19033 The components of the aggregate are static constants, names of
19034 simple variables that are not renamings, or expressions not involving
19035 indexed components whose operands obey these rules.
19039 If any of these conditions are violated, the aggregate will be built in
19040 a temporary (created either by the front-end or the code generator) and then
19041 that temporary will be copied onto the target.
19043 @node The Size of Discriminated Records with Default Discriminants
19044 @section The Size of Discriminated Records with Default Discriminants
19047 If a discriminated type @code{T} has discriminants with default values, it is
19048 possible to declare an object of this type without providing an explicit
19051 @smallexample @c ada
19053 type Size is range 1..100;
19055 type Rec (D : Size := 15) is record
19056 Name : String (1..D);
19064 Such an object is said to be @emph{unconstrained}.
19065 The discriminant of the object
19066 can be modified by a full assignment to the object, as long as it preserves the
19067 relation between the value of the discriminant, and the value of the components
19070 @smallexample @c ada
19072 Word := (3, "yes");
19074 Word := (5, "maybe");
19076 Word := (5, "no"); -- raises Constraint_Error
19081 In order to support this behavior efficiently, an unconstrained object is
19082 given the maximum size that any value of the type requires. In the case
19083 above, @code{Word} has storage for the discriminant and for
19084 a @code{String} of length 100.
19085 It is important to note that unconstrained objects do not require dynamic
19086 allocation. It would be an improper implementation to place on the heap those
19087 components whose size depends on discriminants. (This improper implementation
19088 was used by some Ada83 compilers, where the @code{Name} component above
19090 been stored as a pointer to a dynamic string). Following the principle that
19091 dynamic storage management should never be introduced implicitly,
19092 an Ada compiler should reserve the full size for an unconstrained declared
19093 object, and place it on the stack.
19095 This maximum size approach
19096 has been a source of surprise to some users, who expect the default
19097 values of the discriminants to determine the size reserved for an
19098 unconstrained object: ``If the default is 15, why should the object occupy
19100 The answer, of course, is that the discriminant may be later modified,
19101 and its full range of values must be taken into account. This is why the
19106 type Rec (D : Positive := 15) is record
19107 Name : String (1..D);
19115 is flagged by the compiler with a warning:
19116 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19117 because the required size includes @code{Positive'Last}
19118 bytes. As the first example indicates, the proper approach is to declare an
19119 index type of ``reasonable'' range so that unconstrained objects are not too
19122 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19123 created in the heap by means of an allocator, then it is @emph{not}
19125 it is constrained by the default values of the discriminants, and those values
19126 cannot be modified by full assignment. This is because in the presence of
19127 aliasing all views of the object (which may be manipulated by different tasks,
19128 say) must be consistent, so it is imperative that the object, once created,
19131 @node Strict Conformance to the Ada Reference Manual
19132 @section Strict Conformance to the Ada Reference Manual
19135 The dynamic semantics defined by the Ada Reference Manual impose a set of
19136 run-time checks to be generated. By default, the GNAT compiler will insert many
19137 run-time checks into the compiled code, including most of those required by the
19138 Ada Reference Manual. However, there are three checks that are not enabled
19139 in the default mode for efficiency reasons: arithmetic overflow checking for
19140 integer operations (including division by zero), checks for access before
19141 elaboration on subprogram calls, and stack overflow checking (most operating
19142 systems do not perform this check by default).
19144 Strict conformance to the Ada Reference Manual can be achieved by adding
19145 three compiler options for overflow checking for integer operations
19146 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19147 calls and generic instantiations (@option{-gnatE}), and stack overflow
19148 checking (@option{-fstack-check}).
19150 Note that the result of a floating point arithmetic operation in overflow and
19151 invalid situations, when the @code{Machine_Overflows} attribute of the result
19152 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19153 case for machines compliant with the IEEE floating-point standard, but on
19154 machines that are not fully compliant with this standard, such as Alpha, the
19155 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19156 behavior (although at the cost of a significant performance penalty), so
19157 infinite and NaN values are properly generated.
19160 @node Implementation of Ada 2012 Features
19161 @chapter Implementation of Ada 2012 Features
19162 @cindex Ada 2012 implementation status
19164 This chapter contains a complete list of Ada 2012 features that have been
19165 implemented as of GNAT version 6.4. Generally, these features are only
19166 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19167 @cindex @option{-gnat12} option
19168 or if the configuration pragma @code{Ada_2012} is used.
19169 @cindex pragma @code{Ada_2012}
19170 @cindex configuration pragma @code{Ada_2012}
19171 @cindex @code{Ada_2012} configuration pragma
19172 However, new pragmas, attributes, and restrictions are
19173 unconditionally available, since the Ada 95 standard allows the addition of
19174 new pragmas, attributes, and restrictions (there are exceptions, which are
19175 documented in the individual descriptions), and also certain packages
19176 were made available in earlier versions of Ada.
19178 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19179 This date shows the implementation date of the feature. Any wavefront
19180 subsequent to this date will contain the indicated feature, as will any
19181 subsequent releases. A date of 0000-00-00 means that GNAT has always
19182 implemented the feature, or implemented it as soon as it appeared as a
19183 binding interpretation.
19185 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19186 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19187 The features are ordered based on the relevant sections of the Ada
19188 Reference Manual (``RM''). When a given AI relates to multiple points
19189 in the RM, the earliest is used.
19191 A complete description of the AIs may be found in
19192 @url{www.ada-auth.org/ai05-summary.html}.
19197 @emph{AI-0176 Quantified expressions (2010-09-29)}
19198 @cindex AI-0176 (Ada 2012 feature)
19201 Both universally and existentially quantified expressions are implemented.
19202 They use the new syntax for iterators proposed in AI05-139-2, as well as
19203 the standard Ada loop syntax.
19206 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
19209 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19210 @cindex AI-0079 (Ada 2012 feature)
19213 Wide characters in the unicode category @i{other_format} are now allowed in
19214 source programs between tokens, but not within a token such as an identifier.
19217 RM References: 2.01 (4/2) 2.02 (7)
19220 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
19221 @cindex AI-0091 (Ada 2012 feature)
19224 Wide characters in the unicode category @i{other_format} are not permitted
19225 within an identifier, since this can be a security problem. The error
19226 message for this case has been improved to be more specific, but GNAT has
19227 never allowed such characters to appear in identifiers.
19230 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)
19233 @emph{AI-0100 Placement of pragmas (2010-07-01)}
19234 @cindex AI-0100 (Ada 2012 feature)
19237 This AI is an earlier version of AI-163. It simplifies the rules
19238 for legal placement of pragmas. In the case of lists that allow pragmas, if
19239 the list may have no elements, then the list may consist solely of pragmas.
19242 RM References: 2.08 (7)
19245 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
19246 @cindex AI-0163 (Ada 2012 feature)
19249 A statement sequence may be composed entirely of pragmas. It is no longer
19250 necessary to add a dummy @code{null} statement to make the sequence legal.
19253 RM References: 2.08 (7) 2.08 (16)
19257 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
19258 @cindex AI-0080 (Ada 2012 feature)
19261 This is an editorial change only, described as non-testable in the AI.
19264 RM References: 3.01 (7)
19268 @emph{AI-0183 Aspect specifications (2010-08-16)}
19269 @cindex AI-0183 (Ada 2012 feature)
19272 Aspect specifications have been fully implemented except for pre and post-
19273 conditions, and type invariants, which have their own separate AI's. All
19274 forms of declarations listed in the AI are supported. The following is a
19275 list of the aspects supported (with GNAT implementation aspects marked)
19277 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
19278 @item @code{Ada_2005} @tab -- GNAT
19279 @item @code{Ada_2012} @tab -- GNAT
19280 @item @code{Address} @tab
19281 @item @code{Alignment} @tab
19282 @item @code{Atomic} @tab
19283 @item @code{Atomic_Components} @tab
19284 @item @code{Bit_Order} @tab
19285 @item @code{Component_Size} @tab
19286 @item @code{Contract_Cases} @tab -- GNAT
19287 @item @code{Discard_Names} @tab
19288 @item @code{External_Tag} @tab
19289 @item @code{Favor_Top_Level} @tab -- GNAT
19290 @item @code{Inline} @tab
19291 @item @code{Inline_Always} @tab -- GNAT
19292 @item @code{Invariant} @tab -- GNAT
19293 @item @code{Machine_Radix} @tab
19294 @item @code{No_Return} @tab
19295 @item @code{Object_Size} @tab -- GNAT
19296 @item @code{Pack} @tab
19297 @item @code{Persistent_BSS} @tab -- GNAT
19298 @item @code{Post} @tab
19299 @item @code{Pre} @tab
19300 @item @code{Predicate} @tab
19301 @item @code{Preelaborable_Initialization} @tab
19302 @item @code{Pure_Function} @tab -- GNAT
19303 @item @code{Remote_Access_Type} @tab -- GNAT
19304 @item @code{Shared} @tab -- GNAT
19305 @item @code{Size} @tab
19306 @item @code{Storage_Pool} @tab
19307 @item @code{Storage_Size} @tab
19308 @item @code{Stream_Size} @tab
19309 @item @code{Suppress} @tab
19310 @item @code{Suppress_Debug_Info} @tab -- GNAT
19311 @item @code{Test_Case} @tab -- GNAT
19312 @item @code{Type_Invariant} @tab
19313 @item @code{Unchecked_Union} @tab
19314 @item @code{Universal_Aliasing} @tab -- GNAT
19315 @item @code{Unmodified} @tab -- GNAT
19316 @item @code{Unreferenced} @tab -- GNAT
19317 @item @code{Unreferenced_Objects} @tab -- GNAT
19318 @item @code{Unsuppress} @tab
19319 @item @code{Value_Size} @tab -- GNAT
19320 @item @code{Volatile} @tab
19321 @item @code{Volatile_Components}
19322 @item @code{Warnings} @tab -- GNAT
19326 Note that for aspects with an expression, e.g. @code{Size}, the expression is
19327 treated like a default expression (visibility is analyzed at the point of
19328 occurrence of the aspect, but evaluation of the expression occurs at the
19329 freeze point of the entity involved).
19332 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
19333 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
19334 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
19335 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
19336 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
19341 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
19342 @cindex AI-0128 (Ada 2012 feature)
19345 If an equality operator ("=") is declared for a type, then the implicitly
19346 declared inequality operator ("/=") is a primitive operation of the type.
19347 This is the only reasonable interpretation, and is the one always implemented
19348 by GNAT, but the RM was not entirely clear in making this point.
19351 RM References: 3.02.03 (6) 6.06 (6)
19354 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
19355 @cindex AI-0003 (Ada 2012 feature)
19358 In Ada 2012, a qualified expression is considered to be syntactically a name,
19359 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
19360 useful in disambiguating some cases of overloading.
19363 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
19367 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
19368 @cindex AI-0120 (Ada 2012 feature)
19371 This is an RM editorial change only. The section that lists objects that are
19372 constant failed to include the current instance of a protected object
19373 within a protected function. This has always been treated as a constant
19377 RM References: 3.03 (21)
19380 @emph{AI-0008 General access to constrained objects (0000-00-00)}
19381 @cindex AI-0008 (Ada 2012 feature)
19384 The wording in the RM implied that if you have a general access to a
19385 constrained object, it could be used to modify the discriminants. This was
19386 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
19387 has always done so in this situation.
19390 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
19394 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
19395 @cindex AI-0093 (Ada 2012 feature)
19398 This is an editorial change only, to make more widespread use of the Ada 2012
19399 ``immutably limited''.
19402 RM References: 3.03 (23.4/3)
19407 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
19408 @cindex AI-0096 (Ada 2012 feature)
19411 In general it is illegal for a type derived from a formal limited type to be
19412 nonlimited. This AI makes an exception to this rule: derivation is legal
19413 if it appears in the private part of the generic, and the formal type is not
19414 tagged. If the type is tagged, the legality check must be applied to the
19415 private part of the package.
19418 RM References: 3.04 (5.1/2) 6.02 (7)
19422 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
19423 @cindex AI-0181 (Ada 2012 feature)
19426 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
19427 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
19428 @code{Image} and @code{Value} attributes for the character types. Strictly
19429 speaking this is an inconsistency with Ada 95, but in practice the use of
19430 these attributes is so obscure that it will not cause problems.
19433 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
19437 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
19438 @cindex AI-0182 (Ada 2012 feature)
19441 This AI allows @code{Character'Value} to accept the string @code{'?'} where
19442 @code{?} is any character including non-graphic control characters. GNAT has
19443 always accepted such strings. It also allows strings such as
19444 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
19445 permission and raises @code{Constraint_Error}, as is certainly still
19449 RM References: 3.05 (56/2)
19453 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
19454 @cindex AI-0214 (Ada 2012 feature)
19457 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
19458 to have default expressions by allowing them when the type is limited. It
19459 is often useful to define a default value for a discriminant even though
19460 it can't be changed by assignment.
19463 RM References: 3.07 (9.1/2) 3.07.02 (3)
19467 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
19468 @cindex AI-0102 (Ada 2012 feature)
19471 It is illegal to assign an anonymous access constant to an anonymous access
19472 variable. The RM did not have a clear rule to prevent this, but GNAT has
19473 always generated an error for this usage.
19476 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
19480 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
19481 @cindex AI-0158 (Ada 2012 feature)
19484 This AI extends the syntax of membership tests to simplify complex conditions
19485 that can be expressed as membership in a subset of values of any type. It
19486 introduces syntax for a list of expressions that may be used in loop contexts
19490 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
19494 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
19495 @cindex AI-0173 (Ada 2012 feature)
19498 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
19499 with the tag of an abstract type, and @code{False} otherwise.
19502 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
19507 @emph{AI-0076 function with controlling result (0000-00-00)}
19508 @cindex AI-0076 (Ada 2012 feature)
19511 This is an editorial change only. The RM defines calls with controlling
19512 results, but uses the term ``function with controlling result'' without an
19513 explicit definition.
19516 RM References: 3.09.02 (2/2)
19520 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
19521 @cindex AI-0126 (Ada 2012 feature)
19524 This AI clarifies dispatching rules, and simply confirms that dispatching
19525 executes the operation of the parent type when there is no explicitly or
19526 implicitly declared operation for the descendant type. This has always been
19527 the case in all versions of GNAT.
19530 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
19534 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
19535 @cindex AI-0097 (Ada 2012 feature)
19538 The RM as written implied that in some cases it was possible to create an
19539 object of an abstract type, by having an abstract extension inherit a non-
19540 abstract constructor from its parent type. This mistake has been corrected
19541 in GNAT and in the RM, and this construct is now illegal.
19544 RM References: 3.09.03 (4/2)
19548 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
19549 @cindex AI-0203 (Ada 2012 feature)
19552 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
19553 permitted such usage.
19556 RM References: 3.09.03 (8/3)
19560 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
19561 @cindex AI-0198 (Ada 2012 feature)
19564 This AI resolves a conflict between two rules involving inherited abstract
19565 operations and predefined operators. If a derived numeric type inherits
19566 an abstract operator, it overrides the predefined one. This interpretation
19567 was always the one implemented in GNAT.
19570 RM References: 3.09.03 (4/3)
19573 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
19574 @cindex AI-0073 (Ada 2012 feature)
19577 This AI covers a number of issues regarding returning abstract types. In
19578 particular generic functions cannot have abstract result types or access
19579 result types designated an abstract type. There are some other cases which
19580 are detailed in the AI. Note that this binding interpretation has not been
19581 retrofitted to operate before Ada 2012 mode, since it caused a significant
19582 number of regressions.
19585 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
19589 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
19590 @cindex AI-0070 (Ada 2012 feature)
19593 This is an editorial change only, there are no testable consequences short of
19594 checking for the absence of generated code for an interface declaration.
19597 RM References: 3.09.04 (18/2)
19601 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
19602 @cindex AI-0208 (Ada 2012 feature)
19605 The wording in the Ada 2005 RM concerning characteristics of incomplete views
19606 was incorrect and implied that some programs intended to be legal were now
19607 illegal. GNAT had never considered such programs illegal, so it has always
19608 implemented the intent of this AI.
19611 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
19615 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
19616 @cindex AI-0162 (Ada 2012 feature)
19619 Incomplete types are made more useful by allowing them to be completed by
19620 private types and private extensions.
19623 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
19628 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
19629 @cindex AI-0098 (Ada 2012 feature)
19632 An unintentional omission in the RM implied some inconsistent restrictions on
19633 the use of anonymous access to subprogram values. These restrictions were not
19634 intentional, and have never been enforced by GNAT.
19637 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
19641 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
19642 @cindex AI-0199 (Ada 2012 feature)
19645 A choice list in a record aggregate can include several components of
19646 (distinct) anonymous access types as long as they have matching designated
19650 RM References: 4.03.01 (16)
19654 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
19655 @cindex AI-0220 (Ada 2012 feature)
19658 This AI addresses a wording problem in the RM that appears to permit some
19659 complex cases of aggregates with non-static discriminants. GNAT has always
19660 implemented the intended semantics.
19663 RM References: 4.03.01 (17)
19666 @emph{AI-0147 Conditional expressions (2009-03-29)}
19667 @cindex AI-0147 (Ada 2012 feature)
19670 Conditional expressions are permitted. The form of such an expression is:
19673 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
19676 The parentheses can be omitted in contexts where parentheses are present
19677 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
19678 clause is omitted, @b{else True} is assumed;
19679 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
19680 @emph{(A implies B)} in standard logic.
19683 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
19684 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
19688 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
19689 @cindex AI-0037 (Ada 2012 feature)
19692 This AI confirms that an association of the form @code{Indx => <>} in an
19693 array aggregate must raise @code{Constraint_Error} if @code{Indx}
19694 is out of range. The RM specified a range check on other associations, but
19695 not when the value of the association was defaulted. GNAT has always inserted
19696 a constraint check on the index value.
19699 RM References: 4.03.03 (29)
19703 @emph{AI-0123 Composability of equality (2010-04-13)}
19704 @cindex AI-0123 (Ada 2012 feature)
19707 Equality of untagged record composes, so that the predefined equality for a
19708 composite type that includes a component of some untagged record type
19709 @code{R} uses the equality operation of @code{R} (which may be user-defined
19710 or predefined). This makes the behavior of untagged records identical to that
19711 of tagged types in this respect.
19713 This change is an incompatibility with previous versions of Ada, but it
19714 corrects a non-uniformity that was often a source of confusion. Analysis of
19715 a large number of industrial programs indicates that in those rare cases
19716 where a composite type had an untagged record component with a user-defined
19717 equality, either there was no use of the composite equality, or else the code
19718 expected the same composability as for tagged types, and thus had a bug that
19719 would be fixed by this change.
19722 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
19727 @emph{AI-0088 The value of exponentiation (0000-00-00)}
19728 @cindex AI-0088 (Ada 2012 feature)
19731 This AI clarifies the equivalence rule given for the dynamic semantics of
19732 exponentiation: the value of the operation can be obtained by repeated
19733 multiplication, but the operation can be implemented otherwise (for example
19734 using the familiar divide-by-two-and-square algorithm, even if this is less
19735 accurate), and does not imply repeated reads of a volatile base.
19738 RM References: 4.05.06 (11)
19741 @emph{AI-0188 Case expressions (2010-01-09)}
19742 @cindex AI-0188 (Ada 2012 feature)
19745 Case expressions are permitted. This allows use of constructs such as:
19747 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
19751 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
19754 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
19755 @cindex AI-0104 (Ada 2012 feature)
19758 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
19759 @code{Constraint_Error} because the default value of the allocated object is
19760 @b{null}. This useless construct is illegal in Ada 2012.
19763 RM References: 4.08 (2)
19766 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
19767 @cindex AI-0157 (Ada 2012 feature)
19770 Allocation and Deallocation from an empty storage pool (i.e. allocation or
19771 deallocation of a pointer for which a static storage size clause of zero
19772 has been given) is now illegal and is detected as such. GNAT
19773 previously gave a warning but not an error.
19776 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
19779 @emph{AI-0179 Statement not required after label (2010-04-10)}
19780 @cindex AI-0179 (Ada 2012 feature)
19783 It is not necessary to have a statement following a label, so a label
19784 can appear at the end of a statement sequence without the need for putting a
19785 null statement afterwards, but it is not allowable to have only labels and
19786 no real statements in a statement sequence.
19789 RM References: 5.01 (2)
19793 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
19794 @cindex AI-139-2 (Ada 2012 feature)
19797 The new syntax for iterating over arrays and containers is now implemented.
19798 Iteration over containers is for now limited to read-only iterators. Only
19799 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
19802 RM References: 5.05
19805 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
19806 @cindex AI-0134 (Ada 2012 feature)
19809 For full conformance, the profiles of anonymous-access-to-subprogram
19810 parameters must match. GNAT has always enforced this rule.
19813 RM References: 6.03.01 (18)
19816 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
19817 @cindex AI-0207 (Ada 2012 feature)
19820 This AI confirms that access_to_constant indication must match for mode
19821 conformance. This was implemented in GNAT when the qualifier was originally
19822 introduced in Ada 2005.
19825 RM References: 6.03.01 (16/2)
19829 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
19830 @cindex AI-0046 (Ada 2012 feature)
19833 For full conformance, in the case of access parameters, the null exclusion
19834 must match (either both or neither must have @code{@b{not null}}).
19837 RM References: 6.03.02 (18)
19841 @emph{AI-0118 The association of parameter associations (0000-00-00)}
19842 @cindex AI-0118 (Ada 2012 feature)
19845 This AI clarifies the rules for named associations in subprogram calls and
19846 generic instantiations. The rules have been in place since Ada 83.
19849 RM References: 6.04.01 (2) 12.03 (9)
19853 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
19854 @cindex AI-0196 (Ada 2012 feature)
19857 Null exclusion checks are not made for @code{@b{out}} parameters when
19858 evaluating the actual parameters. GNAT has never generated these checks.
19861 RM References: 6.04.01 (13)
19864 @emph{AI-0015 Constant return objects (0000-00-00)}
19865 @cindex AI-0015 (Ada 2012 feature)
19868 The return object declared in an @i{extended_return_statement} may be
19869 declared constant. This was always intended, and GNAT has always allowed it.
19872 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
19877 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
19878 @cindex AI-0032 (Ada 2012 feature)
19881 If a function returns a class-wide type, the object of an extended return
19882 statement can be declared with a specific type that is covered by the class-
19883 wide type. This has been implemented in GNAT since the introduction of
19884 extended returns. Note AI-0103 complements this AI by imposing matching
19885 rules for constrained return types.
19888 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
19892 @emph{AI-0103 Static matching for extended return (2010-07-23)}
19893 @cindex AI-0103 (Ada 2012 feature)
19896 If the return subtype of a function is an elementary type or a constrained
19897 type, the subtype indication in an extended return statement must match
19898 statically this return subtype.
19901 RM References: 6.05 (5.2/2)
19905 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
19906 @cindex AI-0058 (Ada 2012 feature)
19909 The RM had some incorrect wording implying wrong treatment of abnormal
19910 completion in an extended return. GNAT has always implemented the intended
19911 correct semantics as described by this AI.
19914 RM References: 6.05 (22/2)
19918 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
19919 @cindex AI-0050 (Ada 2012 feature)
19922 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
19923 not take advantage of these incorrect permissions in any case.
19926 RM References: 6.05 (24/2)
19930 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
19931 @cindex AI-0125 (Ada 2012 feature)
19934 In Ada 2012, the declaration of a primitive operation of a type extension
19935 or private extension can also override an inherited primitive that is not
19936 visible at the point of this declaration.
19939 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
19942 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
19943 @cindex AI-0062 (Ada 2012 feature)
19946 A full constant may have a null exclusion even if its associated deferred
19947 constant does not. GNAT has always allowed this.
19950 RM References: 7.04 (6/2) 7.04 (7.1/2)
19954 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
19955 @cindex AI-0178 (Ada 2012 feature)
19958 This AI clarifies the role of incomplete views and plugs an omission in the
19959 RM. GNAT always correctly restricted the use of incomplete views and types.
19962 RM References: 7.05 (3/2) 7.05 (6/2)
19965 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
19966 @cindex AI-0087 (Ada 2012 feature)
19969 The actual for a formal nonlimited derived type cannot be limited. In
19970 particular, a formal derived type that extends a limited interface but which
19971 is not explicitly limited cannot be instantiated with a limited type.
19974 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
19977 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
19978 @cindex AI-0099 (Ada 2012 feature)
19981 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
19982 and therefore depends on the run-time characteristics of an object (i.e. its
19983 tag) and not on its nominal type. As the AI indicates: ``we do not expect
19984 this to affect any implementation''.
19987 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
19992 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
19993 @cindex AI-0064 (Ada 2012 feature)
19996 This is an editorial change only. The intended behavior is already checked
19997 by an existing ACATS test, which GNAT has always executed correctly.
20000 RM References: 7.06.01 (17.1/1)
20003 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20004 @cindex AI-0026 (Ada 2012 feature)
20007 Record representation clauses concerning Unchecked_Union types cannot mention
20008 the discriminant of the type. The type of a component declared in the variant
20009 part of an Unchecked_Union cannot be controlled, have controlled components,
20010 nor have protected or task parts. If an Unchecked_Union type is declared
20011 within the body of a generic unit or its descendants, then the type of a
20012 component declared in the variant part cannot be a formal private type or a
20013 formal private extension declared within the same generic unit.
20016 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
20020 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20021 @cindex AI-0205 (Ada 2012 feature)
20024 This AI corrects a simple omission in the RM. Return objects have always
20025 been visible within an extended return statement.
20028 RM References: 8.03 (17)
20032 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20033 @cindex AI-0042 (Ada 2012 feature)
20036 This AI fixes a wording gap in the RM. An operation of a synchronized
20037 interface can be implemented by a protected or task entry, but the abstract
20038 operation is not being overridden in the usual sense, and it must be stated
20039 separately that this implementation is legal. This has always been the case
20043 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
20046 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20047 @cindex AI-0030 (Ada 2012 feature)
20050 Requeue is permitted to a protected, synchronized or task interface primitive
20051 providing it is known that the overriding operation is an entry. Otherwise
20052 the requeue statement has the same effect as a procedure call. Use of pragma
20053 @code{Implemented} provides a way to impose a static requirement on the
20054 overriding operation by adhering to one of the implementation kinds: entry,
20055 protected procedure or any of the above.
20058 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
20059 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
20063 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20064 @cindex AI-0201 (Ada 2012 feature)
20067 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20068 attribute, then individual components may not be addressable by independent
20069 tasks. However, if the representation clause has no effect (is confirming),
20070 then independence is not compromised. Furthermore, in GNAT, specification of
20071 other appropriately addressable component sizes (e.g. 16 for 8-bit
20072 characters) also preserves independence. GNAT now gives very clear warnings
20073 both for the declaration of such a type, and for any assignment to its components.
20076 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
20079 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20080 @cindex AI-0009 (Ada 2012 feature)
20083 This AI introduces the new pragmas @code{Independent} and
20084 @code{Independent_Components},
20085 which control guaranteeing independence of access to objects and components.
20086 The AI also requires independence not unaffected by confirming rep clauses.
20089 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
20090 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
20094 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20095 @cindex AI-0072 (Ada 2012 feature)
20098 This AI clarifies that task signalling for reading @code{'Terminated} only
20099 occurs if the result is True. GNAT semantics has always been consistent with
20100 this notion of task signalling.
20103 RM References: 9.10 (6.1/1)
20106 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20107 @cindex AI-0108 (Ada 2012 feature)
20110 This AI confirms that an incomplete type from a limited view does not have
20111 discriminants. This has always been the case in GNAT.
20114 RM References: 10.01.01 (12.3/2)
20117 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20118 @cindex AI-0129 (Ada 2012 feature)
20121 This AI clarifies the description of limited views: a limited view of a
20122 package includes only one view of a type that has an incomplete declaration
20123 and a full declaration (there is no possible ambiguity in a client package).
20124 This AI also fixes an omission: a nested package in the private part has no
20125 limited view. GNAT always implemented this correctly.
20128 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
20133 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20134 @cindex AI-0077 (Ada 2012 feature)
20137 This AI clarifies that a declaration does not include a context clause,
20138 and confirms that it is illegal to have a context in which both a limited
20139 and a nonlimited view of a package are accessible. Such double visibility
20140 was always rejected by GNAT.
20143 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
20146 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20147 @cindex AI-0122 (Ada 2012 feature)
20150 This AI clarifies the visibility of private children of generic units within
20151 instantiations of a parent. GNAT has always handled this correctly.
20154 RM References: 10.01.02 (12/2)
20159 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20160 @cindex AI-0040 (Ada 2012 feature)
20163 This AI confirms that a limited with clause in a child unit cannot name
20164 an ancestor of the unit. This has always been checked in GNAT.
20167 RM References: 10.01.02 (20/2)
20170 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20171 @cindex AI-0132 (Ada 2012 feature)
20174 This AI fills a gap in the description of library unit pragmas. The pragma
20175 clearly must apply to a library unit, even if it does not carry the name
20176 of the enclosing unit. GNAT has always enforced the required check.
20179 RM References: 10.01.05 (7)
20183 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20184 @cindex AI-0034 (Ada 2012 feature)
20187 The RM makes certain limited with clauses illegal because of categorization
20188 considerations, when the corresponding normal with would be legal. This is
20189 not intended, and GNAT has always implemented the recommended behavior.
20192 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
20196 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20197 @cindex AI-0035 (Ada 2012 feature)
20200 This AI remedies some inconsistencies in the legality rules for Pure units.
20201 Derived access types are legal in a pure unit (on the assumption that the
20202 rule for a zero storage pool size has been enforced on the ancestor type).
20203 The rules are enforced in generic instances and in subunits. GNAT has always
20204 implemented the recommended behavior.
20207 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)
20211 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20212 @cindex AI-0219 (Ada 2012 feature)
20215 This AI refines the rules for the cases with limited parameters which do not
20216 allow the implementations to omit ``redundant''. GNAT now properly conforms
20217 to the requirements of this binding interpretation.
20220 RM References: 10.02.01 (18/2)
20223 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
20224 @cindex AI-0043 (Ada 2012 feature)
20227 This AI covers various omissions in the RM regarding the raising of
20228 exceptions. GNAT has always implemented the intended semantics.
20231 RM References: 11.04.01 (10.1/2) 11 (2)
20235 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
20236 @cindex AI-0200 (Ada 2012 feature)
20239 This AI plugs a gap in the RM which appeared to allow some obviously intended
20240 illegal instantiations. GNAT has never allowed these instantiations.
20243 RM References: 12.07 (16)
20247 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
20248 @cindex AI-0112 (Ada 2012 feature)
20251 This AI concerns giving names to various representation aspects, but the
20252 practical effect is simply to make the use of duplicate
20253 @code{Atomic}[@code{_Components}],
20254 @code{Volatile}[@code{_Components}] and
20255 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
20256 now performs this required check.
20259 RM References: 13.01 (8)
20262 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
20263 @cindex AI-0106 (Ada 2012 feature)
20266 The RM appeared to allow representation pragmas on generic formal parameters,
20267 but this was not intended, and GNAT has never permitted this usage.
20270 RM References: 13.01 (9.1/1)
20274 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
20275 @cindex AI-0012 (Ada 2012 feature)
20278 It is now illegal to give an inappropriate component size or a pragma
20279 @code{Pack} that attempts to change the component size in the case of atomic
20280 or aliased components. Previously GNAT ignored such an attempt with a
20284 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
20288 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
20289 @cindex AI-0039 (Ada 2012 feature)
20292 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
20293 for stream attributes, but these were never useful and are now illegal. GNAT
20294 has always regarded such expressions as illegal.
20297 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
20301 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
20302 @cindex AI-0095 (Ada 2012 feature)
20305 The prefix of @code{'Address} cannot statically denote a subprogram with
20306 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
20307 @code{Program_Error} if the prefix denotes a subprogram with convention
20311 RM References: 13.03 (11/1)
20315 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
20316 @cindex AI-0116 (Ada 2012 feature)
20319 This AI requires that the alignment of a class-wide object be no greater
20320 than the alignment of any type in the class. GNAT has always followed this
20324 RM References: 13.03 (29) 13.11 (16)
20328 @emph{AI-0146 Type invariants (2009-09-21)}
20329 @cindex AI-0146 (Ada 2012 feature)
20332 Type invariants may be specified for private types using the aspect notation.
20333 Aspect @code{Type_Invariant} may be specified for any private type,
20334 @code{Type_Invariant'Class} can
20335 only be specified for tagged types, and is inherited by any descendent of the
20336 tagged types. The invariant is a boolean expression that is tested for being
20337 true in the following situations: conversions to the private type, object
20338 declarations for the private type that are default initialized, and
20340 parameters and returned result on return from any primitive operation for
20341 the type that is visible to a client.
20342 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
20343 @code{Invariant'Class} for @code{Type_Invariant'Class}.
20346 RM References: 13.03.03 (00)
20349 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
20350 @cindex AI-0078 (Ada 2012 feature)
20353 In Ada 2012, compilers are required to support unchecked conversion where the
20354 target alignment is a multiple of the source alignment. GNAT always supported
20355 this case (and indeed all cases of differing alignments, doing copies where
20356 required if the alignment was reduced).
20359 RM References: 13.09 (7)
20363 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
20364 @cindex AI-0195 (Ada 2012 feature)
20367 The handling of invalid values is now designated to be implementation
20368 defined. This is a documentation change only, requiring Annex M in the GNAT
20369 Reference Manual to document this handling.
20370 In GNAT, checks for invalid values are made
20371 only when necessary to avoid erroneous behavior. Operations like assignments
20372 which cannot cause erroneous behavior ignore the possibility of invalid
20373 values and do not do a check. The date given above applies only to the
20374 documentation change, this behavior has always been implemented by GNAT.
20377 RM References: 13.09.01 (10)
20380 @emph{AI-0193 Alignment of allocators (2010-09-16)}
20381 @cindex AI-0193 (Ada 2012 feature)
20384 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
20385 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
20389 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
20390 13.11.01 (2) 13.11.01 (3)
20394 @emph{AI-0177 Parameterized expressions (2010-07-10)}
20395 @cindex AI-0177 (Ada 2012 feature)
20398 The new Ada 2012 notion of parameterized expressions is implemented. The form
20401 @i{function specification} @b{is} (@i{expression})
20405 This is exactly equivalent to the
20406 corresponding function body that returns the expression, but it can appear
20407 in a package spec. Note that the expression must be parenthesized.
20410 RM References: 13.11.01 (3/2)
20413 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
20414 @cindex AI-0033 (Ada 2012 feature)
20417 Neither of these two pragmas may appear within a generic template, because
20418 the generic might be instantiated at other than the library level.
20421 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
20425 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
20426 @cindex AI-0161 (Ada 2012 feature)
20429 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
20430 of the default stream attributes for elementary types. If this restriction is
20431 in force, then it is necessary to provide explicit subprograms for any
20432 stream attributes used.
20435 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
20438 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
20439 @cindex AI-0194 (Ada 2012 feature)
20442 The @code{Stream_Size} attribute returns the default number of bits in the
20443 stream representation of the given type.
20444 This value is not affected by the presence
20445 of stream subprogram attributes for the type. GNAT has always implemented
20446 this interpretation.
20449 RM References: 13.13.02 (1.2/2)
20452 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
20453 @cindex AI-0109 (Ada 2012 feature)
20456 This AI is an editorial change only. It removes the need for a tag check
20457 that can never fail.
20460 RM References: 13.13.02 (34/2)
20463 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
20464 @cindex AI-0007 (Ada 2012 feature)
20467 The RM as written appeared to limit the possibilities of declaring read
20468 attribute procedures for private scalar types. This limitation was not
20469 intended, and has never been enforced by GNAT.
20472 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
20476 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
20477 @cindex AI-0065 (Ada 2012 feature)
20480 This AI clarifies the fact that all remote access types support external
20481 streaming. This fixes an obvious oversight in the definition of the
20482 language, and GNAT always implemented the intended correct rules.
20485 RM References: 13.13.02 (52/2)
20488 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
20489 @cindex AI-0019 (Ada 2012 feature)
20492 The RM suggests that primitive subprograms of a specific tagged type are
20493 frozen when the tagged type is frozen. This would be an incompatible change
20494 and is not intended. GNAT has never attempted this kind of freezing and its
20495 behavior is consistent with the recommendation of this AI.
20498 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)
20501 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
20502 @cindex AI-0017 (Ada 2012 feature)
20505 So-called ``Taft-amendment types'' (i.e., types that are completed in package
20506 bodies) are not frozen by the occurrence of bodies in the
20507 enclosing declarative part. GNAT always implemented this properly.
20510 RM References: 13.14 (3/1)
20514 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
20515 @cindex AI-0060 (Ada 2012 feature)
20518 This AI extends the definition of remote access types to include access
20519 to limited, synchronized, protected or task class-wide interface types.
20520 GNAT already implemented this extension.
20523 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
20526 @emph{AI-0114 Classification of letters (0000-00-00)}
20527 @cindex AI-0114 (Ada 2012 feature)
20530 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
20531 181 (@code{MICRO SIGN}), and
20532 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
20533 lower case letters by Unicode.
20534 However, they are not allowed in identifiers, and they
20535 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
20536 This behavior is consistent with that defined in Ada 95.
20539 RM References: A.03.02 (59) A.04.06 (7)
20543 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
20544 @cindex AI-0185 (Ada 2012 feature)
20547 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
20548 classification functions for @code{Wide_Character} and
20549 @code{Wide_Wide_Character}, as well as providing
20550 case folding routines for @code{Wide_[Wide_]Character} and
20551 @code{Wide_[Wide_]String}.
20554 RM References: A.03.05 (0) A.03.06 (0)
20558 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
20559 @cindex AI-0031 (Ada 2012 feature)
20562 A new version of @code{Find_Token} is added to all relevant string packages,
20563 with an extra parameter @code{From}. Instead of starting at the first
20564 character of the string, the search for a matching Token starts at the
20565 character indexed by the value of @code{From}.
20566 These procedures are available in all versions of Ada
20567 but if used in versions earlier than Ada 2012 they will generate a warning
20568 that an Ada 2012 subprogram is being used.
20571 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
20576 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
20577 @cindex AI-0056 (Ada 2012 feature)
20580 The wording in the Ada 2005 RM implied an incompatible handling of the
20581 @code{Index} functions, resulting in raising an exception instead of
20582 returning zero in some situations.
20583 This was not intended and has been corrected.
20584 GNAT always returned zero, and is thus consistent with this AI.
20587 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
20591 @emph{AI-0137 String encoding package (2010-03-25)}
20592 @cindex AI-0137 (Ada 2012 feature)
20595 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
20596 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
20597 and @code{Wide_Wide_Strings} have been
20598 implemented. These packages (whose documentation can be found in the spec
20599 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
20600 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
20601 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
20602 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
20603 UTF-16), as well as conversions between the different UTF encodings. With
20604 the exception of @code{Wide_Wide_Strings}, these packages are available in
20605 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
20606 The @code{Wide_Wide_Strings package}
20607 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
20608 mode since it uses @code{Wide_Wide_Character}).
20611 RM References: A.04.11
20614 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
20615 @cindex AI-0038 (Ada 2012 feature)
20618 These are minor errors in the description on three points. The intent on
20619 all these points has always been clear, and GNAT has always implemented the
20620 correct intended semantics.
20623 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)
20626 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
20627 @cindex AI-0044 (Ada 2012 feature)
20630 This AI places restrictions on allowed instantiations of generic containers.
20631 These restrictions are not checked by the compiler, so there is nothing to
20632 change in the implementation. This affects only the RM documentation.
20635 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)
20638 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
20639 @cindex AI-0127 (Ada 2012 feature)
20642 This package provides an interface for identifying the current locale.
20645 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
20646 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
20651 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
20652 @cindex AI-0002 (Ada 2012 feature)
20655 The compiler is not required to support exporting an Ada subprogram with
20656 convention C if there are parameters or a return type of an unconstrained
20657 array type (such as @code{String}). GNAT allows such declarations but
20658 generates warnings. It is possible, but complicated, to write the
20659 corresponding C code and certainly such code would be specific to GNAT and
20663 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
20667 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
20668 @cindex AI05-0216 (Ada 2012 feature)
20671 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
20672 forbid tasks declared locally within subprograms, or functions returning task
20673 objects, and that is the implementation that GNAT has always provided.
20674 However the language in the RM was not sufficiently clear on this point.
20675 Thus this is a documentation change in the RM only.
20678 RM References: D.07 (3/3)
20681 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
20682 @cindex AI-0211 (Ada 2012 feature)
20685 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
20686 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
20689 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
20692 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
20693 @cindex AI-0190 (Ada 2012 feature)
20696 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
20697 used to control storage pools globally.
20698 In particular, you can force every access
20699 type that is used for allocation (@b{new}) to have an explicit storage pool,
20700 or you can declare a pool globally to be used for all access types that lack
20704 RM References: D.07 (8)
20707 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
20708 @cindex AI-0189 (Ada 2012 feature)
20711 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
20712 which says that no dynamic allocation will occur once elaboration is
20714 In general this requires a run-time check, which is not required, and which
20715 GNAT does not attempt. But the static cases of allocators in a task body or
20716 in the body of the main program are detected and flagged at compile or bind
20720 RM References: D.07 (19.1/2) H.04 (23.3/2)
20723 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
20724 @cindex AI-0171 (Ada 2012 feature)
20727 A new package @code{System.Multiprocessors} is added, together with the
20728 definition of pragma @code{CPU} for controlling task affinity. A new no
20729 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
20730 is added to the Ravenscar profile.
20733 RM References: D.13.01 (4/2) D.16
20737 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
20738 @cindex AI-0210 (Ada 2012 feature)
20741 This is a documentation only issue regarding wording of metric requirements,
20742 that does not affect the implementation of the compiler.
20745 RM References: D.15 (24/2)
20749 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
20750 @cindex AI-0206 (Ada 2012 feature)
20753 Remote types packages are now allowed to depend on preelaborated packages.
20754 This was formerly considered illegal.
20757 RM References: E.02.02 (6)
20762 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
20763 @cindex AI-0152 (Ada 2012 feature)
20766 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
20767 where the type of the returned value is an anonymous access type.
20770 RM References: H.04 (8/1)
20774 @node Obsolescent Features
20775 @chapter Obsolescent Features
20778 This chapter describes features that are provided by GNAT, but are
20779 considered obsolescent since there are preferred ways of achieving
20780 the same effect. These features are provided solely for historical
20781 compatibility purposes.
20784 * pragma No_Run_Time::
20785 * pragma Ravenscar::
20786 * pragma Restricted_Run_Time::
20789 @node pragma No_Run_Time
20790 @section pragma No_Run_Time
20792 The pragma @code{No_Run_Time} is used to achieve an affect similar
20793 to the use of the "Zero Foot Print" configurable run time, but without
20794 requiring a specially configured run time. The result of using this
20795 pragma, which must be used for all units in a partition, is to restrict
20796 the use of any language features requiring run-time support code. The
20797 preferred usage is to use an appropriately configured run-time that
20798 includes just those features that are to be made accessible.
20800 @node pragma Ravenscar
20801 @section pragma Ravenscar
20803 The pragma @code{Ravenscar} has exactly the same effect as pragma
20804 @code{Profile (Ravenscar)}. The latter usage is preferred since it
20805 is part of the new Ada 2005 standard.
20807 @node pragma Restricted_Run_Time
20808 @section pragma Restricted_Run_Time
20810 The pragma @code{Restricted_Run_Time} has exactly the same effect as
20811 pragma @code{Profile (Restricted)}. The latter usage is
20812 preferred since the Ada 2005 pragma @code{Profile} is intended for
20813 this kind of implementation dependent addition.
20816 @c GNU Free Documentation License
20818 @node Index,,GNU Free Documentation License, Top
20826 tablishes the following set of restrictions: