1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
30 @settitle GNAT Reference Manual
32 @setchapternewpage odd
35 @include gcc-common.texi
37 @dircategory GNU Ada tools
39 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
43 @title GNAT Reference Manual
44 @subtitle GNAT, The GNU Ada Development Environment
48 @vskip 0pt plus 1filll
55 @node Top, About This Guide, (dir), (dir)
56 @top GNAT Reference Manual
62 GNAT, The GNU Ada Development Environment@*
63 GCC version @value{version-GCC}@*
70 * Implementation Defined Pragmas::
71 * Implementation Defined Aspects::
72 * Implementation Defined Attributes::
73 * Standard and Implementation Defined Restrictions::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
99 * Pragma Abstract_State::
106 * Pragma Allow_Integer_Address::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Async_Readers::
114 * Pragma Async_Writers::
115 * Pragma Attribute_Definition::
117 * Pragma C_Pass_By_Copy::
119 * Pragma Check_Float_Overflow::
120 * Pragma Check_Name::
121 * Pragma Check_Policy::
122 * Pragma CIL_Constructor::
124 * Pragma Common_Object::
125 * Pragma Compile_Time_Error::
126 * Pragma Compile_Time_Warning::
127 * Pragma Compiler_Unit::
128 * Pragma Compiler_Unit_Warning::
129 * Pragma Complete_Representation::
130 * Pragma Complex_Representation::
131 * Pragma Component_Alignment::
132 * Pragma Contract_Cases::
133 * Pragma Convention_Identifier::
135 * Pragma CPP_Constructor::
136 * Pragma CPP_Virtual::
137 * Pragma CPP_Vtable::
140 * Pragma Debug_Policy::
141 * Pragma Default_Storage_Pool::
143 * Pragma Detect_Blocking::
144 * Pragma Disable_Atomic_Synchronization::
145 * Pragma Dispatching_Domain::
146 * Pragma Effective_Reads::
147 * Pragma Effective_Writes::
148 * Pragma Elaboration_Checks::
150 * Pragma Enable_Atomic_Synchronization::
151 * Pragma Export_Exception::
152 * Pragma Export_Function::
153 * Pragma Export_Object::
154 * Pragma Export_Procedure::
155 * Pragma Export_Value::
156 * Pragma Export_Valued_Procedure::
157 * Pragma Extend_System::
158 * Pragma Extensions_Allowed::
160 * Pragma External_Name_Casing::
162 * Pragma Favor_Top_Level::
163 * Pragma Finalize_Storage_Only::
164 * Pragma Float_Representation::
167 * Pragma Implementation_Defined::
168 * Pragma Implemented::
169 * Pragma Implicit_Packing::
170 * Pragma Import_Exception::
171 * Pragma Import_Function::
172 * Pragma Import_Object::
173 * Pragma Import_Procedure::
174 * Pragma Import_Valued_Procedure::
175 * Pragma Independent::
176 * Pragma Independent_Components::
177 * Pragma Initial_Condition::
178 * Pragma Initialize_Scalars::
179 * Pragma Initializes::
180 * Pragma Inline_Always::
181 * Pragma Inline_Generic::
183 * Pragma Interface_Name::
184 * Pragma Interrupt_Handler::
185 * Pragma Interrupt_State::
187 * Pragma Java_Constructor::
188 * Pragma Java_Interface::
189 * Pragma Keep_Names::
192 * Pragma Linker_Alias::
193 * Pragma Linker_Constructor::
194 * Pragma Linker_Destructor::
195 * Pragma Linker_Section::
196 * Pragma Long_Float::
197 * Pragma Loop_Invariant::
198 * Pragma Loop_Optimize::
199 * Pragma Loop_Variant::
200 * Pragma Machine_Attribute::
202 * Pragma Main_Storage::
206 * Pragma No_Run_Time::
207 * Pragma No_Strict_Aliasing ::
208 * Pragma Normalize_Scalars::
209 * Pragma Obsolescent::
210 * Pragma Optimize_Alignment::
212 * Pragma Overflow_Mode::
213 * Pragma Overriding_Renamings::
214 * Pragma Partition_Elaboration_Policy::
217 * Pragma Persistent_BSS::
220 * Pragma Postcondition::
221 * Pragma Post_Class::
223 * Pragma Precondition::
225 * Pragma Preelaborable_Initialization::
227 * Pragma Priority_Specific_Dispatching::
229 * Pragma Profile_Warnings::
230 * Pragma Propagate_Exceptions::
231 * Pragma Provide_Shift_Operators::
232 * Pragma Psect_Object::
233 * Pragma Pure_Function::
235 * Pragma Refined_Depends::
236 * Pragma Refined_Global::
237 * Pragma Refined_Post::
238 * Pragma Refined_State::
239 * Pragma Relative_Deadline::
240 * Pragma Remote_Access_Type::
241 * Pragma Restricted_Run_Time::
242 * Pragma Restriction_Warnings::
243 * Pragma Reviewable::
244 * Pragma Share_Generic::
246 * Pragma Short_Circuit_And_Or::
247 * Pragma Short_Descriptors::
248 * Pragma Simple_Storage_Pool_Type::
249 * Pragma Source_File_Name::
250 * Pragma Source_File_Name_Project::
251 * Pragma Source_Reference::
252 * Pragma SPARK_Mode::
253 * Pragma Static_Elaboration_Desired::
254 * Pragma Stream_Convert::
255 * Pragma Style_Checks::
258 * Pragma Suppress_All::
259 * Pragma Suppress_Debug_Info::
260 * Pragma Suppress_Exception_Locations::
261 * Pragma Suppress_Initialization::
263 * Pragma Task_Storage::
265 * Pragma Thread_Local_Storage::
266 * Pragma Time_Slice::
268 * Pragma Type_Invariant::
269 * Pragma Type_Invariant_Class::
270 * Pragma Unchecked_Union::
271 * Pragma Unimplemented_Unit::
272 * Pragma Universal_Aliasing ::
273 * Pragma Universal_Data::
274 * Pragma Unmodified::
275 * Pragma Unreferenced::
276 * Pragma Unreferenced_Objects::
277 * Pragma Unreserve_All_Interrupts::
278 * Pragma Unsuppress::
279 * Pragma Use_VADS_Size::
280 * Pragma Validity_Checks::
282 * Pragma Warning_As_Error::
284 * Pragma Weak_External::
285 * Pragma Wide_Character_Encoding::
287 Implementation Defined Aspects
289 * Aspect Abstract_State::
290 * Aspect Async_Readers::
291 * Aspect Async_Writers::
292 * Aspect Contract_Cases::
295 * Aspect Dimension_System::
296 * Aspect Effective_Reads::
297 * Aspect Effective_Writes::
298 * Aspect Favor_Top_Level::
300 * Aspect Initial_Condition::
301 * Aspect Initializes::
302 * Aspect Inline_Always::
304 * Aspect Linker_Section::
305 * Aspect Object_Size::
307 * Aspect Persistent_BSS::
309 * Aspect Pure_Function::
310 * Aspect Refined_Depends::
311 * Aspect Refined_Global::
312 * Aspect Refined_Post::
313 * Aspect Refined_State::
314 * Aspect Remote_Access_Type::
315 * Aspect Scalar_Storage_Order::
317 * Aspect Simple_Storage_Pool::
318 * Aspect Simple_Storage_Pool_Type::
319 * Aspect SPARK_Mode::
320 * Aspect Suppress_Debug_Info::
322 * Aspect Thread_Local_Storage::
323 * Aspect Universal_Aliasing::
324 * Aspect Universal_Data::
325 * Aspect Unmodified::
326 * Aspect Unreferenced::
327 * Aspect Unreferenced_Objects::
328 * Aspect Value_Size::
331 Implementation Defined Attributes
333 * Attribute Abort_Signal::
334 * Attribute Address_Size::
335 * Attribute Asm_Input::
336 * Attribute Asm_Output::
337 * Attribute AST_Entry::
339 * Attribute Bit_Position::
340 * Attribute Compiler_Version::
341 * Attribute Code_Address::
342 * Attribute Default_Bit_Order::
343 * Attribute Descriptor_Size::
344 * Attribute Elaborated::
345 * Attribute Elab_Body::
346 * Attribute Elab_Spec::
347 * Attribute Elab_Subp_Body::
349 * Attribute Enabled::
350 * Attribute Enum_Rep::
351 * Attribute Enum_Val::
352 * Attribute Epsilon::
353 * Attribute Fixed_Value::
354 * Attribute Has_Access_Values::
355 * Attribute Has_Discriminants::
357 * Attribute Integer_Value::
358 * Attribute Invalid_Value::
360 * Attribute Library_Level::
361 * Attribute Loop_Entry::
362 * Attribute Machine_Size::
363 * Attribute Mantissa::
364 * Attribute Max_Interrupt_Priority::
365 * Attribute Max_Priority::
366 * Attribute Maximum_Alignment::
367 * Attribute Mechanism_Code::
368 * Attribute Null_Parameter::
369 * Attribute Object_Size::
370 * Attribute Passed_By_Reference::
371 * Attribute Pool_Address::
372 * Attribute Range_Length::
374 * Attribute Restriction_Set::
376 * Attribute Safe_Emax::
377 * Attribute Safe_Large::
378 * Attribute Scalar_Storage_Order::
379 * Attribute Simple_Storage_Pool::
381 * Attribute Storage_Unit::
382 * Attribute Stub_Type::
383 * Attribute System_Allocator_Alignment::
384 * Attribute Target_Name::
386 * Attribute To_Address::
387 * Attribute Type_Class::
388 * Attribute UET_Address::
389 * Attribute Unconstrained_Array::
390 * Attribute Universal_Literal_String::
391 * Attribute Unrestricted_Access::
393 * Attribute Valid_Scalars::
394 * Attribute VADS_Size::
395 * Attribute Value_Size::
396 * Attribute Wchar_T_Size::
397 * Attribute Word_Size::
399 Standard and Implementation Defined Restrictions
401 * Partition-Wide Restrictions::
402 * Program Unit Level Restrictions::
404 Partition-Wide Restrictions
406 * Immediate_Reclamation::
407 * Max_Asynchronous_Select_Nesting::
408 * Max_Entry_Queue_Length::
409 * Max_Protected_Entries::
410 * Max_Select_Alternatives::
411 * Max_Storage_At_Blocking::
414 * No_Abort_Statements::
415 * No_Access_Parameter_Allocators::
416 * No_Access_Subprograms::
418 * No_Anonymous_Allocators::
421 * No_Default_Initialization::
424 * No_Direct_Boolean_Operators::
426 * No_Dispatching_Calls::
427 * No_Dynamic_Attachment::
428 * No_Dynamic_Priorities::
429 * No_Entry_Calls_In_Elaboration_Code::
430 * No_Enumeration_Maps::
431 * No_Exception_Handlers::
432 * No_Exception_Propagation::
433 * No_Exception_Registration::
437 * No_Floating_Point::
438 * No_Implicit_Conditionals::
439 * No_Implicit_Dynamic_Code::
440 * No_Implicit_Heap_Allocations::
441 * No_Implicit_Loops::
442 * No_Initialize_Scalars::
444 * No_Local_Allocators::
445 * No_Local_Protected_Objects::
446 * No_Local_Timing_Events::
447 * No_Nested_Finalization::
448 * No_Protected_Type_Allocators::
449 * No_Protected_Types::
452 * No_Relative_Delay::
453 * No_Requeue_Statements::
454 * No_Secondary_Stack::
455 * No_Select_Statements::
456 * No_Specific_Termination_Handlers::
457 * No_Specification_of_Aspect::
458 * No_Standard_Allocators_After_Elaboration::
459 * No_Standard_Storage_Pools::
460 * No_Stream_Optimizations::
462 * No_Task_Allocators::
463 * No_Task_Attributes_Package::
464 * No_Task_Hierarchy::
465 * No_Task_Termination::
467 * No_Terminate_Alternatives::
468 * No_Unchecked_Access::
470 * Static_Priorities::
471 * Static_Storage_Size::
473 Program Unit Level Restrictions
475 * No_Elaboration_Code::
477 * No_Implementation_Aspect_Specifications::
478 * No_Implementation_Attributes::
479 * No_Implementation_Identifiers::
480 * No_Implementation_Pragmas::
481 * No_Implementation_Restrictions::
482 * No_Implementation_Units::
483 * No_Implicit_Aliasing::
484 * No_Obsolescent_Features::
485 * No_Wide_Characters::
488 The Implementation of Standard I/O
490 * Standard I/O Packages::
496 * Wide_Wide_Text_IO::
500 * Filenames encoding::
502 * Operations on C Streams::
503 * Interfacing to C Streams::
507 * Ada.Characters.Latin_9 (a-chlat9.ads)::
508 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
509 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
510 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
511 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
512 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
513 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
514 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
515 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
516 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
517 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
518 * Ada.Command_Line.Environment (a-colien.ads)::
519 * Ada.Command_Line.Remove (a-colire.ads)::
520 * Ada.Command_Line.Response_File (a-clrefi.ads)::
521 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
522 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
523 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
524 * Ada.Exceptions.Traceback (a-exctra.ads)::
525 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
526 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
527 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
528 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
529 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
530 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
531 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
532 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
533 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
534 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
535 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
536 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
537 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
538 * GNAT.Altivec (g-altive.ads)::
539 * GNAT.Altivec.Conversions (g-altcon.ads)::
540 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
541 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
542 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
543 * GNAT.Array_Split (g-arrspl.ads)::
544 * GNAT.AWK (g-awk.ads)::
545 * GNAT.Bounded_Buffers (g-boubuf.ads)::
546 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
547 * GNAT.Bubble_Sort (g-bubsor.ads)::
548 * GNAT.Bubble_Sort_A (g-busora.ads)::
549 * GNAT.Bubble_Sort_G (g-busorg.ads)::
550 * GNAT.Byte_Order_Mark (g-byorma.ads)::
551 * GNAT.Byte_Swapping (g-bytswa.ads)::
552 * GNAT.Calendar (g-calend.ads)::
553 * GNAT.Calendar.Time_IO (g-catiio.ads)::
554 * GNAT.Case_Util (g-casuti.ads)::
555 * GNAT.CGI (g-cgi.ads)::
556 * GNAT.CGI.Cookie (g-cgicoo.ads)::
557 * GNAT.CGI.Debug (g-cgideb.ads)::
558 * GNAT.Command_Line (g-comlin.ads)::
559 * GNAT.Compiler_Version (g-comver.ads)::
560 * GNAT.Ctrl_C (g-ctrl_c.ads)::
561 * GNAT.CRC32 (g-crc32.ads)::
562 * GNAT.Current_Exception (g-curexc.ads)::
563 * GNAT.Debug_Pools (g-debpoo.ads)::
564 * GNAT.Debug_Utilities (g-debuti.ads)::
565 * GNAT.Decode_String (g-decstr.ads)::
566 * GNAT.Decode_UTF8_String (g-deutst.ads)::
567 * GNAT.Directory_Operations (g-dirope.ads)::
568 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
569 * GNAT.Dynamic_HTables (g-dynhta.ads)::
570 * GNAT.Dynamic_Tables (g-dyntab.ads)::
571 * GNAT.Encode_String (g-encstr.ads)::
572 * GNAT.Encode_UTF8_String (g-enutst.ads)::
573 * GNAT.Exception_Actions (g-excact.ads)::
574 * GNAT.Exception_Traces (g-exctra.ads)::
575 * GNAT.Exceptions (g-except.ads)::
576 * GNAT.Expect (g-expect.ads)::
577 * GNAT.Expect.TTY (g-exptty.ads)::
578 * GNAT.Float_Control (g-flocon.ads)::
579 * GNAT.Heap_Sort (g-heasor.ads)::
580 * GNAT.Heap_Sort_A (g-hesora.ads)::
581 * GNAT.Heap_Sort_G (g-hesorg.ads)::
582 * GNAT.HTable (g-htable.ads)::
583 * GNAT.IO (g-io.ads)::
584 * GNAT.IO_Aux (g-io_aux.ads)::
585 * GNAT.Lock_Files (g-locfil.ads)::
586 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
587 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
588 * GNAT.MD5 (g-md5.ads)::
589 * GNAT.Memory_Dump (g-memdum.ads)::
590 * GNAT.Most_Recent_Exception (g-moreex.ads)::
591 * GNAT.OS_Lib (g-os_lib.ads)::
592 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
593 * GNAT.Random_Numbers (g-rannum.ads)::
594 * GNAT.Regexp (g-regexp.ads)::
595 * GNAT.Registry (g-regist.ads)::
596 * GNAT.Regpat (g-regpat.ads)::
597 * GNAT.Rewrite_Data (g-rewdat.ads)::
598 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
599 * GNAT.Semaphores (g-semaph.ads)::
600 * GNAT.Serial_Communications (g-sercom.ads)::
601 * GNAT.SHA1 (g-sha1.ads)::
602 * GNAT.SHA224 (g-sha224.ads)::
603 * GNAT.SHA256 (g-sha256.ads)::
604 * GNAT.SHA384 (g-sha384.ads)::
605 * GNAT.SHA512 (g-sha512.ads)::
606 * GNAT.Signals (g-signal.ads)::
607 * GNAT.Sockets (g-socket.ads)::
608 * GNAT.Source_Info (g-souinf.ads)::
609 * GNAT.Spelling_Checker (g-speche.ads)::
610 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
611 * GNAT.Spitbol.Patterns (g-spipat.ads)::
612 * GNAT.Spitbol (g-spitbo.ads)::
613 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
614 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
615 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
616 * GNAT.SSE (g-sse.ads)::
617 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
618 * GNAT.Strings (g-string.ads)::
619 * GNAT.String_Split (g-strspl.ads)::
620 * GNAT.Table (g-table.ads)::
621 * GNAT.Task_Lock (g-tasloc.ads)::
622 * GNAT.Threads (g-thread.ads)::
623 * GNAT.Time_Stamp (g-timsta.ads)::
624 * GNAT.Traceback (g-traceb.ads)::
625 * GNAT.Traceback.Symbolic (g-trasym.ads)::
626 * GNAT.UTF_32 (g-utf_32.ads)::
627 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
628 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
629 * GNAT.Wide_String_Split (g-wistsp.ads)::
630 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
631 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
632 * Interfaces.C.Extensions (i-cexten.ads)::
633 * Interfaces.C.Streams (i-cstrea.ads)::
634 * Interfaces.CPP (i-cpp.ads)::
635 * Interfaces.Packed_Decimal (i-pacdec.ads)::
636 * Interfaces.VxWorks (i-vxwork.ads)::
637 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
638 * System.Address_Image (s-addima.ads)::
639 * System.Assertions (s-assert.ads)::
640 * System.Memory (s-memory.ads)::
641 * System.Multiprocessors (s-multip.ads)::
642 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
643 * System.Partition_Interface (s-parint.ads)::
644 * System.Pool_Global (s-pooglo.ads)::
645 * System.Pool_Local (s-pooloc.ads)::
646 * System.Restrictions (s-restri.ads)::
647 * System.Rident (s-rident.ads)::
648 * System.Strings.Stream_Ops (s-ststop.ads)::
649 * System.Unsigned_Types (s-unstyp.ads)::
650 * System.Wch_Cnv (s-wchcnv.ads)::
651 * System.Wch_Con (s-wchcon.ads)::
655 * Text_IO Stream Pointer Positioning::
656 * Text_IO Reading and Writing Non-Regular Files::
658 * Treating Text_IO Files as Streams::
659 * Text_IO Extensions::
660 * Text_IO Facilities for Unbounded Strings::
664 * Wide_Text_IO Stream Pointer Positioning::
665 * Wide_Text_IO Reading and Writing Non-Regular Files::
669 * Wide_Wide_Text_IO Stream Pointer Positioning::
670 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
672 Interfacing to Other Languages
675 * Interfacing to C++::
676 * Interfacing to COBOL::
677 * Interfacing to Fortran::
678 * Interfacing to non-GNAT Ada code::
680 Specialized Needs Annexes
682 Implementation of Specific Ada Features
683 * Machine Code Insertions::
684 * GNAT Implementation of Tasking::
685 * GNAT Implementation of Shared Passive Packages::
686 * Code Generation for Array Aggregates::
687 * The Size of Discriminated Records with Default Discriminants::
688 * Strict Conformance to the Ada Reference Manual::
690 Implementation of Ada 2012 Features
694 GNU Free Documentation License
701 @node About This Guide
702 @unnumbered About This Guide
705 This manual contains useful information in writing programs using the
706 @value{EDITION} compiler. It includes information on implementation dependent
707 characteristics of @value{EDITION}, including all the information required by
708 Annex M of the Ada language standard.
710 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
711 invoked in Ada 83 compatibility mode.
712 By default, @value{EDITION} assumes Ada 2012,
713 but you can override with a compiler switch
714 to explicitly specify the language version.
715 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
716 @value{EDITION} User's Guide}, for details on these switches.)
717 Throughout this manual, references to ``Ada'' without a year suffix
718 apply to all the Ada versions of the language.
720 Ada is designed to be highly portable.
721 In general, a program will have the same effect even when compiled by
722 different compilers on different platforms.
723 However, since Ada is designed to be used in a
724 wide variety of applications, it also contains a number of system
725 dependent features to be used in interfacing to the external world.
726 @cindex Implementation-dependent features
729 Note: Any program that makes use of implementation-dependent features
730 may be non-portable. You should follow good programming practice and
731 isolate and clearly document any sections of your program that make use
732 of these features in a non-portable manner.
735 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
736 ``GNAT'' in the remainder of this document.
740 * What This Reference Manual Contains::
742 * Related Information::
745 @node What This Reference Manual Contains
746 @unnumberedsec What This Reference Manual Contains
749 This reference manual contains the following chapters:
753 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
754 pragmas, which can be used to extend and enhance the functionality of the
758 @ref{Implementation Defined Attributes}, lists GNAT
759 implementation-dependent attributes, which can be used to extend and
760 enhance the functionality of the compiler.
763 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
764 implementation-dependent restrictions, which can be used to extend and
765 enhance the functionality of the compiler.
768 @ref{Implementation Advice}, provides information on generally
769 desirable behavior which are not requirements that all compilers must
770 follow since it cannot be provided on all systems, or which may be
771 undesirable on some systems.
774 @ref{Implementation Defined Characteristics}, provides a guide to
775 minimizing implementation dependent features.
778 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
779 implemented by GNAT, and how they can be imported into user
780 application programs.
783 @ref{Representation Clauses and Pragmas}, describes in detail the
784 way that GNAT represents data, and in particular the exact set
785 of representation clauses and pragmas that is accepted.
788 @ref{Standard Library Routines}, provides a listing of packages and a
789 brief description of the functionality that is provided by Ada's
790 extensive set of standard library routines as implemented by GNAT@.
793 @ref{The Implementation of Standard I/O}, details how the GNAT
794 implementation of the input-output facilities.
797 @ref{The GNAT Library}, is a catalog of packages that complement
798 the Ada predefined library.
801 @ref{Interfacing to Other Languages}, describes how programs
802 written in Ada using GNAT can be interfaced to other programming
805 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
806 of the specialized needs annexes.
809 @ref{Implementation of Specific Ada Features}, discusses issues related
810 to GNAT's implementation of machine code insertions, tasking, and several
814 @ref{Implementation of Ada 2012 Features}, describes the status of the
815 GNAT implementation of the Ada 2012 language standard.
818 @ref{Obsolescent Features} documents implementation dependent features,
819 including pragmas and attributes, which are considered obsolescent, since
820 there are other preferred ways of achieving the same results. These
821 obsolescent forms are retained for backwards compatibility.
825 @cindex Ada 95 Language Reference Manual
826 @cindex Ada 2005 Language Reference Manual
828 This reference manual assumes a basic familiarity with the Ada 95 language, as
829 described in the International Standard ANSI/ISO/IEC-8652:1995,
831 It does not require knowledge of the new features introduced by Ada 2005,
832 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
834 Both reference manuals are included in the GNAT documentation
838 @unnumberedsec Conventions
839 @cindex Conventions, typographical
840 @cindex Typographical conventions
843 Following are examples of the typographical and graphic conventions used
848 @code{Functions}, @code{utility program names}, @code{standard names},
855 @file{File names}, @samp{button names}, and @samp{field names}.
858 @code{Variables}, @env{environment variables}, and @var{metasyntactic
865 [optional information or parameters]
868 Examples are described by text
870 and then shown this way.
875 Commands that are entered by the user are preceded in this manual by the
876 characters @samp{$ } (dollar sign followed by space). If your system uses this
877 sequence as a prompt, then the commands will appear exactly as you see them
878 in the manual. If your system uses some other prompt, then the command will
879 appear with the @samp{$} replaced by whatever prompt character you are using.
881 @node Related Information
882 @unnumberedsec Related Information
884 See the following documents for further information on GNAT:
888 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
889 @value{EDITION} User's Guide}, which provides information on how to use the
890 GNAT compiler system.
893 @cite{Ada 95 Reference Manual}, which contains all reference
894 material for the Ada 95 programming language.
897 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
898 of the Ada 95 standard. The annotations describe
899 detailed aspects of the design decision, and in particular contain useful
900 sections on Ada 83 compatibility.
903 @cite{Ada 2005 Reference Manual}, which contains all reference
904 material for the Ada 2005 programming language.
907 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
908 of the Ada 2005 standard. The annotations describe
909 detailed aspects of the design decision, and in particular contain useful
910 sections on Ada 83 and Ada 95 compatibility.
913 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
914 which contains specific information on compatibility between GNAT and
918 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
919 describes in detail the pragmas and attributes provided by the DEC Ada 83
924 @node Implementation Defined Pragmas
925 @chapter Implementation Defined Pragmas
928 Ada defines a set of pragmas that can be used to supply additional
929 information to the compiler. These language defined pragmas are
930 implemented in GNAT and work as described in the Ada Reference Manual.
932 In addition, Ada allows implementations to define additional pragmas
933 whose meaning is defined by the implementation. GNAT provides a number
934 of these implementation-defined pragmas, which can be used to extend
935 and enhance the functionality of the compiler. This section of the GNAT
936 Reference Manual describes these additional pragmas.
938 Note that any program using these pragmas might not be portable to other
939 compilers (although GNAT implements this set of pragmas on all
940 platforms). Therefore if portability to other compilers is an important
941 consideration, the use of these pragmas should be minimized.
944 * Pragma Abort_Defer::
945 * Pragma Abstract_State::
952 * Pragma Allow_Integer_Address::
955 * Pragma Assert_And_Cut::
956 * Pragma Assertion_Policy::
958 * Pragma Assume_No_Invalid_Values::
959 * Pragma Async_Readers::
960 * Pragma Async_Writers::
961 * Pragma Attribute_Definition::
963 * Pragma C_Pass_By_Copy::
965 * Pragma Check_Float_Overflow::
966 * Pragma Check_Name::
967 * Pragma Check_Policy::
968 * Pragma CIL_Constructor::
970 * Pragma Common_Object::
971 * Pragma Compile_Time_Error::
972 * Pragma Compile_Time_Warning::
973 * Pragma Compiler_Unit::
974 * Pragma Compiler_Unit_Warning::
975 * Pragma Complete_Representation::
976 * Pragma Complex_Representation::
977 * Pragma Component_Alignment::
978 * Pragma Contract_Cases::
979 * Pragma Convention_Identifier::
981 * Pragma CPP_Constructor::
982 * Pragma CPP_Virtual::
983 * Pragma CPP_Vtable::
986 * Pragma Debug_Policy::
987 * Pragma Default_Storage_Pool::
989 * Pragma Detect_Blocking::
990 * Pragma Disable_Atomic_Synchronization::
991 * Pragma Dispatching_Domain::
992 * Pragma Effective_Reads::
993 * Pragma Effective_Writes::
994 * Pragma Elaboration_Checks::
996 * Pragma Enable_Atomic_Synchronization::
997 * Pragma Export_Exception::
998 * Pragma Export_Function::
999 * Pragma Export_Object::
1000 * Pragma Export_Procedure::
1001 * Pragma Export_Value::
1002 * Pragma Export_Valued_Procedure::
1003 * Pragma Extend_System::
1004 * Pragma Extensions_Allowed::
1006 * Pragma External_Name_Casing::
1007 * Pragma Fast_Math::
1008 * Pragma Favor_Top_Level::
1009 * Pragma Finalize_Storage_Only::
1010 * Pragma Float_Representation::
1013 * Pragma Implementation_Defined::
1014 * Pragma Implemented::
1015 * Pragma Implicit_Packing::
1016 * Pragma Import_Exception::
1017 * Pragma Import_Function::
1018 * Pragma Import_Object::
1019 * Pragma Import_Procedure::
1020 * Pragma Import_Valued_Procedure::
1021 * Pragma Independent::
1022 * Pragma Independent_Components::
1023 * Pragma Initial_Condition::
1024 * Pragma Initialize_Scalars::
1025 * Pragma Initializes::
1026 * Pragma Inline_Always::
1027 * Pragma Inline_Generic::
1028 * Pragma Interface::
1029 * Pragma Interface_Name::
1030 * Pragma Interrupt_Handler::
1031 * Pragma Interrupt_State::
1032 * Pragma Invariant::
1033 * Pragma Java_Constructor::
1034 * Pragma Java_Interface::
1035 * Pragma Keep_Names::
1037 * Pragma Link_With::
1038 * Pragma Linker_Alias::
1039 * Pragma Linker_Constructor::
1040 * Pragma Linker_Destructor::
1041 * Pragma Linker_Section::
1042 * Pragma Long_Float::
1043 * Pragma Loop_Invariant::
1044 * Pragma Loop_Optimize::
1045 * Pragma Loop_Variant::
1046 * Pragma Machine_Attribute::
1048 * Pragma Main_Storage::
1050 * Pragma No_Inline::
1051 * Pragma No_Return::
1052 * Pragma No_Run_Time::
1053 * Pragma No_Strict_Aliasing::
1054 * Pragma Normalize_Scalars::
1055 * Pragma Obsolescent::
1056 * Pragma Optimize_Alignment::
1058 * Pragma Overflow_Mode::
1059 * Pragma Overriding_Renamings::
1060 * Pragma Partition_Elaboration_Policy::
1063 * Pragma Persistent_BSS::
1066 * Pragma Postcondition::
1067 * Pragma Post_Class::
1069 * Pragma Precondition::
1070 * Pragma Predicate::
1071 * Pragma Preelaborable_Initialization::
1072 * Pragma Pre_Class::
1073 * Pragma Priority_Specific_Dispatching::
1075 * Pragma Profile_Warnings::
1076 * Pragma Propagate_Exceptions::
1077 * Pragma Provide_Shift_Operators::
1078 * Pragma Psect_Object::
1079 * Pragma Pure_Function::
1080 * Pragma Ravenscar::
1081 * Pragma Refined_Depends::
1082 * Pragma Refined_Global::
1083 * Pragma Refined_Post::
1084 * Pragma Refined_State::
1085 * Pragma Relative_Deadline::
1086 * Pragma Remote_Access_Type::
1087 * Pragma Restricted_Run_Time::
1088 * Pragma Restriction_Warnings::
1089 * Pragma Reviewable::
1090 * Pragma Share_Generic::
1092 * Pragma Short_Circuit_And_Or::
1093 * Pragma Short_Descriptors::
1094 * Pragma Simple_Storage_Pool_Type::
1095 * Pragma Source_File_Name::
1096 * Pragma Source_File_Name_Project::
1097 * Pragma Source_Reference::
1098 * Pragma SPARK_Mode::
1099 * Pragma Static_Elaboration_Desired::
1100 * Pragma Stream_Convert::
1101 * Pragma Style_Checks::
1104 * Pragma Suppress_All::
1105 * Pragma Suppress_Debug_Info::
1106 * Pragma Suppress_Exception_Locations::
1107 * Pragma Suppress_Initialization::
1108 * Pragma Task_Name::
1109 * Pragma Task_Storage::
1110 * Pragma Test_Case::
1111 * Pragma Thread_Local_Storage::
1112 * Pragma Time_Slice::
1114 * Pragma Type_Invariant::
1115 * Pragma Type_Invariant_Class::
1116 * Pragma Unchecked_Union::
1117 * Pragma Unimplemented_Unit::
1118 * Pragma Universal_Aliasing ::
1119 * Pragma Universal_Data::
1120 * Pragma Unmodified::
1121 * Pragma Unreferenced::
1122 * Pragma Unreferenced_Objects::
1123 * Pragma Unreserve_All_Interrupts::
1124 * Pragma Unsuppress::
1125 * Pragma Use_VADS_Size::
1126 * Pragma Validity_Checks::
1128 * Pragma Warning_As_Error::
1130 * Pragma Weak_External::
1131 * Pragma Wide_Character_Encoding::
1134 @node Pragma Abort_Defer
1135 @unnumberedsec Pragma Abort_Defer
1137 @cindex Deferring aborts
1145 This pragma must appear at the start of the statement sequence of a
1146 handled sequence of statements (right after the @code{begin}). It has
1147 the effect of deferring aborts for the sequence of statements (but not
1148 for the declarations or handlers, if any, associated with this statement
1151 @node Pragma Abstract_State
1152 @unnumberedsec Pragma Abstract_State
1153 @findex Abstract_State
1155 For the description of this pragma, see SPARK 2014 Reference Manual,
1159 @unnumberedsec Pragma Ada_83
1163 @smallexample @c ada
1168 A configuration pragma that establishes Ada 83 mode for the unit to
1169 which it applies, regardless of the mode set by the command line
1170 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1171 the syntax and semantics of Ada 83, as defined in the original Ada
1172 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1173 and Ada 2005 are not recognized, optional package bodies are allowed,
1174 and generics may name types with unknown discriminants without using
1175 the @code{(<>)} notation. In addition, some but not all of the additional
1176 restrictions of Ada 83 are enforced.
1178 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1179 Ada 83 code to be compiled and adapted to GNAT with less effort.
1180 Secondly, it aids in keeping code backwards compatible with Ada 83.
1181 However, there is no guarantee that code that is processed correctly
1182 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1183 83 compiler, since GNAT does not enforce all the additional checks
1187 @unnumberedsec Pragma Ada_95
1191 @smallexample @c ada
1196 A configuration pragma that establishes Ada 95 mode for the unit to which
1197 it applies, regardless of the mode set by the command line switches.
1198 This mode is set automatically for the @code{Ada} and @code{System}
1199 packages and their children, so you need not specify it in these
1200 contexts. This pragma is useful when writing a reusable component that
1201 itself uses Ada 95 features, but which is intended to be usable from
1202 either Ada 83 or Ada 95 programs.
1205 @unnumberedsec Pragma Ada_05
1209 @smallexample @c ada
1211 pragma Ada_05 (local_NAME);
1215 A configuration pragma that establishes Ada 2005 mode for the unit to which
1216 it applies, regardless of the mode set by the command line switches.
1217 This pragma is useful when writing a reusable component that
1218 itself uses Ada 2005 features, but which is intended to be usable from
1219 either Ada 83 or Ada 95 programs.
1221 The one argument form (which is not a configuration pragma)
1222 is used for managing the transition from
1223 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1224 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1225 mode will generate a warning. In addition, in Ada_83 or Ada_95
1226 mode, a preference rule is established which does not choose
1227 such an entity unless it is unambiguously specified. This avoids
1228 extra subprograms marked this way from generating ambiguities in
1229 otherwise legal pre-Ada_2005 programs. The one argument form is
1230 intended for exclusive use in the GNAT run-time library.
1232 @node Pragma Ada_2005
1233 @unnumberedsec Pragma Ada_2005
1237 @smallexample @c ada
1242 This configuration pragma is a synonym for pragma Ada_05 and has the
1243 same syntax and effect.
1246 @unnumberedsec Pragma Ada_12
1250 @smallexample @c ada
1252 pragma Ada_12 (local_NAME);
1256 A configuration pragma that establishes Ada 2012 mode for the unit to which
1257 it applies, regardless of the mode set by the command line switches.
1258 This mode is set automatically for the @code{Ada} and @code{System}
1259 packages and their children, so you need not specify it in these
1260 contexts. This pragma is useful when writing a reusable component that
1261 itself uses Ada 2012 features, but which is intended to be usable from
1262 Ada 83, Ada 95, or Ada 2005 programs.
1264 The one argument form, which is not a configuration pragma,
1265 is used for managing the transition from Ada
1266 2005 to Ada 2012 in the run-time library. If an entity is marked
1267 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1268 mode will generate a warning. In addition, in any pre-Ada_2012
1269 mode, a preference rule is established which does not choose
1270 such an entity unless it is unambiguously specified. This avoids
1271 extra subprograms marked this way from generating ambiguities in
1272 otherwise legal pre-Ada_2012 programs. The one argument form is
1273 intended for exclusive use in the GNAT run-time library.
1275 @node Pragma Ada_2012
1276 @unnumberedsec Pragma Ada_2012
1280 @smallexample @c ada
1285 This configuration pragma is a synonym for pragma Ada_12 and has the
1286 same syntax and effect.
1288 @node Pragma Allow_Integer_Address
1289 @unnumberedsec Pragma Allow_Integer_Address
1290 @findex Allow_Integer_Address
1293 @smallexample @c ada
1294 pragma Allow_Integer_Address;
1298 In almost all versions of GNAT, @code{System.Address} is a private
1299 type in accordance with the implementation advice in the RM. This
1300 means that integer values,
1301 in particular integer literals, are not allowed as address values.
1302 If the configuration pragma
1303 @code{Allow_Integer_Address} is given, then integer expressions may
1304 be used anywhere a value of type @code{System.Address} is required.
1305 The effect is to introduce an implicit unchecked conversion from the
1306 integer value to type @code{System.Address}. The reverse case of using
1307 an address where an integer type is required is handled analogously.
1308 The following example compiles without errors:
1310 @smallexample @c ada
1311 pragma Allow_Integer_Address;
1312 with System; use System;
1313 package AddrAsInt is
1316 for X'Address use 16#1240#;
1317 for Y use at 16#3230#;
1318 m : Address := 16#4000#;
1319 n : constant Address := 4000;
1320 p : constant Address := Address (X + Y);
1321 v : Integer := y'Address;
1322 w : constant Integer := Integer (Y'Address);
1323 type R is new integer;
1326 for Z'Address use RR;
1331 Note that pragma @code{Allow_Integer_Address} is ignored if
1332 @code{System.Address}
1333 is not a private type. In implementations of @code{GNAT} where
1334 System.Address is a visible integer type (notably the implementations
1335 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1336 rather than rejected to allow common sets of sources to be used
1337 in the two situations.
1339 @node Pragma Annotate
1340 @unnumberedsec Pragma Annotate
1344 @smallexample @c ada
1345 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1347 ARG ::= NAME | EXPRESSION
1351 This pragma is used to annotate programs. @var{identifier} identifies
1352 the type of annotation. GNAT verifies that it is an identifier, but does
1353 not otherwise analyze it. The second optional identifier is also left
1354 unanalyzed, and by convention is used to control the action of the tool to
1355 which the annotation is addressed. The remaining @var{arg} arguments
1356 can be either string literals or more generally expressions.
1357 String literals are assumed to be either of type
1358 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1359 depending on the character literals they contain.
1360 All other kinds of arguments are analyzed as expressions, and must be
1363 The analyzed pragma is retained in the tree, but not otherwise processed
1364 by any part of the GNAT compiler, except to generate corresponding note
1365 lines in the generated ALI file. For the format of these note lines, see
1366 the compiler source file lib-writ.ads. This pragma is intended for use by
1367 external tools, including ASIS@. The use of pragma Annotate does not
1368 affect the compilation process in any way. This pragma may be used as
1369 a configuration pragma.
1372 @unnumberedsec Pragma Assert
1376 @smallexample @c ada
1379 [, string_EXPRESSION]);
1383 The effect of this pragma depends on whether the corresponding command
1384 line switch is set to activate assertions. The pragma expands into code
1385 equivalent to the following:
1387 @smallexample @c ada
1388 if assertions-enabled then
1389 if not boolean_EXPRESSION then
1390 System.Assertions.Raise_Assert_Failure
1391 (string_EXPRESSION);
1397 The string argument, if given, is the message that will be associated
1398 with the exception occurrence if the exception is raised. If no second
1399 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1400 where @var{file} is the name of the source file containing the assert,
1401 and @var{nnn} is the line number of the assert. A pragma is not a
1402 statement, so if a statement sequence contains nothing but a pragma
1403 assert, then a null statement is required in addition, as in:
1405 @smallexample @c ada
1408 pragma Assert (K > 3, "Bad value for K");
1414 Note that, as with the @code{if} statement to which it is equivalent, the
1415 type of the expression is either @code{Standard.Boolean}, or any type derived
1416 from this standard type.
1418 Assert checks can be either checked or ignored. By default they are ignored.
1419 They will be checked if either the command line switch @option{-gnata} is
1420 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1421 to enable @code{Assert_Checks}.
1423 If assertions are ignored, then there
1424 is no run-time effect (and in particular, any side effects from the
1425 expression will not occur at run time). (The expression is still
1426 analyzed at compile time, and may cause types to be frozen if they are
1427 mentioned here for the first time).
1429 If assertions are checked, then the given expression is tested, and if
1430 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1431 which results in the raising of @code{Assert_Failure} with the given message.
1433 You should generally avoid side effects in the expression arguments of
1434 this pragma, because these side effects will turn on and off with the
1435 setting of the assertions mode, resulting in assertions that have an
1436 effect on the program. However, the expressions are analyzed for
1437 semantic correctness whether or not assertions are enabled, so turning
1438 assertions on and off cannot affect the legality of a program.
1440 Note that the implementation defined policy @code{DISABLE}, given in a
1441 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1443 Note: this is a standard language-defined pragma in versions
1444 of Ada from 2005 on. In GNAT, it is implemented in all versions
1445 of Ada, and the DISABLE policy is an implementation-defined
1448 @node Pragma Assert_And_Cut
1449 @unnumberedsec Pragma Assert_And_Cut
1450 @findex Assert_And_Cut
1453 @smallexample @c ada
1454 pragma Assert_And_Cut (
1456 [, string_EXPRESSION]);
1460 The effect of this pragma is identical to that of pragma @code{Assert},
1461 except that in an @code{Assertion_Policy} pragma, the identifier
1462 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1465 The intention is that this be used within a subprogram when the
1466 given test expresion sums up all the work done so far in the
1467 subprogram, so that the rest of the subprogram can be verified
1468 (informally or formally) using only the entry preconditions,
1469 and the expression in this pragma. This allows dividing up
1470 a subprogram into sections for the purposes of testing or
1471 formal verification. The pragma also serves as useful
1474 @node Pragma Assertion_Policy
1475 @unnumberedsec Pragma Assertion_Policy
1476 @findex Assertion_Policy
1479 @smallexample @c ada
1480 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1482 pragma Assertion_Policy (
1483 ASSERTION_KIND => POLICY_IDENTIFIER
1484 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1486 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1488 RM_ASSERTION_KIND ::= Assert |
1496 Type_Invariant'Class
1498 ID_ASSERTION_KIND ::= Assertions |
1511 Statement_Assertions
1513 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1517 This is a standard Ada 2012 pragma that is available as an
1518 implementation-defined pragma in earlier versions of Ada.
1519 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1520 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1521 are implementation defined additions recognized by the GNAT compiler.
1523 The pragma applies in both cases to pragmas and aspects with matching
1524 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1525 applies to both the @code{Precondition} pragma
1526 and the aspect @code{Precondition}. Note that the identifiers for
1527 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1528 Pre_Class and Post_Class), since these pragmas are intended to be
1529 identical to the corresponding aspects).
1531 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1532 the corresponding pragma or aspect is activated.
1533 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1534 the corresponding pragma or aspect is deactivated.
1535 This pragma overrides the effect of the @option{-gnata} switch on the
1538 The implementation defined policy @code{DISABLE} is like
1539 @code{IGNORE} except that it completely disables semantic
1540 checking of the corresponding pragma or aspect. This is
1541 useful when the pragma or aspect argument references subprograms
1542 in a with'ed package which is replaced by a dummy package
1543 for the final build.
1545 The implementation defined policy @code{Assertions} applies to all
1546 assertion kinds. The form with no assertion kind given implies this
1547 choice, so it applies to all assertion kinds (RM defined, and
1548 implementation defined).
1550 The implementation defined policy @code{Statement_Assertions}
1551 applies to @code{Assert}, @code{Assert_And_Cut},
1552 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1555 @unnumberedsec Pragma Assume
1559 @smallexample @c ada
1562 [, string_EXPRESSION]);
1566 The effect of this pragma is identical to that of pragma @code{Assert},
1567 except that in an @code{Assertion_Policy} pragma, the identifier
1568 @code{Assume} is used to control whether it is ignored or checked
1571 The intention is that this be used for assumptions about the
1572 external environment. So you cannot expect to verify formally
1573 or informally that the condition is met, this must be
1574 established by examining things outside the program itself.
1575 For example, we may have code that depends on the size of
1576 @code{Long_Long_Integer} being at least 64. So we could write:
1578 @smallexample @c ada
1579 pragma Assume (Long_Long_Integer'Size >= 64);
1583 This assumption cannot be proved from the program itself,
1584 but it acts as a useful run-time check that the assumption
1585 is met, and documents the need to ensure that it is met by
1586 reference to information outside the program.
1588 @node Pragma Assume_No_Invalid_Values
1589 @unnumberedsec Pragma Assume_No_Invalid_Values
1590 @findex Assume_No_Invalid_Values
1591 @cindex Invalid representations
1592 @cindex Invalid values
1595 @smallexample @c ada
1596 pragma Assume_No_Invalid_Values (On | Off);
1600 This is a configuration pragma that controls the assumptions made by the
1601 compiler about the occurrence of invalid representations (invalid values)
1604 The default behavior (corresponding to an Off argument for this pragma), is
1605 to assume that values may in general be invalid unless the compiler can
1606 prove they are valid. Consider the following example:
1608 @smallexample @c ada
1609 V1 : Integer range 1 .. 10;
1610 V2 : Integer range 11 .. 20;
1612 for J in V2 .. V1 loop
1618 if V1 and V2 have valid values, then the loop is known at compile
1619 time not to execute since the lower bound must be greater than the
1620 upper bound. However in default mode, no such assumption is made,
1621 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1622 is given, the compiler will assume that any occurrence of a variable
1623 other than in an explicit @code{'Valid} test always has a valid
1624 value, and the loop above will be optimized away.
1626 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1627 you know your code is free of uninitialized variables and other
1628 possible sources of invalid representations, and may result in
1629 more efficient code. A program that accesses an invalid representation
1630 with this pragma in effect is erroneous, so no guarantees can be made
1633 It is peculiar though permissible to use this pragma in conjunction
1634 with validity checking (-gnatVa). In such cases, accessing invalid
1635 values will generally give an exception, though formally the program
1636 is erroneous so there are no guarantees that this will always be the
1637 case, and it is recommended that these two options not be used together.
1639 @node Pragma Async_Readers
1640 @unnumberedsec Pragma Async_Readers
1641 @findex Async_Readers
1643 For the description of this pragma, see SPARK 2014 Reference Manual,
1646 @node Pragma Async_Writers
1647 @unnumberedsec Pragma Async_Writers
1648 @findex Async_Writers
1650 For the description of this pragma, see SPARK 2014 Reference Manual,
1653 @node Pragma Ast_Entry
1654 @unnumberedsec Pragma Ast_Entry
1659 @smallexample @c ada
1660 pragma AST_Entry (entry_IDENTIFIER);
1664 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1665 argument is the simple name of a single entry; at most one @code{AST_Entry}
1666 pragma is allowed for any given entry. This pragma must be used in
1667 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1668 the entry declaration and in the same task type specification or single task
1669 as the entry to which it applies. This pragma specifies that the given entry
1670 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1671 resulting from an OpenVMS system service call. The pragma does not affect
1672 normal use of the entry. For further details on this pragma, see the
1673 DEC Ada Language Reference Manual, section 9.12a.
1675 @node Pragma Attribute_Definition
1676 @unnumberedsec Pragma Attribute_Definition
1677 @findex Attribute_Definition
1680 @smallexample @c ada
1681 pragma Attribute_Definition
1682 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1683 [Entity =>] LOCAL_NAME,
1684 [Expression =>] EXPRESSION | NAME);
1688 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1689 the attribute definition clause:
1691 @smallexample @c ada
1692 for Entity'Attribute use Expression;
1695 If @code{Attribute} is not a recognized attribute name, the pragma is
1696 ignored, and a warning is emitted. This allows source
1697 code to be written that takes advantage of some new attribute, while remaining
1698 compilable with earlier compilers.
1700 @node Pragma C_Pass_By_Copy
1701 @unnumberedsec Pragma C_Pass_By_Copy
1702 @cindex Passing by copy
1703 @findex C_Pass_By_Copy
1706 @smallexample @c ada
1707 pragma C_Pass_By_Copy
1708 ([Max_Size =>] static_integer_EXPRESSION);
1712 Normally the default mechanism for passing C convention records to C
1713 convention subprograms is to pass them by reference, as suggested by RM
1714 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1715 this default, by requiring that record formal parameters be passed by
1716 copy if all of the following conditions are met:
1720 The size of the record type does not exceed the value specified for
1723 The record type has @code{Convention C}.
1725 The formal parameter has this record type, and the subprogram has a
1726 foreign (non-Ada) convention.
1730 If these conditions are met the argument is passed by copy, i.e.@: in a
1731 manner consistent with what C expects if the corresponding formal in the
1732 C prototype is a struct (rather than a pointer to a struct).
1734 You can also pass records by copy by specifying the convention
1735 @code{C_Pass_By_Copy} for the record type, or by using the extended
1736 @code{Import} and @code{Export} pragmas, which allow specification of
1737 passing mechanisms on a parameter by parameter basis.
1740 @unnumberedsec Pragma Check
1742 @cindex Named assertions
1746 @smallexample @c ada
1748 [Name =>] CHECK_KIND,
1749 [Check =>] Boolean_EXPRESSION
1750 [, [Message =>] string_EXPRESSION] );
1752 CHECK_KIND ::= IDENTIFIER |
1755 Type_Invariant'Class |
1760 This pragma is similar to the predefined pragma @code{Assert} except that an
1761 extra identifier argument is present. In conjunction with pragma
1762 @code{Check_Policy}, this can be used to define groups of assertions that can
1763 be independently controlled. The identifier @code{Assertion} is special, it
1764 refers to the normal set of pragma @code{Assert} statements.
1766 Checks introduced by this pragma are normally deactivated by default. They can
1767 be activated either by the command line option @option{-gnata}, which turns on
1768 all checks, or individually controlled using pragma @code{Check_Policy}.
1770 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1771 permitted as check kinds, since this would cause confusion with the use
1772 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1773 pragmas, where they are used to refer to sets of assertions.
1775 @node Pragma Check_Float_Overflow
1776 @unnumberedsec Pragma Check_Float_Overflow
1777 @cindex Floating-point overflow
1778 @findex Check_Float_Overflow
1781 @smallexample @c ada
1782 pragma Check_Float_Overflow;
1786 In Ada, the predefined floating-point types (@code{Short_Float},
1787 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1788 defined to be @emph{unconstrained}. This means that even though each
1789 has a well-defined base range, an operation that delivers a result
1790 outside this base range is not required to raise an exception.
1791 This implementation permission accommodates the notion
1792 of infinities in IEEE floating-point, and corresponds to the
1793 efficient execution mode on most machines. GNAT will not raise
1794 overflow exceptions on these machines; instead it will generate
1795 infinities and NaN's as defined in the IEEE standard.
1797 Generating infinities, although efficient, is not always desirable.
1798 Often the preferable approach is to check for overflow, even at the
1799 (perhaps considerable) expense of run-time performance.
1800 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1801 range constraints -- and indeed such a subtype
1802 can have the same base range as its base type. For example:
1804 @smallexample @c ada
1805 subtype My_Float is Float range Float'Range;
1809 Here @code{My_Float} has the same range as
1810 @code{Float} but is constrained, so operations on
1811 @code{My_Float} values will be checked for overflow
1814 This style will achieve the desired goal, but
1815 it is often more convenient to be able to simply use
1816 the standard predefined floating-point types as long
1817 as overflow checking could be guaranteed.
1818 The @code{Check_Float_Overflow}
1819 configuration pragma achieves this effect. If a unit is compiled
1820 subject to this configuration pragma, then all operations
1821 on predefined floating-point types including operations on
1822 base types of these floating-point types will be treated as
1823 though those types were constrained, and overflow checks
1824 will be generated. The @code{Constraint_Error}
1825 exception is raised if the result is out of range.
1827 This mode can also be set by use of the compiler
1828 switch @option{-gnateF}.
1830 @node Pragma Check_Name
1831 @unnumberedsec Pragma Check_Name
1832 @cindex Defining check names
1833 @cindex Check names, defining
1837 @smallexample @c ada
1838 pragma Check_Name (check_name_IDENTIFIER);
1842 This is a configuration pragma that defines a new implementation
1843 defined check name (unless IDENTIFIER matches one of the predefined
1844 check names, in which case the pragma has no effect). Check names
1845 are global to a partition, so if two or more configuration pragmas
1846 are present in a partition mentioning the same name, only one new
1847 check name is introduced.
1849 An implementation defined check name introduced with this pragma may
1850 be used in only three contexts: @code{pragma Suppress},
1851 @code{pragma Unsuppress},
1852 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1853 any of these three cases, the check name must be visible. A check
1854 name is visible if it is in the configuration pragmas applying to
1855 the current unit, or if it appears at the start of any unit that
1856 is part of the dependency set of the current unit (e.g., units that
1857 are mentioned in @code{with} clauses).
1859 Check names introduced by this pragma are subject to control by compiler
1860 switches (in particular -gnatp) in the usual manner.
1862 @node Pragma Check_Policy
1863 @unnumberedsec Pragma Check_Policy
1864 @cindex Controlling assertions
1865 @cindex Assertions, control
1866 @cindex Check pragma control
1867 @cindex Named assertions
1871 @smallexample @c ada
1873 ([Name =>] CHECK_KIND,
1874 [Policy =>] POLICY_IDENTIFIER);
1876 pragma Check_Policy (
1877 CHECK_KIND => POLICY_IDENTIFIER
1878 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1880 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1882 CHECK_KIND ::= IDENTIFIER |
1885 Type_Invariant'Class |
1888 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1889 avoids confusion between the two possible syntax forms for this pragma.
1891 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1895 This pragma is used to set the checking policy for assertions (specified
1896 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1897 to be checked using the @code{Check} pragma. It may appear either as
1898 a configuration pragma, or within a declarative part of package. In the
1899 latter case, it applies from the point where it appears to the end of
1900 the declarative region (like pragma @code{Suppress}).
1902 The @code{Check_Policy} pragma is similar to the
1903 predefined @code{Assertion_Policy} pragma,
1904 and if the check kind corresponds to one of the assertion kinds that
1905 are allowed by @code{Assertion_Policy}, then the effect is identical.
1907 If the first argument is Debug, then the policy applies to Debug pragmas,
1908 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1909 @code{IGNORE}, and allowing them to execute with normal semantics if
1910 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1911 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1912 be totally ignored and not analyzed semantically.
1914 Finally the first argument may be some other identifier than the above
1915 possibilities, in which case it controls a set of named assertions
1916 that can be checked using pragma @code{Check}. For example, if the pragma:
1918 @smallexample @c ada
1919 pragma Check_Policy (Critical_Error, OFF);
1923 is given, then subsequent @code{Check} pragmas whose first argument is also
1924 @code{Critical_Error} will be disabled.
1926 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1927 to turn on corresponding checks. The default for a set of checks for which no
1928 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1929 @option{-gnata} is given, which turns on all checks by default.
1931 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1932 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1933 compatibility with the standard @code{Assertion_Policy} pragma. The check
1934 policy setting @code{DISABLE} causes the second argument of a corresponding
1935 @code{Check} pragma to be completely ignored and not analyzed.
1937 @node Pragma CIL_Constructor
1938 @unnumberedsec Pragma CIL_Constructor
1939 @findex CIL_Constructor
1943 @smallexample @c ada
1944 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1948 This pragma is used to assert that the specified Ada function should be
1949 mapped to the .NET constructor for some Ada tagged record type.
1951 See section 4.1 of the
1952 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1953 for related information.
1955 @node Pragma Comment
1956 @unnumberedsec Pragma Comment
1961 @smallexample @c ada
1962 pragma Comment (static_string_EXPRESSION);
1966 This is almost identical in effect to pragma @code{Ident}. It allows the
1967 placement of a comment into the object file and hence into the
1968 executable file if the operating system permits such usage. The
1969 difference is that @code{Comment}, unlike @code{Ident}, has
1970 no limitations on placement of the pragma (it can be placed
1971 anywhere in the main source unit), and if more than one pragma
1972 is used, all comments are retained.
1974 @node Pragma Common_Object
1975 @unnumberedsec Pragma Common_Object
1976 @findex Common_Object
1980 @smallexample @c ada
1981 pragma Common_Object (
1982 [Internal =>] LOCAL_NAME
1983 [, [External =>] EXTERNAL_SYMBOL]
1984 [, [Size =>] EXTERNAL_SYMBOL] );
1988 | static_string_EXPRESSION
1992 This pragma enables the shared use of variables stored in overlaid
1993 linker areas corresponding to the use of @code{COMMON}
1994 in Fortran. The single
1995 object @var{LOCAL_NAME} is assigned to the area designated by
1996 the @var{External} argument.
1997 You may define a record to correspond to a series
1998 of fields. The @var{Size} argument
1999 is syntax checked in GNAT, but otherwise ignored.
2001 @code{Common_Object} is not supported on all platforms. If no
2002 support is available, then the code generator will issue a message
2003 indicating that the necessary attribute for implementation of this
2004 pragma is not available.
2006 @node Pragma Compile_Time_Error
2007 @unnumberedsec Pragma Compile_Time_Error
2008 @findex Compile_Time_Error
2012 @smallexample @c ada
2013 pragma Compile_Time_Error
2014 (boolean_EXPRESSION, static_string_EXPRESSION);
2018 This pragma can be used to generate additional compile time
2020 is particularly useful in generics, where errors can be issued for
2021 specific problematic instantiations. The first parameter is a boolean
2022 expression. The pragma is effective only if the value of this expression
2023 is known at compile time, and has the value True. The set of expressions
2024 whose values are known at compile time includes all static boolean
2025 expressions, and also other values which the compiler can determine
2026 at compile time (e.g., the size of a record type set by an explicit
2027 size representation clause, or the value of a variable which was
2028 initialized to a constant and is known not to have been modified).
2029 If these conditions are met, an error message is generated using
2030 the value given as the second argument. This string value may contain
2031 embedded ASCII.LF characters to break the message into multiple lines.
2033 @node Pragma Compile_Time_Warning
2034 @unnumberedsec Pragma Compile_Time_Warning
2035 @findex Compile_Time_Warning
2039 @smallexample @c ada
2040 pragma Compile_Time_Warning
2041 (boolean_EXPRESSION, static_string_EXPRESSION);
2045 Same as pragma Compile_Time_Error, except a warning is issued instead
2046 of an error message. Note that if this pragma is used in a package that
2047 is with'ed by a client, the client will get the warning even though it
2048 is issued by a with'ed package (normally warnings in with'ed units are
2049 suppressed, but this is a special exception to that rule).
2051 One typical use is within a generic where compile time known characteristics
2052 of formal parameters are tested, and warnings given appropriately. Another use
2053 with a first parameter of True is to warn a client about use of a package,
2054 for example that it is not fully implemented.
2056 @node Pragma Compiler_Unit
2057 @unnumberedsec Pragma Compiler_Unit
2058 @findex Compiler_Unit
2062 @smallexample @c ada
2063 pragma Compiler_Unit;
2067 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2068 retained so that old versions of the GNAT run-time that use this pragma can
2069 be compiled with newer versions of the compiler.
2071 @node Pragma Compiler_Unit_Warning
2072 @unnumberedsec Pragma Compiler_Unit_Warning
2073 @findex Compiler_Unit_Warning
2077 @smallexample @c ada
2078 pragma Compiler_Unit_Warning;
2082 This pragma is intended only for internal use in the GNAT run-time library.
2083 It indicates that the unit is used as part of the compiler build. The effect
2084 is to generate warnings for the use of constructs (for example, conditional
2085 expressions) that would cause trouble when bootstrapping using an older
2086 version of GNAT. For the exact list of restrictions, see the compiler sources
2087 and references to Check_Compiler_Unit.
2089 @node Pragma Complete_Representation
2090 @unnumberedsec Pragma Complete_Representation
2091 @findex Complete_Representation
2095 @smallexample @c ada
2096 pragma Complete_Representation;
2100 This pragma must appear immediately within a record representation
2101 clause. Typical placements are before the first component clause
2102 or after the last component clause. The effect is to give an error
2103 message if any component is missing a component clause. This pragma
2104 may be used to ensure that a record representation clause is
2105 complete, and that this invariant is maintained if fields are
2106 added to the record in the future.
2108 @node Pragma Complex_Representation
2109 @unnumberedsec Pragma Complex_Representation
2110 @findex Complex_Representation
2114 @smallexample @c ada
2115 pragma Complex_Representation
2116 ([Entity =>] LOCAL_NAME);
2120 The @var{Entity} argument must be the name of a record type which has
2121 two fields of the same floating-point type. The effect of this pragma is
2122 to force gcc to use the special internal complex representation form for
2123 this record, which may be more efficient. Note that this may result in
2124 the code for this type not conforming to standard ABI (application
2125 binary interface) requirements for the handling of record types. For
2126 example, in some environments, there is a requirement for passing
2127 records by pointer, and the use of this pragma may result in passing
2128 this type in floating-point registers.
2130 @node Pragma Component_Alignment
2131 @unnumberedsec Pragma Component_Alignment
2132 @cindex Alignments of components
2133 @findex Component_Alignment
2137 @smallexample @c ada
2138 pragma Component_Alignment (
2139 [Form =>] ALIGNMENT_CHOICE
2140 [, [Name =>] type_LOCAL_NAME]);
2142 ALIGNMENT_CHOICE ::=
2150 Specifies the alignment of components in array or record types.
2151 The meaning of the @var{Form} argument is as follows:
2154 @findex Component_Size
2155 @item Component_Size
2156 Aligns scalar components and subcomponents of the array or record type
2157 on boundaries appropriate to their inherent size (naturally
2158 aligned). For example, 1-byte components are aligned on byte boundaries,
2159 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2160 integer components are aligned on 4-byte boundaries and so on. These
2161 alignment rules correspond to the normal rules for C compilers on all
2162 machines except the VAX@.
2164 @findex Component_Size_4
2165 @item Component_Size_4
2166 Naturally aligns components with a size of four or fewer
2167 bytes. Components that are larger than 4 bytes are placed on the next
2170 @findex Storage_Unit
2172 Specifies that array or record components are byte aligned, i.e.@:
2173 aligned on boundaries determined by the value of the constant
2174 @code{System.Storage_Unit}.
2178 Specifies that array or record components are aligned on default
2179 boundaries, appropriate to the underlying hardware or operating system or
2180 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2181 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2182 the @code{Default} choice is the same as @code{Component_Size} (natural
2187 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2188 refer to a local record or array type, and the specified alignment
2189 choice applies to the specified type. The use of
2190 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2191 @code{Component_Alignment} pragma to be ignored. The use of
2192 @code{Component_Alignment} together with a record representation clause
2193 is only effective for fields not specified by the representation clause.
2195 If the @code{Name} parameter is absent, the pragma can be used as either
2196 a configuration pragma, in which case it applies to one or more units in
2197 accordance with the normal rules for configuration pragmas, or it can be
2198 used within a declarative part, in which case it applies to types that
2199 are declared within this declarative part, or within any nested scope
2200 within this declarative part. In either case it specifies the alignment
2201 to be applied to any record or array type which has otherwise standard
2204 If the alignment for a record or array type is not specified (using
2205 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2206 clause), the GNAT uses the default alignment as described previously.
2208 @node Pragma Contract_Cases
2209 @unnumberedsec Pragma Contract_Cases
2210 @cindex Contract cases
2211 @findex Contract_Cases
2215 @smallexample @c ada
2216 pragma Contract_Cases (
2217 Condition => Consequence
2218 @{,Condition => Consequence@});
2222 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2223 that can complement or replace the contract given by a precondition and a
2224 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2225 by testing and formal verification tools. The compiler checks its validity and,
2226 depending on the assertion policy at the point of declaration of the pragma,
2227 it may insert a check in the executable. For code generation, the contract
2230 @smallexample @c ada
2231 pragma Contract_Cases (
2239 @smallexample @c ada
2240 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2241 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2242 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2243 pragma Postcondition (if C1 then Pred1);
2244 pragma Postcondition (if C2 then Pred2);
2248 The precondition ensures that one and only one of the conditions is
2249 satisfied on entry to the subprogram.
2250 The postcondition ensures that for the condition that was True on entry,
2251 the corrresponding consequence is True on exit. Other consequence expressions
2254 A precondition @code{P} and postcondition @code{Q} can also be
2255 expressed as contract cases:
2257 @smallexample @c ada
2258 pragma Contract_Cases (P => Q);
2261 The placement and visibility rules for @code{Contract_Cases} pragmas are
2262 identical to those described for preconditions and postconditions.
2264 The compiler checks that boolean expressions given in conditions and
2265 consequences are valid, where the rules for conditions are the same as
2266 the rule for an expression in @code{Precondition} and the rules for
2267 consequences are the same as the rule for an expression in
2268 @code{Postcondition}. In particular, attributes @code{'Old} and
2269 @code{'Result} can only be used within consequence expressions.
2270 The condition for the last contract case may be @code{others}, to denote
2271 any case not captured by the previous cases. The
2272 following is an example of use within a package spec:
2274 @smallexample @c ada
2275 package Math_Functions is
2277 function Sqrt (Arg : Float) return Float;
2278 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2279 Arg >= 100 => Sqrt'Result >= 10,
2280 others => Sqrt'Result = 0);
2286 The meaning of contract cases is that only one case should apply at each
2287 call, as determined by the corresponding condition evaluating to True,
2288 and that the consequence for this case should hold when the subprogram
2291 @node Pragma Convention_Identifier
2292 @unnumberedsec Pragma Convention_Identifier
2293 @findex Convention_Identifier
2294 @cindex Conventions, synonyms
2298 @smallexample @c ada
2299 pragma Convention_Identifier (
2300 [Name =>] IDENTIFIER,
2301 [Convention =>] convention_IDENTIFIER);
2305 This pragma provides a mechanism for supplying synonyms for existing
2306 convention identifiers. The @code{Name} identifier can subsequently
2307 be used as a synonym for the given convention in other pragmas (including
2308 for example pragma @code{Import} or another @code{Convention_Identifier}
2309 pragma). As an example of the use of this, suppose you had legacy code
2310 which used Fortran77 as the identifier for Fortran. Then the pragma:
2312 @smallexample @c ada
2313 pragma Convention_Identifier (Fortran77, Fortran);
2317 would allow the use of the convention identifier @code{Fortran77} in
2318 subsequent code, avoiding the need to modify the sources. As another
2319 example, you could use this to parameterize convention requirements
2320 according to systems. Suppose you needed to use @code{Stdcall} on
2321 windows systems, and @code{C} on some other system, then you could
2322 define a convention identifier @code{Library} and use a single
2323 @code{Convention_Identifier} pragma to specify which convention
2324 would be used system-wide.
2326 @node Pragma CPP_Class
2327 @unnumberedsec Pragma CPP_Class
2329 @cindex Interfacing with C++
2333 @smallexample @c ada
2334 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2338 The argument denotes an entity in the current declarative region that is
2339 declared as a record type. It indicates that the type corresponds to an
2340 externally declared C++ class type, and is to be laid out the same way
2341 that C++ would lay out the type. If the C++ class has virtual primitives
2342 then the record must be declared as a tagged record type.
2344 Types for which @code{CPP_Class} is specified do not have assignment or
2345 equality operators defined (such operations can be imported or declared
2346 as subprograms as required). Initialization is allowed only by constructor
2347 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2348 limited if not explicitly declared as limited or derived from a limited
2349 type, and an error is issued in that case.
2351 See @ref{Interfacing to C++} for related information.
2353 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2354 for backward compatibility but its functionality is available
2355 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2357 @node Pragma CPP_Constructor
2358 @unnumberedsec Pragma CPP_Constructor
2359 @cindex Interfacing with C++
2360 @findex CPP_Constructor
2364 @smallexample @c ada
2365 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2366 [, [External_Name =>] static_string_EXPRESSION ]
2367 [, [Link_Name =>] static_string_EXPRESSION ]);
2371 This pragma identifies an imported function (imported in the usual way
2372 with pragma @code{Import}) as corresponding to a C++ constructor. If
2373 @code{External_Name} and @code{Link_Name} are not specified then the
2374 @code{Entity} argument is a name that must have been previously mentioned
2375 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2376 must be of one of the following forms:
2380 @code{function @var{Fname} return @var{T}}
2384 @code{function @var{Fname} return @var{T}'Class}
2387 @code{function @var{Fname} (@dots{}) return @var{T}}
2391 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2395 where @var{T} is a limited record type imported from C++ with pragma
2396 @code{Import} and @code{Convention} = @code{CPP}.
2398 The first two forms import the default constructor, used when an object
2399 of type @var{T} is created on the Ada side with no explicit constructor.
2400 The latter two forms cover all the non-default constructors of the type.
2401 See the @value{EDITION} User's Guide for details.
2403 If no constructors are imported, it is impossible to create any objects
2404 on the Ada side and the type is implicitly declared abstract.
2406 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2407 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2409 See @ref{Interfacing to C++} for more related information.
2411 Note: The use of functions returning class-wide types for constructors is
2412 currently obsolete. They are supported for backward compatibility. The
2413 use of functions returning the type T leave the Ada sources more clear
2414 because the imported C++ constructors always return an object of type T;
2415 that is, they never return an object whose type is a descendant of type T.
2417 @node Pragma CPP_Virtual
2418 @unnumberedsec Pragma CPP_Virtual
2419 @cindex Interfacing to C++
2422 This pragma is now obsolete and, other than generating a warning if warnings
2423 on obsolescent features are enabled, is completely ignored.
2424 It is retained for compatibility
2425 purposes. It used to be required to ensure compoatibility with C++, but
2426 is no longer required for that purpose because GNAT generates
2427 the same object layout as the G++ compiler by default.
2429 See @ref{Interfacing to C++} for related information.
2431 @node Pragma CPP_Vtable
2432 @unnumberedsec Pragma CPP_Vtable
2433 @cindex Interfacing with C++
2436 This pragma is now obsolete and, other than generating a warning if warnings
2437 on obsolescent features are enabled, is completely ignored.
2438 It used to be required to ensure compatibility with C++, but
2439 is no longer required for that purpose because GNAT generates
2440 the same object layout as the G++ compiler by default.
2442 See @ref{Interfacing to C++} for related information.
2445 @unnumberedsec Pragma CPU
2450 @smallexample @c ada
2451 pragma CPU (EXPRESSION);
2455 This pragma is standard in Ada 2012, but is available in all earlier
2456 versions of Ada as an implementation-defined pragma.
2457 See Ada 2012 Reference Manual for details.
2460 @unnumberedsec Pragma Debug
2465 @smallexample @c ada
2466 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2468 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2470 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2474 The procedure call argument has the syntactic form of an expression, meeting
2475 the syntactic requirements for pragmas.
2477 If debug pragmas are not enabled or if the condition is present and evaluates
2478 to False, this pragma has no effect. If debug pragmas are enabled, the
2479 semantics of the pragma is exactly equivalent to the procedure call statement
2480 corresponding to the argument with a terminating semicolon. Pragmas are
2481 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2482 intersperse calls to debug procedures in the middle of declarations. Debug
2483 pragmas can be enabled either by use of the command line switch @option{-gnata}
2484 or by use of the pragma @code{Check_Policy} with a first argument of
2487 @node Pragma Debug_Policy
2488 @unnumberedsec Pragma Debug_Policy
2489 @findex Debug_Policy
2493 @smallexample @c ada
2494 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2498 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2499 with a first argument of @code{Debug}. It is retained for historical
2500 compatibility reasons.
2502 @node Pragma Default_Storage_Pool
2503 @unnumberedsec Pragma Default_Storage_Pool
2504 @findex Default_Storage_Pool
2508 @smallexample @c ada
2509 pragma Default_Storage_Pool (storage_pool_NAME | null);
2513 This pragma is standard in Ada 2012, but is available in all earlier
2514 versions of Ada as an implementation-defined pragma.
2515 See Ada 2012 Reference Manual for details.
2517 @node Pragma Depends
2518 @unnumberedsec Pragma Depends
2521 For the description of this pragma, see SPARK 2014 Reference Manual,
2524 @node Pragma Detect_Blocking
2525 @unnumberedsec Pragma Detect_Blocking
2526 @findex Detect_Blocking
2530 @smallexample @c ada
2531 pragma Detect_Blocking;
2535 This is a standard pragma in Ada 2005, that is available in all earlier
2536 versions of Ada as an implementation-defined pragma.
2538 This is a configuration pragma that forces the detection of potentially
2539 blocking operations within a protected operation, and to raise Program_Error
2542 @node Pragma Disable_Atomic_Synchronization
2543 @unnumberedsec Pragma Disable_Atomic_Synchronization
2544 @cindex Atomic Synchronization
2545 @findex Disable_Atomic_Synchronization
2549 @smallexample @c ada
2550 pragma Disable_Atomic_Synchronization [(Entity)];
2554 Ada requires that accesses (reads or writes) of an atomic variable be
2555 regarded as synchronization points in the case of multiple tasks.
2556 Particularly in the case of multi-processors this may require special
2557 handling, e.g. the generation of memory barriers. This capability may
2558 be turned off using this pragma in cases where it is known not to be
2561 The placement and scope rules for this pragma are the same as those
2562 for @code{pragma Suppress}. In particular it can be used as a
2563 configuration pragma, or in a declaration sequence where it applies
2564 till the end of the scope. If an @code{Entity} argument is present,
2565 the action applies only to that entity.
2567 @node Pragma Dispatching_Domain
2568 @unnumberedsec Pragma Dispatching_Domain
2569 @findex Dispatching_Domain
2573 @smallexample @c ada
2574 pragma Dispatching_Domain (EXPRESSION);
2578 This pragma is standard in Ada 2012, but is available in all earlier
2579 versions of Ada as an implementation-defined pragma.
2580 See Ada 2012 Reference Manual for details.
2582 @node Pragma Effective_Reads
2583 @unnumberedsec Pragma Effective_Reads
2584 @findex Effective_Reads
2586 For the description of this pragma, see SPARK 2014 Reference Manual,
2589 @node Pragma Effective_Writes
2590 @unnumberedsec Pragma Effective_Writes
2591 @findex Effective_Writes
2593 For the description of this pragma, see SPARK 2014 Reference Manual,
2596 @node Pragma Elaboration_Checks
2597 @unnumberedsec Pragma Elaboration_Checks
2598 @cindex Elaboration control
2599 @findex Elaboration_Checks
2603 @smallexample @c ada
2604 pragma Elaboration_Checks (Dynamic | Static);
2608 This is a configuration pragma that provides control over the
2609 elaboration model used by the compilation affected by the
2610 pragma. If the parameter is @code{Dynamic},
2611 then the dynamic elaboration
2612 model described in the Ada Reference Manual is used, as though
2613 the @option{-gnatE} switch had been specified on the command
2614 line. If the parameter is @code{Static}, then the default GNAT static
2615 model is used. This configuration pragma overrides the setting
2616 of the command line. For full details on the elaboration models
2617 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2618 gnat_ugn, @value{EDITION} User's Guide}.
2620 @node Pragma Eliminate
2621 @unnumberedsec Pragma Eliminate
2622 @cindex Elimination of unused subprograms
2627 @smallexample @c ada
2628 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2629 [Source_Location =>] STRING_LITERAL);
2633 The string literal given for the source location is a string which
2634 specifies the line number of the occurrence of the entity, using
2635 the syntax for SOURCE_TRACE given below:
2637 @smallexample @c ada
2638 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2643 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2645 LINE_NUMBER ::= DIGIT @{DIGIT@}
2649 Spaces around the colon in a @code{Source_Reference} are optional.
2651 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2652 explicit subprogram declaration, where the @code{entity} name in this
2653 designator appears on the source line specified by the source location.
2655 The source trace that is given as the @code{Source_Location} shall obey the
2656 following rules. The @code{FILE_NAME} is the short name (with no directory
2657 information) of an Ada source file, given using exactly the required syntax
2658 for the underlying file system (e.g. case is important if the underlying
2659 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2660 number of the occurrence of the @code{entity}
2661 as a decimal literal without an exponent or point. If an @code{entity} is not
2662 declared in a generic instantiation (this includes generic subprogram
2663 instances), the source trace includes only one source reference. If an entity
2664 is declared inside a generic instantiation, its source trace (when parsing
2665 from left to right) starts with the source location of the declaration of the
2666 entity in the generic unit and ends with the source location of the
2667 instantiation (it is given in square brackets). This approach is recursively
2668 used in case of nested instantiations: the rightmost (nested most deeply in
2669 square brackets) element of the source trace is the location of the outermost
2670 instantiation, the next to left element is the location of the next (first
2671 nested) instantiation in the code of the corresponding generic unit, and so
2672 on, and the leftmost element (that is out of any square brackets) is the
2673 location of the declaration of the entity to eliminate in a generic unit.
2675 Note that the @code{Source_Location} argument specifies which of a set of
2676 similarly named entities is being eliminated, dealing both with overloading,
2677 and also appearance of the same entity name in different scopes.
2679 This pragma indicates that the given entity is not used in the program to be
2680 compiled and built. The effect of the pragma is to allow the compiler to
2681 eliminate the code or data associated with the named entity. Any reference to
2682 an eliminated entity causes a compile-time or link-time error.
2684 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2685 in a system-independent manner, with unused entities eliminated, without
2686 needing to modify the source text. Normally the required set of
2687 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2689 Any source file change that removes, splits, or
2690 adds lines may make the set of Eliminate pragmas invalid because their
2691 @code{Source_Location} argument values may get out of date.
2693 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2694 operation. In this case all the subprograms to which the given operation can
2695 dispatch are considered to be unused (are never called as a result of a direct
2696 or a dispatching call).
2698 @node Pragma Enable_Atomic_Synchronization
2699 @unnumberedsec Pragma Enable_Atomic_Synchronization
2700 @cindex Atomic Synchronization
2701 @findex Enable_Atomic_Synchronization
2705 @smallexample @c ada
2706 pragma Enable_Atomic_Synchronization [(Entity)];
2710 Ada requires that accesses (reads or writes) of an atomic variable be
2711 regarded as synchronization points in the case of multiple tasks.
2712 Particularly in the case of multi-processors this may require special
2713 handling, e.g. the generation of memory barriers. This synchronization
2714 is performed by default, but can be turned off using
2715 @code{pragma Disable_Atomic_Synchronization}. The
2716 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2719 The placement and scope rules for this pragma are the same as those
2720 for @code{pragma Unsuppress}. In particular it can be used as a
2721 configuration pragma, or in a declaration sequence where it applies
2722 till the end of the scope. If an @code{Entity} argument is present,
2723 the action applies only to that entity.
2725 @node Pragma Export_Exception
2726 @unnumberedsec Pragma Export_Exception
2728 @findex Export_Exception
2732 @smallexample @c ada
2733 pragma Export_Exception (
2734 [Internal =>] LOCAL_NAME
2735 [, [External =>] EXTERNAL_SYMBOL]
2736 [, [Form =>] Ada | VMS]
2737 [, [Code =>] static_integer_EXPRESSION]);
2741 | static_string_EXPRESSION
2745 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2746 causes the specified exception to be propagated outside of the Ada program,
2747 so that it can be handled by programs written in other OpenVMS languages.
2748 This pragma establishes an external name for an Ada exception and makes the
2749 name available to the OpenVMS Linker as a global symbol. For further details
2750 on this pragma, see the
2751 DEC Ada Language Reference Manual, section 13.9a3.2.
2753 @node Pragma Export_Function
2754 @unnumberedsec Pragma Export_Function
2755 @cindex Argument passing mechanisms
2756 @findex Export_Function
2761 @smallexample @c ada
2762 pragma Export_Function (
2763 [Internal =>] LOCAL_NAME
2764 [, [External =>] EXTERNAL_SYMBOL]
2765 [, [Parameter_Types =>] PARAMETER_TYPES]
2766 [, [Result_Type =>] result_SUBTYPE_MARK]
2767 [, [Mechanism =>] MECHANISM]
2768 [, [Result_Mechanism =>] MECHANISM_NAME]);
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 Use this pragma to make a function externally callable and optionally
2801 provide information on mechanisms to be used for passing parameter and
2802 result values. We recommend, for the purposes of improving portability,
2803 this pragma always be used in conjunction with a separate pragma
2804 @code{Export}, which must precede the pragma @code{Export_Function}.
2805 GNAT does not require a separate pragma @code{Export}, but if none is
2806 present, @code{Convention Ada} is assumed, which is usually
2807 not what is wanted, so it is usually appropriate to use this
2808 pragma in conjunction with a @code{Export} or @code{Convention}
2809 pragma that specifies the desired foreign convention.
2810 Pragma @code{Export_Function}
2811 (and @code{Export}, if present) must appear in the same declarative
2812 region as the function to which they apply.
2814 @var{internal_name} must uniquely designate the function to which the
2815 pragma applies. If more than one function name exists of this name in
2816 the declarative part you must use the @code{Parameter_Types} and
2817 @code{Result_Type} parameters is mandatory to achieve the required
2818 unique designation. @var{subtype_mark}s in these parameters must
2819 exactly match the subtypes in the corresponding function specification,
2820 using positional notation to match parameters with subtype marks.
2821 The form with an @code{'Access} attribute can be used to match an
2822 anonymous access parameter.
2825 @cindex Passing by descriptor
2826 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2827 The default behavior for Export_Function is to accept either 64bit or
2828 32bit descriptors unless short_descriptor is specified, then only 32bit
2829 descriptors are accepted.
2831 @cindex Suppressing external name
2832 Special treatment is given if the EXTERNAL is an explicit null
2833 string or a static string expressions that evaluates to the null
2834 string. In this case, no external name is generated. This form
2835 still allows the specification of parameter mechanisms.
2837 @node Pragma Export_Object
2838 @unnumberedsec Pragma Export_Object
2839 @findex Export_Object
2843 @smallexample @c ada
2844 pragma Export_Object
2845 [Internal =>] LOCAL_NAME
2846 [, [External =>] EXTERNAL_SYMBOL]
2847 [, [Size =>] EXTERNAL_SYMBOL]
2851 | static_string_EXPRESSION
2855 This pragma designates an object as exported, and apart from the
2856 extended rules for external symbols, is identical in effect to the use of
2857 the normal @code{Export} pragma applied to an object. You may use a
2858 separate Export pragma (and you probably should from the point of view
2859 of portability), but it is not required. @var{Size} is syntax checked,
2860 but otherwise ignored by GNAT@.
2862 @node Pragma Export_Procedure
2863 @unnumberedsec Pragma Export_Procedure
2864 @findex Export_Procedure
2868 @smallexample @c ada
2869 pragma Export_Procedure (
2870 [Internal =>] LOCAL_NAME
2871 [, [External =>] EXTERNAL_SYMBOL]
2872 [, [Parameter_Types =>] PARAMETER_TYPES]
2873 [, [Mechanism =>] MECHANISM]);
2877 | static_string_EXPRESSION
2882 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2886 | subtype_Name ' Access
2890 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2892 MECHANISM_ASSOCIATION ::=
2893 [formal_parameter_NAME =>] MECHANISM_NAME
2898 | Descriptor [([Class =>] CLASS_NAME)]
2899 | Short_Descriptor [([Class =>] CLASS_NAME)]
2901 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2905 This pragma is identical to @code{Export_Function} except that it
2906 applies to a procedure rather than a function and the parameters
2907 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2908 GNAT does not require a separate pragma @code{Export}, but if none is
2909 present, @code{Convention Ada} is assumed, which is usually
2910 not what is wanted, so it is usually appropriate to use this
2911 pragma in conjunction with a @code{Export} or @code{Convention}
2912 pragma that specifies the desired foreign convention.
2915 @cindex Passing by descriptor
2916 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2917 The default behavior for Export_Procedure is to accept either 64bit or
2918 32bit descriptors unless short_descriptor is specified, then only 32bit
2919 descriptors are accepted.
2921 @cindex Suppressing external name
2922 Special treatment is given if the EXTERNAL is an explicit null
2923 string or a static string expressions that evaluates to the null
2924 string. In this case, no external name is generated. This form
2925 still allows the specification of parameter mechanisms.
2927 @node Pragma Export_Value
2928 @unnumberedsec Pragma Export_Value
2929 @findex Export_Value
2933 @smallexample @c ada
2934 pragma Export_Value (
2935 [Value =>] static_integer_EXPRESSION,
2936 [Link_Name =>] static_string_EXPRESSION);
2940 This pragma serves to export a static integer value for external use.
2941 The first argument specifies the value to be exported. The Link_Name
2942 argument specifies the symbolic name to be associated with the integer
2943 value. This pragma is useful for defining a named static value in Ada
2944 that can be referenced in assembly language units to be linked with
2945 the application. This pragma is currently supported only for the
2946 AAMP target and is ignored for other targets.
2948 @node Pragma Export_Valued_Procedure
2949 @unnumberedsec Pragma Export_Valued_Procedure
2950 @findex Export_Valued_Procedure
2954 @smallexample @c ada
2955 pragma Export_Valued_Procedure (
2956 [Internal =>] LOCAL_NAME
2957 [, [External =>] EXTERNAL_SYMBOL]
2958 [, [Parameter_Types =>] PARAMETER_TYPES]
2959 [, [Mechanism =>] MECHANISM]);
2963 | static_string_EXPRESSION
2968 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2972 | subtype_Name ' Access
2976 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2978 MECHANISM_ASSOCIATION ::=
2979 [formal_parameter_NAME =>] MECHANISM_NAME
2984 | Descriptor [([Class =>] CLASS_NAME)]
2985 | Short_Descriptor [([Class =>] CLASS_NAME)]
2987 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2991 This pragma is identical to @code{Export_Procedure} except that the
2992 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2993 mode @code{OUT}, and externally the subprogram is treated as a function
2994 with this parameter as the result of the function. GNAT provides for
2995 this capability to allow the use of @code{OUT} and @code{IN OUT}
2996 parameters in interfacing to external functions (which are not permitted
2998 GNAT does not require a separate pragma @code{Export}, but if none is
2999 present, @code{Convention Ada} is assumed, which is almost certainly
3000 not what is wanted since the whole point of this pragma is to interface
3001 with foreign language functions, so it is usually appropriate to use this
3002 pragma in conjunction with a @code{Export} or @code{Convention}
3003 pragma that specifies the desired foreign convention.
3006 @cindex Passing by descriptor
3007 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3008 The default behavior for Export_Valued_Procedure is to accept either 64bit or
3009 32bit descriptors unless short_descriptor is specified, then only 32bit
3010 descriptors are accepted.
3012 @cindex Suppressing external name
3013 Special treatment is given if the EXTERNAL is an explicit null
3014 string or a static string expressions that evaluates to the null
3015 string. In this case, no external name is generated. This form
3016 still allows the specification of parameter mechanisms.
3018 @node Pragma Extend_System
3019 @unnumberedsec Pragma Extend_System
3020 @cindex @code{system}, extending
3022 @findex Extend_System
3026 @smallexample @c ada
3027 pragma Extend_System ([Name =>] IDENTIFIER);
3031 This pragma is used to provide backwards compatibility with other
3032 implementations that extend the facilities of package @code{System}. In
3033 GNAT, @code{System} contains only the definitions that are present in
3034 the Ada RM@. However, other implementations, notably the DEC Ada 83
3035 implementation, provide many extensions to package @code{System}.
3037 For each such implementation accommodated by this pragma, GNAT provides a
3038 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3039 implementation, which provides the required additional definitions. You
3040 can use this package in two ways. You can @code{with} it in the normal
3041 way and access entities either by selection or using a @code{use}
3042 clause. In this case no special processing is required.
3044 However, if existing code contains references such as
3045 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3046 definitions provided in package @code{System}, you may use this pragma
3047 to extend visibility in @code{System} in a non-standard way that
3048 provides greater compatibility with the existing code. Pragma
3049 @code{Extend_System} is a configuration pragma whose single argument is
3050 the name of the package containing the extended definition
3051 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
3052 control of this pragma will be processed using special visibility
3053 processing that looks in package @code{System.Aux_@var{xxx}} where
3054 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3055 package @code{System}, but not found in package @code{System}.
3057 You can use this pragma either to access a predefined @code{System}
3058 extension supplied with the compiler, for example @code{Aux_DEC} or
3059 you can construct your own extension unit following the above
3060 definition. Note that such a package is a child of @code{System}
3061 and thus is considered part of the implementation.
3062 To compile it you will have to use the @option{-gnatg} switch,
3063 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3064 for compiling System units, as explained in the
3065 @value{EDITION} User's Guide.
3067 @node Pragma Extensions_Allowed
3068 @unnumberedsec Pragma Extensions_Allowed
3069 @cindex Ada Extensions
3070 @cindex GNAT Extensions
3071 @findex Extensions_Allowed
3075 @smallexample @c ada
3076 pragma Extensions_Allowed (On | Off);
3080 This configuration pragma enables or disables the implementation
3081 extension mode (the use of Off as a parameter cancels the effect
3082 of the @option{-gnatX} command switch).
3084 In extension mode, the latest version of the Ada language is
3085 implemented (currently Ada 2012), and in addition a small number
3086 of GNAT specific extensions are recognized as follows:
3089 @item Constrained attribute for generic objects
3090 The @code{Constrained} attribute is permitted for objects of
3091 generic types. The result indicates if the corresponding actual
3096 @node Pragma External
3097 @unnumberedsec Pragma External
3102 @smallexample @c ada
3104 [ Convention =>] convention_IDENTIFIER,
3105 [ Entity =>] LOCAL_NAME
3106 [, [External_Name =>] static_string_EXPRESSION ]
3107 [, [Link_Name =>] static_string_EXPRESSION ]);
3111 This pragma is identical in syntax and semantics to pragma
3112 @code{Export} as defined in the Ada Reference Manual. It is
3113 provided for compatibility with some Ada 83 compilers that
3114 used this pragma for exactly the same purposes as pragma
3115 @code{Export} before the latter was standardized.
3117 @node Pragma External_Name_Casing
3118 @unnumberedsec Pragma External_Name_Casing
3119 @cindex Dec Ada 83 casing compatibility
3120 @cindex External Names, casing
3121 @cindex Casing of External names
3122 @findex External_Name_Casing
3126 @smallexample @c ada
3127 pragma External_Name_Casing (
3128 Uppercase | Lowercase
3129 [, Uppercase | Lowercase | As_Is]);
3133 This pragma provides control over the casing of external names associated
3134 with Import and Export pragmas. There are two cases to consider:
3137 @item Implicit external names
3138 Implicit external names are derived from identifiers. The most common case
3139 arises when a standard Ada Import or Export pragma is used with only two
3142 @smallexample @c ada
3143 pragma Import (C, C_Routine);
3147 Since Ada is a case-insensitive language, the spelling of the identifier in
3148 the Ada source program does not provide any information on the desired
3149 casing of the external name, and so a convention is needed. In GNAT the
3150 default treatment is that such names are converted to all lower case
3151 letters. This corresponds to the normal C style in many environments.
3152 The first argument of pragma @code{External_Name_Casing} can be used to
3153 control this treatment. If @code{Uppercase} is specified, then the name
3154 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3155 then the normal default of all lower case letters will be used.
3157 This same implicit treatment is also used in the case of extended DEC Ada 83
3158 compatible Import and Export pragmas where an external name is explicitly
3159 specified using an identifier rather than a string.
3161 @item Explicit external names
3162 Explicit external names are given as string literals. The most common case
3163 arises when a standard Ada Import or Export pragma is used with three
3166 @smallexample @c ada
3167 pragma Import (C, C_Routine, "C_routine");
3171 In this case, the string literal normally provides the exact casing required
3172 for the external name. The second argument of pragma
3173 @code{External_Name_Casing} may be used to modify this behavior.
3174 If @code{Uppercase} is specified, then the name
3175 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3176 then the name will be forced to all lowercase letters. A specification of
3177 @code{As_Is} provides the normal default behavior in which the casing is
3178 taken from the string provided.
3182 This pragma may appear anywhere that a pragma is valid. In particular, it
3183 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3184 case it applies to all subsequent compilations, or it can be used as a program
3185 unit pragma, in which case it only applies to the current unit, or it can
3186 be used more locally to control individual Import/Export pragmas.
3188 It is primarily intended for use with OpenVMS systems, where many
3189 compilers convert all symbols to upper case by default. For interfacing to
3190 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3193 @smallexample @c ada
3194 pragma External_Name_Casing (Uppercase, Uppercase);
3198 to enforce the upper casing of all external symbols.
3200 @node Pragma Fast_Math
3201 @unnumberedsec Pragma Fast_Math
3206 @smallexample @c ada
3211 This is a configuration pragma which activates a mode in which speed is
3212 considered more important for floating-point operations than absolutely
3213 accurate adherence to the requirements of the standard. Currently the
3214 following operations are affected:
3217 @item Complex Multiplication
3218 The normal simple formula for complex multiplication can result in intermediate
3219 overflows for numbers near the end of the range. The Ada standard requires that
3220 this situation be detected and corrected by scaling, but in Fast_Math mode such
3221 cases will simply result in overflow. Note that to take advantage of this you
3222 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3223 under control of the pragma, rather than use the preinstantiated versions.
3226 @node Pragma Favor_Top_Level
3227 @unnumberedsec Pragma Favor_Top_Level
3228 @findex Favor_Top_Level
3232 @smallexample @c ada
3233 pragma Favor_Top_Level (type_NAME);
3237 The named type must be an access-to-subprogram type. This pragma is an
3238 efficiency hint to the compiler, regarding the use of 'Access or
3239 'Unrestricted_Access on nested (non-library-level) subprograms. The
3240 pragma means that nested subprograms are not used with this type, or
3241 are rare, so that the generated code should be efficient in the
3242 top-level case. When this pragma is used, dynamically generated
3243 trampolines may be used on some targets for nested subprograms.
3244 See also the No_Implicit_Dynamic_Code restriction.
3246 @node Pragma Finalize_Storage_Only
3247 @unnumberedsec Pragma Finalize_Storage_Only
3248 @findex Finalize_Storage_Only
3252 @smallexample @c ada
3253 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3257 This pragma allows the compiler not to emit a Finalize call for objects
3258 defined at the library level. This is mostly useful for types where
3259 finalization is only used to deal with storage reclamation since in most
3260 environments it is not necessary to reclaim memory just before terminating
3261 execution, hence the name.
3263 @node Pragma Float_Representation
3264 @unnumberedsec Pragma Float_Representation
3266 @findex Float_Representation
3270 @smallexample @c ada
3271 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3273 FLOAT_REP ::= VAX_Float | IEEE_Float
3277 In the one argument form, this pragma is a configuration pragma which
3278 allows control over the internal representation chosen for the predefined
3279 floating point types declared in the packages @code{Standard} and
3280 @code{System}. On all systems other than OpenVMS, the argument must
3281 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3282 argument may be @code{VAX_Float} to specify the use of the VAX float
3283 format for the floating-point types in Standard. This requires that
3284 the standard runtime libraries be recompiled.
3286 The two argument form specifies the representation to be used for
3287 the specified floating-point type. On all systems other than OpenVMS,
3289 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3293 For a digits value of 6, 32-bit IEEE short format will be used.
3295 For a digits value of 15, 64-bit IEEE long format will be used.
3297 No other value of digits is permitted.
3301 argument may be @code{VAX_Float} to specify the use of the VAX float
3306 For digits values up to 6, F float format will be used.
3308 For digits values from 7 to 9, D float format will be used.
3310 For digits values from 10 to 15, G float format will be used.
3312 Digits values above 15 are not allowed.
3316 @unnumberedsec Pragma Global
3319 For the description of this pragma, see SPARK 2014 Reference Manual,
3323 @unnumberedsec Pragma Ident
3328 @smallexample @c ada
3329 pragma Ident (static_string_EXPRESSION);
3333 This pragma provides a string identification in the generated object file,
3334 if the system supports the concept of this kind of identification string.
3335 This pragma is allowed only in the outermost declarative part or
3336 declarative items of a compilation unit. If more than one @code{Ident}
3337 pragma is given, only the last one processed is effective.
3339 On OpenVMS systems, the effect of the pragma is identical to the effect of
3340 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3341 maximum allowed length is 31 characters, so if it is important to
3342 maintain compatibility with this compiler, you should obey this length
3345 @node Pragma Implementation_Defined
3346 @unnumberedsec Pragma Implementation_Defined
3347 @findex Implementation_Defined
3351 @smallexample @c ada
3352 pragma Implementation_Defined (local_NAME);
3356 This pragma marks a previously declared entioty as implementation-defined.
3357 For an overloaded entity, applies to the most recent homonym.
3359 @smallexample @c ada
3360 pragma Implementation_Defined;
3364 The form with no arguments appears anywhere within a scope, most
3365 typically a package spec, and indicates that all entities that are
3366 defined within the package spec are Implementation_Defined.
3368 This pragma is used within the GNAT runtime library to identify
3369 implementation-defined entities introduced in language-defined units,
3370 for the purpose of implementing the No_Implementation_Identifiers
3373 @node Pragma Implemented
3374 @unnumberedsec Pragma Implemented
3379 @smallexample @c ada
3380 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3382 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3386 This is an Ada 2012 representation pragma which applies to protected, task
3387 and synchronized interface primitives. The use of pragma Implemented provides
3388 a way to impose a static requirement on the overriding operation by adhering
3389 to one of the three implementation kinds: entry, protected procedure or any of
3390 the above. This pragma is available in all earlier versions of Ada as an
3391 implementation-defined pragma.
3393 @smallexample @c ada
3394 type Synch_Iface is synchronized interface;
3395 procedure Prim_Op (Obj : in out Iface) is abstract;
3396 pragma Implemented (Prim_Op, By_Protected_Procedure);
3398 protected type Prot_1 is new Synch_Iface with
3399 procedure Prim_Op; -- Legal
3402 protected type Prot_2 is new Synch_Iface with
3403 entry Prim_Op; -- Illegal
3406 task type Task_Typ is new Synch_Iface with
3407 entry Prim_Op; -- Illegal
3412 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3413 Implemented determines the runtime behavior of the requeue. Implementation kind
3414 By_Entry guarantees that the action of requeueing will proceed from an entry to
3415 another entry. Implementation kind By_Protected_Procedure transforms the
3416 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3417 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3418 the target's overriding subprogram kind.
3420 @node Pragma Implicit_Packing
3421 @unnumberedsec Pragma Implicit_Packing
3422 @findex Implicit_Packing
3423 @cindex Rational Profile
3427 @smallexample @c ada
3428 pragma Implicit_Packing;
3432 This is a configuration pragma that requests implicit packing for packed
3433 arrays for which a size clause is given but no explicit pragma Pack or
3434 specification of Component_Size is present. It also applies to records
3435 where no record representation clause is present. Consider this example:
3437 @smallexample @c ada
3438 type R is array (0 .. 7) of Boolean;
3443 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3444 does not change the layout of a composite object. So the Size clause in the
3445 above example is normally rejected, since the default layout of the array uses
3446 8-bit components, and thus the array requires a minimum of 64 bits.
3448 If this declaration is compiled in a region of code covered by an occurrence
3449 of the configuration pragma Implicit_Packing, then the Size clause in this
3450 and similar examples will cause implicit packing and thus be accepted. For
3451 this implicit packing to occur, the type in question must be an array of small
3452 components whose size is known at compile time, and the Size clause must
3453 specify the exact size that corresponds to the number of elements in the array
3454 multiplied by the size in bits of the component type (both single and
3455 multi-dimensioned arrays can be controlled with this pragma).
3457 @cindex Array packing
3459 Similarly, the following example shows the use in the record case
3461 @smallexample @c ada
3463 a, b, c, d, e, f, g, h : boolean;
3470 Without a pragma Pack, each Boolean field requires 8 bits, so the
3471 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3472 sufficient. The use of pragma Implicit_Packing allows this record
3473 declaration to compile without an explicit pragma Pack.
3474 @node Pragma Import_Exception
3475 @unnumberedsec Pragma Import_Exception
3477 @findex Import_Exception
3481 @smallexample @c ada
3482 pragma Import_Exception (
3483 [Internal =>] LOCAL_NAME
3484 [, [External =>] EXTERNAL_SYMBOL]
3485 [, [Form =>] Ada | VMS]
3486 [, [Code =>] static_integer_EXPRESSION]);
3490 | static_string_EXPRESSION
3494 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3495 It allows OpenVMS conditions (for example, from OpenVMS system services or
3496 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3497 The pragma specifies that the exception associated with an exception
3498 declaration in an Ada program be defined externally (in non-Ada code).
3499 For further details on this pragma, see the
3500 DEC Ada Language Reference Manual, section 13.9a.3.1.
3502 @node Pragma Import_Function
3503 @unnumberedsec Pragma Import_Function
3504 @findex Import_Function
3508 @smallexample @c ada
3509 pragma Import_Function (
3510 [Internal =>] LOCAL_NAME,
3511 [, [External =>] EXTERNAL_SYMBOL]
3512 [, [Parameter_Types =>] PARAMETER_TYPES]
3513 [, [Result_Type =>] SUBTYPE_MARK]
3514 [, [Mechanism =>] MECHANISM]
3515 [, [Result_Mechanism =>] MECHANISM_NAME]
3516 [, [First_Optional_Parameter =>] IDENTIFIER]);
3520 | static_string_EXPRESSION
3524 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3528 | subtype_Name ' Access
3532 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3534 MECHANISM_ASSOCIATION ::=
3535 [formal_parameter_NAME =>] MECHANISM_NAME
3540 | Descriptor [([Class =>] CLASS_NAME)]
3541 | Short_Descriptor [([Class =>] CLASS_NAME)]
3543 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3547 This pragma is used in conjunction with a pragma @code{Import} to
3548 specify additional information for an imported function. The pragma
3549 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3550 @code{Import_Function} pragma and both must appear in the same
3551 declarative part as the function specification.
3553 The @var{Internal} argument must uniquely designate
3554 the function to which the
3555 pragma applies. If more than one function name exists of this name in
3556 the declarative part you must use the @code{Parameter_Types} and
3557 @var{Result_Type} parameters to achieve the required unique
3558 designation. Subtype marks in these parameters must exactly match the
3559 subtypes in the corresponding function specification, using positional
3560 notation to match parameters with subtype marks.
3561 The form with an @code{'Access} attribute can be used to match an
3562 anonymous access parameter.
3564 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3565 parameters to specify passing mechanisms for the
3566 parameters and result. If you specify a single mechanism name, it
3567 applies to all parameters. Otherwise you may specify a mechanism on a
3568 parameter by parameter basis using either positional or named
3569 notation. If the mechanism is not specified, the default mechanism
3573 @cindex Passing by descriptor
3574 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3575 The default behavior for Import_Function is to pass a 64bit descriptor
3576 unless short_descriptor is specified, then a 32bit descriptor is passed.
3578 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3579 It specifies that the designated parameter and all following parameters
3580 are optional, meaning that they are not passed at the generated code
3581 level (this is distinct from the notion of optional parameters in Ada
3582 where the parameters are passed anyway with the designated optional
3583 parameters). All optional parameters must be of mode @code{IN} and have
3584 default parameter values that are either known at compile time
3585 expressions, or uses of the @code{'Null_Parameter} attribute.
3587 @node Pragma Import_Object
3588 @unnumberedsec Pragma Import_Object
3589 @findex Import_Object
3593 @smallexample @c ada
3594 pragma Import_Object
3595 [Internal =>] LOCAL_NAME
3596 [, [External =>] EXTERNAL_SYMBOL]
3597 [, [Size =>] EXTERNAL_SYMBOL]);
3601 | static_string_EXPRESSION
3605 This pragma designates an object as imported, and apart from the
3606 extended rules for external symbols, is identical in effect to the use of
3607 the normal @code{Import} pragma applied to an object. Unlike the
3608 subprogram case, you need not use a separate @code{Import} pragma,
3609 although you may do so (and probably should do so from a portability
3610 point of view). @var{size} is syntax checked, but otherwise ignored by
3613 @node Pragma Import_Procedure
3614 @unnumberedsec Pragma Import_Procedure
3615 @findex Import_Procedure
3619 @smallexample @c ada
3620 pragma Import_Procedure (
3621 [Internal =>] LOCAL_NAME
3622 [, [External =>] EXTERNAL_SYMBOL]
3623 [, [Parameter_Types =>] PARAMETER_TYPES]
3624 [, [Mechanism =>] MECHANISM]
3625 [, [First_Optional_Parameter =>] IDENTIFIER]);
3629 | static_string_EXPRESSION
3633 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3637 | subtype_Name ' Access
3641 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3643 MECHANISM_ASSOCIATION ::=
3644 [formal_parameter_NAME =>] MECHANISM_NAME
3649 | Descriptor [([Class =>] CLASS_NAME)]
3650 | Short_Descriptor [([Class =>] CLASS_NAME)]
3652 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3656 This pragma is identical to @code{Import_Function} except that it
3657 applies to a procedure rather than a function and the parameters
3658 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3660 @node Pragma Import_Valued_Procedure
3661 @unnumberedsec Pragma Import_Valued_Procedure
3662 @findex Import_Valued_Procedure
3666 @smallexample @c ada
3667 pragma Import_Valued_Procedure (
3668 [Internal =>] LOCAL_NAME
3669 [, [External =>] EXTERNAL_SYMBOL]
3670 [, [Parameter_Types =>] PARAMETER_TYPES]
3671 [, [Mechanism =>] MECHANISM]
3672 [, [First_Optional_Parameter =>] IDENTIFIER]);
3676 | static_string_EXPRESSION
3680 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3684 | subtype_Name ' Access
3688 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3690 MECHANISM_ASSOCIATION ::=
3691 [formal_parameter_NAME =>] MECHANISM_NAME
3696 | Descriptor [([Class =>] CLASS_NAME)]
3697 | Short_Descriptor [([Class =>] CLASS_NAME)]
3699 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3703 This pragma is identical to @code{Import_Procedure} except that the
3704 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3705 mode @code{OUT}, and externally the subprogram is treated as a function
3706 with this parameter as the result of the function. The purpose of this
3707 capability is to allow the use of @code{OUT} and @code{IN OUT}
3708 parameters in interfacing to external functions (which are not permitted
3709 in Ada functions). You may optionally use the @code{Mechanism}
3710 parameters to specify passing mechanisms for the parameters.
3711 If you specify a single mechanism name, it applies to all parameters.
3712 Otherwise you may specify a mechanism on a parameter by parameter
3713 basis using either positional or named notation. If the mechanism is not
3714 specified, the default mechanism is used.
3716 Note that it is important to use this pragma in conjunction with a separate
3717 pragma Import that specifies the desired convention, since otherwise the
3718 default convention is Ada, which is almost certainly not what is required.
3720 @node Pragma Independent
3721 @unnumberedsec Pragma Independent
3726 @smallexample @c ada
3727 pragma Independent (Local_NAME);
3731 This pragma is standard in Ada 2012 mode (which also provides an aspect
3732 of the same name). It is also available as an implementation-defined
3733 pragma in all earlier versions. It specifies that the
3734 designated object or all objects of the designated type must be
3735 independently addressable. This means that separate tasks can safely
3736 manipulate such objects. For example, if two components of a record are
3737 independent, then two separate tasks may access these two components.
3739 constraints on the representation of the object (for instance prohibiting
3742 @node Pragma Independent_Components
3743 @unnumberedsec Pragma Independent_Components
3744 @findex Independent_Components
3748 @smallexample @c ada
3749 pragma Independent_Components (Local_NAME);
3753 This pragma is standard in Ada 2012 mode (which also provides an aspect
3754 of the same name). It is also available as an implementation-defined
3755 pragma in all earlier versions. It specifies that the components of the
3756 designated object, or the components of each object of the designated
3758 independently addressable. This means that separate tasks can safely
3759 manipulate separate components in the composite object. This may place
3760 constraints on the representation of the object (for instance prohibiting
3763 @node Pragma Initial_Condition
3764 @unnumberedsec Pragma Initial_Condition
3765 @findex Initial_Condition
3767 For the description of this pragma, see SPARK 2014 Reference Manual,
3770 @node Pragma Initialize_Scalars
3771 @unnumberedsec Pragma Initialize_Scalars
3772 @findex Initialize_Scalars
3773 @cindex debugging with Initialize_Scalars
3777 @smallexample @c ada
3778 pragma Initialize_Scalars;
3782 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3783 two important differences. First, there is no requirement for the pragma
3784 to be used uniformly in all units of a partition, in particular, it is fine
3785 to use this just for some or all of the application units of a partition,
3786 without needing to recompile the run-time library.
3788 In the case where some units are compiled with the pragma, and some without,
3789 then a declaration of a variable where the type is defined in package
3790 Standard or is locally declared will always be subject to initialization,
3791 as will any declaration of a scalar variable. For composite variables,
3792 whether the variable is initialized may also depend on whether the package
3793 in which the type of the variable is declared is compiled with the pragma.
3795 The other important difference is that you can control the value used
3796 for initializing scalar objects. At bind time, you can select several
3797 options for initialization. You can
3798 initialize with invalid values (similar to Normalize_Scalars, though for
3799 Initialize_Scalars it is not always possible to determine the invalid
3800 values in complex cases like signed component fields with non-standard
3801 sizes). You can also initialize with high or
3802 low values, or with a specified bit pattern. See the @value{EDITION}
3803 User's Guide for binder options for specifying these cases.
3805 This means that you can compile a program, and then without having to
3806 recompile the program, you can run it with different values being used
3807 for initializing otherwise uninitialized values, to test if your program
3808 behavior depends on the choice. Of course the behavior should not change,
3809 and if it does, then most likely you have an incorrect reference to an
3810 uninitialized value.
3812 It is even possible to change the value at execution time eliminating even
3813 the need to rebind with a different switch using an environment variable.
3814 See the @value{EDITION} User's Guide for details.
3816 Note that pragma @code{Initialize_Scalars} is particularly useful in
3817 conjunction with the enhanced validity checking that is now provided
3818 in GNAT, which checks for invalid values under more conditions.
3819 Using this feature (see description of the @option{-gnatV} flag in the
3820 @value{EDITION} User's Guide) in conjunction with
3821 pragma @code{Initialize_Scalars}
3822 provides a powerful new tool to assist in the detection of problems
3823 caused by uninitialized variables.
3825 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3826 effect on the generated code. This may cause your code to be
3827 substantially larger. It may also cause an increase in the amount
3828 of stack required, so it is probably a good idea to turn on stack
3829 checking (see description of stack checking in the @value{EDITION}
3830 User's Guide) when using this pragma.
3832 @node Pragma Initializes
3833 @unnumberedsec Pragma Initializes
3836 For the description of this pragma, see SPARK 2014 Reference Manual,
3839 @node Pragma Inline_Always
3840 @unnumberedsec Pragma Inline_Always
3841 @findex Inline_Always
3845 @smallexample @c ada
3846 pragma Inline_Always (NAME [, NAME]);
3850 Similar to pragma @code{Inline} except that inlining is not subject to
3851 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3852 happens regardless of whether these options are used.
3854 @node Pragma Inline_Generic
3855 @unnumberedsec Pragma Inline_Generic
3856 @findex Inline_Generic
3860 @smallexample @c ada
3861 pragma Inline_Generic (GNAME @{, GNAME@});
3863 GNAME ::= generic_unit_NAME | generic_instance_NAME
3867 This pragma is provided for compatibility with Dec Ada 83. It has
3868 no effect in @code{GNAT} (which always inlines generics), other
3869 than to check that the given names are all names of generic units or
3872 @node Pragma Interface
3873 @unnumberedsec Pragma Interface
3878 @smallexample @c ada
3880 [Convention =>] convention_identifier,
3881 [Entity =>] local_NAME
3882 [, [External_Name =>] static_string_expression]
3883 [, [Link_Name =>] static_string_expression]);
3887 This pragma is identical in syntax and semantics to
3888 the standard Ada pragma @code{Import}. It is provided for compatibility
3889 with Ada 83. The definition is upwards compatible both with pragma
3890 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3891 with some extended implementations of this pragma in certain Ada 83
3892 implementations. The only difference between pragma @code{Interface}
3893 and pragma @code{Import} is that there is special circuitry to allow
3894 both pragmas to appear for the same subprogram entity (normally it
3895 is illegal to have multiple @code{Import} pragmas. This is useful in
3896 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3899 @node Pragma Interface_Name
3900 @unnumberedsec Pragma Interface_Name
3901 @findex Interface_Name
3905 @smallexample @c ada
3906 pragma Interface_Name (
3907 [Entity =>] LOCAL_NAME
3908 [, [External_Name =>] static_string_EXPRESSION]
3909 [, [Link_Name =>] static_string_EXPRESSION]);
3913 This pragma provides an alternative way of specifying the interface name
3914 for an interfaced subprogram, and is provided for compatibility with Ada
3915 83 compilers that use the pragma for this purpose. You must provide at
3916 least one of @var{External_Name} or @var{Link_Name}.
3918 @node Pragma Interrupt_Handler
3919 @unnumberedsec Pragma Interrupt_Handler
3920 @findex Interrupt_Handler
3924 @smallexample @c ada
3925 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3929 This program unit pragma is supported for parameterless protected procedures
3930 as described in Annex C of the Ada Reference Manual. On the AAMP target
3931 the pragma can also be specified for nonprotected parameterless procedures
3932 that are declared at the library level (which includes procedures
3933 declared at the top level of a library package). In the case of AAMP,
3934 when this pragma is applied to a nonprotected procedure, the instruction
3935 @code{IERET} is generated for returns from the procedure, enabling
3936 maskable interrupts, in place of the normal return instruction.
3938 @node Pragma Interrupt_State
3939 @unnumberedsec Pragma Interrupt_State
3940 @findex Interrupt_State
3944 @smallexample @c ada
3945 pragma Interrupt_State
3947 [State =>] SYSTEM | RUNTIME | USER);
3951 Normally certain interrupts are reserved to the implementation. Any attempt
3952 to attach an interrupt causes Program_Error to be raised, as described in
3953 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3954 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3955 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3956 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3957 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3958 Ada exceptions, or used to implement run-time functions such as the
3959 @code{abort} statement and stack overflow checking.
3961 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3962 such uses of interrupts. It subsumes the functionality of pragma
3963 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3964 available on Windows or VMS. On all other platforms than VxWorks,
3965 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3966 and may be used to mark interrupts required by the board support package
3969 Interrupts can be in one of three states:
3973 The interrupt is reserved (no Ada handler can be installed), and the
3974 Ada run-time may not install a handler. As a result you are guaranteed
3975 standard system default action if this interrupt is raised.
3979 The interrupt is reserved (no Ada handler can be installed). The run time
3980 is allowed to install a handler for internal control purposes, but is
3981 not required to do so.
3985 The interrupt is unreserved. The user may install a handler to provide
3990 These states are the allowed values of the @code{State} parameter of the
3991 pragma. The @code{Name} parameter is a value of the type
3992 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3993 @code{Ada.Interrupts.Names}.
3995 This is a configuration pragma, and the binder will check that there
3996 are no inconsistencies between different units in a partition in how a
3997 given interrupt is specified. It may appear anywhere a pragma is legal.
3999 The effect is to move the interrupt to the specified state.
4001 By declaring interrupts to be SYSTEM, you guarantee the standard system
4002 action, such as a core dump.
4004 By declaring interrupts to be USER, you guarantee that you can install
4007 Note that certain signals on many operating systems cannot be caught and
4008 handled by applications. In such cases, the pragma is ignored. See the
4009 operating system documentation, or the value of the array @code{Reserved}
4010 declared in the spec of package @code{System.OS_Interface}.
4012 Overriding the default state of signals used by the Ada runtime may interfere
4013 with an application's runtime behavior in the cases of the synchronous signals,
4014 and in the case of the signal used to implement the @code{abort} statement.
4016 @node Pragma Invariant
4017 @unnumberedsec Pragma Invariant
4022 @smallexample @c ada
4024 ([Entity =>] private_type_LOCAL_NAME,
4025 [Check =>] EXPRESSION
4026 [,[Message =>] String_Expression]);
4030 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4031 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4032 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4033 requires the use of the aspect syntax, which is not available except in 2012
4034 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4035 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4036 note that the aspect Invariant is a synonym in GNAT for the aspect
4037 Type_Invariant, but there is no pragma Type_Invariant.
4039 The pragma must appear within the visible part of the package specification,
4040 after the type to which its Entity argument appears. As with the Invariant
4041 aspect, the Check expression is not analyzed until the end of the visible
4042 part of the package, so it may contain forward references. The Message
4043 argument, if present, provides the exception message used if the invariant
4044 is violated. If no Message parameter is provided, a default message that
4045 identifies the line on which the pragma appears is used.
4047 It is permissible to have multiple Invariants for the same type entity, in
4048 which case they are and'ed together. It is permissible to use this pragma
4049 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4050 invariant pragma for the same entity.
4052 For further details on the use of this pragma, see the Ada 2012 documentation
4053 of the Type_Invariant aspect.
4055 @node Pragma Java_Constructor
4056 @unnumberedsec Pragma Java_Constructor
4057 @findex Java_Constructor
4061 @smallexample @c ada
4062 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4066 This pragma is used to assert that the specified Ada function should be
4067 mapped to the Java constructor for some Ada tagged record type.
4069 See section 7.3.2 of the
4070 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4071 for related information.
4073 @node Pragma Java_Interface
4074 @unnumberedsec Pragma Java_Interface
4075 @findex Java_Interface
4079 @smallexample @c ada
4080 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4084 This pragma is used to assert that the specified Ada abstract tagged type
4085 is to be mapped to a Java interface name.
4087 See sections 7.1 and 7.2 of the
4088 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4089 for related information.
4091 @node Pragma Keep_Names
4092 @unnumberedsec Pragma Keep_Names
4097 @smallexample @c ada
4098 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4102 The @var{LOCAL_NAME} argument
4103 must refer to an enumeration first subtype
4104 in the current declarative part. The effect is to retain the enumeration
4105 literal names for use by @code{Image} and @code{Value} even if a global
4106 @code{Discard_Names} pragma applies. This is useful when you want to
4107 generally suppress enumeration literal names and for example you therefore
4108 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4109 want to retain the names for specific enumeration types.
4111 @node Pragma License
4112 @unnumberedsec Pragma License
4114 @cindex License checking
4118 @smallexample @c ada
4119 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4123 This pragma is provided to allow automated checking for appropriate license
4124 conditions with respect to the standard and modified GPL@. A pragma
4125 @code{License}, which is a configuration pragma that typically appears at
4126 the start of a source file or in a separate @file{gnat.adc} file, specifies
4127 the licensing conditions of a unit as follows:
4131 This is used for a unit that can be freely used with no license restrictions.
4132 Examples of such units are public domain units, and units from the Ada
4136 This is used for a unit that is licensed under the unmodified GPL, and which
4137 therefore cannot be @code{with}'ed by a restricted unit.
4140 This is used for a unit licensed under the GNAT modified GPL that includes
4141 a special exception paragraph that specifically permits the inclusion of
4142 the unit in programs without requiring the entire program to be released
4146 This is used for a unit that is restricted in that it is not permitted to
4147 depend on units that are licensed under the GPL@. Typical examples are
4148 proprietary code that is to be released under more restrictive license
4149 conditions. Note that restricted units are permitted to @code{with} units
4150 which are licensed under the modified GPL (this is the whole point of the
4156 Normally a unit with no @code{License} pragma is considered to have an
4157 unknown license, and no checking is done. However, standard GNAT headers
4158 are recognized, and license information is derived from them as follows.
4160 A GNAT license header starts with a line containing 78 hyphens. The following
4161 comment text is searched for the appearance of any of the following strings.
4163 If the string ``GNU General Public License'' is found, then the unit is assumed
4164 to have GPL license, unless the string ``As a special exception'' follows, in
4165 which case the license is assumed to be modified GPL@.
4167 If one of the strings
4168 ``This specification is adapted from the Ada Semantic Interface'' or
4169 ``This specification is derived from the Ada Reference Manual'' is found
4170 then the unit is assumed to be unrestricted.
4173 These default actions means that a program with a restricted license pragma
4174 will automatically get warnings if a GPL unit is inappropriately
4175 @code{with}'ed. For example, the program:
4177 @smallexample @c ada
4180 procedure Secret_Stuff is
4186 if compiled with pragma @code{License} (@code{Restricted}) in a
4187 @file{gnat.adc} file will generate the warning:
4192 >>> license of withed unit "Sem_Ch3" is incompatible
4194 2. with GNAT.Sockets;
4195 3. procedure Secret_Stuff is
4199 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4200 compiler and is licensed under the
4201 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4202 run time, and is therefore licensed under the modified GPL@.
4204 @node Pragma Link_With
4205 @unnumberedsec Pragma Link_With
4210 @smallexample @c ada
4211 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4215 This pragma is provided for compatibility with certain Ada 83 compilers.
4216 It has exactly the same effect as pragma @code{Linker_Options} except
4217 that spaces occurring within one of the string expressions are treated
4218 as separators. For example, in the following case:
4220 @smallexample @c ada
4221 pragma Link_With ("-labc -ldef");
4225 results in passing the strings @code{-labc} and @code{-ldef} as two
4226 separate arguments to the linker. In addition pragma Link_With allows
4227 multiple arguments, with the same effect as successive pragmas.
4229 @node Pragma Linker_Alias
4230 @unnumberedsec Pragma Linker_Alias
4231 @findex Linker_Alias
4235 @smallexample @c ada
4236 pragma Linker_Alias (
4237 [Entity =>] LOCAL_NAME,
4238 [Target =>] static_string_EXPRESSION);
4242 @var{LOCAL_NAME} must refer to an object that is declared at the library
4243 level. This pragma establishes the given entity as a linker alias for the
4244 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4245 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4246 @var{static_string_EXPRESSION} in the object file, that is to say no space
4247 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4248 to the same address as @var{static_string_EXPRESSION} by the linker.
4250 The actual linker name for the target must be used (e.g.@: the fully
4251 encoded name with qualification in Ada, or the mangled name in C++),
4252 or it must be declared using the C convention with @code{pragma Import}
4253 or @code{pragma Export}.
4255 Not all target machines support this pragma. On some of them it is accepted
4256 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4258 @smallexample @c ada
4259 -- Example of the use of pragma Linker_Alias
4263 pragma Export (C, i);
4265 new_name_for_i : Integer;
4266 pragma Linker_Alias (new_name_for_i, "i");
4270 @node Pragma Linker_Constructor
4271 @unnumberedsec Pragma Linker_Constructor
4272 @findex Linker_Constructor
4276 @smallexample @c ada
4277 pragma Linker_Constructor (procedure_LOCAL_NAME);
4281 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4282 is declared at the library level. A procedure to which this pragma is
4283 applied will be treated as an initialization routine by the linker.
4284 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4285 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4286 of the executable is called (or immediately after the shared library is
4287 loaded if the procedure is linked in a shared library), in particular
4288 before the Ada run-time environment is set up.
4290 Because of these specific contexts, the set of operations such a procedure
4291 can perform is very limited and the type of objects it can manipulate is
4292 essentially restricted to the elementary types. In particular, it must only
4293 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4295 This pragma is used by GNAT to implement auto-initialization of shared Stand
4296 Alone Libraries, which provides a related capability without the restrictions
4297 listed above. Where possible, the use of Stand Alone Libraries is preferable
4298 to the use of this pragma.
4300 @node Pragma Linker_Destructor
4301 @unnumberedsec Pragma Linker_Destructor
4302 @findex Linker_Destructor
4306 @smallexample @c ada
4307 pragma Linker_Destructor (procedure_LOCAL_NAME);
4311 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4312 is declared at the library level. A procedure to which this pragma is
4313 applied will be treated as a finalization routine by the linker.
4314 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4315 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4316 of the executable has exited (or immediately before the shared library
4317 is unloaded if the procedure is linked in a shared library), in particular
4318 after the Ada run-time environment is shut down.
4320 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4321 because of these specific contexts.
4323 @node Pragma Linker_Section
4324 @unnumberedsec Pragma Linker_Section
4325 @findex Linker_Section
4329 @smallexample @c ada
4330 pragma Linker_Section (
4331 [Entity =>] LOCAL_NAME,
4332 [Section =>] static_string_EXPRESSION);
4336 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4337 declared at the library level. This pragma specifies the name of the
4338 linker section for the given entity. It is equivalent to
4339 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4340 be placed in the @var{static_string_EXPRESSION} section of the
4341 executable (assuming the linker doesn't rename the section).
4342 GNAT also provides an implementation defined aspect of the same name.
4344 In the case of specifying this aspect for a type, the effect is to
4345 specify the corresponding for all library level objects of the type which
4346 do not have an explicit linker section set. Note that this only applies to
4347 whole objects, not to components of composite objects.
4349 In the case of a subprogram, the linker section applies to all previously
4350 declared matching overloaded subprograms in the current declarative part
4351 which do not already have a linker section assigned. The linker section
4352 aspect is useful in this case for specifying different linker sections
4353 for different elements of such an overloaded set.
4355 Note that an empty string specifies that no linker section is specified.
4356 This is not quite the same as omitting the pragma or aspect, since it
4357 can be used to specify that one element of an overloaded set of subprograms
4358 has the default linker section, or that one object of a type for which a
4359 linker section is specified should has the default linker section.
4361 The compiler normally places library-level entities in standard sections
4362 depending on the class: procedures and functions generally go in the
4363 @code{.text} section, initialized variables in the @code{.data} section
4364 and uninitialized variables in the @code{.bss} section.
4366 Other, special sections may exist on given target machines to map special
4367 hardware, for example I/O ports or flash memory. This pragma is a means to
4368 defer the final layout of the executable to the linker, thus fully working
4369 at the symbolic level with the compiler.
4371 Some file formats do not support arbitrary sections so not all target
4372 machines support this pragma. The use of this pragma may cause a program
4373 execution to be erroneous if it is used to place an entity into an
4374 inappropriate section (e.g.@: a modified variable into the @code{.text}
4375 section). See also @code{pragma Persistent_BSS}.
4377 @smallexample @c ada
4378 -- Example of the use of pragma Linker_Section
4382 pragma Volatile (Port_A);
4383 pragma Linker_Section (Port_A, ".bss.port_a");
4386 pragma Volatile (Port_B);
4387 pragma Linker_Section (Port_B, ".bss.port_b");
4389 type Port_Type is new Integer with Linker_Section => ".bss";
4390 PA : Port_Type with Linker_Section => ".bss.PA";
4391 PB : Port_Type; -- ends up in linker section ".bss"
4393 procedure Q with Linker_Section => "Qsection";
4397 @node Pragma Long_Float
4398 @unnumberedsec Pragma Long_Float
4404 @smallexample @c ada
4405 pragma Long_Float (FLOAT_FORMAT);
4407 FLOAT_FORMAT ::= D_Float | G_Float
4411 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4412 It allows control over the internal representation chosen for the predefined
4413 type @code{Long_Float} and for floating point type representations with
4414 @code{digits} specified in the range 7 through 15.
4415 For further details on this pragma, see the
4416 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4417 this pragma, the standard runtime libraries must be recompiled.
4419 @node Pragma Loop_Invariant
4420 @unnumberedsec Pragma Loop_Invariant
4421 @findex Loop_Invariant
4425 @smallexample @c ada
4426 pragma Loop_Invariant ( boolean_EXPRESSION );
4430 The effect of this pragma is similar to that of pragma @code{Assert},
4431 except that in an @code{Assertion_Policy} pragma, the identifier
4432 @code{Loop_Invariant} is used to control whether it is ignored or checked
4435 @code{Loop_Invariant} can only appear as one of the items in the sequence
4436 of statements of a loop body, or nested inside block statements that
4437 appear in the sequence of statements of a loop body.
4438 The intention is that it be used to
4439 represent a "loop invariant" assertion, i.e. something that is true each
4440 time through the loop, and which can be used to show that the loop is
4441 achieving its purpose.
4443 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4444 apply to the same loop should be grouped in the same sequence of
4447 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4448 may be used to refer to the value of an expression on entry to the loop. This
4449 attribute can only be used within the expression of a @code{Loop_Invariant}
4450 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4452 @node Pragma Loop_Optimize
4453 @unnumberedsec Pragma Loop_Optimize
4454 @findex Loop_Optimize
4458 @smallexample @c ada
4459 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4461 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4465 This pragma must appear immediately within a loop statement. It allows the
4466 programmer to specify optimization hints for the enclosing loop. The hints
4467 are not mutually exclusive and can be freely mixed, but not all combinations
4468 will yield a sensible outcome.
4470 There are five supported optimization hints for a loop:
4475 The programmer asserts that there are no loop-carried dependencies which would prevent consecutive iterations of the loop from being executed simultaneously.
4479 The loop must not be unrolled. This is a strong hint: the compiler will not
4480 unroll a loop marked with this hint.
4484 The loop should be unrolled. This is a weak hint: the compiler will try to
4485 apply unrolling to this loop preferably to other optimizations, notably
4486 vectorization, but there is no guarantee that the loop will be unrolled.
4490 The loop must not be vectorized. This is a strong hint: the compiler will not
4491 vectorize a loop marked with this hint.
4495 The loop should be vectorized. This is a weak hint: the compiler will try to
4496 apply vectorization to this loop preferably to other optimizations, notably
4497 unrolling, but there is no guarantee that the loop will be vectorized.
4501 These hints do not void the need to pass the appropriate switches to the
4502 compiler in order to enable the relevant optimizations, that is to say
4503 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4506 @node Pragma Loop_Variant
4507 @unnumberedsec Pragma Loop_Variant
4508 @findex Loop_Variant
4512 @smallexample @c ada
4513 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4514 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4515 CHANGE_DIRECTION ::= Increases | Decreases
4519 @code{Loop_Variant} can only appear as one of the items in the sequence
4520 of statements of a loop body, or nested inside block statements that
4521 appear in the sequence of statements of a loop body.
4522 It allows the specification of quantities which must always
4523 decrease or increase in successive iterations of the loop. In its simplest
4524 form, just one expression is specified, whose value must increase or decrease
4525 on each iteration of the loop.
4527 In a more complex form, multiple arguments can be given which are intepreted
4528 in a nesting lexicographic manner. For example:
4530 @smallexample @c ada
4531 pragma Loop_Variant (Increases => X, Decreases => Y);
4535 specifies that each time through the loop either X increases, or X stays
4536 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4537 loop is making progress. It can be useful in helping to show informally
4538 or prove formally that the loop always terminates.
4540 @code{Loop_Variant} is an assertion whose effect can be controlled using
4541 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4542 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4543 to ignore the check (in which case the pragma has no effect on the program),
4544 or @code{Disable} in which case the pragma is not even checked for correct
4547 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4548 apply to the same loop should be grouped in the same sequence of
4551 The @code{Loop_Entry} attribute may be used within the expressions of the
4552 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4554 @node Pragma Machine_Attribute
4555 @unnumberedsec Pragma Machine_Attribute
4556 @findex Machine_Attribute
4560 @smallexample @c ada
4561 pragma Machine_Attribute (
4562 [Entity =>] LOCAL_NAME,
4563 [Attribute_Name =>] static_string_EXPRESSION
4564 [, [Info =>] static_EXPRESSION] );
4568 Machine-dependent attributes can be specified for types and/or
4569 declarations. This pragma is semantically equivalent to
4570 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4571 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4572 in GNU C, where @code{@var{attribute_name}} is recognized by the
4573 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4574 specific macro. A string literal for the optional parameter @var{info}
4575 is transformed into an identifier, which may make this pragma unusable
4576 for some attributes. @xref{Target Attributes,, Defining target-specific
4577 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4578 Internals}, further information.
4581 @unnumberedsec Pragma Main
4587 @smallexample @c ada
4589 (MAIN_OPTION [, MAIN_OPTION]);
4592 [Stack_Size =>] static_integer_EXPRESSION
4593 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4594 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4598 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4599 no effect in GNAT, other than being syntax checked.
4601 @node Pragma Main_Storage
4602 @unnumberedsec Pragma Main_Storage
4604 @findex Main_Storage
4608 @smallexample @c ada
4610 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4612 MAIN_STORAGE_OPTION ::=
4613 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4614 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4618 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4619 no effect in GNAT, other than being syntax checked. Note that the pragma
4620 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4622 @node Pragma No_Body
4623 @unnumberedsec Pragma No_Body
4628 @smallexample @c ada
4633 There are a number of cases in which a package spec does not require a body,
4634 and in fact a body is not permitted. GNAT will not permit the spec to be
4635 compiled if there is a body around. The pragma No_Body allows you to provide
4636 a body file, even in a case where no body is allowed. The body file must
4637 contain only comments and a single No_Body pragma. This is recognized by
4638 the compiler as indicating that no body is logically present.
4640 This is particularly useful during maintenance when a package is modified in
4641 such a way that a body needed before is no longer needed. The provision of a
4642 dummy body with a No_Body pragma ensures that there is no interference from
4643 earlier versions of the package body.
4645 @node Pragma No_Inline
4646 @unnumberedsec Pragma No_Inline
4651 @smallexample @c ada
4652 pragma No_Inline (NAME @{, NAME@});
4656 This pragma suppresses inlining for the callable entity or the instances of
4657 the generic subprogram designated by @var{NAME}, including inlining that
4658 results from the use of pragma @code{Inline}. This pragma is always active,
4659 in particular it is not subject to the use of option @option{-gnatn} or
4660 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4661 pragma @code{Inline_Always} for the same @var{NAME}.
4663 @node Pragma No_Return
4664 @unnumberedsec Pragma No_Return
4669 @smallexample @c ada
4670 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4674 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4675 declarations in the current declarative part. A procedure to which this
4676 pragma is applied may not contain any explicit @code{return} statements.
4677 In addition, if the procedure contains any implicit returns from falling
4678 off the end of a statement sequence, then execution of that implicit
4679 return will cause Program_Error to be raised.
4681 One use of this pragma is to identify procedures whose only purpose is to raise
4682 an exception. Another use of this pragma is to suppress incorrect warnings
4683 about missing returns in functions, where the last statement of a function
4684 statement sequence is a call to such a procedure.
4686 Note that in Ada 2005 mode, this pragma is part of the language. It is
4687 available in all earlier versions of Ada as an implementation-defined
4690 @node Pragma No_Run_Time
4691 @unnumberedsec Pragma No_Run_Time
4696 @smallexample @c ada
4701 This is an obsolete configuration pragma that historically was used to
4702 setup what is now called the "zero footprint" library. It causes any
4703 library units outside this basic library to be ignored. The use of
4704 this pragma has been superseded by the general configurable run-time
4705 capability of @code{GNAT} where the compiler takes into account whatever
4706 units happen to be accessible in the library.
4708 @node Pragma No_Strict_Aliasing
4709 @unnumberedsec Pragma No_Strict_Aliasing
4710 @findex No_Strict_Aliasing
4714 @smallexample @c ada
4715 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4719 @var{type_LOCAL_NAME} must refer to an access type
4720 declaration in the current declarative part. The effect is to inhibit
4721 strict aliasing optimization for the given type. The form with no
4722 arguments is a configuration pragma which applies to all access types
4723 declared in units to which the pragma applies. For a detailed
4724 description of the strict aliasing optimization, and the situations
4725 in which it must be suppressed, see @ref{Optimization and Strict
4726 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4728 This pragma currently has no effects on access to unconstrained array types.
4730 @node Pragma Normalize_Scalars
4731 @unnumberedsec Pragma Normalize_Scalars
4732 @findex Normalize_Scalars
4736 @smallexample @c ada
4737 pragma Normalize_Scalars;
4741 This is a language defined pragma which is fully implemented in GNAT@. The
4742 effect is to cause all scalar objects that are not otherwise initialized
4743 to be initialized. The initial values are implementation dependent and
4747 @item Standard.Character
4749 Objects whose root type is Standard.Character are initialized to
4750 Character'Last unless the subtype range excludes NUL (in which case
4751 NUL is used). This choice will always generate an invalid value if
4754 @item Standard.Wide_Character
4756 Objects whose root type is Standard.Wide_Character are initialized to
4757 Wide_Character'Last unless the subtype range excludes NUL (in which case
4758 NUL is used). This choice will always generate an invalid value if
4761 @item Standard.Wide_Wide_Character
4763 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4764 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4765 which case NUL is used). This choice will always generate an invalid value if
4770 Objects of an integer type are treated differently depending on whether
4771 negative values are present in the subtype. If no negative values are
4772 present, then all one bits is used as the initial value except in the
4773 special case where zero is excluded from the subtype, in which case
4774 all zero bits are used. This choice will always generate an invalid
4775 value if one exists.
4777 For subtypes with negative values present, the largest negative number
4778 is used, except in the unusual case where this largest negative number
4779 is in the subtype, and the largest positive number is not, in which case
4780 the largest positive value is used. This choice will always generate
4781 an invalid value if one exists.
4783 @item Floating-Point Types
4784 Objects of all floating-point types are initialized to all 1-bits. For
4785 standard IEEE format, this corresponds to a NaN (not a number) which is
4786 indeed an invalid value.
4788 @item Fixed-Point Types
4789 Objects of all fixed-point types are treated as described above for integers,
4790 with the rules applying to the underlying integer value used to represent
4791 the fixed-point value.
4794 Objects of a modular type are initialized to all one bits, except in
4795 the special case where zero is excluded from the subtype, in which
4796 case all zero bits are used. This choice will always generate an
4797 invalid value if one exists.
4799 @item Enumeration types
4800 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4801 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4802 whose Pos value is zero, in which case a code of zero is used. This choice
4803 will always generate an invalid value if one exists.
4807 @node Pragma Obsolescent
4808 @unnumberedsec Pragma Obsolescent
4813 @smallexample @c ada
4816 pragma Obsolescent (
4817 [Message =>] static_string_EXPRESSION
4818 [,[Version =>] Ada_05]]);
4820 pragma Obsolescent (
4822 [,[Message =>] static_string_EXPRESSION
4823 [,[Version =>] Ada_05]] );
4827 This pragma can occur immediately following a declaration of an entity,
4828 including the case of a record component. If no Entity argument is present,
4829 then this declaration is the one to which the pragma applies. If an Entity
4830 parameter is present, it must either match the name of the entity in this
4831 declaration, or alternatively, the pragma can immediately follow an enumeration
4832 type declaration, where the Entity argument names one of the enumeration
4835 This pragma is used to indicate that the named entity
4836 is considered obsolescent and should not be used. Typically this is
4837 used when an API must be modified by eventually removing or modifying
4838 existing subprograms or other entities. The pragma can be used at an
4839 intermediate stage when the entity is still present, but will be
4842 The effect of this pragma is to output a warning message on a reference to
4843 an entity thus marked that the subprogram is obsolescent if the appropriate
4844 warning option in the compiler is activated. If the Message parameter is
4845 present, then a second warning message is given containing this text. In
4846 addition, a reference to the entity is considered to be a violation of pragma
4847 Restrictions (No_Obsolescent_Features).
4849 This pragma can also be used as a program unit pragma for a package,
4850 in which case the entity name is the name of the package, and the
4851 pragma indicates that the entire package is considered
4852 obsolescent. In this case a client @code{with}'ing such a package
4853 violates the restriction, and the @code{with} statement is
4854 flagged with warnings if the warning option is set.
4856 If the Version parameter is present (which must be exactly
4857 the identifier Ada_05, no other argument is allowed), then the
4858 indication of obsolescence applies only when compiling in Ada 2005
4859 mode. This is primarily intended for dealing with the situations
4860 in the predefined library where subprograms or packages
4861 have become defined as obsolescent in Ada 2005
4862 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4864 The following examples show typical uses of this pragma:
4866 @smallexample @c ada
4868 pragma Obsolescent (p, Message => "use pp instead of p");
4873 pragma Obsolescent ("use q2new instead");
4875 type R is new integer;
4878 Message => "use RR in Ada 2005",
4888 type E is (a, bc, 'd', quack);
4889 pragma Obsolescent (Entity => bc)
4890 pragma Obsolescent (Entity => 'd')
4893 (a, b : character) return character;
4894 pragma Obsolescent (Entity => "+");
4899 Note that, as for all pragmas, if you use a pragma argument identifier,
4900 then all subsequent parameters must also use a pragma argument identifier.
4901 So if you specify "Entity =>" for the Entity argument, and a Message
4902 argument is present, it must be preceded by "Message =>".
4904 @node Pragma Optimize_Alignment
4905 @unnumberedsec Pragma Optimize_Alignment
4906 @findex Optimize_Alignment
4907 @cindex Alignment, default settings
4911 @smallexample @c ada
4912 pragma Optimize_Alignment (TIME | SPACE | OFF);
4916 This is a configuration pragma which affects the choice of default alignments
4917 for types and objects where no alignment is explicitly specified. There is a
4918 time/space trade-off in the selection of these values. Large alignments result
4919 in more efficient code, at the expense of larger data space, since sizes have
4920 to be increased to match these alignments. Smaller alignments save space, but
4921 the access code is slower. The normal choice of default alignments for types
4922 and individual alignment promotions for objects (which is what you get if you
4923 do not use this pragma, or if you use an argument of OFF), tries to balance
4924 these two requirements.
4926 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4927 First any packed record is given an alignment of 1. Second, if a size is given
4928 for the type, then the alignment is chosen to avoid increasing this size. For
4931 @smallexample @c ada
4941 In the default mode, this type gets an alignment of 4, so that access to the
4942 Integer field X are efficient. But this means that objects of the type end up
4943 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4944 allowed to be bigger than the size of the type, but it can waste space if for
4945 example fields of type R appear in an enclosing record. If the above type is
4946 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4948 However, there is one case in which SPACE is ignored. If a variable length
4949 record (that is a discriminated record with a component which is an array
4950 whose length depends on a discriminant), has a pragma Pack, then it is not
4951 in general possible to set the alignment of such a record to one, so the
4952 pragma is ignored in this case (with a warning).
4954 Specifying SPACE also disables alignment promotions for standalone objects,
4955 which occur when the compiler increases the alignment of a specific object
4956 without changing the alignment of its type.
4958 Specifying TIME causes larger default alignments to be chosen in the case of
4959 small types with sizes that are not a power of 2. For example, consider:
4961 @smallexample @c ada
4973 The default alignment for this record is normally 1, but if this type is
4974 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4975 to 4, which wastes space for objects of the type, since they are now 4 bytes
4976 long, but results in more efficient access when the whole record is referenced.
4978 As noted above, this is a configuration pragma, and there is a requirement
4979 that all units in a partition be compiled with a consistent setting of the
4980 optimization setting. This would normally be achieved by use of a configuration
4981 pragma file containing the appropriate setting. The exception to this rule is
4982 that units with an explicit configuration pragma in the same file as the source
4983 unit are excluded from the consistency check, as are all predefined units. The
4984 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4985 pragma appears at the start of the file.
4987 @node Pragma Ordered
4988 @unnumberedsec Pragma Ordered
4990 @findex pragma @code{Ordered}
4994 @smallexample @c ada
4995 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4999 Most enumeration types are from a conceptual point of view unordered.
5000 For example, consider:
5002 @smallexample @c ada
5003 type Color is (Red, Blue, Green, Yellow);
5007 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5008 but really these relations make no sense; the enumeration type merely
5009 specifies a set of possible colors, and the order is unimportant.
5011 For unordered enumeration types, it is generally a good idea if
5012 clients avoid comparisons (other than equality or inequality) and
5013 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5014 other than the unit where the type is declared, its body, and its subunits.)
5015 For example, if code buried in some client says:
5017 @smallexample @c ada
5018 if Current_Color < Yellow then ...
5019 if Current_Color in Blue .. Green then ...
5023 then the client code is relying on the order, which is undesirable.
5024 It makes the code hard to read and creates maintenance difficulties if
5025 entries have to be added to the enumeration type. Instead,
5026 the code in the client should list the possibilities, or an
5027 appropriate subtype should be declared in the unit that declares
5028 the original enumeration type. E.g., the following subtype could
5029 be declared along with the type @code{Color}:
5031 @smallexample @c ada
5032 subtype RBG is Color range Red .. Green;
5036 and then the client could write:
5038 @smallexample @c ada
5039 if Current_Color in RBG then ...
5040 if Current_Color = Blue or Current_Color = Green then ...
5044 However, some enumeration types are legitimately ordered from a conceptual
5045 point of view. For example, if you declare:
5047 @smallexample @c ada
5048 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5052 then the ordering imposed by the language is reasonable, and
5053 clients can depend on it, writing for example:
5055 @smallexample @c ada
5056 if D in Mon .. Fri then ...
5061 The pragma @option{Ordered} is provided to mark enumeration types that
5062 are conceptually ordered, alerting the reader that clients may depend
5063 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5064 rather than one to mark them as unordered, since in our experience,
5065 the great majority of enumeration types are conceptually unordered.
5067 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5068 and @code{Wide_Wide_Character}
5069 are considered to be ordered types, so each is declared with a
5070 pragma @code{Ordered} in package @code{Standard}.
5072 Normally pragma @code{Ordered} serves only as documentation and a guide for
5073 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5074 requests warnings for inappropriate uses (comparisons and explicit
5075 subranges) for unordered types. If this switch is used, then any
5076 enumeration type not marked with pragma @code{Ordered} will be considered
5077 as unordered, and will generate warnings for inappropriate uses.
5079 For additional information please refer to the description of the
5080 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5082 @node Pragma Overflow_Mode
5083 @unnumberedsec Pragma Overflow_Mode
5084 @findex Overflow checks
5085 @findex Overflow mode
5086 @findex pragma @code{Overflow_Mode}
5090 @smallexample @c ada
5091 pragma Overflow_Mode
5093 [,[Assertions =>] MODE]);
5095 MODE ::= STRICT | MINIMIZED | ELIMINATED
5099 This pragma sets the current overflow mode to the given setting. For details
5100 of the meaning of these modes, please refer to the
5101 ``Overflow Check Handling in GNAT'' appendix in the
5102 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5103 the given mode applies to all expressions. If both parameters are present,
5104 the @code{General} mode applies to expressions outside assertions, and
5105 the @code{Eliminated} mode applies to expressions within assertions.
5107 The case of the @code{MODE} parameter is ignored,
5108 so @code{MINIMIZED}, @code{Minimized} and
5109 @code{minimized} all have the same effect.
5111 The @code{Overflow_Mode} pragma has the same scoping and placement
5112 rules as pragma @code{Suppress}, so it can occur either as a
5113 configuration pragma, specifying a default for the whole
5114 program, or in a declarative scope, where it applies to the
5115 remaining declarations and statements in that scope.
5117 The pragma @code{Suppress (Overflow_Check)} suppresses
5118 overflow checking, but does not affect the overflow mode.
5120 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5121 overflow checking, but does not affect the overflow mode.
5123 @node Pragma Overriding_Renamings
5124 @unnumberedsec Pragma Overriding_Renamings
5125 @findex Overriding_Renamings
5126 @cindex Rational profile
5127 @cindex Rational compatibility
5131 @smallexample @c ada
5132 pragma Overriding_Renamings;
5136 This is a GNAT configuration pragma to simplify porting
5137 legacy code accepted by the Rational
5138 Ada compiler. In the presence of this pragma, a renaming declaration that
5139 renames an inherited operation declared in the same scope is legal if selected
5140 notation is used as in:
5142 @smallexample @c ada
5143 pragma Overriding_Renamings;
5148 function F (..) renames R.F;
5153 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5154 declaration of the overriding operation.
5156 @node Pragma Partition_Elaboration_Policy
5157 @unnumberedsec Pragma Partition_Elaboration_Policy
5158 @findex Partition_Elaboration_Policy
5162 @smallexample @c ada
5163 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5165 POLICY_IDENTIFIER ::= Concurrent | Sequential
5169 This pragma is standard in Ada 2005, but is available in all earlier
5170 versions of Ada as an implementation-defined pragma.
5171 See Ada 2012 Reference Manual for details.
5173 @node Pragma Part_Of
5174 @unnumberedsec Pragma Part_Of
5177 For the description of this pragma, see SPARK 2014 Reference Manual,
5180 @node Pragma Passive
5181 @unnumberedsec Pragma Passive
5186 @smallexample @c ada
5187 pragma Passive [(Semaphore | No)];
5191 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
5192 compatibility with DEC Ada 83 implementations, where it is used within a
5193 task definition to request that a task be made passive. If the argument
5194 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5195 treats the pragma as an assertion that the containing task is passive
5196 and that optimization of context switch with this task is permitted and
5197 desired. If the argument @code{No} is present, the task must not be
5198 optimized. GNAT does not attempt to optimize any tasks in this manner
5199 (since protected objects are available in place of passive tasks).
5201 For more information on the subject of passive tasks, see the section
5202 ``Passive Task Optimization'' in the GNAT Users Guide.
5204 @node Pragma Persistent_BSS
5205 @unnumberedsec Pragma Persistent_BSS
5206 @findex Persistent_BSS
5210 @smallexample @c ada
5211 pragma Persistent_BSS [(LOCAL_NAME)]
5215 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5216 section. On some targets the linker and loader provide for special
5217 treatment of this section, allowing a program to be reloaded without
5218 affecting the contents of this data (hence the name persistent).
5220 There are two forms of usage. If an argument is given, it must be the
5221 local name of a library level object, with no explicit initialization
5222 and whose type is potentially persistent. If no argument is given, then
5223 the pragma is a configuration pragma, and applies to all library level
5224 objects with no explicit initialization of potentially persistent types.
5226 A potentially persistent type is a scalar type, or a non-tagged,
5227 non-discriminated record, all of whose components have no explicit
5228 initialization and are themselves of a potentially persistent type,
5229 or an array, all of whose constraints are static, and whose component
5230 type is potentially persistent.
5232 If this pragma is used on a target where this feature is not supported,
5233 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5235 @node Pragma Polling
5236 @unnumberedsec Pragma Polling
5241 @smallexample @c ada
5242 pragma Polling (ON | OFF);
5246 This pragma controls the generation of polling code. This is normally off.
5247 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5248 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
5249 runtime library, and can be found in file @file{a-excpol.adb}.
5251 Pragma @code{Polling} can appear as a configuration pragma (for example it
5252 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5253 can be used in the statement or declaration sequence to control polling
5256 A call to the polling routine is generated at the start of every loop and
5257 at the start of every subprogram call. This guarantees that the @code{Poll}
5258 routine is called frequently, and places an upper bound (determined by
5259 the complexity of the code) on the period between two @code{Poll} calls.
5261 The primary purpose of the polling interface is to enable asynchronous
5262 aborts on targets that cannot otherwise support it (for example Windows
5263 NT), but it may be used for any other purpose requiring periodic polling.
5264 The standard version is null, and can be replaced by a user program. This
5265 will require re-compilation of the @code{Ada.Exceptions} package that can
5266 be found in files @file{a-except.ads} and @file{a-except.adb}.
5268 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5269 distribution) is used to enable the asynchronous abort capability on
5270 targets that do not normally support the capability. The version of
5271 @code{Poll} in this file makes a call to the appropriate runtime routine
5272 to test for an abort condition.
5274 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5275 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5279 @unnumberedsec Pragma Post
5281 @cindex Checks, postconditions
5282 @findex Postconditions
5286 @smallexample @c ada
5287 pragma Post (Boolean_Expression);
5291 The @code{Post} pragma is intended to be an exact replacement for
5292 the language-defined
5293 @code{Post} aspect, and shares its restrictions and semantics.
5294 It must appear either immediately following the corresponding
5295 subprogram declaration (only other pragmas may intervene), or
5296 if there is no separate subprogram declaration, then it can
5297 appear at the start of the declarations in a subprogram body
5298 (preceded only by other pragmas).
5300 @node Pragma Postcondition
5301 @unnumberedsec Pragma Postcondition
5302 @cindex Postcondition
5303 @cindex Checks, postconditions
5304 @findex Postconditions
5308 @smallexample @c ada
5309 pragma Postcondition (
5310 [Check =>] Boolean_Expression
5311 [,[Message =>] String_Expression]);
5315 The @code{Postcondition} pragma allows specification of automatic
5316 postcondition checks for subprograms. These checks are similar to
5317 assertions, but are automatically inserted just prior to the return
5318 statements of the subprogram with which they are associated (including
5319 implicit returns at the end of procedure bodies and associated
5320 exception handlers).
5322 In addition, the boolean expression which is the condition which
5323 must be true may contain references to function'Result in the case
5324 of a function to refer to the returned value.
5326 @code{Postcondition} pragmas may appear either immediately following the
5327 (separate) declaration of a subprogram, or at the start of the
5328 declarations of a subprogram body. Only other pragmas may intervene
5329 (that is appear between the subprogram declaration and its
5330 postconditions, or appear before the postcondition in the
5331 declaration sequence in a subprogram body). In the case of a
5332 postcondition appearing after a subprogram declaration, the
5333 formal arguments of the subprogram are visible, and can be
5334 referenced in the postcondition expressions.
5336 The postconditions are collected and automatically tested just
5337 before any return (implicit or explicit) in the subprogram body.
5338 A postcondition is only recognized if postconditions are active
5339 at the time the pragma is encountered. The compiler switch @option{gnata}
5340 turns on all postconditions by default, and pragma @code{Check_Policy}
5341 with an identifier of @code{Postcondition} can also be used to
5342 control whether postconditions are active.
5344 The general approach is that postconditions are placed in the spec
5345 if they represent functional aspects which make sense to the client.
5346 For example we might have:
5348 @smallexample @c ada
5349 function Direction return Integer;
5350 pragma Postcondition
5351 (Direction'Result = +1
5353 Direction'Result = -1);
5357 which serves to document that the result must be +1 or -1, and
5358 will test that this is the case at run time if postcondition
5361 Postconditions within the subprogram body can be used to
5362 check that some internal aspect of the implementation,
5363 not visible to the client, is operating as expected.
5364 For instance if a square root routine keeps an internal
5365 counter of the number of times it is called, then we
5366 might have the following postcondition:
5368 @smallexample @c ada
5369 Sqrt_Calls : Natural := 0;
5371 function Sqrt (Arg : Float) return Float is
5372 pragma Postcondition
5373 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5379 As this example, shows, the use of the @code{Old} attribute
5380 is often useful in postconditions to refer to the state on
5381 entry to the subprogram.
5383 Note that postconditions are only checked on normal returns
5384 from the subprogram. If an abnormal return results from
5385 raising an exception, then the postconditions are not checked.
5387 If a postcondition fails, then the exception
5388 @code{System.Assertions.Assert_Failure} is raised. If
5389 a message argument was supplied, then the given string
5390 will be used as the exception message. If no message
5391 argument was supplied, then the default message has
5392 the form "Postcondition failed at file:line". The
5393 exception is raised in the context of the subprogram
5394 body, so it is possible to catch postcondition failures
5395 within the subprogram body itself.
5397 Within a package spec, normal visibility rules
5398 in Ada would prevent forward references within a
5399 postcondition pragma to functions defined later in
5400 the same package. This would introduce undesirable
5401 ordering constraints. To avoid this problem, all
5402 postcondition pragmas are analyzed at the end of
5403 the package spec, allowing forward references.
5405 The following example shows that this even allows
5406 mutually recursive postconditions as in:
5408 @smallexample @c ada
5409 package Parity_Functions is
5410 function Odd (X : Natural) return Boolean;
5411 pragma Postcondition
5415 (x /= 0 and then Even (X - 1))));
5417 function Even (X : Natural) return Boolean;
5418 pragma Postcondition
5422 (x /= 1 and then Odd (X - 1))));
5424 end Parity_Functions;
5428 There are no restrictions on the complexity or form of
5429 conditions used within @code{Postcondition} pragmas.
5430 The following example shows that it is even possible
5431 to verify performance behavior.
5433 @smallexample @c ada
5436 Performance : constant Float;
5437 -- Performance constant set by implementation
5438 -- to match target architecture behavior.
5440 procedure Treesort (Arg : String);
5441 -- Sorts characters of argument using N*logN sort
5442 pragma Postcondition
5443 (Float (Clock - Clock'Old) <=
5444 Float (Arg'Length) *
5445 log (Float (Arg'Length)) *
5451 Note: postcondition pragmas associated with subprograms that are
5452 marked as Inline_Always, or those marked as Inline with front-end
5453 inlining (-gnatN option set) are accepted and legality-checked
5454 by the compiler, but are ignored at run-time even if postcondition
5455 checking is enabled.
5457 Note that pragma @code{Postcondition} differs from the language-defined
5458 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5459 multiple occurrences, allowing occurences in the body even if there
5460 is a separate spec, and allowing a second string parameter, and the
5461 use of the pragma identifier @code{Check}. Historically, pragma
5462 @code{Postcondition} was implemented prior to the development of
5463 Ada 2012, and has been retained in its original form for
5464 compatibility purposes.
5466 @node Pragma Post_Class
5467 @unnumberedsec Pragma Post_Class
5469 @cindex Checks, postconditions
5470 @findex Postconditions
5474 @smallexample @c ada
5475 pragma Post_Class (Boolean_Expression);
5479 The @code{Post_Class} pragma is intended to be an exact replacement for
5480 the language-defined
5481 @code{Post'Class} aspect, and shares its restrictions and semantics.
5482 It must appear either immediately following the corresponding
5483 subprogram declaration (only other pragmas may intervene), or
5484 if there is no separate subprogram declaration, then it can
5485 appear at the start of the declarations in a subprogram body
5486 (preceded only by other pragmas).
5488 Note: This pragma is called @code{Post_Class} rather than
5489 @code{Post'Class} because the latter would not be strictly
5490 conforming to the allowed syntax for pragmas. The motivation
5491 for provinding pragmas equivalent to the aspects is to allow a program
5492 to be written using the pragmas, and then compiled if necessary
5493 using an Ada compiler that does not recognize the pragmas or
5494 aspects, but is prepared to ignore the pragmas. The assertion
5495 policy that controls this pragma is @code{Post'Class}, not
5499 @unnumberedsec Pragma Pre
5501 @cindex Checks, preconditions
5502 @findex Preconditions
5506 @smallexample @c ada
5507 pragma Pre (Boolean_Expression);
5511 The @code{Pre} pragma is intended to be an exact replacement for
5512 the language-defined
5513 @code{Pre} aspect, and shares its restrictions and semantics.
5514 It must appear either immediately following the corresponding
5515 subprogram declaration (only other pragmas may intervene), or
5516 if there is no separate subprogram declaration, then it can
5517 appear at the start of the declarations in a subprogram body
5518 (preceded only by other pragmas).
5520 @node Pragma Precondition
5521 @unnumberedsec Pragma Precondition
5522 @cindex Preconditions
5523 @cindex Checks, preconditions
5524 @findex Preconditions
5528 @smallexample @c ada
5529 pragma Precondition (
5530 [Check =>] Boolean_Expression
5531 [,[Message =>] String_Expression]);
5535 The @code{Precondition} pragma is similar to @code{Postcondition}
5536 except that the corresponding checks take place immediately upon
5537 entry to the subprogram, and if a precondition fails, the exception
5538 is raised in the context of the caller, and the attribute 'Result
5539 cannot be used within the precondition expression.
5541 Otherwise, the placement and visibility rules are identical to those
5542 described for postconditions. The following is an example of use
5543 within a package spec:
5545 @smallexample @c ada
5546 package Math_Functions is
5548 function Sqrt (Arg : Float) return Float;
5549 pragma Precondition (Arg >= 0.0)
5555 @code{Precondition} pragmas may appear either immediately following the
5556 (separate) declaration of a subprogram, or at the start of the
5557 declarations of a subprogram body. Only other pragmas may intervene
5558 (that is appear between the subprogram declaration and its
5559 postconditions, or appear before the postcondition in the
5560 declaration sequence in a subprogram body).
5562 Note: precondition pragmas associated with subprograms that are
5563 marked as Inline_Always, or those marked as Inline with front-end
5564 inlining (-gnatN option set) are accepted and legality-checked
5565 by the compiler, but are ignored at run-time even if precondition
5566 checking is enabled.
5568 Note that pragma @code{Precondition} differs from the language-defined
5569 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5570 multiple occurrences, allowing occurences in the body even if there
5571 is a separate spec, and allowing a second string parameter, and the
5572 use of the pragma identifier @code{Check}. Historically, pragma
5573 @code{Precondition} was implemented prior to the development of
5574 Ada 2012, and has been retained in its original form for
5575 compatibility purposes.
5577 @node Pragma Predicate
5578 @unnumberedsec Pragma Predicate
5580 @findex Predicate pragma
5584 @smallexample @c ada
5586 ([Entity =>] type_LOCAL_NAME,
5587 [Check =>] EXPRESSION);
5591 This pragma (available in all versions of Ada in GNAT) encompasses both
5592 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5593 Ada 2012. A predicate is regarded as static if it has an allowed form
5594 for @code{Static_Predicate} and is otherwise treated as a
5595 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5596 pragma behave exactly as described in the Ada 2012 reference manual.
5597 For example, if we have
5599 @smallexample @c ada
5600 type R is range 1 .. 10;
5602 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5604 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5608 the effect is identical to the following Ada 2012 code:
5610 @smallexample @c ada
5611 type R is range 1 .. 10;
5613 Static_Predicate => S not in 4 .. 6;
5615 Dynamic_Predicate => F(Q) or G(Q);
5618 Note that there is are no pragmas @code{Dynamic_Predicate}
5619 or @code{Static_Predicate}. That is
5620 because these pragmas would affect legality and semantics of
5621 the program and thus do not have a neutral effect if ignored.
5622 The motivation behind providing pragmas equivalent to
5623 corresponding aspects is to allow a program to be written
5624 using the pragmas, and then compiled with a compiler that
5625 will ignore the pragmas. That doesn't work in the case of
5626 static and dynamic predicates, since if the corresponding
5627 pragmas are ignored, then the behavior of the program is
5628 fundamentally changed (for example a membership test
5629 @code{A in B} would not take into account a predicate
5630 defined for subtype B). When following this approach, the
5631 use of predicates should be avoided.
5633 @node Pragma Preelaborable_Initialization
5634 @unnumberedsec Pragma Preelaborable_Initialization
5635 @findex Preelaborable_Initialization
5639 @smallexample @c ada
5640 pragma Preelaborable_Initialization (DIRECT_NAME);
5644 This pragma is standard in Ada 2005, but is available in all earlier
5645 versions of Ada as an implementation-defined pragma.
5646 See Ada 2012 Reference Manual for details.
5648 @node Pragma Pre_Class
5649 @unnumberedsec Pragma Pre_Class
5651 @cindex Checks, preconditions
5652 @findex Preconditions
5656 @smallexample @c ada
5657 pragma Pre_Class (Boolean_Expression);
5661 The @code{Pre_Class} pragma is intended to be an exact replacement for
5662 the language-defined
5663 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5664 It must appear either immediately following the corresponding
5665 subprogram declaration (only other pragmas may intervene), or
5666 if there is no separate subprogram declaration, then it can
5667 appear at the start of the declarations in a subprogram body
5668 (preceded only by other pragmas).
5670 Note: This pragma is called @code{Pre_Class} rather than
5671 @code{Pre'Class} because the latter would not be strictly
5672 conforming to the allowed syntax for pragmas. The motivation
5673 for providing pragmas equivalent to the aspects is to allow a program
5674 to be written using the pragmas, and then compiled if necessary
5675 using an Ada compiler that does not recognize the pragmas or
5676 aspects, but is prepared to ignore the pragmas. The assertion
5677 policy that controls this pragma is @code{Pre'Class}, not
5680 @node Pragma Priority_Specific_Dispatching
5681 @unnumberedsec Pragma Priority_Specific_Dispatching
5682 @findex Priority_Specific_Dispatching
5686 @smallexample @c ada
5687 pragma Priority_Specific_Dispatching (
5689 first_priority_EXPRESSION,
5690 last_priority_EXPRESSION)
5692 POLICY_IDENTIFIER ::=
5693 EDF_Across_Priorities |
5694 FIFO_Within_Priorities |
5695 Non_Preemptive_Within_Priorities |
5696 Round_Robin_Within_Priorities
5700 This pragma is standard in Ada 2005, but is available in all earlier
5701 versions of Ada as an implementation-defined pragma.
5702 See Ada 2012 Reference Manual for details.
5704 @node Pragma Profile
5705 @unnumberedsec Pragma Profile
5710 @smallexample @c ada
5711 pragma Profile (Ravenscar | Restricted | Rational);
5715 This pragma is standard in Ada 2005, but is available in all earlier
5716 versions of Ada as an implementation-defined pragma. This is a
5717 configuration pragma that establishes a set of configiuration pragmas
5718 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5719 The other two possibilities (@code{Restricted} or @code{Rational})
5720 are implementation-defined. The set of configuration pragmas
5721 is defined in the following sections.
5725 @item Pragma Profile (Ravenscar)
5729 The @code{Ravenscar} profile is standard in Ada 2005,
5730 but is available in all earlier
5731 versions of Ada as an implementation-defined pragma. This profile
5732 establishes the following set of configuration pragmas:
5735 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5736 [RM D.2.2] Tasks are dispatched following a preemptive
5737 priority-ordered scheduling policy.
5739 @item Locking_Policy (Ceiling_Locking)
5740 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5741 the ceiling priority of the corresponding protected object.
5743 @item Detect_Blocking
5744 This pragma forces the detection of potentially blocking operations within a
5745 protected operation, and to raise Program_Error if that happens.
5749 plus the following set of restrictions:
5752 @item Max_Entry_Queue_Length => 1
5753 No task can be queued on a protected entry.
5754 @item Max_Protected_Entries => 1
5755 @item Max_Task_Entries => 0
5756 No rendezvous statements are allowed.
5757 @item No_Abort_Statements
5758 @item No_Dynamic_Attachment
5759 @item No_Dynamic_Priorities
5760 @item No_Implicit_Heap_Allocations
5761 @item No_Local_Protected_Objects
5762 @item No_Local_Timing_Events
5763 @item No_Protected_Type_Allocators
5764 @item No_Relative_Delay
5765 @item No_Requeue_Statements
5766 @item No_Select_Statements
5767 @item No_Specific_Termination_Handlers
5768 @item No_Task_Allocators
5769 @item No_Task_Hierarchy
5770 @item No_Task_Termination
5771 @item Simple_Barriers
5775 The Ravenscar profile also includes the following restrictions that specify
5776 that there are no semantic dependences on the corresponding predefined
5780 @item No_Dependence => Ada.Asynchronous_Task_Control
5781 @item No_Dependence => Ada.Calendar
5782 @item No_Dependence => Ada.Execution_Time.Group_Budget
5783 @item No_Dependence => Ada.Execution_Time.Timers
5784 @item No_Dependence => Ada.Task_Attributes
5785 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5790 This set of configuration pragmas and restrictions correspond to the
5791 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5792 published by the @cite{International Real-Time Ada Workshop}, 1997,
5793 and whose most recent description is available at
5794 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5796 The original definition of the profile was revised at subsequent IRTAW
5797 meetings. It has been included in the ISO
5798 @cite{Guide for the Use of the Ada Programming Language in High
5799 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5800 the next revision of the standard. The formal definition given by
5801 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5802 AI-305) available at
5803 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5804 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5806 The above set is a superset of the restrictions provided by pragma
5807 @code{Profile (Restricted)}, it includes six additional restrictions
5808 (@code{Simple_Barriers}, @code{No_Select_Statements},
5809 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5810 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5811 that pragma @code{Profile (Ravenscar)}, like the pragma
5812 @code{Profile (Restricted)},
5813 automatically causes the use of a simplified,
5814 more efficient version of the tasking run-time system.
5816 @item Pragma Profile (Restricted)
5817 @findex Restricted Run Time
5819 This profile corresponds to the GNAT restricted run time. It
5820 establishes the following set of restrictions:
5823 @item No_Abort_Statements
5824 @item No_Entry_Queue
5825 @item No_Task_Hierarchy
5826 @item No_Task_Allocators
5827 @item No_Dynamic_Priorities
5828 @item No_Terminate_Alternatives
5829 @item No_Dynamic_Attachment
5830 @item No_Protected_Type_Allocators
5831 @item No_Local_Protected_Objects
5832 @item No_Requeue_Statements
5833 @item No_Task_Attributes_Package
5834 @item Max_Asynchronous_Select_Nesting = 0
5835 @item Max_Task_Entries = 0
5836 @item Max_Protected_Entries = 1
5837 @item Max_Select_Alternatives = 0
5841 This set of restrictions causes the automatic selection of a simplified
5842 version of the run time that provides improved performance for the
5843 limited set of tasking functionality permitted by this set of restrictions.
5845 @item Pragma Profile (Rational)
5846 @findex Rational compatibility mode
5848 The Rational profile is intended to facilitate porting legacy code that
5849 compiles with the Rational APEX compiler, even when the code includes non-
5850 conforming Ada constructs. The profile enables the following three pragmas:
5853 @item pragma Implicit_Packing
5854 @item pragma Overriding_Renamings
5855 @item pragma Use_VADS_Size
5860 @node Pragma Profile_Warnings
5861 @unnumberedsec Pragma Profile_Warnings
5862 @findex Profile_Warnings
5866 @smallexample @c ada
5867 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5871 This is an implementation-defined pragma that is similar in
5872 effect to @code{pragma Profile} except that instead of
5873 generating @code{Restrictions} pragmas, it generates
5874 @code{Restriction_Warnings} pragmas. The result is that
5875 violations of the profile generate warning messages instead
5878 @node Pragma Propagate_Exceptions
5879 @unnumberedsec Pragma Propagate_Exceptions
5880 @cindex Interfacing to C++
5881 @findex Propagate_Exceptions
5885 @smallexample @c ada
5886 pragma Propagate_Exceptions;
5890 This pragma is now obsolete and, other than generating a warning if warnings
5891 on obsolescent features are enabled, is ignored.
5892 It is retained for compatibility
5893 purposes. It used to be used in connection with optimization of
5894 a now-obsolete mechanism for implementation of exceptions.
5896 @node Pragma Provide_Shift_Operators
5897 @unnumberedsec Pragma Provide_Shift_Operators
5898 @cindex Shift operators
5899 @findex Provide_Shift_Operators
5903 @smallexample @c ada
5904 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5908 This pragma can be applied to a first subtype local name that specifies
5909 either an unsigned or signed type. It has the effect of providing the
5910 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5911 Rotate_Left and Rotate_Right) for the given type. It is similar to
5912 including the function declarations for these five operators, together
5913 with the pragma Import (Intrinsic, ...) statements.
5915 @node Pragma Psect_Object
5916 @unnumberedsec Pragma Psect_Object
5917 @findex Psect_Object
5921 @smallexample @c ada
5922 pragma Psect_Object (
5923 [Internal =>] LOCAL_NAME,
5924 [, [External =>] EXTERNAL_SYMBOL]
5925 [, [Size =>] EXTERNAL_SYMBOL]);
5929 | static_string_EXPRESSION
5933 This pragma is identical in effect to pragma @code{Common_Object}.
5935 @node Pragma Pure_Function
5936 @unnumberedsec Pragma Pure_Function
5937 @findex Pure_Function
5941 @smallexample @c ada
5942 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5946 This pragma appears in the same declarative part as a function
5947 declaration (or a set of function declarations if more than one
5948 overloaded declaration exists, in which case the pragma applies
5949 to all entities). It specifies that the function @code{Entity} is
5950 to be considered pure for the purposes of code generation. This means
5951 that the compiler can assume that there are no side effects, and
5952 in particular that two calls with identical arguments produce the
5953 same result. It also means that the function can be used in an
5956 Note that, quite deliberately, there are no static checks to try
5957 to ensure that this promise is met, so @code{Pure_Function} can be used
5958 with functions that are conceptually pure, even if they do modify
5959 global variables. For example, a square root function that is
5960 instrumented to count the number of times it is called is still
5961 conceptually pure, and can still be optimized, even though it
5962 modifies a global variable (the count). Memo functions are another
5963 example (where a table of previous calls is kept and consulted to
5964 avoid re-computation).
5966 Note also that the normal rules excluding optimization of subprograms
5967 in pure units (when parameter types are descended from System.Address,
5968 or when the full view of a parameter type is limited), do not apply
5969 for the Pure_Function case. If you explicitly specify Pure_Function,
5970 the compiler may optimize away calls with identical arguments, and
5971 if that results in unexpected behavior, the proper action is not to
5972 use the pragma for subprograms that are not (conceptually) pure.
5975 Note: Most functions in a @code{Pure} package are automatically pure, and
5976 there is no need to use pragma @code{Pure_Function} for such functions. One
5977 exception is any function that has at least one formal of type
5978 @code{System.Address} or a type derived from it. Such functions are not
5979 considered pure by default, since the compiler assumes that the
5980 @code{Address} parameter may be functioning as a pointer and that the
5981 referenced data may change even if the address value does not.
5982 Similarly, imported functions are not considered to be pure by default,
5983 since there is no way of checking that they are in fact pure. The use
5984 of pragma @code{Pure_Function} for such a function will override these default
5985 assumption, and cause the compiler to treat a designated subprogram as pure
5988 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5989 applies to the underlying renamed function. This can be used to
5990 disambiguate cases of overloading where some but not all functions
5991 in a set of overloaded functions are to be designated as pure.
5993 If pragma @code{Pure_Function} is applied to a library level function, the
5994 function is also considered pure from an optimization point of view, but the
5995 unit is not a Pure unit in the categorization sense. So for example, a function
5996 thus marked is free to @code{with} non-pure units.
5998 @node Pragma Ravenscar
5999 @unnumberedsec Pragma Ravenscar
6000 @findex Pragma Ravenscar
6004 @smallexample @c ada
6009 This pragma is considered obsolescent, but is retained for
6010 compatibility purposes. It is equivalent to:
6012 @smallexample @c ada
6013 pragma Profile (Ravenscar);
6017 which is the preferred method of setting the @code{Ravenscar} profile.
6019 @node Pragma Refined_Depends
6020 @unnumberedsec Pragma Refined_Depends
6021 @findex Refined_Depends
6023 For the description of this pragma, see SPARK 2014 Reference Manual,
6026 @node Pragma Refined_Global
6027 @unnumberedsec Pragma Refined_Global
6028 @findex Refined_Global
6030 For the description of this pragma, see SPARK 2014 Reference Manual,
6033 @node Pragma Refined_Post
6034 @unnumberedsec Pragma Refined_Post
6035 @findex Refined_Post
6037 For the description of this pragma, see SPARK 2014 Reference Manual,
6040 @node Pragma Refined_State
6041 @unnumberedsec Pragma Refined_State
6042 @findex Refined_State
6044 For the description of this pragma, see SPARK 2014 Reference Manual,
6047 @node Pragma Relative_Deadline
6048 @unnumberedsec Pragma Relative_Deadline
6049 @findex Relative_Deadline
6053 @smallexample @c ada
6054 pragma Relative_Deadline (time_span_EXPRESSION);
6058 This pragma is standard in Ada 2005, but is available in all earlier
6059 versions of Ada as an implementation-defined pragma.
6060 See Ada 2012 Reference Manual for details.
6062 @node Pragma Remote_Access_Type
6063 @unnumberedsec Pragma Remote_Access_Type
6064 @findex Remote_Access_Type
6068 @smallexample @c ada
6069 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6073 This pragma appears in the formal part of a generic declaration.
6074 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6075 the use of a remote access to class-wide type as actual for a formal
6078 When this pragma applies to a formal access type @code{Entity}, that
6079 type is treated as a remote access to class-wide type in the generic.
6080 It must be a formal general access type, and its designated type must
6081 be the class-wide type of a formal tagged limited private type from the
6082 same generic declaration.
6084 In the generic unit, the formal type is subject to all restrictions
6085 pertaining to remote access to class-wide types. At instantiation, the
6086 actual type must be a remote access to class-wide type.
6088 @node Pragma Restricted_Run_Time
6089 @unnumberedsec Pragma Restricted_Run_Time
6090 @findex Pragma Restricted_Run_Time
6094 @smallexample @c ada
6095 pragma Restricted_Run_Time;
6099 This pragma is considered obsolescent, but is retained for
6100 compatibility purposes. It is equivalent to:
6102 @smallexample @c ada
6103 pragma Profile (Restricted);
6107 which is the preferred method of setting the restricted run time
6110 @node Pragma Restriction_Warnings
6111 @unnumberedsec Pragma Restriction_Warnings
6112 @findex Restriction_Warnings
6116 @smallexample @c ada
6117 pragma Restriction_Warnings
6118 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6122 This pragma allows a series of restriction identifiers to be
6123 specified (the list of allowed identifiers is the same as for
6124 pragma @code{Restrictions}). For each of these identifiers
6125 the compiler checks for violations of the restriction, but
6126 generates a warning message rather than an error message
6127 if the restriction is violated.
6129 One use of this is in situations where you want to know
6130 about violations of a restriction, but you want to ignore some of
6131 these violations. Consider this example, where you want to set
6132 Ada_95 mode and enable style checks, but you want to know about
6133 any other use of implementation pragmas:
6135 @smallexample @c ada
6136 pragma Restriction_Warnings (No_Implementation_Pragmas);
6137 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6139 pragma Style_Checks ("2bfhkM160");
6140 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6144 By including the above lines in a configuration pragmas file,
6145 the Ada_95 and Style_Checks pragmas are accepted without
6146 generating a warning, but any other use of implementation
6147 defined pragmas will cause a warning to be generated.
6149 @node Pragma Reviewable
6150 @unnumberedsec Pragma Reviewable
6155 @smallexample @c ada
6160 This pragma is an RM-defined standard pragma, but has no effect on the
6161 program being compiled, or on the code generated for the program.
6163 To obtain the required output specified in RM H.3.1, the compiler must be
6164 run with various special switches as follows:
6168 @item Where compiler-generated run-time checks remain
6170 The switch @option{-gnatGL}
6171 @findex @option{-gnatGL}
6172 may be used to list the expanded code in pseudo-Ada form.
6173 Runtime checks show up in the listing either as explicit
6174 checks or operators marked with @{@} to indicate a check is present.
6176 @item An identification of known exceptions at compile time
6178 If the program is compiled with @option{-gnatwa},
6179 @findex @option{-gnatwa}
6180 the compiler warning messages will indicate all cases where the compiler
6181 detects that an exception is certain to occur at run time.
6183 @item Possible reads of uninitialized variables
6185 The compiler warns of many such cases, but its output is incomplete.
6187 The CodePeer analysis tool
6188 @findex CodePeer static analysis tool
6191 A supplemental static analysis tool
6193 may be used to obtain a comprehensive list of all
6194 possible points at which uninitialized data may be read.
6196 @item Where run-time support routines are implicitly invoked
6198 In the output from @option{-gnatGL},
6199 @findex @option{-gnatGL}
6200 run-time calls are explicitly listed as calls to the relevant
6203 @item Object code listing
6205 This may be obtained either by using the @option{-S} switch,
6207 or the objdump utility.
6210 @item Constructs known to be erroneous at compile time
6212 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6213 @findex @option{-gnatwa}
6215 @item Stack usage information
6217 Static stack usage data (maximum per-subprogram) can be obtained via the
6218 @option{-fstack-usage} switch to the compiler.
6219 @findex @option{-fstack-usage}
6220 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6224 The gnatstack utility
6226 can be used to provide additional information on stack usage.
6229 @item Object code listing of entire partition
6231 This can be obtained by compiling the partition with @option{-S},
6233 or by applying objdump
6235 to all the object files that are part of the partition.
6237 @item A description of the run-time model
6239 The full sources of the run-time are available, and the documentation of
6240 these routines describes how these run-time routines interface to the
6241 underlying operating system facilities.
6243 @item Control and data-flow information
6247 @findex CodePeer static analysis tool
6250 A supplemental static analysis tool
6252 may be used to obtain complete control and data-flow information, as well as
6253 comprehensive messages identifying possible problems based on this
6257 @node Pragma Share_Generic
6258 @unnumberedsec Pragma Share_Generic
6259 @findex Share_Generic
6263 @smallexample @c ada
6264 pragma Share_Generic (GNAME @{, GNAME@});
6266 GNAME ::= generic_unit_NAME | generic_instance_NAME
6270 This pragma is provided for compatibility with Dec Ada 83. It has
6271 no effect in @code{GNAT} (which does not implement shared generics), other
6272 than to check that the given names are all names of generic units or
6276 @unnumberedsec Pragma Shared
6280 This pragma is provided for compatibility with Ada 83. The syntax and
6281 semantics are identical to pragma Atomic.
6283 @node Pragma Short_Circuit_And_Or
6284 @unnumberedsec Pragma Short_Circuit_And_Or
6285 @findex Short_Circuit_And_Or
6289 @smallexample @c ada
6290 pragma Short_Circuit_And_Or;
6294 This configuration pragma causes any occurrence of the AND operator applied to
6295 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6296 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6297 may be useful in the context of certification protocols requiring the use of
6298 short-circuited logical operators. If this configuration pragma occurs locally
6299 within the file being compiled, it applies only to the file being compiled.
6300 There is no requirement that all units in a partition use this option.
6302 @node Pragma Short_Descriptors
6303 @unnumberedsec Pragma Short_Descriptors
6304 @findex Short_Descriptors
6308 @smallexample @c ada
6309 pragma Short_Descriptors
6313 In VMS versions of the compiler, this configuration pragma causes all
6314 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6315 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6316 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6319 @node Pragma Simple_Storage_Pool_Type
6320 @unnumberedsec Pragma Simple_Storage_Pool_Type
6321 @findex Simple_Storage_Pool_Type
6322 @cindex Storage pool, simple
6323 @cindex Simple storage pool
6327 @smallexample @c ada
6328 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6332 A type can be established as a ``simple storage pool type'' by applying
6333 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6334 A type named in the pragma must be a library-level immutably limited record
6335 type or limited tagged type declared immediately within a package declaration.
6336 The type can also be a limited private type whose full type is allowed as
6337 a simple storage pool type.
6339 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6340 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6341 are subtype conformant with the following subprogram declarations:
6343 @smallexample @c ada
6346 Storage_Address : out System.Address;
6347 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6348 Alignment : System.Storage_Elements.Storage_Count);
6350 procedure Deallocate
6352 Storage_Address : System.Address;
6353 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6354 Alignment : System.Storage_Elements.Storage_Count);
6356 function Storage_Size (Pool : SSP)
6357 return System.Storage_Elements.Storage_Count;
6361 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6362 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6363 applying an unchecked deallocation has no effect other than to set its actual
6364 parameter to null. If @code{Storage_Size} is not declared, then the
6365 @code{Storage_Size} attribute applied to an access type associated with
6366 a pool object of type SSP returns zero. Additional operations can be declared
6367 for a simple storage pool type (such as for supporting a mark/release
6368 storage-management discipline).
6370 An object of a simple storage pool type can be associated with an access
6371 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6373 @smallexample @c ada
6375 My_Pool : My_Simple_Storage_Pool_Type;
6377 type Acc is access My_Data_Type;
6379 for Acc'Simple_Storage_Pool use My_Pool;
6384 See attribute @code{Simple_Storage_Pool} for further details.
6386 @node Pragma Source_File_Name
6387 @unnumberedsec Pragma Source_File_Name
6388 @findex Source_File_Name
6392 @smallexample @c ada
6393 pragma Source_File_Name (
6394 [Unit_Name =>] unit_NAME,
6395 Spec_File_Name => STRING_LITERAL,
6396 [Index => INTEGER_LITERAL]);
6398 pragma Source_File_Name (
6399 [Unit_Name =>] unit_NAME,
6400 Body_File_Name => STRING_LITERAL,
6401 [Index => INTEGER_LITERAL]);
6405 Use this to override the normal naming convention. It is a configuration
6406 pragma, and so has the usual applicability of configuration pragmas
6407 (i.e.@: it applies to either an entire partition, or to all units in a
6408 compilation, or to a single unit, depending on how it is used.
6409 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
6410 the second argument is required, and indicates whether this is the file
6411 name for the spec or for the body.
6413 The optional Index argument should be used when a file contains multiple
6414 units, and when you do not want to use @code{gnatchop} to separate then
6415 into multiple files (which is the recommended procedure to limit the
6416 number of recompilations that are needed when some sources change).
6417 For instance, if the source file @file{source.ada} contains
6419 @smallexample @c ada
6431 you could use the following configuration pragmas:
6433 @smallexample @c ada
6434 pragma Source_File_Name
6435 (B, Spec_File_Name => "source.ada", Index => 1);
6436 pragma Source_File_Name
6437 (A, Body_File_Name => "source.ada", Index => 2);
6440 Note that the @code{gnatname} utility can also be used to generate those
6441 configuration pragmas.
6443 Another form of the @code{Source_File_Name} pragma allows
6444 the specification of patterns defining alternative file naming schemes
6445 to apply to all files.
6447 @smallexample @c ada
6448 pragma Source_File_Name
6449 ( [Spec_File_Name =>] STRING_LITERAL
6450 [,[Casing =>] CASING_SPEC]
6451 [,[Dot_Replacement =>] STRING_LITERAL]);
6453 pragma Source_File_Name
6454 ( [Body_File_Name =>] STRING_LITERAL
6455 [,[Casing =>] CASING_SPEC]
6456 [,[Dot_Replacement =>] STRING_LITERAL]);
6458 pragma Source_File_Name
6459 ( [Subunit_File_Name =>] STRING_LITERAL
6460 [,[Casing =>] CASING_SPEC]
6461 [,[Dot_Replacement =>] STRING_LITERAL]);
6463 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6467 The first argument is a pattern that contains a single asterisk indicating
6468 the point at which the unit name is to be inserted in the pattern string
6469 to form the file name. The second argument is optional. If present it
6470 specifies the casing of the unit name in the resulting file name string.
6471 The default is lower case. Finally the third argument allows for systematic
6472 replacement of any dots in the unit name by the specified string literal.
6474 Note that Source_File_Name pragmas should not be used if you are using
6475 project files. The reason for this rule is that the project manager is not
6476 aware of these pragmas, and so other tools that use the projet file would not
6477 be aware of the intended naming conventions. If you are using project files,
6478 file naming is controlled by Source_File_Name_Project pragmas, which are
6479 usually supplied automatically by the project manager. A pragma
6480 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6482 For more details on the use of the @code{Source_File_Name} pragma,
6483 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6484 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6487 @node Pragma Source_File_Name_Project
6488 @unnumberedsec Pragma Source_File_Name_Project
6489 @findex Source_File_Name_Project
6492 This pragma has the same syntax and semantics as pragma Source_File_Name.
6493 It is only allowed as a stand alone configuration pragma.
6494 It cannot appear after a @ref{Pragma Source_File_Name}, and
6495 most importantly, once pragma Source_File_Name_Project appears,
6496 no further Source_File_Name pragmas are allowed.
6498 The intention is that Source_File_Name_Project pragmas are always
6499 generated by the Project Manager in a manner consistent with the naming
6500 specified in a project file, and when naming is controlled in this manner,
6501 it is not permissible to attempt to modify this naming scheme using
6502 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6503 known to the project manager).
6505 @node Pragma Source_Reference
6506 @unnumberedsec Pragma Source_Reference
6507 @findex Source_Reference
6511 @smallexample @c ada
6512 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6516 This pragma must appear as the first line of a source file.
6517 @var{integer_literal} is the logical line number of the line following
6518 the pragma line (for use in error messages and debugging
6519 information). @var{string_literal} is a static string constant that
6520 specifies the file name to be used in error messages and debugging
6521 information. This is most notably used for the output of @code{gnatchop}
6522 with the @option{-r} switch, to make sure that the original unchopped
6523 source file is the one referred to.
6525 The second argument must be a string literal, it cannot be a static
6526 string expression other than a string literal. This is because its value
6527 is needed for error messages issued by all phases of the compiler.
6529 @node Pragma SPARK_Mode
6530 @unnumberedsec Pragma SPARK_Mode
6535 @smallexample @c ada
6536 pragma SPARK_Mode [(On | Off)] ;
6540 In general a program can have some parts that are in SPARK 2014 (and
6541 follow all the rules in the SPARK Reference Manual), and some parts
6542 that are full Ada 2012.
6544 The SPARK_Mode pragma is used to identify which parts are in SPARK
6545 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6546 be used in the following places:
6551 As a configuration pragma, in which case it sets the default mode for
6552 all units compiled with this pragma.
6555 Immediately following a library-level subprogram spec
6558 Immediately within a library-level package body
6561 Immediately following the @code{private} keyword of a library-level
6565 Immediately following the @code{begin} keyword of a library-level
6569 Immediately within a library-level subprogram body
6574 Normally a subprogram or package spec/body inherits the current mode
6575 that is active at the point it is declared. But this can be overridden
6576 by pragma within the spec or body as above.
6578 The basic consistency rule is that you can't turn SPARK_Mode back
6579 @code{On}, once you have explicitly (with a pragma) turned if
6580 @code{Off}. So the following rules apply:
6583 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6584 also have SPARK_Mode @code{Off}.
6587 For a package, we have four parts:
6591 the package public declarations
6593 the package private part
6595 the body of the package
6597 the elaboration code after @code{begin}
6601 For a package, the rule is that if you explicitly turn SPARK_Mode
6602 @code{Off} for any part, then all the following parts must have
6603 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6604 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6605 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6606 default everywhere, and one particular package spec has pragma
6607 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6610 @node Pragma Static_Elaboration_Desired
6611 @unnumberedsec Pragma Static_Elaboration_Desired
6612 @findex Static_Elaboration_Desired
6616 @smallexample @c ada
6617 pragma Static_Elaboration_Desired;
6621 This pragma is used to indicate that the compiler should attempt to initialize
6622 statically the objects declared in the library unit to which the pragma applies,
6623 when these objects are initialized (explicitly or implicitly) by an aggregate.
6624 In the absence of this pragma, aggregates in object declarations are expanded
6625 into assignments and loops, even when the aggregate components are static
6626 constants. When the aggregate is present the compiler builds a static expression
6627 that requires no run-time code, so that the initialized object can be placed in
6628 read-only data space. If the components are not static, or the aggregate has
6629 more that 100 components, the compiler emits a warning that the pragma cannot
6630 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6631 construction of larger aggregates with static components that include an others
6634 @node Pragma Stream_Convert
6635 @unnumberedsec Pragma Stream_Convert
6636 @findex Stream_Convert
6640 @smallexample @c ada
6641 pragma Stream_Convert (
6642 [Entity =>] type_LOCAL_NAME,
6643 [Read =>] function_NAME,
6644 [Write =>] function_NAME);
6648 This pragma provides an efficient way of providing user-defined stream
6649 attributes. Not only is it simpler to use than specifying the attributes
6650 directly, but more importantly, it allows the specification to be made in such
6651 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6652 needed (i.e. unless the stream attributes are actually used); the use of
6653 the Stream_Convert pragma adds no overhead at all, unless the stream
6654 attributes are actually used on the designated type.
6656 The first argument specifies the type for which stream functions are
6657 provided. The second parameter provides a function used to read values
6658 of this type. It must name a function whose argument type may be any
6659 subtype, and whose returned type must be the type given as the first
6660 argument to the pragma.
6662 The meaning of the @var{Read} parameter is that if a stream attribute directly
6663 or indirectly specifies reading of the type given as the first parameter,
6664 then a value of the type given as the argument to the Read function is
6665 read from the stream, and then the Read function is used to convert this
6666 to the required target type.
6668 Similarly the @var{Write} parameter specifies how to treat write attributes
6669 that directly or indirectly apply to the type given as the first parameter.
6670 It must have an input parameter of the type specified by the first parameter,
6671 and the return type must be the same as the input type of the Read function.
6672 The effect is to first call the Write function to convert to the given stream
6673 type, and then write the result type to the stream.
6675 The Read and Write functions must not be overloaded subprograms. If necessary
6676 renamings can be supplied to meet this requirement.
6677 The usage of this attribute is best illustrated by a simple example, taken
6678 from the GNAT implementation of package Ada.Strings.Unbounded:
6680 @smallexample @c ada
6681 function To_Unbounded (S : String)
6682 return Unbounded_String
6683 renames To_Unbounded_String;
6685 pragma Stream_Convert
6686 (Unbounded_String, To_Unbounded, To_String);
6690 The specifications of the referenced functions, as given in the Ada
6691 Reference Manual are:
6693 @smallexample @c ada
6694 function To_Unbounded_String (Source : String)
6695 return Unbounded_String;
6697 function To_String (Source : Unbounded_String)
6702 The effect is that if the value of an unbounded string is written to a stream,
6703 then the representation of the item in the stream is in the same format that
6704 would be used for @code{Standard.String'Output}, and this same representation
6705 is expected when a value of this type is read from the stream. Note that the
6706 value written always includes the bounds, even for Unbounded_String'Write,
6707 since Unbounded_String is not an array type.
6709 Note that the @code{Stream_Convert} pragma is not effective in the case of
6710 a derived type of a non-limited tagged type. If such a type is specified then
6711 the pragma is silently ignored, and the default implementation of the stream
6712 attributes is used instead.
6714 @node Pragma Style_Checks
6715 @unnumberedsec Pragma Style_Checks
6716 @findex Style_Checks
6720 @smallexample @c ada
6721 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6722 On | Off [, LOCAL_NAME]);
6726 This pragma is used in conjunction with compiler switches to control the
6727 built in style checking provided by GNAT@. The compiler switches, if set,
6728 provide an initial setting for the switches, and this pragma may be used
6729 to modify these settings, or the settings may be provided entirely by
6730 the use of the pragma. This pragma can be used anywhere that a pragma
6731 is legal, including use as a configuration pragma (including use in
6732 the @file{gnat.adc} file).
6734 The form with a string literal specifies which style options are to be
6735 activated. These are additive, so they apply in addition to any previously
6736 set style check options. The codes for the options are the same as those
6737 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6738 For example the following two methods can be used to enable
6743 @smallexample @c ada
6744 pragma Style_Checks ("l");
6749 gcc -c -gnatyl @dots{}
6754 The form ALL_CHECKS activates all standard checks (its use is equivalent
6755 to the use of the @code{gnaty} switch with no options. @xref{Top,
6756 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6757 @value{EDITION} User's Guide}, for details.)
6759 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6760 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6761 options (i.e. equivalent to -gnatyg).
6763 The forms with @code{Off} and @code{On}
6764 can be used to temporarily disable style checks
6765 as shown in the following example:
6767 @smallexample @c ada
6771 pragma Style_Checks ("k"); -- requires keywords in lower case
6772 pragma Style_Checks (Off); -- turn off style checks
6773 NULL; -- this will not generate an error message
6774 pragma Style_Checks (On); -- turn style checks back on
6775 NULL; -- this will generate an error message
6779 Finally the two argument form is allowed only if the first argument is
6780 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6781 for the specified entity, as shown in the following example:
6783 @smallexample @c ada
6787 pragma Style_Checks ("r"); -- require consistency of identifier casing
6789 Rf1 : Integer := ARG; -- incorrect, wrong case
6790 pragma Style_Checks (Off, Arg);
6791 Rf2 : Integer := ARG; -- OK, no error
6794 @node Pragma Subtitle
6795 @unnumberedsec Pragma Subtitle
6800 @smallexample @c ada
6801 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6805 This pragma is recognized for compatibility with other Ada compilers
6806 but is ignored by GNAT@.
6808 @node Pragma Suppress
6809 @unnumberedsec Pragma Suppress
6814 @smallexample @c ada
6815 pragma Suppress (Identifier [, [On =>] Name]);
6819 This is a standard pragma, and supports all the check names required in
6820 the RM. It is included here because GNAT recognizes some additional check
6821 names that are implementation defined (as permitted by the RM):
6826 @code{Alignment_Check} can be used to suppress alignment checks
6827 on addresses used in address clauses. Such checks can also be suppressed
6828 by suppressing range checks, but the specific use of @code{Alignment_Check}
6829 allows suppression of alignment checks without suppressing other range checks.
6832 @code{Atomic_Synchronization} can be used to suppress the special memory
6833 synchronization instructions that are normally generated for access to
6834 @code{Atomic} variables to ensure correct synchronization between tasks
6835 that use such variables for synchronization purposes.
6838 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6839 for a duplicated tag value when a tagged type is declared.
6842 @code{Predicate_Check} can be used to control whether predicate checks are
6843 active. It is applicable only to predicates for which the policy is
6844 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6845 predicate is ignored or checked for the whole program, the use of
6846 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6847 predicate to be turned on and off at specific points in the program.
6850 @code{Validity_Check} can be used specifically to control validity checks.
6851 If @code{Suppress} is used to suppress validity checks, then no validity
6852 checks are performed, including those specified by the appropriate compiler
6853 switch or the @code{Validity_Checks} pragma.
6856 Additional check names previously introduced by use of the @code{Check_Name}
6857 pragma are also allowed.
6862 Note that pragma Suppress gives the compiler permission to omit
6863 checks, but does not require the compiler to omit checks. The compiler
6864 will generate checks if they are essentially free, even when they are
6865 suppressed. In particular, if the compiler can prove that a certain
6866 check will necessarily fail, it will generate code to do an
6867 unconditional ``raise'', even if checks are suppressed. The compiler
6870 Of course, run-time checks are omitted whenever the compiler can prove
6871 that they will not fail, whether or not checks are suppressed.
6873 @node Pragma Suppress_All
6874 @unnumberedsec Pragma Suppress_All
6875 @findex Suppress_All
6879 @smallexample @c ada
6880 pragma Suppress_All;
6884 This pragma can appear anywhere within a unit.
6885 The effect is to apply @code{Suppress (All_Checks)} to the unit
6886 in which it appears. This pragma is implemented for compatibility with DEC
6887 Ada 83 usage where it appears at the end of a unit, and for compatibility
6888 with Rational Ada, where it appears as a program unit pragma.
6889 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6890 as a normal configuration pragma is the preferred usage in GNAT@.
6892 @node Pragma Suppress_Debug_Info
6893 @unnumberedsec Pragma Suppress_Debug_Info
6894 @findex Suppress_Debug_Info
6898 @smallexample @c ada
6899 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6903 This pragma can be used to suppress generation of debug information
6904 for the specified entity. It is intended primarily for use in debugging
6905 the debugger, and navigating around debugger problems.
6907 @node Pragma Suppress_Exception_Locations
6908 @unnumberedsec Pragma Suppress_Exception_Locations
6909 @findex Suppress_Exception_Locations
6913 @smallexample @c ada
6914 pragma Suppress_Exception_Locations;
6918 In normal mode, a raise statement for an exception by default generates
6919 an exception message giving the file name and line number for the location
6920 of the raise. This is useful for debugging and logging purposes, but this
6921 entails extra space for the strings for the messages. The configuration
6922 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6923 generation of these strings, with the result that space is saved, but the
6924 exception message for such raises is null. This configuration pragma may
6925 appear in a global configuration pragma file, or in a specific unit as
6926 usual. It is not required that this pragma be used consistently within
6927 a partition, so it is fine to have some units within a partition compiled
6928 with this pragma and others compiled in normal mode without it.
6930 @node Pragma Suppress_Initialization
6931 @unnumberedsec Pragma Suppress_Initialization
6932 @findex Suppress_Initialization
6933 @cindex Suppressing initialization
6934 @cindex Initialization, suppression of
6938 @smallexample @c ada
6939 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6943 Here subtype_Name is the name introduced by a type declaration
6944 or subtype declaration.
6945 This pragma suppresses any implicit or explicit initialization
6946 for all variables of the given type or subtype,
6947 including initialization resulting from the use of pragmas
6948 Normalize_Scalars or Initialize_Scalars.
6950 This is considered a representation item, so it cannot be given after
6951 the type is frozen. It applies to all subsequent object declarations,
6952 and also any allocator that creates objects of the type.
6954 If the pragma is given for the first subtype, then it is considered
6955 to apply to the base type and all its subtypes. If the pragma is given
6956 for other than a first subtype, then it applies only to the given subtype.
6957 The pragma may not be given after the type is frozen.
6959 Note that this includes eliminating initialization of discriminants
6960 for discriminated types, and tags for tagged types. In these cases,
6961 you will have to use some non-portable mechanism (e.g. address
6962 overlays or unchecked conversion) to achieve required initialization
6963 of these fields before accessing any object of the corresponding type.
6965 @node Pragma Task_Name
6966 @unnumberedsec Pragma Task_Name
6971 @smallexample @c ada
6972 pragma Task_Name (string_EXPRESSION);
6976 This pragma appears within a task definition (like pragma
6977 @code{Priority}) and applies to the task in which it appears. The
6978 argument must be of type String, and provides a name to be used for
6979 the task instance when the task is created. Note that this expression
6980 is not required to be static, and in particular, it can contain
6981 references to task discriminants. This facility can be used to
6982 provide different names for different tasks as they are created,
6983 as illustrated in the example below.
6985 The task name is recorded internally in the run-time structures
6986 and is accessible to tools like the debugger. In addition the
6987 routine @code{Ada.Task_Identification.Image} will return this
6988 string, with a unique task address appended.
6990 @smallexample @c ada
6991 -- Example of the use of pragma Task_Name
6993 with Ada.Task_Identification;
6994 use Ada.Task_Identification;
6995 with Text_IO; use Text_IO;
6998 type Astring is access String;
7000 task type Task_Typ (Name : access String) is
7001 pragma Task_Name (Name.all);
7004 task body Task_Typ is
7005 Nam : constant String := Image (Current_Task);
7007 Put_Line ("-->" & Nam (1 .. 14) & "<--");
7010 type Ptr_Task is access Task_Typ;
7011 Task_Var : Ptr_Task;
7015 new Task_Typ (new String'("This is task 1"));
7017 new Task_Typ (new String'("This is task 2"));
7021 @node Pragma Task_Storage
7022 @unnumberedsec Pragma Task_Storage
7023 @findex Task_Storage
7026 @smallexample @c ada
7027 pragma Task_Storage (
7028 [Task_Type =>] LOCAL_NAME,
7029 [Top_Guard =>] static_integer_EXPRESSION);
7033 This pragma specifies the length of the guard area for tasks. The guard
7034 area is an additional storage area allocated to a task. A value of zero
7035 means that either no guard area is created or a minimal guard area is
7036 created, depending on the target. This pragma can appear anywhere a
7037 @code{Storage_Size} attribute definition clause is allowed for a task
7040 @node Pragma Test_Case
7041 @unnumberedsec Pragma Test_Case
7047 @smallexample @c ada
7049 [Name =>] static_string_Expression
7050 ,[Mode =>] (Nominal | Robustness)
7051 [, Requires => Boolean_Expression]
7052 [, Ensures => Boolean_Expression]);
7056 The @code{Test_Case} pragma allows defining fine-grain specifications
7057 for use by testing tools.
7058 The compiler checks the validity of the @code{Test_Case} pragma, but its
7059 presence does not lead to any modification of the code generated by the
7062 @code{Test_Case} pragmas may only appear immediately following the
7063 (separate) declaration of a subprogram in a package declaration, inside
7064 a package spec unit. Only other pragmas may intervene (that is appear
7065 between the subprogram declaration and a test case).
7067 The compiler checks that boolean expressions given in @code{Requires} and
7068 @code{Ensures} are valid, where the rules for @code{Requires} are the
7069 same as the rule for an expression in @code{Precondition} and the rules
7070 for @code{Ensures} are the same as the rule for an expression in
7071 @code{Postcondition}. In particular, attributes @code{'Old} and
7072 @code{'Result} can only be used within the @code{Ensures}
7073 expression. The following is an example of use within a package spec:
7075 @smallexample @c ada
7076 package Math_Functions is
7078 function Sqrt (Arg : Float) return Float;
7079 pragma Test_Case (Name => "Test 1",
7081 Requires => Arg < 10000,
7082 Ensures => Sqrt'Result < 10);
7088 The meaning of a test case is that there is at least one context where
7089 @code{Requires} holds such that, if the associated subprogram is executed in
7090 that context, then @code{Ensures} holds when the subprogram returns.
7091 Mode @code{Nominal} indicates that the input context should also satisfy the
7092 precondition of the subprogram, and the output context should also satisfy its
7093 postcondition. More @code{Robustness} indicates that the precondition and
7094 postcondition of the subprogram should be ignored for this test case.
7096 @node Pragma Thread_Local_Storage
7097 @unnumberedsec Pragma Thread_Local_Storage
7098 @findex Thread_Local_Storage
7099 @cindex Task specific storage
7100 @cindex TLS (Thread Local Storage)
7101 @cindex Task_Attributes
7104 @smallexample @c ada
7105 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7109 This pragma specifies that the specified entity, which must be
7110 a variable declared in a library level package, is to be marked as
7111 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7112 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7113 (and hence each Ada task) to see a distinct copy of the variable.
7115 The variable may not have default initialization, and if there is
7116 an explicit initialization, it must be either @code{null} for an
7117 access variable, or a static expression for a scalar variable.
7118 This provides a low level mechanism similar to that provided by
7119 the @code{Ada.Task_Attributes} package, but much more efficient
7120 and is also useful in writing interface code that will interact
7121 with foreign threads.
7123 If this pragma is used on a system where @code{TLS} is not supported,
7124 then an error message will be generated and the program will be rejected.
7126 @node Pragma Time_Slice
7127 @unnumberedsec Pragma Time_Slice
7132 @smallexample @c ada
7133 pragma Time_Slice (static_duration_EXPRESSION);
7137 For implementations of GNAT on operating systems where it is possible
7138 to supply a time slice value, this pragma may be used for this purpose.
7139 It is ignored if it is used in a system that does not allow this control,
7140 or if it appears in other than the main program unit.
7142 Note that the effect of this pragma is identical to the effect of the
7143 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7146 @unnumberedsec Pragma Title
7151 @smallexample @c ada
7152 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7155 [Title =>] STRING_LITERAL,
7156 | [Subtitle =>] STRING_LITERAL
7160 Syntax checked but otherwise ignored by GNAT@. This is a listing control
7161 pragma used in DEC Ada 83 implementations to provide a title and/or
7162 subtitle for the program listing. The program listing generated by GNAT
7163 does not have titles or subtitles.
7165 Unlike other pragmas, the full flexibility of named notation is allowed
7166 for this pragma, i.e.@: the parameters may be given in any order if named
7167 notation is used, and named and positional notation can be mixed
7168 following the normal rules for procedure calls in Ada.
7170 @node Pragma Type_Invariant
7171 @unnumberedsec Pragma Type_Invariant
7173 @findex Type_Invariant pragma
7177 @smallexample @c ada
7178 pragma Type_Invariant
7179 ([Entity =>] type_LOCAL_NAME,
7180 [Check =>] EXPRESSION);
7184 The @code{Type_Invariant} pragma is intended to be an exact
7185 replacement for the language-defined @code{Type_Invariant}
7186 aspect, and shares its restrictions and semantics. It differs
7187 from the language defined @code{Invariant} pragma in that it
7188 does not permit a string parameter, and it is
7189 controlled by the assertion identifier @code{Type_Invariant}
7190 rather than @code{Invariant}.
7192 @node Pragma Type_Invariant_Class
7193 @unnumberedsec Pragma Type_Invariant_Class
7195 @findex Type_Invariant_Class pragma
7199 @smallexample @c ada
7200 pragma Type_Invariant_Class
7201 ([Entity =>] type_LOCAL_NAME,
7202 [Check =>] EXPRESSION);
7206 The @code{Type_Invariant_Class} pragma is intended to be an exact
7207 replacement for the language-defined @code{Type_Invariant'Class}
7208 aspect, and shares its restrictions and semantics.
7210 Note: This pragma is called @code{Type_Invariant_Class} rather than
7211 @code{Type_Invariant'Class} because the latter would not be strictly
7212 conforming to the allowed syntax for pragmas. The motivation
7213 for providing pragmas equivalent to the aspects is to allow a program
7214 to be written using the pragmas, and then compiled if necessary
7215 using an Ada compiler that does not recognize the pragmas or
7216 aspects, but is prepared to ignore the pragmas. The assertion
7217 policy that controls this pragma is @code{Type_Invariant'Class},
7218 not @code{Type_Invariant_Class}.
7220 @node Pragma Unchecked_Union
7221 @unnumberedsec Pragma Unchecked_Union
7223 @findex Unchecked_Union
7227 @smallexample @c ada
7228 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7232 This pragma is used to specify a representation of a record type that is
7233 equivalent to a C union. It was introduced as a GNAT implementation defined
7234 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7235 pragma, making it language defined, and GNAT fully implements this extended
7236 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7237 details, consult the Ada 2012 Reference Manual, section B.3.3.
7239 @node Pragma Unimplemented_Unit
7240 @unnumberedsec Pragma Unimplemented_Unit
7241 @findex Unimplemented_Unit
7245 @smallexample @c ada
7246 pragma Unimplemented_Unit;
7250 If this pragma occurs in a unit that is processed by the compiler, GNAT
7251 aborts with the message @samp{@var{xxx} not implemented}, where
7252 @var{xxx} is the name of the current compilation unit. This pragma is
7253 intended to allow the compiler to handle unimplemented library units in
7256 The abort only happens if code is being generated. Thus you can use
7257 specs of unimplemented packages in syntax or semantic checking mode.
7259 @node Pragma Universal_Aliasing
7260 @unnumberedsec Pragma Universal_Aliasing
7261 @findex Universal_Aliasing
7265 @smallexample @c ada
7266 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7270 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7271 declarative part. The effect is to inhibit strict type-based aliasing
7272 optimization for the given type. In other words, the effect is as though
7273 access types designating this type were subject to pragma No_Strict_Aliasing.
7274 For a detailed description of the strict aliasing optimization, and the
7275 situations in which it must be suppressed, @xref{Optimization and Strict
7276 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7278 @node Pragma Universal_Data
7279 @unnumberedsec Pragma Universal_Data
7280 @findex Universal_Data
7284 @smallexample @c ada
7285 pragma Universal_Data [(library_unit_Name)];
7289 This pragma is supported only for the AAMP target and is ignored for
7290 other targets. The pragma specifies that all library-level objects
7291 (Counter 0 data) associated with the library unit are to be accessed
7292 and updated using universal addressing (24-bit addresses for AAMP5)
7293 rather than the default of 16-bit Data Environment (DENV) addressing.
7294 Use of this pragma will generally result in less efficient code for
7295 references to global data associated with the library unit, but
7296 allows such data to be located anywhere in memory. This pragma is
7297 a library unit pragma, but can also be used as a configuration pragma
7298 (including use in the @file{gnat.adc} file). The functionality
7299 of this pragma is also available by applying the -univ switch on the
7300 compilations of units where universal addressing of the data is desired.
7302 @node Pragma Unmodified
7303 @unnumberedsec Pragma Unmodified
7305 @cindex Warnings, unmodified
7309 @smallexample @c ada
7310 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7314 This pragma signals that the assignable entities (variables,
7315 @code{out} parameters, @code{in out} parameters) whose names are listed are
7316 deliberately not assigned in the current source unit. This
7317 suppresses warnings about the
7318 entities being referenced but not assigned, and in addition a warning will be
7319 generated if one of these entities is in fact assigned in the
7320 same unit as the pragma (or in the corresponding body, or one
7323 This is particularly useful for clearly signaling that a particular
7324 parameter is not modified, even though the spec suggests that it might
7327 For the variable case, warnings are never given for unreferenced variables
7328 whose name contains one of the substrings
7329 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7330 are typically to be used in cases where such warnings are expected.
7331 Thus it is never necessary to use @code{pragma Unmodified} for such
7332 variables, though it is harmless to do so.
7334 @node Pragma Unreferenced
7335 @unnumberedsec Pragma Unreferenced
7336 @findex Unreferenced
7337 @cindex Warnings, unreferenced
7341 @smallexample @c ada
7342 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7343 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7347 This pragma signals that the entities whose names are listed are
7348 deliberately not referenced in the current source unit after the
7349 occurrence of the pragma. This
7350 suppresses warnings about the
7351 entities being unreferenced, and in addition a warning will be
7352 generated if one of these entities is in fact subsequently referenced in the
7353 same unit as the pragma (or in the corresponding body, or one
7356 This is particularly useful for clearly signaling that a particular
7357 parameter is not referenced in some particular subprogram implementation
7358 and that this is deliberate. It can also be useful in the case of
7359 objects declared only for their initialization or finalization side
7362 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7363 current scope, then the entity most recently declared is the one to which
7364 the pragma applies. Note that in the case of accept formals, the pragma
7365 Unreferenced may appear immediately after the keyword @code{do} which
7366 allows the indication of whether or not accept formals are referenced
7367 or not to be given individually for each accept statement.
7369 The left hand side of an assignment does not count as a reference for the
7370 purpose of this pragma. Thus it is fine to assign to an entity for which
7371 pragma Unreferenced is given.
7373 Note that if a warning is desired for all calls to a given subprogram,
7374 regardless of whether they occur in the same unit as the subprogram
7375 declaration, then this pragma should not be used (calls from another
7376 unit would not be flagged); pragma Obsolescent can be used instead
7377 for this purpose, see @xref{Pragma Obsolescent}.
7379 The second form of pragma @code{Unreferenced} is used within a context
7380 clause. In this case the arguments must be unit names of units previously
7381 mentioned in @code{with} clauses (similar to the usage of pragma
7382 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7383 units and unreferenced entities within these units.
7385 For the variable case, warnings are never given for unreferenced variables
7386 whose name contains one of the substrings
7387 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7388 are typically to be used in cases where such warnings are expected.
7389 Thus it is never necessary to use @code{pragma Unreferenced} for such
7390 variables, though it is harmless to do so.
7392 @node Pragma Unreferenced_Objects
7393 @unnumberedsec Pragma Unreferenced_Objects
7394 @findex Unreferenced_Objects
7395 @cindex Warnings, unreferenced
7399 @smallexample @c ada
7400 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7404 This pragma signals that for the types or subtypes whose names are
7405 listed, objects which are declared with one of these types or subtypes may
7406 not be referenced, and if no references appear, no warnings are given.
7408 This is particularly useful for objects which are declared solely for their
7409 initialization and finalization effect. Such variables are sometimes referred
7410 to as RAII variables (Resource Acquisition Is Initialization). Using this
7411 pragma on the relevant type (most typically a limited controlled type), the
7412 compiler will automatically suppress unwanted warnings about these variables
7413 not being referenced.
7415 @node Pragma Unreserve_All_Interrupts
7416 @unnumberedsec Pragma Unreserve_All_Interrupts
7417 @findex Unreserve_All_Interrupts
7421 @smallexample @c ada
7422 pragma Unreserve_All_Interrupts;
7426 Normally certain interrupts are reserved to the implementation. Any attempt
7427 to attach an interrupt causes Program_Error to be raised, as described in
7428 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
7429 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
7430 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7431 interrupt execution.
7433 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7434 a program, then all such interrupts are unreserved. This allows the
7435 program to handle these interrupts, but disables their standard
7436 functions. For example, if this pragma is used, then pressing
7437 @kbd{Ctrl-C} will not automatically interrupt execution. However,
7438 a program can then handle the @code{SIGINT} interrupt as it chooses.
7440 For a full list of the interrupts handled in a specific implementation,
7441 see the source code for the spec of @code{Ada.Interrupts.Names} in
7442 file @file{a-intnam.ads}. This is a target dependent file that contains the
7443 list of interrupts recognized for a given target. The documentation in
7444 this file also specifies what interrupts are affected by the use of
7445 the @code{Unreserve_All_Interrupts} pragma.
7447 For a more general facility for controlling what interrupts can be
7448 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7449 of the @code{Unreserve_All_Interrupts} pragma.
7451 @node Pragma Unsuppress
7452 @unnumberedsec Pragma Unsuppress
7457 @smallexample @c ada
7458 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7462 This pragma undoes the effect of a previous pragma @code{Suppress}. If
7463 there is no corresponding pragma @code{Suppress} in effect, it has no
7464 effect. The range of the effect is the same as for pragma
7465 @code{Suppress}. The meaning of the arguments is identical to that used
7466 in pragma @code{Suppress}.
7468 One important application is to ensure that checks are on in cases where
7469 code depends on the checks for its correct functioning, so that the code
7470 will compile correctly even if the compiler switches are set to suppress
7471 checks. For example, in a program that depends on external names of tagged
7472 types and wants to ensure that the duplicated tag check occurs even if all
7473 run-time checks are suppressed by a compiler switch, the following
7474 configuration pragma will ensure this test is not suppressed:
7476 @smallexample @c ada
7477 pragma Unsuppress (Duplicated_Tag_Check);
7481 This pragma is standard in Ada 2005. It is available in all earlier versions
7482 of Ada as an implementation-defined pragma.
7484 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7485 a number of implementation-defined check names. See description of pragma
7486 @code{Suppress} for full details.
7488 @node Pragma Use_VADS_Size
7489 @unnumberedsec Pragma Use_VADS_Size
7490 @cindex @code{Size}, VADS compatibility
7491 @cindex Rational profile
7492 @findex Use_VADS_Size
7496 @smallexample @c ada
7497 pragma Use_VADS_Size;
7501 This is a configuration pragma. In a unit to which it applies, any use
7502 of the 'Size attribute is automatically interpreted as a use of the
7503 'VADS_Size attribute. Note that this may result in incorrect semantic
7504 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7505 the handling of existing code which depends on the interpretation of Size
7506 as implemented in the VADS compiler. See description of the VADS_Size
7507 attribute for further details.
7509 @node Pragma Validity_Checks
7510 @unnumberedsec Pragma Validity_Checks
7511 @findex Validity_Checks
7515 @smallexample @c ada
7516 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7520 This pragma is used in conjunction with compiler switches to control the
7521 built-in validity checking provided by GNAT@. The compiler switches, if set
7522 provide an initial setting for the switches, and this pragma may be used
7523 to modify these settings, or the settings may be provided entirely by
7524 the use of the pragma. This pragma can be used anywhere that a pragma
7525 is legal, including use as a configuration pragma (including use in
7526 the @file{gnat.adc} file).
7528 The form with a string literal specifies which validity options are to be
7529 activated. The validity checks are first set to include only the default
7530 reference manual settings, and then a string of letters in the string
7531 specifies the exact set of options required. The form of this string
7532 is exactly as described for the @option{-gnatVx} compiler switch (see the
7533 @value{EDITION} User's Guide for details). For example the following two
7534 methods can be used to enable validity checking for mode @code{in} and
7535 @code{in out} subprogram parameters:
7539 @smallexample @c ada
7540 pragma Validity_Checks ("im");
7545 gcc -c -gnatVim @dots{}
7550 The form ALL_CHECKS activates all standard checks (its use is equivalent
7551 to the use of the @code{gnatva} switch.
7553 The forms with @code{Off} and @code{On}
7554 can be used to temporarily disable validity checks
7555 as shown in the following example:
7557 @smallexample @c ada
7561 pragma Validity_Checks ("c"); -- validity checks for copies
7562 pragma Validity_Checks (Off); -- turn off validity checks
7563 A := B; -- B will not be validity checked
7564 pragma Validity_Checks (On); -- turn validity checks back on
7565 A := C; -- C will be validity checked
7568 @node Pragma Volatile
7569 @unnumberedsec Pragma Volatile
7574 @smallexample @c ada
7575 pragma Volatile (LOCAL_NAME);
7579 This pragma is defined by the Ada Reference Manual, and the GNAT
7580 implementation is fully conformant with this definition. The reason it
7581 is mentioned in this section is that a pragma of the same name was supplied
7582 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7583 implementation of pragma Volatile is upwards compatible with the
7584 implementation in DEC Ada 83.
7586 @node Pragma Warning_As_Error
7587 @unnumberedsec Pragma Warning_As_Error
7588 @findex Warning_As_Error
7592 @smallexample @c ada
7593 pragma Warning_As_Error (static_string_EXPRESSION);
7597 This configuration pragma allows the programmer to specify a set
7598 of warnings that will be treated as errors. Any warning which
7599 matches the pattern given by the pragma argument will be treated
7600 as an error. This gives much more precise control that -gnatwe
7601 which treats all warnings as errors.
7603 The pattern may contain asterisks, which match zero or more characters in
7604 the message. For example, you can use
7605 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7606 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7607 expression notations are permitted. All characters other than asterisk in
7608 these three specific cases are treated as literal characters in the match.
7609 The match is case insensitive, for example XYZ matches xyz.
7611 Note that the pattern matches if it occurs anywhere within the warning
7612 message string (it is not necessary to put an asterisk at the start and
7613 the end of the message, since this is implied).
7615 Another possibility for the static_string_EXPRESSION which works whether
7616 or not error tags are enabled (@option{-gnatw.d}) is to use the
7617 @option{-gnatw} tag string, enclosed in brackets,
7618 as shown in the example below, to treat a class of warnings as errors.
7620 The above use of patterns to match the message applies only to warning
7621 messages generated by the front end. This pragma can also be applied to
7622 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7623 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7624 can also be treated as errors.
7626 The pragma can appear either in a global configuration pragma file
7627 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7628 configuration pragma file containing:
7630 @smallexample @c ada
7631 pragma Warning_As_Error ("[-gnatwj]");
7635 which will treat all obsolescent feature warnings as errors, the
7636 following program compiles as shown (compile options here are
7637 @option{-gnatwa.d -gnatl -gnatj55}).
7639 @smallexample @c ada
7640 1. pragma Warning_As_Error ("*never assigned*");
7641 2. function Warnerr return String is
7644 >>> error: variable "X" is never read and
7645 never assigned [-gnatwv] [warning-as-error]
7649 >>> warning: variable "Y" is assigned but
7650 never read [-gnatwu]
7656 >>> error: use of "%" is an obsolescent
7657 feature (RM J.2(4)), use """ instead
7658 [-gnatwj] [warning-as-error]
7662 8 lines: No errors, 3 warnings (2 treated as errors)
7666 Note that this pragma does not affect the set of warnings issued in
7667 any way, it merely changes the effect of a matching warning if one
7668 is produced as a result of other warnings options. As shown in this
7669 example, if the pragma results in a warning being treated as an error,
7670 the tag is changed from "warning:" to "error:" and the string
7671 "[warning-as-error]" is appended to the end of the message.
7673 @node Pragma Warnings
7674 @unnumberedsec Pragma Warnings
7679 @smallexample @c ada
7680 pragma Warnings (On | Off [,REASON]);
7681 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7682 pragma Warnings (static_string_EXPRESSION [,REASON]);
7683 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7685 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7689 Normally warnings are enabled, with the output being controlled by
7690 the command line switch. Warnings (@code{Off}) turns off generation of
7691 warnings until a Warnings (@code{On}) is encountered or the end of the
7692 current unit. If generation of warnings is turned off using this
7693 pragma, then some or all of the warning messages are suppressed,
7694 regardless of the setting of the command line switches.
7696 The @code{Reason} parameter may optionally appear as the last argument
7697 in any of the forms of this pragma. It is intended purely for the
7698 purposes of documenting the reason for the @code{Warnings} pragma.
7699 The compiler will check that the argument is a static string but
7700 otherwise ignore this argument. Other tools may provide specialized
7701 processing for this string.
7703 The form with a single argument (or two arguments if Reason present),
7704 where the first argument is @code{ON} or @code{OFF}
7705 may be used as a configuration pragma.
7707 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7708 the specified entity. This suppression is effective from the point where
7709 it occurs till the end of the extended scope of the variable (similar to
7710 the scope of @code{Suppress}). This form cannot be used as a configuration
7713 The form with a single static_string_EXPRESSION argument (and possible
7714 reason) provides more precise
7715 control over which warnings are active. The string is a list of letters
7716 specifying which warnings are to be activated and which deactivated. The
7717 code for these letters is the same as the string used in the command
7718 line switch controlling warnings. For a brief summary, use the gnatmake
7719 command with no arguments, which will generate usage information containing
7720 the list of warnings switches supported. For
7721 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7722 User's Guide}. This form can also be used as a configuration pragma.
7725 The warnings controlled by the @option{-gnatw} switch are generated by the
7726 front end of the compiler. The GCC back end can provide additional warnings
7727 and they are controlled by the @option{-W} switch. Such warnings can be
7728 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7729 message which designates the @option{-Wxxx} switch that controls the message.
7730 The form with a single static_string_EXPRESSION argument also works for these
7731 warnings, but the string must be a single full @option{-Wxxx} switch in this
7732 case. The above reference lists a few examples of these additional warnings.
7735 The specified warnings will be in effect until the end of the program
7736 or another pragma Warnings is encountered. The effect of the pragma is
7737 cumulative. Initially the set of warnings is the standard default set
7738 as possibly modified by compiler switches. Then each pragma Warning
7739 modifies this set of warnings as specified. This form of the pragma may
7740 also be used as a configuration pragma.
7742 The fourth form, with an @code{On|Off} parameter and a string, is used to
7743 control individual messages, based on their text. The string argument
7744 is a pattern that is used to match against the text of individual
7745 warning messages (not including the initial "warning: " tag).
7747 The pattern may contain asterisks, which match zero or more characters in
7748 the message. For example, you can use
7749 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7750 message @code{warning: 960 bits of "a" unused}. No other regular
7751 expression notations are permitted. All characters other than asterisk in
7752 these three specific cases are treated as literal characters in the match.
7753 The match is case insensitive, for example XYZ matches xyz.
7755 Note that the pattern matches if it occurs anywhere within the warning
7756 message string (it is not necessary to put an asterisk at the start and
7757 the end of the message, since this is implied).
7759 The above use of patterns to match the message applies only to warning
7760 messages generated by the front end. This form of the pragma with a string
7761 argument can also be used to control warnings provided by the back end and
7762 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7763 such warnings can be turned on and off.
7765 There are two ways to use the pragma in this form. The OFF form can be used
7766 as a configuration pragma. The effect is to suppress all warnings (if any)
7767 that match the pattern string throughout the compilation (or match the
7768 -W switch in the back end case).
7770 The second usage is to suppress a warning locally, and in this case, two
7771 pragmas must appear in sequence:
7773 @smallexample @c ada
7774 pragma Warnings (Off, Pattern);
7775 @dots{} code where given warning is to be suppressed
7776 pragma Warnings (On, Pattern);
7780 In this usage, the pattern string must match in the Off and On pragmas,
7781 and at least one matching warning must be suppressed.
7783 Note: to write a string that will match any warning, use the string
7784 @code{"***"}. It will not work to use a single asterisk or two asterisks
7785 since this looks like an operator name. This form with three asterisks
7786 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7787 matching @code{pragma Warnings (On, "***")} will be required. This can be
7788 helpful in avoiding forgetting to turn warnings back on.
7790 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7791 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7792 be useful in checking whether obsolete pragmas in existing programs are hiding
7795 Note: pragma Warnings does not affect the processing of style messages. See
7796 separate entry for pragma Style_Checks for control of style messages.
7798 @node Pragma Weak_External
7799 @unnumberedsec Pragma Weak_External
7800 @findex Weak_External
7804 @smallexample @c ada
7805 pragma Weak_External ([Entity =>] LOCAL_NAME);
7809 @var{LOCAL_NAME} must refer to an object that is declared at the library
7810 level. This pragma specifies that the given entity should be marked as a
7811 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7812 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7813 of a regular symbol, that is to say a symbol that does not have to be
7814 resolved by the linker if used in conjunction with a pragma Import.
7816 When a weak symbol is not resolved by the linker, its address is set to
7817 zero. This is useful in writing interfaces to external modules that may
7818 or may not be linked in the final executable, for example depending on
7819 configuration settings.
7821 If a program references at run time an entity to which this pragma has been
7822 applied, and the corresponding symbol was not resolved at link time, then
7823 the execution of the program is erroneous. It is not erroneous to take the
7824 Address of such an entity, for example to guard potential references,
7825 as shown in the example below.
7827 Some file formats do not support weak symbols so not all target machines
7828 support this pragma.
7830 @smallexample @c ada
7831 -- Example of the use of pragma Weak_External
7833 package External_Module is
7835 pragma Import (C, key);
7836 pragma Weak_External (key);
7837 function Present return boolean;
7838 end External_Module;
7840 with System; use System;
7841 package body External_Module is
7842 function Present return boolean is
7844 return key'Address /= System.Null_Address;
7846 end External_Module;
7849 @node Pragma Wide_Character_Encoding
7850 @unnumberedsec Pragma Wide_Character_Encoding
7851 @findex Wide_Character_Encoding
7855 @smallexample @c ada
7856 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7860 This pragma specifies the wide character encoding to be used in program
7861 source text appearing subsequently. It is a configuration pragma, but may
7862 also be used at any point that a pragma is allowed, and it is permissible
7863 to have more than one such pragma in a file, allowing multiple encodings
7864 to appear within the same file.
7866 The argument can be an identifier or a character literal. In the identifier
7867 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7868 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7869 case it is correspondingly one of the characters @samp{h}, @samp{u},
7870 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7872 Note that when the pragma is used within a file, it affects only the
7873 encoding within that file, and does not affect withed units, specs,
7876 @node Implementation Defined Aspects
7877 @chapter Implementation Defined Aspects
7878 Ada defines (throughout the Ada 2012 reference manual, summarized
7879 in Annex K) a set of aspects that can be specified for certain entities.
7880 These language defined aspects are implemented in GNAT in Ada 2012 mode
7881 and work as described in the Ada 2012 Reference Manual.
7883 In addition, Ada 2012 allows implementations to define additional aspects
7884 whose meaning is defined by the implementation. GNAT provides
7885 a number of these implementation-defined aspects which can be used
7886 to extend and enhance the functionality of the compiler. This section of
7887 the GNAT reference manual describes these additional aspects.
7889 Note that any program using these aspects may not be portable to
7890 other compilers (although GNAT implements this set of aspects on all
7891 platforms). Therefore if portability to other compilers is an important
7892 consideration, you should minimize the use of these aspects.
7894 Note that for many of these aspects, the effect is essentially similar
7895 to the use of a pragma or attribute specification with the same name
7896 applied to the entity. For example, if we write:
7898 @smallexample @c ada
7899 type R is range 1 .. 100
7900 with Value_Size => 10;
7904 then the effect is the same as:
7906 @smallexample @c ada
7907 type R is range 1 .. 100;
7908 for R'Value_Size use 10;
7914 @smallexample @c ada
7915 type R is new Integer
7916 with Shared => True;
7920 then the effect is the same as:
7922 @smallexample @c ada
7923 type R is new Integer;
7928 In the documentation below, such cases are simply marked
7929 as being equivalent to the corresponding pragma or attribute definition
7933 * Aspect Abstract_State::
7934 * Aspect Async_Readers::
7935 * Aspect Async_Writers::
7936 * Aspect Contract_Cases::
7938 * Aspect Dimension::
7939 * Aspect Dimension_System::
7940 * Aspect Effective_Reads::
7941 * Aspect Effective_Writes::
7942 * Aspect Favor_Top_Level::
7944 * Aspect Initial_Condition::
7945 * Aspect Initializes::
7946 * Aspect Inline_Always::
7947 * Aspect Invariant::
7948 * Aspect Linker_Section::
7949 * Aspect Lock_Free::
7950 * Aspect Object_Size::
7952 * Aspect Persistent_BSS::
7953 * Aspect Predicate::
7954 * Aspect Pure_Function::
7955 * Aspect Refined_Depends::
7956 * Aspect Refined_Global::
7957 * Aspect Refined_Post::
7958 * Aspect Refined_State::
7959 * Aspect Remote_Access_Type::
7960 * Aspect Scalar_Storage_Order::
7962 * Aspect Simple_Storage_Pool::
7963 * Aspect Simple_Storage_Pool_Type::
7964 * Aspect SPARK_Mode::
7965 * Aspect Suppress_Debug_Info::
7966 * Aspect Test_Case::
7967 * Aspect Thread_Local_Storage::
7968 * Aspect Universal_Aliasing::
7969 * Aspect Universal_Data::
7970 * Aspect Unmodified::
7971 * Aspect Unreferenced::
7972 * Aspect Unreferenced_Objects::
7973 * Aspect Value_Size::
7977 @node Aspect Abstract_State
7978 @unnumberedsec Aspect Abstract_State
7979 @findex Abstract_State
7981 This aspect is equivalent to pragma @code{Abstract_State}.
7983 @node Aspect Async_Readers
7984 @unnumberedsec Aspect Async_Readers
7985 @findex Async_Readers
7987 This aspect is equivalent to pragma @code{Async_Readers}.
7989 @node Aspect Async_Writers
7990 @unnumberedsec Aspect Async_Writers
7991 @findex Async_Writers
7993 This aspect is equivalent to pragma @code{Async_Writers}.
7995 @node Aspect Contract_Cases
7996 @unnumberedsec Aspect Contract_Cases
7997 @findex Contract_Cases
7999 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8000 of clauses being enclosed in parentheses so that syntactically it is an
8003 @node Aspect Depends
8004 @unnumberedsec Aspect Depends
8007 This aspect is equivalent to pragma @code{Depends}.
8009 @node Aspect Dimension
8010 @unnumberedsec Aspect Dimension
8013 The @code{Dimension} aspect is used to specify the dimensions of a given
8014 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8015 used when doing formatted output of dimensioned quantities. The syntax is:
8017 @smallexample @c ada
8019 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8021 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8025 | others => RATIONAL
8026 | DISCRETE_CHOICE_LIST => RATIONAL
8028 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8032 This aspect can only be applied to a subtype whose parent type has
8033 a @code{Dimension_Systen} aspect. The aspect must specify values for
8034 all dimensions of the system. The rational values are the powers of the
8035 corresponding dimensions that are used by the compiler to verify that
8036 physical (numeric) computations are dimensionally consistent. For example,
8037 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8038 For further examples of the usage
8039 of this aspect, see package @code{System.Dim.Mks}.
8040 Note that when the dimensioned type is an integer type, then any
8041 dimension value must be an integer literal.
8043 @node Aspect Dimension_System
8044 @unnumberedsec Aspect Dimension_System
8045 @findex Dimension_System
8047 The @code{Dimension_System} aspect is used to define a system of
8048 dimensions that will be used in subsequent subtype declarations with
8049 @code{Dimension} aspects that reference this system. The syntax is:
8051 @smallexample @c ada
8052 with Dimension_System => (DIMENSION @{, DIMENSION@});
8054 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
8055 [Unit_Symbol =>] SYMBOL,
8056 [Dim_Symbol =>] SYMBOL)
8058 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8062 This aspect is applied to a type, which must be a numeric derived type
8063 (typically a floating-point type), that
8064 will represent values within the dimension system. Each @code{DIMENSION}
8065 corresponds to one particular dimension. A maximum of 7 dimensions may
8066 be specified. @code{Unit_Name} is the name of the dimension (for example
8067 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8068 of this dimension (for example @code{m} for @code{Meter}).
8069 @code{Dim_Symbol} gives
8070 the identification within the dimension system (typically this is a
8071 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8072 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8073 The @code{Dim_Symbol} is used in error messages when numeric operations have
8074 inconsistent dimensions.
8076 GNAT provides the standard definition of the International MKS system in
8077 the run-time package @code{System.Dim.Mks}. You can easily define
8078 similar packages for cgs units or British units, and define conversion factors
8079 between values in different systems. The MKS system is characterized by the
8082 @smallexample @c ada
8083 type Mks_Type is new Long_Long_Float
8085 Dimension_System => (
8086 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
8087 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
8088 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
8089 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
8090 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
8091 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
8092 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
8096 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8097 Guide for detailed examples of use of the dimension system.
8099 @node Aspect Effective_Reads
8100 @unnumberedsec Aspect Effective_Reads
8101 @findex Effective_Reads
8103 This aspect is equivalent to pragma @code{Effective_Reads}.
8105 @node Aspect Effective_Writes
8106 @unnumberedsec Aspect Effective_Writes
8107 @findex Effective_Writes
8109 This aspect is equivalent to pragma @code{Effective_Writes}.
8111 @node Aspect Favor_Top_Level
8112 @unnumberedsec Aspect Favor_Top_Level
8113 @findex Favor_Top_Level
8115 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8118 @unnumberedsec Aspect Global
8121 This aspect is equivalent to pragma @code{Global}.
8123 @node Aspect Initial_Condition
8124 @unnumberedsec Aspect Initial_Condition
8125 @findex Initial_Condition
8127 This aspect is equivalent to pragma @code{Initial_Condition}.
8129 @node Aspect Initializes
8130 @unnumberedsec Aspect Initializes
8133 This aspect is equivalent to pragma @code{Initializes}.
8135 @node Aspect Inline_Always
8136 @unnumberedsec Aspect Inline_Always
8137 @findex Inline_Always
8139 This aspect is equivalent to pragma @code{Inline_Always}.
8141 @node Aspect Invariant
8142 @unnumberedsec Aspect Invariant
8145 This aspect is equivalent to pragma @code{Invariant}. It is a
8146 synonym for the language defined aspect @code{Type_Invariant} except
8147 that it is separately controllable using pragma @code{Assertion_Policy}.
8149 @node Aspect Linker_Section
8150 @unnumberedsec Aspect Linker_Section
8151 @findex Linker_Section
8153 This aspect is equivalent to an @code{Linker_Section} pragma.
8155 @node Aspect Lock_Free
8156 @unnumberedsec Aspect Lock_Free
8159 This aspect is equivalent to pragma @code{Lock_Free}.
8161 @node Aspect Object_Size
8162 @unnumberedsec Aspect Object_Size
8165 This aspect is equivalent to an @code{Object_Size} attribute definition
8168 @node Aspect Part_Of
8169 @unnumberedsec Aspect Part_Of
8172 This aspect is equivalent to pragma @code{Part_Of}.
8174 @node Aspect Persistent_BSS
8175 @unnumberedsec Aspect Persistent_BSS
8176 @findex Persistent_BSS
8178 This aspect is equivalent to pragma @code{Persistent_BSS}.
8180 @node Aspect Predicate
8181 @unnumberedsec Aspect Predicate
8184 This aspect is equivalent to pragma @code{Predicate}. It is thus
8185 similar to the language defined aspects @code{Dynamic_Predicate}
8186 and @code{Static_Predicate} except that whether the resulting
8187 predicate is static or dynamic is controlled by the form of the
8188 expression. It is also separately controllable using pragma
8189 @code{Assertion_Policy}.
8191 @node Aspect Pure_Function
8192 @unnumberedsec Aspect Pure_Function
8193 @findex Pure_Function
8195 This aspect is equivalent to pragma @code{Pure_Function}.
8197 @node Aspect Refined_Depends
8198 @unnumberedsec Aspect Refined_Depends
8199 @findex Refined_Depends
8201 This aspect is equivalent to pragma @code{Refined_Depends}.
8203 @node Aspect Refined_Global
8204 @unnumberedsec Aspect Refined_Global
8205 @findex Refined_Global
8207 This aspect is equivalent to pragma @code{Refined_Global}.
8209 @node Aspect Refined_Post
8210 @unnumberedsec Aspect Refined_Post
8211 @findex Refined_Post
8213 This aspect is equivalent to pragma @code{Refined_Post}.
8215 @node Aspect Refined_State
8216 @unnumberedsec Aspect Refined_State
8217 @findex Refined_State
8219 This aspect is equivalent to pragma @code{Refined_State}.
8221 @node Aspect Remote_Access_Type
8222 @unnumberedsec Aspect Remote_Access_Type
8223 @findex Remote_Access_Type
8225 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8227 @node Aspect Scalar_Storage_Order
8228 @unnumberedsec Aspect Scalar_Storage_Order
8229 @findex Scalar_Storage_Order
8231 This aspect is equivalent to a @code{Scalar_Storage_Order}
8232 attribute definition clause.
8235 @unnumberedsec Aspect Shared
8238 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8239 for aspect @code{Atomic}.
8241 @node Aspect Simple_Storage_Pool
8242 @unnumberedsec Aspect Simple_Storage_Pool
8243 @findex Simple_Storage_Pool
8245 This aspect is equivalent to a @code{Simple_Storage_Pool}
8246 attribute definition clause.
8248 @node Aspect Simple_Storage_Pool_Type
8249 @unnumberedsec Aspect Simple_Storage_Pool_Type
8250 @findex Simple_Storage_Pool_Type
8252 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8254 @node Aspect SPARK_Mode
8255 @unnumberedsec Aspect SPARK_Mode
8258 This aspect is equivalent to pragma @code{SPARK_Mode} and
8259 may be specified for either or both of the specification and body
8260 of a subprogram or package.
8262 @node Aspect Suppress_Debug_Info
8263 @unnumberedsec Aspect Suppress_Debug_Info
8264 @findex Suppress_Debug_Info
8266 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8268 @node Aspect Test_Case
8269 @unnumberedsec Aspect Test_Case
8272 This aspect is equivalent to pragma @code{Test_Case}.
8274 @node Aspect Thread_Local_Storage
8275 @unnumberedsec Aspect Thread_Local_Storage
8276 @findex Thread_Local_Storage
8278 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8280 @node Aspect Universal_Aliasing
8281 @unnumberedsec Aspect Universal_Aliasing
8282 @findex Universal_Aliasing
8284 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8286 @node Aspect Universal_Data
8287 @unnumberedsec Aspect Universal_Data
8288 @findex Universal_Data
8290 This aspect is equivalent to pragma @code{Universal_Data}.
8292 @node Aspect Unmodified
8293 @unnumberedsec Aspect Unmodified
8296 This aspect is equivalent to pragma @code{Unmodified}.
8298 @node Aspect Unreferenced
8299 @unnumberedsec Aspect Unreferenced
8300 @findex Unreferenced
8302 This aspect is equivalent to pragma @code{Unreferenced}.
8304 @node Aspect Unreferenced_Objects
8305 @unnumberedsec Aspect Unreferenced_Objects
8306 @findex Unreferenced_Objects
8308 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8310 @node Aspect Value_Size
8311 @unnumberedsec Aspect Value_Size
8314 This aspect is equivalent to a @code{Value_Size}
8315 attribute definition clause.
8317 @node Aspect Warnings
8318 @unnumberedsec Aspect Warnings
8321 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8322 where the first argument is @code{ON} or @code{OFF} and the second argument
8326 @node Implementation Defined Attributes
8327 @chapter Implementation Defined Attributes
8328 Ada defines (throughout the Ada reference manual,
8329 summarized in Annex K),
8330 a set of attributes that provide useful additional functionality in all
8331 areas of the language. These language defined attributes are implemented
8332 in GNAT and work as described in the Ada Reference Manual.
8334 In addition, Ada allows implementations to define additional
8335 attributes whose meaning is defined by the implementation. GNAT provides
8336 a number of these implementation-dependent attributes which can be used
8337 to extend and enhance the functionality of the compiler. This section of
8338 the GNAT reference manual describes these additional attributes.
8340 Note that any program using these attributes may not be portable to
8341 other compilers (although GNAT implements this set of attributes on all
8342 platforms). Therefore if portability to other compilers is an important
8343 consideration, you should minimize the use of these attributes.
8346 * Attribute Abort_Signal::
8347 * Attribute Address_Size::
8348 * Attribute Asm_Input::
8349 * Attribute Asm_Output::
8350 * Attribute AST_Entry::
8352 * Attribute Bit_Position::
8353 * Attribute Compiler_Version::
8354 * Attribute Code_Address::
8355 * Attribute Default_Bit_Order::
8356 * Attribute Descriptor_Size::
8357 * Attribute Elaborated::
8358 * Attribute Elab_Body::
8359 * Attribute Elab_Spec::
8360 * Attribute Elab_Subp_Body::
8362 * Attribute Enabled::
8363 * Attribute Enum_Rep::
8364 * Attribute Enum_Val::
8365 * Attribute Epsilon::
8366 * Attribute Fixed_Value::
8367 * Attribute Has_Access_Values::
8368 * Attribute Has_Discriminants::
8370 * Attribute Integer_Value::
8371 * Attribute Invalid_Value::
8373 * Attribute Library_Level::
8374 * Attribute Loop_Entry::
8375 * Attribute Machine_Size::
8376 * Attribute Mantissa::
8377 * Attribute Max_Interrupt_Priority::
8378 * Attribute Max_Priority::
8379 * Attribute Maximum_Alignment::
8380 * Attribute Mechanism_Code::
8381 * Attribute Null_Parameter::
8382 * Attribute Object_Size::
8383 * Attribute Passed_By_Reference::
8384 * Attribute Pool_Address::
8385 * Attribute Range_Length::
8387 * Attribute Restriction_Set::
8388 * Attribute Result::
8389 * Attribute Safe_Emax::
8390 * Attribute Safe_Large::
8391 * Attribute Scalar_Storage_Order::
8392 * Attribute Simple_Storage_Pool::
8394 * Attribute Storage_Unit::
8395 * Attribute Stub_Type::
8396 * Attribute System_Allocator_Alignment::
8397 * Attribute Target_Name::
8399 * Attribute To_Address::
8400 * Attribute Type_Class::
8401 * Attribute UET_Address::
8402 * Attribute Unconstrained_Array::
8403 * Attribute Universal_Literal_String::
8404 * Attribute Unrestricted_Access::
8405 * Attribute Update::
8406 * Attribute Valid_Scalars::
8407 * Attribute VADS_Size::
8408 * Attribute Value_Size::
8409 * Attribute Wchar_T_Size::
8410 * Attribute Word_Size::
8413 @node Attribute Abort_Signal
8414 @unnumberedsec Attribute Abort_Signal
8415 @findex Abort_Signal
8417 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8418 prefix) provides the entity for the special exception used to signal
8419 task abort or asynchronous transfer of control. Normally this attribute
8420 should only be used in the tasking runtime (it is highly peculiar, and
8421 completely outside the normal semantics of Ada, for a user program to
8422 intercept the abort exception).
8424 @node Attribute Address_Size
8425 @unnumberedsec Attribute Address_Size
8426 @cindex Size of @code{Address}
8427 @findex Address_Size
8429 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8430 prefix) is a static constant giving the number of bits in an
8431 @code{Address}. It is the same value as System.Address'Size,
8432 but has the advantage of being static, while a direct
8433 reference to System.Address'Size is non-static because Address
8436 @node Attribute Asm_Input
8437 @unnumberedsec Attribute Asm_Input
8440 The @code{Asm_Input} attribute denotes a function that takes two
8441 parameters. The first is a string, the second is an expression of the
8442 type designated by the prefix. The first (string) argument is required
8443 to be a static expression, and is the constraint for the parameter,
8444 (e.g.@: what kind of register is required). The second argument is the
8445 value to be used as the input argument. The possible values for the
8446 constant are the same as those used in the RTL, and are dependent on
8447 the configuration file used to built the GCC back end.
8448 @ref{Machine Code Insertions}
8450 @node Attribute Asm_Output
8451 @unnumberedsec Attribute Asm_Output
8454 The @code{Asm_Output} attribute denotes a function that takes two
8455 parameters. The first is a string, the second is the name of a variable
8456 of the type designated by the attribute prefix. The first (string)
8457 argument is required to be a static expression and designates the
8458 constraint for the parameter (e.g.@: what kind of register is
8459 required). The second argument is the variable to be updated with the
8460 result. The possible values for constraint are the same as those used in
8461 the RTL, and are dependent on the configuration file used to build the
8462 GCC back end. If there are no output operands, then this argument may
8463 either be omitted, or explicitly given as @code{No_Output_Operands}.
8464 @ref{Machine Code Insertions}
8466 @node Attribute AST_Entry
8467 @unnumberedsec Attribute AST_Entry
8471 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
8472 the name of an entry, it yields a value of the predefined type AST_Handler
8473 (declared in the predefined package System, as extended by the use of
8474 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
8475 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
8476 Language Reference Manual}, section 9.12a.
8479 @unnumberedsec Attribute Bit
8481 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8482 offset within the storage unit (byte) that contains the first bit of
8483 storage allocated for the object. The value of this attribute is of the
8484 type @code{Universal_Integer}, and is always a non-negative number not
8485 exceeding the value of @code{System.Storage_Unit}.
8487 For an object that is a variable or a constant allocated in a register,
8488 the value is zero. (The use of this attribute does not force the
8489 allocation of a variable to memory).
8491 For an object that is a formal parameter, this attribute applies
8492 to either the matching actual parameter or to a copy of the
8493 matching actual parameter.
8495 For an access object the value is zero. Note that
8496 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8497 designated object. Similarly for a record component
8498 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8499 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8500 are subject to index checks.
8502 This attribute is designed to be compatible with the DEC Ada 83 definition
8503 and implementation of the @code{Bit} attribute.
8505 @node Attribute Bit_Position
8506 @unnumberedsec Attribute Bit_Position
8507 @findex Bit_Position
8509 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8510 of the fields of the record type, yields the bit
8511 offset within the record contains the first bit of
8512 storage allocated for the object. The value of this attribute is of the
8513 type @code{Universal_Integer}. The value depends only on the field
8514 @var{C} and is independent of the alignment of
8515 the containing record @var{R}.
8517 @node Attribute Compiler_Version
8518 @unnumberedsec Attribute Compiler_Version
8519 @findex Compiler_Version
8521 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8522 prefix) yields a static string identifying the version of the compiler
8523 being used to compile the unit containing the attribute reference. A
8524 typical result would be something like "@value{EDITION} @i{version} (20090221)".
8526 @node Attribute Code_Address
8527 @unnumberedsec Attribute Code_Address
8528 @findex Code_Address
8529 @cindex Subprogram address
8530 @cindex Address of subprogram code
8533 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8534 intended effect seems to be to provide
8535 an address value which can be used to call the subprogram by means of
8536 an address clause as in the following example:
8538 @smallexample @c ada
8539 procedure K is @dots{}
8542 for L'Address use K'Address;
8543 pragma Import (Ada, L);
8547 A call to @code{L} is then expected to result in a call to @code{K}@.
8548 In Ada 83, where there were no access-to-subprogram values, this was
8549 a common work-around for getting the effect of an indirect call.
8550 GNAT implements the above use of @code{Address} and the technique
8551 illustrated by the example code works correctly.
8553 However, for some purposes, it is useful to have the address of the start
8554 of the generated code for the subprogram. On some architectures, this is
8555 not necessarily the same as the @code{Address} value described above.
8556 For example, the @code{Address} value may reference a subprogram
8557 descriptor rather than the subprogram itself.
8559 The @code{'Code_Address} attribute, which can only be applied to
8560 subprogram entities, always returns the address of the start of the
8561 generated code of the specified subprogram, which may or may not be
8562 the same value as is returned by the corresponding @code{'Address}
8565 @node Attribute Default_Bit_Order
8566 @unnumberedsec Attribute Default_Bit_Order
8568 @cindex Little endian
8569 @findex Default_Bit_Order
8571 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8572 permissible prefix), provides the value @code{System.Default_Bit_Order}
8573 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8574 @code{Low_Order_First}). This is used to construct the definition of
8575 @code{Default_Bit_Order} in package @code{System}.
8577 @node Attribute Descriptor_Size
8578 @unnumberedsec Attribute Descriptor_Size
8581 @findex Descriptor_Size
8583 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8584 descriptor allocated for a type. The result is non-zero only for unconstrained
8585 array types and the returned value is of type universal integer. In GNAT, an
8586 array descriptor contains bounds information and is located immediately before
8587 the first element of the array.
8589 @smallexample @c ada
8590 type Unconstr_Array is array (Positive range <>) of Boolean;
8591 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8595 The attribute takes into account any additional padding due to type alignment.
8596 In the example above, the descriptor contains two values of type
8597 @code{Positive} representing the low and high bound. Since @code{Positive} has
8598 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8599 Positive'Size + 2} or 64 bits.
8601 @node Attribute Elaborated
8602 @unnumberedsec Attribute Elaborated
8605 The prefix of the @code{'Elaborated} attribute must be a unit name. The
8606 value is a Boolean which indicates whether or not the given unit has been
8607 elaborated. This attribute is primarily intended for internal use by the
8608 generated code for dynamic elaboration checking, but it can also be used
8609 in user programs. The value will always be True once elaboration of all
8610 units has been completed. An exception is for units which need no
8611 elaboration, the value is always False for such units.
8613 @node Attribute Elab_Body
8614 @unnumberedsec Attribute Elab_Body
8617 This attribute can only be applied to a program unit name. It returns
8618 the entity for the corresponding elaboration procedure for elaborating
8619 the body of the referenced unit. This is used in the main generated
8620 elaboration procedure by the binder and is not normally used in any
8621 other context. However, there may be specialized situations in which it
8622 is useful to be able to call this elaboration procedure from Ada code,
8623 e.g.@: if it is necessary to do selective re-elaboration to fix some
8626 @node Attribute Elab_Spec
8627 @unnumberedsec Attribute Elab_Spec
8630 This attribute can only be applied to a program unit name. It returns
8631 the entity for the corresponding elaboration procedure for elaborating
8632 the spec of the referenced unit. This is used in the main
8633 generated elaboration procedure by the binder and is not normally used
8634 in any other context. However, there may be specialized situations in
8635 which it is useful to be able to call this elaboration procedure from
8636 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8639 @node Attribute Elab_Subp_Body
8640 @unnumberedsec Attribute Elab_Subp_Body
8641 @findex Elab_Subp_Body
8643 This attribute can only be applied to a library level subprogram
8644 name and is only allowed in CodePeer mode. It returns the entity
8645 for the corresponding elaboration procedure for elaborating the body
8646 of the referenced subprogram unit. This is used in the main generated
8647 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8650 @node Attribute Emax
8651 @unnumberedsec Attribute Emax
8652 @cindex Ada 83 attributes
8655 The @code{Emax} attribute is provided for compatibility with Ada 83. See
8656 the Ada 83 reference manual for an exact description of the semantics of
8659 @node Attribute Enabled
8660 @unnumberedsec Attribute Enabled
8663 The @code{Enabled} attribute allows an application program to check at compile
8664 time to see if the designated check is currently enabled. The prefix is a
8665 simple identifier, referencing any predefined check name (other than
8666 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8667 no argument is given for the attribute, the check is for the general state
8668 of the check, if an argument is given, then it is an entity name, and the
8669 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8670 given naming the entity (if not, then the argument is ignored).
8672 Note that instantiations inherit the check status at the point of the
8673 instantiation, so a useful idiom is to have a library package that
8674 introduces a check name with @code{pragma Check_Name}, and then contains
8675 generic packages or subprograms which use the @code{Enabled} attribute
8676 to see if the check is enabled. A user of this package can then issue
8677 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8678 the package or subprogram, controlling whether the check will be present.
8680 @node Attribute Enum_Rep
8681 @unnumberedsec Attribute Enum_Rep
8682 @cindex Representation of enums
8685 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8686 function with the following spec:
8688 @smallexample @c ada
8689 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8690 return @i{Universal_Integer};
8694 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8695 enumeration type or to a non-overloaded enumeration
8696 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
8697 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8698 enumeration literal or object.
8700 The function returns the representation value for the given enumeration
8701 value. This will be equal to value of the @code{Pos} attribute in the
8702 absence of an enumeration representation clause. This is a static
8703 attribute (i.e.@: the result is static if the argument is static).
8705 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8706 in which case it simply returns the integer value. The reason for this
8707 is to allow it to be used for @code{(<>)} discrete formal arguments in
8708 a generic unit that can be instantiated with either enumeration types
8709 or integer types. Note that if @code{Enum_Rep} is used on a modular
8710 type whose upper bound exceeds the upper bound of the largest signed
8711 integer type, and the argument is a variable, so that the universal
8712 integer calculation is done at run time, then the call to @code{Enum_Rep}
8713 may raise @code{Constraint_Error}.
8715 @node Attribute Enum_Val
8716 @unnumberedsec Attribute Enum_Val
8717 @cindex Representation of enums
8720 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8721 function with the following spec:
8723 @smallexample @c ada
8724 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8725 return @var{S}'Base};
8729 The function returns the enumeration value whose representation matches the
8730 argument, or raises Constraint_Error if no enumeration literal of the type
8731 has the matching value.
8732 This will be equal to value of the @code{Val} attribute in the
8733 absence of an enumeration representation clause. This is a static
8734 attribute (i.e.@: the result is static if the argument is static).
8736 @node Attribute Epsilon
8737 @unnumberedsec Attribute Epsilon
8738 @cindex Ada 83 attributes
8741 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
8742 the Ada 83 reference manual for an exact description of the semantics of
8745 @node Attribute Fixed_Value
8746 @unnumberedsec Attribute Fixed_Value
8749 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8750 function with the following specification:
8752 @smallexample @c ada
8753 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8758 The value returned is the fixed-point value @var{V} such that
8760 @smallexample @c ada
8761 @var{V} = Arg * @var{S}'Small
8765 The effect is thus similar to first converting the argument to the
8766 integer type used to represent @var{S}, and then doing an unchecked
8767 conversion to the fixed-point type. The difference is
8768 that there are full range checks, to ensure that the result is in range.
8769 This attribute is primarily intended for use in implementation of the
8770 input-output functions for fixed-point values.
8772 @node Attribute Has_Access_Values
8773 @unnumberedsec Attribute Has_Access_Values
8774 @cindex Access values, testing for
8775 @findex Has_Access_Values
8777 The prefix of the @code{Has_Access_Values} attribute is a type. The result
8778 is a Boolean value which is True if the is an access type, or is a composite
8779 type with a component (at any nesting depth) that is an access type, and is
8781 The intended use of this attribute is in conjunction with generic
8782 definitions. If the attribute is applied to a generic private type, it
8783 indicates whether or not the corresponding actual type has access values.
8785 @node Attribute Has_Discriminants
8786 @unnumberedsec Attribute Has_Discriminants
8787 @cindex Discriminants, testing for
8788 @findex Has_Discriminants
8790 The prefix of the @code{Has_Discriminants} attribute is a type. The result
8791 is a Boolean value which is True if the type has discriminants, and False
8792 otherwise. The intended use of this attribute is in conjunction with generic
8793 definitions. If the attribute is applied to a generic private type, it
8794 indicates whether or not the corresponding actual type has discriminants.
8797 @unnumberedsec Attribute Img
8800 The @code{Img} attribute differs from @code{Image} in that it is applied
8801 directly to an object, and yields the same result as
8802 @code{Image} for the subtype of the object. This is convenient for
8805 @smallexample @c ada
8806 Put_Line ("X = " & X'Img);
8810 has the same meaning as the more verbose:
8812 @smallexample @c ada
8813 Put_Line ("X = " & @var{T}'Image (X));
8817 where @var{T} is the (sub)type of the object @code{X}.
8819 Note that technically, in analogy to @code{Image},
8820 @code{X'Img} returns a parameterless function
8821 that returns the appropriate string when called. This means that
8822 @code{X'Img} can be renamed as a function-returning-string, or used
8823 in an instantiation as a function parameter.
8825 @node Attribute Integer_Value
8826 @unnumberedsec Attribute Integer_Value
8827 @findex Integer_Value
8829 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8830 function with the following spec:
8832 @smallexample @c ada
8833 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8838 The value returned is the integer value @var{V}, such that
8840 @smallexample @c ada
8841 Arg = @var{V} * @var{T}'Small
8845 where @var{T} is the type of @code{Arg}.
8846 The effect is thus similar to first doing an unchecked conversion from
8847 the fixed-point type to its corresponding implementation type, and then
8848 converting the result to the target integer type. The difference is
8849 that there are full range checks, to ensure that the result is in range.
8850 This attribute is primarily intended for use in implementation of the
8851 standard input-output functions for fixed-point values.
8853 @node Attribute Invalid_Value
8854 @unnumberedsec Attribute Invalid_Value
8855 @findex Invalid_Value
8857 For every scalar type S, S'Invalid_Value returns an undefined value of the
8858 type. If possible this value is an invalid representation for the type. The
8859 value returned is identical to the value used to initialize an otherwise
8860 uninitialized value of the type if pragma Initialize_Scalars is used,
8861 including the ability to modify the value with the binder -Sxx flag and
8862 relevant environment variables at run time.
8864 @node Attribute Large
8865 @unnumberedsec Attribute Large
8866 @cindex Ada 83 attributes
8869 The @code{Large} attribute is provided for compatibility with Ada 83. See
8870 the Ada 83 reference manual for an exact description of the semantics of
8873 @node Attribute Library_Level
8874 @unnumberedsec Attribute Library_Level
8875 @findex Library_Level
8878 @code{P'Library_Level}, where P is an entity name,
8879 returns a Boolean value which is True if the entity is declared
8880 at the library level, and False otherwise. Note that within a
8881 generic instantition, the name of the generic unit denotes the
8882 instance, which means that this attribute can be used to test
8883 if a generic is instantiated at the library level, as shown
8886 @smallexample @c ada
8890 pragma Compile_Time_Error
8891 (not Gen'Library_Level,
8892 "Gen can only be instantiated at library level");
8897 @node Attribute Loop_Entry
8898 @unnumberedsec Attribute Loop_Entry
8903 @smallexample @c ada
8904 X'Loop_Entry [(loop_name)]
8908 The @code{Loop_Entry} attribute is used to refer to the value that an
8909 expression had upon entry to a given loop in much the same way that the
8910 @code{Old} attribute in a subprogram postcondition can be used to refer
8911 to the value an expression had upon entry to the subprogram. The
8912 relevant loop is either identified by the given loop name, or it is the
8913 innermost enclosing loop when no loop name is given.
8916 A @code{Loop_Entry} attribute can only occur within a
8917 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8918 @code{Loop_Entry} is to compare the current value of objects with their
8919 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8922 The effect of using @code{X'Loop_Entry} is the same as declaring
8923 a constant initialized with the initial value of @code{X} at loop
8924 entry. This copy is not performed if the loop is not entered, or if the
8925 corresponding pragmas are ignored or disabled.
8927 @node Attribute Machine_Size
8928 @unnumberedsec Attribute Machine_Size
8929 @findex Machine_Size
8931 This attribute is identical to the @code{Object_Size} attribute. It is
8932 provided for compatibility with the DEC Ada 83 attribute of this name.
8934 @node Attribute Mantissa
8935 @unnumberedsec Attribute Mantissa
8936 @cindex Ada 83 attributes
8939 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8940 the Ada 83 reference manual for an exact description of the semantics of
8943 @node Attribute Max_Interrupt_Priority
8944 @unnumberedsec Attribute Max_Interrupt_Priority
8945 @cindex Interrupt priority, maximum
8946 @findex Max_Interrupt_Priority
8948 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8949 permissible prefix), provides the same value as
8950 @code{System.Max_Interrupt_Priority}.
8952 @node Attribute Max_Priority
8953 @unnumberedsec Attribute Max_Priority
8954 @cindex Priority, maximum
8955 @findex Max_Priority
8957 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8958 prefix) provides the same value as @code{System.Max_Priority}.
8960 @node Attribute Maximum_Alignment
8961 @unnumberedsec Attribute Maximum_Alignment
8962 @cindex Alignment, maximum
8963 @findex Maximum_Alignment
8965 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8966 permissible prefix) provides the maximum useful alignment value for the
8967 target. This is a static value that can be used to specify the alignment
8968 for an object, guaranteeing that it is properly aligned in all
8971 @node Attribute Mechanism_Code
8972 @unnumberedsec Attribute Mechanism_Code
8973 @cindex Return values, passing mechanism
8974 @cindex Parameters, passing mechanism
8975 @findex Mechanism_Code
8977 @code{@var{function}'Mechanism_Code} yields an integer code for the
8978 mechanism used for the result of function, and
8979 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8980 used for formal parameter number @var{n} (a static integer value with 1
8981 meaning the first parameter) of @var{subprogram}. The code returned is:
8989 by descriptor (default descriptor class)
8991 by descriptor (UBS: unaligned bit string)
8993 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8995 by descriptor (UBA: unaligned bit array)
8997 by descriptor (S: string, also scalar access type parameter)
8999 by descriptor (SB: string with arbitrary bounds)
9001 by descriptor (A: contiguous array)
9003 by descriptor (NCA: non-contiguous array)
9007 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
9010 @node Attribute Null_Parameter
9011 @unnumberedsec Attribute Null_Parameter
9012 @cindex Zero address, passing
9013 @findex Null_Parameter
9015 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9016 type or subtype @var{T} allocated at machine address zero. The attribute
9017 is allowed only as the default expression of a formal parameter, or as
9018 an actual expression of a subprogram call. In either case, the
9019 subprogram must be imported.
9021 The identity of the object is represented by the address zero in the
9022 argument list, independent of the passing mechanism (explicit or
9025 This capability is needed to specify that a zero address should be
9026 passed for a record or other composite object passed by reference.
9027 There is no way of indicating this without the @code{Null_Parameter}
9030 @node Attribute Object_Size
9031 @unnumberedsec Attribute Object_Size
9032 @cindex Size, used for objects
9035 The size of an object is not necessarily the same as the size of the type
9036 of an object. This is because by default object sizes are increased to be
9037 a multiple of the alignment of the object. For example,
9038 @code{Natural'Size} is
9039 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9040 Similarly, a record containing an integer and a character:
9042 @smallexample @c ada
9050 will have a size of 40 (that is @code{Rec'Size} will be 40). The
9051 alignment will be 4, because of the
9052 integer field, and so the default size of record objects for this type
9053 will be 64 (8 bytes).
9055 If the alignment of the above record is specified to be 1, then the
9056 object size will be 40 (5 bytes). This is true by default, and also
9057 an object size of 40 can be explicitly specified in this case.
9059 A consequence of this capability is that different object sizes can be
9060 given to subtypes that would otherwise be considered in Ada to be
9061 statically matching. But it makes no sense to consider such subtypes
9062 as statically matching. Consequently, in @code{GNAT} we add a rule
9063 to the static matching rules that requires object sizes to match.
9064 Consider this example:
9066 @smallexample @c ada
9067 1. procedure BadAVConvert is
9068 2. type R is new Integer;
9069 3. subtype R1 is R range 1 .. 10;
9070 4. subtype R2 is R range 1 .. 10;
9071 5. for R1'Object_Size use 8;
9072 6. for R2'Object_Size use 16;
9073 7. type R1P is access all R1;
9074 8. type R2P is access all R2;
9075 9. R1PV : R1P := new R1'(4);
9078 12. R2PV := R2P (R1PV);
9080 >>> target designated subtype not compatible with
9081 type "R1" defined at line 3
9087 In the absence of lines 5 and 6,
9088 types @code{R1} and @code{R2} statically match and
9089 hence the conversion on line 12 is legal. But since lines 5 and 6
9090 cause the object sizes to differ, @code{GNAT} considers that types
9091 @code{R1} and @code{R2} are not statically matching, and line 12
9092 generates the diagnostic shown above.
9095 Similar additional checks are performed in other contexts requiring
9096 statically matching subtypes.
9098 @node Attribute Passed_By_Reference
9099 @unnumberedsec Attribute Passed_By_Reference
9100 @cindex Parameters, when passed by reference
9101 @findex Passed_By_Reference
9103 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9104 a value of type @code{Boolean} value that is @code{True} if the type is
9105 normally passed by reference and @code{False} if the type is normally
9106 passed by copy in calls. For scalar types, the result is always @code{False}
9107 and is static. For non-scalar types, the result is non-static.
9109 @node Attribute Pool_Address
9110 @unnumberedsec Attribute Pool_Address
9111 @cindex Parameters, when passed by reference
9112 @findex Pool_Address
9114 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9115 of X within its storage pool. This is the same as
9116 @code{@var{X}'Address}, except that for an unconstrained array whose
9117 bounds are allocated just before the first component,
9118 @code{@var{X}'Pool_Address} returns the address of those bounds,
9119 whereas @code{@var{X}'Address} returns the address of the first
9122 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9123 the object is allocated'', which could be a user-defined storage pool,
9124 the global heap, on the stack, or in a static memory area. For an
9125 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9126 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9128 @node Attribute Range_Length
9129 @unnumberedsec Attribute Range_Length
9130 @findex Range_Length
9132 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9133 the number of values represented by the subtype (zero for a null
9134 range). The result is static for static subtypes. @code{Range_Length}
9135 applied to the index subtype of a one dimensional array always gives the
9136 same result as @code{Length} applied to the array itself.
9139 @unnumberedsec Attribute Ref
9144 @node Attribute Restriction_Set
9145 @unnumberedsec Attribute Restriction_Set
9146 @findex Restriction_Set
9147 @cindex Restrictions
9149 This attribute allows compile time testing of restrictions that
9150 are currently in effect. It is primarily intended for specializing
9151 code in the run-time based on restrictions that are active (e.g.
9152 don't need to save fpt registers if restriction No_Floating_Point
9153 is known to be in effect), but can be used anywhere.
9155 There are two forms:
9157 @smallexample @c ada
9158 System'Restriction_Set (partition_boolean_restriction_NAME)
9159 System'Restriction_Set (No_Dependence => library_unit_NAME);
9163 In the case of the first form, the only restriction names
9164 allowed are parameterless restrictions that are checked
9165 for consistency at bind time. For a complete list see the
9166 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9168 The result returned is True if the restriction is known to
9169 be in effect, and False if the restriction is known not to
9170 be in effect. An important guarantee is that the value of
9171 a Restriction_Set attribute is known to be consistent throughout
9172 all the code of a partition.
9174 This is trivially achieved if the entire partition is compiled
9175 with a consistent set of restriction pragmas. However, the
9176 compilation model does not require this. It is possible to
9177 compile one set of units with one set of pragmas, and another
9178 set of units with another set of pragmas. It is even possible
9179 to compile a spec with one set of pragmas, and then WITH the
9180 same spec with a different set of pragmas. Inconsistencies
9181 in the actual use of the restriction are checked at bind time.
9183 In order to achieve the guarantee of consistency for the
9184 Restriction_Set pragma, we consider that a use of the pragma
9185 that yields False is equivalent to a violation of the
9188 So for example if you write
9190 @smallexample @c ada
9191 if System'Restriction_Set (No_Floating_Point) then
9199 And the result is False, so that the else branch is executed,
9200 you can assume that this restriction is not set for any unit
9201 in the partition. This is checked by considering this use of
9202 the restriction pragma to be a violation of the restriction
9203 No_Floating_Point. This means that no other unit can attempt
9204 to set this restriction (if some unit does attempt to set it,
9205 the binder will refuse to bind the partition).
9207 Technical note: The restriction name and the unit name are
9208 intepreted entirely syntactically, as in the corresponding
9209 Restrictions pragma, they are not analyzed semantically,
9210 so they do not have a type.
9212 @node Attribute Result
9213 @unnumberedsec Attribute Result
9216 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9217 for a function. The prefix must be the name of the corresponding function. This
9218 is used to refer to the result of the function in the postcondition expression.
9219 For a further discussion of the use of this attribute and examples of its use,
9220 see the description of pragma Postcondition.
9222 @node Attribute Safe_Emax
9223 @unnumberedsec Attribute Safe_Emax
9224 @cindex Ada 83 attributes
9227 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
9228 the Ada 83 reference manual for an exact description of the semantics of
9231 @node Attribute Safe_Large
9232 @unnumberedsec Attribute Safe_Large
9233 @cindex Ada 83 attributes
9236 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
9237 the Ada 83 reference manual for an exact description of the semantics of
9240 @node Attribute Scalar_Storage_Order
9241 @unnumberedsec Attribute Scalar_Storage_Order
9243 @cindex Scalar storage order
9244 @findex Scalar_Storage_Order
9246 For every array or record type @var{S}, the representation attribute
9247 @code{Scalar_Storage_Order} denotes the order in which storage elements
9248 that make up scalar components are ordered within S:
9250 @smallexample @c ada
9251 -- Component type definitions
9253 subtype Yr_Type is Natural range 0 .. 127;
9254 subtype Mo_Type is Natural range 1 .. 12;
9255 subtype Da_Type is Natural range 1 .. 31;
9257 -- Record declaration
9260 Years_Since_1980 : Yr_Type;
9262 Day_Of_Month : Da_Type;
9265 -- Record representation clause
9268 Years_Since_1980 at 0 range 0 .. 6;
9269 Month at 0 range 7 .. 10;
9270 Day_Of_Month at 0 range 11 .. 15;
9273 -- Attribute definition clauses
9275 for Date'Bit_Order use System.High_Order_First;
9276 for Date'Scalar_Storage_Order use System.High_Order_First;
9277 -- If Scalar_Storage_Order is specified, it must be consistent with
9278 -- Bit_Order, so it's best to always define the latter explicitly if
9279 -- the former is used.
9282 Other properties are
9283 as for standard representation attribute @code{Bit_Order}, as defined by
9284 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9286 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
9287 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
9288 this means that if a @code{Scalar_Storage_Order} attribute definition
9289 clause is not confirming, then the type's @code{Bit_Order} shall be
9290 specified explicitly and set to the same value.
9292 For a record extension, the derived type shall have the same scalar storage
9293 order as the parent type.
9295 If a component of @var{S} has itself a record or array type, then it shall also
9296 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
9297 if the component is a packed array, or does not start on a byte boundary, then
9298 the scalar storage order specified for S and for the nested component type shall
9301 If @var{S} appears as the type of a record or array component, the enclosing
9302 record or array shall also have a @code{Scalar_Storage_Order} attribute
9305 No component of a type that has a @code{Scalar_Storage_Order} attribute
9306 definition may be aliased.
9308 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9309 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9311 If the opposite storage order is specified, then whenever the value of
9312 a scalar component of an object of type @var{S} is read, the storage
9313 elements of the enclosing machine scalar are first reversed (before
9314 retrieving the component value, possibly applying some shift and mask
9315 operatings on the enclosing machine scalar), and the opposite operation
9318 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9319 are relaxed. Instead, the following rules apply:
9322 @item the underlying storage elements are those at positions
9323 @code{(position + first_bit / storage_element_size) ..
9324 (position + (last_bit + storage_element_size - 1) /
9325 storage_element_size)}
9326 @item the sequence of underlying storage elements shall have
9327 a size no greater than the largest machine scalar
9328 @item the enclosing machine scalar is defined as the smallest machine
9329 scalar starting at a position no greater than
9330 @code{position + first_bit / storage_element_size} and covering
9331 storage elements at least up to @code{position + (last_bit +
9332 storage_element_size - 1) / storage_element_size}
9333 @item the position of the component is interpreted relative to that machine
9338 @node Attribute Simple_Storage_Pool
9339 @unnumberedsec Attribute Simple_Storage_Pool
9340 @cindex Storage pool, simple
9341 @cindex Simple storage pool
9342 @findex Simple_Storage_Pool
9344 For every nonformal, nonderived access-to-object type @var{Acc}, the
9345 representation attribute @code{Simple_Storage_Pool} may be specified
9346 via an attribute_definition_clause (or by specifying the equivalent aspect):
9348 @smallexample @c ada
9350 My_Pool : My_Simple_Storage_Pool_Type;
9352 type Acc is access My_Data_Type;
9354 for Acc'Simple_Storage_Pool use My_Pool;
9359 The name given in an attribute_definition_clause for the
9360 @code{Simple_Storage_Pool} attribute shall denote a variable of
9361 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9363 The use of this attribute is only allowed for a prefix denoting a type
9364 for which it has been specified. The type of the attribute is the type
9365 of the variable specified as the simple storage pool of the access type,
9366 and the attribute denotes that variable.
9368 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9369 for the same access type.
9371 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9372 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9373 with a warning and its evaluation raises the exception @code{Program_Error}.
9375 If the Simple_Storage_Pool attribute has been specified for an access
9376 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9377 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9378 which is intended to indicate the number of storage elements reserved for
9379 the simple storage pool. If the Storage_Size function has not been defined
9380 for the simple storage pool type, then this attribute returns zero.
9382 If an access type @var{S} has a specified simple storage pool of type
9383 @var{SSP}, then the evaluation of an allocator for that access type calls
9384 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9385 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9386 semantics of such allocators is the same as those defined for allocators
9387 in section 13.11 of the Ada Reference Manual, with the term
9388 ``simple storage pool'' substituted for ``storage pool''.
9390 If an access type @var{S} has a specified simple storage pool of type
9391 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9392 for that access type invokes the primitive @code{Deallocate} procedure
9393 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9394 parameter. The detailed semantics of such unchecked deallocations is the same
9395 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9396 term ``simple storage pool'' is substituted for ``storage pool''.
9398 @node Attribute Small
9399 @unnumberedsec Attribute Small
9400 @cindex Ada 83 attributes
9403 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9405 GNAT also allows this attribute to be applied to floating-point types
9406 for compatibility with Ada 83. See
9407 the Ada 83 reference manual for an exact description of the semantics of
9408 this attribute when applied to floating-point types.
9410 @node Attribute Storage_Unit
9411 @unnumberedsec Attribute Storage_Unit
9412 @findex Storage_Unit
9414 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9415 prefix) provides the same value as @code{System.Storage_Unit}.
9417 @node Attribute Stub_Type
9418 @unnumberedsec Attribute Stub_Type
9421 The GNAT implementation of remote access-to-classwide types is
9422 organized as described in AARM section E.4 (20.t): a value of an RACW type
9423 (designating a remote object) is represented as a normal access
9424 value, pointing to a "stub" object which in turn contains the
9425 necessary information to contact the designated remote object. A
9426 call on any dispatching operation of such a stub object does the
9427 remote call, if necessary, using the information in the stub object
9428 to locate the target partition, etc.
9430 For a prefix @code{T} that denotes a remote access-to-classwide type,
9431 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9433 By construction, the layout of @code{T'Stub_Type} is identical to that of
9434 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9435 unit @code{System.Partition_Interface}. Use of this attribute will create
9436 an implicit dependency on this unit.
9438 @node Attribute System_Allocator_Alignment
9439 @unnumberedsec Attribute System_Allocator_Alignment
9440 @cindex Alignment, allocator
9441 @findex System_Allocator_Alignment
9443 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9444 permissible prefix) provides the observable guaranted to be honored by
9445 the system allocator (malloc). This is a static value that can be used
9446 in user storage pools based on malloc either to reject allocation
9447 with alignment too large or to enable a realignment circuitry if the
9448 alignment request is larger than this value.
9450 @node Attribute Target_Name
9451 @unnumberedsec Attribute Target_Name
9454 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9455 prefix) provides a static string value that identifies the target
9456 for the current compilation. For GCC implementations, this is the
9457 standard gcc target name without the terminating slash (for
9458 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9460 @node Attribute Tick
9461 @unnumberedsec Attribute Tick
9464 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
9465 provides the same value as @code{System.Tick},
9467 @node Attribute To_Address
9468 @unnumberedsec Attribute To_Address
9471 The @code{System'To_Address}
9472 (@code{System} is the only permissible prefix)
9473 denotes a function identical to
9474 @code{System.Storage_Elements.To_Address} except that
9475 it is a static attribute. This means that if its argument is
9476 a static expression, then the result of the attribute is a
9477 static expression. This means that such an expression can be
9478 used in contexts (e.g.@: preelaborable packages) which require a
9479 static expression and where the function call could not be used
9480 (since the function call is always non-static, even if its
9481 argument is static). The argument must be in the range
9482 -(2**(m-1) .. 2**m-1, where m is the memory size
9483 (typically 32 or 64). Negative values are intepreted in a
9484 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9487 @node Attribute Type_Class
9488 @unnumberedsec Attribute Type_Class
9491 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9492 the value of the type class for the full type of @var{type}. If
9493 @var{type} is a generic formal type, the value is the value for the
9494 corresponding actual subtype. The value of this attribute is of type
9495 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9497 @smallexample @c ada
9499 (Type_Class_Enumeration,
9501 Type_Class_Fixed_Point,
9502 Type_Class_Floating_Point,
9507 Type_Class_Address);
9511 Protected types yield the value @code{Type_Class_Task}, which thus
9512 applies to all concurrent types. This attribute is designed to
9513 be compatible with the DEC Ada 83 attribute of the same name.
9515 @node Attribute UET_Address
9516 @unnumberedsec Attribute UET_Address
9519 The @code{UET_Address} attribute can only be used for a prefix which
9520 denotes a library package. It yields the address of the unit exception
9521 table when zero cost exception handling is used. This attribute is
9522 intended only for use within the GNAT implementation. See the unit
9523 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9524 for details on how this attribute is used in the implementation.
9526 @node Attribute Unconstrained_Array
9527 @unnumberedsec Attribute Unconstrained_Array
9528 @findex Unconstrained_Array
9530 The @code{Unconstrained_Array} attribute can be used with a prefix that
9531 denotes any type or subtype. It is a static attribute that yields
9532 @code{True} if the prefix designates an unconstrained array,
9533 and @code{False} otherwise. In a generic instance, the result is
9534 still static, and yields the result of applying this test to the
9537 @node Attribute Universal_Literal_String
9538 @unnumberedsec Attribute Universal_Literal_String
9539 @cindex Named numbers, representation of
9540 @findex Universal_Literal_String
9542 The prefix of @code{Universal_Literal_String} must be a named
9543 number. The static result is the string consisting of the characters of
9544 the number as defined in the original source. This allows the user
9545 program to access the actual text of named numbers without intermediate
9546 conversions and without the need to enclose the strings in quotes (which
9547 would preclude their use as numbers).
9549 For example, the following program prints the first 50 digits of pi:
9551 @smallexample @c ada
9552 with Text_IO; use Text_IO;
9556 Put (Ada.Numerics.Pi'Universal_Literal_String);
9560 @node Attribute Unrestricted_Access
9561 @unnumberedsec Attribute Unrestricted_Access
9562 @cindex @code{Access}, unrestricted
9563 @findex Unrestricted_Access
9565 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9566 except that all accessibility and aliased view checks are omitted. This
9567 is a user-beware attribute. It is similar to
9568 @code{Address}, for which it is a desirable replacement where the value
9569 desired is an access type. In other words, its effect is similar to
9570 first applying the @code{Address} attribute and then doing an unchecked
9571 conversion to a desired access type. In GNAT, but not necessarily in
9572 other implementations, the use of static chains for inner level
9573 subprograms means that @code{Unrestricted_Access} applied to a
9574 subprogram yields a value that can be called as long as the subprogram
9575 is in scope (normal Ada accessibility rules restrict this usage).
9577 It is possible to use @code{Unrestricted_Access} for any type, but care
9578 must be exercised if it is used to create pointers to unconstrained array
9579 objects. In this case, the resulting pointer has the same scope as the
9580 context of the attribute, and may not be returned to some enclosing
9581 scope. For instance, a function cannot use @code{Unrestricted_Access}
9582 to create a unconstrained pointer and then return that value to the
9583 caller. In addition, it is only valid to create pointers to unconstrained
9584 arrays using this attribute if the pointer has the normal default ``fat''
9585 representation where a pointer has two components, one points to the array
9586 and one points to the bounds. If a size clause is used to force ``thin''
9587 representation for a pointer to unconstrained where there is only space for
9588 a single pointer, then the resulting pointer is not usable.
9590 In the simple case where a direct use of Unrestricted_Access attempts
9591 to make a thin pointer for a non-aliased object, the compiler will
9592 reject the use as illegal, as shown in the following example:
9594 @smallexample @c ada
9595 with System; use System;
9596 procedure SliceUA2 is
9597 type A is access all String;
9598 for A'Size use Standard'Address_Size;
9600 procedure P (Arg : A) is
9605 X : String := "hello world!";
9606 X2 : aliased String := "hello world!";
9608 AV : A := X'Unrestricted_Access; -- ERROR
9610 >>> illegal use of Unrestricted_Access attribute
9611 >>> attempt to generate thin pointer to unaliased object
9614 P (X'Unrestricted_Access); -- ERROR
9616 >>> illegal use of Unrestricted_Access attribute
9617 >>> attempt to generate thin pointer to unaliased object
9619 P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9621 >>> illegal use of Unrestricted_Access attribute
9622 >>> attempt to generate thin pointer to unaliased object
9624 P (X2'Unrestricted_Access); -- OK
9629 but other cases cannot be detected by the compiler, and are
9630 considered to be erroneous. Consider the following example:
9632 @smallexample @c ada
9633 with System; use System;
9634 with System; use System;
9635 procedure SliceUA is
9636 type AF is access all String;
9638 type A is access all String;
9639 for A'Size use Standard'Address_Size;
9641 procedure P (Arg : A) is
9643 if Arg'Length /= 6 then
9644 raise Program_Error;
9648 X : String := "hello world!";
9649 Y : AF := X (7 .. 12)'Unrestricted_Access;
9657 A normal unconstrained array value
9658 or a constrained array object marked as aliased has the bounds in memory
9659 just before the array, so a thin pointer can retrieve both the data and
9660 the bounds. But in this case, the non-aliased object @code{X} does not have the
9661 bounds before the string. If the size clause for type @code{A}
9662 were not present, then the pointer
9663 would be a fat pointer, where one component is a pointer to the bounds,
9664 and all would be well. But with the size clause present, the conversion from
9665 fat pointer to thin pointer in the call looses the bounds, and so this
9666 program raises a @code{Program_Error} exception if executed.
9668 In general, it is advisable to completely
9669 avoid mixing the use of thin pointers and the use of
9670 @code{Unrestricted_Access} where the designated type is an
9671 unconstrained array. The use of thin pointers should be restricted to
9672 cases of porting legacy code which implicitly assumes the size of pointers,
9673 and such code should not in any case be using this attribute.
9675 Another erroroneous situation arises if the attribute is
9676 applied to a constant. The resulting pointer can be used to access the
9677 constant, but the effect of trying to modify a constant in this manner
9678 is not well-defined. Consider this example:
9680 @smallexample @c ada
9681 P : constant Integer := 4;
9682 type R is access all Integer;
9683 RV : R := P'Unrestricted_Access;
9689 Here we attempt to modify the constant P from 4 to 3, but the compiler may
9690 or may not notice this attempt, and subsequent references to P may yield
9691 either the value 3 or the value 4 or the assignment may blow up if the
9692 compiler decides to put P in read-only memory. One particular case where
9693 @code{Unrestricted_Access} can be used in this way is to modify the
9694 value of an @code{IN} parameter:
9696 @smallexample @c ada
9697 procedure K (S : in String) is
9698 type R is access all Character;
9699 RV : R := S (3)'Unrestricted_Access;
9706 In general this is a risky approach. It may appear to "work" but such uses of
9707 @code{Unrestricted_Access} are potentially non-portable, even from one version
9708 of @code{GNAT} to another, so are best avoided if possible.
9710 @node Attribute Update
9711 @unnumberedsec Attribute Update
9714 The @code{Update} attribute creates a copy of an array or record value
9715 with one or more modified components. The syntax is:
9717 @smallexample @c ada
9718 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
9719 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
9720 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
9721 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
9723 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
9724 INDEX_EXPRESSION_LIST_LIST ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
9725 INDEX_EXPRESSION_LIST ::= ( EXPRESSION @{, EXPRESSION @} )
9729 where @code{PREFIX} is the name of an array or record object, and
9730 the association list in parentheses does not contain an @code{others}
9731 choice. The effect is to yield a copy of the array or record value which
9732 is unchanged apart from the components mentioned in the association list, which
9733 are changed to the indicated value. The original value of the array or
9734 record value is not affected. For example:
9736 @smallexample @c ada
9737 type Arr is Array (1 .. 5) of Integer;
9739 Avar1 : Arr := (1,2,3,4,5);
9740 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
9744 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9745 begin unmodified. Similarly:
9747 @smallexample @c ada
9748 type Rec is A, B, C : Integer;
9750 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9751 Rvar2 : Rec := Rvar1'Update (B => 20);
9755 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9756 with @code{Rvar1} being unmodifed.
9757 Note that the value of the attribute reference is computed
9758 completely before it is used. This means that if you write:
9760 @smallexample @c ada
9761 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
9765 then the value of @code{Avar1} is not modified if @code{Function_Call}
9766 raises an exception, unlike the effect of a series of direct assignments
9767 to elements of @code{Avar1}. In general this requires that
9768 two extra complete copies of the object are required, which should be
9769 kept in mind when considering efficiency.
9771 The @code{Update} attribute cannot be applied to prefixes of a limited
9772 type, and cannot reference discriminants in the case of a record type.
9773 The accessibility level of an Update attribute result object is defined
9774 as for an aggregate.
9776 In the record case, no component can be mentioned more than once. In
9777 the array case, two overlapping ranges can appear in the association list,
9778 in which case the modifications are processed left to right.
9780 Multi-dimensional arrays can be modified, as shown by this example:
9782 @smallexample @c ada
9783 A : array (1 .. 10, 1 .. 10) of Integer;
9785 A := A'Update ((1, 2) => 20, (3, 4) => 30);
9789 which changes element (1,2) to 20 and (3,4) to 30.
9791 @node Attribute Valid_Scalars
9792 @unnumberedsec Attribute Valid_Scalars
9793 @findex Valid_Scalars
9795 The @code{'Valid_Scalars} attribute is intended to make it easier to
9796 check the validity of scalar subcomponents of composite objects. It
9797 is defined for any prefix @code{X} that denotes an object.
9798 The value of this attribute is of the predefined type Boolean.
9799 @code{X'Valid_Scalars} yields True if and only if evaluation of
9800 @code{P'Valid} yields True for every scalar part P of X or if X has
9801 no scalar parts. It is not specified in what order the scalar parts
9802 are checked, nor whether any more are checked after any one of them
9803 is determined to be invalid. If the prefix @code{X} is of a class-wide
9804 type @code{T'Class} (where @code{T} is the associated specific type),
9805 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9806 only the scalar parts of components of @code{T} are traversed; in other
9807 words, components of extensions of @code{T} are not traversed even if
9808 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9809 be determined at compile time that the prefix of the attribute has no
9810 scalar parts (e.g., if the prefix is of an access type, an interface type,
9811 an undiscriminated task type, or an undiscriminated protected type).
9813 @node Attribute VADS_Size
9814 @unnumberedsec Attribute VADS_Size
9815 @cindex @code{Size}, VADS compatibility
9818 The @code{'VADS_Size} attribute is intended to make it easier to port
9819 legacy code which relies on the semantics of @code{'Size} as implemented
9820 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
9821 same semantic interpretation. In particular, @code{'VADS_Size} applied
9822 to a predefined or other primitive type with no Size clause yields the
9823 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9824 typical machines). In addition @code{'VADS_Size} applied to an object
9825 gives the result that would be obtained by applying the attribute to
9826 the corresponding type.
9828 @node Attribute Value_Size
9829 @unnumberedsec Attribute Value_Size
9830 @cindex @code{Size}, setting for not-first subtype
9832 @code{@var{type}'Value_Size} is the number of bits required to represent
9833 a value of the given subtype. It is the same as @code{@var{type}'Size},
9834 but, unlike @code{Size}, may be set for non-first subtypes.
9836 @node Attribute Wchar_T_Size
9837 @unnumberedsec Attribute Wchar_T_Size
9838 @findex Wchar_T_Size
9839 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9840 prefix) provides the size in bits of the C @code{wchar_t} type
9841 primarily for constructing the definition of this type in
9842 package @code{Interfaces.C}.
9844 @node Attribute Word_Size
9845 @unnumberedsec Attribute Word_Size
9847 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9848 prefix) provides the value @code{System.Word_Size}.
9850 @node Standard and Implementation Defined Restrictions
9851 @chapter Standard and Implementation Defined Restrictions
9854 All RM defined Restriction identifiers are implemented:
9857 @item language-defined restrictions (see 13.12.1)
9858 @item tasking restrictions (see D.7)
9859 @item high integrity restrictions (see H.4)
9863 GNAT implements additional restriction identifiers. All restrictions, whether
9864 language defined or GNAT-specific, are listed in the following.
9867 * Partition-Wide Restrictions::
9868 * Program Unit Level Restrictions::
9871 @node Partition-Wide Restrictions
9872 @section Partition-Wide Restrictions
9874 There are two separate lists of restriction identifiers. The first
9875 set requires consistency throughout a partition (in other words, if the
9876 restriction identifier is used for any compilation unit in the partition,
9877 then all compilation units in the partition must obey the restriction).
9880 * Immediate_Reclamation::
9881 * Max_Asynchronous_Select_Nesting::
9882 * Max_Entry_Queue_Length::
9883 * Max_Protected_Entries::
9884 * Max_Select_Alternatives::
9885 * Max_Storage_At_Blocking::
9886 * Max_Task_Entries::
9888 * No_Abort_Statements::
9889 * No_Access_Parameter_Allocators::
9890 * No_Access_Subprograms::
9892 * No_Anonymous_Allocators::
9895 * No_Default_Initialization::
9898 * No_Direct_Boolean_Operators::
9900 * No_Dispatching_Calls::
9901 * No_Dynamic_Attachment::
9902 * No_Dynamic_Priorities::
9903 * No_Entry_Calls_In_Elaboration_Code::
9904 * No_Enumeration_Maps::
9905 * No_Exception_Handlers::
9906 * No_Exception_Propagation::
9907 * No_Exception_Registration::
9911 * No_Floating_Point::
9912 * No_Implicit_Conditionals::
9913 * No_Implicit_Dynamic_Code::
9914 * No_Implicit_Heap_Allocations::
9915 * No_Implicit_Loops::
9916 * No_Initialize_Scalars::
9918 * No_Local_Allocators::
9919 * No_Local_Protected_Objects::
9920 * No_Local_Timing_Events::
9921 * No_Nested_Finalization::
9922 * No_Protected_Type_Allocators::
9923 * No_Protected_Types::
9926 * No_Relative_Delay::
9927 * No_Requeue_Statements::
9928 * No_Secondary_Stack::
9929 * No_Select_Statements::
9930 * No_Specific_Termination_Handlers::
9931 * No_Specification_of_Aspect::
9932 * No_Standard_Allocators_After_Elaboration::
9933 * No_Standard_Storage_Pools::
9934 * No_Stream_Optimizations::
9936 * No_Task_Allocators::
9937 * No_Task_Attributes_Package::
9938 * No_Task_Hierarchy::
9939 * No_Task_Termination::
9941 * No_Terminate_Alternatives::
9942 * No_Unchecked_Access::
9944 * Static_Priorities::
9945 * Static_Storage_Size::
9948 @node Immediate_Reclamation
9949 @unnumberedsubsec Immediate_Reclamation
9950 @findex Immediate_Reclamation
9951 [RM H.4] This restriction ensures that, except for storage occupied by
9952 objects created by allocators and not deallocated via unchecked
9953 deallocation, any storage reserved at run time for an object is
9954 immediately reclaimed when the object no longer exists.
9956 @node Max_Asynchronous_Select_Nesting
9957 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9958 @findex Max_Asynchronous_Select_Nesting
9959 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9960 selects. Violations of this restriction with a value of zero are
9961 detected at compile time. Violations of this restriction with values
9962 other than zero cause Storage_Error to be raised.
9964 @node Max_Entry_Queue_Length
9965 @unnumberedsubsec Max_Entry_Queue_Length
9966 @findex Max_Entry_Queue_Length
9967 [RM D.7] This restriction is a declaration that any protected entry compiled in
9968 the scope of the restriction has at most the specified number of
9969 tasks waiting on the entry at any one time, and so no queue is required.
9970 Note that this restriction is checked at run time. Violation of this
9971 restriction results in the raising of Program_Error exception at the point of
9974 @findex Max_Entry_Queue_Depth
9975 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9976 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9977 compatibility purposes (and a warning will be generated for its use if
9978 warnings on obsolescent features are activated).
9980 @node Max_Protected_Entries
9981 @unnumberedsubsec Max_Protected_Entries
9982 @findex Max_Protected_Entries
9983 [RM D.7] Specifies the maximum number of entries per protected type. The
9984 bounds of every entry family of a protected unit shall be static, or shall be
9985 defined by a discriminant of a subtype whose corresponding bound is static.
9987 @node Max_Select_Alternatives
9988 @unnumberedsubsec Max_Select_Alternatives
9989 @findex Max_Select_Alternatives
9990 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9992 @node Max_Storage_At_Blocking
9993 @unnumberedsubsec Max_Storage_At_Blocking
9994 @findex Max_Storage_At_Blocking
9995 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9996 Storage_Size that can be retained by a blocked task. A violation of this
9997 restriction causes Storage_Error to be raised.
9999 @node Max_Task_Entries
10000 @unnumberedsubsec Max_Task_Entries
10001 @findex Max_Task_Entries
10002 [RM D.7] Specifies the maximum number of entries
10003 per task. The bounds of every entry family
10004 of a task unit shall be static, or shall be
10005 defined by a discriminant of a subtype whose
10006 corresponding bound is static.
10009 @unnumberedsubsec Max_Tasks
10011 [RM D.7] Specifies the maximum number of task that may be created, not
10012 counting the creation of the environment task. Violations of this
10013 restriction with a value of zero are detected at compile
10014 time. Violations of this restriction with values other than zero cause
10015 Storage_Error to be raised.
10017 @node No_Abort_Statements
10018 @unnumberedsubsec No_Abort_Statements
10019 @findex No_Abort_Statements
10020 [RM D.7] There are no abort_statements, and there are
10021 no calls to Task_Identification.Abort_Task.
10023 @node No_Access_Parameter_Allocators
10024 @unnumberedsubsec No_Access_Parameter_Allocators
10025 @findex No_Access_Parameter_Allocators
10026 [RM H.4] This restriction ensures at compile time that there are no
10027 occurrences of an allocator as the actual parameter to an access
10030 @node No_Access_Subprograms
10031 @unnumberedsubsec No_Access_Subprograms
10032 @findex No_Access_Subprograms
10033 [RM H.4] This restriction ensures at compile time that there are no
10034 declarations of access-to-subprogram types.
10036 @node No_Allocators
10037 @unnumberedsubsec No_Allocators
10038 @findex No_Allocators
10039 [RM H.4] This restriction ensures at compile time that there are no
10040 occurrences of an allocator.
10042 @node No_Anonymous_Allocators
10043 @unnumberedsubsec No_Anonymous_Allocators
10044 @findex No_Anonymous_Allocators
10045 [RM H.4] This restriction ensures at compile time that there are no
10046 occurrences of an allocator of anonymous access type.
10049 @unnumberedsubsec No_Calendar
10050 @findex No_Calendar
10051 [GNAT] This restriction ensures at compile time that there is no implicit or
10052 explicit dependence on the package @code{Ada.Calendar}.
10054 @node No_Coextensions
10055 @unnumberedsubsec No_Coextensions
10056 @findex No_Coextensions
10057 [RM H.4] This restriction ensures at compile time that there are no
10058 coextensions. See 3.10.2.
10060 @node No_Default_Initialization
10061 @unnumberedsubsec No_Default_Initialization
10062 @findex No_Default_Initialization
10064 [GNAT] This restriction prohibits any instance of default initialization
10065 of variables. The binder implements a consistency rule which prevents
10066 any unit compiled without the restriction from with'ing a unit with the
10067 restriction (this allows the generation of initialization procedures to
10068 be skipped, since you can be sure that no call is ever generated to an
10069 initialization procedure in a unit with the restriction active). If used
10070 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10071 is to prohibit all cases of variables declared without a specific
10072 initializer (including the case of OUT scalar parameters).
10075 @unnumberedsubsec No_Delay
10077 [RM H.4] This restriction ensures at compile time that there are no
10078 delay statements and no dependences on package Calendar.
10080 @node No_Dependence
10081 @unnumberedsubsec No_Dependence
10082 @findex No_Dependence
10083 [RM 13.12.1] This restriction checks at compile time that there are no
10084 dependence on a library unit.
10086 @node No_Direct_Boolean_Operators
10087 @unnumberedsubsec No_Direct_Boolean_Operators
10088 @findex No_Direct_Boolean_Operators
10089 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10090 are used on operands of type Boolean (or any type derived from Boolean).
10091 This is intended for use in safety critical programs where the certification
10092 protocol requires the use of short-circuit (and then, or else) forms for all
10093 composite boolean operations.
10096 @unnumberedsubsec No_Dispatch
10097 @findex No_Dispatch
10098 [RM H.4] This restriction ensures at compile time that there are no
10099 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10101 @node No_Dispatching_Calls
10102 @unnumberedsubsec No_Dispatching_Calls
10103 @findex No_Dispatching_Calls
10104 [GNAT] This restriction ensures at compile time that the code generated by the
10105 compiler involves no dispatching calls. The use of this restriction allows the
10106 safe use of record extensions, classwide membership tests and other classwide
10107 features not involving implicit dispatching. This restriction ensures that
10108 the code contains no indirect calls through a dispatching mechanism. Note that
10109 this includes internally-generated calls created by the compiler, for example
10110 in the implementation of class-wide objects assignments. The
10111 membership test is allowed in the presence of this restriction, because its
10112 implementation requires no dispatching.
10113 This restriction is comparable to the official Ada restriction
10114 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10115 all classwide constructs that do not imply dispatching.
10116 The following example indicates constructs that violate this restriction.
10120 type T is tagged record
10123 procedure P (X : T);
10125 type DT is new T with record
10126 More_Data : Natural;
10128 procedure Q (X : DT);
10132 procedure Example is
10133 procedure Test (O : T'Class) is
10134 N : Natural := O'Size;-- Error: Dispatching call
10135 C : T'Class := O; -- Error: implicit Dispatching Call
10137 if O in DT'Class then -- OK : Membership test
10138 Q (DT (O)); -- OK : Type conversion plus direct call
10140 P (O); -- Error: Dispatching call
10146 P (Obj); -- OK : Direct call
10147 P (T (Obj)); -- OK : Type conversion plus direct call
10148 P (T'Class (Obj)); -- Error: Dispatching call
10150 Test (Obj); -- OK : Type conversion
10152 if Obj in T'Class then -- OK : Membership test
10158 @node No_Dynamic_Attachment
10159 @unnumberedsubsec No_Dynamic_Attachment
10160 @findex No_Dynamic_Attachment
10161 [RM D.7] This restriction ensures that there is no call to any of the
10162 operations defined in package Ada.Interrupts
10163 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10164 Detach_Handler, and Reference).
10166 @findex No_Dynamic_Interrupts
10167 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10168 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10169 compatibility purposes (and a warning will be generated for its use if
10170 warnings on obsolescent features are activated).
10172 @node No_Dynamic_Priorities
10173 @unnumberedsubsec No_Dynamic_Priorities
10174 @findex No_Dynamic_Priorities
10175 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10177 @node No_Entry_Calls_In_Elaboration_Code
10178 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10179 @findex No_Entry_Calls_In_Elaboration_Code
10180 [GNAT] This restriction ensures at compile time that no task or protected entry
10181 calls are made during elaboration code. As a result of the use of this
10182 restriction, the compiler can assume that no code past an accept statement
10183 in a task can be executed at elaboration time.
10185 @node No_Enumeration_Maps
10186 @unnumberedsubsec No_Enumeration_Maps
10187 @findex No_Enumeration_Maps
10188 [GNAT] This restriction ensures at compile time that no operations requiring
10189 enumeration maps are used (that is Image and Value attributes applied
10190 to enumeration types).
10192 @node No_Exception_Handlers
10193 @unnumberedsubsec No_Exception_Handlers
10194 @findex No_Exception_Handlers
10195 [GNAT] This restriction ensures at compile time that there are no explicit
10196 exception handlers. It also indicates that no exception propagation will
10197 be provided. In this mode, exceptions may be raised but will result in
10198 an immediate call to the last chance handler, a routine that the user
10199 must define with the following profile:
10201 @smallexample @c ada
10202 procedure Last_Chance_Handler
10203 (Source_Location : System.Address; Line : Integer);
10204 pragma Export (C, Last_Chance_Handler,
10205 "__gnat_last_chance_handler");
10208 The parameter is a C null-terminated string representing a message to be
10209 associated with the exception (typically the source location of the raise
10210 statement generated by the compiler). The Line parameter when nonzero
10211 represents the line number in the source program where the raise occurs.
10213 @node No_Exception_Propagation
10214 @unnumberedsubsec No_Exception_Propagation
10215 @findex No_Exception_Propagation
10216 [GNAT] This restriction guarantees that exceptions are never propagated
10217 to an outer subprogram scope. The only case in which an exception may
10218 be raised is when the handler is statically in the same subprogram, so
10219 that the effect of a raise is essentially like a goto statement. Any
10220 other raise statement (implicit or explicit) will be considered
10221 unhandled. Exception handlers are allowed, but may not contain an
10222 exception occurrence identifier (exception choice). In addition, use of
10223 the package GNAT.Current_Exception is not permitted, and reraise
10224 statements (raise with no operand) are not permitted.
10226 @node No_Exception_Registration
10227 @unnumberedsubsec No_Exception_Registration
10228 @findex No_Exception_Registration
10229 [GNAT] This restriction ensures at compile time that no stream operations for
10230 types Exception_Id or Exception_Occurrence are used. This also makes it
10231 impossible to pass exceptions to or from a partition with this restriction
10232 in a distributed environment. If this exception is active, then the generated
10233 code is simplified by omitting the otherwise-required global registration
10234 of exceptions when they are declared.
10236 @node No_Exceptions
10237 @unnumberedsubsec No_Exceptions
10238 @findex No_Exceptions
10239 [RM H.4] This restriction ensures at compile time that there are no
10240 raise statements and no exception handlers.
10242 @node No_Finalization
10243 @unnumberedsubsec No_Finalization
10244 @findex No_Finalization
10245 [GNAT] This restriction disables the language features described in
10246 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10247 performed by the compiler to support these features. The following types
10248 are no longer considered controlled when this restriction is in effect:
10251 @code{Ada.Finalization.Controlled}
10253 @code{Ada.Finalization.Limited_Controlled}
10255 Derivations from @code{Controlled} or @code{Limited_Controlled}
10263 Array and record types with controlled components
10265 The compiler no longer generates code to initialize, finalize or adjust an
10266 object or a nested component, either declared on the stack or on the heap. The
10267 deallocation of a controlled object no longer finalizes its contents.
10269 @node No_Fixed_Point
10270 @unnumberedsubsec No_Fixed_Point
10271 @findex No_Fixed_Point
10272 [RM H.4] This restriction ensures at compile time that there are no
10273 occurrences of fixed point types and operations.
10275 @node No_Floating_Point
10276 @unnumberedsubsec No_Floating_Point
10277 @findex No_Floating_Point
10278 [RM H.4] This restriction ensures at compile time that there are no
10279 occurrences of floating point types and operations.
10281 @node No_Implicit_Conditionals
10282 @unnumberedsubsec No_Implicit_Conditionals
10283 @findex No_Implicit_Conditionals
10284 [GNAT] This restriction ensures that the generated code does not contain any
10285 implicit conditionals, either by modifying the generated code where possible,
10286 or by rejecting any construct that would otherwise generate an implicit
10287 conditional. Note that this check does not include run time constraint
10288 checks, which on some targets may generate implicit conditionals as
10289 well. To control the latter, constraint checks can be suppressed in the
10290 normal manner. Constructs generating implicit conditionals include comparisons
10291 of composite objects and the Max/Min attributes.
10293 @node No_Implicit_Dynamic_Code
10294 @unnumberedsubsec No_Implicit_Dynamic_Code
10295 @findex No_Implicit_Dynamic_Code
10297 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10298 This is a structure that is built on the stack and contains dynamic
10299 code to be executed at run time. On some targets, a trampoline is
10300 built for the following features: @code{Access},
10301 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10302 nested task bodies; primitive operations of nested tagged types.
10303 Trampolines do not work on machines that prevent execution of stack
10304 data. For example, on windows systems, enabling DEP (data execution
10305 protection) will cause trampolines to raise an exception.
10306 Trampolines are also quite slow at run time.
10308 On many targets, trampolines have been largely eliminated. Look at the
10309 version of system.ads for your target --- if it has
10310 Always_Compatible_Rep equal to False, then trampolines are largely
10311 eliminated. In particular, a trampoline is built for the following
10312 features: @code{Address} of a nested subprogram;
10313 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10314 but only if pragma Favor_Top_Level applies, or the access type has a
10315 foreign-language convention; primitive operations of nested tagged
10318 @node No_Implicit_Heap_Allocations
10319 @unnumberedsubsec No_Implicit_Heap_Allocations
10320 @findex No_Implicit_Heap_Allocations
10321 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10323 @node No_Implicit_Loops
10324 @unnumberedsubsec No_Implicit_Loops
10325 @findex No_Implicit_Loops
10326 [GNAT] This restriction ensures that the generated code does not contain any
10327 implicit @code{for} loops, either by modifying
10328 the generated code where possible,
10329 or by rejecting any construct that would otherwise generate an implicit
10330 @code{for} loop. If this restriction is active, it is possible to build
10331 large array aggregates with all static components without generating an
10332 intermediate temporary, and without generating a loop to initialize individual
10333 components. Otherwise, a loop is created for arrays larger than about 5000
10336 @node No_Initialize_Scalars
10337 @unnumberedsubsec No_Initialize_Scalars
10338 @findex No_Initialize_Scalars
10339 [GNAT] This restriction ensures that no unit in the partition is compiled with
10340 pragma Initialize_Scalars. This allows the generation of more efficient
10341 code, and in particular eliminates dummy null initialization routines that
10342 are otherwise generated for some record and array types.
10345 @unnumberedsubsec No_IO
10347 [RM H.4] This restriction ensures at compile time that there are no
10348 dependences on any of the library units Sequential_IO, Direct_IO,
10349 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10351 @node No_Local_Allocators
10352 @unnumberedsubsec No_Local_Allocators
10353 @findex No_Local_Allocators
10354 [RM H.4] This restriction ensures at compile time that there are no
10355 occurrences of an allocator in subprograms, generic subprograms, tasks,
10358 @node No_Local_Protected_Objects
10359 @unnumberedsubsec No_Local_Protected_Objects
10360 @findex No_Local_Protected_Objects
10361 [RM D.7] This restriction ensures at compile time that protected objects are
10362 only declared at the library level.
10364 @node No_Local_Timing_Events
10365 @unnumberedsubsec No_Local_Timing_Events
10366 @findex No_Local_Timing_Events
10367 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10368 declared at the library level.
10370 @node No_Nested_Finalization
10371 @unnumberedsubsec No_Nested_Finalization
10372 @findex No_Nested_Finalization
10373 [RM D.7] All objects requiring finalization are declared at the library level.
10375 @node No_Protected_Type_Allocators
10376 @unnumberedsubsec No_Protected_Type_Allocators
10377 @findex No_Protected_Type_Allocators
10378 [RM D.7] This restriction ensures at compile time that there are no allocator
10379 expressions that attempt to allocate protected objects.
10381 @node No_Protected_Types
10382 @unnumberedsubsec No_Protected_Types
10383 @findex No_Protected_Types
10384 [RM H.4] This restriction ensures at compile time that there are no
10385 declarations of protected types or protected objects.
10388 @unnumberedsubsec No_Recursion
10389 @findex No_Recursion
10390 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10391 part of its execution.
10393 @node No_Reentrancy
10394 @unnumberedsubsec No_Reentrancy
10395 @findex No_Reentrancy
10396 [RM H.4] A program execution is erroneous if a subprogram is executed by
10397 two tasks at the same time.
10399 @node No_Relative_Delay
10400 @unnumberedsubsec No_Relative_Delay
10401 @findex No_Relative_Delay
10402 [RM D.7] This restriction ensures at compile time that there are no delay
10403 relative statements and prevents expressions such as @code{delay 1.23;} from
10404 appearing in source code.
10406 @node No_Requeue_Statements
10407 @unnumberedsubsec No_Requeue_Statements
10408 @findex No_Requeue_Statements
10409 [RM D.7] This restriction ensures at compile time that no requeue statements
10410 are permitted and prevents keyword @code{requeue} from being used in source
10414 The restriction @code{No_Requeue} is recognized as a
10415 synonym for @code{No_Requeue_Statements}. This is retained for historical
10416 compatibility purposes (and a warning will be generated for its use if
10417 warnings on oNobsolescent features are activated).
10419 @node No_Secondary_Stack
10420 @unnumberedsubsec No_Secondary_Stack
10421 @findex No_Secondary_Stack
10422 [GNAT] This restriction ensures at compile time that the generated code
10423 does not contain any reference to the secondary stack. The secondary
10424 stack is used to implement functions returning unconstrained objects
10425 (arrays or records) on some targets.
10427 @node No_Select_Statements
10428 @unnumberedsubsec No_Select_Statements
10429 @findex No_Select_Statements
10430 [RM D.7] This restriction ensures at compile time no select statements of any
10431 kind are permitted, that is the keyword @code{select} may not appear.
10433 @node No_Specific_Termination_Handlers
10434 @unnumberedsubsec No_Specific_Termination_Handlers
10435 @findex No_Specific_Termination_Handlers
10436 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10437 or to Ada.Task_Termination.Specific_Handler.
10439 @node No_Specification_of_Aspect
10440 @unnumberedsubsec No_Specification_of_Aspect
10441 @findex No_Specification_of_Aspect
10442 [RM 13.12.1] This restriction checks at compile time that no aspect
10443 specification, attribute definition clause, or pragma is given for a
10446 @node No_Standard_Allocators_After_Elaboration
10447 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10448 @findex No_Standard_Allocators_After_Elaboration
10449 [RM D.7] Specifies that an allocator using a standard storage pool
10450 should never be evaluated at run time after the elaboration of the
10451 library items of the partition has completed. Otherwise, Storage_Error
10454 @node No_Standard_Storage_Pools
10455 @unnumberedsubsec No_Standard_Storage_Pools
10456 @findex No_Standard_Storage_Pools
10457 [GNAT] This restriction ensures at compile time that no access types
10458 use the standard default storage pool. Any access type declared must
10459 have an explicit Storage_Pool attribute defined specifying a
10460 user-defined storage pool.
10462 @node No_Stream_Optimizations
10463 @unnumberedsubsec No_Stream_Optimizations
10464 @findex No_Stream_Optimizations
10465 [GNAT] This restriction affects the performance of stream operations on types
10466 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10467 compiler uses block reads and writes when manipulating @code{String} objects
10468 due to their supperior performance. When this restriction is in effect, the
10469 compiler performs all IO operations on a per-character basis.
10472 @unnumberedsubsec No_Streams
10474 [GNAT] This restriction ensures at compile/bind time that there are no
10475 stream objects created and no use of stream attributes.
10476 This restriction does not forbid dependences on the package
10477 @code{Ada.Streams}. So it is permissible to with
10478 @code{Ada.Streams} (or another package that does so itself)
10479 as long as no actual stream objects are created and no
10480 stream attributes are used.
10482 Note that the use of restriction allows optimization of tagged types,
10483 since they do not need to worry about dispatching stream operations.
10484 To take maximum advantage of this space-saving optimization, any
10485 unit declaring a tagged type should be compiled with the restriction,
10486 though this is not required.
10488 @node No_Task_Allocators
10489 @unnumberedsubsec No_Task_Allocators
10490 @findex No_Task_Allocators
10491 [RM D.7] There are no allocators for task types
10492 or types containing task subcomponents.
10494 @node No_Task_Attributes_Package
10495 @unnumberedsubsec No_Task_Attributes_Package
10496 @findex No_Task_Attributes_Package
10497 [GNAT] This restriction ensures at compile time that there are no implicit or
10498 explicit dependencies on the package @code{Ada.Task_Attributes}.
10500 @findex No_Task_Attributes
10501 The restriction @code{No_Task_Attributes} is recognized as a synonym
10502 for @code{No_Task_Attributes_Package}. This is retained for historical
10503 compatibility purposes (and a warning will be generated for its use if
10504 warnings on obsolescent features are activated).
10506 @node No_Task_Hierarchy
10507 @unnumberedsubsec No_Task_Hierarchy
10508 @findex No_Task_Hierarchy
10509 [RM D.7] All (non-environment) tasks depend
10510 directly on the environment task of the partition.
10512 @node No_Task_Termination
10513 @unnumberedsubsec No_Task_Termination
10514 @findex No_Task_Termination
10515 [RM D.7] Tasks which terminate are erroneous.
10518 @unnumberedsubsec No_Tasking
10520 [GNAT] This restriction prevents the declaration of tasks or task types
10521 throughout the partition. It is similar in effect to the use of
10522 @code{Max_Tasks => 0} except that violations are caught at compile time
10523 and cause an error message to be output either by the compiler or
10526 @node No_Terminate_Alternatives
10527 @unnumberedsubsec No_Terminate_Alternatives
10528 @findex No_Terminate_Alternatives
10529 [RM D.7] There are no selective accepts with terminate alternatives.
10531 @node No_Unchecked_Access
10532 @unnumberedsubsec No_Unchecked_Access
10533 @findex No_Unchecked_Access
10534 [RM H.4] This restriction ensures at compile time that there are no
10535 occurrences of the Unchecked_Access attribute.
10537 @node Simple_Barriers
10538 @unnumberedsubsec Simple_Barriers
10539 @findex Simple_Barriers
10540 [RM D.7] This restriction ensures at compile time that barriers in entry
10541 declarations for protected types are restricted to either static boolean
10542 expressions or references to simple boolean variables defined in the private
10543 part of the protected type. No other form of entry barriers is permitted.
10545 @findex Boolean_Entry_Barriers
10546 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10547 synonym for @code{Simple_Barriers}. This is retained for historical
10548 compatibility purposes (and a warning will be generated for its use if
10549 warnings on obsolescent features are activated).
10551 @node Static_Priorities
10552 @unnumberedsubsec Static_Priorities
10553 @findex Static_Priorities
10554 [GNAT] This restriction ensures at compile time that all priority expressions
10555 are static, and that there are no dependences on the package
10556 @code{Ada.Dynamic_Priorities}.
10558 @node Static_Storage_Size
10559 @unnumberedsubsec Static_Storage_Size
10560 @findex Static_Storage_Size
10561 [GNAT] This restriction ensures at compile time that any expression appearing
10562 in a Storage_Size pragma or attribute definition clause is static.
10564 @node Program Unit Level Restrictions
10565 @section Program Unit Level Restrictions
10568 The second set of restriction identifiers
10569 does not require partition-wide consistency.
10570 The restriction may be enforced for a single
10571 compilation unit without any effect on any of the
10572 other compilation units in the partition.
10575 * No_Elaboration_Code::
10577 * No_Implementation_Aspect_Specifications::
10578 * No_Implementation_Attributes::
10579 * No_Implementation_Identifiers::
10580 * No_Implementation_Pragmas::
10581 * No_Implementation_Restrictions::
10582 * No_Implementation_Units::
10583 * No_Implicit_Aliasing::
10584 * No_Obsolescent_Features::
10585 * No_Wide_Characters::
10589 @node No_Elaboration_Code
10590 @unnumberedsubsec No_Elaboration_Code
10591 @findex No_Elaboration_Code
10592 [GNAT] This restriction ensures at compile time that no elaboration code is
10593 generated. Note that this is not the same condition as is enforced
10594 by pragma @code{Preelaborate}. There are cases in which pragma
10595 @code{Preelaborate} still permits code to be generated (e.g.@: code
10596 to initialize a large array to all zeroes), and there are cases of units
10597 which do not meet the requirements for pragma @code{Preelaborate},
10598 but for which no elaboration code is generated. Generally, it is
10599 the case that preelaborable units will meet the restrictions, with
10600 the exception of large aggregates initialized with an others_clause,
10601 and exception declarations (which generate calls to a run-time
10602 registry procedure). This restriction is enforced on
10603 a unit by unit basis, it need not be obeyed consistently
10604 throughout a partition.
10606 In the case of aggregates with others, if the aggregate has a dynamic
10607 size, there is no way to eliminate the elaboration code (such dynamic
10608 bounds would be incompatible with @code{Preelaborate} in any case). If
10609 the bounds are static, then use of this restriction actually modifies
10610 the code choice of the compiler to avoid generating a loop, and instead
10611 generate the aggregate statically if possible, no matter how many times
10612 the data for the others clause must be repeatedly generated.
10614 It is not possible to precisely document
10615 the constructs which are compatible with this restriction, since,
10616 unlike most other restrictions, this is not a restriction on the
10617 source code, but a restriction on the generated object code. For
10618 example, if the source contains a declaration:
10621 Val : constant Integer := X;
10625 where X is not a static constant, it may be possible, depending
10626 on complex optimization circuitry, for the compiler to figure
10627 out the value of X at compile time, in which case this initialization
10628 can be done by the loader, and requires no initialization code. It
10629 is not possible to document the precise conditions under which the
10630 optimizer can figure this out.
10632 Note that this the implementation of this restriction requires full
10633 code generation. If it is used in conjunction with "semantics only"
10634 checking, then some cases of violations may be missed.
10636 @node No_Entry_Queue
10637 @unnumberedsubsec No_Entry_Queue
10638 @findex No_Entry_Queue
10639 [GNAT] This restriction is a declaration that any protected entry compiled in
10640 the scope of the restriction has at most one task waiting on the entry
10641 at any one time, and so no queue is required. This restriction is not
10642 checked at compile time. A program execution is erroneous if an attempt
10643 is made to queue a second task on such an entry.
10645 @node No_Implementation_Aspect_Specifications
10646 @unnumberedsubsec No_Implementation_Aspect_Specifications
10647 @findex No_Implementation_Aspect_Specifications
10648 [RM 13.12.1] This restriction checks at compile time that no
10649 GNAT-defined aspects are present. With this restriction, the only
10650 aspects that can be used are those defined in the Ada Reference Manual.
10652 @node No_Implementation_Attributes
10653 @unnumberedsubsec No_Implementation_Attributes
10654 @findex No_Implementation_Attributes
10655 [RM 13.12.1] This restriction checks at compile time that no
10656 GNAT-defined attributes are present. With this restriction, the only
10657 attributes that can be used are those defined in the Ada Reference
10660 @node No_Implementation_Identifiers
10661 @unnumberedsubsec No_Implementation_Identifiers
10662 @findex No_Implementation_Identifiers
10663 [RM 13.12.1] This restriction checks at compile time that no
10664 implementation-defined identifiers (marked with pragma Implementation_Defined)
10665 occur within language-defined packages.
10667 @node No_Implementation_Pragmas
10668 @unnumberedsubsec No_Implementation_Pragmas
10669 @findex No_Implementation_Pragmas
10670 [RM 13.12.1] This restriction checks at compile time that no
10671 GNAT-defined pragmas are present. With this restriction, the only
10672 pragmas that can be used are those defined in the Ada Reference Manual.
10674 @node No_Implementation_Restrictions
10675 @unnumberedsubsec No_Implementation_Restrictions
10676 @findex No_Implementation_Restrictions
10677 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
10678 identifiers (other than @code{No_Implementation_Restrictions} itself)
10679 are present. With this restriction, the only other restriction identifiers
10680 that can be used are those defined in the Ada Reference Manual.
10682 @node No_Implementation_Units
10683 @unnumberedsubsec No_Implementation_Units
10684 @findex No_Implementation_Units
10685 [RM 13.12.1] This restriction checks at compile time that there is no
10686 mention in the context clause of any implementation-defined descendants
10687 of packages Ada, Interfaces, or System.
10689 @node No_Implicit_Aliasing
10690 @unnumberedsubsec No_Implicit_Aliasing
10691 @findex No_Implicit_Aliasing
10692 [GNAT] This restriction, which is not required to be partition-wide consistent,
10693 requires an explicit aliased keyword for an object to which 'Access,
10694 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
10695 the 'Unrestricted_Access attribute for objects. Note: the reason that
10696 Unrestricted_Access is forbidden is that it would require the prefix
10697 to be aliased, and in such cases, it can always be replaced by
10698 the standard attribute Unchecked_Access which is preferable.
10700 @node No_Obsolescent_Features
10701 @unnumberedsubsec No_Obsolescent_Features
10702 @findex No_Obsolescent_Features
10703 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10704 features are used, as defined in Annex J of the Ada Reference Manual.
10706 @node No_Wide_Characters
10707 @unnumberedsubsec No_Wide_Characters
10708 @findex No_Wide_Characters
10709 [GNAT] This restriction ensures at compile time that no uses of the types
10710 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10712 appear, and that no wide or wide wide string or character literals
10713 appear in the program (that is literals representing characters not in
10714 type @code{Character}).
10717 @unnumberedsubsec SPARK_05
10719 [GNAT] This restriction checks at compile time that some constructs
10720 forbidden in SPARK 2005 are not present. Error messages related to
10721 SPARK restriction have the form:
10724 The restriction @code{SPARK} is recognized as a
10725 synonym for @code{SPARK_05}. This is retained for historical
10726 compatibility purposes (and an unconditional warning will be generated
10727 for its use, advising replacement by @code{SPARK}.
10730 violation of restriction "SPARK" at <file>
10734 This is not a replacement for the semantic checks performed by the
10735 SPARK Examiner tool, as the compiler currently only deals with code,
10736 not SPARK 2005 annotations, and does not guarantee catching all
10737 cases of constructs forbidden by SPARK 2005.
10739 Thus it may well be the case that code which passes the compiler with
10740 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10741 the different visibility rules of the Examiner based on SPARK 2005
10742 @code{inherit} annotations.
10744 This restriction can be useful in providing an initial filter for code
10745 developed using SPARK 2005, or in examining legacy code to see how far
10746 it is from meeting SPARK restrictions.
10748 The list below summarises the checks that are performed when this
10749 restriction is in force:
10751 @item No block statements
10752 @item No case statements with only an others clause
10753 @item Exit statements in loops must respect the SPARK 2005 language restrictions
10754 @item No goto statements
10755 @item Return can only appear as last statement in function
10756 @item Function must have return statement
10757 @item Loop parameter specification must include subtype mark
10758 @item Prefix of expanded name cannot be a loop statement
10759 @item Abstract subprogram not allowed
10760 @item User-defined operators not allowed
10761 @item Access type parameters not allowed
10762 @item Default expressions for parameters not allowed
10763 @item Default expressions for record fields not allowed
10764 @item No tasking constructs allowed
10765 @item Label needed at end of subprograms and packages
10766 @item No mixing of positional and named parameter association
10767 @item No access types as result type
10768 @item No unconstrained arrays as result types
10769 @item No null procedures
10770 @item Initial and later declarations must be in correct order (declaration can't come after body)
10771 @item No attributes on private types if full declaration not visible
10772 @item No package declaration within package specification
10773 @item No controlled types
10774 @item No discriminant types
10775 @item No overloading
10776 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
10777 @item Access attribute not allowed
10778 @item Allocator not allowed
10779 @item Result of catenation must be String
10780 @item Operands of catenation must be string literal, static char or another catenation
10781 @item No conditional expressions
10782 @item No explicit dereference
10783 @item Quantified expression not allowed
10784 @item Slicing not allowed
10785 @item No exception renaming
10786 @item No generic renaming
10787 @item No object renaming
10788 @item No use clause
10789 @item Aggregates must be qualified
10790 @item Non-static choice in array aggregates not allowed
10791 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
10792 @item No mixing of positional and named association in aggregate, no multi choice
10793 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
10794 @item Fixed point operands to * or / must be qualified or converted
10795 @item Comparison operators not allowed for Booleans or arrays (except strings)
10796 @item Equality not allowed for arrays with non-matching static bounds (except strings)
10797 @item Conversion / qualification not allowed for arrays with non-matching static bounds
10798 @item Subprogram declaration only allowed in package spec (unless followed by import)
10799 @item Access types not allowed
10800 @item Incomplete type declaration not allowed
10801 @item Object and subtype declarations must respect SPARK restrictions
10802 @item Digits or delta constraint not allowed
10803 @item Decimal fixed point type not allowed
10804 @item Aliasing of objects not allowed
10805 @item Modular type modulus must be power of 2
10806 @item Base not allowed on subtype mark
10807 @item Unary operators not allowed on modular types (except not)
10808 @item Non-tagged record cannot be null
10809 @item No class-wide operations
10810 @item Initialization expressions must respect SPARK restrictions
10811 @item Non-static ranges not allowed except in iteration schemes
10812 @item String subtypes must have lower bound of 1
10813 @item Subtype of Boolean cannot have constraint
10814 @item At most one tagged type or extension per package
10815 @item Interface is not allowed
10816 @item Character literal cannot be prefixed (selector name cannot be character literal)
10817 @item Record aggregate cannot contain 'others'
10818 @item Component association in record aggregate must contain a single choice
10819 @item Ancestor part cannot be a type mark
10820 @item Attributes 'Image, 'Width and 'Value not allowed
10821 @item Functions may not update globals
10822 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
10823 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
10826 The following restrictions are enforced, but note that they are actually more
10827 strict that the latest SPARK 2005 language definition:
10830 @item No derived types other than tagged type extensions
10831 @item Subtype of unconstrained array must have constraint
10834 This list summarises the main SPARK 2005 language rules that are not
10835 currently checked by the SPARK_05 restriction:
10838 @item SPARK annotations are treated as comments so are not checked at all
10839 @item Based real literals not allowed
10840 @item Objects cannot be initialized at declaration by calls to user-defined functions
10841 @item Objects cannot be initialized at declaration by assignments from variables
10842 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
10843 @item Ranges shall not be null
10844 @item A fixed point delta expression must be a simple expression
10845 @item Restrictions on where renaming declarations may be placed
10846 @item Externals of mode 'out' cannot be referenced
10847 @item Externals of mode 'in' cannot be updated
10848 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
10849 @item Subprogram cannot have parent unit name
10850 @item SPARK 2005 inherited subprogram must be prefixed with overriding
10851 @item External variables (or functions that reference them) may not be passed as actual parameters
10852 @item Globals must be explicitly mentioned in contract
10853 @item Deferred constants cannot be completed by pragma Import
10854 @item Package initialization cannot read/write variables from other packages
10855 @item Prefix not allowed for entities that are directly visible
10856 @item Identifier declaration can't override inherited package name
10857 @item Cannot use Standard or other predefined packages as identifiers
10858 @item After renaming, cannot use the original name
10859 @item Subprograms can only be renamed to remove package prefix
10860 @item Pragma import must be immediately after entity it names
10861 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
10864 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
10865 violations will be reported for constructs forbidden in SPARK 95,
10866 instead of SPARK 2005.
10868 @c ------------------------
10869 @node Implementation Advice
10870 @chapter Implementation Advice
10872 The main text of the Ada Reference Manual describes the required
10873 behavior of all Ada compilers, and the GNAT compiler conforms to
10874 these requirements.
10876 In addition, there are sections throughout the Ada Reference Manual headed
10877 by the phrase ``Implementation advice''. These sections are not normative,
10878 i.e., they do not specify requirements that all compilers must
10879 follow. Rather they provide advice on generally desirable behavior. You
10880 may wonder why they are not requirements. The most typical answer is
10881 that they describe behavior that seems generally desirable, but cannot
10882 be provided on all systems, or which may be undesirable on some systems.
10884 As far as practical, GNAT follows the implementation advice sections in
10885 the Ada Reference Manual. This chapter contains a table giving the
10886 reference manual section number, paragraph number and several keywords
10887 for each advice. Each entry consists of the text of the advice followed
10888 by the GNAT interpretation of this advice. Most often, this simply says
10889 ``followed'', which means that GNAT follows the advice. However, in a
10890 number of cases, GNAT deliberately deviates from this advice, in which
10891 case the text describes what GNAT does and why.
10893 @cindex Error detection
10894 @unnumberedsec 1.1.3(20): Error Detection
10897 If an implementation detects the use of an unsupported Specialized Needs
10898 Annex feature at run time, it should raise @code{Program_Error} if
10901 Not relevant. All specialized needs annex features are either supported,
10902 or diagnosed at compile time.
10904 @cindex Child Units
10905 @unnumberedsec 1.1.3(31): Child Units
10908 If an implementation wishes to provide implementation-defined
10909 extensions to the functionality of a language-defined library unit, it
10910 should normally do so by adding children to the library unit.
10914 @cindex Bounded errors
10915 @unnumberedsec 1.1.5(12): Bounded Errors
10918 If an implementation detects a bounded error or erroneous
10919 execution, it should raise @code{Program_Error}.
10921 Followed in all cases in which the implementation detects a bounded
10922 error or erroneous execution. Not all such situations are detected at
10926 @unnumberedsec 2.8(16): Pragmas
10929 Normally, implementation-defined pragmas should have no semantic effect
10930 for error-free programs; that is, if the implementation-defined pragmas
10931 are removed from a working program, the program should still be legal,
10932 and should still have the same semantics.
10934 The following implementation defined pragmas are exceptions to this
10946 @item CPP_Constructor
10950 @item Interface_Name
10952 @item Machine_Attribute
10954 @item Unimplemented_Unit
10956 @item Unchecked_Union
10961 In each of the above cases, it is essential to the purpose of the pragma
10962 that this advice not be followed. For details see the separate section
10963 on implementation defined pragmas.
10965 @unnumberedsec 2.8(17-19): Pragmas
10968 Normally, an implementation should not define pragmas that can
10969 make an illegal program legal, except as follows:
10973 A pragma used to complete a declaration, such as a pragma @code{Import};
10977 A pragma used to configure the environment by adding, removing, or
10978 replacing @code{library_items}.
10980 See response to paragraph 16 of this same section.
10982 @cindex Character Sets
10983 @cindex Alternative Character Sets
10984 @unnumberedsec 3.5.2(5): Alternative Character Sets
10987 If an implementation supports a mode with alternative interpretations
10988 for @code{Character} and @code{Wide_Character}, the set of graphic
10989 characters of @code{Character} should nevertheless remain a proper
10990 subset of the set of graphic characters of @code{Wide_Character}. Any
10991 character set ``localizations'' should be reflected in the results of
10992 the subprograms defined in the language-defined package
10993 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
10994 an alternative interpretation of @code{Character}, the implementation should
10995 also support a corresponding change in what is a legal
10996 @code{identifier_letter}.
10998 Not all wide character modes follow this advice, in particular the JIS
10999 and IEC modes reflect standard usage in Japan, and in these encoding,
11000 the upper half of the Latin-1 set is not part of the wide-character
11001 subset, since the most significant bit is used for wide character
11002 encoding. However, this only applies to the external forms. Internally
11003 there is no such restriction.
11005 @cindex Integer types
11006 @unnumberedsec 3.5.4(28): Integer Types
11010 An implementation should support @code{Long_Integer} in addition to
11011 @code{Integer} if the target machine supports 32-bit (or longer)
11012 arithmetic. No other named integer subtypes are recommended for package
11013 @code{Standard}. Instead, appropriate named integer subtypes should be
11014 provided in the library package @code{Interfaces} (see B.2).
11016 @code{Long_Integer} is supported. Other standard integer types are supported
11017 so this advice is not fully followed. These types
11018 are supported for convenient interface to C, and so that all hardware
11019 types of the machine are easily available.
11020 @unnumberedsec 3.5.4(29): Integer Types
11024 An implementation for a two's complement machine should support
11025 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
11026 implementation should support a non-binary modules up to @code{Integer'Last}.
11030 @cindex Enumeration values
11031 @unnumberedsec 3.5.5(8): Enumeration Values
11034 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11035 subtype, if the value of the operand does not correspond to the internal
11036 code for any enumeration literal of its type (perhaps due to an
11037 un-initialized variable), then the implementation should raise
11038 @code{Program_Error}. This is particularly important for enumeration
11039 types with noncontiguous internal codes specified by an
11040 enumeration_representation_clause.
11044 @cindex Float types
11045 @unnumberedsec 3.5.7(17): Float Types
11048 An implementation should support @code{Long_Float} in addition to
11049 @code{Float} if the target machine supports 11 or more digits of
11050 precision. No other named floating point subtypes are recommended for
11051 package @code{Standard}. Instead, appropriate named floating point subtypes
11052 should be provided in the library package @code{Interfaces} (see B.2).
11054 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
11055 former provides improved compatibility with other implementations
11056 supporting this type. The latter corresponds to the highest precision
11057 floating-point type supported by the hardware. On most machines, this
11058 will be the same as @code{Long_Float}, but on some machines, it will
11059 correspond to the IEEE extended form. The notable case is all ia32
11060 (x86) implementations, where @code{Long_Long_Float} corresponds to
11061 the 80-bit extended precision format supported in hardware on this
11062 processor. Note that the 128-bit format on SPARC is not supported,
11063 since this is a software rather than a hardware format.
11065 @cindex Multidimensional arrays
11066 @cindex Arrays, multidimensional
11067 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11070 An implementation should normally represent multidimensional arrays in
11071 row-major order, consistent with the notation used for multidimensional
11072 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
11073 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11074 column-major order should be used instead (see B.5, ``Interfacing with
11079 @findex Duration'Small
11080 @unnumberedsec 9.6(30-31): Duration'Small
11083 Whenever possible in an implementation, the value of @code{Duration'Small}
11084 should be no greater than 100 microseconds.
11086 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
11090 The time base for @code{delay_relative_statements} should be monotonic;
11091 it need not be the same time base as used for @code{Calendar.Clock}.
11095 @unnumberedsec 10.2.1(12): Consistent Representation
11098 In an implementation, a type declared in a pre-elaborated package should
11099 have the same representation in every elaboration of a given version of
11100 the package, whether the elaborations occur in distinct executions of
11101 the same program, or in executions of distinct programs or partitions
11102 that include the given version.
11104 Followed, except in the case of tagged types. Tagged types involve
11105 implicit pointers to a local copy of a dispatch table, and these pointers
11106 have representations which thus depend on a particular elaboration of the
11107 package. It is not easy to see how it would be possible to follow this
11108 advice without severely impacting efficiency of execution.
11110 @cindex Exception information
11111 @unnumberedsec 11.4.1(19): Exception Information
11114 @code{Exception_Message} by default and @code{Exception_Information}
11115 should produce information useful for
11116 debugging. @code{Exception_Message} should be short, about one
11117 line. @code{Exception_Information} can be long. @code{Exception_Message}
11118 should not include the
11119 @code{Exception_Name}. @code{Exception_Information} should include both
11120 the @code{Exception_Name} and the @code{Exception_Message}.
11122 Followed. For each exception that doesn't have a specified
11123 @code{Exception_Message}, the compiler generates one containing the location
11124 of the raise statement. This location has the form ``file:line'', where
11125 file is the short file name (without path information) and line is the line
11126 number in the file. Note that in the case of the Zero Cost Exception
11127 mechanism, these messages become redundant with the Exception_Information that
11128 contains a full backtrace of the calling sequence, so they are disabled.
11129 To disable explicitly the generation of the source location message, use the
11130 Pragma @code{Discard_Names}.
11132 @cindex Suppression of checks
11133 @cindex Checks, suppression of
11134 @unnumberedsec 11.5(28): Suppression of Checks
11137 The implementation should minimize the code executed for checks that
11138 have been suppressed.
11142 @cindex Representation clauses
11143 @unnumberedsec 13.1 (21-24): Representation Clauses
11146 The recommended level of support for all representation items is
11147 qualified as follows:
11151 An implementation need not support representation items containing
11152 non-static expressions, except that an implementation should support a
11153 representation item for a given entity if each non-static expression in
11154 the representation item is a name that statically denotes a constant
11155 declared before the entity.
11157 Followed. In fact, GNAT goes beyond the recommended level of support
11158 by allowing nonstatic expressions in some representation clauses even
11159 without the need to declare constants initialized with the values of
11163 @smallexample @c ada
11166 for Y'Address use X'Address;>>
11171 An implementation need not support a specification for the @code{Size}
11172 for a given composite subtype, nor the size or storage place for an
11173 object (including a component) of a given composite subtype, unless the
11174 constraints on the subtype and its composite subcomponents (if any) are
11175 all static constraints.
11177 Followed. Size Clauses are not permitted on non-static components, as
11182 An aliased component, or a component whose type is by-reference, should
11183 always be allocated at an addressable location.
11187 @cindex Packed types
11188 @unnumberedsec 13.2(6-8): Packed Types
11191 If a type is packed, then the implementation should try to minimize
11192 storage allocated to objects of the type, possibly at the expense of
11193 speed of accessing components, subject to reasonable complexity in
11194 addressing calculations.
11198 The recommended level of support pragma @code{Pack} is:
11200 For a packed record type, the components should be packed as tightly as
11201 possible subject to the Sizes of the component subtypes, and subject to
11202 any @code{record_representation_clause} that applies to the type; the
11203 implementation may, but need not, reorder components or cross aligned
11204 word boundaries to improve the packing. A component whose @code{Size} is
11205 greater than the word size may be allocated an integral number of words.
11207 Followed. Tight packing of arrays is supported for all component sizes
11208 up to 64-bits. If the array component size is 1 (that is to say, if
11209 the component is a boolean type or an enumeration type with two values)
11210 then values of the type are implicitly initialized to zero. This
11211 happens both for objects of the packed type, and for objects that have a
11212 subcomponent of the packed type.
11216 An implementation should support Address clauses for imported
11220 @cindex @code{Address} clauses
11221 @unnumberedsec 13.3(14-19): Address Clauses
11225 For an array @var{X}, @code{@var{X}'Address} should point at the first
11226 component of the array, and not at the array bounds.
11232 The recommended level of support for the @code{Address} attribute is:
11234 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11235 object that is aliased or of a by-reference type, or is an entity whose
11236 @code{Address} has been specified.
11238 Followed. A valid address will be produced even if none of those
11239 conditions have been met. If necessary, the object is forced into
11240 memory to ensure the address is valid.
11244 An implementation should support @code{Address} clauses for imported
11251 Objects (including subcomponents) that are aliased or of a by-reference
11252 type should be allocated on storage element boundaries.
11258 If the @code{Address} of an object is specified, or it is imported or exported,
11259 then the implementation should not perform optimizations based on
11260 assumptions of no aliases.
11264 @cindex @code{Alignment} clauses
11265 @unnumberedsec 13.3(29-35): Alignment Clauses
11268 The recommended level of support for the @code{Alignment} attribute for
11271 An implementation should support specified Alignments that are factors
11272 and multiples of the number of storage elements per word, subject to the
11279 An implementation need not support specified @code{Alignment}s for
11280 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11281 loaded and stored by available machine instructions.
11287 An implementation need not support specified @code{Alignment}s that are
11288 greater than the maximum @code{Alignment} the implementation ever returns by
11295 The recommended level of support for the @code{Alignment} attribute for
11298 Same as above, for subtypes, but in addition:
11304 For stand-alone library-level objects of statically constrained
11305 subtypes, the implementation should support all @code{Alignment}s
11306 supported by the target linker. For example, page alignment is likely to
11307 be supported for such objects, but not for subtypes.
11311 @cindex @code{Size} clauses
11312 @unnumberedsec 13.3(42-43): Size Clauses
11315 The recommended level of support for the @code{Size} attribute of
11318 A @code{Size} clause should be supported for an object if the specified
11319 @code{Size} is at least as large as its subtype's @code{Size}, and
11320 corresponds to a size in storage elements that is a multiple of the
11321 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11325 @unnumberedsec 13.3(50-56): Size Clauses
11328 If the @code{Size} of a subtype is specified, and allows for efficient
11329 independent addressability (see 9.10) on the target architecture, then
11330 the @code{Size} of the following objects of the subtype should equal the
11331 @code{Size} of the subtype:
11333 Aliased objects (including components).
11339 @code{Size} clause on a composite subtype should not affect the
11340 internal layout of components.
11342 Followed. But note that this can be overridden by use of the implementation
11343 pragma Implicit_Packing in the case of packed arrays.
11347 The recommended level of support for the @code{Size} attribute of subtypes is:
11351 The @code{Size} (if not specified) of a static discrete or fixed point
11352 subtype should be the number of bits needed to represent each value
11353 belonging to the subtype using an unbiased representation, leaving space
11354 for a sign bit only if the subtype contains negative values. If such a
11355 subtype is a first subtype, then an implementation should support a
11356 specified @code{Size} for it that reflects this representation.
11362 For a subtype implemented with levels of indirection, the @code{Size}
11363 should include the size of the pointers, but not the size of what they
11368 @cindex @code{Component_Size} clauses
11369 @unnumberedsec 13.3(71-73): Component Size Clauses
11372 The recommended level of support for the @code{Component_Size}
11377 An implementation need not support specified @code{Component_Sizes} that are
11378 less than the @code{Size} of the component subtype.
11384 An implementation should support specified @code{Component_Size}s that
11385 are factors and multiples of the word size. For such
11386 @code{Component_Size}s, the array should contain no gaps between
11387 components. For other @code{Component_Size}s (if supported), the array
11388 should contain no gaps between components when packing is also
11389 specified; the implementation should forbid this combination in cases
11390 where it cannot support a no-gaps representation.
11394 @cindex Enumeration representation clauses
11395 @cindex Representation clauses, enumeration
11396 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11399 The recommended level of support for enumeration representation clauses
11402 An implementation need not support enumeration representation clauses
11403 for boolean types, but should at minimum support the internal codes in
11404 the range @code{System.Min_Int.System.Max_Int}.
11408 @cindex Record representation clauses
11409 @cindex Representation clauses, records
11410 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11413 The recommended level of support for
11414 @*@code{record_representation_clauses} is:
11416 An implementation should support storage places that can be extracted
11417 with a load, mask, shift sequence of machine code, and set with a load,
11418 shift, mask, store sequence, given the available machine instructions
11419 and run-time model.
11425 A storage place should be supported if its size is equal to the
11426 @code{Size} of the component subtype, and it starts and ends on a
11427 boundary that obeys the @code{Alignment} of the component subtype.
11433 If the default bit ordering applies to the declaration of a given type,
11434 then for a component whose subtype's @code{Size} is less than the word
11435 size, any storage place that does not cross an aligned word boundary
11436 should be supported.
11442 An implementation may reserve a storage place for the tag field of a
11443 tagged type, and disallow other components from overlapping that place.
11445 Followed. The storage place for the tag field is the beginning of the tagged
11446 record, and its size is Address'Size. GNAT will reject an explicit component
11447 clause for the tag field.
11451 An implementation need not support a @code{component_clause} for a
11452 component of an extension part if the storage place is not after the
11453 storage places of all components of the parent type, whether or not
11454 those storage places had been specified.
11456 Followed. The above advice on record representation clauses is followed,
11457 and all mentioned features are implemented.
11459 @cindex Storage place attributes
11460 @unnumberedsec 13.5.2(5): Storage Place Attributes
11463 If a component is represented using some form of pointer (such as an
11464 offset) to the actual data of the component, and this data is contiguous
11465 with the rest of the object, then the storage place attributes should
11466 reflect the place of the actual data, not the pointer. If a component is
11467 allocated discontinuously from the rest of the object, then a warning
11468 should be generated upon reference to one of its storage place
11471 Followed. There are no such components in GNAT@.
11473 @cindex Bit ordering
11474 @unnumberedsec 13.5.3(7-8): Bit Ordering
11477 The recommended level of support for the non-default bit ordering is:
11481 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11482 should support the non-default bit ordering in addition to the default
11485 Followed. Word size does not equal storage size in this implementation.
11486 Thus non-default bit ordering is not supported.
11488 @cindex @code{Address}, as private type
11489 @unnumberedsec 13.7(37): Address as Private
11492 @code{Address} should be of a private type.
11496 @cindex Operations, on @code{Address}
11497 @cindex @code{Address}, operations of
11498 @unnumberedsec 13.7.1(16): Address Operations
11501 Operations in @code{System} and its children should reflect the target
11502 environment semantics as closely as is reasonable. For example, on most
11503 machines, it makes sense for address arithmetic to ``wrap around''.
11504 Operations that do not make sense should raise @code{Program_Error}.
11506 Followed. Address arithmetic is modular arithmetic that wraps around. No
11507 operation raises @code{Program_Error}, since all operations make sense.
11509 @cindex Unchecked conversion
11510 @unnumberedsec 13.9(14-17): Unchecked Conversion
11513 The @code{Size} of an array object should not include its bounds; hence,
11514 the bounds should not be part of the converted data.
11520 The implementation should not generate unnecessary run-time checks to
11521 ensure that the representation of @var{S} is a representation of the
11522 target type. It should take advantage of the permission to return by
11523 reference when possible. Restrictions on unchecked conversions should be
11524 avoided unless required by the target environment.
11526 Followed. There are no restrictions on unchecked conversion. A warning is
11527 generated if the source and target types do not have the same size since
11528 the semantics in this case may be target dependent.
11532 The recommended level of support for unchecked conversions is:
11536 Unchecked conversions should be supported and should be reversible in
11537 the cases where this clause defines the result. To enable meaningful use
11538 of unchecked conversion, a contiguous representation should be used for
11539 elementary subtypes, for statically constrained array subtypes whose
11540 component subtype is one of the subtypes described in this paragraph,
11541 and for record subtypes without discriminants whose component subtypes
11542 are described in this paragraph.
11546 @cindex Heap usage, implicit
11547 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11550 An implementation should document any cases in which it dynamically
11551 allocates heap storage for a purpose other than the evaluation of an
11554 Followed, the only other points at which heap storage is dynamically
11555 allocated are as follows:
11559 At initial elaboration time, to allocate dynamically sized global
11563 To allocate space for a task when a task is created.
11566 To extend the secondary stack dynamically when needed. The secondary
11567 stack is used for returning variable length results.
11572 A default (implementation-provided) storage pool for an
11573 access-to-constant type should not have overhead to support deallocation of
11574 individual objects.
11580 A storage pool for an anonymous access type should be created at the
11581 point of an allocator for the type, and be reclaimed when the designated
11582 object becomes inaccessible.
11586 @cindex Unchecked deallocation
11587 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11590 For a standard storage pool, @code{Free} should actually reclaim the
11595 @cindex Stream oriented attributes
11596 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11599 If a stream element is the same size as a storage element, then the
11600 normal in-memory representation should be used by @code{Read} and
11601 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
11602 should use the smallest number of stream elements needed to represent
11603 all values in the base range of the scalar type.
11606 Followed. By default, GNAT uses the interpretation suggested by AI-195,
11607 which specifies using the size of the first subtype.
11608 However, such an implementation is based on direct binary
11609 representations and is therefore target- and endianness-dependent.
11610 To address this issue, GNAT also supplies an alternate implementation
11611 of the stream attributes @code{Read} and @code{Write},
11612 which uses the target-independent XDR standard representation
11614 @cindex XDR representation
11615 @cindex @code{Read} attribute
11616 @cindex @code{Write} attribute
11617 @cindex Stream oriented attributes
11618 The XDR implementation is provided as an alternative body of the
11619 @code{System.Stream_Attributes} package, in the file
11620 @file{s-stratt-xdr.adb} in the GNAT library.
11621 There is no @file{s-stratt-xdr.ads} file.
11622 In order to install the XDR implementation, do the following:
11624 @item Replace the default implementation of the
11625 @code{System.Stream_Attributes} package with the XDR implementation.
11626 For example on a Unix platform issue the commands:
11628 $ mv s-stratt.adb s-stratt-default.adb
11629 $ mv s-stratt-xdr.adb s-stratt.adb
11633 Rebuild the GNAT run-time library as documented in
11634 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11637 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11640 If an implementation provides additional named predefined integer types,
11641 then the names should end with @samp{Integer} as in
11642 @samp{Long_Integer}. If an implementation provides additional named
11643 predefined floating point types, then the names should end with
11644 @samp{Float} as in @samp{Long_Float}.
11648 @findex Ada.Characters.Handling
11649 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11652 If an implementation provides a localized definition of @code{Character}
11653 or @code{Wide_Character}, then the effects of the subprograms in
11654 @code{Characters.Handling} should reflect the localizations. See also
11657 Followed. GNAT provides no such localized definitions.
11659 @cindex Bounded-length strings
11660 @unnumberedsec A.4.4(106): Bounded-Length String Handling
11663 Bounded string objects should not be implemented by implicit pointers
11664 and dynamic allocation.
11666 Followed. No implicit pointers or dynamic allocation are used.
11668 @cindex Random number generation
11669 @unnumberedsec A.5.2(46-47): Random Number Generation
11672 Any storage associated with an object of type @code{Generator} should be
11673 reclaimed on exit from the scope of the object.
11679 If the generator period is sufficiently long in relation to the number
11680 of distinct initiator values, then each possible value of
11681 @code{Initiator} passed to @code{Reset} should initiate a sequence of
11682 random numbers that does not, in a practical sense, overlap the sequence
11683 initiated by any other value. If this is not possible, then the mapping
11684 between initiator values and generator states should be a rapidly
11685 varying function of the initiator value.
11687 Followed. The generator period is sufficiently long for the first
11688 condition here to hold true.
11690 @findex Get_Immediate
11691 @unnumberedsec A.10.7(23): @code{Get_Immediate}
11694 The @code{Get_Immediate} procedures should be implemented with
11695 unbuffered input. For a device such as a keyboard, input should be
11696 @dfn{available} if a key has already been typed, whereas for a disk
11697 file, input should always be available except at end of file. For a file
11698 associated with a keyboard-like device, any line-editing features of the
11699 underlying operating system should be disabled during the execution of
11700 @code{Get_Immediate}.
11702 Followed on all targets except VxWorks. For VxWorks, there is no way to
11703 provide this functionality that does not result in the input buffer being
11704 flushed before the @code{Get_Immediate} call. A special unit
11705 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
11706 this functionality.
11709 @unnumberedsec B.1(39-41): Pragma @code{Export}
11712 If an implementation supports pragma @code{Export} to a given language,
11713 then it should also allow the main subprogram to be written in that
11714 language. It should support some mechanism for invoking the elaboration
11715 of the Ada library units included in the system, and for invoking the
11716 finalization of the environment task. On typical systems, the
11717 recommended mechanism is to provide two subprograms whose link names are
11718 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
11719 elaboration code for library units. @code{adafinal} should contain the
11720 finalization code. These subprograms should have no effect the second
11721 and subsequent time they are called.
11727 Automatic elaboration of pre-elaborated packages should be
11728 provided when pragma @code{Export} is supported.
11730 Followed when the main program is in Ada. If the main program is in a
11731 foreign language, then
11732 @code{adainit} must be called to elaborate pre-elaborated
11737 For each supported convention @var{L} other than @code{Intrinsic}, an
11738 implementation should support @code{Import} and @code{Export} pragmas
11739 for objects of @var{L}-compatible types and for subprograms, and pragma
11740 @code{Convention} for @var{L}-eligible types and for subprograms,
11741 presuming the other language has corresponding features. Pragma
11742 @code{Convention} need not be supported for scalar types.
11746 @cindex Package @code{Interfaces}
11748 @unnumberedsec B.2(12-13): Package @code{Interfaces}
11751 For each implementation-defined convention identifier, there should be a
11752 child package of package Interfaces with the corresponding name. This
11753 package should contain any declarations that would be useful for
11754 interfacing to the language (implementation) represented by the
11755 convention. Any declarations useful for interfacing to any language on
11756 the given hardware architecture should be provided directly in
11759 Followed. An additional package not defined
11760 in the Ada Reference Manual is @code{Interfaces.CPP}, used
11761 for interfacing to C++.
11765 An implementation supporting an interface to C, COBOL, or Fortran should
11766 provide the corresponding package or packages described in the following
11769 Followed. GNAT provides all the packages described in this section.
11771 @cindex C, interfacing with
11772 @unnumberedsec B.3(63-71): Interfacing with C
11775 An implementation should support the following interface correspondences
11776 between Ada and C@.
11782 An Ada procedure corresponds to a void-returning C function.
11788 An Ada function corresponds to a non-void C function.
11794 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
11801 An Ada @code{in} parameter of an access-to-object type with designated
11802 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
11803 where @var{t} is the C type corresponding to the Ada type @var{T}.
11809 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
11810 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
11811 argument to a C function, where @var{t} is the C type corresponding to
11812 the Ada type @var{T}. In the case of an elementary @code{out} or
11813 @code{in out} parameter, a pointer to a temporary copy is used to
11814 preserve by-copy semantics.
11820 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11821 @code{@var{t}*} argument to a C function, where @var{t} is the C
11822 structure corresponding to the Ada type @var{T}.
11824 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
11825 pragma, or Convention, or by explicitly specifying the mechanism for a given
11826 call using an extended import or export pragma.
11830 An Ada parameter of an array type with component type @var{T}, of any
11831 mode, is passed as a @code{@var{t}*} argument to a C function, where
11832 @var{t} is the C type corresponding to the Ada type @var{T}.
11838 An Ada parameter of an access-to-subprogram type is passed as a pointer
11839 to a C function whose prototype corresponds to the designated
11840 subprogram's specification.
11844 @cindex COBOL, interfacing with
11845 @unnumberedsec B.4(95-98): Interfacing with COBOL
11848 An Ada implementation should support the following interface
11849 correspondences between Ada and COBOL@.
11855 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11856 the COBOL type corresponding to @var{T}.
11862 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11863 the corresponding COBOL type.
11869 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11870 COBOL type corresponding to the Ada parameter type; for scalars, a local
11871 copy is used if necessary to ensure by-copy semantics.
11875 @cindex Fortran, interfacing with
11876 @unnumberedsec B.5(22-26): Interfacing with Fortran
11879 An Ada implementation should support the following interface
11880 correspondences between Ada and Fortran:
11886 An Ada procedure corresponds to a Fortran subroutine.
11892 An Ada function corresponds to a Fortran function.
11898 An Ada parameter of an elementary, array, or record type @var{T} is
11899 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11900 the Fortran type corresponding to the Ada type @var{T}, and where the
11901 INTENT attribute of the corresponding dummy argument matches the Ada
11902 formal parameter mode; the Fortran implementation's parameter passing
11903 conventions are used. For elementary types, a local copy is used if
11904 necessary to ensure by-copy semantics.
11910 An Ada parameter of an access-to-subprogram type is passed as a
11911 reference to a Fortran procedure whose interface corresponds to the
11912 designated subprogram's specification.
11916 @cindex Machine operations
11917 @unnumberedsec C.1(3-5): Access to Machine Operations
11920 The machine code or intrinsic support should allow access to all
11921 operations normally available to assembly language programmers for the
11922 target environment, including privileged instructions, if any.
11928 The interfacing pragmas (see Annex B) should support interface to
11929 assembler; the default assembler should be associated with the
11930 convention identifier @code{Assembler}.
11936 If an entity is exported to assembly language, then the implementation
11937 should allocate it at an addressable location, and should ensure that it
11938 is retained by the linking process, even if not otherwise referenced
11939 from the Ada code. The implementation should assume that any call to a
11940 machine code or assembler subprogram is allowed to read or update every
11941 object that is specified as exported.
11945 @unnumberedsec C.1(10-16): Access to Machine Operations
11948 The implementation should ensure that little or no overhead is
11949 associated with calling intrinsic and machine-code subprograms.
11951 Followed for both intrinsics and machine-code subprograms.
11955 It is recommended that intrinsic subprograms be provided for convenient
11956 access to any machine operations that provide special capabilities or
11957 efficiency and that are not otherwise available through the language
11960 Followed. A full set of machine operation intrinsic subprograms is provided.
11964 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11965 swap, decrement and test, enqueue/dequeue.
11967 Followed on any target supporting such operations.
11971 Standard numeric functions---e.g.@:, sin, log.
11973 Followed on any target supporting such operations.
11977 String manipulation operations---e.g.@:, translate and test.
11979 Followed on any target supporting such operations.
11983 Vector operations---e.g.@:, compare vector against thresholds.
11985 Followed on any target supporting such operations.
11989 Direct operations on I/O ports.
11991 Followed on any target supporting such operations.
11993 @cindex Interrupt support
11994 @unnumberedsec C.3(28): Interrupt Support
11997 If the @code{Ceiling_Locking} policy is not in effect, the
11998 implementation should provide means for the application to specify which
11999 interrupts are to be blocked during protected actions, if the underlying
12000 system allows for a finer-grain control of interrupt blocking.
12002 Followed. The underlying system does not allow for finer-grain control
12003 of interrupt blocking.
12005 @cindex Protected procedure handlers
12006 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12009 Whenever possible, the implementation should allow interrupt handlers to
12010 be called directly by the hardware.
12012 Followed on any target where the underlying operating system permits
12017 Whenever practical, violations of any
12018 implementation-defined restrictions should be detected before run time.
12020 Followed. Compile time warnings are given when possible.
12022 @cindex Package @code{Interrupts}
12024 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12028 If implementation-defined forms of interrupt handler procedures are
12029 supported, such as protected procedures with parameters, then for each
12030 such form of a handler, a type analogous to @code{Parameterless_Handler}
12031 should be specified in a child package of @code{Interrupts}, with the
12032 same operations as in the predefined package Interrupts.
12036 @cindex Pre-elaboration requirements
12037 @unnumberedsec C.4(14): Pre-elaboration Requirements
12040 It is recommended that pre-elaborated packages be implemented in such a
12041 way that there should be little or no code executed at run time for the
12042 elaboration of entities not already covered by the Implementation
12045 Followed. Executable code is generated in some cases, e.g.@: loops
12046 to initialize large arrays.
12048 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12051 If the pragma applies to an entity, then the implementation should
12052 reduce the amount of storage used for storing names associated with that
12057 @cindex Package @code{Task_Attributes}
12058 @findex Task_Attributes
12059 @unnumberedsec C.7.2(30): The Package Task_Attributes
12062 Some implementations are targeted to domains in which memory use at run
12063 time must be completely deterministic. For such implementations, it is
12064 recommended that the storage for task attributes will be pre-allocated
12065 statically and not from the heap. This can be accomplished by either
12066 placing restrictions on the number and the size of the task's
12067 attributes, or by using the pre-allocated storage for the first @var{N}
12068 attribute objects, and the heap for the others. In the latter case,
12069 @var{N} should be documented.
12071 Not followed. This implementation is not targeted to such a domain.
12073 @cindex Locking Policies
12074 @unnumberedsec D.3(17): Locking Policies
12078 The implementation should use names that end with @samp{_Locking} for
12079 locking policies defined by the implementation.
12081 Followed. Two implementation-defined locking policies are defined,
12082 whose names (@code{Inheritance_Locking} and
12083 @code{Concurrent_Readers_Locking}) follow this suggestion.
12085 @cindex Entry queuing policies
12086 @unnumberedsec D.4(16): Entry Queuing Policies
12089 Names that end with @samp{_Queuing} should be used
12090 for all implementation-defined queuing policies.
12092 Followed. No such implementation-defined queuing policies exist.
12094 @cindex Preemptive abort
12095 @unnumberedsec D.6(9-10): Preemptive Abort
12098 Even though the @code{abort_statement} is included in the list of
12099 potentially blocking operations (see 9.5.1), it is recommended that this
12100 statement be implemented in a way that never requires the task executing
12101 the @code{abort_statement} to block.
12107 On a multi-processor, the delay associated with aborting a task on
12108 another processor should be bounded; the implementation should use
12109 periodic polling, if necessary, to achieve this.
12113 @cindex Tasking restrictions
12114 @unnumberedsec D.7(21): Tasking Restrictions
12117 When feasible, the implementation should take advantage of the specified
12118 restrictions to produce a more efficient implementation.
12120 GNAT currently takes advantage of these restrictions by providing an optimized
12121 run time when the Ravenscar profile and the GNAT restricted run time set
12122 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
12123 pragma @code{Profile (Restricted)} for more details.
12125 @cindex Time, monotonic
12126 @unnumberedsec D.8(47-49): Monotonic Time
12129 When appropriate, implementations should provide configuration
12130 mechanisms to change the value of @code{Tick}.
12132 Such configuration mechanisms are not appropriate to this implementation
12133 and are thus not supported.
12137 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12138 be implemented as transformations of the same time base.
12144 It is recommended that the @dfn{best} time base which exists in
12145 the underlying system be available to the application through
12146 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
12150 @cindex Partition communication subsystem
12152 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12155 Whenever possible, the PCS on the called partition should allow for
12156 multiple tasks to call the RPC-receiver with different messages and
12157 should allow them to block until the corresponding subprogram body
12160 Followed by GLADE, a separately supplied PCS that can be used with
12165 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12166 should raise @code{Storage_Error} if it runs out of space trying to
12167 write the @code{Item} into the stream.
12169 Followed by GLADE, a separately supplied PCS that can be used with
12172 @cindex COBOL support
12173 @unnumberedsec F(7): COBOL Support
12176 If COBOL (respectively, C) is widely supported in the target
12177 environment, implementations supporting the Information Systems Annex
12178 should provide the child package @code{Interfaces.COBOL} (respectively,
12179 @code{Interfaces.C}) specified in Annex B and should support a
12180 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12181 pragmas (see Annex B), thus allowing Ada programs to interface with
12182 programs written in that language.
12186 @cindex Decimal radix support
12187 @unnumberedsec F.1(2): Decimal Radix Support
12190 Packed decimal should be used as the internal representation for objects
12191 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12193 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
12197 @unnumberedsec G: Numerics
12200 If Fortran (respectively, C) is widely supported in the target
12201 environment, implementations supporting the Numerics Annex
12202 should provide the child package @code{Interfaces.Fortran} (respectively,
12203 @code{Interfaces.C}) specified in Annex B and should support a
12204 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12205 pragmas (see Annex B), thus allowing Ada programs to interface with
12206 programs written in that language.
12210 @cindex Complex types
12211 @unnumberedsec G.1.1(56-58): Complex Types
12214 Because the usual mathematical meaning of multiplication of a complex
12215 operand and a real operand is that of the scaling of both components of
12216 the former by the latter, an implementation should not perform this
12217 operation by first promoting the real operand to complex type and then
12218 performing a full complex multiplication. In systems that, in the
12219 future, support an Ada binding to IEC 559:1989, the latter technique
12220 will not generate the required result when one of the components of the
12221 complex operand is infinite. (Explicit multiplication of the infinite
12222 component by the zero component obtained during promotion yields a NaN
12223 that propagates into the final result.) Analogous advice applies in the
12224 case of multiplication of a complex operand and a pure-imaginary
12225 operand, and in the case of division of a complex operand by a real or
12226 pure-imaginary operand.
12232 Similarly, because the usual mathematical meaning of addition of a
12233 complex operand and a real operand is that the imaginary operand remains
12234 unchanged, an implementation should not perform this operation by first
12235 promoting the real operand to complex type and then performing a full
12236 complex addition. In implementations in which the @code{Signed_Zeros}
12237 attribute of the component type is @code{True} (and which therefore
12238 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12239 predefined arithmetic operations), the latter technique will not
12240 generate the required result when the imaginary component of the complex
12241 operand is a negatively signed zero. (Explicit addition of the negative
12242 zero to the zero obtained during promotion yields a positive zero.)
12243 Analogous advice applies in the case of addition of a complex operand
12244 and a pure-imaginary operand, and in the case of subtraction of a
12245 complex operand and a real or pure-imaginary operand.
12251 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12252 attempt to provide a rational treatment of the signs of zero results and
12253 result components. As one example, the result of the @code{Argument}
12254 function should have the sign of the imaginary component of the
12255 parameter @code{X} when the point represented by that parameter lies on
12256 the positive real axis; as another, the sign of the imaginary component
12257 of the @code{Compose_From_Polar} function should be the same as
12258 (respectively, the opposite of) that of the @code{Argument} parameter when that
12259 parameter has a value of zero and the @code{Modulus} parameter has a
12260 nonnegative (respectively, negative) value.
12264 @cindex Complex elementary functions
12265 @unnumberedsec G.1.2(49): Complex Elementary Functions
12268 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12269 @code{True} should attempt to provide a rational treatment of the signs
12270 of zero results and result components. For example, many of the complex
12271 elementary functions have components that are odd functions of one of
12272 the parameter components; in these cases, the result component should
12273 have the sign of the parameter component at the origin. Other complex
12274 elementary functions have zero components whose sign is opposite that of
12275 a parameter component at the origin, or is always positive or always
12280 @cindex Accuracy requirements
12281 @unnumberedsec G.2.4(19): Accuracy Requirements
12284 The versions of the forward trigonometric functions without a
12285 @code{Cycle} parameter should not be implemented by calling the
12286 corresponding version with a @code{Cycle} parameter of
12287 @code{2.0*Numerics.Pi}, since this will not provide the required
12288 accuracy in some portions of the domain. For the same reason, the
12289 version of @code{Log} without a @code{Base} parameter should not be
12290 implemented by calling the corresponding version with a @code{Base}
12291 parameter of @code{Numerics.e}.
12295 @cindex Complex arithmetic accuracy
12296 @cindex Accuracy, complex arithmetic
12297 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12301 The version of the @code{Compose_From_Polar} function without a
12302 @code{Cycle} parameter should not be implemented by calling the
12303 corresponding version with a @code{Cycle} parameter of
12304 @code{2.0*Numerics.Pi}, since this will not provide the required
12305 accuracy in some portions of the domain.
12309 @cindex Sequential elaboration policy
12310 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12314 If the partition elaboration policy is @code{Sequential} and the
12315 Environment task becomes permanently blocked during elaboration then the
12316 partition is deadlocked and it is recommended that the partition be
12317 immediately terminated.
12321 @c -----------------------------------------
12322 @node Implementation Defined Characteristics
12323 @chapter Implementation Defined Characteristics
12326 In addition to the implementation dependent pragmas and attributes, and the
12327 implementation advice, there are a number of other Ada features that are
12328 potentially implementation dependent and are designated as
12329 implementation-defined. These are mentioned throughout the Ada Reference
12330 Manual, and are summarized in Annex M@.
12332 A requirement for conforming Ada compilers is that they provide
12333 documentation describing how the implementation deals with each of these
12334 issues. In this chapter you will find each point in Annex M listed,
12335 followed by a description of how GNAT
12336 handles the implementation dependence.
12338 You can use this chapter as a guide to minimizing implementation
12339 dependent features in your programs if portability to other compilers
12340 and other operating systems is an important consideration. The numbers
12341 in each entry below correspond to the paragraph numbers in the Ada
12350 Whether or not each recommendation given in Implementation
12351 Advice is followed. See 1.1.2(37).
12354 @xref{Implementation Advice}.
12361 Capacity limitations of the implementation. See 1.1.3(3).
12364 The complexity of programs that can be processed is limited only by the
12365 total amount of available virtual memory, and disk space for the
12366 generated object files.
12373 Variations from the standard that are impractical to avoid
12374 given the implementation's execution environment. See 1.1.3(6).
12377 There are no variations from the standard.
12384 Which @code{code_statement}s cause external
12385 interactions. See 1.1.3(10).
12388 Any @code{code_statement} can potentially cause external interactions.
12394 The coded representation for the text of an Ada
12395 program. See 2.1(4).
12398 See separate section on source representation.
12405 The control functions allowed in comments. See 2.1(14).
12408 See separate section on source representation.
12414 The representation for an end of line. See 2.2(2).
12417 See separate section on source representation.
12423 Maximum supported line length and lexical element
12424 length. See 2.2(15).
12427 The maximum line length is 255 characters and the maximum length of
12428 a lexical element is also 255 characters. This is the default setting
12429 if not overridden by the use of compiler switch @option{-gnaty} (which
12430 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12431 line length to be specified to be any value up to 32767. The maximum
12432 length of a lexical element is the same as the maximum line length.
12438 Implementation defined pragmas. See 2.8(14).
12442 @xref{Implementation Defined Pragmas}.
12448 Effect of pragma @code{Optimize}. See 2.8(27).
12451 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12452 parameter, checks that the optimization flag is set, and aborts if it is
12459 The sequence of characters of the value returned by
12460 @code{@var{S}'Image} when some of the graphic characters of
12461 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
12465 The sequence of characters is as defined by the wide character encoding
12466 method used for the source. See section on source representation for
12473 The predefined integer types declared in
12474 @code{Standard}. See 3.5.4(25).
12478 @item Short_Short_Integer
12480 @item Short_Integer
12481 (Short) 16 bit signed
12485 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12486 32 bit signed (all other targets)
12487 @item Long_Long_Integer
12495 Any nonstandard integer types and the operators defined
12496 for them. See 3.5.4(26).
12499 There are no nonstandard integer types.
12505 Any nonstandard real types and the operators defined for
12506 them. See 3.5.6(8).
12509 There are no nonstandard real types.
12515 What combinations of requested decimal precision and range
12516 are supported for floating point types. See 3.5.7(7).
12519 The precision and range is as defined by the IEEE standard.
12525 The predefined floating point types declared in
12526 @code{Standard}. See 3.5.7(16).
12533 (Short) 32 bit IEEE short
12536 @item Long_Long_Float
12537 64 bit IEEE long (80 bit IEEE long on x86 processors)
12544 The small of an ordinary fixed point type. See 3.5.9(8).
12547 @code{Fine_Delta} is 2**(@minus{}63)
12553 What combinations of small, range, and digits are
12554 supported for fixed point types. See 3.5.9(10).
12557 Any combinations are permitted that do not result in a small less than
12558 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12559 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12560 is 64 bits (true of all architectures except ia32), then the output from
12561 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
12562 is because floating-point conversions are used to convert fixed point.
12568 The result of @code{Tags.Expanded_Name} for types declared
12569 within an unnamed @code{block_statement}. See 3.9(10).
12572 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12573 decimal integer are allocated.
12579 Implementation-defined attributes. See 4.1.4(12).
12582 @xref{Implementation Defined Attributes}.
12588 Any implementation-defined time types. See 9.6(6).
12591 There are no implementation-defined time types.
12597 The time base associated with relative delays.
12600 See 9.6(20). The time base used is that provided by the C library
12601 function @code{gettimeofday}.
12607 The time base of the type @code{Calendar.Time}. See
12611 The time base used is that provided by the C library function
12612 @code{gettimeofday}.
12618 The time zone used for package @code{Calendar}
12619 operations. See 9.6(24).
12622 The time zone used by package @code{Calendar} is the current system time zone
12623 setting for local time, as accessed by the C library function
12630 Any limit on @code{delay_until_statements} of
12631 @code{select_statements}. See 9.6(29).
12634 There are no such limits.
12640 Whether or not two non-overlapping parts of a composite
12641 object are independently addressable, in the case where packing, record
12642 layout, or @code{Component_Size} is specified for the object. See
12646 Separate components are independently addressable if they do not share
12647 overlapping storage units.
12653 The representation for a compilation. See 10.1(2).
12656 A compilation is represented by a sequence of files presented to the
12657 compiler in a single invocation of the @command{gcc} command.
12663 Any restrictions on compilations that contain multiple
12664 compilation_units. See 10.1(4).
12667 No single file can contain more than one compilation unit, but any
12668 sequence of files can be presented to the compiler as a single
12675 The mechanisms for creating an environment and for adding
12676 and replacing compilation units. See 10.1.4(3).
12679 See separate section on compilation model.
12685 The manner of explicitly assigning library units to a
12686 partition. See 10.2(2).
12689 If a unit contains an Ada main program, then the Ada units for the partition
12690 are determined by recursive application of the rules in the Ada Reference
12691 Manual section 10.2(2-6). In other words, the Ada units will be those that
12692 are needed by the main program, and then this definition of need is applied
12693 recursively to those units, and the partition contains the transitive
12694 closure determined by this relationship. In short, all the necessary units
12695 are included, with no need to explicitly specify the list. If additional
12696 units are required, e.g.@: by foreign language units, then all units must be
12697 mentioned in the context clause of one of the needed Ada units.
12699 If the partition contains no main program, or if the main program is in
12700 a language other than Ada, then GNAT
12701 provides the binder options @option{-z} and @option{-n} respectively, and in
12702 this case a list of units can be explicitly supplied to the binder for
12703 inclusion in the partition (all units needed by these units will also
12704 be included automatically). For full details on the use of these
12705 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
12706 @value{EDITION} User's Guide}.
12712 The implementation-defined means, if any, of specifying
12713 which compilation units are needed by a given compilation unit. See
12717 The units needed by a given compilation unit are as defined in
12718 the Ada Reference Manual section 10.2(2-6). There are no
12719 implementation-defined pragmas or other implementation-defined
12720 means for specifying needed units.
12726 The manner of designating the main subprogram of a
12727 partition. See 10.2(7).
12730 The main program is designated by providing the name of the
12731 corresponding @file{ALI} file as the input parameter to the binder.
12737 The order of elaboration of @code{library_items}. See
12741 The first constraint on ordering is that it meets the requirements of
12742 Chapter 10 of the Ada Reference Manual. This still leaves some
12743 implementation dependent choices, which are resolved by first
12744 elaborating bodies as early as possible (i.e., in preference to specs
12745 where there is a choice), and second by evaluating the immediate with
12746 clauses of a unit to determine the probably best choice, and
12747 third by elaborating in alphabetical order of unit names
12748 where a choice still remains.
12754 Parameter passing and function return for the main
12755 subprogram. See 10.2(21).
12758 The main program has no parameters. It may be a procedure, or a function
12759 returning an integer type. In the latter case, the returned integer
12760 value is the return code of the program (overriding any value that
12761 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
12767 The mechanisms for building and running partitions. See
12771 GNAT itself supports programs with only a single partition. The GNATDIST
12772 tool provided with the GLADE package (which also includes an implementation
12773 of the PCS) provides a completely flexible method for building and running
12774 programs consisting of multiple partitions. See the separate GLADE manual
12781 The details of program execution, including program
12782 termination. See 10.2(25).
12785 See separate section on compilation model.
12791 The semantics of any non-active partitions supported by the
12792 implementation. See 10.2(28).
12795 Passive partitions are supported on targets where shared memory is
12796 provided by the operating system. See the GLADE reference manual for
12803 The information returned by @code{Exception_Message}. See
12807 Exception message returns the null string unless a specific message has
12808 been passed by the program.
12814 The result of @code{Exceptions.Exception_Name} for types
12815 declared within an unnamed @code{block_statement}. See 11.4.1(12).
12818 Blocks have implementation defined names of the form @code{B@var{nnn}}
12819 where @var{nnn} is an integer.
12825 The information returned by
12826 @code{Exception_Information}. See 11.4.1(13).
12829 @code{Exception_Information} returns a string in the following format:
12832 @emph{Exception_Name:} nnnnn
12833 @emph{Message:} mmmmm
12835 @emph{Load address:} 0xhhhh
12836 @emph{Call stack traceback locations:}
12837 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
12845 @code{nnnn} is the fully qualified name of the exception in all upper
12846 case letters. This line is always present.
12849 @code{mmmm} is the message (this line present only if message is non-null)
12852 @code{ppp} is the Process Id value as a decimal integer (this line is
12853 present only if the Process Id is nonzero). Currently we are
12854 not making use of this field.
12857 The Load address line, the Call stack traceback locations line and the
12858 following values are present only if at least one traceback location was
12859 recorded. The Load address indicates the address at which the main executable
12860 was loaded; this line may not be present if operating system hasn't relocated
12861 the main executable. The values are given in C style format, with lower case
12862 letters for a-f, and only as many digits present as are necessary.
12866 The line terminator sequence at the end of each line, including
12867 the last line is a single @code{LF} character (@code{16#0A#}).
12873 Implementation-defined check names. See 11.5(27).
12876 The implementation defined check name Alignment_Check controls checking of
12877 address clause values for proper alignment (that is, the address supplied
12878 must be consistent with the alignment of the type).
12880 The implementation defined check name Predicate_Check controls whether
12881 predicate checks are generated.
12883 The implementation defined check name Validity_Check controls whether
12884 validity checks are generated.
12886 In addition, a user program can add implementation-defined check names
12887 by means of the pragma Check_Name.
12893 The interpretation of each aspect of representation. See
12897 See separate section on data representations.
12903 Any restrictions placed upon representation items. See
12907 See separate section on data representations.
12913 The meaning of @code{Size} for indefinite subtypes. See
12917 Size for an indefinite subtype is the maximum possible size, except that
12918 for the case of a subprogram parameter, the size of the parameter object
12919 is the actual size.
12925 The default external representation for a type tag. See
12929 The default external representation for a type tag is the fully expanded
12930 name of the type in upper case letters.
12936 What determines whether a compilation unit is the same in
12937 two different partitions. See 13.3(76).
12940 A compilation unit is the same in two different partitions if and only
12941 if it derives from the same source file.
12947 Implementation-defined components. See 13.5.1(15).
12950 The only implementation defined component is the tag for a tagged type,
12951 which contains a pointer to the dispatching table.
12957 If @code{Word_Size} = @code{Storage_Unit}, the default bit
12958 ordering. See 13.5.3(5).
12961 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12962 implementation, so no non-default bit ordering is supported. The default
12963 bit ordering corresponds to the natural endianness of the target architecture.
12969 The contents of the visible part of package @code{System}
12970 and its language-defined children. See 13.7(2).
12973 See the definition of these packages in files @file{system.ads} and
12974 @file{s-stoele.ads}.
12980 The contents of the visible part of package
12981 @code{System.Machine_Code}, and the meaning of
12982 @code{code_statements}. See 13.8(7).
12985 See the definition and documentation in file @file{s-maccod.ads}.
12991 The effect of unchecked conversion. See 13.9(11).
12994 Unchecked conversion between types of the same size
12995 results in an uninterpreted transmission of the bits from one type
12996 to the other. If the types are of unequal sizes, then in the case of
12997 discrete types, a shorter source is first zero or sign extended as
12998 necessary, and a shorter target is simply truncated on the left.
12999 For all non-discrete types, the source is first copied if necessary
13000 to ensure that the alignment requirements of the target are met, then
13001 a pointer is constructed to the source value, and the result is obtained
13002 by dereferencing this pointer after converting it to be a pointer to the
13003 target type. Unchecked conversions where the target subtype is an
13004 unconstrained array are not permitted. If the target alignment is
13005 greater than the source alignment, then a copy of the result is
13006 made with appropriate alignment
13012 The semantics of operations on invalid representations.
13016 For assignments and other operations where the use of invalid values cannot
13017 result in erroneous behavior, the compiler ignores the possibility of invalid
13018 values. An exception is raised at the point where an invalid value would
13019 result in erroneous behavior. For example executing:
13021 @smallexample @c ada
13022 procedure invalidvals is
13024 Y : Natural range 1 .. 10;
13025 for Y'Address use X'Address;
13026 Z : Natural range 1 .. 10;
13027 A : array (Natural range 1 .. 10) of Integer;
13029 Z := Y; -- no exception
13030 A (Z) := 3; -- exception raised;
13035 As indicated, an exception is raised on the array assignment, but not
13036 on the simple assignment of the invalid negative value from Y to Z.
13042 The manner of choosing a storage pool for an access type
13043 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
13046 There are 3 different standard pools used by the compiler when
13047 @code{Storage_Pool} is not specified depending whether the type is local
13048 to a subprogram or defined at the library level and whether
13049 @code{Storage_Size}is specified or not. See documentation in the runtime
13050 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13051 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13052 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13053 default pools used.
13059 Whether or not the implementation provides user-accessible
13060 names for the standard pool type(s). See 13.11(17).
13064 See documentation in the sources of the run time mentioned in the previous
13065 paragraph. All these pools are accessible by means of @code{with}'ing
13072 The meaning of @code{Storage_Size}. See 13.11(18).
13075 @code{Storage_Size} is measured in storage units, and refers to the
13076 total space available for an access type collection, or to the primary
13077 stack space for a task.
13083 Implementation-defined aspects of storage pools. See
13087 See documentation in the sources of the run time mentioned in the
13088 paragraph about standard storage pools above
13089 for details on GNAT-defined aspects of storage pools.
13095 The set of restrictions allowed in a pragma
13096 @code{Restrictions}. See 13.12(7).
13099 @xref{Standard and Implementation Defined Restrictions}.
13105 The consequences of violating limitations on
13106 @code{Restrictions} pragmas. See 13.12(9).
13109 Restrictions that can be checked at compile time result in illegalities
13110 if violated. Currently there are no other consequences of violating
13117 The representation used by the @code{Read} and
13118 @code{Write} attributes of elementary types in terms of stream
13119 elements. See 13.13.2(9).
13122 The representation is the in-memory representation of the base type of
13123 the type, using the number of bits corresponding to the
13124 @code{@var{type}'Size} value, and the natural ordering of the machine.
13130 The names and characteristics of the numeric subtypes
13131 declared in the visible part of package @code{Standard}. See A.1(3).
13134 See items describing the integer and floating-point types supported.
13140 The string returned by @code{Character_Set_Version}.
13144 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13145 the string "Unicode 4.0", referring to version 4.0 of the
13146 Unicode specification.
13152 The accuracy actually achieved by the elementary
13153 functions. See A.5.1(1).
13156 The elementary functions correspond to the functions available in the C
13157 library. Only fast math mode is implemented.
13163 The sign of a zero result from some of the operators or
13164 functions in @code{Numerics.Generic_Elementary_Functions}, when
13165 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
13168 The sign of zeroes follows the requirements of the IEEE 754 standard on
13176 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
13179 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13186 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
13189 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13195 The algorithms for random number generation. See
13199 The algorithm is the Mersenne Twister, as documented in the source file
13200 @file{s-rannum.adb}. This version of the algorithm has a period of
13207 The string representation of a random number generator's
13208 state. See A.5.2(38).
13211 The value returned by the Image function is the concatenation of
13212 the fixed-width decimal representations of the 624 32-bit integers
13213 of the state vector.
13219 The minimum time interval between calls to the
13220 time-dependent Reset procedure that are guaranteed to initiate different
13221 random number sequences. See A.5.2(45).
13224 The minimum period between reset calls to guarantee distinct series of
13225 random numbers is one microsecond.
13231 The values of the @code{Model_Mantissa},
13232 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13233 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13234 Annex is not supported. See A.5.3(72).
13237 Run the compiler with @option{-gnatS} to produce a listing of package
13238 @code{Standard}, has the values of all numeric attributes.
13244 Any implementation-defined characteristics of the
13245 input-output packages. See A.7(14).
13248 There are no special implementation defined characteristics for these
13255 The value of @code{Buffer_Size} in @code{Storage_IO}. See
13259 All type representations are contiguous, and the @code{Buffer_Size} is
13260 the value of @code{@var{type}'Size} rounded up to the next storage unit
13267 External files for standard input, standard output, and
13268 standard error See A.10(5).
13271 These files are mapped onto the files provided by the C streams
13272 libraries. See source file @file{i-cstrea.ads} for further details.
13278 The accuracy of the value produced by @code{Put}. See
13282 If more digits are requested in the output than are represented by the
13283 precision of the value, zeroes are output in the corresponding least
13284 significant digit positions.
13290 The meaning of @code{Argument_Count}, @code{Argument}, and
13291 @code{Command_Name}. See A.15(1).
13294 These are mapped onto the @code{argv} and @code{argc} parameters of the
13295 main program in the natural manner.
13301 The interpretation of the @code{Form} parameter in procedure
13302 @code{Create_Directory}. See A.16(56).
13305 The @code{Form} parameter is not used.
13311 The interpretation of the @code{Form} parameter in procedure
13312 @code{Create_Path}. See A.16(60).
13315 The @code{Form} parameter is not used.
13321 The interpretation of the @code{Form} parameter in procedure
13322 @code{Copy_File}. See A.16(68).
13325 The @code{Form} parameter is case-insensitive.
13327 Two fields are recognized in the @code{Form} parameter:
13331 @item preserve=<value>
13338 <value> starts immediately after the character '=' and ends with the
13339 character immediately preceding the next comma (',') or with the last
13340 character of the parameter.
13342 The only possible values for preserve= are:
13346 @item no_attributes
13347 Do not try to preserve any file attributes. This is the default if no
13348 preserve= is found in Form.
13350 @item all_attributes
13351 Try to preserve all file attributes (timestamps, access rights).
13354 Preserve the timestamp of the copied file, but not the other file attributes.
13359 The only possible values for mode= are:
13364 Only do the copy if the destination file does not already exist. If it already
13365 exists, Copy_File fails.
13368 Copy the file in all cases. Overwrite an already existing destination file.
13371 Append the original file to the destination file. If the destination file does
13372 not exist, the destination file is a copy of the source file. When mode=append,
13373 the field preserve=, if it exists, is not taken into account.
13378 If the Form parameter includes one or both of the fields and the value or
13379 values are incorrect, Copy_file fails with Use_Error.
13381 Examples of correct Forms:
13384 Form => "preserve=no_attributes,mode=overwrite" (the default)
13385 Form => "mode=append"
13386 Form => "mode=copy, preserve=all_attributes"
13390 Examples of incorrect Forms
13393 Form => "preserve=junk"
13394 Form => "mode=internal, preserve=timestamps"
13401 The interpretation of the @code{Pattern} parameter, when not the null string,
13402 in the @code{Start_Search} and @code{Search} procedures.
13403 See A.16(104) and A.16(112).
13406 When the @code{Pattern} parameter is not the null string, it is interpreted
13407 according to the syntax of regular expressions as defined in the
13408 @code{GNAT.Regexp} package.
13409 @xref{GNAT.Regexp (g-regexp.ads)}.
13415 Implementation-defined convention names. See B.1(11).
13418 The following convention names are supported
13423 @item Ada_Pass_By_Copy
13424 Allowed for any types except by-reference types such as limited
13425 records. Compatible with convention Ada, but causes any parameters
13426 with this convention to be passed by copy.
13427 @item Ada_Pass_By_Reference
13428 Allowed for any types except by-copy types such as scalars.
13429 Compatible with convention Ada, but causes any parameters
13430 with this convention to be passed by reference.
13434 Synonym for Assembler
13436 Synonym for Assembler
13439 @item C_Pass_By_Copy
13440 Allowed only for record types, like C, but also notes that record
13441 is to be passed by copy rather than reference.
13444 @item C_Plus_Plus (or CPP)
13447 Treated the same as C
13449 Treated the same as C
13453 For support of pragma @code{Import} with convention Intrinsic, see
13454 separate section on Intrinsic Subprograms.
13456 Stdcall (used for Windows implementations only). This convention correspond
13457 to the WINAPI (previously called Pascal convention) C/C++ convention under
13458 Windows. A routine with this convention cleans the stack before
13459 exit. This pragma cannot be applied to a dispatching call.
13461 Synonym for Stdcall
13463 Synonym for Stdcall
13465 Stubbed is a special convention used to indicate that the body of the
13466 subprogram will be entirely ignored. Any call to the subprogram
13467 is converted into a raise of the @code{Program_Error} exception. If a
13468 pragma @code{Import} specifies convention @code{stubbed} then no body need
13469 be present at all. This convention is useful during development for the
13470 inclusion of subprograms whose body has not yet been written.
13474 In addition, all otherwise unrecognized convention names are also
13475 treated as being synonymous with convention C@. In all implementations
13476 except for VMS, use of such other names results in a warning. In VMS
13477 implementations, these names are accepted silently.
13483 The meaning of link names. See B.1(36).
13486 Link names are the actual names used by the linker.
13492 The manner of choosing link names when neither the link
13493 name nor the address of an imported or exported entity is specified. See
13497 The default linker name is that which would be assigned by the relevant
13498 external language, interpreting the Ada name as being in all lower case
13505 The effect of pragma @code{Linker_Options}. See B.1(37).
13508 The string passed to @code{Linker_Options} is presented uninterpreted as
13509 an argument to the link command, unless it contains ASCII.NUL characters.
13510 NUL characters if they appear act as argument separators, so for example
13512 @smallexample @c ada
13513 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13517 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13518 linker. The order of linker options is preserved for a given unit. The final
13519 list of options passed to the linker is in reverse order of the elaboration
13520 order. For example, linker options for a body always appear before the options
13521 from the corresponding package spec.
13527 The contents of the visible part of package
13528 @code{Interfaces} and its language-defined descendants. See B.2(1).
13531 See files with prefix @file{i-} in the distributed library.
13537 Implementation-defined children of package
13538 @code{Interfaces}. The contents of the visible part of package
13539 @code{Interfaces}. See B.2(11).
13542 See files with prefix @file{i-} in the distributed library.
13548 The types @code{Floating}, @code{Long_Floating},
13549 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13550 @code{COBOL_Character}; and the initialization of the variables
13551 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13552 @code{Interfaces.COBOL}. See B.4(50).
13558 @item Long_Floating
13559 (Floating) Long_Float
13564 @item Decimal_Element
13566 @item COBOL_Character
13571 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13577 Support for access to machine instructions. See C.1(1).
13580 See documentation in file @file{s-maccod.ads} in the distributed library.
13586 Implementation-defined aspects of access to machine
13587 operations. See C.1(9).
13590 See documentation in file @file{s-maccod.ads} in the distributed library.
13596 Implementation-defined aspects of interrupts. See C.3(2).
13599 Interrupts are mapped to signals or conditions as appropriate. See
13601 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13602 on the interrupts supported on a particular target.
13608 Implementation-defined aspects of pre-elaboration. See
13612 GNAT does not permit a partition to be restarted without reloading,
13613 except under control of the debugger.
13619 The semantics of pragma @code{Discard_Names}. See C.5(7).
13622 Pragma @code{Discard_Names} causes names of enumeration literals to
13623 be suppressed. In the presence of this pragma, the Image attribute
13624 provides the image of the Pos of the literal, and Value accepts
13631 The result of the @code{Task_Identification.Image}
13632 attribute. See C.7.1(7).
13635 The result of this attribute is a string that identifies
13636 the object or component that denotes a given task. If a variable @code{Var}
13637 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
13639 is the hexadecimal representation of the virtual address of the corresponding
13640 task control block. If the variable is an array of tasks, the image of each
13641 task will have the form of an indexed component indicating the position of a
13642 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
13643 component of a record, the image of the task will have the form of a selected
13644 component. These rules are fully recursive, so that the image of a task that
13645 is a subcomponent of a composite object corresponds to the expression that
13646 designates this task.
13648 If a task is created by an allocator, its image depends on the context. If the
13649 allocator is part of an object declaration, the rules described above are used
13650 to construct its image, and this image is not affected by subsequent
13651 assignments. If the allocator appears within an expression, the image
13652 includes only the name of the task type.
13654 If the configuration pragma Discard_Names is present, or if the restriction
13655 No_Implicit_Heap_Allocation is in effect, the image reduces to
13656 the numeric suffix, that is to say the hexadecimal representation of the
13657 virtual address of the control block of the task.
13662 The value of @code{Current_Task} when in a protected entry
13663 or interrupt handler. See C.7.1(17).
13666 Protected entries or interrupt handlers can be executed by any
13667 convenient thread, so the value of @code{Current_Task} is undefined.
13673 The effect of calling @code{Current_Task} from an entry
13674 body or interrupt handler. See C.7.1(19).
13677 The effect of calling @code{Current_Task} from an entry body or
13678 interrupt handler is to return the identification of the task currently
13679 executing the code.
13685 Implementation-defined aspects of
13686 @code{Task_Attributes}. See C.7.2(19).
13689 There are no implementation-defined aspects of @code{Task_Attributes}.
13695 Values of all @code{Metrics}. See D(2).
13698 The metrics information for GNAT depends on the performance of the
13699 underlying operating system. The sources of the run-time for tasking
13700 implementation, together with the output from @option{-gnatG} can be
13701 used to determine the exact sequence of operating systems calls made
13702 to implement various tasking constructs. Together with appropriate
13703 information on the performance of the underlying operating system,
13704 on the exact target in use, this information can be used to determine
13705 the required metrics.
13711 The declarations of @code{Any_Priority} and
13712 @code{Priority}. See D.1(11).
13715 See declarations in file @file{system.ads}.
13721 Implementation-defined execution resources. See D.1(15).
13724 There are no implementation-defined execution resources.
13730 Whether, on a multiprocessor, a task that is waiting for
13731 access to a protected object keeps its processor busy. See D.2.1(3).
13734 On a multi-processor, a task that is waiting for access to a protected
13735 object does not keep its processor busy.
13741 The affect of implementation defined execution resources
13742 on task dispatching. See D.2.1(9).
13745 Tasks map to threads in the threads package used by GNAT@. Where possible
13746 and appropriate, these threads correspond to native threads of the
13747 underlying operating system.
13753 Implementation-defined @code{policy_identifiers} allowed
13754 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
13757 There are no implementation-defined policy-identifiers allowed in this
13764 Implementation-defined aspects of priority inversion. See
13768 Execution of a task cannot be preempted by the implementation processing
13769 of delay expirations for lower priority tasks.
13775 Implementation-defined task dispatching. See D.2.2(18).
13778 The policy is the same as that of the underlying threads implementation.
13784 Implementation-defined @code{policy_identifiers} allowed
13785 in a pragma @code{Locking_Policy}. See D.3(4).
13788 The two implementation defined policies permitted in GNAT are
13789 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
13790 targets that support the @code{Inheritance_Locking} policy, locking is
13791 implemented by inheritance, i.e.@: the task owning the lock operates
13792 at a priority equal to the highest priority of any task currently
13793 requesting the lock. On targets that support the
13794 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
13795 read/write lock allowing multiple propected object functions to enter
13802 Default ceiling priorities. See D.3(10).
13805 The ceiling priority of protected objects of the type
13806 @code{System.Interrupt_Priority'Last} as described in the Ada
13807 Reference Manual D.3(10),
13813 The ceiling of any protected object used internally by
13814 the implementation. See D.3(16).
13817 The ceiling priority of internal protected objects is
13818 @code{System.Priority'Last}.
13824 Implementation-defined queuing policies. See D.4(1).
13827 There are no implementation-defined queuing policies.
13833 On a multiprocessor, any conditions that cause the
13834 completion of an aborted construct to be delayed later than what is
13835 specified for a single processor. See D.6(3).
13838 The semantics for abort on a multi-processor is the same as on a single
13839 processor, there are no further delays.
13845 Any operations that implicitly require heap storage
13846 allocation. See D.7(8).
13849 The only operation that implicitly requires heap storage allocation is
13856 Implementation-defined aspects of pragma
13857 @code{Restrictions}. See D.7(20).
13860 There are no such implementation-defined aspects.
13866 Implementation-defined aspects of package
13867 @code{Real_Time}. See D.8(17).
13870 There are no implementation defined aspects of package @code{Real_Time}.
13876 Implementation-defined aspects of
13877 @code{delay_statements}. See D.9(8).
13880 Any difference greater than one microsecond will cause the task to be
13881 delayed (see D.9(7)).
13887 The upper bound on the duration of interrupt blocking
13888 caused by the implementation. See D.12(5).
13891 The upper bound is determined by the underlying operating system. In
13892 no cases is it more than 10 milliseconds.
13898 The means for creating and executing distributed
13899 programs. See E(5).
13902 The GLADE package provides a utility GNATDIST for creating and executing
13903 distributed programs. See the GLADE reference manual for further details.
13909 Any events that can result in a partition becoming
13910 inaccessible. See E.1(7).
13913 See the GLADE reference manual for full details on such events.
13919 The scheduling policies, treatment of priorities, and
13920 management of shared resources between partitions in certain cases. See
13924 See the GLADE reference manual for full details on these aspects of
13925 multi-partition execution.
13931 Events that cause the version of a compilation unit to
13932 change. See E.3(5).
13935 Editing the source file of a compilation unit, or the source files of
13936 any units on which it is dependent in a significant way cause the version
13937 to change. No other actions cause the version number to change. All changes
13938 are significant except those which affect only layout, capitalization or
13945 Whether the execution of the remote subprogram is
13946 immediately aborted as a result of cancellation. See E.4(13).
13949 See the GLADE reference manual for details on the effect of abort in
13950 a distributed application.
13956 Implementation-defined aspects of the PCS@. See E.5(25).
13959 See the GLADE reference manual for a full description of all implementation
13960 defined aspects of the PCS@.
13966 Implementation-defined interfaces in the PCS@. See
13970 See the GLADE reference manual for a full description of all
13971 implementation defined interfaces.
13977 The values of named numbers in the package
13978 @code{Decimal}. See F.2(7).
13990 @item Max_Decimal_Digits
13998 The value of @code{Max_Picture_Length} in the package
13999 @code{Text_IO.Editing}. See F.3.3(16).
14008 The value of @code{Max_Picture_Length} in the package
14009 @code{Wide_Text_IO.Editing}. See F.3.4(5).
14018 The accuracy actually achieved by the complex elementary
14019 functions and by other complex arithmetic operations. See G.1(1).
14022 Standard library functions are used for the complex arithmetic
14023 operations. Only fast math mode is currently supported.
14029 The sign of a zero result (or a component thereof) from
14030 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14031 @code{Real'Signed_Zeros} is True. See G.1.1(53).
14034 The signs of zero values are as recommended by the relevant
14035 implementation advice.
14041 The sign of a zero result (or a component thereof) from
14042 any operator or function in
14043 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14044 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
14047 The signs of zero values are as recommended by the relevant
14048 implementation advice.
14054 Whether the strict mode or the relaxed mode is the
14055 default. See G.2(2).
14058 The strict mode is the default. There is no separate relaxed mode. GNAT
14059 provides a highly efficient implementation of strict mode.
14065 The result interval in certain cases of fixed-to-float
14066 conversion. See G.2.1(10).
14069 For cases where the result interval is implementation dependent, the
14070 accuracy is that provided by performing all operations in 64-bit IEEE
14071 floating-point format.
14077 The result of a floating point arithmetic operation in
14078 overflow situations, when the @code{Machine_Overflows} attribute of the
14079 result type is @code{False}. See G.2.1(13).
14082 Infinite and NaN values are produced as dictated by the IEEE
14083 floating-point standard.
14085 Note that on machines that are not fully compliant with the IEEE
14086 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14087 must be used for achieving IEEE conforming behavior (although at the cost
14088 of a significant performance penalty), so infinite and NaN values are
14089 properly generated.
14095 The result interval for division (or exponentiation by a
14096 negative exponent), when the floating point hardware implements division
14097 as multiplication by a reciprocal. See G.2.1(16).
14100 Not relevant, division is IEEE exact.
14106 The definition of close result set, which determines the
14107 accuracy of certain fixed point multiplications and divisions. See
14111 Operations in the close result set are performed using IEEE long format
14112 floating-point arithmetic. The input operands are converted to
14113 floating-point, the operation is done in floating-point, and the result
14114 is converted to the target type.
14120 Conditions on a @code{universal_real} operand of a fixed
14121 point multiplication or division for which the result shall be in the
14122 perfect result set. See G.2.3(22).
14125 The result is only defined to be in the perfect result set if the result
14126 can be computed by a single scaling operation involving a scale factor
14127 representable in 64-bits.
14133 The result of a fixed point arithmetic operation in
14134 overflow situations, when the @code{Machine_Overflows} attribute of the
14135 result type is @code{False}. See G.2.3(27).
14138 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14145 The result of an elementary function reference in
14146 overflow situations, when the @code{Machine_Overflows} attribute of the
14147 result type is @code{False}. See G.2.4(4).
14150 IEEE infinite and Nan values are produced as appropriate.
14156 The value of the angle threshold, within which certain
14157 elementary functions, complex arithmetic operations, and complex
14158 elementary functions yield results conforming to a maximum relative
14159 error bound. See G.2.4(10).
14162 Information on this subject is not yet available.
14168 The accuracy of certain elementary functions for
14169 parameters beyond the angle threshold. See G.2.4(10).
14172 Information on this subject is not yet available.
14178 The result of a complex arithmetic operation or complex
14179 elementary function reference in overflow situations, when the
14180 @code{Machine_Overflows} attribute of the corresponding real type is
14181 @code{False}. See G.2.6(5).
14184 IEEE infinite and Nan values are produced as appropriate.
14190 The accuracy of certain complex arithmetic operations and
14191 certain complex elementary functions for parameters (or components
14192 thereof) beyond the angle threshold. See G.2.6(8).
14195 Information on those subjects is not yet available.
14201 Information regarding bounded errors and erroneous
14202 execution. See H.2(1).
14205 Information on this subject is not yet available.
14211 Implementation-defined aspects of pragma
14212 @code{Inspection_Point}. See H.3.2(8).
14215 Pragma @code{Inspection_Point} ensures that the variable is live and can
14216 be examined by the debugger at the inspection point.
14222 Implementation-defined aspects of pragma
14223 @code{Restrictions}. See H.4(25).
14226 There are no implementation-defined aspects of pragma @code{Restrictions}. The
14227 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14228 generated code. Checks must suppressed by use of pragma @code{Suppress}.
14234 Any restrictions on pragma @code{Restrictions}. See
14238 There are no restrictions on pragma @code{Restrictions}.
14243 @c =======================
14244 @node Intrinsic Subprograms
14245 @chapter Intrinsic Subprograms
14246 @cindex Intrinsic Subprograms
14249 * Intrinsic Operators::
14250 * Enclosing_Entity::
14251 * Exception_Information::
14252 * Exception_Message::
14256 * Shifts and Rotates::
14257 * Source_Location::
14261 GNAT allows a user application program to write the declaration:
14263 @smallexample @c ada
14264 pragma Import (Intrinsic, name);
14268 providing that the name corresponds to one of the implemented intrinsic
14269 subprograms in GNAT, and that the parameter profile of the referenced
14270 subprogram meets the requirements. This chapter describes the set of
14271 implemented intrinsic subprograms, and the requirements on parameter profiles.
14272 Note that no body is supplied; as with other uses of pragma Import, the
14273 body is supplied elsewhere (in this case by the compiler itself). Note
14274 that any use of this feature is potentially non-portable, since the
14275 Ada standard does not require Ada compilers to implement this feature.
14277 @node Intrinsic Operators
14278 @section Intrinsic Operators
14279 @cindex Intrinsic operator
14282 All the predefined numeric operators in package Standard
14283 in @code{pragma Import (Intrinsic,..)}
14284 declarations. In the binary operator case, the operands must have the same
14285 size. The operand or operands must also be appropriate for
14286 the operator. For example, for addition, the operands must
14287 both be floating-point or both be fixed-point, and the
14288 right operand for @code{"**"} must have a root type of
14289 @code{Standard.Integer'Base}.
14290 You can use an intrinsic operator declaration as in the following example:
14292 @smallexample @c ada
14293 type Int1 is new Integer;
14294 type Int2 is new Integer;
14296 function "+" (X1 : Int1; X2 : Int2) return Int1;
14297 function "+" (X1 : Int1; X2 : Int2) return Int2;
14298 pragma Import (Intrinsic, "+");
14302 This declaration would permit ``mixed mode'' arithmetic on items
14303 of the differing types @code{Int1} and @code{Int2}.
14304 It is also possible to specify such operators for private types, if the
14305 full views are appropriate arithmetic types.
14307 @node Enclosing_Entity
14308 @section Enclosing_Entity
14309 @cindex Enclosing_Entity
14311 This intrinsic subprogram is used in the implementation of the
14312 library routine @code{GNAT.Source_Info}. The only useful use of the
14313 intrinsic import in this case is the one in this unit, so an
14314 application program should simply call the function
14315 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14316 the current subprogram, package, task, entry, or protected subprogram.
14318 @node Exception_Information
14319 @section Exception_Information
14320 @cindex Exception_Information'
14322 This intrinsic subprogram is used in the implementation of the
14323 library routine @code{GNAT.Current_Exception}. The only useful
14324 use of the intrinsic import in this case is the one in this unit,
14325 so an application program should simply call the function
14326 @code{GNAT.Current_Exception.Exception_Information} to obtain
14327 the exception information associated with the current exception.
14329 @node Exception_Message
14330 @section Exception_Message
14331 @cindex Exception_Message
14333 This intrinsic subprogram is used in the implementation of the
14334 library routine @code{GNAT.Current_Exception}. The only useful
14335 use of the intrinsic import in this case is the one in this unit,
14336 so an application program should simply call the function
14337 @code{GNAT.Current_Exception.Exception_Message} to obtain
14338 the message associated with the current exception.
14340 @node Exception_Name
14341 @section Exception_Name
14342 @cindex Exception_Name
14344 This intrinsic subprogram is used in the implementation of the
14345 library routine @code{GNAT.Current_Exception}. The only useful
14346 use of the intrinsic import in this case is the one in this unit,
14347 so an application program should simply call the function
14348 @code{GNAT.Current_Exception.Exception_Name} to obtain
14349 the name of the current exception.
14355 This intrinsic subprogram is used in the implementation of the
14356 library routine @code{GNAT.Source_Info}. The only useful use of the
14357 intrinsic import in this case is the one in this unit, so an
14358 application program should simply call the function
14359 @code{GNAT.Source_Info.File} to obtain the name of the current
14366 This intrinsic subprogram is used in the implementation of the
14367 library routine @code{GNAT.Source_Info}. The only useful use of the
14368 intrinsic import in this case is the one in this unit, so an
14369 application program should simply call the function
14370 @code{GNAT.Source_Info.Line} to obtain the number of the current
14373 @node Shifts and Rotates
14374 @section Shifts and Rotates
14376 @cindex Shift_Right
14377 @cindex Shift_Right_Arithmetic
14378 @cindex Rotate_Left
14379 @cindex Rotate_Right
14381 In standard Ada, the shift and rotate functions are available only
14382 for the predefined modular types in package @code{Interfaces}. However, in
14383 GNAT it is possible to define these functions for any integer
14384 type (signed or modular), as in this example:
14386 @smallexample @c ada
14387 function Shift_Left
14389 Amount : Natural) return T;
14393 The function name must be one of
14394 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14395 Rotate_Right. T must be an integer type. T'Size must be
14396 8, 16, 32 or 64 bits; if T is modular, the modulus
14397 must be 2**8, 2**16, 2**32 or 2**64.
14398 The result type must be the same as the type of @code{Value}.
14399 The shift amount must be Natural.
14400 The formal parameter names can be anything.
14402 A more convenient way of providing these shift operators is to use
14403 the Provide_Shift_Operators pragma, which provides the function declarations
14404 and corresponding pragma Import's for all five shift functions.
14406 @node Source_Location
14407 @section Source_Location
14408 @cindex Source_Location
14410 This intrinsic subprogram is used in the implementation of the
14411 library routine @code{GNAT.Source_Info}. The only useful use of the
14412 intrinsic import in this case is the one in this unit, so an
14413 application program should simply call the function
14414 @code{GNAT.Source_Info.Source_Location} to obtain the current
14415 source file location.
14417 @node Representation Clauses and Pragmas
14418 @chapter Representation Clauses and Pragmas
14419 @cindex Representation Clauses
14422 * Alignment Clauses::
14424 * Storage_Size Clauses::
14425 * Size of Variant Record Objects::
14426 * Biased Representation ::
14427 * Value_Size and Object_Size Clauses::
14428 * Component_Size Clauses::
14429 * Bit_Order Clauses::
14430 * Effect of Bit_Order on Byte Ordering::
14431 * Pragma Pack for Arrays::
14432 * Pragma Pack for Records::
14433 * Record Representation Clauses::
14434 * Handling of Records with Holes::
14435 * Enumeration Clauses::
14436 * Address Clauses::
14437 * Effect of Convention on Representation::
14438 * Conventions and Anonymous Access Types::
14439 * Determining the Representations chosen by GNAT::
14443 @cindex Representation Clause
14444 @cindex Representation Pragma
14445 @cindex Pragma, representation
14446 This section describes the representation clauses accepted by GNAT, and
14447 their effect on the representation of corresponding data objects.
14449 GNAT fully implements Annex C (Systems Programming). This means that all
14450 the implementation advice sections in chapter 13 are fully implemented.
14451 However, these sections only require a minimal level of support for
14452 representation clauses. GNAT provides much more extensive capabilities,
14453 and this section describes the additional capabilities provided.
14455 @node Alignment Clauses
14456 @section Alignment Clauses
14457 @cindex Alignment Clause
14460 GNAT requires that all alignment clauses specify a power of 2, and all
14461 default alignments are always a power of 2. The default alignment
14462 values are as follows:
14465 @item @emph{Primitive Types}.
14466 For primitive types, the alignment is the minimum of the actual size of
14467 objects of the type divided by @code{Storage_Unit},
14468 and the maximum alignment supported by the target.
14469 (This maximum alignment is given by the GNAT-specific attribute
14470 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14471 @cindex @code{Maximum_Alignment} attribute
14472 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14473 default alignment will be 8 on any target that supports alignments
14474 this large, but on some targets, the maximum alignment may be smaller
14475 than 8, in which case objects of type @code{Long_Float} will be maximally
14478 @item @emph{Arrays}.
14479 For arrays, the alignment is equal to the alignment of the component type
14480 for the normal case where no packing or component size is given. If the
14481 array is packed, and the packing is effective (see separate section on
14482 packed arrays), then the alignment will be one for long packed arrays,
14483 or arrays whose length is not known at compile time. For short packed
14484 arrays, which are handled internally as modular types, the alignment
14485 will be as described for primitive types, e.g.@: a packed array of length
14486 31 bits will have an object size of four bytes, and an alignment of 4.
14488 @item @emph{Records}.
14489 For the normal non-packed case, the alignment of a record is equal to
14490 the maximum alignment of any of its components. For tagged records, this
14491 includes the implicit access type used for the tag. If a pragma @code{Pack}
14492 is used and all components are packable (see separate section on pragma
14493 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14494 record makes it profitable to increase it.
14496 A special case is when:
14499 the size of the record is given explicitly, or a
14500 full record representation clause is given, and
14502 the size of the record is 2, 4, or 8 bytes.
14505 In this case, an alignment is chosen to match the
14506 size of the record. For example, if we have:
14508 @smallexample @c ada
14509 type Small is record
14512 for Small'Size use 16;
14516 then the default alignment of the record type @code{Small} is 2, not 1. This
14517 leads to more efficient code when the record is treated as a unit, and also
14518 allows the type to specified as @code{Atomic} on architectures requiring
14524 An alignment clause may specify a larger alignment than the default value
14525 up to some maximum value dependent on the target (obtainable by using the
14526 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14527 a smaller alignment than the default value for enumeration, integer and
14528 fixed point types, as well as for record types, for example
14530 @smallexample @c ada
14535 for V'alignment use 1;
14539 @cindex Alignment, default
14540 The default alignment for the type @code{V} is 4, as a result of the
14541 Integer field in the record, but it is permissible, as shown, to
14542 override the default alignment of the record with a smaller value.
14544 @cindex Alignment, subtypes
14545 Note that according to the Ada standard, an alignment clause applies only
14546 to the first named subtype. If additional subtypes are declared, then the
14547 compiler is allowed to choose any alignment it likes, and there is no way
14548 to control this choice. Consider:
14550 @smallexample @c ada
14551 type R is range 1 .. 10_000;
14552 for R'Alignment use 1;
14553 subtype RS is R range 1 .. 1000;
14557 The alignment clause specifies an alignment of 1 for the first named subtype
14558 @code{R} but this does not necessarily apply to @code{RS}. When writing
14559 portable Ada code, you should avoid writing code that explicitly or
14560 implicitly relies on the alignment of such subtypes.
14562 For the GNAT compiler, if an explicit alignment clause is given, this
14563 value is also used for any subsequent subtypes. So for GNAT, in the
14564 above example, you can count on the alignment of @code{RS} being 1. But this
14565 assumption is non-portable, and other compilers may choose different
14566 alignments for the subtype @code{RS}.
14569 @section Size Clauses
14570 @cindex Size Clause
14573 The default size for a type @code{T} is obtainable through the
14574 language-defined attribute @code{T'Size} and also through the
14575 equivalent GNAT-defined attribute @code{T'Value_Size}.
14576 For objects of type @code{T}, GNAT will generally increase the type size
14577 so that the object size (obtainable through the GNAT-defined attribute
14578 @code{T'Object_Size})
14579 is a multiple of @code{T'Alignment * Storage_Unit}.
14582 @smallexample @c ada
14583 type Smallint is range 1 .. 6;
14592 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
14593 as specified by the RM rules,
14594 but objects of this type will have a size of 8
14595 (@code{Smallint'Object_Size} = 8),
14596 since objects by default occupy an integral number
14597 of storage units. On some targets, notably older
14598 versions of the Digital Alpha, the size of stand
14599 alone objects of this type may be 32, reflecting
14600 the inability of the hardware to do byte load/stores.
14602 Similarly, the size of type @code{Rec} is 40 bits
14603 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
14604 the alignment is 4, so objects of this type will have
14605 their size increased to 64 bits so that it is a multiple
14606 of the alignment (in bits). This decision is
14607 in accordance with the specific Implementation Advice in RM 13.3(43):
14610 A @code{Size} clause should be supported for an object if the specified
14611 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
14612 to a size in storage elements that is a multiple of the object's
14613 @code{Alignment} (if the @code{Alignment} is nonzero).
14617 An explicit size clause may be used to override the default size by
14618 increasing it. For example, if we have:
14620 @smallexample @c ada
14621 type My_Boolean is new Boolean;
14622 for My_Boolean'Size use 32;
14626 then values of this type will always be 32 bits long. In the case of
14627 discrete types, the size can be increased up to 64 bits, with the effect
14628 that the entire specified field is used to hold the value, sign- or
14629 zero-extended as appropriate. If more than 64 bits is specified, then
14630 padding space is allocated after the value, and a warning is issued that
14631 there are unused bits.
14633 Similarly the size of records and arrays may be increased, and the effect
14634 is to add padding bits after the value. This also causes a warning message
14637 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
14638 Size in bits, this corresponds to an object of size 256 megabytes (minus
14639 one). This limitation is true on all targets. The reason for this
14640 limitation is that it improves the quality of the code in many cases
14641 if it is known that a Size value can be accommodated in an object of
14644 @node Storage_Size Clauses
14645 @section Storage_Size Clauses
14646 @cindex Storage_Size Clause
14649 For tasks, the @code{Storage_Size} clause specifies the amount of space
14650 to be allocated for the task stack. This cannot be extended, and if the
14651 stack is exhausted, then @code{Storage_Error} will be raised (if stack
14652 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
14653 or a @code{Storage_Size} pragma in the task definition to set the
14654 appropriate required size. A useful technique is to include in every
14655 task definition a pragma of the form:
14657 @smallexample @c ada
14658 pragma Storage_Size (Default_Stack_Size);
14662 Then @code{Default_Stack_Size} can be defined in a global package, and
14663 modified as required. Any tasks requiring stack sizes different from the
14664 default can have an appropriate alternative reference in the pragma.
14666 You can also use the @option{-d} binder switch to modify the default stack
14669 For access types, the @code{Storage_Size} clause specifies the maximum
14670 space available for allocation of objects of the type. If this space is
14671 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
14672 In the case where the access type is declared local to a subprogram, the
14673 use of a @code{Storage_Size} clause triggers automatic use of a special
14674 predefined storage pool (@code{System.Pool_Size}) that ensures that all
14675 space for the pool is automatically reclaimed on exit from the scope in
14676 which the type is declared.
14678 A special case recognized by the compiler is the specification of a
14679 @code{Storage_Size} of zero for an access type. This means that no
14680 items can be allocated from the pool, and this is recognized at compile
14681 time, and all the overhead normally associated with maintaining a fixed
14682 size storage pool is eliminated. Consider the following example:
14684 @smallexample @c ada
14686 type R is array (Natural) of Character;
14687 type P is access all R;
14688 for P'Storage_Size use 0;
14689 -- Above access type intended only for interfacing purposes
14693 procedure g (m : P);
14694 pragma Import (C, g);
14705 As indicated in this example, these dummy storage pools are often useful in
14706 connection with interfacing where no object will ever be allocated. If you
14707 compile the above example, you get the warning:
14710 p.adb:16:09: warning: allocation from empty storage pool
14711 p.adb:16:09: warning: Storage_Error will be raised at run time
14715 Of course in practice, there will not be any explicit allocators in the
14716 case of such an access declaration.
14718 @node Size of Variant Record Objects
14719 @section Size of Variant Record Objects
14720 @cindex Size, variant record objects
14721 @cindex Variant record objects, size
14724 In the case of variant record objects, there is a question whether Size gives
14725 information about a particular variant, or the maximum size required
14726 for any variant. Consider the following program
14728 @smallexample @c ada
14729 with Text_IO; use Text_IO;
14731 type R1 (A : Boolean := False) is record
14733 when True => X : Character;
14734 when False => null;
14742 Put_Line (Integer'Image (V1'Size));
14743 Put_Line (Integer'Image (V2'Size));
14748 Here we are dealing with a variant record, where the True variant
14749 requires 16 bits, and the False variant requires 8 bits.
14750 In the above example, both V1 and V2 contain the False variant,
14751 which is only 8 bits long. However, the result of running the
14760 The reason for the difference here is that the discriminant value of
14761 V1 is fixed, and will always be False. It is not possible to assign
14762 a True variant value to V1, therefore 8 bits is sufficient. On the
14763 other hand, in the case of V2, the initial discriminant value is
14764 False (from the default), but it is possible to assign a True
14765 variant value to V2, therefore 16 bits must be allocated for V2
14766 in the general case, even fewer bits may be needed at any particular
14767 point during the program execution.
14769 As can be seen from the output of this program, the @code{'Size}
14770 attribute applied to such an object in GNAT gives the actual allocated
14771 size of the variable, which is the largest size of any of the variants.
14772 The Ada Reference Manual is not completely clear on what choice should
14773 be made here, but the GNAT behavior seems most consistent with the
14774 language in the RM@.
14776 In some cases, it may be desirable to obtain the size of the current
14777 variant, rather than the size of the largest variant. This can be
14778 achieved in GNAT by making use of the fact that in the case of a
14779 subprogram parameter, GNAT does indeed return the size of the current
14780 variant (because a subprogram has no way of knowing how much space
14781 is actually allocated for the actual).
14783 Consider the following modified version of the above program:
14785 @smallexample @c ada
14786 with Text_IO; use Text_IO;
14788 type R1 (A : Boolean := False) is record
14790 when True => X : Character;
14791 when False => null;
14797 function Size (V : R1) return Integer is
14803 Put_Line (Integer'Image (V2'Size));
14804 Put_Line (Integer'IMage (Size (V2)));
14806 Put_Line (Integer'Image (V2'Size));
14807 Put_Line (Integer'IMage (Size (V2)));
14812 The output from this program is
14822 Here we see that while the @code{'Size} attribute always returns
14823 the maximum size, regardless of the current variant value, the
14824 @code{Size} function does indeed return the size of the current
14827 @node Biased Representation
14828 @section Biased Representation
14829 @cindex Size for biased representation
14830 @cindex Biased representation
14833 In the case of scalars with a range starting at other than zero, it is
14834 possible in some cases to specify a size smaller than the default minimum
14835 value, and in such cases, GNAT uses an unsigned biased representation,
14836 in which zero is used to represent the lower bound, and successive values
14837 represent successive values of the type.
14839 For example, suppose we have the declaration:
14841 @smallexample @c ada
14842 type Small is range -7 .. -4;
14843 for Small'Size use 2;
14847 Although the default size of type @code{Small} is 4, the @code{Size}
14848 clause is accepted by GNAT and results in the following representation
14852 -7 is represented as 2#00#
14853 -6 is represented as 2#01#
14854 -5 is represented as 2#10#
14855 -4 is represented as 2#11#
14859 Biased representation is only used if the specified @code{Size} clause
14860 cannot be accepted in any other manner. These reduced sizes that force
14861 biased representation can be used for all discrete types except for
14862 enumeration types for which a representation clause is given.
14864 @node Value_Size and Object_Size Clauses
14865 @section Value_Size and Object_Size Clauses
14867 @findex Object_Size
14868 @cindex Size, of objects
14871 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
14872 number of bits required to hold values of type @code{T}.
14873 Although this interpretation was allowed in Ada 83, it was not required,
14874 and this requirement in practice can cause some significant difficulties.
14875 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
14876 However, in Ada 95 and Ada 2005,
14877 @code{Natural'Size} is
14878 typically 31. This means that code may change in behavior when moving
14879 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
14881 @smallexample @c ada
14882 type Rec is record;
14888 at 0 range 0 .. Natural'Size - 1;
14889 at 0 range Natural'Size .. 2 * Natural'Size - 1;
14894 In the above code, since the typical size of @code{Natural} objects
14895 is 32 bits and @code{Natural'Size} is 31, the above code can cause
14896 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
14897 there are cases where the fact that the object size can exceed the
14898 size of the type causes surprises.
14900 To help get around this problem GNAT provides two implementation
14901 defined attributes, @code{Value_Size} and @code{Object_Size}. When
14902 applied to a type, these attributes yield the size of the type
14903 (corresponding to the RM defined size attribute), and the size of
14904 objects of the type respectively.
14906 The @code{Object_Size} is used for determining the default size of
14907 objects and components. This size value can be referred to using the
14908 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
14909 the basis of the determination of the size. The backend is free to
14910 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
14911 character might be stored in 32 bits on a machine with no efficient
14912 byte access instructions such as the Alpha.
14914 The default rules for the value of @code{Object_Size} for
14915 discrete types are as follows:
14919 The @code{Object_Size} for base subtypes reflect the natural hardware
14920 size in bits (run the compiler with @option{-gnatS} to find those values
14921 for numeric types). Enumeration types and fixed-point base subtypes have
14922 8, 16, 32 or 64 bits for this size, depending on the range of values
14926 The @code{Object_Size} of a subtype is the same as the
14927 @code{Object_Size} of
14928 the type from which it is obtained.
14931 The @code{Object_Size} of a derived base type is copied from the parent
14932 base type, and the @code{Object_Size} of a derived first subtype is copied
14933 from the parent first subtype.
14937 The @code{Value_Size} attribute
14938 is the (minimum) number of bits required to store a value
14940 This value is used to determine how tightly to pack
14941 records or arrays with components of this type, and also affects
14942 the semantics of unchecked conversion (unchecked conversions where
14943 the @code{Value_Size} values differ generate a warning, and are potentially
14946 The default rules for the value of @code{Value_Size} are as follows:
14950 The @code{Value_Size} for a base subtype is the minimum number of bits
14951 required to store all values of the type (including the sign bit
14952 only if negative values are possible).
14955 If a subtype statically matches the first subtype of a given type, then it has
14956 by default the same @code{Value_Size} as the first subtype. This is a
14957 consequence of RM 13.1(14) (``if two subtypes statically match,
14958 then their subtype-specific aspects are the same''.)
14961 All other subtypes have a @code{Value_Size} corresponding to the minimum
14962 number of bits required to store all values of the subtype. For
14963 dynamic bounds, it is assumed that the value can range down or up
14964 to the corresponding bound of the ancestor
14968 The RM defined attribute @code{Size} corresponds to the
14969 @code{Value_Size} attribute.
14971 The @code{Size} attribute may be defined for a first-named subtype. This sets
14972 the @code{Value_Size} of
14973 the first-named subtype to the given value, and the
14974 @code{Object_Size} of this first-named subtype to the given value padded up
14975 to an appropriate boundary. It is a consequence of the default rules
14976 above that this @code{Object_Size} will apply to all further subtypes. On the
14977 other hand, @code{Value_Size} is affected only for the first subtype, any
14978 dynamic subtypes obtained from it directly, and any statically matching
14979 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
14981 @code{Value_Size} and
14982 @code{Object_Size} may be explicitly set for any subtype using
14983 an attribute definition clause. Note that the use of these attributes
14984 can cause the RM 13.1(14) rule to be violated. If two access types
14985 reference aliased objects whose subtypes have differing @code{Object_Size}
14986 values as a result of explicit attribute definition clauses, then it
14987 is illegal to convert from one access subtype to the other. For a more
14988 complete description of this additional legality rule, see the
14989 description of the @code{Object_Size} attribute.
14991 At the implementation level, Esize stores the Object_Size and the
14992 RM_Size field stores the @code{Value_Size} (and hence the value of the
14993 @code{Size} attribute,
14994 which, as noted above, is equivalent to @code{Value_Size}).
14996 To get a feel for the difference, consider the following examples (note
14997 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15000 Object_Size Value_Size
15002 type x1 is range 0 .. 5; 8 3
15004 type x2 is range 0 .. 5;
15005 for x2'size use 12; 16 12
15007 subtype x3 is x2 range 0 .. 3; 16 2
15009 subtype x4 is x2'base range 0 .. 10; 8 4
15011 subtype x5 is x2 range 0 .. dynamic; 16 3*
15013 subtype x6 is x2'base range 0 .. dynamic; 8 3*
15018 Note: the entries marked ``3*'' are not actually specified by the Ada
15019 Reference Manual, but it seems in the spirit of the RM rules to allocate
15020 the minimum number of bits (here 3, given the range for @code{x2})
15021 known to be large enough to hold the given range of values.
15023 So far, so good, but GNAT has to obey the RM rules, so the question is
15024 under what conditions must the RM @code{Size} be used.
15025 The following is a list
15026 of the occasions on which the RM @code{Size} must be used:
15030 Component size for packed arrays or records
15033 Value of the attribute @code{Size} for a type
15036 Warning about sizes not matching for unchecked conversion
15040 For record types, the @code{Object_Size} is always a multiple of the
15041 alignment of the type (this is true for all types). In some cases the
15042 @code{Value_Size} can be smaller. Consider:
15052 On a typical 32-bit architecture, the X component will be four bytes, and
15053 require four-byte alignment, and the Y component will be one byte. In this
15054 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15055 required to store a value of this type, and for example, it is permissible
15056 to have a component of type R in an outer array whose component size is
15057 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15058 since it must be rounded up so that this value is a multiple of the
15059 alignment (4 bytes = 32 bits).
15062 For all other types, the @code{Object_Size}
15063 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15064 Only @code{Size} may be specified for such types.
15066 Note that @code{Value_Size} can be used to force biased representation
15067 for a particular subtype. Consider this example:
15070 type R is (A, B, C, D, E, F);
15071 subtype RAB is R range A .. B;
15072 subtype REF is R range E .. F;
15076 By default, @code{RAB}
15077 has a size of 1 (sufficient to accommodate the representation
15078 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15079 has a size of 3 (sufficient to accommodate the representation
15080 of @code{E} and @code{F}, 4 and 5). But if we add the
15081 following @code{Value_Size} attribute definition clause:
15084 for REF'Value_Size use 1;
15088 then biased representation is forced for @code{REF},
15089 and 0 will represent @code{E} and 1 will represent @code{F}.
15090 A warning is issued when a @code{Value_Size} attribute
15091 definition clause forces biased representation. This
15092 warning can be turned off using @code{-gnatw.B}.
15094 @node Component_Size Clauses
15095 @section Component_Size Clauses
15096 @cindex Component_Size Clause
15099 Normally, the value specified in a component size clause must be consistent
15100 with the subtype of the array component with regard to size and alignment.
15101 In other words, the value specified must be at least equal to the size
15102 of this subtype, and must be a multiple of the alignment value.
15104 In addition, component size clauses are allowed which cause the array
15105 to be packed, by specifying a smaller value. A first case is for
15106 component size values in the range 1 through 63. The value specified
15107 must not be smaller than the Size of the subtype. GNAT will accurately
15108 honor all packing requests in this range. For example, if we have:
15110 @smallexample @c ada
15111 type r is array (1 .. 8) of Natural;
15112 for r'Component_Size use 31;
15116 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15117 Of course access to the components of such an array is considerably
15118 less efficient than if the natural component size of 32 is used.
15119 A second case is when the subtype of the component is a record type
15120 padded because of its default alignment. For example, if we have:
15122 @smallexample @c ada
15129 type a is array (1 .. 8) of r;
15130 for a'Component_Size use 72;
15134 then the resulting array has a length of 72 bytes, instead of 96 bytes
15135 if the alignment of the record (4) was obeyed.
15137 Note that there is no point in giving both a component size clause
15138 and a pragma Pack for the same array type. if such duplicate
15139 clauses are given, the pragma Pack will be ignored.
15141 @node Bit_Order Clauses
15142 @section Bit_Order Clauses
15143 @cindex Bit_Order Clause
15144 @cindex bit ordering
15145 @cindex ordering, of bits
15148 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15149 attribute. The specification may either correspond to the default bit
15150 order for the target, in which case the specification has no effect and
15151 places no additional restrictions, or it may be for the non-standard
15152 setting (that is the opposite of the default).
15154 In the case where the non-standard value is specified, the effect is
15155 to renumber bits within each byte, but the ordering of bytes is not
15156 affected. There are certain
15157 restrictions placed on component clauses as follows:
15161 @item Components fitting within a single storage unit.
15163 These are unrestricted, and the effect is merely to renumber bits. For
15164 example if we are on a little-endian machine with @code{Low_Order_First}
15165 being the default, then the following two declarations have exactly
15168 @smallexample @c ada
15171 B : Integer range 1 .. 120;
15175 A at 0 range 0 .. 0;
15176 B at 0 range 1 .. 7;
15181 B : Integer range 1 .. 120;
15184 for R2'Bit_Order use High_Order_First;
15187 A at 0 range 7 .. 7;
15188 B at 0 range 0 .. 6;
15193 The useful application here is to write the second declaration with the
15194 @code{Bit_Order} attribute definition clause, and know that it will be treated
15195 the same, regardless of whether the target is little-endian or big-endian.
15197 @item Components occupying an integral number of bytes.
15199 These are components that exactly fit in two or more bytes. Such component
15200 declarations are allowed, but have no effect, since it is important to realize
15201 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15202 In particular, the following attempt at getting an endian-independent integer
15205 @smallexample @c ada
15210 for R2'Bit_Order use High_Order_First;
15213 A at 0 range 0 .. 31;
15218 This declaration will result in a little-endian integer on a
15219 little-endian machine, and a big-endian integer on a big-endian machine.
15220 If byte flipping is required for interoperability between big- and
15221 little-endian machines, this must be explicitly programmed. This capability
15222 is not provided by @code{Bit_Order}.
15224 @item Components that are positioned across byte boundaries
15226 but do not occupy an integral number of bytes. Given that bytes are not
15227 reordered, such fields would occupy a non-contiguous sequence of bits
15228 in memory, requiring non-trivial code to reassemble. They are for this
15229 reason not permitted, and any component clause specifying such a layout
15230 will be flagged as illegal by GNAT@.
15235 Since the misconception that Bit_Order automatically deals with all
15236 endian-related incompatibilities is a common one, the specification of
15237 a component field that is an integral number of bytes will always
15238 generate a warning. This warning may be suppressed using @code{pragma
15239 Warnings (Off)} if desired. The following section contains additional
15240 details regarding the issue of byte ordering.
15242 @node Effect of Bit_Order on Byte Ordering
15243 @section Effect of Bit_Order on Byte Ordering
15244 @cindex byte ordering
15245 @cindex ordering, of bytes
15248 In this section we will review the effect of the @code{Bit_Order} attribute
15249 definition clause on byte ordering. Briefly, it has no effect at all, but
15250 a detailed example will be helpful. Before giving this
15251 example, let us review the precise
15252 definition of the effect of defining @code{Bit_Order}. The effect of a
15253 non-standard bit order is described in section 15.5.3 of the Ada
15257 2 A bit ordering is a method of interpreting the meaning of
15258 the storage place attributes.
15262 To understand the precise definition of storage place attributes in
15263 this context, we visit section 13.5.1 of the manual:
15266 13 A record_representation_clause (without the mod_clause)
15267 specifies the layout. The storage place attributes (see 13.5.2)
15268 are taken from the values of the position, first_bit, and last_bit
15269 expressions after normalizing those values so that first_bit is
15270 less than Storage_Unit.
15274 The critical point here is that storage places are taken from
15275 the values after normalization, not before. So the @code{Bit_Order}
15276 interpretation applies to normalized values. The interpretation
15277 is described in the later part of the 15.5.3 paragraph:
15280 2 A bit ordering is a method of interpreting the meaning of
15281 the storage place attributes. High_Order_First (known in the
15282 vernacular as ``big endian'') means that the first bit of a
15283 storage element (bit 0) is the most significant bit (interpreting
15284 the sequence of bits that represent a component as an unsigned
15285 integer value). Low_Order_First (known in the vernacular as
15286 ``little endian'') means the opposite: the first bit is the
15291 Note that the numbering is with respect to the bits of a storage
15292 unit. In other words, the specification affects only the numbering
15293 of bits within a single storage unit.
15295 We can make the effect clearer by giving an example.
15297 Suppose that we have an external device which presents two bytes, the first
15298 byte presented, which is the first (low addressed byte) of the two byte
15299 record is called Master, and the second byte is called Slave.
15301 The left most (most significant bit is called Control for each byte, and
15302 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15303 (least significant) bit.
15305 On a big-endian machine, we can write the following representation clause
15307 @smallexample @c ada
15308 type Data is record
15309 Master_Control : Bit;
15317 Slave_Control : Bit;
15327 for Data use record
15328 Master_Control at 0 range 0 .. 0;
15329 Master_V1 at 0 range 1 .. 1;
15330 Master_V2 at 0 range 2 .. 2;
15331 Master_V3 at 0 range 3 .. 3;
15332 Master_V4 at 0 range 4 .. 4;
15333 Master_V5 at 0 range 5 .. 5;
15334 Master_V6 at 0 range 6 .. 6;
15335 Master_V7 at 0 range 7 .. 7;
15336 Slave_Control at 1 range 0 .. 0;
15337 Slave_V1 at 1 range 1 .. 1;
15338 Slave_V2 at 1 range 2 .. 2;
15339 Slave_V3 at 1 range 3 .. 3;
15340 Slave_V4 at 1 range 4 .. 4;
15341 Slave_V5 at 1 range 5 .. 5;
15342 Slave_V6 at 1 range 6 .. 6;
15343 Slave_V7 at 1 range 7 .. 7;
15348 Now if we move this to a little endian machine, then the bit ordering within
15349 the byte is backwards, so we have to rewrite the record rep clause as:
15351 @smallexample @c ada
15352 for Data use record
15353 Master_Control at 0 range 7 .. 7;
15354 Master_V1 at 0 range 6 .. 6;
15355 Master_V2 at 0 range 5 .. 5;
15356 Master_V3 at 0 range 4 .. 4;
15357 Master_V4 at 0 range 3 .. 3;
15358 Master_V5 at 0 range 2 .. 2;
15359 Master_V6 at 0 range 1 .. 1;
15360 Master_V7 at 0 range 0 .. 0;
15361 Slave_Control at 1 range 7 .. 7;
15362 Slave_V1 at 1 range 6 .. 6;
15363 Slave_V2 at 1 range 5 .. 5;
15364 Slave_V3 at 1 range 4 .. 4;
15365 Slave_V4 at 1 range 3 .. 3;
15366 Slave_V5 at 1 range 2 .. 2;
15367 Slave_V6 at 1 range 1 .. 1;
15368 Slave_V7 at 1 range 0 .. 0;
15373 It is a nuisance to have to rewrite the clause, especially if
15374 the code has to be maintained on both machines. However,
15375 this is a case that we can handle with the
15376 @code{Bit_Order} attribute if it is implemented.
15377 Note that the implementation is not required on byte addressed
15378 machines, but it is indeed implemented in GNAT.
15379 This means that we can simply use the
15380 first record clause, together with the declaration
15382 @smallexample @c ada
15383 for Data'Bit_Order use High_Order_First;
15387 and the effect is what is desired, namely the layout is exactly the same,
15388 independent of whether the code is compiled on a big-endian or little-endian
15391 The important point to understand is that byte ordering is not affected.
15392 A @code{Bit_Order} attribute definition never affects which byte a field
15393 ends up in, only where it ends up in that byte.
15394 To make this clear, let us rewrite the record rep clause of the previous
15397 @smallexample @c ada
15398 for Data'Bit_Order use High_Order_First;
15399 for Data use record
15400 Master_Control at 0 range 0 .. 0;
15401 Master_V1 at 0 range 1 .. 1;
15402 Master_V2 at 0 range 2 .. 2;
15403 Master_V3 at 0 range 3 .. 3;
15404 Master_V4 at 0 range 4 .. 4;
15405 Master_V5 at 0 range 5 .. 5;
15406 Master_V6 at 0 range 6 .. 6;
15407 Master_V7 at 0 range 7 .. 7;
15408 Slave_Control at 0 range 8 .. 8;
15409 Slave_V1 at 0 range 9 .. 9;
15410 Slave_V2 at 0 range 10 .. 10;
15411 Slave_V3 at 0 range 11 .. 11;
15412 Slave_V4 at 0 range 12 .. 12;
15413 Slave_V5 at 0 range 13 .. 13;
15414 Slave_V6 at 0 range 14 .. 14;
15415 Slave_V7 at 0 range 15 .. 15;
15420 This is exactly equivalent to saying (a repeat of the first example):
15422 @smallexample @c ada
15423 for Data'Bit_Order use High_Order_First;
15424 for Data use record
15425 Master_Control at 0 range 0 .. 0;
15426 Master_V1 at 0 range 1 .. 1;
15427 Master_V2 at 0 range 2 .. 2;
15428 Master_V3 at 0 range 3 .. 3;
15429 Master_V4 at 0 range 4 .. 4;
15430 Master_V5 at 0 range 5 .. 5;
15431 Master_V6 at 0 range 6 .. 6;
15432 Master_V7 at 0 range 7 .. 7;
15433 Slave_Control at 1 range 0 .. 0;
15434 Slave_V1 at 1 range 1 .. 1;
15435 Slave_V2 at 1 range 2 .. 2;
15436 Slave_V3 at 1 range 3 .. 3;
15437 Slave_V4 at 1 range 4 .. 4;
15438 Slave_V5 at 1 range 5 .. 5;
15439 Slave_V6 at 1 range 6 .. 6;
15440 Slave_V7 at 1 range 7 .. 7;
15445 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15446 field. The storage place attributes are obtained by normalizing the
15447 values given so that the @code{First_Bit} value is less than 8. After
15448 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15449 we specified in the other case.
15451 Now one might expect that the @code{Bit_Order} attribute might affect
15452 bit numbering within the entire record component (two bytes in this
15453 case, thus affecting which byte fields end up in), but that is not
15454 the way this feature is defined, it only affects numbering of bits,
15455 not which byte they end up in.
15457 Consequently it never makes sense to specify a starting bit number
15458 greater than 7 (for a byte addressable field) if an attribute
15459 definition for @code{Bit_Order} has been given, and indeed it
15460 may be actively confusing to specify such a value, so the compiler
15461 generates a warning for such usage.
15463 If you do need to control byte ordering then appropriate conditional
15464 values must be used. If in our example, the slave byte came first on
15465 some machines we might write:
15467 @smallexample @c ada
15468 Master_Byte_First constant Boolean := @dots{};
15470 Master_Byte : constant Natural :=
15471 1 - Boolean'Pos (Master_Byte_First);
15472 Slave_Byte : constant Natural :=
15473 Boolean'Pos (Master_Byte_First);
15475 for Data'Bit_Order use High_Order_First;
15476 for Data use record
15477 Master_Control at Master_Byte range 0 .. 0;
15478 Master_V1 at Master_Byte range 1 .. 1;
15479 Master_V2 at Master_Byte range 2 .. 2;
15480 Master_V3 at Master_Byte range 3 .. 3;
15481 Master_V4 at Master_Byte range 4 .. 4;
15482 Master_V5 at Master_Byte range 5 .. 5;
15483 Master_V6 at Master_Byte range 6 .. 6;
15484 Master_V7 at Master_Byte range 7 .. 7;
15485 Slave_Control at Slave_Byte range 0 .. 0;
15486 Slave_V1 at Slave_Byte range 1 .. 1;
15487 Slave_V2 at Slave_Byte range 2 .. 2;
15488 Slave_V3 at Slave_Byte range 3 .. 3;
15489 Slave_V4 at Slave_Byte range 4 .. 4;
15490 Slave_V5 at Slave_Byte range 5 .. 5;
15491 Slave_V6 at Slave_Byte range 6 .. 6;
15492 Slave_V7 at Slave_Byte range 7 .. 7;
15497 Now to switch between machines, all that is necessary is
15498 to set the boolean constant @code{Master_Byte_First} in
15499 an appropriate manner.
15501 @node Pragma Pack for Arrays
15502 @section Pragma Pack for Arrays
15503 @cindex Pragma Pack (for arrays)
15506 Pragma @code{Pack} applied to an array has no effect unless the component type
15507 is packable. For a component type to be packable, it must be one of the
15514 Any type whose size is specified with a size clause
15516 Any packed array type with a static size
15518 Any record type padded because of its default alignment
15522 For all these cases, if the component subtype size is in the range
15523 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15524 component size were specified giving the component subtype size.
15525 For example if we have:
15527 @smallexample @c ada
15528 type r is range 0 .. 17;
15530 type ar is array (1 .. 8) of r;
15535 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15536 and the size of the array @code{ar} will be exactly 40 bits.
15538 Note that in some cases this rather fierce approach to packing can produce
15539 unexpected effects. For example, in Ada 95 and Ada 2005,
15540 subtype @code{Natural} typically has a size of 31, meaning that if you
15541 pack an array of @code{Natural}, you get 31-bit
15542 close packing, which saves a few bits, but results in far less efficient
15543 access. Since many other Ada compilers will ignore such a packing request,
15544 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15545 might not be what is intended. You can easily remove this warning by
15546 using an explicit @code{Component_Size} setting instead, which never generates
15547 a warning, since the intention of the programmer is clear in this case.
15549 GNAT treats packed arrays in one of two ways. If the size of the array is
15550 known at compile time and is less than 64 bits, then internally the array
15551 is represented as a single modular type, of exactly the appropriate number
15552 of bits. If the length is greater than 63 bits, or is not known at compile
15553 time, then the packed array is represented as an array of bytes, and the
15554 length is always a multiple of 8 bits.
15556 Note that to represent a packed array as a modular type, the alignment must
15557 be suitable for the modular type involved. For example, on typical machines
15558 a 32-bit packed array will be represented by a 32-bit modular integer with
15559 an alignment of four bytes. If you explicitly override the default alignment
15560 with an alignment clause that is too small, the modular representation
15561 cannot be used. For example, consider the following set of declarations:
15563 @smallexample @c ada
15564 type R is range 1 .. 3;
15565 type S is array (1 .. 31) of R;
15566 for S'Component_Size use 2;
15568 for S'Alignment use 1;
15572 If the alignment clause were not present, then a 62-bit modular
15573 representation would be chosen (typically with an alignment of 4 or 8
15574 bytes depending on the target). But the default alignment is overridden
15575 with the explicit alignment clause. This means that the modular
15576 representation cannot be used, and instead the array of bytes
15577 representation must be used, meaning that the length must be a multiple
15578 of 8. Thus the above set of declarations will result in a diagnostic
15579 rejecting the size clause and noting that the minimum size allowed is 64.
15581 @cindex Pragma Pack (for type Natural)
15582 @cindex Pragma Pack warning
15584 One special case that is worth noting occurs when the base type of the
15585 component size is 8/16/32 and the subtype is one bit less. Notably this
15586 occurs with subtype @code{Natural}. Consider:
15588 @smallexample @c ada
15589 type Arr is array (1 .. 32) of Natural;
15594 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
15595 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
15596 Ada 83 compilers did not attempt 31 bit packing.
15598 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
15599 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
15600 substantial unintended performance penalty when porting legacy Ada 83 code.
15601 To help prevent this, GNAT generates a warning in such cases. If you really
15602 want 31 bit packing in a case like this, you can set the component size
15605 @smallexample @c ada
15606 type Arr is array (1 .. 32) of Natural;
15607 for Arr'Component_Size use 31;
15611 Here 31-bit packing is achieved as required, and no warning is generated,
15612 since in this case the programmer intention is clear.
15614 @node Pragma Pack for Records
15615 @section Pragma Pack for Records
15616 @cindex Pragma Pack (for records)
15619 Pragma @code{Pack} applied to a record will pack the components to reduce
15620 wasted space from alignment gaps and by reducing the amount of space
15621 taken by components. We distinguish between @emph{packable} components and
15622 @emph{non-packable} components.
15623 Components of the following types are considered packable:
15626 Components of a primitive type are packable unless they are aliased
15627 or of an atomic type.
15630 Small packed arrays, whose size does not exceed 64 bits, and where the
15631 size is statically known at compile time, are represented internally
15632 as modular integers, and so they are also packable.
15637 All packable components occupy the exact number of bits corresponding to
15638 their @code{Size} value, and are packed with no padding bits, i.e.@: they
15639 can start on an arbitrary bit boundary.
15641 All other types are non-packable, they occupy an integral number of
15643 are placed at a boundary corresponding to their alignment requirements.
15645 For example, consider the record
15647 @smallexample @c ada
15648 type Rb1 is array (1 .. 13) of Boolean;
15651 type Rb2 is array (1 .. 65) of Boolean;
15654 type AF is new Float with Atomic;
15668 The representation for the record X2 is as follows:
15670 @smallexample @c ada
15671 for X2'Size use 224;
15673 L1 at 0 range 0 .. 0;
15674 L2 at 0 range 1 .. 64;
15675 L3 at 12 range 0 .. 31;
15676 L4 at 16 range 0 .. 0;
15677 L5 at 16 range 1 .. 13;
15678 L6 at 18 range 0 .. 71;
15683 Studying this example, we see that the packable fields @code{L1}
15685 of length equal to their sizes, and placed at specific bit boundaries (and
15686 not byte boundaries) to
15687 eliminate padding. But @code{L3} is of a non-packable float type (because
15688 it is aliased), so it is on the next appropriate alignment boundary.
15690 The next two fields are fully packable, so @code{L4} and @code{L5} are
15691 minimally packed with no gaps. However, type @code{Rb2} is a packed
15692 array that is longer than 64 bits, so it is itself non-packable. Thus
15693 the @code{L6} field is aligned to the next byte boundary, and takes an
15694 integral number of bytes, i.e.@: 72 bits.
15696 @node Record Representation Clauses
15697 @section Record Representation Clauses
15698 @cindex Record Representation Clause
15701 Record representation clauses may be given for all record types, including
15702 types obtained by record extension. Component clauses are allowed for any
15703 static component. The restrictions on component clauses depend on the type
15706 @cindex Component Clause
15707 For all components of an elementary type, the only restriction on component
15708 clauses is that the size must be at least the 'Size value of the type
15709 (actually the Value_Size). There are no restrictions due to alignment,
15710 and such components may freely cross storage boundaries.
15712 Packed arrays with a size up to and including 64 bits are represented
15713 internally using a modular type with the appropriate number of bits, and
15714 thus the same lack of restriction applies. For example, if you declare:
15716 @smallexample @c ada
15717 type R is array (1 .. 49) of Boolean;
15723 then a component clause for a component of type R may start on any
15724 specified bit boundary, and may specify a value of 49 bits or greater.
15726 For packed bit arrays that are longer than 64 bits, there are two
15727 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
15728 including the important case of single bits or boolean values, then
15729 there are no limitations on placement of such components, and they
15730 may start and end at arbitrary bit boundaries.
15732 If the component size is not a power of 2 (e.g.@: 3 or 5), then
15733 an array of this type longer than 64 bits must always be placed on
15734 on a storage unit (byte) boundary and occupy an integral number
15735 of storage units (bytes). Any component clause that does not
15736 meet this requirement will be rejected.
15738 Any aliased component, or component of an aliased type, must
15739 have its normal alignment and size. A component clause that
15740 does not meet this requirement will be rejected.
15742 The tag field of a tagged type always occupies an address sized field at
15743 the start of the record. No component clause may attempt to overlay this
15744 tag. When a tagged type appears as a component, the tag field must have
15747 In the case of a record extension T1, of a type T, no component clause applied
15748 to the type T1 can specify a storage location that would overlap the first
15749 T'Size bytes of the record.
15751 For all other component types, including non-bit-packed arrays,
15752 the component can be placed at an arbitrary bit boundary,
15753 so for example, the following is permitted:
15755 @smallexample @c ada
15756 type R is array (1 .. 10) of Boolean;
15765 G at 0 range 0 .. 0;
15766 H at 0 range 1 .. 1;
15767 L at 0 range 2 .. 81;
15768 R at 0 range 82 .. 161;
15773 Note: the above rules apply to recent releases of GNAT 5.
15774 In GNAT 3, there are more severe restrictions on larger components.
15775 For non-primitive types, including packed arrays with a size greater than
15776 64 bits, component clauses must respect the alignment requirement of the
15777 type, in particular, always starting on a byte boundary, and the length
15778 must be a multiple of the storage unit.
15780 @node Handling of Records with Holes
15781 @section Handling of Records with Holes
15782 @cindex Handling of Records with Holes
15784 As a result of alignment considerations, records may contain "holes"
15786 which do not correspond to the data bits of any of the components.
15787 Record representation clauses can also result in holes in records.
15789 GNAT does not attempt to clear these holes, so in record objects,
15790 they should be considered to hold undefined rubbish. The generated
15791 equality routine just tests components so does not access these
15792 undefined bits, and assignment and copy operations may or may not
15793 preserve the contents of these holes (for assignments, the holes
15794 in the target will in practice contain either the bits that are
15795 present in the holes in the source, or the bits that were present
15796 in the target before the assignment).
15798 If it is necessary to ensure that holes in records have all zero
15799 bits, then record objects for which this initialization is desired
15800 should be explicitly set to all zero values using Unchecked_Conversion
15801 or address overlays. For example
15803 @smallexample @c ada
15804 type HRec is record
15811 On typical machines, integers need to be aligned on a four-byte
15812 boundary, resulting in three bytes of undefined rubbish following
15813 the 8-bit field for C. To ensure that the hole in a variable of
15814 type HRec is set to all zero bits,
15815 you could for example do:
15817 @smallexample @c ada
15818 type Base is record
15819 Dummy1, Dummy2 : Integer := 0;
15824 for RealVar'Address use BaseVar'Address;
15828 Now the 8-bytes of the value of RealVar start out containing all zero
15829 bits. A safer approach is to just define dummy fields, avoiding the
15832 @smallexample @c ada
15833 type HRec is record
15835 Dummy1 : Short_Short_Integer := 0;
15836 Dummy2 : Short_Short_Integer := 0;
15837 Dummy3 : Short_Short_Integer := 0;
15843 And to make absolutely sure that the intent of this is followed, you
15844 can use representation clauses:
15846 @smallexample @c ada
15847 for Hrec use record
15848 C at 0 range 0 .. 7;
15849 Dummy1 at 1 range 0 .. 7;
15850 Dummy2 at 2 range 0 .. 7;
15851 Dummy3 at 3 range 0 .. 7;
15852 I at 4 range 0 .. 31;
15854 for Hrec'Size use 64;
15857 @node Enumeration Clauses
15858 @section Enumeration Clauses
15860 The only restriction on enumeration clauses is that the range of values
15861 must be representable. For the signed case, if one or more of the
15862 representation values are negative, all values must be in the range:
15864 @smallexample @c ada
15865 System.Min_Int .. System.Max_Int
15869 For the unsigned case, where all values are nonnegative, the values must
15872 @smallexample @c ada
15873 0 .. System.Max_Binary_Modulus;
15877 A @emph{confirming} representation clause is one in which the values range
15878 from 0 in sequence, i.e.@: a clause that confirms the default representation
15879 for an enumeration type.
15880 Such a confirming representation
15881 is permitted by these rules, and is specially recognized by the compiler so
15882 that no extra overhead results from the use of such a clause.
15884 If an array has an index type which is an enumeration type to which an
15885 enumeration clause has been applied, then the array is stored in a compact
15886 manner. Consider the declarations:
15888 @smallexample @c ada
15889 type r is (A, B, C);
15890 for r use (A => 1, B => 5, C => 10);
15891 type t is array (r) of Character;
15895 The array type t corresponds to a vector with exactly three elements and
15896 has a default size equal to @code{3*Character'Size}. This ensures efficient
15897 use of space, but means that accesses to elements of the array will incur
15898 the overhead of converting representation values to the corresponding
15899 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
15901 @node Address Clauses
15902 @section Address Clauses
15903 @cindex Address Clause
15905 The reference manual allows a general restriction on representation clauses,
15906 as found in RM 13.1(22):
15909 An implementation need not support representation
15910 items containing nonstatic expressions, except that
15911 an implementation should support a representation item
15912 for a given entity if each nonstatic expression in the
15913 representation item is a name that statically denotes
15914 a constant declared before the entity.
15918 In practice this is applicable only to address clauses, since this is the
15919 only case in which a non-static expression is permitted by the syntax. As
15920 the AARM notes in sections 13.1 (22.a-22.h):
15923 22.a Reason: This is to avoid the following sort of thing:
15925 22.b X : Integer := F(@dots{});
15926 Y : Address := G(@dots{});
15927 for X'Address use Y;
15929 22.c In the above, we have to evaluate the
15930 initialization expression for X before we
15931 know where to put the result. This seems
15932 like an unreasonable implementation burden.
15934 22.d The above code should instead be written
15937 22.e Y : constant Address := G(@dots{});
15938 X : Integer := F(@dots{});
15939 for X'Address use Y;
15941 22.f This allows the expression ``Y'' to be safely
15942 evaluated before X is created.
15944 22.g The constant could be a formal parameter of mode in.
15946 22.h An implementation can support other nonstatic
15947 expressions if it wants to. Expressions of type
15948 Address are hardly ever static, but their value
15949 might be known at compile time anyway in many
15954 GNAT does indeed permit many additional cases of non-static expressions. In
15955 particular, if the type involved is elementary there are no restrictions
15956 (since in this case, holding a temporary copy of the initialization value,
15957 if one is present, is inexpensive). In addition, if there is no implicit or
15958 explicit initialization, then there are no restrictions. GNAT will reject
15959 only the case where all three of these conditions hold:
15964 The type of the item is non-elementary (e.g.@: a record or array).
15967 There is explicit or implicit initialization required for the object.
15968 Note that access values are always implicitly initialized.
15971 The address value is non-static. Here GNAT is more permissive than the
15972 RM, and allows the address value to be the address of a previously declared
15973 stand-alone variable, as long as it does not itself have an address clause.
15975 @smallexample @c ada
15976 Anchor : Some_Initialized_Type;
15977 Overlay : Some_Initialized_Type;
15978 for Overlay'Address use Anchor'Address;
15982 However, the prefix of the address clause cannot be an array component, or
15983 a component of a discriminated record.
15988 As noted above in section 22.h, address values are typically non-static. In
15989 particular the To_Address function, even if applied to a literal value, is
15990 a non-static function call. To avoid this minor annoyance, GNAT provides
15991 the implementation defined attribute 'To_Address. The following two
15992 expressions have identical values:
15996 @smallexample @c ada
15997 To_Address (16#1234_0000#)
15998 System'To_Address (16#1234_0000#);
16002 except that the second form is considered to be a static expression, and
16003 thus when used as an address clause value is always permitted.
16006 Additionally, GNAT treats as static an address clause that is an
16007 unchecked_conversion of a static integer value. This simplifies the porting
16008 of legacy code, and provides a portable equivalent to the GNAT attribute
16011 Another issue with address clauses is the interaction with alignment
16012 requirements. When an address clause is given for an object, the address
16013 value must be consistent with the alignment of the object (which is usually
16014 the same as the alignment of the type of the object). If an address clause
16015 is given that specifies an inappropriately aligned address value, then the
16016 program execution is erroneous.
16018 Since this source of erroneous behavior can have unfortunate effects, GNAT
16019 checks (at compile time if possible, generating a warning, or at execution
16020 time with a run-time check) that the alignment is appropriate. If the
16021 run-time check fails, then @code{Program_Error} is raised. This run-time
16022 check is suppressed if range checks are suppressed, or if the special GNAT
16023 check Alignment_Check is suppressed, or if
16024 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16026 Finally, GNAT does not permit overlaying of objects of controlled types or
16027 composite types containing a controlled component. In most cases, the compiler
16028 can detect an attempt at such overlays and will generate a warning at compile
16029 time and a Program_Error exception at run time.
16032 An address clause cannot be given for an exported object. More
16033 understandably the real restriction is that objects with an address
16034 clause cannot be exported. This is because such variables are not
16035 defined by the Ada program, so there is no external object to export.
16038 It is permissible to give an address clause and a pragma Import for the
16039 same object. In this case, the variable is not really defined by the
16040 Ada program, so there is no external symbol to be linked. The link name
16041 and the external name are ignored in this case. The reason that we allow this
16042 combination is that it provides a useful idiom to avoid unwanted
16043 initializations on objects with address clauses.
16045 When an address clause is given for an object that has implicit or
16046 explicit initialization, then by default initialization takes place. This
16047 means that the effect of the object declaration is to overwrite the
16048 memory at the specified address. This is almost always not what the
16049 programmer wants, so GNAT will output a warning:
16059 for Ext'Address use System'To_Address (16#1234_1234#);
16061 >>> warning: implicit initialization of "Ext" may
16062 modify overlaid storage
16063 >>> warning: use pragma Import for "Ext" to suppress
16064 initialization (RM B(24))
16070 As indicated by the warning message, the solution is to use a (dummy) pragma
16071 Import to suppress this initialization. The pragma tell the compiler that the
16072 object is declared and initialized elsewhere. The following package compiles
16073 without warnings (and the initialization is suppressed):
16075 @smallexample @c ada
16083 for Ext'Address use System'To_Address (16#1234_1234#);
16084 pragma Import (Ada, Ext);
16089 A final issue with address clauses involves their use for overlaying
16090 variables, as in the following example:
16091 @cindex Overlaying of objects
16093 @smallexample @c ada
16096 for B'Address use A'Address;
16100 or alternatively, using the form recommended by the RM:
16102 @smallexample @c ada
16104 Addr : constant Address := A'Address;
16106 for B'Address use Addr;
16110 In both of these cases, @code{A}
16111 and @code{B} become aliased to one another via the
16112 address clause. This use of address clauses to overlay
16113 variables, achieving an effect similar to unchecked
16114 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16115 the effect is implementation defined. Furthermore, the
16116 Ada RM specifically recommends that in a situation
16117 like this, @code{B} should be subject to the following
16118 implementation advice (RM 13.3(19)):
16121 19 If the Address of an object is specified, or it is imported
16122 or exported, then the implementation should not perform
16123 optimizations based on assumptions of no aliases.
16127 GNAT follows this recommendation, and goes further by also applying
16128 this recommendation to the overlaid variable (@code{A}
16129 in the above example) in this case. This means that the overlay
16130 works "as expected", in that a modification to one of the variables
16131 will affect the value of the other.
16133 Note that when address clause overlays are used in this way, there is an
16134 issue of unintentional initialization, as shown by this example:
16136 @smallexample @c ada
16137 package Overwrite_Record is
16139 A : Character := 'C';
16140 B : Character := 'A';
16142 X : Short_Integer := 3;
16144 for Y'Address use X'Address;
16146 >>> warning: default initialization of "Y" may
16147 modify "X", use pragma Import for "Y" to
16148 suppress initialization (RM B.1(24))
16150 end Overwrite_Record;
16154 Here the default initialization of @code{Y} will clobber the value
16155 of @code{X}, which justifies the warning. The warning notes that
16156 this effect can be eliminated by adding a @code{pragma Import}
16157 which suppresses the initialization:
16159 @smallexample @c ada
16160 package Overwrite_Record is
16162 A : Character := 'C';
16163 B : Character := 'A';
16165 X : Short_Integer := 3;
16167 for Y'Address use X'Address;
16168 pragma Import (Ada, Y);
16169 end Overwrite_Record;
16173 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16174 be initialized when they would not otherwise have been in the absence
16175 of the use of this pragma. This may cause an overlay to have this
16176 unintended clobbering effect. The compiler avoids this for scalar
16177 types, but not for composite objects (where in general the effect
16178 of @code{Initialize_Scalars} is part of the initialization routine
16179 for the composite object:
16181 @smallexample @c ada
16182 pragma Initialize_Scalars;
16183 with Ada.Text_IO; use Ada.Text_IO;
16184 procedure Overwrite_Array is
16185 type Arr is array (1 .. 5) of Integer;
16186 X : Arr := (others => 1);
16188 for A'Address use X'Address;
16190 >>> warning: default initialization of "A" may
16191 modify "X", use pragma Import for "A" to
16192 suppress initialization (RM B.1(24))
16195 if X /= Arr'(others => 1) then
16196 Put_Line ("X was clobbered");
16198 Put_Line ("X was not clobbered");
16200 end Overwrite_Array;
16204 The above program generates the warning as shown, and at execution
16205 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16206 added as suggested:
16208 @smallexample @c ada
16209 pragma Initialize_Scalars;
16210 with Ada.Text_IO; use Ada.Text_IO;
16211 procedure Overwrite_Array is
16212 type Arr is array (1 .. 5) of Integer;
16213 X : Arr := (others => 1);
16215 for A'Address use X'Address;
16216 pragma Import (Ada, A);
16218 if X /= Arr'(others => 1) then
16219 Put_Line ("X was clobbered");
16221 Put_Line ("X was not clobbered");
16223 end Overwrite_Array;
16227 then the program compiles without the warning and when run will generate
16228 the output @code{X was not clobbered}.
16230 @node Effect of Convention on Representation
16231 @section Effect of Convention on Representation
16232 @cindex Convention, effect on representation
16235 Normally the specification of a foreign language convention for a type or
16236 an object has no effect on the chosen representation. In particular, the
16237 representation chosen for data in GNAT generally meets the standard system
16238 conventions, and for example records are laid out in a manner that is
16239 consistent with C@. This means that specifying convention C (for example)
16242 There are four exceptions to this general rule:
16246 @item Convention Fortran and array subtypes
16247 If pragma Convention Fortran is specified for an array subtype, then in
16248 accordance with the implementation advice in section 3.6.2(11) of the
16249 Ada Reference Manual, the array will be stored in a Fortran-compatible
16250 column-major manner, instead of the normal default row-major order.
16252 @item Convention C and enumeration types
16253 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16254 to accommodate all values of the type. For example, for the enumeration
16257 @smallexample @c ada
16258 type Color is (Red, Green, Blue);
16262 8 bits is sufficient to store all values of the type, so by default, objects
16263 of type @code{Color} will be represented using 8 bits. However, normal C
16264 convention is to use 32 bits for all enum values in C, since enum values
16265 are essentially of type int. If pragma @code{Convention C} is specified for an
16266 Ada enumeration type, then the size is modified as necessary (usually to
16267 32 bits) to be consistent with the C convention for enum values.
16269 Note that this treatment applies only to types. If Convention C is given for
16270 an enumeration object, where the enumeration type is not Convention C, then
16271 Object_Size bits are allocated. For example, for a normal enumeration type,
16272 with less than 256 elements, only 8 bits will be allocated for the object.
16273 Since this may be a surprise in terms of what C expects, GNAT will issue a
16274 warning in this situation. The warning can be suppressed by giving an explicit
16275 size clause specifying the desired size.
16277 @item Convention C/Fortran and Boolean types
16278 In C, the usual convention for boolean values, that is values used for
16279 conditions, is that zero represents false, and nonzero values represent
16280 true. In Ada, the normal convention is that two specific values, typically
16281 0/1, are used to represent false/true respectively.
16283 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16284 value represents true).
16286 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16287 C or Fortran convention for a derived Boolean, as in the following example:
16289 @smallexample @c ada
16290 type C_Switch is new Boolean;
16291 pragma Convention (C, C_Switch);
16295 then the GNAT generated code will treat any nonzero value as true. For truth
16296 values generated by GNAT, the conventional value 1 will be used for True, but
16297 when one of these values is read, any nonzero value is treated as True.
16299 @item Access types on OpenVMS
16300 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16301 arrays) are 64-bits long. An exception to this rule is for the case of
16302 C-convention access types where there is no explicit size clause present (or
16303 inherited for derived types). In this case, GNAT chooses to make these
16304 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16305 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16309 @node Conventions and Anonymous Access Types
16310 @section Conventions and Anonymous Access Types
16311 @cindex Anonymous access types
16312 @cindex Convention for anonymous access types
16314 The RM is not entirely clear on convention handling in a number of cases,
16315 and in particular, it is not clear on the convention to be given to
16316 anonymous access types in general, and in particular what is to be
16317 done for the case of anonymous access-to-subprogram.
16319 In GNAT, we decide that if an explicit Convention is applied
16320 to an object or component, and its type is such an anonymous type,
16321 then the convention will apply to this anonymous type as well. This
16322 seems to make sense since it is anomolous in any case to have a
16323 different convention for an object and its type, and there is clearly
16324 no way to explicitly specify a convention for an anonymous type, since
16325 it doesn't have a name to specify!
16327 Furthermore, we decide that if a convention is applied to a record type,
16328 then this convention is inherited by any of its components that are of an
16329 anonymous access type which do not have an explicitly specified convention.
16331 The following program shows these conventions in action:
16333 @smallexample @c ada
16334 package ConvComp is
16335 type Foo is range 1 .. 10;
16337 A : access function (X : Foo) return Integer;
16340 pragma Convention (C, T1);
16343 A : access function (X : Foo) return Integer;
16344 pragma Convention (C, A);
16347 pragma Convention (COBOL, T2);
16350 A : access function (X : Foo) return Integer;
16351 pragma Convention (COBOL, A);
16354 pragma Convention (C, T3);
16357 A : access function (X : Foo) return Integer;
16360 pragma Convention (COBOL, T4);
16362 function F (X : Foo) return Integer;
16363 pragma Convention (C, F);
16365 function F (X : Foo) return Integer is (13);
16367 TV1 : T1 := (F'Access, 12); -- OK
16368 TV2 : T2 := (F'Access, 13); -- OK
16370 TV3 : T3 := (F'Access, 13); -- ERROR
16372 >>> subprogram "F" has wrong convention
16373 >>> does not match access to subprogram declared at line 17
16374 38. TV4 : T4 := (F'Access, 13); -- ERROR
16376 >>> subprogram "F" has wrong convention
16377 >>> does not match access to subprogram declared at line 24
16381 @node Determining the Representations chosen by GNAT
16382 @section Determining the Representations chosen by GNAT
16383 @cindex Representation, determination of
16384 @cindex @option{-gnatR} switch
16387 Although the descriptions in this section are intended to be complete, it is
16388 often easier to simply experiment to see what GNAT accepts and what the
16389 effect is on the layout of types and objects.
16391 As required by the Ada RM, if a representation clause is not accepted, then
16392 it must be rejected as illegal by the compiler. However, when a
16393 representation clause or pragma is accepted, there can still be questions
16394 of what the compiler actually does. For example, if a partial record
16395 representation clause specifies the location of some components and not
16396 others, then where are the non-specified components placed? Or if pragma
16397 @code{Pack} is used on a record, then exactly where are the resulting
16398 fields placed? The section on pragma @code{Pack} in this chapter can be
16399 used to answer the second question, but it is often easier to just see
16400 what the compiler does.
16402 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
16403 with this option, then the compiler will output information on the actual
16404 representations chosen, in a format similar to source representation
16405 clauses. For example, if we compile the package:
16407 @smallexample @c ada
16409 type r (x : boolean) is tagged record
16411 when True => S : String (1 .. 100);
16412 when False => null;
16416 type r2 is new r (false) with record
16421 y2 at 16 range 0 .. 31;
16428 type x1 is array (1 .. 10) of x;
16429 for x1'component_size use 11;
16431 type ia is access integer;
16433 type Rb1 is array (1 .. 13) of Boolean;
16436 type Rb2 is array (1 .. 65) of Boolean;
16452 using the switch @option{-gnatR} we obtain the following output:
16455 Representation information for unit q
16456 -------------------------------------
16459 for r'Alignment use 4;
16461 x at 4 range 0 .. 7;
16462 _tag at 0 range 0 .. 31;
16463 s at 5 range 0 .. 799;
16466 for r2'Size use 160;
16467 for r2'Alignment use 4;
16469 x at 4 range 0 .. 7;
16470 _tag at 0 range 0 .. 31;
16471 _parent at 0 range 0 .. 63;
16472 y2 at 16 range 0 .. 31;
16476 for x'Alignment use 1;
16478 y at 0 range 0 .. 7;
16481 for x1'Size use 112;
16482 for x1'Alignment use 1;
16483 for x1'Component_Size use 11;
16485 for rb1'Size use 13;
16486 for rb1'Alignment use 2;
16487 for rb1'Component_Size use 1;
16489 for rb2'Size use 72;
16490 for rb2'Alignment use 1;
16491 for rb2'Component_Size use 1;
16493 for x2'Size use 224;
16494 for x2'Alignment use 4;
16496 l1 at 0 range 0 .. 0;
16497 l2 at 0 range 1 .. 64;
16498 l3 at 12 range 0 .. 31;
16499 l4 at 16 range 0 .. 0;
16500 l5 at 16 range 1 .. 13;
16501 l6 at 18 range 0 .. 71;
16506 The Size values are actually the Object_Size, i.e.@: the default size that
16507 will be allocated for objects of the type.
16508 The ?? size for type r indicates that we have a variant record, and the
16509 actual size of objects will depend on the discriminant value.
16511 The Alignment values show the actual alignment chosen by the compiler
16512 for each record or array type.
16514 The record representation clause for type r shows where all fields
16515 are placed, including the compiler generated tag field (whose location
16516 cannot be controlled by the programmer).
16518 The record representation clause for the type extension r2 shows all the
16519 fields present, including the parent field, which is a copy of the fields
16520 of the parent type of r2, i.e.@: r1.
16522 The component size and size clauses for types rb1 and rb2 show
16523 the exact effect of pragma @code{Pack} on these arrays, and the record
16524 representation clause for type x2 shows how pragma @code{Pack} affects
16527 In some cases, it may be useful to cut and paste the representation clauses
16528 generated by the compiler into the original source to fix and guarantee
16529 the actual representation to be used.
16531 @node Standard Library Routines
16532 @chapter Standard Library Routines
16535 The Ada Reference Manual contains in Annex A a full description of an
16536 extensive set of standard library routines that can be used in any Ada
16537 program, and which must be provided by all Ada compilers. They are
16538 analogous to the standard C library used by C programs.
16540 GNAT implements all of the facilities described in annex A, and for most
16541 purposes the description in the Ada Reference Manual, or appropriate Ada
16542 text book, will be sufficient for making use of these facilities.
16544 In the case of the input-output facilities,
16545 @xref{The Implementation of Standard I/O},
16546 gives details on exactly how GNAT interfaces to the
16547 file system. For the remaining packages, the Ada Reference Manual
16548 should be sufficient. The following is a list of the packages included,
16549 together with a brief description of the functionality that is provided.
16551 For completeness, references are included to other predefined library
16552 routines defined in other sections of the Ada Reference Manual (these are
16553 cross-indexed from Annex A). For further details see the relevant
16554 package declarations in the run-time library. In particular, a few units
16555 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
16556 and in this case the package declaration contains comments explaining why
16557 the unit is not implemented.
16561 This is a parent package for all the standard library packages. It is
16562 usually included implicitly in your program, and itself contains no
16563 useful data or routines.
16565 @item Ada.Assertions (11.4.2)
16566 @code{Assertions} provides the @code{Assert} subprograms, and also
16567 the declaration of the @code{Assertion_Error} exception.
16569 @item Ada.Asynchronous_Task_Control (D.11)
16570 @code{Asynchronous_Task_Control} provides low level facilities for task
16571 synchronization. It is typically not implemented. See package spec for details.
16573 @item Ada.Calendar (9.6)
16574 @code{Calendar} provides time of day access, and routines for
16575 manipulating times and durations.
16577 @item Ada.Calendar.Arithmetic (9.6.1)
16578 This package provides additional arithmetic
16579 operations for @code{Calendar}.
16581 @item Ada.Calendar.Formatting (9.6.1)
16582 This package provides formatting operations for @code{Calendar}.
16584 @item Ada.Calendar.Time_Zones (9.6.1)
16585 This package provides additional @code{Calendar} facilities
16586 for handling time zones.
16588 @item Ada.Characters (A.3.1)
16589 This is a dummy parent package that contains no useful entities
16591 @item Ada.Characters.Conversions (A.3.2)
16592 This package provides character conversion functions.
16594 @item Ada.Characters.Handling (A.3.2)
16595 This package provides some basic character handling capabilities,
16596 including classification functions for classes of characters (e.g.@: test
16597 for letters, or digits).
16599 @item Ada.Characters.Latin_1 (A.3.3)
16600 This package includes a complete set of definitions of the characters
16601 that appear in type CHARACTER@. It is useful for writing programs that
16602 will run in international environments. For example, if you want an
16603 upper case E with an acute accent in a string, it is often better to use
16604 the definition of @code{UC_E_Acute} in this package. Then your program
16605 will print in an understandable manner even if your environment does not
16606 support these extended characters.
16608 @item Ada.Command_Line (A.15)
16609 This package provides access to the command line parameters and the name
16610 of the current program (analogous to the use of @code{argc} and @code{argv}
16611 in C), and also allows the exit status for the program to be set in a
16612 system-independent manner.
16614 @item Ada.Complex_Text_IO (G.1.3)
16615 This package provides text input and output of complex numbers.
16617 @item Ada.Containers (A.18.1)
16618 A top level package providing a few basic definitions used by all the
16619 following specific child packages that provide specific kinds of
16622 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
16624 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
16626 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
16628 @item Ada.Containers.Generic_Array_Sort (A.18.26)
16630 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
16632 @item Ada.Containers.Generic_Sort (A.18.26)
16634 @item Ada.Containers.Hashed_Maps (A.18.5)
16636 @item Ada.Containers.Hashed_Sets (A.18.8)
16638 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
16640 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
16642 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
16644 @item Ada.Containers.Indefinite_Holders (A.18.18)
16646 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
16648 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
16650 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
16652 @item Ada.Containers.Indefinite_Vectors (A.18.11)
16654 @item Ada.Containers.Multiway_Trees (A.18.10)
16656 @item Ada.Containers.Ordered_Maps (A.18.6)
16658 @item Ada.Containers.Ordered_Sets (A.18.9)
16660 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
16662 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
16664 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
16666 @item Ada.Containers.Vectors (A.18.2)
16668 @item Ada.Directories (A.16)
16669 This package provides operations on directories.
16671 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
16672 This package provides additional directory operations handling
16673 hiearchical file names.
16675 @item Ada.Directories.Information (A.16)
16676 This is an implementation defined package for additional directory
16677 operations, which is not implemented in GNAT.
16679 @item Ada.Decimal (F.2)
16680 This package provides constants describing the range of decimal numbers
16681 implemented, and also a decimal divide routine (analogous to the COBOL
16682 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
16684 @item Ada.Direct_IO (A.8.4)
16685 This package provides input-output using a model of a set of records of
16686 fixed-length, containing an arbitrary definite Ada type, indexed by an
16687 integer record number.
16689 @item Ada.Dispatching (D.2.1)
16690 A parent package containing definitions for task dispatching operations.
16692 @item Ada.Dispatching.EDF (D.2.6)
16693 Not implemented in GNAT.
16695 @item Ada.Dispatching.Non_Preemptive (D.2.4)
16696 Not implemented in GNAT.
16698 @item Ada.Dispatching.Round_Robin (D.2.5)
16699 Not implemented in GNAT.
16701 @item Ada.Dynamic_Priorities (D.5)
16702 This package allows the priorities of a task to be adjusted dynamically
16703 as the task is running.
16705 @item Ada.Environment_Variables (A.17)
16706 This package provides facilities for accessing environment variables.
16708 @item Ada.Exceptions (11.4.1)
16709 This package provides additional information on exceptions, and also
16710 contains facilities for treating exceptions as data objects, and raising
16711 exceptions with associated messages.
16713 @item Ada.Execution_Time (D.14)
16714 Not implemented in GNAT.
16716 @item Ada.Execution_Time.Group_Budgets (D.14.2)
16717 Not implemented in GNAT.
16719 @item Ada.Execution_Time.Timers (D.14.1)'
16720 Not implemented in GNAT.
16722 @item Ada.Finalization (7.6)
16723 This package contains the declarations and subprograms to support the
16724 use of controlled types, providing for automatic initialization and
16725 finalization (analogous to the constructors and destructors of C++).
16727 @item Ada.Float_Text_IO (A.10.9)
16728 A library level instantiation of Text_IO.Float_IO for type Float.
16730 @item Ada.Float_Wide_Text_IO (A.10.9)
16731 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
16733 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
16734 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
16736 @item Ada.Integer_Text_IO (A.10.9)
16737 A library level instantiation of Text_IO.Integer_IO for type Integer.
16739 @item Ada.Integer_Wide_Text_IO (A.10.9)
16740 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
16742 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
16743 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
16745 @item Ada.Interrupts (C.3.2)
16746 This package provides facilities for interfacing to interrupts, which
16747 includes the set of signals or conditions that can be raised and
16748 recognized as interrupts.
16750 @item Ada.Interrupts.Names (C.3.2)
16751 This package provides the set of interrupt names (actually signal
16752 or condition names) that can be handled by GNAT@.
16754 @item Ada.IO_Exceptions (A.13)
16755 This package defines the set of exceptions that can be raised by use of
16756 the standard IO packages.
16758 @item Ada.Iterator_Interfaces (5.5.1)
16759 This package provides a generic interface to generalized iterators.
16761 @item Ada.Locales (A.19)
16762 This package provides declarations providing information (Language
16763 and Country) about the current locale.
16766 This package contains some standard constants and exceptions used
16767 throughout the numerics packages. Note that the constants pi and e are
16768 defined here, and it is better to use these definitions than rolling
16771 @item Ada.Numerics.Complex_Arrays (G.3.2)
16772 Provides operations on arrays of complex numbers.
16774 @item Ada.Numerics.Complex_Elementary_Functions
16775 Provides the implementation of standard elementary functions (such as
16776 log and trigonometric functions) operating on complex numbers using the
16777 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
16778 created by the package @code{Numerics.Complex_Types}.
16780 @item Ada.Numerics.Complex_Types
16781 This is a predefined instantiation of
16782 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
16783 build the type @code{Complex} and @code{Imaginary}.
16785 @item Ada.Numerics.Discrete_Random
16786 This generic package provides a random number generator suitable for generating
16787 uniformly distributed values of a specified discrete subtype.
16789 @item Ada.Numerics.Float_Random
16790 This package provides a random number generator suitable for generating
16791 uniformly distributed floating point values in the unit interval.
16793 @item Ada.Numerics.Generic_Complex_Elementary_Functions
16794 This is a generic version of the package that provides the
16795 implementation of standard elementary functions (such as log and
16796 trigonometric functions) for an arbitrary complex type.
16798 The following predefined instantiations of this package are provided:
16802 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
16804 @code{Ada.Numerics.Complex_Elementary_Functions}
16806 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
16809 @item Ada.Numerics.Generic_Complex_Types
16810 This is a generic package that allows the creation of complex types,
16811 with associated complex arithmetic operations.
16813 The following predefined instantiations of this package exist
16816 @code{Ada.Numerics.Short_Complex_Complex_Types}
16818 @code{Ada.Numerics.Complex_Complex_Types}
16820 @code{Ada.Numerics.Long_Complex_Complex_Types}
16823 @item Ada.Numerics.Generic_Elementary_Functions
16824 This is a generic package that provides the implementation of standard
16825 elementary functions (such as log an trigonometric functions) for an
16826 arbitrary float type.
16828 The following predefined instantiations of this package exist
16832 @code{Ada.Numerics.Short_Elementary_Functions}
16834 @code{Ada.Numerics.Elementary_Functions}
16836 @code{Ada.Numerics.Long_Elementary_Functions}
16839 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
16840 Generic operations on arrays of reals
16842 @item Ada.Numerics.Real_Arrays (G.3.1)
16843 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
16845 @item Ada.Real_Time (D.8)
16846 This package provides facilities similar to those of @code{Calendar}, but
16847 operating with a finer clock suitable for real time control. Note that
16848 annex D requires that there be no backward clock jumps, and GNAT generally
16849 guarantees this behavior, but of course if the external clock on which
16850 the GNAT runtime depends is deliberately reset by some external event,
16851 then such a backward jump may occur.
16853 @item Ada.Real_Time.Timing_Events (D.15)
16854 Not implemented in GNAT.
16856 @item Ada.Sequential_IO (A.8.1)
16857 This package provides input-output facilities for sequential files,
16858 which can contain a sequence of values of a single type, which can be
16859 any Ada type, including indefinite (unconstrained) types.
16861 @item Ada.Storage_IO (A.9)
16862 This package provides a facility for mapping arbitrary Ada types to and
16863 from a storage buffer. It is primarily intended for the creation of new
16866 @item Ada.Streams (13.13.1)
16867 This is a generic package that provides the basic support for the
16868 concept of streams as used by the stream attributes (@code{Input},
16869 @code{Output}, @code{Read} and @code{Write}).
16871 @item Ada.Streams.Stream_IO (A.12.1)
16872 This package is a specialization of the type @code{Streams} defined in
16873 package @code{Streams} together with a set of operations providing
16874 Stream_IO capability. The Stream_IO model permits both random and
16875 sequential access to a file which can contain an arbitrary set of values
16876 of one or more Ada types.
16878 @item Ada.Strings (A.4.1)
16879 This package provides some basic constants used by the string handling
16882 @item Ada.Strings.Bounded (A.4.4)
16883 This package provides facilities for handling variable length
16884 strings. The bounded model requires a maximum length. It is thus
16885 somewhat more limited than the unbounded model, but avoids the use of
16886 dynamic allocation or finalization.
16888 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
16889 Provides case-insensitive comparisons of bounded strings
16891 @item Ada.Strings.Bounded.Hash (A.4.9)
16892 This package provides a generic hash function for bounded strings
16894 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
16895 This package provides a generic hash function for bounded strings that
16896 converts the string to be hashed to lower case.
16898 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
16899 This package provides a comparison function for bounded strings that works
16900 in a case insensitive manner by converting to lower case before the comparison.
16902 @item Ada.Strings.Fixed (A.4.3)
16903 This package provides facilities for handling fixed length strings.
16905 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
16906 This package provides an equality function for fixed strings that compares
16907 the strings after converting both to lower case.
16909 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
16910 This package provides a case insensitive hash function for fixed strings that
16911 converts the string to lower case before computing the hash.
16913 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
16914 This package provides a comparison function for fixed strings that works
16915 in a case insensitive manner by converting to lower case before the comparison.
16917 Ada.Strings.Hash (A.4.9)
16918 This package provides a hash function for strings.
16920 Ada.Strings.Hash_Case_Insensitive (A.4.9)
16921 This package provides a hash function for strings that is case insensitive.
16922 The string is converted to lower case before computing the hash.
16924 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
16925 This package provides a comparison function for\strings that works
16926 in a case insensitive manner by converting to lower case before the comparison.
16928 @item Ada.Strings.Maps (A.4.2)
16929 This package provides facilities for handling character mappings and
16930 arbitrarily defined subsets of characters. For instance it is useful in
16931 defining specialized translation tables.
16933 @item Ada.Strings.Maps.Constants (A.4.6)
16934 This package provides a standard set of predefined mappings and
16935 predefined character sets. For example, the standard upper to lower case
16936 conversion table is found in this package. Note that upper to lower case
16937 conversion is non-trivial if you want to take the entire set of
16938 characters, including extended characters like E with an acute accent,
16939 into account. You should use the mappings in this package (rather than
16940 adding 32 yourself) to do case mappings.
16942 @item Ada.Strings.Unbounded (A.4.5)
16943 This package provides facilities for handling variable length
16944 strings. The unbounded model allows arbitrary length strings, but
16945 requires the use of dynamic allocation and finalization.
16947 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
16948 Provides case-insensitive comparisons of unbounded strings
16950 @item Ada.Strings.Unbounded.Hash (A.4.9)
16951 This package provides a generic hash function for unbounded strings
16953 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
16954 This package provides a generic hash function for unbounded strings that
16955 converts the string to be hashed to lower case.
16957 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
16958 This package provides a comparison function for unbounded strings that works
16959 in a case insensitive manner by converting to lower case before the comparison.
16961 @item Ada.Strings.UTF_Encoding (A.4.11)
16962 This package provides basic definitions for dealing with UTF-encoded strings.
16964 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
16965 This package provides conversion functions for UTF-encoded strings.
16967 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
16968 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
16969 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
16970 These packages provide facilities for handling UTF encodings for
16971 Strings, Wide_Strings and Wide_Wide_Strings.
16973 @item Ada.Strings.Wide_Bounded (A.4.7)
16974 @itemx Ada.Strings.Wide_Fixed (A.4.7)
16975 @itemx Ada.Strings.Wide_Maps (A.4.7)
16976 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
16977 These packages provide analogous capabilities to the corresponding
16978 packages without @samp{Wide_} in the name, but operate with the types
16979 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
16980 and @code{Character}. Versions of all the child packages are available.
16982 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
16983 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
16984 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
16985 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
16986 These packages provide analogous capabilities to the corresponding
16987 packages without @samp{Wide_} in the name, but operate with the types
16988 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
16989 of @code{String} and @code{Character}.
16991 @item Ada.Synchronous_Barriers (D.10.1)
16992 This package provides facilities for synchronizing tasks at a low level
16995 @item Ada.Synchronous_Task_Control (D.10)
16996 This package provides some standard facilities for controlling task
16997 communication in a synchronous manner.
16999 @item Ada.Synchronous_Task_Control.EDF (D.10)
17000 Not implemented in GNAT.
17003 This package contains definitions for manipulation of the tags of tagged
17006 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17007 This package provides a way of constructing tagged class-wide values given
17008 only the tag value.
17010 @item Ada.Task_Attributes (C.7.2)
17011 This package provides the capability of associating arbitrary
17012 task-specific data with separate tasks.
17014 @item Ada.Task_Identifification (C.7.1)
17015 This package provides capabilities for task identification.
17017 @item Ada.Task_Termination (C.7.3)
17018 This package provides control over task termination.
17021 This package provides basic text input-output capabilities for
17022 character, string and numeric data. The subpackages of this
17023 package are listed next. Note that although these are defined
17024 as subpackages in the RM, they are actually transparently
17025 implemented as child packages in GNAT, meaning that they
17026 are only loaded if needed.
17028 @item Ada.Text_IO.Decimal_IO
17029 Provides input-output facilities for decimal fixed-point types
17031 @item Ada.Text_IO.Enumeration_IO
17032 Provides input-output facilities for enumeration types.
17034 @item Ada.Text_IO.Fixed_IO
17035 Provides input-output facilities for ordinary fixed-point types.
17037 @item Ada.Text_IO.Float_IO
17038 Provides input-output facilities for float types. The following
17039 predefined instantiations of this generic package are available:
17043 @code{Short_Float_Text_IO}
17045 @code{Float_Text_IO}
17047 @code{Long_Float_Text_IO}
17050 @item Ada.Text_IO.Integer_IO
17051 Provides input-output facilities for integer types. The following
17052 predefined instantiations of this generic package are available:
17055 @item Short_Short_Integer
17056 @code{Ada.Short_Short_Integer_Text_IO}
17057 @item Short_Integer
17058 @code{Ada.Short_Integer_Text_IO}
17060 @code{Ada.Integer_Text_IO}
17062 @code{Ada.Long_Integer_Text_IO}
17063 @item Long_Long_Integer
17064 @code{Ada.Long_Long_Integer_Text_IO}
17067 @item Ada.Text_IO.Modular_IO
17068 Provides input-output facilities for modular (unsigned) types.
17070 @item Ada.Text_IO.Bounded_IO (A.10.11)
17071 Provides input-output facilities for bounded strings.
17073 @item Ada.Text_IO.Complex_IO (G.1.3)
17074 This package provides basic text input-output capabilities for complex
17077 @item Ada.Text_IO.Editing (F.3.3)
17078 This package contains routines for edited output, analogous to the use
17079 of pictures in COBOL@. The picture formats used by this package are a
17080 close copy of the facility in COBOL@.
17082 @item Ada.Text_IO.Text_Streams (A.12.2)
17083 This package provides a facility that allows Text_IO files to be treated
17084 as streams, so that the stream attributes can be used for writing
17085 arbitrary data, including binary data, to Text_IO files.
17087 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17088 This package provides input-output facilities for unbounded strings.
17090 @item Ada.Unchecked_Conversion (13.9)
17091 This generic package allows arbitrary conversion from one type to
17092 another of the same size, providing for breaking the type safety in
17093 special circumstances.
17095 If the types have the same Size (more accurately the same Value_Size),
17096 then the effect is simply to transfer the bits from the source to the
17097 target type without any modification. This usage is well defined, and
17098 for simple types whose representation is typically the same across
17099 all implementations, gives a portable method of performing such
17102 If the types do not have the same size, then the result is implementation
17103 defined, and thus may be non-portable. The following describes how GNAT
17104 handles such unchecked conversion cases.
17106 If the types are of different sizes, and are both discrete types, then
17107 the effect is of a normal type conversion without any constraint checking.
17108 In particular if the result type has a larger size, the result will be
17109 zero or sign extended. If the result type has a smaller size, the result
17110 will be truncated by ignoring high order bits.
17112 If the types are of different sizes, and are not both discrete types,
17113 then the conversion works as though pointers were created to the source
17114 and target, and the pointer value is converted. The effect is that bits
17115 are copied from successive low order storage units and bits of the source
17116 up to the length of the target type.
17118 A warning is issued if the lengths differ, since the effect in this
17119 case is implementation dependent, and the above behavior may not match
17120 that of some other compiler.
17122 A pointer to one type may be converted to a pointer to another type using
17123 unchecked conversion. The only case in which the effect is undefined is
17124 when one or both pointers are pointers to unconstrained array types. In
17125 this case, the bounds information may get incorrectly transferred, and in
17126 particular, GNAT uses double size pointers for such types, and it is
17127 meaningless to convert between such pointer types. GNAT will issue a
17128 warning if the alignment of the target designated type is more strict
17129 than the alignment of the source designated type (since the result may
17130 be unaligned in this case).
17132 A pointer other than a pointer to an unconstrained array type may be
17133 converted to and from System.Address. Such usage is common in Ada 83
17134 programs, but note that Ada.Address_To_Access_Conversions is the
17135 preferred method of performing such conversions in Ada 95 and Ada 2005.
17137 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17138 used in conjunction with pointers to unconstrained objects, since
17139 the bounds information cannot be handled correctly in this case.
17141 @item Ada.Unchecked_Deallocation (13.11.2)
17142 This generic package allows explicit freeing of storage previously
17143 allocated by use of an allocator.
17145 @item Ada.Wide_Text_IO (A.11)
17146 This package is similar to @code{Ada.Text_IO}, except that the external
17147 file supports wide character representations, and the internal types are
17148 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17149 and @code{String}. The corresponding set of nested packages and child
17150 packages are defined.
17152 @item Ada.Wide_Wide_Text_IO (A.11)
17153 This package is similar to @code{Ada.Text_IO}, except that the external
17154 file supports wide character representations, and the internal types are
17155 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17156 and @code{String}. The corresponding set of nested packages and child
17157 packages are defined.
17161 For packages in Interfaces and System, all the RM defined packages are
17162 available in GNAT, see the Ada 2012 RM for full details.
17164 @node The Implementation of Standard I/O
17165 @chapter The Implementation of Standard I/O
17168 GNAT implements all the required input-output facilities described in
17169 A.6 through A.14. These sections of the Ada Reference Manual describe the
17170 required behavior of these packages from the Ada point of view, and if
17171 you are writing a portable Ada program that does not need to know the
17172 exact manner in which Ada maps to the outside world when it comes to
17173 reading or writing external files, then you do not need to read this
17174 chapter. As long as your files are all regular files (not pipes or
17175 devices), and as long as you write and read the files only from Ada, the
17176 description in the Ada Reference Manual is sufficient.
17178 However, if you want to do input-output to pipes or other devices, such
17179 as the keyboard or screen, or if the files you are dealing with are
17180 either generated by some other language, or to be read by some other
17181 language, then you need to know more about the details of how the GNAT
17182 implementation of these input-output facilities behaves.
17184 In this chapter we give a detailed description of exactly how GNAT
17185 interfaces to the file system. As always, the sources of the system are
17186 available to you for answering questions at an even more detailed level,
17187 but for most purposes the information in this chapter will suffice.
17189 Another reason that you may need to know more about how input-output is
17190 implemented arises when you have a program written in mixed languages
17191 where, for example, files are shared between the C and Ada sections of
17192 the same program. GNAT provides some additional facilities, in the form
17193 of additional child library packages, that facilitate this sharing, and
17194 these additional facilities are also described in this chapter.
17197 * Standard I/O Packages::
17203 * Wide_Wide_Text_IO::
17205 * Text Translation::
17207 * Filenames encoding::
17209 * Operations on C Streams::
17210 * Interfacing to C Streams::
17213 @node Standard I/O Packages
17214 @section Standard I/O Packages
17217 The Standard I/O packages described in Annex A for
17223 Ada.Text_IO.Complex_IO
17225 Ada.Text_IO.Text_Streams
17229 Ada.Wide_Text_IO.Complex_IO
17231 Ada.Wide_Text_IO.Text_Streams
17233 Ada.Wide_Wide_Text_IO
17235 Ada.Wide_Wide_Text_IO.Complex_IO
17237 Ada.Wide_Wide_Text_IO.Text_Streams
17247 are implemented using the C
17248 library streams facility; where
17252 All files are opened using @code{fopen}.
17254 All input/output operations use @code{fread}/@code{fwrite}.
17258 There is no internal buffering of any kind at the Ada library level. The only
17259 buffering is that provided at the system level in the implementation of the
17260 library routines that support streams. This facilitates shared use of these
17261 streams by mixed language programs. Note though that system level buffering is
17262 explicitly enabled at elaboration of the standard I/O packages and that can
17263 have an impact on mixed language programs, in particular those using I/O before
17264 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17265 the Ada elaboration routine before performing any I/O or when impractical,
17266 flush the common I/O streams and in particular Standard_Output before
17267 elaborating the Ada code.
17270 @section FORM Strings
17273 The format of a FORM string in GNAT is:
17276 "keyword=value,keyword=value,@dots{},keyword=value"
17280 where letters may be in upper or lower case, and there are no spaces
17281 between values. The order of the entries is not important. Currently
17282 the following keywords defined.
17285 TEXT_TRANSLATION=[YES|NO]
17287 WCEM=[n|h|u|s|e|8|b]
17288 ENCODING=[UTF8|8BITS]
17292 The use of these parameters is described later in this section. If an
17293 unrecognized keyword appears in a form string, it is silently ignored
17294 and not considered invalid.
17297 For OpenVMS additional FORM string keywords are available for use with
17298 RMS services. The syntax is:
17301 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17305 The following RMS keywords and values are currently defined:
17308 Context=Force_Stream_Mode|Force_Record_Mode
17312 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
17313 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17319 Direct_IO can only be instantiated for definite types. This is a
17320 restriction of the Ada language, which means that the records are fixed
17321 length (the length being determined by @code{@var{type}'Size}, rounded
17322 up to the next storage unit boundary if necessary).
17324 The records of a Direct_IO file are simply written to the file in index
17325 sequence, with the first record starting at offset zero, and subsequent
17326 records following. There is no control information of any kind. For
17327 example, if 32-bit integers are being written, each record takes
17328 4-bytes, so the record at index @var{K} starts at offset
17329 (@var{K}@minus{}1)*4.
17331 There is no limit on the size of Direct_IO files, they are expanded as
17332 necessary to accommodate whatever records are written to the file.
17334 @node Sequential_IO
17335 @section Sequential_IO
17338 Sequential_IO may be instantiated with either a definite (constrained)
17339 or indefinite (unconstrained) type.
17341 For the definite type case, the elements written to the file are simply
17342 the memory images of the data values with no control information of any
17343 kind. The resulting file should be read using the same type, no validity
17344 checking is performed on input.
17346 For the indefinite type case, the elements written consist of two
17347 parts. First is the size of the data item, written as the memory image
17348 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17349 the data value. The resulting file can only be read using the same
17350 (unconstrained) type. Normal assignment checks are performed on these
17351 read operations, and if these checks fail, @code{Data_Error} is
17352 raised. In particular, in the array case, the lengths must match, and in
17353 the variant record case, if the variable for a particular read operation
17354 is constrained, the discriminants must match.
17356 Note that it is not possible to use Sequential_IO to write variable
17357 length array items, and then read the data back into different length
17358 arrays. For example, the following will raise @code{Data_Error}:
17360 @smallexample @c ada
17361 package IO is new Sequential_IO (String);
17366 IO.Write (F, "hello!")
17367 IO.Reset (F, Mode=>In_File);
17374 On some Ada implementations, this will print @code{hell}, but the program is
17375 clearly incorrect, since there is only one element in the file, and that
17376 element is the string @code{hello!}.
17378 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17379 using Stream_IO, and this is the preferred mechanism. In particular, the
17380 above program fragment rewritten to use Stream_IO will work correctly.
17386 Text_IO files consist of a stream of characters containing the following
17387 special control characters:
17390 LF (line feed, 16#0A#) Line Mark
17391 FF (form feed, 16#0C#) Page Mark
17395 A canonical Text_IO file is defined as one in which the following
17396 conditions are met:
17400 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17404 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17405 end of a page and consequently can appear only immediately following a
17406 @code{LF} (line mark) character.
17409 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17410 (line mark, page mark). In the former case, the page mark is implicitly
17411 assumed to be present.
17415 A file written using Text_IO will be in canonical form provided that no
17416 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17417 or @code{Put_Line}. There will be no @code{FF} character at the end of
17418 the file unless an explicit @code{New_Page} operation was performed
17419 before closing the file.
17421 A canonical Text_IO file that is a regular file (i.e., not a device or a
17422 pipe) can be read using any of the routines in Text_IO@. The
17423 semantics in this case will be exactly as defined in the Ada Reference
17424 Manual, and all the routines in Text_IO are fully implemented.
17426 A text file that does not meet the requirements for a canonical Text_IO
17427 file has one of the following:
17431 The file contains @code{FF} characters not immediately following a
17432 @code{LF} character.
17435 The file contains @code{LF} or @code{FF} characters written by
17436 @code{Put} or @code{Put_Line}, which are not logically considered to be
17437 line marks or page marks.
17440 The file ends in a character other than @code{LF} or @code{FF},
17441 i.e.@: there is no explicit line mark or page mark at the end of the file.
17445 Text_IO can be used to read such non-standard text files but subprograms
17446 to do with line or page numbers do not have defined meanings. In
17447 particular, a @code{FF} character that does not follow a @code{LF}
17448 character may or may not be treated as a page mark from the point of
17449 view of page and line numbering. Every @code{LF} character is considered
17450 to end a line, and there is an implied @code{LF} character at the end of
17454 * Text_IO Stream Pointer Positioning::
17455 * Text_IO Reading and Writing Non-Regular Files::
17457 * Treating Text_IO Files as Streams::
17458 * Text_IO Extensions::
17459 * Text_IO Facilities for Unbounded Strings::
17462 @node Text_IO Stream Pointer Positioning
17463 @subsection Stream Pointer Positioning
17466 @code{Ada.Text_IO} has a definition of current position for a file that
17467 is being read. No internal buffering occurs in Text_IO, and usually the
17468 physical position in the stream used to implement the file corresponds
17469 to this logical position defined by Text_IO@. There are two exceptions:
17473 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17474 is positioned past the @code{LF} (line mark) that precedes the page
17475 mark. Text_IO maintains an internal flag so that subsequent read
17476 operations properly handle the logical position which is unchanged by
17477 the @code{End_Of_Page} call.
17480 After a call to @code{End_Of_File} that returns @code{True}, if the
17481 Text_IO file was positioned before the line mark at the end of file
17482 before the call, then the logical position is unchanged, but the stream
17483 is physically positioned right at the end of file (past the line mark,
17484 and past a possible page mark following the line mark. Again Text_IO
17485 maintains internal flags so that subsequent read operations properly
17486 handle the logical position.
17490 These discrepancies have no effect on the observable behavior of
17491 Text_IO, but if a single Ada stream is shared between a C program and
17492 Ada program, or shared (using @samp{shared=yes} in the form string)
17493 between two Ada files, then the difference may be observable in some
17496 @node Text_IO Reading and Writing Non-Regular Files
17497 @subsection Reading and Writing Non-Regular Files
17500 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
17501 can be used for reading and writing. Writing is not affected and the
17502 sequence of characters output is identical to the normal file case, but
17503 for reading, the behavior of Text_IO is modified to avoid undesirable
17504 look-ahead as follows:
17506 An input file that is not a regular file is considered to have no page
17507 marks. Any @code{Ascii.FF} characters (the character normally used for a
17508 page mark) appearing in the file are considered to be data
17509 characters. In particular:
17513 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17514 following a line mark. If a page mark appears, it will be treated as a
17518 This avoids the need to wait for an extra character to be typed or
17519 entered from the pipe to complete one of these operations.
17522 @code{End_Of_Page} always returns @code{False}
17525 @code{End_Of_File} will return @code{False} if there is a page mark at
17526 the end of the file.
17530 Output to non-regular files is the same as for regular files. Page marks
17531 may be written to non-regular files using @code{New_Page}, but as noted
17532 above they will not be treated as page marks on input if the output is
17533 piped to another Ada program.
17535 Another important discrepancy when reading non-regular files is that the end
17536 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
17537 pressing the @key{EOT} key,
17539 is signaled once (i.e.@: the test @code{End_Of_File}
17540 will yield @code{True}, or a read will
17541 raise @code{End_Error}), but then reading can resume
17542 to read data past that end of
17543 file indication, until another end of file indication is entered.
17545 @node Get_Immediate
17546 @subsection Get_Immediate
17547 @cindex Get_Immediate
17550 Get_Immediate returns the next character (including control characters)
17551 from the input file. In particular, Get_Immediate will return LF or FF
17552 characters used as line marks or page marks. Such operations leave the
17553 file positioned past the control character, and it is thus not treated
17554 as having its normal function. This means that page, line and column
17555 counts after this kind of Get_Immediate call are set as though the mark
17556 did not occur. In the case where a Get_Immediate leaves the file
17557 positioned between the line mark and page mark (which is not normally
17558 possible), it is undefined whether the FF character will be treated as a
17561 @node Treating Text_IO Files as Streams
17562 @subsection Treating Text_IO Files as Streams
17563 @cindex Stream files
17566 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
17567 as a stream. Data written to a Text_IO file in this stream mode is
17568 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
17569 16#0C# (@code{FF}), the resulting file may have non-standard
17570 format. Similarly if read operations are used to read from a Text_IO
17571 file treated as a stream, then @code{LF} and @code{FF} characters may be
17572 skipped and the effect is similar to that described above for
17573 @code{Get_Immediate}.
17575 @node Text_IO Extensions
17576 @subsection Text_IO Extensions
17577 @cindex Text_IO extensions
17580 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
17581 to the standard @code{Text_IO} package:
17584 @item function File_Exists (Name : String) return Boolean;
17585 Determines if a file of the given name exists.
17587 @item function Get_Line return String;
17588 Reads a string from the standard input file. The value returned is exactly
17589 the length of the line that was read.
17591 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
17592 Similar, except that the parameter File specifies the file from which
17593 the string is to be read.
17597 @node Text_IO Facilities for Unbounded Strings
17598 @subsection Text_IO Facilities for Unbounded Strings
17599 @cindex Text_IO for unbounded strings
17600 @cindex Unbounded_String, Text_IO operations
17603 The package @code{Ada.Strings.Unbounded.Text_IO}
17604 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
17605 subprograms useful for Text_IO operations on unbounded strings:
17609 @item function Get_Line (File : File_Type) return Unbounded_String;
17610 Reads a line from the specified file
17611 and returns the result as an unbounded string.
17613 @item procedure Put (File : File_Type; U : Unbounded_String);
17614 Writes the value of the given unbounded string to the specified file
17615 Similar to the effect of
17616 @code{Put (To_String (U))} except that an extra copy is avoided.
17618 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
17619 Writes the value of the given unbounded string to the specified file,
17620 followed by a @code{New_Line}.
17621 Similar to the effect of @code{Put_Line (To_String (U))} except
17622 that an extra copy is avoided.
17626 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
17627 and is optional. If the parameter is omitted, then the standard input or
17628 output file is referenced as appropriate.
17630 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
17631 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
17632 @code{Wide_Text_IO} functionality for unbounded wide strings.
17634 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
17635 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
17636 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
17639 @section Wide_Text_IO
17642 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
17643 both input and output files may contain special sequences that represent
17644 wide character values. The encoding scheme for a given file may be
17645 specified using a FORM parameter:
17652 as part of the FORM string (WCEM = wide character encoding method),
17653 where @var{x} is one of the following characters
17659 Upper half encoding
17671 The encoding methods match those that
17672 can be used in a source
17673 program, but there is no requirement that the encoding method used for
17674 the source program be the same as the encoding method used for files,
17675 and different files may use different encoding methods.
17677 The default encoding method for the standard files, and for opened files
17678 for which no WCEM parameter is given in the FORM string matches the
17679 wide character encoding specified for the main program (the default
17680 being brackets encoding if no coding method was specified with -gnatW).
17684 In this encoding, a wide character is represented by a five character
17692 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
17693 characters (using upper case letters) of the wide character code. For
17694 example, ESC A345 is used to represent the wide character with code
17695 16#A345#. This scheme is compatible with use of the full
17696 @code{Wide_Character} set.
17698 @item Upper Half Coding
17699 The wide character with encoding 16#abcd#, where the upper bit is on
17700 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
17701 16#cd#. The second byte may never be a format control character, but is
17702 not required to be in the upper half. This method can be also used for
17703 shift-JIS or EUC where the internal coding matches the external coding.
17705 @item Shift JIS Coding
17706 A wide character is represented by a two character sequence 16#ab# and
17707 16#cd#, with the restrictions described for upper half encoding as
17708 described above. The internal character code is the corresponding JIS
17709 character according to the standard algorithm for Shift-JIS
17710 conversion. Only characters defined in the JIS code set table can be
17711 used with this encoding method.
17714 A wide character is represented by a two character sequence 16#ab# and
17715 16#cd#, with both characters being in the upper half. The internal
17716 character code is the corresponding JIS character according to the EUC
17717 encoding algorithm. Only characters defined in the JIS code set table
17718 can be used with this encoding method.
17721 A wide character is represented using
17722 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17723 10646-1/Am.2. Depending on the character value, the representation
17724 is a one, two, or three byte sequence:
17727 16#0000#-16#007f#: 2#0xxxxxxx#
17728 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
17729 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17733 where the @var{xxx} bits correspond to the left-padded bits of the
17734 16-bit character value. Note that all lower half ASCII characters
17735 are represented as ASCII bytes and all upper half characters and
17736 other wide characters are represented as sequences of upper-half
17737 (The full UTF-8 scheme allows for encoding 31-bit characters as
17738 6-byte sequences, but in this implementation, all UTF-8 sequences
17739 of four or more bytes length will raise a Constraint_Error, as
17740 will all invalid UTF-8 sequences.)
17742 @item Brackets Coding
17743 In this encoding, a wide character is represented by the following eight
17744 character sequence:
17751 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
17752 characters (using uppercase letters) of the wide character code. For
17753 example, @code{["A345"]} is used to represent the wide character with code
17755 This scheme is compatible with use of the full Wide_Character set.
17756 On input, brackets coding can also be used for upper half characters,
17757 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
17758 is only used for wide characters with a code greater than @code{16#FF#}.
17760 Note that brackets coding is not normally used in the context of
17761 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
17762 a portable way of encoding source files. In the context of Wide_Text_IO
17763 or Wide_Wide_Text_IO, it can only be used if the file does not contain
17764 any instance of the left bracket character other than to encode wide
17765 character values using the brackets encoding method. In practice it is
17766 expected that some standard wide character encoding method such
17767 as UTF-8 will be used for text input output.
17769 If brackets notation is used, then any occurrence of a left bracket
17770 in the input file which is not the start of a valid wide character
17771 sequence will cause Constraint_Error to be raised. It is possible to
17772 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
17773 input will interpret this as a left bracket.
17775 However, when a left bracket is output, it will be output as a left bracket
17776 and not as ["5B"]. We make this decision because for normal use of
17777 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
17778 brackets. For example, if we write:
17781 Put_Line ("Start of output [first run]");
17785 we really do not want to have the left bracket in this message clobbered so
17786 that the output reads:
17789 Start of output ["5B"]first run]
17793 In practice brackets encoding is reasonably useful for normal Put_Line use
17794 since we won't get confused between left brackets and wide character
17795 sequences in the output. But for input, or when files are written out
17796 and read back in, it really makes better sense to use one of the standard
17797 encoding methods such as UTF-8.
17802 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
17803 not all wide character
17804 values can be represented. An attempt to output a character that cannot
17805 be represented using the encoding scheme for the file causes
17806 Constraint_Error to be raised. An invalid wide character sequence on
17807 input also causes Constraint_Error to be raised.
17810 * Wide_Text_IO Stream Pointer Positioning::
17811 * Wide_Text_IO Reading and Writing Non-Regular Files::
17814 @node Wide_Text_IO Stream Pointer Positioning
17815 @subsection Stream Pointer Positioning
17818 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17819 of stream pointer positioning (@pxref{Text_IO}). There is one additional
17822 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
17823 normal lower ASCII set (i.e.@: a character in the range:
17825 @smallexample @c ada
17826 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
17830 then although the logical position of the file pointer is unchanged by
17831 the @code{Look_Ahead} call, the stream is physically positioned past the
17832 wide character sequence. Again this is to avoid the need for buffering
17833 or backup, and all @code{Wide_Text_IO} routines check the internal
17834 indication that this situation has occurred so that this is not visible
17835 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
17836 can be observed if the wide text file shares a stream with another file.
17838 @node Wide_Text_IO Reading and Writing Non-Regular Files
17839 @subsection Reading and Writing Non-Regular Files
17842 As in the case of Text_IO, when a non-regular file is read, it is
17843 assumed that the file contains no page marks (any form characters are
17844 treated as data characters), and @code{End_Of_Page} always returns
17845 @code{False}. Similarly, the end of file indication is not sticky, so
17846 it is possible to read beyond an end of file.
17848 @node Wide_Wide_Text_IO
17849 @section Wide_Wide_Text_IO
17852 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
17853 both input and output files may contain special sequences that represent
17854 wide wide character values. The encoding scheme for a given file may be
17855 specified using a FORM parameter:
17862 as part of the FORM string (WCEM = wide character encoding method),
17863 where @var{x} is one of the following characters
17869 Upper half encoding
17881 The encoding methods match those that
17882 can be used in a source
17883 program, but there is no requirement that the encoding method used for
17884 the source program be the same as the encoding method used for files,
17885 and different files may use different encoding methods.
17887 The default encoding method for the standard files, and for opened files
17888 for which no WCEM parameter is given in the FORM string matches the
17889 wide character encoding specified for the main program (the default
17890 being brackets encoding if no coding method was specified with -gnatW).
17895 A wide character is represented using
17896 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17897 10646-1/Am.2. Depending on the character value, the representation
17898 is a one, two, three, or four byte sequence:
17901 16#000000#-16#00007f#: 2#0xxxxxxx#
17902 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
17903 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17904 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
17908 where the @var{xxx} bits correspond to the left-padded bits of the
17909 21-bit character value. Note that all lower half ASCII characters
17910 are represented as ASCII bytes and all upper half characters and
17911 other wide characters are represented as sequences of upper-half
17914 @item Brackets Coding
17915 In this encoding, a wide wide character is represented by the following eight
17916 character sequence if is in wide character range
17922 and by the following ten character sequence if not
17925 [ " a b c d e f " ]
17929 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
17930 are the four or six hexadecimal
17931 characters (using uppercase letters) of the wide wide character code. For
17932 example, @code{["01A345"]} is used to represent the wide wide character
17933 with code @code{16#01A345#}.
17935 This scheme is compatible with use of the full Wide_Wide_Character set.
17936 On input, brackets coding can also be used for upper half characters,
17937 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
17938 is only used for wide characters with a code greater than @code{16#FF#}.
17943 If is also possible to use the other Wide_Character encoding methods,
17944 such as Shift-JIS, but the other schemes cannot support the full range
17945 of wide wide characters.
17946 An attempt to output a character that cannot
17947 be represented using the encoding scheme for the file causes
17948 Constraint_Error to be raised. An invalid wide character sequence on
17949 input also causes Constraint_Error to be raised.
17952 * Wide_Wide_Text_IO Stream Pointer Positioning::
17953 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
17956 @node Wide_Wide_Text_IO Stream Pointer Positioning
17957 @subsection Stream Pointer Positioning
17960 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17961 of stream pointer positioning (@pxref{Text_IO}). There is one additional
17964 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
17965 normal lower ASCII set (i.e.@: a character in the range:
17967 @smallexample @c ada
17968 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
17972 then although the logical position of the file pointer is unchanged by
17973 the @code{Look_Ahead} call, the stream is physically positioned past the
17974 wide character sequence. Again this is to avoid the need for buffering
17975 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
17976 indication that this situation has occurred so that this is not visible
17977 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
17978 can be observed if the wide text file shares a stream with another file.
17980 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
17981 @subsection Reading and Writing Non-Regular Files
17984 As in the case of Text_IO, when a non-regular file is read, it is
17985 assumed that the file contains no page marks (any form characters are
17986 treated as data characters), and @code{End_Of_Page} always returns
17987 @code{False}. Similarly, the end of file indication is not sticky, so
17988 it is possible to read beyond an end of file.
17994 A stream file is a sequence of bytes, where individual elements are
17995 written to the file as described in the Ada Reference Manual. The type
17996 @code{Stream_Element} is simply a byte. There are two ways to read or
17997 write a stream file.
18001 The operations @code{Read} and @code{Write} directly read or write a
18002 sequence of stream elements with no control information.
18005 The stream attributes applied to a stream file transfer data in the
18006 manner described for stream attributes.
18009 @node Text Translation
18010 @section Text Translation
18013 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18014 passed to Text_IO.Create and Text_IO.Open:
18015 @samp{Text_Translation=@var{Yes}} is the default, which means to
18016 translate LF to/from CR/LF on Windows systems.
18017 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
18018 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18019 may be used to create Unix-style files on
18020 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
18024 @section Shared Files
18027 Section A.14 of the Ada Reference Manual allows implementations to
18028 provide a wide variety of behavior if an attempt is made to access the
18029 same external file with two or more internal files.
18031 To provide a full range of functionality, while at the same time
18032 minimizing the problems of portability caused by this implementation
18033 dependence, GNAT handles file sharing as follows:
18037 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18038 to open two or more files with the same full name is considered an error
18039 and is not supported. The exception @code{Use_Error} will be
18040 raised. Note that a file that is not explicitly closed by the program
18041 remains open until the program terminates.
18044 If the form parameter @samp{shared=no} appears in the form string, the
18045 file can be opened or created with its own separate stream identifier,
18046 regardless of whether other files sharing the same external file are
18047 opened. The exact effect depends on how the C stream routines handle
18048 multiple accesses to the same external files using separate streams.
18051 If the form parameter @samp{shared=yes} appears in the form string for
18052 each of two or more files opened using the same full name, the same
18053 stream is shared between these files, and the semantics are as described
18054 in Ada Reference Manual, Section A.14.
18058 When a program that opens multiple files with the same name is ported
18059 from another Ada compiler to GNAT, the effect will be that
18060 @code{Use_Error} is raised.
18062 The documentation of the original compiler and the documentation of the
18063 program should then be examined to determine if file sharing was
18064 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18065 and @code{Create} calls as required.
18067 When a program is ported from GNAT to some other Ada compiler, no
18068 special attention is required unless the @samp{shared=@var{xxx}} form
18069 parameter is used in the program. In this case, you must examine the
18070 documentation of the new compiler to see if it supports the required
18071 file sharing semantics, and form strings modified appropriately. Of
18072 course it may be the case that the program cannot be ported if the
18073 target compiler does not support the required functionality. The best
18074 approach in writing portable code is to avoid file sharing (and hence
18075 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18078 One common use of file sharing in Ada 83 is the use of instantiations of
18079 Sequential_IO on the same file with different types, to achieve
18080 heterogeneous input-output. Although this approach will work in GNAT if
18081 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18082 for this purpose (using the stream attributes)
18084 @node Filenames encoding
18085 @section Filenames encoding
18088 An encoding form parameter can be used to specify the filename
18089 encoding @samp{encoding=@var{xxx}}.
18093 If the form parameter @samp{encoding=utf8} appears in the form string, the
18094 filename must be encoded in UTF-8.
18097 If the form parameter @samp{encoding=8bits} appears in the form
18098 string, the filename must be a standard 8bits string.
18101 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18102 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18103 variable. And if not set @samp{utf8} is assumed.
18107 The current system Windows ANSI code page.
18112 This encoding form parameter is only supported on the Windows
18113 platform. On the other Operating Systems the run-time is supporting
18117 @section Open Modes
18120 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18121 using the mode shown in the following table:
18124 @center @code{Open} and @code{Create} Call Modes
18126 @b{OPEN } @b{CREATE}
18127 Append_File "r+" "w+"
18129 Out_File (Direct_IO) "r+" "w"
18130 Out_File (all other cases) "w" "w"
18131 Inout_File "r+" "w+"
18135 If text file translation is required, then either @samp{b} or @samp{t}
18136 is added to the mode, depending on the setting of Text. Text file
18137 translation refers to the mapping of CR/LF sequences in an external file
18138 to LF characters internally. This mapping only occurs in DOS and
18139 DOS-like systems, and is not relevant to other systems.
18141 A special case occurs with Stream_IO@. As shown in the above table, the
18142 file is initially opened in @samp{r} or @samp{w} mode for the
18143 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
18144 subsequently requires switching from reading to writing or vice-versa,
18145 then the file is reopened in @samp{r+} mode to permit the required operation.
18147 @node Operations on C Streams
18148 @section Operations on C Streams
18149 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18150 access to the C library functions for operations on C streams:
18152 @smallexample @c adanocomment
18153 package Interfaces.C_Streams is
18154 -- Note: the reason we do not use the types that are in
18155 -- Interfaces.C is that we want to avoid dragging in the
18156 -- code in this unit if possible.
18157 subtype chars is System.Address;
18158 -- Pointer to null-terminated array of characters
18159 subtype FILEs is System.Address;
18160 -- Corresponds to the C type FILE*
18161 subtype voids is System.Address;
18162 -- Corresponds to the C type void*
18163 subtype int is Integer;
18164 subtype long is Long_Integer;
18165 -- Note: the above types are subtypes deliberately, and it
18166 -- is part of this spec that the above correspondences are
18167 -- guaranteed. This means that it is legitimate to, for
18168 -- example, use Integer instead of int. We provide these
18169 -- synonyms for clarity, but in some cases it may be
18170 -- convenient to use the underlying types (for example to
18171 -- avoid an unnecessary dependency of a spec on the spec
18173 type size_t is mod 2 ** Standard'Address_Size;
18174 NULL_Stream : constant FILEs;
18175 -- Value returned (NULL in C) to indicate an
18176 -- fdopen/fopen/tmpfile error
18177 ----------------------------------
18178 -- Constants Defined in stdio.h --
18179 ----------------------------------
18180 EOF : constant int;
18181 -- Used by a number of routines to indicate error or
18183 IOFBF : constant int;
18184 IOLBF : constant int;
18185 IONBF : constant int;
18186 -- Used to indicate buffering mode for setvbuf call
18187 SEEK_CUR : constant int;
18188 SEEK_END : constant int;
18189 SEEK_SET : constant int;
18190 -- Used to indicate origin for fseek call
18191 function stdin return FILEs;
18192 function stdout return FILEs;
18193 function stderr return FILEs;
18194 -- Streams associated with standard files
18195 --------------------------
18196 -- Standard C functions --
18197 --------------------------
18198 -- The functions selected below are ones that are
18199 -- available in UNIX (but not necessarily in ANSI C).
18200 -- These are very thin interfaces
18201 -- which copy exactly the C headers. For more
18202 -- documentation on these functions, see the Microsoft C
18203 -- "Run-Time Library Reference" (Microsoft Press, 1990,
18204 -- ISBN 1-55615-225-6), which includes useful information
18205 -- on system compatibility.
18206 procedure clearerr (stream : FILEs);
18207 function fclose (stream : FILEs) return int;
18208 function fdopen (handle : int; mode : chars) return FILEs;
18209 function feof (stream : FILEs) return int;
18210 function ferror (stream : FILEs) return int;
18211 function fflush (stream : FILEs) return int;
18212 function fgetc (stream : FILEs) return int;
18213 function fgets (strng : chars; n : int; stream : FILEs)
18215 function fileno (stream : FILEs) return int;
18216 function fopen (filename : chars; Mode : chars)
18218 -- Note: to maintain target independence, use
18219 -- text_translation_required, a boolean variable defined in
18220 -- a-sysdep.c to deal with the target dependent text
18221 -- translation requirement. If this variable is set,
18222 -- then b/t should be appended to the standard mode
18223 -- argument to set the text translation mode off or on
18225 function fputc (C : int; stream : FILEs) return int;
18226 function fputs (Strng : chars; Stream : FILEs) return int;
18243 function ftell (stream : FILEs) return long;
18250 function isatty (handle : int) return int;
18251 procedure mktemp (template : chars);
18252 -- The return value (which is just a pointer to template)
18254 procedure rewind (stream : FILEs);
18255 function rmtmp return int;
18263 function tmpfile return FILEs;
18264 function ungetc (c : int; stream : FILEs) return int;
18265 function unlink (filename : chars) return int;
18266 ---------------------
18267 -- Extra functions --
18268 ---------------------
18269 -- These functions supply slightly thicker bindings than
18270 -- those above. They are derived from functions in the
18271 -- C Run-Time Library, but may do a bit more work than
18272 -- just directly calling one of the Library functions.
18273 function is_regular_file (handle : int) return int;
18274 -- Tests if given handle is for a regular file (result 1)
18275 -- or for a non-regular file (pipe or device, result 0).
18276 ---------------------------------
18277 -- Control of Text/Binary Mode --
18278 ---------------------------------
18279 -- If text_translation_required is true, then the following
18280 -- functions may be used to dynamically switch a file from
18281 -- binary to text mode or vice versa. These functions have
18282 -- no effect if text_translation_required is false (i.e.@: in
18283 -- normal UNIX mode). Use fileno to get a stream handle.
18284 procedure set_binary_mode (handle : int);
18285 procedure set_text_mode (handle : int);
18286 ----------------------------
18287 -- Full Path Name support --
18288 ----------------------------
18289 procedure full_name (nam : chars; buffer : chars);
18290 -- Given a NUL terminated string representing a file
18291 -- name, returns in buffer a NUL terminated string
18292 -- representing the full path name for the file name.
18293 -- On systems where it is relevant the drive is also
18294 -- part of the full path name. It is the responsibility
18295 -- of the caller to pass an actual parameter for buffer
18296 -- that is big enough for any full path name. Use
18297 -- max_path_len given below as the size of buffer.
18298 max_path_len : integer;
18299 -- Maximum length of an allowable full path name on the
18300 -- system, including a terminating NUL character.
18301 end Interfaces.C_Streams;
18304 @node Interfacing to C Streams
18305 @section Interfacing to C Streams
18308 The packages in this section permit interfacing Ada files to C Stream
18311 @smallexample @c ada
18312 with Interfaces.C_Streams;
18313 package Ada.Sequential_IO.C_Streams is
18314 function C_Stream (F : File_Type)
18315 return Interfaces.C_Streams.FILEs;
18317 (File : in out File_Type;
18318 Mode : in File_Mode;
18319 C_Stream : in Interfaces.C_Streams.FILEs;
18320 Form : in String := "");
18321 end Ada.Sequential_IO.C_Streams;
18323 with Interfaces.C_Streams;
18324 package Ada.Direct_IO.C_Streams is
18325 function C_Stream (F : File_Type)
18326 return Interfaces.C_Streams.FILEs;
18328 (File : in out File_Type;
18329 Mode : in File_Mode;
18330 C_Stream : in Interfaces.C_Streams.FILEs;
18331 Form : in String := "");
18332 end Ada.Direct_IO.C_Streams;
18334 with Interfaces.C_Streams;
18335 package Ada.Text_IO.C_Streams is
18336 function C_Stream (F : File_Type)
18337 return Interfaces.C_Streams.FILEs;
18339 (File : in out File_Type;
18340 Mode : in File_Mode;
18341 C_Stream : in Interfaces.C_Streams.FILEs;
18342 Form : in String := "");
18343 end Ada.Text_IO.C_Streams;
18345 with Interfaces.C_Streams;
18346 package Ada.Wide_Text_IO.C_Streams is
18347 function C_Stream (F : File_Type)
18348 return Interfaces.C_Streams.FILEs;
18350 (File : in out File_Type;
18351 Mode : in File_Mode;
18352 C_Stream : in Interfaces.C_Streams.FILEs;
18353 Form : in String := "");
18354 end Ada.Wide_Text_IO.C_Streams;
18356 with Interfaces.C_Streams;
18357 package Ada.Wide_Wide_Text_IO.C_Streams is
18358 function C_Stream (F : File_Type)
18359 return Interfaces.C_Streams.FILEs;
18361 (File : in out File_Type;
18362 Mode : in File_Mode;
18363 C_Stream : in Interfaces.C_Streams.FILEs;
18364 Form : in String := "");
18365 end Ada.Wide_Wide_Text_IO.C_Streams;
18367 with Interfaces.C_Streams;
18368 package Ada.Stream_IO.C_Streams is
18369 function C_Stream (F : File_Type)
18370 return Interfaces.C_Streams.FILEs;
18372 (File : in out File_Type;
18373 Mode : in File_Mode;
18374 C_Stream : in Interfaces.C_Streams.FILEs;
18375 Form : in String := "");
18376 end Ada.Stream_IO.C_Streams;
18380 In each of these six packages, the @code{C_Stream} function obtains the
18381 @code{FILE} pointer from a currently opened Ada file. It is then
18382 possible to use the @code{Interfaces.C_Streams} package to operate on
18383 this stream, or the stream can be passed to a C program which can
18384 operate on it directly. Of course the program is responsible for
18385 ensuring that only appropriate sequences of operations are executed.
18387 One particular use of relevance to an Ada program is that the
18388 @code{setvbuf} function can be used to control the buffering of the
18389 stream used by an Ada file. In the absence of such a call the standard
18390 default buffering is used.
18392 The @code{Open} procedures in these packages open a file giving an
18393 existing C Stream instead of a file name. Typically this stream is
18394 imported from a C program, allowing an Ada file to operate on an
18397 @node The GNAT Library
18398 @chapter The GNAT Library
18401 The GNAT library contains a number of general and special purpose packages.
18402 It represents functionality that the GNAT developers have found useful, and
18403 which is made available to GNAT users. The packages described here are fully
18404 supported, and upwards compatibility will be maintained in future releases,
18405 so you can use these facilities with the confidence that the same functionality
18406 will be available in future releases.
18408 The chapter here simply gives a brief summary of the facilities available.
18409 The full documentation is found in the spec file for the package. The full
18410 sources of these library packages, including both spec and body, are provided
18411 with all GNAT releases. For example, to find out the full specifications of
18412 the SPITBOL pattern matching capability, including a full tutorial and
18413 extensive examples, look in the @file{g-spipat.ads} file in the library.
18415 For each entry here, the package name (as it would appear in a @code{with}
18416 clause) is given, followed by the name of the corresponding spec file in
18417 parentheses. The packages are children in four hierarchies, @code{Ada},
18418 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18419 GNAT-specific hierarchy.
18421 Note that an application program should only use packages in one of these
18422 four hierarchies if the package is defined in the Ada Reference Manual,
18423 or is listed in this section of the GNAT Programmers Reference Manual.
18424 All other units should be considered internal implementation units and
18425 should not be directly @code{with}'ed by application code. The use of
18426 a @code{with} statement that references one of these internal implementation
18427 units makes an application potentially dependent on changes in versions
18428 of GNAT, and will generate a warning message.
18431 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18432 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18433 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18434 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18435 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18436 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18437 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18438 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18439 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18440 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18441 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18442 * Ada.Command_Line.Environment (a-colien.ads)::
18443 * Ada.Command_Line.Remove (a-colire.ads)::
18444 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18445 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18446 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18447 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18448 * Ada.Exceptions.Traceback (a-exctra.ads)::
18449 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18450 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18451 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18452 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18453 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18454 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18455 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18456 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18457 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18458 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18459 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18460 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18461 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18462 * GNAT.Altivec (g-altive.ads)::
18463 * GNAT.Altivec.Conversions (g-altcon.ads)::
18464 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18465 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18466 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18467 * GNAT.Array_Split (g-arrspl.ads)::
18468 * GNAT.AWK (g-awk.ads)::
18469 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18470 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18471 * GNAT.Bubble_Sort (g-bubsor.ads)::
18472 * GNAT.Bubble_Sort_A (g-busora.ads)::
18473 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18474 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18475 * GNAT.Byte_Swapping (g-bytswa.ads)::
18476 * GNAT.Calendar (g-calend.ads)::
18477 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18478 * GNAT.Case_Util (g-casuti.ads)::
18479 * GNAT.CGI (g-cgi.ads)::
18480 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18481 * GNAT.CGI.Debug (g-cgideb.ads)::
18482 * GNAT.Command_Line (g-comlin.ads)::
18483 * GNAT.Compiler_Version (g-comver.ads)::
18484 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18485 * GNAT.CRC32 (g-crc32.ads)::
18486 * GNAT.Current_Exception (g-curexc.ads)::
18487 * GNAT.Debug_Pools (g-debpoo.ads)::
18488 * GNAT.Debug_Utilities (g-debuti.ads)::
18489 * GNAT.Decode_String (g-decstr.ads)::
18490 * GNAT.Decode_UTF8_String (g-deutst.ads)::
18491 * GNAT.Directory_Operations (g-dirope.ads)::
18492 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
18493 * GNAT.Dynamic_HTables (g-dynhta.ads)::
18494 * GNAT.Dynamic_Tables (g-dyntab.ads)::
18495 * GNAT.Encode_String (g-encstr.ads)::
18496 * GNAT.Encode_UTF8_String (g-enutst.ads)::
18497 * GNAT.Exception_Actions (g-excact.ads)::
18498 * GNAT.Exception_Traces (g-exctra.ads)::
18499 * GNAT.Exceptions (g-except.ads)::
18500 * GNAT.Expect (g-expect.ads)::
18501 * GNAT.Expect.TTY (g-exptty.ads)::
18502 * GNAT.Float_Control (g-flocon.ads)::
18503 * GNAT.Heap_Sort (g-heasor.ads)::
18504 * GNAT.Heap_Sort_A (g-hesora.ads)::
18505 * GNAT.Heap_Sort_G (g-hesorg.ads)::
18506 * GNAT.HTable (g-htable.ads)::
18507 * GNAT.IO (g-io.ads)::
18508 * GNAT.IO_Aux (g-io_aux.ads)::
18509 * GNAT.Lock_Files (g-locfil.ads)::
18510 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
18511 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
18512 * GNAT.MD5 (g-md5.ads)::
18513 * GNAT.Memory_Dump (g-memdum.ads)::
18514 * GNAT.Most_Recent_Exception (g-moreex.ads)::
18515 * GNAT.OS_Lib (g-os_lib.ads)::
18516 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
18517 * GNAT.Random_Numbers (g-rannum.ads)::
18518 * GNAT.Regexp (g-regexp.ads)::
18519 * GNAT.Registry (g-regist.ads)::
18520 * GNAT.Regpat (g-regpat.ads)::
18521 * GNAT.Rewrite_Data (g-rewdat.ads)::
18522 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
18523 * GNAT.Semaphores (g-semaph.ads)::
18524 * GNAT.Serial_Communications (g-sercom.ads)::
18525 * GNAT.SHA1 (g-sha1.ads)::
18526 * GNAT.SHA224 (g-sha224.ads)::
18527 * GNAT.SHA256 (g-sha256.ads)::
18528 * GNAT.SHA384 (g-sha384.ads)::
18529 * GNAT.SHA512 (g-sha512.ads)::
18530 * GNAT.Signals (g-signal.ads)::
18531 * GNAT.Sockets (g-socket.ads)::
18532 * GNAT.Source_Info (g-souinf.ads)::
18533 * GNAT.Spelling_Checker (g-speche.ads)::
18534 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
18535 * GNAT.Spitbol.Patterns (g-spipat.ads)::
18536 * GNAT.Spitbol (g-spitbo.ads)::
18537 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
18538 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
18539 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
18540 * GNAT.SSE (g-sse.ads)::
18541 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
18542 * GNAT.Strings (g-string.ads)::
18543 * GNAT.String_Split (g-strspl.ads)::
18544 * GNAT.Table (g-table.ads)::
18545 * GNAT.Task_Lock (g-tasloc.ads)::
18546 * GNAT.Threads (g-thread.ads)::
18547 * GNAT.Time_Stamp (g-timsta.ads)::
18548 * GNAT.Traceback (g-traceb.ads)::
18549 * GNAT.Traceback.Symbolic (g-trasym.ads)::
18550 * GNAT.UTF_32 (g-utf_32.ads)::
18551 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
18552 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
18553 * GNAT.Wide_String_Split (g-wistsp.ads)::
18554 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
18555 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
18556 * Interfaces.C.Extensions (i-cexten.ads)::
18557 * Interfaces.C.Streams (i-cstrea.ads)::
18558 * Interfaces.CPP (i-cpp.ads)::
18559 * Interfaces.Packed_Decimal (i-pacdec.ads)::
18560 * Interfaces.VxWorks (i-vxwork.ads)::
18561 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
18562 * System.Address_Image (s-addima.ads)::
18563 * System.Assertions (s-assert.ads)::
18564 * System.Memory (s-memory.ads)::
18565 * System.Multiprocessors (s-multip.ads)::
18566 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
18567 * System.Partition_Interface (s-parint.ads)::
18568 * System.Pool_Global (s-pooglo.ads)::
18569 * System.Pool_Local (s-pooloc.ads)::
18570 * System.Restrictions (s-restri.ads)::
18571 * System.Rident (s-rident.ads)::
18572 * System.Strings.Stream_Ops (s-ststop.ads)::
18573 * System.Unsigned_Types (s-unstyp.ads)::
18574 * System.Wch_Cnv (s-wchcnv.ads)::
18575 * System.Wch_Con (s-wchcon.ads)::
18578 @node Ada.Characters.Latin_9 (a-chlat9.ads)
18579 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18580 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18581 @cindex Latin_9 constants for Character
18584 This child of @code{Ada.Characters}
18585 provides a set of definitions corresponding to those in the
18586 RM-defined package @code{Ada.Characters.Latin_1} but with the
18587 few modifications required for @code{Latin-9}
18588 The provision of such a package
18589 is specifically authorized by the Ada Reference Manual
18592 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
18593 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18594 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18595 @cindex Latin_1 constants for Wide_Character
18598 This child of @code{Ada.Characters}
18599 provides a set of definitions corresponding to those in the
18600 RM-defined package @code{Ada.Characters.Latin_1} but with the
18601 types of the constants being @code{Wide_Character}
18602 instead of @code{Character}. The provision of such a package
18603 is specifically authorized by the Ada Reference Manual
18606 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
18607 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18608 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18609 @cindex Latin_9 constants for Wide_Character
18612 This child of @code{Ada.Characters}
18613 provides a set of definitions corresponding to those in the
18614 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18615 types of the constants being @code{Wide_Character}
18616 instead of @code{Character}. The provision of such a package
18617 is specifically authorized by the Ada Reference Manual
18620 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
18621 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18622 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18623 @cindex Latin_1 constants for Wide_Wide_Character
18626 This child of @code{Ada.Characters}
18627 provides a set of definitions corresponding to those in the
18628 RM-defined package @code{Ada.Characters.Latin_1} but with the
18629 types of the constants being @code{Wide_Wide_Character}
18630 instead of @code{Character}. The provision of such a package
18631 is specifically authorized by the Ada Reference Manual
18634 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
18635 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18636 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18637 @cindex Latin_9 constants for Wide_Wide_Character
18640 This child of @code{Ada.Characters}
18641 provides a set of definitions corresponding to those in the
18642 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18643 types of the constants being @code{Wide_Wide_Character}
18644 instead of @code{Character}. The provision of such a package
18645 is specifically authorized by the Ada Reference Manual
18648 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
18649 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18650 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18651 @cindex Formal container for doubly linked lists
18654 This child of @code{Ada.Containers} defines a modified version of the
18655 Ada 2005 container for doubly linked lists, meant to facilitate formal
18656 verification of code using such containers. The specification of this
18657 unit is compatible with SPARK 2014.
18659 Note that although this container was designed with formal verification
18660 in mind, it may well be generally useful in that it is a simplified more
18661 efficient version than the one defined in the standard. In particular it
18662 does not have the complex overhead required to detect cursor tampering.
18664 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
18665 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18666 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18667 @cindex Formal container for hashed maps
18670 This child of @code{Ada.Containers} defines a modified version of the
18671 Ada 2005 container for hashed maps, meant to facilitate formal
18672 verification of code using such containers. The specification of this
18673 unit is compatible with SPARK 2014.
18675 Note that although this container was designed with formal verification
18676 in mind, it may well be generally useful in that it is a simplified more
18677 efficient version than the one defined in the standard. In particular it
18678 does not have the complex overhead required to detect cursor tampering.
18680 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
18681 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18682 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18683 @cindex Formal container for hashed sets
18686 This child of @code{Ada.Containers} defines a modified version of the
18687 Ada 2005 container for hashed sets, meant to facilitate formal
18688 verification of code using such containers. The specification of this
18689 unit is compatible with SPARK 2014.
18691 Note that although this container was designed with formal verification
18692 in mind, it may well be generally useful in that it is a simplified more
18693 efficient version than the one defined in the standard. In particular it
18694 does not have the complex overhead required to detect cursor tampering.
18696 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
18697 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18698 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18699 @cindex Formal container for ordered maps
18702 This child of @code{Ada.Containers} defines a modified version of the
18703 Ada 2005 container for ordered maps, meant to facilitate formal
18704 verification of code using such containers. The specification of this
18705 unit is compatible with SPARK 2014.
18707 Note that although this container was designed with formal verification
18708 in mind, it may well be generally useful in that it is a simplified more
18709 efficient version than the one defined in the standard. In particular it
18710 does not have the complex overhead required to detect cursor tampering.
18712 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
18713 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18714 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18715 @cindex Formal container for ordered sets
18718 This child of @code{Ada.Containers} defines a modified version of the
18719 Ada 2005 container for ordered sets, meant to facilitate formal
18720 verification of code using such containers. The specification of this
18721 unit is compatible with SPARK 2014.
18723 Note that although this container was designed with formal verification
18724 in mind, it may well be generally useful in that it is a simplified more
18725 efficient version than the one defined in the standard. In particular it
18726 does not have the complex overhead required to detect cursor tampering.
18728 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
18729 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18730 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18731 @cindex Formal container for vectors
18734 This child of @code{Ada.Containers} defines a modified version of the
18735 Ada 2005 container for vectors, meant to facilitate formal
18736 verification of code using such containers. The specification of this
18737 unit is compatible with SPARK 2014.
18739 Note that although this container was designed with formal verification
18740 in mind, it may well be generally useful in that it is a simplified more
18741 efficient version than the one defined in the standard. In particular it
18742 does not have the complex overhead required to detect cursor tampering.
18744 @node Ada.Command_Line.Environment (a-colien.ads)
18745 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18746 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18747 @cindex Environment entries
18750 This child of @code{Ada.Command_Line}
18751 provides a mechanism for obtaining environment values on systems
18752 where this concept makes sense.
18754 @node Ada.Command_Line.Remove (a-colire.ads)
18755 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18756 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18757 @cindex Removing command line arguments
18758 @cindex Command line, argument removal
18761 This child of @code{Ada.Command_Line}
18762 provides a mechanism for logically removing
18763 arguments from the argument list. Once removed, an argument is not visible
18764 to further calls on the subprograms in @code{Ada.Command_Line} will not
18765 see the removed argument.
18767 @node Ada.Command_Line.Response_File (a-clrefi.ads)
18768 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18769 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18770 @cindex Response file for command line
18771 @cindex Command line, response file
18772 @cindex Command line, handling long command lines
18775 This child of @code{Ada.Command_Line} provides a mechanism facilities for
18776 getting command line arguments from a text file, called a "response file".
18777 Using a response file allow passing a set of arguments to an executable longer
18778 than the maximum allowed by the system on the command line.
18780 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
18781 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18782 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18783 @cindex C Streams, Interfacing with Direct_IO
18786 This package provides subprograms that allow interfacing between
18787 C streams and @code{Direct_IO}. The stream identifier can be
18788 extracted from a file opened on the Ada side, and an Ada file
18789 can be constructed from a stream opened on the C side.
18791 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
18792 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18793 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18794 @cindex Null_Occurrence, testing for
18797 This child subprogram provides a way of testing for the null
18798 exception occurrence (@code{Null_Occurrence}) without raising
18801 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
18802 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18803 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18804 @cindex Null_Occurrence, testing for
18807 This child subprogram is used for handling otherwise unhandled
18808 exceptions (hence the name last chance), and perform clean ups before
18809 terminating the program. Note that this subprogram never returns.
18811 @node Ada.Exceptions.Traceback (a-exctra.ads)
18812 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18813 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18814 @cindex Traceback for Exception Occurrence
18817 This child package provides the subprogram (@code{Tracebacks}) to
18818 give a traceback array of addresses based on an exception
18821 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
18822 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18823 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18824 @cindex C Streams, Interfacing with Sequential_IO
18827 This package provides subprograms that allow interfacing between
18828 C streams and @code{Sequential_IO}. The stream identifier can be
18829 extracted from a file opened on the Ada side, and an Ada file
18830 can be constructed from a stream opened on the C side.
18832 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
18833 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18834 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18835 @cindex C Streams, Interfacing with Stream_IO
18838 This package provides subprograms that allow interfacing between
18839 C streams and @code{Stream_IO}. The stream identifier can be
18840 extracted from a file opened on the Ada side, and an Ada file
18841 can be constructed from a stream opened on the C side.
18843 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
18844 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18845 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18846 @cindex @code{Unbounded_String}, IO support
18847 @cindex @code{Text_IO}, extensions for unbounded strings
18850 This package provides subprograms for Text_IO for unbounded
18851 strings, avoiding the necessity for an intermediate operation
18852 with ordinary strings.
18854 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
18855 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18856 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18857 @cindex @code{Unbounded_Wide_String}, IO support
18858 @cindex @code{Text_IO}, extensions for unbounded wide strings
18861 This package provides subprograms for Text_IO for unbounded
18862 wide strings, avoiding the necessity for an intermediate operation
18863 with ordinary wide strings.
18865 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
18866 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18867 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18868 @cindex @code{Unbounded_Wide_Wide_String}, IO support
18869 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
18872 This package provides subprograms for Text_IO for unbounded
18873 wide wide strings, avoiding the necessity for an intermediate operation
18874 with ordinary wide wide strings.
18876 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
18877 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18878 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18879 @cindex C Streams, Interfacing with @code{Text_IO}
18882 This package provides subprograms that allow interfacing between
18883 C streams and @code{Text_IO}. The stream identifier can be
18884 extracted from a file opened on the Ada side, and an Ada file
18885 can be constructed from a stream opened on the C side.
18887 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
18888 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18889 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18890 @cindex @code{Text_IO} resetting standard files
18893 This procedure is used to reset the status of the standard files used
18894 by Ada.Text_IO. This is useful in a situation (such as a restart in an
18895 embedded application) where the status of the files may change during
18896 execution (for example a standard input file may be redefined to be
18899 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
18900 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18901 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18902 @cindex Unicode categorization, Wide_Character
18905 This package provides subprograms that allow categorization of
18906 Wide_Character values according to Unicode categories.
18908 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
18909 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18910 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18911 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
18914 This package provides subprograms that allow interfacing between
18915 C streams and @code{Wide_Text_IO}. The stream identifier can be
18916 extracted from a file opened on the Ada side, and an Ada file
18917 can be constructed from a stream opened on the C side.
18919 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
18920 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18921 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18922 @cindex @code{Wide_Text_IO} resetting standard files
18925 This procedure is used to reset the status of the standard files used
18926 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
18927 embedded application) where the status of the files may change during
18928 execution (for example a standard input file may be redefined to be
18931 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
18932 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18933 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18934 @cindex Unicode categorization, Wide_Wide_Character
18937 This package provides subprograms that allow categorization of
18938 Wide_Wide_Character values according to Unicode categories.
18940 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
18941 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18942 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18943 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
18946 This package provides subprograms that allow interfacing between
18947 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
18948 extracted from a file opened on the Ada side, and an Ada file
18949 can be constructed from a stream opened on the C side.
18951 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
18952 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18953 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18954 @cindex @code{Wide_Wide_Text_IO} resetting standard files
18957 This procedure is used to reset the status of the standard files used
18958 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
18959 restart in an embedded application) where the status of the files may
18960 change during execution (for example a standard input file may be
18961 redefined to be interactive).
18963 @node GNAT.Altivec (g-altive.ads)
18964 @section @code{GNAT.Altivec} (@file{g-altive.ads})
18965 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
18969 This is the root package of the GNAT AltiVec binding. It provides
18970 definitions of constants and types common to all the versions of the
18973 @node GNAT.Altivec.Conversions (g-altcon.ads)
18974 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18975 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18979 This package provides the Vector/View conversion routines.
18981 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
18982 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18983 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18987 This package exposes the Ada interface to the AltiVec operations on
18988 vector objects. A soft emulation is included by default in the GNAT
18989 library. The hard binding is provided as a separate package. This unit
18990 is common to both bindings.
18992 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
18993 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
18994 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
18998 This package exposes the various vector types part of the Ada binding
18999 to AltiVec facilities.
19001 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19002 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19003 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19007 This package provides public 'View' data types from/to which private
19008 vector representations can be converted via
19009 GNAT.Altivec.Conversions. This allows convenient access to individual
19010 vector elements and provides a simple way to initialize vector
19013 @node GNAT.Array_Split (g-arrspl.ads)
19014 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19015 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19016 @cindex Array splitter
19019 Useful array-manipulation routines: given a set of separators, split
19020 an array wherever the separators appear, and provide direct access
19021 to the resulting slices.
19023 @node GNAT.AWK (g-awk.ads)
19024 @section @code{GNAT.AWK} (@file{g-awk.ads})
19025 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19030 Provides AWK-like parsing functions, with an easy interface for parsing one
19031 or more files containing formatted data. The file is viewed as a database
19032 where each record is a line and a field is a data element in this line.
19034 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19035 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19036 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19038 @cindex Bounded Buffers
19041 Provides a concurrent generic bounded buffer abstraction. Instances are
19042 useful directly or as parts of the implementations of other abstractions,
19045 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19046 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19047 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19052 Provides a thread-safe asynchronous intertask mailbox communication facility.
19054 @node GNAT.Bubble_Sort (g-bubsor.ads)
19055 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19056 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19058 @cindex Bubble sort
19061 Provides a general implementation of bubble sort usable for sorting arbitrary
19062 data items. Exchange and comparison procedures are provided by passing
19063 access-to-procedure values.
19065 @node GNAT.Bubble_Sort_A (g-busora.ads)
19066 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19067 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19069 @cindex Bubble sort
19072 Provides a general implementation of bubble sort usable for sorting arbitrary
19073 data items. Move and comparison procedures are provided by passing
19074 access-to-procedure values. This is an older version, retained for
19075 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19077 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19078 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19079 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19081 @cindex Bubble sort
19084 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19085 are provided as generic parameters, this improves efficiency, especially
19086 if the procedures can be inlined, at the expense of duplicating code for
19087 multiple instantiations.
19089 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19090 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19091 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19092 @cindex UTF-8 representation
19093 @cindex Wide characte representations
19096 Provides a routine which given a string, reads the start of the string to
19097 see whether it is one of the standard byte order marks (BOM's) which signal
19098 the encoding of the string. The routine includes detection of special XML
19099 sequences for various UCS input formats.
19101 @node GNAT.Byte_Swapping (g-bytswa.ads)
19102 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19103 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19104 @cindex Byte swapping
19108 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19109 Machine-specific implementations are available in some cases.
19111 @node GNAT.Calendar (g-calend.ads)
19112 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19113 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19114 @cindex @code{Calendar}
19117 Extends the facilities provided by @code{Ada.Calendar} to include handling
19118 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19119 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19120 C @code{timeval} format.
19122 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19123 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19124 @cindex @code{Calendar}
19126 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19128 @node GNAT.CRC32 (g-crc32.ads)
19129 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19130 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19132 @cindex Cyclic Redundancy Check
19135 This package implements the CRC-32 algorithm. For a full description
19136 of this algorithm see
19137 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19138 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19139 Aug.@: 1988. Sarwate, D.V@.
19141 @node GNAT.Case_Util (g-casuti.ads)
19142 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19143 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19144 @cindex Casing utilities
19145 @cindex Character handling (@code{GNAT.Case_Util})
19148 A set of simple routines for handling upper and lower casing of strings
19149 without the overhead of the full casing tables
19150 in @code{Ada.Characters.Handling}.
19152 @node GNAT.CGI (g-cgi.ads)
19153 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19154 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19155 @cindex CGI (Common Gateway Interface)
19158 This is a package for interfacing a GNAT program with a Web server via the
19159 Common Gateway Interface (CGI)@. Basically this package parses the CGI
19160 parameters, which are a set of key/value pairs sent by the Web server. It
19161 builds a table whose index is the key and provides some services to deal
19164 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19165 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19166 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19167 @cindex CGI (Common Gateway Interface) cookie support
19168 @cindex Cookie support in CGI
19171 This is a package to interface a GNAT program with a Web server via the
19172 Common Gateway Interface (CGI). It exports services to deal with Web
19173 cookies (piece of information kept in the Web client software).
19175 @node GNAT.CGI.Debug (g-cgideb.ads)
19176 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19177 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19178 @cindex CGI (Common Gateway Interface) debugging
19181 This is a package to help debugging CGI (Common Gateway Interface)
19182 programs written in Ada.
19184 @node GNAT.Command_Line (g-comlin.ads)
19185 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19186 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19187 @cindex Command line
19190 Provides a high level interface to @code{Ada.Command_Line} facilities,
19191 including the ability to scan for named switches with optional parameters
19192 and expand file names using wild card notations.
19194 @node GNAT.Compiler_Version (g-comver.ads)
19195 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19196 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19197 @cindex Compiler Version
19198 @cindex Version, of compiler
19201 Provides a routine for obtaining the version of the compiler used to
19202 compile the program. More accurately this is the version of the binder
19203 used to bind the program (this will normally be the same as the version
19204 of the compiler if a consistent tool set is used to compile all units
19207 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19208 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19209 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19213 Provides a simple interface to handle Ctrl-C keyboard events.
19215 @node GNAT.Current_Exception (g-curexc.ads)
19216 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19217 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19218 @cindex Current exception
19219 @cindex Exception retrieval
19222 Provides access to information on the current exception that has been raised
19223 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19224 specification syntax.
19225 This is particularly useful in simulating typical facilities for
19226 obtaining information about exceptions provided by Ada 83 compilers.
19228 @node GNAT.Debug_Pools (g-debpoo.ads)
19229 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19230 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19232 @cindex Debug pools
19233 @cindex Memory corruption debugging
19236 Provide a debugging storage pools that helps tracking memory corruption
19237 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19238 @value{EDITION} User's Guide}.
19240 @node GNAT.Debug_Utilities (g-debuti.ads)
19241 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19242 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19246 Provides a few useful utilities for debugging purposes, including conversion
19247 to and from string images of address values. Supports both C and Ada formats
19248 for hexadecimal literals.
19250 @node GNAT.Decode_String (g-decstr.ads)
19251 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19252 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19253 @cindex Decoding strings
19254 @cindex String decoding
19255 @cindex Wide character encoding
19260 A generic package providing routines for decoding wide character and wide wide
19261 character strings encoded as sequences of 8-bit characters using a specified
19262 encoding method. Includes validation routines, and also routines for stepping
19263 to next or previous encoded character in an encoded string.
19264 Useful in conjunction with Unicode character coding. Note there is a
19265 preinstantiation for UTF-8. See next entry.
19267 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19268 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19269 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19270 @cindex Decoding strings
19271 @cindex Decoding UTF-8 strings
19272 @cindex UTF-8 string decoding
19273 @cindex Wide character decoding
19278 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19280 @node GNAT.Directory_Operations (g-dirope.ads)
19281 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19282 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19283 @cindex Directory operations
19286 Provides a set of routines for manipulating directories, including changing
19287 the current directory, making new directories, and scanning the files in a
19290 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19291 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19292 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19293 @cindex Directory operations iteration
19296 A child unit of GNAT.Directory_Operations providing additional operations
19297 for iterating through directories.
19299 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19300 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19301 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19302 @cindex Hash tables
19305 A generic implementation of hash tables that can be used to hash arbitrary
19306 data. Provided in two forms, a simple form with built in hash functions,
19307 and a more complex form in which the hash function is supplied.
19310 This package provides a facility similar to that of @code{GNAT.HTable},
19311 except that this package declares a type that can be used to define
19312 dynamic instances of the hash table, while an instantiation of
19313 @code{GNAT.HTable} creates a single instance of the hash table.
19315 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19316 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19317 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19318 @cindex Table implementation
19319 @cindex Arrays, extendable
19322 A generic package providing a single dimension array abstraction where the
19323 length of the array can be dynamically modified.
19326 This package provides a facility similar to that of @code{GNAT.Table},
19327 except that this package declares a type that can be used to define
19328 dynamic instances of the table, while an instantiation of
19329 @code{GNAT.Table} creates a single instance of the table type.
19331 @node GNAT.Encode_String (g-encstr.ads)
19332 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19333 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19334 @cindex Encoding strings
19335 @cindex String encoding
19336 @cindex Wide character encoding
19341 A generic package providing routines for encoding wide character and wide
19342 wide character strings as sequences of 8-bit characters using a specified
19343 encoding method. Useful in conjunction with Unicode character coding.
19344 Note there is a preinstantiation for UTF-8. See next entry.
19346 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19347 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19348 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19349 @cindex Encoding strings
19350 @cindex Encoding UTF-8 strings
19351 @cindex UTF-8 string encoding
19352 @cindex Wide character encoding
19357 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19359 @node GNAT.Exception_Actions (g-excact.ads)
19360 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19361 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19362 @cindex Exception actions
19365 Provides callbacks when an exception is raised. Callbacks can be registered
19366 for specific exceptions, or when any exception is raised. This
19367 can be used for instance to force a core dump to ease debugging.
19369 @node GNAT.Exception_Traces (g-exctra.ads)
19370 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19371 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19372 @cindex Exception traces
19376 Provides an interface allowing to control automatic output upon exception
19379 @node GNAT.Exceptions (g-except.ads)
19380 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19381 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19382 @cindex Exceptions, Pure
19383 @cindex Pure packages, exceptions
19386 Normally it is not possible to raise an exception with
19387 a message from a subprogram in a pure package, since the
19388 necessary types and subprograms are in @code{Ada.Exceptions}
19389 which is not a pure unit. @code{GNAT.Exceptions} provides a
19390 facility for getting around this limitation for a few
19391 predefined exceptions, and for example allow raising
19392 @code{Constraint_Error} with a message from a pure subprogram.
19394 @node GNAT.Expect (g-expect.ads)
19395 @section @code{GNAT.Expect} (@file{g-expect.ads})
19396 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19399 Provides a set of subprograms similar to what is available
19400 with the standard Tcl Expect tool.
19401 It allows you to easily spawn and communicate with an external process.
19402 You can send commands or inputs to the process, and compare the output
19403 with some expected regular expression. Currently @code{GNAT.Expect}
19404 is implemented on all native GNAT ports except for OpenVMS@.
19405 It is not implemented for cross ports, and in particular is not
19406 implemented for VxWorks or LynxOS@.
19408 @node GNAT.Expect.TTY (g-exptty.ads)
19409 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19410 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19413 As GNAT.Expect but using pseudo-terminal.
19414 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19415 ports except for OpenVMS@. It is not implemented for cross ports, and
19416 in particular is not implemented for VxWorks or LynxOS@.
19418 @node GNAT.Float_Control (g-flocon.ads)
19419 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19420 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19421 @cindex Floating-Point Processor
19424 Provides an interface for resetting the floating-point processor into the
19425 mode required for correct semantic operation in Ada. Some third party
19426 library calls may cause this mode to be modified, and the Reset procedure
19427 in this package can be used to reestablish the required mode.
19429 @node GNAT.Heap_Sort (g-heasor.ads)
19430 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19431 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19435 Provides a general implementation of heap sort usable for sorting arbitrary
19436 data items. Exchange and comparison procedures are provided by passing
19437 access-to-procedure values. The algorithm used is a modified heap sort
19438 that performs approximately N*log(N) comparisons in the worst case.
19440 @node GNAT.Heap_Sort_A (g-hesora.ads)
19441 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19442 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19446 Provides a general implementation of heap sort usable for sorting arbitrary
19447 data items. Move and comparison procedures are provided by passing
19448 access-to-procedure values. The algorithm used is a modified heap sort
19449 that performs approximately N*log(N) comparisons in the worst case.
19450 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19451 interface, but may be slightly more efficient.
19453 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19454 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19455 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19459 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19460 are provided as generic parameters, this improves efficiency, especially
19461 if the procedures can be inlined, at the expense of duplicating code for
19462 multiple instantiations.
19464 @node GNAT.HTable (g-htable.ads)
19465 @section @code{GNAT.HTable} (@file{g-htable.ads})
19466 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19467 @cindex Hash tables
19470 A generic implementation of hash tables that can be used to hash arbitrary
19471 data. Provides two approaches, one a simple static approach, and the other
19472 allowing arbitrary dynamic hash tables.
19474 @node GNAT.IO (g-io.ads)
19475 @section @code{GNAT.IO} (@file{g-io.ads})
19476 @cindex @code{GNAT.IO} (@file{g-io.ads})
19478 @cindex Input/Output facilities
19481 A simple preelaborable input-output package that provides a subset of
19482 simple Text_IO functions for reading characters and strings from
19483 Standard_Input, and writing characters, strings and integers to either
19484 Standard_Output or Standard_Error.
19486 @node GNAT.IO_Aux (g-io_aux.ads)
19487 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19488 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19490 @cindex Input/Output facilities
19492 Provides some auxiliary functions for use with Text_IO, including a test
19493 for whether a file exists, and functions for reading a line of text.
19495 @node GNAT.Lock_Files (g-locfil.ads)
19496 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19497 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19498 @cindex File locking
19499 @cindex Locking using files
19502 Provides a general interface for using files as locks. Can be used for
19503 providing program level synchronization.
19505 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
19506 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19507 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19508 @cindex Random number generation
19511 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
19512 a modified version of the Blum-Blum-Shub generator.
19514 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
19515 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19516 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19517 @cindex Random number generation
19520 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
19521 a modified version of the Blum-Blum-Shub generator.
19523 @node GNAT.MD5 (g-md5.ads)
19524 @section @code{GNAT.MD5} (@file{g-md5.ads})
19525 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
19526 @cindex Message Digest MD5
19529 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
19531 @node GNAT.Memory_Dump (g-memdum.ads)
19532 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19533 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19534 @cindex Dump Memory
19537 Provides a convenient routine for dumping raw memory to either the
19538 standard output or standard error files. Uses GNAT.IO for actual
19541 @node GNAT.Most_Recent_Exception (g-moreex.ads)
19542 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19543 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19544 @cindex Exception, obtaining most recent
19547 Provides access to the most recently raised exception. Can be used for
19548 various logging purposes, including duplicating functionality of some
19549 Ada 83 implementation dependent extensions.
19551 @node GNAT.OS_Lib (g-os_lib.ads)
19552 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19553 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19554 @cindex Operating System interface
19555 @cindex Spawn capability
19558 Provides a range of target independent operating system interface functions,
19559 including time/date management, file operations, subprocess management,
19560 including a portable spawn procedure, and access to environment variables
19561 and error return codes.
19563 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
19564 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19565 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19566 @cindex Hash functions
19569 Provides a generator of static minimal perfect hash functions. No
19570 collisions occur and each item can be retrieved from the table in one
19571 probe (perfect property). The hash table size corresponds to the exact
19572 size of the key set and no larger (minimal property). The key set has to
19573 be know in advance (static property). The hash functions are also order
19574 preserving. If w2 is inserted after w1 in the generator, their
19575 hashcode are in the same order. These hashing functions are very
19576 convenient for use with realtime applications.
19578 @node GNAT.Random_Numbers (g-rannum.ads)
19579 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19580 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19581 @cindex Random number generation
19584 Provides random number capabilities which extend those available in the
19585 standard Ada library and are more convenient to use.
19587 @node GNAT.Regexp (g-regexp.ads)
19588 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
19589 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
19590 @cindex Regular expressions
19591 @cindex Pattern matching
19594 A simple implementation of regular expressions, using a subset of regular
19595 expression syntax copied from familiar Unix style utilities. This is the
19596 simplest of the three pattern matching packages provided, and is particularly
19597 suitable for ``file globbing'' applications.
19599 @node GNAT.Registry (g-regist.ads)
19600 @section @code{GNAT.Registry} (@file{g-regist.ads})
19601 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
19602 @cindex Windows Registry
19605 This is a high level binding to the Windows registry. It is possible to
19606 do simple things like reading a key value, creating a new key. For full
19607 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
19608 package provided with the Win32Ada binding
19610 @node GNAT.Regpat (g-regpat.ads)
19611 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
19612 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
19613 @cindex Regular expressions
19614 @cindex Pattern matching
19617 A complete implementation of Unix-style regular expression matching, copied
19618 from the original V7 style regular expression library written in C by
19619 Henry Spencer (and binary compatible with this C library).
19621 @node GNAT.Rewrite_Data (g-rewdat.ads)
19622 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
19623 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
19624 @cindex Rewrite data
19627 A unit to rewrite on-the-fly string occurrences in a stream of
19628 data. The implementation has a very minimal memory footprint as the
19629 full content to be processed is not loaded into memory all at once. This makes
19630 this interface usable for large files or socket streams.
19632 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
19633 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19634 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19635 @cindex Secondary Stack Info
19638 Provide the capability to query the high water mark of the current task's
19641 @node GNAT.Semaphores (g-semaph.ads)
19642 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
19643 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
19647 Provides classic counting and binary semaphores using protected types.
19649 @node GNAT.Serial_Communications (g-sercom.ads)
19650 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19651 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19652 @cindex Serial_Communications
19655 Provides a simple interface to send and receive data over a serial
19656 port. This is only supported on GNU/Linux and Windows.
19658 @node GNAT.SHA1 (g-sha1.ads)
19659 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
19660 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
19661 @cindex Secure Hash Algorithm SHA-1
19664 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
19667 @node GNAT.SHA224 (g-sha224.ads)
19668 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
19669 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
19670 @cindex Secure Hash Algorithm SHA-224
19673 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
19675 @node GNAT.SHA256 (g-sha256.ads)
19676 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
19677 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
19678 @cindex Secure Hash Algorithm SHA-256
19681 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
19683 @node GNAT.SHA384 (g-sha384.ads)
19684 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
19685 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
19686 @cindex Secure Hash Algorithm SHA-384
19689 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
19691 @node GNAT.SHA512 (g-sha512.ads)
19692 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
19693 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
19694 @cindex Secure Hash Algorithm SHA-512
19697 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
19699 @node GNAT.Signals (g-signal.ads)
19700 @section @code{GNAT.Signals} (@file{g-signal.ads})
19701 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
19705 Provides the ability to manipulate the blocked status of signals on supported
19708 @node GNAT.Sockets (g-socket.ads)
19709 @section @code{GNAT.Sockets} (@file{g-socket.ads})
19710 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
19714 A high level and portable interface to develop sockets based applications.
19715 This package is based on the sockets thin binding found in
19716 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
19717 on all native GNAT ports except for OpenVMS@. It is not implemented
19718 for the LynxOS@ cross port.
19720 @node GNAT.Source_Info (g-souinf.ads)
19721 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
19722 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
19723 @cindex Source Information
19726 Provides subprograms that give access to source code information known at
19727 compile time, such as the current file name and line number.
19729 @node GNAT.Spelling_Checker (g-speche.ads)
19730 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19731 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19732 @cindex Spell checking
19735 Provides a function for determining whether one string is a plausible
19736 near misspelling of another string.
19738 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
19739 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19740 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19741 @cindex Spell checking
19744 Provides a generic function that can be instantiated with a string type for
19745 determining whether one string is a plausible near misspelling of another
19748 @node GNAT.Spitbol.Patterns (g-spipat.ads)
19749 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19750 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19751 @cindex SPITBOL pattern matching
19752 @cindex Pattern matching
19755 A complete implementation of SNOBOL4 style pattern matching. This is the
19756 most elaborate of the pattern matching packages provided. It fully duplicates
19757 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
19758 efficient algorithm developed by Robert Dewar for the SPITBOL system.
19760 @node GNAT.Spitbol (g-spitbo.ads)
19761 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19762 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19763 @cindex SPITBOL interface
19766 The top level package of the collection of SPITBOL-style functionality, this
19767 package provides basic SNOBOL4 string manipulation functions, such as
19768 Pad, Reverse, Trim, Substr capability, as well as a generic table function
19769 useful for constructing arbitrary mappings from strings in the style of
19770 the SNOBOL4 TABLE function.
19772 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
19773 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19774 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19775 @cindex Sets of strings
19776 @cindex SPITBOL Tables
19779 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19780 for type @code{Standard.Boolean}, giving an implementation of sets of
19783 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
19784 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19785 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19786 @cindex Integer maps
19788 @cindex SPITBOL Tables
19791 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19792 for type @code{Standard.Integer}, giving an implementation of maps
19793 from string to integer values.
19795 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
19796 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19797 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19798 @cindex String maps
19800 @cindex SPITBOL Tables
19803 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
19804 a variable length string type, giving an implementation of general
19805 maps from strings to strings.
19807 @node GNAT.SSE (g-sse.ads)
19808 @section @code{GNAT.SSE} (@file{g-sse.ads})
19809 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
19812 Root of a set of units aimed at offering Ada bindings to a subset of
19813 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
19814 targets. It exposes vector component types together with a general
19815 introduction to the binding contents and use.
19817 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
19818 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19819 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19822 SSE vector types for use with SSE related intrinsics.
19824 @node GNAT.Strings (g-string.ads)
19825 @section @code{GNAT.Strings} (@file{g-string.ads})
19826 @cindex @code{GNAT.Strings} (@file{g-string.ads})
19829 Common String access types and related subprograms. Basically it
19830 defines a string access and an array of string access types.
19832 @node GNAT.String_Split (g-strspl.ads)
19833 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
19834 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
19835 @cindex String splitter
19838 Useful string manipulation routines: given a set of separators, split
19839 a string wherever the separators appear, and provide direct access
19840 to the resulting slices. This package is instantiated from
19841 @code{GNAT.Array_Split}.
19843 @node GNAT.Table (g-table.ads)
19844 @section @code{GNAT.Table} (@file{g-table.ads})
19845 @cindex @code{GNAT.Table} (@file{g-table.ads})
19846 @cindex Table implementation
19847 @cindex Arrays, extendable
19850 A generic package providing a single dimension array abstraction where the
19851 length of the array can be dynamically modified.
19854 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
19855 except that this package declares a single instance of the table type,
19856 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
19857 used to define dynamic instances of the table.
19859 @node GNAT.Task_Lock (g-tasloc.ads)
19860 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19861 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19862 @cindex Task synchronization
19863 @cindex Task locking
19867 A very simple facility for locking and unlocking sections of code using a
19868 single global task lock. Appropriate for use in situations where contention
19869 between tasks is very rarely expected.
19871 @node GNAT.Time_Stamp (g-timsta.ads)
19872 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19873 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19875 @cindex Current time
19878 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
19879 represents the current date and time in ISO 8601 format. This is a very simple
19880 routine with minimal code and there are no dependencies on any other unit.
19882 @node GNAT.Threads (g-thread.ads)
19883 @section @code{GNAT.Threads} (@file{g-thread.ads})
19884 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
19885 @cindex Foreign threads
19886 @cindex Threads, foreign
19889 Provides facilities for dealing with foreign threads which need to be known
19890 by the GNAT run-time system. Consult the documentation of this package for
19891 further details if your program has threads that are created by a non-Ada
19892 environment which then accesses Ada code.
19894 @node GNAT.Traceback (g-traceb.ads)
19895 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
19896 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
19897 @cindex Trace back facilities
19900 Provides a facility for obtaining non-symbolic traceback information, useful
19901 in various debugging situations.
19903 @node GNAT.Traceback.Symbolic (g-trasym.ads)
19904 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19905 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19906 @cindex Trace back facilities
19908 @node GNAT.UTF_32 (g-utf_32.ads)
19909 @section @code{GNAT.UTF_32} (@file{g-table.ads})
19910 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
19911 @cindex Wide character codes
19914 This is a package intended to be used in conjunction with the
19915 @code{Wide_Character} type in Ada 95 and the
19916 @code{Wide_Wide_Character} type in Ada 2005 (available
19917 in @code{GNAT} in Ada 2005 mode). This package contains
19918 Unicode categorization routines, as well as lexical
19919 categorization routines corresponding to the Ada 2005
19920 lexical rules for identifiers and strings, and also a
19921 lower case to upper case fold routine corresponding to
19922 the Ada 2005 rules for identifier equivalence.
19924 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
19925 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19926 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19927 @cindex Spell checking
19930 Provides a function for determining whether one wide wide string is a plausible
19931 near misspelling of another wide wide string, where the strings are represented
19932 using the UTF_32_String type defined in System.Wch_Cnv.
19934 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
19935 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19936 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19937 @cindex Spell checking
19940 Provides a function for determining whether one wide string is a plausible
19941 near misspelling of another wide string.
19943 @node GNAT.Wide_String_Split (g-wistsp.ads)
19944 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19945 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19946 @cindex Wide_String splitter
19949 Useful wide string manipulation routines: given a set of separators, split
19950 a wide string wherever the separators appear, and provide direct access
19951 to the resulting slices. This package is instantiated from
19952 @code{GNAT.Array_Split}.
19954 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
19955 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19956 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19957 @cindex Spell checking
19960 Provides a function for determining whether one wide wide string is a plausible
19961 near misspelling of another wide wide string.
19963 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
19964 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19965 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19966 @cindex Wide_Wide_String splitter
19969 Useful wide wide string manipulation routines: given a set of separators, split
19970 a wide wide string wherever the separators appear, and provide direct access
19971 to the resulting slices. This package is instantiated from
19972 @code{GNAT.Array_Split}.
19974 @node Interfaces.C.Extensions (i-cexten.ads)
19975 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19976 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19979 This package contains additional C-related definitions, intended
19980 for use with either manually or automatically generated bindings
19983 @node Interfaces.C.Streams (i-cstrea.ads)
19984 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19985 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19986 @cindex C streams, interfacing
19989 This package is a binding for the most commonly used operations
19992 @node Interfaces.CPP (i-cpp.ads)
19993 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
19994 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
19995 @cindex C++ interfacing
19996 @cindex Interfacing, to C++
19999 This package provides facilities for use in interfacing to C++. It
20000 is primarily intended to be used in connection with automated tools
20001 for the generation of C++ interfaces.
20003 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20004 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20005 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20006 @cindex IBM Packed Format
20007 @cindex Packed Decimal
20010 This package provides a set of routines for conversions to and
20011 from a packed decimal format compatible with that used on IBM
20014 @node Interfaces.VxWorks (i-vxwork.ads)
20015 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20016 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20017 @cindex Interfacing to VxWorks
20018 @cindex VxWorks, interfacing
20021 This package provides a limited binding to the VxWorks API.
20022 In particular, it interfaces with the
20023 VxWorks hardware interrupt facilities.
20025 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20026 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20027 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20028 @cindex Interfacing to VxWorks' I/O
20029 @cindex VxWorks, I/O interfacing
20030 @cindex VxWorks, Get_Immediate
20031 @cindex Get_Immediate, VxWorks
20034 This package provides a binding to the ioctl (IO/Control)
20035 function of VxWorks, defining a set of option values and
20036 function codes. A particular use of this package is
20037 to enable the use of Get_Immediate under VxWorks.
20039 @node System.Address_Image (s-addima.ads)
20040 @section @code{System.Address_Image} (@file{s-addima.ads})
20041 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20042 @cindex Address image
20043 @cindex Image, of an address
20046 This function provides a useful debugging
20047 function that gives an (implementation dependent)
20048 string which identifies an address.
20050 @node System.Assertions (s-assert.ads)
20051 @section @code{System.Assertions} (@file{s-assert.ads})
20052 @cindex @code{System.Assertions} (@file{s-assert.ads})
20054 @cindex Assert_Failure, exception
20057 This package provides the declaration of the exception raised
20058 by an run-time assertion failure, as well as the routine that
20059 is used internally to raise this assertion.
20061 @node System.Memory (s-memory.ads)
20062 @section @code{System.Memory} (@file{s-memory.ads})
20063 @cindex @code{System.Memory} (@file{s-memory.ads})
20064 @cindex Memory allocation
20067 This package provides the interface to the low level routines used
20068 by the generated code for allocation and freeing storage for the
20069 default storage pool (analogous to the C routines malloc and free.
20070 It also provides a reallocation interface analogous to the C routine
20071 realloc. The body of this unit may be modified to provide alternative
20072 allocation mechanisms for the default pool, and in addition, direct
20073 calls to this unit may be made for low level allocation uses (for
20074 example see the body of @code{GNAT.Tables}).
20076 @node System.Multiprocessors (s-multip.ads)
20077 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20078 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20079 @cindex Multiprocessor interface
20080 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20081 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20082 technically an implementation-defined addition).
20084 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20085 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20086 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20087 @cindex Multiprocessor interface
20088 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20089 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20090 technically an implementation-defined addition).
20092 @node System.Partition_Interface (s-parint.ads)
20093 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20094 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20095 @cindex Partition interfacing functions
20098 This package provides facilities for partition interfacing. It
20099 is used primarily in a distribution context when using Annex E
20102 @node System.Pool_Global (s-pooglo.ads)
20103 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20104 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20105 @cindex Storage pool, global
20106 @cindex Global storage pool
20109 This package provides a storage pool that is equivalent to the default
20110 storage pool used for access types for which no pool is specifically
20111 declared. It uses malloc/free to allocate/free and does not attempt to
20112 do any automatic reclamation.
20114 @node System.Pool_Local (s-pooloc.ads)
20115 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20116 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20117 @cindex Storage pool, local
20118 @cindex Local storage pool
20121 This package provides a storage pool that is intended for use with locally
20122 defined access types. It uses malloc/free for allocate/free, and maintains
20123 a list of allocated blocks, so that all storage allocated for the pool can
20124 be freed automatically when the pool is finalized.
20126 @node System.Restrictions (s-restri.ads)
20127 @section @code{System.Restrictions} (@file{s-restri.ads})
20128 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20129 @cindex Run-time restrictions access
20132 This package provides facilities for accessing at run time
20133 the status of restrictions specified at compile time for
20134 the partition. Information is available both with regard
20135 to actual restrictions specified, and with regard to
20136 compiler determined information on which restrictions
20137 are violated by one or more packages in the partition.
20139 @node System.Rident (s-rident.ads)
20140 @section @code{System.Rident} (@file{s-rident.ads})
20141 @cindex @code{System.Rident} (@file{s-rident.ads})
20142 @cindex Restrictions definitions
20145 This package provides definitions of the restrictions
20146 identifiers supported by GNAT, and also the format of
20147 the restrictions provided in package System.Restrictions.
20148 It is not normally necessary to @code{with} this generic package
20149 since the necessary instantiation is included in
20150 package System.Restrictions.
20152 @node System.Strings.Stream_Ops (s-ststop.ads)
20153 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20154 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20155 @cindex Stream operations
20156 @cindex String stream operations
20159 This package provides a set of stream subprograms for standard string types.
20160 It is intended primarily to support implicit use of such subprograms when
20161 stream attributes are applied to string types, but the subprograms in this
20162 package can be used directly by application programs.
20164 @node System.Unsigned_Types (s-unstyp.ads)
20165 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20166 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20169 This package contains definitions of standard unsigned types that
20170 correspond in size to the standard signed types declared in Standard,
20171 and (unlike the types in Interfaces) have corresponding names. It
20172 also contains some related definitions for other specialized types
20173 used by the compiler in connection with packed array types.
20175 @node System.Wch_Cnv (s-wchcnv.ads)
20176 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20177 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20178 @cindex Wide Character, Representation
20179 @cindex Wide String, Conversion
20180 @cindex Representation of wide characters
20183 This package provides routines for converting between
20184 wide and wide wide characters and a representation as a value of type
20185 @code{Standard.String}, using a specified wide character
20186 encoding method. It uses definitions in
20187 package @code{System.Wch_Con}.
20189 @node System.Wch_Con (s-wchcon.ads)
20190 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20191 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20194 This package provides definitions and descriptions of
20195 the various methods used for encoding wide characters
20196 in ordinary strings. These definitions are used by
20197 the package @code{System.Wch_Cnv}.
20199 @node Interfacing to Other Languages
20200 @chapter Interfacing to Other Languages
20202 The facilities in annex B of the Ada Reference Manual are fully
20203 implemented in GNAT, and in addition, a full interface to C++ is
20207 * Interfacing to C::
20208 * Interfacing to C++::
20209 * Interfacing to COBOL::
20210 * Interfacing to Fortran::
20211 * Interfacing to non-GNAT Ada code::
20214 @node Interfacing to C
20215 @section Interfacing to C
20218 Interfacing to C with GNAT can use one of two approaches:
20222 The types in the package @code{Interfaces.C} may be used.
20224 Standard Ada types may be used directly. This may be less portable to
20225 other compilers, but will work on all GNAT compilers, which guarantee
20226 correspondence between the C and Ada types.
20230 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20231 effect, since this is the default. The following table shows the
20232 correspondence between Ada scalar types and the corresponding C types.
20237 @item Short_Integer
20239 @item Short_Short_Integer
20243 @item Long_Long_Integer
20251 @item Long_Long_Float
20252 This is the longest floating-point type supported by the hardware.
20256 Additionally, there are the following general correspondences between Ada
20260 Ada enumeration types map to C enumeration types directly if pragma
20261 @code{Convention C} is specified, which causes them to have int
20262 length. Without pragma @code{Convention C}, Ada enumeration types map to
20263 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20264 @code{int}, respectively) depending on the number of values passed.
20265 This is the only case in which pragma @code{Convention C} affects the
20266 representation of an Ada type.
20269 Ada access types map to C pointers, except for the case of pointers to
20270 unconstrained types in Ada, which have no direct C equivalent.
20273 Ada arrays map directly to C arrays.
20276 Ada records map directly to C structures.
20279 Packed Ada records map to C structures where all members are bit fields
20280 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20283 @node Interfacing to C++
20284 @section Interfacing to C++
20287 The interface to C++ makes use of the following pragmas, which are
20288 primarily intended to be constructed automatically using a binding generator
20289 tool, although it is possible to construct them by hand.
20291 Using these pragmas it is possible to achieve complete
20292 inter-operability between Ada tagged types and C++ class definitions.
20293 See @ref{Implementation Defined Pragmas}, for more details.
20296 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20297 The argument denotes an entity in the current declarative region that is
20298 declared as a tagged or untagged record type. It indicates that the type
20299 corresponds to an externally declared C++ class type, and is to be laid
20300 out the same way that C++ would lay out the type.
20302 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20303 for backward compatibility but its functionality is available
20304 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20306 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20307 This pragma identifies an imported function (imported in the usual way
20308 with pragma @code{Import}) as corresponding to a C++ constructor.
20311 A few restrictions are placed on the use of the @code{Access} attribute
20312 in conjunction with subprograms subject to convention @code{CPP}: the
20313 attribute may be used neither on primitive operations of a tagged
20314 record type with convention @code{CPP}, imported or not, nor on
20315 subprograms imported with pragma @code{CPP_Constructor}.
20317 In addition, C++ exceptions are propagated and can be handled in an
20318 @code{others} choice of an exception handler. The corresponding Ada
20319 occurrence has no message, and the simple name of the exception identity
20320 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20321 tasks works properly when such foreign exceptions are propagated.
20323 It is also possible to import a C++ exception using the following syntax:
20325 @smallexample @c ada
20326 LOCAL_NAME : exception;
20327 pragma Import (Cpp,
20328 [Entity =>] LOCAL_NAME,
20329 [External_Name =>] static_string_EXPRESSION);
20333 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20334 cover a specific C++ exception in an exception handler.
20336 @node Interfacing to COBOL
20337 @section Interfacing to COBOL
20340 Interfacing to COBOL is achieved as described in section B.4 of
20341 the Ada Reference Manual.
20343 @node Interfacing to Fortran
20344 @section Interfacing to Fortran
20347 Interfacing to Fortran is achieved as described in section B.5 of the
20348 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
20349 multi-dimensional array causes the array to be stored in column-major
20350 order as required for convenient interface to Fortran.
20352 @node Interfacing to non-GNAT Ada code
20353 @section Interfacing to non-GNAT Ada code
20355 It is possible to specify the convention @code{Ada} in a pragma
20356 @code{Import} or pragma @code{Export}. However this refers to
20357 the calling conventions used by GNAT, which may or may not be
20358 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20359 compiler to allow interoperation.
20361 If arguments types are kept simple, and if the foreign compiler generally
20362 follows system calling conventions, then it may be possible to integrate
20363 files compiled by other Ada compilers, provided that the elaboration
20364 issues are adequately addressed (for example by eliminating the
20365 need for any load time elaboration).
20367 In particular, GNAT running on VMS is designed to
20368 be highly compatible with the DEC Ada 83 compiler, so this is one
20369 case in which it is possible to import foreign units of this type,
20370 provided that the data items passed are restricted to simple scalar
20371 values or simple record types without variants, or simple array
20372 types with fixed bounds.
20374 @node Specialized Needs Annexes
20375 @chapter Specialized Needs Annexes
20378 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20379 required in all implementations. However, as described in this chapter,
20380 GNAT implements all of these annexes:
20383 @item Systems Programming (Annex C)
20384 The Systems Programming Annex is fully implemented.
20386 @item Real-Time Systems (Annex D)
20387 The Real-Time Systems Annex is fully implemented.
20389 @item Distributed Systems (Annex E)
20390 Stub generation is fully implemented in the GNAT compiler. In addition,
20391 a complete compatible PCS is available as part of the GLADE system,
20392 a separate product. When the two
20393 products are used in conjunction, this annex is fully implemented.
20395 @item Information Systems (Annex F)
20396 The Information Systems annex is fully implemented.
20398 @item Numerics (Annex G)
20399 The Numerics Annex is fully implemented.
20401 @item Safety and Security / High-Integrity Systems (Annex H)
20402 The Safety and Security Annex (termed the High-Integrity Systems Annex
20403 in Ada 2005) is fully implemented.
20406 @node Implementation of Specific Ada Features
20407 @chapter Implementation of Specific Ada Features
20410 This chapter describes the GNAT implementation of several Ada language
20414 * Machine Code Insertions::
20415 * GNAT Implementation of Tasking::
20416 * GNAT Implementation of Shared Passive Packages::
20417 * Code Generation for Array Aggregates::
20418 * The Size of Discriminated Records with Default Discriminants::
20419 * Strict Conformance to the Ada Reference Manual::
20422 @node Machine Code Insertions
20423 @section Machine Code Insertions
20424 @cindex Machine Code insertions
20427 Package @code{Machine_Code} provides machine code support as described
20428 in the Ada Reference Manual in two separate forms:
20431 Machine code statements, consisting of qualified expressions that
20432 fit the requirements of RM section 13.8.
20434 An intrinsic callable procedure, providing an alternative mechanism of
20435 including machine instructions in a subprogram.
20439 The two features are similar, and both are closely related to the mechanism
20440 provided by the asm instruction in the GNU C compiler. Full understanding
20441 and use of the facilities in this package requires understanding the asm
20442 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
20443 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
20445 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20446 semantic restrictions and effects as described below. Both are provided so
20447 that the procedure call can be used as a statement, and the function call
20448 can be used to form a code_statement.
20450 The first example given in the GCC documentation is the C @code{asm}
20453 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20457 The equivalent can be written for GNAT as:
20459 @smallexample @c ada
20460 Asm ("fsinx %1 %0",
20461 My_Float'Asm_Output ("=f", result),
20462 My_Float'Asm_Input ("f", angle));
20466 The first argument to @code{Asm} is the assembler template, and is
20467 identical to what is used in GNU C@. This string must be a static
20468 expression. The second argument is the output operand list. It is
20469 either a single @code{Asm_Output} attribute reference, or a list of such
20470 references enclosed in parentheses (technically an array aggregate of
20473 The @code{Asm_Output} attribute denotes a function that takes two
20474 parameters. The first is a string, the second is the name of a variable
20475 of the type designated by the attribute prefix. The first (string)
20476 argument is required to be a static expression and designates the
20477 constraint for the parameter (e.g.@: what kind of register is
20478 required). The second argument is the variable to be updated with the
20479 result. The possible values for constraint are the same as those used in
20480 the RTL, and are dependent on the configuration file used to build the
20481 GCC back end. If there are no output operands, then this argument may
20482 either be omitted, or explicitly given as @code{No_Output_Operands}.
20484 The second argument of @code{@var{my_float}'Asm_Output} functions as
20485 though it were an @code{out} parameter, which is a little curious, but
20486 all names have the form of expressions, so there is no syntactic
20487 irregularity, even though normally functions would not be permitted
20488 @code{out} parameters. The third argument is the list of input
20489 operands. It is either a single @code{Asm_Input} attribute reference, or
20490 a list of such references enclosed in parentheses (technically an array
20491 aggregate of such references).
20493 The @code{Asm_Input} attribute denotes a function that takes two
20494 parameters. The first is a string, the second is an expression of the
20495 type designated by the prefix. The first (string) argument is required
20496 to be a static expression, and is the constraint for the parameter,
20497 (e.g.@: what kind of register is required). The second argument is the
20498 value to be used as the input argument. The possible values for the
20499 constant are the same as those used in the RTL, and are dependent on
20500 the configuration file used to built the GCC back end.
20502 If there are no input operands, this argument may either be omitted, or
20503 explicitly given as @code{No_Input_Operands}. The fourth argument, not
20504 present in the above example, is a list of register names, called the
20505 @dfn{clobber} argument. This argument, if given, must be a static string
20506 expression, and is a space or comma separated list of names of registers
20507 that must be considered destroyed as a result of the @code{Asm} call. If
20508 this argument is the null string (the default value), then the code
20509 generator assumes that no additional registers are destroyed.
20511 The fifth argument, not present in the above example, called the
20512 @dfn{volatile} argument, is by default @code{False}. It can be set to
20513 the literal value @code{True} to indicate to the code generator that all
20514 optimizations with respect to the instruction specified should be
20515 suppressed, and that in particular, for an instruction that has outputs,
20516 the instruction will still be generated, even if none of the outputs are
20517 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
20518 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
20519 Generally it is strongly advisable to use Volatile for any ASM statement
20520 that is missing either input or output operands, or when two or more ASM
20521 statements appear in sequence, to avoid unwanted optimizations. A warning
20522 is generated if this advice is not followed.
20524 The @code{Asm} subprograms may be used in two ways. First the procedure
20525 forms can be used anywhere a procedure call would be valid, and
20526 correspond to what the RM calls ``intrinsic'' routines. Such calls can
20527 be used to intersperse machine instructions with other Ada statements.
20528 Second, the function forms, which return a dummy value of the limited
20529 private type @code{Asm_Insn}, can be used in code statements, and indeed
20530 this is the only context where such calls are allowed. Code statements
20531 appear as aggregates of the form:
20533 @smallexample @c ada
20534 Asm_Insn'(Asm (@dots{}));
20535 Asm_Insn'(Asm_Volatile (@dots{}));
20539 In accordance with RM rules, such code statements are allowed only
20540 within subprograms whose entire body consists of such statements. It is
20541 not permissible to intermix such statements with other Ada statements.
20543 Typically the form using intrinsic procedure calls is more convenient
20544 and more flexible. The code statement form is provided to meet the RM
20545 suggestion that such a facility should be made available. The following
20546 is the exact syntax of the call to @code{Asm}. As usual, if named notation
20547 is used, the arguments may be given in arbitrary order, following the
20548 normal rules for use of positional and named arguments)
20552 [Template =>] static_string_EXPRESSION
20553 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
20554 [,[Inputs =>] INPUT_OPERAND_LIST ]
20555 [,[Clobber =>] static_string_EXPRESSION ]
20556 [,[Volatile =>] static_boolean_EXPRESSION] )
20558 OUTPUT_OPERAND_LIST ::=
20559 [PREFIX.]No_Output_Operands
20560 | OUTPUT_OPERAND_ATTRIBUTE
20561 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
20563 OUTPUT_OPERAND_ATTRIBUTE ::=
20564 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
20566 INPUT_OPERAND_LIST ::=
20567 [PREFIX.]No_Input_Operands
20568 | INPUT_OPERAND_ATTRIBUTE
20569 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
20571 INPUT_OPERAND_ATTRIBUTE ::=
20572 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
20576 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
20577 are declared in the package @code{Machine_Code} and must be referenced
20578 according to normal visibility rules. In particular if there is no
20579 @code{use} clause for this package, then appropriate package name
20580 qualification is required.
20582 @node GNAT Implementation of Tasking
20583 @section GNAT Implementation of Tasking
20586 This chapter outlines the basic GNAT approach to tasking (in particular,
20587 a multi-layered library for portability) and discusses issues related
20588 to compliance with the Real-Time Systems Annex.
20591 * Mapping Ada Tasks onto the Underlying Kernel Threads::
20592 * Ensuring Compliance with the Real-Time Annex::
20595 @node Mapping Ada Tasks onto the Underlying Kernel Threads
20596 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
20599 GNAT's run-time support comprises two layers:
20602 @item GNARL (GNAT Run-time Layer)
20603 @item GNULL (GNAT Low-level Library)
20607 In GNAT, Ada's tasking services rely on a platform and OS independent
20608 layer known as GNARL@. This code is responsible for implementing the
20609 correct semantics of Ada's task creation, rendezvous, protected
20612 GNARL decomposes Ada's tasking semantics into simpler lower level
20613 operations such as create a thread, set the priority of a thread,
20614 yield, create a lock, lock/unlock, etc. The spec for these low-level
20615 operations constitutes GNULLI, the GNULL Interface. This interface is
20616 directly inspired from the POSIX real-time API@.
20618 If the underlying executive or OS implements the POSIX standard
20619 faithfully, the GNULL Interface maps as is to the services offered by
20620 the underlying kernel. Otherwise, some target dependent glue code maps
20621 the services offered by the underlying kernel to the semantics expected
20624 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
20625 key point is that each Ada task is mapped on a thread in the underlying
20626 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
20628 In addition Ada task priorities map onto the underlying thread priorities.
20629 Mapping Ada tasks onto the underlying kernel threads has several advantages:
20633 The underlying scheduler is used to schedule the Ada tasks. This
20634 makes Ada tasks as efficient as kernel threads from a scheduling
20638 Interaction with code written in C containing threads is eased
20639 since at the lowest level Ada tasks and C threads map onto the same
20640 underlying kernel concept.
20643 When an Ada task is blocked during I/O the remaining Ada tasks are
20647 On multiprocessor systems Ada tasks can execute in parallel.
20651 Some threads libraries offer a mechanism to fork a new process, with the
20652 child process duplicating the threads from the parent.
20654 support this functionality when the parent contains more than one task.
20655 @cindex Forking a new process
20657 @node Ensuring Compliance with the Real-Time Annex
20658 @subsection Ensuring Compliance with the Real-Time Annex
20659 @cindex Real-Time Systems Annex compliance
20662 Although mapping Ada tasks onto
20663 the underlying threads has significant advantages, it does create some
20664 complications when it comes to respecting the scheduling semantics
20665 specified in the real-time annex (Annex D).
20667 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
20668 scheduling policy states:
20671 @emph{When the active priority of a ready task that is not running
20672 changes, or the setting of its base priority takes effect, the
20673 task is removed from the ready queue for its old active priority
20674 and is added at the tail of the ready queue for its new active
20675 priority, except in the case where the active priority is lowered
20676 due to the loss of inherited priority, in which case the task is
20677 added at the head of the ready queue for its new active priority.}
20681 While most kernels do put tasks at the end of the priority queue when
20682 a task changes its priority, (which respects the main
20683 FIFO_Within_Priorities requirement), almost none keep a thread at the
20684 beginning of its priority queue when its priority drops from the loss
20685 of inherited priority.
20687 As a result most vendors have provided incomplete Annex D implementations.
20689 The GNAT run-time, has a nice cooperative solution to this problem
20690 which ensures that accurate FIFO_Within_Priorities semantics are
20693 The principle is as follows. When an Ada task T is about to start
20694 running, it checks whether some other Ada task R with the same
20695 priority as T has been suspended due to the loss of priority
20696 inheritance. If this is the case, T yields and is placed at the end of
20697 its priority queue. When R arrives at the front of the queue it
20700 Note that this simple scheme preserves the relative order of the tasks
20701 that were ready to execute in the priority queue where R has been
20704 @node GNAT Implementation of Shared Passive Packages
20705 @section GNAT Implementation of Shared Passive Packages
20706 @cindex Shared passive packages
20709 GNAT fully implements the pragma @code{Shared_Passive} for
20710 @cindex pragma @code{Shared_Passive}
20711 the purpose of designating shared passive packages.
20712 This allows the use of passive partitions in the
20713 context described in the Ada Reference Manual; i.e., for communication
20714 between separate partitions of a distributed application using the
20715 features in Annex E.
20717 @cindex Distribution Systems Annex
20719 However, the implementation approach used by GNAT provides for more
20720 extensive usage as follows:
20723 @item Communication between separate programs
20725 This allows separate programs to access the data in passive
20726 partitions, using protected objects for synchronization where
20727 needed. The only requirement is that the two programs have a
20728 common shared file system. It is even possible for programs
20729 running on different machines with different architectures
20730 (e.g.@: different endianness) to communicate via the data in
20731 a passive partition.
20733 @item Persistence between program runs
20735 The data in a passive package can persist from one run of a
20736 program to another, so that a later program sees the final
20737 values stored by a previous run of the same program.
20742 The implementation approach used is to store the data in files. A
20743 separate stream file is created for each object in the package, and
20744 an access to an object causes the corresponding file to be read or
20747 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
20748 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
20749 set to the directory to be used for these files.
20750 The files in this directory
20751 have names that correspond to their fully qualified names. For
20752 example, if we have the package
20754 @smallexample @c ada
20756 pragma Shared_Passive (X);
20763 and the environment variable is set to @code{/stemp/}, then the files created
20764 will have the names:
20772 These files are created when a value is initially written to the object, and
20773 the files are retained until manually deleted. This provides the persistence
20774 semantics. If no file exists, it means that no partition has assigned a value
20775 to the variable; in this case the initial value declared in the package
20776 will be used. This model ensures that there are no issues in synchronizing
20777 the elaboration process, since elaboration of passive packages elaborates the
20778 initial values, but does not create the files.
20780 The files are written using normal @code{Stream_IO} access.
20781 If you want to be able
20782 to communicate between programs or partitions running on different
20783 architectures, then you should use the XDR versions of the stream attribute
20784 routines, since these are architecture independent.
20786 If active synchronization is required for access to the variables in the
20787 shared passive package, then as described in the Ada Reference Manual, the
20788 package may contain protected objects used for this purpose. In this case
20789 a lock file (whose name is @file{___lock} (three underscores)
20790 is created in the shared memory directory.
20791 @cindex @file{___lock} file (for shared passive packages)
20792 This is used to provide the required locking
20793 semantics for proper protected object synchronization.
20795 As of January 2003, GNAT supports shared passive packages on all platforms
20796 except for OpenVMS.
20798 @node Code Generation for Array Aggregates
20799 @section Code Generation for Array Aggregates
20802 * Static constant aggregates with static bounds::
20803 * Constant aggregates with unconstrained nominal types::
20804 * Aggregates with static bounds::
20805 * Aggregates with non-static bounds::
20806 * Aggregates in assignment statements::
20810 Aggregates have a rich syntax and allow the user to specify the values of
20811 complex data structures by means of a single construct. As a result, the
20812 code generated for aggregates can be quite complex and involve loops, case
20813 statements and multiple assignments. In the simplest cases, however, the
20814 compiler will recognize aggregates whose components and constraints are
20815 fully static, and in those cases the compiler will generate little or no
20816 executable code. The following is an outline of the code that GNAT generates
20817 for various aggregate constructs. For further details, you will find it
20818 useful to examine the output produced by the -gnatG flag to see the expanded
20819 source that is input to the code generator. You may also want to examine
20820 the assembly code generated at various levels of optimization.
20822 The code generated for aggregates depends on the context, the component values,
20823 and the type. In the context of an object declaration the code generated is
20824 generally simpler than in the case of an assignment. As a general rule, static
20825 component values and static subtypes also lead to simpler code.
20827 @node Static constant aggregates with static bounds
20828 @subsection Static constant aggregates with static bounds
20831 For the declarations:
20832 @smallexample @c ada
20833 type One_Dim is array (1..10) of integer;
20834 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
20838 GNAT generates no executable code: the constant ar0 is placed in static memory.
20839 The same is true for constant aggregates with named associations:
20841 @smallexample @c ada
20842 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
20843 Cr3 : constant One_Dim := (others => 7777);
20847 The same is true for multidimensional constant arrays such as:
20849 @smallexample @c ada
20850 type two_dim is array (1..3, 1..3) of integer;
20851 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
20855 The same is true for arrays of one-dimensional arrays: the following are
20858 @smallexample @c ada
20859 type ar1b is array (1..3) of boolean;
20860 type ar_ar is array (1..3) of ar1b;
20861 None : constant ar1b := (others => false); -- fully static
20862 None2 : constant ar_ar := (1..3 => None); -- fully static
20866 However, for multidimensional aggregates with named associations, GNAT will
20867 generate assignments and loops, even if all associations are static. The
20868 following two declarations generate a loop for the first dimension, and
20869 individual component assignments for the second dimension:
20871 @smallexample @c ada
20872 Zero1: constant two_dim := (1..3 => (1..3 => 0));
20873 Zero2: constant two_dim := (others => (others => 0));
20876 @node Constant aggregates with unconstrained nominal types
20877 @subsection Constant aggregates with unconstrained nominal types
20880 In such cases the aggregate itself establishes the subtype, so that
20881 associations with @code{others} cannot be used. GNAT determines the
20882 bounds for the actual subtype of the aggregate, and allocates the
20883 aggregate statically as well. No code is generated for the following:
20885 @smallexample @c ada
20886 type One_Unc is array (natural range <>) of integer;
20887 Cr_Unc : constant One_Unc := (12,24,36);
20890 @node Aggregates with static bounds
20891 @subsection Aggregates with static bounds
20894 In all previous examples the aggregate was the initial (and immutable) value
20895 of a constant. If the aggregate initializes a variable, then code is generated
20896 for it as a combination of individual assignments and loops over the target
20897 object. The declarations
20899 @smallexample @c ada
20900 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
20901 Cr_Var2 : One_Dim := (others > -1);
20905 generate the equivalent of
20907 @smallexample @c ada
20913 for I in Cr_Var2'range loop
20918 @node Aggregates with non-static bounds
20919 @subsection Aggregates with non-static bounds
20922 If the bounds of the aggregate are not statically compatible with the bounds
20923 of the nominal subtype of the target, then constraint checks have to be
20924 generated on the bounds. For a multidimensional array, constraint checks may
20925 have to be applied to sub-arrays individually, if they do not have statically
20926 compatible subtypes.
20928 @node Aggregates in assignment statements
20929 @subsection Aggregates in assignment statements
20932 In general, aggregate assignment requires the construction of a temporary,
20933 and a copy from the temporary to the target of the assignment. This is because
20934 it is not always possible to convert the assignment into a series of individual
20935 component assignments. For example, consider the simple case:
20937 @smallexample @c ada
20942 This cannot be converted into:
20944 @smallexample @c ada
20950 So the aggregate has to be built first in a separate location, and then
20951 copied into the target. GNAT recognizes simple cases where this intermediate
20952 step is not required, and the assignments can be performed in place, directly
20953 into the target. The following sufficient criteria are applied:
20957 The bounds of the aggregate are static, and the associations are static.
20959 The components of the aggregate are static constants, names of
20960 simple variables that are not renamings, or expressions not involving
20961 indexed components whose operands obey these rules.
20965 If any of these conditions are violated, the aggregate will be built in
20966 a temporary (created either by the front-end or the code generator) and then
20967 that temporary will be copied onto the target.
20969 @node The Size of Discriminated Records with Default Discriminants
20970 @section The Size of Discriminated Records with Default Discriminants
20973 If a discriminated type @code{T} has discriminants with default values, it is
20974 possible to declare an object of this type without providing an explicit
20977 @smallexample @c ada
20979 type Size is range 1..100;
20981 type Rec (D : Size := 15) is record
20982 Name : String (1..D);
20990 Such an object is said to be @emph{unconstrained}.
20991 The discriminant of the object
20992 can be modified by a full assignment to the object, as long as it preserves the
20993 relation between the value of the discriminant, and the value of the components
20996 @smallexample @c ada
20998 Word := (3, "yes");
21000 Word := (5, "maybe");
21002 Word := (5, "no"); -- raises Constraint_Error
21007 In order to support this behavior efficiently, an unconstrained object is
21008 given the maximum size that any value of the type requires. In the case
21009 above, @code{Word} has storage for the discriminant and for
21010 a @code{String} of length 100.
21011 It is important to note that unconstrained objects do not require dynamic
21012 allocation. It would be an improper implementation to place on the heap those
21013 components whose size depends on discriminants. (This improper implementation
21014 was used by some Ada83 compilers, where the @code{Name} component above
21016 been stored as a pointer to a dynamic string). Following the principle that
21017 dynamic storage management should never be introduced implicitly,
21018 an Ada compiler should reserve the full size for an unconstrained declared
21019 object, and place it on the stack.
21021 This maximum size approach
21022 has been a source of surprise to some users, who expect the default
21023 values of the discriminants to determine the size reserved for an
21024 unconstrained object: ``If the default is 15, why should the object occupy
21026 The answer, of course, is that the discriminant may be later modified,
21027 and its full range of values must be taken into account. This is why the
21032 type Rec (D : Positive := 15) is record
21033 Name : String (1..D);
21041 is flagged by the compiler with a warning:
21042 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21043 because the required size includes @code{Positive'Last}
21044 bytes. As the first example indicates, the proper approach is to declare an
21045 index type of ``reasonable'' range so that unconstrained objects are not too
21048 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21049 created in the heap by means of an allocator, then it is @emph{not}
21051 it is constrained by the default values of the discriminants, and those values
21052 cannot be modified by full assignment. This is because in the presence of
21053 aliasing all views of the object (which may be manipulated by different tasks,
21054 say) must be consistent, so it is imperative that the object, once created,
21057 @node Strict Conformance to the Ada Reference Manual
21058 @section Strict Conformance to the Ada Reference Manual
21061 The dynamic semantics defined by the Ada Reference Manual impose a set of
21062 run-time checks to be generated. By default, the GNAT compiler will insert many
21063 run-time checks into the compiled code, including most of those required by the
21064 Ada Reference Manual. However, there are three checks that are not enabled
21065 in the default mode for efficiency reasons: arithmetic overflow checking for
21066 integer operations (including division by zero), checks for access before
21067 elaboration on subprogram calls, and stack overflow checking (most operating
21068 systems do not perform this check by default).
21070 Strict conformance to the Ada Reference Manual can be achieved by adding
21071 three compiler options for overflow checking for integer operations
21072 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21073 calls and generic instantiations (@option{-gnatE}), and stack overflow
21074 checking (@option{-fstack-check}).
21076 Note that the result of a floating point arithmetic operation in overflow and
21077 invalid situations, when the @code{Machine_Overflows} attribute of the result
21078 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21079 case for machines compliant with the IEEE floating-point standard, but on
21080 machines that are not fully compliant with this standard, such as Alpha, the
21081 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21082 behavior (although at the cost of a significant performance penalty), so
21083 infinite and NaN values are properly generated.
21086 @node Implementation of Ada 2012 Features
21087 @chapter Implementation of Ada 2012 Features
21088 @cindex Ada 2012 implementation status
21090 This chapter contains a complete list of Ada 2012 features that have been
21091 implemented as of GNAT version 6.4. Generally, these features are only
21092 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21093 @cindex @option{-gnat12} option
21094 or if the configuration pragma @code{Ada_2012} is used.
21095 @cindex pragma @code{Ada_2012}
21096 @cindex configuration pragma @code{Ada_2012}
21097 @cindex @code{Ada_2012} configuration pragma
21098 However, new pragmas, attributes, and restrictions are
21099 unconditionally available, since the Ada 95 standard allows the addition of
21100 new pragmas, attributes, and restrictions (there are exceptions, which are
21101 documented in the individual descriptions), and also certain packages
21102 were made available in earlier versions of Ada.
21104 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21105 This date shows the implementation date of the feature. Any wavefront
21106 subsequent to this date will contain the indicated feature, as will any
21107 subsequent releases. A date of 0000-00-00 means that GNAT has always
21108 implemented the feature, or implemented it as soon as it appeared as a
21109 binding interpretation.
21111 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21112 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21113 The features are ordered based on the relevant sections of the Ada
21114 Reference Manual (``RM''). When a given AI relates to multiple points
21115 in the RM, the earliest is used.
21117 A complete description of the AIs may be found in
21118 @url{www.ada-auth.org/ai05-summary.html}.
21123 @emph{AI-0176 Quantified expressions (2010-09-29)}
21124 @cindex AI-0176 (Ada 2012 feature)
21127 Both universally and existentially quantified expressions are implemented.
21128 They use the new syntax for iterators proposed in AI05-139-2, as well as
21129 the standard Ada loop syntax.
21132 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
21135 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21136 @cindex AI-0079 (Ada 2012 feature)
21139 Wide characters in the unicode category @i{other_format} are now allowed in
21140 source programs between tokens, but not within a token such as an identifier.
21143 RM References: 2.01 (4/2) 2.02 (7)
21146 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21147 @cindex AI-0091 (Ada 2012 feature)
21150 Wide characters in the unicode category @i{other_format} are not permitted
21151 within an identifier, since this can be a security problem. The error
21152 message for this case has been improved to be more specific, but GNAT has
21153 never allowed such characters to appear in identifiers.
21156 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)
21159 @emph{AI-0100 Placement of pragmas (2010-07-01)}
21160 @cindex AI-0100 (Ada 2012 feature)
21163 This AI is an earlier version of AI-163. It simplifies the rules
21164 for legal placement of pragmas. In the case of lists that allow pragmas, if
21165 the list may have no elements, then the list may consist solely of pragmas.
21168 RM References: 2.08 (7)
21171 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21172 @cindex AI-0163 (Ada 2012 feature)
21175 A statement sequence may be composed entirely of pragmas. It is no longer
21176 necessary to add a dummy @code{null} statement to make the sequence legal.
21179 RM References: 2.08 (7) 2.08 (16)
21183 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21184 @cindex AI-0080 (Ada 2012 feature)
21187 This is an editorial change only, described as non-testable in the AI.
21190 RM References: 3.01 (7)
21194 @emph{AI-0183 Aspect specifications (2010-08-16)}
21195 @cindex AI-0183 (Ada 2012 feature)
21198 Aspect specifications have been fully implemented except for pre and post-
21199 conditions, and type invariants, which have their own separate AI's. All
21200 forms of declarations listed in the AI are supported. The following is a
21201 list of the aspects supported (with GNAT implementation aspects marked)
21203 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21204 @item @code{Ada_2005} @tab -- GNAT
21205 @item @code{Ada_2012} @tab -- GNAT
21206 @item @code{Address} @tab
21207 @item @code{Alignment} @tab
21208 @item @code{Atomic} @tab
21209 @item @code{Atomic_Components} @tab
21210 @item @code{Bit_Order} @tab
21211 @item @code{Component_Size} @tab
21212 @item @code{Contract_Cases} @tab -- GNAT
21213 @item @code{Discard_Names} @tab
21214 @item @code{External_Tag} @tab
21215 @item @code{Favor_Top_Level} @tab -- GNAT
21216 @item @code{Inline} @tab
21217 @item @code{Inline_Always} @tab -- GNAT
21218 @item @code{Invariant} @tab -- GNAT
21219 @item @code{Machine_Radix} @tab
21220 @item @code{No_Return} @tab
21221 @item @code{Object_Size} @tab -- GNAT
21222 @item @code{Pack} @tab
21223 @item @code{Persistent_BSS} @tab -- GNAT
21224 @item @code{Post} @tab
21225 @item @code{Pre} @tab
21226 @item @code{Predicate} @tab
21227 @item @code{Preelaborable_Initialization} @tab
21228 @item @code{Pure_Function} @tab -- GNAT
21229 @item @code{Remote_Access_Type} @tab -- GNAT
21230 @item @code{Shared} @tab -- GNAT
21231 @item @code{Size} @tab
21232 @item @code{Storage_Pool} @tab
21233 @item @code{Storage_Size} @tab
21234 @item @code{Stream_Size} @tab
21235 @item @code{Suppress} @tab
21236 @item @code{Suppress_Debug_Info} @tab -- GNAT
21237 @item @code{Test_Case} @tab -- GNAT
21238 @item @code{Thread_Local_Storage} @tab -- GNAT
21239 @item @code{Type_Invariant} @tab
21240 @item @code{Unchecked_Union} @tab
21241 @item @code{Universal_Aliasing} @tab -- GNAT
21242 @item @code{Unmodified} @tab -- GNAT
21243 @item @code{Unreferenced} @tab -- GNAT
21244 @item @code{Unreferenced_Objects} @tab -- GNAT
21245 @item @code{Unsuppress} @tab
21246 @item @code{Value_Size} @tab -- GNAT
21247 @item @code{Volatile} @tab
21248 @item @code{Volatile_Components}
21249 @item @code{Warnings} @tab -- GNAT
21253 Note that for aspects with an expression, e.g. @code{Size}, the expression is
21254 treated like a default expression (visibility is analyzed at the point of
21255 occurrence of the aspect, but evaluation of the expression occurs at the
21256 freeze point of the entity involved).
21259 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
21260 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
21261 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
21262 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
21263 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
21268 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21269 @cindex AI-0128 (Ada 2012 feature)
21272 If an equality operator ("=") is declared for a type, then the implicitly
21273 declared inequality operator ("/=") is a primitive operation of the type.
21274 This is the only reasonable interpretation, and is the one always implemented
21275 by GNAT, but the RM was not entirely clear in making this point.
21278 RM References: 3.02.03 (6) 6.06 (6)
21281 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21282 @cindex AI-0003 (Ada 2012 feature)
21285 In Ada 2012, a qualified expression is considered to be syntactically a name,
21286 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21287 useful in disambiguating some cases of overloading.
21290 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
21294 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21295 @cindex AI-0120 (Ada 2012 feature)
21298 This is an RM editorial change only. The section that lists objects that are
21299 constant failed to include the current instance of a protected object
21300 within a protected function. This has always been treated as a constant
21304 RM References: 3.03 (21)
21307 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21308 @cindex AI-0008 (Ada 2012 feature)
21311 The wording in the RM implied that if you have a general access to a
21312 constrained object, it could be used to modify the discriminants. This was
21313 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21314 has always done so in this situation.
21317 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
21321 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21322 @cindex AI-0093 (Ada 2012 feature)
21325 This is an editorial change only, to make more widespread use of the Ada 2012
21326 ``immutably limited''.
21329 RM References: 3.03 (23.4/3)
21334 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21335 @cindex AI-0096 (Ada 2012 feature)
21338 In general it is illegal for a type derived from a formal limited type to be
21339 nonlimited. This AI makes an exception to this rule: derivation is legal
21340 if it appears in the private part of the generic, and the formal type is not
21341 tagged. If the type is tagged, the legality check must be applied to the
21342 private part of the package.
21345 RM References: 3.04 (5.1/2) 6.02 (7)
21349 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21350 @cindex AI-0181 (Ada 2012 feature)
21353 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21354 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21355 @code{Image} and @code{Value} attributes for the character types. Strictly
21356 speaking this is an inconsistency with Ada 95, but in practice the use of
21357 these attributes is so obscure that it will not cause problems.
21360 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
21364 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21365 @cindex AI-0182 (Ada 2012 feature)
21368 This AI allows @code{Character'Value} to accept the string @code{'?'} where
21369 @code{?} is any character including non-graphic control characters. GNAT has
21370 always accepted such strings. It also allows strings such as
21371 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21372 permission and raises @code{Constraint_Error}, as is certainly still
21376 RM References: 3.05 (56/2)
21380 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21381 @cindex AI-0214 (Ada 2012 feature)
21384 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21385 to have default expressions by allowing them when the type is limited. It
21386 is often useful to define a default value for a discriminant even though
21387 it can't be changed by assignment.
21390 RM References: 3.07 (9.1/2) 3.07.02 (3)
21394 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21395 @cindex AI-0102 (Ada 2012 feature)
21398 It is illegal to assign an anonymous access constant to an anonymous access
21399 variable. The RM did not have a clear rule to prevent this, but GNAT has
21400 always generated an error for this usage.
21403 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
21407 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21408 @cindex AI-0158 (Ada 2012 feature)
21411 This AI extends the syntax of membership tests to simplify complex conditions
21412 that can be expressed as membership in a subset of values of any type. It
21413 introduces syntax for a list of expressions that may be used in loop contexts
21417 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
21421 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21422 @cindex AI-0173 (Ada 2012 feature)
21425 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21426 with the tag of an abstract type, and @code{False} otherwise.
21429 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
21434 @emph{AI-0076 function with controlling result (0000-00-00)}
21435 @cindex AI-0076 (Ada 2012 feature)
21438 This is an editorial change only. The RM defines calls with controlling
21439 results, but uses the term ``function with controlling result'' without an
21440 explicit definition.
21443 RM References: 3.09.02 (2/2)
21447 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21448 @cindex AI-0126 (Ada 2012 feature)
21451 This AI clarifies dispatching rules, and simply confirms that dispatching
21452 executes the operation of the parent type when there is no explicitly or
21453 implicitly declared operation for the descendant type. This has always been
21454 the case in all versions of GNAT.
21457 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
21461 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
21462 @cindex AI-0097 (Ada 2012 feature)
21465 The RM as written implied that in some cases it was possible to create an
21466 object of an abstract type, by having an abstract extension inherit a non-
21467 abstract constructor from its parent type. This mistake has been corrected
21468 in GNAT and in the RM, and this construct is now illegal.
21471 RM References: 3.09.03 (4/2)
21475 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
21476 @cindex AI-0203 (Ada 2012 feature)
21479 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
21480 permitted such usage.
21483 RM References: 3.09.03 (8/3)
21487 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
21488 @cindex AI-0198 (Ada 2012 feature)
21491 This AI resolves a conflict between two rules involving inherited abstract
21492 operations and predefined operators. If a derived numeric type inherits
21493 an abstract operator, it overrides the predefined one. This interpretation
21494 was always the one implemented in GNAT.
21497 RM References: 3.09.03 (4/3)
21500 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
21501 @cindex AI-0073 (Ada 2012 feature)
21504 This AI covers a number of issues regarding returning abstract types. In
21505 particular generic functions cannot have abstract result types or access
21506 result types designated an abstract type. There are some other cases which
21507 are detailed in the AI. Note that this binding interpretation has not been
21508 retrofitted to operate before Ada 2012 mode, since it caused a significant
21509 number of regressions.
21512 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
21516 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
21517 @cindex AI-0070 (Ada 2012 feature)
21520 This is an editorial change only, there are no testable consequences short of
21521 checking for the absence of generated code for an interface declaration.
21524 RM References: 3.09.04 (18/2)
21528 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
21529 @cindex AI-0208 (Ada 2012 feature)
21532 The wording in the Ada 2005 RM concerning characteristics of incomplete views
21533 was incorrect and implied that some programs intended to be legal were now
21534 illegal. GNAT had never considered such programs illegal, so it has always
21535 implemented the intent of this AI.
21538 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
21542 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
21543 @cindex AI-0162 (Ada 2012 feature)
21546 Incomplete types are made more useful by allowing them to be completed by
21547 private types and private extensions.
21550 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
21555 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
21556 @cindex AI-0098 (Ada 2012 feature)
21559 An unintentional omission in the RM implied some inconsistent restrictions on
21560 the use of anonymous access to subprogram values. These restrictions were not
21561 intentional, and have never been enforced by GNAT.
21564 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
21568 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
21569 @cindex AI-0199 (Ada 2012 feature)
21572 A choice list in a record aggregate can include several components of
21573 (distinct) anonymous access types as long as they have matching designated
21577 RM References: 4.03.01 (16)
21581 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
21582 @cindex AI-0220 (Ada 2012 feature)
21585 This AI addresses a wording problem in the RM that appears to permit some
21586 complex cases of aggregates with non-static discriminants. GNAT has always
21587 implemented the intended semantics.
21590 RM References: 4.03.01 (17)
21593 @emph{AI-0147 Conditional expressions (2009-03-29)}
21594 @cindex AI-0147 (Ada 2012 feature)
21597 Conditional expressions are permitted. The form of such an expression is:
21600 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
21603 The parentheses can be omitted in contexts where parentheses are present
21604 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
21605 clause is omitted, @b{else True} is assumed;
21606 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
21607 @emph{(A implies B)} in standard logic.
21610 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
21611 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
21615 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
21616 @cindex AI-0037 (Ada 2012 feature)
21619 This AI confirms that an association of the form @code{Indx => <>} in an
21620 array aggregate must raise @code{Constraint_Error} if @code{Indx}
21621 is out of range. The RM specified a range check on other associations, but
21622 not when the value of the association was defaulted. GNAT has always inserted
21623 a constraint check on the index value.
21626 RM References: 4.03.03 (29)
21630 @emph{AI-0123 Composability of equality (2010-04-13)}
21631 @cindex AI-0123 (Ada 2012 feature)
21634 Equality of untagged record composes, so that the predefined equality for a
21635 composite type that includes a component of some untagged record type
21636 @code{R} uses the equality operation of @code{R} (which may be user-defined
21637 or predefined). This makes the behavior of untagged records identical to that
21638 of tagged types in this respect.
21640 This change is an incompatibility with previous versions of Ada, but it
21641 corrects a non-uniformity that was often a source of confusion. Analysis of
21642 a large number of industrial programs indicates that in those rare cases
21643 where a composite type had an untagged record component with a user-defined
21644 equality, either there was no use of the composite equality, or else the code
21645 expected the same composability as for tagged types, and thus had a bug that
21646 would be fixed by this change.
21649 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
21654 @emph{AI-0088 The value of exponentiation (0000-00-00)}
21655 @cindex AI-0088 (Ada 2012 feature)
21658 This AI clarifies the equivalence rule given for the dynamic semantics of
21659 exponentiation: the value of the operation can be obtained by repeated
21660 multiplication, but the operation can be implemented otherwise (for example
21661 using the familiar divide-by-two-and-square algorithm, even if this is less
21662 accurate), and does not imply repeated reads of a volatile base.
21665 RM References: 4.05.06 (11)
21668 @emph{AI-0188 Case expressions (2010-01-09)}
21669 @cindex AI-0188 (Ada 2012 feature)
21672 Case expressions are permitted. This allows use of constructs such as:
21674 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
21678 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
21681 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
21682 @cindex AI-0104 (Ada 2012 feature)
21685 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
21686 @code{Constraint_Error} because the default value of the allocated object is
21687 @b{null}. This useless construct is illegal in Ada 2012.
21690 RM References: 4.08 (2)
21693 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
21694 @cindex AI-0157 (Ada 2012 feature)
21697 Allocation and Deallocation from an empty storage pool (i.e. allocation or
21698 deallocation of a pointer for which a static storage size clause of zero
21699 has been given) is now illegal and is detected as such. GNAT
21700 previously gave a warning but not an error.
21703 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
21706 @emph{AI-0179 Statement not required after label (2010-04-10)}
21707 @cindex AI-0179 (Ada 2012 feature)
21710 It is not necessary to have a statement following a label, so a label
21711 can appear at the end of a statement sequence without the need for putting a
21712 null statement afterwards, but it is not allowable to have only labels and
21713 no real statements in a statement sequence.
21716 RM References: 5.01 (2)
21720 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
21721 @cindex AI-139-2 (Ada 2012 feature)
21724 The new syntax for iterating over arrays and containers is now implemented.
21725 Iteration over containers is for now limited to read-only iterators. Only
21726 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
21729 RM References: 5.05
21732 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
21733 @cindex AI-0134 (Ada 2012 feature)
21736 For full conformance, the profiles of anonymous-access-to-subprogram
21737 parameters must match. GNAT has always enforced this rule.
21740 RM References: 6.03.01 (18)
21743 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
21744 @cindex AI-0207 (Ada 2012 feature)
21747 This AI confirms that access_to_constant indication must match for mode
21748 conformance. This was implemented in GNAT when the qualifier was originally
21749 introduced in Ada 2005.
21752 RM References: 6.03.01 (16/2)
21756 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
21757 @cindex AI-0046 (Ada 2012 feature)
21760 For full conformance, in the case of access parameters, the null exclusion
21761 must match (either both or neither must have @code{@b{not null}}).
21764 RM References: 6.03.02 (18)
21768 @emph{AI-0118 The association of parameter associations (0000-00-00)}
21769 @cindex AI-0118 (Ada 2012 feature)
21772 This AI clarifies the rules for named associations in subprogram calls and
21773 generic instantiations. The rules have been in place since Ada 83.
21776 RM References: 6.04.01 (2) 12.03 (9)
21780 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
21781 @cindex AI-0196 (Ada 2012 feature)
21784 Null exclusion checks are not made for @code{@b{out}} parameters when
21785 evaluating the actual parameters. GNAT has never generated these checks.
21788 RM References: 6.04.01 (13)
21791 @emph{AI-0015 Constant return objects (0000-00-00)}
21792 @cindex AI-0015 (Ada 2012 feature)
21795 The return object declared in an @i{extended_return_statement} may be
21796 declared constant. This was always intended, and GNAT has always allowed it.
21799 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
21804 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
21805 @cindex AI-0032 (Ada 2012 feature)
21808 If a function returns a class-wide type, the object of an extended return
21809 statement can be declared with a specific type that is covered by the class-
21810 wide type. This has been implemented in GNAT since the introduction of
21811 extended returns. Note AI-0103 complements this AI by imposing matching
21812 rules for constrained return types.
21815 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
21819 @emph{AI-0103 Static matching for extended return (2010-07-23)}
21820 @cindex AI-0103 (Ada 2012 feature)
21823 If the return subtype of a function is an elementary type or a constrained
21824 type, the subtype indication in an extended return statement must match
21825 statically this return subtype.
21828 RM References: 6.05 (5.2/2)
21832 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
21833 @cindex AI-0058 (Ada 2012 feature)
21836 The RM had some incorrect wording implying wrong treatment of abnormal
21837 completion in an extended return. GNAT has always implemented the intended
21838 correct semantics as described by this AI.
21841 RM References: 6.05 (22/2)
21845 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
21846 @cindex AI-0050 (Ada 2012 feature)
21849 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
21850 not take advantage of these incorrect permissions in any case.
21853 RM References: 6.05 (24/2)
21857 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
21858 @cindex AI-0125 (Ada 2012 feature)
21861 In Ada 2012, the declaration of a primitive operation of a type extension
21862 or private extension can also override an inherited primitive that is not
21863 visible at the point of this declaration.
21866 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
21869 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
21870 @cindex AI-0062 (Ada 2012 feature)
21873 A full constant may have a null exclusion even if its associated deferred
21874 constant does not. GNAT has always allowed this.
21877 RM References: 7.04 (6/2) 7.04 (7.1/2)
21881 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
21882 @cindex AI-0178 (Ada 2012 feature)
21885 This AI clarifies the role of incomplete views and plugs an omission in the
21886 RM. GNAT always correctly restricted the use of incomplete views and types.
21889 RM References: 7.05 (3/2) 7.05 (6/2)
21892 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
21893 @cindex AI-0087 (Ada 2012 feature)
21896 The actual for a formal nonlimited derived type cannot be limited. In
21897 particular, a formal derived type that extends a limited interface but which
21898 is not explicitly limited cannot be instantiated with a limited type.
21901 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
21904 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
21905 @cindex AI-0099 (Ada 2012 feature)
21908 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
21909 and therefore depends on the run-time characteristics of an object (i.e. its
21910 tag) and not on its nominal type. As the AI indicates: ``we do not expect
21911 this to affect any implementation''.
21914 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
21919 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
21920 @cindex AI-0064 (Ada 2012 feature)
21923 This is an editorial change only. The intended behavior is already checked
21924 by an existing ACATS test, which GNAT has always executed correctly.
21927 RM References: 7.06.01 (17.1/1)
21930 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
21931 @cindex AI-0026 (Ada 2012 feature)
21934 Record representation clauses concerning Unchecked_Union types cannot mention
21935 the discriminant of the type. The type of a component declared in the variant
21936 part of an Unchecked_Union cannot be controlled, have controlled components,
21937 nor have protected or task parts. If an Unchecked_Union type is declared
21938 within the body of a generic unit or its descendants, then the type of a
21939 component declared in the variant part cannot be a formal private type or a
21940 formal private extension declared within the same generic unit.
21943 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
21947 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
21948 @cindex AI-0205 (Ada 2012 feature)
21951 This AI corrects a simple omission in the RM. Return objects have always
21952 been visible within an extended return statement.
21955 RM References: 8.03 (17)
21959 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
21960 @cindex AI-0042 (Ada 2012 feature)
21963 This AI fixes a wording gap in the RM. An operation of a synchronized
21964 interface can be implemented by a protected or task entry, but the abstract
21965 operation is not being overridden in the usual sense, and it must be stated
21966 separately that this implementation is legal. This has always been the case
21970 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
21973 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
21974 @cindex AI-0030 (Ada 2012 feature)
21977 Requeue is permitted to a protected, synchronized or task interface primitive
21978 providing it is known that the overriding operation is an entry. Otherwise
21979 the requeue statement has the same effect as a procedure call. Use of pragma
21980 @code{Implemented} provides a way to impose a static requirement on the
21981 overriding operation by adhering to one of the implementation kinds: entry,
21982 protected procedure or any of the above.
21985 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
21986 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
21990 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
21991 @cindex AI-0201 (Ada 2012 feature)
21994 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
21995 attribute, then individual components may not be addressable by independent
21996 tasks. However, if the representation clause has no effect (is confirming),
21997 then independence is not compromised. Furthermore, in GNAT, specification of
21998 other appropriately addressable component sizes (e.g. 16 for 8-bit
21999 characters) also preserves independence. GNAT now gives very clear warnings
22000 both for the declaration of such a type, and for any assignment to its components.
22003 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
22006 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22007 @cindex AI-0009 (Ada 2012 feature)
22010 This AI introduces the new pragmas @code{Independent} and
22011 @code{Independent_Components},
22012 which control guaranteeing independence of access to objects and components.
22013 The AI also requires independence not unaffected by confirming rep clauses.
22016 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
22017 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
22021 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22022 @cindex AI-0072 (Ada 2012 feature)
22025 This AI clarifies that task signalling for reading @code{'Terminated} only
22026 occurs if the result is True. GNAT semantics has always been consistent with
22027 this notion of task signalling.
22030 RM References: 9.10 (6.1/1)
22033 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22034 @cindex AI-0108 (Ada 2012 feature)
22037 This AI confirms that an incomplete type from a limited view does not have
22038 discriminants. This has always been the case in GNAT.
22041 RM References: 10.01.01 (12.3/2)
22044 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22045 @cindex AI-0129 (Ada 2012 feature)
22048 This AI clarifies the description of limited views: a limited view of a
22049 package includes only one view of a type that has an incomplete declaration
22050 and a full declaration (there is no possible ambiguity in a client package).
22051 This AI also fixes an omission: a nested package in the private part has no
22052 limited view. GNAT always implemented this correctly.
22055 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
22060 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22061 @cindex AI-0077 (Ada 2012 feature)
22064 This AI clarifies that a declaration does not include a context clause,
22065 and confirms that it is illegal to have a context in which both a limited
22066 and a nonlimited view of a package are accessible. Such double visibility
22067 was always rejected by GNAT.
22070 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
22073 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22074 @cindex AI-0122 (Ada 2012 feature)
22077 This AI clarifies the visibility of private children of generic units within
22078 instantiations of a parent. GNAT has always handled this correctly.
22081 RM References: 10.01.02 (12/2)
22086 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22087 @cindex AI-0040 (Ada 2012 feature)
22090 This AI confirms that a limited with clause in a child unit cannot name
22091 an ancestor of the unit. This has always been checked in GNAT.
22094 RM References: 10.01.02 (20/2)
22097 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22098 @cindex AI-0132 (Ada 2012 feature)
22101 This AI fills a gap in the description of library unit pragmas. The pragma
22102 clearly must apply to a library unit, even if it does not carry the name
22103 of the enclosing unit. GNAT has always enforced the required check.
22106 RM References: 10.01.05 (7)
22110 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22111 @cindex AI-0034 (Ada 2012 feature)
22114 The RM makes certain limited with clauses illegal because of categorization
22115 considerations, when the corresponding normal with would be legal. This is
22116 not intended, and GNAT has always implemented the recommended behavior.
22119 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
22123 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22124 @cindex AI-0035 (Ada 2012 feature)
22127 This AI remedies some inconsistencies in the legality rules for Pure units.
22128 Derived access types are legal in a pure unit (on the assumption that the
22129 rule for a zero storage pool size has been enforced on the ancestor type).
22130 The rules are enforced in generic instances and in subunits. GNAT has always
22131 implemented the recommended behavior.
22134 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)
22138 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22139 @cindex AI-0219 (Ada 2012 feature)
22142 This AI refines the rules for the cases with limited parameters which do not
22143 allow the implementations to omit ``redundant''. GNAT now properly conforms
22144 to the requirements of this binding interpretation.
22147 RM References: 10.02.01 (18/2)
22150 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22151 @cindex AI-0043 (Ada 2012 feature)
22154 This AI covers various omissions in the RM regarding the raising of
22155 exceptions. GNAT has always implemented the intended semantics.
22158 RM References: 11.04.01 (10.1/2) 11 (2)
22162 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22163 @cindex AI-0200 (Ada 2012 feature)
22166 This AI plugs a gap in the RM which appeared to allow some obviously intended
22167 illegal instantiations. GNAT has never allowed these instantiations.
22170 RM References: 12.07 (16)
22174 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22175 @cindex AI-0112 (Ada 2012 feature)
22178 This AI concerns giving names to various representation aspects, but the
22179 practical effect is simply to make the use of duplicate
22180 @code{Atomic}[@code{_Components}],
22181 @code{Volatile}[@code{_Components}] and
22182 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22183 now performs this required check.
22186 RM References: 13.01 (8)
22189 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22190 @cindex AI-0106 (Ada 2012 feature)
22193 The RM appeared to allow representation pragmas on generic formal parameters,
22194 but this was not intended, and GNAT has never permitted this usage.
22197 RM References: 13.01 (9.1/1)
22201 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22202 @cindex AI-0012 (Ada 2012 feature)
22205 It is now illegal to give an inappropriate component size or a pragma
22206 @code{Pack} that attempts to change the component size in the case of atomic
22207 or aliased components. Previously GNAT ignored such an attempt with a
22211 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
22215 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22216 @cindex AI-0039 (Ada 2012 feature)
22219 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22220 for stream attributes, but these were never useful and are now illegal. GNAT
22221 has always regarded such expressions as illegal.
22224 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
22228 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22229 @cindex AI-0095 (Ada 2012 feature)
22232 The prefix of @code{'Address} cannot statically denote a subprogram with
22233 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22234 @code{Program_Error} if the prefix denotes a subprogram with convention
22238 RM References: 13.03 (11/1)
22242 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22243 @cindex AI-0116 (Ada 2012 feature)
22246 This AI requires that the alignment of a class-wide object be no greater
22247 than the alignment of any type in the class. GNAT has always followed this
22251 RM References: 13.03 (29) 13.11 (16)
22255 @emph{AI-0146 Type invariants (2009-09-21)}
22256 @cindex AI-0146 (Ada 2012 feature)
22259 Type invariants may be specified for private types using the aspect notation.
22260 Aspect @code{Type_Invariant} may be specified for any private type,
22261 @code{Type_Invariant'Class} can
22262 only be specified for tagged types, and is inherited by any descendent of the
22263 tagged types. The invariant is a boolean expression that is tested for being
22264 true in the following situations: conversions to the private type, object
22265 declarations for the private type that are default initialized, and
22267 parameters and returned result on return from any primitive operation for
22268 the type that is visible to a client.
22269 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22270 @code{Invariant'Class} for @code{Type_Invariant'Class}.
22273 RM References: 13.03.03 (00)
22276 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22277 @cindex AI-0078 (Ada 2012 feature)
22280 In Ada 2012, compilers are required to support unchecked conversion where the
22281 target alignment is a multiple of the source alignment. GNAT always supported
22282 this case (and indeed all cases of differing alignments, doing copies where
22283 required if the alignment was reduced).
22286 RM References: 13.09 (7)
22290 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22291 @cindex AI-0195 (Ada 2012 feature)
22294 The handling of invalid values is now designated to be implementation
22295 defined. This is a documentation change only, requiring Annex M in the GNAT
22296 Reference Manual to document this handling.
22297 In GNAT, checks for invalid values are made
22298 only when necessary to avoid erroneous behavior. Operations like assignments
22299 which cannot cause erroneous behavior ignore the possibility of invalid
22300 values and do not do a check. The date given above applies only to the
22301 documentation change, this behavior has always been implemented by GNAT.
22304 RM References: 13.09.01 (10)
22307 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22308 @cindex AI-0193 (Ada 2012 feature)
22311 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22312 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22316 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
22317 13.11.01 (2) 13.11.01 (3)
22321 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22322 @cindex AI-0177 (Ada 2012 feature)
22325 The new Ada 2012 notion of parameterized expressions is implemented. The form
22328 @i{function specification} @b{is} (@i{expression})
22332 This is exactly equivalent to the
22333 corresponding function body that returns the expression, but it can appear
22334 in a package spec. Note that the expression must be parenthesized.
22337 RM References: 13.11.01 (3/2)
22340 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22341 @cindex AI-0033 (Ada 2012 feature)
22344 Neither of these two pragmas may appear within a generic template, because
22345 the generic might be instantiated at other than the library level.
22348 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
22352 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22353 @cindex AI-0161 (Ada 2012 feature)
22356 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22357 of the default stream attributes for elementary types. If this restriction is
22358 in force, then it is necessary to provide explicit subprograms for any
22359 stream attributes used.
22362 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
22365 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22366 @cindex AI-0194 (Ada 2012 feature)
22369 The @code{Stream_Size} attribute returns the default number of bits in the
22370 stream representation of the given type.
22371 This value is not affected by the presence
22372 of stream subprogram attributes for the type. GNAT has always implemented
22373 this interpretation.
22376 RM References: 13.13.02 (1.2/2)
22379 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22380 @cindex AI-0109 (Ada 2012 feature)
22383 This AI is an editorial change only. It removes the need for a tag check
22384 that can never fail.
22387 RM References: 13.13.02 (34/2)
22390 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22391 @cindex AI-0007 (Ada 2012 feature)
22394 The RM as written appeared to limit the possibilities of declaring read
22395 attribute procedures for private scalar types. This limitation was not
22396 intended, and has never been enforced by GNAT.
22399 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
22403 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22404 @cindex AI-0065 (Ada 2012 feature)
22407 This AI clarifies the fact that all remote access types support external
22408 streaming. This fixes an obvious oversight in the definition of the
22409 language, and GNAT always implemented the intended correct rules.
22412 RM References: 13.13.02 (52/2)
22415 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22416 @cindex AI-0019 (Ada 2012 feature)
22419 The RM suggests that primitive subprograms of a specific tagged type are
22420 frozen when the tagged type is frozen. This would be an incompatible change
22421 and is not intended. GNAT has never attempted this kind of freezing and its
22422 behavior is consistent with the recommendation of this AI.
22425 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)
22428 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22429 @cindex AI-0017 (Ada 2012 feature)
22432 So-called ``Taft-amendment types'' (i.e., types that are completed in package
22433 bodies) are not frozen by the occurrence of bodies in the
22434 enclosing declarative part. GNAT always implemented this properly.
22437 RM References: 13.14 (3/1)
22441 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22442 @cindex AI-0060 (Ada 2012 feature)
22445 This AI extends the definition of remote access types to include access
22446 to limited, synchronized, protected or task class-wide interface types.
22447 GNAT already implemented this extension.
22450 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
22453 @emph{AI-0114 Classification of letters (0000-00-00)}
22454 @cindex AI-0114 (Ada 2012 feature)
22457 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
22458 181 (@code{MICRO SIGN}), and
22459 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
22460 lower case letters by Unicode.
22461 However, they are not allowed in identifiers, and they
22462 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
22463 This behavior is consistent with that defined in Ada 95.
22466 RM References: A.03.02 (59) A.04.06 (7)
22470 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
22471 @cindex AI-0185 (Ada 2012 feature)
22474 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
22475 classification functions for @code{Wide_Character} and
22476 @code{Wide_Wide_Character}, as well as providing
22477 case folding routines for @code{Wide_[Wide_]Character} and
22478 @code{Wide_[Wide_]String}.
22481 RM References: A.03.05 (0) A.03.06 (0)
22485 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
22486 @cindex AI-0031 (Ada 2012 feature)
22489 A new version of @code{Find_Token} is added to all relevant string packages,
22490 with an extra parameter @code{From}. Instead of starting at the first
22491 character of the string, the search for a matching Token starts at the
22492 character indexed by the value of @code{From}.
22493 These procedures are available in all versions of Ada
22494 but if used in versions earlier than Ada 2012 they will generate a warning
22495 that an Ada 2012 subprogram is being used.
22498 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
22503 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
22504 @cindex AI-0056 (Ada 2012 feature)
22507 The wording in the Ada 2005 RM implied an incompatible handling of the
22508 @code{Index} functions, resulting in raising an exception instead of
22509 returning zero in some situations.
22510 This was not intended and has been corrected.
22511 GNAT always returned zero, and is thus consistent with this AI.
22514 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
22518 @emph{AI-0137 String encoding package (2010-03-25)}
22519 @cindex AI-0137 (Ada 2012 feature)
22522 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
22523 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
22524 and @code{Wide_Wide_Strings} have been
22525 implemented. These packages (whose documentation can be found in the spec
22526 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
22527 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
22528 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
22529 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
22530 UTF-16), as well as conversions between the different UTF encodings. With
22531 the exception of @code{Wide_Wide_Strings}, these packages are available in
22532 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
22533 The @code{Wide_Wide_Strings package}
22534 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
22535 mode since it uses @code{Wide_Wide_Character}).
22538 RM References: A.04.11
22541 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
22542 @cindex AI-0038 (Ada 2012 feature)
22545 These are minor errors in the description on three points. The intent on
22546 all these points has always been clear, and GNAT has always implemented the
22547 correct intended semantics.
22550 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)
22553 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
22554 @cindex AI-0044 (Ada 2012 feature)
22557 This AI places restrictions on allowed instantiations of generic containers.
22558 These restrictions are not checked by the compiler, so there is nothing to
22559 change in the implementation. This affects only the RM documentation.
22562 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)
22565 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
22566 @cindex AI-0127 (Ada 2012 feature)
22569 This package provides an interface for identifying the current locale.
22572 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
22573 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
22578 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
22579 @cindex AI-0002 (Ada 2012 feature)
22582 The compiler is not required to support exporting an Ada subprogram with
22583 convention C if there are parameters or a return type of an unconstrained
22584 array type (such as @code{String}). GNAT allows such declarations but
22585 generates warnings. It is possible, but complicated, to write the
22586 corresponding C code and certainly such code would be specific to GNAT and
22590 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
22594 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
22595 @cindex AI05-0216 (Ada 2012 feature)
22598 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
22599 forbid tasks declared locally within subprograms, or functions returning task
22600 objects, and that is the implementation that GNAT has always provided.
22601 However the language in the RM was not sufficiently clear on this point.
22602 Thus this is a documentation change in the RM only.
22605 RM References: D.07 (3/3)
22608 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
22609 @cindex AI-0211 (Ada 2012 feature)
22612 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
22613 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
22616 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
22619 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
22620 @cindex AI-0190 (Ada 2012 feature)
22623 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
22624 used to control storage pools globally.
22625 In particular, you can force every access
22626 type that is used for allocation (@b{new}) to have an explicit storage pool,
22627 or you can declare a pool globally to be used for all access types that lack
22631 RM References: D.07 (8)
22634 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
22635 @cindex AI-0189 (Ada 2012 feature)
22638 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
22639 which says that no dynamic allocation will occur once elaboration is
22641 In general this requires a run-time check, which is not required, and which
22642 GNAT does not attempt. But the static cases of allocators in a task body or
22643 in the body of the main program are detected and flagged at compile or bind
22647 RM References: D.07 (19.1/2) H.04 (23.3/2)
22650 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
22651 @cindex AI-0171 (Ada 2012 feature)
22654 A new package @code{System.Multiprocessors} is added, together with the
22655 definition of pragma @code{CPU} for controlling task affinity. A new no
22656 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
22657 is added to the Ravenscar profile.
22660 RM References: D.13.01 (4/2) D.16
22664 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
22665 @cindex AI-0210 (Ada 2012 feature)
22668 This is a documentation only issue regarding wording of metric requirements,
22669 that does not affect the implementation of the compiler.
22672 RM References: D.15 (24/2)
22676 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
22677 @cindex AI-0206 (Ada 2012 feature)
22680 Remote types packages are now allowed to depend on preelaborated packages.
22681 This was formerly considered illegal.
22684 RM References: E.02.02 (6)
22689 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
22690 @cindex AI-0152 (Ada 2012 feature)
22693 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
22694 where the type of the returned value is an anonymous access type.
22697 RM References: H.04 (8/1)
22701 @node Obsolescent Features
22702 @chapter Obsolescent Features
22705 This chapter describes features that are provided by GNAT, but are
22706 considered obsolescent since there are preferred ways of achieving
22707 the same effect. These features are provided solely for historical
22708 compatibility purposes.
22711 * pragma No_Run_Time::
22712 * pragma Ravenscar::
22713 * pragma Restricted_Run_Time::
22714 * pragma Task_Info::
22715 * System.Task_Info (s-tasinf.ads)::
22718 @node pragma No_Run_Time
22719 @section pragma No_Run_Time
22721 The pragma @code{No_Run_Time} is used to achieve an affect similar
22722 to the use of the "Zero Foot Print" configurable run time, but without
22723 requiring a specially configured run time. The result of using this
22724 pragma, which must be used for all units in a partition, is to restrict
22725 the use of any language features requiring run-time support code. The
22726 preferred usage is to use an appropriately configured run-time that
22727 includes just those features that are to be made accessible.
22729 @node pragma Ravenscar
22730 @section pragma Ravenscar
22732 The pragma @code{Ravenscar} has exactly the same effect as pragma
22733 @code{Profile (Ravenscar)}. The latter usage is preferred since it
22734 is part of the new Ada 2005 standard.
22736 @node pragma Restricted_Run_Time
22737 @section pragma Restricted_Run_Time
22739 The pragma @code{Restricted_Run_Time} has exactly the same effect as
22740 pragma @code{Profile (Restricted)}. The latter usage is
22741 preferred since the Ada 2005 pragma @code{Profile} is intended for
22742 this kind of implementation dependent addition.
22744 @node pragma Task_Info
22745 @section pragma Task_Info
22747 The functionality provided by pragma @code{Task_Info} is now part of the
22748 Ada language. The @code{CPU} aspect and the package
22749 @code{System.Multiprocessors} offer a less system-dependent way to specify
22750 task affinity or to query the number of processsors.
22755 @smallexample @c ada
22756 pragma Task_Info (EXPRESSION);
22760 This pragma appears within a task definition (like pragma
22761 @code{Priority}) and applies to the task in which it appears. The
22762 argument must be of type @code{System.Task_Info.Task_Info_Type}.
22763 The @code{Task_Info} pragma provides system dependent control over
22764 aspects of tasking implementation, for example, the ability to map
22765 tasks to specific processors. For details on the facilities available
22766 for the version of GNAT that you are using, see the documentation
22767 in the spec of package System.Task_Info in the runtime
22770 @node System.Task_Info (s-tasinf.ads)
22771 @section package System.Task_Info (@file{s-tasinf.ads})
22774 This package provides target dependent functionality that is used
22775 to support the @code{Task_Info} pragma. The predefined Ada package
22776 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
22777 standard replacement for GNAT's @code{Task_Info} functionality.
22780 @c GNU Free Documentation License
22782 @node Index,,GNU Free Documentation License, Top
22790 tablishes the following set of restrictions: