c-family/
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob9e875bc9c52f6b6773ccd68a8165da2eecb21fc2
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
17 @copying
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''.
26 @end copying
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
35 @syncodeindex fn cp
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
52 @insertcopying
54 @end titlepage
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
60 @noindent
61 GNAT Reference Manual
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
67 @noindent
68 AdaCore
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Standard and Implementation Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
81 * The GNAT Library::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
88 * Index::
90  --- The Detailed Node Listing ---
92 About This Guide
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
110 * Pragma Ast_Entry::
111 * Pragma C_Pass_By_Copy::
112 * Pragma Check::
113 * Pragma Check_Name::
114 * Pragma Check_Policy::
115 * Pragma Comment::
116 * Pragma Common_Object::
117 * Pragma Compile_Time_Error::
118 * Pragma Compile_Time_Warning::
119 * Pragma Compiler_Unit::
120 * Pragma Complete_Representation::
121 * Pragma Complex_Representation::
122 * Pragma Component_Alignment::
123 * Pragma Contract_Case::
124 * Pragma Convention_Identifier::
125 * Pragma CPP_Class::
126 * Pragma CPP_Constructor::
127 * Pragma CPP_Virtual::
128 * Pragma CPP_Vtable::
129 * Pragma Debug::
130 * Pragma Debug_Policy::
131 * Pragma Detect_Blocking::
132 * Pragma Elaboration_Checks::
133 * Pragma Eliminate::
134 * Pragma Export_Exception::
135 * Pragma Export_Function::
136 * Pragma Export_Object::
137 * Pragma Export_Procedure::
138 * Pragma Export_Value::
139 * Pragma Export_Valued_Procedure::
140 * Pragma Extend_System::
141 * Pragma Extensions_Allowed::
142 * Pragma External::
143 * Pragma External_Name_Casing::
144 * Pragma Fast_Math::
145 * Pragma Favor_Top_Level::
146 * Pragma Finalize_Storage_Only::
147 * Pragma Float_Representation::
148 * Pragma Ident::
149 * Pragma Implemented::
150 * Pragma Implicit_Packing::
151 * Pragma Import_Exception::
152 * Pragma Import_Function::
153 * Pragma Import_Object::
154 * Pragma Import_Procedure::
155 * Pragma Import_Valued_Procedure::
156 * Pragma Initialize_Scalars::
157 * Pragma Inline_Always::
158 * Pragma Inline_Generic::
159 * Pragma Interface::
160 * Pragma Interface_Name::
161 * Pragma Interrupt_Handler::
162 * Pragma Interrupt_State::
163 * Pragma Invariant::
164 * Pragma Keep_Names::
165 * Pragma License::
166 * Pragma Link_With::
167 * Pragma Linker_Alias::
168 * Pragma Linker_Constructor::
169 * Pragma Linker_Destructor::
170 * Pragma Linker_Section::
171 * Pragma Long_Float::
172 * Pragma Machine_Attribute::
173 * Pragma Main::
174 * Pragma Main_Storage::
175 * Pragma No_Body::
176 * Pragma No_Return::
177 * Pragma No_Strict_Aliasing ::
178 * Pragma Normalize_Scalars::
179 * Pragma Obsolescent::
180 * Pragma Optimize_Alignment::
181 * Pragma Ordered::
182 * Pragma Overflow_Checks::
183 * Pragma Passive::
184 * Pragma Persistent_BSS::
185 * Pragma Polling::
186 * Pragma Postcondition::
187 * Pragma Precondition::
188 * Pragma Profile (Ravenscar)::
189 * Pragma Profile (Restricted)::
190 * Pragma Psect_Object::
191 * Pragma Pure_Function::
192 * Pragma Remote_Access_Type::
193 * Pragma Restriction_Warnings::
194 * Pragma Shared::
195 * Pragma Short_Circuit_And_Or::
196 * Pragma Short_Descriptors::
197 * Pragma Simple_Storage_Pool_Type::
198 * Pragma Source_File_Name::
199 * Pragma Source_File_Name_Project::
200 * Pragma Source_Reference::
201 * Pragma Static_Elaboration_Desired::
202 * Pragma Stream_Convert::
203 * Pragma Style_Checks::
204 * Pragma Subtitle::
205 * Pragma Suppress::
206 * Pragma Suppress_All::
207 * Pragma Suppress_Exception_Locations::
208 * Pragma Suppress_Initialization::
209 * Pragma Task_Info::
210 * Pragma Task_Name::
211 * Pragma Task_Storage::
212 * Pragma Test_Case::
213 * Pragma Thread_Local_Storage::
214 * Pragma Time_Slice::
215 * Pragma Title::
216 * Pragma Unchecked_Union::
217 * Pragma Unimplemented_Unit::
218 * Pragma Universal_Aliasing ::
219 * Pragma Universal_Data::
220 * Pragma Unmodified::
221 * Pragma Unreferenced::
222 * Pragma Unreferenced_Objects::
223 * Pragma Unreserve_All_Interrupts::
224 * Pragma Unsuppress::
225 * Pragma Use_VADS_Size::
226 * Pragma Validity_Checks::
227 * Pragma Volatile::
228 * Pragma Warnings::
229 * Pragma Weak_External::
230 * Pragma Wide_Character_Encoding::
232 Implementation Defined Attributes
234 * Abort_Signal::
235 * Address_Size::
236 * Asm_Input::
237 * Asm_Output::
238 * AST_Entry::
239 * Bit::
240 * Bit_Position::
241 * Compiler_Version::
242 * Code_Address::
243 * Default_Bit_Order::
244 * Descriptor_Size::
245 * Elaborated::
246 * Elab_Body::
247 * Elab_Spec::
248 * Elab_Subp_Body::
249 * Emax::
250 * Enabled::
251 * Enum_Rep::
252 * Enum_Val::
253 * Epsilon::
254 * Fixed_Value::
255 * Has_Access_Values::
256 * Has_Discriminants::
257 * Img::
258 * Integer_Value::
259 * Invalid_Value::
260 * Large::
261 * Machine_Size::
262 * Mantissa::
263 * Max_Interrupt_Priority::
264 * Max_Priority::
265 * Maximum_Alignment::
266 * Mechanism_Code::
267 * Null_Parameter::
268 * Object_Size::
269 * Passed_By_Reference::
270 * Pool_Address::
271 * Range_Length::
272 * Result::
273 * Safe_Emax::
274 * Safe_Large::
275 * Scalar_Storage_Order::
276 * Simple_Storage_Pool::
277 * Small::
278 * Storage_Unit::
279 * Stub_Type::
280 * System_Allocator_Alignment::
281 * Target_Name::
282 * Tick::
283 * To_Address::
284 * Type_Class::
285 * UET_Address::
286 * Unconstrained_Array::
287 * Universal_Literal_String::
288 * Unrestricted_Access::
289 * Valid_Scalars::
290 * VADS_Size::
291 * Value_Size::
292 * Wchar_T_Size::
293 * Word_Size::
295 Standard and Implementation Defined Restrictions
297 * Partition-Wide Restrictions::
298 * Program Unit Level Restrictions::
300 Partition-Wide Restrictions
302 * Immediate_Reclamation::
303 * Max_Asynchronous_Select_Nesting::
304 * Max_Entry_Queue_Length::
305 * Max_Protected_Entries::
306 * Max_Select_Alternatives::
307 * Max_Storage_At_Blocking::
308 * Max_Task_Entries::
309 * Max_Tasks::
310 * No_Abort_Statements::
311 * No_Access_Parameter_Allocators::
312 * No_Access_Subprograms::
313 * No_Allocators::
314 * No_Anonymous_Allocators::
315 * No_Calendar::
316 * No_Coextensions::
317 * No_Default_Initialization::
318 * No_Delay::
319 * No_Dependence::
320 * No_Direct_Boolean_Operators::
321 * No_Dispatch::
322 * No_Dispatching_Calls::
323 * No_Dynamic_Attachment::
324 * No_Dynamic_Priorities::
325 * No_Entry_Calls_In_Elaboration_Code::
326 * No_Enumeration_Maps::
327 * No_Exception_Handlers::
328 * No_Exception_Propagation::
329 * No_Exception_Registration::
330 * No_Exceptions::
331 * No_Finalization::
332 * No_Fixed_Point::
333 * No_Floating_Point::
334 * No_Implicit_Conditionals::
335 * No_Implicit_Dynamic_Code::
336 * No_Implicit_Heap_Allocations::
337 * No_Implicit_Loops::
338 * No_Initialize_Scalars::
339 * No_IO::
340 * No_Local_Allocators::
341 * No_Local_Protected_Objects::
342 * No_Local_Timing_Events::
343 * No_Nested_Finalization::
344 * No_Protected_Type_Allocators::
345 * No_Protected_Types::
346 * No_Recursion::
347 * No_Reentrancy::
348 * No_Relative_Delay::
349 * No_Requeue_Statements::
350 * No_Secondary_Stack::
351 * No_Select_Statements::
352 * No_Specific_Termination_Handlers::
353 * No_Specification_of_Aspect::
354 * No_Standard_Allocators_After_Elaboration::
355 * No_Standard_Storage_Pools::
356 * No_Stream_Optimizations::
357 * No_Streams::
358 * No_Task_Allocators::
359 * No_Task_Attributes_Package::
360 * No_Task_Hierarchy::
361 * No_Task_Termination::
362 * No_Tasking::
363 * No_Terminate_Alternatives::
364 * No_Unchecked_Access::
365 * Simple_Barriers::
366 * Static_Priorities::
367 * Static_Storage_Size::
369 Program Unit Level Restrictions
371 * No_Elaboration_Code::
372 * No_Entry_Queue::
373 * No_Implementation_Aspect_Specifications::
374 * No_Implementation_Attributes::
375 * No_Implementation_Identifiers::
376 * No_Implementation_Pragmas::
377 * No_Implementation_Restrictions::
378 * No_Implementation_Units::
379 * No_Implicit_Aliasing::
380 * No_Obsolescent_Features::
381 * No_Wide_Characters::
382 * SPARK::
384 The Implementation of Standard I/O
386 * Standard I/O Packages::
387 * FORM Strings::
388 * Direct_IO::
389 * Sequential_IO::
390 * Text_IO::
391 * Wide_Text_IO::
392 * Wide_Wide_Text_IO::
393 * Stream_IO::
394 * Text Translation::
395 * Shared Files::
396 * Filenames encoding::
397 * Open Modes::
398 * Operations on C Streams::
399 * Interfacing to C Streams::
401 The GNAT Library
403 * Ada.Characters.Latin_9 (a-chlat9.ads)::
404 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
405 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
406 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
407 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
408 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
409 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
410 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
411 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
412 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
413 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
414 * Ada.Command_Line.Environment (a-colien.ads)::
415 * Ada.Command_Line.Remove (a-colire.ads)::
416 * Ada.Command_Line.Response_File (a-clrefi.ads)::
417 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
418 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
419 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
420 * Ada.Exceptions.Traceback (a-exctra.ads)::
421 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
422 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
423 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
424 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
425 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
426 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
427 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
428 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
429 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
430 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
431 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
432 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
433 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
434 * GNAT.Altivec (g-altive.ads)::
435 * GNAT.Altivec.Conversions (g-altcon.ads)::
436 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
437 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
438 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
439 * GNAT.Array_Split (g-arrspl.ads)::
440 * GNAT.AWK (g-awk.ads)::
441 * GNAT.Bounded_Buffers (g-boubuf.ads)::
442 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
443 * GNAT.Bubble_Sort (g-bubsor.ads)::
444 * GNAT.Bubble_Sort_A (g-busora.ads)::
445 * GNAT.Bubble_Sort_G (g-busorg.ads)::
446 * GNAT.Byte_Order_Mark (g-byorma.ads)::
447 * GNAT.Byte_Swapping (g-bytswa.ads)::
448 * GNAT.Calendar (g-calend.ads)::
449 * GNAT.Calendar.Time_IO (g-catiio.ads)::
450 * GNAT.Case_Util (g-casuti.ads)::
451 * GNAT.CGI (g-cgi.ads)::
452 * GNAT.CGI.Cookie (g-cgicoo.ads)::
453 * GNAT.CGI.Debug (g-cgideb.ads)::
454 * GNAT.Command_Line (g-comlin.ads)::
455 * GNAT.Compiler_Version (g-comver.ads)::
456 * GNAT.Ctrl_C (g-ctrl_c.ads)::
457 * GNAT.CRC32 (g-crc32.ads)::
458 * GNAT.Current_Exception (g-curexc.ads)::
459 * GNAT.Debug_Pools (g-debpoo.ads)::
460 * GNAT.Debug_Utilities (g-debuti.ads)::
461 * GNAT.Decode_String (g-decstr.ads)::
462 * GNAT.Decode_UTF8_String (g-deutst.ads)::
463 * GNAT.Directory_Operations (g-dirope.ads)::
464 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
465 * GNAT.Dynamic_HTables (g-dynhta.ads)::
466 * GNAT.Dynamic_Tables (g-dyntab.ads)::
467 * GNAT.Encode_String (g-encstr.ads)::
468 * GNAT.Encode_UTF8_String (g-enutst.ads)::
469 * GNAT.Exception_Actions (g-excact.ads)::
470 * GNAT.Exception_Traces (g-exctra.ads)::
471 * GNAT.Exceptions (g-except.ads)::
472 * GNAT.Expect (g-expect.ads)::
473 * GNAT.Expect.TTY (g-exptty.ads)::
474 * GNAT.Float_Control (g-flocon.ads)::
475 * GNAT.Heap_Sort (g-heasor.ads)::
476 * GNAT.Heap_Sort_A (g-hesora.ads)::
477 * GNAT.Heap_Sort_G (g-hesorg.ads)::
478 * GNAT.HTable (g-htable.ads)::
479 * GNAT.IO (g-io.ads)::
480 * GNAT.IO_Aux (g-io_aux.ads)::
481 * GNAT.Lock_Files (g-locfil.ads)::
482 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
483 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
484 * GNAT.MD5 (g-md5.ads)::
485 * GNAT.Memory_Dump (g-memdum.ads)::
486 * GNAT.Most_Recent_Exception (g-moreex.ads)::
487 * GNAT.OS_Lib (g-os_lib.ads)::
488 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
489 * GNAT.Random_Numbers (g-rannum.ads)::
490 * GNAT.Regexp (g-regexp.ads)::
491 * GNAT.Registry (g-regist.ads)::
492 * GNAT.Regpat (g-regpat.ads)::
493 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
494 * GNAT.Semaphores (g-semaph.ads)::
495 * GNAT.Serial_Communications (g-sercom.ads)::
496 * GNAT.SHA1 (g-sha1.ads)::
497 * GNAT.SHA224 (g-sha224.ads)::
498 * GNAT.SHA256 (g-sha256.ads)::
499 * GNAT.SHA384 (g-sha384.ads)::
500 * GNAT.SHA512 (g-sha512.ads)::
501 * GNAT.Signals (g-signal.ads)::
502 * GNAT.Sockets (g-socket.ads)::
503 * GNAT.Source_Info (g-souinf.ads)::
504 * GNAT.Spelling_Checker (g-speche.ads)::
505 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
506 * GNAT.Spitbol.Patterns (g-spipat.ads)::
507 * GNAT.Spitbol (g-spitbo.ads)::
508 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
509 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
510 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
511 * GNAT.SSE (g-sse.ads)::
512 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
513 * GNAT.Strings (g-string.ads)::
514 * GNAT.String_Split (g-strspl.ads)::
515 * GNAT.Table (g-table.ads)::
516 * GNAT.Task_Lock (g-tasloc.ads)::
517 * GNAT.Threads (g-thread.ads)::
518 * GNAT.Time_Stamp (g-timsta.ads)::
519 * GNAT.Traceback (g-traceb.ads)::
520 * GNAT.Traceback.Symbolic (g-trasym.ads)::
521 * GNAT.UTF_32 (g-utf_32.ads)::
522 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
523 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
524 * GNAT.Wide_String_Split (g-wistsp.ads)::
525 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
526 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
527 * Interfaces.C.Extensions (i-cexten.ads)::
528 * Interfaces.C.Streams (i-cstrea.ads)::
529 * Interfaces.CPP (i-cpp.ads)::
530 * Interfaces.Packed_Decimal (i-pacdec.ads)::
531 * Interfaces.VxWorks (i-vxwork.ads)::
532 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
533 * System.Address_Image (s-addima.ads)::
534 * System.Assertions (s-assert.ads)::
535 * System.Memory (s-memory.ads)::
536 * System.Partition_Interface (s-parint.ads)::
537 * System.Pool_Global (s-pooglo.ads)::
538 * System.Pool_Local (s-pooloc.ads)::
539 * System.Restrictions (s-restri.ads)::
540 * System.Rident (s-rident.ads)::
541 * System.Strings.Stream_Ops (s-ststop.ads)::
542 * System.Task_Info (s-tasinf.ads)::
543 * System.Wch_Cnv (s-wchcnv.ads)::
544 * System.Wch_Con (s-wchcon.ads)::
546 Text_IO
548 * Text_IO Stream Pointer Positioning::
549 * Text_IO Reading and Writing Non-Regular Files::
550 * Get_Immediate::
551 * Treating Text_IO Files as Streams::
552 * Text_IO Extensions::
553 * Text_IO Facilities for Unbounded Strings::
555 Wide_Text_IO
557 * Wide_Text_IO Stream Pointer Positioning::
558 * Wide_Text_IO Reading and Writing Non-Regular Files::
560 Wide_Wide_Text_IO
562 * Wide_Wide_Text_IO Stream Pointer Positioning::
563 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
565 Interfacing to Other Languages
567 * Interfacing to C::
568 * Interfacing to C++::
569 * Interfacing to COBOL::
570 * Interfacing to Fortran::
571 * Interfacing to non-GNAT Ada code::
573 Specialized Needs Annexes
575 Implementation of Specific Ada Features
576 * Machine Code Insertions::
577 * GNAT Implementation of Tasking::
578 * GNAT Implementation of Shared Passive Packages::
579 * Code Generation for Array Aggregates::
580 * The Size of Discriminated Records with Default Discriminants::
581 * Strict Conformance to the Ada Reference Manual::
583 Implementation of Ada 2012 Features
585 Obsolescent Features
587 GNU Free Documentation License
589 Index
590 @end menu
592 @end ifnottex
594 @node About This Guide
595 @unnumbered About This Guide
597 @noindent
598 This manual contains useful information in writing programs using the
599 @value{EDITION} compiler.  It includes information on implementation dependent
600 characteristics of @value{EDITION}, including all the information required by
601 Annex M of the Ada language standard.
603 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
604 Ada 83 compatibility mode.
605 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
606 but you can override with a compiler switch
607 to explicitly specify the language version.
608 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
609 @value{EDITION} User's Guide}, for details on these switches.)
610 Throughout this manual, references to ``Ada'' without a year suffix
611 apply to both the Ada 95 and Ada 2005 versions of the language.
613 Ada is designed to be highly portable.
614 In general, a program will have the same effect even when compiled by
615 different compilers on different platforms.
616 However, since Ada is designed to be used in a
617 wide variety of applications, it also contains a number of system
618 dependent features to be used in interfacing to the external world.
619 @cindex Implementation-dependent features
620 @cindex Portability
622 Note: Any program that makes use of implementation-dependent features
623 may be non-portable.  You should follow good programming practice and
624 isolate and clearly document any sections of your program that make use
625 of these features in a non-portable manner.
627 @ifset PROEDITION
628 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
629 ``GNAT'' in the remainder of this document.
630 @end ifset
632 @menu
633 * What This Reference Manual Contains::
634 * Conventions::
635 * Related Information::
636 @end menu
638 @node What This Reference Manual Contains
639 @unnumberedsec What This Reference Manual Contains
641 @noindent
642 This reference manual contains the following chapters:
644 @itemize @bullet
645 @item
646 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
647 pragmas, which can be used to extend and enhance the functionality of the
648 compiler.
650 @item
651 @ref{Implementation Defined Attributes}, lists GNAT
652 implementation-dependent attributes, which can be used to extend and
653 enhance the functionality of the compiler.
655 @item
656 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
657 implementation-dependent restrictions, which can be used to extend and
658 enhance the functionality of the compiler.
660 @item
661 @ref{Implementation Advice}, provides information on generally
662 desirable behavior which are not requirements that all compilers must
663 follow since it cannot be provided on all systems, or which may be
664 undesirable on some systems.
666 @item
667 @ref{Implementation Defined Characteristics}, provides a guide to
668 minimizing implementation dependent features.
670 @item
671 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
672 implemented by GNAT, and how they can be imported into user
673 application programs.
675 @item
676 @ref{Representation Clauses and Pragmas}, describes in detail the
677 way that GNAT represents data, and in particular the exact set
678 of representation clauses and pragmas that is accepted.
680 @item
681 @ref{Standard Library Routines}, provides a listing of packages and a
682 brief description of the functionality that is provided by Ada's
683 extensive set of standard library routines as implemented by GNAT@.
685 @item
686 @ref{The Implementation of Standard I/O}, details how the GNAT
687 implementation of the input-output facilities.
689 @item
690 @ref{The GNAT Library}, is a catalog of packages that complement
691 the Ada predefined library.
693 @item
694 @ref{Interfacing to Other Languages}, describes how programs
695 written in Ada using GNAT can be interfaced to other programming
696 languages.
698 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
699 of the specialized needs annexes.
701 @item
702 @ref{Implementation of Specific Ada Features}, discusses issues related
703 to GNAT's implementation of machine code insertions, tasking, and several
704 other features.
706 @item
707 @ref{Implementation of Ada 2012 Features}, describes the status of the
708 GNAT implementation of the Ada 2012 language standard.
710 @item
711 @ref{Obsolescent Features} documents implementation dependent features,
712 including pragmas and attributes, which are considered obsolescent, since
713 there are other preferred ways of achieving the same results. These
714 obsolescent forms are retained for backwards compatibility.
716 @end itemize
718 @cindex Ada 95 Language Reference Manual
719 @cindex Ada 2005 Language Reference Manual
720 @noindent
721 This reference manual assumes a basic familiarity with the Ada 95 language, as
722 described in the International Standard ANSI/ISO/IEC-8652:1995,
723 January 1995.
724 It does not require knowledge of the new features introduced by Ada 2005,
725 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
726 and Amendment 1).
727 Both reference manuals are included in the GNAT documentation
728 package.
730 @node Conventions
731 @unnumberedsec Conventions
732 @cindex Conventions, typographical
733 @cindex Typographical conventions
735 @noindent
736 Following are examples of the typographical and graphic conventions used
737 in this guide:
739 @itemize @bullet
740 @item
741 @code{Functions}, @code{utility program names}, @code{standard names},
742 and @code{classes}.
744 @item
745 @code{Option flags}
747 @item
748 @file{File names}, @samp{button names}, and @samp{field names}.
750 @item
751 @code{Variables}, @env{environment variables}, and @var{metasyntactic
752 variables}.
754 @item
755 @emph{Emphasis}.
757 @item
758 [optional information or parameters]
760 @item
761 Examples are described by text
762 @smallexample
763 and then shown this way.
764 @end smallexample
765 @end itemize
767 @noindent
768 Commands that are entered by the user are preceded in this manual by the
769 characters @samp{$ } (dollar sign followed by space).  If your system uses this
770 sequence as a prompt, then the commands will appear exactly as you see them
771 in the manual.  If your system uses some other prompt, then the command will
772 appear with the @samp{$} replaced by whatever prompt character you are using.
774 @node Related Information
775 @unnumberedsec Related Information
776 @noindent
777 See the following documents for further information on GNAT:
779 @itemize @bullet
780 @item
781 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
782 @value{EDITION} User's Guide}, which provides information on how to use the
783 GNAT compiler system.
785 @item
786 @cite{Ada 95 Reference Manual}, which contains all reference
787 material for the Ada 95 programming language.
789 @item
790 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
791 of the Ada 95 standard.  The annotations describe
792 detailed aspects of the design decision, and in particular contain useful
793 sections on Ada 83 compatibility.
795 @item
796 @cite{Ada 2005 Reference Manual}, which contains all reference
797 material for the Ada 2005 programming language.
799 @item
800 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
801 of the Ada 2005 standard.  The annotations describe
802 detailed aspects of the design decision, and in particular contain useful
803 sections on Ada 83 and Ada 95 compatibility.
805 @item
806 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
807 which contains specific information on compatibility between GNAT and
808 DEC Ada 83 systems.
810 @item
811 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
812 describes in detail the pragmas and attributes provided by the DEC Ada 83
813 compiler system.
815 @end itemize
817 @node Implementation Defined Pragmas
818 @chapter Implementation Defined Pragmas
820 @noindent
821 Ada defines a set of pragmas that can be used to supply additional
822 information to the compiler.  These language defined pragmas are
823 implemented in GNAT and work as described in the Ada Reference Manual.
825 In addition, Ada allows implementations to define additional pragmas
826 whose meaning is defined by the implementation.  GNAT provides a number
827 of these implementation-defined pragmas, which can be used to extend
828 and enhance the functionality of the compiler.  This section of the GNAT
829 Reference Manual describes these additional pragmas.
831 Note that any program using these pragmas might not be portable to other
832 compilers (although GNAT implements this set of pragmas on all
833 platforms).  Therefore if portability to other compilers is an important
834 consideration, the use of these pragmas should be minimized.
836 @menu
837 * Pragma Abort_Defer::
838 * Pragma Ada_83::
839 * Pragma Ada_95::
840 * Pragma Ada_05::
841 * Pragma Ada_2005::
842 * Pragma Ada_12::
843 * Pragma Ada_2012::
844 * Pragma Annotate::
845 * Pragma Assert::
846 * Pragma Assertion_Policy::
847 * Pragma Assume_No_Invalid_Values::
848 * Pragma Ast_Entry::
849 * Pragma C_Pass_By_Copy::
850 * Pragma Check::
851 * Pragma Check_Name::
852 * Pragma Check_Policy::
853 * Pragma Comment::
854 * Pragma Common_Object::
855 * Pragma Compile_Time_Error::
856 * Pragma Compile_Time_Warning::
857 * Pragma Compiler_Unit::
858 * Pragma Complete_Representation::
859 * Pragma Complex_Representation::
860 * Pragma Component_Alignment::
861 * Pragma Contract_Case::
862 * Pragma Convention_Identifier::
863 * Pragma CPP_Class::
864 * Pragma CPP_Constructor::
865 * Pragma CPP_Virtual::
866 * Pragma CPP_Vtable::
867 * Pragma Debug::
868 * Pragma Debug_Policy::
869 * Pragma Detect_Blocking::
870 * Pragma Elaboration_Checks::
871 * Pragma Eliminate::
872 * Pragma Export_Exception::
873 * Pragma Export_Function::
874 * Pragma Export_Object::
875 * Pragma Export_Procedure::
876 * Pragma Export_Value::
877 * Pragma Export_Valued_Procedure::
878 * Pragma Extend_System::
879 * Pragma Extensions_Allowed::
880 * Pragma External::
881 * Pragma External_Name_Casing::
882 * Pragma Fast_Math::
883 * Pragma Favor_Top_Level::
884 * Pragma Finalize_Storage_Only::
885 * Pragma Float_Representation::
886 * Pragma Ident::
887 * Pragma Implemented::
888 * Pragma Implicit_Packing::
889 * Pragma Import_Exception::
890 * Pragma Import_Function::
891 * Pragma Import_Object::
892 * Pragma Import_Procedure::
893 * Pragma Import_Valued_Procedure::
894 * Pragma Initialize_Scalars::
895 * Pragma Inline_Always::
896 * Pragma Inline_Generic::
897 * Pragma Interface::
898 * Pragma Interface_Name::
899 * Pragma Interrupt_Handler::
900 * Pragma Interrupt_State::
901 * Pragma Invariant::
902 * Pragma Keep_Names::
903 * Pragma License::
904 * Pragma Link_With::
905 * Pragma Linker_Alias::
906 * Pragma Linker_Constructor::
907 * Pragma Linker_Destructor::
908 * Pragma Linker_Section::
909 * Pragma Long_Float::
910 * Pragma Machine_Attribute::
911 * Pragma Main::
912 * Pragma Main_Storage::
913 * Pragma No_Body::
914 * Pragma No_Return::
915 * Pragma No_Strict_Aliasing::
916 * Pragma Normalize_Scalars::
917 * Pragma Obsolescent::
918 * Pragma Optimize_Alignment::
919 * Pragma Ordered::
920 * Pragma Overflow_Checks::
921 * Pragma Passive::
922 * Pragma Persistent_BSS::
923 * Pragma Polling::
924 * Pragma Postcondition::
925 * Pragma Precondition::
926 * Pragma Profile (Ravenscar)::
927 * Pragma Profile (Restricted)::
928 * Pragma Psect_Object::
929 * Pragma Pure_Function::
930 * Pragma Remote_Access_Type::
931 * Pragma Restriction_Warnings::
932 * Pragma Shared::
933 * Pragma Short_Circuit_And_Or::
934 * Pragma Short_Descriptors::
935 * Pragma Simple_Storage_Pool_Type::
936 * Pragma Source_File_Name::
937 * Pragma Source_File_Name_Project::
938 * Pragma Source_Reference::
939 * Pragma Static_Elaboration_Desired::
940 * Pragma Stream_Convert::
941 * Pragma Style_Checks::
942 * Pragma Subtitle::
943 * Pragma Suppress::
944 * Pragma Suppress_All::
945 * Pragma Suppress_Exception_Locations::
946 * Pragma Suppress_Initialization::
947 * Pragma Task_Info::
948 * Pragma Task_Name::
949 * Pragma Task_Storage::
950 * Pragma Test_Case::
951 * Pragma Thread_Local_Storage::
952 * Pragma Time_Slice::
953 * Pragma Title::
954 * Pragma Unchecked_Union::
955 * Pragma Unimplemented_Unit::
956 * Pragma Universal_Aliasing ::
957 * Pragma Universal_Data::
958 * Pragma Unmodified::
959 * Pragma Unreferenced::
960 * Pragma Unreferenced_Objects::
961 * Pragma Unreserve_All_Interrupts::
962 * Pragma Unsuppress::
963 * Pragma Use_VADS_Size::
964 * Pragma Validity_Checks::
965 * Pragma Volatile::
966 * Pragma Warnings::
967 * Pragma Weak_External::
968 * Pragma Wide_Character_Encoding::
969 @end menu
971 @node Pragma Abort_Defer
972 @unnumberedsec Pragma Abort_Defer
973 @findex Abort_Defer
974 @cindex Deferring aborts
975 @noindent
976 Syntax:
977 @smallexample
978 pragma Abort_Defer;
979 @end smallexample
981 @noindent
982 This pragma must appear at the start of the statement sequence of a
983 handled sequence of statements (right after the @code{begin}).  It has
984 the effect of deferring aborts for the sequence of statements (but not
985 for the declarations or handlers, if any, associated with this statement
986 sequence).
988 @node Pragma Ada_83
989 @unnumberedsec Pragma Ada_83
990 @findex Ada_83
991 @noindent
992 Syntax:
993 @smallexample @c ada
994 pragma Ada_83;
995 @end smallexample
997 @noindent
998 A configuration pragma that establishes Ada 83 mode for the unit to
999 which it applies, regardless of the mode set by the command line
1000 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1001 the syntax and semantics of Ada 83, as defined in the original Ada
1002 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1003 and Ada 2005 are not recognized, optional package bodies are allowed,
1004 and generics may name types with unknown discriminants without using
1005 the @code{(<>)} notation.  In addition, some but not all of the additional
1006 restrictions of Ada 83 are enforced.
1008 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1009 Ada 83 code to be compiled and adapted to GNAT with less effort.
1010 Secondly, it aids in keeping code backwards compatible with Ada 83.
1011 However, there is no guarantee that code that is processed correctly
1012 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1013 83 compiler, since GNAT does not enforce all the additional checks
1014 required by Ada 83.
1016 @node Pragma Ada_95
1017 @unnumberedsec Pragma Ada_95
1018 @findex Ada_95
1019 @noindent
1020 Syntax:
1021 @smallexample @c ada
1022 pragma Ada_95;
1023 @end smallexample
1025 @noindent
1026 A configuration pragma that establishes Ada 95 mode for the unit to which
1027 it applies, regardless of the mode set by the command line switches.
1028 This mode is set automatically for the @code{Ada} and @code{System}
1029 packages and their children, so you need not specify it in these
1030 contexts.  This pragma is useful when writing a reusable component that
1031 itself uses Ada 95 features, but which is intended to be usable from
1032 either Ada 83 or Ada 95 programs.
1034 @node Pragma Ada_05
1035 @unnumberedsec Pragma Ada_05
1036 @findex Ada_05
1037 @noindent
1038 Syntax:
1039 @smallexample @c ada
1040 pragma Ada_05;
1041 @end smallexample
1043 @noindent
1044 A configuration pragma that establishes Ada 2005 mode for the unit to which
1045 it applies, regardless of the mode set by the command line switches.
1046 This pragma is useful when writing a reusable component that
1047 itself uses Ada 2005 features, but which is intended to be usable from
1048 either Ada 83 or Ada 95 programs.
1050 @node Pragma Ada_2005
1051 @unnumberedsec Pragma Ada_2005
1052 @findex Ada_2005
1053 @noindent
1054 Syntax:
1055 @smallexample @c ada
1056 pragma Ada_2005;
1057 @end smallexample
1059 @noindent
1060 This configuration pragma is a synonym for pragma Ada_05 and has the
1061 same syntax and effect.
1063 @node Pragma Ada_12
1064 @unnumberedsec Pragma Ada_12
1065 @findex Ada_12
1066 @noindent
1067 Syntax:
1068 @smallexample @c ada
1069 pragma Ada_12;
1070 @end smallexample
1072 @noindent
1073 A configuration pragma that establishes Ada 2012 mode for the unit to which
1074 it applies, regardless of the mode set by the command line switches.
1075 This mode is set automatically for the @code{Ada} and @code{System}
1076 packages and their children, so you need not specify it in these
1077 contexts.  This pragma is useful when writing a reusable component that
1078 itself uses Ada 2012 features, but which is intended to be usable from
1079 Ada 83, Ada 95, or Ada 2005 programs.
1081 @node Pragma Ada_2012
1082 @unnumberedsec Pragma Ada_2012
1083 @findex Ada_2005
1084 @noindent
1085 Syntax:
1086 @smallexample @c ada
1087 pragma Ada_2012;
1088 @end smallexample
1090 @noindent
1091 This configuration pragma is a synonym for pragma Ada_12 and has the
1092 same syntax and effect.
1094 @node Pragma Annotate
1095 @unnumberedsec Pragma Annotate
1096 @findex Annotate
1097 @noindent
1098 Syntax:
1099 @smallexample @c ada
1100 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1102 ARG ::= NAME | EXPRESSION
1103 @end smallexample
1105 @noindent
1106 This pragma is used to annotate programs.  @var{identifier} identifies
1107 the type of annotation.  GNAT verifies that it is an identifier, but does
1108 not otherwise analyze it. The second optional identifier is also left
1109 unanalyzed, and by convention is used to control the action of the tool to
1110 which the annotation is addressed.  The remaining @var{arg} arguments
1111 can be either string literals or more generally expressions.
1112 String literals are assumed to be either of type
1113 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1114 depending on the character literals they contain.
1115 All other kinds of arguments are analyzed as expressions, and must be
1116 unambiguous.
1118 The analyzed pragma is retained in the tree, but not otherwise processed
1119 by any part of the GNAT compiler, except to generate corresponding note
1120 lines in the generated ALI file. For the format of these note lines, see
1121 the compiler source file lib-writ.ads. This pragma is intended for use by
1122 external tools, including ASIS@. The use of pragma Annotate does not
1123 affect the compilation process in any way. This pragma may be used as
1124 a configuration pragma.
1126 @node Pragma Assert
1127 @unnumberedsec Pragma Assert
1128 @findex Assert
1129 @noindent
1130 Syntax:
1131 @smallexample @c ada
1132 pragma Assert (
1133   boolean_EXPRESSION
1134   [, string_EXPRESSION]);
1135 @end smallexample
1137 @noindent
1138 The effect of this pragma depends on whether the corresponding command
1139 line switch is set to activate assertions.  The pragma expands into code
1140 equivalent to the following:
1142 @smallexample @c ada
1143 if assertions-enabled then
1144    if not boolean_EXPRESSION then
1145       System.Assertions.Raise_Assert_Failure
1146         (string_EXPRESSION);
1147    end if;
1148 end if;
1149 @end smallexample
1151 @noindent
1152 The string argument, if given, is the message that will be associated
1153 with the exception occurrence if the exception is raised.  If no second
1154 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1155 where @var{file} is the name of the source file containing the assert,
1156 and @var{nnn} is the line number of the assert.  A pragma is not a
1157 statement, so if a statement sequence contains nothing but a pragma
1158 assert, then a null statement is required in addition, as in:
1160 @smallexample @c ada
1161 @dots{}
1162 if J > 3 then
1163    pragma Assert (K > 3, "Bad value for K");
1164    null;
1165 end if;
1166 @end smallexample
1168 @noindent
1169 Note that, as with the @code{if} statement to which it is equivalent, the
1170 type of the expression is either @code{Standard.Boolean}, or any type derived
1171 from this standard type.
1173 If assertions are disabled (switch @option{-gnata} not used), then there
1174 is no run-time effect (and in particular, any side effects from the
1175 expression will not occur at run time).  (The expression is still
1176 analyzed at compile time, and may cause types to be frozen if they are
1177 mentioned here for the first time).
1179 If assertions are enabled, then the given expression is tested, and if
1180 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1181 which results in the raising of @code{Assert_Failure} with the given message.
1183 You should generally avoid side effects in the expression arguments of
1184 this pragma, because these side effects will turn on and off with the
1185 setting of the assertions mode, resulting in assertions that have an
1186 effect on the program.  However, the expressions are analyzed for
1187 semantic correctness whether or not assertions are enabled, so turning
1188 assertions on and off cannot affect the legality of a program.
1190 Note that the implementation defined policy @code{DISABLE}, given in a
1191 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1193 Note: this is a standard language-defined pragma in versions
1194 of Ada from 2005 on. In GNAT, it is implemented in all versions
1195 of Ada, and the DISABLE policy is an implementation-defined
1196 addition.
1199 @node Pragma Assertion_Policy
1200 @unnumberedsec Pragma Assertion_Policy
1201 @findex Debug_Policy
1202 @noindent
1203 Syntax:
1205 @smallexample @c ada
1206 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1207 @end smallexample
1209 @noindent
1210 If the argument is @code{CHECK}, then assertions are enabled.
1211 If the argument is @code{IGNORE}, then assertions are ignored.
1212 This pragma overrides the effect of the @option{-gnata} switch on the
1213 command line.
1215 Assertions are of three kinds:
1217 @itemize @bullet
1218 @item
1219 Pragma @code{Assert}.
1220 @item
1221 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1222 postconditions, type invariants and (sub)type predicates.
1223 @item
1224 Corresponding pragmas for type invariants and (sub)type predicates.
1225 @end itemize
1227 The implementation defined policy @code{DISABLE} is like
1228 @code{IGNORE} except that it completely disables semantic
1229 checking of the argument to @code{pragma Assert}. This may
1230 be useful when the pragma argument references subprograms
1231 in a with'ed package which is replaced by a dummy package
1232 for the final build.
1234 Note: this is a standard language-defined pragma in versions
1235 of Ada from 2005 on. In GNAT, it is implemented in all versions
1236 of Ada, and the DISABLE policy is an implementation-defined
1237 addition.
1239 @node Pragma Assume_No_Invalid_Values
1240 @unnumberedsec Pragma Assume_No_Invalid_Values
1241 @findex Assume_No_Invalid_Values
1242 @cindex Invalid representations
1243 @cindex Invalid values
1244 @noindent
1245 Syntax:
1246 @smallexample @c ada
1247 pragma Assume_No_Invalid_Values (On | Off);
1248 @end smallexample
1250 @noindent
1251 This is a configuration pragma that controls the assumptions made by the
1252 compiler about the occurrence of invalid representations (invalid values)
1253 in the code.
1255 The default behavior (corresponding to an Off argument for this pragma), is
1256 to assume that values may in general be invalid unless the compiler can
1257 prove they are valid. Consider the following example:
1259 @smallexample @c ada
1260 V1 : Integer range 1 .. 10;
1261 V2 : Integer range 11 .. 20;
1263 for J in V2 .. V1 loop
1264    ...
1265 end loop;
1266 @end smallexample
1268 @noindent
1269 if V1 and V2 have valid values, then the loop is known at compile
1270 time not to execute since the lower bound must be greater than the
1271 upper bound. However in default mode, no such assumption is made,
1272 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1273 is given, the compiler will assume that any occurrence of a variable
1274 other than in an explicit @code{'Valid} test always has a valid
1275 value, and the loop above will be optimized away.
1277 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1278 you know your code is free of uninitialized variables and other
1279 possible sources of invalid representations, and may result in
1280 more efficient code. A program that accesses an invalid representation
1281 with this pragma in effect is erroneous, so no guarantees can be made
1282 about its behavior.
1284 It is peculiar though permissible to use this pragma in conjunction
1285 with validity checking (-gnatVa). In such cases, accessing invalid
1286 values will generally give an exception, though formally the program
1287 is erroneous so there are no guarantees that this will always be the
1288 case, and it is recommended that these two options not be used together.
1290 @node Pragma Ast_Entry
1291 @unnumberedsec Pragma Ast_Entry
1292 @cindex OpenVMS
1293 @findex Ast_Entry
1294 @noindent
1295 Syntax:
1296 @smallexample @c ada
1297 pragma AST_Entry (entry_IDENTIFIER);
1298 @end smallexample
1300 @noindent
1301 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1302 argument is the simple name of a single entry; at most one @code{AST_Entry}
1303 pragma is allowed for any given entry.  This pragma must be used in
1304 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1305 the entry declaration and in the same task type specification or single task
1306 as the entry to which it applies.  This pragma specifies that the given entry
1307 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1308 resulting from an OpenVMS system service call.  The pragma does not affect
1309 normal use of the entry.  For further details on this pragma, see the
1310 DEC Ada Language Reference Manual, section 9.12a.
1312 @node Pragma C_Pass_By_Copy
1313 @unnumberedsec Pragma C_Pass_By_Copy
1314 @cindex Passing by copy
1315 @findex C_Pass_By_Copy
1316 @noindent
1317 Syntax:
1318 @smallexample @c ada
1319 pragma C_Pass_By_Copy
1320   ([Max_Size =>] static_integer_EXPRESSION);
1321 @end smallexample
1323 @noindent
1324 Normally the default mechanism for passing C convention records to C
1325 convention subprograms is to pass them by reference, as suggested by RM
1326 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1327 this default, by requiring that record formal parameters be passed by
1328 copy if all of the following conditions are met:
1330 @itemize @bullet
1331 @item
1332 The size of the record type does not exceed the value specified for
1333 @code{Max_Size}.
1334 @item
1335 The record type has @code{Convention C}.
1336 @item
1337 The formal parameter has this record type, and the subprogram has a
1338 foreign (non-Ada) convention.
1339 @end itemize
1341 @noindent
1342 If these conditions are met the argument is passed by copy, i.e.@: in a
1343 manner consistent with what C expects if the corresponding formal in the
1344 C prototype is a struct (rather than a pointer to a struct).
1346 You can also pass records by copy by specifying the convention
1347 @code{C_Pass_By_Copy} for the record type, or by using the extended
1348 @code{Import} and @code{Export} pragmas, which allow specification of
1349 passing mechanisms on a parameter by parameter basis.
1351 @node Pragma Check
1352 @unnumberedsec Pragma Check
1353 @cindex Assertions
1354 @cindex Named assertions
1355 @findex Check
1356 @noindent
1357 Syntax:
1358 @smallexample @c ada
1359 pragma Check (
1360      [Name    =>] Identifier,
1361      [Check   =>] Boolean_EXPRESSION
1362   [, [Message =>] string_EXPRESSION] );
1363 @end smallexample
1365 @noindent
1366 This pragma is similar to the predefined pragma @code{Assert} except that an
1367 extra identifier argument is present. In conjunction with pragma
1368 @code{Check_Policy}, this can be used to define groups of assertions that can
1369 be independently controlled. The identifier @code{Assertion} is special, it
1370 refers to the normal set of pragma @code{Assert} statements. The identifiers
1371 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1372 names, so these three names would normally not be used directly in a pragma
1373 @code{Check}.
1375 Checks introduced by this pragma are normally deactivated by default. They can
1376 be activated either by the command line option @option{-gnata}, which turns on
1377 all checks, or individually controlled using pragma @code{Check_Policy}.
1379 @node Pragma Check_Name
1380 @unnumberedsec Pragma Check_Name
1381 @cindex Defining check names
1382 @cindex Check names, defining
1383 @findex Check_Name
1384 @noindent
1385 Syntax:
1386 @smallexample @c ada
1387 pragma Check_Name (check_name_IDENTIFIER);
1388 @end smallexample
1390 @noindent
1391 This is a configuration pragma that defines a new implementation
1392 defined check name (unless IDENTIFIER matches one of the predefined
1393 check names, in which case the pragma has no effect). Check names
1394 are global to a partition, so if two or more configuration pragmas
1395 are present in a partition mentioning the same name, only one new
1396 check name is introduced.
1398 An implementation defined check name introduced with this pragma may
1399 be used in only three contexts: @code{pragma Suppress},
1400 @code{pragma Unsuppress},
1401 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1402 any of these three cases, the check name must be visible. A check
1403 name is visible if it is in the configuration pragmas applying to
1404 the current unit, or if it appears at the start of any unit that
1405 is part of the dependency set of the current unit (e.g., units that
1406 are mentioned in @code{with} clauses).
1408 @node Pragma Check_Policy
1409 @unnumberedsec Pragma Check_Policy
1410 @cindex Controlling assertions
1411 @cindex Assertions, control
1412 @cindex Check pragma control
1413 @cindex Named assertions
1414 @findex Check
1415 @noindent
1416 Syntax:
1417 @smallexample @c ada
1418 pragma Check_Policy
1419  ([Name   =>] Identifier,
1420   [Policy =>] POLICY_IDENTIFIER);
1422 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1423 @end smallexample
1425 @noindent
1426 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1427 except that it controls sets of named assertions introduced using the
1428 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1429 @code{Assertion_Policy}) can be used within a declarative part, in which case
1430 it controls the status to the end of the corresponding construct (in a manner
1431 identical to pragma @code{Suppress)}.
1433 The identifier given as the first argument corresponds to a name used in
1434 associated @code{Check} pragmas. For example, if the pragma:
1436 @smallexample @c ada
1437 pragma Check_Policy (Critical_Error, OFF);
1438 @end smallexample
1440 @noindent
1441 is given, then subsequent @code{Check} pragmas whose first argument is also
1442 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1443 controls the behavior of normal assertions (thus a pragma
1444 @code{Check_Policy} with this identifier is similar to the normal
1445 @code{Assertion_Policy} pragma except that it can appear within a
1446 declarative part).
1448 The special identifiers @code{Precondition} and @code{Postcondition} control
1449 the status of preconditions and postconditions given as pragmas.
1450 If a @code{Precondition} pragma
1451 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1452 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1453 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1454 are recognized. Note that preconditions and postconditions given as aspects
1455 are controlled differently, either by the @code{Assertion_Policy} pragma or
1456 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1458 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1459 to turn on corresponding checks. The default for a set of checks for which no
1460 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1461 @option{-gnata} is given, which turns on all checks by default.
1463 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1464 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1465 compatibility with the standard @code{Assertion_Policy} pragma.
1467 The implementation defined policy @code{DISABLE} is like
1468 @code{OFF} except that it completely disables semantic
1469 checking of the argument to the corresponding class of
1470 pragmas. This may be useful when the pragma arguments reference
1471 subprograms in a with'ed package which is replaced by a dummy package
1472 for the final build.
1474 @node Pragma Comment
1475 @unnumberedsec Pragma Comment
1476 @findex Comment
1477 @noindent
1478 Syntax:
1480 @smallexample @c ada
1481 pragma Comment (static_string_EXPRESSION);
1482 @end smallexample
1484 @noindent
1485 This is almost identical in effect to pragma @code{Ident}.  It allows the
1486 placement of a comment into the object file and hence into the
1487 executable file if the operating system permits such usage.  The
1488 difference is that @code{Comment}, unlike @code{Ident}, has
1489 no limitations on placement of the pragma (it can be placed
1490 anywhere in the main source unit), and if more than one pragma
1491 is used, all comments are retained.
1493 @node Pragma Common_Object
1494 @unnumberedsec Pragma Common_Object
1495 @findex Common_Object
1496 @noindent
1497 Syntax:
1499 @smallexample @c ada
1500 pragma Common_Object (
1501      [Internal =>] LOCAL_NAME
1502   [, [External =>] EXTERNAL_SYMBOL]
1503   [, [Size     =>] EXTERNAL_SYMBOL] );
1505 EXTERNAL_SYMBOL ::=
1506   IDENTIFIER
1507 | static_string_EXPRESSION
1508 @end smallexample
1510 @noindent
1511 This pragma enables the shared use of variables stored in overlaid
1512 linker areas corresponding to the use of @code{COMMON}
1513 in Fortran.  The single
1514 object @var{LOCAL_NAME} is assigned to the area designated by
1515 the @var{External} argument.
1516 You may define a record to correspond to a series
1517 of fields.  The @var{Size} argument
1518 is syntax checked in GNAT, but otherwise ignored.
1520 @code{Common_Object} is not supported on all platforms.  If no
1521 support is available, then the code generator will issue a message
1522 indicating that the necessary attribute for implementation of this
1523 pragma is not available.
1525 @node Pragma Compile_Time_Error
1526 @unnumberedsec Pragma Compile_Time_Error
1527 @findex Compile_Time_Error
1528 @noindent
1529 Syntax:
1531 @smallexample @c ada
1532 pragma Compile_Time_Error
1533          (boolean_EXPRESSION, static_string_EXPRESSION);
1534 @end smallexample
1536 @noindent
1537 This pragma can be used to generate additional compile time
1538 error messages. It
1539 is particularly useful in generics, where errors can be issued for
1540 specific problematic instantiations. The first parameter is a boolean
1541 expression. The pragma is effective only if the value of this expression
1542 is known at compile time, and has the value True. The set of expressions
1543 whose values are known at compile time includes all static boolean
1544 expressions, and also other values which the compiler can determine
1545 at compile time (e.g., the size of a record type set by an explicit
1546 size representation clause, or the value of a variable which was
1547 initialized to a constant and is known not to have been modified).
1548 If these conditions are met, an error message is generated using
1549 the value given as the second argument. This string value may contain
1550 embedded ASCII.LF characters to break the message into multiple lines.
1552 @node Pragma Compile_Time_Warning
1553 @unnumberedsec Pragma Compile_Time_Warning
1554 @findex Compile_Time_Warning
1555 @noindent
1556 Syntax:
1558 @smallexample @c ada
1559 pragma Compile_Time_Warning
1560          (boolean_EXPRESSION, static_string_EXPRESSION);
1561 @end smallexample
1563 @noindent
1564 Same as pragma Compile_Time_Error, except a warning is issued instead
1565 of an error message. Note that if this pragma is used in a package that
1566 is with'ed by a client, the client will get the warning even though it
1567 is issued by a with'ed package (normally warnings in with'ed units are
1568 suppressed, but this is a special exception to that rule).
1570 One typical use is within a generic where compile time known characteristics
1571 of formal parameters are tested, and warnings given appropriately. Another use
1572 with a first parameter of True is to warn a client about use of a package,
1573 for example that it is not fully implemented.
1575 @node Pragma Compiler_Unit
1576 @unnumberedsec Pragma Compiler_Unit
1577 @findex Compiler_Unit
1578 @noindent
1579 Syntax:
1581 @smallexample @c ada
1582 pragma Compiler_Unit;
1583 @end smallexample
1585 @noindent
1586 This pragma is intended only for internal use in the GNAT run-time library.
1587 It indicates that the unit is used as part of the compiler build. The effect
1588 is to disallow constructs (raise with message, conditional expressions etc)
1589 that would cause trouble when bootstrapping using an older version of GNAT.
1590 For the exact list of restrictions, see the compiler sources and references
1591 to Is_Compiler_Unit.
1593 @node Pragma Complete_Representation
1594 @unnumberedsec Pragma Complete_Representation
1595 @findex Complete_Representation
1596 @noindent
1597 Syntax:
1599 @smallexample @c ada
1600 pragma Complete_Representation;
1601 @end smallexample
1603 @noindent
1604 This pragma must appear immediately within a record representation
1605 clause. Typical placements are before the first component clause
1606 or after the last component clause. The effect is to give an error
1607 message if any component is missing a component clause. This pragma
1608 may be used to ensure that a record representation clause is
1609 complete, and that this invariant is maintained if fields are
1610 added to the record in the future.
1612 @node Pragma Complex_Representation
1613 @unnumberedsec Pragma Complex_Representation
1614 @findex Complex_Representation
1615 @noindent
1616 Syntax:
1618 @smallexample @c ada
1619 pragma Complex_Representation
1620         ([Entity =>] LOCAL_NAME);
1621 @end smallexample
1623 @noindent
1624 The @var{Entity} argument must be the name of a record type which has
1625 two fields of the same floating-point type.  The effect of this pragma is
1626 to force gcc to use the special internal complex representation form for
1627 this record, which may be more efficient.  Note that this may result in
1628 the code for this type not conforming to standard ABI (application
1629 binary interface) requirements for the handling of record types.  For
1630 example, in some environments, there is a requirement for passing
1631 records by pointer, and the use of this pragma may result in passing
1632 this type in floating-point registers.
1634 @node Pragma Component_Alignment
1635 @unnumberedsec Pragma Component_Alignment
1636 @cindex Alignments of components
1637 @findex Component_Alignment
1638 @noindent
1639 Syntax:
1641 @smallexample @c ada
1642 pragma Component_Alignment (
1643      [Form =>] ALIGNMENT_CHOICE
1644   [, [Name =>] type_LOCAL_NAME]);
1646 ALIGNMENT_CHOICE ::=
1647   Component_Size
1648 | Component_Size_4
1649 | Storage_Unit
1650 | Default
1651 @end smallexample
1653 @noindent
1654 Specifies the alignment of components in array or record types.
1655 The meaning of the @var{Form} argument is as follows:
1657 @table @code
1658 @findex Component_Size
1659 @item Component_Size
1660 Aligns scalar components and subcomponents of the array or record type
1661 on boundaries appropriate to their inherent size (naturally
1662 aligned).  For example, 1-byte components are aligned on byte boundaries,
1663 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1664 integer components are aligned on 4-byte boundaries and so on.  These
1665 alignment rules correspond to the normal rules for C compilers on all
1666 machines except the VAX@.
1668 @findex Component_Size_4
1669 @item Component_Size_4
1670 Naturally aligns components with a size of four or fewer
1671 bytes.  Components that are larger than 4 bytes are placed on the next
1672 4-byte boundary.
1674 @findex Storage_Unit
1675 @item Storage_Unit
1676 Specifies that array or record components are byte aligned, i.e.@:
1677 aligned on boundaries determined by the value of the constant
1678 @code{System.Storage_Unit}.
1680 @cindex OpenVMS
1681 @item Default
1682 Specifies that array or record components are aligned on default
1683 boundaries, appropriate to the underlying hardware or operating system or
1684 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1685 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1686 the @code{Default} choice is the same as @code{Component_Size} (natural
1687 alignment).
1688 @end table
1690 @noindent
1691 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1692 refer to a local record or array type, and the specified alignment
1693 choice applies to the specified type.  The use of
1694 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1695 @code{Component_Alignment} pragma to be ignored.  The use of
1696 @code{Component_Alignment} together with a record representation clause
1697 is only effective for fields not specified by the representation clause.
1699 If the @code{Name} parameter is absent, the pragma can be used as either
1700 a configuration pragma, in which case it applies to one or more units in
1701 accordance with the normal rules for configuration pragmas, or it can be
1702 used within a declarative part, in which case it applies to types that
1703 are declared within this declarative part, or within any nested scope
1704 within this declarative part.  In either case it specifies the alignment
1705 to be applied to any record or array type which has otherwise standard
1706 representation.
1708 If the alignment for a record or array type is not specified (using
1709 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1710 clause), the GNAT uses the default alignment as described previously.
1712 @node Pragma Contract_Case
1713 @unnumberedsec Pragma Contract_Case
1714 @cindex Contract cases
1715 @findex Contract_Case
1716 @noindent
1717 Syntax:
1719 @smallexample @c ada
1720 pragma Contract_Case (
1721    [Name     =>] static_string_Expression
1722   ,[Mode     =>] (Nominal | Robustness)
1723  [, Requires =>  Boolean_Expression]
1724  [, Ensures  =>  Boolean_Expression]);
1725 @end smallexample
1727 @noindent
1728 The @code{Contract_Case} pragma allows defining fine-grain specifications
1729 that can complement or replace the contract given by a precondition and a
1730 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1731 by testing and formal verification tools. The compiler checks its validity and,
1732 depending on the assertion policy at the point of declaration of the pragma,
1733 it may insert a check in the executable. For code generation, the contract
1734 case
1736 @smallexample @c ada
1737 pragma Contract_Case (
1738    Name     => ...
1739    Mode     => ...
1740    Requires => R,
1741    Ensures  => E);
1742 @end smallexample
1744 @noindent
1745 is equivalent to
1747 @smallexample @c ada
1748 pragma Postcondition (not R'Old or else E);
1749 @end smallexample
1751 @noindent
1752 which is also equivalent to (in Ada 2012)
1754 @smallexample @c ada
1755 pragma Postcondition (if R'Old then E);
1756 @end smallexample
1758 @noindent
1759 expressing that, whenever condition @code{R} is satisfied on entry to the
1760 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1762 A precondition @code{P} and postcondition @code{Q} can also be
1763 expressed as contract cases:
1765 @smallexample @c ada
1766 pragma Contract_Case (
1767    Name     => "Replace precondition",
1768    Mode     => Nominal,
1769    Requires => not P,
1770    Ensures  => False);
1771 pragma Contract_Case (
1772    Name     => "Replace postcondition",
1773    Mode     => Nominal,
1774    Requires => P,
1775    Ensures  => Q);
1776 @end smallexample
1778 @code{Contract_Case} pragmas may only appear immediately following the
1779 (separate) declaration of a subprogram in a package declaration, inside
1780 a package spec unit. Only other pragmas may intervene (that is appear
1781 between the subprogram declaration and a contract case).
1783 The compiler checks that boolean expressions given in @code{Requires} and
1784 @code{Ensures} are valid, where the rules for @code{Requires} are the
1785 same as the rule for an expression in @code{Precondition} and the rules
1786 for @code{Ensures} are the same as the rule for an expression in
1787 @code{Postcondition}. In particular, attributes @code{'Old} and
1788 @code{'Result} can only be used within the @code{Ensures}
1789 expression. The following is an example of use within a package spec:
1791 @smallexample @c ada
1792 package Math_Functions is
1793    ...
1794    function Sqrt (Arg : Float) return Float;
1795    pragma Contract_Case (Name     => "Small argument",
1796                          Mode     => Nominal,
1797                          Requires => Arg < 100,
1798                          Ensures  => Sqrt'Result < 10);
1799    ...
1800 end Math_Functions;
1801 @end smallexample
1803 @noindent
1804 The meaning of a contract case is that, whenever the associated subprogram is
1805 executed in a context where @code{Requires} holds, then @code{Ensures}
1806 should hold when the subprogram returns. Mode @code{Nominal} indicates
1807 that the input context should also satisfy the precondition of the
1808 subprogram, and the output context should also satisfy its
1809 postcondition. More @code{Robustness} indicates that the precondition and
1810 postcondition of the subprogram should be ignored for this contract case,
1811 which is mostly useful when testing such a contract using a testing tool
1812 that understands contract cases.
1814 @node Pragma Convention_Identifier
1815 @unnumberedsec Pragma Convention_Identifier
1816 @findex Convention_Identifier
1817 @cindex Conventions, synonyms
1818 @noindent
1819 Syntax:
1821 @smallexample @c ada
1822 pragma Convention_Identifier (
1823          [Name =>]       IDENTIFIER,
1824          [Convention =>] convention_IDENTIFIER);
1825 @end smallexample
1827 @noindent
1828 This pragma provides a mechanism for supplying synonyms for existing
1829 convention identifiers. The @code{Name} identifier can subsequently
1830 be used as a synonym for the given convention in other pragmas (including
1831 for example pragma @code{Import} or another @code{Convention_Identifier}
1832 pragma). As an example of the use of this, suppose you had legacy code
1833 which used Fortran77 as the identifier for Fortran. Then the pragma:
1835 @smallexample @c ada
1836 pragma Convention_Identifier (Fortran77, Fortran);
1837 @end smallexample
1839 @noindent
1840 would allow the use of the convention identifier @code{Fortran77} in
1841 subsequent code, avoiding the need to modify the sources. As another
1842 example, you could use this to parameterize convention requirements
1843 according to systems. Suppose you needed to use @code{Stdcall} on
1844 windows systems, and @code{C} on some other system, then you could
1845 define a convention identifier @code{Library} and use a single
1846 @code{Convention_Identifier} pragma to specify which convention
1847 would be used system-wide.
1849 @node Pragma CPP_Class
1850 @unnumberedsec Pragma CPP_Class
1851 @findex CPP_Class
1852 @cindex Interfacing with C++
1853 @noindent
1854 Syntax:
1856 @smallexample @c ada
1857 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1858 @end smallexample
1860 @noindent
1861 The argument denotes an entity in the current declarative region that is
1862 declared as a record type. It indicates that the type corresponds to an
1863 externally declared C++ class type, and is to be laid out the same way
1864 that C++ would lay out the type. If the C++ class has virtual primitives
1865 then the record must be declared as a tagged record type.
1867 Types for which @code{CPP_Class} is specified do not have assignment or
1868 equality operators defined (such operations can be imported or declared
1869 as subprograms as required). Initialization is allowed only by constructor
1870 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1871 limited if not explicitly declared as limited or derived from a limited
1872 type, and an error is issued in that case.
1874 See @ref{Interfacing to C++} for related information.
1876 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1877 for backward compatibility but its functionality is available
1878 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1880 @node Pragma CPP_Constructor
1881 @unnumberedsec Pragma CPP_Constructor
1882 @cindex Interfacing with C++
1883 @findex CPP_Constructor
1884 @noindent
1885 Syntax:
1887 @smallexample @c ada
1888 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1889   [, [External_Name =>] static_string_EXPRESSION ]
1890   [, [Link_Name     =>] static_string_EXPRESSION ]);
1891 @end smallexample
1893 @noindent
1894 This pragma identifies an imported function (imported in the usual way
1895 with pragma @code{Import}) as corresponding to a C++ constructor. If
1896 @code{External_Name} and @code{Link_Name} are not specified then the
1897 @code{Entity} argument is a name that must have been previously mentioned
1898 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1899 must be of one of the following forms:
1901 @itemize @bullet
1902 @item
1903 @code{function @var{Fname} return @var{T}}
1905 @itemize @bullet
1906 @item
1907 @code{function @var{Fname} return @var{T}'Class}
1909 @item
1910 @code{function @var{Fname} (@dots{}) return @var{T}}
1911 @end itemize
1913 @item
1914 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1915 @end itemize
1917 @noindent
1918 where @var{T} is a limited record type imported from C++ with pragma
1919 @code{Import} and @code{Convention} = @code{CPP}.
1921 The first two forms import the default constructor, used when an object
1922 of type @var{T} is created on the Ada side with no explicit constructor.
1923 The latter two forms cover all the non-default constructors of the type.
1924 See the @value{EDITION} User's Guide for details.
1926 If no constructors are imported, it is impossible to create any objects
1927 on the Ada side and the type is implicitly declared abstract.
1929 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1930 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
1931 GCC switch).
1932 See @ref{Interfacing to C++} for more related information.
1934 Note: The use of functions returning class-wide types for constructors is
1935 currently obsolete. They are supported for backward compatibility. The
1936 use of functions returning the type T leave the Ada sources more clear
1937 because the imported C++ constructors always return an object of type T;
1938 that is, they never return an object whose type is a descendant of type T.
1940 @node Pragma CPP_Virtual
1941 @unnumberedsec Pragma CPP_Virtual
1942 @cindex Interfacing to C++
1943 @findex CPP_Virtual
1944 @noindent
1945 This pragma is now obsolete has has no effect because GNAT generates
1946 the same object layout than the G++ compiler.
1948 See @ref{Interfacing to C++} for related information.
1950 @node Pragma CPP_Vtable
1951 @unnumberedsec Pragma CPP_Vtable
1952 @cindex Interfacing with C++
1953 @findex CPP_Vtable
1954 @noindent
1955 This pragma is now obsolete has has no effect because GNAT generates
1956 the same object layout than the G++ compiler.
1958 See @ref{Interfacing to C++} for related information.
1960 @node Pragma Debug
1961 @unnumberedsec Pragma Debug
1962 @findex Debug
1963 @noindent
1964 Syntax:
1966 @smallexample @c ada
1967 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1969 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1970   PROCEDURE_NAME
1971 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1972 @end smallexample
1974 @noindent
1975 The procedure call argument has the syntactic form of an expression, meeting
1976 the syntactic requirements for pragmas.
1978 If debug pragmas are not enabled or if the condition is present and evaluates
1979 to False, this pragma has no effect. If debug pragmas are enabled, the
1980 semantics of the pragma is exactly equivalent to the procedure call statement
1981 corresponding to the argument with a terminating semicolon. Pragmas are
1982 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1983 intersperse calls to debug procedures in the middle of declarations. Debug
1984 pragmas can be enabled either by use of the command line switch @option{-gnata}
1985 or by use of the configuration pragma @code{Debug_Policy}.
1987 @node Pragma Debug_Policy
1988 @unnumberedsec Pragma Debug_Policy
1989 @findex Debug_Policy
1990 @noindent
1991 Syntax:
1993 @smallexample @c ada
1994 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1995 @end smallexample
1997 @noindent
1998 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1999 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2000 This pragma overrides the effect of the @option{-gnata} switch on the
2001 command line.
2003 The implementation defined policy @code{DISABLE} is like
2004 @code{IGNORE} except that it completely disables semantic
2005 checking of the argument to @code{pragma Debug}. This may
2006 be useful when the pragma argument references subprograms
2007 in a with'ed package which is replaced by a dummy package
2008 for the final build.
2010 @node Pragma Detect_Blocking
2011 @unnumberedsec Pragma Detect_Blocking
2012 @findex Detect_Blocking
2013 @noindent
2014 Syntax:
2016 @smallexample @c ada
2017 pragma Detect_Blocking;
2018 @end smallexample
2020 @noindent
2021 This is a configuration pragma that forces the detection of potentially
2022 blocking operations within a protected operation, and to raise Program_Error
2023 if that happens.
2025 @node Pragma Elaboration_Checks
2026 @unnumberedsec Pragma Elaboration_Checks
2027 @cindex Elaboration control
2028 @findex Elaboration_Checks
2029 @noindent
2030 Syntax:
2032 @smallexample @c ada
2033 pragma Elaboration_Checks (Dynamic | Static);
2034 @end smallexample
2036 @noindent
2037 This is a configuration pragma that provides control over the
2038 elaboration model used by the compilation affected by the
2039 pragma.  If the parameter is @code{Dynamic},
2040 then the dynamic elaboration
2041 model described in the Ada Reference Manual is used, as though
2042 the @option{-gnatE} switch had been specified on the command
2043 line.  If the parameter is @code{Static}, then the default GNAT static
2044 model is used.  This configuration pragma overrides the setting
2045 of the command line.  For full details on the elaboration models
2046 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2047 gnat_ugn, @value{EDITION} User's Guide}.
2049 @node Pragma Eliminate
2050 @unnumberedsec Pragma Eliminate
2051 @cindex Elimination of unused subprograms
2052 @findex Eliminate
2053 @noindent
2054 Syntax:
2056 @smallexample @c ada
2057 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2058                   [Source_Location =>] STRING_LITERAL);
2059 @end smallexample
2061 @noindent
2062 The string literal given for the source location is a string which
2063 specifies the line number of the occurrence of the entity, using
2064 the syntax for SOURCE_TRACE given below:
2066 @smallexample @c ada
2067  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2069  LBRACKET         ::= [
2070  RBRACKET         ::= ]
2072  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2074  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2075 @end smallexample
2077 @noindent
2078 Spaces around the colon in a @code{Source_Reference} are optional.
2080 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2081 explicit subprogram declaration, where the @code{entity} name in this
2082 designator appears on the source line specified by the source location.
2084 The source trace that is given as the @code{Source_Location} shall obey the
2085 following rules. The @code{FILE_NAME} is the short name (with no directory
2086 information) of an Ada source file, given using exactly the required syntax
2087 for the underlying file system (e.g. case is important if the underlying
2088 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2089 number of the occurrence of the @code{entity}
2090 as a decimal literal without an exponent or point. If an @code{entity} is not
2091 declared in a generic instantiation (this includes generic subprogram
2092 instances), the source trace includes only one source reference. If an entity
2093 is declared inside a generic instantiation, its source trace (when parsing
2094 from left to right) starts with the source location of the declaration of the
2095 entity in the generic unit and ends with the source location of the
2096 instantiation (it is given in square brackets). This approach is recursively
2097 used in case of nested instantiations: the rightmost (nested most deeply in
2098 square brackets) element of the source trace is the location of the outermost
2099 instantiation, the next to left element is the location of the next (first
2100 nested) instantiation in the code of the corresponding generic unit, and so
2101 on, and the leftmost element (that is out of any square brackets) is the
2102 location of the declaration of the entity to eliminate in a generic unit.
2104 Note that the @code{Source_Location} argument specifies which of a set of
2105 similarly named entities is being eliminated, dealing both with overloading,
2106 and also appearence of the same entity name in different scopes.
2108 This pragma indicates that the given entity is not used in the program to be
2109 compiled and built. The effect of the pragma is to allow the compiler to
2110 eliminate the code or data associated with the named entity. Any reference to
2111 an eliminated entity causes a compile-time or link-time error.
2113 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2114 in a system-independent manner, with unused entities eliminated, without
2115 needing to modify the source text. Normally the required set of
2116 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2118 Any source file change that removes, splits, or
2119 adds lines may make the set of Eliminate pragmas invalid because their
2120 @code{Source_Location} argument values may get out of date.
2122 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2123 operation. In this case all the subprograms to which the given operation can
2124 dispatch are considered to be unused (are never called as a result of a direct
2125 or a dispatching call).
2127 @node Pragma Export_Exception
2128 @unnumberedsec Pragma Export_Exception
2129 @cindex OpenVMS
2130 @findex Export_Exception
2131 @noindent
2132 Syntax:
2134 @smallexample @c ada
2135 pragma Export_Exception (
2136      [Internal =>] LOCAL_NAME
2137   [, [External =>] EXTERNAL_SYMBOL]
2138   [, [Form     =>] Ada | VMS]
2139   [, [Code     =>] static_integer_EXPRESSION]);
2141 EXTERNAL_SYMBOL ::=
2142   IDENTIFIER
2143 | static_string_EXPRESSION
2144 @end smallexample
2146 @noindent
2147 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2148 causes the specified exception to be propagated outside of the Ada program,
2149 so that it can be handled by programs written in other OpenVMS languages.
2150 This pragma establishes an external name for an Ada exception and makes the
2151 name available to the OpenVMS Linker as a global symbol.  For further details
2152 on this pragma, see the
2153 DEC Ada Language Reference Manual, section 13.9a3.2.
2155 @node Pragma Export_Function
2156 @unnumberedsec Pragma Export_Function
2157 @cindex Argument passing mechanisms
2158 @findex Export_Function
2160 @noindent
2161 Syntax:
2163 @smallexample @c ada
2164 pragma Export_Function (
2165      [Internal         =>] LOCAL_NAME
2166   [, [External         =>] EXTERNAL_SYMBOL]
2167   [, [Parameter_Types  =>] PARAMETER_TYPES]
2168   [, [Result_Type      =>] result_SUBTYPE_MARK]
2169   [, [Mechanism        =>] MECHANISM]
2170   [, [Result_Mechanism =>] MECHANISM_NAME]);
2172 EXTERNAL_SYMBOL ::=
2173   IDENTIFIER
2174 | static_string_EXPRESSION
2175 | ""
2177 PARAMETER_TYPES ::=
2178   null
2179 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2181 TYPE_DESIGNATOR ::=
2182   subtype_NAME
2183 | subtype_Name ' Access
2185 MECHANISM ::=
2186   MECHANISM_NAME
2187 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2189 MECHANISM_ASSOCIATION ::=
2190   [formal_parameter_NAME =>] MECHANISM_NAME
2192 MECHANISM_NAME ::=
2193   Value
2194 | Reference
2195 | Descriptor [([Class =>] CLASS_NAME)]
2196 | Short_Descriptor [([Class =>] CLASS_NAME)]
2198 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2199 @end smallexample
2201 @noindent
2202 Use this pragma to make a function externally callable and optionally
2203 provide information on mechanisms to be used for passing parameter and
2204 result values.  We recommend, for the purposes of improving portability,
2205 this pragma always be used in conjunction with a separate pragma
2206 @code{Export}, which must precede the pragma @code{Export_Function}.
2207 GNAT does not require a separate pragma @code{Export}, but if none is
2208 present, @code{Convention Ada} is assumed, which is usually
2209 not what is wanted, so it is usually appropriate to use this
2210 pragma in conjunction with a @code{Export} or @code{Convention}
2211 pragma that specifies the desired foreign convention.
2212 Pragma @code{Export_Function}
2213 (and @code{Export}, if present) must appear in the same declarative
2214 region as the function to which they apply.
2216 @var{internal_name} must uniquely designate the function to which the
2217 pragma applies.  If more than one function name exists of this name in
2218 the declarative part you must use the @code{Parameter_Types} and
2219 @code{Result_Type} parameters is mandatory to achieve the required
2220 unique designation.  @var{subtype_mark}s in these parameters must
2221 exactly match the subtypes in the corresponding function specification,
2222 using positional notation to match parameters with subtype marks.
2223 The form with an @code{'Access} attribute can be used to match an
2224 anonymous access parameter.
2226 @cindex OpenVMS
2227 @cindex Passing by descriptor
2228 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2229 The default behavior for Export_Function is to accept either 64bit or
2230 32bit descriptors unless short_descriptor is specified, then only 32bit
2231 descriptors are accepted.
2233 @cindex Suppressing external name
2234 Special treatment is given if the EXTERNAL is an explicit null
2235 string or a static string expressions that evaluates to the null
2236 string. In this case, no external name is generated. This form
2237 still allows the specification of parameter mechanisms.
2239 @node Pragma Export_Object
2240 @unnumberedsec Pragma Export_Object
2241 @findex Export_Object
2242 @noindent
2243 Syntax:
2245 @smallexample @c ada
2246 pragma Export_Object
2247       [Internal =>] LOCAL_NAME
2248    [, [External =>] EXTERNAL_SYMBOL]
2249    [, [Size     =>] EXTERNAL_SYMBOL]
2251 EXTERNAL_SYMBOL ::=
2252   IDENTIFIER
2253 | static_string_EXPRESSION
2254 @end smallexample
2256 @noindent
2257 This pragma designates an object as exported, and apart from the
2258 extended rules for external symbols, is identical in effect to the use of
2259 the normal @code{Export} pragma applied to an object.  You may use a
2260 separate Export pragma (and you probably should from the point of view
2261 of portability), but it is not required.  @var{Size} is syntax checked,
2262 but otherwise ignored by GNAT@.
2264 @node Pragma Export_Procedure
2265 @unnumberedsec Pragma Export_Procedure
2266 @findex Export_Procedure
2267 @noindent
2268 Syntax:
2270 @smallexample @c ada
2271 pragma Export_Procedure (
2272      [Internal        =>] LOCAL_NAME
2273   [, [External        =>] EXTERNAL_SYMBOL]
2274   [, [Parameter_Types =>] PARAMETER_TYPES]
2275   [, [Mechanism       =>] MECHANISM]);
2277 EXTERNAL_SYMBOL ::=
2278   IDENTIFIER
2279 | static_string_EXPRESSION
2280 | ""
2282 PARAMETER_TYPES ::=
2283   null
2284 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2286 TYPE_DESIGNATOR ::=
2287   subtype_NAME
2288 | subtype_Name ' Access
2290 MECHANISM ::=
2291   MECHANISM_NAME
2292 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2294 MECHANISM_ASSOCIATION ::=
2295   [formal_parameter_NAME =>] MECHANISM_NAME
2297 MECHANISM_NAME ::=
2298   Value
2299 | Reference
2300 | Descriptor [([Class =>] CLASS_NAME)]
2301 | Short_Descriptor [([Class =>] CLASS_NAME)]
2303 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2304 @end smallexample
2306 @noindent
2307 This pragma is identical to @code{Export_Function} except that it
2308 applies to a procedure rather than a function and the parameters
2309 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2310 GNAT does not require a separate pragma @code{Export}, but if none is
2311 present, @code{Convention Ada} is assumed, which is usually
2312 not what is wanted, so it is usually appropriate to use this
2313 pragma in conjunction with a @code{Export} or @code{Convention}
2314 pragma that specifies the desired foreign convention.
2316 @cindex OpenVMS
2317 @cindex Passing by descriptor
2318 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2319 The default behavior for Export_Procedure is to accept either 64bit or
2320 32bit descriptors unless short_descriptor is specified, then only 32bit
2321 descriptors are accepted.
2323 @cindex Suppressing external name
2324 Special treatment is given if the EXTERNAL is an explicit null
2325 string or a static string expressions that evaluates to the null
2326 string. In this case, no external name is generated. This form
2327 still allows the specification of parameter mechanisms.
2329 @node Pragma Export_Value
2330 @unnumberedsec Pragma Export_Value
2331 @findex Export_Value
2332 @noindent
2333 Syntax:
2335 @smallexample @c ada
2336 pragma Export_Value (
2337   [Value     =>] static_integer_EXPRESSION,
2338   [Link_Name =>] static_string_EXPRESSION);
2339 @end smallexample
2341 @noindent
2342 This pragma serves to export a static integer value for external use.
2343 The first argument specifies the value to be exported. The Link_Name
2344 argument specifies the symbolic name to be associated with the integer
2345 value. This pragma is useful for defining a named static value in Ada
2346 that can be referenced in assembly language units to be linked with
2347 the application. This pragma is currently supported only for the
2348 AAMP target and is ignored for other targets.
2350 @node Pragma Export_Valued_Procedure
2351 @unnumberedsec Pragma Export_Valued_Procedure
2352 @findex Export_Valued_Procedure
2353 @noindent
2354 Syntax:
2356 @smallexample @c ada
2357 pragma Export_Valued_Procedure (
2358      [Internal        =>] LOCAL_NAME
2359   [, [External        =>] EXTERNAL_SYMBOL]
2360   [, [Parameter_Types =>] PARAMETER_TYPES]
2361   [, [Mechanism       =>] MECHANISM]);
2363 EXTERNAL_SYMBOL ::=
2364   IDENTIFIER
2365 | static_string_EXPRESSION
2366 | ""
2368 PARAMETER_TYPES ::=
2369   null
2370 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2372 TYPE_DESIGNATOR ::=
2373   subtype_NAME
2374 | subtype_Name ' Access
2376 MECHANISM ::=
2377   MECHANISM_NAME
2378 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2380 MECHANISM_ASSOCIATION ::=
2381   [formal_parameter_NAME =>] MECHANISM_NAME
2383 MECHANISM_NAME ::=
2384   Value
2385 | Reference
2386 | Descriptor [([Class =>] CLASS_NAME)]
2387 | Short_Descriptor [([Class =>] CLASS_NAME)]
2389 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2390 @end smallexample
2392 @noindent
2393 This pragma is identical to @code{Export_Procedure} except that the
2394 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2395 mode @code{OUT}, and externally the subprogram is treated as a function
2396 with this parameter as the result of the function.  GNAT provides for
2397 this capability to allow the use of @code{OUT} and @code{IN OUT}
2398 parameters in interfacing to external functions (which are not permitted
2399 in Ada functions).
2400 GNAT does not require a separate pragma @code{Export}, but if none is
2401 present, @code{Convention Ada} is assumed, which is almost certainly
2402 not what is wanted since the whole point of this pragma is to interface
2403 with foreign language functions, so it is usually appropriate to use this
2404 pragma in conjunction with a @code{Export} or @code{Convention}
2405 pragma that specifies the desired foreign convention.
2407 @cindex OpenVMS
2408 @cindex Passing by descriptor
2409 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2410 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2411 32bit descriptors unless short_descriptor is specified, then only 32bit
2412 descriptors are accepted.
2414 @cindex Suppressing external name
2415 Special treatment is given if the EXTERNAL is an explicit null
2416 string or a static string expressions that evaluates to the null
2417 string. In this case, no external name is generated. This form
2418 still allows the specification of parameter mechanisms.
2420 @node Pragma Extend_System
2421 @unnumberedsec Pragma Extend_System
2422 @cindex @code{system}, extending
2423 @cindex Dec Ada 83
2424 @findex Extend_System
2425 @noindent
2426 Syntax:
2428 @smallexample @c ada
2429 pragma Extend_System ([Name =>] IDENTIFIER);
2430 @end smallexample
2432 @noindent
2433 This pragma is used to provide backwards compatibility with other
2434 implementations that extend the facilities of package @code{System}.  In
2435 GNAT, @code{System} contains only the definitions that are present in
2436 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2437 implementation, provide many extensions to package @code{System}.
2439 For each such implementation accommodated by this pragma, GNAT provides a
2440 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2441 implementation, which provides the required additional definitions.  You
2442 can use this package in two ways.  You can @code{with} it in the normal
2443 way and access entities either by selection or using a @code{use}
2444 clause.  In this case no special processing is required.
2446 However, if existing code contains references such as
2447 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2448 definitions provided in package @code{System}, you may use this pragma
2449 to extend visibility in @code{System} in a non-standard way that
2450 provides greater compatibility with the existing code.  Pragma
2451 @code{Extend_System} is a configuration pragma whose single argument is
2452 the name of the package containing the extended definition
2453 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2454 control of this pragma will be processed using special visibility
2455 processing that looks in package @code{System.Aux_@var{xxx}} where
2456 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2457 package @code{System}, but not found in package @code{System}.
2459 You can use this pragma either to access a predefined @code{System}
2460 extension supplied with the compiler, for example @code{Aux_DEC} or
2461 you can construct your own extension unit following the above
2462 definition.  Note that such a package is a child of @code{System}
2463 and thus is considered part of the implementation.  To compile
2464 it you will have to use the appropriate switch for compiling
2465 system units.
2466 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2467 for details.
2469 @node Pragma Extensions_Allowed
2470 @unnumberedsec Pragma Extensions_Allowed
2471 @cindex Ada Extensions
2472 @cindex GNAT Extensions
2473 @findex Extensions_Allowed
2474 @noindent
2475 Syntax:
2477 @smallexample @c ada
2478 pragma Extensions_Allowed (On | Off);
2479 @end smallexample
2481 @noindent
2482 This configuration pragma enables or disables the implementation
2483 extension mode (the use of Off as a parameter cancels the effect
2484 of the @option{-gnatX} command switch).
2486 In extension mode, the latest version of the Ada language is
2487 implemented (currently Ada 2012), and in addition a small number
2488 of GNAT specific extensions are recognized as follows:
2490 @table @asis
2491 @item Constrained attribute for generic objects
2492 The @code{Constrained} attribute is permitted for objects of
2493 generic types. The result indicates if the corresponding actual
2494 is constrained.
2496 @end table
2498 @node Pragma External
2499 @unnumberedsec Pragma External
2500 @findex External
2501 @noindent
2502 Syntax:
2504 @smallexample @c ada
2505 pragma External (
2506   [   Convention    =>] convention_IDENTIFIER,
2507   [   Entity        =>] LOCAL_NAME
2508   [, [External_Name =>] static_string_EXPRESSION ]
2509   [, [Link_Name     =>] static_string_EXPRESSION ]);
2510 @end smallexample
2512 @noindent
2513 This pragma is identical in syntax and semantics to pragma
2514 @code{Export} as defined in the Ada Reference Manual.  It is
2515 provided for compatibility with some Ada 83 compilers that
2516 used this pragma for exactly the same purposes as pragma
2517 @code{Export} before the latter was standardized.
2519 @node Pragma External_Name_Casing
2520 @unnumberedsec Pragma External_Name_Casing
2521 @cindex Dec Ada 83 casing compatibility
2522 @cindex External Names, casing
2523 @cindex Casing of External names
2524 @findex External_Name_Casing
2525 @noindent
2526 Syntax:
2528 @smallexample @c ada
2529 pragma External_Name_Casing (
2530   Uppercase | Lowercase
2531   [, Uppercase | Lowercase | As_Is]);
2532 @end smallexample
2534 @noindent
2535 This pragma provides control over the casing of external names associated
2536 with Import and Export pragmas.  There are two cases to consider:
2538 @table @asis
2539 @item Implicit external names
2540 Implicit external names are derived from identifiers.  The most common case
2541 arises when a standard Ada Import or Export pragma is used with only two
2542 arguments, as in:
2544 @smallexample @c ada
2545    pragma Import (C, C_Routine);
2546 @end smallexample
2548 @noindent
2549 Since Ada is a case-insensitive language, the spelling of the identifier in
2550 the Ada source program does not provide any information on the desired
2551 casing of the external name, and so a convention is needed.  In GNAT the
2552 default treatment is that such names are converted to all lower case
2553 letters.  This corresponds to the normal C style in many environments.
2554 The first argument of pragma @code{External_Name_Casing} can be used to
2555 control this treatment.  If @code{Uppercase} is specified, then the name
2556 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2557 then the normal default of all lower case letters will be used.
2559 This same implicit treatment is also used in the case of extended DEC Ada 83
2560 compatible Import and Export pragmas where an external name is explicitly
2561 specified using an identifier rather than a string.
2563 @item Explicit external names
2564 Explicit external names are given as string literals.  The most common case
2565 arises when a standard Ada Import or Export pragma is used with three
2566 arguments, as in:
2568 @smallexample @c ada
2569 pragma Import (C, C_Routine, "C_routine");
2570 @end smallexample
2572 @noindent
2573 In this case, the string literal normally provides the exact casing required
2574 for the external name.  The second argument of pragma
2575 @code{External_Name_Casing} may be used to modify this behavior.
2576 If @code{Uppercase} is specified, then the name
2577 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2578 then the name will be forced to all lowercase letters.  A specification of
2579 @code{As_Is} provides the normal default behavior in which the casing is
2580 taken from the string provided.
2581 @end table
2583 @noindent
2584 This pragma may appear anywhere that a pragma is valid.  In particular, it
2585 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2586 case it applies to all subsequent compilations, or it can be used as a program
2587 unit pragma, in which case it only applies to the current unit, or it can
2588 be used more locally to control individual Import/Export pragmas.
2590 It is primarily intended for use with OpenVMS systems, where many
2591 compilers convert all symbols to upper case by default.  For interfacing to
2592 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2593 the pragma:
2595 @smallexample @c ada
2596 pragma External_Name_Casing (Uppercase, Uppercase);
2597 @end smallexample
2599 @noindent
2600 to enforce the upper casing of all external symbols.
2602 @node Pragma Fast_Math
2603 @unnumberedsec Pragma Fast_Math
2604 @findex Fast_Math
2605 @noindent
2606 Syntax:
2608 @smallexample @c ada
2609 pragma Fast_Math;
2610 @end smallexample
2612 @noindent
2613 This is a configuration pragma which activates a mode in which speed is
2614 considered more important for floating-point operations than absolutely
2615 accurate adherence to the requirements of the standard. Currently the
2616 following operations are affected:
2618 @table @asis
2619 @item Complex Multiplication
2620 The normal simple formula for complex multiplication can result in intermediate
2621 overflows for numbers near the end of the range. The Ada standard requires that
2622 this situation be detected and corrected by scaling, but in Fast_Math mode such
2623 cases will simply result in overflow. Note that to take advantage of this you
2624 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2625 under control of the pragma, rather than use the preinstantiated versions.
2626 @end table
2628 @node Pragma Favor_Top_Level
2629 @unnumberedsec Pragma Favor_Top_Level
2630 @findex Favor_Top_Level
2631 @noindent
2632 Syntax:
2634 @smallexample @c ada
2635 pragma Favor_Top_Level (type_NAME);
2636 @end smallexample
2638 @noindent
2639 The named type must be an access-to-subprogram type. This pragma is an
2640 efficiency hint to the compiler, regarding the use of 'Access or
2641 'Unrestricted_Access on nested (non-library-level) subprograms. The
2642 pragma means that nested subprograms are not used with this type, or
2643 are rare, so that the generated code should be efficient in the
2644 top-level case. When this pragma is used, dynamically generated
2645 trampolines may be used on some targets for nested subprograms.
2646 See also the No_Implicit_Dynamic_Code restriction.
2648 @node Pragma Finalize_Storage_Only
2649 @unnumberedsec Pragma Finalize_Storage_Only
2650 @findex Finalize_Storage_Only
2651 @noindent
2652 Syntax:
2654 @smallexample @c ada
2655 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2656 @end smallexample
2658 @noindent
2659 This pragma allows the compiler not to emit a Finalize call for objects
2660 defined at the library level.  This is mostly useful for types where
2661 finalization is only used to deal with storage reclamation since in most
2662 environments it is not necessary to reclaim memory just before terminating
2663 execution, hence the name.
2665 @node Pragma Float_Representation
2666 @unnumberedsec Pragma Float_Representation
2667 @cindex OpenVMS
2668 @findex Float_Representation
2669 @noindent
2670 Syntax:
2672 @smallexample @c ada
2673 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2675 FLOAT_REP ::= VAX_Float | IEEE_Float
2676 @end smallexample
2678 @noindent
2679 In the one argument form, this pragma is a configuration pragma which
2680 allows control over the internal representation chosen for the predefined
2681 floating point types declared in the packages @code{Standard} and
2682 @code{System}. On all systems other than OpenVMS, the argument must
2683 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2684 argument may be @code{VAX_Float} to specify the use of the VAX float
2685 format for the floating-point types in Standard. This requires that
2686 the standard runtime libraries be recompiled.
2688 The two argument form specifies the representation to be used for
2689 the specified floating-point type. On all systems other than OpenVMS,
2690 the argument must
2691 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2692 argument may be @code{VAX_Float} to specify the use of the VAX float
2693 format, as follows:
2695 @itemize @bullet
2696 @item
2697 For digits values up to 6, F float format will be used.
2698 @item
2699 For digits values from 7 to 9, D float format will be used.
2700 @item
2701 For digits values from 10 to 15, G float format will be used.
2702 @item
2703 Digits values above 15 are not allowed.
2704 @end itemize
2706 @node Pragma Ident
2707 @unnumberedsec Pragma Ident
2708 @findex Ident
2709 @noindent
2710 Syntax:
2712 @smallexample @c ada
2713 pragma Ident (static_string_EXPRESSION);
2714 @end smallexample
2716 @noindent
2717 This pragma provides a string identification in the generated object file,
2718 if the system supports the concept of this kind of identification string.
2719 This pragma is allowed only in the outermost declarative part or
2720 declarative items of a compilation unit. If more than one @code{Ident}
2721 pragma is given, only the last one processed is effective.
2722 @cindex OpenVMS
2723 On OpenVMS systems, the effect of the pragma is identical to the effect of
2724 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2725 maximum allowed length is 31 characters, so if it is important to
2726 maintain compatibility with this compiler, you should obey this length
2727 limit.
2729 @node Pragma Implemented
2730 @unnumberedsec Pragma Implemented
2731 @findex Implemented
2732 @noindent
2733 Syntax:
2735 @smallexample @c ada
2736 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2738 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2739 @end smallexample
2741 @noindent
2742 This is an Ada 2012 representation pragma which applies to protected, task
2743 and synchronized interface primitives. The use of pragma Implemented provides
2744 a way to impose a static requirement on the overriding operation by adhering
2745 to one of the three implementation kids: entry, protected procedure or any of
2746 the above.
2748 @smallexample @c ada
2749 type Synch_Iface is synchronized interface;
2750 procedure Prim_Op (Obj : in out Iface) is abstract;
2751 pragma Implemented (Prim_Op, By_Protected_Procedure);
2753 protected type Prot_1 is new Synch_Iface with
2754    procedure Prim_Op;  --  Legal
2755 end Prot_1;
2757 protected type Prot_2 is new Synch_Iface with
2758    entry Prim_Op;      --  Illegal
2759 end Prot_2;
2761 task type Task_Typ is new Synch_Iface with
2762    entry Prim_Op;      --  Illegal
2763 end Task_Typ;
2764 @end smallexample
2766 @noindent
2767 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2768 Implemented determines the runtime behavior of the requeue. Implementation kind
2769 By_Entry guarantees that the action of requeueing will proceed from an entry to
2770 another entry. Implementation kind By_Protected_Procedure transforms the
2771 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2772 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2773 the target's overriding subprogram kind.
2775 @node Pragma Implicit_Packing
2776 @unnumberedsec Pragma Implicit_Packing
2777 @findex Implicit_Packing
2778 @noindent
2779 Syntax:
2781 @smallexample @c ada
2782 pragma Implicit_Packing;
2783 @end smallexample
2785 @noindent
2786 This is a configuration pragma that requests implicit packing for packed
2787 arrays for which a size clause is given but no explicit pragma Pack or
2788 specification of Component_Size is present. It also applies to records
2789 where no record representation clause is present. Consider this example:
2791 @smallexample @c ada
2792 type R is array (0 .. 7) of Boolean;
2793 for R'Size use 8;
2794 @end smallexample
2796 @noindent
2797 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2798 does not change the layout of a composite object. So the Size clause in the
2799 above example is normally rejected, since the default layout of the array uses
2800 8-bit components, and thus the array requires a minimum of 64 bits.
2802 If this declaration is compiled in a region of code covered by an occurrence
2803 of the configuration pragma Implicit_Packing, then the Size clause in this
2804 and similar examples will cause implicit packing and thus be accepted. For
2805 this implicit packing to occur, the type in question must be an array of small
2806 components whose size is known at compile time, and the Size clause must
2807 specify the exact size that corresponds to the length of the array multiplied
2808 by the size in bits of the component type.
2809 @cindex Array packing
2811 Similarly, the following example shows the use in the record case
2813 @smallexample @c ada
2814 type r is record
2815    a, b, c, d, e, f, g, h : boolean;
2816    chr                    : character;
2817 end record;
2818 for r'size use 16;
2819 @end smallexample
2821 @noindent
2822 Without a pragma Pack, each Boolean field requires 8 bits, so the
2823 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2824 sufficient. The use of pragma Implicit_Packing allows this record
2825 declaration to compile without an explicit pragma Pack.
2826 @node Pragma Import_Exception
2827 @unnumberedsec Pragma Import_Exception
2828 @cindex OpenVMS
2829 @findex Import_Exception
2830 @noindent
2831 Syntax:
2833 @smallexample @c ada
2834 pragma Import_Exception (
2835      [Internal =>] LOCAL_NAME
2836   [, [External =>] EXTERNAL_SYMBOL]
2837   [, [Form     =>] Ada | VMS]
2838   [, [Code     =>] static_integer_EXPRESSION]);
2840 EXTERNAL_SYMBOL ::=
2841   IDENTIFIER
2842 | static_string_EXPRESSION
2843 @end smallexample
2845 @noindent
2846 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2847 It allows OpenVMS conditions (for example, from OpenVMS system services or
2848 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2849 The pragma specifies that the exception associated with an exception
2850 declaration in an Ada program be defined externally (in non-Ada code).
2851 For further details on this pragma, see the
2852 DEC Ada Language Reference Manual, section 13.9a.3.1.
2854 @node Pragma Import_Function
2855 @unnumberedsec Pragma Import_Function
2856 @findex Import_Function
2857 @noindent
2858 Syntax:
2860 @smallexample @c ada
2861 pragma Import_Function (
2862      [Internal                 =>] LOCAL_NAME,
2863   [, [External                 =>] EXTERNAL_SYMBOL]
2864   [, [Parameter_Types          =>] PARAMETER_TYPES]
2865   [, [Result_Type              =>] SUBTYPE_MARK]
2866   [, [Mechanism                =>] MECHANISM]
2867   [, [Result_Mechanism         =>] MECHANISM_NAME]
2868   [, [First_Optional_Parameter =>] IDENTIFIER]);
2870 EXTERNAL_SYMBOL ::=
2871   IDENTIFIER
2872 | static_string_EXPRESSION
2874 PARAMETER_TYPES ::=
2875   null
2876 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2878 TYPE_DESIGNATOR ::=
2879   subtype_NAME
2880 | subtype_Name ' Access
2882 MECHANISM ::=
2883   MECHANISM_NAME
2884 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2886 MECHANISM_ASSOCIATION ::=
2887   [formal_parameter_NAME =>] MECHANISM_NAME
2889 MECHANISM_NAME ::=
2890   Value
2891 | Reference
2892 | Descriptor [([Class =>] CLASS_NAME)]
2893 | Short_Descriptor [([Class =>] CLASS_NAME)]
2895 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2896 @end smallexample
2898 @noindent
2899 This pragma is used in conjunction with a pragma @code{Import} to
2900 specify additional information for an imported function.  The pragma
2901 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2902 @code{Import_Function} pragma and both must appear in the same
2903 declarative part as the function specification.
2905 The @var{Internal} argument must uniquely designate
2906 the function to which the
2907 pragma applies.  If more than one function name exists of this name in
2908 the declarative part you must use the @code{Parameter_Types} and
2909 @var{Result_Type} parameters to achieve the required unique
2910 designation.  Subtype marks in these parameters must exactly match the
2911 subtypes in the corresponding function specification, using positional
2912 notation to match parameters with subtype marks.
2913 The form with an @code{'Access} attribute can be used to match an
2914 anonymous access parameter.
2916 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2917 parameters to specify passing mechanisms for the
2918 parameters and result.  If you specify a single mechanism name, it
2919 applies to all parameters.  Otherwise you may specify a mechanism on a
2920 parameter by parameter basis using either positional or named
2921 notation.  If the mechanism is not specified, the default mechanism
2922 is used.
2924 @cindex OpenVMS
2925 @cindex Passing by descriptor
2926 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2927 The default behavior for Import_Function is to pass a 64bit descriptor
2928 unless short_descriptor is specified, then a 32bit descriptor is passed.
2930 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2931 It specifies that the designated parameter and all following parameters
2932 are optional, meaning that they are not passed at the generated code
2933 level (this is distinct from the notion of optional parameters in Ada
2934 where the parameters are passed anyway with the designated optional
2935 parameters).  All optional parameters must be of mode @code{IN} and have
2936 default parameter values that are either known at compile time
2937 expressions, or uses of the @code{'Null_Parameter} attribute.
2939 @node Pragma Import_Object
2940 @unnumberedsec Pragma Import_Object
2941 @findex Import_Object
2942 @noindent
2943 Syntax:
2945 @smallexample @c ada
2946 pragma Import_Object
2947      [Internal =>] LOCAL_NAME
2948   [, [External =>] EXTERNAL_SYMBOL]
2949   [, [Size     =>] EXTERNAL_SYMBOL]);
2951 EXTERNAL_SYMBOL ::=
2952   IDENTIFIER
2953 | static_string_EXPRESSION
2954 @end smallexample
2956 @noindent
2957 This pragma designates an object as imported, and apart from the
2958 extended rules for external symbols, is identical in effect to the use of
2959 the normal @code{Import} pragma applied to an object.  Unlike the
2960 subprogram case, you need not use a separate @code{Import} pragma,
2961 although you may do so (and probably should do so from a portability
2962 point of view).  @var{size} is syntax checked, but otherwise ignored by
2963 GNAT@.
2965 @node Pragma Import_Procedure
2966 @unnumberedsec Pragma Import_Procedure
2967 @findex Import_Procedure
2968 @noindent
2969 Syntax:
2971 @smallexample @c ada
2972 pragma Import_Procedure (
2973      [Internal                 =>] LOCAL_NAME
2974   [, [External                 =>] EXTERNAL_SYMBOL]
2975   [, [Parameter_Types          =>] PARAMETER_TYPES]
2976   [, [Mechanism                =>] MECHANISM]
2977   [, [First_Optional_Parameter =>] IDENTIFIER]);
2979 EXTERNAL_SYMBOL ::=
2980   IDENTIFIER
2981 | static_string_EXPRESSION
2983 PARAMETER_TYPES ::=
2984   null
2985 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2987 TYPE_DESIGNATOR ::=
2988   subtype_NAME
2989 | subtype_Name ' Access
2991 MECHANISM ::=
2992   MECHANISM_NAME
2993 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2995 MECHANISM_ASSOCIATION ::=
2996   [formal_parameter_NAME =>] MECHANISM_NAME
2998 MECHANISM_NAME ::=
2999   Value
3000 | Reference
3001 | Descriptor [([Class =>] CLASS_NAME)]
3002 | Short_Descriptor [([Class =>] CLASS_NAME)]
3004 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3005 @end smallexample
3007 @noindent
3008 This pragma is identical to @code{Import_Function} except that it
3009 applies to a procedure rather than a function and the parameters
3010 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3012 @node Pragma Import_Valued_Procedure
3013 @unnumberedsec Pragma Import_Valued_Procedure
3014 @findex Import_Valued_Procedure
3015 @noindent
3016 Syntax:
3018 @smallexample @c ada
3019 pragma Import_Valued_Procedure (
3020      [Internal                 =>] LOCAL_NAME
3021   [, [External                 =>] EXTERNAL_SYMBOL]
3022   [, [Parameter_Types          =>] PARAMETER_TYPES]
3023   [, [Mechanism                =>] MECHANISM]
3024   [, [First_Optional_Parameter =>] IDENTIFIER]);
3026 EXTERNAL_SYMBOL ::=
3027   IDENTIFIER
3028 | static_string_EXPRESSION
3030 PARAMETER_TYPES ::=
3031   null
3032 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3034 TYPE_DESIGNATOR ::=
3035   subtype_NAME
3036 | subtype_Name ' Access
3038 MECHANISM ::=
3039   MECHANISM_NAME
3040 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3042 MECHANISM_ASSOCIATION ::=
3043   [formal_parameter_NAME =>] MECHANISM_NAME
3045 MECHANISM_NAME ::=
3046   Value
3047 | Reference
3048 | Descriptor [([Class =>] CLASS_NAME)]
3049 | Short_Descriptor [([Class =>] CLASS_NAME)]
3051 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3052 @end smallexample
3054 @noindent
3055 This pragma is identical to @code{Import_Procedure} except that the
3056 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3057 mode @code{OUT}, and externally the subprogram is treated as a function
3058 with this parameter as the result of the function.  The purpose of this
3059 capability is to allow the use of @code{OUT} and @code{IN OUT}
3060 parameters in interfacing to external functions (which are not permitted
3061 in Ada functions).  You may optionally use the @code{Mechanism}
3062 parameters to specify passing mechanisms for the parameters.
3063 If you specify a single mechanism name, it applies to all parameters.
3064 Otherwise you may specify a mechanism on a parameter by parameter
3065 basis using either positional or named notation.  If the mechanism is not
3066 specified, the default mechanism is used.
3068 Note that it is important to use this pragma in conjunction with a separate
3069 pragma Import that specifies the desired convention, since otherwise the
3070 default convention is Ada, which is almost certainly not what is required.
3072 @node Pragma Initialize_Scalars
3073 @unnumberedsec Pragma Initialize_Scalars
3074 @findex Initialize_Scalars
3075 @cindex debugging with Initialize_Scalars
3076 @noindent
3077 Syntax:
3079 @smallexample @c ada
3080 pragma Initialize_Scalars;
3081 @end smallexample
3083 @noindent
3084 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3085 two important differences.  First, there is no requirement for the pragma
3086 to be used uniformly in all units of a partition, in particular, it is fine
3087 to use this just for some or all of the application units of a partition,
3088 without needing to recompile the run-time library.
3090 In the case where some units are compiled with the pragma, and some without,
3091 then a declaration of a variable where the type is defined in package
3092 Standard or is locally declared will always be subject to initialization,
3093 as will any declaration of a scalar variable.  For composite variables,
3094 whether the variable is initialized may also depend on whether the package
3095 in which the type of the variable is declared is compiled with the pragma.
3097 The other important difference is that you can control the value used
3098 for initializing scalar objects.  At bind time, you can select several
3099 options for initialization. You can
3100 initialize with invalid values (similar to Normalize_Scalars, though for
3101 Initialize_Scalars it is not always possible to determine the invalid
3102 values in complex cases like signed component fields with non-standard
3103 sizes). You can also initialize with high or
3104 low values, or with a specified bit pattern.  See the @value{EDITION}
3105 User's Guide for binder options for specifying these cases.
3107 This means that you can compile a program, and then without having to
3108 recompile the program, you can run it with different values being used
3109 for initializing otherwise uninitialized values, to test if your program
3110 behavior depends on the choice.  Of course the behavior should not change,
3111 and if it does, then most likely you have an erroneous reference to an
3112 uninitialized value.
3114 It is even possible to change the value at execution time eliminating even
3115 the need to rebind with a different switch using an environment variable.
3116 See the @value{EDITION} User's Guide for details.
3118 Note that pragma @code{Initialize_Scalars} is particularly useful in
3119 conjunction with the enhanced validity checking that is now provided
3120 in GNAT, which checks for invalid values under more conditions.
3121 Using this feature (see description of the @option{-gnatV} flag in the
3122 @value{EDITION} User's Guide) in conjunction with
3123 pragma @code{Initialize_Scalars}
3124 provides a powerful new tool to assist in the detection of problems
3125 caused by uninitialized variables.
3127 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3128 effect on the generated code. This may cause your code to be
3129 substantially larger. It may also cause an increase in the amount
3130 of stack required, so it is probably a good idea to turn on stack
3131 checking (see description of stack checking in the @value{EDITION}
3132 User's Guide) when using this pragma.
3134 @node Pragma Inline_Always
3135 @unnumberedsec Pragma Inline_Always
3136 @findex Inline_Always
3137 @noindent
3138 Syntax:
3140 @smallexample @c ada
3141 pragma Inline_Always (NAME [, NAME]);
3142 @end smallexample
3144 @noindent
3145 Similar to pragma @code{Inline} except that inlining is not subject to
3146 the use of option @option{-gnatn} and the inlining happens regardless of
3147 whether this option is used.
3149 @node Pragma Inline_Generic
3150 @unnumberedsec Pragma Inline_Generic
3151 @findex Inline_Generic
3152 @noindent
3153 Syntax:
3155 @smallexample @c ada
3156 pragma Inline_Generic (generic_package_NAME);
3157 @end smallexample
3159 @noindent
3160 This is implemented for compatibility with DEC Ada 83 and is recognized,
3161 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
3162 by default when using GNAT@.
3164 @node Pragma Interface
3165 @unnumberedsec Pragma Interface
3166 @findex Interface
3167 @noindent
3168 Syntax:
3170 @smallexample @c ada
3171 pragma Interface (
3172      [Convention    =>] convention_identifier,
3173      [Entity        =>] local_NAME
3174   [, [External_Name =>] static_string_expression]
3175   [, [Link_Name     =>] static_string_expression]);
3176 @end smallexample
3178 @noindent
3179 This pragma is identical in syntax and semantics to
3180 the standard Ada pragma @code{Import}.  It is provided for compatibility
3181 with Ada 83.  The definition is upwards compatible both with pragma
3182 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3183 with some extended implementations of this pragma in certain Ada 83
3184 implementations.  The only difference between pragma @code{Interface}
3185 and pragma @code{Import} is that there is special circuitry to allow
3186 both pragmas to appear for the same subprogram entity (normally it
3187 is illegal to have multiple @code{Import} pragmas. This is useful in
3188 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3189 Ada 83 compilers.
3191 @node Pragma Interface_Name
3192 @unnumberedsec Pragma Interface_Name
3193 @findex Interface_Name
3194 @noindent
3195 Syntax:
3197 @smallexample @c ada
3198 pragma Interface_Name (
3199      [Entity        =>] LOCAL_NAME
3200   [, [External_Name =>] static_string_EXPRESSION]
3201   [, [Link_Name     =>] static_string_EXPRESSION]);
3202 @end smallexample
3204 @noindent
3205 This pragma provides an alternative way of specifying the interface name
3206 for an interfaced subprogram, and is provided for compatibility with Ada
3207 83 compilers that use the pragma for this purpose.  You must provide at
3208 least one of @var{External_Name} or @var{Link_Name}.
3210 @node Pragma Interrupt_Handler
3211 @unnumberedsec Pragma Interrupt_Handler
3212 @findex Interrupt_Handler
3213 @noindent
3214 Syntax:
3216 @smallexample @c ada
3217 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3218 @end smallexample
3220 @noindent
3221 This program unit pragma is supported for parameterless protected procedures
3222 as described in Annex C of the Ada Reference Manual. On the AAMP target
3223 the pragma can also be specified for nonprotected parameterless procedures
3224 that are declared at the library level (which includes procedures
3225 declared at the top level of a library package). In the case of AAMP,
3226 when this pragma is applied to a nonprotected procedure, the instruction
3227 @code{IERET} is generated for returns from the procedure, enabling
3228 maskable interrupts, in place of the normal return instruction.
3230 @node Pragma Interrupt_State
3231 @unnumberedsec Pragma Interrupt_State
3232 @findex Interrupt_State
3233 @noindent
3234 Syntax:
3236 @smallexample @c ada
3237 pragma Interrupt_State
3238  ([Name  =>] value,
3239   [State =>] SYSTEM | RUNTIME | USER);
3240 @end smallexample
3242 @noindent
3243 Normally certain interrupts are reserved to the implementation.  Any attempt
3244 to attach an interrupt causes Program_Error to be raised, as described in
3245 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3246 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3247 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3248 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3249 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3250 Ada exceptions, or used to implement run-time functions such as the
3251 @code{abort} statement and stack overflow checking.
3253 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3254 such uses of interrupts.  It subsumes the functionality of pragma
3255 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3256 available on Windows or VMS.  On all other platforms than VxWorks,
3257 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3258 and may be used to mark interrupts required by the board support package
3259 as reserved.
3261 Interrupts can be in one of three states:
3262 @itemize @bullet
3263 @item System
3265 The interrupt is reserved (no Ada handler can be installed), and the
3266 Ada run-time may not install a handler. As a result you are guaranteed
3267 standard system default action if this interrupt is raised.
3269 @item Runtime
3271 The interrupt is reserved (no Ada handler can be installed). The run time
3272 is allowed to install a handler for internal control purposes, but is
3273 not required to do so.
3275 @item User
3277 The interrupt is unreserved.  The user may install a handler to provide
3278 some other action.
3279 @end itemize
3281 @noindent
3282 These states are the allowed values of the @code{State} parameter of the
3283 pragma.  The @code{Name} parameter is a value of the type
3284 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3285 @code{Ada.Interrupts.Names}.
3287 This is a configuration pragma, and the binder will check that there
3288 are no inconsistencies between different units in a partition in how a
3289 given interrupt is specified. It may appear anywhere a pragma is legal.
3291 The effect is to move the interrupt to the specified state.
3293 By declaring interrupts to be SYSTEM, you guarantee the standard system
3294 action, such as a core dump.
3296 By declaring interrupts to be USER, you guarantee that you can install
3297 a handler.
3299 Note that certain signals on many operating systems cannot be caught and
3300 handled by applications.  In such cases, the pragma is ignored.  See the
3301 operating system documentation, or the value of the array @code{Reserved}
3302 declared in the spec of package @code{System.OS_Interface}.
3304 Overriding the default state of signals used by the Ada runtime may interfere
3305 with an application's runtime behavior in the cases of the synchronous signals,
3306 and in the case of the signal used to implement the @code{abort} statement.
3308 @node Pragma Invariant
3309 @unnumberedsec Pragma Invariant
3310 @findex Invariant
3311 @noindent
3312 Syntax:
3314 @smallexample @c ada
3315 pragma Invariant
3316   ([Entity =>]    private_type_LOCAL_NAME,
3317    [Check  =>]    EXPRESSION
3318    [,[Message =>] String_Expression]);
3319 @end smallexample
3321 @noindent
3322 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3323 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3324 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3325 requires the use of the aspect syntax, which is not available except in 2012
3326 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3327 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3328 note that the aspect Invariant is a synonym in GNAT for the aspect
3329 Type_Invariant, but there is no pragma Type_Invariant.
3331 The pragma must appear within the visible part of the package specification,
3332 after the type to which its Entity argument appears. As with the Invariant
3333 aspect, the Check expression is not analyzed until the end of the visible
3334 part of the package, so it may contain forward references. The Message
3335 argument, if present, provides the exception message used if the invariant
3336 is violated. If no Message parameter is provided, a default message that
3337 identifies the line on which the pragma appears is used.
3339 It is permissible to have multiple Invariants for the same type entity, in
3340 which case they are and'ed together. It is permissible to use this pragma
3341 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3342 invariant pragma for the same entity.
3344 For further details on the use of this pragma, see the Ada 2012 documentation
3345 of the Type_Invariant aspect.
3347 @node Pragma Keep_Names
3348 @unnumberedsec Pragma Keep_Names
3349 @findex Keep_Names
3350 @noindent
3351 Syntax:
3353 @smallexample @c ada
3354 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3355 @end smallexample
3357 @noindent
3358 The @var{LOCAL_NAME} argument
3359 must refer to an enumeration first subtype
3360 in the current declarative part. The effect is to retain the enumeration
3361 literal names for use by @code{Image} and @code{Value} even if a global
3362 @code{Discard_Names} pragma applies. This is useful when you want to
3363 generally suppress enumeration literal names and for example you therefore
3364 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3365 want to retain the names for specific enumeration types.
3367 @node Pragma License
3368 @unnumberedsec Pragma License
3369 @findex License
3370 @cindex License checking
3371 @noindent
3372 Syntax:
3374 @smallexample @c ada
3375 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3376 @end smallexample
3378 @noindent
3379 This pragma is provided to allow automated checking for appropriate license
3380 conditions with respect to the standard and modified GPL@.  A pragma
3381 @code{License}, which is a configuration pragma that typically appears at
3382 the start of a source file or in a separate @file{gnat.adc} file, specifies
3383 the licensing conditions of a unit as follows:
3385 @itemize @bullet
3386 @item Unrestricted
3387 This is used for a unit that can be freely used with no license restrictions.
3388 Examples of such units are public domain units, and units from the Ada
3389 Reference Manual.
3391 @item GPL
3392 This is used for a unit that is licensed under the unmodified GPL, and which
3393 therefore cannot be @code{with}'ed by a restricted unit.
3395 @item Modified_GPL
3396 This is used for a unit licensed under the GNAT modified GPL that includes
3397 a special exception paragraph that specifically permits the inclusion of
3398 the unit in programs without requiring the entire program to be released
3399 under the GPL@.
3401 @item Restricted
3402 This is used for a unit that is restricted in that it is not permitted to
3403 depend on units that are licensed under the GPL@.  Typical examples are
3404 proprietary code that is to be released under more restrictive license
3405 conditions.  Note that restricted units are permitted to @code{with} units
3406 which are licensed under the modified GPL (this is the whole point of the
3407 modified GPL).
3409 @end itemize
3411 @noindent
3412 Normally a unit with no @code{License} pragma is considered to have an
3413 unknown license, and no checking is done.  However, standard GNAT headers
3414 are recognized, and license information is derived from them as follows.
3416 @itemize @bullet
3418 A GNAT license header starts with a line containing 78 hyphens.  The following
3419 comment text is searched for the appearance of any of the following strings.
3421 If the string ``GNU General Public License'' is found, then the unit is assumed
3422 to have GPL license, unless the string ``As a special exception'' follows, in
3423 which case the license is assumed to be modified GPL@.
3425 If one of the strings
3426 ``This specification is adapted from the Ada Semantic Interface'' or
3427 ``This specification is derived from the Ada Reference Manual'' is found
3428 then the unit is assumed to be unrestricted.
3429 @end itemize
3431 @noindent
3432 These default actions means that a program with a restricted license pragma
3433 will automatically get warnings if a GPL unit is inappropriately
3434 @code{with}'ed.  For example, the program:
3436 @smallexample @c ada
3437 with Sem_Ch3;
3438 with GNAT.Sockets;
3439 procedure Secret_Stuff is
3440   @dots{}
3441 end Secret_Stuff
3442 @end smallexample
3444 @noindent
3445 if compiled with pragma @code{License} (@code{Restricted}) in a
3446 @file{gnat.adc} file will generate the warning:
3448 @smallexample
3449 1.  with Sem_Ch3;
3450         |
3451    >>> license of withed unit "Sem_Ch3" is incompatible
3453 2.  with GNAT.Sockets;
3454 3.  procedure Secret_Stuff is
3455 @end smallexample
3457 @noindent
3458 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3459 compiler and is licensed under the
3460 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3461 run time, and is therefore licensed under the modified GPL@.
3463 @node Pragma Link_With
3464 @unnumberedsec Pragma Link_With
3465 @findex Link_With
3466 @noindent
3467 Syntax:
3469 @smallexample @c ada
3470 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3471 @end smallexample
3473 @noindent
3474 This pragma is provided for compatibility with certain Ada 83 compilers.
3475 It has exactly the same effect as pragma @code{Linker_Options} except
3476 that spaces occurring within one of the string expressions are treated
3477 as separators. For example, in the following case:
3479 @smallexample @c ada
3480 pragma Link_With ("-labc -ldef");
3481 @end smallexample
3483 @noindent
3484 results in passing the strings @code{-labc} and @code{-ldef} as two
3485 separate arguments to the linker. In addition pragma Link_With allows
3486 multiple arguments, with the same effect as successive pragmas.
3488 @node Pragma Linker_Alias
3489 @unnumberedsec Pragma Linker_Alias
3490 @findex Linker_Alias
3491 @noindent
3492 Syntax:
3494 @smallexample @c ada
3495 pragma Linker_Alias (
3496   [Entity =>] LOCAL_NAME,
3497   [Target =>] static_string_EXPRESSION);
3498 @end smallexample
3500 @noindent
3501 @var{LOCAL_NAME} must refer to an object that is declared at the library
3502 level. This pragma establishes the given entity as a linker alias for the
3503 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3504 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3505 @var{static_string_EXPRESSION} in the object file, that is to say no space
3506 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3507 to the same address as @var{static_string_EXPRESSION} by the linker.
3509 The actual linker name for the target must be used (e.g.@: the fully
3510 encoded name with qualification in Ada, or the mangled name in C++),
3511 or it must be declared using the C convention with @code{pragma Import}
3512 or @code{pragma Export}.
3514 Not all target machines support this pragma. On some of them it is accepted
3515 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3517 @smallexample @c ada
3518 --  Example of the use of pragma Linker_Alias
3520 package p is
3521   i : Integer := 1;
3522   pragma Export (C, i);
3524   new_name_for_i : Integer;
3525   pragma Linker_Alias (new_name_for_i, "i");
3526 end p;
3527 @end smallexample
3529 @node Pragma Linker_Constructor
3530 @unnumberedsec Pragma Linker_Constructor
3531 @findex Linker_Constructor
3532 @noindent
3533 Syntax:
3535 @smallexample @c ada
3536 pragma Linker_Constructor (procedure_LOCAL_NAME);
3537 @end smallexample
3539 @noindent
3540 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3541 is declared at the library level. A procedure to which this pragma is
3542 applied will be treated as an initialization routine by the linker.
3543 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3544 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3545 of the executable is called (or immediately after the shared library is
3546 loaded if the procedure is linked in a shared library), in particular
3547 before the Ada run-time environment is set up.
3549 Because of these specific contexts, the set of operations such a procedure
3550 can perform is very limited and the type of objects it can manipulate is
3551 essentially restricted to the elementary types. In particular, it must only
3552 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3554 This pragma is used by GNAT to implement auto-initialization of shared Stand
3555 Alone Libraries, which provides a related capability without the restrictions
3556 listed above. Where possible, the use of Stand Alone Libraries is preferable
3557 to the use of this pragma.
3559 @node Pragma Linker_Destructor
3560 @unnumberedsec Pragma Linker_Destructor
3561 @findex Linker_Destructor
3562 @noindent
3563 Syntax:
3565 @smallexample @c ada
3566 pragma Linker_Destructor (procedure_LOCAL_NAME);
3567 @end smallexample
3569 @noindent
3570 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3571 is declared at the library level. A procedure to which this pragma is
3572 applied will be treated as a finalization routine by the linker.
3573 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3574 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3575 of the executable has exited (or immediately before the shared library
3576 is unloaded if the procedure is linked in a shared library), in particular
3577 after the Ada run-time environment is shut down.
3579 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3580 because of these specific contexts.
3582 @node Pragma Linker_Section
3583 @unnumberedsec Pragma Linker_Section
3584 @findex Linker_Section
3585 @noindent
3586 Syntax:
3588 @smallexample @c ada
3589 pragma Linker_Section (
3590   [Entity  =>] LOCAL_NAME,
3591   [Section =>] static_string_EXPRESSION);
3592 @end smallexample
3594 @noindent
3595 @var{LOCAL_NAME} must refer to an object that is declared at the library
3596 level. This pragma specifies the name of the linker section for the given
3597 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3598 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3599 section of the executable (assuming the linker doesn't rename the section).
3601 The compiler normally places library-level objects in standard sections
3602 depending on their type: procedures and functions generally go in the
3603 @code{.text} section, initialized variables in the @code{.data} section
3604 and uninitialized variables in the @code{.bss} section.
3606 Other, special sections may exist on given target machines to map special
3607 hardware, for example I/O ports or flash memory. This pragma is a means to
3608 defer the final layout of the executable to the linker, thus fully working
3609 at the symbolic level with the compiler.
3611 Some file formats do not support arbitrary sections so not all target
3612 machines support this pragma. The use of this pragma may cause a program
3613 execution to be erroneous if it is used to place an entity into an
3614 inappropriate section (e.g.@: a modified variable into the @code{.text}
3615 section). See also @code{pragma Persistent_BSS}.
3617 @smallexample @c ada
3618 --  Example of the use of pragma Linker_Section
3620 package IO_Card is
3621   Port_A : Integer;
3622   pragma Volatile (Port_A);
3623   pragma Linker_Section (Port_A, ".bss.port_a");
3625   Port_B : Integer;
3626   pragma Volatile (Port_B);
3627   pragma Linker_Section (Port_B, ".bss.port_b");
3628 end IO_Card;
3629 @end smallexample
3631 @node Pragma Long_Float
3632 @unnumberedsec Pragma Long_Float
3633 @cindex OpenVMS
3634 @findex Long_Float
3635 @noindent
3636 Syntax:
3638 @smallexample @c ada
3639 pragma Long_Float (FLOAT_FORMAT);
3641 FLOAT_FORMAT ::= D_Float | G_Float
3642 @end smallexample
3644 @noindent
3645 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3646 It allows control over the internal representation chosen for the predefined
3647 type @code{Long_Float} and for floating point type representations with
3648 @code{digits} specified in the range 7 through 15.
3649 For further details on this pragma, see the
3650 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3651 this pragma, the standard runtime libraries must be recompiled.
3653 @node Pragma Machine_Attribute
3654 @unnumberedsec Pragma Machine_Attribute
3655 @findex Machine_Attribute
3656 @noindent
3657 Syntax:
3659 @smallexample @c ada
3660 pragma Machine_Attribute (
3661      [Entity         =>] LOCAL_NAME,
3662      [Attribute_Name =>] static_string_EXPRESSION
3663   [, [Info           =>] static_EXPRESSION] );
3664 @end smallexample
3666 @noindent
3667 Machine-dependent attributes can be specified for types and/or
3668 declarations.  This pragma is semantically equivalent to
3669 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3670 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3671 in GNU C, where @code{@var{attribute_name}} is recognized by the
3672 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3673 specific macro.  A string literal for the optional parameter @var{info}
3674 is transformed into an identifier, which may make this pragma unusable
3675 for some attributes.  @xref{Target Attributes,, Defining target-specific
3676 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3677 Internals}, further information.
3679 @node Pragma Main
3680 @unnumberedsec Pragma Main
3681 @cindex OpenVMS
3682 @findex Main
3683 @noindent
3684 Syntax:
3686 @smallexample @c ada
3687 pragma Main
3688  (MAIN_OPTION [, MAIN_OPTION]);
3690 MAIN_OPTION ::=
3691   [Stack_Size              =>] static_integer_EXPRESSION
3692 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3693 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3694 @end smallexample
3696 @noindent
3697 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3698 no effect in GNAT, other than being syntax checked.
3700 @node Pragma Main_Storage
3701 @unnumberedsec Pragma Main_Storage
3702 @cindex OpenVMS
3703 @findex Main_Storage
3704 @noindent
3705 Syntax:
3707 @smallexample @c ada
3708 pragma Main_Storage
3709   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3711 MAIN_STORAGE_OPTION ::=
3712   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3713 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3714 @end smallexample
3716 @noindent
3717 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3718 no effect in GNAT, other than being syntax checked.  Note that the pragma
3719 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3721 @node Pragma No_Body
3722 @unnumberedsec Pragma No_Body
3723 @findex No_Body
3724 @noindent
3725 Syntax:
3727 @smallexample @c ada
3728 pragma No_Body;
3729 @end smallexample
3731 @noindent
3732 There are a number of cases in which a package spec does not require a body,
3733 and in fact a body is not permitted. GNAT will not permit the spec to be
3734 compiled if there is a body around. The pragma No_Body allows you to provide
3735 a body file, even in a case where no body is allowed. The body file must
3736 contain only comments and a single No_Body pragma. This is recognized by
3737 the compiler as indicating that no body is logically present.
3739 This is particularly useful during maintenance when a package is modified in
3740 such a way that a body needed before is no longer needed. The provision of a
3741 dummy body with a No_Body pragma ensures that there is no interference from
3742 earlier versions of the package body.
3744 @node Pragma No_Return
3745 @unnumberedsec Pragma No_Return
3746 @findex No_Return
3747 @noindent
3748 Syntax:
3750 @smallexample @c ada
3751 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3752 @end smallexample
3754 @noindent
3755 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3756 declarations in the current declarative part.  A procedure to which this
3757 pragma is applied may not contain any explicit @code{return} statements.
3758 In addition, if the procedure contains any implicit returns from falling
3759 off the end of a statement sequence, then execution of that implicit
3760 return will cause Program_Error to be raised.
3762 One use of this pragma is to identify procedures whose only purpose is to raise
3763 an exception. Another use of this pragma is to suppress incorrect warnings
3764 about missing returns in functions, where the last statement of a function
3765 statement sequence is a call to such a procedure.
3767 Note that in Ada 2005 mode, this pragma is part of the language, and is
3768 identical in effect to the pragma as implemented in Ada 95 mode.
3770 @node Pragma No_Strict_Aliasing
3771 @unnumberedsec Pragma No_Strict_Aliasing
3772 @findex No_Strict_Aliasing
3773 @noindent
3774 Syntax:
3776 @smallexample @c ada
3777 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3778 @end smallexample
3780 @noindent
3781 @var{type_LOCAL_NAME} must refer to an access type
3782 declaration in the current declarative part.  The effect is to inhibit
3783 strict aliasing optimization for the given type.  The form with no
3784 arguments is a configuration pragma which applies to all access types
3785 declared in units to which the pragma applies. For a detailed
3786 description of the strict aliasing optimization, and the situations
3787 in which it must be suppressed, see @ref{Optimization and Strict
3788 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3790 This pragma currently has no effects on access to unconstrained array types.
3792 @node Pragma Normalize_Scalars
3793 @unnumberedsec Pragma Normalize_Scalars
3794 @findex Normalize_Scalars
3795 @noindent
3796 Syntax:
3798 @smallexample @c ada
3799 pragma Normalize_Scalars;
3800 @end smallexample
3802 @noindent
3803 This is a language defined pragma which is fully implemented in GNAT@.  The
3804 effect is to cause all scalar objects that are not otherwise initialized
3805 to be initialized.  The initial values are implementation dependent and
3806 are as follows:
3808 @table @code
3809 @item Standard.Character
3810 @noindent
3811 Objects whose root type is Standard.Character are initialized to
3812 Character'Last unless the subtype range excludes NUL (in which case
3813 NUL is used). This choice will always generate an invalid value if
3814 one exists.
3816 @item Standard.Wide_Character
3817 @noindent
3818 Objects whose root type is Standard.Wide_Character are initialized to
3819 Wide_Character'Last unless the subtype range excludes NUL (in which case
3820 NUL is used). This choice will always generate an invalid value if
3821 one exists.
3823 @item Standard.Wide_Wide_Character
3824 @noindent
3825 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3826 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3827 which case NUL is used). This choice will always generate an invalid value if
3828 one exists.
3830 @item Integer types
3831 @noindent
3832 Objects of an integer type are treated differently depending on whether
3833 negative values are present in the subtype. If no negative values are
3834 present, then all one bits is used as the initial value except in the
3835 special case where zero is excluded from the subtype, in which case
3836 all zero bits are used. This choice will always generate an invalid
3837 value if one exists.
3839 For subtypes with negative values present, the largest negative number
3840 is used, except in the unusual case where this largest negative number
3841 is in the subtype, and the largest positive number is not, in which case
3842 the largest positive value is used. This choice will always generate
3843 an invalid value if one exists.
3845 @item Floating-Point Types
3846 Objects of all floating-point types are initialized to all 1-bits. For
3847 standard IEEE format, this corresponds to a NaN (not a number) which is
3848 indeed an invalid value.
3850 @item Fixed-Point Types
3851 Objects of all fixed-point types are treated as described above for integers,
3852 with the rules applying to the underlying integer value used to represent
3853 the fixed-point value.
3855 @item Modular types
3856 Objects of a modular type are initialized to all one bits, except in
3857 the special case where zero is excluded from the subtype, in which
3858 case all zero bits are used. This choice will always generate an
3859 invalid value if one exists.
3861 @item Enumeration types
3862 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3863 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3864 whose Pos value is zero, in which case a code of zero is used. This choice
3865 will always generate an invalid value if one exists.
3867 @end table
3869 @node Pragma Obsolescent
3870 @unnumberedsec Pragma Obsolescent
3871 @findex Obsolescent
3872 @noindent
3873 Syntax:
3875 @smallexample @c ada
3876 pragma Obsolescent;
3878 pragma Obsolescent (
3879   [Message =>] static_string_EXPRESSION
3880 [,[Version =>] Ada_05]]);
3882 pragma Obsolescent (
3883   [Entity  =>] NAME
3884 [,[Message =>] static_string_EXPRESSION
3885 [,[Version =>] Ada_05]] );
3886 @end smallexample
3888 @noindent
3889 This pragma can occur immediately following a declaration of an entity,
3890 including the case of a record component. If no Entity argument is present,
3891 then this declaration is the one to which the pragma applies. If an Entity
3892 parameter is present, it must either match the name of the entity in this
3893 declaration, or alternatively, the pragma can immediately follow an enumeration
3894 type declaration, where the Entity argument names one of the enumeration
3895 literals.
3897 This pragma is used to indicate that the named entity
3898 is considered obsolescent and should not be used. Typically this is
3899 used when an API must be modified by eventually removing or modifying
3900 existing subprograms or other entities. The pragma can be used at an
3901 intermediate stage when the entity is still present, but will be
3902 removed later.
3904 The effect of this pragma is to output a warning message on a reference to
3905 an entity thus marked that the subprogram is obsolescent if the appropriate
3906 warning option in the compiler is activated. If the Message parameter is
3907 present, then a second warning message is given containing this text. In
3908 addition, a reference to the entity is considered to be a violation of pragma
3909 Restrictions (No_Obsolescent_Features).
3911 This pragma can also be used as a program unit pragma for a package,
3912 in which case the entity name is the name of the package, and the
3913 pragma indicates that the entire package is considered
3914 obsolescent. In this case a client @code{with}'ing such a package
3915 violates the restriction, and the @code{with} statement is
3916 flagged with warnings if the warning option is set.
3918 If the Version parameter is present (which must be exactly
3919 the identifier Ada_05, no other argument is allowed), then the
3920 indication of obsolescence applies only when compiling in Ada 2005
3921 mode. This is primarily intended for dealing with the situations
3922 in the predefined library where subprograms or packages
3923 have become defined as obsolescent in Ada 2005
3924 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3926 The following examples show typical uses of this pragma:
3928 @smallexample @c ada
3929 package p is
3930    pragma Obsolescent (p, Message => "use pp instead of p");
3931 end p;
3933 package q is
3934    procedure q2;
3935    pragma Obsolescent ("use q2new instead");
3937    type R is new integer;
3938    pragma Obsolescent
3939      (Entity  => R,
3940       Message => "use RR in Ada 2005",
3941       Version => Ada_05);
3943    type M is record
3944       F1 : Integer;
3945       F2 : Integer;
3946       pragma Obsolescent;
3947       F3 : Integer;
3948    end record;
3950    type E is (a, bc, 'd', quack);
3951    pragma Obsolescent (Entity => bc)
3952    pragma Obsolescent (Entity => 'd')
3954    function "+"
3955      (a, b : character) return character;
3956    pragma Obsolescent (Entity => "+");
3957 end;
3958 @end smallexample
3960 @noindent
3961 Note that, as for all pragmas, if you use a pragma argument identifier,
3962 then all subsequent parameters must also use a pragma argument identifier.
3963 So if you specify "Entity =>" for the Entity argument, and a Message
3964 argument is present, it must be preceded by "Message =>".
3966 @node Pragma Optimize_Alignment
3967 @unnumberedsec Pragma Optimize_Alignment
3968 @findex Optimize_Alignment
3969 @cindex Alignment, default settings
3970 @noindent
3971 Syntax:
3973 @smallexample @c ada
3974 pragma Optimize_Alignment (TIME | SPACE | OFF);
3975 @end smallexample
3977 @noindent
3978 This is a configuration pragma which affects the choice of default alignments
3979 for types where no alignment is explicitly specified. There is a time/space
3980 trade-off in the selection of these values. Large alignments result in more
3981 efficient code, at the expense of larger data space, since sizes have to be
3982 increased to match these alignments. Smaller alignments save space, but the
3983 access code is slower. The normal choice of default alignments (which is what
3984 you get if you do not use this pragma, or if you use an argument of OFF),
3985 tries to balance these two requirements.
3987 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3988 First any packed record is given an alignment of 1. Second, if a size is given
3989 for the type, then the alignment is chosen to avoid increasing this size. For
3990 example, consider:
3992 @smallexample @c ada
3993    type R is record
3994       X : Integer;
3995       Y : Character;
3996    end record;
3998    for R'Size use 5*8;
3999 @end smallexample
4001 @noindent
4002 In the default mode, this type gets an alignment of 4, so that access to the
4003 Integer field X are efficient. But this means that objects of the type end up
4004 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4005 allowed to be bigger than the size of the type, but it can waste space if for
4006 example fields of type R appear in an enclosing record. If the above type is
4007 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4009 Specifying TIME causes larger default alignments to be chosen in the case of
4010 small types with sizes that are not a power of 2. For example, consider:
4012 @smallexample @c ada
4013    type R is record
4014       A : Character;
4015       B : Character;
4016       C : Boolean;
4017    end record;
4019    pragma Pack (R);
4020    for R'Size use 17;
4021 @end smallexample
4023 @noindent
4024 The default alignment for this record is normally 1, but if this type is
4025 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4026 to 4, which wastes space for objects of the type, since they are now 4 bytes
4027 long, but results in more efficient access when the whole record is referenced.
4029 As noted above, this is a configuration pragma, and there is a requirement
4030 that all units in a partition be compiled with a consistent setting of the
4031 optimization setting. This would normally be achieved by use of a configuration
4032 pragma file containing the appropriate setting. The exception to this rule is
4033 that units with an explicit configuration pragma in the same file as the source
4034 unit are excluded from the consistency check, as are all predefined units. The
4035 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4036 pragma appears at the start of the file.
4038 @node Pragma Ordered
4039 @unnumberedsec Pragma Ordered
4040 @findex Ordered
4041 @findex pragma @code{Ordered}
4042 @noindent
4043 Syntax:
4045 @smallexample @c ada
4046 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4047 @end smallexample
4049 @noindent
4050 Most enumeration types are from a conceptual point of view unordered.
4051 For example, consider:
4053 @smallexample @c ada
4054 type Color is (Red, Blue, Green, Yellow);
4055 @end smallexample
4057 @noindent
4058 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4059 but really these relations make no sense; the enumeration type merely
4060 specifies a set of possible colors, and the order is unimportant.
4062 For unordered enumeration types, it is generally a good idea if
4063 clients avoid comparisons (other than equality or inequality) and
4064 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4065 other than the unit where the type is declared, its body, and its subunits.)
4066 For example, if code buried in some client says:
4068 @smallexample @c ada
4069 if Current_Color < Yellow then ...
4070 if Current_Color in Blue .. Green then ...
4071 @end smallexample
4073 @noindent
4074 then the client code is relying on the order, which is undesirable.
4075 It makes the code hard to read and creates maintenance difficulties if
4076 entries have to be added to the enumeration type. Instead,
4077 the code in the client should list the possibilities, or an
4078 appropriate subtype should be declared in the unit that declares
4079 the original enumeration type. E.g., the following subtype could
4080 be declared along with the type @code{Color}:
4082 @smallexample @c ada
4083 subtype RBG is Color range Red .. Green;
4084 @end smallexample
4086 @noindent
4087 and then the client could write:
4089 @smallexample @c ada
4090 if Current_Color in RBG then ...
4091 if Current_Color = Blue or Current_Color = Green then ...
4092 @end smallexample
4094 @noindent
4095 However, some enumeration types are legitimately ordered from a conceptual
4096 point of view. For example, if you declare:
4098 @smallexample @c ada
4099 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4100 @end smallexample
4102 @noindent
4103 then the ordering imposed by the language is reasonable, and
4104 clients can depend on it, writing for example:
4106 @smallexample @c ada
4107 if D in Mon .. Fri then ...
4108 if D < Wed then ...
4109 @end smallexample
4111 @noindent
4112 The pragma @option{Ordered} is provided to mark enumeration types that
4113 are conceptually ordered, alerting the reader that clients may depend
4114 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4115 rather than one to mark them as unordered, since in our experience,
4116 the great majority of enumeration types are conceptually unordered.
4118 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4119 and @code{Wide_Wide_Character}
4120 are considered to be ordered types, so each is declared with a
4121 pragma @code{Ordered} in package @code{Standard}.
4123 Normally pragma @code{Ordered} serves only as documentation and a guide for
4124 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4125 requests warnings for inappropriate uses (comparisons and explicit
4126 subranges) for unordered types. If this switch is used, then any
4127 enumeration type not marked with pragma @code{Ordered} will be considered
4128 as unordered, and will generate warnings for inappropriate uses.
4130 For additional information please refer to the description of the
4131 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4133 @node Pragma Overflow_Checks
4134 @unnumberedsec Pragma Overflow_Checks
4135 @findex Overflow checks
4136 @findex pragma @code{Overflow_Checks}
4137 @noindent
4138 Syntax:
4140 @smallexample @c ada
4141 pragma Overflow_Checks
4142  (  [General    =>] MODE
4143   [,[Assertions =>] MODE]);
4145 MODE ::= SUPPRESSED | CHECKED | MINIMIZED | ELIMINATED
4146 @end smallexample
4148 @noindent
4149 This pragma sets the current overflow mode to the given mode. For details
4150 of the meaning of these modes, please refer to the
4151 ``Overflow Check Handling in GNAT'' appendix in the
4152 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4153 the given mode applies to all expressions. If both parameters are present,
4154 the @code{General} mode applies to expressions outside assertions, and
4155 the @code{Eliminated} mode applies to expressions within assertions.
4157 The case of the @code{MODE} parameter is ignored,
4158 so @code{MINIMIZED}, @code{Minimized} and
4159 @code{minimized} all have the same effect.
4161 The @code{Overflow_Checks} pragma has the same scoping and placement
4162 rules as pragma @code{Suppress}, so it can occur either as a
4163 configuration pragma, specifying a default for the whole
4164 program, or in a declarative scope, where it applies to the
4165 remaining declarations and statements in that scope.
4167 The pragma @code{Suppress (Overflow_Check)} sets mode
4169 @smallexample @c ada
4170    General => Suppressed
4171 @end smallexample
4173 @noindent
4174 suppressing all overflow checking within and outside
4175 assertions.
4177 The pragam @code{Unsuppress (Overflow_Check)} sets mode
4179 @smallexample @c ada
4180    General => Checked
4181 @end smallexample
4183 @noindent
4184 which causes overflow checking of all intermediate overflows.
4185 This applies both inside and outside assertions.
4188 @node Pragma Passive
4189 @unnumberedsec Pragma Passive
4190 @findex Passive
4191 @noindent
4192 Syntax:
4194 @smallexample @c ada
4195 pragma Passive [(Semaphore | No)];
4196 @end smallexample
4198 @noindent
4199 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
4200 compatibility with DEC Ada 83 implementations, where it is used within a
4201 task definition to request that a task be made passive.  If the argument
4202 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4203 treats the pragma as an assertion that the containing task is passive
4204 and that optimization of context switch with this task is permitted and
4205 desired.  If the argument @code{No} is present, the task must not be
4206 optimized.  GNAT does not attempt to optimize any tasks in this manner
4207 (since protected objects are available in place of passive tasks).
4209 @node Pragma Persistent_BSS
4210 @unnumberedsec Pragma Persistent_BSS
4211 @findex Persistent_BSS
4212 @noindent
4213 Syntax:
4215 @smallexample @c ada
4216 pragma Persistent_BSS [(LOCAL_NAME)]
4217 @end smallexample
4219 @noindent
4220 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4221 section. On some targets the linker and loader provide for special
4222 treatment of this section, allowing a program to be reloaded without
4223 affecting the contents of this data (hence the name persistent).
4225 There are two forms of usage. If an argument is given, it must be the
4226 local name of a library level object, with no explicit initialization
4227 and whose type is potentially persistent. If no argument is given, then
4228 the pragma is a configuration pragma, and applies to all library level
4229 objects with no explicit initialization of potentially persistent types.
4231 A potentially persistent type is a scalar type, or a non-tagged,
4232 non-discriminated record, all of whose components have no explicit
4233 initialization and are themselves of a potentially persistent type,
4234 or an array, all of whose constraints are static, and whose component
4235 type is potentially persistent.
4237 If this pragma is used on a target where this feature is not supported,
4238 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4240 @node Pragma Polling
4241 @unnumberedsec Pragma Polling
4242 @findex Polling
4243 @noindent
4244 Syntax:
4246 @smallexample @c ada
4247 pragma Polling (ON | OFF);
4248 @end smallexample
4250 @noindent
4251 This pragma controls the generation of polling code.  This is normally off.
4252 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4253 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
4254 runtime library, and can be found in file @file{a-excpol.adb}.
4256 Pragma @code{Polling} can appear as a configuration pragma (for example it
4257 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4258 can be used in the statement or declaration sequence to control polling
4259 more locally.
4261 A call to the polling routine is generated at the start of every loop and
4262 at the start of every subprogram call.  This guarantees that the @code{Poll}
4263 routine is called frequently, and places an upper bound (determined by
4264 the complexity of the code) on the period between two @code{Poll} calls.
4266 The primary purpose of the polling interface is to enable asynchronous
4267 aborts on targets that cannot otherwise support it (for example Windows
4268 NT), but it may be used for any other purpose requiring periodic polling.
4269 The standard version is null, and can be replaced by a user program.  This
4270 will require re-compilation of the @code{Ada.Exceptions} package that can
4271 be found in files @file{a-except.ads} and @file{a-except.adb}.
4273 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4274 distribution) is used to enable the asynchronous abort capability on
4275 targets that do not normally support the capability.  The version of
4276 @code{Poll} in this file makes a call to the appropriate runtime routine
4277 to test for an abort condition.
4279 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4280 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4281 details.
4283 @node Pragma Postcondition
4284 @unnumberedsec Pragma Postcondition
4285 @cindex Postconditions
4286 @cindex Checks, postconditions
4287 @findex Postconditions
4288 @noindent
4289 Syntax:
4291 @smallexample @c ada
4292 pragma Postcondition (
4293    [Check   =>] Boolean_Expression
4294  [,[Message =>] String_Expression]);
4295 @end smallexample
4297 @noindent
4298 The @code{Postcondition} pragma allows specification of automatic
4299 postcondition checks for subprograms. These checks are similar to
4300 assertions, but are automatically inserted just prior to the return
4301 statements of the subprogram with which they are associated (including
4302 implicit returns at the end of procedure bodies and associated
4303 exception handlers).
4305 In addition, the boolean expression which is the condition which
4306 must be true may contain references to function'Result in the case
4307 of a function to refer to the returned value.
4309 @code{Postcondition} pragmas may appear either immediately following the
4310 (separate) declaration of a subprogram, or at the start of the
4311 declarations of a subprogram body. Only other pragmas may intervene
4312 (that is appear between the subprogram declaration and its
4313 postconditions, or appear before the postcondition in the
4314 declaration sequence in a subprogram body). In the case of a
4315 postcondition appearing after a subprogram declaration, the
4316 formal arguments of the subprogram are visible, and can be
4317 referenced in the postcondition expressions.
4319 The postconditions are collected and automatically tested just
4320 before any return (implicit or explicit) in the subprogram body.
4321 A postcondition is only recognized if postconditions are active
4322 at the time the pragma is encountered. The compiler switch @option{gnata}
4323 turns on all postconditions by default, and pragma @code{Check_Policy}
4324 with an identifier of @code{Postcondition} can also be used to
4325 control whether postconditions are active.
4327 The general approach is that postconditions are placed in the spec
4328 if they represent functional aspects which make sense to the client.
4329 For example we might have:
4331 @smallexample @c ada
4332    function Direction return Integer;
4333    pragma Postcondition
4334     (Direction'Result = +1
4335        or else
4336      Direction'Result = -1);
4337 @end smallexample
4339 @noindent
4340 which serves to document that the result must be +1 or -1, and
4341 will test that this is the case at run time if postcondition
4342 checking is active.
4344 Postconditions within the subprogram body can be used to
4345 check that some internal aspect of the implementation,
4346 not visible to the client, is operating as expected.
4347 For instance if a square root routine keeps an internal
4348 counter of the number of times it is called, then we
4349 might have the following postcondition:
4351 @smallexample @c ada
4352    Sqrt_Calls : Natural := 0;
4354    function Sqrt (Arg : Float) return Float is
4355      pragma Postcondition
4356        (Sqrt_Calls = Sqrt_Calls'Old + 1);
4357      ...
4358    end Sqrt
4359 @end smallexample
4361 @noindent
4362 As this example, shows, the use of the @code{Old} attribute
4363 is often useful in postconditions to refer to the state on
4364 entry to the subprogram.
4366 Note that postconditions are only checked on normal returns
4367 from the subprogram. If an abnormal return results from
4368 raising an exception, then the postconditions are not checked.
4370 If a postcondition fails, then the exception
4371 @code{System.Assertions.Assert_Failure} is raised. If
4372 a message argument was supplied, then the given string
4373 will be used as the exception message. If no message
4374 argument was supplied, then the default message has
4375 the form "Postcondition failed at file:line". The
4376 exception is raised in the context of the subprogram
4377 body, so it is possible to catch postcondition failures
4378 within the subprogram body itself.
4380 Within a package spec, normal visibility rules
4381 in Ada would prevent forward references within a
4382 postcondition pragma to functions defined later in
4383 the same package. This would introduce undesirable
4384 ordering constraints. To avoid this problem, all
4385 postcondition pragmas are analyzed at the end of
4386 the package spec, allowing forward references.
4388 The following example shows that this even allows
4389 mutually recursive postconditions as in:
4391 @smallexample @c ada
4392 package Parity_Functions is
4393    function Odd  (X : Natural) return Boolean;
4394    pragma Postcondition
4395      (Odd'Result =
4396         (x = 1
4397           or else
4398         (x /= 0 and then Even (X - 1))));
4400    function Even (X : Natural) return Boolean;
4401    pragma Postcondition
4402      (Even'Result =
4403         (x = 0
4404           or else
4405         (x /= 1 and then Odd (X - 1))));
4407 end Parity_Functions;
4408 @end smallexample
4410 @noindent
4411 There are no restrictions on the complexity or form of
4412 conditions used within @code{Postcondition} pragmas.
4413 The following example shows that it is even possible
4414 to verify performance behavior.
4416 @smallexample @c ada
4417 package Sort is
4419    Performance : constant Float;
4420    --  Performance constant set by implementation
4421    --  to match target architecture behavior.
4423    procedure Treesort (Arg : String);
4424    --  Sorts characters of argument using N*logN sort
4425    pragma Postcondition
4426      (Float (Clock - Clock'Old) <=
4427         Float (Arg'Length) *
4428         log (Float (Arg'Length)) *
4429         Performance);
4430 end Sort;
4431 @end smallexample
4433 @noindent
4434 Note: postcondition pragmas associated with subprograms that are
4435 marked as Inline_Always, or those marked as Inline with front-end
4436 inlining (-gnatN option set) are accepted and legality-checked
4437 by the compiler, but are ignored at run-time even if postcondition
4438 checking is enabled.
4440 @node Pragma Precondition
4441 @unnumberedsec Pragma Precondition
4442 @cindex Preconditions
4443 @cindex Checks, preconditions
4444 @findex Preconditions
4445 @noindent
4446 Syntax:
4448 @smallexample @c ada
4449 pragma Precondition (
4450    [Check   =>] Boolean_Expression
4451  [,[Message =>] String_Expression]);
4452 @end smallexample
4454 @noindent
4455 The @code{Precondition} pragma is similar to @code{Postcondition}
4456 except that the corresponding checks take place immediately upon
4457 entry to the subprogram, and if a precondition fails, the exception
4458 is raised in the context of the caller, and the attribute 'Result
4459 cannot be used within the precondition expression.
4461 Otherwise, the placement and visibility rules are identical to those
4462 described for postconditions. The following is an example of use
4463 within a package spec:
4465 @smallexample @c ada
4466 package Math_Functions is
4467    ...
4468    function Sqrt (Arg : Float) return Float;
4469    pragma Precondition (Arg >= 0.0)
4470    ...
4471 end Math_Functions;
4472 @end smallexample
4474 @noindent
4475 @code{Precondition} pragmas may appear either immediately following the
4476 (separate) declaration of a subprogram, or at the start of the
4477 declarations of a subprogram body. Only other pragmas may intervene
4478 (that is appear between the subprogram declaration and its
4479 postconditions, or appear before the postcondition in the
4480 declaration sequence in a subprogram body).
4482 Note: postcondition pragmas associated with subprograms that are
4483 marked as Inline_Always, or those marked as Inline with front-end
4484 inlining (-gnatN option set) are accepted and legality-checked
4485 by the compiler, but are ignored at run-time even if postcondition
4486 checking is enabled.
4488 @node Pragma Profile (Ravenscar)
4489 @unnumberedsec Pragma Profile (Ravenscar)
4490 @findex Ravenscar
4491 @noindent
4492 Syntax:
4494 @smallexample @c ada
4495 pragma Profile (Ravenscar);
4496 @end smallexample
4498 @noindent
4499 A configuration pragma that establishes the following set of configuration
4500 pragmas:
4502 @table @code
4503 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4504 [RM D.2.2] Tasks are dispatched following a preemptive
4505 priority-ordered scheduling policy.
4507 @item Locking_Policy (Ceiling_Locking)
4508 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4509 the ceiling priority of the corresponding protected object.
4511 @c @item Detect_Blocking
4512 @c This pragma forces the detection of potentially blocking operations within a
4513 @c protected operation, and to raise Program_Error if that happens.
4514 @end table
4515 @noindent
4517 plus the following set of restrictions:
4519 @table @code
4520 @item Max_Entry_Queue_Length => 1
4521 No task can be queued on a protected entry.
4522 @item Max_Protected_Entries => 1
4523 @item Max_Task_Entries => 0
4524 No rendezvous statements are allowed.
4525 @item No_Abort_Statements
4526 @item No_Dynamic_Attachment
4527 @item No_Dynamic_Priorities
4528 @item No_Implicit_Heap_Allocations
4529 @item No_Local_Protected_Objects
4530 @item No_Local_Timing_Events
4531 @item No_Protected_Type_Allocators
4532 @item No_Relative_Delay
4533 @item No_Requeue_Statements
4534 @item No_Select_Statements
4535 @item No_Specific_Termination_Handlers
4536 @item No_Task_Allocators
4537 @item No_Task_Hierarchy
4538 @item No_Task_Termination
4539 @item Simple_Barriers
4540 @end table
4541 @noindent
4543 The Ravenscar profile also includes the following restrictions that specify
4544 that there are no semantic dependences on the corresponding predefined
4545 packages:
4547 @table @code
4548 @item No_Dependence => Ada.Asynchronous_Task_Control
4549 @item No_Dependence => Ada.Calendar
4550 @item No_Dependence => Ada.Execution_Time.Group_Budget
4551 @item No_Dependence => Ada.Execution_Time.Timers
4552 @item No_Dependence => Ada.Task_Attributes
4553 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4554 @end table
4556 @noindent
4558 This set of configuration pragmas and restrictions correspond to the
4559 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4560 published by the @cite{International Real-Time Ada Workshop}, 1997,
4561 and whose most recent description is available at
4562 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4564 The original definition of the profile was revised at subsequent IRTAW
4565 meetings. It has been included in the ISO
4566 @cite{Guide for the Use of the Ada Programming Language in High
4567 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4568 the next revision of the standard. The formal definition given by
4569 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4570 AI-305) available at
4571 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4572 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4574 The above set is a superset of the restrictions provided by pragma
4575 @code{Profile (Restricted)}, it includes six additional restrictions
4576 (@code{Simple_Barriers}, @code{No_Select_Statements},
4577 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4578 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4579 that pragma @code{Profile (Ravenscar)}, like the pragma
4580 @code{Profile (Restricted)},
4581 automatically causes the use of a simplified,
4582 more efficient version of the tasking run-time system.
4584 @node Pragma Profile (Restricted)
4585 @unnumberedsec Pragma Profile (Restricted)
4586 @findex Restricted Run Time
4587 @noindent
4588 Syntax:
4590 @smallexample @c ada
4591 pragma Profile (Restricted);
4592 @end smallexample
4594 @noindent
4595 A configuration pragma that establishes the following set of restrictions:
4597 @itemize @bullet
4598 @item No_Abort_Statements
4599 @item No_Entry_Queue
4600 @item No_Task_Hierarchy
4601 @item No_Task_Allocators
4602 @item No_Dynamic_Priorities
4603 @item No_Terminate_Alternatives
4604 @item No_Dynamic_Attachment
4605 @item No_Protected_Type_Allocators
4606 @item No_Local_Protected_Objects
4607 @item No_Requeue_Statements
4608 @item No_Task_Attributes_Package
4609 @item Max_Asynchronous_Select_Nesting =  0
4610 @item Max_Task_Entries =  0
4611 @item Max_Protected_Entries = 1
4612 @item Max_Select_Alternatives = 0
4613 @end itemize
4615 @noindent
4616 This set of restrictions causes the automatic selection of a simplified
4617 version of the run time that provides improved performance for the
4618 limited set of tasking functionality permitted by this set of restrictions.
4620 @node Pragma Psect_Object
4621 @unnumberedsec Pragma Psect_Object
4622 @findex Psect_Object
4623 @noindent
4624 Syntax:
4626 @smallexample @c ada
4627 pragma Psect_Object (
4628      [Internal =>] LOCAL_NAME,
4629   [, [External =>] EXTERNAL_SYMBOL]
4630   [, [Size     =>] EXTERNAL_SYMBOL]);
4632 EXTERNAL_SYMBOL ::=
4633   IDENTIFIER
4634 | static_string_EXPRESSION
4635 @end smallexample
4637 @noindent
4638 This pragma is identical in effect to pragma @code{Common_Object}.
4640 @node Pragma Pure_Function
4641 @unnumberedsec Pragma Pure_Function
4642 @findex Pure_Function
4643 @noindent
4644 Syntax:
4646 @smallexample @c ada
4647 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4648 @end smallexample
4650 @noindent
4651 This pragma appears in the same declarative part as a function
4652 declaration (or a set of function declarations if more than one
4653 overloaded declaration exists, in which case the pragma applies
4654 to all entities).  It specifies that the function @code{Entity} is
4655 to be considered pure for the purposes of code generation.  This means
4656 that the compiler can assume that there are no side effects, and
4657 in particular that two calls with identical arguments produce the
4658 same result.  It also means that the function can be used in an
4659 address clause.
4661 Note that, quite deliberately, there are no static checks to try
4662 to ensure that this promise is met, so @code{Pure_Function} can be used
4663 with functions that are conceptually pure, even if they do modify
4664 global variables.  For example, a square root function that is
4665 instrumented to count the number of times it is called is still
4666 conceptually pure, and can still be optimized, even though it
4667 modifies a global variable (the count).  Memo functions are another
4668 example (where a table of previous calls is kept and consulted to
4669 avoid re-computation).
4671 Note also that the normal rules excluding optimization of subprograms
4672 in pure units (when parameter types are descended from System.Address,
4673 or when the full view of a parameter type is limited), do not apply
4674 for the Pure_Function case. If you explicitly specify Pure_Function,
4675 the compiler may optimize away calls with identical arguments, and
4676 if that results in unexpected behavior, the proper action is not to
4677 use the pragma for subprograms that are not (conceptually) pure.
4679 @findex Pure
4680 Note: Most functions in a @code{Pure} package are automatically pure, and
4681 there is no need to use pragma @code{Pure_Function} for such functions.  One
4682 exception is any function that has at least one formal of type
4683 @code{System.Address} or a type derived from it.  Such functions are not
4684 considered pure by default, since the compiler assumes that the
4685 @code{Address} parameter may be functioning as a pointer and that the
4686 referenced data may change even if the address value does not.
4687 Similarly, imported functions are not considered to be pure by default,
4688 since there is no way of checking that they are in fact pure.  The use
4689 of pragma @code{Pure_Function} for such a function will override these default
4690 assumption, and cause the compiler to treat a designated subprogram as pure
4691 in these cases.
4693 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4694 applies to the underlying renamed function.  This can be used to
4695 disambiguate cases of overloading where some but not all functions
4696 in a set of overloaded functions are to be designated as pure.
4698 If pragma @code{Pure_Function} is applied to a library level function, the
4699 function is also considered pure from an optimization point of view, but the
4700 unit is not a Pure unit in the categorization sense. So for example, a function
4701 thus marked is free to @code{with} non-pure units.
4703 @node Pragma Remote_Access_Type
4704 @unnumberedsec Pragma Remote_Access_Type
4705 @findex Remote_Access_Type
4706 @noindent
4707 Syntax:
4709 @smallexample @c ada
4710 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4711 @end smallexample
4713 @noindent
4714 This pragma appears in the formal part of a generic declaration.
4715 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4716 the use of a remote access to class-wide type as actual for a formal
4717 access type.
4719 When this pragma applies to a formal access type @code{Entity}, that
4720 type is treated as a remote access to class-wide type in the generic.
4721 It must be a formal general access type, and its designated type must
4722 be the class-wide type of a formal tagged limited private type from the
4723 same generic declaration.
4725 In the generic unit, the formal type is subject to all restrictions
4726 pertaining to remote access to class-wide types. At instantiation, the
4727 actual type must be a remote access to class-wide type.
4729 @node Pragma Restriction_Warnings
4730 @unnumberedsec Pragma Restriction_Warnings
4731 @findex Restriction_Warnings
4732 @noindent
4733 Syntax:
4735 @smallexample @c ada
4736 pragma Restriction_Warnings
4737   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4738 @end smallexample
4740 @noindent
4741 This pragma allows a series of restriction identifiers to be
4742 specified (the list of allowed identifiers is the same as for
4743 pragma @code{Restrictions}). For each of these identifiers
4744 the compiler checks for violations of the restriction, but
4745 generates a warning message rather than an error message
4746 if the restriction is violated.
4748 @node Pragma Shared
4749 @unnumberedsec Pragma Shared
4750 @findex Shared
4752 @noindent
4753 This pragma is provided for compatibility with Ada 83. The syntax and
4754 semantics are identical to pragma Atomic.
4756 @node Pragma Short_Circuit_And_Or
4757 @unnumberedsec Pragma Short_Circuit_And_Or
4758 @findex Short_Circuit_And_Or
4760 @noindent
4761 This configuration pragma causes any occurrence of the AND operator applied to
4762 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4763 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4764 may be useful in the context of certification protocols requiring the use of
4765 short-circuited logical operators. If this configuration pragma occurs locally
4766 within the file being compiled, it applies only to the file being compiled.
4767 There is no requirement that all units in a partition use this option.
4769 @node Pragma Short_Descriptors
4770 @unnumberedsec Pragma Short_Descriptors
4771 @findex Short_Descriptors
4772 @noindent
4773 Syntax:
4775 @smallexample @c ada
4776 pragma Short_Descriptors
4777 @end smallexample
4779 @noindent
4780 In VMS versions of the compiler, this configuration pragma causes all
4781 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4782 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4783 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4784 versions.
4786 @node Pragma Simple_Storage_Pool_Type
4787 @unnumberedsec Pragma Simple_Storage_Pool_Type
4788 @findex Simple_Storage_Pool_Type
4789 @cindex Storage pool, simple
4790 @cindex Simple storage pool
4791 @noindent
4792 Syntax:
4794 @smallexample @c ada
4795 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4796 @end smallexample
4798 @noindent
4799 A type can be established as a ``simple storage pool type'' by applying
4800 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4801 A type named in the pragma must be a library-level immutably limited record
4802 type or limited tagged type declared immediately within a package declaration.
4803 The type can also be a limited private type whose full type is allowed as
4804 a simple storage pool type.
4806 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4807 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4808 are subtype conformant with the following subprogram declarations:
4810 @smallexample @c ada
4811 procedure Allocate
4812   (Pool                     : in out SSP;
4813    Storage_Address          : out System.Address;
4814    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4815    Alignment                : System.Storage_Elements.Storage_Count);
4817 procedure Deallocate
4818   (Pool : in out SSP;
4819    Storage_Address          : System.Address;
4820    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4821    Alignment                : System.Storage_Elements.Storage_Count);
4823 function Storage_Size (Pool : SSP)
4824   return System.Storage_Elements.Storage_Count;
4825 @end smallexample
4827 @noindent
4828 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4829 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4830 applying an unchecked deallocation has no effect other than to set its actual
4831 parameter to null. If @code{Storage_Size} is not declared, then the
4832 @code{Storage_Size} attribute applied to an access type associated with
4833 a pool object of type SSP returns zero. Additional operations can be declared
4834 for a simple storage pool type (such as for supporting a mark/release
4835 storage-management discipline).
4837 An object of a simple storage pool type can be associated with an access
4838 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4840 @smallexample @c ada
4842 My_Pool : My_Simple_Storage_Pool_Type;
4844 type Acc is access My_Data_Type;
4846 for Acc'Simple_Storage_Pool use My_Pool;
4848 @end smallexample
4850 @noindent
4851 See attribute @code{Simple_Storage_Pool} for further details.
4853 @node Pragma Source_File_Name
4854 @unnumberedsec Pragma Source_File_Name
4855 @findex Source_File_Name
4856 @noindent
4857 Syntax:
4859 @smallexample @c ada
4860 pragma Source_File_Name (
4861   [Unit_Name   =>] unit_NAME,
4862   Spec_File_Name =>  STRING_LITERAL,
4863   [Index => INTEGER_LITERAL]);
4865 pragma Source_File_Name (
4866   [Unit_Name   =>] unit_NAME,
4867   Body_File_Name =>  STRING_LITERAL,
4868   [Index => INTEGER_LITERAL]);
4869 @end smallexample
4871 @noindent
4872 Use this to override the normal naming convention.  It is a configuration
4873 pragma, and so has the usual applicability of configuration pragmas
4874 (i.e.@: it applies to either an entire partition, or to all units in a
4875 compilation, or to a single unit, depending on how it is used.
4876 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4877 the second argument is required, and indicates whether this is the file
4878 name for the spec or for the body.
4880 The optional Index argument should be used when a file contains multiple
4881 units, and when you do not want to use @code{gnatchop} to separate then
4882 into multiple files (which is the recommended procedure to limit the
4883 number of recompilations that are needed when some sources change).
4884 For instance, if the source file @file{source.ada} contains
4886 @smallexample @c ada
4887 package B is
4889 end B;
4891 with B;
4892 procedure A is
4893 begin
4894    ..
4895 end A;
4896 @end smallexample
4898 you could use the following configuration pragmas:
4900 @smallexample @c ada
4901 pragma Source_File_Name
4902   (B, Spec_File_Name => "source.ada", Index => 1);
4903 pragma Source_File_Name
4904   (A, Body_File_Name => "source.ada", Index => 2);
4905 @end smallexample
4907 Note that the @code{gnatname} utility can also be used to generate those
4908 configuration pragmas.
4910 Another form of the @code{Source_File_Name} pragma allows
4911 the specification of patterns defining alternative file naming schemes
4912 to apply to all files.
4914 @smallexample @c ada
4915 pragma Source_File_Name
4916   (  [Spec_File_Name  =>] STRING_LITERAL
4917    [,[Casing          =>] CASING_SPEC]
4918    [,[Dot_Replacement =>] STRING_LITERAL]);
4920 pragma Source_File_Name
4921   (  [Body_File_Name  =>] STRING_LITERAL
4922    [,[Casing          =>] CASING_SPEC]
4923    [,[Dot_Replacement =>] STRING_LITERAL]);
4925 pragma Source_File_Name
4926   (  [Subunit_File_Name =>] STRING_LITERAL
4927    [,[Casing            =>] CASING_SPEC]
4928    [,[Dot_Replacement   =>] STRING_LITERAL]);
4930 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4931 @end smallexample
4933 @noindent
4934 The first argument is a pattern that contains a single asterisk indicating
4935 the point at which the unit name is to be inserted in the pattern string
4936 to form the file name.  The second argument is optional.  If present it
4937 specifies the casing of the unit name in the resulting file name string.
4938 The default is lower case.  Finally the third argument allows for systematic
4939 replacement of any dots in the unit name by the specified string literal.
4941 Note that Source_File_Name pragmas should not be used if you are using
4942 project files. The reason for this rule is that the project manager is not
4943 aware of these pragmas, and so other tools that use the projet file would not
4944 be aware of the intended naming conventions. If you are using project files,
4945 file naming is controlled by Source_File_Name_Project pragmas, which are
4946 usually supplied automatically by the project manager. A pragma
4947 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4949 For more details on the use of the @code{Source_File_Name} pragma,
4950 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4951 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4952 User's Guide}.
4954 @node Pragma Source_File_Name_Project
4955 @unnumberedsec Pragma Source_File_Name_Project
4956 @findex Source_File_Name_Project
4957 @noindent
4959 This pragma has the same syntax and semantics as pragma Source_File_Name.
4960 It is only allowed as a stand alone configuration pragma.
4961 It cannot appear after a @ref{Pragma Source_File_Name}, and
4962 most importantly, once pragma Source_File_Name_Project appears,
4963 no further Source_File_Name pragmas are allowed.
4965 The intention is that Source_File_Name_Project pragmas are always
4966 generated by the Project Manager in a manner consistent with the naming
4967 specified in a project file, and when naming is controlled in this manner,
4968 it is not permissible to attempt to modify this naming scheme using
4969 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4970 known to the project manager).
4972 @node Pragma Source_Reference
4973 @unnumberedsec Pragma Source_Reference
4974 @findex Source_Reference
4975 @noindent
4976 Syntax:
4978 @smallexample @c ada
4979 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4980 @end smallexample
4982 @noindent
4983 This pragma must appear as the first line of a source file.
4984 @var{integer_literal} is the logical line number of the line following
4985 the pragma line (for use in error messages and debugging
4986 information).  @var{string_literal} is a static string constant that
4987 specifies the file name to be used in error messages and debugging
4988 information.  This is most notably used for the output of @code{gnatchop}
4989 with the @option{-r} switch, to make sure that the original unchopped
4990 source file is the one referred to.
4992 The second argument must be a string literal, it cannot be a static
4993 string expression other than a string literal.  This is because its value
4994 is needed for error messages issued by all phases of the compiler.
4996 @node Pragma Static_Elaboration_Desired
4997 @unnumberedsec Pragma Static_Elaboration_Desired
4998 @findex Static_Elaboration_Desired
4999 @noindent
5000 Syntax:
5002 @smallexample @c ada
5003 pragma Static_Elaboration_Desired;
5004 @end smallexample
5006 @noindent
5007 This pragma is used to indicate that the compiler should attempt to initialize
5008 statically the objects declared in the library unit to which the pragma applies,
5009 when these objects are initialized (explicitly or implicitly) by an aggregate.
5010 In the absence of this pragma, aggregates in object declarations are expanded
5011 into assignments and loops, even when the aggregate components are static
5012 constants. When the aggregate is present the compiler builds a static expression
5013 that requires no run-time code, so that the initialized object can be placed in
5014 read-only data space. If the components are not static, or the aggregate has
5015 more that 100 components, the compiler emits a warning that the pragma cannot
5016 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5017 construction of larger aggregates with static components that include an others
5018 choice.)
5020 @node Pragma Stream_Convert
5021 @unnumberedsec Pragma Stream_Convert
5022 @findex Stream_Convert
5023 @noindent
5024 Syntax:
5026 @smallexample @c ada
5027 pragma Stream_Convert (
5028   [Entity =>] type_LOCAL_NAME,
5029   [Read   =>] function_NAME,
5030   [Write  =>] function_NAME);
5031 @end smallexample
5033 @noindent
5034 This pragma provides an efficient way of providing stream functions for
5035 types defined in packages.  Not only is it simpler to use than declaring
5036 the necessary functions with attribute representation clauses, but more
5037 significantly, it allows the declaration to made in such a way that the
5038 stream packages are not loaded unless they are needed.  The use of
5039 the Stream_Convert pragma adds no overhead at all, unless the stream
5040 attributes are actually used on the designated type.
5042 The first argument specifies the type for which stream functions are
5043 provided.  The second parameter provides a function used to read values
5044 of this type.  It must name a function whose argument type may be any
5045 subtype, and whose returned type must be the type given as the first
5046 argument to the pragma.
5048 The meaning of the @var{Read}
5049 parameter is that if a stream attribute directly
5050 or indirectly specifies reading of the type given as the first parameter,
5051 then a value of the type given as the argument to the Read function is
5052 read from the stream, and then the Read function is used to convert this
5053 to the required target type.
5055 Similarly the @var{Write} parameter specifies how to treat write attributes
5056 that directly or indirectly apply to the type given as the first parameter.
5057 It must have an input parameter of the type specified by the first parameter,
5058 and the return type must be the same as the input type of the Read function.
5059 The effect is to first call the Write function to convert to the given stream
5060 type, and then write the result type to the stream.
5062 The Read and Write functions must not be overloaded subprograms.  If necessary
5063 renamings can be supplied to meet this requirement.
5064 The usage of this attribute is best illustrated by a simple example, taken
5065 from the GNAT implementation of package Ada.Strings.Unbounded:
5067 @smallexample @c ada
5068 function To_Unbounded (S : String)
5069            return Unbounded_String
5070   renames To_Unbounded_String;
5072 pragma Stream_Convert
5073   (Unbounded_String, To_Unbounded, To_String);
5074 @end smallexample
5076 @noindent
5077 The specifications of the referenced functions, as given in the Ada
5078 Reference Manual are:
5080 @smallexample @c ada
5081 function To_Unbounded_String (Source : String)
5082   return Unbounded_String;
5084 function To_String (Source : Unbounded_String)
5085   return String;
5086 @end smallexample
5088 @noindent
5089 The effect is that if the value of an unbounded string is written to a stream,
5090 then the representation of the item in the stream is in the same format that
5091 would be used for @code{Standard.String'Output}, and this same representation
5092 is expected when a value of this type is read from the stream. Note that the
5093 value written always includes the bounds, even for Unbounded_String'Write,
5094 since Unbounded_String is not an array type.
5096 @node Pragma Style_Checks
5097 @unnumberedsec Pragma Style_Checks
5098 @findex Style_Checks
5099 @noindent
5100 Syntax:
5102 @smallexample @c ada
5103 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5104                      On | Off [, LOCAL_NAME]);
5105 @end smallexample
5107 @noindent
5108 This pragma is used in conjunction with compiler switches to control the
5109 built in style checking provided by GNAT@.  The compiler switches, if set,
5110 provide an initial setting for the switches, and this pragma may be used
5111 to modify these settings, or the settings may be provided entirely by
5112 the use of the pragma.  This pragma can be used anywhere that a pragma
5113 is legal, including use as a configuration pragma (including use in
5114 the @file{gnat.adc} file).
5116 The form with a string literal specifies which style options are to be
5117 activated.  These are additive, so they apply in addition to any previously
5118 set style check options.  The codes for the options are the same as those
5119 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5120 For example the following two methods can be used to enable
5121 layout checking:
5123 @itemize @bullet
5124 @item
5125 @smallexample @c ada
5126 pragma Style_Checks ("l");
5127 @end smallexample
5129 @item
5130 @smallexample
5131 gcc -c -gnatyl @dots{}
5132 @end smallexample
5133 @end itemize
5135 @noindent
5136 The form ALL_CHECKS activates all standard checks (its use is equivalent
5137 to the use of the @code{gnaty} switch with no options.  @xref{Top,
5138 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5139 @value{EDITION} User's Guide}, for details.)
5141 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5142 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5143 options (i.e. equivalent to -gnatyg).
5145 The forms with @code{Off} and @code{On}
5146 can be used to temporarily disable style checks
5147 as shown in the following example:
5149 @smallexample @c ada
5150 @iftex
5151 @leftskip=0cm
5152 @end iftex
5153 pragma Style_Checks ("k"); -- requires keywords in lower case
5154 pragma Style_Checks (Off); -- turn off style checks
5155 NULL;                      -- this will not generate an error message
5156 pragma Style_Checks (On);  -- turn style checks back on
5157 NULL;                      -- this will generate an error message
5158 @end smallexample
5160 @noindent
5161 Finally the two argument form is allowed only if the first argument is
5162 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
5163 for the specified entity, as shown in the following example:
5165 @smallexample @c ada
5166 @iftex
5167 @leftskip=0cm
5168 @end iftex
5169 pragma Style_Checks ("r"); -- require consistency of identifier casing
5170 Arg : Integer;
5171 Rf1 : Integer := ARG;      -- incorrect, wrong case
5172 pragma Style_Checks (Off, Arg);
5173 Rf2 : Integer := ARG;      -- OK, no error
5174 @end smallexample
5176 @node Pragma Subtitle
5177 @unnumberedsec Pragma Subtitle
5178 @findex Subtitle
5179 @noindent
5180 Syntax:
5182 @smallexample @c ada
5183 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5184 @end smallexample
5186 @noindent
5187 This pragma is recognized for compatibility with other Ada compilers
5188 but is ignored by GNAT@.
5190 @node Pragma Suppress
5191 @unnumberedsec Pragma Suppress
5192 @findex Suppress
5193 @noindent
5194 Syntax:
5196 @smallexample @c ada
5197 pragma Suppress (Identifier [, [On =>] Name]);
5198 @end smallexample
5200 @noindent
5201 This is a standard pragma, and supports all the check names required in
5202 the RM. It is included here because GNAT recognizes one additional check
5203 name: @code{Alignment_Check} which can be used to suppress alignment checks
5204 on addresses used in address clauses. Such checks can also be suppressed
5205 by suppressing range checks, but the specific use of @code{Alignment_Check}
5206 allows suppression of alignment checks without suppressing other range checks.
5208 Note that pragma Suppress gives the compiler permission to omit
5209 checks, but does not require the compiler to omit checks. The compiler
5210 will generate checks if they are essentially free, even when they are
5211 suppressed. In particular, if the compiler can prove that a certain
5212 check will necessarily fail, it will generate code to do an
5213 unconditional ``raise'', even if checks are suppressed. The compiler
5214 warns in this case.
5216 Of course, run-time checks are omitted whenever the compiler can prove
5217 that they will not fail, whether or not checks are suppressed.
5219 @node Pragma Suppress_All
5220 @unnumberedsec Pragma Suppress_All
5221 @findex Suppress_All
5222 @noindent
5223 Syntax:
5225 @smallexample @c ada
5226 pragma Suppress_All;
5227 @end smallexample
5229 @noindent
5230 This pragma can appear anywhere within a unit.
5231 The effect is to apply @code{Suppress (All_Checks)} to the unit
5232 in which it appears.  This pragma is implemented for compatibility with DEC
5233 Ada 83 usage where it appears at the end of a unit, and for compatibility
5234 with Rational Ada, where it appears as a program unit pragma.
5235 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5236 as a normal configuration pragma is the preferred usage in GNAT@.
5238 @node Pragma Suppress_Exception_Locations
5239 @unnumberedsec Pragma Suppress_Exception_Locations
5240 @findex Suppress_Exception_Locations
5241 @noindent
5242 Syntax:
5244 @smallexample @c ada
5245 pragma Suppress_Exception_Locations;
5246 @end smallexample
5248 @noindent
5249 In normal mode, a raise statement for an exception by default generates
5250 an exception message giving the file name and line number for the location
5251 of the raise. This is useful for debugging and logging purposes, but this
5252 entails extra space for the strings for the messages. The configuration
5253 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5254 generation of these strings, with the result that space is saved, but the
5255 exception message for such raises is null. This configuration pragma may
5256 appear in a global configuration pragma file, or in a specific unit as
5257 usual. It is not required that this pragma be used consistently within
5258 a partition, so it is fine to have some units within a partition compiled
5259 with this pragma and others compiled in normal mode without it.
5261 @node Pragma Suppress_Initialization
5262 @unnumberedsec Pragma Suppress_Initialization
5263 @findex Suppress_Initialization
5264 @cindex Suppressing initialization
5265 @cindex Initialization, suppression of
5266 @noindent
5267 Syntax:
5269 @smallexample @c ada
5270 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5271 @end smallexample
5273 @noindent
5274 Here subtype_Name is the name introduced by a type declaration
5275 or subtype declaration.
5276 This pragma suppresses any implicit or explicit initialization
5277 for all variables of the given type or subtype,
5278 including initialization resulting from the use of pragmas
5279 Normalize_Scalars or Initialize_Scalars.
5281 This is considered a representation item, so it cannot be given after
5282 the type is frozen. It applies to all subsequent object declarations,
5283 and also any allocator that creates objects of the type.
5285 If the pragma is given for the first subtype, then it is considered
5286 to apply to the base type and all its subtypes. If the pragma is given
5287 for other than a first subtype, then it applies only to the given subtype.
5288 The pragma may not be given after the type is frozen.
5290 @node Pragma Task_Info
5291 @unnumberedsec Pragma Task_Info
5292 @findex Task_Info
5293 @noindent
5294 Syntax
5296 @smallexample @c ada
5297 pragma Task_Info (EXPRESSION);
5298 @end smallexample
5300 @noindent
5301 This pragma appears within a task definition (like pragma
5302 @code{Priority}) and applies to the task in which it appears.  The
5303 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5304 The @code{Task_Info} pragma provides system dependent control over
5305 aspects of tasking implementation, for example, the ability to map
5306 tasks to specific processors.  For details on the facilities available
5307 for the version of GNAT that you are using, see the documentation
5308 in the spec of package System.Task_Info in the runtime
5309 library.
5311 @node Pragma Task_Name
5312 @unnumberedsec Pragma Task_Name
5313 @findex Task_Name
5314 @noindent
5315 Syntax
5317 @smallexample @c ada
5318 pragma Task_Name (string_EXPRESSION);
5319 @end smallexample
5321 @noindent
5322 This pragma appears within a task definition (like pragma
5323 @code{Priority}) and applies to the task in which it appears.  The
5324 argument must be of type String, and provides a name to be used for
5325 the task instance when the task is created.  Note that this expression
5326 is not required to be static, and in particular, it can contain
5327 references to task discriminants.  This facility can be used to
5328 provide different names for different tasks as they are created,
5329 as illustrated in the example below.
5331 The task name is recorded internally in the run-time structures
5332 and is accessible to tools like the debugger.  In addition the
5333 routine @code{Ada.Task_Identification.Image} will return this
5334 string, with a unique task address appended.
5336 @smallexample @c ada
5337 --  Example of the use of pragma Task_Name
5339 with Ada.Task_Identification;
5340 use Ada.Task_Identification;
5341 with Text_IO; use Text_IO;
5342 procedure t3 is
5344    type Astring is access String;
5346    task type Task_Typ (Name : access String) is
5347       pragma Task_Name (Name.all);
5348    end Task_Typ;
5350    task body Task_Typ is
5351       Nam : constant String := Image (Current_Task);
5352    begin
5353       Put_Line ("-->" & Nam (1 .. 14) & "<--");
5354    end Task_Typ;
5356    type Ptr_Task is access Task_Typ;
5357    Task_Var : Ptr_Task;
5359 begin
5360    Task_Var :=
5361      new Task_Typ (new String'("This is task 1"));
5362    Task_Var :=
5363      new Task_Typ (new String'("This is task 2"));
5364 end;
5365 @end smallexample
5367 @node Pragma Task_Storage
5368 @unnumberedsec Pragma Task_Storage
5369 @findex Task_Storage
5370 Syntax:
5372 @smallexample @c ada
5373 pragma Task_Storage (
5374   [Task_Type =>] LOCAL_NAME,
5375   [Top_Guard =>] static_integer_EXPRESSION);
5376 @end smallexample
5378 @noindent
5379 This pragma specifies the length of the guard area for tasks.  The guard
5380 area is an additional storage area allocated to a task.  A value of zero
5381 means that either no guard area is created or a minimal guard area is
5382 created, depending on the target.  This pragma can appear anywhere a
5383 @code{Storage_Size} attribute definition clause is allowed for a task
5384 type.
5386 @node Pragma Test_Case
5387 @unnumberedsec Pragma Test_Case
5388 @cindex Test cases
5389 @findex Test_Case
5390 @noindent
5391 Syntax:
5393 @smallexample @c ada
5394 pragma Test_Case (
5395    [Name     =>] static_string_Expression
5396   ,[Mode     =>] (Nominal | Robustness)
5397  [, Requires =>  Boolean_Expression]
5398  [, Ensures  =>  Boolean_Expression]);
5399 @end smallexample
5401 @noindent
5402 The @code{Test_Case} pragma allows defining fine-grain specifications
5403 for use by testing tools. Its syntax is similar to the syntax of the
5404 @code{Contract_Case} pragma, which is used for both testing and
5405 formal verification.
5406 The compiler checks the validity of the @code{Test_Case} pragma, but its
5407 presence does not lead to any modification of the code generated by the
5408 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5410 @code{Test_Case} pragmas may only appear immediately following the
5411 (separate) declaration of a subprogram in a package declaration, inside
5412 a package spec unit. Only other pragmas may intervene (that is appear
5413 between the subprogram declaration and a test case).
5415 The compiler checks that boolean expressions given in @code{Requires} and
5416 @code{Ensures} are valid, where the rules for @code{Requires} are the
5417 same as the rule for an expression in @code{Precondition} and the rules
5418 for @code{Ensures} are the same as the rule for an expression in
5419 @code{Postcondition}. In particular, attributes @code{'Old} and
5420 @code{'Result} can only be used within the @code{Ensures}
5421 expression. The following is an example of use within a package spec:
5423 @smallexample @c ada
5424 package Math_Functions is
5425    ...
5426    function Sqrt (Arg : Float) return Float;
5427    pragma Test_Case (Name     => "Test 1",
5428                      Mode     => Nominal,
5429                      Requires => Arg < 10000,
5430                      Ensures  => Sqrt'Result < 10);
5431    ...
5432 end Math_Functions;
5433 @end smallexample
5435 @noindent
5436 The meaning of a test case is that there is at least one context where
5437 @code{Requires} holds such that, if the associated subprogram is executed in
5438 that context, then @code{Ensures} holds when the subprogram returns.
5439 Mode @code{Nominal} indicates that the input context should also satisfy the
5440 precondition of the subprogram, and the output context should also satisfy its
5441 postcondition. More @code{Robustness} indicates that the precondition and
5442 postcondition of the subprogram should be ignored for this test case.
5444 @node Pragma Thread_Local_Storage
5445 @unnumberedsec Pragma Thread_Local_Storage
5446 @findex Thread_Local_Storage
5447 @cindex Task specific storage
5448 @cindex TLS (Thread Local Storage)
5449 Syntax:
5451 @smallexample @c ada
5452 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5453 @end smallexample
5455 @noindent
5456 This pragma specifies that the specified entity, which must be
5457 a variable declared in a library level package, is to be marked as
5458 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5459 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5460 (and hence each Ada task) to see a distinct copy of the variable.
5462 The variable may not have default initialization, and if there is
5463 an explicit initialization, it must be either @code{null} for an
5464 access variable, or a static expression for a scalar variable.
5465 This provides a low level mechanism similar to that provided by
5466 the @code{Ada.Task_Attributes} package, but much more efficient
5467 and is also useful in writing interface code that will interact
5468 with foreign threads.
5470 If this pragma is used on a system where @code{TLS} is not supported,
5471 then an error message will be generated and the program will be rejected.
5473 @node Pragma Time_Slice
5474 @unnumberedsec Pragma Time_Slice
5475 @findex Time_Slice
5476 @noindent
5477 Syntax:
5479 @smallexample @c ada
5480 pragma Time_Slice (static_duration_EXPRESSION);
5481 @end smallexample
5483 @noindent
5484 For implementations of GNAT on operating systems where it is possible
5485 to supply a time slice value, this pragma may be used for this purpose.
5486 It is ignored if it is used in a system that does not allow this control,
5487 or if it appears in other than the main program unit.
5488 @cindex OpenVMS
5489 Note that the effect of this pragma is identical to the effect of the
5490 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5492 @node Pragma Title
5493 @unnumberedsec Pragma Title
5494 @findex Title
5495 @noindent
5496 Syntax:
5498 @smallexample @c ada
5499 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5501 TITLING_OPTION ::=
5502   [Title    =>] STRING_LITERAL,
5503 | [Subtitle =>] STRING_LITERAL
5504 @end smallexample
5506 @noindent
5507 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
5508 pragma used in DEC Ada 83 implementations to provide a title and/or
5509 subtitle for the program listing.  The program listing generated by GNAT
5510 does not have titles or subtitles.
5512 Unlike other pragmas, the full flexibility of named notation is allowed
5513 for this pragma, i.e.@: the parameters may be given in any order if named
5514 notation is used, and named and positional notation can be mixed
5515 following the normal rules for procedure calls in Ada.
5517 @node Pragma Unchecked_Union
5518 @unnumberedsec Pragma Unchecked_Union
5519 @cindex Unions in C
5520 @findex Unchecked_Union
5521 @noindent
5522 Syntax:
5524 @smallexample @c ada
5525 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5526 @end smallexample
5528 @noindent
5529 This pragma is used to specify a representation of a record type that is
5530 equivalent to a C union. It was introduced as a GNAT implementation defined
5531 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5532 pragma, making it language defined, and GNAT fully implements this extended
5533 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5534 details, consult the Ada 2005 Reference Manual, section B.3.3.
5536 @node Pragma Unimplemented_Unit
5537 @unnumberedsec Pragma Unimplemented_Unit
5538 @findex Unimplemented_Unit
5539 @noindent
5540 Syntax:
5542 @smallexample @c ada
5543 pragma Unimplemented_Unit;
5544 @end smallexample
5546 @noindent
5547 If this pragma occurs in a unit that is processed by the compiler, GNAT
5548 aborts with the message @samp{@var{xxx} not implemented}, where
5549 @var{xxx} is the name of the current compilation unit.  This pragma is
5550 intended to allow the compiler to handle unimplemented library units in
5551 a clean manner.
5553 The abort only happens if code is being generated.  Thus you can use
5554 specs of unimplemented packages in syntax or semantic checking mode.
5556 @node Pragma Universal_Aliasing
5557 @unnumberedsec Pragma Universal_Aliasing
5558 @findex Universal_Aliasing
5559 @noindent
5560 Syntax:
5562 @smallexample @c ada
5563 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5564 @end smallexample
5566 @noindent
5567 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5568 declarative part.  The effect is to inhibit strict type-based aliasing
5569 optimization for the given type.  In other words, the effect is as though
5570 access types designating this type were subject to pragma No_Strict_Aliasing.
5571 For a detailed description of the strict aliasing optimization, and the
5572 situations in which it must be suppressed, @xref{Optimization and Strict
5573 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5575 @node Pragma Universal_Data
5576 @unnumberedsec Pragma Universal_Data
5577 @findex Universal_Data
5578 @noindent
5579 Syntax:
5581 @smallexample @c ada
5582 pragma Universal_Data [(library_unit_Name)];
5583 @end smallexample
5585 @noindent
5586 This pragma is supported only for the AAMP target and is ignored for
5587 other targets. The pragma specifies that all library-level objects
5588 (Counter 0 data) associated with the library unit are to be accessed
5589 and updated using universal addressing (24-bit addresses for AAMP5)
5590 rather than the default of 16-bit Data Environment (DENV) addressing.
5591 Use of this pragma will generally result in less efficient code for
5592 references to global data associated with the library unit, but
5593 allows such data to be located anywhere in memory. This pragma is
5594 a library unit pragma, but can also be used as a configuration pragma
5595 (including use in the @file{gnat.adc} file). The functionality
5596 of this pragma is also available by applying the -univ switch on the
5597 compilations of units where universal addressing of the data is desired.
5599 @node Pragma Unmodified
5600 @unnumberedsec Pragma Unmodified
5601 @findex Unmodified
5602 @cindex Warnings, unmodified
5603 @noindent
5604 Syntax:
5606 @smallexample @c ada
5607 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5608 @end smallexample
5610 @noindent
5611 This pragma signals that the assignable entities (variables,
5612 @code{out} parameters, @code{in out} parameters) whose names are listed are
5613 deliberately not assigned in the current source unit. This
5614 suppresses warnings about the
5615 entities being referenced but not assigned, and in addition a warning will be
5616 generated if one of these entities is in fact assigned in the
5617 same unit as the pragma (or in the corresponding body, or one
5618 of its subunits).
5620 This is particularly useful for clearly signaling that a particular
5621 parameter is not modified, even though the spec suggests that it might
5624 @node Pragma Unreferenced
5625 @unnumberedsec Pragma Unreferenced
5626 @findex Unreferenced
5627 @cindex Warnings, unreferenced
5628 @noindent
5629 Syntax:
5631 @smallexample @c ada
5632 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5633 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5634 @end smallexample
5636 @noindent
5637 This pragma signals that the entities whose names are listed are
5638 deliberately not referenced in the current source unit. This
5639 suppresses warnings about the
5640 entities being unreferenced, and in addition a warning will be
5641 generated if one of these entities is in fact subsequently referenced in the
5642 same unit as the pragma (or in the corresponding body, or one
5643 of its subunits).
5645 This is particularly useful for clearly signaling that a particular
5646 parameter is not referenced in some particular subprogram implementation
5647 and that this is deliberate. It can also be useful in the case of
5648 objects declared only for their initialization or finalization side
5649 effects.
5651 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5652 current scope, then the entity most recently declared is the one to which
5653 the pragma applies. Note that in the case of accept formals, the pragma
5654 Unreferenced may appear immediately after the keyword @code{do} which
5655 allows the indication of whether or not accept formals are referenced
5656 or not to be given individually for each accept statement.
5658 The left hand side of an assignment does not count as a reference for the
5659 purpose of this pragma. Thus it is fine to assign to an entity for which
5660 pragma Unreferenced is given.
5662 Note that if a warning is desired for all calls to a given subprogram,
5663 regardless of whether they occur in the same unit as the subprogram
5664 declaration, then this pragma should not be used (calls from another
5665 unit would not be flagged); pragma Obsolescent can be used instead
5666 for this purpose, see @xref{Pragma Obsolescent}.
5668 The second form of pragma @code{Unreferenced} is used within a context
5669 clause. In this case the arguments must be unit names of units previously
5670 mentioned in @code{with} clauses (similar to the usage of pragma
5671 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5672 units and unreferenced entities within these units.
5674 @node Pragma Unreferenced_Objects
5675 @unnumberedsec Pragma Unreferenced_Objects
5676 @findex Unreferenced_Objects
5677 @cindex Warnings, unreferenced
5678 @noindent
5679 Syntax:
5681 @smallexample @c ada
5682 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5683 @end smallexample
5685 @noindent
5686 This pragma signals that for the types or subtypes whose names are
5687 listed, objects which are declared with one of these types or subtypes may
5688 not be referenced, and if no references appear, no warnings are given.
5690 This is particularly useful for objects which are declared solely for their
5691 initialization and finalization effect. Such variables are sometimes referred
5692 to as RAII variables (Resource Acquisition Is Initialization). Using this
5693 pragma on the relevant type (most typically a limited controlled type), the
5694 compiler will automatically suppress unwanted warnings about these variables
5695 not being referenced.
5697 @node Pragma Unreserve_All_Interrupts
5698 @unnumberedsec Pragma Unreserve_All_Interrupts
5699 @findex Unreserve_All_Interrupts
5700 @noindent
5701 Syntax:
5703 @smallexample @c ada
5704 pragma Unreserve_All_Interrupts;
5705 @end smallexample
5707 @noindent
5708 Normally certain interrupts are reserved to the implementation.  Any attempt
5709 to attach an interrupt causes Program_Error to be raised, as described in
5710 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5711 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5712 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5713 interrupt execution.
5715 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5716 a program, then all such interrupts are unreserved.  This allows the
5717 program to handle these interrupts, but disables their standard
5718 functions.  For example, if this pragma is used, then pressing
5719 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
5720 a program can then handle the @code{SIGINT} interrupt as it chooses.
5722 For a full list of the interrupts handled in a specific implementation,
5723 see the source code for the spec of @code{Ada.Interrupts.Names} in
5724 file @file{a-intnam.ads}.  This is a target dependent file that contains the
5725 list of interrupts recognized for a given target.  The documentation in
5726 this file also specifies what interrupts are affected by the use of
5727 the @code{Unreserve_All_Interrupts} pragma.
5729 For a more general facility for controlling what interrupts can be
5730 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5731 of the @code{Unreserve_All_Interrupts} pragma.
5733 @node Pragma Unsuppress
5734 @unnumberedsec Pragma Unsuppress
5735 @findex Unsuppress
5736 @noindent
5737 Syntax:
5739 @smallexample @c ada
5740 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5741 @end smallexample
5743 @noindent
5744 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5745 there is no corresponding pragma @code{Suppress} in effect, it has no
5746 effect.  The range of the effect is the same as for pragma
5747 @code{Suppress}.  The meaning of the arguments is identical to that used
5748 in pragma @code{Suppress}.
5750 One important application is to ensure that checks are on in cases where
5751 code depends on the checks for its correct functioning, so that the code
5752 will compile correctly even if the compiler switches are set to suppress
5753 checks.
5755 @node Pragma Use_VADS_Size
5756 @unnumberedsec Pragma Use_VADS_Size
5757 @cindex @code{Size}, VADS compatibility
5758 @findex Use_VADS_Size
5759 @noindent
5760 Syntax:
5762 @smallexample @c ada
5763 pragma Use_VADS_Size;
5764 @end smallexample
5766 @noindent
5767 This is a configuration pragma.  In a unit to which it applies, any use
5768 of the 'Size attribute is automatically interpreted as a use of the
5769 'VADS_Size attribute.  Note that this may result in incorrect semantic
5770 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5771 the handling of existing code which depends on the interpretation of Size
5772 as implemented in the VADS compiler.  See description of the VADS_Size
5773 attribute for further details.
5775 @node Pragma Validity_Checks
5776 @unnumberedsec Pragma Validity_Checks
5777 @findex Validity_Checks
5778 @noindent
5779 Syntax:
5781 @smallexample @c ada
5782 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5783 @end smallexample
5785 @noindent
5786 This pragma is used in conjunction with compiler switches to control the
5787 built-in validity checking provided by GNAT@.  The compiler switches, if set
5788 provide an initial setting for the switches, and this pragma may be used
5789 to modify these settings, or the settings may be provided entirely by
5790 the use of the pragma.  This pragma can be used anywhere that a pragma
5791 is legal, including use as a configuration pragma (including use in
5792 the @file{gnat.adc} file).
5794 The form with a string literal specifies which validity options are to be
5795 activated.  The validity checks are first set to include only the default
5796 reference manual settings, and then a string of letters in the string
5797 specifies the exact set of options required.  The form of this string
5798 is exactly as described for the @option{-gnatVx} compiler switch (see the
5799 @value{EDITION} User's Guide for details).  For example the following two
5800 methods can be used to enable validity checking for mode @code{in} and
5801 @code{in out} subprogram parameters:
5803 @itemize @bullet
5804 @item
5805 @smallexample @c ada
5806 pragma Validity_Checks ("im");
5807 @end smallexample
5809 @item
5810 @smallexample
5811 gcc -c -gnatVim @dots{}
5812 @end smallexample
5813 @end itemize
5815 @noindent
5816 The form ALL_CHECKS activates all standard checks (its use is equivalent
5817 to the use of the @code{gnatva} switch.
5819 The forms with @code{Off} and @code{On}
5820 can be used to temporarily disable validity checks
5821 as shown in the following example:
5823 @smallexample @c ada
5824 @iftex
5825 @leftskip=0cm
5826 @end iftex
5827 pragma Validity_Checks ("c"); -- validity checks for copies
5828 pragma Validity_Checks (Off); -- turn off validity checks
5829 A := B;                       -- B will not be validity checked
5830 pragma Validity_Checks (On);  -- turn validity checks back on
5831 A := C;                       -- C will be validity checked
5832 @end smallexample
5834 @node Pragma Volatile
5835 @unnumberedsec Pragma Volatile
5836 @findex Volatile
5837 @noindent
5838 Syntax:
5840 @smallexample @c ada
5841 pragma Volatile (LOCAL_NAME);
5842 @end smallexample
5844 @noindent
5845 This pragma is defined by the Ada Reference Manual, and the GNAT
5846 implementation is fully conformant with this definition.  The reason it
5847 is mentioned in this section is that a pragma of the same name was supplied
5848 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5849 implementation of pragma Volatile is upwards compatible with the
5850 implementation in DEC Ada 83.
5852 @node Pragma Warnings
5853 @unnumberedsec Pragma Warnings
5854 @findex Warnings
5855 @noindent
5856 Syntax:
5858 @smallexample @c ada
5859 pragma Warnings (On | Off);
5860 pragma Warnings (On | Off, LOCAL_NAME);
5861 pragma Warnings (static_string_EXPRESSION);
5862 pragma Warnings (On | Off, static_string_EXPRESSION);
5863 @end smallexample
5865 @noindent
5866 Normally warnings are enabled, with the output being controlled by
5867 the command line switch.  Warnings (@code{Off}) turns off generation of
5868 warnings until a Warnings (@code{On}) is encountered or the end of the
5869 current unit.  If generation of warnings is turned off using this
5870 pragma, then no warning messages are output, regardless of the
5871 setting of the command line switches.
5873 The form with a single argument may be used as a configuration pragma.
5875 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5876 the specified entity.  This suppression is effective from the point where
5877 it occurs till the end of the extended scope of the variable (similar to
5878 the scope of @code{Suppress}).
5880 The form with a single static_string_EXPRESSION argument provides more precise
5881 control over which warnings are active. The string is a list of letters
5882 specifying which warnings are to be activated and which deactivated. The
5883 code for these letters is the same as the string used in the command
5884 line switch controlling warnings. For a brief summary, use the gnatmake
5885 command with no arguments, which will generate usage information containing
5886 the list of warnings switches supported. For
5887 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5888 User's Guide}.
5890 @noindent
5891 The specified warnings will be in effect until the end of the program
5892 or another pragma Warnings is encountered. The effect of the pragma is
5893 cumulative. Initially the set of warnings is the standard default set
5894 as possibly modified by compiler switches. Then each pragma Warning
5895 modifies this set of warnings as specified. This form of the pragma may
5896 also be used as a configuration pragma.
5898 The fourth form, with an @code{On|Off} parameter and a string, is used to
5899 control individual messages, based on their text. The string argument
5900 is a pattern that is used to match against the text of individual
5901 warning messages (not including the initial "warning: " tag).
5903 The pattern may contain asterisks, which match zero or more characters in
5904 the message. For example, you can use
5905 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5906 message @code{warning: 960 bits of "a" unused}. No other regular
5907 expression notations are permitted. All characters other than asterisk in
5908 these three specific cases are treated as literal characters in the match.
5910 There are two ways to use the pragma in this form. The OFF form can be used as a
5911 configuration pragma. The effect is to suppress all warnings (if any)
5912 that match the pattern string throughout the compilation.
5914 The second usage is to suppress a warning locally, and in this case, two
5915 pragmas must appear in sequence:
5917 @smallexample @c ada
5918 pragma Warnings (Off, Pattern);
5919 @dots{} code where given warning is to be suppressed
5920 pragma Warnings (On, Pattern);
5921 @end smallexample
5923 @noindent
5924 In this usage, the pattern string must match in the Off and On pragmas,
5925 and at least one matching warning must be suppressed.
5927 Note: to write a string that will match any warning, use the string
5928 @code{"***"}. It will not work to use a single asterisk or two asterisks
5929 since this looks like an operator name. This form with three asterisks
5930 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5931 matching @code{pragma Warnings (On, "***")} will be required. This can be
5932 helpful in avoiding forgetting to turn warnings back on.
5934 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5935 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5936 be useful in checking whether obsolete pragmas in existing programs are hiding
5937 real problems.
5939 Note: pragma Warnings does not affect the processing of style messages. See
5940 separate entry for pragma Style_Checks for control of style messages.
5942 @node Pragma Weak_External
5943 @unnumberedsec Pragma Weak_External
5944 @findex Weak_External
5945 @noindent
5946 Syntax:
5948 @smallexample @c ada
5949 pragma Weak_External ([Entity =>] LOCAL_NAME);
5950 @end smallexample
5952 @noindent
5953 @var{LOCAL_NAME} must refer to an object that is declared at the library
5954 level. This pragma specifies that the given entity should be marked as a
5955 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5956 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5957 of a regular symbol, that is to say a symbol that does not have to be
5958 resolved by the linker if used in conjunction with a pragma Import.
5960 When a weak symbol is not resolved by the linker, its address is set to
5961 zero. This is useful in writing interfaces to external modules that may
5962 or may not be linked in the final executable, for example depending on
5963 configuration settings.
5965 If a program references at run time an entity to which this pragma has been
5966 applied, and the corresponding symbol was not resolved at link time, then
5967 the execution of the program is erroneous. It is not erroneous to take the
5968 Address of such an entity, for example to guard potential references,
5969 as shown in the example below.
5971 Some file formats do not support weak symbols so not all target machines
5972 support this pragma.
5974 @smallexample @c ada
5975 --  Example of the use of pragma Weak_External
5977 package External_Module is
5978   key : Integer;
5979   pragma Import (C, key);
5980   pragma Weak_External (key);
5981   function Present return boolean;
5982 end External_Module;
5984 with System; use System;
5985 package body External_Module is
5986   function Present return boolean is
5987   begin
5988     return key'Address /= System.Null_Address;
5989   end Present;
5990 end External_Module;
5991 @end smallexample
5993 @node Pragma Wide_Character_Encoding
5994 @unnumberedsec Pragma Wide_Character_Encoding
5995 @findex Wide_Character_Encoding
5996 @noindent
5997 Syntax:
5999 @smallexample @c ada
6000 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6001 @end smallexample
6003 @noindent
6004 This pragma specifies the wide character encoding to be used in program
6005 source text appearing subsequently. It is a configuration pragma, but may
6006 also be used at any point that a pragma is allowed, and it is permissible
6007 to have more than one such pragma in a file, allowing multiple encodings
6008 to appear within the same file.
6010 The argument can be an identifier or a character literal. In the identifier
6011 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6012 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6013 case it is correspondingly one of the characters @samp{h}, @samp{u},
6014 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6016 Note that when the pragma is used within a file, it affects only the
6017 encoding within that file, and does not affect withed units, specs,
6018 or subunits.
6020 @node Implementation Defined Attributes
6021 @chapter Implementation Defined Attributes
6022 Ada defines (throughout the Ada reference manual,
6023 summarized in Annex K),
6024 a set of attributes that provide useful additional functionality in all
6025 areas of the language.  These language defined attributes are implemented
6026 in GNAT and work as described in the Ada Reference Manual.
6028 In addition, Ada allows implementations to define additional
6029 attributes whose meaning is defined by the implementation.  GNAT provides
6030 a number of these implementation-dependent attributes which can be used
6031 to extend and enhance the functionality of the compiler.  This section of
6032 the GNAT reference manual describes these additional attributes.
6034 Note that any program using these attributes may not be portable to
6035 other compilers (although GNAT implements this set of attributes on all
6036 platforms).  Therefore if portability to other compilers is an important
6037 consideration, you should minimize the use of these attributes.
6039 @menu
6040 * Abort_Signal::
6041 * Address_Size::
6042 * Asm_Input::
6043 * Asm_Output::
6044 * AST_Entry::
6045 * Bit::
6046 * Bit_Position::
6047 * Compiler_Version::
6048 * Code_Address::
6049 * Default_Bit_Order::
6050 * Descriptor_Size::
6051 * Elaborated::
6052 * Elab_Body::
6053 * Elab_Spec::
6054 * Elab_Subp_Body::
6055 * Emax::
6056 * Enabled::
6057 * Enum_Rep::
6058 * Enum_Val::
6059 * Epsilon::
6060 * Fixed_Value::
6061 * Has_Access_Values::
6062 * Has_Discriminants::
6063 * Img::
6064 * Integer_Value::
6065 * Invalid_Value::
6066 * Large::
6067 * Machine_Size::
6068 * Mantissa::
6069 * Max_Interrupt_Priority::
6070 * Max_Priority::
6071 * Maximum_Alignment::
6072 * Mechanism_Code::
6073 * Null_Parameter::
6074 * Object_Size::
6075 * Passed_By_Reference::
6076 * Pool_Address::
6077 * Range_Length::
6078 * Ref::
6079 * Result::
6080 * Safe_Emax::
6081 * Safe_Large::
6082 * Scalar_Storage_Order::
6083 * Simple_Storage_Pool::
6084 * Small::
6085 * Storage_Unit::
6086 * Stub_Type::
6087 * System_Allocator_Alignment::
6088 * Target_Name::
6089 * Tick::
6090 * To_Address::
6091 * Type_Class::
6092 * UET_Address::
6093 * Unconstrained_Array::
6094 * Universal_Literal_String::
6095 * Unrestricted_Access::
6096 * Valid_Scalars::
6097 * VADS_Size::
6098 * Value_Size::
6099 * Wchar_T_Size::
6100 * Word_Size::
6101 @end menu
6103 @node Abort_Signal
6104 @unnumberedsec Abort_Signal
6105 @findex Abort_Signal
6106 @noindent
6107 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6108 prefix) provides the entity for the special exception used to signal
6109 task abort or asynchronous transfer of control.  Normally this attribute
6110 should only be used in the tasking runtime (it is highly peculiar, and
6111 completely outside the normal semantics of Ada, for a user program to
6112 intercept the abort exception).
6114 @node Address_Size
6115 @unnumberedsec Address_Size
6116 @cindex Size of @code{Address}
6117 @findex Address_Size
6118 @noindent
6119 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6120 prefix) is a static constant giving the number of bits in an
6121 @code{Address}. It is the same value as System.Address'Size,
6122 but has the advantage of being static, while a direct
6123 reference to System.Address'Size is non-static because Address
6124 is a private type.
6126 @node Asm_Input
6127 @unnumberedsec Asm_Input
6128 @findex Asm_Input
6129 @noindent
6130 The @code{Asm_Input} attribute denotes a function that takes two
6131 parameters.  The first is a string, the second is an expression of the
6132 type designated by the prefix.  The first (string) argument is required
6133 to be a static expression, and is the constraint for the parameter,
6134 (e.g.@: what kind of register is required).  The second argument is the
6135 value to be used as the input argument.  The possible values for the
6136 constant are the same as those used in the RTL, and are dependent on
6137 the configuration file used to built the GCC back end.
6138 @ref{Machine Code Insertions}
6140 @node Asm_Output
6141 @unnumberedsec Asm_Output
6142 @findex Asm_Output
6143 @noindent
6144 The @code{Asm_Output} attribute denotes a function that takes two
6145 parameters.  The first is a string, the second is the name of a variable
6146 of the type designated by the attribute prefix.  The first (string)
6147 argument is required to be a static expression and designates the
6148 constraint for the parameter (e.g.@: what kind of register is
6149 required).  The second argument is the variable to be updated with the
6150 result.  The possible values for constraint are the same as those used in
6151 the RTL, and are dependent on the configuration file used to build the
6152 GCC back end.  If there are no output operands, then this argument may
6153 either be omitted, or explicitly given as @code{No_Output_Operands}.
6154 @ref{Machine Code Insertions}
6156 @node AST_Entry
6157 @unnumberedsec AST_Entry
6158 @cindex OpenVMS
6159 @findex AST_Entry
6160 @noindent
6161 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
6162 the name of an entry, it yields a value of the predefined type AST_Handler
6163 (declared in the predefined package System, as extended by the use of
6164 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
6165 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
6166 Language Reference Manual}, section 9.12a.
6168 @node Bit
6169 @unnumberedsec Bit
6170 @findex Bit
6171 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6172 offset within the storage unit (byte) that contains the first bit of
6173 storage allocated for the object.  The value of this attribute is of the
6174 type @code{Universal_Integer}, and is always a non-negative number not
6175 exceeding the value of @code{System.Storage_Unit}.
6177 For an object that is a variable or a constant allocated in a register,
6178 the value is zero.  (The use of this attribute does not force the
6179 allocation of a variable to memory).
6181 For an object that is a formal parameter, this attribute applies
6182 to either the matching actual parameter or to a copy of the
6183 matching actual parameter.
6185 For an access object the value is zero.  Note that
6186 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6187 designated object.  Similarly for a record component
6188 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6189 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6190 are subject to index checks.
6192 This attribute is designed to be compatible with the DEC Ada 83 definition
6193 and implementation of the @code{Bit} attribute.
6195 @node Bit_Position
6196 @unnumberedsec Bit_Position
6197 @findex Bit_Position
6198 @noindent
6199 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6200 of the fields of the record type, yields the bit
6201 offset within the record contains the first bit of
6202 storage allocated for the object.  The value of this attribute is of the
6203 type @code{Universal_Integer}.  The value depends only on the field
6204 @var{C} and is independent of the alignment of
6205 the containing record @var{R}.
6207 @node Compiler_Version
6208 @unnumberedsec Compiler_Version
6209 @findex Compiler_Version
6210 @noindent
6211 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6212 prefix) yields a static string identifying the version of the compiler
6213 being used to compile the unit containing the attribute reference. A
6214 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6216 @node Code_Address
6217 @unnumberedsec Code_Address
6218 @findex Code_Address
6219 @cindex Subprogram address
6220 @cindex Address of subprogram code
6221 @noindent
6222 The @code{'Address}
6223 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6224 intended effect seems to be to provide
6225 an address value which can be used to call the subprogram by means of
6226 an address clause as in the following example:
6228 @smallexample @c ada
6229 procedure K is @dots{}
6231 procedure L;
6232 for L'Address use K'Address;
6233 pragma Import (Ada, L);
6234 @end smallexample
6236 @noindent
6237 A call to @code{L} is then expected to result in a call to @code{K}@.
6238 In Ada 83, where there were no access-to-subprogram values, this was
6239 a common work-around for getting the effect of an indirect call.
6240 GNAT implements the above use of @code{Address} and the technique
6241 illustrated by the example code works correctly.
6243 However, for some purposes, it is useful to have the address of the start
6244 of the generated code for the subprogram.  On some architectures, this is
6245 not necessarily the same as the @code{Address} value described above.
6246 For example, the @code{Address} value may reference a subprogram
6247 descriptor rather than the subprogram itself.
6249 The @code{'Code_Address} attribute, which can only be applied to
6250 subprogram entities, always returns the address of the start of the
6251 generated code of the specified subprogram, which may or may not be
6252 the same value as is returned by the corresponding @code{'Address}
6253 attribute.
6255 @node Default_Bit_Order
6256 @unnumberedsec Default_Bit_Order
6257 @cindex Big endian
6258 @cindex Little endian
6259 @findex Default_Bit_Order
6260 @noindent
6261 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6262 permissible prefix), provides the value @code{System.Default_Bit_Order}
6263 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6264 @code{Low_Order_First}).  This is used to construct the definition of
6265 @code{Default_Bit_Order} in package @code{System}.
6267 @node Descriptor_Size
6268 @unnumberedsec Descriptor_Size
6269 @cindex Descriptor
6270 @cindex Dope vector
6271 @findex Descriptor_Size
6272 @noindent
6273 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6274 descriptor allocated for a type.  The result is non-zero only for unconstrained
6275 array types and the returned value is of type universal integer.  In GNAT, an
6276 array descriptor contains bounds information and is located immediately before
6277 the first element of the array.
6279 @smallexample @c ada
6280 type Unconstr_Array is array (Positive range <>) of Boolean;
6281 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6282 @end smallexample
6284 @noindent
6285 The attribute takes into account any additional padding due to type alignment.
6286 In the example above, the descriptor contains two values of type
6287 @code{Positive} representing the low and high bound.  Since @code{Positive} has
6288 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6289 Positive'Size + 2} or 64 bits.
6291 @node Elaborated
6292 @unnumberedsec Elaborated
6293 @findex Elaborated
6294 @noindent
6295 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
6296 value is a Boolean which indicates whether or not the given unit has been
6297 elaborated.  This attribute is primarily intended for internal use by the
6298 generated code for dynamic elaboration checking, but it can also be used
6299 in user programs.  The value will always be True once elaboration of all
6300 units has been completed.  An exception is for units which need no
6301 elaboration, the value is always False for such units.
6303 @node Elab_Body
6304 @unnumberedsec Elab_Body
6305 @findex Elab_Body
6306 @noindent
6307 This attribute can only be applied to a program unit name.  It returns
6308 the entity for the corresponding elaboration procedure for elaborating
6309 the body of the referenced unit.  This is used in the main generated
6310 elaboration procedure by the binder and is not normally used in any
6311 other context.  However, there may be specialized situations in which it
6312 is useful to be able to call this elaboration procedure from Ada code,
6313 e.g.@: if it is necessary to do selective re-elaboration to fix some
6314 error.
6316 @node Elab_Spec
6317 @unnumberedsec Elab_Spec
6318 @findex Elab_Spec
6319 @noindent
6320 This attribute can only be applied to a program unit name.  It returns
6321 the entity for the corresponding elaboration procedure for elaborating
6322 the spec of the referenced unit.  This is used in the main
6323 generated elaboration procedure by the binder and is not normally used
6324 in any other context.  However, there may be specialized situations in
6325 which it is useful to be able to call this elaboration procedure from
6326 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6327 some error.
6329 @node Elab_Subp_Body
6330 @unnumberedsec Elab_Subp_Body
6331 @findex Elab_Subp_Body
6332 @noindent
6333 This attribute can only be applied to a library level subprogram
6334 name and is only allowed in CodePeer mode. It returns the entity
6335 for the corresponding elaboration procedure for elaborating the body
6336 of the referenced subprogram unit. This is used in the main generated
6337 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6338 otherwise.
6340 @node Emax
6341 @unnumberedsec Emax
6342 @cindex Ada 83 attributes
6343 @findex Emax
6344 @noindent
6345 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
6346 the Ada 83 reference manual for an exact description of the semantics of
6347 this attribute.
6349 @node Enabled
6350 @unnumberedsec Enabled
6351 @findex Enabled
6352 @noindent
6353 The @code{Enabled} attribute allows an application program to check at compile
6354 time to see if the designated check is currently enabled. The prefix is a
6355 simple identifier, referencing any predefined check name (other than
6356 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6357 no argument is given for the attribute, the check is for the general state
6358 of the check, if an argument is given, then it is an entity name, and the
6359 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6360 given naming the entity (if not, then the argument is ignored).
6362 Note that instantiations inherit the check status at the point of the
6363 instantiation, so a useful idiom is to have a library package that
6364 introduces a check name with @code{pragma Check_Name}, and then contains
6365 generic packages or subprograms which use the @code{Enabled} attribute
6366 to see if the check is enabled. A user of this package can then issue
6367 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6368 the package or subprogram, controlling whether the check will be present.
6370 @node Enum_Rep
6371 @unnumberedsec Enum_Rep
6372 @cindex Representation of enums
6373 @findex Enum_Rep
6374 @noindent
6375 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6376 function with the following spec:
6378 @smallexample @c ada
6379 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6380   return @i{Universal_Integer};
6381 @end smallexample
6383 @noindent
6384 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6385 enumeration type or to a non-overloaded enumeration
6386 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
6387 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6388 enumeration literal or object.
6390 The function returns the representation value for the given enumeration
6391 value.  This will be equal to value of the @code{Pos} attribute in the
6392 absence of an enumeration representation clause.  This is a static
6393 attribute (i.e.@: the result is static if the argument is static).
6395 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6396 in which case it simply returns the integer value.  The reason for this
6397 is to allow it to be used for @code{(<>)} discrete formal arguments in
6398 a generic unit that can be instantiated with either enumeration types
6399 or integer types.  Note that if @code{Enum_Rep} is used on a modular
6400 type whose upper bound exceeds the upper bound of the largest signed
6401 integer type, and the argument is a variable, so that the universal
6402 integer calculation is done at run time, then the call to @code{Enum_Rep}
6403 may raise @code{Constraint_Error}.
6405 @node Enum_Val
6406 @unnumberedsec Enum_Val
6407 @cindex Representation of enums
6408 @findex Enum_Val
6409 @noindent
6410 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6411 function with the following spec:
6413 @smallexample @c ada
6414 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6415   return @var{S}'Base};
6416 @end smallexample
6418 @noindent
6419 The function returns the enumeration value whose representation matches the
6420 argument, or raises Constraint_Error if no enumeration literal of the type
6421 has the matching value.
6422 This will be equal to value of the @code{Val} attribute in the
6423 absence of an enumeration representation clause.  This is a static
6424 attribute (i.e.@: the result is static if the argument is static).
6426 @node Epsilon
6427 @unnumberedsec Epsilon
6428 @cindex Ada 83 attributes
6429 @findex Epsilon
6430 @noindent
6431 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
6432 the Ada 83 reference manual for an exact description of the semantics of
6433 this attribute.
6435 @node Fixed_Value
6436 @unnumberedsec Fixed_Value
6437 @findex Fixed_Value
6438 @noindent
6439 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6440 function with the following specification:
6442 @smallexample @c ada
6443 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6444   return @var{S};
6445 @end smallexample
6447 @noindent
6448 The value returned is the fixed-point value @var{V} such that
6450 @smallexample @c ada
6451 @var{V} = Arg * @var{S}'Small
6452 @end smallexample
6454 @noindent
6455 The effect is thus similar to first converting the argument to the
6456 integer type used to represent @var{S}, and then doing an unchecked
6457 conversion to the fixed-point type.  The difference is
6458 that there are full range checks, to ensure that the result is in range.
6459 This attribute is primarily intended for use in implementation of the
6460 input-output functions for fixed-point values.
6462 @node Has_Access_Values
6463 @unnumberedsec Has_Access_Values
6464 @cindex Access values, testing for
6465 @findex Has_Access_Values
6466 @noindent
6467 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
6468 is a Boolean value which is True if the is an access type, or is a composite
6469 type with a component (at any nesting depth) that is an access type, and is
6470 False otherwise.
6471 The intended use of this attribute is in conjunction with generic
6472 definitions.  If the attribute is applied to a generic private type, it
6473 indicates whether or not the corresponding actual type has access values.
6475 @node Has_Discriminants
6476 @unnumberedsec Has_Discriminants
6477 @cindex Discriminants, testing for
6478 @findex Has_Discriminants
6479 @noindent
6480 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
6481 is a Boolean value which is True if the type has discriminants, and False
6482 otherwise.  The intended use of this attribute is in conjunction with generic
6483 definitions.  If the attribute is applied to a generic private type, it
6484 indicates whether or not the corresponding actual type has discriminants.
6486 @node Img
6487 @unnumberedsec Img
6488 @findex Img
6489 @noindent
6490 The @code{Img} attribute differs from @code{Image} in that it may be
6491 applied to objects as well as types, in which case it gives the
6492 @code{Image} for the subtype of the object.  This is convenient for
6493 debugging:
6495 @smallexample @c ada
6496 Put_Line ("X = " & X'Img);
6497 @end smallexample
6499 @noindent
6500 has the same meaning as the more verbose:
6502 @smallexample @c ada
6503 Put_Line ("X = " & @var{T}'Image (X));
6504 @end smallexample
6506 @noindent
6507 where @var{T} is the (sub)type of the object @code{X}.
6509 @node Integer_Value
6510 @unnumberedsec Integer_Value
6511 @findex Integer_Value
6512 @noindent
6513 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6514 function with the following spec:
6516 @smallexample @c ada
6517 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6518   return @var{S};
6519 @end smallexample
6521 @noindent
6522 The value returned is the integer value @var{V}, such that
6524 @smallexample @c ada
6525 Arg = @var{V} * @var{T}'Small
6526 @end smallexample
6528 @noindent
6529 where @var{T} is the type of @code{Arg}.
6530 The effect is thus similar to first doing an unchecked conversion from
6531 the fixed-point type to its corresponding implementation type, and then
6532 converting the result to the target integer type.  The difference is
6533 that there are full range checks, to ensure that the result is in range.
6534 This attribute is primarily intended for use in implementation of the
6535 standard input-output functions for fixed-point values.
6537 @node Invalid_Value
6538 @unnumberedsec Invalid_Value
6539 @findex Invalid_Value
6540 @noindent
6541 For every scalar type S, S'Invalid_Value returns an undefined value of the
6542 type. If possible this value is an invalid representation for the type. The
6543 value returned is identical to the value used to initialize an otherwise
6544 uninitialized value of the type if pragma Initialize_Scalars is used,
6545 including the ability to modify the value with the binder -Sxx flag and
6546 relevant environment variables at run time.
6548 @node Large
6549 @unnumberedsec Large
6550 @cindex Ada 83 attributes
6551 @findex Large
6552 @noindent
6553 The @code{Large} attribute is provided for compatibility with Ada 83.  See
6554 the Ada 83 reference manual for an exact description of the semantics of
6555 this attribute.
6557 @node Machine_Size
6558 @unnumberedsec Machine_Size
6559 @findex Machine_Size
6560 @noindent
6561 This attribute is identical to the @code{Object_Size} attribute.  It is
6562 provided for compatibility with the DEC Ada 83 attribute of this name.
6564 @node Mantissa
6565 @unnumberedsec Mantissa
6566 @cindex Ada 83 attributes
6567 @findex Mantissa
6568 @noindent
6569 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
6570 the Ada 83 reference manual for an exact description of the semantics of
6571 this attribute.
6573 @node Max_Interrupt_Priority
6574 @unnumberedsec Max_Interrupt_Priority
6575 @cindex Interrupt priority, maximum
6576 @findex Max_Interrupt_Priority
6577 @noindent
6578 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6579 permissible prefix), provides the same value as
6580 @code{System.Max_Interrupt_Priority}.
6582 @node Max_Priority
6583 @unnumberedsec Max_Priority
6584 @cindex Priority, maximum
6585 @findex Max_Priority
6586 @noindent
6587 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6588 prefix) provides the same value as @code{System.Max_Priority}.
6590 @node Maximum_Alignment
6591 @unnumberedsec Maximum_Alignment
6592 @cindex Alignment, maximum
6593 @findex Maximum_Alignment
6594 @noindent
6595 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6596 permissible prefix) provides the maximum useful alignment value for the
6597 target.  This is a static value that can be used to specify the alignment
6598 for an object, guaranteeing that it is properly aligned in all
6599 cases.
6601 @node Mechanism_Code
6602 @unnumberedsec Mechanism_Code
6603 @cindex Return values, passing mechanism
6604 @cindex Parameters, passing mechanism
6605 @findex Mechanism_Code
6606 @noindent
6607 @code{@var{function}'Mechanism_Code} yields an integer code for the
6608 mechanism used for the result of function, and
6609 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6610 used for formal parameter number @var{n} (a static integer value with 1
6611 meaning the first parameter) of @var{subprogram}.  The code returned is:
6613 @table @asis
6614 @item 1
6615 by copy (value)
6616 @item 2
6617 by reference
6618 @item 3
6619 by descriptor (default descriptor class)
6620 @item 4
6621 by descriptor (UBS: unaligned bit string)
6622 @item 5
6623 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6624 @item 6
6625 by descriptor (UBA: unaligned bit array)
6626 @item 7
6627 by descriptor (S: string, also scalar access type parameter)
6628 @item 8
6629 by descriptor (SB: string with arbitrary bounds)
6630 @item 9
6631 by descriptor (A: contiguous array)
6632 @item 10
6633 by descriptor (NCA: non-contiguous array)
6634 @end table
6636 @noindent
6637 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6638 @cindex OpenVMS
6640 @node Null_Parameter
6641 @unnumberedsec Null_Parameter
6642 @cindex Zero address, passing
6643 @findex Null_Parameter
6644 @noindent
6645 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6646 type or subtype @var{T} allocated at machine address zero.  The attribute
6647 is allowed only as the default expression of a formal parameter, or as
6648 an actual expression of a subprogram call.  In either case, the
6649 subprogram must be imported.
6651 The identity of the object is represented by the address zero in the
6652 argument list, independent of the passing mechanism (explicit or
6653 default).
6655 This capability is needed to specify that a zero address should be
6656 passed for a record or other composite object passed by reference.
6657 There is no way of indicating this without the @code{Null_Parameter}
6658 attribute.
6660 @node Object_Size
6661 @unnumberedsec Object_Size
6662 @cindex Size, used for objects
6663 @findex Object_Size
6664 @noindent
6665 The size of an object is not necessarily the same as the size of the type
6666 of an object.  This is because by default object sizes are increased to be
6667 a multiple of the alignment of the object.  For example,
6668 @code{Natural'Size} is
6669 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6670 Similarly, a record containing an integer and a character:
6672 @smallexample @c ada
6673 type Rec is record
6674    I : Integer;
6675    C : Character;
6676 end record;
6677 @end smallexample
6679 @noindent
6680 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
6681 alignment will be 4, because of the
6682 integer field, and so the default size of record objects for this type
6683 will be 64 (8 bytes).
6685 @node Passed_By_Reference
6686 @unnumberedsec Passed_By_Reference
6687 @cindex Parameters, when passed by reference
6688 @findex Passed_By_Reference
6689 @noindent
6690 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6691 a value of type @code{Boolean} value that is @code{True} if the type is
6692 normally passed by reference and @code{False} if the type is normally
6693 passed by copy in calls.  For scalar types, the result is always @code{False}
6694 and is static.  For non-scalar types, the result is non-static.
6696 @node Pool_Address
6697 @unnumberedsec Pool_Address
6698 @cindex Parameters, when passed by reference
6699 @findex Pool_Address
6700 @noindent
6701 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6702 of X within its storage pool. This is the same as
6703 @code{@var{X}'Address}, except that for an unconstrained array whose
6704 bounds are allocated just before the first component,
6705 @code{@var{X}'Pool_Address} returns the address of those bounds,
6706 whereas @code{@var{X}'Address} returns the address of the first
6707 component.
6709 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6710 the object is allocated'', which could be a user-defined storage pool,
6711 the global heap, on the stack, or in a static memory area. For an
6712 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6713 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6715 @node Range_Length
6716 @unnumberedsec Range_Length
6717 @findex Range_Length
6718 @noindent
6719 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6720 the number of values represented by the subtype (zero for a null
6721 range).  The result is static for static subtypes.  @code{Range_Length}
6722 applied to the index subtype of a one dimensional array always gives the
6723 same result as @code{Range} applied to the array itself.
6725 @node Ref
6726 @unnumberedsec Ref
6727 @findex Ref
6728 @noindent
6729 The @code{System.Address'Ref}
6730 (@code{System.Address} is the only permissible prefix)
6731 denotes a function identical to
6732 @code{System.Storage_Elements.To_Address} except that
6733 it is a static attribute.  See @ref{To_Address} for more details.
6735 @node Result
6736 @unnumberedsec Result
6737 @findex Result
6738 @noindent
6739 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6740 for a function. The prefix must be the name of the corresponding function. This
6741 is used to refer to the result of the function in the postcondition expression.
6742 For a further discussion of the use of this attribute and examples of its use,
6743 see the description of pragma Postcondition.
6745 @node Safe_Emax
6746 @unnumberedsec Safe_Emax
6747 @cindex Ada 83 attributes
6748 @findex Safe_Emax
6749 @noindent
6750 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6751 the Ada 83 reference manual for an exact description of the semantics of
6752 this attribute.
6754 @node Safe_Large
6755 @unnumberedsec Safe_Large
6756 @cindex Ada 83 attributes
6757 @findex Safe_Large
6758 @noindent
6759 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6760 the Ada 83 reference manual for an exact description of the semantics of
6761 this attribute.
6763 @node Scalar_Storage_Order
6764 @unnumberedsec Scalar_Storage_Order
6765 @cindex Endianness
6766 @cindex Scalar storage order
6767 @findex Scalar_Storage_Order
6768 @noindent
6769 For every array or record type @var{S}, the representation attribute
6770 @code{Scalar_Storage_Order} denotes the order in which storage elements
6771 that make up scalar components are ordered within S. Other properties are
6772 as for standard representation attribute @code{Bit_Order}, as defined by
6773 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
6775 If @code{@var{S}'Scalar_Storage_Order} is specified explicitly, it shall be
6776 equal to @code{@var{S}'Bit_Order}. Note: This means that if a
6777 @code{Scalar_Storage_Order} attribute definition clause is not confirming,
6778 then the type's @code{Bit_Order} shall be specified explicitly and set to
6779 the same value.
6781 If a component of S has itself a record or array type, then it shall also
6782 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
6783 if the component does not start on a byte boundary, then the scalar storage
6784 order specified for S and for the nested component type shall be identical.
6786 No component of a type that has a @code{Scalar_Storage_Order} attribute
6787 definition may be aliased.
6789 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
6790 with a value equal to @code{System.Default_Bit_Order}) has no effect.
6792 If the opposite storage order is specified, then whenever the value of
6793 a scalar component of S is read, the storage elements of the enclosing
6794 machine scalar are first reversed (before retrieving the component value,
6795 possibly applying some shift and mask operatings on the enclosing machine
6796 scalar), and the opposite operation is done for writes.
6798 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
6799 are relaxed. Instead, the following rules apply:
6801 @itemize @bullet
6802 @item the underlying storage elements are those at positions
6803   @code{(position + first_bit / storage_element_size) ..
6804         (position + (last_bit + storage_element_size - 1) /
6805                     storage_element_size)}
6806 @item the sequence of underlying storage elements shall have
6807         a size no greater than the largest machine scalar
6808 @item the enclosing machine scalar is defined as the smallest machine
6809         scalar starting at a position no greater than
6810         @code{position + first_bit / storage_element_size} and covering
6811         storage elements at least up to @code{position + (last_bit +
6812         storage_element_size - 1) / storage_element_size}
6813 @item the position of the component is interpreted relative to that machine
6814  scalar.
6816 @end itemize
6818 @node Simple_Storage_Pool
6819 @unnumberedsec Simple_Storage_Pool
6820 @cindex Storage pool, simple
6821 @cindex Simple storage pool
6822 @findex Simple_Storage_Pool
6823 @noindent
6824 For every nonformal, nonderived access-to-object type @var{Acc}, the
6825 representation attribute @code{Simple_Storage_Pool} may be specified
6826 via an attribute_definition_clause (or by specifying the equivalent aspect):
6828 @smallexample @c ada
6830 My_Pool : My_Simple_Storage_Pool_Type;
6832 type Acc is access My_Data_Type;
6834 for Acc'Simple_Storage_Pool use My_Pool;
6836 @end smallexample
6838 @noindent
6839 The name given in an attribute_definition_clause for the
6840 @code{Simple_Storage_Pool} attribute shall denote a variable of
6841 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6843 The use of this attribute is only allowed for a prefix denoting a type
6844 for which it has been specified. The type of the attribute is the type
6845 of the variable specified as the simple storage pool of the access type,
6846 and the attribute denotes that variable.
6848 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6849 for the same access type.
6851 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6852 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6853 with a warning and its evaluation raises the exception @code{Program_Error}.
6855 If the Simple_Storage_Pool attribute has been specified for an access
6856 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6857 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6858 which is intended to indicate the number of storage elements reserved for
6859 the simple storage pool. If the Storage_Size function has not been defined
6860 for the simple storage pool type, then this attribute returns zero.
6862 If an access type @var{S} has a specified simple storage pool of type
6863 @var{SSP}, then the evaluation of an allocator for that access type calls
6864 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6865 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6866 semantics of such allocators is the same as those defined for allocators
6867 in section 13.11 of the Ada Reference Manual, with the term
6868 ``simple storage pool'' substituted for ``storage pool''.
6870 If an access type @var{S} has a specified simple storage pool of type
6871 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6872 for that access type invokes the primitive @code{Deallocate} procedure
6873 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6874 parameter. The detailed semantics of such unchecked deallocations is the same
6875 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6876 term ``simple storage pool'' is substituted for ``storage pool''.
6878 @node Small
6879 @unnumberedsec Small
6880 @cindex Ada 83 attributes
6881 @findex Small
6882 @noindent
6883 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6884 fixed-point types.
6885 GNAT also allows this attribute to be applied to floating-point types
6886 for compatibility with Ada 83.  See
6887 the Ada 83 reference manual for an exact description of the semantics of
6888 this attribute when applied to floating-point types.
6890 @node Storage_Unit
6891 @unnumberedsec Storage_Unit
6892 @findex Storage_Unit
6893 @noindent
6894 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6895 prefix) provides the same value as @code{System.Storage_Unit}.
6897 @node Stub_Type
6898 @unnumberedsec Stub_Type
6899 @findex Stub_Type
6900 @noindent
6901 The GNAT implementation of remote access-to-classwide types is
6902 organized as described in AARM section E.4 (20.t): a value of an RACW type
6903 (designating a remote object) is represented as a normal access
6904 value, pointing to a "stub" object which in turn contains the
6905 necessary information to contact the designated remote object. A
6906 call on any dispatching operation of such a stub object does the
6907 remote call, if necessary, using the information in the stub object
6908 to locate the target partition, etc.
6910 For a prefix @code{T} that denotes a remote access-to-classwide type,
6911 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6913 By construction, the layout of @code{T'Stub_Type} is identical to that of
6914 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6915 unit @code{System.Partition_Interface}. Use of this attribute will create
6916 an implicit dependency on this unit.
6918 @node System_Allocator_Alignment
6919 @unnumberedsec System_Allocator_Alignment
6920 @cindex Alignment, allocator
6921 @findex System_Allocator_Alignment
6922 @noindent
6923 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6924 permissible prefix) provides the observable guaranted to be honored by
6925 the system allocator (malloc). This is a static value that can be used
6926 in user storage pools based on malloc either to reject allocation
6927 with alignment too large or to enable a realignment circuitry if the
6928 alignment request is larger than this value.
6930 @node Target_Name
6931 @unnumberedsec Target_Name
6932 @findex Target_Name
6933 @noindent
6934 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6935 prefix) provides a static string value that identifies the target
6936 for the current compilation. For GCC implementations, this is the
6937 standard gcc target name without the terminating slash (for
6938 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6940 @node Tick
6941 @unnumberedsec Tick
6942 @findex Tick
6943 @noindent
6944 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6945 provides the same value as @code{System.Tick},
6947 @node To_Address
6948 @unnumberedsec To_Address
6949 @findex To_Address
6950 @noindent
6951 The @code{System'To_Address}
6952 (@code{System} is the only permissible prefix)
6953 denotes a function identical to
6954 @code{System.Storage_Elements.To_Address} except that
6955 it is a static attribute.  This means that if its argument is
6956 a static expression, then the result of the attribute is a
6957 static expression.  The result is that such an expression can be
6958 used in contexts (e.g.@: preelaborable packages) which require a
6959 static expression and where the function call could not be used
6960 (since the function call is always non-static, even if its
6961 argument is static).
6963 @node Type_Class
6964 @unnumberedsec Type_Class
6965 @findex Type_Class
6966 @noindent
6967 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6968 the value of the type class for the full type of @var{type}.  If
6969 @var{type} is a generic formal type, the value is the value for the
6970 corresponding actual subtype.  The value of this attribute is of type
6971 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6973 @smallexample @c ada
6974   type Type_Class is
6975     (Type_Class_Enumeration,
6976      Type_Class_Integer,
6977      Type_Class_Fixed_Point,
6978      Type_Class_Floating_Point,
6979      Type_Class_Array,
6980      Type_Class_Record,
6981      Type_Class_Access,
6982      Type_Class_Task,
6983      Type_Class_Address);
6984 @end smallexample
6986 @noindent
6987 Protected types yield the value @code{Type_Class_Task}, which thus
6988 applies to all concurrent types.  This attribute is designed to
6989 be compatible with the DEC Ada 83 attribute of the same name.
6991 @node UET_Address
6992 @unnumberedsec UET_Address
6993 @findex UET_Address
6994 @noindent
6995 The @code{UET_Address} attribute can only be used for a prefix which
6996 denotes a library package.  It yields the address of the unit exception
6997 table when zero cost exception handling is used.  This attribute is
6998 intended only for use within the GNAT implementation.  See the unit
6999 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7000 for details on how this attribute is used in the implementation.
7002 @node Unconstrained_Array
7003 @unnumberedsec Unconstrained_Array
7004 @findex Unconstrained_Array
7005 @noindent
7006 The @code{Unconstrained_Array} attribute can be used with a prefix that
7007 denotes any type or subtype. It is a static attribute that yields
7008 @code{True} if the prefix designates an unconstrained array,
7009 and @code{False} otherwise. In a generic instance, the result is
7010 still static, and yields the result of applying this test to the
7011 generic actual.
7013 @node Universal_Literal_String
7014 @unnumberedsec Universal_Literal_String
7015 @cindex Named numbers, representation of
7016 @findex Universal_Literal_String
7017 @noindent
7018 The prefix of @code{Universal_Literal_String} must be a named
7019 number.  The static result is the string consisting of the characters of
7020 the number as defined in the original source.  This allows the user
7021 program to access the actual text of named numbers without intermediate
7022 conversions and without the need to enclose the strings in quotes (which
7023 would preclude their use as numbers).
7025 For example, the following program prints the first 50 digits of pi:
7027 @smallexample @c ada
7028 with Text_IO; use Text_IO;
7029 with Ada.Numerics;
7030 procedure Pi is
7031 begin
7032    Put (Ada.Numerics.Pi'Universal_Literal_String);
7033 end;
7034 @end smallexample
7036 @node Unrestricted_Access
7037 @unnumberedsec Unrestricted_Access
7038 @cindex @code{Access}, unrestricted
7039 @findex Unrestricted_Access
7040 @noindent
7041 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7042 except that all accessibility and aliased view checks are omitted.  This
7043 is a user-beware attribute.  It is similar to
7044 @code{Address}, for which it is a desirable replacement where the value
7045 desired is an access type.  In other words, its effect is identical to
7046 first applying the @code{Address} attribute and then doing an unchecked
7047 conversion to a desired access type.  In GNAT, but not necessarily in
7048 other implementations, the use of static chains for inner level
7049 subprograms means that @code{Unrestricted_Access} applied to a
7050 subprogram yields a value that can be called as long as the subprogram
7051 is in scope (normal Ada accessibility rules restrict this usage).
7053 It is possible to use @code{Unrestricted_Access} for any type, but care
7054 must be exercised if it is used to create pointers to unconstrained
7055 objects. In this case, the resulting pointer has the same scope as the
7056 context of the attribute, and may not be returned to some enclosing
7057 scope. For instance, a function cannot use @code{Unrestricted_Access}
7058 to create a unconstrained pointer and then return that value to the
7059 caller.
7061 @node Valid_Scalars
7062 @unnumberedsec Valid_Scalars
7063 @findex Valid_Scalars
7064 @noindent
7065 The @code{'Valid_Scalars} attribute is intended to make it easier to
7066 check the validity of scalar subcomponents of composite objects. It
7067 is defined for any prefix @code{X} that denotes an object.
7068 The value of this attribute is of the predefined type Boolean.
7069 @code{X'Valid_Scalars} yields True if and only if evaluation of
7070 @code{P'Valid} yields True for every scalar part P of X or if X has
7071 no scalar parts. It is not specified in what order the scalar parts
7072 are checked, nor whether any more are checked after any one of them
7073 is determined to be invalid. If the prefix @code{X} is of a class-wide
7074 type @code{T'Class} (where @code{T} is the associated specific type),
7075 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7076 only the scalar parts of components of @code{T} are traversed; in other
7077 words, components of extensions of @code{T} are not traversed even if
7078 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7079 be determined at compile time that the prefix of the attribute has no
7080 scalar parts (e.g., if the prefix is of an access type, an interface type,
7081 an undiscriminated task type, or an undiscriminated protected type).
7083 @node VADS_Size
7084 @unnumberedsec VADS_Size
7085 @cindex @code{Size}, VADS compatibility
7086 @findex VADS_Size
7087 @noindent
7088 The @code{'VADS_Size} attribute is intended to make it easier to port
7089 legacy code which relies on the semantics of @code{'Size} as implemented
7090 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
7091 same semantic interpretation.  In particular, @code{'VADS_Size} applied
7092 to a predefined or other primitive type with no Size clause yields the
7093 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7094 typical machines).  In addition @code{'VADS_Size} applied to an object
7095 gives the result that would be obtained by applying the attribute to
7096 the corresponding type.
7098 @node Value_Size
7099 @unnumberedsec Value_Size
7100 @cindex @code{Size}, setting for not-first subtype
7101 @findex Value_Size
7102 @code{@var{type}'Value_Size} is the number of bits required to represent
7103 a value of the given subtype.  It is the same as @code{@var{type}'Size},
7104 but, unlike @code{Size}, may be set for non-first subtypes.
7106 @node Wchar_T_Size
7107 @unnumberedsec Wchar_T_Size
7108 @findex Wchar_T_Size
7109 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7110 prefix) provides the size in bits of the C @code{wchar_t} type
7111 primarily for constructing the definition of this type in
7112 package @code{Interfaces.C}.
7114 @node Word_Size
7115 @unnumberedsec Word_Size
7116 @findex Word_Size
7117 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7118 prefix) provides the value @code{System.Word_Size}.
7120 @node Standard and Implementation Defined Restrictions
7121 @chapter Standard and Implementation Defined Restrictions
7123 @noindent
7124 All RM defined Restriction identifiers are implemented:
7126 @itemize @bullet
7127 @item language-defined restrictions (see 13.12.1)
7128 @item tasking restrictions (see D.7)
7129 @item high integrity restrictions (see H.4)
7130 @end itemize
7132 @noindent
7133 GNAT implements additional restriction identifiers. All restrictions, whether
7134 language defined or GNAT-specific, are listed in the following.
7136 @menu
7137 * Partition-Wide Restrictions::
7138 * Program Unit Level Restrictions::
7139 @end menu
7141 @node Partition-Wide Restrictions
7142 @section Partition-Wide Restrictions
7144 There are two separate lists of restriction identifiers. The first
7145 set requires consistency throughout a partition (in other words, if the
7146 restriction identifier is used for any compilation unit in the partition,
7147 then all compilation units in the partition must obey the restriction).
7149 @menu
7150 * Immediate_Reclamation::
7151 * Max_Asynchronous_Select_Nesting::
7152 * Max_Entry_Queue_Length::
7153 * Max_Protected_Entries::
7154 * Max_Select_Alternatives::
7155 * Max_Storage_At_Blocking::
7156 * Max_Task_Entries::
7157 * Max_Tasks::
7158 * No_Abort_Statements::
7159 * No_Access_Parameter_Allocators::
7160 * No_Access_Subprograms::
7161 * No_Allocators::
7162 * No_Anonymous_Allocators::
7163 * No_Calendar::
7164 * No_Coextensions::
7165 * No_Default_Initialization::
7166 * No_Delay::
7167 * No_Dependence::
7168 * No_Direct_Boolean_Operators::
7169 * No_Dispatch::
7170 * No_Dispatching_Calls::
7171 * No_Dynamic_Attachment::
7172 * No_Dynamic_Priorities::
7173 * No_Entry_Calls_In_Elaboration_Code::
7174 * No_Enumeration_Maps::
7175 * No_Exception_Handlers::
7176 * No_Exception_Propagation::
7177 * No_Exception_Registration::
7178 * No_Exceptions::
7179 * No_Finalization::
7180 * No_Fixed_Point::
7181 * No_Floating_Point::
7182 * No_Implicit_Conditionals::
7183 * No_Implicit_Dynamic_Code::
7184 * No_Implicit_Heap_Allocations::
7185 * No_Implicit_Loops::
7186 * No_Initialize_Scalars::
7187 * No_IO::
7188 * No_Local_Allocators::
7189 * No_Local_Protected_Objects::
7190 * No_Local_Timing_Events::
7191 * No_Nested_Finalization::
7192 * No_Protected_Type_Allocators::
7193 * No_Protected_Types::
7194 * No_Recursion::
7195 * No_Reentrancy::
7196 * No_Relative_Delay::
7197 * No_Requeue_Statements::
7198 * No_Secondary_Stack::
7199 * No_Select_Statements::
7200 * No_Specific_Termination_Handlers::
7201 * No_Specification_of_Aspect::
7202 * No_Standard_Allocators_After_Elaboration::
7203 * No_Standard_Storage_Pools::
7204 * No_Stream_Optimizations::
7205 * No_Streams::
7206 * No_Task_Allocators::
7207 * No_Task_Attributes_Package::
7208 * No_Task_Hierarchy::
7209 * No_Task_Termination::
7210 * No_Tasking::
7211 * No_Terminate_Alternatives::
7212 * No_Unchecked_Access::
7213 * Simple_Barriers::
7214 * Static_Priorities::
7215 * Static_Storage_Size::
7216 @end menu
7218 @node Immediate_Reclamation
7219 @unnumberedsubsec Immediate_Reclamation
7220 @findex Immediate_Reclamation
7221 [RM H.4] This restriction ensures that, except for storage occupied by
7222 objects created by allocators and not deallocated via unchecked
7223 deallocation, any storage reserved at run time for an object is
7224 immediately reclaimed when the object no longer exists.
7226 @node Max_Asynchronous_Select_Nesting
7227 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7228 @findex Max_Asynchronous_Select_Nesting
7229 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7230 selects. Violations of this restriction with a value of zero are
7231 detected at compile time. Violations of this restriction with values
7232 other than zero cause Storage_Error to be raised.
7234 @node Max_Entry_Queue_Length
7235 @unnumberedsubsec Max_Entry_Queue_Length
7236 @findex Max_Entry_Queue_Length
7237 [RM D.7] This restriction is a declaration that any protected entry compiled in
7238 the scope of the restriction has at most the specified number of
7239 tasks waiting on the entry at any one time, and so no queue is required.
7240 Note that this restriction is checked at run time. Violation of this
7241 restriction results in the raising of Program_Error exception at the point of
7242 the call.
7244 @node Max_Protected_Entries
7245 @unnumberedsubsec Max_Protected_Entries
7246 @findex Max_Protected_Entries
7247 [RM D.7] Specifies the maximum number of entries per protected type. The
7248 bounds of every entry family of a protected unit shall be static, or shall be
7249 defined by a discriminant of a subtype whose corresponding bound is static.
7251 @node Max_Select_Alternatives
7252 @unnumberedsubsec Max_Select_Alternatives
7253 @findex Max_Select_Alternatives
7254 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7256 @node Max_Storage_At_Blocking
7257 @unnumberedsubsec Max_Storage_At_Blocking
7258 @findex Max_Storage_At_Blocking
7259 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7260 Storage_Size that can be retained by a blocked task. A violation of this
7261 restriction causes Storage_Error to be raised.
7263 @node Max_Task_Entries
7264 @unnumberedsubsec Max_Task_Entries
7265 @findex Max_Task_Entries
7266 [RM D.7] Specifies the maximum number of entries
7267 per task.  The bounds of every entry family
7268 of a task unit shall be static, or shall be
7269 defined by a discriminant of a subtype whose
7270 corresponding bound is static.
7272 @node Max_Tasks
7273 @unnumberedsubsec Max_Tasks
7274 @findex Max_Tasks
7275 [RM D.7] Specifies the maximum number of task that may be created, not
7276 counting the creation of the environment task.  Violations of this
7277 restriction with a value of zero are detected at compile
7278 time. Violations of this restriction with values other than zero cause
7279 Storage_Error to be raised.
7281 @node No_Abort_Statements
7282 @unnumberedsubsec No_Abort_Statements
7283 @findex No_Abort_Statements
7284 [RM D.7] There are no abort_statements, and there are
7285 no calls to Task_Identification.Abort_Task.
7287 @node No_Access_Parameter_Allocators
7288 @unnumberedsubsec No_Access_Parameter_Allocators
7289 @findex No_Access_Parameter_Allocators
7290 [RM H.4] This restriction ensures at compile time that there are no
7291 occurrences of an allocator as the actual parameter to an access
7292 parameter.
7294 @node No_Access_Subprograms
7295 @unnumberedsubsec No_Access_Subprograms
7296 @findex No_Access_Subprograms
7297 [RM H.4] This restriction ensures at compile time that there are no
7298 declarations of access-to-subprogram types.
7300 @node No_Allocators
7301 @unnumberedsubsec No_Allocators
7302 @findex No_Allocators
7303 [RM H.4] This restriction ensures at compile time that there are no
7304 occurrences of an allocator.
7306 @node No_Anonymous_Allocators
7307 @unnumberedsubsec No_Anonymous_Allocators
7308 @findex No_Anonymous_Allocators
7309 [RM H.4] This restriction ensures at compile time that there are no
7310 occurrences of an allocator of anonymous access type.
7312 @node No_Calendar
7313 @unnumberedsubsec No_Calendar
7314 @findex No_Calendar
7315 [GNAT] This restriction ensures at compile time that there is no implicit or
7316 explicit dependence on the package @code{Ada.Calendar}.
7318 @node No_Coextensions
7319 @unnumberedsubsec No_Coextensions
7320 @findex No_Coextensions
7321 [RM H.4] This restriction ensures at compile time that there are no
7322 coextensions. See 3.10.2.
7324 @node No_Default_Initialization
7325 @unnumberedsubsec No_Default_Initialization
7326 @findex No_Default_Initialization
7328 [GNAT] This restriction prohibits any instance of default initialization
7329 of variables.  The binder implements a consistency rule which prevents
7330 any unit compiled without the restriction from with'ing a unit with the
7331 restriction (this allows the generation of initialization procedures to
7332 be skipped, since you can be sure that no call is ever generated to an
7333 initialization procedure in a unit with the restriction active). If used
7334 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7335 is to prohibit all cases of variables declared without a specific
7336 initializer (including the case of OUT scalar parameters).
7338 @node No_Delay
7339 @unnumberedsubsec No_Delay
7340 @findex No_Delay
7341 [RM H.4] This restriction ensures at compile time that there are no
7342 delay statements and no dependences on package Calendar.
7344 @node No_Dependence
7345 @unnumberedsubsec No_Dependence
7346 @findex No_Dependence
7347 [RM 13.12.1] This restriction checks at compile time that there are no
7348 dependence on a library unit.
7350 @node No_Direct_Boolean_Operators
7351 @unnumberedsubsec No_Direct_Boolean_Operators
7352 @findex No_Direct_Boolean_Operators
7353 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7354 operands of type Boolean (or any type derived
7355 from Boolean). This is intended for use in safety critical programs
7356 where the certification protocol requires the use of short-circuit
7357 (and then, or else) forms for all composite boolean operations.
7359 @node No_Dispatch
7360 @unnumberedsubsec No_Dispatch
7361 @findex No_Dispatch
7362 [RM H.4] This restriction ensures at compile time that there are no
7363 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7365 @node No_Dispatching_Calls
7366 @unnumberedsubsec No_Dispatching_Calls
7367 @findex No_Dispatching_Calls
7368 [GNAT] This restriction ensures at compile time that the code generated by the
7369 compiler involves no dispatching calls. The use of this restriction allows the
7370 safe use of record extensions, classwide membership tests and other classwide
7371 features not involving implicit dispatching. This restriction ensures that
7372 the code contains no indirect calls through a dispatching mechanism. Note that
7373 this includes internally-generated calls created by the compiler, for example
7374 in the implementation of class-wide objects assignments. The
7375 membership test is allowed in the presence of this restriction, because its
7376 implementation requires no dispatching.
7377 This restriction is comparable to the official Ada restriction
7378 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7379 all classwide constructs that do not imply dispatching.
7380 The following example indicates constructs that violate this restriction.
7382 @smallexample
7383 package Pkg is
7384   type T is tagged record
7385     Data : Natural;
7386   end record;
7387   procedure P (X : T);
7389   type DT is new T with record
7390     More_Data : Natural;
7391   end record;
7392   procedure Q (X : DT);
7393 end Pkg;
7395 with Pkg; use Pkg;
7396 procedure Example is
7397   procedure Test (O : T'Class) is
7398     N : Natural  := O'Size;--  Error: Dispatching call
7399     C : T'Class := O;      --  Error: implicit Dispatching Call
7400   begin
7401     if O in DT'Class then  --  OK   : Membership test
7402        Q (DT (O));         --  OK   : Type conversion plus direct call
7403     else
7404        P (O);              --  Error: Dispatching call
7405     end if;
7406   end Test;
7408   Obj : DT;
7409 begin
7410   P (Obj);                 --  OK   : Direct call
7411   P (T (Obj));             --  OK   : Type conversion plus direct call
7412   P (T'Class (Obj));       --  Error: Dispatching call
7414   Test (Obj);              --  OK   : Type conversion
7416   if Obj in T'Class then   --  OK   : Membership test
7417      null;
7418   end if;
7419 end Example;
7420 @end smallexample
7422 @node No_Dynamic_Attachment
7423 @unnumberedsubsec No_Dynamic_Attachment
7424 @findex No_Dynamic_Attachment
7425 [RM D.7] This restriction ensures that there is no call to any of the
7426 operations defined in package Ada.Interrupts
7427 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7428 Detach_Handler, and Reference).
7430 @node No_Dynamic_Priorities
7431 @unnumberedsubsec No_Dynamic_Priorities
7432 @findex No_Dynamic_Priorities
7433 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7435 @node No_Entry_Calls_In_Elaboration_Code
7436 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7437 @findex No_Entry_Calls_In_Elaboration_Code
7438 [GNAT] This restriction ensures at compile time that no task or protected entry
7439 calls are made during elaboration code.  As a result of the use of this
7440 restriction, the compiler can assume that no code past an accept statement
7441 in a task can be executed at elaboration time.
7443 @node No_Enumeration_Maps
7444 @unnumberedsubsec No_Enumeration_Maps
7445 @findex No_Enumeration_Maps
7446 [GNAT] This restriction ensures at compile time that no operations requiring
7447 enumeration maps are used (that is Image and Value attributes applied
7448 to enumeration types).
7450 @node No_Exception_Handlers
7451 @unnumberedsubsec No_Exception_Handlers
7452 @findex No_Exception_Handlers
7453 [GNAT] This restriction ensures at compile time that there are no explicit
7454 exception handlers. It also indicates that no exception propagation will
7455 be provided. In this mode, exceptions may be raised but will result in
7456 an immediate call to the last chance handler, a routine that the user
7457 must define with the following profile:
7459 @smallexample @c ada
7460 procedure Last_Chance_Handler
7461   (Source_Location : System.Address; Line : Integer);
7462 pragma Export (C, Last_Chance_Handler,
7463                "__gnat_last_chance_handler");
7464 @end smallexample
7466 The parameter is a C null-terminated string representing a message to be
7467 associated with the exception (typically the source location of the raise
7468 statement generated by the compiler). The Line parameter when nonzero
7469 represents the line number in the source program where the raise occurs.
7471 @node No_Exception_Propagation
7472 @unnumberedsubsec No_Exception_Propagation
7473 @findex No_Exception_Propagation
7474 [GNAT] This restriction guarantees that exceptions are never propagated
7475 to an outer subprogram scope. The only case in which an exception may
7476 be raised is when the handler is statically in the same subprogram, so
7477 that the effect of a raise is essentially like a goto statement. Any
7478 other raise statement (implicit or explicit) will be considered
7479 unhandled. Exception handlers are allowed, but may not contain an
7480 exception occurrence identifier (exception choice). In addition, use of
7481 the package GNAT.Current_Exception is not permitted, and reraise
7482 statements (raise with no operand) are not permitted.
7484 @node No_Exception_Registration
7485 @unnumberedsubsec No_Exception_Registration
7486 @findex No_Exception_Registration
7487 [GNAT] This restriction ensures at compile time that no stream operations for
7488 types Exception_Id or Exception_Occurrence are used. This also makes it
7489 impossible to pass exceptions to or from a partition with this restriction
7490 in a distributed environment. If this exception is active, then the generated
7491 code is simplified by omitting the otherwise-required global registration
7492 of exceptions when they are declared.
7494 @node No_Exceptions
7495 @unnumberedsubsec No_Exceptions
7496 @findex No_Exceptions
7497 [RM H.4] This restriction ensures at compile time that there are no
7498 raise statements and no exception handlers.
7500 @node No_Finalization
7501 @unnumberedsubsec No_Finalization
7502 @findex No_Finalization
7503 [GNAT] This restriction disables the language features described in
7504 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7505 performed by the compiler to support these features. The following types
7506 are no longer considered controlled when this restriction is in effect:
7507 @itemize @bullet
7508 @item
7509 @code{Ada.Finalization.Controlled}
7510 @item
7511 @code{Ada.Finalization.Limited_Controlled}
7512 @item
7513 Derivations from @code{Controlled} or @code{Limited_Controlled}
7514 @item
7515 Class-wide types
7516 @item
7517 Protected types
7518 @item
7519 Task types
7520 @item
7521 Array and record types with controlled components
7522 @end itemize
7523 The compiler no longer generates code to initialize, finalize or adjust an
7524 object or a nested component, either declared on the stack or on the heap. The
7525 deallocation of a controlled object no longer finalizes its contents.
7527 @node No_Fixed_Point
7528 @unnumberedsubsec No_Fixed_Point
7529 @findex No_Fixed_Point
7530 [RM H.4] This restriction ensures at compile time that there are no
7531 occurrences of fixed point types and operations.
7533 @node No_Floating_Point
7534 @unnumberedsubsec No_Floating_Point
7535 @findex No_Floating_Point
7536 [RM H.4] This restriction ensures at compile time that there are no
7537 occurrences of floating point types and operations.
7539 @node No_Implicit_Conditionals
7540 @unnumberedsubsec No_Implicit_Conditionals
7541 @findex No_Implicit_Conditionals
7542 [GNAT] This restriction ensures that the generated code does not contain any
7543 implicit conditionals, either by modifying the generated code where possible,
7544 or by rejecting any construct that would otherwise generate an implicit
7545 conditional. Note that this check does not include run time constraint
7546 checks, which on some targets may generate implicit conditionals as
7547 well. To control the latter, constraint checks can be suppressed in the
7548 normal manner. Constructs generating implicit conditionals include comparisons
7549 of composite objects and the Max/Min attributes.
7551 @node No_Implicit_Dynamic_Code
7552 @unnumberedsubsec No_Implicit_Dynamic_Code
7553 @findex No_Implicit_Dynamic_Code
7554 @cindex trampoline
7555 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7556 This is a structure that is built on the stack and contains dynamic
7557 code to be executed at run time. On some targets, a trampoline is
7558 built for the following features: @code{Access},
7559 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7560 nested task bodies; primitive operations of nested tagged types.
7561 Trampolines do not work on machines that prevent execution of stack
7562 data. For example, on windows systems, enabling DEP (data execution
7563 protection) will cause trampolines to raise an exception.
7564 Trampolines are also quite slow at run time.
7566 On many targets, trampolines have been largely eliminated. Look at the
7567 version of system.ads for your target --- if it has
7568 Always_Compatible_Rep equal to False, then trampolines are largely
7569 eliminated. In particular, a trampoline is built for the following
7570 features: @code{Address} of a nested subprogram;
7571 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7572 but only if pragma Favor_Top_Level applies, or the access type has a
7573 foreign-language convention; primitive operations of nested tagged
7574 types.
7576 @node No_Implicit_Heap_Allocations
7577 @unnumberedsubsec No_Implicit_Heap_Allocations
7578 @findex No_Implicit_Heap_Allocations
7579 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7581 @node No_Implicit_Loops
7582 @unnumberedsubsec No_Implicit_Loops
7583 @findex No_Implicit_Loops
7584 [GNAT] This restriction ensures that the generated code does not contain any
7585 implicit @code{for} loops, either by modifying
7586 the generated code where possible,
7587 or by rejecting any construct that would otherwise generate an implicit
7588 @code{for} loop. If this restriction is active, it is possible to build
7589 large array aggregates with all static components without generating an
7590 intermediate temporary, and without generating a loop to initialize individual
7591 components. Otherwise, a loop is created for arrays larger than about 5000
7592 scalar components.
7594 @node No_Initialize_Scalars
7595 @unnumberedsubsec No_Initialize_Scalars
7596 @findex No_Initialize_Scalars
7597 [GNAT] This restriction ensures that no unit in the partition is compiled with
7598 pragma Initialize_Scalars. This allows the generation of more efficient
7599 code, and in particular eliminates dummy null initialization routines that
7600 are otherwise generated for some record and array types.
7602 @node No_IO
7603 @unnumberedsubsec No_IO
7604 @findex No_IO
7605 [RM H.4] This restriction ensures at compile time that there are no
7606 dependences on any of the library units Sequential_IO, Direct_IO,
7607 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7609 @node No_Local_Allocators
7610 @unnumberedsubsec No_Local_Allocators
7611 @findex No_Local_Allocators
7612 [RM H.4] This restriction ensures at compile time that there are no
7613 occurrences of an allocator in subprograms, generic subprograms, tasks,
7614 and entry bodies.
7616 @node No_Local_Protected_Objects
7617 @unnumberedsubsec No_Local_Protected_Objects
7618 @findex No_Local_Protected_Objects
7619 [RM D.7] This restriction ensures at compile time that protected objects are
7620 only declared at the library level.
7622 @node No_Local_Timing_Events
7623 @unnumberedsubsec No_Local_Timing_Events
7624 @findex No_Local_Timing_Events
7625 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7626 declared at the library level.
7628 @node No_Nested_Finalization
7629 @unnumberedsubsec No_Nested_Finalization
7630 @findex No_Nested_Finalization
7631 [RM D.7] All objects requiring finalization are declared at the library level.
7633 @node No_Protected_Type_Allocators
7634 @unnumberedsubsec No_Protected_Type_Allocators
7635 @findex No_Protected_Type_Allocators
7636 [RM D.7] This restriction ensures at compile time that there are no allocator
7637 expressions that attempt to allocate protected objects.
7639 @node No_Protected_Types
7640 @unnumberedsubsec No_Protected_Types
7641 @findex No_Protected_Types
7642 [RM H.4] This restriction ensures at compile time that there are no
7643 declarations of protected types or protected objects.
7645 @node No_Recursion
7646 @unnumberedsubsec No_Recursion
7647 @findex No_Recursion
7648 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7649 part of its execution.
7651 @node No_Reentrancy
7652 @unnumberedsubsec No_Reentrancy
7653 @findex No_Reentrancy
7654 [RM H.4] A program execution is erroneous if a subprogram is executed by
7655 two tasks at the same time.
7657 @node No_Relative_Delay
7658 @unnumberedsubsec No_Relative_Delay
7659 @findex No_Relative_Delay
7660 [RM D.7] This restriction ensures at compile time that there are no delay
7661 relative statements and prevents expressions such as @code{delay 1.23;} from
7662 appearing in source code.
7664 @node No_Requeue_Statements
7665 @unnumberedsubsec No_Requeue_Statements
7666 @findex No_Requeue_Statements
7667 [RM D.7] This restriction ensures at compile time that no requeue statements
7668 are permitted and prevents keyword @code{requeue} from being used in source
7669 code.
7671 @node No_Secondary_Stack
7672 @unnumberedsubsec No_Secondary_Stack
7673 @findex No_Secondary_Stack
7674 [GNAT] This restriction ensures at compile time that the generated code
7675 does not contain any reference to the secondary stack.  The secondary
7676 stack is used to implement functions returning unconstrained objects
7677 (arrays or records) on some targets.
7679 @node No_Select_Statements
7680 @unnumberedsubsec No_Select_Statements
7681 @findex No_Select_Statements
7682 [RM D.7] This restriction ensures at compile time no select statements of any
7683 kind are permitted, that is the keyword @code{select} may not appear.
7685 @node No_Specific_Termination_Handlers
7686 @unnumberedsubsec No_Specific_Termination_Handlers
7687 @findex No_Specific_Termination_Handlers
7688 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7689 or to Ada.Task_Termination.Specific_Handler.
7691 @node No_Specification_of_Aspect
7692 @unnumberedsubsec No_Specification_of_Aspect
7693 @findex No_Specification_of_Aspect
7694 [RM 13.12.1] This restriction checks at compile time that no aspect
7695 specification, attribute definition clause, or pragma is given for a
7696 given aspect.
7698 @node No_Standard_Allocators_After_Elaboration
7699 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7700 @findex No_Standard_Allocators_After_Elaboration
7701 [RM D.7] Specifies that an allocator using a standard storage pool
7702 should never be evaluated at run time after the elaboration of the
7703 library items of the partition has completed. Otherwise, Storage_Error
7704 is raised.
7706 @node No_Standard_Storage_Pools
7707 @unnumberedsubsec No_Standard_Storage_Pools
7708 @findex No_Standard_Storage_Pools
7709 [GNAT] This restriction ensures at compile time that no access types
7710 use the standard default storage pool.  Any access type declared must
7711 have an explicit Storage_Pool attribute defined specifying a
7712 user-defined storage pool.
7714 @node No_Stream_Optimizations
7715 @unnumberedsubsec No_Stream_Optimizations
7716 @findex No_Stream_Optimizations
7717 [GNAT] This restriction affects the performance of stream operations on types
7718 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7719 compiler uses block reads and writes when manipulating @code{String} objects
7720 due to their supperior performance. When this restriction is in effect, the
7721 compiler performs all IO operations on a per-character basis.
7723 @node No_Streams
7724 @unnumberedsubsec No_Streams
7725 @findex No_Streams
7726 [GNAT] This restriction ensures at compile/bind time that there are no
7727 stream objects created and no use of stream attributes.
7728 This restriction does not forbid dependences on the package
7729 @code{Ada.Streams}. So it is permissible to with
7730 @code{Ada.Streams} (or another package that does so itself)
7731 as long as no actual stream objects are created and no
7732 stream attributes are used.
7734 Note that the use of restriction allows optimization of tagged types,
7735 since they do not need to worry about dispatching stream operations.
7736 To take maximum advantage of this space-saving optimization, any
7737 unit declaring a tagged type should be compiled with the restriction,
7738 though this is not required.
7740 @node No_Task_Allocators
7741 @unnumberedsubsec No_Task_Allocators
7742 @findex No_Task_Allocators
7743 [RM D.7] There are no allocators for task types
7744 or types containing task subcomponents.
7746 @node No_Task_Attributes_Package
7747 @unnumberedsubsec No_Task_Attributes_Package
7748 @findex No_Task_Attributes_Package
7749 [GNAT] This restriction ensures at compile time that there are no implicit or
7750 explicit dependencies on the package @code{Ada.Task_Attributes}.
7752 @node No_Task_Hierarchy
7753 @unnumberedsubsec No_Task_Hierarchy
7754 @findex No_Task_Hierarchy
7755 [RM D.7] All (non-environment) tasks depend
7756 directly on the environment task of the partition.
7758 @node No_Task_Termination
7759 @unnumberedsubsec No_Task_Termination
7760 @findex No_Task_Termination
7761 [RM D.7] Tasks which terminate are erroneous.
7763 @node No_Tasking
7764 @unnumberedsubsec No_Tasking
7765 @findex No_Tasking
7766 [GNAT] This restriction prevents the declaration of tasks or task types
7767 throughout the partition.  It is similar in effect to the use of
7768 @code{Max_Tasks => 0} except that violations are caught at compile time
7769 and cause an error message to be output either by the compiler or
7770 binder.
7772 @node No_Terminate_Alternatives
7773 @unnumberedsubsec No_Terminate_Alternatives
7774 @findex No_Terminate_Alternatives
7775 [RM D.7] There are no selective accepts with terminate alternatives.
7777 @node No_Unchecked_Access
7778 @unnumberedsubsec No_Unchecked_Access
7779 @findex No_Unchecked_Access
7780 [RM H.4] This restriction ensures at compile time that there are no
7781 occurrences of the Unchecked_Access attribute.
7783 @node Simple_Barriers
7784 @unnumberedsubsec Simple_Barriers
7785 @findex Simple_Barriers
7786 [RM D.7] This restriction ensures at compile time that barriers in entry
7787 declarations for protected types are restricted to either static boolean
7788 expressions or references to simple boolean variables defined in the private
7789 part of the protected type.  No other form of entry barriers is permitted.
7791 @node Static_Priorities
7792 @unnumberedsubsec Static_Priorities
7793 @findex Static_Priorities
7794 [GNAT] This restriction ensures at compile time that all priority expressions
7795 are static, and that there are no dependences on the package
7796 @code{Ada.Dynamic_Priorities}.
7798 @node Static_Storage_Size
7799 @unnumberedsubsec Static_Storage_Size
7800 @findex Static_Storage_Size
7801 [GNAT] This restriction ensures at compile time that any expression appearing
7802 in a Storage_Size pragma or attribute definition clause is static.
7804 @node Program Unit Level Restrictions
7805 @section Program Unit Level Restrictions
7807 @noindent
7808 The second set of restriction identifiers
7809 does not require partition-wide consistency.
7810 The restriction may be enforced for a single
7811 compilation unit without any effect on any of the
7812 other compilation units in the partition.
7814 @menu
7815 * No_Elaboration_Code::
7816 * No_Entry_Queue::
7817 * No_Implementation_Aspect_Specifications::
7818 * No_Implementation_Attributes::
7819 * No_Implementation_Identifiers::
7820 * No_Implementation_Pragmas::
7821 * No_Implementation_Restrictions::
7822 * No_Implementation_Units::
7823 * No_Implicit_Aliasing::
7824 * No_Obsolescent_Features::
7825 * No_Wide_Characters::
7826 * SPARK::
7827 @end menu
7829 @node No_Elaboration_Code
7830 @unnumberedsubsec No_Elaboration_Code
7831 @findex No_Elaboration_Code
7832 [GNAT] This restriction ensures at compile time that no elaboration code is
7833 generated.  Note that this is not the same condition as is enforced
7834 by pragma @code{Preelaborate}.  There are cases in which pragma
7835 @code{Preelaborate} still permits code to be generated (e.g.@: code
7836 to initialize a large array to all zeroes), and there are cases of units
7837 which do not meet the requirements for pragma @code{Preelaborate},
7838 but for which no elaboration code is generated.  Generally, it is
7839 the case that preelaborable units will meet the restrictions, with
7840 the exception of large aggregates initialized with an others_clause,
7841 and exception declarations (which generate calls to a run-time
7842 registry procedure).  This restriction is enforced on
7843 a unit by unit basis, it need not be obeyed consistently
7844 throughout a partition.
7846 In the case of aggregates with others, if the aggregate has a dynamic
7847 size, there is no way to eliminate the elaboration code (such dynamic
7848 bounds would be incompatible with @code{Preelaborate} in any case). If
7849 the bounds are static, then use of this restriction actually modifies
7850 the code choice of the compiler to avoid generating a loop, and instead
7851 generate the aggregate statically if possible, no matter how many times
7852 the data for the others clause must be repeatedly generated.
7854 It is not possible to precisely document
7855 the constructs which are compatible with this restriction, since,
7856 unlike most other restrictions, this is not a restriction on the
7857 source code, but a restriction on the generated object code. For
7858 example, if the source contains a declaration:
7860 @smallexample
7861    Val : constant Integer := X;
7862 @end smallexample
7864 @noindent
7865 where X is not a static constant, it may be possible, depending
7866 on complex optimization circuitry, for the compiler to figure
7867 out the value of X at compile time, in which case this initialization
7868 can be done by the loader, and requires no initialization code. It
7869 is not possible to document the precise conditions under which the
7870 optimizer can figure this out.
7872 Note that this the implementation of this restriction requires full
7873 code generation. If it is used in conjunction with "semantics only"
7874 checking, then some cases of violations may be missed.
7876 @node No_Entry_Queue
7877 @unnumberedsubsec No_Entry_Queue
7878 @findex No_Entry_Queue
7879 [GNAT] This restriction is a declaration that any protected entry compiled in
7880 the scope of the restriction has at most one task waiting on the entry
7881 at any one time, and so no queue is required.  This restriction is not
7882 checked at compile time.  A program execution is erroneous if an attempt
7883 is made to queue a second task on such an entry.
7885 @node No_Implementation_Aspect_Specifications
7886 @unnumberedsubsec No_Implementation_Aspect_Specifications
7887 @findex No_Implementation_Aspect_Specifications
7888 [RM 13.12.1] This restriction checks at compile time that no
7889 GNAT-defined aspects are present.  With this restriction, the only
7890 aspects that can be used are those defined in the Ada Reference Manual.
7892 @node No_Implementation_Attributes
7893 @unnumberedsubsec No_Implementation_Attributes
7894 @findex No_Implementation_Attributes
7895 [RM 13.12.1] This restriction checks at compile time that no
7896 GNAT-defined attributes are present.  With this restriction, the only
7897 attributes that can be used are those defined in the Ada Reference
7898 Manual.
7900 @node No_Implementation_Identifiers
7901 @unnumberedsubsec No_Implementation_Identifiers
7902 @findex No_Implementation_Identifiers
7903 [RM 13.12.1] This restriction checks at compile time that no
7904 implementation-defined identifiers occur within language-defined
7905 packages.
7907 @node No_Implementation_Pragmas
7908 @unnumberedsubsec No_Implementation_Pragmas
7909 @findex No_Implementation_Pragmas
7910 [RM 13.12.1] This restriction checks at compile time that no
7911 GNAT-defined pragmas are present.  With this restriction, the only
7912 pragmas that can be used are those defined in the Ada Reference Manual.
7914 @node No_Implementation_Restrictions
7915 @unnumberedsubsec No_Implementation_Restrictions
7916 @findex No_Implementation_Restrictions
7917 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7918 identifiers (other than @code{No_Implementation_Restrictions} itself)
7919 are present.  With this restriction, the only other restriction identifiers
7920 that can be used are those defined in the Ada Reference Manual.
7922 @node No_Implementation_Units
7923 @unnumberedsubsec No_Implementation_Units
7924 @findex No_Implementation_Units
7925 [RM 13.12.1] This restriction checks at compile time that there is no
7926 mention in the context clause of any implementation-defined descendants
7927 of packages Ada, Interfaces, or System.
7929 @node No_Implicit_Aliasing
7930 @unnumberedsubsec No_Implicit_Aliasing
7931 @findex No_Implicit_Aliasing
7932 [GNAT] This restriction, which is not required to be partition-wide consistent,
7933 requires an explicit aliased keyword for an object to which 'Access,
7934 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7935 the 'Unrestricted_Access attribute for objects. Note: the reason that
7936 Unrestricted_Access is forbidden is that it would require the prefix
7937 to be aliased, and in such cases, it can always be replaced by
7938 the standard attribute Unchecked_Access which is preferable.
7940 @node No_Obsolescent_Features
7941 @unnumberedsubsec No_Obsolescent_Features
7942 @findex No_Obsolescent_Features
7943 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7944 features are used, as defined in Annex J of the Ada Reference Manual.
7946 @node No_Wide_Characters
7947 @unnumberedsubsec No_Wide_Characters
7948 @findex No_Wide_Characters
7949 [GNAT] This restriction ensures at compile time that no uses of the types
7950 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7951 wide types
7952 appear, and that no wide or wide wide string or character literals
7953 appear in the program (that is literals representing characters not in
7954 type @code{Character}.
7956 @node SPARK
7957 @unnumberedsubsec SPARK
7958 @findex SPARK
7959 [GNAT] This restriction checks at compile time that some constructs
7960 forbidden in SPARK are not present. The SPARK version used as a
7961 reference is the same as the Ada mode for the unit, so a unit compiled
7962 in Ada 95 mode with SPARK restrictions will be checked for constructs
7963 forbidden in SPARK 95.  Error messages related to SPARK restriction have
7964 the form:
7966 @smallexample
7967 violation of restriction "SPARK" at <file>
7968  <error message>
7969 @end smallexample
7971 This is not a replacement for the semantic checks performed by the
7972 SPARK Examiner tool, as the compiler only deals currently with code,
7973 not at all with SPARK annotations and does not guarantee catching all
7974 cases of constructs forbidden by SPARK.
7976 Thus it may well be the case that code which
7977 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7978 e.g. due to the different visibility rules of the Examiner based on
7979 SPARK @code{inherit} annotations.
7981 This restriction can be useful in providing an initial filter for
7982 code developed using SPARK, or in examining legacy code to see how far
7983 it is from meeting SPARK restrictions.
7985 @c ------------------------
7986 @node Implementation Advice
7987 @chapter Implementation Advice
7988 @noindent
7989 The main text of the Ada Reference Manual describes the required
7990 behavior of all Ada compilers, and the GNAT compiler conforms to
7991 these requirements.
7993 In addition, there are sections throughout the Ada Reference Manual headed
7994 by the phrase ``Implementation advice''.  These sections are not normative,
7995 i.e., they do not specify requirements that all compilers must
7996 follow.  Rather they provide advice on generally desirable behavior.  You
7997 may wonder why they are not requirements.  The most typical answer is
7998 that they describe behavior that seems generally desirable, but cannot
7999 be provided on all systems, or which may be undesirable on some systems.
8001 As far as practical, GNAT follows the implementation advice sections in
8002 the Ada Reference Manual.  This chapter contains a table giving the
8003 reference manual section number, paragraph number and several keywords
8004 for each advice.  Each entry consists of the text of the advice followed
8005 by the GNAT interpretation of this advice.  Most often, this simply says
8006 ``followed'', which means that GNAT follows the advice.  However, in a
8007 number of cases, GNAT deliberately deviates from this advice, in which
8008 case the text describes what GNAT does and why.
8010 @cindex Error detection
8011 @unnumberedsec 1.1.3(20): Error Detection
8012 @sp 1
8013 @cartouche
8014 If an implementation detects the use of an unsupported Specialized Needs
8015 Annex feature at run time, it should raise @code{Program_Error} if
8016 feasible.
8017 @end cartouche
8018 Not relevant.  All specialized needs annex features are either supported,
8019 or diagnosed at compile time.
8021 @cindex Child Units
8022 @unnumberedsec 1.1.3(31): Child Units
8023 @sp 1
8024 @cartouche
8025 If an implementation wishes to provide implementation-defined
8026 extensions to the functionality of a language-defined library unit, it
8027 should normally do so by adding children to the library unit.
8028 @end cartouche
8029 Followed.
8031 @cindex Bounded errors
8032 @unnumberedsec 1.1.5(12): Bounded Errors
8033 @sp 1
8034 @cartouche
8035 If an implementation detects a bounded error or erroneous
8036 execution, it should raise @code{Program_Error}.
8037 @end cartouche
8038 Followed in all cases in which the implementation detects a bounded
8039 error or erroneous execution.  Not all such situations are detected at
8040 runtime.
8042 @cindex Pragmas
8043 @unnumberedsec 2.8(16): Pragmas
8044 @sp 1
8045 @cartouche
8046 Normally, implementation-defined pragmas should have no semantic effect
8047 for error-free programs; that is, if the implementation-defined pragmas
8048 are removed from a working program, the program should still be legal,
8049 and should still have the same semantics.
8050 @end cartouche
8051 The following implementation defined pragmas are exceptions to this
8052 rule:
8054 @table @code
8055 @item Abort_Defer
8056 Affects semantics
8057 @item Ada_83
8058 Affects legality
8059 @item Assert
8060 Affects semantics
8061 @item CPP_Class
8062 Affects semantics
8063 @item CPP_Constructor
8064 Affects semantics
8065 @item Debug
8066 Affects semantics
8067 @item Interface_Name
8068 Affects semantics
8069 @item Machine_Attribute
8070 Affects semantics
8071 @item Unimplemented_Unit
8072 Affects legality
8073 @item Unchecked_Union
8074 Affects semantics
8075 @end table
8077 @noindent
8078 In each of the above cases, it is essential to the purpose of the pragma
8079 that this advice not be followed.  For details see the separate section
8080 on implementation defined pragmas.
8082 @unnumberedsec 2.8(17-19): Pragmas
8083 @sp 1
8084 @cartouche
8085 Normally, an implementation should not define pragmas that can
8086 make an illegal program legal, except as follows:
8087 @end cartouche
8088 @sp 1
8089 @cartouche
8090 A pragma used to complete a declaration, such as a pragma @code{Import};
8091 @end cartouche
8092 @sp 1
8093 @cartouche
8094 A pragma used to configure the environment by adding, removing, or
8095 replacing @code{library_items}.
8096 @end cartouche
8097 See response to paragraph 16 of this same section.
8099 @cindex Character Sets
8100 @cindex Alternative Character Sets
8101 @unnumberedsec 3.5.2(5): Alternative Character Sets
8102 @sp 1
8103 @cartouche
8104 If an implementation supports a mode with alternative interpretations
8105 for @code{Character} and @code{Wide_Character}, the set of graphic
8106 characters of @code{Character} should nevertheless remain a proper
8107 subset of the set of graphic characters of @code{Wide_Character}.  Any
8108 character set ``localizations'' should be reflected in the results of
8109 the subprograms defined in the language-defined package
8110 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
8111 an alternative interpretation of @code{Character}, the implementation should
8112 also support a corresponding change in what is a legal
8113 @code{identifier_letter}.
8114 @end cartouche
8115 Not all wide character modes follow this advice, in particular the JIS
8116 and IEC modes reflect standard usage in Japan, and in these encoding,
8117 the upper half of the Latin-1 set is not part of the wide-character
8118 subset, since the most significant bit is used for wide character
8119 encoding.  However, this only applies to the external forms.  Internally
8120 there is no such restriction.
8122 @cindex Integer types
8123 @unnumberedsec 3.5.4(28): Integer Types
8125 @sp 1
8126 @cartouche
8127 An implementation should support @code{Long_Integer} in addition to
8128 @code{Integer} if the target machine supports 32-bit (or longer)
8129 arithmetic.  No other named integer subtypes are recommended for package
8130 @code{Standard}.  Instead, appropriate named integer subtypes should be
8131 provided in the library package @code{Interfaces} (see B.2).
8132 @end cartouche
8133 @code{Long_Integer} is supported.  Other standard integer types are supported
8134 so this advice is not fully followed.  These types
8135 are supported for convenient interface to C, and so that all hardware
8136 types of the machine are easily available.
8137 @unnumberedsec 3.5.4(29): Integer Types
8139 @sp 1
8140 @cartouche
8141 An implementation for a two's complement machine should support
8142 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
8143 implementation should support a non-binary modules up to @code{Integer'Last}.
8144 @end cartouche
8145 Followed.
8147 @cindex Enumeration values
8148 @unnumberedsec 3.5.5(8): Enumeration Values
8149 @sp 1
8150 @cartouche
8151 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8152 subtype, if the value of the operand does not correspond to the internal
8153 code for any enumeration literal of its type (perhaps due to an
8154 un-initialized variable), then the implementation should raise
8155 @code{Program_Error}.  This is particularly important for enumeration
8156 types with noncontiguous internal codes specified by an
8157 enumeration_representation_clause.
8158 @end cartouche
8159 Followed.
8161 @cindex Float types
8162 @unnumberedsec 3.5.7(17): Float Types
8163 @sp 1
8164 @cartouche
8165 An implementation should support @code{Long_Float} in addition to
8166 @code{Float} if the target machine supports 11 or more digits of
8167 precision.  No other named floating point subtypes are recommended for
8168 package @code{Standard}.  Instead, appropriate named floating point subtypes
8169 should be provided in the library package @code{Interfaces} (see B.2).
8170 @end cartouche
8171 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
8172 former provides improved compatibility with other implementations
8173 supporting this type.  The latter corresponds to the highest precision
8174 floating-point type supported by the hardware.  On most machines, this
8175 will be the same as @code{Long_Float}, but on some machines, it will
8176 correspond to the IEEE extended form.  The notable case is all ia32
8177 (x86) implementations, where @code{Long_Long_Float} corresponds to
8178 the 80-bit extended precision format supported in hardware on this
8179 processor.  Note that the 128-bit format on SPARC is not supported,
8180 since this is a software rather than a hardware format.
8182 @cindex Multidimensional arrays
8183 @cindex Arrays, multidimensional
8184 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8185 @sp 1
8186 @cartouche
8187 An implementation should normally represent multidimensional arrays in
8188 row-major order, consistent with the notation used for multidimensional
8189 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
8190 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8191 column-major order should be used instead (see B.5, ``Interfacing with
8192 Fortran'').
8193 @end cartouche
8194 Followed.
8196 @findex Duration'Small
8197 @unnumberedsec 9.6(30-31): Duration'Small
8198 @sp 1
8199 @cartouche
8200 Whenever possible in an implementation, the value of @code{Duration'Small}
8201 should be no greater than 100 microseconds.
8202 @end cartouche
8203 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
8205 @sp 1
8206 @cartouche
8207 The time base for @code{delay_relative_statements} should be monotonic;
8208 it need not be the same time base as used for @code{Calendar.Clock}.
8209 @end cartouche
8210 Followed.
8212 @unnumberedsec 10.2.1(12): Consistent Representation
8213 @sp 1
8214 @cartouche
8215 In an implementation, a type declared in a pre-elaborated package should
8216 have the same representation in every elaboration of a given version of
8217 the package, whether the elaborations occur in distinct executions of
8218 the same program, or in executions of distinct programs or partitions
8219 that include the given version.
8220 @end cartouche
8221 Followed, except in the case of tagged types.  Tagged types involve
8222 implicit pointers to a local copy of a dispatch table, and these pointers
8223 have representations which thus depend on a particular elaboration of the
8224 package.  It is not easy to see how it would be possible to follow this
8225 advice without severely impacting efficiency of execution.
8227 @cindex Exception information
8228 @unnumberedsec 11.4.1(19): Exception Information
8229 @sp 1
8230 @cartouche
8231 @code{Exception_Message} by default and @code{Exception_Information}
8232 should produce information useful for
8233 debugging.  @code{Exception_Message} should be short, about one
8234 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
8235 should not include the
8236 @code{Exception_Name}.  @code{Exception_Information} should include both
8237 the @code{Exception_Name} and the @code{Exception_Message}.
8238 @end cartouche
8239 Followed.  For each exception that doesn't have a specified
8240 @code{Exception_Message}, the compiler generates one containing the location
8241 of the raise statement.  This location has the form ``file:line'', where
8242 file is the short file name (without path information) and line is the line
8243 number in the file.  Note that in the case of the Zero Cost Exception
8244 mechanism, these messages become redundant with the Exception_Information that
8245 contains a full backtrace of the calling sequence, so they are disabled.
8246 To disable explicitly the generation of the source location message, use the
8247 Pragma @code{Discard_Names}.
8249 @cindex Suppression of checks
8250 @cindex Checks, suppression of
8251 @unnumberedsec 11.5(28): Suppression of Checks
8252 @sp 1
8253 @cartouche
8254 The implementation should minimize the code executed for checks that
8255 have been suppressed.
8256 @end cartouche
8257 Followed.
8259 @cindex Representation clauses
8260 @unnumberedsec 13.1 (21-24): Representation Clauses
8261 @sp 1
8262 @cartouche
8263 The recommended level of support for all representation items is
8264 qualified as follows:
8265 @end cartouche
8266 @sp 1
8267 @cartouche
8268 An implementation need not support representation items containing
8269 non-static expressions, except that an implementation should support a
8270 representation item for a given entity if each non-static expression in
8271 the representation item is a name that statically denotes a constant
8272 declared before the entity.
8273 @end cartouche
8274 Followed.  In fact, GNAT goes beyond the recommended level of support
8275 by allowing nonstatic expressions in some representation clauses even
8276 without the need to declare constants initialized with the values of
8277 such expressions.
8278 For example:
8280 @smallexample @c ada
8281   X : Integer;
8282   Y : Float;
8283   for Y'Address use X'Address;>>
8284 @end smallexample
8286 @sp 1
8287 @cartouche
8288 An implementation need not support a specification for the @code{Size}
8289 for a given composite subtype, nor the size or storage place for an
8290 object (including a component) of a given composite subtype, unless the
8291 constraints on the subtype and its composite subcomponents (if any) are
8292 all static constraints.
8293 @end cartouche
8294 Followed.  Size Clauses are not permitted on non-static components, as
8295 described above.
8297 @sp 1
8298 @cartouche
8299 An aliased component, or a component whose type is by-reference, should
8300 always be allocated at an addressable location.
8301 @end cartouche
8302 Followed.
8304 @cindex Packed types
8305 @unnumberedsec 13.2(6-8): Packed Types
8306 @sp 1
8307 @cartouche
8308 If a type is packed, then the implementation should try to minimize
8309 storage allocated to objects of the type, possibly at the expense of
8310 speed of accessing components, subject to reasonable complexity in
8311 addressing calculations.
8312 @end cartouche
8313 @sp 1
8314 @cartouche
8315 The recommended level of support pragma @code{Pack} is:
8317 For a packed record type, the components should be packed as tightly as
8318 possible subject to the Sizes of the component subtypes, and subject to
8319 any @code{record_representation_clause} that applies to the type; the
8320 implementation may, but need not, reorder components or cross aligned
8321 word boundaries to improve the packing.  A component whose @code{Size} is
8322 greater than the word size may be allocated an integral number of words.
8323 @end cartouche
8324 Followed.  Tight packing of arrays is supported for all component sizes
8325 up to 64-bits. If the array component size is 1 (that is to say, if
8326 the component is a boolean type or an enumeration type with two values)
8327 then values of the type are implicitly initialized to zero. This
8328 happens both for objects of the packed type, and for objects that have a
8329 subcomponent of the packed type.
8331 @sp 1
8332 @cartouche
8333 An implementation should support Address clauses for imported
8334 subprograms.
8335 @end cartouche
8336 Followed.
8337 @cindex @code{Address} clauses
8338 @unnumberedsec 13.3(14-19): Address Clauses
8340 @sp 1
8341 @cartouche
8342 For an array @var{X}, @code{@var{X}'Address} should point at the first
8343 component of the array, and not at the array bounds.
8344 @end cartouche
8345 Followed.
8347 @sp 1
8348 @cartouche
8349 The recommended level of support for the @code{Address} attribute is:
8351 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8352 object that is aliased or of a by-reference type, or is an entity whose
8353 @code{Address} has been specified.
8354 @end cartouche
8355 Followed.  A valid address will be produced even if none of those
8356 conditions have been met.  If necessary, the object is forced into
8357 memory to ensure the address is valid.
8359 @sp 1
8360 @cartouche
8361 An implementation should support @code{Address} clauses for imported
8362 subprograms.
8363 @end cartouche
8364 Followed.
8366 @sp 1
8367 @cartouche
8368 Objects (including subcomponents) that are aliased or of a by-reference
8369 type should be allocated on storage element boundaries.
8370 @end cartouche
8371 Followed.
8373 @sp 1
8374 @cartouche
8375 If the @code{Address} of an object is specified, or it is imported or exported,
8376 then the implementation should not perform optimizations based on
8377 assumptions of no aliases.
8378 @end cartouche
8379 Followed.
8381 @cindex @code{Alignment} clauses
8382 @unnumberedsec 13.3(29-35): Alignment Clauses
8383 @sp 1
8384 @cartouche
8385 The recommended level of support for the @code{Alignment} attribute for
8386 subtypes is:
8388 An implementation should support specified Alignments that are factors
8389 and multiples of the number of storage elements per word, subject to the
8390 following:
8391 @end cartouche
8392 Followed.
8394 @sp 1
8395 @cartouche
8396 An implementation need not support specified @code{Alignment}s for
8397 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8398 loaded and stored by available machine instructions.
8399 @end cartouche
8400 Followed.
8402 @sp 1
8403 @cartouche
8404 An implementation need not support specified @code{Alignment}s that are
8405 greater than the maximum @code{Alignment} the implementation ever returns by
8406 default.
8407 @end cartouche
8408 Followed.
8410 @sp 1
8411 @cartouche
8412 The recommended level of support for the @code{Alignment} attribute for
8413 objects is:
8415 Same as above, for subtypes, but in addition:
8416 @end cartouche
8417 Followed.
8419 @sp 1
8420 @cartouche
8421 For stand-alone library-level objects of statically constrained
8422 subtypes, the implementation should support all @code{Alignment}s
8423 supported by the target linker.  For example, page alignment is likely to
8424 be supported for such objects, but not for subtypes.
8425 @end cartouche
8426 Followed.
8428 @cindex @code{Size} clauses
8429 @unnumberedsec 13.3(42-43): Size Clauses
8430 @sp 1
8431 @cartouche
8432 The recommended level of support for the @code{Size} attribute of
8433 objects is:
8435 A @code{Size} clause should be supported for an object if the specified
8436 @code{Size} is at least as large as its subtype's @code{Size}, and
8437 corresponds to a size in storage elements that is a multiple of the
8438 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8439 @end cartouche
8440 Followed.
8442 @unnumberedsec 13.3(50-56): Size Clauses
8443 @sp 1
8444 @cartouche
8445 If the @code{Size} of a subtype is specified, and allows for efficient
8446 independent addressability (see 9.10) on the target architecture, then
8447 the @code{Size} of the following objects of the subtype should equal the
8448 @code{Size} of the subtype:
8450 Aliased objects (including components).
8451 @end cartouche
8452 Followed.
8454 @sp 1
8455 @cartouche
8456 @code{Size} clause on a composite subtype should not affect the
8457 internal layout of components.
8458 @end cartouche
8459 Followed. But note that this can be overridden by use of the implementation
8460 pragma Implicit_Packing in the case of packed arrays.
8462 @sp 1
8463 @cartouche
8464 The recommended level of support for the @code{Size} attribute of subtypes is:
8465 @end cartouche
8466 @sp 1
8467 @cartouche
8468 The @code{Size} (if not specified) of a static discrete or fixed point
8469 subtype should be the number of bits needed to represent each value
8470 belonging to the subtype using an unbiased representation, leaving space
8471 for a sign bit only if the subtype contains negative values.  If such a
8472 subtype is a first subtype, then an implementation should support a
8473 specified @code{Size} for it that reflects this representation.
8474 @end cartouche
8475 Followed.
8477 @sp 1
8478 @cartouche
8479 For a subtype implemented with levels of indirection, the @code{Size}
8480 should include the size of the pointers, but not the size of what they
8481 point at.
8482 @end cartouche
8483 Followed.
8485 @cindex @code{Component_Size} clauses
8486 @unnumberedsec 13.3(71-73): Component Size Clauses
8487 @sp 1
8488 @cartouche
8489 The recommended level of support for the @code{Component_Size}
8490 attribute is:
8491 @end cartouche
8492 @sp 1
8493 @cartouche
8494 An implementation need not support specified @code{Component_Sizes} that are
8495 less than the @code{Size} of the component subtype.
8496 @end cartouche
8497 Followed.
8499 @sp 1
8500 @cartouche
8501 An implementation should support specified @code{Component_Size}s that
8502 are factors and multiples of the word size.  For such
8503 @code{Component_Size}s, the array should contain no gaps between
8504 components.  For other @code{Component_Size}s (if supported), the array
8505 should contain no gaps between components when packing is also
8506 specified; the implementation should forbid this combination in cases
8507 where it cannot support a no-gaps representation.
8508 @end cartouche
8509 Followed.
8511 @cindex Enumeration representation clauses
8512 @cindex Representation clauses, enumeration
8513 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8514 @sp 1
8515 @cartouche
8516 The recommended level of support for enumeration representation clauses
8519 An implementation need not support enumeration representation clauses
8520 for boolean types, but should at minimum support the internal codes in
8521 the range @code{System.Min_Int.System.Max_Int}.
8522 @end cartouche
8523 Followed.
8525 @cindex Record representation clauses
8526 @cindex Representation clauses, records
8527 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8528 @sp 1
8529 @cartouche
8530 The recommended level of support for
8531 @*@code{record_representation_clauses} is:
8533 An implementation should support storage places that can be extracted
8534 with a load, mask, shift sequence of machine code, and set with a load,
8535 shift, mask, store sequence, given the available machine instructions
8536 and run-time model.
8537 @end cartouche
8538 Followed.
8540 @sp 1
8541 @cartouche
8542 A storage place should be supported if its size is equal to the
8543 @code{Size} of the component subtype, and it starts and ends on a
8544 boundary that obeys the @code{Alignment} of the component subtype.
8545 @end cartouche
8546 Followed.
8548 @sp 1
8549 @cartouche
8550 If the default bit ordering applies to the declaration of a given type,
8551 then for a component whose subtype's @code{Size} is less than the word
8552 size, any storage place that does not cross an aligned word boundary
8553 should be supported.
8554 @end cartouche
8555 Followed.
8557 @sp 1
8558 @cartouche
8559 An implementation may reserve a storage place for the tag field of a
8560 tagged type, and disallow other components from overlapping that place.
8561 @end cartouche
8562 Followed.  The storage place for the tag field is the beginning of the tagged
8563 record, and its size is Address'Size.  GNAT will reject an explicit component
8564 clause for the tag field.
8566 @sp 1
8567 @cartouche
8568 An implementation need not support a @code{component_clause} for a
8569 component of an extension part if the storage place is not after the
8570 storage places of all components of the parent type, whether or not
8571 those storage places had been specified.
8572 @end cartouche
8573 Followed.  The above advice on record representation clauses is followed,
8574 and all mentioned features are implemented.
8576 @cindex Storage place attributes
8577 @unnumberedsec 13.5.2(5): Storage Place Attributes
8578 @sp 1
8579 @cartouche
8580 If a component is represented using some form of pointer (such as an
8581 offset) to the actual data of the component, and this data is contiguous
8582 with the rest of the object, then the storage place attributes should
8583 reflect the place of the actual data, not the pointer.  If a component is
8584 allocated discontinuously from the rest of the object, then a warning
8585 should be generated upon reference to one of its storage place
8586 attributes.
8587 @end cartouche
8588 Followed.  There are no such components in GNAT@.
8590 @cindex Bit ordering
8591 @unnumberedsec 13.5.3(7-8): Bit Ordering
8592 @sp 1
8593 @cartouche
8594 The recommended level of support for the non-default bit ordering is:
8595 @end cartouche
8596 @sp 1
8597 @cartouche
8598 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8599 should support the non-default bit ordering in addition to the default
8600 bit ordering.
8601 @end cartouche
8602 Followed.  Word size does not equal storage size in this implementation.
8603 Thus non-default bit ordering is not supported.
8605 @cindex @code{Address}, as private type
8606 @unnumberedsec 13.7(37): Address as Private
8607 @sp 1
8608 @cartouche
8609 @code{Address} should be of a private type.
8610 @end cartouche
8611 Followed.
8613 @cindex Operations, on @code{Address}
8614 @cindex @code{Address}, operations of
8615 @unnumberedsec 13.7.1(16): Address Operations
8616 @sp 1
8617 @cartouche
8618 Operations in @code{System} and its children should reflect the target
8619 environment semantics as closely as is reasonable.  For example, on most
8620 machines, it makes sense for address arithmetic to ``wrap around''.
8621 Operations that do not make sense should raise @code{Program_Error}.
8622 @end cartouche
8623 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
8624 operation raises @code{Program_Error}, since all operations make sense.
8626 @cindex Unchecked conversion
8627 @unnumberedsec 13.9(14-17): Unchecked Conversion
8628 @sp 1
8629 @cartouche
8630 The @code{Size} of an array object should not include its bounds; hence,
8631 the bounds should not be part of the converted data.
8632 @end cartouche
8633 Followed.
8635 @sp 1
8636 @cartouche
8637 The implementation should not generate unnecessary run-time checks to
8638 ensure that the representation of @var{S} is a representation of the
8639 target type.  It should take advantage of the permission to return by
8640 reference when possible.  Restrictions on unchecked conversions should be
8641 avoided unless required by the target environment.
8642 @end cartouche
8643 Followed.  There are no restrictions on unchecked conversion.  A warning is
8644 generated if the source and target types do not have the same size since
8645 the semantics in this case may be target dependent.
8647 @sp 1
8648 @cartouche
8649 The recommended level of support for unchecked conversions is:
8650 @end cartouche
8651 @sp 1
8652 @cartouche
8653 Unchecked conversions should be supported and should be reversible in
8654 the cases where this clause defines the result.  To enable meaningful use
8655 of unchecked conversion, a contiguous representation should be used for
8656 elementary subtypes, for statically constrained array subtypes whose
8657 component subtype is one of the subtypes described in this paragraph,
8658 and for record subtypes without discriminants whose component subtypes
8659 are described in this paragraph.
8660 @end cartouche
8661 Followed.
8663 @cindex Heap usage, implicit
8664 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8665 @sp 1
8666 @cartouche
8667 An implementation should document any cases in which it dynamically
8668 allocates heap storage for a purpose other than the evaluation of an
8669 allocator.
8670 @end cartouche
8671 Followed, the only other points at which heap storage is dynamically
8672 allocated are as follows:
8674 @itemize @bullet
8675 @item
8676 At initial elaboration time, to allocate dynamically sized global
8677 objects.
8679 @item
8680 To allocate space for a task when a task is created.
8682 @item
8683 To extend the secondary stack dynamically when needed.  The secondary
8684 stack is used for returning variable length results.
8685 @end itemize
8687 @sp 1
8688 @cartouche
8689 A default (implementation-provided) storage pool for an
8690 access-to-constant type should not have overhead to support deallocation of
8691 individual objects.
8692 @end cartouche
8693 Followed.
8695 @sp 1
8696 @cartouche
8697 A storage pool for an anonymous access type should be created at the
8698 point of an allocator for the type, and be reclaimed when the designated
8699 object becomes inaccessible.
8700 @end cartouche
8701 Followed.
8703 @cindex Unchecked deallocation
8704 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8705 @sp 1
8706 @cartouche
8707 For a standard storage pool, @code{Free} should actually reclaim the
8708 storage.
8709 @end cartouche
8710 Followed.
8712 @cindex Stream oriented attributes
8713 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8714 @sp 1
8715 @cartouche
8716 If a stream element is the same size as a storage element, then the
8717 normal in-memory representation should be used by @code{Read} and
8718 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
8719 should use the smallest number of stream elements needed to represent
8720 all values in the base range of the scalar type.
8721 @end cartouche
8723 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
8724 which specifies using the size of the first subtype.
8725 However, such an implementation is based on direct binary
8726 representations and is therefore target- and endianness-dependent.
8727 To address this issue, GNAT also supplies an alternate implementation
8728 of the stream attributes @code{Read} and @code{Write},
8729 which uses the target-independent XDR standard representation
8730 for scalar types.
8731 @cindex XDR representation
8732 @cindex @code{Read} attribute
8733 @cindex @code{Write} attribute
8734 @cindex Stream oriented attributes
8735 The XDR implementation is provided as an alternative body of the
8736 @code{System.Stream_Attributes} package, in the file
8737 @file{s-stratt-xdr.adb} in the GNAT library.
8738 There is no @file{s-stratt-xdr.ads} file.
8739 In order to install the XDR implementation, do the following:
8740 @enumerate
8741 @item Replace the default implementation of the
8742 @code{System.Stream_Attributes} package with the XDR implementation.
8743 For example on a Unix platform issue the commands:
8744 @smallexample
8745 $ mv s-stratt.adb s-stratt-default.adb
8746 $ mv s-stratt-xdr.adb s-stratt.adb
8747 @end smallexample
8749 @item
8750 Rebuild the GNAT run-time library as documented in
8751 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8752 @end enumerate
8754 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8755 @sp 1
8756 @cartouche
8757 If an implementation provides additional named predefined integer types,
8758 then the names should end with @samp{Integer} as in
8759 @samp{Long_Integer}.  If an implementation provides additional named
8760 predefined floating point types, then the names should end with
8761 @samp{Float} as in @samp{Long_Float}.
8762 @end cartouche
8763 Followed.
8765 @findex Ada.Characters.Handling
8766 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8767 @sp 1
8768 @cartouche
8769 If an implementation provides a localized definition of @code{Character}
8770 or @code{Wide_Character}, then the effects of the subprograms in
8771 @code{Characters.Handling} should reflect the localizations.  See also
8772 3.5.2.
8773 @end cartouche
8774 Followed.  GNAT provides no such localized definitions.
8776 @cindex Bounded-length strings
8777 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8778 @sp 1
8779 @cartouche
8780 Bounded string objects should not be implemented by implicit pointers
8781 and dynamic allocation.
8782 @end cartouche
8783 Followed.  No implicit pointers or dynamic allocation are used.
8785 @cindex Random number generation
8786 @unnumberedsec A.5.2(46-47): Random Number Generation
8787 @sp 1
8788 @cartouche
8789 Any storage associated with an object of type @code{Generator} should be
8790 reclaimed on exit from the scope of the object.
8791 @end cartouche
8792 Followed.
8794 @sp 1
8795 @cartouche
8796 If the generator period is sufficiently long in relation to the number
8797 of distinct initiator values, then each possible value of
8798 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8799 random numbers that does not, in a practical sense, overlap the sequence
8800 initiated by any other value.  If this is not possible, then the mapping
8801 between initiator values and generator states should be a rapidly
8802 varying function of the initiator value.
8803 @end cartouche
8804 Followed.  The generator period is sufficiently long for the first
8805 condition here to hold true.
8807 @findex Get_Immediate
8808 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8809 @sp 1
8810 @cartouche
8811 The @code{Get_Immediate} procedures should be implemented with
8812 unbuffered input.  For a device such as a keyboard, input should be
8813 @dfn{available} if a key has already been typed, whereas for a disk
8814 file, input should always be available except at end of file.  For a file
8815 associated with a keyboard-like device, any line-editing features of the
8816 underlying operating system should be disabled during the execution of
8817 @code{Get_Immediate}.
8818 @end cartouche
8819 Followed on all targets except VxWorks. For VxWorks, there is no way to
8820 provide this functionality that does not result in the input buffer being
8821 flushed before the @code{Get_Immediate} call. A special unit
8822 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8823 this functionality.
8825 @findex Export
8826 @unnumberedsec B.1(39-41): Pragma @code{Export}
8827 @sp 1
8828 @cartouche
8829 If an implementation supports pragma @code{Export} to a given language,
8830 then it should also allow the main subprogram to be written in that
8831 language.  It should support some mechanism for invoking the elaboration
8832 of the Ada library units included in the system, and for invoking the
8833 finalization of the environment task.  On typical systems, the
8834 recommended mechanism is to provide two subprograms whose link names are
8835 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
8836 elaboration code for library units.  @code{adafinal} should contain the
8837 finalization code.  These subprograms should have no effect the second
8838 and subsequent time they are called.
8839 @end cartouche
8840 Followed.
8842 @sp 1
8843 @cartouche
8844 Automatic elaboration of pre-elaborated packages should be
8845 provided when pragma @code{Export} is supported.
8846 @end cartouche
8847 Followed when the main program is in Ada.  If the main program is in a
8848 foreign language, then
8849 @code{adainit} must be called to elaborate pre-elaborated
8850 packages.
8852 @sp 1
8853 @cartouche
8854 For each supported convention @var{L} other than @code{Intrinsic}, an
8855 implementation should support @code{Import} and @code{Export} pragmas
8856 for objects of @var{L}-compatible types and for subprograms, and pragma
8857 @code{Convention} for @var{L}-eligible types and for subprograms,
8858 presuming the other language has corresponding features.  Pragma
8859 @code{Convention} need not be supported for scalar types.
8860 @end cartouche
8861 Followed.
8863 @cindex Package @code{Interfaces}
8864 @findex Interfaces
8865 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8866 @sp 1
8867 @cartouche
8868 For each implementation-defined convention identifier, there should be a
8869 child package of package Interfaces with the corresponding name.  This
8870 package should contain any declarations that would be useful for
8871 interfacing to the language (implementation) represented by the
8872 convention.  Any declarations useful for interfacing to any language on
8873 the given hardware architecture should be provided directly in
8874 @code{Interfaces}.
8875 @end cartouche
8876 Followed. An additional package not defined
8877 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8878 for interfacing to C++.
8880 @sp 1
8881 @cartouche
8882 An implementation supporting an interface to C, COBOL, or Fortran should
8883 provide the corresponding package or packages described in the following
8884 clauses.
8885 @end cartouche
8886 Followed.  GNAT provides all the packages described in this section.
8888 @cindex C, interfacing with
8889 @unnumberedsec B.3(63-71): Interfacing with C
8890 @sp 1
8891 @cartouche
8892 An implementation should support the following interface correspondences
8893 between Ada and C@.
8894 @end cartouche
8895 Followed.
8897 @sp 1
8898 @cartouche
8899 An Ada procedure corresponds to a void-returning C function.
8900 @end cartouche
8901 Followed.
8903 @sp 1
8904 @cartouche
8905 An Ada function corresponds to a non-void C function.
8906 @end cartouche
8907 Followed.
8909 @sp 1
8910 @cartouche
8911 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8912 function.
8913 @end cartouche
8914 Followed.
8916 @sp 1
8917 @cartouche
8918 An Ada @code{in} parameter of an access-to-object type with designated
8919 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8920 where @var{t} is the C type corresponding to the Ada type @var{T}.
8921 @end cartouche
8922 Followed.
8924 @sp 1
8925 @cartouche
8926 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8927 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8928 argument to a C function, where @var{t} is the C type corresponding to
8929 the Ada type @var{T}.  In the case of an elementary @code{out} or
8930 @code{in out} parameter, a pointer to a temporary copy is used to
8931 preserve by-copy semantics.
8932 @end cartouche
8933 Followed.
8935 @sp 1
8936 @cartouche
8937 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8938 @code{@var{t}*} argument to a C function, where @var{t} is the C
8939 structure corresponding to the Ada type @var{T}.
8940 @end cartouche
8941 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
8942 pragma, or Convention, or by explicitly specifying the mechanism for a given
8943 call using an extended import or export pragma.
8945 @sp 1
8946 @cartouche
8947 An Ada parameter of an array type with component type @var{T}, of any
8948 mode, is passed as a @code{@var{t}*} argument to a C function, where
8949 @var{t} is the C type corresponding to the Ada type @var{T}.
8950 @end cartouche
8951 Followed.
8953 @sp 1
8954 @cartouche
8955 An Ada parameter of an access-to-subprogram type is passed as a pointer
8956 to a C function whose prototype corresponds to the designated
8957 subprogram's specification.
8958 @end cartouche
8959 Followed.
8961 @cindex COBOL, interfacing with
8962 @unnumberedsec B.4(95-98): Interfacing with COBOL
8963 @sp 1
8964 @cartouche
8965 An Ada implementation should support the following interface
8966 correspondences between Ada and COBOL@.
8967 @end cartouche
8968 Followed.
8970 @sp 1
8971 @cartouche
8972 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8973 the COBOL type corresponding to @var{T}.
8974 @end cartouche
8975 Followed.
8977 @sp 1
8978 @cartouche
8979 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8980 the corresponding COBOL type.
8981 @end cartouche
8982 Followed.
8984 @sp 1
8985 @cartouche
8986 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8987 COBOL type corresponding to the Ada parameter type; for scalars, a local
8988 copy is used if necessary to ensure by-copy semantics.
8989 @end cartouche
8990 Followed.
8992 @cindex Fortran, interfacing with
8993 @unnumberedsec B.5(22-26): Interfacing with Fortran
8994 @sp 1
8995 @cartouche
8996 An Ada implementation should support the following interface
8997 correspondences between Ada and Fortran:
8998 @end cartouche
8999 Followed.
9001 @sp 1
9002 @cartouche
9003 An Ada procedure corresponds to a Fortran subroutine.
9004 @end cartouche
9005 Followed.
9007 @sp 1
9008 @cartouche
9009 An Ada function corresponds to a Fortran function.
9010 @end cartouche
9011 Followed.
9013 @sp 1
9014 @cartouche
9015 An Ada parameter of an elementary, array, or record type @var{T} is
9016 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9017 the Fortran type corresponding to the Ada type @var{T}, and where the
9018 INTENT attribute of the corresponding dummy argument matches the Ada
9019 formal parameter mode; the Fortran implementation's parameter passing
9020 conventions are used.  For elementary types, a local copy is used if
9021 necessary to ensure by-copy semantics.
9022 @end cartouche
9023 Followed.
9025 @sp 1
9026 @cartouche
9027 An Ada parameter of an access-to-subprogram type is passed as a
9028 reference to a Fortran procedure whose interface corresponds to the
9029 designated subprogram's specification.
9030 @end cartouche
9031 Followed.
9033 @cindex Machine operations
9034 @unnumberedsec C.1(3-5): Access to Machine Operations
9035 @sp 1
9036 @cartouche
9037 The machine code or intrinsic support should allow access to all
9038 operations normally available to assembly language programmers for the
9039 target environment, including privileged instructions, if any.
9040 @end cartouche
9041 Followed.
9043 @sp 1
9044 @cartouche
9045 The interfacing pragmas (see Annex B) should support interface to
9046 assembler; the default assembler should be associated with the
9047 convention identifier @code{Assembler}.
9048 @end cartouche
9049 Followed.
9051 @sp 1
9052 @cartouche
9053 If an entity is exported to assembly language, then the implementation
9054 should allocate it at an addressable location, and should ensure that it
9055 is retained by the linking process, even if not otherwise referenced
9056 from the Ada code.  The implementation should assume that any call to a
9057 machine code or assembler subprogram is allowed to read or update every
9058 object that is specified as exported.
9059 @end cartouche
9060 Followed.
9062 @unnumberedsec C.1(10-16): Access to Machine Operations
9063 @sp 1
9064 @cartouche
9065 The implementation should ensure that little or no overhead is
9066 associated with calling intrinsic and machine-code subprograms.
9067 @end cartouche
9068 Followed for both intrinsics and machine-code subprograms.
9070 @sp 1
9071 @cartouche
9072 It is recommended that intrinsic subprograms be provided for convenient
9073 access to any machine operations that provide special capabilities or
9074 efficiency and that are not otherwise available through the language
9075 constructs.
9076 @end cartouche
9077 Followed.  A full set of machine operation intrinsic subprograms is provided.
9079 @sp 1
9080 @cartouche
9081 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9082 swap, decrement and test, enqueue/dequeue.
9083 @end cartouche
9084 Followed on any target supporting such operations.
9086 @sp 1
9087 @cartouche
9088 Standard numeric functions---e.g.@:, sin, log.
9089 @end cartouche
9090 Followed on any target supporting such operations.
9092 @sp 1
9093 @cartouche
9094 String manipulation operations---e.g.@:, translate and test.
9095 @end cartouche
9096 Followed on any target supporting such operations.
9098 @sp 1
9099 @cartouche
9100 Vector operations---e.g.@:, compare vector against thresholds.
9101 @end cartouche
9102 Followed on any target supporting such operations.
9104 @sp 1
9105 @cartouche
9106 Direct operations on I/O ports.
9107 @end cartouche
9108 Followed on any target supporting such operations.
9110 @cindex Interrupt support
9111 @unnumberedsec C.3(28): Interrupt Support
9112 @sp 1
9113 @cartouche
9114 If the @code{Ceiling_Locking} policy is not in effect, the
9115 implementation should provide means for the application to specify which
9116 interrupts are to be blocked during protected actions, if the underlying
9117 system allows for a finer-grain control of interrupt blocking.
9118 @end cartouche
9119 Followed.  The underlying system does not allow for finer-grain control
9120 of interrupt blocking.
9122 @cindex Protected procedure handlers
9123 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9124 @sp 1
9125 @cartouche
9126 Whenever possible, the implementation should allow interrupt handlers to
9127 be called directly by the hardware.
9128 @end cartouche
9129 Followed on any target where the underlying operating system permits
9130 such direct calls.
9132 @sp 1
9133 @cartouche
9134 Whenever practical, violations of any
9135 implementation-defined restrictions should be detected before run time.
9136 @end cartouche
9137 Followed.  Compile time warnings are given when possible.
9139 @cindex Package @code{Interrupts}
9140 @findex Interrupts
9141 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9143 @sp 1
9144 @cartouche
9145 If implementation-defined forms of interrupt handler procedures are
9146 supported, such as protected procedures with parameters, then for each
9147 such form of a handler, a type analogous to @code{Parameterless_Handler}
9148 should be specified in a child package of @code{Interrupts}, with the
9149 same operations as in the predefined package Interrupts.
9150 @end cartouche
9151 Followed.
9153 @cindex Pre-elaboration requirements
9154 @unnumberedsec C.4(14): Pre-elaboration Requirements
9155 @sp 1
9156 @cartouche
9157 It is recommended that pre-elaborated packages be implemented in such a
9158 way that there should be little or no code executed at run time for the
9159 elaboration of entities not already covered by the Implementation
9160 Requirements.
9161 @end cartouche
9162 Followed.  Executable code is generated in some cases, e.g.@: loops
9163 to initialize large arrays.
9165 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9166 @sp 1
9167 @cartouche
9168 If the pragma applies to an entity, then the implementation should
9169 reduce the amount of storage used for storing names associated with that
9170 entity.
9171 @end cartouche
9172 Followed.
9174 @cindex Package @code{Task_Attributes}
9175 @findex Task_Attributes
9176 @unnumberedsec C.7.2(30): The Package Task_Attributes
9177 @sp 1
9178 @cartouche
9179 Some implementations are targeted to domains in which memory use at run
9180 time must be completely deterministic.  For such implementations, it is
9181 recommended that the storage for task attributes will be pre-allocated
9182 statically and not from the heap.  This can be accomplished by either
9183 placing restrictions on the number and the size of the task's
9184 attributes, or by using the pre-allocated storage for the first @var{N}
9185 attribute objects, and the heap for the others.  In the latter case,
9186 @var{N} should be documented.
9187 @end cartouche
9188 Not followed.  This implementation is not targeted to such a domain.
9190 @cindex Locking Policies
9191 @unnumberedsec D.3(17): Locking Policies
9193 @sp 1
9194 @cartouche
9195 The implementation should use names that end with @samp{_Locking} for
9196 locking policies defined by the implementation.
9197 @end cartouche
9198 Followed.  Two implementation-defined locking policies are defined,
9199 whose names (@code{Inheritance_Locking} and
9200 @code{Concurrent_Readers_Locking}) follow this suggestion.
9202 @cindex Entry queuing policies
9203 @unnumberedsec D.4(16): Entry Queuing Policies
9204 @sp 1
9205 @cartouche
9206 Names that end with @samp{_Queuing} should be used
9207 for all implementation-defined queuing policies.
9208 @end cartouche
9209 Followed.  No such implementation-defined queuing policies exist.
9211 @cindex Preemptive abort
9212 @unnumberedsec D.6(9-10): Preemptive Abort
9213 @sp 1
9214 @cartouche
9215 Even though the @code{abort_statement} is included in the list of
9216 potentially blocking operations (see 9.5.1), it is recommended that this
9217 statement be implemented in a way that never requires the task executing
9218 the @code{abort_statement} to block.
9219 @end cartouche
9220 Followed.
9222 @sp 1
9223 @cartouche
9224 On a multi-processor, the delay associated with aborting a task on
9225 another processor should be bounded; the implementation should use
9226 periodic polling, if necessary, to achieve this.
9227 @end cartouche
9228 Followed.
9230 @cindex Tasking restrictions
9231 @unnumberedsec D.7(21): Tasking Restrictions
9232 @sp 1
9233 @cartouche
9234 When feasible, the implementation should take advantage of the specified
9235 restrictions to produce a more efficient implementation.
9236 @end cartouche
9237 GNAT currently takes advantage of these restrictions by providing an optimized
9238 run time when the Ravenscar profile and the GNAT restricted run time set
9239 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
9240 pragma @code{Profile (Restricted)} for more details.
9242 @cindex Time, monotonic
9243 @unnumberedsec D.8(47-49): Monotonic Time
9244 @sp 1
9245 @cartouche
9246 When appropriate, implementations should provide configuration
9247 mechanisms to change the value of @code{Tick}.
9248 @end cartouche
9249 Such configuration mechanisms are not appropriate to this implementation
9250 and are thus not supported.
9252 @sp 1
9253 @cartouche
9254 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9255 be implemented as transformations of the same time base.
9256 @end cartouche
9257 Followed.
9259 @sp 1
9260 @cartouche
9261 It is recommended that the @dfn{best} time base which exists in
9262 the underlying system be available to the application through
9263 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
9264 @end cartouche
9265 Followed.
9267 @cindex Partition communication subsystem
9268 @cindex PCS
9269 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9270 @sp 1
9271 @cartouche
9272 Whenever possible, the PCS on the called partition should allow for
9273 multiple tasks to call the RPC-receiver with different messages and
9274 should allow them to block until the corresponding subprogram body
9275 returns.
9276 @end cartouche
9277 Followed by GLADE, a separately supplied PCS that can be used with
9278 GNAT.
9280 @sp 1
9281 @cartouche
9282 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9283 should raise @code{Storage_Error} if it runs out of space trying to
9284 write the @code{Item} into the stream.
9285 @end cartouche
9286 Followed by GLADE, a separately supplied PCS that can be used with
9287 GNAT@.
9289 @cindex COBOL support
9290 @unnumberedsec F(7): COBOL Support
9291 @sp 1
9292 @cartouche
9293 If COBOL (respectively, C) is widely supported in the target
9294 environment, implementations supporting the Information Systems Annex
9295 should provide the child package @code{Interfaces.COBOL} (respectively,
9296 @code{Interfaces.C}) specified in Annex B and should support a
9297 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9298 pragmas (see Annex B), thus allowing Ada programs to interface with
9299 programs written in that language.
9300 @end cartouche
9301 Followed.
9303 @cindex Decimal radix support
9304 @unnumberedsec F.1(2): Decimal Radix Support
9305 @sp 1
9306 @cartouche
9307 Packed decimal should be used as the internal representation for objects
9308 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9309 @end cartouche
9310 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
9311 representations.
9313 @cindex Numerics
9314 @unnumberedsec G: Numerics
9315 @sp 2
9316 @cartouche
9317 If Fortran (respectively, C) is widely supported in the target
9318 environment, implementations supporting the Numerics Annex
9319 should provide the child package @code{Interfaces.Fortran} (respectively,
9320 @code{Interfaces.C}) specified in Annex B and should support a
9321 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9322 pragmas (see Annex B), thus allowing Ada programs to interface with
9323 programs written in that language.
9324 @end cartouche
9325 Followed.
9327 @cindex Complex types
9328 @unnumberedsec G.1.1(56-58): Complex Types
9329 @sp 2
9330 @cartouche
9331 Because the usual mathematical meaning of multiplication of a complex
9332 operand and a real operand is that of the scaling of both components of
9333 the former by the latter, an implementation should not perform this
9334 operation by first promoting the real operand to complex type and then
9335 performing a full complex multiplication.  In systems that, in the
9336 future, support an Ada binding to IEC 559:1989, the latter technique
9337 will not generate the required result when one of the components of the
9338 complex operand is infinite.  (Explicit multiplication of the infinite
9339 component by the zero component obtained during promotion yields a NaN
9340 that propagates into the final result.) Analogous advice applies in the
9341 case of multiplication of a complex operand and a pure-imaginary
9342 operand, and in the case of division of a complex operand by a real or
9343 pure-imaginary operand.
9344 @end cartouche
9345 Not followed.
9347 @sp 1
9348 @cartouche
9349 Similarly, because the usual mathematical meaning of addition of a
9350 complex operand and a real operand is that the imaginary operand remains
9351 unchanged, an implementation should not perform this operation by first
9352 promoting the real operand to complex type and then performing a full
9353 complex addition.  In implementations in which the @code{Signed_Zeros}
9354 attribute of the component type is @code{True} (and which therefore
9355 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9356 predefined arithmetic operations), the latter technique will not
9357 generate the required result when the imaginary component of the complex
9358 operand is a negatively signed zero.  (Explicit addition of the negative
9359 zero to the zero obtained during promotion yields a positive zero.)
9360 Analogous advice applies in the case of addition of a complex operand
9361 and a pure-imaginary operand, and in the case of subtraction of a
9362 complex operand and a real or pure-imaginary operand.
9363 @end cartouche
9364 Not followed.
9366 @sp 1
9367 @cartouche
9368 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9369 attempt to provide a rational treatment of the signs of zero results and
9370 result components.  As one example, the result of the @code{Argument}
9371 function should have the sign of the imaginary component of the
9372 parameter @code{X} when the point represented by that parameter lies on
9373 the positive real axis; as another, the sign of the imaginary component
9374 of the @code{Compose_From_Polar} function should be the same as
9375 (respectively, the opposite of) that of the @code{Argument} parameter when that
9376 parameter has a value of zero and the @code{Modulus} parameter has a
9377 nonnegative (respectively, negative) value.
9378 @end cartouche
9379 Followed.
9381 @cindex Complex elementary functions
9382 @unnumberedsec G.1.2(49): Complex Elementary Functions
9383 @sp 1
9384 @cartouche
9385 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9386 @code{True} should attempt to provide a rational treatment of the signs
9387 of zero results and result components.  For example, many of the complex
9388 elementary functions have components that are odd functions of one of
9389 the parameter components; in these cases, the result component should
9390 have the sign of the parameter component at the origin.  Other complex
9391 elementary functions have zero components whose sign is opposite that of
9392 a parameter component at the origin, or is always positive or always
9393 negative.
9394 @end cartouche
9395 Followed.
9397 @cindex Accuracy requirements
9398 @unnumberedsec G.2.4(19): Accuracy Requirements
9399 @sp 1
9400 @cartouche
9401 The versions of the forward trigonometric functions without a
9402 @code{Cycle} parameter should not be implemented by calling the
9403 corresponding version with a @code{Cycle} parameter of
9404 @code{2.0*Numerics.Pi}, since this will not provide the required
9405 accuracy in some portions of the domain.  For the same reason, the
9406 version of @code{Log} without a @code{Base} parameter should not be
9407 implemented by calling the corresponding version with a @code{Base}
9408 parameter of @code{Numerics.e}.
9409 @end cartouche
9410 Followed.
9412 @cindex Complex arithmetic accuracy
9413 @cindex Accuracy, complex arithmetic
9414 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9416 @sp 1
9417 @cartouche
9418 The version of the @code{Compose_From_Polar} function without a
9419 @code{Cycle} parameter should not be implemented by calling the
9420 corresponding version with a @code{Cycle} parameter of
9421 @code{2.0*Numerics.Pi}, since this will not provide the required
9422 accuracy in some portions of the domain.
9423 @end cartouche
9424 Followed.
9426 @c -----------------------------------------
9427 @node Implementation Defined Characteristics
9428 @chapter Implementation Defined Characteristics
9430 @noindent
9431 In addition to the implementation dependent pragmas and attributes, and the
9432 implementation advice, there are a number of other Ada features that are
9433 potentially implementation dependent and are designated as
9434 implementation-defined. These are mentioned throughout the Ada Reference
9435 Manual, and are summarized in Annex M@.
9437 A requirement for conforming Ada compilers is that they provide
9438 documentation describing how the implementation deals with each of these
9439 issues.  In this chapter, you will find each point in Annex M listed
9440 followed by a description in italic font of how GNAT
9441 handles the implementation dependence.
9443 You can use this chapter as a guide to minimizing implementation
9444 dependent features in your programs if portability to other compilers
9445 and other operating systems is an important consideration.  The numbers
9446 in each section below correspond to the paragraph number in the Ada
9447 Reference Manual.
9449 @sp 1
9450 @cartouche
9451 @noindent
9452 @strong{2}.  Whether or not each recommendation given in Implementation
9453 Advice is followed.  See 1.1.2(37).
9454 @end cartouche
9455 @noindent
9456 @xref{Implementation Advice}.
9458 @sp 1
9459 @cartouche
9460 @noindent
9461 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
9462 @end cartouche
9463 @noindent
9464 The complexity of programs that can be processed is limited only by the
9465 total amount of available virtual memory, and disk space for the
9466 generated object files.
9468 @sp 1
9469 @cartouche
9470 @noindent
9471 @strong{4}.  Variations from the standard that are impractical to avoid
9472 given the implementation's execution environment.  See 1.1.3(6).
9473 @end cartouche
9474 @noindent
9475 There are no variations from the standard.
9477 @sp 1
9478 @cartouche
9479 @noindent
9480 @strong{5}.  Which @code{code_statement}s cause external
9481 interactions.  See 1.1.3(10).
9482 @end cartouche
9483 @noindent
9484 Any @code{code_statement} can potentially cause external interactions.
9486 @sp 1
9487 @cartouche
9488 @noindent
9489 @strong{6}.  The coded representation for the text of an Ada
9490 program.  See 2.1(4).
9491 @end cartouche
9492 @noindent
9493 See separate section on source representation.
9495 @sp 1
9496 @cartouche
9497 @noindent
9498 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
9499 @end cartouche
9500 @noindent
9501 See separate section on source representation.
9503 @sp 1
9504 @cartouche
9505 @noindent
9506 @strong{8}.  The representation for an end of line.  See 2.2(2).
9507 @end cartouche
9508 @noindent
9509 See separate section on source representation.
9511 @sp 1
9512 @cartouche
9513 @noindent
9514 @strong{9}.  Maximum supported line length and lexical element
9515 length.  See 2.2(15).
9516 @end cartouche
9517 @noindent
9518 The maximum line length is 255 characters and the maximum length of a
9519 lexical element is also 255 characters.
9521 @sp 1
9522 @cartouche
9523 @noindent
9524 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
9525 @end cartouche
9526 @noindent
9528 @xref{Implementation Defined Pragmas}.
9530 @sp 1
9531 @cartouche
9532 @noindent
9533 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
9534 @end cartouche
9535 @noindent
9536 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9537 parameter, checks that the optimization flag is set, and aborts if it is
9538 not.
9540 @sp 1
9541 @cartouche
9542 @noindent
9543 @strong{12}.  The sequence of characters of the value returned by
9544 @code{@var{S}'Image} when some of the graphic characters of
9545 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
9546 3.5(37).
9547 @end cartouche
9548 @noindent
9549 The sequence of characters is as defined by the wide character encoding
9550 method used for the source.  See section on source representation for
9551 further details.
9553 @sp 1
9554 @cartouche
9555 @noindent
9556 @strong{13}.  The predefined integer types declared in
9557 @code{Standard}.  See 3.5.4(25).
9558 @end cartouche
9559 @noindent
9560 @table @code
9561 @item Short_Short_Integer
9562 8 bit signed
9563 @item Short_Integer
9564 (Short) 16 bit signed
9565 @item Integer
9566 32 bit signed
9567 @item Long_Integer
9568 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9569 32 bit signed (all other targets)
9570 @item Long_Long_Integer
9571 64 bit signed
9572 @end table
9574 @sp 1
9575 @cartouche
9576 @noindent
9577 @strong{14}.  Any nonstandard integer types and the operators defined
9578 for them.  See 3.5.4(26).
9579 @end cartouche
9580 @noindent
9581 There are no nonstandard integer types.
9583 @sp 1
9584 @cartouche
9585 @noindent
9586 @strong{15}.  Any nonstandard real types and the operators defined for
9587 them.  See 3.5.6(8).
9588 @end cartouche
9589 @noindent
9590 There are no nonstandard real types.
9592 @sp 1
9593 @cartouche
9594 @noindent
9595 @strong{16}.  What combinations of requested decimal precision and range
9596 are supported for floating point types.  See 3.5.7(7).
9597 @end cartouche
9598 @noindent
9599 The precision and range is as defined by the IEEE standard.
9601 @sp 1
9602 @cartouche
9603 @noindent
9604 @strong{17}.  The predefined floating point types declared in
9605 @code{Standard}.  See 3.5.7(16).
9606 @end cartouche
9607 @noindent
9608 @table @code
9609 @item Short_Float
9610 32 bit IEEE short
9611 @item Float
9612 (Short) 32 bit IEEE short
9613 @item Long_Float
9614 64 bit IEEE long
9615 @item Long_Long_Float
9616 64 bit IEEE long (80 bit IEEE long on x86 processors)
9617 @end table
9619 @sp 1
9620 @cartouche
9621 @noindent
9622 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
9623 @end cartouche
9624 @noindent
9625 @code{Fine_Delta} is 2**(@minus{}63)
9627 @sp 1
9628 @cartouche
9629 @noindent
9630 @strong{19}.  What combinations of small, range, and digits are
9631 supported for fixed point types.  See 3.5.9(10).
9632 @end cartouche
9633 @noindent
9634 Any combinations are permitted that do not result in a small less than
9635 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9636 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9637 is 64 bits (true of all architectures except ia32), then the output from
9638 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
9639 is because floating-point conversions are used to convert fixed point.
9641 @sp 1
9642 @cartouche
9643 @noindent
9644 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
9645 within an unnamed @code{block_statement}.  See 3.9(10).
9646 @end cartouche
9647 @noindent
9648 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9649 decimal integer are allocated.
9651 @sp 1
9652 @cartouche
9653 @noindent
9654 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
9655 @end cartouche
9656 @noindent
9657 @xref{Implementation Defined Attributes}.
9659 @sp 1
9660 @cartouche
9661 @noindent
9662 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
9663 @end cartouche
9664 @noindent
9665 There are no implementation-defined time types.
9667 @sp 1
9668 @cartouche
9669 @noindent
9670 @strong{23}.  The time base associated with relative delays.
9671 @end cartouche
9672 @noindent
9673 See 9.6(20).  The time base used is that provided by the C library
9674 function @code{gettimeofday}.
9676 @sp 1
9677 @cartouche
9678 @noindent
9679 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
9680 9.6(23).
9681 @end cartouche
9682 @noindent
9683 The time base used is that provided by the C library function
9684 @code{gettimeofday}.
9686 @sp 1
9687 @cartouche
9688 @noindent
9689 @strong{25}.  The time zone used for package @code{Calendar}
9690 operations.  See 9.6(24).
9691 @end cartouche
9692 @noindent
9693 The time zone used by package @code{Calendar} is the current system time zone
9694 setting for local time, as accessed by the C library function
9695 @code{localtime}.
9697 @sp 1
9698 @cartouche
9699 @noindent
9700 @strong{26}.  Any limit on @code{delay_until_statements} of
9701 @code{select_statements}.  See 9.6(29).
9702 @end cartouche
9703 @noindent
9704 There are no such limits.
9706 @sp 1
9707 @cartouche
9708 @noindent
9709 @strong{27}.  Whether or not two non-overlapping parts of a composite
9710 object are independently addressable, in the case where packing, record
9711 layout, or @code{Component_Size} is specified for the object.  See
9712 9.10(1).
9713 @end cartouche
9714 @noindent
9715 Separate components are independently addressable if they do not share
9716 overlapping storage units.
9718 @sp 1
9719 @cartouche
9720 @noindent
9721 @strong{28}.  The representation for a compilation.  See 10.1(2).
9722 @end cartouche
9723 @noindent
9724 A compilation is represented by a sequence of files presented to the
9725 compiler in a single invocation of the @command{gcc} command.
9727 @sp 1
9728 @cartouche
9729 @noindent
9730 @strong{29}.  Any restrictions on compilations that contain multiple
9731 compilation_units.  See 10.1(4).
9732 @end cartouche
9733 @noindent
9734 No single file can contain more than one compilation unit, but any
9735 sequence of files can be presented to the compiler as a single
9736 compilation.
9738 @sp 1
9739 @cartouche
9740 @noindent
9741 @strong{30}.  The mechanisms for creating an environment and for adding
9742 and replacing compilation units.  See 10.1.4(3).
9743 @end cartouche
9744 @noindent
9745 See separate section on compilation model.
9747 @sp 1
9748 @cartouche
9749 @noindent
9750 @strong{31}.  The manner of explicitly assigning library units to a
9751 partition.  See 10.2(2).
9752 @end cartouche
9753 @noindent
9754 If a unit contains an Ada main program, then the Ada units for the partition
9755 are determined by recursive application of the rules in the Ada Reference
9756 Manual section 10.2(2-6).  In other words, the Ada units will be those that
9757 are needed by the main program, and then this definition of need is applied
9758 recursively to those units, and the partition contains the transitive
9759 closure determined by this relationship.  In short, all the necessary units
9760 are included, with no need to explicitly specify the list.  If additional
9761 units are required, e.g.@: by foreign language units, then all units must be
9762 mentioned in the context clause of one of the needed Ada units.
9764 If the partition contains no main program, or if the main program is in
9765 a language other than Ada, then GNAT
9766 provides the binder options @option{-z} and @option{-n} respectively, and in
9767 this case a list of units can be explicitly supplied to the binder for
9768 inclusion in the partition (all units needed by these units will also
9769 be included automatically).  For full details on the use of these
9770 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9771 @value{EDITION} User's Guide}.
9773 @sp 1
9774 @cartouche
9775 @noindent
9776 @strong{32}.  The implementation-defined means, if any, of specifying
9777 which compilation units are needed by a given compilation unit.  See
9778 10.2(2).
9779 @end cartouche
9780 @noindent
9781 The units needed by a given compilation unit are as defined in
9782 the Ada Reference Manual section 10.2(2-6).  There are no
9783 implementation-defined pragmas or other implementation-defined
9784 means for specifying needed units.
9786 @sp 1
9787 @cartouche
9788 @noindent
9789 @strong{33}.  The manner of designating the main subprogram of a
9790 partition.  See 10.2(7).
9791 @end cartouche
9792 @noindent
9793 The main program is designated by providing the name of the
9794 corresponding @file{ALI} file as the input parameter to the binder.
9796 @sp 1
9797 @cartouche
9798 @noindent
9799 @strong{34}.  The order of elaboration of @code{library_items}.  See
9800 10.2(18).
9801 @end cartouche
9802 @noindent
9803 The first constraint on ordering is that it meets the requirements of
9804 Chapter 10 of the Ada Reference Manual.  This still leaves some
9805 implementation dependent choices, which are resolved by first
9806 elaborating bodies as early as possible (i.e., in preference to specs
9807 where there is a choice), and second by evaluating the immediate with
9808 clauses of a unit to determine the probably best choice, and
9809 third by elaborating in alphabetical order of unit names
9810 where a choice still remains.
9812 @sp 1
9813 @cartouche
9814 @noindent
9815 @strong{35}.  Parameter passing and function return for the main
9816 subprogram.  See 10.2(21).
9817 @end cartouche
9818 @noindent
9819 The main program has no parameters.  It may be a procedure, or a function
9820 returning an integer type.  In the latter case, the returned integer
9821 value is the return code of the program (overriding any value that
9822 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9824 @sp 1
9825 @cartouche
9826 @noindent
9827 @strong{36}.  The mechanisms for building and running partitions.  See
9828 10.2(24).
9829 @end cartouche
9830 @noindent
9831 GNAT itself supports programs with only a single partition.  The GNATDIST
9832 tool provided with the GLADE package (which also includes an implementation
9833 of the PCS) provides a completely flexible method for building and running
9834 programs consisting of multiple partitions.  See the separate GLADE manual
9835 for details.
9837 @sp 1
9838 @cartouche
9839 @noindent
9840 @strong{37}.  The details of program execution, including program
9841 termination.  See 10.2(25).
9842 @end cartouche
9843 @noindent
9844 See separate section on compilation model.
9846 @sp 1
9847 @cartouche
9848 @noindent
9849 @strong{38}.  The semantics of any non-active partitions supported by the
9850 implementation.  See 10.2(28).
9851 @end cartouche
9852 @noindent
9853 Passive partitions are supported on targets where shared memory is
9854 provided by the operating system.  See the GLADE reference manual for
9855 further details.
9857 @sp 1
9858 @cartouche
9859 @noindent
9860 @strong{39}.  The information returned by @code{Exception_Message}.  See
9861 11.4.1(10).
9862 @end cartouche
9863 @noindent
9864 Exception message returns the null string unless a specific message has
9865 been passed by the program.
9867 @sp 1
9868 @cartouche
9869 @noindent
9870 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
9871 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
9872 @end cartouche
9873 @noindent
9874 Blocks have implementation defined names of the form @code{B@var{nnn}}
9875 where @var{nnn} is an integer.
9877 @sp 1
9878 @cartouche
9879 @noindent
9880 @strong{41}.  The information returned by
9881 @code{Exception_Information}.  See 11.4.1(13).
9882 @end cartouche
9883 @noindent
9884 @code{Exception_Information} returns a string in the following format:
9886 @smallexample
9887 @emph{Exception_Name:} nnnnn
9888 @emph{Message:} mmmmm
9889 @emph{PID:} ppp
9890 @emph{Call stack traceback locations:}
9891 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9892 @end smallexample
9894 @noindent
9895 where
9897 @itemize @bullet
9898 @item
9899 @code{nnnn} is the fully qualified name of the exception in all upper
9900 case letters. This line is always present.
9902 @item
9903 @code{mmmm} is the message (this line present only if message is non-null)
9905 @item
9906 @code{ppp} is the Process Id value as a decimal integer (this line is
9907 present only if the Process Id is nonzero). Currently we are
9908 not making use of this field.
9910 @item
9911 The Call stack traceback locations line and the following values
9912 are present only if at least one traceback location was recorded.
9913 The values are given in C style format, with lower case letters
9914 for a-f, and only as many digits present as are necessary.
9915 @end itemize
9917 @noindent
9918 The line terminator sequence at the end of each line, including
9919 the last line is a single @code{LF} character (@code{16#0A#}).
9921 @sp 1
9922 @cartouche
9923 @noindent
9924 @strong{42}.  Implementation-defined check names.  See 11.5(27).
9925 @end cartouche
9926 @noindent
9927 The implementation defined check name Alignment_Check controls checking of
9928 address clause values for proper alignment (that is, the address supplied
9929 must be consistent with the alignment of the type).
9931 In addition, a user program can add implementation-defined check names
9932 by means of the pragma Check_Name.
9934 @sp 1
9935 @cartouche
9936 @noindent
9937 @strong{43}.  The interpretation of each aspect of representation.  See
9938 13.1(20).
9939 @end cartouche
9940 @noindent
9941 See separate section on data representations.
9943 @sp 1
9944 @cartouche
9945 @noindent
9946 @strong{44}.  Any restrictions placed upon representation items.  See
9947 13.1(20).
9948 @end cartouche
9949 @noindent
9950 See separate section on data representations.
9952 @sp 1
9953 @cartouche
9954 @noindent
9955 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
9956 13.3(48).
9957 @end cartouche
9958 @noindent
9959 Size for an indefinite subtype is the maximum possible size, except that
9960 for the case of a subprogram parameter, the size of the parameter object
9961 is the actual size.
9963 @sp 1
9964 @cartouche
9965 @noindent
9966 @strong{46}.  The default external representation for a type tag.  See
9967 13.3(75).
9968 @end cartouche
9969 @noindent
9970 The default external representation for a type tag is the fully expanded
9971 name of the type in upper case letters.
9973 @sp 1
9974 @cartouche
9975 @noindent
9976 @strong{47}.  What determines whether a compilation unit is the same in
9977 two different partitions.  See 13.3(76).
9978 @end cartouche
9979 @noindent
9980 A compilation unit is the same in two different partitions if and only
9981 if it derives from the same source file.
9983 @sp 1
9984 @cartouche
9985 @noindent
9986 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
9987 @end cartouche
9988 @noindent
9989 The only implementation defined component is the tag for a tagged type,
9990 which contains a pointer to the dispatching table.
9992 @sp 1
9993 @cartouche
9994 @noindent
9995 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
9996 ordering.  See 13.5.3(5).
9997 @end cartouche
9998 @noindent
9999 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10000 implementation, so no non-default bit ordering is supported.  The default
10001 bit ordering corresponds to the natural endianness of the target architecture.
10003 @sp 1
10004 @cartouche
10005 @noindent
10006 @strong{50}.  The contents of the visible part of package @code{System}
10007 and its language-defined children.  See 13.7(2).
10008 @end cartouche
10009 @noindent
10010 See the definition of these packages in files @file{system.ads} and
10011 @file{s-stoele.ads}.
10013 @sp 1
10014 @cartouche
10015 @noindent
10016 @strong{51}.  The contents of the visible part of package
10017 @code{System.Machine_Code}, and the meaning of
10018 @code{code_statements}.  See 13.8(7).
10019 @end cartouche
10020 @noindent
10021 See the definition and documentation in file @file{s-maccod.ads}.
10023 @sp 1
10024 @cartouche
10025 @noindent
10026 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
10027 @end cartouche
10028 @noindent
10029 Unchecked conversion between types of the same size
10030 results in an uninterpreted transmission of the bits from one type
10031 to the other.  If the types are of unequal sizes, then in the case of
10032 discrete types, a shorter source is first zero or sign extended as
10033 necessary, and a shorter target is simply truncated on the left.
10034 For all non-discrete types, the source is first copied if necessary
10035 to ensure that the alignment requirements of the target are met, then
10036 a pointer is constructed to the source value, and the result is obtained
10037 by dereferencing this pointer after converting it to be a pointer to the
10038 target type. Unchecked conversions where the target subtype is an
10039 unconstrained array are not permitted. If the target alignment is
10040 greater than the source alignment, then a copy of the result is
10041 made with appropriate alignment
10043 @sp 1
10044 @cartouche
10045 @noindent
10046 @strong{53}. The semantics of operations on invalid representations.
10047 See 13.9.2(10-11).
10048 @end cartouche
10049 @noindent
10050 For assignments and other operations where the use of invalid values cannot
10051 result in erroneous behavior, the compiler ignores the possibility of invalid
10052 values. An exception is raised at the point where an invalid value would
10053 result in erroneous behavior. For example executing:
10055 @smallexample @c ada
10056 procedure invalidvals is
10057    X : Integer := -1;
10058    Y : Natural range 1 .. 10;
10059    for Y'Address use X'Address;
10060    Z : Natural range 1 .. 10;
10061    A : array (Natural range 1 .. 10) of Integer;
10062 begin
10063    Z := Y;     -- no exception
10064    A (Z) := 3; -- exception raised;
10065 end;
10066 @end smallexample
10068 @noindent
10069 As indicated, an exception is raised on the array assignment, but not
10070 on the simple assignment of the invalid negative value from Y to Z.
10072 @sp 1
10073 @cartouche
10074 @noindent
10075 @strong{53}.  The manner of choosing a storage pool for an access type
10076 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
10077 @end cartouche
10078 @noindent
10079 There are 3 different standard pools used by the compiler when
10080 @code{Storage_Pool} is not specified depending whether the type is local
10081 to a subprogram or defined at the library level and whether
10082 @code{Storage_Size}is specified or not.  See documentation in the runtime
10083 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10084 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10085 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10086 default pools used.
10088 @sp 1
10089 @cartouche
10090 @noindent
10091 @strong{54}.  Whether or not the implementation provides user-accessible
10092 names for the standard pool type(s).  See 13.11(17).
10093 @end cartouche
10094 @noindent
10096 See documentation in the sources of the run time mentioned in paragraph
10097 @strong{53} .  All these pools are accessible by means of @code{with}'ing
10098 these units.
10100 @sp 1
10101 @cartouche
10102 @noindent
10103 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
10104 @end cartouche
10105 @noindent
10106 @code{Storage_Size} is measured in storage units, and refers to the
10107 total space available for an access type collection, or to the primary
10108 stack space for a task.
10110 @sp 1
10111 @cartouche
10112 @noindent
10113 @strong{56}.  Implementation-defined aspects of storage pools.  See
10114 13.11(22).
10115 @end cartouche
10116 @noindent
10117 See documentation in the sources of the run time mentioned in paragraph
10118 @strong{53} for details on GNAT-defined aspects of storage pools.
10120 @sp 1
10121 @cartouche
10122 @noindent
10123 @strong{57}.  The set of restrictions allowed in a pragma
10124 @code{Restrictions}.  See 13.12(7).
10125 @end cartouche
10126 @noindent
10127 @xref{Standard and Implementation Defined Restrictions}.
10129 @sp 1
10130 @cartouche
10131 @noindent
10132 @strong{58}.  The consequences of violating limitations on
10133 @code{Restrictions} pragmas.  See 13.12(9).
10134 @end cartouche
10135 @noindent
10136 Restrictions that can be checked at compile time result in illegalities
10137 if violated.  Currently there are no other consequences of violating
10138 restrictions.
10140 @sp 1
10141 @cartouche
10142 @noindent
10143 @strong{59}.  The representation used by the @code{Read} and
10144 @code{Write} attributes of elementary types in terms of stream
10145 elements.  See 13.13.2(9).
10146 @end cartouche
10147 @noindent
10148 The representation is the in-memory representation of the base type of
10149 the type, using the number of bits corresponding to the
10150 @code{@var{type}'Size} value, and the natural ordering of the machine.
10152 @sp 1
10153 @cartouche
10154 @noindent
10155 @strong{60}.  The names and characteristics of the numeric subtypes
10156 declared in the visible part of package @code{Standard}.  See A.1(3).
10157 @end cartouche
10158 @noindent
10159 See items describing the integer and floating-point types supported.
10161 @sp 1
10162 @cartouche
10163 @noindent
10164 @strong{61}.  The accuracy actually achieved by the elementary
10165 functions.  See A.5.1(1).
10166 @end cartouche
10167 @noindent
10168 The elementary functions correspond to the functions available in the C
10169 library.  Only fast math mode is implemented.
10171 @sp 1
10172 @cartouche
10173 @noindent
10174 @strong{62}.  The sign of a zero result from some of the operators or
10175 functions in @code{Numerics.Generic_Elementary_Functions}, when
10176 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
10177 @end cartouche
10178 @noindent
10179 The sign of zeroes follows the requirements of the IEEE 754 standard on
10180 floating-point.
10182 @sp 1
10183 @cartouche
10184 @noindent
10185 @strong{63}.  The value of
10186 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
10187 @end cartouche
10188 @noindent
10189 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10191 @sp 1
10192 @cartouche
10193 @noindent
10194 @strong{64}.  The value of
10195 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
10196 @end cartouche
10197 @noindent
10198 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10200 @sp 1
10201 @cartouche
10202 @noindent
10203 @strong{65}.  The algorithms for random number generation.  See
10204 A.5.2(32).
10205 @end cartouche
10206 @noindent
10207 The algorithm is the Mersenne Twister, as documented in the source file
10208 @file{s-rannum.adb}. This version of the algorithm has a period of
10209 2**19937-1.
10211 @sp 1
10212 @cartouche
10213 @noindent
10214 @strong{66}.  The string representation of a random number generator's
10215 state.  See A.5.2(38).
10216 @end cartouche
10217 @noindent
10218 The value returned by the Image function is the concatenation of
10219 the fixed-width decimal representations of the 624 32-bit integers
10220 of the state vector.
10222 @sp 1
10223 @cartouche
10224 @noindent
10225 @strong{67}.  The minimum time interval between calls to the
10226 time-dependent Reset procedure that are guaranteed to initiate different
10227 random number sequences.  See A.5.2(45).
10228 @end cartouche
10229 @noindent
10230 The minimum period between reset calls to guarantee distinct series of
10231 random numbers is one microsecond.
10233 @sp 1
10234 @cartouche
10235 @noindent
10236 @strong{68}.  The values of the @code{Model_Mantissa},
10237 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10238 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10239 Annex is not supported.  See A.5.3(72).
10240 @end cartouche
10241 @noindent
10242 Run the compiler with @option{-gnatS} to produce a listing of package
10243 @code{Standard}, has the values of all numeric attributes.
10245 @sp 1
10246 @cartouche
10247 @noindent
10248 @strong{69}.  Any implementation-defined characteristics of the
10249 input-output packages.  See A.7(14).
10250 @end cartouche
10251 @noindent
10252 There are no special implementation defined characteristics for these
10253 packages.
10255 @sp 1
10256 @cartouche
10257 @noindent
10258 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
10259 A.9(10).
10260 @end cartouche
10261 @noindent
10262 All type representations are contiguous, and the @code{Buffer_Size} is
10263 the value of @code{@var{type}'Size} rounded up to the next storage unit
10264 boundary.
10266 @sp 1
10267 @cartouche
10268 @noindent
10269 @strong{71}.  External files for standard input, standard output, and
10270 standard error See A.10(5).
10271 @end cartouche
10272 @noindent
10273 These files are mapped onto the files provided by the C streams
10274 libraries.  See source file @file{i-cstrea.ads} for further details.
10276 @sp 1
10277 @cartouche
10278 @noindent
10279 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
10280 A.10.9(36).
10281 @end cartouche
10282 @noindent
10283 If more digits are requested in the output than are represented by the
10284 precision of the value, zeroes are output in the corresponding least
10285 significant digit positions.
10287 @sp 1
10288 @cartouche
10289 @noindent
10290 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
10291 @code{Command_Name}.  See A.15(1).
10292 @end cartouche
10293 @noindent
10294 These are mapped onto the @code{argv} and @code{argc} parameters of the
10295 main program in the natural manner.
10297 @sp 1
10298 @cartouche
10299 @noindent
10300 @strong{74}.  The interpretation of the @code{Form} parameter in procedure
10301 @code{Create_Directory}.  See A.16(56).
10302 @end cartouche
10303 @noindent
10304 The @code{Form} parameter is not used.
10306 @sp 1
10307 @cartouche
10308 @noindent
10309 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
10310 @code{Create_Path}.  See A.16(60).
10311 @end cartouche
10312 @noindent
10313 The @code{Form} parameter is not used.
10315 @sp 1
10316 @cartouche
10317 @noindent
10318 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
10319 @code{Copy_File}.  See A.16(68).
10320 @end cartouche
10321 @noindent
10322 The @code{Form} parameter is case-insensitive.
10324 Two fields are recognized in the @code{Form} parameter:
10326 @table @code
10328 @item preserve=<value>
10330 @item mode=<value>
10332 @end table
10334 @noindent
10335 <value> starts immediately after the character '=' and ends with the
10336 character immediately preceding the next comma (',') or with the last
10337 character of the parameter.
10339 The only possible values for preserve= are:
10341 @table @code
10343 @item no_attributes
10344 Do not try to preserve any file attributes. This is the default if no
10345 preserve= is found in Form.
10347 @item all_attributes
10348 Try to preserve all file attributes (timestamps, access rights).
10350 @item timestamps
10351 Preserve the timestamp of the copied file, but not the other file attributes.
10353 @end table
10355 @noindent
10356 The only possible values for mode= are:
10358 @table @code
10360 @item copy
10361 Only do the copy if the destination file does not already exist. If it already
10362 exists, Copy_File fails.
10364 @item overwrite
10365 Copy the file in all cases. Overwrite an already existing destination file.
10367 @item append
10368 Append the original file to the destination file. If the destination file does
10369 not exist, the destination file is a copy of the source file. When mode=append,
10370 the field preserve=, if it exists, is not taken into account.
10372 @end table
10374 @noindent
10375 If the Form parameter includes one or both of the fields and the value or
10376 values are incorrect, Copy_file fails with Use_Error.
10378 Examples of correct Forms:
10380 @smallexample
10381 Form => "preserve=no_attributes,mode=overwrite" (the default)
10382 Form => "mode=append"
10383 Form => "mode=copy, preserve=all_attributes"
10384 @end smallexample
10386 @noindent
10387 Examples of incorrect Forms
10389 @smallexample
10390 Form => "preserve=junk"
10391 Form => "mode=internal, preserve=timestamps"
10392 @end smallexample
10394 @sp 1
10395 @cartouche
10396 @noindent
10397 @strong{77}.  Implementation-defined convention names.  See B.1(11).
10398 @end cartouche
10399 @noindent
10400 The following convention names are supported
10402 @table @code
10403 @item  Ada
10405 @item Ada_Pass_By_Copy
10406 Allowed for any types except by-reference types such as limited
10407 records. Compatible with convention Ada, but causes any parameters
10408 with this convention to be passed by copy.
10409 @item Ada_Pass_By_Reference
10410 Allowed for any types except by-copy types such as scalars.
10411 Compatible with convention Ada, but causes any parameters
10412 with this convention to be passed by reference.
10413 @item Assembler
10414 Assembly language
10415 @item Asm
10416 Synonym for Assembler
10417 @item Assembly
10418 Synonym for Assembler
10419 @item C
10421 @item C_Pass_By_Copy
10422 Allowed only for record types, like C, but also notes that record
10423 is to be passed by copy rather than reference.
10424 @item COBOL
10425 COBOL
10426 @item C_Plus_Plus (or CPP)
10428 @item Default
10429 Treated the same as C
10430 @item External
10431 Treated the same as C
10432 @item Fortran
10433 Fortran
10434 @item Intrinsic
10435 For support of pragma @code{Import} with convention Intrinsic, see
10436 separate section on Intrinsic Subprograms.
10437 @item Stdcall
10438 Stdcall (used for Windows implementations only).  This convention correspond
10439 to the WINAPI (previously called Pascal convention) C/C++ convention under
10440 Windows.  A routine with this convention cleans the stack before
10441 exit. This pragma cannot be applied to a dispatching call.
10442 @item DLL
10443 Synonym for Stdcall
10444 @item Win32
10445 Synonym for Stdcall
10446 @item Stubbed
10447 Stubbed is a special convention used to indicate that the body of the
10448 subprogram will be entirely ignored.  Any call to the subprogram
10449 is converted into a raise of the @code{Program_Error} exception.  If a
10450 pragma @code{Import} specifies convention @code{stubbed} then no body need
10451 be present at all.  This convention is useful during development for the
10452 inclusion of subprograms whose body has not yet been written.
10454 @end table
10455 @noindent
10456 In addition, all otherwise unrecognized convention names are also
10457 treated as being synonymous with convention C@.  In all implementations
10458 except for VMS, use of such other names results in a warning.  In VMS
10459 implementations, these names are accepted silently.
10461 @sp 1
10462 @cartouche
10463 @noindent
10464 @strong{78}.  The meaning of link names.  See B.1(36).
10465 @end cartouche
10466 @noindent
10467 Link names are the actual names used by the linker.
10469 @sp 1
10470 @cartouche
10471 @noindent
10472 @strong{79}.  The manner of choosing link names when neither the link
10473 name nor the address of an imported or exported entity is specified.  See
10474 B.1(36).
10475 @end cartouche
10476 @noindent
10477 The default linker name is that which would be assigned by the relevant
10478 external language, interpreting the Ada name as being in all lower case
10479 letters.
10481 @sp 1
10482 @cartouche
10483 @noindent
10484 @strong{80}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
10485 @end cartouche
10486 @noindent
10487 The string passed to @code{Linker_Options} is presented uninterpreted as
10488 an argument to the link command, unless it contains ASCII.NUL characters.
10489 NUL characters if they appear act as argument separators, so for example
10491 @smallexample @c ada
10492 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10493 @end smallexample
10495 @noindent
10496 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10497 linker. The order of linker options is preserved for a given unit. The final
10498 list of options passed to the linker is in reverse order of the elaboration
10499 order. For example, linker options for a body always appear before the options
10500 from the corresponding package spec.
10502 @sp 1
10503 @cartouche
10504 @noindent
10505 @strong{81}.  The contents of the visible part of package
10506 @code{Interfaces} and its language-defined descendants.  See B.2(1).
10507 @end cartouche
10508 @noindent
10509 See files with prefix @file{i-} in the distributed library.
10511 @sp 1
10512 @cartouche
10513 @noindent
10514 @strong{82}.  Implementation-defined children of package
10515 @code{Interfaces}.  The contents of the visible part of package
10516 @code{Interfaces}.  See B.2(11).
10517 @end cartouche
10518 @noindent
10519 See files with prefix @file{i-} in the distributed library.
10521 @sp 1
10522 @cartouche
10523 @noindent
10524 @strong{83}.  The types @code{Floating}, @code{Long_Floating},
10525 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10526 @code{COBOL_Character}; and the initialization of the variables
10527 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10528 @code{Interfaces.COBOL}.  See B.4(50).
10529 @end cartouche
10530 @noindent
10531 @table @code
10532 @item Floating
10533 Float
10534 @item Long_Floating
10535 (Floating) Long_Float
10536 @item Binary
10537 Integer
10538 @item Long_Binary
10539 Long_Long_Integer
10540 @item Decimal_Element
10541 Character
10542 @item COBOL_Character
10543 Character
10544 @end table
10546 @noindent
10547 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10549 @sp 1
10550 @cartouche
10551 @noindent
10552 @strong{84}.  Support for access to machine instructions.  See C.1(1).
10553 @end cartouche
10554 @noindent
10555 See documentation in file @file{s-maccod.ads} in the distributed library.
10557 @sp 1
10558 @cartouche
10559 @noindent
10560 @strong{85}.  Implementation-defined aspects of access to machine
10561 operations.  See C.1(9).
10562 @end cartouche
10563 @noindent
10564 See documentation in file @file{s-maccod.ads} in the distributed library.
10566 @sp 1
10567 @cartouche
10568 @noindent
10569 @strong{86}.  Implementation-defined aspects of interrupts.  See C.3(2).
10570 @end cartouche
10571 @noindent
10572 Interrupts are mapped to signals or conditions as appropriate.  See
10573 definition of unit
10574 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10575 on the interrupts supported on a particular target.
10577 @sp 1
10578 @cartouche
10579 @noindent
10580 @strong{87}.  Implementation-defined aspects of pre-elaboration.  See
10581 C.4(13).
10582 @end cartouche
10583 @noindent
10584 GNAT does not permit a partition to be restarted without reloading,
10585 except under control of the debugger.
10587 @sp 1
10588 @cartouche
10589 @noindent
10590 @strong{88}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
10591 @end cartouche
10592 @noindent
10593 Pragma @code{Discard_Names} causes names of enumeration literals to
10594 be suppressed.  In the presence of this pragma, the Image attribute
10595 provides the image of the Pos of the literal, and Value accepts
10596 Pos values.
10598 @sp 1
10599 @cartouche
10600 @noindent
10601 @strong{89}.  The result of the @code{Task_Identification.Image}
10602 attribute.  See C.7.1(7).
10603 @end cartouche
10604 @noindent
10605 The result of this attribute is a string that identifies
10606 the object or component that denotes a given task. If a variable @code{Var}
10607 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10608 where the suffix
10609 is the hexadecimal representation of the virtual address of the corresponding
10610 task control block. If the variable is an array of tasks, the image of each
10611 task will have the form of an indexed component indicating the position of a
10612 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10613 component of a record, the image of the task will have the form of a selected
10614 component. These rules are fully recursive, so that the image of a task that
10615 is a subcomponent of a composite object corresponds to the expression that
10616 designates this task.
10617 @noindent
10618 If a task is created by an allocator, its image depends on the context. If the
10619 allocator is part of an object declaration, the rules described above are used
10620 to construct its image, and this image is not affected by subsequent
10621 assignments. If the allocator appears within an expression, the image
10622 includes only the name of the task type.
10623 @noindent
10624 If the configuration pragma Discard_Names is present, or if the restriction
10625 No_Implicit_Heap_Allocation is in effect,  the image reduces to
10626 the numeric suffix, that is to say the hexadecimal representation of the
10627 virtual address of the control block of the task.
10628 @sp 1
10629 @cartouche
10630 @noindent
10631 @strong{90}.  The value of @code{Current_Task} when in a protected entry
10632 or interrupt handler.  See C.7.1(17).
10633 @end cartouche
10634 @noindent
10635 Protected entries or interrupt handlers can be executed by any
10636 convenient thread, so the value of @code{Current_Task} is undefined.
10638 @sp 1
10639 @cartouche
10640 @noindent
10641 @strong{91}.  The effect of calling @code{Current_Task} from an entry
10642 body or interrupt handler.  See C.7.1(19).
10643 @end cartouche
10644 @noindent
10645 The effect of calling @code{Current_Task} from an entry body or
10646 interrupt handler is to return the identification of the task currently
10647 executing the code.
10649 @sp 1
10650 @cartouche
10651 @noindent
10652 @strong{92}.  Implementation-defined aspects of
10653 @code{Task_Attributes}.  See C.7.2(19).
10654 @end cartouche
10655 @noindent
10656 There are no implementation-defined aspects of @code{Task_Attributes}.
10658 @sp 1
10659 @cartouche
10660 @noindent
10661 @strong{93}.  Values of all @code{Metrics}.  See D(2).
10662 @end cartouche
10663 @noindent
10664 The metrics information for GNAT depends on the performance of the
10665 underlying operating system.  The sources of the run-time for tasking
10666 implementation, together with the output from @option{-gnatG} can be
10667 used to determine the exact sequence of operating systems calls made
10668 to implement various tasking constructs.  Together with appropriate
10669 information on the performance of the underlying operating system,
10670 on the exact target in use, this information can be used to determine
10671 the required metrics.
10673 @sp 1
10674 @cartouche
10675 @noindent
10676 @strong{94}.  The declarations of @code{Any_Priority} and
10677 @code{Priority}.  See D.1(11).
10678 @end cartouche
10679 @noindent
10680 See declarations in file @file{system.ads}.
10682 @sp 1
10683 @cartouche
10684 @noindent
10685 @strong{95}.  Implementation-defined execution resources.  See D.1(15).
10686 @end cartouche
10687 @noindent
10688 There are no implementation-defined execution resources.
10690 @sp 1
10691 @cartouche
10692 @noindent
10693 @strong{96}.  Whether, on a multiprocessor, a task that is waiting for
10694 access to a protected object keeps its processor busy.  See D.2.1(3).
10695 @end cartouche
10696 @noindent
10697 On a multi-processor, a task that is waiting for access to a protected
10698 object does not keep its processor busy.
10700 @sp 1
10701 @cartouche
10702 @noindent
10703 @strong{97}.  The affect of implementation defined execution resources
10704 on task dispatching.  See D.2.1(9).
10705 @end cartouche
10706 @noindent
10707 Tasks map to threads in the threads package used by GNAT@.  Where possible
10708 and appropriate, these threads correspond to native threads of the
10709 underlying operating system.
10711 @sp 1
10712 @cartouche
10713 @noindent
10714 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
10715 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
10716 @end cartouche
10717 @noindent
10718 There are no implementation-defined policy-identifiers allowed in this
10719 pragma.
10721 @sp 1
10722 @cartouche
10723 @noindent
10724 @strong{99}.  Implementation-defined aspects of priority inversion.  See
10725 D.2.2(16).
10726 @end cartouche
10727 @noindent
10728 Execution of a task cannot be preempted by the implementation processing
10729 of delay expirations for lower priority tasks.
10731 @sp 1
10732 @cartouche
10733 @noindent
10734 @strong{100}.  Implementation-defined task dispatching.  See D.2.2(18).
10735 @end cartouche
10736 @noindent
10737 The policy is the same as that of the underlying threads implementation.
10739 @sp 1
10740 @cartouche
10741 @noindent
10742 @strong{101}.  Implementation-defined @code{policy_identifiers} allowed
10743 in a pragma @code{Locking_Policy}.  See D.3(4).
10744 @end cartouche
10745 @noindent
10746 The two implementation defined policies permitted in GNAT are
10747 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
10748 targets that support the @code{Inheritance_Locking} policy, locking is
10749 implemented by inheritance, i.e.@: the task owning the lock operates
10750 at a priority equal to the highest priority of any task currently
10751 requesting the lock.  On targets that support the
10752 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10753 read/write lock allowing multiple propected object functions to enter
10754 concurrently.
10756 @sp 1
10757 @cartouche
10758 @noindent
10759 @strong{102}.  Default ceiling priorities.  See D.3(10).
10760 @end cartouche
10761 @noindent
10762 The ceiling priority of protected objects of the type
10763 @code{System.Interrupt_Priority'Last} as described in the Ada
10764 Reference Manual D.3(10),
10766 @sp 1
10767 @cartouche
10768 @noindent
10769 @strong{103}.  The ceiling of any protected object used internally by
10770 the implementation.  See D.3(16).
10771 @end cartouche
10772 @noindent
10773 The ceiling priority of internal protected objects is
10774 @code{System.Priority'Last}.
10776 @sp 1
10777 @cartouche
10778 @noindent
10779 @strong{104}.  Implementation-defined queuing policies.  See D.4(1).
10780 @end cartouche
10781 @noindent
10782 There are no implementation-defined queuing policies.
10784 @sp 1
10785 @cartouche
10786 @noindent
10787 @strong{105}.  On a multiprocessor, any conditions that cause the
10788 completion of an aborted construct to be delayed later than what is
10789 specified for a single processor.  See D.6(3).
10790 @end cartouche
10791 @noindent
10792 The semantics for abort on a multi-processor is the same as on a single
10793 processor, there are no further delays.
10795 @sp 1
10796 @cartouche
10797 @noindent
10798 @strong{106}.  Any operations that implicitly require heap storage
10799 allocation.  See D.7(8).
10800 @end cartouche
10801 @noindent
10802 The only operation that implicitly requires heap storage allocation is
10803 task creation.
10805 @sp 1
10806 @cartouche
10807 @noindent
10808 @strong{107}.  Implementation-defined aspects of pragma
10809 @code{Restrictions}.  See D.7(20).
10810 @end cartouche
10811 @noindent
10812 There are no such implementation-defined aspects.
10814 @sp 1
10815 @cartouche
10816 @noindent
10817 @strong{108}.  Implementation-defined aspects of package
10818 @code{Real_Time}.  See D.8(17).
10819 @end cartouche
10820 @noindent
10821 There are no implementation defined aspects of package @code{Real_Time}.
10823 @sp 1
10824 @cartouche
10825 @noindent
10826 @strong{109}.  Implementation-defined aspects of
10827 @code{delay_statements}.  See D.9(8).
10828 @end cartouche
10829 @noindent
10830 Any difference greater than one microsecond will cause the task to be
10831 delayed (see D.9(7)).
10833 @sp 1
10834 @cartouche
10835 @noindent
10836 @strong{110}.  The upper bound on the duration of interrupt blocking
10837 caused by the implementation.  See D.12(5).
10838 @end cartouche
10839 @noindent
10840 The upper bound is determined by the underlying operating system.  In
10841 no cases is it more than 10 milliseconds.
10843 @sp 1
10844 @cartouche
10845 @noindent
10846 @strong{111}.  The means for creating and executing distributed
10847 programs.  See E(5).
10848 @end cartouche
10849 @noindent
10850 The GLADE package provides a utility GNATDIST for creating and executing
10851 distributed programs.  See the GLADE reference manual for further details.
10853 @sp 1
10854 @cartouche
10855 @noindent
10856 @strong{112}.  Any events that can result in a partition becoming
10857 inaccessible.  See E.1(7).
10858 @end cartouche
10859 @noindent
10860 See the GLADE reference manual for full details on such events.
10862 @sp 1
10863 @cartouche
10864 @noindent
10865 @strong{113}.  The scheduling policies, treatment of priorities, and
10866 management of shared resources between partitions in certain cases.  See
10867 E.1(11).
10868 @end cartouche
10869 @noindent
10870 See the GLADE reference manual for full details on these aspects of
10871 multi-partition execution.
10873 @sp 1
10874 @cartouche
10875 @noindent
10876 @strong{114}.  Events that cause the version of a compilation unit to
10877 change.  See E.3(5).
10878 @end cartouche
10879 @noindent
10880 Editing the source file of a compilation unit, or the source files of
10881 any units on which it is dependent in a significant way cause the version
10882 to change.  No other actions cause the version number to change.  All changes
10883 are significant except those which affect only layout, capitalization or
10884 comments.
10886 @sp 1
10887 @cartouche
10888 @noindent
10889 @strong{115}.  Whether the execution of the remote subprogram is
10890 immediately aborted as a result of cancellation.  See E.4(13).
10891 @end cartouche
10892 @noindent
10893 See the GLADE reference manual for details on the effect of abort in
10894 a distributed application.
10896 @sp 1
10897 @cartouche
10898 @noindent
10899 @strong{116}.  Implementation-defined aspects of the PCS@.  See E.5(25).
10900 @end cartouche
10901 @noindent
10902 See the GLADE reference manual for a full description of all implementation
10903 defined aspects of the PCS@.
10905 @sp 1
10906 @cartouche
10907 @noindent
10908 @strong{117}.  Implementation-defined interfaces in the PCS@.  See
10909 E.5(26).
10910 @end cartouche
10911 @noindent
10912 See the GLADE reference manual for a full description of all
10913 implementation defined interfaces.
10915 @sp 1
10916 @cartouche
10917 @noindent
10918 @strong{118}.  The values of named numbers in the package
10919 @code{Decimal}.  See F.2(7).
10920 @end cartouche
10921 @noindent
10922 @table @code
10923 @item Max_Scale
10925 @item Min_Scale
10927 @item Min_Delta
10928 1.0E-18
10929 @item Max_Delta
10930 1.0E+18
10931 @item Max_Decimal_Digits
10933 @end table
10935 @sp 1
10936 @cartouche
10937 @noindent
10938 @strong{119}.  The value of @code{Max_Picture_Length} in the package
10939 @code{Text_IO.Editing}.  See F.3.3(16).
10940 @end cartouche
10941 @noindent
10944 @sp 1
10945 @cartouche
10946 @noindent
10947 @strong{120}.  The value of @code{Max_Picture_Length} in the package
10948 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
10949 @end cartouche
10950 @noindent
10953 @sp 1
10954 @cartouche
10955 @noindent
10956 @strong{121}.  The accuracy actually achieved by the complex elementary
10957 functions and by other complex arithmetic operations.  See G.1(1).
10958 @end cartouche
10959 @noindent
10960 Standard library functions are used for the complex arithmetic
10961 operations.  Only fast math mode is currently supported.
10963 @sp 1
10964 @cartouche
10965 @noindent
10966 @strong{122}.  The sign of a zero result (or a component thereof) from
10967 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10968 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
10969 @end cartouche
10970 @noindent
10971 The signs of zero values are as recommended by the relevant
10972 implementation advice.
10974 @sp 1
10975 @cartouche
10976 @noindent
10977 @strong{123}.  The sign of a zero result (or a component thereof) from
10978 any operator or function in
10979 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10980 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
10981 @end cartouche
10982 @noindent
10983 The signs of zero values are as recommended by the relevant
10984 implementation advice.
10986 @sp 1
10987 @cartouche
10988 @noindent
10989 @strong{124}.  Whether the strict mode or the relaxed mode is the
10990 default.  See G.2(2).
10991 @end cartouche
10992 @noindent
10993 The strict mode is the default.  There is no separate relaxed mode.  GNAT
10994 provides a highly efficient implementation of strict mode.
10996 @sp 1
10997 @cartouche
10998 @noindent
10999 @strong{125}.  The result interval in certain cases of fixed-to-float
11000 conversion.  See G.2.1(10).
11001 @end cartouche
11002 @noindent
11003 For cases where the result interval is implementation dependent, the
11004 accuracy is that provided by performing all operations in 64-bit IEEE
11005 floating-point format.
11007 @sp 1
11008 @cartouche
11009 @noindent
11010 @strong{126}.  The result of a floating point arithmetic operation in
11011 overflow situations, when the @code{Machine_Overflows} attribute of the
11012 result type is @code{False}.  See G.2.1(13).
11013 @end cartouche
11014 @noindent
11015 Infinite and NaN values are produced as dictated by the IEEE
11016 floating-point standard.
11018 Note that on machines that are not fully compliant with the IEEE
11019 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11020 must be used for achieving IEEE conforming behavior (although at the cost
11021 of a significant performance penalty), so infinite and NaN values are
11022 properly generated.
11024 @sp 1
11025 @cartouche
11026 @noindent
11027 @strong{127}.  The result interval for division (or exponentiation by a
11028 negative exponent), when the floating point hardware implements division
11029 as multiplication by a reciprocal.  See G.2.1(16).
11030 @end cartouche
11031 @noindent
11032 Not relevant, division is IEEE exact.
11034 @sp 1
11035 @cartouche
11036 @noindent
11037 @strong{128}.  The definition of close result set, which determines the
11038 accuracy of certain fixed point multiplications and divisions.  See
11039 G.2.3(5).
11040 @end cartouche
11041 @noindent
11042 Operations in the close result set are performed using IEEE long format
11043 floating-point arithmetic.  The input operands are converted to
11044 floating-point, the operation is done in floating-point, and the result
11045 is converted to the target type.
11047 @sp 1
11048 @cartouche
11049 @noindent
11050 @strong{129}.  Conditions on a @code{universal_real} operand of a fixed
11051 point multiplication or division for which the result shall be in the
11052 perfect result set.  See G.2.3(22).
11053 @end cartouche
11054 @noindent
11055 The result is only defined to be in the perfect result set if the result
11056 can be computed by a single scaling operation involving a scale factor
11057 representable in 64-bits.
11059 @sp 1
11060 @cartouche
11061 @noindent
11062 @strong{130}.  The result of a fixed point arithmetic operation in
11063 overflow situations, when the @code{Machine_Overflows} attribute of the
11064 result type is @code{False}.  See G.2.3(27).
11065 @end cartouche
11066 @noindent
11067 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11068 types.
11070 @sp 1
11071 @cartouche
11072 @noindent
11073 @strong{131}.  The result of an elementary function reference in
11074 overflow situations, when the @code{Machine_Overflows} attribute of the
11075 result type is @code{False}.  See G.2.4(4).
11076 @end cartouche
11077 @noindent
11078 IEEE infinite and Nan values are produced as appropriate.
11080 @sp 1
11081 @cartouche
11082 @noindent
11083 @strong{132}.  The value of the angle threshold, within which certain
11084 elementary functions, complex arithmetic operations, and complex
11085 elementary functions yield results conforming to a maximum relative
11086 error bound.  See G.2.4(10).
11087 @end cartouche
11088 @noindent
11089 Information on this subject is not yet available.
11091 @sp 1
11092 @cartouche
11093 @noindent
11094 @strong{133}.  The accuracy of certain elementary functions for
11095 parameters beyond the angle threshold.  See G.2.4(10).
11096 @end cartouche
11097 @noindent
11098 Information on this subject is not yet available.
11100 @sp 1
11101 @cartouche
11102 @noindent
11103 @strong{134}.  The result of a complex arithmetic operation or complex
11104 elementary function reference in overflow situations, when the
11105 @code{Machine_Overflows} attribute of the corresponding real type is
11106 @code{False}.  See G.2.6(5).
11107 @end cartouche
11108 @noindent
11109 IEEE infinite and Nan values are produced as appropriate.
11111 @sp 1
11112 @cartouche
11113 @noindent
11114 @strong{135}.  The accuracy of certain complex arithmetic operations and
11115 certain complex elementary functions for parameters (or components
11116 thereof) beyond the angle threshold.  See G.2.6(8).
11117 @end cartouche
11118 @noindent
11119 Information on those subjects is not yet available.
11121 @sp 1
11122 @cartouche
11123 @noindent
11124 @strong{136}.  Information regarding bounded errors and erroneous
11125 execution.  See H.2(1).
11126 @end cartouche
11127 @noindent
11128 Information on this subject is not yet available.
11130 @sp 1
11131 @cartouche
11132 @noindent
11133 @strong{137}.  Implementation-defined aspects of pragma
11134 @code{Inspection_Point}.  See H.3.2(8).
11135 @end cartouche
11136 @noindent
11137 Pragma @code{Inspection_Point} ensures that the variable is live and can
11138 be examined by the debugger at the inspection point.
11140 @sp 1
11141 @cartouche
11142 @noindent
11143 @strong{138}.  Implementation-defined aspects of pragma
11144 @code{Restrictions}.  See H.4(25).
11145 @end cartouche
11146 @noindent
11147 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
11148 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11149 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
11151 @sp 1
11152 @cartouche
11153 @noindent
11154 @strong{139}.  Any restrictions on pragma @code{Restrictions}.  See
11155 H.4(27).
11156 @end cartouche
11157 @noindent
11158 There are no restrictions on pragma @code{Restrictions}.
11160 @node Intrinsic Subprograms
11161 @chapter Intrinsic Subprograms
11162 @cindex Intrinsic Subprograms
11164 @menu
11165 * Intrinsic Operators::
11166 * Enclosing_Entity::
11167 * Exception_Information::
11168 * Exception_Message::
11169 * Exception_Name::
11170 * File::
11171 * Line::
11172 * Shifts and Rotates::
11173 * Source_Location::
11174 @end menu
11176 @noindent
11177 GNAT allows a user application program to write the declaration:
11179 @smallexample @c ada
11180    pragma Import (Intrinsic, name);
11181 @end smallexample
11183 @noindent
11184 providing that the name corresponds to one of the implemented intrinsic
11185 subprograms in GNAT, and that the parameter profile of the referenced
11186 subprogram meets the requirements.  This chapter describes the set of
11187 implemented intrinsic subprograms, and the requirements on parameter profiles.
11188 Note that no body is supplied; as with other uses of pragma Import, the
11189 body is supplied elsewhere (in this case by the compiler itself).  Note
11190 that any use of this feature is potentially non-portable, since the
11191 Ada standard does not require Ada compilers to implement this feature.
11193 @node Intrinsic Operators
11194 @section Intrinsic Operators
11195 @cindex Intrinsic operator
11197 @noindent
11198 All the predefined numeric operators in package Standard
11199 in @code{pragma Import (Intrinsic,..)}
11200 declarations.  In the binary operator case, the operands must have the same
11201 size.  The operand or operands must also be appropriate for
11202 the operator.  For example, for addition, the operands must
11203 both be floating-point or both be fixed-point, and the
11204 right operand for @code{"**"} must have a root type of
11205 @code{Standard.Integer'Base}.
11206 You can use an intrinsic operator declaration as in the following example:
11208 @smallexample @c ada
11209    type Int1 is new Integer;
11210    type Int2 is new Integer;
11212    function "+" (X1 : Int1; X2 : Int2) return Int1;
11213    function "+" (X1 : Int1; X2 : Int2) return Int2;
11214    pragma Import (Intrinsic, "+");
11215 @end smallexample
11217 @noindent
11218 This declaration would permit ``mixed mode'' arithmetic on items
11219 of the differing types @code{Int1} and @code{Int2}.
11220 It is also possible to specify such operators for private types, if the
11221 full views are appropriate arithmetic types.
11223 @node Enclosing_Entity
11224 @section Enclosing_Entity
11225 @cindex Enclosing_Entity
11226 @noindent
11227 This intrinsic subprogram is used in the implementation of the
11228 library routine @code{GNAT.Source_Info}.  The only useful use of the
11229 intrinsic import in this case is the one in this unit, so an
11230 application program should simply call the function
11231 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11232 the current subprogram, package, task, entry, or protected subprogram.
11234 @node Exception_Information
11235 @section Exception_Information
11236 @cindex Exception_Information'
11237 @noindent
11238 This intrinsic subprogram is used in the implementation of the
11239 library routine @code{GNAT.Current_Exception}.  The only useful
11240 use of the intrinsic import in this case is the one in this unit,
11241 so an application program should simply call the function
11242 @code{GNAT.Current_Exception.Exception_Information} to obtain
11243 the exception information associated with the current exception.
11245 @node Exception_Message
11246 @section Exception_Message
11247 @cindex Exception_Message
11248 @noindent
11249 This intrinsic subprogram is used in the implementation of the
11250 library routine @code{GNAT.Current_Exception}.  The only useful
11251 use of the intrinsic import in this case is the one in this unit,
11252 so an application program should simply call the function
11253 @code{GNAT.Current_Exception.Exception_Message} to obtain
11254 the message associated with the current exception.
11256 @node Exception_Name
11257 @section Exception_Name
11258 @cindex Exception_Name
11259 @noindent
11260 This intrinsic subprogram is used in the implementation of the
11261 library routine @code{GNAT.Current_Exception}.  The only useful
11262 use of the intrinsic import in this case is the one in this unit,
11263 so an application program should simply call the function
11264 @code{GNAT.Current_Exception.Exception_Name} to obtain
11265 the name of the current exception.
11267 @node File
11268 @section File
11269 @cindex File
11270 @noindent
11271 This intrinsic subprogram is used in the implementation of the
11272 library routine @code{GNAT.Source_Info}.  The only useful use of the
11273 intrinsic import in this case is the one in this unit, so an
11274 application program should simply call the function
11275 @code{GNAT.Source_Info.File} to obtain the name of the current
11276 file.
11278 @node Line
11279 @section Line
11280 @cindex Line
11281 @noindent
11282 This intrinsic subprogram is used in the implementation of the
11283 library routine @code{GNAT.Source_Info}.  The only useful use of the
11284 intrinsic import in this case is the one in this unit, so an
11285 application program should simply call the function
11286 @code{GNAT.Source_Info.Line} to obtain the number of the current
11287 source line.
11289 @node Shifts and Rotates
11290 @section Shifts and Rotates
11291 @cindex Shift_Left
11292 @cindex Shift_Right
11293 @cindex Shift_Right_Arithmetic
11294 @cindex Rotate_Left
11295 @cindex Rotate_Right
11296 @noindent
11297 In standard Ada, the shift and rotate functions are available only
11298 for the predefined modular types in package @code{Interfaces}.  However, in
11299 GNAT it is possible to define these functions for any integer
11300 type (signed or modular), as in this example:
11302 @smallexample @c ada
11303    function Shift_Left
11304      (Value  : T;
11305       Amount : Natural)
11306       return   T;
11307 @end smallexample
11309 @noindent
11310 The function name must be one of
11311 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11312 Rotate_Right. T must be an integer type. T'Size must be
11313 8, 16, 32 or 64 bits; if T is modular, the modulus
11314 must be 2**8, 2**16, 2**32 or 2**64.
11315 The result type must be the same as the type of @code{Value}.
11316 The shift amount must be Natural.
11317 The formal parameter names can be anything.
11319 @node Source_Location
11320 @section Source_Location
11321 @cindex Source_Location
11322 @noindent
11323 This intrinsic subprogram is used in the implementation of the
11324 library routine @code{GNAT.Source_Info}.  The only useful use of the
11325 intrinsic import in this case is the one in this unit, so an
11326 application program should simply call the function
11327 @code{GNAT.Source_Info.Source_Location} to obtain the current
11328 source file location.
11330 @node Representation Clauses and Pragmas
11331 @chapter Representation Clauses and Pragmas
11332 @cindex Representation Clauses
11334 @menu
11335 * Alignment Clauses::
11336 * Size Clauses::
11337 * Storage_Size Clauses::
11338 * Size of Variant Record Objects::
11339 * Biased Representation ::
11340 * Value_Size and Object_Size Clauses::
11341 * Component_Size Clauses::
11342 * Bit_Order Clauses::
11343 * Effect of Bit_Order on Byte Ordering::
11344 * Pragma Pack for Arrays::
11345 * Pragma Pack for Records::
11346 * Record Representation Clauses::
11347 * Enumeration Clauses::
11348 * Address Clauses::
11349 * Effect of Convention on Representation::
11350 * Determining the Representations chosen by GNAT::
11351 @end menu
11353 @noindent
11354 @cindex Representation Clause
11355 @cindex Representation Pragma
11356 @cindex Pragma, representation
11357 This section describes the representation clauses accepted by GNAT, and
11358 their effect on the representation of corresponding data objects.
11360 GNAT fully implements Annex C (Systems Programming).  This means that all
11361 the implementation advice sections in chapter 13 are fully implemented.
11362 However, these sections only require a minimal level of support for
11363 representation clauses.  GNAT provides much more extensive capabilities,
11364 and this section describes the additional capabilities provided.
11366 @node Alignment Clauses
11367 @section Alignment Clauses
11368 @cindex Alignment Clause
11370 @noindent
11371 GNAT requires that all alignment clauses specify a power of 2, and all
11372 default alignments are always a power of 2.  The default alignment
11373 values are as follows:
11375 @itemize @bullet
11376 @item @emph{Primitive Types}.
11377 For primitive types, the alignment is the minimum of the actual size of
11378 objects of the type divided by @code{Storage_Unit},
11379 and the maximum alignment supported by the target.
11380 (This maximum alignment is given by the GNAT-specific attribute
11381 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11382 @cindex @code{Maximum_Alignment} attribute
11383 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11384 default alignment will be 8 on any target that supports alignments
11385 this large, but on some targets, the maximum alignment may be smaller
11386 than 8, in which case objects of type @code{Long_Float} will be maximally
11387 aligned.
11389 @item @emph{Arrays}.
11390 For arrays, the alignment is equal to the alignment of the component type
11391 for the normal case where no packing or component size is given.  If the
11392 array is packed, and the packing is effective (see separate section on
11393 packed arrays), then the alignment will be one for long packed arrays,
11394 or arrays whose length is not known at compile time.  For short packed
11395 arrays, which are handled internally as modular types, the alignment
11396 will be as described for primitive types, e.g.@: a packed array of length
11397 31 bits will have an object size of four bytes, and an alignment of 4.
11399 @item @emph{Records}.
11400 For the normal non-packed case, the alignment of a record is equal to
11401 the maximum alignment of any of its components.  For tagged records, this
11402 includes the implicit access type used for the tag.  If a pragma @code{Pack}
11403 is used and all components are packable (see separate section on pragma
11404 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11405 record makes it profitable to increase it.
11407 A special case is when:
11408 @itemize @bullet
11409 @item
11410 the size of the record is given explicitly, or a
11411 full record representation clause is given, and
11412 @item
11413 the size of the record is 2, 4, or 8 bytes.
11414 @end itemize
11415 @noindent
11416 In this case, an alignment is chosen to match the
11417 size of the record. For example, if we have:
11419 @smallexample @c ada
11420    type Small is record
11421       A, B : Character;
11422    end record;
11423    for Small'Size use 16;
11424 @end smallexample
11426 @noindent
11427 then the default alignment of the record type @code{Small} is 2, not 1. This
11428 leads to more efficient code when the record is treated as a unit, and also
11429 allows the type to specified as @code{Atomic} on architectures requiring
11430 strict alignment.
11432 @end itemize
11434 @noindent
11435 An alignment clause may specify a larger alignment than the default value
11436 up to some maximum value dependent on the target (obtainable by using the
11437 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11438 a smaller alignment than the default value for enumeration, integer and
11439 fixed point types, as well as for record types, for example
11441 @smallexample @c ada
11442   type V is record
11443      A : Integer;
11444   end record;
11446   for V'alignment use 1;
11447 @end smallexample
11449 @noindent
11450 @cindex Alignment, default
11451 The default alignment for the type @code{V} is 4, as a result of the
11452 Integer field in the record, but it is permissible, as shown, to
11453 override the default alignment of the record with a smaller value.
11455 @node Size Clauses
11456 @section Size Clauses
11457 @cindex Size Clause
11459 @noindent
11460 The default size for a type @code{T} is obtainable through the
11461 language-defined attribute @code{T'Size} and also through the
11462 equivalent GNAT-defined attribute @code{T'Value_Size}.
11463 For objects of type @code{T}, GNAT will generally increase the type size
11464 so that the object size (obtainable through the GNAT-defined attribute
11465 @code{T'Object_Size})
11466 is a multiple of @code{T'Alignment * Storage_Unit}.
11467 For example
11469 @smallexample @c ada
11470    type Smallint is range 1 .. 6;
11472    type Rec is record
11473       Y1 : integer;
11474       Y2 : boolean;
11475    end record;
11476 @end smallexample
11478 @noindent
11479 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11480 as specified by the RM rules,
11481 but objects of this type will have a size of 8
11482 (@code{Smallint'Object_Size} = 8),
11483 since objects by default occupy an integral number
11484 of storage units.  On some targets, notably older
11485 versions of the Digital Alpha, the size of stand
11486 alone objects of this type may be 32, reflecting
11487 the inability of the hardware to do byte load/stores.
11489 Similarly, the size of type @code{Rec} is 40 bits
11490 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11491 the alignment is 4, so objects of this type will have
11492 their size increased to 64 bits so that it is a multiple
11493 of the alignment (in bits).  This decision is
11494 in accordance with the specific Implementation Advice in RM 13.3(43):
11496 @quotation
11497 A @code{Size} clause should be supported for an object if the specified
11498 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11499 to a size in storage elements that is a multiple of the object's
11500 @code{Alignment} (if the @code{Alignment} is nonzero).
11501 @end quotation
11503 @noindent
11504 An explicit size clause may be used to override the default size by
11505 increasing it.  For example, if we have:
11507 @smallexample @c ada
11508    type My_Boolean is new Boolean;
11509    for My_Boolean'Size use 32;
11510 @end smallexample
11512 @noindent
11513 then values of this type will always be 32 bits long.  In the case of
11514 discrete types, the size can be increased up to 64 bits, with the effect
11515 that the entire specified field is used to hold the value, sign- or
11516 zero-extended as appropriate.  If more than 64 bits is specified, then
11517 padding space is allocated after the value, and a warning is issued that
11518 there are unused bits.
11520 Similarly the size of records and arrays may be increased, and the effect
11521 is to add padding bits after the value.  This also causes a warning message
11522 to be generated.
11524 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
11525 Size in bits, this corresponds to an object of size 256 megabytes (minus
11526 one).  This limitation is true on all targets.  The reason for this
11527 limitation is that it improves the quality of the code in many cases
11528 if it is known that a Size value can be accommodated in an object of
11529 type Integer.
11531 @node Storage_Size Clauses
11532 @section Storage_Size Clauses
11533 @cindex Storage_Size Clause
11535 @noindent
11536 For tasks, the @code{Storage_Size} clause specifies the amount of space
11537 to be allocated for the task stack.  This cannot be extended, and if the
11538 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11539 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
11540 or a @code{Storage_Size} pragma in the task definition to set the
11541 appropriate required size.  A useful technique is to include in every
11542 task definition a pragma of the form:
11544 @smallexample @c ada
11545    pragma Storage_Size (Default_Stack_Size);
11546 @end smallexample
11548 @noindent
11549 Then @code{Default_Stack_Size} can be defined in a global package, and
11550 modified as required. Any tasks requiring stack sizes different from the
11551 default can have an appropriate alternative reference in the pragma.
11553 You can also use the @option{-d} binder switch to modify the default stack
11554 size.
11556 For access types, the @code{Storage_Size} clause specifies the maximum
11557 space available for allocation of objects of the type.  If this space is
11558 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11559 In the case where the access type is declared local to a subprogram, the
11560 use of a @code{Storage_Size} clause triggers automatic use of a special
11561 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11562 space for the pool is automatically reclaimed on exit from the scope in
11563 which the type is declared.
11565 A special case recognized by the compiler is the specification of a
11566 @code{Storage_Size} of zero for an access type.  This means that no
11567 items can be allocated from the pool, and this is recognized at compile
11568 time, and all the overhead normally associated with maintaining a fixed
11569 size storage pool is eliminated.  Consider the following example:
11571 @smallexample @c ada
11572    procedure p is
11573       type R is array (Natural) of Character;
11574       type P is access all R;
11575       for P'Storage_Size use 0;
11576       --  Above access type intended only for interfacing purposes
11578       y : P;
11580       procedure g (m : P);
11581       pragma Import (C, g);
11583       --  @dots{}
11585    begin
11586       --  @dots{}
11587       y := new R;
11588    end;
11589 @end smallexample
11591 @noindent
11592 As indicated in this example, these dummy storage pools are often useful in
11593 connection with interfacing where no object will ever be allocated.  If you
11594 compile the above example, you get the warning:
11596 @smallexample
11597    p.adb:16:09: warning: allocation from empty storage pool
11598    p.adb:16:09: warning: Storage_Error will be raised at run time
11599 @end smallexample
11601 @noindent
11602 Of course in practice, there will not be any explicit allocators in the
11603 case of such an access declaration.
11605 @node Size of Variant Record Objects
11606 @section Size of Variant Record Objects
11607 @cindex Size, variant record objects
11608 @cindex Variant record objects, size
11610 @noindent
11611 In the case of variant record objects, there is a question whether Size gives
11612 information about a particular variant, or the maximum size required
11613 for any variant.  Consider the following program
11615 @smallexample @c ada
11616 with Text_IO; use Text_IO;
11617 procedure q is
11618    type R1 (A : Boolean := False) is record
11619      case A is
11620        when True  => X : Character;
11621        when False => null;
11622      end case;
11623    end record;
11625    V1 : R1 (False);
11626    V2 : R1;
11628 begin
11629    Put_Line (Integer'Image (V1'Size));
11630    Put_Line (Integer'Image (V2'Size));
11631 end q;
11632 @end smallexample
11634 @noindent
11635 Here we are dealing with a variant record, where the True variant
11636 requires 16 bits, and the False variant requires 8 bits.
11637 In the above example, both V1 and V2 contain the False variant,
11638 which is only 8 bits long.  However, the result of running the
11639 program is:
11641 @smallexample
11644 @end smallexample
11646 @noindent
11647 The reason for the difference here is that the discriminant value of
11648 V1 is fixed, and will always be False.  It is not possible to assign
11649 a True variant value to V1, therefore 8 bits is sufficient.  On the
11650 other hand, in the case of V2, the initial discriminant value is
11651 False (from the default), but it is possible to assign a True
11652 variant value to V2, therefore 16 bits must be allocated for V2
11653 in the general case, even fewer bits may be needed at any particular
11654 point during the program execution.
11656 As can be seen from the output of this program, the @code{'Size}
11657 attribute applied to such an object in GNAT gives the actual allocated
11658 size of the variable, which is the largest size of any of the variants.
11659 The Ada Reference Manual is not completely clear on what choice should
11660 be made here, but the GNAT behavior seems most consistent with the
11661 language in the RM@.
11663 In some cases, it may be desirable to obtain the size of the current
11664 variant, rather than the size of the largest variant.  This can be
11665 achieved in GNAT by making use of the fact that in the case of a
11666 subprogram parameter, GNAT does indeed return the size of the current
11667 variant (because a subprogram has no way of knowing how much space
11668 is actually allocated for the actual).
11670 Consider the following modified version of the above program:
11672 @smallexample @c ada
11673 with Text_IO; use Text_IO;
11674 procedure q is
11675    type R1 (A : Boolean := False) is record
11676      case A is
11677        when True  => X : Character;
11678        when False => null;
11679      end case;
11680    end record;
11682    V2 : R1;
11684    function Size (V : R1) return Integer is
11685    begin
11686       return V'Size;
11687    end Size;
11689 begin
11690    Put_Line (Integer'Image (V2'Size));
11691    Put_Line (Integer'IMage (Size (V2)));
11692    V2 := (True, 'x');
11693    Put_Line (Integer'Image (V2'Size));
11694    Put_Line (Integer'IMage (Size (V2)));
11695 end q;
11696 @end smallexample
11698 @noindent
11699 The output from this program is
11701 @smallexample
11706 @end smallexample
11708 @noindent
11709 Here we see that while the @code{'Size} attribute always returns
11710 the maximum size, regardless of the current variant value, the
11711 @code{Size} function does indeed return the size of the current
11712 variant value.
11714 @node Biased Representation
11715 @section Biased Representation
11716 @cindex Size for biased representation
11717 @cindex Biased representation
11719 @noindent
11720 In the case of scalars with a range starting at other than zero, it is
11721 possible in some cases to specify a size smaller than the default minimum
11722 value, and in such cases, GNAT uses an unsigned biased representation,
11723 in which zero is used to represent the lower bound, and successive values
11724 represent successive values of the type.
11726 For example, suppose we have the declaration:
11728 @smallexample @c ada
11729    type Small is range -7 .. -4;
11730    for Small'Size use 2;
11731 @end smallexample
11733 @noindent
11734 Although the default size of type @code{Small} is 4, the @code{Size}
11735 clause is accepted by GNAT and results in the following representation
11736 scheme:
11738 @smallexample
11739   -7 is represented as 2#00#
11740   -6 is represented as 2#01#
11741   -5 is represented as 2#10#
11742   -4 is represented as 2#11#
11743 @end smallexample
11745 @noindent
11746 Biased representation is only used if the specified @code{Size} clause
11747 cannot be accepted in any other manner.  These reduced sizes that force
11748 biased representation can be used for all discrete types except for
11749 enumeration types for which a representation clause is given.
11751 @node Value_Size and Object_Size Clauses
11752 @section Value_Size and Object_Size Clauses
11753 @findex Value_Size
11754 @findex Object_Size
11755 @cindex Size, of objects
11757 @noindent
11758 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11759 number of bits required to hold values of type @code{T}.
11760 Although this interpretation was allowed in Ada 83, it was not required,
11761 and this requirement in practice can cause some significant difficulties.
11762 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11763 However, in Ada 95 and Ada 2005,
11764 @code{Natural'Size} is
11765 typically 31.  This means that code may change in behavior when moving
11766 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
11768 @smallexample @c ada
11769    type Rec is record;
11770       A : Natural;
11771       B : Natural;
11772    end record;
11774    for Rec use record
11775       at 0  range 0 .. Natural'Size - 1;
11776       at 0  range Natural'Size .. 2 * Natural'Size - 1;
11777    end record;
11778 @end smallexample
11780 @noindent
11781 In the above code, since the typical size of @code{Natural} objects
11782 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11783 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11784 there are cases where the fact that the object size can exceed the
11785 size of the type causes surprises.
11787 To help get around this problem GNAT provides two implementation
11788 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
11789 applied to a type, these attributes yield the size of the type
11790 (corresponding to the RM defined size attribute), and the size of
11791 objects of the type respectively.
11793 The @code{Object_Size} is used for determining the default size of
11794 objects and components.  This size value can be referred to using the
11795 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
11796 the basis of the determination of the size.  The backend is free to
11797 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11798 character might be stored in 32 bits on a machine with no efficient
11799 byte access instructions such as the Alpha.
11801 The default rules for the value of @code{Object_Size} for
11802 discrete types are as follows:
11804 @itemize @bullet
11805 @item
11806 The @code{Object_Size} for base subtypes reflect the natural hardware
11807 size in bits (run the compiler with @option{-gnatS} to find those values
11808 for numeric types). Enumeration types and fixed-point base subtypes have
11809 8, 16, 32 or 64 bits for this size, depending on the range of values
11810 to be stored.
11812 @item
11813 The @code{Object_Size} of a subtype is the same as the
11814 @code{Object_Size} of
11815 the type from which it is obtained.
11817 @item
11818 The @code{Object_Size} of a derived base type is copied from the parent
11819 base type, and the @code{Object_Size} of a derived first subtype is copied
11820 from the parent first subtype.
11821 @end itemize
11823 @noindent
11824 The @code{Value_Size} attribute
11825 is the (minimum) number of bits required to store a value
11826 of the type.
11827 This value is used to determine how tightly to pack
11828 records or arrays with components of this type, and also affects
11829 the semantics of unchecked conversion (unchecked conversions where
11830 the @code{Value_Size} values differ generate a warning, and are potentially
11831 target dependent).
11833 The default rules for the value of @code{Value_Size} are as follows:
11835 @itemize @bullet
11836 @item
11837 The @code{Value_Size} for a base subtype is the minimum number of bits
11838 required to store all values of the type (including the sign bit
11839 only if negative values are possible).
11841 @item
11842 If a subtype statically matches the first subtype of a given type, then it has
11843 by default the same @code{Value_Size} as the first subtype.  This is a
11844 consequence of RM 13.1(14) (``if two subtypes statically match,
11845 then their subtype-specific aspects are the same''.)
11847 @item
11848 All other subtypes have a @code{Value_Size} corresponding to the minimum
11849 number of bits required to store all values of the subtype.  For
11850 dynamic bounds, it is assumed that the value can range down or up
11851 to the corresponding bound of the ancestor
11852 @end itemize
11854 @noindent
11855 The RM defined attribute @code{Size} corresponds to the
11856 @code{Value_Size} attribute.
11858 The @code{Size} attribute may be defined for a first-named subtype.  This sets
11859 the @code{Value_Size} of
11860 the first-named subtype to the given value, and the
11861 @code{Object_Size} of this first-named subtype to the given value padded up
11862 to an appropriate boundary.  It is a consequence of the default rules
11863 above that this @code{Object_Size} will apply to all further subtypes.  On the
11864 other hand, @code{Value_Size} is affected only for the first subtype, any
11865 dynamic subtypes obtained from it directly, and any statically matching
11866 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
11868 @code{Value_Size} and
11869 @code{Object_Size} may be explicitly set for any subtype using
11870 an attribute definition clause.  Note that the use of these attributes
11871 can cause the RM 13.1(14) rule to be violated.  If two access types
11872 reference aliased objects whose subtypes have differing @code{Object_Size}
11873 values as a result of explicit attribute definition clauses, then it
11874 is erroneous to convert from one access subtype to the other.
11876 At the implementation level, Esize stores the Object_Size and the
11877 RM_Size field stores the @code{Value_Size} (and hence the value of the
11878 @code{Size} attribute,
11879 which, as noted above, is equivalent to @code{Value_Size}).
11881 To get a feel for the difference, consider the following examples (note
11882 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11884 @smallexample
11885                                        Object_Size     Value_Size
11887 type x1 is range 0 .. 5;                    8               3
11889 type x2 is range 0 .. 5;
11890 for x2'size use 12;                        16              12
11892 subtype x3 is x2 range 0 .. 3;             16               2
11894 subtype x4 is x2'base range 0 .. 10;        8               4
11896 subtype x5 is x2 range 0 .. dynamic;       16               3*
11898 subtype x6 is x2'base range 0 .. dynamic;   8               3*
11900 @end smallexample
11902 @noindent
11903 Note: the entries marked ``3*'' are not actually specified by the Ada
11904 Reference Manual, but it seems in the spirit of the RM rules to allocate
11905 the minimum number of bits (here 3, given the range for @code{x2})
11906 known to be large enough to hold the given range of values.
11908 So far, so good, but GNAT has to obey the RM rules, so the question is
11909 under what conditions must the RM @code{Size} be used.
11910 The following is a list
11911 of the occasions on which the RM @code{Size} must be used:
11913 @itemize @bullet
11914 @item
11915 Component size for packed arrays or records
11917 @item
11918 Value of the attribute @code{Size} for a type
11920 @item
11921 Warning about sizes not matching for unchecked conversion
11922 @end itemize
11924 @noindent
11925 For record types, the @code{Object_Size} is always a multiple of the
11926 alignment of the type (this is true for all types). In some cases the
11927 @code{Value_Size} can be smaller. Consider:
11929 @smallexample
11930    type R is record
11931      X : Integer;
11932      Y : Character;
11933    end record;
11934 @end smallexample
11936 @noindent
11937 On a typical 32-bit architecture, the X component will be four bytes, and
11938 require four-byte alignment, and the Y component will be one byte. In this
11939 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11940 required to store a value of this type, and for example, it is permissible
11941 to have a component of type R in an outer array whose component size is
11942 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11943 since it must be rounded up so that this value is a multiple of the
11944 alignment (4 bytes = 32 bits).
11946 @noindent
11947 For all other types, the @code{Object_Size}
11948 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11949 Only @code{Size} may be specified for such types.
11951 @node Component_Size Clauses
11952 @section Component_Size Clauses
11953 @cindex Component_Size Clause
11955 @noindent
11956 Normally, the value specified in a component size clause must be consistent
11957 with the subtype of the array component with regard to size and alignment.
11958 In other words, the value specified must be at least equal to the size
11959 of this subtype, and must be a multiple of the alignment value.
11961 In addition, component size clauses are allowed which cause the array
11962 to be packed, by specifying a smaller value.  A first case is for
11963 component size values in the range 1 through 63.  The value specified
11964 must not be smaller than the Size of the subtype.  GNAT will accurately
11965 honor all packing requests in this range.  For example, if we have:
11967 @smallexample @c ada
11968 type r is array (1 .. 8) of Natural;
11969 for r'Component_Size use 31;
11970 @end smallexample
11972 @noindent
11973 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11974 Of course access to the components of such an array is considerably
11975 less efficient than if the natural component size of 32 is used.
11976 A second case is when the subtype of the component is a record type
11977 padded because of its default alignment.  For example, if we have:
11979 @smallexample @c ada
11980 type r is record
11981   i : Integer;
11982   j : Integer;
11983   b : Boolean;
11984 end record;
11986 type a is array (1 .. 8) of r;
11987 for a'Component_Size use 72;
11988 @end smallexample
11990 @noindent
11991 then the resulting array has a length of 72 bytes, instead of 96 bytes
11992 if the alignment of the record (4) was obeyed.
11994 Note that there is no point in giving both a component size clause
11995 and a pragma Pack for the same array type. if such duplicate
11996 clauses are given, the pragma Pack will be ignored.
11998 @node Bit_Order Clauses
11999 @section Bit_Order Clauses
12000 @cindex Bit_Order Clause
12001 @cindex bit ordering
12002 @cindex ordering, of bits
12004 @noindent
12005 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12006 attribute.  The specification may either correspond to the default bit
12007 order for the target, in which case the specification has no effect and
12008 places no additional restrictions, or it may be for the non-standard
12009 setting (that is the opposite of the default).
12011 In the case where the non-standard value is specified, the effect is
12012 to renumber bits within each byte, but the ordering of bytes is not
12013 affected.  There are certain
12014 restrictions placed on component clauses as follows:
12016 @itemize @bullet
12018 @item Components fitting within a single storage unit.
12019 @noindent
12020 These are unrestricted, and the effect is merely to renumber bits.  For
12021 example if we are on a little-endian machine with @code{Low_Order_First}
12022 being the default, then the following two declarations have exactly
12023 the same effect:
12025 @smallexample @c ada
12026    type R1 is record
12027       A : Boolean;
12028       B : Integer range 1 .. 120;
12029    end record;
12031    for R1 use record
12032       A at 0 range 0 .. 0;
12033       B at 0 range 1 .. 7;
12034    end record;
12036    type R2 is record
12037       A : Boolean;
12038       B : Integer range 1 .. 120;
12039    end record;
12041    for R2'Bit_Order use High_Order_First;
12043    for R2 use record
12044       A at 0 range 7 .. 7;
12045       B at 0 range 0 .. 6;
12046    end record;
12047 @end smallexample
12049 @noindent
12050 The useful application here is to write the second declaration with the
12051 @code{Bit_Order} attribute definition clause, and know that it will be treated
12052 the same, regardless of whether the target is little-endian or big-endian.
12054 @item Components occupying an integral number of bytes.
12055 @noindent
12056 These are components that exactly fit in two or more bytes.  Such component
12057 declarations are allowed, but have no effect, since it is important to realize
12058 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12059 In particular, the following attempt at getting an endian-independent integer
12060 does not work:
12062 @smallexample @c ada
12063    type R2 is record
12064       A : Integer;
12065    end record;
12067    for R2'Bit_Order use High_Order_First;
12069    for R2 use record
12070       A at 0 range 0 .. 31;
12071    end record;
12072 @end smallexample
12074 @noindent
12075 This declaration will result in a little-endian integer on a
12076 little-endian machine, and a big-endian integer on a big-endian machine.
12077 If byte flipping is required for interoperability between big- and
12078 little-endian machines, this must be explicitly programmed.  This capability
12079 is not provided by @code{Bit_Order}.
12081 @item Components that are positioned across byte boundaries
12082 @noindent
12083 but do not occupy an integral number of bytes.  Given that bytes are not
12084 reordered, such fields would occupy a non-contiguous sequence of bits
12085 in memory, requiring non-trivial code to reassemble.  They are for this
12086 reason not permitted, and any component clause specifying such a layout
12087 will be flagged as illegal by GNAT@.
12089 @end itemize
12091 @noindent
12092 Since the misconception that Bit_Order automatically deals with all
12093 endian-related incompatibilities is a common one, the specification of
12094 a component field that is an integral number of bytes will always
12095 generate a warning.  This warning may be suppressed using @code{pragma
12096 Warnings (Off)} if desired.  The following section contains additional
12097 details regarding the issue of byte ordering.
12099 @node Effect of Bit_Order on Byte Ordering
12100 @section Effect of Bit_Order on Byte Ordering
12101 @cindex byte ordering
12102 @cindex ordering, of bytes
12104 @noindent
12105 In this section we will review the effect of the @code{Bit_Order} attribute
12106 definition clause on byte ordering.  Briefly, it has no effect at all, but
12107 a detailed example will be helpful.  Before giving this
12108 example, let us review the precise
12109 definition of the effect of defining @code{Bit_Order}.  The effect of a
12110 non-standard bit order is described in section 15.5.3 of the Ada
12111 Reference Manual:
12113 @quotation
12114 2   A bit ordering is a method of interpreting the meaning of
12115 the storage place attributes.
12116 @end quotation
12118 @noindent
12119 To understand the precise definition of storage place attributes in
12120 this context, we visit section 13.5.1 of the manual:
12122 @quotation
12123 13   A record_representation_clause (without the mod_clause)
12124 specifies the layout.  The storage place attributes (see 13.5.2)
12125 are taken from the values of the position, first_bit, and last_bit
12126 expressions after normalizing those values so that first_bit is
12127 less than Storage_Unit.
12128 @end quotation
12130 @noindent
12131 The critical point here is that storage places are taken from
12132 the values after normalization, not before.  So the @code{Bit_Order}
12133 interpretation applies to normalized values.  The interpretation
12134 is described in the later part of the 15.5.3 paragraph:
12136 @quotation
12137 2   A bit ordering is a method of interpreting the meaning of
12138 the storage place attributes.  High_Order_First (known in the
12139 vernacular as ``big endian'') means that the first bit of a
12140 storage element (bit 0) is the most significant bit (interpreting
12141 the sequence of bits that represent a component as an unsigned
12142 integer value).  Low_Order_First (known in the vernacular as
12143 ``little endian'') means the opposite: the first bit is the
12144 least significant.
12145 @end quotation
12147 @noindent
12148 Note that the numbering is with respect to the bits of a storage
12149 unit.  In other words, the specification affects only the numbering
12150 of bits within a single storage unit.
12152 We can make the effect clearer by giving an example.
12154 Suppose that we have an external device which presents two bytes, the first
12155 byte presented, which is the first (low addressed byte) of the two byte
12156 record is called Master, and the second byte is called Slave.
12158 The left most (most significant bit is called Control for each byte, and
12159 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12160 (least significant) bit.
12162 On a big-endian machine, we can write the following representation clause
12164 @smallexample @c ada
12165    type Data is record
12166       Master_Control : Bit;
12167       Master_V1      : Bit;
12168       Master_V2      : Bit;
12169       Master_V3      : Bit;
12170       Master_V4      : Bit;
12171       Master_V5      : Bit;
12172       Master_V6      : Bit;
12173       Master_V7      : Bit;
12174       Slave_Control  : Bit;
12175       Slave_V1       : Bit;
12176       Slave_V2       : Bit;
12177       Slave_V3       : Bit;
12178       Slave_V4       : Bit;
12179       Slave_V5       : Bit;
12180       Slave_V6       : Bit;
12181       Slave_V7       : Bit;
12182    end record;
12184    for Data use record
12185       Master_Control at 0 range 0 .. 0;
12186       Master_V1      at 0 range 1 .. 1;
12187       Master_V2      at 0 range 2 .. 2;
12188       Master_V3      at 0 range 3 .. 3;
12189       Master_V4      at 0 range 4 .. 4;
12190       Master_V5      at 0 range 5 .. 5;
12191       Master_V6      at 0 range 6 .. 6;
12192       Master_V7      at 0 range 7 .. 7;
12193       Slave_Control  at 1 range 0 .. 0;
12194       Slave_V1       at 1 range 1 .. 1;
12195       Slave_V2       at 1 range 2 .. 2;
12196       Slave_V3       at 1 range 3 .. 3;
12197       Slave_V4       at 1 range 4 .. 4;
12198       Slave_V5       at 1 range 5 .. 5;
12199       Slave_V6       at 1 range 6 .. 6;
12200       Slave_V7       at 1 range 7 .. 7;
12201    end record;
12202 @end smallexample
12204 @noindent
12205 Now if we move this to a little endian machine, then the bit ordering within
12206 the byte is backwards, so we have to rewrite the record rep clause as:
12208 @smallexample @c ada
12209    for Data use record
12210       Master_Control at 0 range 7 .. 7;
12211       Master_V1      at 0 range 6 .. 6;
12212       Master_V2      at 0 range 5 .. 5;
12213       Master_V3      at 0 range 4 .. 4;
12214       Master_V4      at 0 range 3 .. 3;
12215       Master_V5      at 0 range 2 .. 2;
12216       Master_V6      at 0 range 1 .. 1;
12217       Master_V7      at 0 range 0 .. 0;
12218       Slave_Control  at 1 range 7 .. 7;
12219       Slave_V1       at 1 range 6 .. 6;
12220       Slave_V2       at 1 range 5 .. 5;
12221       Slave_V3       at 1 range 4 .. 4;
12222       Slave_V4       at 1 range 3 .. 3;
12223       Slave_V5       at 1 range 2 .. 2;
12224       Slave_V6       at 1 range 1 .. 1;
12225       Slave_V7       at 1 range 0 .. 0;
12226    end record;
12227 @end smallexample
12229 @noindent
12230 It is a nuisance to have to rewrite the clause, especially if
12231 the code has to be maintained on both machines.  However,
12232 this is a case that we can handle with the
12233 @code{Bit_Order} attribute if it is implemented.
12234 Note that the implementation is not required on byte addressed
12235 machines, but it is indeed implemented in GNAT.
12236 This means that we can simply use the
12237 first record clause, together with the declaration
12239 @smallexample @c ada
12240    for Data'Bit_Order use High_Order_First;
12241 @end smallexample
12243 @noindent
12244 and the effect is what is desired, namely the layout is exactly the same,
12245 independent of whether the code is compiled on a big-endian or little-endian
12246 machine.
12248 The important point to understand is that byte ordering is not affected.
12249 A @code{Bit_Order} attribute definition never affects which byte a field
12250 ends up in, only where it ends up in that byte.
12251 To make this clear, let us rewrite the record rep clause of the previous
12252 example as:
12254 @smallexample @c ada
12255    for Data'Bit_Order use High_Order_First;
12256    for Data use record
12257       Master_Control at 0 range  0 .. 0;
12258       Master_V1      at 0 range  1 .. 1;
12259       Master_V2      at 0 range  2 .. 2;
12260       Master_V3      at 0 range  3 .. 3;
12261       Master_V4      at 0 range  4 .. 4;
12262       Master_V5      at 0 range  5 .. 5;
12263       Master_V6      at 0 range  6 .. 6;
12264       Master_V7      at 0 range  7 .. 7;
12265       Slave_Control  at 0 range  8 .. 8;
12266       Slave_V1       at 0 range  9 .. 9;
12267       Slave_V2       at 0 range 10 .. 10;
12268       Slave_V3       at 0 range 11 .. 11;
12269       Slave_V4       at 0 range 12 .. 12;
12270       Slave_V5       at 0 range 13 .. 13;
12271       Slave_V6       at 0 range 14 .. 14;
12272       Slave_V7       at 0 range 15 .. 15;
12273    end record;
12274 @end smallexample
12276 @noindent
12277 This is exactly equivalent to saying (a repeat of the first example):
12279 @smallexample @c ada
12280    for Data'Bit_Order use High_Order_First;
12281    for Data use record
12282       Master_Control at 0 range 0 .. 0;
12283       Master_V1      at 0 range 1 .. 1;
12284       Master_V2      at 0 range 2 .. 2;
12285       Master_V3      at 0 range 3 .. 3;
12286       Master_V4      at 0 range 4 .. 4;
12287       Master_V5      at 0 range 5 .. 5;
12288       Master_V6      at 0 range 6 .. 6;
12289       Master_V7      at 0 range 7 .. 7;
12290       Slave_Control  at 1 range 0 .. 0;
12291       Slave_V1       at 1 range 1 .. 1;
12292       Slave_V2       at 1 range 2 .. 2;
12293       Slave_V3       at 1 range 3 .. 3;
12294       Slave_V4       at 1 range 4 .. 4;
12295       Slave_V5       at 1 range 5 .. 5;
12296       Slave_V6       at 1 range 6 .. 6;
12297       Slave_V7       at 1 range 7 .. 7;
12298    end record;
12299 @end smallexample
12301 @noindent
12302 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12303 field.  The storage place attributes are obtained by normalizing the
12304 values given so that the @code{First_Bit} value is less than 8.  After
12305 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12306 we specified in the other case.
12308 Now one might expect that the @code{Bit_Order} attribute might affect
12309 bit numbering within the entire record component (two bytes in this
12310 case, thus affecting which byte fields end up in), but that is not
12311 the way this feature is defined, it only affects numbering of bits,
12312 not which byte they end up in.
12314 Consequently it never makes sense to specify a starting bit number
12315 greater than 7 (for a byte addressable field) if an attribute
12316 definition for @code{Bit_Order} has been given, and indeed it
12317 may be actively confusing to specify such a value, so the compiler
12318 generates a warning for such usage.
12320 If you do need to control byte ordering then appropriate conditional
12321 values must be used.  If in our example, the slave byte came first on
12322 some machines we might write:
12324 @smallexample @c ada
12325    Master_Byte_First constant Boolean := @dots{};
12327    Master_Byte : constant Natural :=
12328                    1 - Boolean'Pos (Master_Byte_First);
12329    Slave_Byte  : constant Natural :=
12330                    Boolean'Pos (Master_Byte_First);
12332    for Data'Bit_Order use High_Order_First;
12333    for Data use record
12334       Master_Control at Master_Byte range 0 .. 0;
12335       Master_V1      at Master_Byte range 1 .. 1;
12336       Master_V2      at Master_Byte range 2 .. 2;
12337       Master_V3      at Master_Byte range 3 .. 3;
12338       Master_V4      at Master_Byte range 4 .. 4;
12339       Master_V5      at Master_Byte range 5 .. 5;
12340       Master_V6      at Master_Byte range 6 .. 6;
12341       Master_V7      at Master_Byte range 7 .. 7;
12342       Slave_Control  at Slave_Byte  range 0 .. 0;
12343       Slave_V1       at Slave_Byte  range 1 .. 1;
12344       Slave_V2       at Slave_Byte  range 2 .. 2;
12345       Slave_V3       at Slave_Byte  range 3 .. 3;
12346       Slave_V4       at Slave_Byte  range 4 .. 4;
12347       Slave_V5       at Slave_Byte  range 5 .. 5;
12348       Slave_V6       at Slave_Byte  range 6 .. 6;
12349       Slave_V7       at Slave_Byte  range 7 .. 7;
12350    end record;
12351 @end smallexample
12353 @noindent
12354 Now to switch between machines, all that is necessary is
12355 to set the boolean constant @code{Master_Byte_First} in
12356 an appropriate manner.
12358 @node Pragma Pack for Arrays
12359 @section Pragma Pack for Arrays
12360 @cindex Pragma Pack (for arrays)
12362 @noindent
12363 Pragma @code{Pack} applied to an array has no effect unless the component type
12364 is packable.  For a component type to be packable, it must be one of the
12365 following cases:
12367 @itemize @bullet
12368 @item
12369 Any scalar type
12370 @item
12371 Any type whose size is specified with a size clause
12372 @item
12373 Any packed array type with a static size
12374 @item
12375 Any record type padded because of its default alignment
12376 @end itemize
12378 @noindent
12379 For all these cases, if the component subtype size is in the range
12380 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12381 component size were specified giving the component subtype size.
12382 For example if we have:
12384 @smallexample @c ada
12385    type r is range 0 .. 17;
12387    type ar is array (1 .. 8) of r;
12388    pragma Pack (ar);
12389 @end smallexample
12391 @noindent
12392 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12393 and the size of the array @code{ar} will be exactly 40 bits.
12395 Note that in some cases this rather fierce approach to packing can produce
12396 unexpected effects.  For example, in Ada 95 and Ada 2005,
12397 subtype @code{Natural} typically has a size of 31, meaning that if you
12398 pack an array of @code{Natural}, you get 31-bit
12399 close packing, which saves a few bits, but results in far less efficient
12400 access.  Since many other Ada compilers will ignore such a packing request,
12401 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12402 might not be what is intended.  You can easily remove this warning by
12403 using an explicit @code{Component_Size} setting instead, which never generates
12404 a warning, since the intention of the programmer is clear in this case.
12406 GNAT treats packed arrays in one of two ways.  If the size of the array is
12407 known at compile time and is less than 64 bits, then internally the array
12408 is represented as a single modular type, of exactly the appropriate number
12409 of bits.  If the length is greater than 63 bits, or is not known at compile
12410 time, then the packed array is represented as an array of bytes, and the
12411 length is always a multiple of 8 bits.
12413 Note that to represent a packed array as a modular type, the alignment must
12414 be suitable for the modular type involved. For example, on typical machines
12415 a 32-bit packed array will be represented by a 32-bit modular integer with
12416 an alignment of four bytes. If you explicitly override the default alignment
12417 with an alignment clause that is too small, the modular representation
12418 cannot be used. For example, consider the following set of declarations:
12420 @smallexample @c ada
12421    type R is range 1 .. 3;
12422    type S is array (1 .. 31) of R;
12423    for S'Component_Size use 2;
12424    for S'Size use 62;
12425    for S'Alignment use 1;
12426 @end smallexample
12428 @noindent
12429 If the alignment clause were not present, then a 62-bit modular
12430 representation would be chosen (typically with an alignment of 4 or 8
12431 bytes depending on the target). But the default alignment is overridden
12432 with the explicit alignment clause. This means that the modular
12433 representation cannot be used, and instead the array of bytes
12434 representation must be used, meaning that the length must be a multiple
12435 of 8. Thus the above set of declarations will result in a diagnostic
12436 rejecting the size clause and noting that the minimum size allowed is 64.
12438 @cindex Pragma Pack (for type Natural)
12439 @cindex Pragma Pack warning
12441 One special case that is worth noting occurs when the base type of the
12442 component size is 8/16/32 and the subtype is one bit less. Notably this
12443 occurs with subtype @code{Natural}. Consider:
12445 @smallexample @c ada
12446    type Arr is array (1 .. 32) of Natural;
12447    pragma Pack (Arr);
12448 @end smallexample
12450 @noindent
12451 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12452 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12453 Ada 83 compilers did not attempt 31 bit packing.
12455 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12456 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12457 substantial unintended performance penalty when porting legacy Ada 83 code.
12458 To help prevent this, GNAT generates a warning in such cases. If you really
12459 want 31 bit packing in a case like this, you can set the component size
12460 explicitly:
12462 @smallexample @c ada
12463    type Arr is array (1 .. 32) of Natural;
12464    for Arr'Component_Size use 31;
12465 @end smallexample
12467 @noindent
12468 Here 31-bit packing is achieved as required, and no warning is generated,
12469 since in this case the programmer intention is clear.
12471 @node Pragma Pack for Records
12472 @section Pragma Pack for Records
12473 @cindex Pragma Pack (for records)
12475 @noindent
12476 Pragma @code{Pack} applied to a record will pack the components to reduce
12477 wasted space from alignment gaps and by reducing the amount of space
12478 taken by components.  We distinguish between @emph{packable} components and
12479 @emph{non-packable} components.
12480 Components of the following types are considered packable:
12481 @itemize @bullet
12482 @item
12483 All primitive types are packable.
12485 @item
12486 Small packed arrays, whose size does not exceed 64 bits, and where the
12487 size is statically known at compile time, are represented internally
12488 as modular integers, and so they are also packable.
12490 @end itemize
12492 @noindent
12493 All packable components occupy the exact number of bits corresponding to
12494 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12495 can start on an arbitrary bit boundary.
12497 All other types are non-packable, they occupy an integral number of
12498 storage units, and
12499 are placed at a boundary corresponding to their alignment requirements.
12501 For example, consider the record
12503 @smallexample @c ada
12504    type Rb1 is array (1 .. 13) of Boolean;
12505    pragma Pack (rb1);
12507    type Rb2 is array (1 .. 65) of Boolean;
12508    pragma Pack (rb2);
12510    type x2 is record
12511       l1 : Boolean;
12512       l2 : Duration;
12513       l3 : Float;
12514       l4 : Boolean;
12515       l5 : Rb1;
12516       l6 : Rb2;
12517    end record;
12518    pragma Pack (x2);
12519 @end smallexample
12521 @noindent
12522 The representation for the record x2 is as follows:
12524 @smallexample @c ada
12525 for x2'Size use 224;
12526 for x2 use record
12527    l1 at  0 range  0 .. 0;
12528    l2 at  0 range  1 .. 64;
12529    l3 at 12 range  0 .. 31;
12530    l4 at 16 range  0 .. 0;
12531    l5 at 16 range  1 .. 13;
12532    l6 at 18 range  0 .. 71;
12533 end record;
12534 @end smallexample
12536 @noindent
12537 Studying this example, we see that the packable fields @code{l1}
12538 and @code{l2} are
12539 of length equal to their sizes, and placed at specific bit boundaries (and
12540 not byte boundaries) to
12541 eliminate padding.  But @code{l3} is of a non-packable float type, so
12542 it is on the next appropriate alignment boundary.
12544 The next two fields are fully packable, so @code{l4} and @code{l5} are
12545 minimally packed with no gaps.  However, type @code{Rb2} is a packed
12546 array that is longer than 64 bits, so it is itself non-packable.  Thus
12547 the @code{l6} field is aligned to the next byte boundary, and takes an
12548 integral number of bytes, i.e.@: 72 bits.
12550 @node Record Representation Clauses
12551 @section Record Representation Clauses
12552 @cindex Record Representation Clause
12554 @noindent
12555 Record representation clauses may be given for all record types, including
12556 types obtained by record extension.  Component clauses are allowed for any
12557 static component.  The restrictions on component clauses depend on the type
12558 of the component.
12560 @cindex Component Clause
12561 For all components of an elementary type, the only restriction on component
12562 clauses is that the size must be at least the 'Size value of the type
12563 (actually the Value_Size).  There are no restrictions due to alignment,
12564 and such components may freely cross storage boundaries.
12566 Packed arrays with a size up to and including 64 bits are represented
12567 internally using a modular type with the appropriate number of bits, and
12568 thus the same lack of restriction applies.  For example, if you declare:
12570 @smallexample @c ada
12571    type R is array (1 .. 49) of Boolean;
12572    pragma Pack (R);
12573    for R'Size use 49;
12574 @end smallexample
12576 @noindent
12577 then a component clause for a component of type R may start on any
12578 specified bit boundary, and may specify a value of 49 bits or greater.
12580 For packed bit arrays that are longer than 64 bits, there are two
12581 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12582 including the important case of single bits or boolean values, then
12583 there are no limitations on placement of such components, and they
12584 may start and end at arbitrary bit boundaries.
12586 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12587 an array of this type longer than 64 bits must always be placed on
12588 on a storage unit (byte) boundary and occupy an integral number
12589 of storage units (bytes). Any component clause that does not
12590 meet this requirement will be rejected.
12592 Any aliased component, or component of an aliased type, must
12593 have its normal alignment and size. A component clause that
12594 does not meet this requirement will be rejected.
12596 The tag field of a tagged type always occupies an address sized field at
12597 the start of the record.  No component clause may attempt to overlay this
12598 tag. When a tagged type appears as a component, the tag field must have
12599 proper alignment
12601 In the case of a record extension T1, of a type T, no component clause applied
12602 to the type T1 can specify a storage location that would overlap the first
12603 T'Size bytes of the record.
12605 For all other component types, including non-bit-packed arrays,
12606 the component can be placed at an arbitrary bit boundary,
12607 so for example, the following is permitted:
12609 @smallexample @c ada
12610    type R is array (1 .. 10) of Boolean;
12611    for R'Size use 80;
12613    type Q is record
12614       G, H : Boolean;
12615       L, M : R;
12616    end record;
12618    for Q use record
12619       G at 0 range  0 ..   0;
12620       H at 0 range  1 ..   1;
12621       L at 0 range  2 ..  81;
12622       R at 0 range 82 .. 161;
12623    end record;
12624 @end smallexample
12626 @noindent
12627 Note: the above rules apply to recent releases of GNAT 5.
12628 In GNAT 3, there are more severe restrictions on larger components.
12629 For non-primitive types, including packed arrays with a size greater than
12630 64 bits, component clauses must respect the alignment requirement of the
12631 type, in particular, always starting on a byte boundary, and the length
12632 must be a multiple of the storage unit.
12634 @node Enumeration Clauses
12635 @section Enumeration Clauses
12637 The only restriction on enumeration clauses is that the range of values
12638 must be representable.  For the signed case, if one or more of the
12639 representation values are negative, all values must be in the range:
12641 @smallexample @c ada
12642    System.Min_Int .. System.Max_Int
12643 @end smallexample
12645 @noindent
12646 For the unsigned case, where all values are nonnegative, the values must
12647 be in the range:
12649 @smallexample @c ada
12650    0 .. System.Max_Binary_Modulus;
12651 @end smallexample
12653 @noindent
12654 A @emph{confirming} representation clause is one in which the values range
12655 from 0 in sequence, i.e.@: a clause that confirms the default representation
12656 for an enumeration type.
12657 Such a confirming representation
12658 is permitted by these rules, and is specially recognized by the compiler so
12659 that no extra overhead results from the use of such a clause.
12661 If an array has an index type which is an enumeration type to which an
12662 enumeration clause has been applied, then the array is stored in a compact
12663 manner.  Consider the declarations:
12665 @smallexample @c ada
12666    type r is (A, B, C);
12667    for r use (A => 1, B => 5, C => 10);
12668    type t is array (r) of Character;
12669 @end smallexample
12671 @noindent
12672 The array type t corresponds to a vector with exactly three elements and
12673 has a default size equal to @code{3*Character'Size}.  This ensures efficient
12674 use of space, but means that accesses to elements of the array will incur
12675 the overhead of converting representation values to the corresponding
12676 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12678 @node Address Clauses
12679 @section Address Clauses
12680 @cindex Address Clause
12682 The reference manual allows a general restriction on representation clauses,
12683 as found in RM 13.1(22):
12685 @quotation
12686 An implementation need not support representation
12687 items containing nonstatic expressions, except that
12688 an implementation should support a representation item
12689 for a given entity if each nonstatic expression in the
12690 representation item is a name that statically denotes
12691 a constant declared before the entity.
12692 @end quotation
12694 @noindent
12695 In practice this is applicable only to address clauses, since this is the
12696 only case in which a non-static expression is permitted by the syntax.  As
12697 the AARM notes in sections 13.1 (22.a-22.h):
12699 @display
12700   22.a   Reason: This is to avoid the following sort of thing:
12702   22.b        X : Integer := F(@dots{});
12703               Y : Address := G(@dots{});
12704               for X'Address use Y;
12706   22.c   In the above, we have to evaluate the
12707          initialization expression for X before we
12708          know where to put the result.  This seems
12709          like an unreasonable implementation burden.
12711   22.d   The above code should instead be written
12712          like this:
12714   22.e        Y : constant Address := G(@dots{});
12715               X : Integer := F(@dots{});
12716               for X'Address use Y;
12718   22.f   This allows the expression ``Y'' to be safely
12719          evaluated before X is created.
12721   22.g   The constant could be a formal parameter of mode in.
12723   22.h   An implementation can support other nonstatic
12724          expressions if it wants to.  Expressions of type
12725          Address are hardly ever static, but their value
12726          might be known at compile time anyway in many
12727          cases.
12728 @end display
12730 @noindent
12731 GNAT does indeed permit many additional cases of non-static expressions.  In
12732 particular, if the type involved is elementary there are no restrictions
12733 (since in this case, holding a temporary copy of the initialization value,
12734 if one is present, is inexpensive).  In addition, if there is no implicit or
12735 explicit initialization, then there are no restrictions.  GNAT will reject
12736 only the case where all three of these conditions hold:
12738 @itemize @bullet
12740 @item
12741 The type of the item is non-elementary (e.g.@: a record or array).
12743 @item
12744 There is explicit or implicit initialization required for the object.
12745 Note that access values are always implicitly initialized.
12747 @item
12748 The address value is non-static.  Here GNAT is more permissive than the
12749 RM, and allows the address value to be the address of a previously declared
12750 stand-alone variable, as long as it does not itself have an address clause.
12752 @smallexample @c ada
12753            Anchor  : Some_Initialized_Type;
12754            Overlay : Some_Initialized_Type;
12755            for Overlay'Address use Anchor'Address;
12756 @end smallexample
12758 @noindent
12759 However, the prefix of the address clause cannot be an array component, or
12760 a component of a discriminated record.
12762 @end itemize
12764 @noindent
12765 As noted above in section 22.h, address values are typically non-static.  In
12766 particular the To_Address function, even if applied to a literal value, is
12767 a non-static function call.  To avoid this minor annoyance, GNAT provides
12768 the implementation defined attribute 'To_Address.  The following two
12769 expressions have identical values:
12771 @findex Attribute
12772 @findex To_Address
12773 @smallexample @c ada
12774    To_Address (16#1234_0000#)
12775    System'To_Address (16#1234_0000#);
12776 @end smallexample
12778 @noindent
12779 except that the second form is considered to be a static expression, and
12780 thus when used as an address clause value is always permitted.
12782 @noindent
12783 Additionally, GNAT treats as static an address clause that is an
12784 unchecked_conversion of a static integer value.  This simplifies the porting
12785 of legacy code, and provides a portable equivalent to the GNAT attribute
12786 @code{To_Address}.
12788 Another issue with address clauses is the interaction with alignment
12789 requirements.  When an address clause is given for an object, the address
12790 value must be consistent with the alignment of the object (which is usually
12791 the same as the alignment of the type of the object).  If an address clause
12792 is given that specifies an inappropriately aligned address value, then the
12793 program execution is erroneous.
12795 Since this source of erroneous behavior can have unfortunate effects, GNAT
12796 checks (at compile time if possible, generating a warning, or at execution
12797 time with a run-time check) that the alignment is appropriate.  If the
12798 run-time check fails, then @code{Program_Error} is raised.  This run-time
12799 check is suppressed if range checks are suppressed, or if the special GNAT
12800 check Alignment_Check is suppressed, or if
12801 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12803 Finally, GNAT does not permit overlaying of objects of controlled types or
12804 composite types containing a controlled component. In most cases, the compiler
12805 can detect an attempt at such overlays and will generate a warning at compile
12806 time and a Program_Error exception at run time.
12808 @findex Export
12809 An address clause cannot be given for an exported object.  More
12810 understandably the real restriction is that objects with an address
12811 clause cannot be exported.  This is because such variables are not
12812 defined by the Ada program, so there is no external object to export.
12814 @findex Import
12815 It is permissible to give an address clause and a pragma Import for the
12816 same object.  In this case, the variable is not really defined by the
12817 Ada program, so there is no external symbol to be linked.  The link name
12818 and the external name are ignored in this case.  The reason that we allow this
12819 combination is that it provides a useful idiom to avoid unwanted
12820 initializations on objects with address clauses.
12822 When an address clause is given for an object that has implicit or
12823 explicit initialization, then by default initialization takes place.  This
12824 means that the effect of the object declaration is to overwrite the
12825 memory at the specified address.  This is almost always not what the
12826 programmer wants, so GNAT will output a warning:
12828 @smallexample
12829   with System;
12830   package G is
12831      type R is record
12832         M : Integer := 0;
12833      end record;
12835      Ext : R;
12836      for Ext'Address use System'To_Address (16#1234_1234#);
12837          |
12838   >>> warning: implicit initialization of "Ext" may
12839       modify overlaid storage
12840   >>> warning: use pragma Import for "Ext" to suppress
12841       initialization (RM B(24))
12843   end G;
12844 @end smallexample
12846 @noindent
12847 As indicated by the warning message, the solution is to use a (dummy) pragma
12848 Import to suppress this initialization.  The pragma tell the compiler that the
12849 object is declared and initialized elsewhere.  The following package compiles
12850 without warnings (and the initialization is suppressed):
12852 @smallexample @c ada
12853    with System;
12854    package G is
12855       type R is record
12856          M : Integer := 0;
12857       end record;
12859       Ext : R;
12860       for Ext'Address use System'To_Address (16#1234_1234#);
12861       pragma Import (Ada, Ext);
12862    end G;
12863 @end smallexample
12865 @noindent
12866 A final issue with address clauses involves their use for overlaying
12867 variables, as in the following example:
12868 @cindex Overlaying of objects
12870 @smallexample @c ada
12871   A : Integer;
12872   B : Integer;
12873   for B'Address use A'Address;
12874 @end smallexample
12876 @noindent
12877 or alternatively, using the form recommended by the RM:
12879 @smallexample @c ada
12880   A    : Integer;
12881   Addr : constant Address := A'Address;
12882   B    : Integer;
12883   for B'Address use Addr;
12884 @end smallexample
12886 @noindent
12887 In both of these cases, @code{A}
12888 and @code{B} become aliased to one another via the
12889 address clause. This use of address clauses to overlay
12890 variables, achieving an effect similar to unchecked
12891 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12892 the effect is implementation defined. Furthermore, the
12893 Ada RM specifically recommends that in a situation
12894 like this, @code{B} should be subject to the following
12895 implementation advice (RM 13.3(19)):
12897 @quotation
12898 19  If the Address of an object is specified, or it is imported
12899     or exported, then the implementation should not perform
12900     optimizations based on assumptions of no aliases.
12901 @end quotation
12903 @noindent
12904 GNAT follows this recommendation, and goes further by also applying
12905 this recommendation to the overlaid variable (@code{A}
12906 in the above example) in this case. This means that the overlay
12907 works "as expected", in that a modification to one of the variables
12908 will affect the value of the other.
12910 @node Effect of Convention on Representation
12911 @section Effect of Convention on Representation
12912 @cindex Convention, effect on representation
12914 @noindent
12915 Normally the specification of a foreign language convention for a type or
12916 an object has no effect on the chosen representation.  In particular, the
12917 representation chosen for data in GNAT generally meets the standard system
12918 conventions, and for example records are laid out in a manner that is
12919 consistent with C@.  This means that specifying convention C (for example)
12920 has no effect.
12922 There are four exceptions to this general rule:
12924 @itemize @bullet
12926 @item Convention Fortran and array subtypes
12927 If pragma Convention Fortran is specified for an array subtype, then in
12928 accordance with the implementation advice in section 3.6.2(11) of the
12929 Ada Reference Manual, the array will be stored in a Fortran-compatible
12930 column-major manner, instead of the normal default row-major order.
12932 @item Convention C and enumeration types
12933 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12934 to accommodate all values of the type.  For example, for the enumeration
12935 type declared by:
12937 @smallexample @c ada
12938    type Color is (Red, Green, Blue);
12939 @end smallexample
12941 @noindent
12942 8 bits is sufficient to store all values of the type, so by default, objects
12943 of type @code{Color} will be represented using 8 bits.  However, normal C
12944 convention is to use 32 bits for all enum values in C, since enum values
12945 are essentially of type int.  If pragma @code{Convention C} is specified for an
12946 Ada enumeration type, then the size is modified as necessary (usually to
12947 32 bits) to be consistent with the C convention for enum values.
12949 Note that this treatment applies only to types. If Convention C is given for
12950 an enumeration object, where the enumeration type is not Convention C, then
12951 Object_Size bits are allocated. For example, for a normal enumeration type,
12952 with less than 256 elements, only 8 bits will be allocated for the object.
12953 Since this may be a surprise in terms of what C expects, GNAT will issue a
12954 warning in this situation. The warning can be suppressed by giving an explicit
12955 size clause specifying the desired size.
12957 @item Convention C/Fortran and Boolean types
12958 In C, the usual convention for boolean values, that is values used for
12959 conditions, is that zero represents false, and nonzero values represent
12960 true.  In Ada, the normal convention is that two specific values, typically
12961 0/1, are used to represent false/true respectively.
12963 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12964 value represents true).
12966 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12967 C or Fortran convention for a derived Boolean, as in the following example:
12969 @smallexample @c ada
12970    type C_Switch is new Boolean;
12971    pragma Convention (C, C_Switch);
12972 @end smallexample
12974 @noindent
12975 then the GNAT generated code will treat any nonzero value as true.  For truth
12976 values generated by GNAT, the conventional value 1 will be used for True, but
12977 when one of these values is read, any nonzero value is treated as True.
12979 @item Access types on OpenVMS
12980 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12981 arrays) are 64-bits long. An exception to this rule is for the case of
12982 C-convention access types where there is no explicit size clause present (or
12983 inherited for derived types). In this case, GNAT chooses to make these
12984 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12985 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12987 @end itemize
12989 @node Determining the Representations chosen by GNAT
12990 @section Determining the Representations chosen by GNAT
12991 @cindex Representation, determination of
12992 @cindex @option{-gnatR} switch
12994 @noindent
12995 Although the descriptions in this section are intended to be complete, it is
12996 often easier to simply experiment to see what GNAT accepts and what the
12997 effect is on the layout of types and objects.
12999 As required by the Ada RM, if a representation clause is not accepted, then
13000 it must be rejected as illegal by the compiler.  However, when a
13001 representation clause or pragma is accepted, there can still be questions
13002 of what the compiler actually does.  For example, if a partial record
13003 representation clause specifies the location of some components and not
13004 others, then where are the non-specified components placed? Or if pragma
13005 @code{Pack} is used on a record, then exactly where are the resulting
13006 fields placed? The section on pragma @code{Pack} in this chapter can be
13007 used to answer the second question, but it is often easier to just see
13008 what the compiler does.
13010 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
13011 with this option, then the compiler will output information on the actual
13012 representations chosen, in a format similar to source representation
13013 clauses.  For example, if we compile the package:
13015 @smallexample @c ada
13016 package q is
13017    type r (x : boolean) is tagged record
13018       case x is
13019          when True => S : String (1 .. 100);
13020          when False => null;
13021       end case;
13022    end record;
13024    type r2 is new r (false) with record
13025       y2 : integer;
13026    end record;
13028    for r2 use record
13029       y2 at 16 range 0 .. 31;
13030    end record;
13032    type x is record
13033       y : character;
13034    end record;
13036    type x1 is array (1 .. 10) of x;
13037    for x1'component_size use 11;
13039    type ia is access integer;
13041    type Rb1 is array (1 .. 13) of Boolean;
13042    pragma Pack (rb1);
13044    type Rb2 is array (1 .. 65) of Boolean;
13045    pragma Pack (rb2);
13047    type x2 is record
13048       l1 : Boolean;
13049       l2 : Duration;
13050       l3 : Float;
13051       l4 : Boolean;
13052       l5 : Rb1;
13053       l6 : Rb2;
13054    end record;
13055    pragma Pack (x2);
13056 end q;
13057 @end smallexample
13059 @noindent
13060 using the switch @option{-gnatR} we obtain the following output:
13062 @smallexample
13063 Representation information for unit q
13064 -------------------------------------
13066 for r'Size use ??;
13067 for r'Alignment use 4;
13068 for r use record
13069    x    at 4 range  0 .. 7;
13070    _tag at 0 range  0 .. 31;
13071    s    at 5 range  0 .. 799;
13072 end record;
13074 for r2'Size use 160;
13075 for r2'Alignment use 4;
13076 for r2 use record
13077    x       at  4 range  0 .. 7;
13078    _tag    at  0 range  0 .. 31;
13079    _parent at  0 range  0 .. 63;
13080    y2      at 16 range  0 .. 31;
13081 end record;
13083 for x'Size use 8;
13084 for x'Alignment use 1;
13085 for x use record
13086    y at 0 range  0 .. 7;
13087 end record;
13089 for x1'Size use 112;
13090 for x1'Alignment use 1;
13091 for x1'Component_Size use 11;
13093 for rb1'Size use 13;
13094 for rb1'Alignment use 2;
13095 for rb1'Component_Size use 1;
13097 for rb2'Size use 72;
13098 for rb2'Alignment use 1;
13099 for rb2'Component_Size use 1;
13101 for x2'Size use 224;
13102 for x2'Alignment use 4;
13103 for x2 use record
13104    l1 at  0 range  0 .. 0;
13105    l2 at  0 range  1 .. 64;
13106    l3 at 12 range  0 .. 31;
13107    l4 at 16 range  0 .. 0;
13108    l5 at 16 range  1 .. 13;
13109    l6 at 18 range  0 .. 71;
13110 end record;
13111 @end smallexample
13113 @noindent
13114 The Size values are actually the Object_Size, i.e.@: the default size that
13115 will be allocated for objects of the type.
13116 The ?? size for type r indicates that we have a variant record, and the
13117 actual size of objects will depend on the discriminant value.
13119 The Alignment values show the actual alignment chosen by the compiler
13120 for each record or array type.
13122 The record representation clause for type r shows where all fields
13123 are placed, including the compiler generated tag field (whose location
13124 cannot be controlled by the programmer).
13126 The record representation clause for the type extension r2 shows all the
13127 fields present, including the parent field, which is a copy of the fields
13128 of the parent type of r2, i.e.@: r1.
13130 The component size and size clauses for types rb1 and rb2 show
13131 the exact effect of pragma @code{Pack} on these arrays, and the record
13132 representation clause for type x2 shows how pragma @code{Pack} affects
13133 this record type.
13135 In some cases, it may be useful to cut and paste the representation clauses
13136 generated by the compiler into the original source to fix and guarantee
13137 the actual representation to be used.
13139 @node Standard Library Routines
13140 @chapter Standard Library Routines
13142 @noindent
13143 The Ada Reference Manual contains in Annex A a full description of an
13144 extensive set of standard library routines that can be used in any Ada
13145 program, and which must be provided by all Ada compilers.  They are
13146 analogous to the standard C library used by C programs.
13148 GNAT implements all of the facilities described in annex A, and for most
13149 purposes the description in the Ada Reference Manual, or appropriate Ada
13150 text book, will be sufficient for making use of these facilities.
13152 In the case of the input-output facilities,
13153 @xref{The Implementation of Standard I/O},
13154 gives details on exactly how GNAT interfaces to the
13155 file system.  For the remaining packages, the Ada Reference Manual
13156 should be sufficient.  The following is a list of the packages included,
13157 together with a brief description of the functionality that is provided.
13159 For completeness, references are included to other predefined library
13160 routines defined in other sections of the Ada Reference Manual (these are
13161 cross-indexed from Annex A).
13163 @table @code
13164 @item Ada (A.2)
13165 This is a parent package for all the standard library packages.  It is
13166 usually included implicitly in your program, and itself contains no
13167 useful data or routines.
13169 @item Ada.Calendar (9.6)
13170 @code{Calendar} provides time of day access, and routines for
13171 manipulating times and durations.
13173 @item Ada.Characters (A.3.1)
13174 This is a dummy parent package that contains no useful entities
13176 @item Ada.Characters.Handling (A.3.2)
13177 This package provides some basic character handling capabilities,
13178 including classification functions for classes of characters (e.g.@: test
13179 for letters, or digits).
13181 @item Ada.Characters.Latin_1 (A.3.3)
13182 This package includes a complete set of definitions of the characters
13183 that appear in type CHARACTER@.  It is useful for writing programs that
13184 will run in international environments.  For example, if you want an
13185 upper case E with an acute accent in a string, it is often better to use
13186 the definition of @code{UC_E_Acute} in this package.  Then your program
13187 will print in an understandable manner even if your environment does not
13188 support these extended characters.
13190 @item Ada.Command_Line (A.15)
13191 This package provides access to the command line parameters and the name
13192 of the current program (analogous to the use of @code{argc} and @code{argv}
13193 in C), and also allows the exit status for the program to be set in a
13194 system-independent manner.
13196 @item Ada.Decimal (F.2)
13197 This package provides constants describing the range of decimal numbers
13198 implemented, and also a decimal divide routine (analogous to the COBOL
13199 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13201 @item Ada.Direct_IO (A.8.4)
13202 This package provides input-output using a model of a set of records of
13203 fixed-length, containing an arbitrary definite Ada type, indexed by an
13204 integer record number.
13206 @item Ada.Dynamic_Priorities (D.5)
13207 This package allows the priorities of a task to be adjusted dynamically
13208 as the task is running.
13210 @item Ada.Exceptions (11.4.1)
13211 This package provides additional information on exceptions, and also
13212 contains facilities for treating exceptions as data objects, and raising
13213 exceptions with associated messages.
13215 @item Ada.Finalization (7.6)
13216 This package contains the declarations and subprograms to support the
13217 use of controlled types, providing for automatic initialization and
13218 finalization (analogous to the constructors and destructors of C++)
13220 @item Ada.Interrupts (C.3.2)
13221 This package provides facilities for interfacing to interrupts, which
13222 includes the set of signals or conditions that can be raised and
13223 recognized as interrupts.
13225 @item Ada.Interrupts.Names (C.3.2)
13226 This package provides the set of interrupt names (actually signal
13227 or condition names) that can be handled by GNAT@.
13229 @item Ada.IO_Exceptions (A.13)
13230 This package defines the set of exceptions that can be raised by use of
13231 the standard IO packages.
13233 @item Ada.Numerics
13234 This package contains some standard constants and exceptions used
13235 throughout the numerics packages.  Note that the constants pi and e are
13236 defined here, and it is better to use these definitions than rolling
13237 your own.
13239 @item Ada.Numerics.Complex_Elementary_Functions
13240 Provides the implementation of standard elementary functions (such as
13241 log and trigonometric functions) operating on complex numbers using the
13242 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13243 created by the package @code{Numerics.Complex_Types}.
13245 @item Ada.Numerics.Complex_Types
13246 This is a predefined instantiation of
13247 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13248 build the type @code{Complex} and @code{Imaginary}.
13250 @item Ada.Numerics.Discrete_Random
13251 This generic package provides a random number generator suitable for generating
13252 uniformly distributed values of a specified discrete subtype.
13254 @item Ada.Numerics.Float_Random
13255 This package provides a random number generator suitable for generating
13256 uniformly distributed floating point values in the unit interval.
13258 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13259 This is a generic version of the package that provides the
13260 implementation of standard elementary functions (such as log and
13261 trigonometric functions) for an arbitrary complex type.
13263 The following predefined instantiations of this package are provided:
13265 @table @code
13266 @item Short_Float
13267 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13268 @item Float
13269 @code{Ada.Numerics.Complex_Elementary_Functions}
13270 @item Long_Float
13271 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13272 @end table
13274 @item Ada.Numerics.Generic_Complex_Types
13275 This is a generic package that allows the creation of complex types,
13276 with associated complex arithmetic operations.
13278 The following predefined instantiations of this package exist
13279 @table @code
13280 @item Short_Float
13281 @code{Ada.Numerics.Short_Complex_Complex_Types}
13282 @item Float
13283 @code{Ada.Numerics.Complex_Complex_Types}
13284 @item Long_Float
13285 @code{Ada.Numerics.Long_Complex_Complex_Types}
13286 @end table
13288 @item Ada.Numerics.Generic_Elementary_Functions
13289 This is a generic package that provides the implementation of standard
13290 elementary functions (such as log an trigonometric functions) for an
13291 arbitrary float type.
13293 The following predefined instantiations of this package exist
13295 @table @code
13296 @item Short_Float
13297 @code{Ada.Numerics.Short_Elementary_Functions}
13298 @item Float
13299 @code{Ada.Numerics.Elementary_Functions}
13300 @item Long_Float
13301 @code{Ada.Numerics.Long_Elementary_Functions}
13302 @end table
13304 @item Ada.Real_Time (D.8)
13305 This package provides facilities similar to those of @code{Calendar}, but
13306 operating with a finer clock suitable for real time control. Note that
13307 annex D requires that there be no backward clock jumps, and GNAT generally
13308 guarantees this behavior, but of course if the external clock on which
13309 the GNAT runtime depends is deliberately reset by some external event,
13310 then such a backward jump may occur.
13312 @item Ada.Sequential_IO (A.8.1)
13313 This package provides input-output facilities for sequential files,
13314 which can contain a sequence of values of a single type, which can be
13315 any Ada type, including indefinite (unconstrained) types.
13317 @item Ada.Storage_IO (A.9)
13318 This package provides a facility for mapping arbitrary Ada types to and
13319 from a storage buffer.  It is primarily intended for the creation of new
13320 IO packages.
13322 @item Ada.Streams (13.13.1)
13323 This is a generic package that provides the basic support for the
13324 concept of streams as used by the stream attributes (@code{Input},
13325 @code{Output}, @code{Read} and @code{Write}).
13327 @item Ada.Streams.Stream_IO (A.12.1)
13328 This package is a specialization of the type @code{Streams} defined in
13329 package @code{Streams} together with a set of operations providing
13330 Stream_IO capability.  The Stream_IO model permits both random and
13331 sequential access to a file which can contain an arbitrary set of values
13332 of one or more Ada types.
13334 @item Ada.Strings (A.4.1)
13335 This package provides some basic constants used by the string handling
13336 packages.
13338 @item Ada.Strings.Bounded (A.4.4)
13339 This package provides facilities for handling variable length
13340 strings.  The bounded model requires a maximum length.  It is thus
13341 somewhat more limited than the unbounded model, but avoids the use of
13342 dynamic allocation or finalization.
13344 @item Ada.Strings.Fixed (A.4.3)
13345 This package provides facilities for handling fixed length strings.
13347 @item Ada.Strings.Maps (A.4.2)
13348 This package provides facilities for handling character mappings and
13349 arbitrarily defined subsets of characters.  For instance it is useful in
13350 defining specialized translation tables.
13352 @item Ada.Strings.Maps.Constants (A.4.6)
13353 This package provides a standard set of predefined mappings and
13354 predefined character sets.  For example, the standard upper to lower case
13355 conversion table is found in this package.  Note that upper to lower case
13356 conversion is non-trivial if you want to take the entire set of
13357 characters, including extended characters like E with an acute accent,
13358 into account.  You should use the mappings in this package (rather than
13359 adding 32 yourself) to do case mappings.
13361 @item Ada.Strings.Unbounded (A.4.5)
13362 This package provides facilities for handling variable length
13363 strings.  The unbounded model allows arbitrary length strings, but
13364 requires the use of dynamic allocation and finalization.
13366 @item Ada.Strings.Wide_Bounded (A.4.7)
13367 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13368 @itemx Ada.Strings.Wide_Maps (A.4.7)
13369 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13370 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13371 These packages provide analogous capabilities to the corresponding
13372 packages without @samp{Wide_} in the name, but operate with the types
13373 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13374 and @code{Character}.
13376 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13377 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13378 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13379 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13380 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13381 These packages provide analogous capabilities to the corresponding
13382 packages without @samp{Wide_} in the name, but operate with the types
13383 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13384 of @code{String} and @code{Character}.
13386 @item Ada.Synchronous_Task_Control (D.10)
13387 This package provides some standard facilities for controlling task
13388 communication in a synchronous manner.
13390 @item Ada.Tags
13391 This package contains definitions for manipulation of the tags of tagged
13392 values.
13394 @item Ada.Task_Attributes
13395 This package provides the capability of associating arbitrary
13396 task-specific data with separate tasks.
13398 @item Ada.Text_IO
13399 This package provides basic text input-output capabilities for
13400 character, string and numeric data.  The subpackages of this
13401 package are listed next.
13403 @item Ada.Text_IO.Decimal_IO
13404 Provides input-output facilities for decimal fixed-point types
13406 @item Ada.Text_IO.Enumeration_IO
13407 Provides input-output facilities for enumeration types.
13409 @item Ada.Text_IO.Fixed_IO
13410 Provides input-output facilities for ordinary fixed-point types.
13412 @item Ada.Text_IO.Float_IO
13413 Provides input-output facilities for float types.  The following
13414 predefined instantiations of this generic package are available:
13416 @table @code
13417 @item Short_Float
13418 @code{Short_Float_Text_IO}
13419 @item Float
13420 @code{Float_Text_IO}
13421 @item Long_Float
13422 @code{Long_Float_Text_IO}
13423 @end table
13425 @item Ada.Text_IO.Integer_IO
13426 Provides input-output facilities for integer types.  The following
13427 predefined instantiations of this generic package are available:
13429 @table @code
13430 @item Short_Short_Integer
13431 @code{Ada.Short_Short_Integer_Text_IO}
13432 @item Short_Integer
13433 @code{Ada.Short_Integer_Text_IO}
13434 @item Integer
13435 @code{Ada.Integer_Text_IO}
13436 @item Long_Integer
13437 @code{Ada.Long_Integer_Text_IO}
13438 @item Long_Long_Integer
13439 @code{Ada.Long_Long_Integer_Text_IO}
13440 @end table
13442 @item Ada.Text_IO.Modular_IO
13443 Provides input-output facilities for modular (unsigned) types
13445 @item Ada.Text_IO.Complex_IO (G.1.3)
13446 This package provides basic text input-output capabilities for complex
13447 data.
13449 @item Ada.Text_IO.Editing (F.3.3)
13450 This package contains routines for edited output, analogous to the use
13451 of pictures in COBOL@.  The picture formats used by this package are a
13452 close copy of the facility in COBOL@.
13454 @item Ada.Text_IO.Text_Streams (A.12.2)
13455 This package provides a facility that allows Text_IO files to be treated
13456 as streams, so that the stream attributes can be used for writing
13457 arbitrary data, including binary data, to Text_IO files.
13459 @item Ada.Unchecked_Conversion (13.9)
13460 This generic package allows arbitrary conversion from one type to
13461 another of the same size, providing for breaking the type safety in
13462 special circumstances.
13464 If the types have the same Size (more accurately the same Value_Size),
13465 then the effect is simply to transfer the bits from the source to the
13466 target type without any modification.  This usage is well defined, and
13467 for simple types whose representation is typically the same across
13468 all implementations, gives a portable method of performing such
13469 conversions.
13471 If the types do not have the same size, then the result is implementation
13472 defined, and thus may be non-portable.  The following describes how GNAT
13473 handles such unchecked conversion cases.
13475 If the types are of different sizes, and are both discrete types, then
13476 the effect is of a normal type conversion without any constraint checking.
13477 In particular if the result type has a larger size, the result will be
13478 zero or sign extended.  If the result type has a smaller size, the result
13479 will be truncated by ignoring high order bits.
13481 If the types are of different sizes, and are not both discrete types,
13482 then the conversion works as though pointers were created to the source
13483 and target, and the pointer value is converted.  The effect is that bits
13484 are copied from successive low order storage units and bits of the source
13485 up to the length of the target type.
13487 A warning is issued if the lengths differ, since the effect in this
13488 case is implementation dependent, and the above behavior may not match
13489 that of some other compiler.
13491 A pointer to one type may be converted to a pointer to another type using
13492 unchecked conversion.  The only case in which the effect is undefined is
13493 when one or both pointers are pointers to unconstrained array types.  In
13494 this case, the bounds information may get incorrectly transferred, and in
13495 particular, GNAT uses double size pointers for such types, and it is
13496 meaningless to convert between such pointer types.  GNAT will issue a
13497 warning if the alignment of the target designated type is more strict
13498 than the alignment of the source designated type (since the result may
13499 be unaligned in this case).
13501 A pointer other than a pointer to an unconstrained array type may be
13502 converted to and from System.Address.  Such usage is common in Ada 83
13503 programs, but note that Ada.Address_To_Access_Conversions is the
13504 preferred method of performing such conversions in Ada 95 and Ada 2005.
13505 Neither
13506 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13507 used in conjunction with pointers to unconstrained objects, since
13508 the bounds information cannot be handled correctly in this case.
13510 @item Ada.Unchecked_Deallocation (13.11.2)
13511 This generic package allows explicit freeing of storage previously
13512 allocated by use of an allocator.
13514 @item Ada.Wide_Text_IO (A.11)
13515 This package is similar to @code{Ada.Text_IO}, except that the external
13516 file supports wide character representations, and the internal types are
13517 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13518 and @code{String}.  It contains generic subpackages listed next.
13520 @item Ada.Wide_Text_IO.Decimal_IO
13521 Provides input-output facilities for decimal fixed-point types
13523 @item Ada.Wide_Text_IO.Enumeration_IO
13524 Provides input-output facilities for enumeration types.
13526 @item Ada.Wide_Text_IO.Fixed_IO
13527 Provides input-output facilities for ordinary fixed-point types.
13529 @item Ada.Wide_Text_IO.Float_IO
13530 Provides input-output facilities for float types.  The following
13531 predefined instantiations of this generic package are available:
13533 @table @code
13534 @item Short_Float
13535 @code{Short_Float_Wide_Text_IO}
13536 @item Float
13537 @code{Float_Wide_Text_IO}
13538 @item Long_Float
13539 @code{Long_Float_Wide_Text_IO}
13540 @end table
13542 @item Ada.Wide_Text_IO.Integer_IO
13543 Provides input-output facilities for integer types.  The following
13544 predefined instantiations of this generic package are available:
13546 @table @code
13547 @item Short_Short_Integer
13548 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13549 @item Short_Integer
13550 @code{Ada.Short_Integer_Wide_Text_IO}
13551 @item Integer
13552 @code{Ada.Integer_Wide_Text_IO}
13553 @item Long_Integer
13554 @code{Ada.Long_Integer_Wide_Text_IO}
13555 @item Long_Long_Integer
13556 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13557 @end table
13559 @item Ada.Wide_Text_IO.Modular_IO
13560 Provides input-output facilities for modular (unsigned) types
13562 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13563 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13564 external file supports wide character representations.
13566 @item Ada.Wide_Text_IO.Editing (F.3.4)
13567 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13568 types are @code{Wide_Character} and @code{Wide_String} instead of
13569 @code{Character} and @code{String}.
13571 @item Ada.Wide_Text_IO.Streams (A.12.3)
13572 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13573 types are @code{Wide_Character} and @code{Wide_String} instead of
13574 @code{Character} and @code{String}.
13576 @item Ada.Wide_Wide_Text_IO (A.11)
13577 This package is similar to @code{Ada.Text_IO}, except that the external
13578 file supports wide character representations, and the internal types are
13579 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13580 and @code{String}.  It contains generic subpackages listed next.
13582 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13583 Provides input-output facilities for decimal fixed-point types
13585 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13586 Provides input-output facilities for enumeration types.
13588 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13589 Provides input-output facilities for ordinary fixed-point types.
13591 @item Ada.Wide_Wide_Text_IO.Float_IO
13592 Provides input-output facilities for float types.  The following
13593 predefined instantiations of this generic package are available:
13595 @table @code
13596 @item Short_Float
13597 @code{Short_Float_Wide_Wide_Text_IO}
13598 @item Float
13599 @code{Float_Wide_Wide_Text_IO}
13600 @item Long_Float
13601 @code{Long_Float_Wide_Wide_Text_IO}
13602 @end table
13604 @item Ada.Wide_Wide_Text_IO.Integer_IO
13605 Provides input-output facilities for integer types.  The following
13606 predefined instantiations of this generic package are available:
13608 @table @code
13609 @item Short_Short_Integer
13610 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13611 @item Short_Integer
13612 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13613 @item Integer
13614 @code{Ada.Integer_Wide_Wide_Text_IO}
13615 @item Long_Integer
13616 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13617 @item Long_Long_Integer
13618 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13619 @end table
13621 @item Ada.Wide_Wide_Text_IO.Modular_IO
13622 Provides input-output facilities for modular (unsigned) types
13624 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13625 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13626 external file supports wide character representations.
13628 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13629 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13630 types are @code{Wide_Character} and @code{Wide_String} instead of
13631 @code{Character} and @code{String}.
13633 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13634 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13635 types are @code{Wide_Character} and @code{Wide_String} instead of
13636 @code{Character} and @code{String}.
13637 @end table
13639 @node The Implementation of Standard I/O
13640 @chapter The Implementation of Standard I/O
13642 @noindent
13643 GNAT implements all the required input-output facilities described in
13644 A.6 through A.14.  These sections of the Ada Reference Manual describe the
13645 required behavior of these packages from the Ada point of view, and if
13646 you are writing a portable Ada program that does not need to know the
13647 exact manner in which Ada maps to the outside world when it comes to
13648 reading or writing external files, then you do not need to read this
13649 chapter.  As long as your files are all regular files (not pipes or
13650 devices), and as long as you write and read the files only from Ada, the
13651 description in the Ada Reference Manual is sufficient.
13653 However, if you want to do input-output to pipes or other devices, such
13654 as the keyboard or screen, or if the files you are dealing with are
13655 either generated by some other language, or to be read by some other
13656 language, then you need to know more about the details of how the GNAT
13657 implementation of these input-output facilities behaves.
13659 In this chapter we give a detailed description of exactly how GNAT
13660 interfaces to the file system.  As always, the sources of the system are
13661 available to you for answering questions at an even more detailed level,
13662 but for most purposes the information in this chapter will suffice.
13664 Another reason that you may need to know more about how input-output is
13665 implemented arises when you have a program written in mixed languages
13666 where, for example, files are shared between the C and Ada sections of
13667 the same program.  GNAT provides some additional facilities, in the form
13668 of additional child library packages, that facilitate this sharing, and
13669 these additional facilities are also described in this chapter.
13671 @menu
13672 * Standard I/O Packages::
13673 * FORM Strings::
13674 * Direct_IO::
13675 * Sequential_IO::
13676 * Text_IO::
13677 * Wide_Text_IO::
13678 * Wide_Wide_Text_IO::
13679 * Stream_IO::
13680 * Text Translation::
13681 * Shared Files::
13682 * Filenames encoding::
13683 * Open Modes::
13684 * Operations on C Streams::
13685 * Interfacing to C Streams::
13686 @end menu
13688 @node Standard I/O Packages
13689 @section Standard I/O Packages
13691 @noindent
13692 The Standard I/O packages described in Annex A for
13694 @itemize @bullet
13695 @item
13696 Ada.Text_IO
13697 @item
13698 Ada.Text_IO.Complex_IO
13699 @item
13700 Ada.Text_IO.Text_Streams
13701 @item
13702 Ada.Wide_Text_IO
13703 @item
13704 Ada.Wide_Text_IO.Complex_IO
13705 @item
13706 Ada.Wide_Text_IO.Text_Streams
13707 @item
13708 Ada.Wide_Wide_Text_IO
13709 @item
13710 Ada.Wide_Wide_Text_IO.Complex_IO
13711 @item
13712 Ada.Wide_Wide_Text_IO.Text_Streams
13713 @item
13714 Ada.Stream_IO
13715 @item
13716 Ada.Sequential_IO
13717 @item
13718 Ada.Direct_IO
13719 @end itemize
13721 @noindent
13722 are implemented using the C
13723 library streams facility; where
13725 @itemize @bullet
13726 @item
13727 All files are opened using @code{fopen}.
13728 @item
13729 All input/output operations use @code{fread}/@code{fwrite}.
13730 @end itemize
13732 @noindent
13733 There is no internal buffering of any kind at the Ada library level. The only
13734 buffering is that provided at the system level in the implementation of the
13735 library routines that support streams. This facilitates shared use of these
13736 streams by mixed language programs. Note though that system level buffering is
13737 explicitly enabled at elaboration of the standard I/O packages and that can
13738 have an impact on mixed language programs, in particular those using I/O before
13739 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13740 the Ada elaboration routine before performing any I/O or when impractical,
13741 flush the common I/O streams and in particular Standard_Output before
13742 elaborating the Ada code.
13744 @node FORM Strings
13745 @section FORM Strings
13747 @noindent
13748 The format of a FORM string in GNAT is:
13750 @smallexample
13751 "keyword=value,keyword=value,@dots{},keyword=value"
13752 @end smallexample
13754 @noindent
13755 where letters may be in upper or lower case, and there are no spaces
13756 between values.  The order of the entries is not important.  Currently
13757 the following keywords defined.
13759 @smallexample
13760 TEXT_TRANSLATION=[YES|NO]
13761 SHARED=[YES|NO]
13762 WCEM=[n|h|u|s|e|8|b]
13763 ENCODING=[UTF8|8BITS]
13764 @end smallexample
13766 @noindent
13767 The use of these parameters is described later in this section. If an
13768 unrecognized keyword appears in a form string, it is silently ignored
13769 and not considered invalid.
13771 @node Direct_IO
13772 @section Direct_IO
13774 @noindent
13775 Direct_IO can only be instantiated for definite types.  This is a
13776 restriction of the Ada language, which means that the records are fixed
13777 length (the length being determined by @code{@var{type}'Size}, rounded
13778 up to the next storage unit boundary if necessary).
13780 The records of a Direct_IO file are simply written to the file in index
13781 sequence, with the first record starting at offset zero, and subsequent
13782 records following.  There is no control information of any kind.  For
13783 example, if 32-bit integers are being written, each record takes
13784 4-bytes, so the record at index @var{K} starts at offset
13785 (@var{K}@minus{}1)*4.
13787 There is no limit on the size of Direct_IO files, they are expanded as
13788 necessary to accommodate whatever records are written to the file.
13790 @node Sequential_IO
13791 @section Sequential_IO
13793 @noindent
13794 Sequential_IO may be instantiated with either a definite (constrained)
13795 or indefinite (unconstrained) type.
13797 For the definite type case, the elements written to the file are simply
13798 the memory images of the data values with no control information of any
13799 kind.  The resulting file should be read using the same type, no validity
13800 checking is performed on input.
13802 For the indefinite type case, the elements written consist of two
13803 parts.  First is the size of the data item, written as the memory image
13804 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13805 the data value.  The resulting file can only be read using the same
13806 (unconstrained) type.  Normal assignment checks are performed on these
13807 read operations, and if these checks fail, @code{Data_Error} is
13808 raised.  In particular, in the array case, the lengths must match, and in
13809 the variant record case, if the variable for a particular read operation
13810 is constrained, the discriminants must match.
13812 Note that it is not possible to use Sequential_IO to write variable
13813 length array items, and then read the data back into different length
13814 arrays.  For example, the following will raise @code{Data_Error}:
13816 @smallexample @c ada
13817  package IO is new Sequential_IO (String);
13818  F : IO.File_Type;
13819  S : String (1..4);
13820  @dots{}
13821  IO.Create (F)
13822  IO.Write (F, "hello!")
13823  IO.Reset (F, Mode=>In_File);
13824  IO.Read (F, S);
13825  Put_Line (S);
13827 @end smallexample
13829 @noindent
13830 On some Ada implementations, this will print @code{hell}, but the program is
13831 clearly incorrect, since there is only one element in the file, and that
13832 element is the string @code{hello!}.
13834 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13835 using Stream_IO, and this is the preferred mechanism.  In particular, the
13836 above program fragment rewritten to use Stream_IO will work correctly.
13838 @node Text_IO
13839 @section Text_IO
13841 @noindent
13842 Text_IO files consist of a stream of characters containing the following
13843 special control characters:
13845 @smallexample
13846 LF (line feed, 16#0A#) Line Mark
13847 FF (form feed, 16#0C#) Page Mark
13848 @end smallexample
13850 @noindent
13851 A canonical Text_IO file is defined as one in which the following
13852 conditions are met:
13854 @itemize @bullet
13855 @item
13856 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13857 of the line.
13859 @item
13860 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13861 end of a page and consequently can appear only immediately following a
13862 @code{LF} (line mark) character.
13864 @item
13865 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13866 (line mark, page mark).  In the former case, the page mark is implicitly
13867 assumed to be present.
13868 @end itemize
13870 @noindent
13871 A file written using Text_IO will be in canonical form provided that no
13872 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13873 or @code{Put_Line}.  There will be no @code{FF} character at the end of
13874 the file unless an explicit @code{New_Page} operation was performed
13875 before closing the file.
13877 A canonical Text_IO file that is a regular file (i.e., not a device or a
13878 pipe) can be read using any of the routines in Text_IO@.  The
13879 semantics in this case will be exactly as defined in the Ada Reference
13880 Manual, and all the routines in Text_IO are fully implemented.
13882 A text file that does not meet the requirements for a canonical Text_IO
13883 file has one of the following:
13885 @itemize @bullet
13886 @item
13887 The file contains @code{FF} characters not immediately following a
13888 @code{LF} character.
13890 @item
13891 The file contains @code{LF} or @code{FF} characters written by
13892 @code{Put} or @code{Put_Line}, which are not logically considered to be
13893 line marks or page marks.
13895 @item
13896 The file ends in a character other than @code{LF} or @code{FF},
13897 i.e.@: there is no explicit line mark or page mark at the end of the file.
13898 @end itemize
13900 @noindent
13901 Text_IO can be used to read such non-standard text files but subprograms
13902 to do with line or page numbers do not have defined meanings.  In
13903 particular, a @code{FF} character that does not follow a @code{LF}
13904 character may or may not be treated as a page mark from the point of
13905 view of page and line numbering.  Every @code{LF} character is considered
13906 to end a line, and there is an implied @code{LF} character at the end of
13907 the file.
13909 @menu
13910 * Text_IO Stream Pointer Positioning::
13911 * Text_IO Reading and Writing Non-Regular Files::
13912 * Get_Immediate::
13913 * Treating Text_IO Files as Streams::
13914 * Text_IO Extensions::
13915 * Text_IO Facilities for Unbounded Strings::
13916 @end menu
13918 @node Text_IO Stream Pointer Positioning
13919 @subsection Stream Pointer Positioning
13921 @noindent
13922 @code{Ada.Text_IO} has a definition of current position for a file that
13923 is being read.  No internal buffering occurs in Text_IO, and usually the
13924 physical position in the stream used to implement the file corresponds
13925 to this logical position defined by Text_IO@.  There are two exceptions:
13927 @itemize @bullet
13928 @item
13929 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13930 is positioned past the @code{LF} (line mark) that precedes the page
13931 mark.  Text_IO maintains an internal flag so that subsequent read
13932 operations properly handle the logical position which is unchanged by
13933 the @code{End_Of_Page} call.
13935 @item
13936 After a call to @code{End_Of_File} that returns @code{True}, if the
13937 Text_IO file was positioned before the line mark at the end of file
13938 before the call, then the logical position is unchanged, but the stream
13939 is physically positioned right at the end of file (past the line mark,
13940 and past a possible page mark following the line mark.  Again Text_IO
13941 maintains internal flags so that subsequent read operations properly
13942 handle the logical position.
13943 @end itemize
13945 @noindent
13946 These discrepancies have no effect on the observable behavior of
13947 Text_IO, but if a single Ada stream is shared between a C program and
13948 Ada program, or shared (using @samp{shared=yes} in the form string)
13949 between two Ada files, then the difference may be observable in some
13950 situations.
13952 @node Text_IO Reading and Writing Non-Regular Files
13953 @subsection Reading and Writing Non-Regular Files
13955 @noindent
13956 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
13957 can be used for reading and writing.  Writing is not affected and the
13958 sequence of characters output is identical to the normal file case, but
13959 for reading, the behavior of Text_IO is modified to avoid undesirable
13960 look-ahead as follows:
13962 An input file that is not a regular file is considered to have no page
13963 marks.  Any @code{Ascii.FF} characters (the character normally used for a
13964 page mark) appearing in the file are considered to be data
13965 characters.  In particular:
13967 @itemize @bullet
13968 @item
13969 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13970 following a line mark.  If a page mark appears, it will be treated as a
13971 data character.
13973 @item
13974 This avoids the need to wait for an extra character to be typed or
13975 entered from the pipe to complete one of these operations.
13977 @item
13978 @code{End_Of_Page} always returns @code{False}
13980 @item
13981 @code{End_Of_File} will return @code{False} if there is a page mark at
13982 the end of the file.
13983 @end itemize
13985 @noindent
13986 Output to non-regular files is the same as for regular files.  Page marks
13987 may be written to non-regular files using @code{New_Page}, but as noted
13988 above they will not be treated as page marks on input if the output is
13989 piped to another Ada program.
13991 Another important discrepancy when reading non-regular files is that the end
13992 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
13993 pressing the @key{EOT} key,
13994 then end of file
13995 is signaled once (i.e.@: the test @code{End_Of_File}
13996 will yield @code{True}, or a read will
13997 raise @code{End_Error}), but then reading can resume
13998 to read data past that end of
13999 file indication, until another end of file indication is entered.
14001 @node Get_Immediate
14002 @subsection Get_Immediate
14003 @cindex Get_Immediate
14005 @noindent
14006 Get_Immediate returns the next character (including control characters)
14007 from the input file.  In particular, Get_Immediate will return LF or FF
14008 characters used as line marks or page marks.  Such operations leave the
14009 file positioned past the control character, and it is thus not treated
14010 as having its normal function.  This means that page, line and column
14011 counts after this kind of Get_Immediate call are set as though the mark
14012 did not occur.  In the case where a Get_Immediate leaves the file
14013 positioned between the line mark and page mark (which is not normally
14014 possible), it is undefined whether the FF character will be treated as a
14015 page mark.
14017 @node Treating Text_IO Files as Streams
14018 @subsection Treating Text_IO Files as Streams
14019 @cindex Stream files
14021 @noindent
14022 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14023 as a stream.  Data written to a Text_IO file in this stream mode is
14024 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
14025 16#0C# (@code{FF}), the resulting file may have non-standard
14026 format.  Similarly if read operations are used to read from a Text_IO
14027 file treated as a stream, then @code{LF} and @code{FF} characters may be
14028 skipped and the effect is similar to that described above for
14029 @code{Get_Immediate}.
14031 @node Text_IO Extensions
14032 @subsection Text_IO Extensions
14033 @cindex Text_IO extensions
14035 @noindent
14036 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14037 to the standard @code{Text_IO} package:
14039 @itemize @bullet
14040 @item function File_Exists (Name : String) return Boolean;
14041 Determines if a file of the given name exists.
14043 @item function Get_Line return String;
14044 Reads a string from the standard input file.  The value returned is exactly
14045 the length of the line that was read.
14047 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14048 Similar, except that the parameter File specifies the file from which
14049 the string is to be read.
14051 @end itemize
14053 @node Text_IO Facilities for Unbounded Strings
14054 @subsection Text_IO Facilities for Unbounded Strings
14055 @cindex Text_IO for unbounded strings
14056 @cindex Unbounded_String, Text_IO operations
14058 @noindent
14059 The package @code{Ada.Strings.Unbounded.Text_IO}
14060 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14061 subprograms useful for Text_IO operations on unbounded strings:
14063 @itemize @bullet
14065 @item function Get_Line (File : File_Type) return Unbounded_String;
14066 Reads a line from the specified file
14067 and returns the result as an unbounded string.
14069 @item procedure Put (File : File_Type; U : Unbounded_String);
14070 Writes the value of the given unbounded string to the specified file
14071 Similar to the effect of
14072 @code{Put (To_String (U))} except that an extra copy is avoided.
14074 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14075 Writes the value of the given unbounded string to the specified file,
14076 followed by a @code{New_Line}.
14077 Similar to the effect of @code{Put_Line (To_String (U))} except
14078 that an extra copy is avoided.
14079 @end itemize
14081 @noindent
14082 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14083 and is optional.  If the parameter is omitted, then the standard input or
14084 output file is referenced as appropriate.
14086 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14087 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14088 @code{Wide_Text_IO} functionality for unbounded wide strings.
14090 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14091 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14092 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14094 @node Wide_Text_IO
14095 @section Wide_Text_IO
14097 @noindent
14098 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14099 both input and output files may contain special sequences that represent
14100 wide character values.  The encoding scheme for a given file may be
14101 specified using a FORM parameter:
14103 @smallexample
14104 WCEM=@var{x}
14105 @end smallexample
14107 @noindent
14108 as part of the FORM string (WCEM = wide character encoding method),
14109 where @var{x} is one of the following characters
14111 @table @samp
14112 @item h
14113 Hex ESC encoding
14114 @item u
14115 Upper half encoding
14116 @item s
14117 Shift-JIS encoding
14118 @item e
14119 EUC Encoding
14120 @item 8
14121 UTF-8 encoding
14122 @item b
14123 Brackets encoding
14124 @end table
14126 @noindent
14127 The encoding methods match those that
14128 can be used in a source
14129 program, but there is no requirement that the encoding method used for
14130 the source program be the same as the encoding method used for files,
14131 and different files may use different encoding methods.
14133 The default encoding method for the standard files, and for opened files
14134 for which no WCEM parameter is given in the FORM string matches the
14135 wide character encoding specified for the main program (the default
14136 being brackets encoding if no coding method was specified with -gnatW).
14138 @table @asis
14139 @item Hex Coding
14140 In this encoding, a wide character is represented by a five character
14141 sequence:
14143 @smallexample
14144 ESC a b c d
14145 @end smallexample
14147 @noindent
14148 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14149 characters (using upper case letters) of the wide character code.  For
14150 example, ESC A345 is used to represent the wide character with code
14151 16#A345#.  This scheme is compatible with use of the full
14152 @code{Wide_Character} set.
14154 @item Upper Half Coding
14155 The wide character with encoding 16#abcd#, where the upper bit is on
14156 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14157 16#cd#.  The second byte may never be a format control character, but is
14158 not required to be in the upper half.  This method can be also used for
14159 shift-JIS or EUC where the internal coding matches the external coding.
14161 @item Shift JIS Coding
14162 A wide character is represented by a two character sequence 16#ab# and
14163 16#cd#, with the restrictions described for upper half encoding as
14164 described above.  The internal character code is the corresponding JIS
14165 character according to the standard algorithm for Shift-JIS
14166 conversion.  Only characters defined in the JIS code set table can be
14167 used with this encoding method.
14169 @item EUC Coding
14170 A wide character is represented by a two character sequence 16#ab# and
14171 16#cd#, with both characters being in the upper half.  The internal
14172 character code is the corresponding JIS character according to the EUC
14173 encoding algorithm.  Only characters defined in the JIS code set table
14174 can be used with this encoding method.
14176 @item UTF-8 Coding
14177 A wide character is represented using
14178 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14179 10646-1/Am.2.  Depending on the character value, the representation
14180 is a one, two, or three byte sequence:
14182 @smallexample
14183 16#0000#-16#007f#: 2#0xxxxxxx#
14184 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14185 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14186 @end smallexample
14188 @noindent
14189 where the @var{xxx} bits correspond to the left-padded bits of the
14190 16-bit character value.  Note that all lower half ASCII characters
14191 are represented as ASCII bytes and all upper half characters and
14192 other wide characters are represented as sequences of upper-half
14193 (The full UTF-8 scheme allows for encoding 31-bit characters as
14194 6-byte sequences, but in this implementation, all UTF-8 sequences
14195 of four or more bytes length will raise a Constraint_Error, as
14196 will all invalid UTF-8 sequences.)
14198 @item Brackets Coding
14199 In this encoding, a wide character is represented by the following eight
14200 character sequence:
14202 @smallexample
14203 [ " a b c d " ]
14204 @end smallexample
14206 @noindent
14207 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14208 characters (using uppercase letters) of the wide character code.  For
14209 example, @code{["A345"]} is used to represent the wide character with code
14210 @code{16#A345#}.
14211 This scheme is compatible with use of the full Wide_Character set.
14212 On input, brackets coding can also be used for upper half characters,
14213 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
14214 is only used for wide characters with a code greater than @code{16#FF#}.
14216 Note that brackets coding is not normally used in the context of
14217 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14218 a portable way of encoding source files. In the context of Wide_Text_IO
14219 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14220 any instance of the left bracket character other than to encode wide
14221 character values using the brackets encoding method. In practice it is
14222 expected that some standard wide character encoding method such
14223 as UTF-8 will be used for text input output.
14225 If brackets notation is used, then any occurrence of a left bracket
14226 in the input file which is not the start of a valid wide character
14227 sequence will cause Constraint_Error to be raised. It is possible to
14228 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14229 input will interpret this as a left bracket.
14231 However, when a left bracket is output, it will be output as a left bracket
14232 and not as ["5B"]. We make this decision because for normal use of
14233 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14234 brackets. For example, if we write:
14236 @smallexample
14237    Put_Line ("Start of output [first run]");
14238 @end smallexample
14240 @noindent
14241 we really do not want to have the left bracket in this message clobbered so
14242 that the output reads:
14244 @smallexample
14245    Start of output ["5B"]first run]
14246 @end smallexample
14248 @noindent
14249 In practice brackets encoding is reasonably useful for normal Put_Line use
14250 since we won't get confused between left brackets and wide character
14251 sequences in the output. But for input, or when files are written out
14252 and read back in, it really makes better sense to use one of the standard
14253 encoding methods such as UTF-8.
14255 @end table
14257 @noindent
14258 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14259 not all wide character
14260 values can be represented.  An attempt to output a character that cannot
14261 be represented using the encoding scheme for the file causes
14262 Constraint_Error to be raised.  An invalid wide character sequence on
14263 input also causes Constraint_Error to be raised.
14265 @menu
14266 * Wide_Text_IO Stream Pointer Positioning::
14267 * Wide_Text_IO Reading and Writing Non-Regular Files::
14268 @end menu
14270 @node Wide_Text_IO Stream Pointer Positioning
14271 @subsection Stream Pointer Positioning
14273 @noindent
14274 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14275 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
14276 case:
14278 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14279 normal lower ASCII set (i.e.@: a character in the range:
14281 @smallexample @c ada
14282 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14283 @end smallexample
14285 @noindent
14286 then although the logical position of the file pointer is unchanged by
14287 the @code{Look_Ahead} call, the stream is physically positioned past the
14288 wide character sequence.  Again this is to avoid the need for buffering
14289 or backup, and all @code{Wide_Text_IO} routines check the internal
14290 indication that this situation has occurred so that this is not visible
14291 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
14292 can be observed if the wide text file shares a stream with another file.
14294 @node Wide_Text_IO Reading and Writing Non-Regular Files
14295 @subsection Reading and Writing Non-Regular Files
14297 @noindent
14298 As in the case of Text_IO, when a non-regular file is read, it is
14299 assumed that the file contains no page marks (any form characters are
14300 treated as data characters), and @code{End_Of_Page} always returns
14301 @code{False}.  Similarly, the end of file indication is not sticky, so
14302 it is possible to read beyond an end of file.
14304 @node Wide_Wide_Text_IO
14305 @section Wide_Wide_Text_IO
14307 @noindent
14308 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14309 both input and output files may contain special sequences that represent
14310 wide wide character values.  The encoding scheme for a given file may be
14311 specified using a FORM parameter:
14313 @smallexample
14314 WCEM=@var{x}
14315 @end smallexample
14317 @noindent
14318 as part of the FORM string (WCEM = wide character encoding method),
14319 where @var{x} is one of the following characters
14321 @table @samp
14322 @item h
14323 Hex ESC encoding
14324 @item u
14325 Upper half encoding
14326 @item s
14327 Shift-JIS encoding
14328 @item e
14329 EUC Encoding
14330 @item 8
14331 UTF-8 encoding
14332 @item b
14333 Brackets encoding
14334 @end table
14336 @noindent
14337 The encoding methods match those that
14338 can be used in a source
14339 program, but there is no requirement that the encoding method used for
14340 the source program be the same as the encoding method used for files,
14341 and different files may use different encoding methods.
14343 The default encoding method for the standard files, and for opened files
14344 for which no WCEM parameter is given in the FORM string matches the
14345 wide character encoding specified for the main program (the default
14346 being brackets encoding if no coding method was specified with -gnatW).
14348 @table @asis
14350 @item UTF-8 Coding
14351 A wide character is represented using
14352 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14353 10646-1/Am.2.  Depending on the character value, the representation
14354 is a one, two, three, or four byte sequence:
14356 @smallexample
14357 16#000000#-16#00007f#: 2#0xxxxxxx#
14358 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14359 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14360 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14361 @end smallexample
14363 @noindent
14364 where the @var{xxx} bits correspond to the left-padded bits of the
14365 21-bit character value.  Note that all lower half ASCII characters
14366 are represented as ASCII bytes and all upper half characters and
14367 other wide characters are represented as sequences of upper-half
14368 characters.
14370 @item Brackets Coding
14371 In this encoding, a wide wide character is represented by the following eight
14372 character sequence if is in wide character range
14374 @smallexample
14375 [ " a b c d " ]
14376 @end smallexample
14378 and by the following ten character sequence if not
14380 @smallexample
14381 [ " a b c d e f " ]
14382 @end smallexample
14384 @noindent
14385 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14386 are the four or six hexadecimal
14387 characters (using uppercase letters) of the wide wide character code.  For
14388 example, @code{["01A345"]} is used to represent the wide wide character
14389 with code @code{16#01A345#}.
14391 This scheme is compatible with use of the full Wide_Wide_Character set.
14392 On input, brackets coding can also be used for upper half characters,
14393 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
14394 is only used for wide characters with a code greater than @code{16#FF#}.
14396 @end table
14398 @noindent
14399 If is also possible to use the other Wide_Character encoding methods,
14400 such as Shift-JIS, but the other schemes cannot support the full range
14401 of wide wide characters.
14402 An attempt to output a character that cannot
14403 be represented using the encoding scheme for the file causes
14404 Constraint_Error to be raised.  An invalid wide character sequence on
14405 input also causes Constraint_Error to be raised.
14407 @menu
14408 * Wide_Wide_Text_IO Stream Pointer Positioning::
14409 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14410 @end menu
14412 @node Wide_Wide_Text_IO Stream Pointer Positioning
14413 @subsection Stream Pointer Positioning
14415 @noindent
14416 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14417 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
14418 case:
14420 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14421 normal lower ASCII set (i.e.@: a character in the range:
14423 @smallexample @c ada
14424 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14425 @end smallexample
14427 @noindent
14428 then although the logical position of the file pointer is unchanged by
14429 the @code{Look_Ahead} call, the stream is physically positioned past the
14430 wide character sequence.  Again this is to avoid the need for buffering
14431 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14432 indication that this situation has occurred so that this is not visible
14433 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
14434 can be observed if the wide text file shares a stream with another file.
14436 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14437 @subsection Reading and Writing Non-Regular Files
14439 @noindent
14440 As in the case of Text_IO, when a non-regular file is read, it is
14441 assumed that the file contains no page marks (any form characters are
14442 treated as data characters), and @code{End_Of_Page} always returns
14443 @code{False}.  Similarly, the end of file indication is not sticky, so
14444 it is possible to read beyond an end of file.
14446 @node Stream_IO
14447 @section Stream_IO
14449 @noindent
14450 A stream file is a sequence of bytes, where individual elements are
14451 written to the file as described in the Ada Reference Manual.  The type
14452 @code{Stream_Element} is simply a byte.  There are two ways to read or
14453 write a stream file.
14455 @itemize @bullet
14456 @item
14457 The operations @code{Read} and @code{Write} directly read or write a
14458 sequence of stream elements with no control information.
14460 @item
14461 The stream attributes applied to a stream file transfer data in the
14462 manner described for stream attributes.
14463 @end itemize
14465 @node Text Translation
14466 @section Text Translation
14468 @noindent
14469 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14470 passed to Text_IO.Create and Text_IO.Open:
14471 @samp{Text_Translation=@var{Yes}} is the default, which means to
14472 translate LF to/from CR/LF on Windows systems.
14473 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14474 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14475 may be used to create Unix-style files on
14476 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14477 systems.
14479 @node Shared Files
14480 @section Shared Files
14482 @noindent
14483 Section A.14 of the Ada Reference Manual allows implementations to
14484 provide a wide variety of behavior if an attempt is made to access the
14485 same external file with two or more internal files.
14487 To provide a full range of functionality, while at the same time
14488 minimizing the problems of portability caused by this implementation
14489 dependence, GNAT handles file sharing as follows:
14491 @itemize @bullet
14492 @item
14493 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14494 to open two or more files with the same full name is considered an error
14495 and is not supported.  The exception @code{Use_Error} will be
14496 raised.  Note that a file that is not explicitly closed by the program
14497 remains open until the program terminates.
14499 @item
14500 If the form parameter @samp{shared=no} appears in the form string, the
14501 file can be opened or created with its own separate stream identifier,
14502 regardless of whether other files sharing the same external file are
14503 opened.  The exact effect depends on how the C stream routines handle
14504 multiple accesses to the same external files using separate streams.
14506 @item
14507 If the form parameter @samp{shared=yes} appears in the form string for
14508 each of two or more files opened using the same full name, the same
14509 stream is shared between these files, and the semantics are as described
14510 in Ada Reference Manual, Section A.14.
14511 @end itemize
14513 @noindent
14514 When a program that opens multiple files with the same name is ported
14515 from another Ada compiler to GNAT, the effect will be that
14516 @code{Use_Error} is raised.
14518 The documentation of the original compiler and the documentation of the
14519 program should then be examined to determine if file sharing was
14520 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14521 and @code{Create} calls as required.
14523 When a program is ported from GNAT to some other Ada compiler, no
14524 special attention is required unless the @samp{shared=@var{xxx}} form
14525 parameter is used in the program.  In this case, you must examine the
14526 documentation of the new compiler to see if it supports the required
14527 file sharing semantics, and form strings modified appropriately.  Of
14528 course it may be the case that the program cannot be ported if the
14529 target compiler does not support the required functionality.  The best
14530 approach in writing portable code is to avoid file sharing (and hence
14531 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14532 completely.
14534 One common use of file sharing in Ada 83 is the use of instantiations of
14535 Sequential_IO on the same file with different types, to achieve
14536 heterogeneous input-output.  Although this approach will work in GNAT if
14537 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14538 for this purpose (using the stream attributes)
14540 @node Filenames encoding
14541 @section Filenames encoding
14543 @noindent
14544 An encoding form parameter can be used to specify the filename
14545 encoding @samp{encoding=@var{xxx}}.
14547 @itemize @bullet
14548 @item
14549 If the form parameter @samp{encoding=utf8} appears in the form string, the
14550 filename must be encoded in UTF-8.
14552 @item
14553 If the form parameter @samp{encoding=8bits} appears in the form
14554 string, the filename must be a standard 8bits string.
14555 @end itemize
14557 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14558 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14559 variable. And if not set @samp{utf8} is assumed.
14561 @table @samp
14562 @item CP_ACP
14563 The current system Windows ANSI code page.
14564 @item CP_UTF8
14565 UTF-8 encoding
14566 @end table
14568 This encoding form parameter is only supported on the Windows
14569 platform. On the other Operating Systems the run-time is supporting
14570 UTF-8 natively.
14572 @node Open Modes
14573 @section Open Modes
14575 @noindent
14576 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14577 using the mode shown in the following table:
14579 @sp 2
14580 @center @code{Open} and @code{Create} Call Modes
14581 @smallexample
14582                                @b{OPEN }           @b{CREATE}
14583 Append_File                    "r+"             "w+"
14584 In_File                        "r"              "w+"
14585 Out_File (Direct_IO)           "r+"             "w"
14586 Out_File (all other cases)     "w"              "w"
14587 Inout_File                     "r+"             "w+"
14588 @end smallexample
14590 @noindent
14591 If text file translation is required, then either @samp{b} or @samp{t}
14592 is added to the mode, depending on the setting of Text.  Text file
14593 translation refers to the mapping of CR/LF sequences in an external file
14594 to LF characters internally.  This mapping only occurs in DOS and
14595 DOS-like systems, and is not relevant to other systems.
14597 A special case occurs with Stream_IO@.  As shown in the above table, the
14598 file is initially opened in @samp{r} or @samp{w} mode for the
14599 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
14600 subsequently requires switching from reading to writing or vice-versa,
14601 then the file is reopened in @samp{r+} mode to permit the required operation.
14603 @node Operations on C Streams
14604 @section Operations on C Streams
14605 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14606 access to the C library functions for operations on C streams:
14608 @smallexample @c adanocomment
14609 package Interfaces.C_Streams is
14610   -- Note: the reason we do not use the types that are in
14611   -- Interfaces.C is that we want to avoid dragging in the
14612   -- code in this unit if possible.
14613   subtype chars is System.Address;
14614   -- Pointer to null-terminated array of characters
14615   subtype FILEs is System.Address;
14616   -- Corresponds to the C type FILE*
14617   subtype voids is System.Address;
14618   -- Corresponds to the C type void*
14619   subtype int is Integer;
14620   subtype long is Long_Integer;
14621   -- Note: the above types are subtypes deliberately, and it
14622   -- is part of this spec that the above correspondences are
14623   -- guaranteed.  This means that it is legitimate to, for
14624   -- example, use Integer instead of int.  We provide these
14625   -- synonyms for clarity, but in some cases it may be
14626   -- convenient to use the underlying types (for example to
14627   -- avoid an unnecessary dependency of a spec on the spec
14628   -- of this unit).
14629   type size_t is mod 2 ** Standard'Address_Size;
14630   NULL_Stream : constant FILEs;
14631   -- Value returned (NULL in C) to indicate an
14632   -- fdopen/fopen/tmpfile error
14633   ----------------------------------
14634   -- Constants Defined in stdio.h --
14635   ----------------------------------
14636   EOF : constant int;
14637   -- Used by a number of routines to indicate error or
14638   -- end of file
14639   IOFBF : constant int;
14640   IOLBF : constant int;
14641   IONBF : constant int;
14642   -- Used to indicate buffering mode for setvbuf call
14643   SEEK_CUR : constant int;
14644   SEEK_END : constant int;
14645   SEEK_SET : constant int;
14646   -- Used to indicate origin for fseek call
14647   function stdin return FILEs;
14648   function stdout return FILEs;
14649   function stderr return FILEs;
14650   -- Streams associated with standard files
14651   --------------------------
14652   -- Standard C functions --
14653   --------------------------
14654   -- The functions selected below are ones that are
14655   -- available in UNIX (but not necessarily in ANSI C).
14656   -- These are very thin interfaces
14657   -- which copy exactly the C headers.  For more
14658   -- documentation on these functions, see the Microsoft C
14659   -- "Run-Time Library Reference" (Microsoft Press, 1990,
14660   -- ISBN 1-55615-225-6), which includes useful information
14661   -- on system compatibility.
14662   procedure clearerr (stream : FILEs);
14663   function fclose (stream : FILEs) return int;
14664   function fdopen (handle : int; mode : chars) return FILEs;
14665   function feof (stream : FILEs) return int;
14666   function ferror (stream : FILEs) return int;
14667   function fflush (stream : FILEs) return int;
14668   function fgetc (stream : FILEs) return int;
14669   function fgets (strng : chars; n : int; stream : FILEs)
14670       return chars;
14671   function fileno (stream : FILEs) return int;
14672   function fopen (filename : chars; Mode : chars)
14673       return FILEs;
14674   -- Note: to maintain target independence, use
14675   -- text_translation_required, a boolean variable defined in
14676   -- a-sysdep.c to deal with the target dependent text
14677   -- translation requirement.  If this variable is set,
14678   -- then  b/t should be appended to the standard mode
14679   -- argument to set the text translation mode off or on
14680   -- as required.
14681   function fputc (C : int; stream : FILEs) return int;
14682   function fputs (Strng : chars; Stream : FILEs) return int;
14683   function fread
14684      (buffer : voids;
14685       size : size_t;
14686       count : size_t;
14687       stream : FILEs)
14688       return size_t;
14689   function freopen
14690      (filename : chars;
14691       mode : chars;
14692       stream : FILEs)
14693       return FILEs;
14694   function fseek
14695      (stream : FILEs;
14696       offset : long;
14697       origin : int)
14698       return int;
14699   function ftell (stream : FILEs) return long;
14700   function fwrite
14701      (buffer : voids;
14702       size : size_t;
14703       count : size_t;
14704       stream : FILEs)
14705       return size_t;
14706   function isatty (handle : int) return int;
14707   procedure mktemp (template : chars);
14708   -- The return value (which is just a pointer to template)
14709   -- is discarded
14710   procedure rewind (stream : FILEs);
14711   function rmtmp return int;
14712   function setvbuf
14713      (stream : FILEs;
14714       buffer : chars;
14715       mode : int;
14716       size : size_t)
14717       return int;
14719   function tmpfile return FILEs;
14720   function ungetc (c : int; stream : FILEs) return int;
14721   function unlink (filename : chars) return int;
14722   ---------------------
14723   -- Extra functions --
14724   ---------------------
14725   -- These functions supply slightly thicker bindings than
14726   -- those above.  They are derived from functions in the
14727   -- C Run-Time Library, but may do a bit more work than
14728   -- just directly calling one of the Library functions.
14729   function is_regular_file (handle : int) return int;
14730   -- Tests if given handle is for a regular file (result 1)
14731   -- or for a non-regular file (pipe or device, result 0).
14732   ---------------------------------
14733   -- Control of Text/Binary Mode --
14734   ---------------------------------
14735   -- If text_translation_required is true, then the following
14736   -- functions may be used to dynamically switch a file from
14737   -- binary to text mode or vice versa.  These functions have
14738   -- no effect if text_translation_required is false (i.e.@: in
14739   -- normal UNIX mode).  Use fileno to get a stream handle.
14740   procedure set_binary_mode (handle : int);
14741   procedure set_text_mode (handle : int);
14742   ----------------------------
14743   -- Full Path Name support --
14744   ----------------------------
14745   procedure full_name (nam : chars; buffer : chars);
14746   -- Given a NUL terminated string representing a file
14747   -- name, returns in buffer a NUL terminated string
14748   -- representing the full path name for the file name.
14749   -- On systems where it is relevant the   drive is also
14750   -- part of the full path name.  It is the responsibility
14751   -- of the caller to pass an actual parameter for buffer
14752   -- that is big enough for any full path name.  Use
14753   -- max_path_len given below as the size of buffer.
14754   max_path_len : integer;
14755   -- Maximum length of an allowable full path name on the
14756   -- system, including a terminating NUL character.
14757 end Interfaces.C_Streams;
14758 @end smallexample
14760 @node Interfacing to C Streams
14761 @section Interfacing to C Streams
14763 @noindent
14764 The packages in this section permit interfacing Ada files to C Stream
14765 operations.
14767 @smallexample @c ada
14768  with Interfaces.C_Streams;
14769  package Ada.Sequential_IO.C_Streams is
14770     function C_Stream (F : File_Type)
14771        return Interfaces.C_Streams.FILEs;
14772     procedure Open
14773       (File : in out File_Type;
14774        Mode : in File_Mode;
14775        C_Stream : in Interfaces.C_Streams.FILEs;
14776        Form : in String := "");
14777  end Ada.Sequential_IO.C_Streams;
14779   with Interfaces.C_Streams;
14780   package Ada.Direct_IO.C_Streams is
14781      function C_Stream (F : File_Type)
14782         return Interfaces.C_Streams.FILEs;
14783      procedure Open
14784        (File : in out File_Type;
14785         Mode : in File_Mode;
14786         C_Stream : in Interfaces.C_Streams.FILEs;
14787         Form : in String := "");
14788   end Ada.Direct_IO.C_Streams;
14790   with Interfaces.C_Streams;
14791   package Ada.Text_IO.C_Streams is
14792      function C_Stream (F : File_Type)
14793         return Interfaces.C_Streams.FILEs;
14794      procedure Open
14795        (File : in out File_Type;
14796         Mode : in File_Mode;
14797         C_Stream : in Interfaces.C_Streams.FILEs;
14798         Form : in String := "");
14799   end Ada.Text_IO.C_Streams;
14801   with Interfaces.C_Streams;
14802   package Ada.Wide_Text_IO.C_Streams is
14803      function C_Stream (F : File_Type)
14804         return Interfaces.C_Streams.FILEs;
14805      procedure Open
14806        (File : in out File_Type;
14807         Mode : in File_Mode;
14808         C_Stream : in Interfaces.C_Streams.FILEs;
14809         Form : in String := "");
14810  end Ada.Wide_Text_IO.C_Streams;
14812   with Interfaces.C_Streams;
14813   package Ada.Wide_Wide_Text_IO.C_Streams is
14814      function C_Stream (F : File_Type)
14815         return Interfaces.C_Streams.FILEs;
14816      procedure Open
14817        (File : in out File_Type;
14818         Mode : in File_Mode;
14819         C_Stream : in Interfaces.C_Streams.FILEs;
14820         Form : in String := "");
14821  end Ada.Wide_Wide_Text_IO.C_Streams;
14823  with Interfaces.C_Streams;
14824  package Ada.Stream_IO.C_Streams is
14825     function C_Stream (F : File_Type)
14826        return Interfaces.C_Streams.FILEs;
14827     procedure Open
14828       (File : in out File_Type;
14829        Mode : in File_Mode;
14830        C_Stream : in Interfaces.C_Streams.FILEs;
14831        Form : in String := "");
14832  end Ada.Stream_IO.C_Streams;
14833 @end smallexample
14835 @noindent
14836 In each of these six packages, the @code{C_Stream} function obtains the
14837 @code{FILE} pointer from a currently opened Ada file.  It is then
14838 possible to use the @code{Interfaces.C_Streams} package to operate on
14839 this stream, or the stream can be passed to a C program which can
14840 operate on it directly.  Of course the program is responsible for
14841 ensuring that only appropriate sequences of operations are executed.
14843 One particular use of relevance to an Ada program is that the
14844 @code{setvbuf} function can be used to control the buffering of the
14845 stream used by an Ada file.  In the absence of such a call the standard
14846 default buffering is used.
14848 The @code{Open} procedures in these packages open a file giving an
14849 existing C Stream instead of a file name.  Typically this stream is
14850 imported from a C program, allowing an Ada file to operate on an
14851 existing C file.
14853 @node The GNAT Library
14854 @chapter The GNAT Library
14856 @noindent
14857 The GNAT library contains a number of general and special purpose packages.
14858 It represents functionality that the GNAT developers have found useful, and
14859 which is made available to GNAT users.  The packages described here are fully
14860 supported, and upwards compatibility will be maintained in future releases,
14861 so you can use these facilities with the confidence that the same functionality
14862 will be available in future releases.
14864 The chapter here simply gives a brief summary of the facilities available.
14865 The full documentation is found in the spec file for the package.  The full
14866 sources of these library packages, including both spec and body, are provided
14867 with all GNAT releases.  For example, to find out the full specifications of
14868 the SPITBOL pattern matching capability, including a full tutorial and
14869 extensive examples, look in the @file{g-spipat.ads} file in the library.
14871 For each entry here, the package name (as it would appear in a @code{with}
14872 clause) is given, followed by the name of the corresponding spec file in
14873 parentheses.  The packages are children in four hierarchies, @code{Ada},
14874 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14875 GNAT-specific hierarchy.
14877 Note that an application program should only use packages in one of these
14878 four hierarchies if the package is defined in the Ada Reference Manual,
14879 or is listed in this section of the GNAT Programmers Reference Manual.
14880 All other units should be considered internal implementation units and
14881 should not be directly @code{with}'ed by application code.  The use of
14882 a @code{with} statement that references one of these internal implementation
14883 units makes an application potentially dependent on changes in versions
14884 of GNAT, and will generate a warning message.
14886 @menu
14887 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14888 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14889 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14890 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14891 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14892 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14893 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14894 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14895 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14896 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14897 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14898 * Ada.Command_Line.Environment (a-colien.ads)::
14899 * Ada.Command_Line.Remove (a-colire.ads)::
14900 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14901 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14902 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14903 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14904 * Ada.Exceptions.Traceback (a-exctra.ads)::
14905 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14906 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14907 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14908 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14909 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14910 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14911 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14912 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14913 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14914 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14915 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14916 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14917 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14918 * GNAT.Altivec (g-altive.ads)::
14919 * GNAT.Altivec.Conversions (g-altcon.ads)::
14920 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14921 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14922 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14923 * GNAT.Array_Split (g-arrspl.ads)::
14924 * GNAT.AWK (g-awk.ads)::
14925 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14926 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14927 * GNAT.Bubble_Sort (g-bubsor.ads)::
14928 * GNAT.Bubble_Sort_A (g-busora.ads)::
14929 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14930 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14931 * GNAT.Byte_Swapping (g-bytswa.ads)::
14932 * GNAT.Calendar (g-calend.ads)::
14933 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14934 * GNAT.Case_Util (g-casuti.ads)::
14935 * GNAT.CGI (g-cgi.ads)::
14936 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14937 * GNAT.CGI.Debug (g-cgideb.ads)::
14938 * GNAT.Command_Line (g-comlin.ads)::
14939 * GNAT.Compiler_Version (g-comver.ads)::
14940 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14941 * GNAT.CRC32 (g-crc32.ads)::
14942 * GNAT.Current_Exception (g-curexc.ads)::
14943 * GNAT.Debug_Pools (g-debpoo.ads)::
14944 * GNAT.Debug_Utilities (g-debuti.ads)::
14945 * GNAT.Decode_String (g-decstr.ads)::
14946 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14947 * GNAT.Directory_Operations (g-dirope.ads)::
14948 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14949 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14950 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14951 * GNAT.Encode_String (g-encstr.ads)::
14952 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14953 * GNAT.Exception_Actions (g-excact.ads)::
14954 * GNAT.Exception_Traces (g-exctra.ads)::
14955 * GNAT.Exceptions (g-except.ads)::
14956 * GNAT.Expect (g-expect.ads)::
14957 * GNAT.Expect.TTY (g-exptty.ads)::
14958 * GNAT.Float_Control (g-flocon.ads)::
14959 * GNAT.Heap_Sort (g-heasor.ads)::
14960 * GNAT.Heap_Sort_A (g-hesora.ads)::
14961 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14962 * GNAT.HTable (g-htable.ads)::
14963 * GNAT.IO (g-io.ads)::
14964 * GNAT.IO_Aux (g-io_aux.ads)::
14965 * GNAT.Lock_Files (g-locfil.ads)::
14966 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14967 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14968 * GNAT.MD5 (g-md5.ads)::
14969 * GNAT.Memory_Dump (g-memdum.ads)::
14970 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14971 * GNAT.OS_Lib (g-os_lib.ads)::
14972 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14973 * GNAT.Random_Numbers (g-rannum.ads)::
14974 * GNAT.Regexp (g-regexp.ads)::
14975 * GNAT.Registry (g-regist.ads)::
14976 * GNAT.Regpat (g-regpat.ads)::
14977 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14978 * GNAT.Semaphores (g-semaph.ads)::
14979 * GNAT.Serial_Communications (g-sercom.ads)::
14980 * GNAT.SHA1 (g-sha1.ads)::
14981 * GNAT.SHA224 (g-sha224.ads)::
14982 * GNAT.SHA256 (g-sha256.ads)::
14983 * GNAT.SHA384 (g-sha384.ads)::
14984 * GNAT.SHA512 (g-sha512.ads)::
14985 * GNAT.Signals (g-signal.ads)::
14986 * GNAT.Sockets (g-socket.ads)::
14987 * GNAT.Source_Info (g-souinf.ads)::
14988 * GNAT.Spelling_Checker (g-speche.ads)::
14989 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14990 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14991 * GNAT.Spitbol (g-spitbo.ads)::
14992 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14993 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14994 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14995 * GNAT.SSE (g-sse.ads)::
14996 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14997 * GNAT.Strings (g-string.ads)::
14998 * GNAT.String_Split (g-strspl.ads)::
14999 * GNAT.Table (g-table.ads)::
15000 * GNAT.Task_Lock (g-tasloc.ads)::
15001 * GNAT.Threads (g-thread.ads)::
15002 * GNAT.Time_Stamp (g-timsta.ads)::
15003 * GNAT.Traceback (g-traceb.ads)::
15004 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15005 * GNAT.UTF_32 (g-utf_32.ads)::
15006 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15007 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15008 * GNAT.Wide_String_Split (g-wistsp.ads)::
15009 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15010 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15011 * Interfaces.C.Extensions (i-cexten.ads)::
15012 * Interfaces.C.Streams (i-cstrea.ads)::
15013 * Interfaces.CPP (i-cpp.ads)::
15014 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15015 * Interfaces.VxWorks (i-vxwork.ads)::
15016 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15017 * System.Address_Image (s-addima.ads)::
15018 * System.Assertions (s-assert.ads)::
15019 * System.Memory (s-memory.ads)::
15020 * System.Partition_Interface (s-parint.ads)::
15021 * System.Pool_Global (s-pooglo.ads)::
15022 * System.Pool_Local (s-pooloc.ads)::
15023 * System.Restrictions (s-restri.ads)::
15024 * System.Rident (s-rident.ads)::
15025 * System.Strings.Stream_Ops (s-ststop.ads)::
15026 * System.Task_Info (s-tasinf.ads)::
15027 * System.Wch_Cnv (s-wchcnv.ads)::
15028 * System.Wch_Con (s-wchcon.ads)::
15029 @end menu
15031 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15032 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15033 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15034 @cindex Latin_9 constants for Character
15036 @noindent
15037 This child of @code{Ada.Characters}
15038 provides a set of definitions corresponding to those in the
15039 RM-defined package @code{Ada.Characters.Latin_1} but with the
15040 few modifications required for @code{Latin-9}
15041 The provision of such a package
15042 is specifically authorized by the Ada Reference Manual
15043 (RM A.3.3(27)).
15045 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15046 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15047 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15048 @cindex Latin_1 constants for Wide_Character
15050 @noindent
15051 This child of @code{Ada.Characters}
15052 provides a set of definitions corresponding to those in the
15053 RM-defined package @code{Ada.Characters.Latin_1} but with the
15054 types of the constants being @code{Wide_Character}
15055 instead of @code{Character}.  The provision of such a package
15056 is specifically authorized by the Ada Reference Manual
15057 (RM A.3.3(27)).
15059 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15060 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15061 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15062 @cindex Latin_9 constants for Wide_Character
15064 @noindent
15065 This child of @code{Ada.Characters}
15066 provides a set of definitions corresponding to those in the
15067 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15068 types of the constants being @code{Wide_Character}
15069 instead of @code{Character}.  The provision of such a package
15070 is specifically authorized by the Ada Reference Manual
15071 (RM A.3.3(27)).
15073 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15074 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15075 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15076 @cindex Latin_1 constants for Wide_Wide_Character
15078 @noindent
15079 This child of @code{Ada.Characters}
15080 provides a set of definitions corresponding to those in the
15081 RM-defined package @code{Ada.Characters.Latin_1} but with the
15082 types of the constants being @code{Wide_Wide_Character}
15083 instead of @code{Character}.  The provision of such a package
15084 is specifically authorized by the Ada Reference Manual
15085 (RM A.3.3(27)).
15087 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15088 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15089 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15090 @cindex Latin_9 constants for Wide_Wide_Character
15092 @noindent
15093 This child of @code{Ada.Characters}
15094 provides a set of definitions corresponding to those in the
15095 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15096 types of the constants being @code{Wide_Wide_Character}
15097 instead of @code{Character}.  The provision of such a package
15098 is specifically authorized by the Ada Reference Manual
15099 (RM A.3.3(27)).
15101 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15102 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15103 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15104 @cindex Formal container for doubly linked lists
15106 @noindent
15107 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15108 container for doubly linked lists, meant to facilitate formal verification of
15109 code using such containers.
15111 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15112 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15113 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15114 @cindex Formal container for hashed maps
15116 @noindent
15117 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15118 container for hashed maps, meant to facilitate formal verification of
15119 code using such containers.
15121 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15122 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15123 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15124 @cindex Formal container for hashed sets
15126 @noindent
15127 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15128 container for hashed sets, meant to facilitate formal verification of
15129 code using such containers.
15131 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15132 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15133 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15134 @cindex Formal container for ordered maps
15136 @noindent
15137 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15138 container for ordered maps, meant to facilitate formal verification of
15139 code using such containers.
15141 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15142 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15143 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15144 @cindex Formal container for ordered sets
15146 @noindent
15147 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15148 container for ordered sets, meant to facilitate formal verification of
15149 code using such containers.
15151 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15152 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15153 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15154 @cindex Formal container for vectors
15156 @noindent
15157 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15158 container for vectors, meant to facilitate formal verification of
15159 code using such containers.
15161 @node Ada.Command_Line.Environment (a-colien.ads)
15162 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15163 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15164 @cindex Environment entries
15166 @noindent
15167 This child of @code{Ada.Command_Line}
15168 provides a mechanism for obtaining environment values on systems
15169 where this concept makes sense.
15171 @node Ada.Command_Line.Remove (a-colire.ads)
15172 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15173 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15174 @cindex Removing command line arguments
15175 @cindex Command line, argument removal
15177 @noindent
15178 This child of @code{Ada.Command_Line}
15179 provides a mechanism for logically removing
15180 arguments from the argument list.  Once removed, an argument is not visible
15181 to further calls on the subprograms in @code{Ada.Command_Line} will not
15182 see the removed argument.
15184 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15185 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15186 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15187 @cindex Response file for command line
15188 @cindex Command line, response file
15189 @cindex Command line, handling long command lines
15191 @noindent
15192 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15193 getting command line arguments from a text file, called a "response file".
15194 Using a response file allow passing a set of arguments to an executable longer
15195 than the maximum allowed by the system on the command line.
15197 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15198 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15199 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15200 @cindex C Streams, Interfacing with Direct_IO
15202 @noindent
15203 This package provides subprograms that allow interfacing between
15204 C streams and @code{Direct_IO}.  The stream identifier can be
15205 extracted from a file opened on the Ada side, and an Ada file
15206 can be constructed from a stream opened on the C side.
15208 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15209 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15210 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15211 @cindex Null_Occurrence, testing for
15213 @noindent
15214 This child subprogram provides a way of testing for the null
15215 exception occurrence (@code{Null_Occurrence}) without raising
15216 an exception.
15218 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15219 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15220 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15221 @cindex Null_Occurrence, testing for
15223 @noindent
15224 This child subprogram is used for handling otherwise unhandled
15225 exceptions (hence the name last chance), and perform clean ups before
15226 terminating the program. Note that this subprogram never returns.
15228 @node Ada.Exceptions.Traceback (a-exctra.ads)
15229 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15230 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15231 @cindex Traceback for Exception Occurrence
15233 @noindent
15234 This child package provides the subprogram (@code{Tracebacks}) to
15235 give a traceback array of addresses based on an exception
15236 occurrence.
15238 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15239 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15240 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15241 @cindex C Streams, Interfacing with Sequential_IO
15243 @noindent
15244 This package provides subprograms that allow interfacing between
15245 C streams and @code{Sequential_IO}.  The stream identifier can be
15246 extracted from a file opened on the Ada side, and an Ada file
15247 can be constructed from a stream opened on the C side.
15249 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15250 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15251 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15252 @cindex C Streams, Interfacing with Stream_IO
15254 @noindent
15255 This package provides subprograms that allow interfacing between
15256 C streams and @code{Stream_IO}.  The stream identifier can be
15257 extracted from a file opened on the Ada side, and an Ada file
15258 can be constructed from a stream opened on the C side.
15260 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15261 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15262 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15263 @cindex @code{Unbounded_String}, IO support
15264 @cindex @code{Text_IO}, extensions for unbounded strings
15266 @noindent
15267 This package provides subprograms for Text_IO for unbounded
15268 strings, avoiding the necessity for an intermediate operation
15269 with ordinary strings.
15271 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15272 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15273 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15274 @cindex @code{Unbounded_Wide_String}, IO support
15275 @cindex @code{Text_IO}, extensions for unbounded wide strings
15277 @noindent
15278 This package provides subprograms for Text_IO for unbounded
15279 wide strings, avoiding the necessity for an intermediate operation
15280 with ordinary wide strings.
15282 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15283 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15284 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15285 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15286 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15288 @noindent
15289 This package provides subprograms for Text_IO for unbounded
15290 wide wide strings, avoiding the necessity for an intermediate operation
15291 with ordinary wide wide strings.
15293 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15294 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15295 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15296 @cindex C Streams, Interfacing with @code{Text_IO}
15298 @noindent
15299 This package provides subprograms that allow interfacing between
15300 C streams and @code{Text_IO}.  The stream identifier can be
15301 extracted from a file opened on the Ada side, and an Ada file
15302 can be constructed from a stream opened on the C side.
15304 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15305 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15306 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15307 @cindex @code{Text_IO} resetting standard files
15309 @noindent
15310 This procedure is used to reset the status of the standard files used
15311 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
15312 embedded application) where the status of the files may change during
15313 execution (for example a standard input file may be redefined to be
15314 interactive).
15316 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15317 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15318 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15319 @cindex Unicode categorization, Wide_Character
15321 @noindent
15322 This package provides subprograms that allow categorization of
15323 Wide_Character values according to Unicode categories.
15325 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15326 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15327 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15328 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15330 @noindent
15331 This package provides subprograms that allow interfacing between
15332 C streams and @code{Wide_Text_IO}.  The stream identifier can be
15333 extracted from a file opened on the Ada side, and an Ada file
15334 can be constructed from a stream opened on the C side.
15336 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15337 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15338 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15339 @cindex @code{Wide_Text_IO} resetting standard files
15341 @noindent
15342 This procedure is used to reset the status of the standard files used
15343 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
15344 embedded application) where the status of the files may change during
15345 execution (for example a standard input file may be redefined to be
15346 interactive).
15348 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15349 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15350 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15351 @cindex Unicode categorization, Wide_Wide_Character
15353 @noindent
15354 This package provides subprograms that allow categorization of
15355 Wide_Wide_Character values according to Unicode categories.
15357 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15358 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15359 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15360 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15362 @noindent
15363 This package provides subprograms that allow interfacing between
15364 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
15365 extracted from a file opened on the Ada side, and an Ada file
15366 can be constructed from a stream opened on the C side.
15368 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15369 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15370 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15371 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15373 @noindent
15374 This procedure is used to reset the status of the standard files used
15375 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15376 restart in an embedded application) where the status of the files may
15377 change during execution (for example a standard input file may be
15378 redefined to be interactive).
15380 @node GNAT.Altivec (g-altive.ads)
15381 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15382 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15383 @cindex AltiVec
15385 @noindent
15386 This is the root package of the GNAT AltiVec binding. It provides
15387 definitions of constants and types common to all the versions of the
15388 binding.
15390 @node GNAT.Altivec.Conversions (g-altcon.ads)
15391 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15392 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15393 @cindex AltiVec
15395 @noindent
15396 This package provides the Vector/View conversion routines.
15398 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15399 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15400 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15401 @cindex AltiVec
15403 @noindent
15404 This package exposes the Ada interface to the AltiVec operations on
15405 vector objects. A soft emulation is included by default in the GNAT
15406 library. The hard binding is provided as a separate package. This unit
15407 is common to both bindings.
15409 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15410 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15411 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15412 @cindex AltiVec
15414 @noindent
15415 This package exposes the various vector types part of the Ada binding
15416 to AltiVec facilities.
15418 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15419 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15420 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15421 @cindex AltiVec
15423 @noindent
15424 This package provides public 'View' data types from/to which private
15425 vector representations can be converted via
15426 GNAT.Altivec.Conversions. This allows convenient access to individual
15427 vector elements and provides a simple way to initialize vector
15428 objects.
15430 @node GNAT.Array_Split (g-arrspl.ads)
15431 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15432 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15433 @cindex Array splitter
15435 @noindent
15436 Useful array-manipulation routines: given a set of separators, split
15437 an array wherever the separators appear, and provide direct access
15438 to the resulting slices.
15440 @node GNAT.AWK (g-awk.ads)
15441 @section @code{GNAT.AWK} (@file{g-awk.ads})
15442 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15443 @cindex Parsing
15444 @cindex AWK
15446 @noindent
15447 Provides AWK-like parsing functions, with an easy interface for parsing one
15448 or more files containing formatted data.  The file is viewed as a database
15449 where each record is a line and a field is a data element in this line.
15451 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15452 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15453 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15454 @cindex Parsing
15455 @cindex Bounded Buffers
15457 @noindent
15458 Provides a concurrent generic bounded buffer abstraction.  Instances are
15459 useful directly or as parts of the implementations of other abstractions,
15460 such as mailboxes.
15462 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15463 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15464 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15465 @cindex Parsing
15466 @cindex Mailboxes
15468 @noindent
15469 Provides a thread-safe asynchronous intertask mailbox communication facility.
15471 @node GNAT.Bubble_Sort (g-bubsor.ads)
15472 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15473 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15474 @cindex Sorting
15475 @cindex Bubble sort
15477 @noindent
15478 Provides a general implementation of bubble sort usable for sorting arbitrary
15479 data items.  Exchange and comparison procedures are provided by passing
15480 access-to-procedure values.
15482 @node GNAT.Bubble_Sort_A (g-busora.ads)
15483 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15484 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15485 @cindex Sorting
15486 @cindex Bubble sort
15488 @noindent
15489 Provides a general implementation of bubble sort usable for sorting arbitrary
15490 data items.  Move and comparison procedures are provided by passing
15491 access-to-procedure values. This is an older version, retained for
15492 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15494 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15495 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15496 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15497 @cindex Sorting
15498 @cindex Bubble sort
15500 @noindent
15501 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15502 are provided as generic parameters, this improves efficiency, especially
15503 if the procedures can be inlined, at the expense of duplicating code for
15504 multiple instantiations.
15506 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15507 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15508 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15509 @cindex UTF-8 representation
15510 @cindex Wide characte representations
15512 @noindent
15513 Provides a routine which given a string, reads the start of the string to
15514 see whether it is one of the standard byte order marks (BOM's) which signal
15515 the encoding of the string. The routine includes detection of special XML
15516 sequences for various UCS input formats.
15518 @node GNAT.Byte_Swapping (g-bytswa.ads)
15519 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15520 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15521 @cindex Byte swapping
15522 @cindex Endianness
15524 @noindent
15525 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15526 Machine-specific implementations are available in some cases.
15528 @node GNAT.Calendar (g-calend.ads)
15529 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15530 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15531 @cindex @code{Calendar}
15533 @noindent
15534 Extends the facilities provided by @code{Ada.Calendar} to include handling
15535 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15536 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15537 C @code{timeval} format.
15539 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15540 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15541 @cindex @code{Calendar}
15542 @cindex Time
15543 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15545 @node GNAT.CRC32 (g-crc32.ads)
15546 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15547 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15548 @cindex CRC32
15549 @cindex Cyclic Redundancy Check
15551 @noindent
15552 This package implements the CRC-32 algorithm.  For a full description
15553 of this algorithm see
15554 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15555 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15556 Aug.@: 1988.  Sarwate, D.V@.
15558 @node GNAT.Case_Util (g-casuti.ads)
15559 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15560 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15561 @cindex Casing utilities
15562 @cindex Character handling (@code{GNAT.Case_Util})
15564 @noindent
15565 A set of simple routines for handling upper and lower casing of strings
15566 without the overhead of the full casing tables
15567 in @code{Ada.Characters.Handling}.
15569 @node GNAT.CGI (g-cgi.ads)
15570 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15571 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15572 @cindex CGI (Common Gateway Interface)
15574 @noindent
15575 This is a package for interfacing a GNAT program with a Web server via the
15576 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
15577 parameters, which are a set of key/value pairs sent by the Web server.  It
15578 builds a table whose index is the key and provides some services to deal
15579 with this table.
15581 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15582 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15583 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15584 @cindex CGI (Common Gateway Interface) cookie support
15585 @cindex Cookie support in CGI
15587 @noindent
15588 This is a package to interface a GNAT program with a Web server via the
15589 Common Gateway Interface (CGI).  It exports services to deal with Web
15590 cookies (piece of information kept in the Web client software).
15592 @node GNAT.CGI.Debug (g-cgideb.ads)
15593 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15594 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15595 @cindex CGI (Common Gateway Interface) debugging
15597 @noindent
15598 This is a package to help debugging CGI (Common Gateway Interface)
15599 programs written in Ada.
15601 @node GNAT.Command_Line (g-comlin.ads)
15602 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15603 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15604 @cindex Command line
15606 @noindent
15607 Provides a high level interface to @code{Ada.Command_Line} facilities,
15608 including the ability to scan for named switches with optional parameters
15609 and expand file names using wild card notations.
15611 @node GNAT.Compiler_Version (g-comver.ads)
15612 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15613 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15614 @cindex Compiler Version
15615 @cindex Version, of compiler
15617 @noindent
15618 Provides a routine for obtaining the version of the compiler used to
15619 compile the program. More accurately this is the version of the binder
15620 used to bind the program (this will normally be the same as the version
15621 of the compiler if a consistent tool set is used to compile all units
15622 of a partition).
15624 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15625 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15626 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15627 @cindex Interrupt
15629 @noindent
15630 Provides a simple interface to handle Ctrl-C keyboard events.
15632 @node GNAT.Current_Exception (g-curexc.ads)
15633 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15634 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15635 @cindex Current exception
15636 @cindex Exception retrieval
15638 @noindent
15639 Provides access to information on the current exception that has been raised
15640 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15641 specification syntax.
15642 This is particularly useful in simulating typical facilities for
15643 obtaining information about exceptions provided by Ada 83 compilers.
15645 @node GNAT.Debug_Pools (g-debpoo.ads)
15646 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15647 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15648 @cindex Debugging
15649 @cindex Debug pools
15650 @cindex Memory corruption debugging
15652 @noindent
15653 Provide a debugging storage pools that helps tracking memory corruption
15654 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15655 @value{EDITION} User's Guide}.
15657 @node GNAT.Debug_Utilities (g-debuti.ads)
15658 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15659 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15660 @cindex Debugging
15662 @noindent
15663 Provides a few useful utilities for debugging purposes, including conversion
15664 to and from string images of address values. Supports both C and Ada formats
15665 for hexadecimal literals.
15667 @node GNAT.Decode_String (g-decstr.ads)
15668 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15669 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15670 @cindex Decoding strings
15671 @cindex String decoding
15672 @cindex Wide character encoding
15673 @cindex UTF-8
15674 @cindex Unicode
15676 @noindent
15677 A generic package providing routines for decoding wide character and wide wide
15678 character strings encoded as sequences of 8-bit characters using a specified
15679 encoding method. Includes validation routines, and also routines for stepping
15680 to next or previous encoded character in an encoded string.
15681 Useful in conjunction with Unicode character coding. Note there is a
15682 preinstantiation for UTF-8. See next entry.
15684 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15685 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15686 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15687 @cindex Decoding strings
15688 @cindex Decoding UTF-8 strings
15689 @cindex UTF-8 string decoding
15690 @cindex Wide character decoding
15691 @cindex UTF-8
15692 @cindex Unicode
15694 @noindent
15695 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15697 @node GNAT.Directory_Operations (g-dirope.ads)
15698 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15699 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15700 @cindex Directory operations
15702 @noindent
15703 Provides a set of routines for manipulating directories, including changing
15704 the current directory, making new directories, and scanning the files in a
15705 directory.
15707 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15708 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15709 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15710 @cindex Directory operations iteration
15712 @noindent
15713 A child unit of GNAT.Directory_Operations providing additional operations
15714 for iterating through directories.
15716 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15717 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15718 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15719 @cindex Hash tables
15721 @noindent
15722 A generic implementation of hash tables that can be used to hash arbitrary
15723 data.  Provided in two forms, a simple form with built in hash functions,
15724 and a more complex form in which the hash function is supplied.
15726 @noindent
15727 This package provides a facility similar to that of @code{GNAT.HTable},
15728 except that this package declares a type that can be used to define
15729 dynamic instances of the hash table, while an instantiation of
15730 @code{GNAT.HTable} creates a single instance of the hash table.
15732 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15733 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15734 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15735 @cindex Table implementation
15736 @cindex Arrays, extendable
15738 @noindent
15739 A generic package providing a single dimension array abstraction where the
15740 length of the array can be dynamically modified.
15742 @noindent
15743 This package provides a facility similar to that of @code{GNAT.Table},
15744 except that this package declares a type that can be used to define
15745 dynamic instances of the table, while an instantiation of
15746 @code{GNAT.Table} creates a single instance of the table type.
15748 @node GNAT.Encode_String (g-encstr.ads)
15749 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15750 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15751 @cindex Encoding strings
15752 @cindex String encoding
15753 @cindex Wide character encoding
15754 @cindex UTF-8
15755 @cindex Unicode
15757 @noindent
15758 A generic package providing routines for encoding wide character and wide
15759 wide character strings as sequences of 8-bit characters using a specified
15760 encoding method. Useful in conjunction with Unicode character coding.
15761 Note there is a preinstantiation for UTF-8. See next entry.
15763 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15764 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15765 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15766 @cindex Encoding strings
15767 @cindex Encoding UTF-8 strings
15768 @cindex UTF-8 string encoding
15769 @cindex Wide character encoding
15770 @cindex UTF-8
15771 @cindex Unicode
15773 @noindent
15774 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15776 @node GNAT.Exception_Actions (g-excact.ads)
15777 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15778 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15779 @cindex Exception actions
15781 @noindent
15782 Provides callbacks when an exception is raised. Callbacks can be registered
15783 for specific exceptions, or when any exception is raised. This
15784 can be used for instance to force a core dump to ease debugging.
15786 @node GNAT.Exception_Traces (g-exctra.ads)
15787 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15788 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15789 @cindex Exception traces
15790 @cindex Debugging
15792 @noindent
15793 Provides an interface allowing to control automatic output upon exception
15794 occurrences.
15796 @node GNAT.Exceptions (g-except.ads)
15797 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15798 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15799 @cindex Exceptions, Pure
15800 @cindex Pure packages, exceptions
15802 @noindent
15803 Normally it is not possible to raise an exception with
15804 a message from a subprogram in a pure package, since the
15805 necessary types and subprograms are in @code{Ada.Exceptions}
15806 which is not a pure unit. @code{GNAT.Exceptions} provides a
15807 facility for getting around this limitation for a few
15808 predefined exceptions, and for example allow raising
15809 @code{Constraint_Error} with a message from a pure subprogram.
15811 @node GNAT.Expect (g-expect.ads)
15812 @section @code{GNAT.Expect} (@file{g-expect.ads})
15813 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15815 @noindent
15816 Provides a set of subprograms similar to what is available
15817 with the standard Tcl Expect tool.
15818 It allows you to easily spawn and communicate with an external process.
15819 You can send commands or inputs to the process, and compare the output
15820 with some expected regular expression. Currently @code{GNAT.Expect}
15821 is implemented on all native GNAT ports except for OpenVMS@.
15822 It is not implemented for cross ports, and in particular is not
15823 implemented for VxWorks or LynxOS@.
15825 @node GNAT.Expect.TTY (g-exptty.ads)
15826 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15827 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15829 @noindent
15830 As GNAT.Expect but using pseudo-terminal.
15831 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15832 ports except for OpenVMS@. It is not implemented for cross ports, and
15833 in particular is not implemented for VxWorks or LynxOS@.
15835 @node GNAT.Float_Control (g-flocon.ads)
15836 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15837 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15838 @cindex Floating-Point Processor
15840 @noindent
15841 Provides an interface for resetting the floating-point processor into the
15842 mode required for correct semantic operation in Ada.  Some third party
15843 library calls may cause this mode to be modified, and the Reset procedure
15844 in this package can be used to reestablish the required mode.
15846 @node GNAT.Heap_Sort (g-heasor.ads)
15847 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15848 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15849 @cindex Sorting
15851 @noindent
15852 Provides a general implementation of heap sort usable for sorting arbitrary
15853 data items. Exchange and comparison procedures are provided by passing
15854 access-to-procedure values.  The algorithm used is a modified heap sort
15855 that performs approximately N*log(N) comparisons in the worst case.
15857 @node GNAT.Heap_Sort_A (g-hesora.ads)
15858 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15859 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15860 @cindex Sorting
15862 @noindent
15863 Provides a general implementation of heap sort usable for sorting arbitrary
15864 data items. Move and comparison procedures are provided by passing
15865 access-to-procedure values.  The algorithm used is a modified heap sort
15866 that performs approximately N*log(N) comparisons in the worst case.
15867 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15868 interface, but may be slightly more efficient.
15870 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15871 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15872 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15873 @cindex Sorting
15875 @noindent
15876 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15877 are provided as generic parameters, this improves efficiency, especially
15878 if the procedures can be inlined, at the expense of duplicating code for
15879 multiple instantiations.
15881 @node GNAT.HTable (g-htable.ads)
15882 @section @code{GNAT.HTable} (@file{g-htable.ads})
15883 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15884 @cindex Hash tables
15886 @noindent
15887 A generic implementation of hash tables that can be used to hash arbitrary
15888 data.  Provides two approaches, one a simple static approach, and the other
15889 allowing arbitrary dynamic hash tables.
15891 @node GNAT.IO (g-io.ads)
15892 @section @code{GNAT.IO} (@file{g-io.ads})
15893 @cindex @code{GNAT.IO} (@file{g-io.ads})
15894 @cindex Simple I/O
15895 @cindex Input/Output facilities
15897 @noindent
15898 A simple preelaborable input-output package that provides a subset of
15899 simple Text_IO functions for reading characters and strings from
15900 Standard_Input, and writing characters, strings and integers to either
15901 Standard_Output or Standard_Error.
15903 @node GNAT.IO_Aux (g-io_aux.ads)
15904 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15905 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15906 @cindex Text_IO
15907 @cindex Input/Output facilities
15909 Provides some auxiliary functions for use with Text_IO, including a test
15910 for whether a file exists, and functions for reading a line of text.
15912 @node GNAT.Lock_Files (g-locfil.ads)
15913 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15914 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15915 @cindex File locking
15916 @cindex Locking using files
15918 @noindent
15919 Provides a general interface for using files as locks.  Can be used for
15920 providing program level synchronization.
15922 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15923 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15924 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15925 @cindex Random number generation
15927 @noindent
15928 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
15929 a modified version of the Blum-Blum-Shub generator.
15931 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15932 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15933 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15934 @cindex Random number generation
15936 @noindent
15937 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
15938 a modified version of the Blum-Blum-Shub generator.
15940 @node GNAT.MD5 (g-md5.ads)
15941 @section @code{GNAT.MD5} (@file{g-md5.ads})
15942 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15943 @cindex Message Digest MD5
15945 @noindent
15946 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15948 @node GNAT.Memory_Dump (g-memdum.ads)
15949 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15950 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15951 @cindex Dump Memory
15953 @noindent
15954 Provides a convenient routine for dumping raw memory to either the
15955 standard output or standard error files. Uses GNAT.IO for actual
15956 output.
15958 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15959 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15960 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15961 @cindex Exception, obtaining most recent
15963 @noindent
15964 Provides access to the most recently raised exception.  Can be used for
15965 various logging purposes, including duplicating functionality of some
15966 Ada 83 implementation dependent extensions.
15968 @node GNAT.OS_Lib (g-os_lib.ads)
15969 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15970 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15971 @cindex Operating System interface
15972 @cindex Spawn capability
15974 @noindent
15975 Provides a range of target independent operating system interface functions,
15976 including time/date management, file operations, subprocess management,
15977 including a portable spawn procedure, and access to environment variables
15978 and error return codes.
15980 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15981 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15982 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15983 @cindex Hash functions
15985 @noindent
15986 Provides a generator of static minimal perfect hash functions. No
15987 collisions occur and each item can be retrieved from the table in one
15988 probe (perfect property). The hash table size corresponds to the exact
15989 size of the key set and no larger (minimal property). The key set has to
15990 be know in advance (static property). The hash functions are also order
15991 preserving. If w2 is inserted after w1 in the generator, their
15992 hashcode are in the same order. These hashing functions are very
15993 convenient for use with realtime applications.
15995 @node GNAT.Random_Numbers (g-rannum.ads)
15996 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15997 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15998 @cindex Random number generation
16000 @noindent
16001 Provides random number capabilities which extend those available in the
16002 standard Ada library and are more convenient to use.
16004 @node GNAT.Regexp (g-regexp.ads)
16005 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16006 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16007 @cindex Regular expressions
16008 @cindex Pattern matching
16010 @noindent
16011 A simple implementation of regular expressions, using a subset of regular
16012 expression syntax copied from familiar Unix style utilities.  This is the
16013 simples of the three pattern matching packages provided, and is particularly
16014 suitable for ``file globbing'' applications.
16016 @node GNAT.Registry (g-regist.ads)
16017 @section @code{GNAT.Registry} (@file{g-regist.ads})
16018 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16019 @cindex Windows Registry
16021 @noindent
16022 This is a high level binding to the Windows registry.  It is possible to
16023 do simple things like reading a key value, creating a new key.  For full
16024 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16025 package provided with the Win32Ada binding
16027 @node GNAT.Regpat (g-regpat.ads)
16028 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16029 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16030 @cindex Regular expressions
16031 @cindex Pattern matching
16033 @noindent
16034 A complete implementation of Unix-style regular expression matching, copied
16035 from the original V7 style regular expression library written in C by
16036 Henry Spencer (and binary compatible with this C library).
16038 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16039 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16040 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16041 @cindex Secondary Stack Info
16043 @noindent
16044 Provide the capability to query the high water mark of the current task's
16045 secondary stack.
16047 @node GNAT.Semaphores (g-semaph.ads)
16048 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16049 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16050 @cindex Semaphores
16052 @noindent
16053 Provides classic counting and binary semaphores using protected types.
16055 @node GNAT.Serial_Communications (g-sercom.ads)
16056 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16057 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16058 @cindex Serial_Communications
16060 @noindent
16061 Provides a simple interface to send and receive data over a serial
16062 port. This is only supported on GNU/Linux and Windows.
16064 @node GNAT.SHA1 (g-sha1.ads)
16065 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16066 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16067 @cindex Secure Hash Algorithm SHA-1
16069 @noindent
16070 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16071 and RFC 3174.
16073 @node GNAT.SHA224 (g-sha224.ads)
16074 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16075 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16076 @cindex Secure Hash Algorithm SHA-224
16078 @noindent
16079 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16081 @node GNAT.SHA256 (g-sha256.ads)
16082 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16083 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16084 @cindex Secure Hash Algorithm SHA-256
16086 @noindent
16087 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16089 @node GNAT.SHA384 (g-sha384.ads)
16090 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16091 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16092 @cindex Secure Hash Algorithm SHA-384
16094 @noindent
16095 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16097 @node GNAT.SHA512 (g-sha512.ads)
16098 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16099 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16100 @cindex Secure Hash Algorithm SHA-512
16102 @noindent
16103 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16105 @node GNAT.Signals (g-signal.ads)
16106 @section @code{GNAT.Signals} (@file{g-signal.ads})
16107 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16108 @cindex Signals
16110 @noindent
16111 Provides the ability to manipulate the blocked status of signals on supported
16112 targets.
16114 @node GNAT.Sockets (g-socket.ads)
16115 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16116 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16117 @cindex Sockets
16119 @noindent
16120 A high level and portable interface to develop sockets based applications.
16121 This package is based on the sockets thin binding found in
16122 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16123 on all native GNAT ports except for OpenVMS@.  It is not implemented
16124 for the LynxOS@ cross port.
16126 @node GNAT.Source_Info (g-souinf.ads)
16127 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16128 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16129 @cindex Source Information
16131 @noindent
16132 Provides subprograms that give access to source code information known at
16133 compile time, such as the current file name and line number.
16135 @node GNAT.Spelling_Checker (g-speche.ads)
16136 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16137 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16138 @cindex Spell checking
16140 @noindent
16141 Provides a function for determining whether one string is a plausible
16142 near misspelling of another string.
16144 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16145 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16146 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16147 @cindex Spell checking
16149 @noindent
16150 Provides a generic function that can be instantiated with a string type for
16151 determining whether one string is a plausible near misspelling of another
16152 string.
16154 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16155 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16156 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16157 @cindex SPITBOL pattern matching
16158 @cindex Pattern matching
16160 @noindent
16161 A complete implementation of SNOBOL4 style pattern matching.  This is the
16162 most elaborate of the pattern matching packages provided.  It fully duplicates
16163 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16164 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16166 @node GNAT.Spitbol (g-spitbo.ads)
16167 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16168 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16169 @cindex SPITBOL interface
16171 @noindent
16172 The top level package of the collection of SPITBOL-style functionality, this
16173 package provides basic SNOBOL4 string manipulation functions, such as
16174 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16175 useful for constructing arbitrary mappings from strings in the style of
16176 the SNOBOL4 TABLE function.
16178 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16179 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16180 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16181 @cindex Sets of strings
16182 @cindex SPITBOL Tables
16184 @noindent
16185 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16186 for type @code{Standard.Boolean}, giving an implementation of sets of
16187 string values.
16189 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16190 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16191 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16192 @cindex Integer maps
16193 @cindex Maps
16194 @cindex SPITBOL Tables
16196 @noindent
16197 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16198 for type @code{Standard.Integer}, giving an implementation of maps
16199 from string to integer values.
16201 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16202 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16203 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16204 @cindex String maps
16205 @cindex Maps
16206 @cindex SPITBOL Tables
16208 @noindent
16209 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16210 a variable length string type, giving an implementation of general
16211 maps from strings to strings.
16213 @node GNAT.SSE (g-sse.ads)
16214 @section @code{GNAT.SSE} (@file{g-sse.ads})
16215 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16217 @noindent
16218 Root of a set of units aimed at offering Ada bindings to a subset of
16219 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16220 targets.  It exposes vector component types together with a general
16221 introduction to the binding contents and use.
16223 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16224 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16225 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16227 @noindent
16228 SSE vector types for use with SSE related intrinsics.
16230 @node GNAT.Strings (g-string.ads)
16231 @section @code{GNAT.Strings} (@file{g-string.ads})
16232 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16234 @noindent
16235 Common String access types and related subprograms. Basically it
16236 defines a string access and an array of string access types.
16238 @node GNAT.String_Split (g-strspl.ads)
16239 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16240 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16241 @cindex String splitter
16243 @noindent
16244 Useful string manipulation routines: given a set of separators, split
16245 a string wherever the separators appear, and provide direct access
16246 to the resulting slices. This package is instantiated from
16247 @code{GNAT.Array_Split}.
16249 @node GNAT.Table (g-table.ads)
16250 @section @code{GNAT.Table} (@file{g-table.ads})
16251 @cindex @code{GNAT.Table} (@file{g-table.ads})
16252 @cindex Table implementation
16253 @cindex Arrays, extendable
16255 @noindent
16256 A generic package providing a single dimension array abstraction where the
16257 length of the array can be dynamically modified.
16259 @noindent
16260 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16261 except that this package declares a single instance of the table type,
16262 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16263 used to define dynamic instances of the table.
16265 @node GNAT.Task_Lock (g-tasloc.ads)
16266 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16267 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16268 @cindex Task synchronization
16269 @cindex Task locking
16270 @cindex Locking
16272 @noindent
16273 A very simple facility for locking and unlocking sections of code using a
16274 single global task lock.  Appropriate for use in situations where contention
16275 between tasks is very rarely expected.
16277 @node GNAT.Time_Stamp (g-timsta.ads)
16278 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16279 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16280 @cindex Time stamp
16281 @cindex Current time
16283 @noindent
16284 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16285 represents the current date and time in ISO 8601 format. This is a very simple
16286 routine with minimal code and there are no dependencies on any other unit.
16288 @node GNAT.Threads (g-thread.ads)
16289 @section @code{GNAT.Threads} (@file{g-thread.ads})
16290 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16291 @cindex Foreign threads
16292 @cindex Threads, foreign
16294 @noindent
16295 Provides facilities for dealing with foreign threads which need to be known
16296 by the GNAT run-time system. Consult the documentation of this package for
16297 further details if your program has threads that are created by a non-Ada
16298 environment which then accesses Ada code.
16300 @node GNAT.Traceback (g-traceb.ads)
16301 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16302 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16303 @cindex Trace back facilities
16305 @noindent
16306 Provides a facility for obtaining non-symbolic traceback information, useful
16307 in various debugging situations.
16309 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16310 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16311 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16312 @cindex Trace back facilities
16314 @node GNAT.UTF_32 (g-utf_32.ads)
16315 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16316 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16317 @cindex Wide character codes
16319 @noindent
16320 This is a package intended to be used in conjunction with the
16321 @code{Wide_Character} type in Ada 95 and the
16322 @code{Wide_Wide_Character} type in Ada 2005 (available
16323 in @code{GNAT} in Ada 2005 mode). This package contains
16324 Unicode categorization routines, as well as lexical
16325 categorization routines corresponding to the Ada 2005
16326 lexical rules for identifiers and strings, and also a
16327 lower case to upper case fold routine corresponding to
16328 the Ada 2005 rules for identifier equivalence.
16330 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16331 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16332 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16333 @cindex Spell checking
16335 @noindent
16336 Provides a function for determining whether one wide wide string is a plausible
16337 near misspelling of another wide wide string, where the strings are represented
16338 using the UTF_32_String type defined in System.Wch_Cnv.
16340 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16341 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16342 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16343 @cindex Spell checking
16345 @noindent
16346 Provides a function for determining whether one wide string is a plausible
16347 near misspelling of another wide string.
16349 @node GNAT.Wide_String_Split (g-wistsp.ads)
16350 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16351 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16352 @cindex Wide_String splitter
16354 @noindent
16355 Useful wide string manipulation routines: given a set of separators, split
16356 a wide string wherever the separators appear, and provide direct access
16357 to the resulting slices. This package is instantiated from
16358 @code{GNAT.Array_Split}.
16360 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16361 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16362 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16363 @cindex Spell checking
16365 @noindent
16366 Provides a function for determining whether one wide wide string is a plausible
16367 near misspelling of another wide wide string.
16369 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16370 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16371 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16372 @cindex Wide_Wide_String splitter
16374 @noindent
16375 Useful wide wide string manipulation routines: given a set of separators, split
16376 a wide wide string wherever the separators appear, and provide direct access
16377 to the resulting slices. This package is instantiated from
16378 @code{GNAT.Array_Split}.
16380 @node Interfaces.C.Extensions (i-cexten.ads)
16381 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16382 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16384 @noindent
16385 This package contains additional C-related definitions, intended
16386 for use with either manually or automatically generated bindings
16387 to C libraries.
16389 @node Interfaces.C.Streams (i-cstrea.ads)
16390 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16391 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16392 @cindex  C streams, interfacing
16394 @noindent
16395 This package is a binding for the most commonly used operations
16396 on C streams.
16398 @node Interfaces.CPP (i-cpp.ads)
16399 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16400 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16401 @cindex  C++ interfacing
16402 @cindex  Interfacing, to C++
16404 @noindent
16405 This package provides facilities for use in interfacing to C++.  It
16406 is primarily intended to be used in connection with automated tools
16407 for the generation of C++ interfaces.
16409 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16410 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16411 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16412 @cindex  IBM Packed Format
16413 @cindex  Packed Decimal
16415 @noindent
16416 This package provides a set of routines for conversions to and
16417 from a packed decimal format compatible with that used on IBM
16418 mainframes.
16420 @node Interfaces.VxWorks (i-vxwork.ads)
16421 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16422 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16423 @cindex Interfacing to VxWorks
16424 @cindex VxWorks, interfacing
16426 @noindent
16427 This package provides a limited binding to the VxWorks API.
16428 In particular, it interfaces with the
16429 VxWorks hardware interrupt facilities.
16431 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16432 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16433 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16434 @cindex Interfacing to VxWorks' I/O
16435 @cindex VxWorks, I/O interfacing
16436 @cindex VxWorks, Get_Immediate
16437 @cindex Get_Immediate, VxWorks
16439 @noindent
16440 This package provides a binding to the ioctl (IO/Control)
16441 function of VxWorks, defining a set of option values and
16442 function codes. A particular use of this package is
16443 to enable the use of Get_Immediate under VxWorks.
16445 @node System.Address_Image (s-addima.ads)
16446 @section @code{System.Address_Image} (@file{s-addima.ads})
16447 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16448 @cindex Address image
16449 @cindex Image, of an address
16451 @noindent
16452 This function provides a useful debugging
16453 function that gives an (implementation dependent)
16454 string which identifies an address.
16456 @node System.Assertions (s-assert.ads)
16457 @section @code{System.Assertions} (@file{s-assert.ads})
16458 @cindex @code{System.Assertions} (@file{s-assert.ads})
16459 @cindex Assertions
16460 @cindex Assert_Failure, exception
16462 @noindent
16463 This package provides the declaration of the exception raised
16464 by an run-time assertion failure, as well as the routine that
16465 is used internally to raise this assertion.
16467 @node System.Memory (s-memory.ads)
16468 @section @code{System.Memory} (@file{s-memory.ads})
16469 @cindex @code{System.Memory} (@file{s-memory.ads})
16470 @cindex Memory allocation
16472 @noindent
16473 This package provides the interface to the low level routines used
16474 by the generated code for allocation and freeing storage for the
16475 default storage pool (analogous to the C routines malloc and free.
16476 It also provides a reallocation interface analogous to the C routine
16477 realloc. The body of this unit may be modified to provide alternative
16478 allocation mechanisms for the default pool, and in addition, direct
16479 calls to this unit may be made for low level allocation uses (for
16480 example see the body of @code{GNAT.Tables}).
16482 @node System.Partition_Interface (s-parint.ads)
16483 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16484 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16485 @cindex Partition interfacing functions
16487 @noindent
16488 This package provides facilities for partition interfacing.  It
16489 is used primarily in a distribution context when using Annex E
16490 with @code{GLADE}.
16492 @node System.Pool_Global (s-pooglo.ads)
16493 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16494 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16495 @cindex Storage pool, global
16496 @cindex Global storage pool
16498 @noindent
16499 This package provides a storage pool that is equivalent to the default
16500 storage pool used for access types for which no pool is specifically
16501 declared. It uses malloc/free to allocate/free and does not attempt to
16502 do any automatic reclamation.
16504 @node System.Pool_Local (s-pooloc.ads)
16505 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16506 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16507 @cindex Storage pool, local
16508 @cindex Local storage pool
16510 @noindent
16511 This package provides a storage pool that is intended for use with locally
16512 defined access types. It uses malloc/free for allocate/free, and maintains
16513 a list of allocated blocks, so that all storage allocated for the pool can
16514 be freed automatically when the pool is finalized.
16516 @node System.Restrictions (s-restri.ads)
16517 @section @code{System.Restrictions} (@file{s-restri.ads})
16518 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16519 @cindex Run-time restrictions access
16521 @noindent
16522 This package provides facilities for accessing at run time
16523 the status of restrictions specified at compile time for
16524 the partition. Information is available both with regard
16525 to actual restrictions specified, and with regard to
16526 compiler determined information on which restrictions
16527 are violated by one or more packages in the partition.
16529 @node System.Rident (s-rident.ads)
16530 @section @code{System.Rident} (@file{s-rident.ads})
16531 @cindex @code{System.Rident} (@file{s-rident.ads})
16532 @cindex Restrictions definitions
16534 @noindent
16535 This package provides definitions of the restrictions
16536 identifiers supported by GNAT, and also the format of
16537 the restrictions provided in package System.Restrictions.
16538 It is not normally necessary to @code{with} this generic package
16539 since the necessary instantiation is included in
16540 package System.Restrictions.
16542 @node System.Strings.Stream_Ops (s-ststop.ads)
16543 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16544 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16545 @cindex Stream operations
16546 @cindex String stream operations
16548 @noindent
16549 This package provides a set of stream subprograms for standard string types.
16550 It is intended primarily to support implicit use of such subprograms when
16551 stream attributes are applied to string types, but the subprograms in this
16552 package can be used directly by application programs.
16554 @node System.Task_Info (s-tasinf.ads)
16555 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16556 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16557 @cindex Task_Info pragma
16559 @noindent
16560 This package provides target dependent functionality that is used
16561 to support the @code{Task_Info} pragma
16563 @node System.Wch_Cnv (s-wchcnv.ads)
16564 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16565 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16566 @cindex Wide Character, Representation
16567 @cindex Wide String, Conversion
16568 @cindex Representation of wide characters
16570 @noindent
16571 This package provides routines for converting between
16572 wide and wide wide characters and a representation as a value of type
16573 @code{Standard.String}, using a specified wide character
16574 encoding method.  It uses definitions in
16575 package @code{System.Wch_Con}.
16577 @node System.Wch_Con (s-wchcon.ads)
16578 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16579 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16581 @noindent
16582 This package provides definitions and descriptions of
16583 the various methods used for encoding wide characters
16584 in ordinary strings.  These definitions are used by
16585 the package @code{System.Wch_Cnv}.
16587 @node Interfacing to Other Languages
16588 @chapter Interfacing to Other Languages
16589 @noindent
16590 The facilities in annex B of the Ada Reference Manual are fully
16591 implemented in GNAT, and in addition, a full interface to C++ is
16592 provided.
16594 @menu
16595 * Interfacing to C::
16596 * Interfacing to C++::
16597 * Interfacing to COBOL::
16598 * Interfacing to Fortran::
16599 * Interfacing to non-GNAT Ada code::
16600 @end menu
16602 @node Interfacing to C
16603 @section Interfacing to C
16605 @noindent
16606 Interfacing to C with GNAT can use one of two approaches:
16608 @itemize @bullet
16609 @item
16610 The types in the package @code{Interfaces.C} may be used.
16611 @item
16612 Standard Ada types may be used directly.  This may be less portable to
16613 other compilers, but will work on all GNAT compilers, which guarantee
16614 correspondence between the C and Ada types.
16615 @end itemize
16617 @noindent
16618 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16619 effect, since this is the default.  The following table shows the
16620 correspondence between Ada scalar types and the corresponding C types.
16622 @table @code
16623 @item Integer
16624 @code{int}
16625 @item Short_Integer
16626 @code{short}
16627 @item Short_Short_Integer
16628 @code{signed char}
16629 @item Long_Integer
16630 @code{long}
16631 @item Long_Long_Integer
16632 @code{long long}
16633 @item Short_Float
16634 @code{float}
16635 @item Float
16636 @code{float}
16637 @item Long_Float
16638 @code{double}
16639 @item Long_Long_Float
16640 This is the longest floating-point type supported by the hardware.
16641 @end table
16643 @noindent
16644 Additionally, there are the following general correspondences between Ada
16645 and C types:
16646 @itemize @bullet
16647 @item
16648 Ada enumeration types map to C enumeration types directly if pragma
16649 @code{Convention C} is specified, which causes them to have int
16650 length.  Without pragma @code{Convention C}, Ada enumeration types map to
16651 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16652 @code{int}, respectively) depending on the number of values passed.
16653 This is the only case in which pragma @code{Convention C} affects the
16654 representation of an Ada type.
16656 @item
16657 Ada access types map to C pointers, except for the case of pointers to
16658 unconstrained types in Ada, which have no direct C equivalent.
16660 @item
16661 Ada arrays map directly to C arrays.
16663 @item
16664 Ada records map directly to C structures.
16666 @item
16667 Packed Ada records map to C structures where all members are bit fields
16668 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16669 @end itemize
16671 @node Interfacing to C++
16672 @section Interfacing to C++
16674 @noindent
16675 The interface to C++ makes use of the following pragmas, which are
16676 primarily intended to be constructed automatically using a binding generator
16677 tool, although it is possible to construct them by hand.
16679 Using these pragmas it is possible to achieve complete
16680 inter-operability between Ada tagged types and C++ class definitions.
16681 See @ref{Implementation Defined Pragmas}, for more details.
16683 @table @code
16684 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16685 The argument denotes an entity in the current declarative region that is
16686 declared as a tagged or untagged record type. It indicates that the type
16687 corresponds to an externally declared C++ class type, and is to be laid
16688 out the same way that C++ would lay out the type.
16690 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16691 for backward compatibility but its functionality is available
16692 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16694 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16695 This pragma identifies an imported function (imported in the usual way
16696 with pragma @code{Import}) as corresponding to a C++ constructor.
16697 @end table
16699 In addition, C++ exceptions are propagated and can be handled in an
16700 @code{others} choice of an exception handler. The corresponding Ada
16701 occurrence has no message, and the simple name of the exception identity
16702 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
16703 tasks works properly when such foreign exceptions are propagated.
16705 @node Interfacing to COBOL
16706 @section Interfacing to COBOL
16708 @noindent
16709 Interfacing to COBOL is achieved as described in section B.4 of
16710 the Ada Reference Manual.
16712 @node Interfacing to Fortran
16713 @section Interfacing to Fortran
16715 @noindent
16716 Interfacing to Fortran is achieved as described in section B.5 of the
16717 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
16718 multi-dimensional array causes the array to be stored in column-major
16719 order as required for convenient interface to Fortran.
16721 @node Interfacing to non-GNAT Ada code
16722 @section Interfacing to non-GNAT Ada code
16724 It is possible to specify the convention @code{Ada} in a pragma
16725 @code{Import} or pragma @code{Export}.  However this refers to
16726 the calling conventions used by GNAT, which may or may not be
16727 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16728 compiler to allow interoperation.
16730 If arguments types are kept simple, and if the foreign compiler generally
16731 follows system calling conventions, then it may be possible to integrate
16732 files compiled by other Ada compilers, provided that the elaboration
16733 issues are adequately addressed (for example by eliminating the
16734 need for any load time elaboration).
16736 In particular, GNAT running on VMS is designed to
16737 be highly compatible with the DEC Ada 83 compiler, so this is one
16738 case in which it is possible to import foreign units of this type,
16739 provided that the data items passed are restricted to simple scalar
16740 values or simple record types without variants, or simple array
16741 types with fixed bounds.
16743 @node Specialized Needs Annexes
16744 @chapter Specialized Needs Annexes
16746 @noindent
16747 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16748 required in all implementations.  However, as described in this chapter,
16749 GNAT implements all of these annexes:
16751 @table @asis
16752 @item Systems Programming (Annex C)
16753 The Systems Programming Annex is fully implemented.
16755 @item Real-Time Systems (Annex D)
16756 The Real-Time Systems Annex is fully implemented.
16758 @item Distributed Systems (Annex E)
16759 Stub generation is fully implemented in the GNAT compiler.  In addition,
16760 a complete compatible PCS is available as part of the GLADE system,
16761 a separate product.  When the two
16762 products are used in conjunction, this annex is fully implemented.
16764 @item Information Systems (Annex F)
16765 The Information Systems annex is fully implemented.
16767 @item Numerics (Annex G)
16768 The Numerics Annex is fully implemented.
16770 @item Safety and Security / High-Integrity Systems (Annex H)
16771 The Safety and Security Annex (termed the High-Integrity Systems Annex
16772 in Ada 2005) is fully implemented.
16773 @end table
16775 @node Implementation of Specific Ada Features
16776 @chapter Implementation of Specific Ada Features
16778 @noindent
16779 This chapter describes the GNAT implementation of several Ada language
16780 facilities.
16782 @menu
16783 * Machine Code Insertions::
16784 * GNAT Implementation of Tasking::
16785 * GNAT Implementation of Shared Passive Packages::
16786 * Code Generation for Array Aggregates::
16787 * The Size of Discriminated Records with Default Discriminants::
16788 * Strict Conformance to the Ada Reference Manual::
16789 @end menu
16791 @node Machine Code Insertions
16792 @section Machine Code Insertions
16793 @cindex Machine Code insertions
16795 @noindent
16796 Package @code{Machine_Code} provides machine code support as described
16797 in the Ada Reference Manual in two separate forms:
16798 @itemize @bullet
16799 @item
16800 Machine code statements, consisting of qualified expressions that
16801 fit the requirements of RM section 13.8.
16802 @item
16803 An intrinsic callable procedure, providing an alternative mechanism of
16804 including machine instructions in a subprogram.
16805 @end itemize
16807 @noindent
16808 The two features are similar, and both are closely related to the mechanism
16809 provided by the asm instruction in the GNU C compiler.  Full understanding
16810 and use of the facilities in this package requires understanding the asm
16811 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16812 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16814 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16815 semantic restrictions and effects as described below.  Both are provided so
16816 that the procedure call can be used as a statement, and the function call
16817 can be used to form a code_statement.
16819 The first example given in the GCC documentation is the C @code{asm}
16820 instruction:
16821 @smallexample
16822    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16823 @end smallexample
16825 @noindent
16826 The equivalent can be written for GNAT as:
16828 @smallexample @c ada
16829 Asm ("fsinx %1 %0",
16830      My_Float'Asm_Output ("=f", result),
16831      My_Float'Asm_Input  ("f",  angle));
16832 @end smallexample
16834 @noindent
16835 The first argument to @code{Asm} is the assembler template, and is
16836 identical to what is used in GNU C@.  This string must be a static
16837 expression.  The second argument is the output operand list.  It is
16838 either a single @code{Asm_Output} attribute reference, or a list of such
16839 references enclosed in parentheses (technically an array aggregate of
16840 such references).
16842 The @code{Asm_Output} attribute denotes a function that takes two
16843 parameters.  The first is a string, the second is the name of a variable
16844 of the type designated by the attribute prefix.  The first (string)
16845 argument is required to be a static expression and designates the
16846 constraint for the parameter (e.g.@: what kind of register is
16847 required).  The second argument is the variable to be updated with the
16848 result.  The possible values for constraint are the same as those used in
16849 the RTL, and are dependent on the configuration file used to build the
16850 GCC back end.  If there are no output operands, then this argument may
16851 either be omitted, or explicitly given as @code{No_Output_Operands}.
16853 The second argument of @code{@var{my_float}'Asm_Output} functions as
16854 though it were an @code{out} parameter, which is a little curious, but
16855 all names have the form of expressions, so there is no syntactic
16856 irregularity, even though normally functions would not be permitted
16857 @code{out} parameters.  The third argument is the list of input
16858 operands.  It is either a single @code{Asm_Input} attribute reference, or
16859 a list of such references enclosed in parentheses (technically an array
16860 aggregate of such references).
16862 The @code{Asm_Input} attribute denotes a function that takes two
16863 parameters.  The first is a string, the second is an expression of the
16864 type designated by the prefix.  The first (string) argument is required
16865 to be a static expression, and is the constraint for the parameter,
16866 (e.g.@: what kind of register is required).  The second argument is the
16867 value to be used as the input argument.  The possible values for the
16868 constant are the same as those used in the RTL, and are dependent on
16869 the configuration file used to built the GCC back end.
16871 If there are no input operands, this argument may either be omitted, or
16872 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
16873 present in the above example, is a list of register names, called the
16874 @dfn{clobber} argument.  This argument, if given, must be a static string
16875 expression, and is a space or comma separated list of names of registers
16876 that must be considered destroyed as a result of the @code{Asm} call.  If
16877 this argument is the null string (the default value), then the code
16878 generator assumes that no additional registers are destroyed.
16880 The fifth argument, not present in the above example, called the
16881 @dfn{volatile} argument, is by default @code{False}.  It can be set to
16882 the literal value @code{True} to indicate to the code generator that all
16883 optimizations with respect to the instruction specified should be
16884 suppressed, and that in particular, for an instruction that has outputs,
16885 the instruction will still be generated, even if none of the outputs are
16886 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16887 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16888 Generally it is strongly advisable to use Volatile for any ASM statement
16889 that is missing either input or output operands, or when two or more ASM
16890 statements appear in sequence, to avoid unwanted optimizations. A warning
16891 is generated if this advice is not followed.
16893 The @code{Asm} subprograms may be used in two ways.  First the procedure
16894 forms can be used anywhere a procedure call would be valid, and
16895 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
16896 be used to intersperse machine instructions with other Ada statements.
16897 Second, the function forms, which return a dummy value of the limited
16898 private type @code{Asm_Insn}, can be used in code statements, and indeed
16899 this is the only context where such calls are allowed.  Code statements
16900 appear as aggregates of the form:
16902 @smallexample @c ada
16903 Asm_Insn'(Asm (@dots{}));
16904 Asm_Insn'(Asm_Volatile (@dots{}));
16905 @end smallexample
16907 @noindent
16908 In accordance with RM rules, such code statements are allowed only
16909 within subprograms whose entire body consists of such statements.  It is
16910 not permissible to intermix such statements with other Ada statements.
16912 Typically the form using intrinsic procedure calls is more convenient
16913 and more flexible.  The code statement form is provided to meet the RM
16914 suggestion that such a facility should be made available.  The following
16915 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16916 is used, the arguments may be given in arbitrary order, following the
16917 normal rules for use of positional and named arguments)
16919 @smallexample
16920 ASM_CALL ::= Asm (
16921                  [Template =>] static_string_EXPRESSION
16922                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
16923                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
16924                [,[Clobber  =>] static_string_EXPRESSION ]
16925                [,[Volatile =>] static_boolean_EXPRESSION] )
16927 OUTPUT_OPERAND_LIST ::=
16928   [PREFIX.]No_Output_Operands
16929 | OUTPUT_OPERAND_ATTRIBUTE
16930 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16932 OUTPUT_OPERAND_ATTRIBUTE ::=
16933   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16935 INPUT_OPERAND_LIST ::=
16936   [PREFIX.]No_Input_Operands
16937 | INPUT_OPERAND_ATTRIBUTE
16938 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16940 INPUT_OPERAND_ATTRIBUTE ::=
16941   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16942 @end smallexample
16944 @noindent
16945 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16946 are declared in the package @code{Machine_Code} and must be referenced
16947 according to normal visibility rules. In particular if there is no
16948 @code{use} clause for this package, then appropriate package name
16949 qualification is required.
16951 @node GNAT Implementation of Tasking
16952 @section GNAT Implementation of Tasking
16954 @noindent
16955 This chapter outlines the basic GNAT approach to tasking (in particular,
16956 a multi-layered library for portability) and discusses issues related
16957 to compliance with the Real-Time Systems Annex.
16959 @menu
16960 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16961 * Ensuring Compliance with the Real-Time Annex::
16962 @end menu
16964 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16965 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16967 @noindent
16968 GNAT's run-time support comprises two layers:
16970 @itemize @bullet
16971 @item GNARL (GNAT Run-time Layer)
16972 @item GNULL (GNAT Low-level Library)
16973 @end itemize
16975 @noindent
16976 In GNAT, Ada's tasking services rely on a platform and OS independent
16977 layer known as GNARL@.  This code is responsible for implementing the
16978 correct semantics of Ada's task creation, rendezvous, protected
16979 operations etc.
16981 GNARL decomposes Ada's tasking semantics into simpler lower level
16982 operations such as create a thread, set the priority of a thread,
16983 yield, create a lock, lock/unlock, etc.  The spec for these low-level
16984 operations constitutes GNULLI, the GNULL Interface.  This interface is
16985 directly inspired from the POSIX real-time API@.
16987 If the underlying executive or OS implements the POSIX standard
16988 faithfully, the GNULL Interface maps as is to the services offered by
16989 the underlying kernel.  Otherwise, some target dependent glue code maps
16990 the services offered by the underlying kernel to the semantics expected
16991 by GNARL@.
16993 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16994 key point is that each Ada task is mapped on a thread in the underlying
16995 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
16997 In addition Ada task priorities map onto the underlying thread priorities.
16998 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17000 @itemize @bullet
17001 @item
17002 The underlying scheduler is used to schedule the Ada tasks.  This
17003 makes Ada tasks as efficient as kernel threads from a scheduling
17004 standpoint.
17006 @item
17007 Interaction with code written in C containing threads is eased
17008 since at the lowest level Ada tasks and C threads map onto the same
17009 underlying kernel concept.
17011 @item
17012 When an Ada task is blocked during I/O the remaining Ada tasks are
17013 able to proceed.
17015 @item
17016 On multiprocessor systems Ada tasks can execute in parallel.
17017 @end itemize
17019 @noindent
17020 Some threads libraries offer a mechanism to fork a new process, with the
17021 child process duplicating the threads from the parent.
17022 GNAT does not
17023 support this functionality when the parent contains more than one task.
17024 @cindex Forking a new process
17026 @node Ensuring Compliance with the Real-Time Annex
17027 @subsection Ensuring Compliance with the Real-Time Annex
17028 @cindex Real-Time Systems Annex compliance
17030 @noindent
17031 Although mapping Ada tasks onto
17032 the underlying threads has significant advantages, it does create some
17033 complications when it comes to respecting the scheduling semantics
17034 specified in the real-time annex (Annex D).
17036 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17037 scheduling policy states:
17039 @quotation
17040 @emph{When the active priority of a ready task that is not running
17041 changes, or the setting of its base priority takes effect, the
17042 task is removed from the ready queue for its old active priority
17043 and is added at the tail of the ready queue for its new active
17044 priority, except in the case where the active priority is lowered
17045 due to the loss of inherited priority, in which case the task is
17046 added at the head of the ready queue for its new active priority.}
17047 @end quotation
17049 @noindent
17050 While most kernels do put tasks at the end of the priority queue when
17051 a task changes its priority, (which respects the main
17052 FIFO_Within_Priorities requirement), almost none keep a thread at the
17053 beginning of its priority queue when its priority drops from the loss
17054 of inherited priority.
17056 As a result most vendors have provided incomplete Annex D implementations.
17058 The GNAT run-time, has a nice cooperative solution to this problem
17059 which ensures that accurate FIFO_Within_Priorities semantics are
17060 respected.
17062 The principle is as follows.  When an Ada task T is about to start
17063 running, it checks whether some other Ada task R with the same
17064 priority as T has been suspended due to the loss of priority
17065 inheritance.  If this is the case, T yields and is placed at the end of
17066 its priority queue.  When R arrives at the front of the queue it
17067 executes.
17069 Note that this simple scheme preserves the relative order of the tasks
17070 that were ready to execute in the priority queue where R has been
17071 placed at the end.
17073 @node GNAT Implementation of Shared Passive Packages
17074 @section GNAT Implementation of Shared Passive Packages
17075 @cindex Shared passive packages
17077 @noindent
17078 GNAT fully implements the pragma @code{Shared_Passive} for
17079 @cindex pragma @code{Shared_Passive}
17080 the purpose of designating shared passive packages.
17081 This allows the use of passive partitions in the
17082 context described in the Ada Reference Manual; i.e., for communication
17083 between separate partitions of a distributed application using the
17084 features in Annex E.
17085 @cindex Annex E
17086 @cindex Distribution Systems Annex
17088 However, the implementation approach used by GNAT provides for more
17089 extensive usage as follows:
17091 @table @emph
17092 @item Communication between separate programs
17094 This allows separate programs to access the data in passive
17095 partitions, using protected objects for synchronization where
17096 needed. The only requirement is that the two programs have a
17097 common shared file system. It is even possible for programs
17098 running on different machines with different architectures
17099 (e.g.@: different endianness) to communicate via the data in
17100 a passive partition.
17102 @item Persistence between program runs
17104 The data in a passive package can persist from one run of a
17105 program to another, so that a later program sees the final
17106 values stored by a previous run of the same program.
17108 @end table
17110 @noindent
17111 The implementation approach used is to store the data in files. A
17112 separate stream file is created for each object in the package, and
17113 an access to an object causes the corresponding file to be read or
17114 written.
17116 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17117 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17118 set to the directory to be used for these files.
17119 The files in this directory
17120 have names that correspond to their fully qualified names. For
17121 example, if we have the package
17123 @smallexample @c ada
17124 package X is
17125   pragma Shared_Passive (X);
17126   Y : Integer;
17127   Z : Float;
17128 end X;
17129 @end smallexample
17131 @noindent
17132 and the environment variable is set to @code{/stemp/}, then the files created
17133 will have the names:
17135 @smallexample
17136 /stemp/x.y
17137 /stemp/x.z
17138 @end smallexample
17140 @noindent
17141 These files are created when a value is initially written to the object, and
17142 the files are retained until manually deleted. This provides the persistence
17143 semantics. If no file exists, it means that no partition has assigned a value
17144 to the variable; in this case the initial value declared in the package
17145 will be used. This model ensures that there are no issues in synchronizing
17146 the elaboration process, since elaboration of passive packages elaborates the
17147 initial values, but does not create the files.
17149 The files are written using normal @code{Stream_IO} access.
17150 If you want to be able
17151 to communicate between programs or partitions running on different
17152 architectures, then you should use the XDR versions of the stream attribute
17153 routines, since these are architecture independent.
17155 If active synchronization is required for access to the variables in the
17156 shared passive package, then as described in the Ada Reference Manual, the
17157 package may contain protected objects used for this purpose. In this case
17158 a lock file (whose name is @file{___lock} (three underscores)
17159 is created in the shared memory directory.
17160 @cindex @file{___lock} file (for shared passive packages)
17161 This is used to provide the required locking
17162 semantics for proper protected object synchronization.
17164 As of January 2003, GNAT supports shared passive packages on all platforms
17165 except for OpenVMS.
17167 @node Code Generation for Array Aggregates
17168 @section Code Generation for Array Aggregates
17170 @menu
17171 * Static constant aggregates with static bounds::
17172 * Constant aggregates with unconstrained nominal types::
17173 * Aggregates with static bounds::
17174 * Aggregates with non-static bounds::
17175 * Aggregates in assignment statements::
17176 @end menu
17178 @noindent
17179 Aggregates have a rich syntax and allow the user to specify the values of
17180 complex data structures by means of a single construct.  As a result, the
17181 code generated for aggregates can be quite complex and involve loops, case
17182 statements and multiple assignments.  In the simplest cases, however, the
17183 compiler will recognize aggregates whose components and constraints are
17184 fully static, and in those cases the compiler will generate little or no
17185 executable code.  The following is an outline of the code that GNAT generates
17186 for various aggregate constructs.  For further details, you will find it
17187 useful to examine the output produced by the -gnatG flag to see the expanded
17188 source that is input to the code generator.  You may also want to examine
17189 the assembly code generated at various levels of optimization.
17191 The code generated for aggregates depends on the context, the component values,
17192 and the type.  In the context of an object declaration the code generated is
17193 generally simpler than in the case of an assignment.  As a general rule, static
17194 component values and static subtypes also lead to simpler code.
17196 @node Static constant aggregates with static bounds
17197 @subsection Static constant aggregates with static bounds
17199 @noindent
17200 For the declarations:
17201 @smallexample @c ada
17202     type One_Dim is array (1..10) of integer;
17203     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17204 @end smallexample
17206 @noindent
17207 GNAT generates no executable code: the constant ar0 is placed in static memory.
17208 The same is true for constant aggregates with named associations:
17210 @smallexample @c ada
17211     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17212     Cr3 : constant One_Dim := (others => 7777);
17213 @end smallexample
17215 @noindent
17216 The same is true for multidimensional constant arrays such as:
17218 @smallexample @c ada
17219     type two_dim is array (1..3, 1..3) of integer;
17220     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17221 @end smallexample
17223 @noindent
17224 The same is true for arrays of one-dimensional arrays: the following are
17225 static:
17227 @smallexample @c ada
17228 type ar1b  is array (1..3) of boolean;
17229 type ar_ar is array (1..3) of ar1b;
17230 None  : constant ar1b := (others => false);     --  fully static
17231 None2 : constant ar_ar := (1..3 => None);       --  fully static
17232 @end smallexample
17234 @noindent
17235 However, for multidimensional aggregates with named associations, GNAT will
17236 generate assignments and loops, even if all associations are static.  The
17237 following two declarations generate a loop for the first dimension, and
17238 individual component assignments for the second dimension:
17240 @smallexample @c ada
17241 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17242 Zero2: constant two_dim := (others => (others => 0));
17243 @end smallexample
17245 @node Constant aggregates with unconstrained nominal types
17246 @subsection Constant aggregates with unconstrained nominal types
17248 @noindent
17249 In such cases the aggregate itself establishes the subtype, so that
17250 associations with @code{others} cannot be used.  GNAT determines the
17251 bounds for the actual subtype of the aggregate, and allocates the
17252 aggregate statically as well.  No code is generated for the following:
17254 @smallexample @c ada
17255     type One_Unc is array (natural range <>) of integer;
17256     Cr_Unc : constant One_Unc := (12,24,36);
17257 @end smallexample
17259 @node Aggregates with static bounds
17260 @subsection Aggregates with static bounds
17262 @noindent
17263 In all previous examples the aggregate was the initial (and immutable) value
17264 of a constant.  If the aggregate initializes a variable, then code is generated
17265 for it as a combination of individual assignments and loops over the target
17266 object.  The declarations
17268 @smallexample @c ada
17269        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17270        Cr_Var2 : One_Dim := (others > -1);
17271 @end smallexample
17273 @noindent
17274 generate the equivalent of
17276 @smallexample @c ada
17277        Cr_Var1 (1) := 2;
17278        Cr_Var1 (2) := 3;
17279        Cr_Var1 (3) := 5;
17280        Cr_Var1 (4) := 11;
17282        for I in Cr_Var2'range loop
17283           Cr_Var2 (I) := -1;
17284        end loop;
17285 @end smallexample
17287 @node Aggregates with non-static bounds
17288 @subsection Aggregates with non-static bounds
17290 @noindent
17291 If the bounds of the aggregate are not statically compatible with the bounds
17292 of the nominal subtype  of the target, then constraint checks have to be
17293 generated on the bounds.  For a multidimensional array, constraint checks may
17294 have to be applied to sub-arrays individually, if they do not have statically
17295 compatible subtypes.
17297 @node Aggregates in assignment statements
17298 @subsection Aggregates in assignment statements
17300 @noindent
17301 In general, aggregate assignment requires the construction of a temporary,
17302 and a copy from the temporary to the target of the assignment.  This is because
17303 it is not always possible to convert the assignment into a series of individual
17304 component assignments.  For example, consider the simple case:
17306 @smallexample @c ada
17307         A := (A(2), A(1));
17308 @end smallexample
17310 @noindent
17311 This cannot be converted into:
17313 @smallexample @c ada
17314         A(1) := A(2);
17315         A(2) := A(1);
17316 @end smallexample
17318 @noindent
17319 So the aggregate has to be built first in a separate location, and then
17320 copied into the target.  GNAT recognizes simple cases where this intermediate
17321 step is not required, and the assignments can be performed in place, directly
17322 into the target.  The following sufficient criteria are applied:
17324 @itemize @bullet
17325 @item
17326 The bounds of the aggregate are static, and the associations are static.
17327 @item
17328 The components of the aggregate are static constants, names of
17329 simple variables that are not renamings, or expressions not involving
17330 indexed components whose operands obey these rules.
17331 @end itemize
17333 @noindent
17334 If any of these conditions are violated, the aggregate will be built in
17335 a temporary (created either by the front-end or the code generator) and then
17336 that temporary will be copied onto the target.
17338 @node The Size of Discriminated Records with Default Discriminants
17339 @section The Size of Discriminated Records with Default Discriminants
17341 @noindent
17342 If a discriminated type @code{T} has discriminants with default values, it is
17343 possible to declare an object of this type without providing an explicit
17344 constraint:
17346 @smallexample @c ada
17347 @group
17348 type Size is range 1..100;
17350 type Rec (D : Size := 15) is record
17351    Name : String (1..D);
17352 end T;
17354 Word : Rec;
17355 @end group
17356 @end smallexample
17358 @noindent
17359 Such an object is said to be @emph{unconstrained}.
17360 The discriminant of the object
17361 can be modified by a full assignment to the object, as long as it preserves the
17362 relation between the value of the discriminant, and the value of the components
17363 that depend on it:
17365 @smallexample @c ada
17366 @group
17367 Word := (3, "yes");
17369 Word := (5, "maybe");
17371 Word := (5, "no"); -- raises Constraint_Error
17372 @end group
17373 @end smallexample
17375 @noindent
17376 In order to support this behavior efficiently, an unconstrained object is
17377 given the maximum size that any value of the type requires. In the case
17378 above, @code{Word} has storage for the discriminant and for
17379 a @code{String} of length 100.
17380 It is important to note that unconstrained objects do not require dynamic
17381 allocation. It would be an improper implementation to place on the heap those
17382 components whose size depends on discriminants. (This improper implementation
17383 was used by some Ada83 compilers, where the @code{Name} component above
17384 would have
17385 been stored as a pointer to a dynamic string). Following the principle that
17386 dynamic storage management should never be introduced implicitly,
17387 an Ada compiler should reserve the full size for an unconstrained declared
17388 object, and place it on the stack.
17390 This maximum size approach
17391 has been a source of surprise to some users, who expect the default
17392 values of the discriminants to determine the size reserved for an
17393 unconstrained object: ``If the default is 15, why should the object occupy
17394 a larger size?''
17395 The answer, of course, is that the discriminant may be later modified,
17396 and its full range of values must be taken into account. This is why the
17397 declaration:
17399 @smallexample
17400 @group
17401 type Rec (D : Positive := 15) is record
17402    Name : String (1..D);
17403 end record;
17405 Too_Large : Rec;
17406 @end group
17407 @end smallexample
17409 @noindent
17410 is flagged by the compiler with a warning:
17411 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17412 because the required size includes @code{Positive'Last}
17413 bytes. As the first example indicates, the proper approach is to declare an
17414 index type of ``reasonable'' range so that unconstrained objects are not too
17415 large.
17417 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17418 created in the heap by means of an allocator, then it is @emph{not}
17419 unconstrained:
17420 it is constrained by the default values of the discriminants, and those values
17421 cannot be modified by full assignment. This is because in the presence of
17422 aliasing all views of the object (which may be manipulated by different tasks,
17423 say) must be consistent, so it is imperative that the object, once created,
17424 remain invariant.
17426 @node Strict Conformance to the Ada Reference Manual
17427 @section Strict Conformance to the Ada Reference Manual
17429 @noindent
17430 The dynamic semantics defined by the Ada Reference Manual impose a set of
17431 run-time checks to be generated. By default, the GNAT compiler will insert many
17432 run-time checks into the compiled code, including most of those required by the
17433 Ada Reference Manual. However, there are three checks that are not enabled
17434 in the default mode for efficiency reasons: arithmetic overflow checking for
17435 integer operations (including division by zero), checks for access before
17436 elaboration on subprogram calls, and stack overflow checking (most operating
17437 systems do not perform this check by default).
17439 Strict conformance to the Ada Reference Manual can be achieved by adding
17440 three compiler options for overflow checking for integer operations
17441 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17442 calls and generic instantiations (@option{-gnatE}), and stack overflow
17443 checking (@option{-fstack-check}).
17445 Note that the result of a floating point arithmetic operation in overflow and
17446 invalid situations, when the @code{Machine_Overflows} attribute of the result
17447 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17448 case for machines compliant with the IEEE floating-point standard, but on
17449 machines that are not fully compliant with this standard, such as Alpha, the
17450 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17451 behavior (although at the cost of a significant performance penalty), so
17452 infinite and NaN values are properly generated.
17455 @node Implementation of Ada 2012 Features
17456 @chapter Implementation of Ada 2012 Features
17457 @cindex Ada 2012 implementation status
17459 This chapter contains a complete list of Ada 2012 features that have been
17460 implemented as of GNAT version 6.4. Generally, these features are only
17461 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17462 @cindex @option{-gnat12} option
17463 or if the configuration pragma @code{Ada_2012} is used.
17464 @cindex pragma @code{Ada_2012}
17465 @cindex configuration pragma @code{Ada_2012}
17466 @cindex @code{Ada_2012} configuration pragma
17467 However, new pragmas, attributes, and restrictions are
17468 unconditionally available, since the Ada 95 standard allows the addition of
17469 new pragmas, attributes, and restrictions (there are exceptions, which are
17470 documented in the individual descriptions), and also certain packages
17471 were made available in earlier versions of Ada.
17473 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17474 This date shows the implementation date of the feature. Any wavefront
17475 subsequent to this date will contain the indicated feature, as will any
17476 subsequent releases. A date of 0000-00-00 means that GNAT has always
17477 implemented the feature, or implemented it as soon as it appeared as a
17478 binding interpretation.
17480 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17481 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17482 The features are ordered based on the relevant sections of the Ada
17483 Reference Manual (``RM'').  When a given AI relates to multiple points
17484 in the RM, the earliest is used.
17486 A complete description of the AIs may be found in
17487 @url{www.ada-auth.org/ai05-summary.html}.
17489 @itemize @bullet
17491 @item
17492 @emph{AI-0176 Quantified expressions (2010-09-29)}
17493 @cindex AI-0176 (Ada 2012 feature)
17495 @noindent
17496   Both universally and existentially quantified expressions are implemented.
17497   They use the new syntax for iterators proposed in AI05-139-2, as well as
17498   the standard Ada loop syntax.
17500 @noindent
17501   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
17503 @item
17504 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17505 @cindex AI-0079 (Ada 2012 feature)
17507 @noindent
17508   Wide characters in the unicode category @i{other_format} are now allowed in
17509   source programs between tokens, but not within a token such as an identifier.
17511 @noindent
17512   RM References:  2.01 (4/2)   2.02 (7)
17514 @item
17515 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17516 @cindex AI-0091 (Ada 2012 feature)
17518 @noindent
17519   Wide characters in the unicode category @i{other_format} are not permitted
17520   within  an identifier, since this can be a security problem. The error
17521   message for this case has been improved to be more specific, but GNAT has
17522   never allowed such characters to appear in identifiers.
17524 @noindent
17525   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)
17527 @item
17528 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
17529 @cindex AI-0100 (Ada 2012 feature)
17531 @noindent
17532   This AI is an earlier version of AI-163. It simplifies the rules
17533   for legal placement of pragmas. In the case of lists that allow pragmas, if
17534   the list may have no elements, then the list may consist solely of pragmas.
17536 @noindent
17537   RM References:  2.08 (7)
17539 @item
17540 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17541 @cindex AI-0163 (Ada 2012 feature)
17543 @noindent
17544   A statement sequence may be composed entirely of pragmas. It is no longer
17545   necessary to add a dummy @code{null} statement to make the sequence legal.
17547 @noindent
17548   RM References:  2.08 (7)   2.08 (16)
17551 @item
17552 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17553 @cindex AI-0080 (Ada 2012 feature)
17555 @noindent
17556   This is an editorial change only, described as non-testable in the AI.
17558 @noindent
17559   RM References:  3.01 (7)
17562 @item
17563 @emph{AI-0183 Aspect specifications (2010-08-16)}
17564 @cindex AI-0183 (Ada 2012 feature)
17566 @noindent
17567   Aspect specifications have been fully implemented except for pre and post-
17568   conditions, and type invariants, which have their own separate AI's. All
17569   forms of declarations listed in the AI are supported. The following is a
17570   list of the aspects supported (with GNAT implementation aspects marked)
17572 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17573 @item @code{Ada_2005} @tab                      -- GNAT
17574 @item @code{Ada_2012} @tab                      -- GNAT
17575 @item @code{Address} @tab
17576 @item @code{Alignment} @tab
17577 @item @code{Atomic} @tab
17578 @item @code{Atomic_Components} @tab
17579 @item @code{Bit_Order} @tab
17580 @item @code{Component_Size} @tab
17581 @item @code{Contract_Case} @tab                 -- GNAT
17582 @item @code{Discard_Names} @tab
17583 @item @code{External_Tag} @tab
17584 @item @code{Favor_Top_Level} @tab               -- GNAT
17585 @item @code{Inline} @tab
17586 @item @code{Inline_Always} @tab                 -- GNAT
17587 @item @code{Invariant} @tab                     -- GNAT
17588 @item @code{Machine_Radix} @tab
17589 @item @code{No_Return} @tab
17590 @item @code{Object_Size} @tab                   -- GNAT
17591 @item @code{Pack} @tab
17592 @item @code{Persistent_BSS} @tab                -- GNAT
17593 @item @code{Post} @tab
17594 @item @code{Pre} @tab
17595 @item @code{Predicate} @tab
17596 @item @code{Preelaborable_Initialization} @tab
17597 @item @code{Pure_Function} @tab                 -- GNAT
17598 @item @code{Remote_Access_Type} @tab            -- GNAT
17599 @item @code{Shared} @tab                        -- GNAT
17600 @item @code{Size} @tab
17601 @item @code{Storage_Pool} @tab
17602 @item @code{Storage_Size} @tab
17603 @item @code{Stream_Size} @tab
17604 @item @code{Suppress} @tab
17605 @item @code{Suppress_Debug_Info} @tab           -- GNAT
17606 @item @code{Test_Case} @tab                     -- GNAT
17607 @item @code{Type_Invariant} @tab
17608 @item @code{Unchecked_Union} @tab
17609 @item @code{Universal_Aliasing} @tab            -- GNAT
17610 @item @code{Unmodified} @tab                    -- GNAT
17611 @item @code{Unreferenced} @tab                  -- GNAT
17612 @item @code{Unreferenced_Objects} @tab          -- GNAT
17613 @item @code{Unsuppress} @tab
17614 @item @code{Value_Size} @tab                    -- GNAT
17615 @item @code{Volatile} @tab
17616 @item @code{Volatile_Components}
17617 @item @code{Warnings} @tab                      -- GNAT
17618 @end multitable
17620 @noindent
17621   Note that for aspects with an expression, e.g. @code{Size}, the expression is
17622   treated like a default expression (visibility is analyzed at the point of
17623   occurrence of the aspect, but evaluation of the expression occurs at the
17624   freeze point of the entity involved.
17626 @noindent
17627   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
17628   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
17629   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
17630   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
17631   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
17632   13.03.01 (0)
17635 @item
17636 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17637 @cindex AI-0128 (Ada 2012 feature)
17639 @noindent
17640   If an equality operator ("=") is declared for a type, then the implicitly
17641   declared inequality operator ("/=") is a primitive operation of the type.
17642   This is the only reasonable interpretation, and is the one always implemented
17643   by GNAT, but the RM was not entirely clear in making this point.
17645 @noindent
17646   RM References:  3.02.03 (6)   6.06 (6)
17648 @item
17649 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17650 @cindex AI-0003 (Ada 2012 feature)
17652 @noindent
17653    In Ada 2012, a qualified expression is considered to be syntactically a name,
17654    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17655    useful in disambiguating some cases of overloading.
17657 @noindent
17658   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
17659   5.04 (7)
17661 @item
17662 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17663 @cindex AI-0120 (Ada 2012 feature)
17665 @noindent
17666   This is an RM editorial change only. The section that lists objects that are
17667   constant failed to include the current instance of a protected object
17668   within a protected function. This has always been treated as a constant
17669   in GNAT.
17671 @noindent
17672   RM References:  3.03 (21)
17674 @item
17675 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17676 @cindex AI-0008 (Ada 2012 feature)
17678 @noindent
17679   The wording in the RM implied that if you have a general access to a
17680   constrained object, it could be used to modify the discriminants. This was
17681   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17682   has always done so in this situation.
17684 @noindent
17685   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
17688 @item
17689 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17690 @cindex AI-0093 (Ada 2012 feature)
17692 @noindent
17693   This is an editorial change only, to make more widespread use of the Ada 2012
17694   ``immutably limited''.
17696 @noindent
17697   RM References:  3.03 (23.4/3)
17701 @item
17702 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17703 @cindex AI-0096 (Ada 2012 feature)
17705 @noindent
17706   In general it is illegal for a type derived from a formal limited type to be
17707   nonlimited.  This AI makes an exception to this rule: derivation is legal
17708   if it appears in the private part of the generic, and the formal type is not
17709   tagged. If the type is tagged, the legality check must be applied to the
17710   private part of the package.
17712 @noindent
17713   RM References:  3.04 (5.1/2)   6.02 (7)
17716 @item
17717 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17718 @cindex AI-0181 (Ada 2012 feature)
17720 @noindent
17721   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17722   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17723   @code{Image} and @code{Value} attributes for the character types. Strictly
17724   speaking this is an inconsistency with Ada 95, but in practice the use of
17725   these attributes is so obscure that it will not cause problems.
17727 @noindent
17728   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
17731 @item
17732 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17733 @cindex AI-0182 (Ada 2012 feature)
17735 @noindent
17736   This AI allows @code{Character'Value} to accept the string @code{'?'} where
17737   @code{?} is any character including non-graphic control characters. GNAT has
17738   always accepted such strings. It also allows strings such as
17739   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17740   permission and raises @code{Constraint_Error}, as is certainly still
17741   permitted.
17743 @noindent
17744   RM References:  3.05 (56/2)
17747 @item
17748 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17749 @cindex AI-0214 (Ada 2012 feature)
17751 @noindent
17752   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17753   to have default expressions by allowing them when the type is limited. It
17754   is often useful to define a default value for a discriminant even though
17755   it can't be changed by assignment.
17757 @noindent
17758   RM References:  3.07 (9.1/2)   3.07.02 (3)
17761 @item
17762 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17763 @cindex AI-0102 (Ada 2012 feature)
17765 @noindent
17766   It is illegal to assign an anonymous access constant to an anonymous access
17767   variable. The RM did not have a clear rule to prevent this, but GNAT has
17768   always generated an error for this usage.
17770 @noindent
17771   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
17774 @item
17775 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17776 @cindex AI-0158 (Ada 2012 feature)
17778 @noindent
17779   This AI extends the syntax of membership tests to simplify complex conditions
17780   that can be expressed as membership in a subset of values of any type. It
17781   introduces syntax for a list of expressions that may be used in loop contexts
17782   as well.
17784 @noindent
17785   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
17788 @item
17789 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17790 @cindex AI-0173 (Ada 2012 feature)
17792 @noindent
17793   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17794   with the tag of an abstract type, and @code{False} otherwise.
17796 @noindent
17797   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
17801 @item
17802 @emph{AI-0076 function with controlling result (0000-00-00)}
17803 @cindex AI-0076 (Ada 2012 feature)
17805 @noindent
17806   This is an editorial change only. The RM defines calls with controlling
17807   results, but uses the term ``function with controlling result'' without an
17808   explicit definition.
17810 @noindent
17811   RM References:  3.09.02 (2/2)
17814 @item
17815 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17816 @cindex AI-0126 (Ada 2012 feature)
17818 @noindent
17819   This AI clarifies dispatching rules, and simply confirms that dispatching
17820   executes the operation of the parent type when there is no explicitly or
17821   implicitly declared operation for the descendant type. This has always been
17822   the case in all versions of GNAT.
17824 @noindent
17825   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
17828 @item
17829 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17830 @cindex AI-0097 (Ada 2012 feature)
17832 @noindent
17833   The RM as written implied that in some cases it was possible to create an
17834   object of an abstract type, by having an abstract extension inherit a non-
17835   abstract constructor from its parent type. This mistake has been corrected
17836   in GNAT and in the RM, and this construct is now illegal.
17838 @noindent
17839   RM References:  3.09.03 (4/2)
17842 @item
17843 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17844 @cindex AI-0203 (Ada 2012 feature)
17846 @noindent
17847   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17848   permitted such usage.
17850 @noindent
17851   RM References:  3.09.03 (8/3)
17854 @item
17855 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
17856 @cindex AI-0198 (Ada 2012 feature)
17858 @noindent
17859   This AI resolves a conflict between two rules involving inherited abstract
17860   operations and predefined operators. If a derived numeric type inherits
17861   an abstract operator, it overrides the predefined one. This interpretation
17862   was always the one implemented in GNAT.
17864 @noindent
17865   RM References:  3.09.03 (4/3)
17867 @item
17868 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17869 @cindex AI-0073 (Ada 2012 feature)
17871 @noindent
17872   This AI covers a number of issues regarding returning abstract types. In
17873   particular generic functions cannot have abstract result types or access
17874   result types designated an abstract type. There are some other cases which
17875   are detailed in the AI. Note that this binding interpretation has not been
17876   retrofitted to operate before Ada 2012 mode, since it caused a significant
17877   number of regressions.
17879 @noindent
17880   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
17883 @item
17884 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17885 @cindex AI-0070 (Ada 2012 feature)
17887 @noindent
17888   This is an editorial change only, there are no testable consequences short of
17889   checking for the absence of generated code for an interface declaration.
17891 @noindent
17892   RM References:  3.09.04 (18/2)
17895 @item
17896 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17897 @cindex AI-0208 (Ada 2012 feature)
17899 @noindent
17900   The wording in the Ada 2005 RM concerning characteristics of incomplete views
17901   was incorrect and implied that some programs intended to be legal were now
17902   illegal. GNAT had never considered such programs illegal, so it has always
17903   implemented the intent of this AI.
17905 @noindent
17906   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
17909 @item
17910 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17911 @cindex AI-0162 (Ada 2012 feature)
17913 @noindent
17914   Incomplete types are made more useful by allowing them to be completed by
17915   private types and private extensions.
17917 @noindent
17918   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
17922 @item
17923 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17924 @cindex AI-0098 (Ada 2012 feature)
17926 @noindent
17927   An unintentional omission in the RM implied some inconsistent restrictions on
17928   the use of anonymous access to subprogram values. These restrictions were not
17929   intentional, and have never been enforced by GNAT.
17931 @noindent
17932   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
17935 @item
17936 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17937 @cindex AI-0199 (Ada 2012 feature)
17939 @noindent
17940   A choice list in a record aggregate can include several components of
17941   (distinct) anonymous access types as long as they have matching designated
17942   subtypes.
17944 @noindent
17945   RM References:  4.03.01 (16)
17948 @item
17949 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17950 @cindex AI-0220 (Ada 2012 feature)
17952 @noindent
17953   This AI addresses a wording problem in the RM that appears to permit some
17954   complex cases of aggregates with non-static discriminants. GNAT has always
17955   implemented the intended semantics.
17957 @noindent
17958   RM References:  4.03.01 (17)
17960 @item
17961 @emph{AI-0147 Conditional expressions (2009-03-29)}
17962 @cindex AI-0147 (Ada 2012 feature)
17964 @noindent
17965   Conditional expressions are permitted. The form of such an expression is:
17967 @smallexample
17968     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17969 @end smallexample
17971   The parentheses can be omitted in contexts where parentheses are present
17972   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17973   clause is omitted, @b{else True} is assumed;
17974   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17975   @emph{(A implies B)} in standard logic.
17977 @noindent
17978   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
17979   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
17982 @item
17983 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17984 @cindex AI-0037 (Ada 2012 feature)
17986 @noindent
17987   This AI confirms that an association of the form @code{Indx => <>} in an
17988   array aggregate must raise @code{Constraint_Error} if @code{Indx}
17989   is out of range. The RM specified a range check on other associations, but
17990   not when the value of the association was defaulted. GNAT has always inserted
17991   a constraint check on the index value.
17993 @noindent
17994   RM References:  4.03.03 (29)
17997 @item
17998 @emph{AI-0123 Composability of equality (2010-04-13)}
17999 @cindex AI-0123 (Ada 2012 feature)
18001 @noindent
18002   Equality of untagged record composes, so that the predefined equality for a
18003   composite type that includes a component of some untagged record type
18004   @code{R} uses the equality operation of @code{R} (which may be user-defined
18005   or predefined). This makes the behavior of untagged records identical to that
18006   of tagged types in this respect.
18008   This change is an incompatibility with previous versions of Ada, but it
18009   corrects a non-uniformity that was often a source of confusion. Analysis of
18010   a large number of industrial programs indicates that in those rare cases
18011   where a composite type had an untagged record component with a user-defined
18012   equality, either there was no use of the composite equality, or else the code
18013   expected the same composability as for tagged types, and thus had a bug that
18014   would be fixed by this change.
18016 @noindent
18017   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
18018   8.05.04 (8)
18021 @item
18022 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18023 @cindex AI-0088 (Ada 2012 feature)
18025 @noindent
18026   This AI clarifies the equivalence rule given for the dynamic semantics of
18027   exponentiation: the value of the operation can be obtained by repeated
18028   multiplication, but the operation can be implemented otherwise (for example
18029   using the familiar divide-by-two-and-square algorithm, even if this is less
18030   accurate), and does not imply repeated reads of a volatile base.
18032 @noindent
18033   RM References:  4.05.06 (11)
18035 @item
18036 @emph{AI-0188 Case expressions (2010-01-09)}
18037 @cindex AI-0188 (Ada 2012 feature)
18039 @noindent
18040   Case expressions are permitted. This allows use of constructs such as:
18041 @smallexample
18042   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18043 @end smallexample
18045 @noindent
18046   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
18048 @item
18049 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18050 @cindex AI-0104 (Ada 2012 feature)
18052 @noindent
18053   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18054   @code{Constraint_Error} because the default value of the allocated object is
18055   @b{null}. This useless construct is illegal in Ada 2012.
18057 @noindent
18058   RM References:  4.08 (2)
18060 @item
18061 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18062 @cindex AI-0157 (Ada 2012 feature)
18064 @noindent
18065   Allocation and Deallocation from an empty storage pool (i.e. allocation or
18066   deallocation of a pointer for which a static storage size clause of zero
18067   has been given) is now illegal and is detected as such. GNAT
18068   previously gave a warning but not an error.
18070 @noindent
18071   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
18073 @item
18074 @emph{AI-0179 Statement not required after label (2010-04-10)}
18075 @cindex AI-0179 (Ada 2012 feature)
18077 @noindent
18078   It is not necessary to have a statement following a label, so a label
18079   can appear at the end of a statement sequence without the need for putting a
18080   null statement afterwards, but it is not allowable to have only labels and
18081   no real statements in a statement sequence.
18083 @noindent
18084   RM References:  5.01 (2)
18087 @item
18088 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18089 @cindex AI-139-2 (Ada 2012 feature)
18091 @noindent
18092   The new syntax for iterating over arrays and containers is now implemented.
18093   Iteration over containers is for now limited to read-only iterators. Only
18094   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
18096 @noindent
18097   RM References:  5.05
18099 @item
18100 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18101 @cindex AI-0134 (Ada 2012 feature)
18103 @noindent
18104   For full conformance, the profiles of anonymous-access-to-subprogram
18105   parameters must match. GNAT has always enforced this rule.
18107 @noindent
18108   RM References:  6.03.01 (18)
18110 @item
18111 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18112 @cindex AI-0207 (Ada 2012 feature)
18114 @noindent
18115   This AI confirms that access_to_constant indication must match for mode
18116   conformance. This was implemented in GNAT when the qualifier was originally
18117   introduced in Ada 2005.
18119 @noindent
18120   RM References:  6.03.01 (16/2)
18123 @item
18124 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18125 @cindex AI-0046 (Ada 2012 feature)
18127 @noindent
18128   For full conformance, in the case of access parameters, the null exclusion
18129   must match (either both or neither must have @code{@b{not null}}).
18131 @noindent
18132   RM References:  6.03.02 (18)
18135 @item
18136 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18137 @cindex AI-0118 (Ada 2012 feature)
18139 @noindent
18140   This AI clarifies the rules for named associations in subprogram calls and
18141   generic instantiations. The rules have been in place since Ada 83.
18143 @noindent
18144   RM References:  6.04.01 (2)   12.03 (9)
18147 @item
18148 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18149 @cindex AI-0196 (Ada 2012 feature)
18151 @noindent
18152   Null exclusion checks are not made for @code{@b{out}} parameters when
18153   evaluating the actual parameters. GNAT has never generated these checks.
18155 @noindent
18156   RM References:  6.04.01 (13)
18158 @item
18159 @emph{AI-0015 Constant return objects (0000-00-00)}
18160 @cindex AI-0015 (Ada 2012 feature)
18162 @noindent
18163   The return object declared in an @i{extended_return_statement} may be
18164   declared constant. This was always intended, and GNAT has always allowed it.
18166 @noindent
18167   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
18168   6.05 (5.7/2)
18171 @item
18172 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18173 @cindex AI-0032 (Ada 2012 feature)
18175 @noindent
18176   If a function returns a class-wide type, the object of an extended return
18177   statement can be declared with a specific type that is covered by the class-
18178   wide type. This has been implemented in GNAT since the introduction of
18179   extended returns. Note AI-0103 complements this AI by imposing matching
18180   rules for constrained return types.
18182 @noindent
18183   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
18184   6.05 (8/2)
18186 @item
18187 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18188 @cindex AI-0103 (Ada 2012 feature)
18190 @noindent
18191   If the return subtype of a function is an elementary type or a constrained
18192   type, the subtype indication in an extended return statement must match
18193   statically this return subtype.
18195 @noindent
18196   RM References:  6.05 (5.2/2)
18199 @item
18200 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18201 @cindex AI-0058 (Ada 2012 feature)
18203 @noindent
18204   The RM had some incorrect wording implying wrong treatment of abnormal
18205   completion in an extended return. GNAT has always implemented the intended
18206   correct semantics as described by this AI.
18208 @noindent
18209   RM References:  6.05 (22/2)
18212 @item
18213 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18214 @cindex AI-0050 (Ada 2012 feature)
18216 @noindent
18217   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
18218   not take advantage of these incorrect permissions in any case.
18220 @noindent
18221   RM References:  6.05 (24/2)
18224 @item
18225 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18226 @cindex AI-0125 (Ada 2012 feature)
18228 @noindent
18229   In Ada 2012, the declaration of a primitive operation of a type extension
18230   or private extension can also override an inherited primitive that is not
18231   visible at the point of this declaration.
18233 @noindent
18234   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
18236 @item
18237 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18238 @cindex AI-0062 (Ada 2012 feature)
18240 @noindent
18241   A full constant may have a null exclusion even if its associated deferred
18242   constant does not. GNAT has always allowed this.
18244 @noindent
18245   RM References:  7.04 (6/2)   7.04 (7.1/2)
18248 @item
18249 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18250 @cindex AI-0178 (Ada 2012 feature)
18252 @noindent
18253   This AI clarifies the role of incomplete views and plugs an omission in the
18254   RM. GNAT always correctly restricted the use of incomplete views and types.
18256 @noindent
18257   RM References:  7.05 (3/2)   7.05 (6/2)
18259 @item
18260 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18261 @cindex AI-0087 (Ada 2012 feature)
18263 @noindent
18264   The actual for a formal nonlimited derived type cannot be limited. In
18265   particular, a formal derived type that extends a limited interface but which
18266   is not explicitly limited cannot be instantiated with a limited type.
18268 @noindent
18269   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
18271 @item
18272 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18273 @cindex AI-0099 (Ada 2012 feature)
18275 @noindent
18276   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18277   and therefore depends on the run-time characteristics of an object (i.e. its
18278   tag) and not on its nominal type. As the AI indicates: ``we do not expect
18279   this to affect any implementation''.
18281 @noindent
18282   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
18286 @item
18287 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18288 @cindex AI-0064 (Ada 2012 feature)
18290 @noindent
18291   This is an editorial change only. The intended behavior is already checked
18292   by an existing ACATS test, which GNAT has always executed correctly.
18294 @noindent
18295   RM References:  7.06.01 (17.1/1)
18297 @item
18298 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18299 @cindex AI-0026 (Ada 2012 feature)
18301 @noindent
18302   Record representation clauses concerning Unchecked_Union types cannot mention
18303   the discriminant of the type. The type of a component declared in the variant
18304   part of an Unchecked_Union cannot be controlled, have controlled components,
18305   nor have protected or task parts. If an Unchecked_Union type is declared
18306   within the body of a generic unit or its descendants, then the type of a
18307   component declared in the variant part cannot be a formal private type or a
18308   formal private extension declared within the same generic unit.
18310 @noindent
18311   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
18314 @item
18315 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18316 @cindex AI-0205 (Ada 2012 feature)
18318 @noindent
18319   This AI corrects a simple omission in the RM. Return objects have always
18320   been visible within an extended return statement.
18322 @noindent
18323   RM References:  8.03 (17)
18326 @item
18327 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18328 @cindex AI-0042 (Ada 2012 feature)
18330 @noindent
18331   This AI fixes a wording gap in the RM. An operation of a synchronized
18332   interface can be implemented by a protected or task entry, but the abstract
18333   operation is not being overridden in the usual sense, and it must be stated
18334   separately that this implementation is legal. This has always been the case
18335   in GNAT.
18337 @noindent
18338   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
18340 @item
18341 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18342 @cindex AI-0030 (Ada 2012 feature)
18344 @noindent
18345   Requeue is permitted to a protected, synchronized or task interface primitive
18346   providing it is known that the overriding operation is an entry. Otherwise
18347   the requeue statement has the same effect as a procedure call. Use of pragma
18348   @code{Implemented} provides a way to impose a static requirement on the
18349   overriding operation by adhering to one of the implementation kinds: entry,
18350   protected procedure or any of the above.
18352 @noindent
18353   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
18354   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
18357 @item
18358 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18359 @cindex AI-0201 (Ada 2012 feature)
18361 @noindent
18362   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18363   attribute, then individual components may not be addressable by independent
18364   tasks. However, if the representation clause has no effect (is confirming),
18365   then independence is not compromised. Furthermore, in GNAT, specification of
18366   other appropriately addressable component sizes (e.g. 16 for 8-bit
18367   characters) also preserves independence. GNAT now gives very clear warnings
18368   both for the declaration of such a type, and for any assignment to its components.
18370 @noindent
18371   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
18373 @item
18374 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18375 @cindex AI-0009 (Ada 2012 feature)
18377 @noindent
18378   This AI introduces the new pragmas @code{Independent} and
18379   @code{Independent_Components},
18380   which control guaranteeing independence of access to objects and components.
18381   The AI also requires independence not unaffected by confirming rep clauses.
18383 @noindent
18384   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
18385   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
18388 @item
18389 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18390 @cindex AI-0072 (Ada 2012 feature)
18392 @noindent
18393   This AI clarifies that task signalling for reading @code{'Terminated} only
18394   occurs if the result is True. GNAT semantics has always been consistent with
18395   this notion of task signalling.
18397 @noindent
18398   RM References:  9.10 (6.1/1)
18400 @item
18401 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18402 @cindex AI-0108 (Ada 2012 feature)
18404 @noindent
18405   This AI confirms that an incomplete type from a limited view does not have
18406   discriminants. This has always been the case in GNAT.
18408 @noindent
18409   RM References:  10.01.01 (12.3/2)
18411 @item
18412 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18413 @cindex AI-0129 (Ada 2012 feature)
18415 @noindent
18416   This AI clarifies the description of limited views: a limited view of a
18417   package includes only one view of a type that has an incomplete declaration
18418   and a full declaration (there is no possible ambiguity in a client package).
18419   This AI also fixes an omission: a nested package in the private part has no
18420   limited view. GNAT always implemented this correctly.
18422 @noindent
18423   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
18427 @item
18428 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18429 @cindex AI-0077 (Ada 2012 feature)
18431 @noindent
18432   This AI clarifies that a declaration does not include a context clause,
18433   and confirms that it is illegal to have a context in which both a limited
18434   and a nonlimited view of a package are accessible. Such double visibility
18435   was always rejected by GNAT.
18437 @noindent
18438   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
18440 @item
18441 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18442 @cindex AI-0122 (Ada 2012 feature)
18444 @noindent
18445   This AI clarifies the visibility of private children of generic units within
18446   instantiations of a parent. GNAT has always handled this correctly.
18448 @noindent
18449   RM References:  10.01.02 (12/2)
18453 @item
18454 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18455 @cindex AI-0040 (Ada 2012 feature)
18457 @noindent
18458   This AI confirms that a limited with clause in a child unit cannot name
18459   an ancestor of the unit. This has always been checked in GNAT.
18461 @noindent
18462   RM References:  10.01.02 (20/2)
18464 @item
18465 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18466 @cindex AI-0132 (Ada 2012 feature)
18468 @noindent
18469   This AI fills a gap in the description of library unit pragmas. The pragma
18470   clearly must apply to a library unit, even if it does not carry the name
18471   of the enclosing unit. GNAT has always enforced the required check.
18473 @noindent
18474   RM References:  10.01.05 (7)
18477 @item
18478 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18479 @cindex AI-0034 (Ada 2012 feature)
18481 @noindent
18482   The RM makes certain limited with clauses illegal because of categorization
18483   considerations, when the corresponding normal with would be legal. This is
18484   not intended, and GNAT has always implemented the recommended behavior.
18486 @noindent
18487   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
18490 @item
18491 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18492 @cindex AI-0035 (Ada 2012 feature)
18494 @noindent
18495   This AI remedies some inconsistencies in the legality rules for Pure units.
18496   Derived access types are legal in a pure unit (on the assumption that the
18497   rule for a zero storage pool size has been enforced on the ancestor type).
18498   The rules are enforced in generic instances and in subunits. GNAT has always
18499   implemented the recommended behavior.
18501 @noindent
18502   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)
18505 @item
18506 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18507 @cindex AI-0219 (Ada 2012 feature)
18509 @noindent
18510   This AI refines the rules for the cases with limited parameters which do not
18511   allow the implementations to omit ``redundant''. GNAT now properly conforms
18512   to the requirements of this binding interpretation.
18514 @noindent
18515   RM References:  10.02.01 (18/2)
18517 @item
18518 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18519 @cindex AI-0043 (Ada 2012 feature)
18521 @noindent
18522   This AI covers various omissions in the RM regarding the raising of
18523   exceptions. GNAT has always implemented the intended semantics.
18525 @noindent
18526   RM References:  11.04.01 (10.1/2)   11 (2)
18529 @item
18530 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18531 @cindex AI-0200 (Ada 2012 feature)
18533 @noindent
18534   This AI plugs a gap in the RM which appeared to allow some obviously intended
18535   illegal instantiations. GNAT has never allowed these instantiations.
18537 @noindent
18538   RM References:  12.07 (16)
18541 @item
18542 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18543 @cindex AI-0112 (Ada 2012 feature)
18545 @noindent
18546   This AI concerns giving names to various representation aspects, but the
18547   practical effect is simply to make the use of duplicate
18548   @code{Atomic}[@code{_Components}],
18549   @code{Volatile}[@code{_Components}] and
18550   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18551   now performs this required check.
18553 @noindent
18554   RM References:  13.01 (8)
18556 @item
18557 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18558 @cindex AI-0106 (Ada 2012 feature)
18560 @noindent
18561   The RM appeared to allow representation pragmas on generic formal parameters,
18562   but this was not intended, and GNAT has never permitted this usage.
18564 @noindent
18565   RM References:  13.01 (9.1/1)
18568 @item
18569 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18570 @cindex AI-0012 (Ada 2012 feature)
18572 @noindent
18573   It is now illegal to give an inappropriate component size or a pragma
18574   @code{Pack} that attempts to change the component size in the case of atomic
18575   or aliased components. Previously GNAT ignored such an attempt with a
18576   warning.
18578 @noindent
18579   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
18582 @item
18583 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18584 @cindex AI-0039 (Ada 2012 feature)
18586 @noindent
18587   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18588   for stream attributes, but these were never useful and are now illegal. GNAT
18589   has always regarded such expressions as illegal.
18591 @noindent
18592   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
18595 @item
18596 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18597 @cindex AI-0095 (Ada 2012 feature)
18599 @noindent
18600   The prefix of @code{'Address} cannot statically denote a subprogram with
18601   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18602   @code{Program_Error} if the prefix denotes a subprogram with convention
18603   @code{Intrinsic}.
18605 @noindent
18606   RM References:  13.03 (11/1)
18609 @item
18610 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18611 @cindex AI-0116 (Ada 2012 feature)
18613 @noindent
18614   This AI requires that the alignment of a class-wide object be no greater
18615   than the alignment of any type in the class. GNAT has always followed this
18616   recommendation.
18618 @noindent
18619   RM References:  13.03 (29)   13.11 (16)
18622 @item
18623 @emph{AI-0146 Type invariants (2009-09-21)}
18624 @cindex AI-0146 (Ada 2012 feature)
18626 @noindent
18627   Type invariants may be specified for private types using the aspect notation.
18628   Aspect @code{Type_Invariant} may be specified for any private type,
18629   @code{Type_Invariant'Class} can
18630   only be specified for tagged types, and is inherited by any descendent of the
18631   tagged types. The invariant is a boolean expression that is tested for being
18632   true in the following situations: conversions to the private type, object
18633   declarations for the private type that are default initialized, and
18634   [@b{in}] @b{out}
18635   parameters and returned result on return from any primitive operation for
18636   the type that is visible to a client.
18637   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
18638   @code{Invariant'Class} for @code{Type_Invariant'Class}.
18640 @noindent
18641   RM References:  13.03.03 (00)
18643 @item
18644 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18645 @cindex AI-0078 (Ada 2012 feature)
18647 @noindent
18648   In Ada 2012, compilers are required to support unchecked conversion where the
18649   target alignment is a multiple of the source alignment. GNAT always supported
18650   this case (and indeed all cases of differing alignments, doing copies where
18651   required if the alignment was reduced).
18653 @noindent
18654   RM References:  13.09 (7)
18657 @item
18658 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18659 @cindex AI-0195 (Ada 2012 feature)
18661 @noindent
18662   The handling of invalid values is now designated to be implementation
18663   defined. This is a documentation change only, requiring Annex M in the GNAT
18664   Reference Manual to document this handling.
18665   In GNAT, checks for invalid values are made
18666   only when necessary to avoid erroneous behavior. Operations like assignments
18667   which cannot cause erroneous behavior ignore the possibility of invalid
18668   values and do not do a check. The date given above applies only to the
18669   documentation change, this behavior has always been implemented by GNAT.
18671 @noindent
18672   RM References:  13.09.01 (10)
18674 @item
18675 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18676 @cindex AI-0193 (Ada 2012 feature)
18678 @noindent
18679   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18680   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18681   of size.
18683 @noindent
18684   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
18685   13.11.01 (2)   13.11.01 (3)
18688 @item
18689 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18690 @cindex AI-0177 (Ada 2012 feature)
18692 @noindent
18693   The new Ada 2012 notion of parameterized expressions is implemented. The form
18694   is:
18695 @smallexample
18696   @i{function specification} @b{is} (@i{expression})
18697 @end smallexample
18699 @noindent
18700   This is exactly equivalent to the
18701   corresponding function body that returns the expression, but it can appear
18702   in a package spec. Note that the expression must be parenthesized.
18704 @noindent
18705   RM References:  13.11.01 (3/2)
18707 @item
18708 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18709 @cindex AI-0033 (Ada 2012 feature)
18711 @noindent
18712   Neither of these two pragmas may appear within a generic template, because
18713   the generic might be instantiated at other than the library level.
18715 @noindent
18716   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
18719 @item
18720 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18721 @cindex AI-0161 (Ada 2012 feature)
18723 @noindent
18724   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18725   of the default stream attributes for elementary types. If this restriction is
18726   in force, then it is necessary to provide explicit subprograms for any
18727   stream attributes used.
18729 @noindent
18730   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
18732 @item
18733 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18734 @cindex AI-0194 (Ada 2012 feature)
18736 @noindent
18737   The @code{Stream_Size} attribute returns the default number of bits in the
18738   stream representation of the given type.
18739   This value is not affected by the presence
18740   of stream subprogram attributes for the type. GNAT has always implemented
18741   this interpretation.
18743 @noindent
18744   RM References:  13.13.02 (1.2/2)
18746 @item
18747 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18748 @cindex AI-0109 (Ada 2012 feature)
18750 @noindent
18751   This AI is an editorial change only. It removes the need for a tag check
18752   that can never fail.
18754 @noindent
18755   RM References:  13.13.02 (34/2)
18757 @item
18758 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18759 @cindex AI-0007 (Ada 2012 feature)
18761 @noindent
18762   The RM as written appeared to limit the possibilities of declaring read
18763   attribute procedures for private scalar types. This limitation was not
18764   intended, and has never been enforced by GNAT.
18766 @noindent
18767   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
18770 @item
18771 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18772 @cindex AI-0065 (Ada 2012 feature)
18774 @noindent
18775   This AI clarifies the fact that all remote access types support external
18776   streaming. This fixes an obvious oversight in the definition of the
18777   language, and GNAT always implemented the intended correct rules.
18779 @noindent
18780   RM References:  13.13.02 (52/2)
18782 @item
18783 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18784 @cindex AI-0019 (Ada 2012 feature)
18786 @noindent
18787   The RM suggests that primitive subprograms of a specific tagged type are
18788   frozen when the tagged type is frozen. This would be an incompatible change
18789   and is not intended. GNAT has never attempted this kind of freezing and its
18790   behavior is consistent with the recommendation of this AI.
18792 @noindent
18793   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)
18795 @item
18796 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18797 @cindex AI-0017 (Ada 2012 feature)
18799 @noindent
18800   So-called ``Taft-amendment types'' (i.e., types that are completed in package
18801   bodies) are not frozen by the occurrence of bodies in the
18802   enclosing declarative part. GNAT always implemented this properly.
18804 @noindent
18805   RM References:  13.14 (3/1)
18808 @item
18809 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18810 @cindex AI-0060 (Ada 2012 feature)
18812 @noindent
18813   This AI extends the definition of remote access types to include access
18814   to limited, synchronized, protected or task class-wide interface types.
18815   GNAT already implemented this extension.
18817 @noindent
18818   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
18820 @item
18821 @emph{AI-0114 Classification of letters (0000-00-00)}
18822 @cindex AI-0114 (Ada 2012 feature)
18824 @noindent
18825   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18826   181 (@code{MICRO SIGN}), and
18827   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18828   lower case letters by Unicode.
18829   However, they are not allowed in identifiers, and they
18830   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18831   This behavior is consistent with that defined in Ada 95.
18833 @noindent
18834   RM References:  A.03.02 (59)   A.04.06 (7)
18837 @item
18838 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18839 @cindex AI-0185 (Ada 2012 feature)
18841 @noindent
18842   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18843   classification functions for @code{Wide_Character} and
18844   @code{Wide_Wide_Character}, as well as providing
18845   case folding routines for @code{Wide_[Wide_]Character} and
18846   @code{Wide_[Wide_]String}.
18848 @noindent
18849   RM References:  A.03.05 (0)   A.03.06 (0)
18852 @item
18853 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18854 @cindex AI-0031 (Ada 2012 feature)
18856 @noindent
18857   A new version of @code{Find_Token} is added to all relevant string packages,
18858   with an extra parameter @code{From}. Instead of starting at the first
18859   character of the string, the search for a matching Token starts at the
18860   character indexed by the value of @code{From}.
18861   These procedures are available in all versions of Ada
18862   but if used in versions earlier than Ada 2012 they will generate a warning
18863   that an Ada 2012 subprogram is being used.
18865 @noindent
18866   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
18867   A.04.05 (46)
18870 @item
18871 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18872 @cindex AI-0056 (Ada 2012 feature)
18874 @noindent
18875   The wording in the Ada 2005 RM implied an incompatible handling of the
18876   @code{Index} functions, resulting in raising an exception instead of
18877   returning zero in some situations.
18878   This was not intended and has been corrected.
18879   GNAT always returned zero, and is thus consistent with this AI.
18881 @noindent
18882   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
18885 @item
18886 @emph{AI-0137 String encoding package (2010-03-25)}
18887 @cindex AI-0137 (Ada 2012 feature)
18889 @noindent
18890   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18891   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18892   and @code{Wide_Wide_Strings} have been
18893   implemented. These packages (whose documentation can be found in the spec
18894   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18895   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18896   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18897   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18898   UTF-16), as well as conversions between the different UTF encodings. With
18899   the exception of @code{Wide_Wide_Strings}, these packages are available in
18900   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18901   The @code{Wide_Wide_Strings package}
18902   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18903   mode since it uses @code{Wide_Wide_Character}).
18905 @noindent
18906   RM References:  A.04.11
18908 @item
18909 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18910 @cindex AI-0038 (Ada 2012 feature)
18912 @noindent
18913   These are minor errors in the description on three points. The intent on
18914   all these points has always been clear, and GNAT has always implemented the
18915   correct intended semantics.
18917 @noindent
18918   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)
18920 @item
18921 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18922 @cindex AI-0044 (Ada 2012 feature)
18924 @noindent
18925   This AI places restrictions on allowed instantiations of generic containers.
18926   These restrictions are not checked by the compiler, so there is nothing to
18927   change in the implementation. This affects only the RM documentation.
18929 @noindent
18930   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)
18932 @item
18933 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18934 @cindex AI-0127 (Ada 2012 feature)
18936 @noindent
18937   This package provides an interface for identifying the current locale.
18939 @noindent
18940   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
18941   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
18945 @item
18946 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18947 @cindex AI-0002 (Ada 2012 feature)
18949 @noindent
18950   The compiler is not required to support exporting an Ada subprogram with
18951   convention C if there are parameters or a return type of an unconstrained
18952   array type (such as @code{String}). GNAT allows such declarations but
18953   generates warnings. It is possible, but complicated, to write the
18954   corresponding C code and certainly such code would be specific to GNAT and
18955   non-portable.
18957 @noindent
18958   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
18961 @item
18962 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18963 @cindex AI05-0216 (Ada 2012 feature)
18965 @noindent
18966   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18967   forbid tasks declared locally within subprograms, or functions returning task
18968   objects, and that is the implementation that GNAT has always provided.
18969   However the language in the RM was not sufficiently clear on this point.
18970   Thus this is a documentation change in the RM only.
18972 @noindent
18973   RM References:  D.07 (3/3)
18975 @item
18976 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18977 @cindex AI-0211 (Ada 2012 feature)
18979 @noindent
18980   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18981   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18983 @noindent
18984   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
18986 @item
18987 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18988 @cindex AI-0190 (Ada 2012 feature)
18990 @noindent
18991   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18992   used to control storage pools globally.
18993   In particular, you can force every access
18994   type that is used for allocation (@b{new}) to have an explicit storage pool,
18995   or you can declare a pool globally to be used for all access types that lack
18996   an explicit one.
18998 @noindent
18999   RM References:  D.07 (8)
19001 @item
19002 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19003 @cindex AI-0189 (Ada 2012 feature)
19005 @noindent
19006   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19007   which says that no dynamic allocation will occur once elaboration is
19008   completed.
19009   In general this requires a run-time check, which is not required, and which
19010   GNAT does not attempt. But the static cases of allocators in a task body or
19011   in the body of the main program are detected and flagged at compile or bind
19012   time.
19014 @noindent
19015   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
19017 @item
19018 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19019 @cindex AI-0171 (Ada 2012 feature)
19021 @noindent
19022   A new package @code{System.Multiprocessors} is added, together with the
19023   definition of pragma @code{CPU} for controlling task affinity. A new no
19024   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19025   is added to the Ravenscar profile.
19027 @noindent
19028   RM References:  D.13.01 (4/2)   D.16
19031 @item
19032 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19033 @cindex AI-0210 (Ada 2012 feature)
19035 @noindent
19036   This is a documentation only issue regarding wording of metric requirements,
19037   that does not affect the implementation of the compiler.
19039 @noindent
19040   RM References:  D.15 (24/2)
19043 @item
19044 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19045 @cindex AI-0206 (Ada 2012 feature)
19047 @noindent
19048   Remote types packages are now allowed to depend on preelaborated packages.
19049   This was formerly considered illegal.
19051 @noindent
19052   RM References:  E.02.02 (6)
19056 @item
19057 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19058 @cindex AI-0152 (Ada 2012 feature)
19060 @noindent
19061   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19062   where the type of the returned value is an anonymous access type.
19064 @noindent
19065   RM References:  H.04 (8/1)
19066 @end itemize
19069 @node Obsolescent Features
19070 @chapter Obsolescent Features
19072 @noindent
19073 This chapter describes features that are provided by GNAT, but are
19074 considered obsolescent since there are preferred ways of achieving
19075 the same effect. These features are provided solely for historical
19076 compatibility purposes.
19078 @menu
19079 * pragma No_Run_Time::
19080 * pragma Ravenscar::
19081 * pragma Restricted_Run_Time::
19082 @end menu
19084 @node pragma No_Run_Time
19085 @section pragma No_Run_Time
19087 The pragma @code{No_Run_Time} is used to achieve an affect similar
19088 to the use of the "Zero Foot Print" configurable run time, but without
19089 requiring a specially configured run time. The result of using this
19090 pragma, which must be used for all units in a partition, is to restrict
19091 the use of any language features requiring run-time support code. The
19092 preferred usage is to use an appropriately configured run-time that
19093 includes just those features that are to be made accessible.
19095 @node pragma Ravenscar
19096 @section pragma Ravenscar
19098 The pragma @code{Ravenscar} has exactly the same effect as pragma
19099 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19100 is part of the new Ada 2005 standard.
19102 @node pragma Restricted_Run_Time
19103 @section pragma Restricted_Run_Time
19105 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19106 pragma @code{Profile (Restricted)}. The latter usage is
19107 preferred since the Ada 2005 pragma @code{Profile} is intended for
19108 this kind of implementation dependent addition.
19110 @include fdl.texi
19111 @c GNU Free Documentation License
19113 @node Index,,GNU Free Documentation License, Top
19114 @unnumbered Index
19116 @printindex cp
19118 @contents
19120 @bye