19430091d59e962e22f5a364886808851d90d786
[platform/upstream/gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
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
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
19
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
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
43
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
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Aspects::
74 * Implementation Defined Attributes::
75 * Standard and Implementation Defined Restrictions::
76 * Implementation Advice::
77 * Implementation Defined Characteristics::
78 * Intrinsic Subprograms::
79 * Representation Clauses and Pragmas::
80 * Standard Library Routines::
81 * The Implementation of Standard I/O::
82 * The GNAT Library::
83 * Interfacing to Other Languages::
84 * Specialized Needs Annexes::
85 * Implementation of Specific Ada Features::
86 * Implementation of Ada 2012 Features::
87 * Obsolescent Features::
88 * GNU Free Documentation License::
89 * Index::
90
91  --- The Detailed Node Listing ---
92
93 About This Guide
94
95 * What This Reference Manual Contains::
96 * Related Information::
97
98 Implementation Defined Pragmas
99
100 * Pragma Abort_Defer::
101 * Pragma Ada_83::
102 * Pragma Ada_95::
103 * Pragma Ada_05::
104 * Pragma Ada_2005::
105 * Pragma Ada_12::
106 * Pragma Ada_2012::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
111 * Pragma Assume::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Attribute_Definition::
114 * Pragma Ast_Entry::
115 * Pragma C_Pass_By_Copy::
116 * Pragma Check::
117 * Pragma Check_Float_Overflow::
118 * Pragma Check_Name::
119 * Pragma Check_Policy::
120 * Pragma CIL_Constructor::
121 * Pragma Comment::
122 * Pragma Common_Object::
123 * Pragma Compile_Time_Error::
124 * Pragma Compile_Time_Warning::
125 * Pragma Compiler_Unit::
126 * Pragma Complete_Representation::
127 * Pragma Complex_Representation::
128 * Pragma Component_Alignment::
129 * Pragma Contract_Cases::
130 * Pragma Convention_Identifier::
131 * Pragma CPP_Class::
132 * Pragma CPP_Constructor::
133 * Pragma CPP_Virtual::
134 * Pragma CPP_Vtable::
135 * Pragma CPU::
136 * Pragma Debug::
137 * Pragma Debug_Policy::
138 * Pragma Default_Storage_Pool::
139 * Pragma Detect_Blocking::
140 * Pragma Disable_Atomic_Synchronization::
141 * Pragma Dispatching_Domain::
142 * Pragma Elaboration_Checks::
143 * Pragma Eliminate::
144 * Pragma Enable_Atomic_Synchronization::
145 * Pragma Export_Exception::
146 * Pragma Export_Function::
147 * Pragma Export_Object::
148 * Pragma Export_Procedure::
149 * Pragma Export_Value::
150 * Pragma Export_Valued_Procedure::
151 * Pragma Extend_System::
152 * Pragma Extensions_Allowed::
153 * Pragma External::
154 * Pragma External_Name_Casing::
155 * Pragma Fast_Math::
156 * Pragma Favor_Top_Level::
157 * Pragma Finalize_Storage_Only::
158 * Pragma Float_Representation::
159 * Pragma Ident::
160 * Pragma Implementation_Defined::
161 * Pragma Implemented::
162 * Pragma Implicit_Packing::
163 * Pragma Import_Exception::
164 * Pragma Import_Function::
165 * Pragma Import_Object::
166 * Pragma Import_Procedure::
167 * Pragma Import_Valued_Procedure::
168 * Pragma Independent::
169 * Pragma Independent_Components::
170 * Pragma Initialize_Scalars::
171 * Pragma Inline_Always::
172 * Pragma Inline_Generic::
173 * Pragma Interface::
174 * Pragma Interface_Name::
175 * Pragma Interrupt_Handler::
176 * Pragma Interrupt_State::
177 * Pragma Invariant::
178 * Pragma Java_Constructor::
179 * Pragma Java_Interface::
180 * Pragma Keep_Names::
181 * Pragma License::
182 * Pragma Link_With::
183 * Pragma Linker_Alias::
184 * Pragma Linker_Constructor::
185 * Pragma Linker_Destructor::
186 * Pragma Linker_Section::
187 * Pragma Long_Float::
188 * Pragma Loop_Invariant::
189 * Pragma Loop_Optimize::
190 * Pragma Loop_Variant::
191 * Pragma Machine_Attribute::
192 * Pragma Main::
193 * Pragma Main_Storage::
194 * Pragma No_Body::
195 * Pragma No_Inline::
196 * Pragma No_Return::
197 * Pragma No_Run_Time::
198 * Pragma No_Strict_Aliasing ::
199 * Pragma Normalize_Scalars::
200 * Pragma Obsolescent::
201 * Pragma Optimize_Alignment::
202 * Pragma Ordered::
203 * Pragma Overflow_Mode::
204 * Pragma Overriding_Renamings::
205 * Pragma Partition_Elaboration_Policy::
206 * Pragma Passive::
207 * Pragma Persistent_BSS::
208 * Pragma Polling::
209 * Pragma Postcondition::
210 * Pragma Precondition::
211 * Pragma Predicate::
212 * Pragma Preelaborable_Initialization::
213 * Pragma Preelaborate_05::
214 * Pragma Priority_Specific_Dispatching::
215 * Pragma Profile::
216 * Pragma Profile_Warnings::
217 * Pragma Propagate_Exceptions::
218 * Pragma Psect_Object::
219 * Pragma Pure_05::
220 * Pragma Pure_12::
221 * Pragma Pure_Function::
222 * Pragma Ravenscar::
223 * Pragma Relative_Deadline::
224 * Pragma Remote_Access_Type::
225 * Pragma Restricted_Run_Time::
226 * Pragma Restriction_Warnings::
227 * Pragma Share_Generic::
228 * Pragma Shared::
229 * Pragma Short_Circuit_And_Or::
230 * Pragma Short_Descriptors::
231 * Pragma Simple_Storage_Pool_Type::
232 * Pragma Source_File_Name::
233 * Pragma Source_File_Name_Project::
234 * Pragma Source_Reference::
235 * Pragma Static_Elaboration_Desired::
236 * Pragma Stream_Convert::
237 * Pragma Style_Checks::
238 * Pragma Subtitle::
239 * Pragma Suppress::
240 * Pragma Suppress_All::
241 * Pragma Suppress_Debug_Info::
242 * Pragma Suppress_Exception_Locations::
243 * Pragma Suppress_Initialization::
244 * Pragma Task_Info::
245 * Pragma Task_Name::
246 * Pragma Task_Storage::
247 * Pragma Test_Case::
248 * Pragma Thread_Local_Storage::
249 * Pragma Time_Slice::
250 * Pragma Title::
251 * Pragma Unchecked_Union::
252 * Pragma Unimplemented_Unit::
253 * Pragma Universal_Aliasing ::
254 * Pragma Universal_Data::
255 * Pragma Unmodified::
256 * Pragma Unreferenced::
257 * Pragma Unreferenced_Objects::
258 * Pragma Unreserve_All_Interrupts::
259 * Pragma Unsuppress::
260 * Pragma Use_VADS_Size::
261 * Pragma Validity_Checks::
262 * Pragma Volatile::
263 * Pragma Warnings::
264 * Pragma Weak_External::
265 * Pragma Wide_Character_Encoding::
266
267 Implementation Defined Aspects
268
269 * Aspect Abstract_State::
270 * Aspect Ada_2005::
271 * Aspect Ada_2012::
272 * Aspect Compiler_Unit::
273 * Aspect Contract_Cases::
274 * Aspect Depends::
275 * Aspect Dimension::
276 * Aspect Dimension_System::
277 * Aspect Favor_Top_Level::
278 * Aspect Global::
279 * Aspect Inline_Always::
280 * Aspect Invariant::
281 * Aspect Object_Size::
282 * Aspect Persistent_BSS::
283 * Aspect Predicate::
284 * Aspect Preelaborate_05::
285 * Aspect Pure_05::
286 * Aspect Pure_12::
287 * Aspect Pure_Function::
288 * Aspect Remote_Access_Type::
289 * Aspect Scalar_Storage_Order::
290 * Aspect Shared::
291 * Aspect Simple_Storage_Pool::
292 * Aspect Simple_Storage_Pool_Type::
293 * Aspect Suppress_Debug_Info::
294 * Aspect Test_Case::
295 * Aspect Universal_Aliasing::
296 * Aspect Universal_Data::
297 * Aspect Unmodified::
298 * Aspect Unreferenced::
299 * Aspect Unreferenced_Objects::
300 * Aspect Value_Size::
301 * Aspect Warnings::
302
303 Implementation Defined Attributes
304
305 * Attribute Abort_Signal::
306 * Attribute Address_Size::
307 * Attribute Asm_Input::
308 * Attribute Asm_Output::
309 * Attribute AST_Entry::
310 * Attribute Bit::
311 * Attribute Bit_Position::
312 * Attribute Compiler_Version::
313 * Attribute Code_Address::
314 * Attribute Default_Bit_Order::
315 * Attribute Descriptor_Size::
316 * Attribute Elaborated::
317 * Attribute Elab_Body::
318 * Attribute Elab_Spec::
319 * Attribute Elab_Subp_Body::
320 * Attribute Emax::
321 * Attribute Enabled::
322 * Attribute Enum_Rep::
323 * Attribute Enum_Val::
324 * Attribute Epsilon::
325 * Attribute Fixed_Value::
326 * Attribute Has_Access_Values::
327 * Attribute Has_Discriminants::
328 * Attribute Img::
329 * Attribute Integer_Value::
330 * Attribute Invalid_Value::
331 * Attribute Large::
332 * Attribute Loop_Entry::
333 * Attribute Machine_Size::
334 * Attribute Mantissa::
335 * Attribute Max_Interrupt_Priority::
336 * Attribute Max_Priority::
337 * Attribute Maximum_Alignment::
338 * Attribute Mechanism_Code::
339 * Attribute Null_Parameter::
340 * Attribute Object_Size::
341 * Attribute Passed_By_Reference::
342 * Attribute Pool_Address::
343 * Attribute Range_Length::
344 * Attribute Result::
345 * Attribute Safe_Emax::
346 * Attribute Safe_Large::
347 * Attribute Scalar_Storage_Order::
348 * Attribute Simple_Storage_Pool::
349 * Attribute Small::
350 * Attribute Storage_Unit::
351 * Attribute Stub_Type::
352 * Attribute System_Allocator_Alignment::
353 * Attribute Target_Name::
354 * Attribute Tick::
355 * Attribute To_Address::
356 * Attribute Type_Class::
357 * Attribute UET_Address::
358 * Attribute Unconstrained_Array::
359 * Attribute Universal_Literal_String::
360 * Attribute Unrestricted_Access::
361 * Attribute Update::
362 * Attribute Valid_Scalars::
363 * Attribute VADS_Size::
364 * Attribute Value_Size::
365 * Attribute Wchar_T_Size::
366 * Attribute Word_Size::
367
368 Standard and Implementation Defined Restrictions
369
370 * Partition-Wide Restrictions::
371 * Program Unit Level Restrictions::
372
373 Partition-Wide Restrictions
374
375 * Immediate_Reclamation::
376 * Max_Asynchronous_Select_Nesting::
377 * Max_Entry_Queue_Length::
378 * Max_Protected_Entries::
379 * Max_Select_Alternatives::
380 * Max_Storage_At_Blocking::
381 * Max_Task_Entries::
382 * Max_Tasks::
383 * No_Abort_Statements::
384 * No_Access_Parameter_Allocators::
385 * No_Access_Subprograms::
386 * No_Allocators::
387 * No_Anonymous_Allocators::
388 * No_Calendar::
389 * No_Coextensions::
390 * No_Default_Initialization::
391 * No_Delay::
392 * No_Dependence::
393 * No_Direct_Boolean_Operators::
394 * No_Dispatch::
395 * No_Dispatching_Calls::
396 * No_Dynamic_Attachment::
397 * No_Dynamic_Priorities::
398 * No_Entry_Calls_In_Elaboration_Code::
399 * No_Enumeration_Maps::
400 * No_Exception_Handlers::
401 * No_Exception_Propagation::
402 * No_Exception_Registration::
403 * No_Exceptions::
404 * No_Finalization::
405 * No_Fixed_Point::
406 * No_Floating_Point::
407 * No_Implicit_Conditionals::
408 * No_Implicit_Dynamic_Code::
409 * No_Implicit_Heap_Allocations::
410 * No_Implicit_Loops::
411 * No_Initialize_Scalars::
412 * No_IO::
413 * No_Local_Allocators::
414 * No_Local_Protected_Objects::
415 * No_Local_Timing_Events::
416 * No_Nested_Finalization::
417 * No_Protected_Type_Allocators::
418 * No_Protected_Types::
419 * No_Recursion::
420 * No_Reentrancy::
421 * No_Relative_Delay::
422 * No_Requeue_Statements::
423 * No_Secondary_Stack::
424 * No_Select_Statements::
425 * No_Specific_Termination_Handlers::
426 * No_Specification_of_Aspect::
427 * No_Standard_Allocators_After_Elaboration::
428 * No_Standard_Storage_Pools::
429 * No_Stream_Optimizations::
430 * No_Streams::
431 * No_Task_Allocators::
432 * No_Task_Attributes_Package::
433 * No_Task_Hierarchy::
434 * No_Task_Termination::
435 * No_Tasking::
436 * No_Terminate_Alternatives::
437 * No_Unchecked_Access::
438 * Simple_Barriers::
439 * Static_Priorities::
440 * Static_Storage_Size::
441
442 Program Unit Level Restrictions
443
444 * No_Elaboration_Code::
445 * No_Entry_Queue::
446 * No_Implementation_Aspect_Specifications::
447 * No_Implementation_Attributes::
448 * No_Implementation_Identifiers::
449 * No_Implementation_Pragmas::
450 * No_Implementation_Restrictions::
451 * No_Implementation_Units::
452 * No_Implicit_Aliasing::
453 * No_Obsolescent_Features::
454 * No_Wide_Characters::
455 * SPARK::
456
457 The Implementation of Standard I/O
458
459 * Standard I/O Packages::
460 * FORM Strings::
461 * Direct_IO::
462 * Sequential_IO::
463 * Text_IO::
464 * Wide_Text_IO::
465 * Wide_Wide_Text_IO::
466 * Stream_IO::
467 * Text Translation::
468 * Shared Files::
469 * Filenames encoding::
470 * Open Modes::
471 * Operations on C Streams::
472 * Interfacing to C Streams::
473
474 The GNAT Library
475
476 * Ada.Characters.Latin_9 (a-chlat9.ads)::
477 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
478 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
479 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
480 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
481 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
482 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
483 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
484 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
485 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
486 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
487 * Ada.Command_Line.Environment (a-colien.ads)::
488 * Ada.Command_Line.Remove (a-colire.ads)::
489 * Ada.Command_Line.Response_File (a-clrefi.ads)::
490 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
491 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
492 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
493 * Ada.Exceptions.Traceback (a-exctra.ads)::
494 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
495 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
496 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
497 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
498 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
499 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
500 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
501 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
502 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
503 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
504 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
505 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
506 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
507 * GNAT.Altivec (g-altive.ads)::
508 * GNAT.Altivec.Conversions (g-altcon.ads)::
509 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
510 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
511 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
512 * GNAT.Array_Split (g-arrspl.ads)::
513 * GNAT.AWK (g-awk.ads)::
514 * GNAT.Bounded_Buffers (g-boubuf.ads)::
515 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
516 * GNAT.Bubble_Sort (g-bubsor.ads)::
517 * GNAT.Bubble_Sort_A (g-busora.ads)::
518 * GNAT.Bubble_Sort_G (g-busorg.ads)::
519 * GNAT.Byte_Order_Mark (g-byorma.ads)::
520 * GNAT.Byte_Swapping (g-bytswa.ads)::
521 * GNAT.Calendar (g-calend.ads)::
522 * GNAT.Calendar.Time_IO (g-catiio.ads)::
523 * GNAT.Case_Util (g-casuti.ads)::
524 * GNAT.CGI (g-cgi.ads)::
525 * GNAT.CGI.Cookie (g-cgicoo.ads)::
526 * GNAT.CGI.Debug (g-cgideb.ads)::
527 * GNAT.Command_Line (g-comlin.ads)::
528 * GNAT.Compiler_Version (g-comver.ads)::
529 * GNAT.Ctrl_C (g-ctrl_c.ads)::
530 * GNAT.CRC32 (g-crc32.ads)::
531 * GNAT.Current_Exception (g-curexc.ads)::
532 * GNAT.Debug_Pools (g-debpoo.ads)::
533 * GNAT.Debug_Utilities (g-debuti.ads)::
534 * GNAT.Decode_String (g-decstr.ads)::
535 * GNAT.Decode_UTF8_String (g-deutst.ads)::
536 * GNAT.Directory_Operations (g-dirope.ads)::
537 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
538 * GNAT.Dynamic_HTables (g-dynhta.ads)::
539 * GNAT.Dynamic_Tables (g-dyntab.ads)::
540 * GNAT.Encode_String (g-encstr.ads)::
541 * GNAT.Encode_UTF8_String (g-enutst.ads)::
542 * GNAT.Exception_Actions (g-excact.ads)::
543 * GNAT.Exception_Traces (g-exctra.ads)::
544 * GNAT.Exceptions (g-except.ads)::
545 * GNAT.Expect (g-expect.ads)::
546 * GNAT.Expect.TTY (g-exptty.ads)::
547 * GNAT.Float_Control (g-flocon.ads)::
548 * GNAT.Heap_Sort (g-heasor.ads)::
549 * GNAT.Heap_Sort_A (g-hesora.ads)::
550 * GNAT.Heap_Sort_G (g-hesorg.ads)::
551 * GNAT.HTable (g-htable.ads)::
552 * GNAT.IO (g-io.ads)::
553 * GNAT.IO_Aux (g-io_aux.ads)::
554 * GNAT.Lock_Files (g-locfil.ads)::
555 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
556 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
557 * GNAT.MD5 (g-md5.ads)::
558 * GNAT.Memory_Dump (g-memdum.ads)::
559 * GNAT.Most_Recent_Exception (g-moreex.ads)::
560 * GNAT.OS_Lib (g-os_lib.ads)::
561 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
562 * GNAT.Random_Numbers (g-rannum.ads)::
563 * GNAT.Regexp (g-regexp.ads)::
564 * GNAT.Registry (g-regist.ads)::
565 * GNAT.Regpat (g-regpat.ads)::
566 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
567 * GNAT.Semaphores (g-semaph.ads)::
568 * GNAT.Serial_Communications (g-sercom.ads)::
569 * GNAT.SHA1 (g-sha1.ads)::
570 * GNAT.SHA224 (g-sha224.ads)::
571 * GNAT.SHA256 (g-sha256.ads)::
572 * GNAT.SHA384 (g-sha384.ads)::
573 * GNAT.SHA512 (g-sha512.ads)::
574 * GNAT.Signals (g-signal.ads)::
575 * GNAT.Sockets (g-socket.ads)::
576 * GNAT.Source_Info (g-souinf.ads)::
577 * GNAT.Spelling_Checker (g-speche.ads)::
578 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
579 * GNAT.Spitbol.Patterns (g-spipat.ads)::
580 * GNAT.Spitbol (g-spitbo.ads)::
581 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
582 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
583 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
584 * GNAT.SSE (g-sse.ads)::
585 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
586 * GNAT.Strings (g-string.ads)::
587 * GNAT.String_Split (g-strspl.ads)::
588 * GNAT.Table (g-table.ads)::
589 * GNAT.Task_Lock (g-tasloc.ads)::
590 * GNAT.Threads (g-thread.ads)::
591 * GNAT.Time_Stamp (g-timsta.ads)::
592 * GNAT.Traceback (g-traceb.ads)::
593 * GNAT.Traceback.Symbolic (g-trasym.ads)::
594 * GNAT.UTF_32 (g-utf_32.ads)::
595 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
596 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
597 * GNAT.Wide_String_Split (g-wistsp.ads)::
598 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
599 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
600 * Interfaces.C.Extensions (i-cexten.ads)::
601 * Interfaces.C.Streams (i-cstrea.ads)::
602 * Interfaces.CPP (i-cpp.ads)::
603 * Interfaces.Packed_Decimal (i-pacdec.ads)::
604 * Interfaces.VxWorks (i-vxwork.ads)::
605 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
606 * System.Address_Image (s-addima.ads)::
607 * System.Assertions (s-assert.ads)::
608 * System.Memory (s-memory.ads)::
609 * System.Multiprocessors (s-multip.ads)::
610 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
611 * System.Partition_Interface (s-parint.ads)::
612 * System.Pool_Global (s-pooglo.ads)::
613 * System.Pool_Local (s-pooloc.ads)::
614 * System.Restrictions (s-restri.ads)::
615 * System.Rident (s-rident.ads)::
616 * System.Strings.Stream_Ops (s-ststop.ads)::
617 * System.Task_Info (s-tasinf.ads)::
618 * System.Wch_Cnv (s-wchcnv.ads)::
619 * System.Wch_Con (s-wchcon.ads)::
620
621 Text_IO
622
623 * Text_IO Stream Pointer Positioning::
624 * Text_IO Reading and Writing Non-Regular Files::
625 * Get_Immediate::
626 * Treating Text_IO Files as Streams::
627 * Text_IO Extensions::
628 * Text_IO Facilities for Unbounded Strings::
629
630 Wide_Text_IO
631
632 * Wide_Text_IO Stream Pointer Positioning::
633 * Wide_Text_IO Reading and Writing Non-Regular Files::
634
635 Wide_Wide_Text_IO
636
637 * Wide_Wide_Text_IO Stream Pointer Positioning::
638 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
639
640 Interfacing to Other Languages
641
642 * Interfacing to C::
643 * Interfacing to C++::
644 * Interfacing to COBOL::
645 * Interfacing to Fortran::
646 * Interfacing to non-GNAT Ada code::
647
648 Specialized Needs Annexes
649
650 Implementation of Specific Ada Features
651 * Machine Code Insertions::
652 * GNAT Implementation of Tasking::
653 * GNAT Implementation of Shared Passive Packages::
654 * Code Generation for Array Aggregates::
655 * The Size of Discriminated Records with Default Discriminants::
656 * Strict Conformance to the Ada Reference Manual::
657
658 Implementation of Ada 2012 Features
659
660 Obsolescent Features
661
662 GNU Free Documentation License
663
664 Index
665 @end menu
666
667 @end ifnottex
668
669 @node About This Guide
670 @unnumbered About This Guide
671
672 @noindent
673 This manual contains useful information in writing programs using the
674 @value{EDITION} compiler.  It includes information on implementation dependent
675 characteristics of @value{EDITION}, including all the information required by
676 Annex M of the Ada language standard.
677
678 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
679 Ada 83 compatibility mode.
680 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
681 but you can override with a compiler switch
682 to explicitly specify the language version.
683 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
684 @value{EDITION} User's Guide}, for details on these switches.)
685 Throughout this manual, references to ``Ada'' without a year suffix
686 apply to both the Ada 95 and Ada 2005 versions of the language.
687
688 Ada is designed to be highly portable.
689 In general, a program will have the same effect even when compiled by
690 different compilers on different platforms.
691 However, since Ada is designed to be used in a
692 wide variety of applications, it also contains a number of system
693 dependent features to be used in interfacing to the external world.
694 @cindex Implementation-dependent features
695 @cindex Portability
696
697 Note: Any program that makes use of implementation-dependent features
698 may be non-portable.  You should follow good programming practice and
699 isolate and clearly document any sections of your program that make use
700 of these features in a non-portable manner.
701
702 @ifset PROEDITION
703 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
704 ``GNAT'' in the remainder of this document.
705 @end ifset
706
707 @menu
708 * What This Reference Manual Contains::
709 * Conventions::
710 * Related Information::
711 @end menu
712
713 @node What This Reference Manual Contains
714 @unnumberedsec What This Reference Manual Contains
715
716 @noindent
717 This reference manual contains the following chapters:
718
719 @itemize @bullet
720 @item
721 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
722 pragmas, which can be used to extend and enhance the functionality of the
723 compiler.
724
725 @item
726 @ref{Implementation Defined Attributes}, lists GNAT
727 implementation-dependent attributes, which can be used to extend and
728 enhance the functionality of the compiler.
729
730 @item
731 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
732 implementation-dependent restrictions, which can be used to extend and
733 enhance the functionality of the compiler.
734
735 @item
736 @ref{Implementation Advice}, provides information on generally
737 desirable behavior which are not requirements that all compilers must
738 follow since it cannot be provided on all systems, or which may be
739 undesirable on some systems.
740
741 @item
742 @ref{Implementation Defined Characteristics}, provides a guide to
743 minimizing implementation dependent features.
744
745 @item
746 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
747 implemented by GNAT, and how they can be imported into user
748 application programs.
749
750 @item
751 @ref{Representation Clauses and Pragmas}, describes in detail the
752 way that GNAT represents data, and in particular the exact set
753 of representation clauses and pragmas that is accepted.
754
755 @item
756 @ref{Standard Library Routines}, provides a listing of packages and a
757 brief description of the functionality that is provided by Ada's
758 extensive set of standard library routines as implemented by GNAT@.
759
760 @item
761 @ref{The Implementation of Standard I/O}, details how the GNAT
762 implementation of the input-output facilities.
763
764 @item
765 @ref{The GNAT Library}, is a catalog of packages that complement
766 the Ada predefined library.
767
768 @item
769 @ref{Interfacing to Other Languages}, describes how programs
770 written in Ada using GNAT can be interfaced to other programming
771 languages.
772
773 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
774 of the specialized needs annexes.
775
776 @item
777 @ref{Implementation of Specific Ada Features}, discusses issues related
778 to GNAT's implementation of machine code insertions, tasking, and several
779 other features.
780
781 @item
782 @ref{Implementation of Ada 2012 Features}, describes the status of the
783 GNAT implementation of the Ada 2012 language standard.
784
785 @item
786 @ref{Obsolescent Features} documents implementation dependent features,
787 including pragmas and attributes, which are considered obsolescent, since
788 there are other preferred ways of achieving the same results. These
789 obsolescent forms are retained for backwards compatibility.
790
791 @end itemize
792
793 @cindex Ada 95 Language Reference Manual
794 @cindex Ada 2005 Language Reference Manual
795 @noindent
796 This reference manual assumes a basic familiarity with the Ada 95 language, as
797 described in the International Standard ANSI/ISO/IEC-8652:1995,
798 January 1995.
799 It does not require knowledge of the new features introduced by Ada 2005,
800 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
801 and Amendment 1).
802 Both reference manuals are included in the GNAT documentation
803 package.
804
805 @node Conventions
806 @unnumberedsec Conventions
807 @cindex Conventions, typographical
808 @cindex Typographical conventions
809
810 @noindent
811 Following are examples of the typographical and graphic conventions used
812 in this guide:
813
814 @itemize @bullet
815 @item
816 @code{Functions}, @code{utility program names}, @code{standard names},
817 and @code{classes}.
818
819 @item
820 @code{Option flags}
821
822 @item
823 @file{File names}, @samp{button names}, and @samp{field names}.
824
825 @item
826 @code{Variables}, @env{environment variables}, and @var{metasyntactic
827 variables}.
828
829 @item
830 @emph{Emphasis}.
831
832 @item
833 [optional information or parameters]
834
835 @item
836 Examples are described by text
837 @smallexample
838 and then shown this way.
839 @end smallexample
840 @end itemize
841
842 @noindent
843 Commands that are entered by the user are preceded in this manual by the
844 characters @samp{$ } (dollar sign followed by space).  If your system uses this
845 sequence as a prompt, then the commands will appear exactly as you see them
846 in the manual.  If your system uses some other prompt, then the command will
847 appear with the @samp{$} replaced by whatever prompt character you are using.
848
849 @node Related Information
850 @unnumberedsec Related Information
851 @noindent
852 See the following documents for further information on GNAT:
853
854 @itemize @bullet
855 @item
856 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
857 @value{EDITION} User's Guide}, which provides information on how to use the
858 GNAT compiler system.
859
860 @item
861 @cite{Ada 95 Reference Manual}, which contains all reference
862 material for the Ada 95 programming language.
863
864 @item
865 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
866 of the Ada 95 standard.  The annotations describe
867 detailed aspects of the design decision, and in particular contain useful
868 sections on Ada 83 compatibility.
869
870 @item
871 @cite{Ada 2005 Reference Manual}, which contains all reference
872 material for the Ada 2005 programming language.
873
874 @item
875 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
876 of the Ada 2005 standard.  The annotations describe
877 detailed aspects of the design decision, and in particular contain useful
878 sections on Ada 83 and Ada 95 compatibility.
879
880 @item
881 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
882 which contains specific information on compatibility between GNAT and
883 DEC Ada 83 systems.
884
885 @item
886 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
887 describes in detail the pragmas and attributes provided by the DEC Ada 83
888 compiler system.
889
890 @end itemize
891
892 @node Implementation Defined Pragmas
893 @chapter Implementation Defined Pragmas
894
895 @noindent
896 Ada defines a set of pragmas that can be used to supply additional
897 information to the compiler.  These language defined pragmas are
898 implemented in GNAT and work as described in the Ada Reference Manual.
899
900 In addition, Ada allows implementations to define additional pragmas
901 whose meaning is defined by the implementation.  GNAT provides a number
902 of these implementation-defined pragmas, which can be used to extend
903 and enhance the functionality of the compiler.  This section of the GNAT
904 Reference Manual describes these additional pragmas.
905
906 Note that any program using these pragmas might not be portable to other
907 compilers (although GNAT implements this set of pragmas on all
908 platforms).  Therefore if portability to other compilers is an important
909 consideration, the use of these pragmas should be minimized.
910
911 @menu
912 * Pragma Abort_Defer::
913 * Pragma Ada_83::
914 * Pragma Ada_95::
915 * Pragma Ada_05::
916 * Pragma Ada_2005::
917 * Pragma Ada_12::
918 * Pragma Ada_2012::
919 * Pragma Annotate::
920 * Pragma Assert::
921 * Pragma Assert_And_Cut::
922 * Pragma Assertion_Policy::
923 * Pragma Assume::
924 * Pragma Assume_No_Invalid_Values::
925 * Pragma Attribute_Definition::
926 * Pragma Ast_Entry::
927 * Pragma C_Pass_By_Copy::
928 * Pragma Check::
929 * Pragma Check_Float_Overflow::
930 * Pragma Check_Name::
931 * Pragma Check_Policy::
932 * Pragma CIL_Constructor::
933 * Pragma Comment::
934 * Pragma Common_Object::
935 * Pragma Compile_Time_Error::
936 * Pragma Compile_Time_Warning::
937 * Pragma Compiler_Unit::
938 * Pragma Complete_Representation::
939 * Pragma Complex_Representation::
940 * Pragma Component_Alignment::
941 * Pragma Contract_Cases::
942 * Pragma Convention_Identifier::
943 * Pragma CPP_Class::
944 * Pragma CPP_Constructor::
945 * Pragma CPP_Virtual::
946 * Pragma CPP_Vtable::
947 * Pragma CPU::
948 * Pragma Debug::
949 * Pragma Debug_Policy::
950 * Pragma Default_Storage_Pool::
951 * Pragma Detect_Blocking::
952 * Pragma Disable_Atomic_Synchronization::
953 * Pragma Dispatching_Domain::
954 * Pragma Elaboration_Checks::
955 * Pragma Eliminate::
956 * Pragma Enable_Atomic_Synchronization::
957 * Pragma Export_Exception::
958 * Pragma Export_Function::
959 * Pragma Export_Object::
960 * Pragma Export_Procedure::
961 * Pragma Export_Value::
962 * Pragma Export_Valued_Procedure::
963 * Pragma Extend_System::
964 * Pragma Extensions_Allowed::
965 * Pragma External::
966 * Pragma External_Name_Casing::
967 * Pragma Fast_Math::
968 * Pragma Favor_Top_Level::
969 * Pragma Finalize_Storage_Only::
970 * Pragma Float_Representation::
971 * Pragma Ident::
972 * Pragma Implementation_Defined::
973 * Pragma Implemented::
974 * Pragma Implicit_Packing::
975 * Pragma Import_Exception::
976 * Pragma Import_Function::
977 * Pragma Import_Object::
978 * Pragma Import_Procedure::
979 * Pragma Import_Valued_Procedure::
980 * Pragma Independent::
981 * Pragma Independent_Components::
982 * Pragma Initialize_Scalars::
983 * Pragma Inline_Always::
984 * Pragma Inline_Generic::
985 * Pragma Interface::
986 * Pragma Interface_Name::
987 * Pragma Interrupt_Handler::
988 * Pragma Interrupt_State::
989 * Pragma Invariant::
990 * Pragma Java_Constructor::
991 * Pragma Java_Interface::
992 * Pragma Keep_Names::
993 * Pragma License::
994 * Pragma Link_With::
995 * Pragma Linker_Alias::
996 * Pragma Linker_Constructor::
997 * Pragma Linker_Destructor::
998 * Pragma Linker_Section::
999 * Pragma Long_Float::
1000 * Pragma Loop_Invariant::
1001 * Pragma Loop_Optimize::
1002 * Pragma Loop_Variant::
1003 * Pragma Machine_Attribute::
1004 * Pragma Main::
1005 * Pragma Main_Storage::
1006 * Pragma No_Body::
1007 * Pragma No_Inline::
1008 * Pragma No_Return::
1009 * Pragma No_Run_Time::
1010 * Pragma No_Strict_Aliasing::
1011 * Pragma Normalize_Scalars::
1012 * Pragma Obsolescent::
1013 * Pragma Optimize_Alignment::
1014 * Pragma Ordered::
1015 * Pragma Overflow_Mode::
1016 * Pragma Overriding_Renamings::
1017 * Pragma Partition_Elaboration_Policy::
1018 * Pragma Passive::
1019 * Pragma Persistent_BSS::
1020 * Pragma Polling::
1021 * Pragma Postcondition::
1022 * Pragma Precondition::
1023 * Pragma Predicate::
1024 * Pragma Preelaborable_Initialization::
1025 * Pragma Preelaborate_05::
1026 * Pragma Priority_Specific_Dispatching::
1027 * Pragma Profile::
1028 * Pragma Profile_Warnings::
1029 * Pragma Propagate_Exceptions::
1030 * Pragma Psect_Object::
1031 * Pragma Pure_05::
1032 * Pragma Pure_12::
1033 * Pragma Pure_Function::
1034 * Pragma Ravenscar::
1035 * Pragma Relative_Deadline::
1036 * Pragma Remote_Access_Type::
1037 * Pragma Restricted_Run_Time::
1038 * Pragma Restriction_Warnings::
1039 * Pragma Share_Generic::
1040 * Pragma Shared::
1041 * Pragma Short_Circuit_And_Or::
1042 * Pragma Short_Descriptors::
1043 * Pragma Simple_Storage_Pool_Type::
1044 * Pragma Source_File_Name::
1045 * Pragma Source_File_Name_Project::
1046 * Pragma Source_Reference::
1047 * Pragma Static_Elaboration_Desired::
1048 * Pragma Stream_Convert::
1049 * Pragma Style_Checks::
1050 * Pragma Subtitle::
1051 * Pragma Suppress::
1052 * Pragma Suppress_All::
1053 * Pragma Suppress_Debug_Info::
1054 * Pragma Suppress_Exception_Locations::
1055 * Pragma Suppress_Initialization::
1056 * Pragma Task_Info::
1057 * Pragma Task_Name::
1058 * Pragma Task_Storage::
1059 * Pragma Test_Case::
1060 * Pragma Thread_Local_Storage::
1061 * Pragma Time_Slice::
1062 * Pragma Title::
1063 * Pragma Unchecked_Union::
1064 * Pragma Unimplemented_Unit::
1065 * Pragma Universal_Aliasing ::
1066 * Pragma Universal_Data::
1067 * Pragma Unmodified::
1068 * Pragma Unreferenced::
1069 * Pragma Unreferenced_Objects::
1070 * Pragma Unreserve_All_Interrupts::
1071 * Pragma Unsuppress::
1072 * Pragma Use_VADS_Size::
1073 * Pragma Validity_Checks::
1074 * Pragma Volatile::
1075 * Pragma Warnings::
1076 * Pragma Weak_External::
1077 * Pragma Wide_Character_Encoding::
1078 @end menu
1079
1080 @node Pragma Abort_Defer
1081 @unnumberedsec Pragma Abort_Defer
1082 @findex Abort_Defer
1083 @cindex Deferring aborts
1084 @noindent
1085 Syntax:
1086 @smallexample
1087 pragma Abort_Defer;
1088 @end smallexample
1089
1090 @noindent
1091 This pragma must appear at the start of the statement sequence of a
1092 handled sequence of statements (right after the @code{begin}).  It has
1093 the effect of deferring aborts for the sequence of statements (but not
1094 for the declarations or handlers, if any, associated with this statement
1095 sequence).
1096
1097 @node Pragma Ada_83
1098 @unnumberedsec Pragma Ada_83
1099 @findex Ada_83
1100 @noindent
1101 Syntax:
1102 @smallexample @c ada
1103 pragma Ada_83;
1104 @end smallexample
1105
1106 @noindent
1107 A configuration pragma that establishes Ada 83 mode for the unit to
1108 which it applies, regardless of the mode set by the command line
1109 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1110 the syntax and semantics of Ada 83, as defined in the original Ada
1111 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1112 and Ada 2005 are not recognized, optional package bodies are allowed,
1113 and generics may name types with unknown discriminants without using
1114 the @code{(<>)} notation.  In addition, some but not all of the additional
1115 restrictions of Ada 83 are enforced.
1116
1117 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1118 Ada 83 code to be compiled and adapted to GNAT with less effort.
1119 Secondly, it aids in keeping code backwards compatible with Ada 83.
1120 However, there is no guarantee that code that is processed correctly
1121 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1122 83 compiler, since GNAT does not enforce all the additional checks
1123 required by Ada 83.
1124
1125 @node Pragma Ada_95
1126 @unnumberedsec Pragma Ada_95
1127 @findex Ada_95
1128 @noindent
1129 Syntax:
1130 @smallexample @c ada
1131 pragma Ada_95;
1132 @end smallexample
1133
1134 @noindent
1135 A configuration pragma that establishes Ada 95 mode for the unit to which
1136 it applies, regardless of the mode set by the command line switches.
1137 This mode is set automatically for the @code{Ada} and @code{System}
1138 packages and their children, so you need not specify it in these
1139 contexts.  This pragma is useful when writing a reusable component that
1140 itself uses Ada 95 features, but which is intended to be usable from
1141 either Ada 83 or Ada 95 programs.
1142
1143 @node Pragma Ada_05
1144 @unnumberedsec Pragma Ada_05
1145 @findex Ada_05
1146 @noindent
1147 Syntax:
1148 @smallexample @c ada
1149 pragma Ada_05;
1150 @end smallexample
1151
1152 @noindent
1153 A configuration pragma that establishes Ada 2005 mode for the unit to which
1154 it applies, regardless of the mode set by the command line switches.
1155 This pragma is useful when writing a reusable component that
1156 itself uses Ada 2005 features, but which is intended to be usable from
1157 either Ada 83 or Ada 95 programs.
1158
1159 @node Pragma Ada_2005
1160 @unnumberedsec Pragma Ada_2005
1161 @findex Ada_2005
1162 @noindent
1163 Syntax:
1164 @smallexample @c ada
1165 pragma Ada_2005;
1166 @end smallexample
1167
1168 @noindent
1169 This configuration pragma is a synonym for pragma Ada_05 and has the
1170 same syntax and effect.
1171
1172 @node Pragma Ada_12
1173 @unnumberedsec Pragma Ada_12
1174 @findex Ada_12
1175 @noindent
1176 Syntax:
1177 @smallexample @c ada
1178 pragma Ada_12;
1179 @end smallexample
1180
1181 @noindent
1182 A configuration pragma that establishes Ada 2012 mode for the unit to which
1183 it applies, regardless of the mode set by the command line switches.
1184 This mode is set automatically for the @code{Ada} and @code{System}
1185 packages and their children, so you need not specify it in these
1186 contexts.  This pragma is useful when writing a reusable component that
1187 itself uses Ada 2012 features, but which is intended to be usable from
1188 Ada 83, Ada 95, or Ada 2005 programs.
1189
1190 @node Pragma Ada_2012
1191 @unnumberedsec Pragma Ada_2012
1192 @findex Ada_2005
1193 @noindent
1194 Syntax:
1195 @smallexample @c ada
1196 pragma Ada_2012;
1197 @end smallexample
1198
1199 @noindent
1200 This configuration pragma is a synonym for pragma Ada_12 and has the
1201 same syntax and effect.
1202
1203 @node Pragma Annotate
1204 @unnumberedsec Pragma Annotate
1205 @findex Annotate
1206 @noindent
1207 Syntax:
1208 @smallexample @c ada
1209 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1210
1211 ARG ::= NAME | EXPRESSION
1212 @end smallexample
1213
1214 @noindent
1215 This pragma is used to annotate programs.  @var{identifier} identifies
1216 the type of annotation.  GNAT verifies that it is an identifier, but does
1217 not otherwise analyze it. The second optional identifier is also left
1218 unanalyzed, and by convention is used to control the action of the tool to
1219 which the annotation is addressed.  The remaining @var{arg} arguments
1220 can be either string literals or more generally expressions.
1221 String literals are assumed to be either of type
1222 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1223 depending on the character literals they contain.
1224 All other kinds of arguments are analyzed as expressions, and must be
1225 unambiguous.
1226
1227 The analyzed pragma is retained in the tree, but not otherwise processed
1228 by any part of the GNAT compiler, except to generate corresponding note
1229 lines in the generated ALI file. For the format of these note lines, see
1230 the compiler source file lib-writ.ads. This pragma is intended for use by
1231 external tools, including ASIS@. The use of pragma Annotate does not
1232 affect the compilation process in any way. This pragma may be used as
1233 a configuration pragma.
1234
1235 @node Pragma Assert
1236 @unnumberedsec Pragma Assert
1237 @findex Assert
1238 @noindent
1239 Syntax:
1240 @smallexample @c ada
1241 pragma Assert (
1242   boolean_EXPRESSION
1243   [, string_EXPRESSION]);
1244 @end smallexample
1245
1246 @noindent
1247 The effect of this pragma depends on whether the corresponding command
1248 line switch is set to activate assertions.  The pragma expands into code
1249 equivalent to the following:
1250
1251 @smallexample @c ada
1252 if assertions-enabled then
1253    if not boolean_EXPRESSION then
1254       System.Assertions.Raise_Assert_Failure
1255         (string_EXPRESSION);
1256    end if;
1257 end if;
1258 @end smallexample
1259
1260 @noindent
1261 The string argument, if given, is the message that will be associated
1262 with the exception occurrence if the exception is raised.  If no second
1263 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1264 where @var{file} is the name of the source file containing the assert,
1265 and @var{nnn} is the line number of the assert.  A pragma is not a
1266 statement, so if a statement sequence contains nothing but a pragma
1267 assert, then a null statement is required in addition, as in:
1268
1269 @smallexample @c ada
1270 @dots{}
1271 if J > 3 then
1272    pragma Assert (K > 3, "Bad value for K");
1273    null;
1274 end if;
1275 @end smallexample
1276
1277 @noindent
1278 Note that, as with the @code{if} statement to which it is equivalent, the
1279 type of the expression is either @code{Standard.Boolean}, or any type derived
1280 from this standard type.
1281
1282 Assert checks can be either checked or ignored. By default they are ignored.
1283 They will be checked if either the command line switch @option{-gnata} is
1284 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1285 to enable @code{Assert_Checks}.
1286
1287 If assertions are ignored, then there
1288 is no run-time effect (and in particular, any side effects from the
1289 expression will not occur at run time).  (The expression is still
1290 analyzed at compile time, and may cause types to be frozen if they are
1291 mentioned here for the first time).
1292
1293 If assertions are checked, then the given expression is tested, and if
1294 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1295 which results in the raising of @code{Assert_Failure} with the given message.
1296
1297 You should generally avoid side effects in the expression arguments of
1298 this pragma, because these side effects will turn on and off with the
1299 setting of the assertions mode, resulting in assertions that have an
1300 effect on the program.  However, the expressions are analyzed for
1301 semantic correctness whether or not assertions are enabled, so turning
1302 assertions on and off cannot affect the legality of a program.
1303
1304 Note that the implementation defined policy @code{DISABLE}, given in a
1305 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1306
1307 Note: this is a standard language-defined pragma in versions
1308 of Ada from 2005 on. In GNAT, it is implemented in all versions
1309 of Ada, and the DISABLE policy is an implementation-defined
1310 addition.
1311
1312 @node Pragma Assert_And_Cut
1313 @unnumberedsec Pragma Assert_And_Cut
1314 @findex Assert_And_Cut
1315 @noindent
1316 Syntax:
1317 @smallexample @c ada
1318 pragma Assert_And_Cut (
1319   boolean_EXPRESSION
1320   [, string_EXPRESSION]);
1321 @end smallexample
1322
1323 @noindent
1324 The effect of this pragma is identical to that of pragma @code{Assert},
1325 except that in an @code{Assertion_Policy} pragma, the identifier
1326 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1327 (or disabled).
1328
1329 The intention is that this be used within a subprogram when the
1330 given test expresion sums up all the work done so far in the
1331 subprogram, so that the rest of the subprogram can be verified
1332 (informally or formally) using only the entry preconditions,
1333 and the expression in this pragma. This allows dividing up
1334 a subprogram into sections for the purposes of testing or
1335 formal verification. The pragma also serves as useful
1336 documentation.
1337
1338 @node Pragma Assertion_Policy
1339 @unnumberedsec Pragma Assertion_Policy
1340 @findex Assertion_Policy
1341 @noindent
1342 Syntax:
1343 @smallexample @c ada
1344 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1345
1346 pragma Assertion_Policy (
1347     ASSERTION_KIND => POLICY_IDENTIFIER
1348  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1349
1350 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1351
1352 RM_ASSERTION_KIND ::= Assert               |
1353                       Static_Predicate     |
1354                       Dynamic_Predicate    |
1355                       Pre                  |
1356                       Pre'Class            |
1357                       Post                 |
1358                       Post'Class           |
1359                       Type_Invariant       |
1360                       Type_Invariant'Class
1361
1362 ID_ASSERTION_KIND ::= Assertions           |
1363                       Assert_And_Cut       |
1364                       Assume               |
1365                       Contract_Cases       |
1366                       Debug                |
1367                       Invariant            |
1368                       Invariant'Class      |
1369                       Loop_Invariant       |
1370                       Loop_Variant         |
1371                       Postcondition        |
1372                       Precondition         |
1373                       Predicate
1374                       Statement_Assertions
1375
1376 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1377 @end smallexample
1378
1379 @noindent
1380 This is a standard Ada 2012 pragma that is available as an
1381 implementation-defined pragma in earlier versions of Ada.
1382 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1383 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1384 are implementation defined additions recognized by the GNAT compiler.
1385
1386 The pragma applies in both cases to pragmas and aspects with matching
1387 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1388 applies to both the @code{Precondition} pragma
1389 and the aspect @code{Precondition}.
1390
1391 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1392 the corresponding pragma or aspect is activated.
1393 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1394 the corresponding pragma or aspect is deactivated.
1395 This pragma overrides the effect of the @option{-gnata} switch on the
1396 command line.
1397
1398 The implementation defined policy @code{DISABLE} is like
1399 @code{IGNORE} except that it completely disables semantic
1400 checking of the corresponding pragma or aspect. This is
1401 useful when the pragma or aspect argument references subprograms
1402 in a with'ed package which is replaced by a dummy package
1403 for the final build.
1404
1405 The implementation defined policy @code{Assertions} applies to all
1406 assertion kinds. The form with no assertion kind given implies this
1407 choice, so it applies to all assertion kinds (RM defined, and
1408 implementation defined).
1409
1410 The implementation defined policy @code{Statement_Assertions}
1411 applies to @code{Assert}, @code{Assert_And_Cut},
1412 @code{Assume}, and @code{Loop_Invariant}.
1413
1414 @node Pragma Assume
1415 @unnumberedsec Pragma Assume
1416 @findex Assume
1417 @noindent
1418 Syntax:
1419 @smallexample @c ada
1420 pragma Assume (
1421   boolean_EXPRESSION
1422   [, string_EXPRESSION]);
1423 @end smallexample
1424
1425 @noindent
1426 The effect of this pragma is identical to that of pragma @code{Assert},
1427 except that in an @code{Assertion_Policy} pragma, the identifier
1428 @code{Assume} is used to control whether it is ignored or checked
1429 (or disabled).
1430
1431 The intention is that this be used for assumptions about the
1432 external environment. So you cannot expect to verify formally
1433 or informally that the condition is met, this must be
1434 established by examining things outside the program itself.
1435 For example, we may have code that depends on the size of
1436 @code{Long_Long_Integer} being at least 64. So we could write:
1437
1438 @smallexample @c ada
1439 pragma Assume (Long_Long_Integer'Size >= 64);
1440 @end smallexample
1441
1442 @noindent
1443 This assumption cannot be proved from the program itself,
1444 but it acts as a useful run-time check that the assumption
1445 is met, and documents the need to ensure that it is met by
1446 reference to information outside the program.
1447
1448 @node Pragma Assume_No_Invalid_Values
1449 @unnumberedsec Pragma Assume_No_Invalid_Values
1450 @findex Assume_No_Invalid_Values
1451 @cindex Invalid representations
1452 @cindex Invalid values
1453 @noindent
1454 Syntax:
1455 @smallexample @c ada
1456 pragma Assume_No_Invalid_Values (On | Off);
1457 @end smallexample
1458
1459 @noindent
1460 This is a configuration pragma that controls the assumptions made by the
1461 compiler about the occurrence of invalid representations (invalid values)
1462 in the code.
1463
1464 The default behavior (corresponding to an Off argument for this pragma), is
1465 to assume that values may in general be invalid unless the compiler can
1466 prove they are valid. Consider the following example:
1467
1468 @smallexample @c ada
1469 V1 : Integer range 1 .. 10;
1470 V2 : Integer range 11 .. 20;
1471 ...
1472 for J in V2 .. V1 loop
1473    ...
1474 end loop;
1475 @end smallexample
1476
1477 @noindent
1478 if V1 and V2 have valid values, then the loop is known at compile
1479 time not to execute since the lower bound must be greater than the
1480 upper bound. However in default mode, no such assumption is made,
1481 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1482 is given, the compiler will assume that any occurrence of a variable
1483 other than in an explicit @code{'Valid} test always has a valid
1484 value, and the loop above will be optimized away.
1485
1486 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1487 you know your code is free of uninitialized variables and other
1488 possible sources of invalid representations, and may result in
1489 more efficient code. A program that accesses an invalid representation
1490 with this pragma in effect is erroneous, so no guarantees can be made
1491 about its behavior.
1492
1493 It is peculiar though permissible to use this pragma in conjunction
1494 with validity checking (-gnatVa). In such cases, accessing invalid
1495 values will generally give an exception, though formally the program
1496 is erroneous so there are no guarantees that this will always be the
1497 case, and it is recommended that these two options not be used together.
1498
1499 @node Pragma Ast_Entry
1500 @unnumberedsec Pragma Ast_Entry
1501 @cindex OpenVMS
1502 @findex Ast_Entry
1503 @noindent
1504 Syntax:
1505 @smallexample @c ada
1506 pragma AST_Entry (entry_IDENTIFIER);
1507 @end smallexample
1508
1509 @noindent
1510 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1511 argument is the simple name of a single entry; at most one @code{AST_Entry}
1512 pragma is allowed for any given entry.  This pragma must be used in
1513 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1514 the entry declaration and in the same task type specification or single task
1515 as the entry to which it applies.  This pragma specifies that the given entry
1516 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1517 resulting from an OpenVMS system service call.  The pragma does not affect
1518 normal use of the entry.  For further details on this pragma, see the
1519 DEC Ada Language Reference Manual, section 9.12a.
1520
1521 @node Pragma Attribute_Definition
1522 @unnumberedsec Pragma Attribute_Definition
1523 @findex Attribute_Definition
1524 @noindent
1525 Syntax:
1526 @smallexample @c ada
1527 pragma Attribute_Definition
1528   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1529    [Entity     =>] LOCAL_NAME,
1530    [Expression =>] EXPRESSION | NAME);
1531 @end smallexample
1532
1533 @noindent
1534 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1535 the attribute definition clause:
1536
1537 @smallexample @c ada
1538   for Entity'Attribute use Expression;
1539 @end smallexample
1540
1541 If @code{Attribute} is not a recognized attribute name, the pragma is
1542 ignored, and a warning is emitted. This allows source
1543 code to be written that takes advantage of some new attribute, while remaining
1544 compilable with earlier compilers.
1545
1546 @node Pragma C_Pass_By_Copy
1547 @unnumberedsec Pragma C_Pass_By_Copy
1548 @cindex Passing by copy
1549 @findex C_Pass_By_Copy
1550 @noindent
1551 Syntax:
1552 @smallexample @c ada
1553 pragma C_Pass_By_Copy
1554   ([Max_Size =>] static_integer_EXPRESSION);
1555 @end smallexample
1556
1557 @noindent
1558 Normally the default mechanism for passing C convention records to C
1559 convention subprograms is to pass them by reference, as suggested by RM
1560 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1561 this default, by requiring that record formal parameters be passed by
1562 copy if all of the following conditions are met:
1563
1564 @itemize @bullet
1565 @item
1566 The size of the record type does not exceed the value specified for
1567 @code{Max_Size}.
1568 @item
1569 The record type has @code{Convention C}.
1570 @item
1571 The formal parameter has this record type, and the subprogram has a
1572 foreign (non-Ada) convention.
1573 @end itemize
1574
1575 @noindent
1576 If these conditions are met the argument is passed by copy, i.e.@: in a
1577 manner consistent with what C expects if the corresponding formal in the
1578 C prototype is a struct (rather than a pointer to a struct).
1579
1580 You can also pass records by copy by specifying the convention
1581 @code{C_Pass_By_Copy} for the record type, or by using the extended
1582 @code{Import} and @code{Export} pragmas, which allow specification of
1583 passing mechanisms on a parameter by parameter basis.
1584
1585 @node Pragma Check
1586 @unnumberedsec Pragma Check
1587 @cindex Assertions
1588 @cindex Named assertions
1589 @findex Check
1590 @noindent
1591 Syntax:
1592 @smallexample @c ada
1593 pragma Check (
1594      [Name    =>] CHECK_KIND,
1595      [Check   =>] Boolean_EXPRESSION
1596   [, [Message =>] string_EXPRESSION] );
1597
1598 CHECK_KIND ::= IDENTIFIER           |
1599                Pre'Class            |
1600                Post'Class           |
1601                Type_Invariant'Class |
1602                Invariant'Class
1603 @end smallexample
1604
1605 @noindent
1606 This pragma is similar to the predefined pragma @code{Assert} except that an
1607 extra identifier argument is present. In conjunction with pragma
1608 @code{Check_Policy}, this can be used to define groups of assertions that can
1609 be independently controlled. The identifier @code{Assertion} is special, it
1610 refers to the normal set of pragma @code{Assert} statements.
1611
1612 Checks introduced by this pragma are normally deactivated by default. They can
1613 be activated either by the command line option @option{-gnata}, which turns on
1614 all checks, or individually controlled using pragma @code{Check_Policy}.
1615
1616 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1617 permitted as check kinds, since this would cause confusion with the use
1618 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1619 pragmas, where they are used to refer to sets of assertions.
1620
1621 @node Pragma Check_Float_Overflow
1622 @unnumberedsec Pragma Check_Float_Overflow
1623 @cindex Floating-point overflow
1624 @findex Check_Float_Overflow
1625 @noindent
1626 Syntax:
1627 @smallexample @c ada
1628 pragma Check_Float_Overflow;
1629 @end smallexample
1630
1631 @noindent
1632 In Ada, the predefined floating-point types (@code{Short_Float},
1633 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1634 defined to be @emph{unconstrained}. This means that even though each
1635 has a well-defined base range, an operation that delivers a result
1636 outside this base range is not required to raise an exception.
1637 This implementation permission accommodates the notion
1638 of infinities in IEEE floating-point, and corresponds to the
1639 efficient execution mode on most machines. GNAT will not raise
1640 overflow exceptions on these machines; instead it will generate
1641 infinities and NaN's as defined in the IEEE standard.
1642
1643 Generating infinities, although efficient, is not always desirable.
1644 Often the preferable approach is to check for overflow, even at the
1645 (perhaps considerable) expense of run-time performance.
1646 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1647 range constraints -- and indeed such a subtype
1648 can have the same base range as its base type. For example:
1649
1650 @smallexample @c ada
1651 subtype My_Float is Float range Float'Range;
1652 @end smallexample
1653
1654 @noindent
1655 Here @code{My_Float} has the same range as
1656 @code{Float} but is constrained, so operations on
1657 @code{My_Float} values will be checked for overflow
1658 against this range.
1659
1660 This style will achieve the desired goal, but
1661 it is often more convenient to be able to simply use
1662 the standard predefined floating-point types as long
1663 as overflow checking could be guaranteed.
1664 The @code{Check_Float_Overflow}
1665 configuration pragma achieves this effect. If a unit is compiled
1666 subject to this configuration pragma, then all operations
1667 on predefined floating-point types will be treated as
1668 though those types were constrained, and overflow checks
1669 will be generated. The @code{Constraint_Error}
1670 exception is raised if the result is out of range.
1671
1672 This mode can also be set by use of the compiler
1673 switch @option{-gnateF}.
1674
1675 @node Pragma Check_Name
1676 @unnumberedsec Pragma Check_Name
1677 @cindex Defining check names
1678 @cindex Check names, defining
1679 @findex Check_Name
1680 @noindent
1681 Syntax:
1682 @smallexample @c ada
1683 pragma Check_Name (check_name_IDENTIFIER);
1684 @end smallexample
1685
1686 @noindent
1687 This is a configuration pragma that defines a new implementation
1688 defined check name (unless IDENTIFIER matches one of the predefined
1689 check names, in which case the pragma has no effect). Check names
1690 are global to a partition, so if two or more configuration pragmas
1691 are present in a partition mentioning the same name, only one new
1692 check name is introduced.
1693
1694 An implementation defined check name introduced with this pragma may
1695 be used in only three contexts: @code{pragma Suppress},
1696 @code{pragma Unsuppress},
1697 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1698 any of these three cases, the check name must be visible. A check
1699 name is visible if it is in the configuration pragmas applying to
1700 the current unit, or if it appears at the start of any unit that
1701 is part of the dependency set of the current unit (e.g., units that
1702 are mentioned in @code{with} clauses).
1703
1704 Check names introduced by this pragma are subject to control by compiler
1705 switches (in particular -gnatp) in the usual manner.
1706
1707 @node Pragma Check_Policy
1708 @unnumberedsec Pragma Check_Policy
1709 @cindex Controlling assertions
1710 @cindex Assertions, control
1711 @cindex Check pragma control
1712 @cindex Named assertions
1713 @findex Check
1714 @noindent
1715 Syntax:
1716 @smallexample @c ada
1717 pragma Check_Policy
1718  ([Name   =>] CHECK_KIND,
1719   [Policy =>] POLICY_IDENTIFIER);
1720
1721 pragma Check_Policy (
1722     CHECK_KIND => POLICY_IDENTIFIER
1723  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1724
1725 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1726
1727 CHECK_KIND ::= IDENTIFIER           |
1728                Pre'Class            |
1729                Post'Class           |
1730                Type_Invariant'Class |
1731                Invariant'Class
1732
1733 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1734 avoids confusion between the two possible syntax forms for this pragma.
1735
1736 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1737 @end smallexample
1738
1739 @noindent
1740 This pragma is used to set the checking policy for assertions (specified
1741 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1742 to be checked using the @code{Check} pragma. It may appear either as
1743 a configuration pragma, or within a declarative part of package. In the
1744 latter case, it applies from the point where it appears to the end of
1745 the declarative region (like pragma @code{Suppress}).
1746
1747 The @code{Check_Policy} pragma is similar to the
1748 predefined @code{Assertion_Policy} pragma,
1749 and if the check kind corresponds to one of the assertion kinds that
1750 are allowed by @code{Assertion_Policy}, then the effect is identical.
1751
1752 If the first argument is Debug, then the policy applies to Debug pragmas,
1753 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1754 @code{IGNORE}, and allowing them to execute with normal semantics if
1755 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1756 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1757 be totally ignored and not analyzed semantically.
1758
1759 Finally the first argument may be some other identifier than the above
1760 possibilities, in which case it controls a set of named assertions
1761 that can be checked using pragma @code{Check}. For example, if the pragma:
1762
1763 @smallexample @c ada
1764 pragma Check_Policy (Critical_Error, OFF);
1765 @end smallexample
1766
1767 @noindent
1768 is given, then subsequent @code{Check} pragmas whose first argument is also
1769 @code{Critical_Error} will be disabled.
1770
1771 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1772 to turn on corresponding checks. The default for a set of checks for which no
1773 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1774 @option{-gnata} is given, which turns on all checks by default.
1775
1776 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1777 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1778 compatibility with the standard @code{Assertion_Policy} pragma. The check
1779 policy setting @code{DISABLE} causes the second argument of a corresponding
1780 @code{Check} pragma to be completely ignored and not analyzed.
1781
1782 @node Pragma CIL_Constructor
1783 @unnumberedsec Pragma CIL_Constructor
1784 @findex CIL_Constructor
1785 @noindent
1786 Syntax:
1787
1788 @smallexample @c ada
1789 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1790 @end smallexample
1791
1792 @noindent
1793 This pragma is used to assert that the specified Ada function should be
1794 mapped to the .NET constructor for some Ada tagged record type.
1795
1796 See section 4.1 of the
1797 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1798 for related information.
1799
1800 @node Pragma Comment
1801 @unnumberedsec Pragma Comment
1802 @findex Comment
1803 @noindent
1804 Syntax:
1805
1806 @smallexample @c ada
1807 pragma Comment (static_string_EXPRESSION);
1808 @end smallexample
1809
1810 @noindent
1811 This is almost identical in effect to pragma @code{Ident}.  It allows the
1812 placement of a comment into the object file and hence into the
1813 executable file if the operating system permits such usage.  The
1814 difference is that @code{Comment}, unlike @code{Ident}, has
1815 no limitations on placement of the pragma (it can be placed
1816 anywhere in the main source unit), and if more than one pragma
1817 is used, all comments are retained.
1818
1819 @node Pragma Common_Object
1820 @unnumberedsec Pragma Common_Object
1821 @findex Common_Object
1822 @noindent
1823 Syntax:
1824
1825 @smallexample @c ada
1826 pragma Common_Object (
1827      [Internal =>] LOCAL_NAME
1828   [, [External =>] EXTERNAL_SYMBOL]
1829   [, [Size     =>] EXTERNAL_SYMBOL] );
1830
1831 EXTERNAL_SYMBOL ::=
1832   IDENTIFIER
1833 | static_string_EXPRESSION
1834 @end smallexample
1835
1836 @noindent
1837 This pragma enables the shared use of variables stored in overlaid
1838 linker areas corresponding to the use of @code{COMMON}
1839 in Fortran.  The single
1840 object @var{LOCAL_NAME} is assigned to the area designated by
1841 the @var{External} argument.
1842 You may define a record to correspond to a series
1843 of fields.  The @var{Size} argument
1844 is syntax checked in GNAT, but otherwise ignored.
1845
1846 @code{Common_Object} is not supported on all platforms.  If no
1847 support is available, then the code generator will issue a message
1848 indicating that the necessary attribute for implementation of this
1849 pragma is not available.
1850
1851 @node Pragma Compile_Time_Error
1852 @unnumberedsec Pragma Compile_Time_Error
1853 @findex Compile_Time_Error
1854 @noindent
1855 Syntax:
1856
1857 @smallexample @c ada
1858 pragma Compile_Time_Error
1859          (boolean_EXPRESSION, static_string_EXPRESSION);
1860 @end smallexample
1861
1862 @noindent
1863 This pragma can be used to generate additional compile time
1864 error messages. It
1865 is particularly useful in generics, where errors can be issued for
1866 specific problematic instantiations. The first parameter is a boolean
1867 expression. The pragma is effective only if the value of this expression
1868 is known at compile time, and has the value True. The set of expressions
1869 whose values are known at compile time includes all static boolean
1870 expressions, and also other values which the compiler can determine
1871 at compile time (e.g., the size of a record type set by an explicit
1872 size representation clause, or the value of a variable which was
1873 initialized to a constant and is known not to have been modified).
1874 If these conditions are met, an error message is generated using
1875 the value given as the second argument. This string value may contain
1876 embedded ASCII.LF characters to break the message into multiple lines.
1877
1878 @node Pragma Compile_Time_Warning
1879 @unnumberedsec Pragma Compile_Time_Warning
1880 @findex Compile_Time_Warning
1881 @noindent
1882 Syntax:
1883
1884 @smallexample @c ada
1885 pragma Compile_Time_Warning
1886          (boolean_EXPRESSION, static_string_EXPRESSION);
1887 @end smallexample
1888
1889 @noindent
1890 Same as pragma Compile_Time_Error, except a warning is issued instead
1891 of an error message. Note that if this pragma is used in a package that
1892 is with'ed by a client, the client will get the warning even though it
1893 is issued by a with'ed package (normally warnings in with'ed units are
1894 suppressed, but this is a special exception to that rule).
1895
1896 One typical use is within a generic where compile time known characteristics
1897 of formal parameters are tested, and warnings given appropriately. Another use
1898 with a first parameter of True is to warn a client about use of a package,
1899 for example that it is not fully implemented.
1900
1901 @node Pragma Compiler_Unit
1902 @unnumberedsec Pragma Compiler_Unit
1903 @findex Compiler_Unit
1904 @noindent
1905 Syntax:
1906
1907 @smallexample @c ada
1908 pragma Compiler_Unit;
1909 @end smallexample
1910
1911 @noindent
1912 This pragma is intended only for internal use in the GNAT run-time library.
1913 It indicates that the unit is used as part of the compiler build. The effect
1914 is to disallow constructs (raise with message, conditional expressions etc)
1915 that would cause trouble when bootstrapping using an older version of GNAT.
1916 For the exact list of restrictions, see the compiler sources and references
1917 to Is_Compiler_Unit.
1918
1919 @node Pragma Complete_Representation
1920 @unnumberedsec Pragma Complete_Representation
1921 @findex Complete_Representation
1922 @noindent
1923 Syntax:
1924
1925 @smallexample @c ada
1926 pragma Complete_Representation;
1927 @end smallexample
1928
1929 @noindent
1930 This pragma must appear immediately within a record representation
1931 clause. Typical placements are before the first component clause
1932 or after the last component clause. The effect is to give an error
1933 message if any component is missing a component clause. This pragma
1934 may be used to ensure that a record representation clause is
1935 complete, and that this invariant is maintained if fields are
1936 added to the record in the future.
1937
1938 @node Pragma Complex_Representation
1939 @unnumberedsec Pragma Complex_Representation
1940 @findex Complex_Representation
1941 @noindent
1942 Syntax:
1943
1944 @smallexample @c ada
1945 pragma Complex_Representation
1946         ([Entity =>] LOCAL_NAME);
1947 @end smallexample
1948
1949 @noindent
1950 The @var{Entity} argument must be the name of a record type which has
1951 two fields of the same floating-point type.  The effect of this pragma is
1952 to force gcc to use the special internal complex representation form for
1953 this record, which may be more efficient.  Note that this may result in
1954 the code for this type not conforming to standard ABI (application
1955 binary interface) requirements for the handling of record types.  For
1956 example, in some environments, there is a requirement for passing
1957 records by pointer, and the use of this pragma may result in passing
1958 this type in floating-point registers.
1959
1960 @node Pragma Component_Alignment
1961 @unnumberedsec Pragma Component_Alignment
1962 @cindex Alignments of components
1963 @findex Component_Alignment
1964 @noindent
1965 Syntax:
1966
1967 @smallexample @c ada
1968 pragma Component_Alignment (
1969      [Form =>] ALIGNMENT_CHOICE
1970   [, [Name =>] type_LOCAL_NAME]);
1971
1972 ALIGNMENT_CHOICE ::=
1973   Component_Size
1974 | Component_Size_4
1975 | Storage_Unit
1976 | Default
1977 @end smallexample
1978
1979 @noindent
1980 Specifies the alignment of components in array or record types.
1981 The meaning of the @var{Form} argument is as follows:
1982
1983 @table @code
1984 @findex Component_Size
1985 @item Component_Size
1986 Aligns scalar components and subcomponents of the array or record type
1987 on boundaries appropriate to their inherent size (naturally
1988 aligned).  For example, 1-byte components are aligned on byte boundaries,
1989 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1990 integer components are aligned on 4-byte boundaries and so on.  These
1991 alignment rules correspond to the normal rules for C compilers on all
1992 machines except the VAX@.
1993
1994 @findex Component_Size_4
1995 @item Component_Size_4
1996 Naturally aligns components with a size of four or fewer
1997 bytes.  Components that are larger than 4 bytes are placed on the next
1998 4-byte boundary.
1999
2000 @findex Storage_Unit
2001 @item Storage_Unit
2002 Specifies that array or record components are byte aligned, i.e.@:
2003 aligned on boundaries determined by the value of the constant
2004 @code{System.Storage_Unit}.
2005
2006 @cindex OpenVMS
2007 @item Default
2008 Specifies that array or record components are aligned on default
2009 boundaries, appropriate to the underlying hardware or operating system or
2010 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2011 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2012 the @code{Default} choice is the same as @code{Component_Size} (natural
2013 alignment).
2014 @end table
2015
2016 @noindent
2017 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2018 refer to a local record or array type, and the specified alignment
2019 choice applies to the specified type.  The use of
2020 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2021 @code{Component_Alignment} pragma to be ignored.  The use of
2022 @code{Component_Alignment} together with a record representation clause
2023 is only effective for fields not specified by the representation clause.
2024
2025 If the @code{Name} parameter is absent, the pragma can be used as either
2026 a configuration pragma, in which case it applies to one or more units in
2027 accordance with the normal rules for configuration pragmas, or it can be
2028 used within a declarative part, in which case it applies to types that
2029 are declared within this declarative part, or within any nested scope
2030 within this declarative part.  In either case it specifies the alignment
2031 to be applied to any record or array type which has otherwise standard
2032 representation.
2033
2034 If the alignment for a record or array type is not specified (using
2035 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2036 clause), the GNAT uses the default alignment as described previously.
2037
2038 @node Pragma Contract_Cases
2039 @unnumberedsec Pragma Contract_Cases
2040 @cindex Contract cases
2041 @findex Contract_Cases
2042 @noindent
2043 Syntax:
2044
2045 @smallexample @c ada
2046 pragma Contract_Cases (
2047    Condition => Consequence
2048  @{,Condition => Consequence@});
2049 @end smallexample
2050
2051 @noindent
2052 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2053 that can complement or replace the contract given by a precondition and a
2054 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2055 by testing and formal verification tools. The compiler checks its validity and,
2056 depending on the assertion policy at the point of declaration of the pragma,
2057 it may insert a check in the executable. For code generation, the contract
2058 cases
2059
2060 @smallexample @c ada
2061 pragma Contract_Cases (
2062   Cond1 => Pred1,
2063   Cond2 => Pred2);
2064 @end smallexample
2065
2066 @noindent
2067 are equivalent to
2068
2069 @smallexample @c ada
2070 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2071 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2072 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2073 pragma Postcondition (if C1 then Pred1);
2074 pragma Postcondition (if C2 then Pred2);
2075 @end smallexample
2076
2077 @noindent
2078 The precondition ensures that one and only one of the conditions is
2079 satisfied on entry to the subprogram.
2080 The postcondition ensures that for the condition that was True on entry,
2081 the corrresponding consequence is True on exit. Other consequence expressions
2082 are not evaluated.
2083
2084 A precondition @code{P} and postcondition @code{Q} can also be
2085 expressed as contract cases:
2086
2087 @smallexample @c ada
2088 pragma Contract_Cases (P => Q);
2089 @end smallexample
2090
2091 The placement and visibility rules for @code{Contract_Cases} pragmas are
2092 identical to those described for preconditions and postconditions.
2093
2094 The compiler checks that boolean expressions given in conditions and
2095 consequences are valid, where the rules for conditions are the same as
2096 the rule for an expression in @code{Precondition} and the rules for
2097 consequences are the same as the rule for an expression in
2098 @code{Postcondition}. In particular, attributes @code{'Old} and
2099 @code{'Result} can only be used within consequence expressions.
2100 The condition for the last contract case may be @code{others}, to denote
2101 any case not captured by the previous cases. The
2102 following is an example of use within a package spec:
2103
2104 @smallexample @c ada
2105 package Math_Functions is
2106    ...
2107    function Sqrt (Arg : Float) return Float;
2108    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2109                           Arg >= 100       => Sqrt'Result >= 10,
2110                           others           => Sqrt'Result = 0);
2111    ...
2112 end Math_Functions;
2113 @end smallexample
2114
2115 @noindent
2116 The meaning of contract cases is that only one case should apply at each
2117 call, as determined by the corresponding condition evaluating to True,
2118 and that the consequence for this case should hold when the subprogram
2119 returns.
2120
2121 @node Pragma Convention_Identifier
2122 @unnumberedsec Pragma Convention_Identifier
2123 @findex Convention_Identifier
2124 @cindex Conventions, synonyms
2125 @noindent
2126 Syntax:
2127
2128 @smallexample @c ada
2129 pragma Convention_Identifier (
2130          [Name =>]       IDENTIFIER,
2131          [Convention =>] convention_IDENTIFIER);
2132 @end smallexample
2133
2134 @noindent
2135 This pragma provides a mechanism for supplying synonyms for existing
2136 convention identifiers. The @code{Name} identifier can subsequently
2137 be used as a synonym for the given convention in other pragmas (including
2138 for example pragma @code{Import} or another @code{Convention_Identifier}
2139 pragma). As an example of the use of this, suppose you had legacy code
2140 which used Fortran77 as the identifier for Fortran. Then the pragma:
2141
2142 @smallexample @c ada
2143 pragma Convention_Identifier (Fortran77, Fortran);
2144 @end smallexample
2145
2146 @noindent
2147 would allow the use of the convention identifier @code{Fortran77} in
2148 subsequent code, avoiding the need to modify the sources. As another
2149 example, you could use this to parameterize convention requirements
2150 according to systems. Suppose you needed to use @code{Stdcall} on
2151 windows systems, and @code{C} on some other system, then you could
2152 define a convention identifier @code{Library} and use a single
2153 @code{Convention_Identifier} pragma to specify which convention
2154 would be used system-wide.
2155
2156 @node Pragma CPP_Class
2157 @unnumberedsec Pragma CPP_Class
2158 @findex CPP_Class
2159 @cindex Interfacing with C++
2160 @noindent
2161 Syntax:
2162
2163 @smallexample @c ada
2164 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2165 @end smallexample
2166
2167 @noindent
2168 The argument denotes an entity in the current declarative region that is
2169 declared as a record type. It indicates that the type corresponds to an
2170 externally declared C++ class type, and is to be laid out the same way
2171 that C++ would lay out the type. If the C++ class has virtual primitives
2172 then the record must be declared as a tagged record type.
2173
2174 Types for which @code{CPP_Class} is specified do not have assignment or
2175 equality operators defined (such operations can be imported or declared
2176 as subprograms as required). Initialization is allowed only by constructor
2177 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2178 limited if not explicitly declared as limited or derived from a limited
2179 type, and an error is issued in that case.
2180
2181 See @ref{Interfacing to C++} for related information.
2182
2183 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2184 for backward compatibility but its functionality is available
2185 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2186
2187 @node Pragma CPP_Constructor
2188 @unnumberedsec Pragma CPP_Constructor
2189 @cindex Interfacing with C++
2190 @findex CPP_Constructor
2191 @noindent
2192 Syntax:
2193
2194 @smallexample @c ada
2195 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2196   [, [External_Name =>] static_string_EXPRESSION ]
2197   [, [Link_Name     =>] static_string_EXPRESSION ]);
2198 @end smallexample
2199
2200 @noindent
2201 This pragma identifies an imported function (imported in the usual way
2202 with pragma @code{Import}) as corresponding to a C++ constructor. If
2203 @code{External_Name} and @code{Link_Name} are not specified then the
2204 @code{Entity} argument is a name that must have been previously mentioned
2205 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2206 must be of one of the following forms:
2207
2208 @itemize @bullet
2209 @item
2210 @code{function @var{Fname} return @var{T}}
2211
2212 @itemize @bullet
2213 @item
2214 @code{function @var{Fname} return @var{T}'Class}
2215
2216 @item
2217 @code{function @var{Fname} (@dots{}) return @var{T}}
2218 @end itemize
2219
2220 @item
2221 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2222 @end itemize
2223
2224 @noindent
2225 where @var{T} is a limited record type imported from C++ with pragma
2226 @code{Import} and @code{Convention} = @code{CPP}.
2227
2228 The first two forms import the default constructor, used when an object
2229 of type @var{T} is created on the Ada side with no explicit constructor.
2230 The latter two forms cover all the non-default constructors of the type.
2231 See the @value{EDITION} User's Guide for details.
2232
2233 If no constructors are imported, it is impossible to create any objects
2234 on the Ada side and the type is implicitly declared abstract.
2235
2236 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2237 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2238 GCC switch).
2239 See @ref{Interfacing to C++} for more related information.
2240
2241 Note: The use of functions returning class-wide types for constructors is
2242 currently obsolete. They are supported for backward compatibility. The
2243 use of functions returning the type T leave the Ada sources more clear
2244 because the imported C++ constructors always return an object of type T;
2245 that is, they never return an object whose type is a descendant of type T.
2246
2247 @node Pragma CPP_Virtual
2248 @unnumberedsec Pragma CPP_Virtual
2249 @cindex Interfacing to C++
2250 @findex CPP_Virtual
2251 @noindent
2252 This pragma is now obsolete and, other than generating a warning if warnings
2253 on obsolescent features are enabled, is completely ignored.
2254 It is retained for compatibility
2255 purposes. It used to be required to ensure compoatibility with C++, but
2256 is no longer required for that purpose because GNAT generates
2257 the same object layout as the G++ compiler by default.
2258
2259 See @ref{Interfacing to C++} for related information.
2260
2261 @node Pragma CPP_Vtable
2262 @unnumberedsec Pragma CPP_Vtable
2263 @cindex Interfacing with C++
2264 @findex CPP_Vtable
2265 @noindent
2266 This pragma is now obsolete and, other than generating a warning if warnings
2267 on obsolescent features are enabled, is completely ignored.
2268 It used to be required to ensure compatibility with C++, but
2269 is no longer required for that purpose because GNAT generates
2270 the same object layout than the G++ compiler by default.
2271
2272 See @ref{Interfacing to C++} for related information.
2273
2274 @node Pragma CPU
2275 @unnumberedsec Pragma CPU
2276 @findex CPU
2277 @noindent
2278 Syntax:
2279
2280 @smallexample @c ada
2281 pragma CPU (EXPRESSSION);
2282 @end smallexample
2283
2284 @noindent
2285 This pragma is standard in Ada 2012, but is available in all earlier
2286 versions of Ada as an implementation-defined pragma.
2287 See Ada 2012 Reference Manual for details.
2288
2289 @node Pragma Debug
2290 @unnumberedsec Pragma Debug
2291 @findex Debug
2292 @noindent
2293 Syntax:
2294
2295 @smallexample @c ada
2296 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2297
2298 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2299   PROCEDURE_NAME
2300 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2301 @end smallexample
2302
2303 @noindent
2304 The procedure call argument has the syntactic form of an expression, meeting
2305 the syntactic requirements for pragmas.
2306
2307 If debug pragmas are not enabled or if the condition is present and evaluates
2308 to False, this pragma has no effect. If debug pragmas are enabled, the
2309 semantics of the pragma is exactly equivalent to the procedure call statement
2310 corresponding to the argument with a terminating semicolon. Pragmas are
2311 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2312 intersperse calls to debug procedures in the middle of declarations. Debug
2313 pragmas can be enabled either by use of the command line switch @option{-gnata}
2314 or by use of the pragma @code{Check_Policy} with a first argument of
2315 @code{Debug}.
2316
2317 @node Pragma Debug_Policy
2318 @unnumberedsec Pragma Debug_Policy
2319 @findex Debug_Policy
2320 @noindent
2321 Syntax:
2322
2323 @smallexample @c ada
2324 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2325 @end smallexample
2326
2327 @noindent
2328 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2329 with a first argument of @code{Debug}. It is retained for historical
2330 compatibility reasons.
2331
2332 @node Pragma Default_Storage_Pool
2333 @unnumberedsec Pragma Default_Storage_Pool
2334 @findex Default_Storage_Pool
2335 @noindent
2336 Syntax:
2337
2338 @smallexample @c ada
2339 pragma Default_Storage_Pool (storage_pool_NAME | null);
2340 @end smallexample
2341
2342 @noindent
2343 This pragma is standard in Ada 2012, but is available in all earlier
2344 versions of Ada as an implementation-defined pragma.
2345 See Ada 2012 Reference Manual for details.
2346
2347 @node Pragma Detect_Blocking
2348 @unnumberedsec Pragma Detect_Blocking
2349 @findex Detect_Blocking
2350 @noindent
2351 Syntax:
2352
2353 @smallexample @c ada
2354 pragma Detect_Blocking;
2355 @end smallexample
2356
2357 @noindent
2358 This is a standard pragma in Ada 2005, that is available in all earlier
2359 versions of Ada as an implementation-defined pragma.
2360
2361 This is a configuration pragma that forces the detection of potentially
2362 blocking operations within a protected operation, and to raise Program_Error
2363 if that happens.
2364
2365 @node Pragma Disable_Atomic_Synchronization
2366 @unnumberedsec Pragma Disable_Atomic_Synchronization
2367 @cindex Atomic Synchronization
2368 @findex Disable_Atomic_Synchronization
2369 @noindent
2370 Syntax:
2371
2372 @smallexample @c ada
2373 pragma Disable_Atomic_Synchronization [(Entity)];
2374 @end smallexample
2375
2376 @noindent
2377 Ada requires that accesses (reads or writes) of an atomic variable be
2378 regarded as synchronization points in the case of multiple tasks.
2379 Particularly in the case of multi-processors this may require special
2380 handling, e.g. the generation of memory barriers. This capability may
2381 be turned off using this pragma in cases where it is known not to be
2382 required.
2383
2384 The placement and scope rules for this pragma are the same as those
2385 for @code{pragma Suppress}. In particular it can be used as a
2386 configuration  pragma, or in a declaration sequence where it applies
2387 till the end of the scope. If an @code{Entity} argument is present,
2388 the action applies only to that entity.
2389
2390 @node Pragma Dispatching_Domain
2391 @unnumberedsec Pragma Dispatching_Domain
2392 @findex Dispatching_Domain
2393 @noindent
2394 Syntax:
2395
2396 @smallexample @c ada
2397 pragma Dispatching_Domain (EXPRESSION);
2398 @end smallexample
2399
2400 @noindent
2401 This pragma is standard in Ada 2012, but is available in all earlier
2402 versions of Ada as an implementation-defined pragma.
2403 See Ada 2012 Reference Manual for details.
2404
2405 @node Pragma Elaboration_Checks
2406 @unnumberedsec Pragma Elaboration_Checks
2407 @cindex Elaboration control
2408 @findex Elaboration_Checks
2409 @noindent
2410 Syntax:
2411
2412 @smallexample @c ada
2413 pragma Elaboration_Checks (Dynamic | Static);
2414 @end smallexample
2415
2416 @noindent
2417 This is a configuration pragma that provides control over the
2418 elaboration model used by the compilation affected by the
2419 pragma.  If the parameter is @code{Dynamic},
2420 then the dynamic elaboration
2421 model described in the Ada Reference Manual is used, as though
2422 the @option{-gnatE} switch had been specified on the command
2423 line.  If the parameter is @code{Static}, then the default GNAT static
2424 model is used.  This configuration pragma overrides the setting
2425 of the command line.  For full details on the elaboration models
2426 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2427 gnat_ugn, @value{EDITION} User's Guide}.
2428
2429 @node Pragma Eliminate
2430 @unnumberedsec Pragma Eliminate
2431 @cindex Elimination of unused subprograms
2432 @findex Eliminate
2433 @noindent
2434 Syntax:
2435
2436 @smallexample @c ada
2437 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2438                   [Source_Location =>] STRING_LITERAL);
2439 @end smallexample
2440
2441 @noindent
2442 The string literal given for the source location is a string which
2443 specifies the line number of the occurrence of the entity, using
2444 the syntax for SOURCE_TRACE given below:
2445
2446 @smallexample @c ada
2447  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2448
2449  LBRACKET         ::= [
2450  RBRACKET         ::= ]
2451
2452  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2453
2454  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2455 @end smallexample
2456
2457 @noindent
2458 Spaces around the colon in a @code{Source_Reference} are optional.
2459
2460 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2461 explicit subprogram declaration, where the @code{entity} name in this
2462 designator appears on the source line specified by the source location.
2463
2464 The source trace that is given as the @code{Source_Location} shall obey the
2465 following rules. The @code{FILE_NAME} is the short name (with no directory
2466 information) of an Ada source file, given using exactly the required syntax
2467 for the underlying file system (e.g. case is important if the underlying
2468 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2469 number of the occurrence of the @code{entity}
2470 as a decimal literal without an exponent or point. If an @code{entity} is not
2471 declared in a generic instantiation (this includes generic subprogram
2472 instances), the source trace includes only one source reference. If an entity
2473 is declared inside a generic instantiation, its source trace (when parsing
2474 from left to right) starts with the source location of the declaration of the
2475 entity in the generic unit and ends with the source location of the
2476 instantiation (it is given in square brackets). This approach is recursively
2477 used in case of nested instantiations: the rightmost (nested most deeply in
2478 square brackets) element of the source trace is the location of the outermost
2479 instantiation, the next to left element is the location of the next (first
2480 nested) instantiation in the code of the corresponding generic unit, and so
2481 on, and the leftmost element (that is out of any square brackets) is the
2482 location of the declaration of the entity to eliminate in a generic unit.
2483
2484 Note that the @code{Source_Location} argument specifies which of a set of
2485 similarly named entities is being eliminated, dealing both with overloading,
2486 and also appearence of the same entity name in different scopes.
2487
2488 This pragma indicates that the given entity is not used in the program to be
2489 compiled and built. The effect of the pragma is to allow the compiler to
2490 eliminate the code or data associated with the named entity. Any reference to
2491 an eliminated entity causes a compile-time or link-time error.
2492
2493 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2494 in a system-independent manner, with unused entities eliminated, without
2495 needing to modify the source text. Normally the required set of
2496 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2497
2498 Any source file change that removes, splits, or
2499 adds lines may make the set of Eliminate pragmas invalid because their
2500 @code{Source_Location} argument values may get out of date.
2501
2502 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2503 operation. In this case all the subprograms to which the given operation can
2504 dispatch are considered to be unused (are never called as a result of a direct
2505 or a dispatching call).
2506
2507 @node Pragma Enable_Atomic_Synchronization
2508 @unnumberedsec Pragma Enable_Atomic_Synchronization
2509 @cindex Atomic Synchronization
2510 @findex Enable_Atomic_Synchronization
2511 @noindent
2512 Syntax:
2513
2514 @smallexample @c ada
2515 pragma Enable_Atomic_Synchronization [(Entity)];
2516 @end smallexample
2517
2518 @noindent
2519 Ada requires that accesses (reads or writes) of an atomic variable be
2520 regarded as synchronization points in the case of multiple tasks.
2521 Particularly in the case of multi-processors this may require special
2522 handling, e.g. the generation of memory barriers. This synchronization
2523 is performed by default, but can be turned off using
2524 @code{pragma Disable_Atomic_Synchronization}. The
2525 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2526 it back on.
2527
2528 The placement and scope rules for this pragma are the same as those
2529 for @code{pragma Unsuppress}. In particular it can be used as a
2530 configuration  pragma, or in a declaration sequence where it applies
2531 till the end of the scope. If an @code{Entity} argument is present,
2532 the action applies only to that entity.
2533
2534 @node Pragma Export_Exception
2535 @unnumberedsec Pragma Export_Exception
2536 @cindex OpenVMS
2537 @findex Export_Exception
2538 @noindent
2539 Syntax:
2540
2541 @smallexample @c ada
2542 pragma Export_Exception (
2543      [Internal =>] LOCAL_NAME
2544   [, [External =>] EXTERNAL_SYMBOL]
2545   [, [Form     =>] Ada | VMS]
2546   [, [Code     =>] static_integer_EXPRESSION]);
2547
2548 EXTERNAL_SYMBOL ::=
2549   IDENTIFIER
2550 | static_string_EXPRESSION
2551 @end smallexample
2552
2553 @noindent
2554 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2555 causes the specified exception to be propagated outside of the Ada program,
2556 so that it can be handled by programs written in other OpenVMS languages.
2557 This pragma establishes an external name for an Ada exception and makes the
2558 name available to the OpenVMS Linker as a global symbol.  For further details
2559 on this pragma, see the
2560 DEC Ada Language Reference Manual, section 13.9a3.2.
2561
2562 @node Pragma Export_Function
2563 @unnumberedsec Pragma Export_Function
2564 @cindex Argument passing mechanisms
2565 @findex Export_Function
2566
2567 @noindent
2568 Syntax:
2569
2570 @smallexample @c ada
2571 pragma Export_Function (
2572      [Internal         =>] LOCAL_NAME
2573   [, [External         =>] EXTERNAL_SYMBOL]
2574   [, [Parameter_Types  =>] PARAMETER_TYPES]
2575   [, [Result_Type      =>] result_SUBTYPE_MARK]
2576   [, [Mechanism        =>] MECHANISM]
2577   [, [Result_Mechanism =>] MECHANISM_NAME]);
2578
2579 EXTERNAL_SYMBOL ::=
2580   IDENTIFIER
2581 | static_string_EXPRESSION
2582 | ""
2583
2584 PARAMETER_TYPES ::=
2585   null
2586 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2587
2588 TYPE_DESIGNATOR ::=
2589   subtype_NAME
2590 | subtype_Name ' Access
2591
2592 MECHANISM ::=
2593   MECHANISM_NAME
2594 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2595
2596 MECHANISM_ASSOCIATION ::=
2597   [formal_parameter_NAME =>] MECHANISM_NAME
2598
2599 MECHANISM_NAME ::=
2600   Value
2601 | Reference
2602 | Descriptor [([Class =>] CLASS_NAME)]
2603 | Short_Descriptor [([Class =>] CLASS_NAME)]
2604
2605 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2606 @end smallexample
2607
2608 @noindent
2609 Use this pragma to make a function externally callable and optionally
2610 provide information on mechanisms to be used for passing parameter and
2611 result values.  We recommend, for the purposes of improving portability,
2612 this pragma always be used in conjunction with a separate pragma
2613 @code{Export}, which must precede the pragma @code{Export_Function}.
2614 GNAT does not require a separate pragma @code{Export}, but if none is
2615 present, @code{Convention Ada} is assumed, which is usually
2616 not what is wanted, so it is usually appropriate to use this
2617 pragma in conjunction with a @code{Export} or @code{Convention}
2618 pragma that specifies the desired foreign convention.
2619 Pragma @code{Export_Function}
2620 (and @code{Export}, if present) must appear in the same declarative
2621 region as the function to which they apply.
2622
2623 @var{internal_name} must uniquely designate the function to which the
2624 pragma applies.  If more than one function name exists of this name in
2625 the declarative part you must use the @code{Parameter_Types} and
2626 @code{Result_Type} parameters is mandatory to achieve the required
2627 unique designation.  @var{subtype_mark}s in these parameters must
2628 exactly match the subtypes in the corresponding function specification,
2629 using positional notation to match parameters with subtype marks.
2630 The form with an @code{'Access} attribute can be used to match an
2631 anonymous access parameter.
2632
2633 @cindex OpenVMS
2634 @cindex Passing by descriptor
2635 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2636 The default behavior for Export_Function is to accept either 64bit or
2637 32bit descriptors unless short_descriptor is specified, then only 32bit
2638 descriptors are accepted.
2639
2640 @cindex Suppressing external name
2641 Special treatment is given if the EXTERNAL is an explicit null
2642 string or a static string expressions that evaluates to the null
2643 string. In this case, no external name is generated. This form
2644 still allows the specification of parameter mechanisms.
2645
2646 @node Pragma Export_Object
2647 @unnumberedsec Pragma Export_Object
2648 @findex Export_Object
2649 @noindent
2650 Syntax:
2651
2652 @smallexample @c ada
2653 pragma Export_Object
2654       [Internal =>] LOCAL_NAME
2655    [, [External =>] EXTERNAL_SYMBOL]
2656    [, [Size     =>] EXTERNAL_SYMBOL]
2657
2658 EXTERNAL_SYMBOL ::=
2659   IDENTIFIER
2660 | static_string_EXPRESSION
2661 @end smallexample
2662
2663 @noindent
2664 This pragma designates an object as exported, and apart from the
2665 extended rules for external symbols, is identical in effect to the use of
2666 the normal @code{Export} pragma applied to an object.  You may use a
2667 separate Export pragma (and you probably should from the point of view
2668 of portability), but it is not required.  @var{Size} is syntax checked,
2669 but otherwise ignored by GNAT@.
2670
2671 @node Pragma Export_Procedure
2672 @unnumberedsec Pragma Export_Procedure
2673 @findex Export_Procedure
2674 @noindent
2675 Syntax:
2676
2677 @smallexample @c ada
2678 pragma Export_Procedure (
2679      [Internal        =>] LOCAL_NAME
2680   [, [External        =>] EXTERNAL_SYMBOL]
2681   [, [Parameter_Types =>] PARAMETER_TYPES]
2682   [, [Mechanism       =>] MECHANISM]);
2683
2684 EXTERNAL_SYMBOL ::=
2685   IDENTIFIER
2686 | static_string_EXPRESSION
2687 | ""
2688
2689 PARAMETER_TYPES ::=
2690   null
2691 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2692
2693 TYPE_DESIGNATOR ::=
2694   subtype_NAME
2695 | subtype_Name ' Access
2696
2697 MECHANISM ::=
2698   MECHANISM_NAME
2699 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2700
2701 MECHANISM_ASSOCIATION ::=
2702   [formal_parameter_NAME =>] MECHANISM_NAME
2703
2704 MECHANISM_NAME ::=
2705   Value
2706 | Reference
2707 | Descriptor [([Class =>] CLASS_NAME)]
2708 | Short_Descriptor [([Class =>] CLASS_NAME)]
2709
2710 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2711 @end smallexample
2712
2713 @noindent
2714 This pragma is identical to @code{Export_Function} except that it
2715 applies to a procedure rather than a function and the parameters
2716 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2717 GNAT does not require a separate pragma @code{Export}, but if none is
2718 present, @code{Convention Ada} is assumed, which is usually
2719 not what is wanted, so it is usually appropriate to use this
2720 pragma in conjunction with a @code{Export} or @code{Convention}
2721 pragma that specifies the desired foreign convention.
2722
2723 @cindex OpenVMS
2724 @cindex Passing by descriptor
2725 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2726 The default behavior for Export_Procedure is to accept either 64bit or
2727 32bit descriptors unless short_descriptor is specified, then only 32bit
2728 descriptors are accepted.
2729
2730 @cindex Suppressing external name
2731 Special treatment is given if the EXTERNAL is an explicit null
2732 string or a static string expressions that evaluates to the null
2733 string. In this case, no external name is generated. This form
2734 still allows the specification of parameter mechanisms.
2735
2736 @node Pragma Export_Value
2737 @unnumberedsec Pragma Export_Value
2738 @findex Export_Value
2739 @noindent
2740 Syntax:
2741
2742 @smallexample @c ada
2743 pragma Export_Value (
2744   [Value     =>] static_integer_EXPRESSION,
2745   [Link_Name =>] static_string_EXPRESSION);
2746 @end smallexample
2747
2748 @noindent
2749 This pragma serves to export a static integer value for external use.
2750 The first argument specifies the value to be exported. The Link_Name
2751 argument specifies the symbolic name to be associated with the integer
2752 value. This pragma is useful for defining a named static value in Ada
2753 that can be referenced in assembly language units to be linked with
2754 the application. This pragma is currently supported only for the
2755 AAMP target and is ignored for other targets.
2756
2757 @node Pragma Export_Valued_Procedure
2758 @unnumberedsec Pragma Export_Valued_Procedure
2759 @findex Export_Valued_Procedure
2760 @noindent
2761 Syntax:
2762
2763 @smallexample @c ada
2764 pragma Export_Valued_Procedure (
2765      [Internal        =>] LOCAL_NAME
2766   [, [External        =>] EXTERNAL_SYMBOL]
2767   [, [Parameter_Types =>] PARAMETER_TYPES]
2768   [, [Mechanism       =>] MECHANISM]);
2769
2770 EXTERNAL_SYMBOL ::=
2771   IDENTIFIER
2772 | static_string_EXPRESSION
2773 | ""
2774
2775 PARAMETER_TYPES ::=
2776   null
2777 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2778
2779 TYPE_DESIGNATOR ::=
2780   subtype_NAME
2781 | subtype_Name ' Access
2782
2783 MECHANISM ::=
2784   MECHANISM_NAME
2785 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2786
2787 MECHANISM_ASSOCIATION ::=
2788   [formal_parameter_NAME =>] MECHANISM_NAME
2789
2790 MECHANISM_NAME ::=
2791   Value
2792 | Reference
2793 | Descriptor [([Class =>] CLASS_NAME)]
2794 | Short_Descriptor [([Class =>] CLASS_NAME)]
2795
2796 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2797 @end smallexample
2798
2799 @noindent
2800 This pragma is identical to @code{Export_Procedure} except that the
2801 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2802 mode @code{OUT}, and externally the subprogram is treated as a function
2803 with this parameter as the result of the function.  GNAT provides for
2804 this capability to allow the use of @code{OUT} and @code{IN OUT}
2805 parameters in interfacing to external functions (which are not permitted
2806 in Ada functions).
2807 GNAT does not require a separate pragma @code{Export}, but if none is
2808 present, @code{Convention Ada} is assumed, which is almost certainly
2809 not what is wanted since the whole point of this pragma is to interface
2810 with foreign language functions, so it is usually appropriate to use this
2811 pragma in conjunction with a @code{Export} or @code{Convention}
2812 pragma that specifies the desired foreign convention.
2813
2814 @cindex OpenVMS
2815 @cindex Passing by descriptor
2816 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2817 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2818 32bit descriptors unless short_descriptor is specified, then only 32bit
2819 descriptors are accepted.
2820
2821 @cindex Suppressing external name
2822 Special treatment is given if the EXTERNAL is an explicit null
2823 string or a static string expressions that evaluates to the null
2824 string. In this case, no external name is generated. This form
2825 still allows the specification of parameter mechanisms.
2826
2827 @node Pragma Extend_System
2828 @unnumberedsec Pragma Extend_System
2829 @cindex @code{system}, extending
2830 @cindex Dec Ada 83
2831 @findex Extend_System
2832 @noindent
2833 Syntax:
2834
2835 @smallexample @c ada
2836 pragma Extend_System ([Name =>] IDENTIFIER);
2837 @end smallexample
2838
2839 @noindent
2840 This pragma is used to provide backwards compatibility with other
2841 implementations that extend the facilities of package @code{System}.  In
2842 GNAT, @code{System} contains only the definitions that are present in
2843 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2844 implementation, provide many extensions to package @code{System}.
2845
2846 For each such implementation accommodated by this pragma, GNAT provides a
2847 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2848 implementation, which provides the required additional definitions.  You
2849 can use this package in two ways.  You can @code{with} it in the normal
2850 way and access entities either by selection or using a @code{use}
2851 clause.  In this case no special processing is required.
2852
2853 However, if existing code contains references such as
2854 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2855 definitions provided in package @code{System}, you may use this pragma
2856 to extend visibility in @code{System} in a non-standard way that
2857 provides greater compatibility with the existing code.  Pragma
2858 @code{Extend_System} is a configuration pragma whose single argument is
2859 the name of the package containing the extended definition
2860 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2861 control of this pragma will be processed using special visibility
2862 processing that looks in package @code{System.Aux_@var{xxx}} where
2863 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2864 package @code{System}, but not found in package @code{System}.
2865
2866 You can use this pragma either to access a predefined @code{System}
2867 extension supplied with the compiler, for example @code{Aux_DEC} or
2868 you can construct your own extension unit following the above
2869 definition.  Note that such a package is a child of @code{System}
2870 and thus is considered part of the implementation.  To compile
2871 it you will have to use the appropriate switch for compiling
2872 system units.
2873 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2874 for details.
2875
2876 @node Pragma Extensions_Allowed
2877 @unnumberedsec Pragma Extensions_Allowed
2878 @cindex Ada Extensions
2879 @cindex GNAT Extensions
2880 @findex Extensions_Allowed
2881 @noindent
2882 Syntax:
2883
2884 @smallexample @c ada
2885 pragma Extensions_Allowed (On | Off);
2886 @end smallexample
2887
2888 @noindent
2889 This configuration pragma enables or disables the implementation
2890 extension mode (the use of Off as a parameter cancels the effect
2891 of the @option{-gnatX} command switch).
2892
2893 In extension mode, the latest version of the Ada language is
2894 implemented (currently Ada 2012), and in addition a small number
2895 of GNAT specific extensions are recognized as follows:
2896
2897 @table @asis
2898 @item Constrained attribute for generic objects
2899 The @code{Constrained} attribute is permitted for objects of
2900 generic types. The result indicates if the corresponding actual
2901 is constrained.
2902
2903 @end table
2904
2905 @node Pragma External
2906 @unnumberedsec Pragma External
2907 @findex External
2908 @noindent
2909 Syntax:
2910
2911 @smallexample @c ada
2912 pragma External (
2913   [   Convention    =>] convention_IDENTIFIER,
2914   [   Entity        =>] LOCAL_NAME
2915   [, [External_Name =>] static_string_EXPRESSION ]
2916   [, [Link_Name     =>] static_string_EXPRESSION ]);
2917 @end smallexample
2918
2919 @noindent
2920 This pragma is identical in syntax and semantics to pragma
2921 @code{Export} as defined in the Ada Reference Manual.  It is
2922 provided for compatibility with some Ada 83 compilers that
2923 used this pragma for exactly the same purposes as pragma
2924 @code{Export} before the latter was standardized.
2925
2926 @node Pragma External_Name_Casing
2927 @unnumberedsec Pragma External_Name_Casing
2928 @cindex Dec Ada 83 casing compatibility
2929 @cindex External Names, casing
2930 @cindex Casing of External names
2931 @findex External_Name_Casing
2932 @noindent
2933 Syntax:
2934
2935 @smallexample @c ada
2936 pragma External_Name_Casing (
2937   Uppercase | Lowercase
2938   [, Uppercase | Lowercase | As_Is]);
2939 @end smallexample
2940
2941 @noindent
2942 This pragma provides control over the casing of external names associated
2943 with Import and Export pragmas.  There are two cases to consider:
2944
2945 @table @asis
2946 @item Implicit external names
2947 Implicit external names are derived from identifiers.  The most common case
2948 arises when a standard Ada Import or Export pragma is used with only two
2949 arguments, as in:
2950
2951 @smallexample @c ada
2952    pragma Import (C, C_Routine);
2953 @end smallexample
2954
2955 @noindent
2956 Since Ada is a case-insensitive language, the spelling of the identifier in
2957 the Ada source program does not provide any information on the desired
2958 casing of the external name, and so a convention is needed.  In GNAT the
2959 default treatment is that such names are converted to all lower case
2960 letters.  This corresponds to the normal C style in many environments.
2961 The first argument of pragma @code{External_Name_Casing} can be used to
2962 control this treatment.  If @code{Uppercase} is specified, then the name
2963 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2964 then the normal default of all lower case letters will be used.
2965
2966 This same implicit treatment is also used in the case of extended DEC Ada 83
2967 compatible Import and Export pragmas where an external name is explicitly
2968 specified using an identifier rather than a string.
2969
2970 @item Explicit external names
2971 Explicit external names are given as string literals.  The most common case
2972 arises when a standard Ada Import or Export pragma is used with three
2973 arguments, as in:
2974
2975 @smallexample @c ada
2976 pragma Import (C, C_Routine, "C_routine");
2977 @end smallexample
2978
2979 @noindent
2980 In this case, the string literal normally provides the exact casing required
2981 for the external name.  The second argument of pragma
2982 @code{External_Name_Casing} may be used to modify this behavior.
2983 If @code{Uppercase} is specified, then the name
2984 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2985 then the name will be forced to all lowercase letters.  A specification of
2986 @code{As_Is} provides the normal default behavior in which the casing is
2987 taken from the string provided.
2988 @end table
2989
2990 @noindent
2991 This pragma may appear anywhere that a pragma is valid.  In particular, it
2992 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2993 case it applies to all subsequent compilations, or it can be used as a program
2994 unit pragma, in which case it only applies to the current unit, or it can
2995 be used more locally to control individual Import/Export pragmas.
2996
2997 It is primarily intended for use with OpenVMS systems, where many
2998 compilers convert all symbols to upper case by default.  For interfacing to
2999 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3000 the pragma:
3001
3002 @smallexample @c ada
3003 pragma External_Name_Casing (Uppercase, Uppercase);
3004 @end smallexample
3005
3006 @noindent
3007 to enforce the upper casing of all external symbols.
3008
3009 @node Pragma Fast_Math
3010 @unnumberedsec Pragma Fast_Math
3011 @findex Fast_Math
3012 @noindent
3013 Syntax:
3014
3015 @smallexample @c ada
3016 pragma Fast_Math;
3017 @end smallexample
3018
3019 @noindent
3020 This is a configuration pragma which activates a mode in which speed is
3021 considered more important for floating-point operations than absolutely
3022 accurate adherence to the requirements of the standard. Currently the
3023 following operations are affected:
3024
3025 @table @asis
3026 @item Complex Multiplication
3027 The normal simple formula for complex multiplication can result in intermediate
3028 overflows for numbers near the end of the range. The Ada standard requires that
3029 this situation be detected and corrected by scaling, but in Fast_Math mode such
3030 cases will simply result in overflow. Note that to take advantage of this you
3031 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3032 under control of the pragma, rather than use the preinstantiated versions.
3033 @end table
3034
3035 @node Pragma Favor_Top_Level
3036 @unnumberedsec Pragma Favor_Top_Level
3037 @findex Favor_Top_Level
3038 @noindent
3039 Syntax:
3040
3041 @smallexample @c ada
3042 pragma Favor_Top_Level (type_NAME);
3043 @end smallexample
3044
3045 @noindent
3046 The named type must be an access-to-subprogram type. This pragma is an
3047 efficiency hint to the compiler, regarding the use of 'Access or
3048 'Unrestricted_Access on nested (non-library-level) subprograms. The
3049 pragma means that nested subprograms are not used with this type, or
3050 are rare, so that the generated code should be efficient in the
3051 top-level case. When this pragma is used, dynamically generated
3052 trampolines may be used on some targets for nested subprograms.
3053 See also the No_Implicit_Dynamic_Code restriction.
3054
3055 @node Pragma Finalize_Storage_Only
3056 @unnumberedsec Pragma Finalize_Storage_Only
3057 @findex Finalize_Storage_Only
3058 @noindent
3059 Syntax:
3060
3061 @smallexample @c ada
3062 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3063 @end smallexample
3064
3065 @noindent
3066 This pragma allows the compiler not to emit a Finalize call for objects
3067 defined at the library level.  This is mostly useful for types where
3068 finalization is only used to deal with storage reclamation since in most
3069 environments it is not necessary to reclaim memory just before terminating
3070 execution, hence the name.
3071
3072 @node Pragma Float_Representation
3073 @unnumberedsec Pragma Float_Representation
3074 @cindex OpenVMS
3075 @findex Float_Representation
3076 @noindent
3077 Syntax:
3078
3079 @smallexample @c ada
3080 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3081
3082 FLOAT_REP ::= VAX_Float | IEEE_Float
3083 @end smallexample
3084
3085 @noindent
3086 In the one argument form, this pragma is a configuration pragma which
3087 allows control over the internal representation chosen for the predefined
3088 floating point types declared in the packages @code{Standard} and
3089 @code{System}. On all systems other than OpenVMS, the argument must
3090 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3091 argument may be @code{VAX_Float} to specify the use of the VAX float
3092 format for the floating-point types in Standard. This requires that
3093 the standard runtime libraries be recompiled.
3094
3095 The two argument form specifies the representation to be used for
3096 the specified floating-point type. On all systems other than OpenVMS,
3097 the argument must
3098 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3099
3100 @itemize @bullet
3101 @item
3102 For a digits value of 6, 32-bit IEEE short format will be used.
3103 @item
3104 For a digits value of 15, 64-bit IEEE long format will be used.
3105 @item
3106 No other value of digits is permitted.
3107 @end itemize
3108
3109 On OpenVMS, the
3110 argument may be @code{VAX_Float} to specify the use of the VAX float
3111 format, as follows:
3112
3113 @itemize @bullet
3114 @item
3115 For digits values up to 6, F float format will be used.
3116 @item
3117 For digits values from 7 to 9, D float format will be used.
3118 @item
3119 For digits values from 10 to 15, G float format will be used.
3120 @item
3121 Digits values above 15 are not allowed.
3122 @end itemize
3123
3124 @node Pragma Ident
3125 @unnumberedsec Pragma Ident
3126 @findex Ident
3127 @noindent
3128 Syntax:
3129
3130 @smallexample @c ada
3131 pragma Ident (static_string_EXPRESSION);
3132 @end smallexample
3133
3134 @noindent
3135 This pragma provides a string identification in the generated object file,
3136 if the system supports the concept of this kind of identification string.
3137 This pragma is allowed only in the outermost declarative part or
3138 declarative items of a compilation unit. If more than one @code{Ident}
3139 pragma is given, only the last one processed is effective.
3140 @cindex OpenVMS
3141 On OpenVMS systems, the effect of the pragma is identical to the effect of
3142 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3143 maximum allowed length is 31 characters, so if it is important to
3144 maintain compatibility with this compiler, you should obey this length
3145 limit.
3146
3147 @node Pragma Implementation_Defined
3148 @unnumberedsec Pragma Implementation_Defined
3149 @findex Implementation_Defined
3150 @noindent
3151 Syntax:
3152
3153 @smallexample @c ada
3154 pragma Implementation_Defined (local_NAME);
3155 @end smallexample
3156
3157 @noindent
3158 This pragma marks a previously declared entioty as implementation-defined.
3159 For an overloaded entity, applies to the most recent homonym.
3160
3161 @smallexample @c ada
3162 pragma Implementation_Defined;
3163 @end smallexample
3164
3165 @noindent
3166 The form with no arguments appears anywhere within a scope, most
3167 typically a package spec, and indicates that all entities that are
3168 defined within the package spec are Implementation_Defined.
3169
3170 This pragma is used within the GNAT runtime library to identify
3171 implementation-defined entities introduced in language-defined units,
3172 for the purpose of implementing the No_Implementation_Identifiers
3173 restriction.
3174
3175 @node Pragma Implemented
3176 @unnumberedsec Pragma Implemented
3177 @findex Implemented
3178 @noindent
3179 Syntax:
3180
3181 @smallexample @c ada
3182 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3183
3184 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3185 @end smallexample
3186
3187 @noindent
3188 This is an Ada 2012 representation pragma which applies to protected, task
3189 and synchronized interface primitives. The use of pragma Implemented provides
3190 a way to impose a static requirement on the overriding operation by adhering
3191 to one of the three implementation kinds: entry, protected procedure or any of
3192 the above. This pragma is available in all earlier versions of Ada as an
3193 implementation-defined pragma.
3194
3195 @smallexample @c ada
3196 type Synch_Iface is synchronized interface;
3197 procedure Prim_Op (Obj : in out Iface) is abstract;
3198 pragma Implemented (Prim_Op, By_Protected_Procedure);
3199
3200 protected type Prot_1 is new Synch_Iface with
3201    procedure Prim_Op;  --  Legal
3202 end Prot_1;
3203
3204 protected type Prot_2 is new Synch_Iface with
3205    entry Prim_Op;      --  Illegal
3206 end Prot_2;
3207
3208 task type Task_Typ is new Synch_Iface with
3209    entry Prim_Op;      --  Illegal
3210 end Task_Typ;
3211 @end smallexample
3212
3213 @noindent
3214 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3215 Implemented determines the runtime behavior of the requeue. Implementation kind
3216 By_Entry guarantees that the action of requeueing will proceed from an entry to
3217 another entry. Implementation kind By_Protected_Procedure transforms the
3218 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3219 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3220 the target's overriding subprogram kind.
3221
3222 @node Pragma Implicit_Packing
3223 @unnumberedsec Pragma Implicit_Packing
3224 @findex Implicit_Packing
3225 @cindex Rational Profile
3226 @noindent
3227 Syntax:
3228
3229 @smallexample @c ada
3230 pragma Implicit_Packing;
3231 @end smallexample
3232
3233 @noindent
3234 This is a configuration pragma that requests implicit packing for packed
3235 arrays for which a size clause is given but no explicit pragma Pack or
3236 specification of Component_Size is present. It also applies to records
3237 where no record representation clause is present. Consider this example:
3238
3239 @smallexample @c ada
3240 type R is array (0 .. 7) of Boolean;
3241 for R'Size use 8;
3242 @end smallexample
3243
3244 @noindent
3245 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3246 does not change the layout of a composite object. So the Size clause in the
3247 above example is normally rejected, since the default layout of the array uses
3248 8-bit components, and thus the array requires a minimum of 64 bits.
3249
3250 If this declaration is compiled in a region of code covered by an occurrence
3251 of the configuration pragma Implicit_Packing, then the Size clause in this
3252 and similar examples will cause implicit packing and thus be accepted. For
3253 this implicit packing to occur, the type in question must be an array of small
3254 components whose size is known at compile time, and the Size clause must
3255 specify the exact size that corresponds to the length of the array multiplied
3256 by the size in bits of the component type.
3257 @cindex Array packing
3258
3259 Similarly, the following example shows the use in the record case
3260
3261 @smallexample @c ada
3262 type r is record
3263    a, b, c, d, e, f, g, h : boolean;
3264    chr                    : character;
3265 end record;
3266 for r'size use 16;
3267 @end smallexample
3268
3269 @noindent
3270 Without a pragma Pack, each Boolean field requires 8 bits, so the
3271 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3272 sufficient. The use of pragma Implicit_Packing allows this record
3273 declaration to compile without an explicit pragma Pack.
3274 @node Pragma Import_Exception
3275 @unnumberedsec Pragma Import_Exception
3276 @cindex OpenVMS
3277 @findex Import_Exception
3278 @noindent
3279 Syntax:
3280
3281 @smallexample @c ada
3282 pragma Import_Exception (
3283      [Internal =>] LOCAL_NAME
3284   [, [External =>] EXTERNAL_SYMBOL]
3285   [, [Form     =>] Ada | VMS]
3286   [, [Code     =>] static_integer_EXPRESSION]);
3287
3288 EXTERNAL_SYMBOL ::=
3289   IDENTIFIER
3290 | static_string_EXPRESSION
3291 @end smallexample
3292
3293 @noindent
3294 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3295 It allows OpenVMS conditions (for example, from OpenVMS system services or
3296 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3297 The pragma specifies that the exception associated with an exception
3298 declaration in an Ada program be defined externally (in non-Ada code).
3299 For further details on this pragma, see the
3300 DEC Ada Language Reference Manual, section 13.9a.3.1.
3301
3302 @node Pragma Import_Function
3303 @unnumberedsec Pragma Import_Function
3304 @findex Import_Function
3305 @noindent
3306 Syntax:
3307
3308 @smallexample @c ada
3309 pragma Import_Function (
3310      [Internal                 =>] LOCAL_NAME,
3311   [, [External                 =>] EXTERNAL_SYMBOL]
3312   [, [Parameter_Types          =>] PARAMETER_TYPES]
3313   [, [Result_Type              =>] SUBTYPE_MARK]
3314   [, [Mechanism                =>] MECHANISM]
3315   [, [Result_Mechanism         =>] MECHANISM_NAME]
3316   [, [First_Optional_Parameter =>] IDENTIFIER]);
3317
3318 EXTERNAL_SYMBOL ::=
3319   IDENTIFIER
3320 | static_string_EXPRESSION
3321
3322 PARAMETER_TYPES ::=
3323   null
3324 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3325
3326 TYPE_DESIGNATOR ::=
3327   subtype_NAME
3328 | subtype_Name ' Access
3329
3330 MECHANISM ::=
3331   MECHANISM_NAME
3332 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3333
3334 MECHANISM_ASSOCIATION ::=
3335   [formal_parameter_NAME =>] MECHANISM_NAME
3336
3337 MECHANISM_NAME ::=
3338   Value
3339 | Reference
3340 | Descriptor [([Class =>] CLASS_NAME)]
3341 | Short_Descriptor [([Class =>] CLASS_NAME)]
3342
3343 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3344 @end smallexample
3345
3346 @noindent
3347 This pragma is used in conjunction with a pragma @code{Import} to
3348 specify additional information for an imported function.  The pragma
3349 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3350 @code{Import_Function} pragma and both must appear in the same
3351 declarative part as the function specification.
3352
3353 The @var{Internal} argument must uniquely designate
3354 the function to which the
3355 pragma applies.  If more than one function name exists of this name in
3356 the declarative part you must use the @code{Parameter_Types} and
3357 @var{Result_Type} parameters to achieve the required unique
3358 designation.  Subtype marks in these parameters must exactly match the
3359 subtypes in the corresponding function specification, using positional
3360 notation to match parameters with subtype marks.
3361 The form with an @code{'Access} attribute can be used to match an
3362 anonymous access parameter.
3363
3364 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3365 parameters to specify passing mechanisms for the
3366 parameters and result.  If you specify a single mechanism name, it
3367 applies to all parameters.  Otherwise you may specify a mechanism on a
3368 parameter by parameter basis using either positional or named
3369 notation.  If the mechanism is not specified, the default mechanism
3370 is used.
3371
3372 @cindex OpenVMS
3373 @cindex Passing by descriptor
3374 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3375 The default behavior for Import_Function is to pass a 64bit descriptor
3376 unless short_descriptor is specified, then a 32bit descriptor is passed.
3377
3378 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3379 It specifies that the designated parameter and all following parameters
3380 are optional, meaning that they are not passed at the generated code
3381 level (this is distinct from the notion of optional parameters in Ada
3382 where the parameters are passed anyway with the designated optional
3383 parameters).  All optional parameters must be of mode @code{IN} and have
3384 default parameter values that are either known at compile time
3385 expressions, or uses of the @code{'Null_Parameter} attribute.
3386
3387 @node Pragma Import_Object
3388 @unnumberedsec Pragma Import_Object
3389 @findex Import_Object
3390 @noindent
3391 Syntax:
3392
3393 @smallexample @c ada
3394 pragma Import_Object
3395      [Internal =>] LOCAL_NAME
3396   [, [External =>] EXTERNAL_SYMBOL]
3397   [, [Size     =>] EXTERNAL_SYMBOL]);
3398
3399 EXTERNAL_SYMBOL ::=
3400   IDENTIFIER
3401 | static_string_EXPRESSION
3402 @end smallexample
3403
3404 @noindent
3405 This pragma designates an object as imported, and apart from the
3406 extended rules for external symbols, is identical in effect to the use of
3407 the normal @code{Import} pragma applied to an object.  Unlike the
3408 subprogram case, you need not use a separate @code{Import} pragma,
3409 although you may do so (and probably should do so from a portability
3410 point of view).  @var{size} is syntax checked, but otherwise ignored by
3411 GNAT@.
3412
3413 @node Pragma Import_Procedure
3414 @unnumberedsec Pragma Import_Procedure
3415 @findex Import_Procedure
3416 @noindent
3417 Syntax:
3418
3419 @smallexample @c ada
3420 pragma Import_Procedure (
3421      [Internal                 =>] LOCAL_NAME
3422   [, [External                 =>] EXTERNAL_SYMBOL]
3423   [, [Parameter_Types          =>] PARAMETER_TYPES]
3424   [, [Mechanism                =>] MECHANISM]
3425   [, [First_Optional_Parameter =>] IDENTIFIER]);
3426
3427 EXTERNAL_SYMBOL ::=
3428   IDENTIFIER
3429 | static_string_EXPRESSION
3430
3431 PARAMETER_TYPES ::=
3432   null
3433 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3434
3435 TYPE_DESIGNATOR ::=
3436   subtype_NAME
3437 | subtype_Name ' Access
3438
3439 MECHANISM ::=
3440   MECHANISM_NAME
3441 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3442
3443 MECHANISM_ASSOCIATION ::=
3444   [formal_parameter_NAME =>] MECHANISM_NAME
3445
3446 MECHANISM_NAME ::=
3447   Value
3448 | Reference
3449 | Descriptor [([Class =>] CLASS_NAME)]
3450 | Short_Descriptor [([Class =>] CLASS_NAME)]
3451
3452 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3453 @end smallexample
3454
3455 @noindent
3456 This pragma is identical to @code{Import_Function} except that it
3457 applies to a procedure rather than a function and the parameters
3458 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3459
3460 @node Pragma Import_Valued_Procedure
3461 @unnumberedsec Pragma Import_Valued_Procedure
3462 @findex Import_Valued_Procedure
3463 @noindent
3464 Syntax:
3465
3466 @smallexample @c ada
3467 pragma Import_Valued_Procedure (
3468      [Internal                 =>] LOCAL_NAME
3469   [, [External                 =>] EXTERNAL_SYMBOL]
3470   [, [Parameter_Types          =>] PARAMETER_TYPES]
3471   [, [Mechanism                =>] MECHANISM]
3472   [, [First_Optional_Parameter =>] IDENTIFIER]);
3473
3474 EXTERNAL_SYMBOL ::=
3475   IDENTIFIER
3476 | static_string_EXPRESSION
3477
3478 PARAMETER_TYPES ::=
3479   null
3480 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3481
3482 TYPE_DESIGNATOR ::=
3483   subtype_NAME
3484 | subtype_Name ' Access
3485
3486 MECHANISM ::=
3487   MECHANISM_NAME
3488 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3489
3490 MECHANISM_ASSOCIATION ::=
3491   [formal_parameter_NAME =>] MECHANISM_NAME
3492
3493 MECHANISM_NAME ::=
3494   Value
3495 | Reference
3496 | Descriptor [([Class =>] CLASS_NAME)]
3497 | Short_Descriptor [([Class =>] CLASS_NAME)]
3498
3499 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3500 @end smallexample
3501
3502 @noindent
3503 This pragma is identical to @code{Import_Procedure} except that the
3504 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3505 mode @code{OUT}, and externally the subprogram is treated as a function
3506 with this parameter as the result of the function.  The purpose of this
3507 capability is to allow the use of @code{OUT} and @code{IN OUT}
3508 parameters in interfacing to external functions (which are not permitted
3509 in Ada functions).  You may optionally use the @code{Mechanism}
3510 parameters to specify passing mechanisms for the parameters.
3511 If you specify a single mechanism name, it applies to all parameters.
3512 Otherwise you may specify a mechanism on a parameter by parameter
3513 basis using either positional or named notation.  If the mechanism is not
3514 specified, the default mechanism is used.
3515
3516 Note that it is important to use this pragma in conjunction with a separate
3517 pragma Import that specifies the desired convention, since otherwise the
3518 default convention is Ada, which is almost certainly not what is required.
3519
3520 @node Pragma Independent
3521 @unnumberedsec Pragma Independent
3522 @findex Independent
3523 @noindent
3524 Syntax:
3525
3526 @smallexample @c ada
3527 pragma Independent (Local_NAME);
3528 @end smallexample
3529
3530 @noindent
3531 This pragma is standard in Ada 2012 mode (which also provides an aspect
3532 of the same name). It is also available as an implementation-defined
3533 pragma in all earlier versions. It specifies that the
3534 designated object or all objects of the designated type must be
3535 independently addressable. This means that separate tasks can safely
3536 manipulate such objects. For example, if two components of a record are
3537 independent, then two separate tasks may access these two components.
3538 This may place
3539 constraints on the representation of the object (for instance prohibiting
3540 tight packing).
3541
3542 @node Pragma Independent_Components
3543 @unnumberedsec Pragma Independent_Components
3544 @findex Independent_Components
3545 @noindent
3546 Syntax:
3547
3548 @smallexample @c ada
3549 pragma Independent_Components (Local_NAME);
3550 @end smallexample
3551
3552 @noindent
3553 This pragma is standard in Ada 2012 mode (which also provides an aspect
3554 of the same name). It is also available as an implementation-defined
3555 pragma in all earlier versions. It specifies that the components of the
3556 designated object, or the components of each object of the designated
3557 type, must be
3558 independently addressable. This means that separate tasks can safely
3559 manipulate separate components in the composite object. This may place
3560 constraints on the representation of the object (for instance prohibiting
3561 tight packing).
3562
3563 @node Pragma Initialize_Scalars
3564 @unnumberedsec Pragma Initialize_Scalars
3565 @findex Initialize_Scalars
3566 @cindex debugging with Initialize_Scalars
3567 @noindent
3568 Syntax:
3569
3570 @smallexample @c ada
3571 pragma Initialize_Scalars;
3572 @end smallexample
3573
3574 @noindent
3575 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3576 two important differences.  First, there is no requirement for the pragma
3577 to be used uniformly in all units of a partition, in particular, it is fine
3578 to use this just for some or all of the application units of a partition,
3579 without needing to recompile the run-time library.
3580
3581 In the case where some units are compiled with the pragma, and some without,
3582 then a declaration of a variable where the type is defined in package
3583 Standard or is locally declared will always be subject to initialization,
3584 as will any declaration of a scalar variable.  For composite variables,
3585 whether the variable is initialized may also depend on whether the package
3586 in which the type of the variable is declared is compiled with the pragma.
3587
3588 The other important difference is that you can control the value used
3589 for initializing scalar objects.  At bind time, you can select several
3590 options for initialization. You can
3591 initialize with invalid values (similar to Normalize_Scalars, though for
3592 Initialize_Scalars it is not always possible to determine the invalid
3593 values in complex cases like signed component fields with non-standard
3594 sizes). You can also initialize with high or
3595 low values, or with a specified bit pattern.  See the @value{EDITION}
3596 User's Guide for binder options for specifying these cases.
3597
3598 This means that you can compile a program, and then without having to
3599 recompile the program, you can run it with different values being used
3600 for initializing otherwise uninitialized values, to test if your program
3601 behavior depends on the choice.  Of course the behavior should not change,
3602 and if it does, then most likely you have an erroneous reference to an
3603 uninitialized value.
3604
3605 It is even possible to change the value at execution time eliminating even
3606 the need to rebind with a different switch using an environment variable.
3607 See the @value{EDITION} User's Guide for details.
3608
3609 Note that pragma @code{Initialize_Scalars} is particularly useful in
3610 conjunction with the enhanced validity checking that is now provided
3611 in GNAT, which checks for invalid values under more conditions.
3612 Using this feature (see description of the @option{-gnatV} flag in the
3613 @value{EDITION} User's Guide) in conjunction with
3614 pragma @code{Initialize_Scalars}
3615 provides a powerful new tool to assist in the detection of problems
3616 caused by uninitialized variables.
3617
3618 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3619 effect on the generated code. This may cause your code to be
3620 substantially larger. It may also cause an increase in the amount
3621 of stack required, so it is probably a good idea to turn on stack
3622 checking (see description of stack checking in the @value{EDITION}
3623 User's Guide) when using this pragma.
3624
3625 @node Pragma Inline_Always
3626 @unnumberedsec Pragma Inline_Always
3627 @findex Inline_Always
3628 @noindent
3629 Syntax:
3630
3631 @smallexample @c ada
3632 pragma Inline_Always (NAME [, NAME]);
3633 @end smallexample
3634
3635 @noindent
3636 Similar to pragma @code{Inline} except that inlining is not subject to
3637 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3638 happens regardless of whether these options are used.
3639
3640 @node Pragma Inline_Generic
3641 @unnumberedsec Pragma Inline_Generic
3642 @findex Inline_Generic
3643 @noindent
3644 Syntax:
3645
3646 @smallexample @c ada
3647 pragma Inline_Generic (GNAME @{, GNAME@});
3648
3649 GNAME ::= generic_unit_NAME | generic_instance_NAME
3650 @end smallexample
3651
3652 @noindent
3653 This pragma is provided for compatibility with Dec Ada 83. It has
3654 no effect in @code{GNAT} (which always inlines generics), other
3655 than to check that the given names are all names of generic units or
3656 generic instances.
3657
3658 @node Pragma Interface
3659 @unnumberedsec Pragma Interface
3660 @findex Interface
3661 @noindent
3662 Syntax:
3663
3664 @smallexample @c ada
3665 pragma Interface (
3666      [Convention    =>] convention_identifier,
3667      [Entity        =>] local_NAME
3668   [, [External_Name =>] static_string_expression]
3669   [, [Link_Name     =>] static_string_expression]);
3670 @end smallexample
3671
3672 @noindent
3673 This pragma is identical in syntax and semantics to
3674 the standard Ada pragma @code{Import}.  It is provided for compatibility
3675 with Ada 83.  The definition is upwards compatible both with pragma
3676 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3677 with some extended implementations of this pragma in certain Ada 83
3678 implementations.  The only difference between pragma @code{Interface}
3679 and pragma @code{Import} is that there is special circuitry to allow
3680 both pragmas to appear for the same subprogram entity (normally it
3681 is illegal to have multiple @code{Import} pragmas. This is useful in
3682 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3683 Ada 83 compilers.
3684
3685 @node Pragma Interface_Name
3686 @unnumberedsec Pragma Interface_Name
3687 @findex Interface_Name
3688 @noindent
3689 Syntax:
3690
3691 @smallexample @c ada
3692 pragma Interface_Name (
3693      [Entity        =>] LOCAL_NAME
3694   [, [External_Name =>] static_string_EXPRESSION]
3695   [, [Link_Name     =>] static_string_EXPRESSION]);
3696 @end smallexample
3697
3698 @noindent
3699 This pragma provides an alternative way of specifying the interface name
3700 for an interfaced subprogram, and is provided for compatibility with Ada
3701 83 compilers that use the pragma for this purpose.  You must provide at
3702 least one of @var{External_Name} or @var{Link_Name}.
3703
3704 @node Pragma Interrupt_Handler
3705 @unnumberedsec Pragma Interrupt_Handler
3706 @findex Interrupt_Handler
3707 @noindent
3708 Syntax:
3709
3710 @smallexample @c ada
3711 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3712 @end smallexample
3713
3714 @noindent
3715 This program unit pragma is supported for parameterless protected procedures
3716 as described in Annex C of the Ada Reference Manual. On the AAMP target
3717 the pragma can also be specified for nonprotected parameterless procedures
3718 that are declared at the library level (which includes procedures
3719 declared at the top level of a library package). In the case of AAMP,
3720 when this pragma is applied to a nonprotected procedure, the instruction
3721 @code{IERET} is generated for returns from the procedure, enabling
3722 maskable interrupts, in place of the normal return instruction.
3723
3724 @node Pragma Interrupt_State
3725 @unnumberedsec Pragma Interrupt_State
3726 @findex Interrupt_State
3727 @noindent
3728 Syntax:
3729
3730 @smallexample @c ada
3731 pragma Interrupt_State
3732  ([Name  =>] value,
3733   [State =>] SYSTEM | RUNTIME | USER);
3734 @end smallexample
3735
3736 @noindent
3737 Normally certain interrupts are reserved to the implementation.  Any attempt
3738 to attach an interrupt causes Program_Error to be raised, as described in
3739 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3740 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3741 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3742 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3743 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3744 Ada exceptions, or used to implement run-time functions such as the
3745 @code{abort} statement and stack overflow checking.
3746
3747 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3748 such uses of interrupts.  It subsumes the functionality of pragma
3749 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3750 available on Windows or VMS.  On all other platforms than VxWorks,
3751 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3752 and may be used to mark interrupts required by the board support package
3753 as reserved.
3754
3755 Interrupts can be in one of three states:
3756 @itemize @bullet
3757 @item System
3758
3759 The interrupt is reserved (no Ada handler can be installed), and the
3760 Ada run-time may not install a handler. As a result you are guaranteed
3761 standard system default action if this interrupt is raised.
3762
3763 @item Runtime
3764
3765 The interrupt is reserved (no Ada handler can be installed). The run time
3766 is allowed to install a handler for internal control purposes, but is
3767 not required to do so.
3768
3769 @item User
3770
3771 The interrupt is unreserved.  The user may install a handler to provide
3772 some other action.
3773 @end itemize
3774
3775 @noindent
3776 These states are the allowed values of the @code{State} parameter of the
3777 pragma.  The @code{Name} parameter is a value of the type
3778 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3779 @code{Ada.Interrupts.Names}.
3780
3781 This is a configuration pragma, and the binder will check that there
3782 are no inconsistencies between different units in a partition in how a
3783 given interrupt is specified. It may appear anywhere a pragma is legal.
3784
3785 The effect is to move the interrupt to the specified state.
3786
3787 By declaring interrupts to be SYSTEM, you guarantee the standard system
3788 action, such as a core dump.
3789
3790 By declaring interrupts to be USER, you guarantee that you can install
3791 a handler.
3792
3793 Note that certain signals on many operating systems cannot be caught and
3794 handled by applications.  In such cases, the pragma is ignored.  See the
3795 operating system documentation, or the value of the array @code{Reserved}
3796 declared in the spec of package @code{System.OS_Interface}.
3797
3798 Overriding the default state of signals used by the Ada runtime may interfere
3799 with an application's runtime behavior in the cases of the synchronous signals,
3800 and in the case of the signal used to implement the @code{abort} statement.
3801
3802 @node Pragma Invariant
3803 @unnumberedsec Pragma Invariant
3804 @findex Invariant
3805 @noindent
3806 Syntax:
3807
3808 @smallexample @c ada
3809 pragma Invariant
3810   ([Entity =>]    private_type_LOCAL_NAME,
3811    [Check  =>]    EXPRESSION
3812    [,[Message =>] String_Expression]);
3813 @end smallexample
3814
3815 @noindent
3816 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3817 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3818 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3819 requires the use of the aspect syntax, which is not available except in 2012
3820 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3821 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3822 note that the aspect Invariant is a synonym in GNAT for the aspect
3823 Type_Invariant, but there is no pragma Type_Invariant.
3824
3825 The pragma must appear within the visible part of the package specification,
3826 after the type to which its Entity argument appears. As with the Invariant
3827 aspect, the Check expression is not analyzed until the end of the visible
3828 part of the package, so it may contain forward references. The Message
3829 argument, if present, provides the exception message used if the invariant
3830 is violated. If no Message parameter is provided, a default message that
3831 identifies the line on which the pragma appears is used.
3832
3833 It is permissible to have multiple Invariants for the same type entity, in
3834 which case they are and'ed together. It is permissible to use this pragma
3835 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3836 invariant pragma for the same entity.
3837
3838 For further details on the use of this pragma, see the Ada 2012 documentation
3839 of the Type_Invariant aspect.
3840
3841 @node Pragma Java_Constructor
3842 @unnumberedsec Pragma Java_Constructor
3843 @findex Java_Constructor
3844 @noindent
3845 Syntax:
3846
3847 @smallexample @c ada
3848 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
3849 @end smallexample
3850
3851 @noindent
3852 This pragma is used to assert that the specified Ada function should be
3853 mapped to the Java constructor for some Ada tagged record type.
3854
3855 See section 7.3.2 of the
3856 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3857 for related information.
3858
3859 @node Pragma Java_Interface
3860 @unnumberedsec Pragma Java_Interface
3861 @findex Java_Interface
3862 @noindent
3863 Syntax:
3864
3865 @smallexample @c ada
3866 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
3867 @end smallexample
3868
3869 @noindent
3870 This pragma is used to assert that the specified Ada abstract tagged type
3871 is to be mapped to a Java interface name.
3872
3873 See sections 7.1 and 7.2 of the
3874 @code{GNAT User's Guide: Supplement for the JVM Platform.}
3875 for related information.
3876
3877 @node Pragma Keep_Names
3878 @unnumberedsec Pragma Keep_Names
3879 @findex Keep_Names
3880 @noindent
3881 Syntax:
3882
3883 @smallexample @c ada
3884 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3885 @end smallexample
3886
3887 @noindent
3888 The @var{LOCAL_NAME} argument
3889 must refer to an enumeration first subtype
3890 in the current declarative part. The effect is to retain the enumeration
3891 literal names for use by @code{Image} and @code{Value} even if a global
3892 @code{Discard_Names} pragma applies. This is useful when you want to
3893 generally suppress enumeration literal names and for example you therefore
3894 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3895 want to retain the names for specific enumeration types.
3896
3897 @node Pragma License
3898 @unnumberedsec Pragma License
3899 @findex License
3900 @cindex License checking
3901 @noindent
3902 Syntax:
3903
3904 @smallexample @c ada
3905 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3906 @end smallexample
3907
3908 @noindent
3909 This pragma is provided to allow automated checking for appropriate license
3910 conditions with respect to the standard and modified GPL@.  A pragma
3911 @code{License}, which is a configuration pragma that typically appears at
3912 the start of a source file or in a separate @file{gnat.adc} file, specifies
3913 the licensing conditions of a unit as follows:
3914
3915 @itemize @bullet
3916 @item Unrestricted
3917 This is used for a unit that can be freely used with no license restrictions.
3918 Examples of such units are public domain units, and units from the Ada
3919 Reference Manual.
3920
3921 @item GPL
3922 This is used for a unit that is licensed under the unmodified GPL, and which
3923 therefore cannot be @code{with}'ed by a restricted unit.
3924
3925 @item Modified_GPL
3926 This is used for a unit licensed under the GNAT modified GPL that includes
3927 a special exception paragraph that specifically permits the inclusion of
3928 the unit in programs without requiring the entire program to be released
3929 under the GPL@.
3930
3931 @item Restricted
3932 This is used for a unit that is restricted in that it is not permitted to
3933 depend on units that are licensed under the GPL@.  Typical examples are
3934 proprietary code that is to be released under more restrictive license
3935 conditions.  Note that restricted units are permitted to @code{with} units
3936 which are licensed under the modified GPL (this is the whole point of the
3937 modified GPL).
3938
3939 @end itemize
3940
3941 @noindent
3942 Normally a unit with no @code{License} pragma is considered to have an
3943 unknown license, and no checking is done.  However, standard GNAT headers
3944 are recognized, and license information is derived from them as follows.
3945
3946 @itemize @bullet
3947
3948 A GNAT license header starts with a line containing 78 hyphens.  The following
3949 comment text is searched for the appearance of any of the following strings.
3950
3951 If the string ``GNU General Public License'' is found, then the unit is assumed
3952 to have GPL license, unless the string ``As a special exception'' follows, in
3953 which case the license is assumed to be modified GPL@.
3954
3955 If one of the strings
3956 ``This specification is adapted from the Ada Semantic Interface'' or
3957 ``This specification is derived from the Ada Reference Manual'' is found
3958 then the unit is assumed to be unrestricted.
3959 @end itemize
3960
3961 @noindent
3962 These default actions means that a program with a restricted license pragma
3963 will automatically get warnings if a GPL unit is inappropriately
3964 @code{with}'ed.  For example, the program:
3965
3966 @smallexample @c ada
3967 with Sem_Ch3;
3968 with GNAT.Sockets;
3969 procedure Secret_Stuff is
3970   @dots{}
3971 end Secret_Stuff
3972 @end smallexample
3973
3974 @noindent
3975 if compiled with pragma @code{License} (@code{Restricted}) in a
3976 @file{gnat.adc} file will generate the warning:
3977
3978 @smallexample
3979 1.  with Sem_Ch3;
3980         |
3981    >>> license of withed unit "Sem_Ch3" is incompatible
3982
3983 2.  with GNAT.Sockets;
3984 3.  procedure Secret_Stuff is
3985 @end smallexample
3986
3987 @noindent
3988 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3989 compiler and is licensed under the
3990 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3991 run time, and is therefore licensed under the modified GPL@.
3992
3993 @node Pragma Link_With
3994 @unnumberedsec Pragma Link_With
3995 @findex Link_With
3996 @noindent
3997 Syntax:
3998
3999 @smallexample @c ada
4000 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4001 @end smallexample
4002
4003 @noindent
4004 This pragma is provided for compatibility with certain Ada 83 compilers.
4005 It has exactly the same effect as pragma @code{Linker_Options} except
4006 that spaces occurring within one of the string expressions are treated
4007 as separators. For example, in the following case:
4008
4009 @smallexample @c ada
4010 pragma Link_With ("-labc -ldef");
4011 @end smallexample
4012
4013 @noindent
4014 results in passing the strings @code{-labc} and @code{-ldef} as two
4015 separate arguments to the linker. In addition pragma Link_With allows
4016 multiple arguments, with the same effect as successive pragmas.
4017
4018 @node Pragma Linker_Alias
4019 @unnumberedsec Pragma Linker_Alias
4020 @findex Linker_Alias
4021 @noindent
4022 Syntax:
4023
4024 @smallexample @c ada
4025 pragma Linker_Alias (
4026   [Entity =>] LOCAL_NAME,
4027   [Target =>] static_string_EXPRESSION);
4028 @end smallexample
4029
4030 @noindent
4031 @var{LOCAL_NAME} must refer to an object that is declared at the library
4032 level. This pragma establishes the given entity as a linker alias for the
4033 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4034 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4035 @var{static_string_EXPRESSION} in the object file, that is to say no space
4036 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4037 to the same address as @var{static_string_EXPRESSION} by the linker.
4038
4039 The actual linker name for the target must be used (e.g.@: the fully
4040 encoded name with qualification in Ada, or the mangled name in C++),
4041 or it must be declared using the C convention with @code{pragma Import}
4042 or @code{pragma Export}.
4043
4044 Not all target machines support this pragma. On some of them it is accepted
4045 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4046
4047 @smallexample @c ada
4048 --  Example of the use of pragma Linker_Alias
4049
4050 package p is
4051   i : Integer := 1;
4052   pragma Export (C, i);
4053
4054   new_name_for_i : Integer;
4055   pragma Linker_Alias (new_name_for_i, "i");
4056 end p;
4057 @end smallexample
4058
4059 @node Pragma Linker_Constructor
4060 @unnumberedsec Pragma Linker_Constructor
4061 @findex Linker_Constructor
4062 @noindent
4063 Syntax:
4064
4065 @smallexample @c ada
4066 pragma Linker_Constructor (procedure_LOCAL_NAME);
4067 @end smallexample
4068
4069 @noindent
4070 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4071 is declared at the library level. A procedure to which this pragma is
4072 applied will be treated as an initialization routine by the linker.
4073 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4074 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4075 of the executable is called (or immediately after the shared library is
4076 loaded if the procedure is linked in a shared library), in particular
4077 before the Ada run-time environment is set up.
4078
4079 Because of these specific contexts, the set of operations such a procedure
4080 can perform is very limited and the type of objects it can manipulate is
4081 essentially restricted to the elementary types. In particular, it must only
4082 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4083
4084 This pragma is used by GNAT to implement auto-initialization of shared Stand
4085 Alone Libraries, which provides a related capability without the restrictions
4086 listed above. Where possible, the use of Stand Alone Libraries is preferable
4087 to the use of this pragma.
4088
4089 @node Pragma Linker_Destructor
4090 @unnumberedsec Pragma Linker_Destructor
4091 @findex Linker_Destructor
4092 @noindent
4093 Syntax:
4094
4095 @smallexample @c ada
4096 pragma Linker_Destructor (procedure_LOCAL_NAME);
4097 @end smallexample
4098
4099 @noindent
4100 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4101 is declared at the library level. A procedure to which this pragma is
4102 applied will be treated as a finalization routine by the linker.
4103 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4104 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4105 of the executable has exited (or immediately before the shared library
4106 is unloaded if the procedure is linked in a shared library), in particular
4107 after the Ada run-time environment is shut down.
4108
4109 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4110 because of these specific contexts.
4111
4112 @node Pragma Linker_Section
4113 @unnumberedsec Pragma Linker_Section
4114 @findex Linker_Section
4115 @noindent
4116 Syntax:
4117
4118 @smallexample @c ada
4119 pragma Linker_Section (
4120   [Entity  =>] LOCAL_NAME,
4121   [Section =>] static_string_EXPRESSION);
4122 @end smallexample
4123
4124 @noindent
4125 @var{LOCAL_NAME} must refer to an object that is declared at the library
4126 level. This pragma specifies the name of the linker section for the given
4127 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
4128 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
4129 section of the executable (assuming the linker doesn't rename the section).
4130
4131 The compiler normally places library-level objects in standard sections
4132 depending on their type: procedures and functions generally go in the
4133 @code{.text} section, initialized variables in the @code{.data} section
4134 and uninitialized variables in the @code{.bss} section.
4135
4136 Other, special sections may exist on given target machines to map special
4137 hardware, for example I/O ports or flash memory. This pragma is a means to
4138 defer the final layout of the executable to the linker, thus fully working
4139 at the symbolic level with the compiler.
4140
4141 Some file formats do not support arbitrary sections so not all target
4142 machines support this pragma. The use of this pragma may cause a program
4143 execution to be erroneous if it is used to place an entity into an
4144 inappropriate section (e.g.@: a modified variable into the @code{.text}
4145 section). See also @code{pragma Persistent_BSS}.
4146
4147 @smallexample @c ada
4148 --  Example of the use of pragma Linker_Section
4149
4150 package IO_Card is
4151   Port_A : Integer;
4152   pragma Volatile (Port_A);
4153   pragma Linker_Section (Port_A, ".bss.port_a");
4154
4155   Port_B : Integer;
4156   pragma Volatile (Port_B);
4157   pragma Linker_Section (Port_B, ".bss.port_b");
4158 end IO_Card;
4159 @end smallexample
4160
4161 @node Pragma Long_Float
4162 @unnumberedsec Pragma Long_Float
4163 @cindex OpenVMS
4164 @findex Long_Float
4165 @noindent
4166 Syntax:
4167
4168 @smallexample @c ada
4169 pragma Long_Float (FLOAT_FORMAT);
4170
4171 FLOAT_FORMAT ::= D_Float | G_Float
4172 @end smallexample
4173
4174 @noindent
4175 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4176 It allows control over the internal representation chosen for the predefined
4177 type @code{Long_Float} and for floating point type representations with
4178 @code{digits} specified in the range 7 through 15.
4179 For further details on this pragma, see the
4180 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4181 this pragma, the standard runtime libraries must be recompiled.
4182
4183 @node Pragma Loop_Invariant
4184 @unnumberedsec Pragma Loop_Invariant
4185 @findex Loop_Invariant
4186 @noindent
4187 Syntax:
4188
4189 @smallexample @c ada
4190 pragma Loop_Invariant ( boolean_EXPRESSION );
4191 @end smallexample
4192
4193 @noindent
4194 The effect of this pragma is similar to that of pragma @code{Assert},
4195 except that in an @code{Assertion_Policy} pragma, the identifier
4196 @code{Loop_Invariant} is used to control whether it is ignored or checked
4197 (or disabled).
4198
4199 @code{Loop_Invariant} can only appear as one of the items in the sequence
4200 of statements of a loop body. The intention is that it be used to
4201 represent a "loop invariant" assertion, i.e. something that is true each
4202 time through the loop, and which can be used to show that the loop is
4203 achieving its purpose.
4204
4205 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4206 may be used to refer to the value of an expression on entry to the loop. This
4207 attribute can only be used within the expression of a @code{Loop_Invariant}
4208 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4209
4210 @node Pragma Loop_Optimize
4211 @unnumberedsec Pragma Loop_Optimize
4212 @findex Loop_Optimize
4213 @noindent
4214 Syntax:
4215
4216 @smallexample @c ada
4217 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4218
4219 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
4220 @end smallexample
4221
4222 @noindent
4223 This pragma must appear immediately within a loop statement.  It allows the
4224 programmer to specify optimization hints for the enclosing loop.  The hints
4225 are not mutually exclusive and can be freely mixed, but not all combinations
4226 will yield a sensible outcome.
4227
4228 There are four supported optimization hints for a loop:
4229 @itemize @bullet
4230 @item No_Unroll
4231
4232 The loop must not be unrolled.  This is a strong hint: the compiler will not
4233 unroll a loop marked with this hint.
4234
4235 @item Unroll
4236
4237 The loop should be unrolled.  This is a weak hint: the compiler will try to
4238 apply unrolling to this loop preferably to other optimizations, notably
4239 vectorization, but there is no guarantee that the loop will be unrolled.
4240
4241 @item No_Vector
4242
4243 The loop must not be vectorized.  This is a strong hint: the compiler will not
4244 vectorize a loop marked with this hint.
4245
4246 @item Vector
4247
4248 The loop should be vectorized.  This is a weak hint: the compiler will try to
4249 apply vectorization to this loop preferably to other optimizations, notably
4250 unrolling, but there is no guarantee that the loop will be vectorized.
4251
4252 @end itemize
4253
4254 These hints do not void the need to pass the appropriate switches to the
4255 compiler in order to enable the relevant optimizations, that is to say
4256 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4257 vectorization.
4258
4259 @node Pragma Loop_Variant
4260 @unnumberedsec Pragma Loop_Variant
4261 @findex Loop_Variant
4262 @noindent
4263 Syntax:
4264
4265 @smallexample @c ada
4266 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4267 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4268 CHANGE_DIRECTION ::= Increases | Decreases
4269 @end smallexample
4270
4271 @noindent
4272 This pragma must appear immediately within the sequence of statements of a
4273 loop statement. It allows the specification of quantities which must always
4274 decrease or increase in successive iterations of the loop. In its simplest
4275 form, just one expression is specified, whose value must increase or decrease
4276 on each iteration of the loop.
4277
4278 In a more complex form, multiple arguments can be given which are intepreted
4279 in a nesting lexicographic manner. For example:
4280
4281 @smallexample @c ada
4282 pragma Loop_Variant (Increases => X, Decreases => Y);
4283 @end smallexample
4284
4285 @noindent
4286 specifies that each time through the loop either X increases, or X stays
4287 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4288 loop is making progress. It can be useful in helping to show informally
4289 or prove formally that the loop always terminates.
4290
4291 @code{Loop_Variant} is an assertion whose effect can be controlled using
4292 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4293 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4294 to ignore the check (in which case the pragma has no effect on the program),
4295 or @code{Disable} in which case the pragma is not even checked for correct
4296 syntax.
4297
4298 The @code{Loop_Entry} attribute may be used within the expressions of the
4299 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4300
4301 @node Pragma Machine_Attribute
4302 @unnumberedsec Pragma Machine_Attribute
4303 @findex Machine_Attribute
4304 @noindent
4305 Syntax:
4306
4307 @smallexample @c ada
4308 pragma Machine_Attribute (
4309      [Entity         =>] LOCAL_NAME,
4310      [Attribute_Name =>] static_string_EXPRESSION
4311   [, [Info           =>] static_EXPRESSION] );
4312 @end smallexample
4313
4314 @noindent
4315 Machine-dependent attributes can be specified for types and/or
4316 declarations.  This pragma is semantically equivalent to
4317 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4318 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4319 in GNU C, where @code{@var{attribute_name}} is recognized by the
4320 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4321 specific macro.  A string literal for the optional parameter @var{info}
4322 is transformed into an identifier, which may make this pragma unusable
4323 for some attributes.  @xref{Target Attributes,, Defining target-specific
4324 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4325 Internals}, further information.
4326
4327 @node Pragma Main
4328 @unnumberedsec Pragma Main
4329 @cindex OpenVMS
4330 @findex Main
4331 @noindent
4332 Syntax:
4333
4334 @smallexample @c ada
4335 pragma Main
4336  (MAIN_OPTION [, MAIN_OPTION]);
4337
4338 MAIN_OPTION ::=
4339   [Stack_Size              =>] static_integer_EXPRESSION
4340 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4341 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4342 @end smallexample
4343
4344 @noindent
4345 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4346 no effect in GNAT, other than being syntax checked.
4347
4348 @node Pragma Main_Storage
4349 @unnumberedsec Pragma Main_Storage
4350 @cindex OpenVMS
4351 @findex Main_Storage
4352 @noindent
4353 Syntax:
4354
4355 @smallexample @c ada
4356 pragma Main_Storage
4357   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4358
4359 MAIN_STORAGE_OPTION ::=
4360   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4361 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4362 @end smallexample
4363
4364 @noindent
4365 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4366 no effect in GNAT, other than being syntax checked.  Note that the pragma
4367 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4368
4369 @node Pragma No_Body
4370 @unnumberedsec Pragma No_Body
4371 @findex No_Body
4372 @noindent
4373 Syntax:
4374
4375 @smallexample @c ada
4376 pragma No_Body;
4377 @end smallexample
4378
4379 @noindent
4380 There are a number of cases in which a package spec does not require a body,
4381 and in fact a body is not permitted. GNAT will not permit the spec to be
4382 compiled if there is a body around. The pragma No_Body allows you to provide
4383 a body file, even in a case where no body is allowed. The body file must
4384 contain only comments and a single No_Body pragma. This is recognized by
4385 the compiler as indicating that no body is logically present.
4386
4387 This is particularly useful during maintenance when a package is modified in
4388 such a way that a body needed before is no longer needed. The provision of a
4389 dummy body with a No_Body pragma ensures that there is no interference from
4390 earlier versions of the package body.
4391
4392 @node Pragma No_Inline
4393 @unnumberedsec Pragma No_Inline
4394 @findex No_Inline
4395 @noindent
4396 Syntax:
4397
4398 @smallexample @c ada
4399 pragma No_Inline (NAME @{, NAME@});
4400 @end smallexample
4401
4402 @noindent
4403 This pragma suppresses inlining for the callable entity or the instances of
4404 the generic subprogram designated by @var{NAME}, including inlining that
4405 results from the use of pragma @code{Inline}.  This pragma is always active,
4406 in particular it is not subject to the use of option @option{-gnatn} or
4407 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4408 pragma @code{Inline_Always} for the same @var{NAME}.
4409
4410 @node Pragma No_Return
4411 @unnumberedsec Pragma No_Return
4412 @findex No_Return
4413 @noindent
4414 Syntax:
4415
4416 @smallexample @c ada
4417 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4418 @end smallexample
4419
4420 @noindent
4421 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4422 declarations in the current declarative part.  A procedure to which this
4423 pragma is applied may not contain any explicit @code{return} statements.
4424 In addition, if the procedure contains any implicit returns from falling
4425 off the end of a statement sequence, then execution of that implicit
4426 return will cause Program_Error to be raised.
4427
4428 One use of this pragma is to identify procedures whose only purpose is to raise
4429 an exception. Another use of this pragma is to suppress incorrect warnings
4430 about missing returns in functions, where the last statement of a function
4431 statement sequence is a call to such a procedure.
4432
4433 Note that in Ada 2005 mode, this pragma is part of the language. It is
4434 available in all earlier versions of Ada as an implementation-defined
4435 pragma.
4436
4437 @node Pragma No_Run_Time
4438 @unnumberedsec Pragma No_Run_Time
4439 @findex No_Run_Time
4440 @noindent
4441 Syntax:
4442
4443 @smallexample @c ada
4444 pragma No_Run_Time;
4445 @end smallexample
4446
4447 @noindent
4448 This is an obsolete configuration pragma that historically was used to
4449 setup what is now called the "zero footprint" library. It causes any
4450 library units outside this basic library to be ignored. The use of
4451 this pragma has been superseded by the general configurable run-time
4452 capability of @code{GNAT} where the compiler takes into account whatever
4453 units happen to be accessible in the library.
4454
4455 @node Pragma No_Strict_Aliasing
4456 @unnumberedsec Pragma No_Strict_Aliasing
4457 @findex No_Strict_Aliasing
4458 @noindent
4459 Syntax:
4460
4461 @smallexample @c ada
4462 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4463 @end smallexample
4464
4465 @noindent
4466 @var{type_LOCAL_NAME} must refer to an access type
4467 declaration in the current declarative part.  The effect is to inhibit
4468 strict aliasing optimization for the given type.  The form with no
4469 arguments is a configuration pragma which applies to all access types
4470 declared in units to which the pragma applies. For a detailed
4471 description of the strict aliasing optimization, and the situations
4472 in which it must be suppressed, see @ref{Optimization and Strict
4473 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4474
4475 This pragma currently has no effects on access to unconstrained array types.
4476
4477 @node Pragma Normalize_Scalars
4478 @unnumberedsec Pragma Normalize_Scalars
4479 @findex Normalize_Scalars
4480 @noindent
4481 Syntax:
4482
4483 @smallexample @c ada
4484 pragma Normalize_Scalars;
4485 @end smallexample
4486
4487 @noindent
4488 This is a language defined pragma which is fully implemented in GNAT@.  The
4489 effect is to cause all scalar objects that are not otherwise initialized
4490 to be initialized.  The initial values are implementation dependent and
4491 are as follows:
4492
4493 @table @code
4494 @item Standard.Character
4495 @noindent
4496 Objects whose root type is Standard.Character are initialized to
4497 Character'Last unless the subtype range excludes NUL (in which case
4498 NUL is used). This choice will always generate an invalid value if
4499 one exists.
4500
4501 @item Standard.Wide_Character
4502 @noindent
4503 Objects whose root type is Standard.Wide_Character are initialized to
4504 Wide_Character'Last unless the subtype range excludes NUL (in which case
4505 NUL is used). This choice will always generate an invalid value if
4506 one exists.
4507
4508 @item Standard.Wide_Wide_Character
4509 @noindent
4510 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4511 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4512 which case NUL is used). This choice will always generate an invalid value if
4513 one exists.
4514
4515 @item Integer types
4516 @noindent
4517 Objects of an integer type are treated differently depending on whether
4518 negative values are present in the subtype. If no negative values are
4519 present, then all one bits is used as the initial value except in the
4520 special case where zero is excluded from the subtype, in which case
4521 all zero bits are used. This choice will always generate an invalid
4522 value if one exists.
4523
4524 For subtypes with negative values present, the largest negative number
4525 is used, except in the unusual case where this largest negative number
4526 is in the subtype, and the largest positive number is not, in which case
4527 the largest positive value is used. This choice will always generate
4528 an invalid value if one exists.
4529
4530 @item Floating-Point Types
4531 Objects of all floating-point types are initialized to all 1-bits. For
4532 standard IEEE format, this corresponds to a NaN (not a number) which is
4533 indeed an invalid value.
4534
4535 @item Fixed-Point Types
4536 Objects of all fixed-point types are treated as described above for integers,
4537 with the rules applying to the underlying integer value used to represent
4538 the fixed-point value.
4539
4540 @item Modular types
4541 Objects of a modular type are initialized to all one bits, except in
4542 the special case where zero is excluded from the subtype, in which
4543 case all zero bits are used. This choice will always generate an
4544 invalid value if one exists.
4545
4546 @item Enumeration types
4547 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4548 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4549 whose Pos value is zero, in which case a code of zero is used. This choice
4550 will always generate an invalid value if one exists.
4551
4552 @end table
4553
4554 @node Pragma Obsolescent
4555 @unnumberedsec Pragma Obsolescent
4556 @findex Obsolescent
4557 @noindent
4558 Syntax:
4559
4560 @smallexample @c ada
4561 pragma Obsolescent;
4562
4563 pragma Obsolescent (
4564   [Message =>] static_string_EXPRESSION
4565 [,[Version =>] Ada_05]]);
4566
4567 pragma Obsolescent (
4568   [Entity  =>] NAME
4569 [,[Message =>] static_string_EXPRESSION
4570 [,[Version =>] Ada_05]] );
4571 @end smallexample
4572
4573 @noindent
4574 This pragma can occur immediately following a declaration of an entity,
4575 including the case of a record component. If no Entity argument is present,
4576 then this declaration is the one to which the pragma applies. If an Entity
4577 parameter is present, it must either match the name of the entity in this
4578 declaration, or alternatively, the pragma can immediately follow an enumeration
4579 type declaration, where the Entity argument names one of the enumeration
4580 literals.
4581
4582 This pragma is used to indicate that the named entity
4583 is considered obsolescent and should not be used. Typically this is
4584 used when an API must be modified by eventually removing or modifying
4585 existing subprograms or other entities. The pragma can be used at an
4586 intermediate stage when the entity is still present, but will be
4587 removed later.
4588
4589 The effect of this pragma is to output a warning message on a reference to
4590 an entity thus marked that the subprogram is obsolescent if the appropriate
4591 warning option in the compiler is activated. If the Message parameter is
4592 present, then a second warning message is given containing this text. In
4593 addition, a reference to the entity is considered to be a violation of pragma
4594 Restrictions (No_Obsolescent_Features).
4595
4596 This pragma can also be used as a program unit pragma for a package,
4597 in which case the entity name is the name of the package, and the
4598 pragma indicates that the entire package is considered
4599 obsolescent. In this case a client @code{with}'ing such a package
4600 violates the restriction, and the @code{with} statement is
4601 flagged with warnings if the warning option is set.
4602
4603 If the Version parameter is present (which must be exactly
4604 the identifier Ada_05, no other argument is allowed), then the
4605 indication of obsolescence applies only when compiling in Ada 2005
4606 mode. This is primarily intended for dealing with the situations
4607 in the predefined library where subprograms or packages
4608 have become defined as obsolescent in Ada 2005
4609 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4610
4611 The following examples show typical uses of this pragma:
4612
4613 @smallexample @c ada
4614 package p is
4615    pragma Obsolescent (p, Message => "use pp instead of p");
4616 end p;
4617
4618 package q is
4619    procedure q2;
4620    pragma Obsolescent ("use q2new instead");
4621
4622    type R is new integer;
4623    pragma Obsolescent
4624      (Entity  => R,
4625       Message => "use RR in Ada 2005",
4626       Version => Ada_05);
4627
4628    type M is record
4629       F1 : Integer;
4630       F2 : Integer;
4631       pragma Obsolescent;
4632       F3 : Integer;
4633    end record;
4634
4635    type E is (a, bc, 'd', quack);
4636    pragma Obsolescent (Entity => bc)
4637    pragma Obsolescent (Entity => 'd')
4638
4639    function "+"
4640      (a, b : character) return character;
4641    pragma Obsolescent (Entity => "+");
4642 end;
4643 @end smallexample
4644
4645 @noindent
4646 Note that, as for all pragmas, if you use a pragma argument identifier,
4647 then all subsequent parameters must also use a pragma argument identifier.
4648 So if you specify "Entity =>" for the Entity argument, and a Message
4649 argument is present, it must be preceded by "Message =>".
4650
4651 @node Pragma Optimize_Alignment
4652 @unnumberedsec Pragma Optimize_Alignment
4653 @findex Optimize_Alignment
4654 @cindex Alignment, default settings
4655 @noindent
4656 Syntax:
4657
4658 @smallexample @c ada
4659 pragma Optimize_Alignment (TIME | SPACE | OFF);
4660 @end smallexample
4661
4662 @noindent
4663 This is a configuration pragma which affects the choice of default alignments
4664 for types where no alignment is explicitly specified. There is a time/space
4665 trade-off in the selection of these values. Large alignments result in more
4666 efficient code, at the expense of larger data space, since sizes have to be
4667 increased to match these alignments. Smaller alignments save space, but the
4668 access code is slower. The normal choice of default alignments (which is what
4669 you get if you do not use this pragma, or if you use an argument of OFF),
4670 tries to balance these two requirements.
4671
4672 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4673 First any packed record is given an alignment of 1. Second, if a size is given
4674 for the type, then the alignment is chosen to avoid increasing this size. For
4675 example, consider:
4676
4677 @smallexample @c ada
4678    type R is record
4679       X : Integer;
4680       Y : Character;
4681    end record;
4682
4683    for R'Size use 5*8;
4684 @end smallexample
4685
4686 @noindent
4687 In the default mode, this type gets an alignment of 4, so that access to the
4688 Integer field X are efficient. But this means that objects of the type end up
4689 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4690 allowed to be bigger than the size of the type, but it can waste space if for
4691 example fields of type R appear in an enclosing record. If the above type is
4692 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4693
4694 However, there is one case in which SPACE is ignored. If a variable length
4695 record (that is a discriminated record with a component which is an array
4696 whose length depends on a discriminant), has a pragma Pack, then it is not
4697 in general possible to set the alignment of such a record to one, so the
4698 pragma is ignored in this case (with a warning).
4699
4700 Specifying TIME causes larger default alignments to be chosen in the case of
4701 small types with sizes that are not a power of 2. For example, consider:
4702
4703 @smallexample @c ada
4704    type R is record
4705       A : Character;
4706       B : Character;
4707       C : Boolean;
4708    end record;
4709
4710    pragma Pack (R);
4711    for R'Size use 17;
4712 @end smallexample
4713
4714 @noindent
4715 The default alignment for this record is normally 1, but if this type is
4716 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4717 to 4, which wastes space for objects of the type, since they are now 4 bytes
4718 long, but results in more efficient access when the whole record is referenced.
4719
4720 As noted above, this is a configuration pragma, and there is a requirement
4721 that all units in a partition be compiled with a consistent setting of the
4722 optimization setting. This would normally be achieved by use of a configuration
4723 pragma file containing the appropriate setting. The exception to this rule is
4724 that units with an explicit configuration pragma in the same file as the source
4725 unit are excluded from the consistency check, as are all predefined units. The
4726 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4727 pragma appears at the start of the file.
4728
4729 @node Pragma Ordered
4730 @unnumberedsec Pragma Ordered
4731 @findex Ordered
4732 @findex pragma @code{Ordered}
4733 @noindent
4734 Syntax:
4735
4736 @smallexample @c ada
4737 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4738 @end smallexample
4739
4740 @noindent
4741 Most enumeration types are from a conceptual point of view unordered.
4742 For example, consider:
4743
4744 @smallexample @c ada
4745 type Color is (Red, Blue, Green, Yellow);
4746 @end smallexample
4747
4748 @noindent
4749 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4750 but really these relations make no sense; the enumeration type merely
4751 specifies a set of possible colors, and the order is unimportant.
4752
4753 For unordered enumeration types, it is generally a good idea if
4754 clients avoid comparisons (other than equality or inequality) and
4755 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4756 other than the unit where the type is declared, its body, and its subunits.)
4757 For example, if code buried in some client says:
4758
4759 @smallexample @c ada
4760 if Current_Color < Yellow then ...
4761 if Current_Color in Blue .. Green then ...
4762 @end smallexample
4763
4764 @noindent
4765 then the client code is relying on the order, which is undesirable.
4766 It makes the code hard to read and creates maintenance difficulties if
4767 entries have to be added to the enumeration type. Instead,
4768 the code in the client should list the possibilities, or an
4769 appropriate subtype should be declared in the unit that declares
4770 the original enumeration type. E.g., the following subtype could
4771 be declared along with the type @code{Color}:
4772
4773 @smallexample @c ada
4774 subtype RBG is Color range Red .. Green;
4775 @end smallexample
4776
4777 @noindent
4778 and then the client could write:
4779
4780 @smallexample @c ada
4781 if Current_Color in RBG then ...
4782 if Current_Color = Blue or Current_Color = Green then ...
4783 @end smallexample
4784
4785 @noindent
4786 However, some enumeration types are legitimately ordered from a conceptual
4787 point of view. For example, if you declare:
4788
4789 @smallexample @c ada
4790 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4791 @end smallexample
4792
4793 @noindent
4794 then the ordering imposed by the language is reasonable, and
4795 clients can depend on it, writing for example:
4796
4797 @smallexample @c ada
4798 if D in Mon .. Fri then ...
4799 if D < Wed then ...
4800 @end smallexample
4801
4802 @noindent
4803 The pragma @option{Ordered} is provided to mark enumeration types that
4804 are conceptually ordered, alerting the reader that clients may depend
4805 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4806 rather than one to mark them as unordered, since in our experience,
4807 the great majority of enumeration types are conceptually unordered.
4808
4809 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4810 and @code{Wide_Wide_Character}
4811 are considered to be ordered types, so each is declared with a
4812 pragma @code{Ordered} in package @code{Standard}.
4813
4814 Normally pragma @code{Ordered} serves only as documentation and a guide for
4815 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4816 requests warnings for inappropriate uses (comparisons and explicit
4817 subranges) for unordered types. If this switch is used, then any
4818 enumeration type not marked with pragma @code{Ordered} will be considered
4819 as unordered, and will generate warnings for inappropriate uses.
4820
4821 For additional information please refer to the description of the
4822 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4823
4824 @node Pragma Overflow_Mode
4825 @unnumberedsec Pragma Overflow_Mode
4826 @findex Overflow checks
4827 @findex Overflow mode
4828 @findex pragma @code{Overflow_Mode}
4829 @noindent
4830 Syntax:
4831
4832 @smallexample @c ada
4833 pragma Overflow_Mode
4834  (  [General    =>] MODE
4835   [,[Assertions =>] MODE]);
4836
4837 MODE ::= STRICT | MINIMIZED | ELIMINATED
4838 @end smallexample
4839
4840 @noindent
4841 This pragma sets the current overflow mode to the given setting. For details
4842 of the meaning of these modes, please refer to the
4843 ``Overflow Check Handling in GNAT'' appendix in the
4844 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4845 the given mode applies to all expressions. If both parameters are present,
4846 the @code{General} mode applies to expressions outside assertions, and
4847 the @code{Eliminated} mode applies to expressions within assertions.
4848
4849 The case of the @code{MODE} parameter is ignored,
4850 so @code{MINIMIZED}, @code{Minimized} and
4851 @code{minimized} all have the same effect.
4852
4853 The @code{Overflow_Mode} pragma has the same scoping and placement
4854 rules as pragma @code{Suppress}, so it can occur either as a
4855 configuration pragma, specifying a default for the whole
4856 program, or in a declarative scope, where it applies to the
4857 remaining declarations and statements in that scope.
4858
4859 The pragma @code{Suppress (Overflow_Check)} suppresses
4860 overflow checking, but does not affect the overflow mode.
4861
4862 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4863 overflow checking, but does not affect the overflow mode.
4864
4865 @node Pragma Overriding_Renamings
4866 @unnumberedsec Pragma Overriding_Renamings
4867 @findex Overriding_Renamings
4868 @cindex Rational profile
4869 @cindex Rational compatibility
4870 @noindent
4871 Syntax:
4872
4873 @smallexample @c ada
4874 pragma Overriding_Renamings;
4875 @end smallexample
4876
4877 @noindent
4878 This is a GNAT configuration pragma to simplify porting
4879 legacy code accepted by the Rational
4880 Ada compiler. In the presence of this pragma, a renaming declaration that
4881 renames an inherited operation declared in the same scope is legal if selected
4882 notation is used as in:
4883
4884 @smallexample @c ada
4885 pragma Overriding_Renamings;
4886 ...
4887 package R is
4888   function F (..);
4889   ...
4890   function F (..) renames R.F;
4891 end R;
4892 @end smallexample
4893
4894 even though
4895 RM 8.3 (15) stipulates that an overridden operation is not visible within the
4896 declaration of the overriding operation.
4897
4898 @node Pragma Partition_Elaboration_Policy
4899 @unnumberedsec Pragma Partition_Elaboration_Policy
4900 @findex Partition_Elaboration_Policy
4901 @noindent
4902 Syntax:
4903
4904 @smallexample @c ada
4905 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4906
4907 POLICY_IDENTIFIER ::= Concurrent | Sequential
4908 @end smallexample
4909
4910 @noindent
4911 This pragma is standard in Ada 2005, but is available in all earlier
4912 versions of Ada as an implementation-defined pragma.
4913 See Ada 2012 Reference Manual for details.
4914
4915 @node Pragma Passive
4916 @unnumberedsec Pragma Passive
4917 @findex Passive
4918 @noindent
4919 Syntax:
4920
4921 @smallexample @c ada
4922 pragma Passive [(Semaphore | No)];
4923 @end smallexample
4924
4925 @noindent
4926 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
4927 compatibility with DEC Ada 83 implementations, where it is used within a
4928 task definition to request that a task be made passive.  If the argument
4929 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4930 treats the pragma as an assertion that the containing task is passive
4931 and that optimization of context switch with this task is permitted and
4932 desired.  If the argument @code{No} is present, the task must not be
4933 optimized.  GNAT does not attempt to optimize any tasks in this manner
4934 (since protected objects are available in place of passive tasks).
4935
4936 @node Pragma Persistent_BSS
4937 @unnumberedsec Pragma Persistent_BSS
4938 @findex Persistent_BSS
4939 @noindent
4940 Syntax:
4941
4942 @smallexample @c ada
4943 pragma Persistent_BSS [(LOCAL_NAME)]
4944 @end smallexample
4945
4946 @noindent
4947 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4948 section. On some targets the linker and loader provide for special
4949 treatment of this section, allowing a program to be reloaded without
4950 affecting the contents of this data (hence the name persistent).
4951
4952 There are two forms of usage. If an argument is given, it must be the
4953 local name of a library level object, with no explicit initialization
4954 and whose type is potentially persistent. If no argument is given, then
4955 the pragma is a configuration pragma, and applies to all library level
4956 objects with no explicit initialization of potentially persistent types.
4957
4958 A potentially persistent type is a scalar type, or a non-tagged,
4959 non-discriminated record, all of whose components have no explicit
4960 initialization and are themselves of a potentially persistent type,
4961 or an array, all of whose constraints are static, and whose component
4962 type is potentially persistent.
4963
4964 If this pragma is used on a target where this feature is not supported,
4965 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4966
4967 @node Pragma Polling
4968 @unnumberedsec Pragma Polling
4969 @findex Polling
4970 @noindent
4971 Syntax:
4972
4973 @smallexample @c ada
4974 pragma Polling (ON | OFF);
4975 @end smallexample
4976
4977 @noindent
4978 This pragma controls the generation of polling code.  This is normally off.
4979 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4980 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
4981 runtime library, and can be found in file @file{a-excpol.adb}.
4982
4983 Pragma @code{Polling} can appear as a configuration pragma (for example it
4984 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4985 can be used in the statement or declaration sequence to control polling
4986 more locally.
4987
4988 A call to the polling routine is generated at the start of every loop and
4989 at the start of every subprogram call.  This guarantees that the @code{Poll}
4990 routine is called frequently, and places an upper bound (determined by
4991 the complexity of the code) on the period between two @code{Poll} calls.
4992
4993 The primary purpose of the polling interface is to enable asynchronous
4994 aborts on targets that cannot otherwise support it (for example Windows
4995 NT), but it may be used for any other purpose requiring periodic polling.
4996 The standard version is null, and can be replaced by a user program.  This
4997 will require re-compilation of the @code{Ada.Exceptions} package that can
4998 be found in files @file{a-except.ads} and @file{a-except.adb}.
4999
5000 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5001 distribution) is used to enable the asynchronous abort capability on
5002 targets that do not normally support the capability.  The version of
5003 @code{Poll} in this file makes a call to the appropriate runtime routine
5004 to test for an abort condition.
5005
5006 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5007 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5008 details.
5009
5010 @node Pragma Postcondition
5011 @unnumberedsec Pragma Postcondition
5012 @cindex Postcondition
5013 @cindex Checks, postconditions
5014 @findex Postconditions
5015 @noindent
5016 Syntax:
5017
5018 @smallexample @c ada
5019 pragma Postcondition (
5020    [Check   =>] Boolean_Expression
5021  [,[Message =>] String_Expression]);
5022 @end smallexample
5023
5024 @noindent
5025 The @code{Postcondition} pragma allows specification of automatic
5026 postcondition checks for subprograms. These checks are similar to
5027 assertions, but are automatically inserted just prior to the return
5028 statements of the subprogram with which they are associated (including
5029 implicit returns at the end of procedure bodies and associated
5030 exception handlers).
5031
5032 In addition, the boolean expression which is the condition which
5033 must be true may contain references to function'Result in the case
5034 of a function to refer to the returned value.
5035
5036 @code{Postcondition} pragmas may appear either immediately following the
5037 (separate) declaration of a subprogram, or at the start of the
5038 declarations of a subprogram body. Only other pragmas may intervene
5039 (that is appear between the subprogram declaration and its
5040 postconditions, or appear before the postcondition in the
5041 declaration sequence in a subprogram body). In the case of a
5042 postcondition appearing after a subprogram declaration, the
5043 formal arguments of the subprogram are visible, and can be
5044 referenced in the postcondition expressions.
5045
5046 The postconditions are collected and automatically tested just
5047 before any return (implicit or explicit) in the subprogram body.
5048 A postcondition is only recognized if postconditions are active
5049 at the time the pragma is encountered. The compiler switch @option{gnata}
5050 turns on all postconditions by default, and pragma @code{Check_Policy}
5051 with an identifier of @code{Postcondition} can also be used to
5052 control whether postconditions are active.
5053
5054 The general approach is that postconditions are placed in the spec
5055 if they represent functional aspects which make sense to the client.
5056 For example we might have:
5057
5058 @smallexample @c ada
5059    function Direction return Integer;
5060    pragma Postcondition
5061     (Direction'Result = +1
5062        or else
5063      Direction'Result = -1);
5064 @end smallexample
5065
5066 @noindent
5067 which serves to document that the result must be +1 or -1, and
5068 will test that this is the case at run time if postcondition
5069 checking is active.
5070
5071 Postconditions within the subprogram body can be used to
5072 check that some internal aspect of the implementation,
5073 not visible to the client, is operating as expected.
5074 For instance if a square root routine keeps an internal
5075 counter of the number of times it is called, then we
5076 might have the following postcondition:
5077
5078 @smallexample @c ada
5079    Sqrt_Calls : Natural := 0;
5080
5081    function Sqrt (Arg : Float) return Float is
5082      pragma Postcondition
5083        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5084      ...
5085    end Sqrt
5086 @end smallexample
5087
5088 @noindent
5089 As this example, shows, the use of the @code{Old} attribute
5090 is often useful in postconditions to refer to the state on
5091 entry to the subprogram.
5092
5093 Note that postconditions are only checked on normal returns
5094 from the subprogram. If an abnormal return results from
5095 raising an exception, then the postconditions are not checked.
5096
5097 If a postcondition fails, then the exception
5098 @code{System.Assertions.Assert_Failure} is raised. If
5099 a message argument was supplied, then the given string
5100 will be used as the exception message. If no message
5101 argument was supplied, then the default message has
5102 the form "Postcondition failed at file:line". The
5103 exception is raised in the context of the subprogram
5104 body, so it is possible to catch postcondition failures
5105 within the subprogram body itself.
5106
5107 Within a package spec, normal visibility rules
5108 in Ada would prevent forward references within a
5109 postcondition pragma to functions defined later in
5110 the same package. This would introduce undesirable
5111 ordering constraints. To avoid this problem, all
5112 postcondition pragmas are analyzed at the end of
5113 the package spec, allowing forward references.
5114
5115 The following example shows that this even allows
5116 mutually recursive postconditions as in:
5117
5118 @smallexample @c ada
5119 package Parity_Functions is
5120    function Odd  (X : Natural) return Boolean;
5121    pragma Postcondition
5122      (Odd'Result =
5123         (x = 1
5124           or else
5125         (x /= 0 and then Even (X - 1))));
5126
5127    function Even (X : Natural) return Boolean;
5128    pragma Postcondition
5129      (Even'Result =
5130         (x = 0
5131           or else
5132         (x /= 1 and then Odd (X - 1))));
5133
5134 end Parity_Functions;
5135 @end smallexample
5136
5137 @noindent
5138 There are no restrictions on the complexity or form of
5139 conditions used within @code{Postcondition} pragmas.
5140 The following example shows that it is even possible
5141 to verify performance behavior.
5142
5143 @smallexample @c ada
5144 package Sort is
5145
5146    Performance : constant Float;
5147    --  Performance constant set by implementation
5148    --  to match target architecture behavior.
5149
5150    procedure Treesort (Arg : String);
5151    --  Sorts characters of argument using N*logN sort
5152    pragma Postcondition
5153      (Float (Clock - Clock'Old) <=
5154         Float (Arg'Length) *
5155         log (Float (Arg'Length)) *
5156         Performance);
5157 end Sort;
5158 @end smallexample
5159
5160 @noindent
5161 Note: postcondition pragmas associated with subprograms that are
5162 marked as Inline_Always, or those marked as Inline with front-end
5163 inlining (-gnatN option set) are accepted and legality-checked
5164 by the compiler, but are ignored at run-time even if postcondition
5165 checking is enabled.
5166
5167 @node Pragma Precondition
5168 @unnumberedsec Pragma Precondition
5169 @cindex Preconditions
5170 @cindex Checks, preconditions
5171 @findex Preconditions
5172 @noindent
5173 Syntax:
5174
5175 @smallexample @c ada
5176 pragma Precondition (
5177    [Check   =>] Boolean_Expression
5178  [,[Message =>] String_Expression]);
5179 @end smallexample
5180
5181 @noindent
5182 The @code{Precondition} pragma is similar to @code{Postcondition}
5183 except that the corresponding checks take place immediately upon
5184 entry to the subprogram, and if a precondition fails, the exception
5185 is raised in the context of the caller, and the attribute 'Result
5186 cannot be used within the precondition expression.
5187
5188 Otherwise, the placement and visibility rules are identical to those
5189 described for postconditions. The following is an example of use
5190 within a package spec:
5191
5192 @smallexample @c ada
5193 package Math_Functions is
5194    ...
5195    function Sqrt (Arg : Float) return Float;
5196    pragma Precondition (Arg >= 0.0)
5197    ...
5198 end Math_Functions;
5199 @end smallexample
5200
5201 @noindent
5202 @code{Precondition} pragmas may appear either immediately following the
5203 (separate) declaration of a subprogram, or at the start of the
5204 declarations of a subprogram body. Only other pragmas may intervene
5205 (that is appear between the subprogram declaration and its
5206 postconditions, or appear before the postcondition in the
5207 declaration sequence in a subprogram body).
5208
5209 Note: precondition pragmas associated with subprograms that are
5210 marked as Inline_Always, or those marked as Inline with front-end
5211 inlining (-gnatN option set) are accepted and legality-checked
5212 by the compiler, but are ignored at run-time even if precondition
5213 checking is enabled.
5214
5215 @node Pragma Predicate
5216 @unnumberedsec Pragma Predicate
5217 @findex Predicate
5218 @findex Predicate pragma
5219 @noindent
5220 Syntax:
5221
5222 @smallexample @c ada
5223 pragma Predicate
5224   ([Entity =>] type_LOCAL_NAME,
5225    [Check  =>] EXPRESSION);
5226 @end smallexample
5227
5228 @noindent
5229 This pragma (available in all versions of Ada in GNAT) encompasses both
5230 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5231 Ada 2012. A predicate is regarded as static if it has an allowed form
5232 for @code{Static_Predicate} and is otherwise treated as a
5233 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5234 pragma behave exactly as described in the Ada 2012 reference manual.
5235 For example, if we have
5236
5237 @smallexample @c ada
5238 type R is range 1 .. 10;
5239 subtype S is R;
5240 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5241 subtype Q is R
5242 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5243 @end smallexample
5244
5245 @noindent
5246 the effect is identical to the following Ada 2012 code:
5247
5248 @smallexample @c ada
5249 type R is range 1 .. 10;
5250 subtype S is R with
5251   Static_Predicate => S not in 4 .. 6;
5252 subtype Q is R with
5253   Dynamic_Predicate => F(Q) or G(Q);
5254 @end smallexample
5255
5256 @node Pragma Preelaborable_Initialization
5257 @unnumberedsec Pragma Preelaborable_Initialization
5258 @findex Preelaborable_Initialization
5259 @noindent
5260 Syntax:
5261
5262 @smallexample @c ada
5263 pragma Preelaborable_Initialization (DIRECT_NAME);
5264 @end smallexample
5265
5266 @noindent
5267 This pragma is standard in Ada 2005, but is available in all earlier
5268 versions of Ada as an implementation-defined pragma.
5269 See Ada 2012 Reference Manual for details.
5270
5271 @node Pragma Preelaborate_05
5272 @unnumberedsec Pragma Preelaborate_05
5273 @findex Preelaborate_05
5274 @noindent
5275 Syntax:
5276
5277 @smallexample @c ada
5278 pragma Preelaborate_05 [(library_unit_NAME)];
5279 @end smallexample
5280
5281 @noindent
5282 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5283 and is intended for use in the standard run-time library only. It has
5284 no effect in Ada 83 or Ada 95 mode, but is
5285 equivalent to @code{pragma Prelaborate} when operating in later
5286 Ada versions. This is used to handle some cases where packages
5287 not previously preelaborable became so in Ada 2005.
5288
5289 @node Pragma Priority_Specific_Dispatching
5290 @unnumberedsec Pragma Priority_Specific_Dispatching
5291 @findex Priority_Specific_Dispatching
5292 @noindent
5293 Syntax:
5294
5295 @smallexample @c ada
5296 pragma Priority_Specific_Dispatching (
5297    POLICY_IDENTIFIER,
5298    first_priority_EXPRESSION,
5299    last_priority_EXPRESSION)
5300
5301 POLICY_IDENTIFIER ::=
5302    EDF_Across_Priorities            |
5303    FIFO_Within_Priorities           |
5304    Non_Preemptive_Within_Priorities |
5305    Round_Robin_Within_Priorities
5306 @end smallexample
5307
5308 @noindent
5309 This pragma is standard in Ada 2005, but is available in all earlier
5310 versions of Ada as an implementation-defined pragma.
5311 See Ada 2012 Reference Manual for details.
5312
5313 @node Pragma Profile
5314 @unnumberedsec Pragma Profile
5315 @findex Profile
5316 @noindent
5317 Syntax:
5318
5319 @smallexample @c ada
5320 pragma Profile (Ravenscar | Restricted | Rational);
5321 @end smallexample
5322
5323 @noindent
5324 This pragma is standard in Ada 2005, but is available in all earlier
5325 versions of Ada as an implementation-defined pragma. This is a
5326 configuration pragma that establishes a set of configiuration pragmas
5327 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5328 The other two possibilities (@code{Restricted} or @code{Rational})
5329 are implementation-defined. The set of configuration pragmas
5330 is defined in the following sections.
5331
5332 @itemize
5333
5334 @item Pragma Profile (Ravenscar)
5335 @findex Ravenscar
5336 @noindent
5337
5338 The @code{Ravenscar} profile is standard in Ada 2005,
5339 but is available in all earlier
5340 versions of Ada as an implementation-defined pragma. This profile
5341 establishes the following set of configuration pragmas:
5342
5343 @table @code
5344 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5345 [RM D.2.2] Tasks are dispatched following a preemptive
5346 priority-ordered scheduling policy.
5347
5348 @item Locking_Policy (Ceiling_Locking)
5349 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5350 the ceiling priority of the corresponding protected object.
5351
5352 @item Detect_Blocking
5353 This pragma forces the detection of potentially blocking operations within a
5354 protected operation, and to raise Program_Error if that happens.
5355 @end table
5356 @noindent
5357
5358 plus the following set of restrictions:
5359
5360 @table @code
5361 @item Max_Entry_Queue_Length => 1
5362 No task can be queued on a protected entry.
5363 @item Max_Protected_Entries => 1
5364 @item Max_Task_Entries => 0
5365 No rendezvous statements are allowed.
5366 @item No_Abort_Statements
5367 @item No_Dynamic_Attachment
5368 @item No_Dynamic_Priorities
5369 @item No_Implicit_Heap_Allocations
5370 @item No_Local_Protected_Objects
5371 @item No_Local_Timing_Events
5372 @item No_Protected_Type_Allocators
5373 @item No_Relative_Delay
5374 @item No_Requeue_Statements
5375 @item No_Select_Statements
5376 @item No_Specific_Termination_Handlers
5377 @item No_Task_Allocators
5378 @item No_Task_Hierarchy
5379 @item No_Task_Termination
5380 @item Simple_Barriers
5381 @end table
5382 @noindent
5383
5384 The Ravenscar profile also includes the following restrictions that specify
5385 that there are no semantic dependences on the corresponding predefined
5386 packages:
5387
5388 @table @code
5389 @item No_Dependence => Ada.Asynchronous_Task_Control
5390 @item No_Dependence => Ada.Calendar
5391 @item No_Dependence => Ada.Execution_Time.Group_Budget
5392 @item No_Dependence => Ada.Execution_Time.Timers
5393 @item No_Dependence => Ada.Task_Attributes
5394 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5395 @end table
5396
5397 @noindent
5398
5399 This set of configuration pragmas and restrictions correspond to the
5400 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5401 published by the @cite{International Real-Time Ada Workshop}, 1997,
5402 and whose most recent description is available at
5403 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5404
5405 The original definition of the profile was revised at subsequent IRTAW
5406 meetings. It has been included in the ISO
5407 @cite{Guide for the Use of the Ada Programming Language in High
5408 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5409 the next revision of the standard. The formal definition given by
5410 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5411 AI-305) available at
5412 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5413 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5414
5415 The above set is a superset of the restrictions provided by pragma
5416 @code{Profile (Restricted)}, it includes six additional restrictions
5417 (@code{Simple_Barriers}, @code{No_Select_Statements},
5418 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5419 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5420 that pragma @code{Profile (Ravenscar)}, like the pragma
5421 @code{Profile (Restricted)},
5422 automatically causes the use of a simplified,
5423 more efficient version of the tasking run-time system.
5424
5425 @item Pragma Profile (Restricted)
5426 @findex Restricted Run Time
5427 @noindent
5428 This profile corresponds to the GNAT restricted run time. It
5429 establishes the following set of restrictions:
5430
5431 @itemize @bullet
5432 @item No_Abort_Statements
5433 @item No_Entry_Queue
5434 @item No_Task_Hierarchy
5435 @item No_Task_Allocators
5436 @item No_Dynamic_Priorities
5437 @item No_Terminate_Alternatives
5438 @item No_Dynamic_Attachment
5439 @item No_Protected_Type_Allocators
5440 @item No_Local_Protected_Objects
5441 @item No_Requeue_Statements
5442 @item No_Task_Attributes_Package
5443 @item Max_Asynchronous_Select_Nesting =  0
5444 @item Max_Task_Entries =  0
5445 @item Max_Protected_Entries = 1
5446 @item Max_Select_Alternatives = 0
5447 @end itemize
5448
5449 @noindent
5450 This set of restrictions causes the automatic selection of a simplified
5451 version of the run time that provides improved performance for the
5452 limited set of tasking functionality permitted by this set of restrictions.
5453
5454 @item Pragma Profile (Rational)
5455 @findex Rational compatibility mode
5456 @noindent
5457 The Rational profile is intended to facilitate porting legacy code that
5458 compiles with the Rational APEX compiler, even when the code includes non-
5459 conforming Ada constructs.  The profile enables the following three pragmas:
5460
5461 @itemize @bullet
5462 @item pragma Implicit_Packing
5463 @item pragma Overriding_Renamings
5464 @item pragma Use_VADS_Size
5465 @end itemize
5466
5467 @end itemize
5468
5469 @node Pragma Profile_Warnings
5470 @unnumberedsec Pragma Profile_Warnings
5471 @findex Profile_Warnings
5472 @noindent
5473 Syntax:
5474
5475 @smallexample @c ada
5476 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5477 @end smallexample
5478
5479 @noindent
5480 This is an implementation-defined pragma that is similar in
5481 effect to @code{pragma Profile} except that instead of
5482 generating @code{Restrictions} pragmas, it generates
5483 @code{Restriction_Warnings} pragmas. The result is that
5484 violations of the profile generate warning messages instead
5485 of error messages.
5486
5487 @node Pragma Propagate_Exceptions
5488 @unnumberedsec Pragma Propagate_Exceptions
5489 @cindex Interfacing to C++
5490 @findex Propagate_Exceptions
5491 @noindent
5492 Syntax:
5493
5494 @smallexample @c ada
5495 pragma Propagate_Exceptions;
5496 @end smallexample
5497
5498 @noindent
5499 This pragma is now obsolete and, other than generating a warning if warnings
5500 on obsolescent features are enabled, is ignored.
5501 It is retained for compatibility
5502 purposes. It used to be used in connection with optimization of
5503 a now-obsolete mechanism for implementation of exceptions.
5504
5505 @node Pragma Psect_Object
5506 @unnumberedsec Pragma Psect_Object
5507 @findex Psect_Object
5508 @noindent
5509 Syntax:
5510
5511 @smallexample @c ada
5512 pragma Psect_Object (
5513      [Internal =>] LOCAL_NAME,
5514   [, [External =>] EXTERNAL_SYMBOL]
5515   [, [Size     =>] EXTERNAL_SYMBOL]);
5516
5517 EXTERNAL_SYMBOL ::=
5518   IDENTIFIER
5519 | static_string_EXPRESSION
5520 @end smallexample
5521
5522 @noindent
5523 This pragma is identical in effect to pragma @code{Common_Object}.
5524
5525 @node Pragma Pure_05
5526 @unnumberedsec Pragma Pure_05
5527 @findex Pure_05
5528 @noindent
5529 Syntax:
5530
5531 @smallexample @c ada
5532 pragma Pure_05 [(library_unit_NAME)];
5533 @end smallexample
5534
5535 @noindent
5536 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5537 and is intended for use in the standard run-time library only. It has
5538 no effect in Ada 83 or Ada 95 mode, but is
5539 equivalent to @code{pragma Pure} when operating in later
5540 Ada versions. This is used to handle some cases where packages
5541 not previously pure became so in Ada 2005.
5542
5543 @node Pragma Pure_12
5544 @unnumberedsec Pragma Pure_12
5545 @findex Pure_12
5546 @noindent
5547 Syntax:
5548
5549 @smallexample @c ada
5550 pragma Pure_12 [(library_unit_NAME)];
5551 @end smallexample
5552
5553 @noindent
5554 This pragma is only available in GNAT mode (@option{-gnatg} switch set)
5555 and is intended for use in the standard run-time library only. It has
5556 no effect in Ada 83, Ada 95, or Ada 2005 modes, but is
5557 equivalent to @code{pragma Pure} when operating in later
5558 Ada versions. This is used to handle some cases where packages
5559 not previously pure became so in Ada 2012.
5560
5561 @node Pragma Pure_Function
5562 @unnumberedsec Pragma Pure_Function
5563 @findex Pure_Function
5564 @noindent
5565 Syntax:
5566
5567 @smallexample @c ada
5568 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5569 @end smallexample
5570
5571 @noindent
5572 This pragma appears in the same declarative part as a function
5573 declaration (or a set of function declarations if more than one
5574 overloaded declaration exists, in which case the pragma applies
5575 to all entities).  It specifies that the function @code{Entity} is
5576 to be considered pure for the purposes of code generation.  This means
5577 that the compiler can assume that there are no side effects, and
5578 in particular that two calls with identical arguments produce the
5579 same result.  It also means that the function can be used in an
5580 address clause.
5581
5582 Note that, quite deliberately, there are no static checks to try
5583 to ensure that this promise is met, so @code{Pure_Function} can be used
5584 with functions that are conceptually pure, even if they do modify
5585 global variables.  For example, a square root function that is
5586 instrumented to count the number of times it is called is still
5587 conceptually pure, and can still be optimized, even though it
5588 modifies a global variable (the count).  Memo functions are another
5589 example (where a table of previous calls is kept and consulted to
5590 avoid re-computation).
5591
5592 Note also that the normal rules excluding optimization of subprograms
5593 in pure units (when parameter types are descended from System.Address,
5594 or when the full view of a parameter type is limited), do not apply
5595 for the Pure_Function case. If you explicitly specify Pure_Function,
5596 the compiler may optimize away calls with identical arguments, and
5597 if that results in unexpected behavior, the proper action is not to
5598 use the pragma for subprograms that are not (conceptually) pure.
5599
5600 @findex Pure
5601 Note: Most functions in a @code{Pure} package are automatically pure, and
5602 there is no need to use pragma @code{Pure_Function} for such functions.  One
5603 exception is any function that has at least one formal of type
5604 @code{System.Address} or a type derived from it.  Such functions are not
5605 considered pure by default, since the compiler assumes that the
5606 @code{Address} parameter may be functioning as a pointer and that the
5607 referenced data may change even if the address value does not.
5608 Similarly, imported functions are not considered to be pure by default,
5609 since there is no way of checking that they are in fact pure.  The use
5610 of pragma @code{Pure_Function} for such a function will override these default
5611 assumption, and cause the compiler to treat a designated subprogram as pure
5612 in these cases.
5613
5614 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5615 applies to the underlying renamed function.  This can be used to
5616 disambiguate cases of overloading where some but not all functions
5617 in a set of overloaded functions are to be designated as pure.
5618
5619 If pragma @code{Pure_Function} is applied to a library level function, the
5620 function is also considered pure from an optimization point of view, but the
5621 unit is not a Pure unit in the categorization sense. So for example, a function
5622 thus marked is free to @code{with} non-pure units.
5623
5624 @node Pragma Ravenscar
5625 @unnumberedsec Pragma Ravenscar
5626 @findex Pragma Ravenscar
5627 @noindent
5628 Syntax:
5629
5630 @smallexample @c ada
5631 pragma Ravenscar;
5632 @end smallexample
5633
5634 @noindent
5635 This pragma is considered obsolescent, but is retained for
5636 compatibility purposes. It is equivalent to:
5637
5638 @smallexample @c ada
5639 pragma Profile (Ravenscar);
5640 @end smallexample
5641
5642 @noindent
5643 which is the preferred method of setting the @code{Ravenscar} profile.
5644
5645 @node Pragma Relative_Deadline
5646 @unnumberedsec Pragma Relative_Deadline
5647 @findex Relative_Deadline
5648 @noindent
5649 Syntax:
5650
5651 @smallexample @c ada
5652 pragma Relative_Deadline (time_span_EXPRESSSION);
5653 @end smallexample
5654
5655 @noindent
5656 This pragma is standard in Ada 2005, but is available in all earlier
5657 versions of Ada as an implementation-defined pragma.
5658 See Ada 2012 Reference Manual for details.
5659
5660 @node Pragma Remote_Access_Type
5661 @unnumberedsec Pragma Remote_Access_Type
5662 @findex Remote_Access_Type
5663 @noindent
5664 Syntax:
5665
5666 @smallexample @c ada
5667 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5668 @end smallexample
5669
5670 @noindent
5671 This pragma appears in the formal part of a generic declaration.
5672 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5673 the use of a remote access to class-wide type as actual for a formal
5674 access type.
5675
5676 When this pragma applies to a formal access type @code{Entity}, that
5677 type is treated as a remote access to class-wide type in the generic.
5678 It must be a formal general access type, and its designated type must
5679 be the class-wide type of a formal tagged limited private type from the
5680 same generic declaration.
5681
5682 In the generic unit, the formal type is subject to all restrictions
5683 pertaining to remote access to class-wide types. At instantiation, the
5684 actual type must be a remote access to class-wide type.
5685
5686 @node Pragma Restricted_Run_Time
5687 @unnumberedsec Pragma Restricted_Run_Time
5688 @findex Pragma Restricted_Run_Time
5689 @noindent
5690 Syntax:
5691
5692 @smallexample @c ada
5693 pragma Restricted_Run_Time;
5694 @end smallexample
5695
5696 @noindent
5697 This pragma is considered obsolescent, but is retained for
5698 compatibility purposes. It is equivalent to:
5699
5700 @smallexample @c ada
5701 pragma Profile (Restricted);
5702 @end smallexample
5703
5704 @noindent
5705 which is the preferred method of setting the restricted run time
5706 profile.
5707
5708 @node Pragma Restriction_Warnings
5709 @unnumberedsec Pragma Restriction_Warnings
5710 @findex Restriction_Warnings
5711 @noindent
5712 Syntax:
5713
5714 @smallexample @c ada
5715 pragma Restriction_Warnings
5716   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5717 @end smallexample
5718
5719 @noindent
5720 This pragma allows a series of restriction identifiers to be
5721 specified (the list of allowed identifiers is the same as for
5722 pragma @code{Restrictions}). For each of these identifiers
5723 the compiler checks for violations of the restriction, but
5724 generates a warning message rather than an error message
5725 if the restriction is violated.
5726
5727 @node Pragma Share_Generic
5728 @unnumberedsec Pragma Share_Generic
5729 @findex Share_Generic
5730 @noindent
5731 Syntax:
5732
5733 @smallexample @c ada
5734 pragma Share_Generic (GNAME @{, GNAME@});
5735
5736 GNAME ::= generic_unit_NAME | generic_instance_NAME
5737 @end smallexample
5738
5739 @noindent
5740 This pragma is provided for compatibility with Dec Ada 83. It has
5741 no effect in @code{GNAT} (which does not implement shared generics), other
5742 than to check that the given names are all names of generic units or
5743 generic instances.
5744
5745 @node Pragma Shared
5746 @unnumberedsec Pragma Shared
5747 @findex Shared
5748
5749 @noindent
5750 This pragma is provided for compatibility with Ada 83. The syntax and
5751 semantics are identical to pragma Atomic.
5752
5753 @node Pragma Short_Circuit_And_Or
5754 @unnumberedsec Pragma Short_Circuit_And_Or
5755 @findex Short_Circuit_And_Or
5756 @noindent
5757 Syntax:
5758
5759 @smallexample @c ada
5760 pragma Short_Circuit_And_Or;
5761 @end smallexample
5762
5763 @noindent
5764 This configuration pragma causes any occurrence of the AND operator applied to
5765 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5766 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5767 may be useful in the context of certification protocols requiring the use of
5768 short-circuited logical operators. If this configuration pragma occurs locally
5769 within the file being compiled, it applies only to the file being compiled.
5770 There is no requirement that all units in a partition use this option.
5771
5772 @node Pragma Short_Descriptors
5773 @unnumberedsec Pragma Short_Descriptors
5774 @findex Short_Descriptors
5775 @noindent
5776 Syntax:
5777
5778 @smallexample @c ada
5779 pragma Short_Descriptors
5780 @end smallexample
5781
5782 @noindent
5783 In VMS versions of the compiler, this configuration pragma causes all
5784 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5785 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5786 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5787 versions.
5788
5789 @node Pragma Simple_Storage_Pool_Type
5790 @unnumberedsec Pragma Simple_Storage_Pool_Type
5791 @findex Simple_Storage_Pool_Type
5792 @cindex Storage pool, simple
5793 @cindex Simple storage pool
5794 @noindent
5795 Syntax:
5796
5797 @smallexample @c ada
5798 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5799 @end smallexample
5800
5801 @noindent
5802 A type can be established as a ``simple storage pool type'' by applying
5803 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5804 A type named in the pragma must be a library-level immutably limited record
5805 type or limited tagged type declared immediately within a package declaration.
5806 The type can also be a limited private type whose full type is allowed as
5807 a simple storage pool type.
5808
5809 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5810 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5811 are subtype conformant with the following subprogram declarations:
5812
5813 @smallexample @c ada
5814 procedure Allocate
5815   (Pool                     : in out SSP;
5816    Storage_Address          : out System.Address;
5817    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5818    Alignment                : System.Storage_Elements.Storage_Count);
5819
5820 procedure Deallocate
5821   (Pool : in out SSP;
5822    Storage_Address          : System.Address;
5823    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5824    Alignment                : System.Storage_Elements.Storage_Count);
5825
5826 function Storage_Size (Pool : SSP)
5827   return System.Storage_Elements.Storage_Count;
5828 @end smallexample
5829
5830 @noindent
5831 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5832 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5833 applying an unchecked deallocation has no effect other than to set its actual
5834 parameter to null. If @code{Storage_Size} is not declared, then the
5835 @code{Storage_Size} attribute applied to an access type associated with
5836 a pool object of type SSP returns zero. Additional operations can be declared
5837 for a simple storage pool type (such as for supporting a mark/release
5838 storage-management discipline).
5839
5840 An object of a simple storage pool type can be associated with an access
5841 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5842
5843 @smallexample @c ada
5844
5845 My_Pool : My_Simple_Storage_Pool_Type;
5846
5847 type Acc is access My_Data_Type;
5848
5849 for Acc'Simple_Storage_Pool use My_Pool;
5850
5851 @end smallexample
5852
5853 @noindent
5854 See attribute @code{Simple_Storage_Pool} for further details.
5855
5856 @node Pragma Source_File_Name
5857 @unnumberedsec Pragma Source_File_Name
5858 @findex Source_File_Name
5859 @noindent
5860 Syntax:
5861
5862 @smallexample @c ada
5863 pragma Source_File_Name (
5864   [Unit_Name   =>] unit_NAME,
5865   Spec_File_Name =>  STRING_LITERAL,
5866   [Index => INTEGER_LITERAL]);
5867
5868 pragma Source_File_Name (
5869   [Unit_Name   =>] unit_NAME,
5870   Body_File_Name =>  STRING_LITERAL,
5871   [Index => INTEGER_LITERAL]);
5872 @end smallexample
5873
5874 @noindent
5875 Use this to override the normal naming convention.  It is a configuration
5876 pragma, and so has the usual applicability of configuration pragmas
5877 (i.e.@: it applies to either an entire partition, or to all units in a
5878 compilation, or to a single unit, depending on how it is used.
5879 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
5880 the second argument is required, and indicates whether this is the file
5881 name for the spec or for the body.
5882
5883 The optional Index argument should be used when a file contains multiple
5884 units, and when you do not want to use @code{gnatchop} to separate then
5885 into multiple files (which is the recommended procedure to limit the
5886 number of recompilations that are needed when some sources change).
5887 For instance, if the source file @file{source.ada} contains
5888
5889 @smallexample @c ada
5890 package B is
5891 ...
5892 end B;
5893
5894 with B;
5895 procedure A is
5896 begin
5897    ..
5898 end A;
5899 @end smallexample
5900
5901 you could use the following configuration pragmas:
5902
5903 @smallexample @c ada
5904 pragma Source_File_Name
5905   (B, Spec_File_Name => "source.ada", Index => 1);
5906 pragma Source_File_Name
5907   (A, Body_File_Name => "source.ada", Index => 2);
5908 @end smallexample
5909
5910 Note that the @code{gnatname} utility can also be used to generate those
5911 configuration pragmas.
5912
5913 Another form of the @code{Source_File_Name} pragma allows
5914 the specification of patterns defining alternative file naming schemes
5915 to apply to all files.
5916
5917 @smallexample @c ada
5918 pragma Source_File_Name
5919   (  [Spec_File_Name  =>] STRING_LITERAL
5920    [,[Casing          =>] CASING_SPEC]
5921    [,[Dot_Replacement =>] STRING_LITERAL]);
5922
5923 pragma Source_File_Name
5924   (  [Body_File_Name  =>] STRING_LITERAL
5925    [,[Casing          =>] CASING_SPEC]
5926    [,[Dot_Replacement =>] STRING_LITERAL]);
5927
5928 pragma Source_File_Name
5929   (  [Subunit_File_Name =>] STRING_LITERAL
5930    [,[Casing            =>] CASING_SPEC]
5931    [,[Dot_Replacement   =>] STRING_LITERAL]);
5932
5933 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5934 @end smallexample
5935
5936 @noindent
5937 The first argument is a pattern that contains a single asterisk indicating
5938 the point at which the unit name is to be inserted in the pattern string
5939 to form the file name.  The second argument is optional.  If present it
5940 specifies the casing of the unit name in the resulting file name string.
5941 The default is lower case.  Finally the third argument allows for systematic
5942 replacement of any dots in the unit name by the specified string literal.
5943
5944 Note that Source_File_Name pragmas should not be used if you are using
5945 project files. The reason for this rule is that the project manager is not
5946 aware of these pragmas, and so other tools that use the projet file would not
5947 be aware of the intended naming conventions. If you are using project files,
5948 file naming is controlled by Source_File_Name_Project pragmas, which are
5949 usually supplied automatically by the project manager. A pragma
5950 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5951
5952 For more details on the use of the @code{Source_File_Name} pragma,
5953 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5954 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5955 User's Guide}.
5956
5957 @node Pragma Source_File_Name_Project
5958 @unnumberedsec Pragma Source_File_Name_Project
5959 @findex Source_File_Name_Project
5960 @noindent
5961
5962 This pragma has the same syntax and semantics as pragma Source_File_Name.
5963 It is only allowed as a stand alone configuration pragma.
5964 It cannot appear after a @ref{Pragma Source_File_Name}, and
5965 most importantly, once pragma Source_File_Name_Project appears,
5966 no further Source_File_Name pragmas are allowed.
5967
5968 The intention is that Source_File_Name_Project pragmas are always
5969 generated by the Project Manager in a manner consistent with the naming
5970 specified in a project file, and when naming is controlled in this manner,
5971 it is not permissible to attempt to modify this naming scheme using
5972 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5973 known to the project manager).
5974
5975 @node Pragma Source_Reference
5976 @unnumberedsec Pragma Source_Reference
5977 @findex Source_Reference
5978 @noindent
5979 Syntax:
5980
5981 @smallexample @c ada
5982 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5983 @end smallexample
5984
5985 @noindent
5986 This pragma must appear as the first line of a source file.
5987 @var{integer_literal} is the logical line number of the line following
5988 the pragma line (for use in error messages and debugging
5989 information).  @var{string_literal} is a static string constant that
5990 specifies the file name to be used in error messages and debugging
5991 information.  This is most notably used for the output of @code{gnatchop}
5992 with the @option{-r} switch, to make sure that the original unchopped
5993 source file is the one referred to.
5994
5995 The second argument must be a string literal, it cannot be a static
5996 string expression other than a string literal.  This is because its value
5997 is needed for error messages issued by all phases of the compiler.
5998
5999 @node Pragma Static_Elaboration_Desired
6000 @unnumberedsec Pragma Static_Elaboration_Desired
6001 @findex Static_Elaboration_Desired
6002 @noindent
6003 Syntax:
6004
6005 @smallexample @c ada
6006 pragma Static_Elaboration_Desired;
6007 @end smallexample
6008
6009 @noindent
6010 This pragma is used to indicate that the compiler should attempt to initialize
6011 statically the objects declared in the library unit to which the pragma applies,
6012 when these objects are initialized (explicitly or implicitly) by an aggregate.
6013 In the absence of this pragma, aggregates in object declarations are expanded
6014 into assignments and loops, even when the aggregate components are static
6015 constants. When the aggregate is present the compiler builds a static expression
6016 that requires no run-time code, so that the initialized object can be placed in
6017 read-only data space. If the components are not static, or the aggregate has
6018 more that 100 components, the compiler emits a warning that the pragma cannot
6019 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6020 construction of larger aggregates with static components that include an others
6021 choice.)
6022
6023 @node Pragma Stream_Convert
6024 @unnumberedsec Pragma Stream_Convert
6025 @findex Stream_Convert
6026 @noindent
6027 Syntax:
6028
6029 @smallexample @c ada
6030 pragma Stream_Convert (
6031   [Entity =>] type_LOCAL_NAME,
6032   [Read   =>] function_NAME,
6033   [Write  =>] function_NAME);
6034 @end smallexample
6035
6036 @noindent
6037 This pragma provides an efficient way of providing stream functions for
6038 types defined in packages.  Not only is it simpler to use than declaring
6039 the necessary functions with attribute representation clauses, but more
6040 significantly, it allows the declaration to made in such a way that the
6041 stream packages are not loaded unless they are needed.  The use of
6042 the Stream_Convert pragma adds no overhead at all, unless the stream
6043 attributes are actually used on the designated type.
6044
6045 The first argument specifies the type for which stream functions are
6046 provided.  The second parameter provides a function used to read values
6047 of this type.  It must name a function whose argument type may be any
6048 subtype, and whose returned type must be the type given as the first
6049 argument to the pragma.
6050
6051 The meaning of the @var{Read}
6052 parameter is that if a stream attribute directly
6053 or indirectly specifies reading of the type given as the first parameter,
6054 then a value of the type given as the argument to the Read function is
6055 read from the stream, and then the Read function is used to convert this
6056 to the required target type.
6057
6058 Similarly the @var{Write} parameter specifies how to treat write attributes
6059 that directly or indirectly apply to the type given as the first parameter.
6060 It must have an input parameter of the type specified by the first parameter,
6061 and the return type must be the same as the input type of the Read function.
6062 The effect is to first call the Write function to convert to the given stream
6063 type, and then write the result type to the stream.
6064
6065 The Read and Write functions must not be overloaded subprograms.  If necessary
6066 renamings can be supplied to meet this requirement.
6067 The usage of this attribute is best illustrated by a simple example, taken
6068 from the GNAT implementation of package Ada.Strings.Unbounded:
6069
6070 @smallexample @c ada
6071 function To_Unbounded (S : String)
6072            return Unbounded_String
6073   renames To_Unbounded_String;
6074
6075 pragma Stream_Convert
6076   (Unbounded_String, To_Unbounded, To_String);
6077 @end smallexample
6078
6079 @noindent
6080 The specifications of the referenced functions, as given in the Ada
6081 Reference Manual are:
6082
6083 @smallexample @c ada
6084 function To_Unbounded_String (Source : String)
6085   return Unbounded_String;
6086
6087 function To_String (Source : Unbounded_String)
6088   return String;
6089 @end smallexample
6090
6091 @noindent
6092 The effect is that if the value of an unbounded string is written to a stream,
6093 then the representation of the item in the stream is in the same format that
6094 would be used for @code{Standard.String'Output}, and this same representation
6095 is expected when a value of this type is read from the stream. Note that the
6096 value written always includes the bounds, even for Unbounded_String'Write,
6097 since Unbounded_String is not an array type.
6098
6099 @node Pragma Style_Checks
6100 @unnumberedsec Pragma Style_Checks
6101 @findex Style_Checks
6102 @noindent
6103 Syntax:
6104
6105 @smallexample @c ada
6106 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6107                      On | Off [, LOCAL_NAME]);
6108 @end smallexample
6109
6110 @noindent
6111 This pragma is used in conjunction with compiler switches to control the
6112 built in style checking provided by GNAT@.  The compiler switches, if set,
6113 provide an initial setting for the switches, and this pragma may be used
6114 to modify these settings, or the settings may be provided entirely by
6115 the use of the pragma.  This pragma can be used anywhere that a pragma
6116 is legal, including use as a configuration pragma (including use in
6117 the @file{gnat.adc} file).
6118
6119 The form with a string literal specifies which style options are to be
6120 activated.  These are additive, so they apply in addition to any previously
6121 set style check options.  The codes for the options are the same as those
6122 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6123 For example the following two methods can be used to enable
6124 layout checking:
6125
6126 @itemize @bullet
6127 @item
6128 @smallexample @c ada
6129 pragma Style_Checks ("l");
6130 @end smallexample
6131
6132 @item
6133 @smallexample
6134 gcc -c -gnatyl @dots{}
6135 @end smallexample
6136 @end itemize
6137
6138 @noindent
6139 The form ALL_CHECKS activates all standard checks (its use is equivalent
6140 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6141 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6142 @value{EDITION} User's Guide}, for details.)
6143
6144 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6145 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6146 options (i.e. equivalent to -gnatyg).
6147
6148 The forms with @code{Off} and @code{On}
6149 can be used to temporarily disable style checks
6150 as shown in the following example:
6151
6152 @smallexample @c ada
6153 @iftex
6154 @leftskip=0cm
6155 @end iftex
6156 pragma Style_Checks ("k"); -- requires keywords in lower case
6157 pragma Style_Checks (Off); -- turn off style checks
6158 NULL;                      -- this will not generate an error message
6159 pragma Style_Checks (On);  -- turn style checks back on
6160 NULL;                      -- this will generate an error message
6161 @end smallexample
6162
6163 @noindent
6164 Finally the two argument form is allowed only if the first argument is
6165 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6166 for the specified entity, as shown in the following example:
6167
6168 @smallexample @c ada
6169 @iftex
6170 @leftskip=0cm
6171 @end iftex
6172 pragma Style_Checks ("r"); -- require consistency of identifier casing
6173 Arg : Integer;
6174 Rf1 : Integer := ARG;      -- incorrect, wrong case
6175 pragma Style_Checks (Off, Arg);
6176 Rf2 : Integer := ARG;      -- OK, no error
6177 @end smallexample
6178
6179 @node Pragma Subtitle
6180 @unnumberedsec Pragma Subtitle
6181 @findex Subtitle
6182 @noindent
6183 Syntax:
6184
6185 @smallexample @c ada
6186 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6187 @end smallexample
6188
6189 @noindent
6190 This pragma is recognized for compatibility with other Ada compilers
6191 but is ignored by GNAT@.
6192
6193 @node Pragma Suppress
6194 @unnumberedsec Pragma Suppress
6195 @findex Suppress
6196 @noindent
6197 Syntax:
6198
6199 @smallexample @c ada
6200 pragma Suppress (Identifier [, [On =>] Name]);
6201 @end smallexample
6202
6203 @noindent
6204 This is a standard pragma, and supports all the check names required in
6205 the RM. It is included here because GNAT recognizes some additional check
6206 names that are implementation defined (as permitted by the RM):
6207
6208 @itemize @bullet
6209
6210 @item
6211 @code{Alignment_Check} can be used to suppress alignment checks
6212 on addresses used in address clauses. Such checks can also be suppressed
6213 by suppressing range checks, but the specific use of @code{Alignment_Check}
6214 allows suppression of alignment checks without suppressing other range checks.
6215
6216 @item
6217 @code{Predicate_Check} can be used to control whether predicate checks are
6218 active. It is applicable only to predicates for which the policy is
6219 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6220 predicate is ignored or checked for the whole program, the use of
6221 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6222 predicate to be turned on and off at specific points in the program.
6223
6224 @item
6225 @code{Validity_Check} can be used specifically to control validity checks.
6226 If @code{Suppress} is used to suppress validity checks, then no validity
6227 checks are performed, including those specified by the appropriate compiler
6228 switch or the @code{Validity_Checks} pragma.
6229
6230 @item
6231 Additional check names previously introduced by use of the @code{Check_Name}
6232 pragma are also allowed.
6233
6234 @end itemize
6235
6236 @noindent
6237 Note that pragma Suppress gives the compiler permission to omit
6238 checks, but does not require the compiler to omit checks. The compiler
6239 will generate checks if they are essentially free, even when they are
6240 suppressed. In particular, if the compiler can prove that a certain
6241 check will necessarily fail, it will generate code to do an
6242 unconditional ``raise'', even if checks are suppressed. The compiler
6243 warns in this case.
6244
6245 Of course, run-time checks are omitted whenever the compiler can prove
6246 that they will not fail, whether or not checks are suppressed.
6247
6248 @node Pragma Suppress_All
6249 @unnumberedsec Pragma Suppress_All
6250 @findex Suppress_All
6251 @noindent
6252 Syntax:
6253
6254 @smallexample @c ada
6255 pragma Suppress_All;
6256 @end smallexample
6257
6258 @noindent
6259 This pragma can appear anywhere within a unit.
6260 The effect is to apply @code{Suppress (All_Checks)} to the unit
6261 in which it appears.  This pragma is implemented for compatibility with DEC
6262 Ada 83 usage where it appears at the end of a unit, and for compatibility
6263 with Rational Ada, where it appears as a program unit pragma.
6264 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6265 as a normal configuration pragma is the preferred usage in GNAT@.
6266
6267 @node Pragma Suppress_Debug_Info
6268 @unnumberedsec Pragma Suppress_Debug_Info
6269 @findex Suppress_Debug_Info
6270 @noindent
6271 Syntax:
6272
6273 @smallexample @c ada
6274 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6275 @end smallexample
6276
6277 @noindent
6278 This pragma can be used to suppress generation of debug information
6279 for the specified entity. It is intended primarily for use in debugging
6280 the debugger, and navigating around debugger problems.
6281
6282 @node Pragma Suppress_Exception_Locations
6283 @unnumberedsec Pragma Suppress_Exception_Locations
6284 @findex Suppress_Exception_Locations
6285 @noindent
6286 Syntax:
6287
6288 @smallexample @c ada
6289 pragma Suppress_Exception_Locations;
6290 @end smallexample
6291
6292 @noindent
6293 In normal mode, a raise statement for an exception by default generates
6294 an exception message giving the file name and line number for the location
6295 of the raise. This is useful for debugging and logging purposes, but this
6296 entails extra space for the strings for the messages. The configuration
6297 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6298 generation of these strings, with the result that space is saved, but the
6299 exception message for such raises is null. This configuration pragma may
6300 appear in a global configuration pragma file, or in a specific unit as
6301 usual. It is not required that this pragma be used consistently within
6302 a partition, so it is fine to have some units within a partition compiled
6303 with this pragma and others compiled in normal mode without it.
6304
6305 @node Pragma Suppress_Initialization
6306 @unnumberedsec Pragma Suppress_Initialization
6307 @findex Suppress_Initialization
6308 @cindex Suppressing initialization
6309 @cindex Initialization, suppression of
6310 @noindent
6311 Syntax:
6312
6313 @smallexample @c ada
6314 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6315 @end smallexample
6316
6317 @noindent
6318 Here subtype_Name is the name introduced by a type declaration
6319 or subtype declaration.
6320 This pragma suppresses any implicit or explicit initialization
6321 for all variables of the given type or subtype,
6322 including initialization resulting from the use of pragmas
6323 Normalize_Scalars or Initialize_Scalars.
6324
6325 This is considered a representation item, so it cannot be given after
6326 the type is frozen. It applies to all subsequent object declarations,
6327 and also any allocator that creates objects of the type.
6328
6329 If the pragma is given for the first subtype, then it is considered
6330 to apply to the base type and all its subtypes. If the pragma is given
6331 for other than a first subtype, then it applies only to the given subtype.
6332 The pragma may not be given after the type is frozen.
6333
6334 @node Pragma Task_Info
6335 @unnumberedsec Pragma Task_Info
6336 @findex Task_Info
6337 @noindent
6338 Syntax
6339
6340 @smallexample @c ada
6341 pragma Task_Info (EXPRESSION);
6342 @end smallexample
6343
6344 @noindent
6345 This pragma appears within a task definition (like pragma
6346 @code{Priority}) and applies to the task in which it appears.  The
6347 argument must be of type @code{System.Task_Info.Task_Info_Type}.
6348 The @code{Task_Info} pragma provides system dependent control over
6349 aspects of tasking implementation, for example, the ability to map
6350 tasks to specific processors.  For details on the facilities available
6351 for the version of GNAT that you are using, see the documentation
6352 in the spec of package System.Task_Info in the runtime
6353 library.
6354
6355 @node Pragma Task_Name
6356 @unnumberedsec Pragma Task_Name
6357 @findex Task_Name
6358 @noindent
6359 Syntax
6360
6361 @smallexample @c ada
6362 pragma Task_Name (string_EXPRESSION);
6363 @end smallexample
6364
6365 @noindent
6366 This pragma appears within a task definition (like pragma
6367 @code{Priority}) and applies to the task in which it appears.  The
6368 argument must be of type String, and provides a name to be used for
6369 the task instance when the task is created.  Note that this expression
6370 is not required to be static, and in particular, it can contain
6371 references to task discriminants.  This facility can be used to
6372 provide different names for different tasks as they are created,
6373 as illustrated in the example below.
6374
6375 The task name is recorded internally in the run-time structures
6376 and is accessible to tools like the debugger.  In addition the
6377 routine @code{Ada.Task_Identification.Image} will return this
6378 string, with a unique task address appended.
6379
6380 @smallexample @c ada
6381 --  Example of the use of pragma Task_Name
6382
6383 with Ada.Task_Identification;
6384 use Ada.Task_Identification;
6385 with Text_IO; use Text_IO;
6386 procedure t3 is
6387
6388    type Astring is access String;
6389
6390    task type Task_Typ (Name : access String) is
6391       pragma Task_Name (Name.all);
6392    end Task_Typ;
6393
6394    task body Task_Typ is
6395       Nam : constant String := Image (Current_Task);
6396    begin
6397       Put_Line ("-->" & Nam (1 .. 14) & "<--");
6398    end Task_Typ;
6399
6400    type Ptr_Task is access Task_Typ;
6401    Task_Var : Ptr_Task;
6402
6403 begin
6404    Task_Var :=
6405      new Task_Typ (new String'("This is task 1"));
6406    Task_Var :=
6407      new Task_Typ (new String'("This is task 2"));
6408 end;
6409 @end smallexample
6410
6411 @node Pragma Task_Storage
6412 @unnumberedsec Pragma Task_Storage
6413 @findex Task_Storage
6414 Syntax:
6415
6416 @smallexample @c ada
6417 pragma Task_Storage (
6418   [Task_Type =>] LOCAL_NAME,
6419   [Top_Guard =>] static_integer_EXPRESSION);
6420 @end smallexample
6421
6422 @noindent
6423 This pragma specifies the length of the guard area for tasks.  The guard
6424 area is an additional storage area allocated to a task.  A value of zero
6425 means that either no guard area is created or a minimal guard area is
6426 created, depending on the target.  This pragma can appear anywhere a
6427 @code{Storage_Size} attribute definition clause is allowed for a task
6428 type.
6429
6430 @node Pragma Test_Case
6431 @unnumberedsec Pragma Test_Case
6432 @cindex Test cases
6433 @findex Test_Case
6434 @noindent
6435 Syntax:
6436
6437 @smallexample @c ada
6438 pragma Test_Case (
6439    [Name     =>] static_string_Expression
6440   ,[Mode     =>] (Nominal | Robustness)
6441  [, Requires =>  Boolean_Expression]
6442  [, Ensures  =>  Boolean_Expression]);
6443 @end smallexample
6444
6445 @noindent
6446 The @code{Test_Case} pragma allows defining fine-grain specifications
6447 for use by testing tools.
6448 The compiler checks the validity of the @code{Test_Case} pragma, but its
6449 presence does not lead to any modification of the code generated by the
6450 compiler.
6451
6452 @code{Test_Case} pragmas may only appear immediately following the
6453 (separate) declaration of a subprogram in a package declaration, inside
6454 a package spec unit. Only other pragmas may intervene (that is appear
6455 between the subprogram declaration and a test case).
6456
6457 The compiler checks that boolean expressions given in @code{Requires} and
6458 @code{Ensures} are valid, where the rules for @code{Requires} are the
6459 same as the rule for an expression in @code{Precondition} and the rules
6460 for @code{Ensures} are the same as the rule for an expression in
6461 @code{Postcondition}. In particular, attributes @code{'Old} and
6462 @code{'Result} can only be used within the @code{Ensures}
6463 expression. The following is an example of use within a package spec:
6464
6465 @smallexample @c ada
6466 package Math_Functions is
6467    ...
6468    function Sqrt (Arg : Float) return Float;
6469    pragma Test_Case (Name     => "Test 1",
6470                      Mode     => Nominal,
6471                      Requires => Arg < 10000,
6472                      Ensures  => Sqrt'Result < 10);
6473    ...
6474 end Math_Functions;
6475 @end smallexample
6476
6477 @noindent
6478 The meaning of a test case is that there is at least one context where
6479 @code{Requires} holds such that, if the associated subprogram is executed in
6480 that context, then @code{Ensures} holds when the subprogram returns.
6481 Mode @code{Nominal} indicates that the input context should also satisfy the
6482 precondition of the subprogram, and the output context should also satisfy its
6483 postcondition. More @code{Robustness} indicates that the precondition and
6484 postcondition of the subprogram should be ignored for this test case.
6485
6486 @node Pragma Thread_Local_Storage
6487 @unnumberedsec Pragma Thread_Local_Storage
6488 @findex Thread_Local_Storage
6489 @cindex Task specific storage
6490 @cindex TLS (Thread Local Storage)
6491 @cindex Task_Attributes
6492 Syntax:
6493
6494 @smallexample @c ada
6495 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
6496 @end smallexample
6497
6498 @noindent
6499 This pragma specifies that the specified entity, which must be
6500 a variable declared in a library level package, is to be marked as
6501 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
6502 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
6503 (and hence each Ada task) to see a distinct copy of the variable.
6504
6505 The variable may not have default initialization, and if there is
6506 an explicit initialization, it must be either @code{null} for an
6507 access variable, or a static expression for a scalar variable.
6508 This provides a low level mechanism similar to that provided by
6509 the @code{Ada.Task_Attributes} package, but much more efficient
6510 and is also useful in writing interface code that will interact
6511 with foreign threads.
6512
6513 If this pragma is used on a system where @code{TLS} is not supported,
6514 then an error message will be generated and the program will be rejected.
6515
6516 @node Pragma Time_Slice
6517 @unnumberedsec Pragma Time_Slice
6518 @findex Time_Slice
6519 @noindent
6520 Syntax:
6521
6522 @smallexample @c ada
6523 pragma Time_Slice (static_duration_EXPRESSION);
6524 @end smallexample
6525
6526 @noindent
6527 For implementations of GNAT on operating systems where it is possible
6528 to supply a time slice value, this pragma may be used for this purpose.
6529 It is ignored if it is used in a system that does not allow this control,
6530 or if it appears in other than the main program unit.
6531 @cindex OpenVMS
6532 Note that the effect of this pragma is identical to the effect of the
6533 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
6534
6535 @node Pragma Title
6536 @unnumberedsec Pragma Title
6537 @findex Title
6538 @noindent
6539 Syntax:
6540
6541 @smallexample @c ada
6542 pragma Title (TITLING_OPTION [, TITLING OPTION]);
6543
6544 TITLING_OPTION ::=
6545   [Title    =>] STRING_LITERAL,
6546 | [Subtitle =>] STRING_LITERAL
6547 @end smallexample
6548
6549 @noindent
6550 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
6551 pragma used in DEC Ada 83 implementations to provide a title and/or
6552 subtitle for the program listing.  The program listing generated by GNAT
6553 does not have titles or subtitles.
6554
6555 Unlike other pragmas, the full flexibility of named notation is allowed
6556 for this pragma, i.e.@: the parameters may be given in any order if named
6557 notation is used, and named and positional notation can be mixed
6558 following the normal rules for procedure calls in Ada.
6559
6560 @node Pragma Unchecked_Union
6561 @unnumberedsec Pragma Unchecked_Union
6562 @cindex Unions in C
6563 @findex Unchecked_Union
6564 @noindent
6565 Syntax:
6566
6567 @smallexample @c ada
6568 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
6569 @end smallexample
6570
6571 @noindent
6572 This pragma is used to specify a representation of a record type that is
6573 equivalent to a C union. It was introduced as a GNAT implementation defined
6574 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
6575 pragma, making it language defined, and GNAT fully implements this extended
6576 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
6577 details, consult the Ada 2012 Reference Manual, section B.3.3.
6578
6579 @node Pragma Unimplemented_Unit
6580 @unnumberedsec Pragma Unimplemented_Unit
6581 @findex Unimplemented_Unit
6582 @noindent
6583 Syntax:
6584
6585 @smallexample @c ada
6586 pragma Unimplemented_Unit;
6587 @end smallexample
6588
6589 @noindent
6590 If this pragma occurs in a unit that is processed by the compiler, GNAT
6591 aborts with the message @samp{@var{xxx} not implemented}, where
6592 @var{xxx} is the name of the current compilation unit.  This pragma is
6593 intended to allow the compiler to handle unimplemented library units in
6594 a clean manner.
6595
6596 The abort only happens if code is being generated.  Thus you can use
6597 specs of unimplemented packages in syntax or semantic checking mode.
6598
6599 @node Pragma Universal_Aliasing
6600 @unnumberedsec Pragma Universal_Aliasing
6601 @findex Universal_Aliasing
6602 @noindent
6603 Syntax:
6604
6605 @smallexample @c ada
6606 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
6607 @end smallexample
6608
6609 @noindent
6610 @var{type_LOCAL_NAME} must refer to a type declaration in the current
6611 declarative part.  The effect is to inhibit strict type-based aliasing
6612 optimization for the given type.  In other words, the effect is as though
6613 access types designating this type were subject to pragma No_Strict_Aliasing.
6614 For a detailed description of the strict aliasing optimization, and the
6615 situations in which it must be suppressed, @xref{Optimization and Strict
6616 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
6617
6618 @node Pragma Universal_Data
6619 @unnumberedsec Pragma Universal_Data
6620 @findex Universal_Data
6621 @noindent
6622 Syntax:
6623
6624 @smallexample @c ada
6625 pragma Universal_Data [(library_unit_Name)];
6626 @end smallexample
6627
6628 @noindent
6629 This pragma is supported only for the AAMP target and is ignored for
6630 other targets. The pragma specifies that all library-level objects
6631 (Counter 0 data) associated with the library unit are to be accessed
6632 and updated using universal addressing (24-bit addresses for AAMP5)
6633 rather than the default of 16-bit Data Environment (DENV) addressing.
6634 Use of this pragma will generally result in less efficient code for
6635 references to global data associated with the library unit, but
6636 allows such data to be located anywhere in memory. This pragma is
6637 a library unit pragma, but can also be used as a configuration pragma
6638 (including use in the @file{gnat.adc} file). The functionality
6639 of this pragma is also available by applying the -univ switch on the
6640 compilations of units where universal addressing of the data is desired.
6641
6642 @node Pragma Unmodified
6643 @unnumberedsec Pragma Unmodified
6644 @findex Unmodified
6645 @cindex Warnings, unmodified
6646 @noindent
6647 Syntax:
6648
6649 @smallexample @c ada
6650 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6651 @end smallexample
6652
6653 @noindent
6654 This pragma signals that the assignable entities (variables,
6655 @code{out} parameters, @code{in out} parameters) whose names are listed are
6656 deliberately not assigned in the current source unit. This
6657 suppresses warnings about the
6658 entities being referenced but not assigned, and in addition a warning will be
6659 generated if one of these entities is in fact assigned in the
6660 same unit as the pragma (or in the corresponding body, or one
6661 of its subunits).
6662
6663 This is particularly useful for clearly signaling that a particular
6664 parameter is not modified, even though the spec suggests that it might
6665 be.
6666
6667 @node Pragma Unreferenced
6668 @unnumberedsec Pragma Unreferenced
6669 @findex Unreferenced
6670 @cindex Warnings, unreferenced
6671 @noindent
6672 Syntax:
6673
6674 @smallexample @c ada
6675 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6676 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6677 @end smallexample
6678
6679 @noindent
6680 This pragma signals that the entities whose names are listed are
6681 deliberately not referenced in the current source unit. This
6682 suppresses warnings about the
6683 entities being unreferenced, and in addition a warning will be
6684 generated if one of these entities is in fact subsequently referenced in the
6685 same unit as the pragma (or in the corresponding body, or one
6686 of its subunits).
6687
6688 This is particularly useful for clearly signaling that a particular
6689 parameter is not referenced in some particular subprogram implementation
6690 and that this is deliberate. It can also be useful in the case of
6691 objects declared only for their initialization or finalization side
6692 effects.
6693
6694 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6695 current scope, then the entity most recently declared is the one to which
6696 the pragma applies. Note that in the case of accept formals, the pragma
6697 Unreferenced may appear immediately after the keyword @code{do} which
6698 allows the indication of whether or not accept formals are referenced
6699 or not to be given individually for each accept statement.
6700
6701 The left hand side of an assignment does not count as a reference for the
6702 purpose of this pragma. Thus it is fine to assign to an entity for which
6703 pragma Unreferenced is given.
6704
6705 Note that if a warning is desired for all calls to a given subprogram,
6706 regardless of whether they occur in the same unit as the subprogram
6707 declaration, then this pragma should not be used (calls from another
6708 unit would not be flagged); pragma Obsolescent can be used instead
6709 for this purpose, see @xref{Pragma Obsolescent}.
6710
6711 The second form of pragma @code{Unreferenced} is used within a context
6712 clause. In this case the arguments must be unit names of units previously
6713 mentioned in @code{with} clauses (similar to the usage of pragma
6714 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6715 units and unreferenced entities within these units.
6716
6717 @node Pragma Unreferenced_Objects
6718 @unnumberedsec Pragma Unreferenced_Objects
6719 @findex Unreferenced_Objects
6720 @cindex Warnings, unreferenced
6721 @noindent
6722 Syntax:
6723
6724 @smallexample @c ada
6725 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6726 @end smallexample
6727
6728 @noindent
6729 This pragma signals that for the types or subtypes whose names are
6730 listed, objects which are declared with one of these types or subtypes may
6731 not be referenced, and if no references appear, no warnings are given.
6732
6733 This is particularly useful for objects which are declared solely for their
6734 initialization and finalization effect. Such variables are sometimes referred
6735 to as RAII variables (Resource Acquisition Is Initialization). Using this
6736 pragma on the relevant type (most typically a limited controlled type), the
6737 compiler will automatically suppress unwanted warnings about these variables
6738 not being referenced.
6739
6740 @node Pragma Unreserve_All_Interrupts
6741 @unnumberedsec Pragma Unreserve_All_Interrupts
6742 @findex Unreserve_All_Interrupts
6743 @noindent
6744 Syntax:
6745
6746 @smallexample @c ada
6747 pragma Unreserve_All_Interrupts;
6748 @end smallexample
6749
6750 @noindent
6751 Normally certain interrupts are reserved to the implementation.  Any attempt
6752 to attach an interrupt causes Program_Error to be raised, as described in
6753 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
6754 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
6755 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6756 interrupt execution.
6757
6758 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6759 a program, then all such interrupts are unreserved.  This allows the
6760 program to handle these interrupts, but disables their standard
6761 functions.  For example, if this pragma is used, then pressing
6762 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
6763 a program can then handle the @code{SIGINT} interrupt as it chooses.
6764
6765 For a full list of the interrupts handled in a specific implementation,
6766 see the source code for the spec of @code{Ada.Interrupts.Names} in
6767 file @file{a-intnam.ads}.  This is a target dependent file that contains the
6768 list of interrupts recognized for a given target.  The documentation in
6769 this file also specifies what interrupts are affected by the use of
6770 the @code{Unreserve_All_Interrupts} pragma.
6771
6772 For a more general facility for controlling what interrupts can be
6773 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6774 of the @code{Unreserve_All_Interrupts} pragma.
6775
6776 @node Pragma Unsuppress
6777 @unnumberedsec Pragma Unsuppress
6778 @findex Unsuppress
6779 @noindent
6780 Syntax:
6781
6782 @smallexample @c ada
6783 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6784 @end smallexample
6785
6786 @noindent
6787 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
6788 there is no corresponding pragma @code{Suppress} in effect, it has no
6789 effect.  The range of the effect is the same as for pragma
6790 @code{Suppress}.  The meaning of the arguments is identical to that used
6791 in pragma @code{Suppress}.
6792
6793 One important application is to ensure that checks are on in cases where
6794 code depends on the checks for its correct functioning, so that the code
6795 will compile correctly even if the compiler switches are set to suppress
6796 checks.
6797
6798 This pragma is standard in Ada 2005. It is available in all earlier versions
6799 of Ada as an implementation-defined pragma.
6800
6801 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
6802 a number of implementation-defined check names. See description of pragma
6803 @code{Suppress} for full details.
6804
6805 @node Pragma Use_VADS_Size
6806 @unnumberedsec Pragma Use_VADS_Size
6807 @cindex @code{Size}, VADS compatibility
6808 @cindex Rational profile
6809 @findex Use_VADS_Size
6810 @noindent
6811 Syntax:
6812
6813 @smallexample @c ada
6814 pragma Use_VADS_Size;
6815 @end smallexample
6816
6817 @noindent
6818 This is a configuration pragma.  In a unit to which it applies, any use
6819 of the 'Size attribute is automatically interpreted as a use of the
6820 'VADS_Size attribute.  Note that this may result in incorrect semantic
6821 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
6822 the handling of existing code which depends on the interpretation of Size
6823 as implemented in the VADS compiler.  See description of the VADS_Size
6824 attribute for further details.
6825
6826 @node Pragma Validity_Checks
6827 @unnumberedsec Pragma Validity_Checks
6828 @findex Validity_Checks
6829 @noindent
6830 Syntax:
6831
6832 @smallexample @c ada
6833 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6834 @end smallexample
6835
6836 @noindent
6837 This pragma is used in conjunction with compiler switches to control the
6838 built-in validity checking provided by GNAT@.  The compiler switches, if set
6839 provide an initial setting for the switches, and this pragma may be used
6840 to modify these settings, or the settings may be provided entirely by
6841 the use of the pragma.  This pragma can be used anywhere that a pragma
6842 is legal, including use as a configuration pragma (including use in
6843 the @file{gnat.adc} file).
6844
6845 The form with a string literal specifies which validity options are to be
6846 activated.  The validity checks are first set to include only the default
6847 reference manual settings, and then a string of letters in the string
6848 specifies the exact set of options required.  The form of this string
6849 is exactly as described for the @option{-gnatVx} compiler switch (see the
6850 @value{EDITION} User's Guide for details).  For example the following two
6851 methods can be used to enable validity checking for mode @code{in} and
6852 @code{in out} subprogram parameters:
6853
6854 @itemize @bullet
6855 @item
6856 @smallexample @c ada
6857 pragma Validity_Checks ("im");
6858 @end smallexample
6859
6860 @item
6861 @smallexample
6862 gcc -c -gnatVim @dots{}
6863 @end smallexample
6864 @end itemize
6865
6866 @noindent
6867 The form ALL_CHECKS activates all standard checks (its use is equivalent
6868 to the use of the @code{gnatva} switch.
6869
6870 The forms with @code{Off} and @code{On}
6871 can be used to temporarily disable validity checks
6872 as shown in the following example:
6873
6874 @smallexample @c ada
6875 @iftex
6876 @leftskip=0cm
6877 @end iftex
6878 pragma Validity_Checks ("c"); -- validity checks for copies
6879 pragma Validity_Checks (Off); -- turn off validity checks
6880 A := B;                       -- B will not be validity checked
6881 pragma Validity_Checks (On);  -- turn validity checks back on
6882 A := C;                       -- C will be validity checked
6883 @end smallexample
6884
6885 @node Pragma Volatile
6886 @unnumberedsec Pragma Volatile
6887 @findex Volatile
6888 @noindent
6889 Syntax:
6890
6891 @smallexample @c ada
6892 pragma Volatile (LOCAL_NAME);
6893 @end smallexample
6894
6895 @noindent
6896 This pragma is defined by the Ada Reference Manual, and the GNAT
6897 implementation is fully conformant with this definition.  The reason it
6898 is mentioned in this section is that a pragma of the same name was supplied
6899 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
6900 implementation of pragma Volatile is upwards compatible with the
6901 implementation in DEC Ada 83.
6902
6903 @node Pragma Warnings
6904 @unnumberedsec Pragma Warnings
6905 @findex Warnings
6906 @noindent
6907 Syntax:
6908
6909 @smallexample @c ada
6910 pragma Warnings (On | Off [,REASON]);
6911 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
6912 pragma Warnings (static_string_EXPRESSION [,REASON]);
6913 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
6914
6915 REASON ::= Reason => static_string_EXPRESSION
6916 @end smallexample
6917
6918 @noindent
6919 Normally warnings are enabled, with the output being controlled by
6920 the command line switch.  Warnings (@code{Off}) turns off generation of
6921 warnings until a Warnings (@code{On}) is encountered or the end of the
6922 current unit.  If generation of warnings is turned off using this
6923 pragma, then some or all of the warning messages are suppressed,
6924 regardless of the setting of the command line switches.
6925
6926 The @code{Reason} parameter may optionally appear as the last argument
6927 in any of the forms of this pragma. It is intended purely for the
6928 purposes of documenting the reason for the @code{Warnings} pragma.
6929 The compiler will check that the argument is a static string but
6930 otherwise ignore this argument. Other tools may provide specialized
6931 processing for this string.
6932
6933 The form with a single argument (or two arguments if Reason present),
6934 where the first argument is @code{ON} or @code{OFF}
6935 may be used as a configuration pragma.
6936
6937 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6938 the specified entity.  This suppression is effective from the point where
6939 it occurs till the end of the extended scope of the variable (similar to
6940 the scope of @code{Suppress}). This form cannot be used as a configuration
6941 pragma.
6942
6943 The form with a single static_string_EXPRESSION argument (and possible
6944 reason) provides more precise
6945 control over which warnings are active. The string is a list of letters
6946 specifying which warnings are to be activated and which deactivated. The
6947 code for these letters is the same as the string used in the command
6948 line switch controlling warnings. For a brief summary, use the gnatmake
6949 command with no arguments, which will generate usage information containing
6950 the list of warnings switches supported. For
6951 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6952 User's Guide}. This form can also be used as a configuration pragma.
6953
6954 @noindent
6955 The warnings controlled by the `-gnatw' switch are generated by the front end
6956 of the compiler. The `GCC' back end can provide additional warnings and they
6957 are controlled by the `-W' switch.
6958 The form with a single static_string_EXPRESSION argument also works for the
6959 latters, but the string must be a single full `-W' switch in this case.
6960 The above reference lists a few examples of these additional warnings.
6961
6962 @noindent
6963 The specified warnings will be in effect until the end of the program
6964 or another pragma Warnings is encountered. The effect of the pragma is
6965 cumulative. Initially the set of warnings is the standard default set
6966 as possibly modified by compiler switches. Then each pragma Warning
6967 modifies this set of warnings as specified. This form of the pragma may
6968 also be used as a configuration pragma.
6969
6970 The fourth form, with an @code{On|Off} parameter and a string, is used to
6971 control individual messages, based on their text. The string argument
6972 is a pattern that is used to match against the text of individual
6973 warning messages (not including the initial "warning: " tag).
6974
6975 The pattern may contain asterisks, which match zero or more characters in
6976 the message. For example, you can use
6977 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6978 message @code{warning: 960 bits of "a" unused}. No other regular
6979 expression notations are permitted. All characters other than asterisk in
6980 these three specific cases are treated as literal characters in the match.
6981
6982 The above use of patterns to match the message applies only to warning
6983 messages generated by the front end. This form of the pragma with a
6984 string argument can also be used to control back end warnings controlled
6985 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6986 of a string of the form "[-Wxxx]" in the message which identifies the
6987 "-W" switch that controls the message. By using the text of the
6988 "-W" switch in the pragma, such back end warnings can be turned on and off.
6989
6990 There are two ways to use the pragma in this form. The OFF form can be used as a
6991 configuration pragma. The effect is to suppress all warnings (if any)
6992 that match the pattern string throughout the compilation (or match the
6993 -W switch in the back end case).
6994
6995 The second usage is to suppress a warning locally, and in this case, two
6996 pragmas must appear in sequence:
6997
6998 @smallexample @c ada
6999 pragma Warnings (Off, Pattern);
7000 @dots{} code where given warning is to be suppressed
7001 pragma Warnings (On, Pattern);
7002 @end smallexample
7003
7004 @noindent
7005 In this usage, the pattern string must match in the Off and On pragmas,
7006 and at least one matching warning must be suppressed.
7007
7008 Note: to write a string that will match any warning, use the string
7009 @code{"***"}. It will not work to use a single asterisk or two asterisks
7010 since this looks like an operator name. This form with three asterisks
7011 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7012 matching @code{pragma Warnings (On, "***")} will be required. This can be
7013 helpful in avoiding forgetting to turn warnings back on.
7014
7015 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7016 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7017 be useful in checking whether obsolete pragmas in existing programs are hiding
7018 real problems.
7019
7020 Note: pragma Warnings does not affect the processing of style messages. See
7021 separate entry for pragma Style_Checks for control of style messages.
7022
7023 @node Pragma Weak_External
7024 @unnumberedsec Pragma Weak_External
7025 @findex Weak_External
7026 @noindent
7027 Syntax:
7028
7029 @smallexample @c ada
7030 pragma Weak_External ([Entity =>] LOCAL_NAME);
7031 @end smallexample
7032
7033 @noindent
7034 @var{LOCAL_NAME} must refer to an object that is declared at the library
7035 level. This pragma specifies that the given entity should be marked as a
7036 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7037 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7038 of a regular symbol, that is to say a symbol that does not have to be
7039 resolved by the linker if used in conjunction with a pragma Import.
7040
7041 When a weak symbol is not resolved by the linker, its address is set to
7042 zero. This is useful in writing interfaces to external modules that may
7043 or may not be linked in the final executable, for example depending on
7044 configuration settings.
7045
7046 If a program references at run time an entity to which this pragma has been
7047 applied, and the corresponding symbol was not resolved at link time, then
7048 the execution of the program is erroneous. It is not erroneous to take the
7049 Address of such an entity, for example to guard potential references,
7050 as shown in the example below.
7051
7052 Some file formats do not support weak symbols so not all target machines
7053 support this pragma.
7054
7055 @smallexample @c ada
7056 --  Example of the use of pragma Weak_External
7057
7058 package External_Module is
7059   key : Integer;
7060   pragma Import (C, key);
7061   pragma Weak_External (key);
7062   function Present return boolean;
7063 end External_Module;
7064
7065 with System; use System;
7066 package body External_Module is
7067   function Present return boolean is
7068   begin
7069     return key'Address /= System.Null_Address;
7070   end Present;
7071 end External_Module;
7072 @end smallexample
7073
7074 @node Pragma Wide_Character_Encoding
7075 @unnumberedsec Pragma Wide_Character_Encoding
7076 @findex Wide_Character_Encoding
7077 @noindent
7078 Syntax:
7079
7080 @smallexample @c ada
7081 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7082 @end smallexample
7083
7084 @noindent
7085 This pragma specifies the wide character encoding to be used in program
7086 source text appearing subsequently. It is a configuration pragma, but may
7087 also be used at any point that a pragma is allowed, and it is permissible
7088 to have more than one such pragma in a file, allowing multiple encodings
7089 to appear within the same file.
7090
7091 The argument can be an identifier or a character literal. In the identifier
7092 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7093 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7094 case it is correspondingly one of the characters @samp{h}, @samp{u},
7095 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7096
7097 Note that when the pragma is used within a file, it affects only the
7098 encoding within that file, and does not affect withed units, specs,
7099 or subunits.
7100
7101 @node Implementation Defined Aspects
7102 @chapter Implementation Defined Aspects
7103 Ada defines (throughout the Ada 2012 reference manual, summarized
7104 in annex K) a set of aspects that can be specified for certain entities.
7105 These language defined aspects are implemented in GNAT in Ada 2012 mode
7106 and work as described in the Ada 2012 Reference Manual.
7107
7108 In addition, Ada 2012 allows implementations to define additional aspects
7109 whose meaning is defined by the implementation.  GNAT provides
7110 a number of these implementation-dependent aspects which can be used
7111 to extend and enhance the functionality of the compiler.  This section of
7112 the GNAT reference manual describes these additional attributes.
7113
7114 Note that any program using these aspects may not be portable to
7115 other compilers (although GNAT implements this set of aspects on all
7116 platforms).  Therefore if portability to other compilers is an important
7117 consideration, you should minimize the use of these aspects.
7118
7119 Note that for many of these aspects, the effect is essentially similar
7120 to the use of a pragma or attribute specification with the same name
7121 applied to the entity. For example, if we write:
7122
7123 @smallexample @c ada
7124 type R is range 1 .. 100
7125   with Value_Size => 10;
7126 @end smallexample
7127
7128 @noindent
7129 then the effect is the same as:
7130
7131 @smallexample @c ada
7132 type R is range 1 .. 100;
7133 for R'Value_Size use 10;
7134 @end smallexample
7135
7136 @noindent
7137 and if we write:
7138
7139 @smallexample @c ada
7140 type R is new Integer
7141   with Shared => True;
7142 @end smallexample
7143
7144 @noindent
7145 then the effect is the same as:
7146
7147 @smallexample @c ada
7148 type R is new Integer;
7149 pragma Shared (R);
7150 @end smallexample
7151
7152 @noindent
7153 In the documentation sections that follow, such cases are simply marked
7154 as being equivalent to the corresponding pragma or attribute definition
7155 clause.
7156
7157 @menu
7158 * Aspect Abstract_State::
7159 * Aspect Ada_2005::
7160 * Aspect Ada_2012::
7161 * Aspect Compiler_Unit::
7162 * Aspect Contract_Cases::
7163 * Aspect Depends::
7164 * Aspect Dimension::
7165 * Aspect Dimension_System::
7166 * Aspect Favor_Top_Level::
7167 * Aspect Global::
7168 * Aspect Inline_Always::
7169 * Aspect Invariant::
7170 * Aspect Lock_Free::
7171 * Aspect Object_Size::
7172 * Aspect Persistent_BSS::
7173 * Aspect Predicate::
7174 * Aspect Preelaborate_05::
7175 * Aspect Pure_05::
7176 * Aspect Pure_12::
7177 * Aspect Pure_Function::
7178 * Aspect Remote_Access_Type::
7179 * Aspect Scalar_Storage_Order::
7180 * Aspect Shared::
7181 * Aspect Simple_Storage_Pool::
7182 * Aspect Simple_Storage_Pool_Type::
7183 * Aspect Suppress_Debug_Info::
7184 * Aspect Test_Case::
7185 * Aspect Universal_Aliasing::
7186 * Aspect Universal_Data::
7187 * Aspect Unmodified::
7188 * Aspect Unreferenced::
7189 * Aspect Unreferenced_Objects::
7190 * Aspect Value_Size::
7191 * Aspect Warnings::
7192 @end menu
7193
7194 @node Aspect Abstract_State
7195 @unnumberedsec Aspect Abstract_State
7196 @findex Abstract_State
7197 @noindent
7198 This aspect is equivalent to pragma @code{Abstract_State}.
7199
7200 @node Aspect Ada_2005
7201 @unnumberedsec Aspect Ada_2005
7202 @findex Ada_2005
7203 @noindent
7204 This aspect is equivalent to the one argument form of pragma @code{Ada_2005}.
7205
7206 @node Aspect Ada_2012
7207 @unnumberedsec Aspect Ada_2012
7208 @findex Ada_2012
7209 @noindent
7210 This aspect is equivalent to the one argument form of pragma @code{Ada_2012}.
7211
7212 @node Aspect Compiler_Unit
7213 @unnumberedsec Aspect Compiler_Unit
7214 @findex Compiler_Unit
7215 @noindent
7216 This aspect is equivalent to pragma @code{Compiler_Unit}.
7217
7218 @node Aspect Contract_Cases
7219 @unnumberedsec Aspect Contract_Cases
7220 @findex Contract_Cases
7221 @noindent
7222 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
7223 of clauses being enclosed in parentheses so that syntactically it is an
7224 aggregate.
7225
7226 @node Aspect Depends
7227 @unnumberedsec Aspect Depends
7228 @findex Depends
7229 @noindent
7230 This aspect is equivalent to pragma @code{Depends}.
7231
7232 * Dimension::
7233
7234 @node Aspect Dimension
7235 @unnumberedsec Aspect Dimension
7236 @findex Dimension
7237 @noindent
7238 The @code{Dimension} aspect is used to specify the dimensions of a given
7239 subtype of a dimensioned numeric type. The aspect also specifies a symbol
7240 used when doing formatted output of dimensioned quantities. The syntax is:
7241
7242 @smallexample @c ada
7243 with Dimension =>
7244   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
7245
7246 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
7247
7248 DIMENSION_VALUE ::=
7249   RATIONAL
7250 | others               => RATIONAL
7251 | DISCRETE_CHOICE_LIST => RATIONAL
7252
7253 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
7254 @end smallexample
7255
7256 @noindent
7257 This aspect can only be applied to a subtype whose parent type has
7258 a @code{Dimension_Systen} aspect. The aspect must specify values for
7259 all dimensions of the system. The rational values are the powers of the
7260 corresponding dimensions that are used by the compiler to verify that
7261 physical (numeric) computations are dimensionally consistent. For example,
7262 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
7263 For further examples of the usage
7264 of this aspect, see package @code{System.Dim.Mks}.
7265 Note that when the dimensioned type is an integer type, then any
7266 dimension value must be an integer literal.
7267
7268 @node Aspect Dimension_System
7269 @unnumberedsec Aspect Dimension_System
7270 @findex Dimension_System
7271 @noindent
7272 The @code{Dimension_System} aspect is used to define a system of
7273 dimensions that will be used in subsequent subtype declarations with
7274 @code{Dimension} aspects that reference this system. The syntax is:
7275
7276 @smallexample @c ada
7277 with Dimension_System => (DIMENSION @{, DIMENSION@});
7278
7279 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
7280                [Unit_Symbol =>] SYMBOL,
7281                [Dim_Symbol  =>] SYMBOL)
7282
7283 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
7284 @end smallexample
7285
7286 @noindent
7287 This aspect is applied to a type, which must be a numeric derived type
7288 (typically a floating-point type), that
7289 will represent values within the dimension system. Each @code{DIMENSION}
7290 corresponds to one particular dimension. A maximum of 7 dimensions may
7291 be specified. @code{Unit_Name} is the name of the dimension (for example
7292 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
7293 of this dimension (for example 'm' for Meter). @code{Dim_Symbol} gives
7294 the identification within the dimension system (typically this is a
7295 single letter, e.g. 'L' standing for length for unit name Meter). The
7296 Unit_Smbol is used in formatted output of dimensioned quantities. The
7297 Dim_Symbol is used in error messages when numeric operations have
7298 inconsistent dimensions.
7299
7300 GNAT provides the standard definition of the International MKS system in
7301 the run-time package @code{System.Dim.Mks}. You can easily define
7302 similar packages for cgs units or British units, and define conversion factors
7303 between values in different systems. The MKS system is characterized by the
7304 following aspect:
7305
7306 @smallexample @c ada
7307    type Mks_Type is new Long_Long_Float
7308      with
7309       Dimension_System => (
7310         (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
7311         (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
7312         (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
7313         (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
7314         (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => "Theta"),
7315         (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
7316         (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
7317 @end smallexample
7318
7319 @noindent
7320 See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users
7321 Guide for detailed examples of use of the dimension system.
7322
7323 @node Aspect Favor_Top_Level
7324 @unnumberedsec Aspect Favor_Top_Level
7325 @findex Favor_Top_Level
7326 @noindent
7327 This aspect is equivalent to pragma @code{Favor_Top_Level}.
7328
7329 @node Aspect Global
7330 @unnumberedsec Aspect Global
7331 @findex Global
7332 @noindent
7333 This aspect is equivalent pragma @code{Global}.
7334
7335 @node Aspect Inline_Always
7336 @unnumberedsec Aspect Inline_Always
7337 @findex Inline_Always
7338 @noindent
7339 This aspect is equivalent to pragma @code{Inline_Always}.
7340
7341 @node Aspect Invariant
7342 @unnumberedsec Aspect Invariant
7343 @findex Invariant
7344 @noindent
7345 This aspect is equivalent to pragma @code{Invariant}. It is a
7346 synonym for the language defined aspect @code{Type_Invariant} except
7347 that it is separately controllable using pragma @code{Assertion_Policy}.
7348
7349 @node Aspect Lock_Free
7350 @unnumberedsec Aspect Lock_Free
7351 @findex Lock_Free
7352 @noindent
7353 This aspect is equivalent to pragma @code{Lock_Free}.
7354
7355 @node Aspect Object_Size
7356 @unnumberedsec Aspect Object_Size
7357 @findex Object_Size
7358 @noindent
7359 This aspect is equivalent to an @code{Object_Size} attribute definition
7360 clause.
7361
7362 @node Aspect Persistent_BSS
7363 @unnumberedsec Aspect Persistent_BSS
7364 @findex Persistent_BSS
7365 @noindent
7366 This aspect is equivalent to pragma @code{Persistent_BSS}.
7367
7368 @node Aspect Predicate
7369 @unnumberedsec Aspect Predicate
7370 @findex Predicate
7371 @noindent
7372 This aspect is equivalent to pragma @code{Predicate}. It is thus
7373 similar to the language defined aspects @code{Dynamic_Predicate}
7374 and @code{Static_Predicate} except that whether the resulting
7375 predicate is static or dynamic is controlled by the form of the
7376 expression. It is also separately controllable using pragma
7377 @code{Assertion_Policy}.
7378
7379 @node Aspect Preelaborate_05
7380 @unnumberedsec Aspect Preelaborate_05
7381 @findex Preelaborate_05
7382 @noindent
7383 This aspect is equivalent to pragma @code{Preelaborate_05}.
7384
7385 @node Aspect Pure_05
7386 @unnumberedsec Aspect Pure_05
7387 @findex Pure_05
7388 @noindent
7389 This aspect is equivalent to pragma @code{Pure_05}.
7390
7391 @node Aspect Pure_12
7392 @unnumberedsec Aspect Pure_12
7393 @findex Pure_12
7394 @noindent
7395 This aspect is equivalent to pragma @code{Pure_12}.
7396
7397 @node Aspect Pure_Function
7398 @unnumberedsec Aspect Pure_Function
7399 @findex Pure_Function
7400 @noindent
7401 This aspect is equivalent to pragma @code{Pure_Function}.
7402
7403 @node Aspect Remote_Access_Type
7404 @unnumberedsec Aspect Remote_Access_Type
7405 @findex Remote_Access_Type
7406 @noindent
7407 This aspect is equivalent to pragma @code{Remote_Access_Type}.
7408
7409 @node Aspect Scalar_Storage_Order
7410 @unnumberedsec Aspect Scalar_Storage_Order
7411 @findex Scalar_Storage_Order
7412 @noindent
7413 This aspect is equivalent to a @code{Scalar_Storage_Order}
7414 attribute definition clause.
7415
7416 @node Aspect Shared
7417 @unnumberedsec Aspect Shared
7418 @findex Shared
7419 @noindent
7420 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
7421 for aspect @code{Atomic}.
7422
7423 @node Aspect Simple_Storage_Pool
7424 @unnumberedsec Aspect Simple_Storage_Pool
7425 @findex Simple_Storage_Pool
7426 @noindent
7427 This aspect is equivalent to a @code{Simple_Storage_Pool}
7428 attribute definition clause.
7429
7430 @node Aspect Simple_Storage_Pool_Type
7431 @unnumberedsec Aspect Simple_Storage_Pool_Type
7432 @findex Simple_Storage_Pool_Type
7433 @noindent
7434 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
7435
7436 @node Aspect Suppress_Debug_Info
7437 @unnumberedsec Aspect Suppress_Debug_Info
7438 @findex Suppress_Debug_Info
7439 @noindent
7440 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
7441
7442 @node Aspect Test_Case
7443 @unnumberedsec Aspect Test_Case
7444 @findex Test_Case
7445 @noindent
7446 This aspect is equivalent to pragma @code{Test_Case}.
7447
7448 @node Aspect Universal_Aliasing
7449 @unnumberedsec Aspect Universal_Aliasing
7450 @findex Universal_Aliasing
7451 @noindent
7452 This aspect is equivalent to pragma @code{Universal_Aliasing}.
7453
7454 @node Aspect Universal_Data
7455 @unnumberedsec Aspect Universal_Data
7456 @findex Universal_Data
7457 @noindent
7458 This aspect is equivalent to pragma @code{Universal_Data}.
7459
7460 @node Aspect Unmodified
7461 @unnumberedsec Aspect Unmodified
7462 @findex Unmodified
7463 @noindent
7464 This aspect is equivalent to pragma @code{Unmodified}.
7465
7466 @node Aspect Unreferenced
7467 @unnumberedsec Aspect Unreferenced
7468 @findex Unreferenced
7469 @noindent
7470 This aspect is equivalent to pragma @code{Unreferenced}.
7471
7472 @node Aspect Unreferenced_Objects
7473 @unnumberedsec Aspect Unreferenced_Objects
7474 @findex Unreferenced_Objects
7475 @noindent
7476 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
7477
7478 @node Aspect Value_Size
7479 @unnumberedsec Aspect Value_Size
7480 @findex Value_Size
7481 @noindent
7482 This aspect is equivalent to a @code{Value_Size}
7483 attribute definition clause.
7484
7485 @node Aspect Warnings
7486 @unnumberedsec Aspect Warnings
7487 @findex Warnings
7488 @noindent
7489 This aspect is equivalent to the two argument form of pragma @code{Warnings},
7490 where the first argument is @code{ON} or @code{OFF} and the second argument
7491 is the entity.
7492
7493 @node Implementation Defined Attributes
7494 @chapter Implementation Defined Attributes
7495 Ada defines (throughout the Ada reference manual,
7496 summarized in Annex K),
7497 a set of attributes that provide useful additional functionality in all
7498 areas of the language.  These language defined attributes are implemented
7499 in GNAT and work as described in the Ada Reference Manual.
7500
7501 In addition, Ada allows implementations to define additional
7502 attributes whose meaning is defined by the implementation.  GNAT provides
7503 a number of these implementation-dependent attributes which can be used
7504 to extend and enhance the functionality of the compiler.  This section of
7505 the GNAT reference manual describes these additional attributes.
7506
7507 Note that any program using these attributes may not be portable to
7508 other compilers (although GNAT implements this set of attributes on all
7509 platforms).  Therefore if portability to other compilers is an important
7510 consideration, you should minimize the use of these attributes.
7511
7512 @menu
7513 * Attribute Abort_Signal::
7514 * Attribute Address_Size::
7515 * Attribute Asm_Input::
7516 * Attribute Asm_Output::
7517 * Attribute AST_Entry::
7518 * Attribute Bit::
7519 * Attribute Bit_Position::
7520 * Attribute Compiler_Version::
7521 * Attribute Code_Address::
7522 * Attribute Default_Bit_Order::
7523 * Attribute Descriptor_Size::
7524 * Attribute Elaborated::
7525 * Attribute Elab_Body::
7526 * Attribute Elab_Spec::
7527 * Attribute Elab_Subp_Body::
7528 * Attribute Emax::
7529 * Attribute Enabled::
7530 * Attribute Enum_Rep::
7531 * Attribute Enum_Val::
7532 * Attribute Epsilon::
7533 * Attribute Fixed_Value::
7534 * Attribute Has_Access_Values::
7535 * Attribute Has_Discriminants::
7536 * Attribute Img::
7537 * Attribute Integer_Value::
7538 * Attribute Invalid_Value::
7539 * Attribute Large::
7540 * Attribute Loop_Entry::
7541 * Attribute Machine_Size::
7542 * Attribute Mantissa::
7543 * Attribute Max_Interrupt_Priority::
7544 * Attribute Max_Priority::
7545 * Attribute Maximum_Alignment::
7546 * Attribute Mechanism_Code::
7547 * Attribute Null_Parameter::
7548 * Attribute Object_Size::
7549 * Attribute Passed_By_Reference::
7550 * Attribute Pool_Address::
7551 * Attribute Range_Length::
7552 * Attribute Ref::
7553 * Attribute Result::
7554 * Attribute Safe_Emax::
7555 * Attribute Safe_Large::
7556 * Attribute Scalar_Storage_Order::
7557 * Attribute Simple_Storage_Pool::
7558 * Attribute Small::
7559 * Attribute Storage_Unit::
7560 * Attribute Stub_Type::
7561 * Attribute System_Allocator_Alignment::
7562 * Attribute Target_Name::
7563 * Attribute Tick::
7564 * Attribute To_Address::
7565 * Attribute Type_Class::
7566 * Attribute UET_Address::
7567 * Attribute Unconstrained_Array::
7568 * Attribute Universal_Literal_String::
7569 * Attribute Unrestricted_Access::
7570 * Attribute Update::
7571 * Attribute Valid_Scalars::
7572 * Attribute VADS_Size::
7573 * Attribute Value_Size::
7574 * Attribute Wchar_T_Size::
7575 * Attribute Word_Size::
7576 @end menu
7577
7578 @node Attribute Abort_Signal
7579 @unnumberedsec Attribute Abort_Signal
7580 @findex Abort_Signal
7581 @noindent
7582 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
7583 prefix) provides the entity for the special exception used to signal
7584 task abort or asynchronous transfer of control.  Normally this attribute
7585 should only be used in the tasking runtime (it is highly peculiar, and
7586 completely outside the normal semantics of Ada, for a user program to
7587 intercept the abort exception).
7588
7589 @node Attribute Address_Size
7590 @unnumberedsec Attribute Address_Size
7591 @cindex Size of @code{Address}
7592 @findex Address_Size
7593 @noindent
7594 @code{Standard'Address_Size} (@code{Standard} is the only allowed
7595 prefix) is a static constant giving the number of bits in an
7596 @code{Address}. It is the same value as System.Address'Size,
7597 but has the advantage of being static, while a direct
7598 reference to System.Address'Size is non-static because Address
7599 is a private type.
7600
7601 @node Attribute Asm_Input
7602 @unnumberedsec Attribute Asm_Input
7603 @findex Asm_Input
7604 @noindent
7605 The @code{Asm_Input} attribute denotes a function that takes two
7606 parameters.  The first is a string, the second is an expression of the
7607 type designated by the prefix.  The first (string) argument is required
7608 to be a static expression, and is the constraint for the parameter,
7609 (e.g.@: what kind of register is required).  The second argument is the
7610 value to be used as the input argument.  The possible values for the
7611 constant are the same as those used in the RTL, and are dependent on
7612 the configuration file used to built the GCC back end.
7613 @ref{Machine Code Insertions}
7614
7615 @node Attribute Asm_Output
7616 @unnumberedsec Attribute Asm_Output
7617 @findex Asm_Output
7618 @noindent
7619 The @code{Asm_Output} attribute denotes a function that takes two
7620 parameters.  The first is a string, the second is the name of a variable
7621 of the type designated by the attribute prefix.  The first (string)
7622 argument is required to be a static expression and designates the
7623 constraint for the parameter (e.g.@: what kind of register is
7624 required).  The second argument is the variable to be updated with the
7625 result.  The possible values for constraint are the same as those used in
7626 the RTL, and are dependent on the configuration file used to build the
7627 GCC back end.  If there are no output operands, then this argument may
7628 either be omitted, or explicitly given as @code{No_Output_Operands}.
7629 @ref{Machine Code Insertions}
7630
7631 @node Attribute AST_Entry
7632 @unnumberedsec Attribute AST_Entry
7633 @cindex OpenVMS
7634 @findex AST_Entry
7635 @noindent
7636 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
7637 the name of an entry, it yields a value of the predefined type AST_Handler
7638 (declared in the predefined package System, as extended by the use of
7639 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
7640 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
7641 Language Reference Manual}, section 9.12a.
7642
7643 @node Attribute Bit
7644 @unnumberedsec Attribute Bit
7645 @findex Bit
7646 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
7647 offset within the storage unit (byte) that contains the first bit of
7648 storage allocated for the object.  The value of this attribute is of the
7649 type @code{Universal_Integer}, and is always a non-negative number not
7650 exceeding the value of @code{System.Storage_Unit}.
7651
7652 For an object that is a variable or a constant allocated in a register,
7653 the value is zero.  (The use of this attribute does not force the
7654 allocation of a variable to memory).
7655
7656 For an object that is a formal parameter, this attribute applies
7657 to either the matching actual parameter or to a copy of the
7658 matching actual parameter.
7659
7660 For an access object the value is zero.  Note that
7661 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
7662 designated object.  Similarly for a record component
7663 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
7664 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
7665 are subject to index checks.
7666
7667 This attribute is designed to be compatible with the DEC Ada 83 definition
7668 and implementation of the @code{Bit} attribute.
7669
7670 @node Attribute Bit_Position
7671 @unnumberedsec Attribute Bit_Position
7672 @findex Bit_Position
7673 @noindent
7674 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
7675 of the fields of the record type, yields the bit
7676 offset within the record contains the first bit of
7677 storage allocated for the object.  The value of this attribute is of the
7678 type @code{Universal_Integer}.  The value depends only on the field
7679 @var{C} and is independent of the alignment of
7680 the containing record @var{R}.
7681
7682 @node Attribute Compiler_Version
7683 @unnumberedsec Attribute Compiler_Version
7684 @findex Compiler_Version
7685 @noindent
7686 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
7687 prefix) yields a static string identifying the version of the compiler
7688 being used to compile the unit containing the attribute reference. A
7689 typical result would be something like "@value{EDITION} @i{version} (20090221)".
7690
7691 @node Attribute Code_Address
7692 @unnumberedsec Attribute Code_Address
7693 @findex Code_Address
7694 @cindex Subprogram address
7695 @cindex Address of subprogram code
7696 @noindent
7697 The @code{'Address}
7698 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
7699 intended effect seems to be to provide
7700 an address value which can be used to call the subprogram by means of
7701 an address clause as in the following example:
7702
7703 @smallexample @c ada
7704 procedure K is @dots{}
7705
7706 procedure L;
7707 for L'Address use K'Address;
7708 pragma Import (Ada, L);
7709 @end smallexample
7710
7711 @noindent
7712 A call to @code{L} is then expected to result in a call to @code{K}@.
7713 In Ada 83, where there were no access-to-subprogram values, this was
7714 a common work-around for getting the effect of an indirect call.
7715 GNAT implements the above use of @code{Address} and the technique
7716 illustrated by the example code works correctly.
7717
7718 However, for some purposes, it is useful to have the address of the start
7719 of the generated code for the subprogram.  On some architectures, this is
7720 not necessarily the same as the @code{Address} value described above.
7721 For example, the @code{Address} value may reference a subprogram
7722 descriptor rather than the subprogram itself.
7723
7724 The @code{'Code_Address} attribute, which can only be applied to
7725 subprogram entities, always returns the address of the start of the
7726 generated code of the specified subprogram, which may or may not be
7727 the same value as is returned by the corresponding @code{'Address}
7728 attribute.
7729
7730 @node Attribute Default_Bit_Order
7731 @unnumberedsec Attribute Default_Bit_Order
7732 @cindex Big endian
7733 @cindex Little endian
7734 @findex Default_Bit_Order
7735 @noindent
7736 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
7737 permissible prefix), provides the value @code{System.Default_Bit_Order}
7738 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
7739 @code{Low_Order_First}).  This is used to construct the definition of
7740 @code{Default_Bit_Order} in package @code{System}.
7741
7742 @node Attribute Descriptor_Size
7743 @unnumberedsec Attribute Descriptor_Size
7744 @cindex Descriptor
7745 @cindex Dope vector
7746 @findex Descriptor_Size
7747 @noindent
7748 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
7749 descriptor allocated for a type.  The result is non-zero only for unconstrained
7750 array types and the returned value is of type universal integer.  In GNAT, an
7751 array descriptor contains bounds information and is located immediately before
7752 the first element of the array.
7753
7754 @smallexample @c ada
7755 type Unconstr_Array is array (Positive range <>) of Boolean;
7756 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
7757 @end smallexample
7758
7759 @noindent
7760 The attribute takes into account any additional padding due to type alignment.
7761 In the example above, the descriptor contains two values of type
7762 @code{Positive} representing the low and high bound.  Since @code{Positive} has
7763 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
7764 Positive'Size + 2} or 64 bits.
7765
7766 @node Attribute Elaborated
7767 @unnumberedsec Attribute Elaborated
7768 @findex Elaborated
7769 @noindent
7770 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
7771 value is a Boolean which indicates whether or not the given unit has been
7772 elaborated.  This attribute is primarily intended for internal use by the
7773 generated code for dynamic elaboration checking, but it can also be used
7774 in user programs.  The value will always be True once elaboration of all
7775 units has been completed.  An exception is for units which need no
7776 elaboration, the value is always False for such units.
7777
7778 @node Attribute Elab_Body
7779 @unnumberedsec Attribute Elab_Body
7780 @findex Elab_Body
7781 @noindent
7782 This attribute can only be applied to a program unit name.  It returns
7783 the entity for the corresponding elaboration procedure for elaborating
7784 the body of the referenced unit.  This is used in the main generated
7785 elaboration procedure by the binder and is not normally used in any
7786 other context.  However, there may be specialized situations in which it
7787 is useful to be able to call this elaboration procedure from Ada code,
7788 e.g.@: if it is necessary to do selective re-elaboration to fix some
7789 error.
7790
7791 @node Attribute Elab_Spec
7792 @unnumberedsec Attribute Elab_Spec
7793 @findex Elab_Spec
7794 @noindent
7795 This attribute can only be applied to a program unit name.  It returns
7796 the entity for the corresponding elaboration procedure for elaborating
7797 the spec of the referenced unit.  This is used in the main
7798 generated elaboration procedure by the binder and is not normally used
7799 in any other context.  However, there may be specialized situations in
7800 which it is useful to be able to call this elaboration procedure from
7801 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
7802 some error.
7803
7804 @node Attribute Elab_Subp_Body
7805 @unnumberedsec Attribute Elab_Subp_Body
7806 @findex Elab_Subp_Body
7807 @noindent
7808 This attribute can only be applied to a library level subprogram
7809 name and is only allowed in CodePeer mode. It returns the entity
7810 for the corresponding elaboration procedure for elaborating the body
7811 of the referenced subprogram unit. This is used in the main generated
7812 elaboration procedure by the binder in CodePeer mode only and is unrecognized
7813 otherwise.
7814
7815 @node Attribute Emax
7816 @unnumberedsec Attribute Emax
7817 @cindex Ada 83 attributes
7818 @findex Emax
7819 @noindent
7820 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
7821 the Ada 83 reference manual for an exact description of the semantics of
7822 this attribute.
7823
7824 @node Attribute Enabled
7825 @unnumberedsec Attribute Enabled
7826 @findex Enabled
7827 @noindent
7828 The @code{Enabled} attribute allows an application program to check at compile
7829 time to see if the designated check is currently enabled. The prefix is a
7830 simple identifier, referencing any predefined check name (other than
7831 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
7832 no argument is given for the attribute, the check is for the general state
7833 of the check, if an argument is given, then it is an entity name, and the
7834 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
7835 given naming the entity (if not, then the argument is ignored).
7836
7837 Note that instantiations inherit the check status at the point of the
7838 instantiation, so a useful idiom is to have a library package that
7839 introduces a check name with @code{pragma Check_Name}, and then contains
7840 generic packages or subprograms which use the @code{Enabled} attribute
7841 to see if the check is enabled. A user of this package can then issue
7842 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
7843 the package or subprogram, controlling whether the check will be present.
7844
7845 @node Attribute Enum_Rep
7846 @unnumberedsec Attribute Enum_Rep
7847 @cindex Representation of enums
7848 @findex Enum_Rep
7849 @noindent
7850 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
7851 function with the following spec:
7852
7853 @smallexample @c ada
7854 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
7855   return @i{Universal_Integer};
7856 @end smallexample
7857
7858 @noindent
7859 It is also allowable to apply @code{Enum_Rep} directly to an object of an
7860 enumeration type or to a non-overloaded enumeration
7861 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
7862 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
7863 enumeration literal or object.
7864
7865 The function returns the representation value for the given enumeration
7866 value.  This will be equal to value of the @code{Pos} attribute in the
7867 absence of an enumeration representation clause.  This is a static
7868 attribute (i.e.@: the result is static if the argument is static).
7869
7870 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
7871 in which case it simply returns the integer value.  The reason for this
7872 is to allow it to be used for @code{(<>)} discrete formal arguments in
7873 a generic unit that can be instantiated with either enumeration types
7874 or integer types.  Note that if @code{Enum_Rep} is used on a modular
7875 type whose upper bound exceeds the upper bound of the largest signed
7876 integer type, and the argument is a variable, so that the universal
7877 integer calculation is done at run time, then the call to @code{Enum_Rep}
7878 may raise @code{Constraint_Error}.
7879
7880 @node Attribute Enum_Val
7881 @unnumberedsec Attribute Enum_Val
7882 @cindex Representation of enums
7883 @findex Enum_Val
7884 @noindent
7885 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
7886 function with the following spec:
7887
7888 @smallexample @c ada
7889 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
7890   return @var{S}'Base};
7891 @end smallexample
7892
7893 @noindent
7894 The function returns the enumeration value whose representation matches the
7895 argument, or raises Constraint_Error if no enumeration literal of the type
7896 has the matching value.
7897 This will be equal to value of the @code{Val} attribute in the
7898 absence of an enumeration representation clause.  This is a static
7899 attribute (i.e.@: the result is static if the argument is static).
7900
7901 @node Attribute Epsilon
7902 @unnumberedsec Attribute Epsilon
7903 @cindex Ada 83 attributes
7904 @findex Epsilon
7905 @noindent
7906 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
7907 the Ada 83 reference manual for an exact description of the semantics of
7908 this attribute.
7909
7910 @node Attribute Fixed_Value
7911 @unnumberedsec Attribute Fixed_Value
7912 @findex Fixed_Value
7913 @noindent
7914 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
7915 function with the following specification:
7916
7917 @smallexample @c ada
7918 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
7919   return @var{S};
7920 @end smallexample
7921
7922 @noindent
7923 The value returned is the fixed-point value @var{V} such that
7924
7925 @smallexample @c ada
7926 @var{V} = Arg * @var{S}'Small
7927 @end smallexample
7928
7929 @noindent
7930 The effect is thus similar to first converting the argument to the
7931 integer type used to represent @var{S}, and then doing an unchecked
7932 conversion to the fixed-point type.  The difference is
7933 that there are full range checks, to ensure that the result is in range.
7934 This attribute is primarily intended for use in implementation of the
7935 input-output functions for fixed-point values.
7936
7937 @node Attribute Has_Access_Values
7938 @unnumberedsec Attribute Has_Access_Values
7939 @cindex Access values, testing for
7940 @findex Has_Access_Values
7941 @noindent
7942 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
7943 is a Boolean value which is True if the is an access type, or is a composite
7944 type with a component (at any nesting depth) that is an access type, and is
7945 False otherwise.
7946 The intended use of this attribute is in conjunction with generic
7947 definitions.  If the attribute is applied to a generic private type, it
7948 indicates whether or not the corresponding actual type has access values.
7949
7950 @node Attribute Has_Discriminants
7951 @unnumberedsec Attribute Has_Discriminants
7952 @cindex Discriminants, testing for
7953 @findex Has_Discriminants
7954 @noindent
7955 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
7956 is a Boolean value which is True if the type has discriminants, and False
7957 otherwise.  The intended use of this attribute is in conjunction with generic
7958 definitions.  If the attribute is applied to a generic private type, it
7959 indicates whether or not the corresponding actual type has discriminants.
7960
7961 @node Attribute Img
7962 @unnumberedsec Attribute Img
7963 @findex Img
7964 @noindent
7965 The @code{Img} attribute differs from @code{Image} in that it may be
7966 applied to objects as well as types, in which case it gives the
7967 @code{Image} for the subtype of the object.  This is convenient for
7968 debugging:
7969
7970 @smallexample @c ada
7971 Put_Line ("X = " & X'Img);
7972 @end smallexample
7973
7974 @noindent
7975 has the same meaning as the more verbose:
7976
7977 @smallexample @c ada
7978 Put_Line ("X = " & @var{T}'Image (X));
7979 @end smallexample
7980
7981 @noindent
7982 where @var{T} is the (sub)type of the object @code{X}.
7983
7984 @node Attribute Integer_Value
7985 @unnumberedsec Attribute Integer_Value
7986 @findex Integer_Value
7987 @noindent
7988 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
7989 function with the following spec:
7990
7991 @smallexample @c ada
7992 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
7993   return @var{S};
7994 @end smallexample
7995
7996 @noindent
7997 The value returned is the integer value @var{V}, such that
7998
7999 @smallexample @c ada
8000 Arg = @var{V} * @var{T}'Small
8001 @end smallexample
8002
8003 @noindent
8004 where @var{T} is the type of @code{Arg}.
8005 The effect is thus similar to first doing an unchecked conversion from
8006 the fixed-point type to its corresponding implementation type, and then
8007 converting the result to the target integer type.  The difference is
8008 that there are full range checks, to ensure that the result is in range.
8009 This attribute is primarily intended for use in implementation of the
8010 standard input-output functions for fixed-point values.
8011
8012 @node Attribute Invalid_Value
8013 @unnumberedsec Attribute Invalid_Value
8014 @findex Invalid_Value
8015 @noindent
8016 For every scalar type S, S'Invalid_Value returns an undefined value of the
8017 type. If possible this value is an invalid representation for the type. The
8018 value returned is identical to the value used to initialize an otherwise
8019 uninitialized value of the type if pragma Initialize_Scalars is used,
8020 including the ability to modify the value with the binder -Sxx flag and
8021 relevant environment variables at run time.
8022
8023 @node Attribute Large
8024 @unnumberedsec Attribute Large
8025 @cindex Ada 83 attributes
8026 @findex Large
8027 @noindent
8028 The @code{Large} attribute is provided for compatibility with Ada 83.  See
8029 the Ada 83 reference manual for an exact description of the semantics of
8030 this attribute.
8031
8032 @node Attribute Loop_Entry
8033 @unnumberedsec Attribute Loop_Entry
8034 @findex Loop_Entry
8035 @noindent
8036 Syntax:
8037
8038 @smallexample @c ada
8039 X'Loop_Entry [(loop_name)]
8040 @end smallexample
8041
8042 @noindent
8043 The @code{Loop_Entry} attribute is used to refer to the value that an
8044 expression had upon entry to a given loop in much the same way that the
8045 @code{Old} attribute in a subprogram postcondition can be used to refer
8046 to the value an expression had upon entry to the subprogram. The
8047 relevant loop is either identified by the given loop name, or it is the
8048 innermost enclosing loop when no loop name is given.
8049
8050 @noindent
8051 A @code{Loop_Entry} attribute can only occur within a
8052 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8053 @code{Loop_Entry} is to compare the current value of objects with their
8054 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8055
8056 @noindent
8057 The effect of using @code{X'Loop_Entry} is the same as declaring
8058 a constant initialized with the initial value of @code{X} at loop
8059 entry. This copy is not performed if the loop is not entered, or if the
8060 corresponding pragmas are ignored or disabled.
8061
8062 @node Attribute Machine_Size
8063 @unnumberedsec Attribute Machine_Size
8064 @findex Machine_Size
8065 @noindent
8066 This attribute is identical to the @code{Object_Size} attribute.  It is
8067 provided for compatibility with the DEC Ada 83 attribute of this name.
8068
8069 @node Attribute Mantissa
8070 @unnumberedsec Attribute Mantissa
8071 @cindex Ada 83 attributes
8072 @findex Mantissa
8073 @noindent
8074 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
8075 the Ada 83 reference manual for an exact description of the semantics of
8076 this attribute.
8077
8078 @node Attribute Max_Interrupt_Priority
8079 @unnumberedsec Attribute Max_Interrupt_Priority
8080 @cindex Interrupt priority, maximum
8081 @findex Max_Interrupt_Priority
8082 @noindent
8083 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8084 permissible prefix), provides the same value as
8085 @code{System.Max_Interrupt_Priority}.
8086
8087 @node Attribute Max_Priority
8088 @unnumberedsec Attribute Max_Priority
8089 @cindex Priority, maximum
8090 @findex Max_Priority
8091 @noindent
8092 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8093 prefix) provides the same value as @code{System.Max_Priority}.
8094
8095 @node Attribute Maximum_Alignment
8096 @unnumberedsec Attribute Maximum_Alignment
8097 @cindex Alignment, maximum
8098 @findex Maximum_Alignment
8099 @noindent
8100 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8101 permissible prefix) provides the maximum useful alignment value for the
8102 target.  This is a static value that can be used to specify the alignment
8103 for an object, guaranteeing that it is properly aligned in all
8104 cases.
8105
8106 @node Attribute Mechanism_Code
8107 @unnumberedsec Attribute Mechanism_Code
8108 @cindex Return values, passing mechanism
8109 @cindex Parameters, passing mechanism
8110 @findex Mechanism_Code
8111 @noindent
8112 @code{@var{function}'Mechanism_Code} yields an integer code for the
8113 mechanism used for the result of function, and
8114 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8115 used for formal parameter number @var{n} (a static integer value with 1
8116 meaning the first parameter) of @var{subprogram}.  The code returned is:
8117
8118 @table @asis
8119 @item 1
8120 by copy (value)
8121 @item 2
8122 by reference
8123 @item 3
8124 by descriptor (default descriptor class)
8125 @item 4
8126 by descriptor (UBS: unaligned bit string)
8127 @item 5
8128 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8129 @item 6
8130 by descriptor (UBA: unaligned bit array)
8131 @item 7
8132 by descriptor (S: string, also scalar access type parameter)
8133 @item 8
8134 by descriptor (SB: string with arbitrary bounds)
8135 @item 9
8136 by descriptor (A: contiguous array)
8137 @item 10
8138 by descriptor (NCA: non-contiguous array)
8139 @end table
8140
8141 @noindent
8142 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
8143 @cindex OpenVMS
8144
8145 @node Attribute Null_Parameter
8146 @unnumberedsec Attribute Null_Parameter
8147 @cindex Zero address, passing
8148 @findex Null_Parameter
8149 @noindent
8150 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
8151 type or subtype @var{T} allocated at machine address zero.  The attribute
8152 is allowed only as the default expression of a formal parameter, or as
8153 an actual expression of a subprogram call.  In either case, the
8154 subprogram must be imported.
8155
8156 The identity of the object is represented by the address zero in the
8157 argument list, independent of the passing mechanism (explicit or
8158 default).
8159
8160 This capability is needed to specify that a zero address should be
8161 passed for a record or other composite object passed by reference.
8162 There is no way of indicating this without the @code{Null_Parameter}
8163 attribute.
8164
8165 @node Attribute Object_Size
8166 @unnumberedsec Attribute Object_Size
8167 @cindex Size, used for objects
8168 @findex Object_Size
8169 @noindent
8170 The size of an object is not necessarily the same as the size of the type
8171 of an object.  This is because by default object sizes are increased to be
8172 a multiple of the alignment of the object.  For example,
8173 @code{Natural'Size} is
8174 31, but by default objects of type @code{Natural} will have a size of 32 bits.
8175 Similarly, a record containing an integer and a character:
8176
8177 @smallexample @c ada
8178 type Rec is record
8179    I : Integer;
8180    C : Character;
8181 end record;
8182 @end smallexample
8183
8184 @noindent
8185 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
8186 alignment will be 4, because of the
8187 integer field, and so the default size of record objects for this type
8188 will be 64 (8 bytes).
8189
8190 @node Attribute Passed_By_Reference
8191 @unnumberedsec Attribute Passed_By_Reference
8192 @cindex Parameters, when passed by reference
8193 @findex Passed_By_Reference
8194 @noindent
8195 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
8196 a value of type @code{Boolean} value that is @code{True} if the type is
8197 normally passed by reference and @code{False} if the type is normally
8198 passed by copy in calls.  For scalar types, the result is always @code{False}
8199 and is static.  For non-scalar types, the result is non-static.
8200
8201 @node Attribute Pool_Address
8202 @unnumberedsec Attribute Pool_Address
8203 @cindex Parameters, when passed by reference
8204 @findex Pool_Address
8205 @noindent
8206 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
8207 of X within its storage pool. This is the same as
8208 @code{@var{X}'Address}, except that for an unconstrained array whose
8209 bounds are allocated just before the first component,
8210 @code{@var{X}'Pool_Address} returns the address of those bounds,
8211 whereas @code{@var{X}'Address} returns the address of the first
8212 component.
8213
8214 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
8215 the object is allocated'', which could be a user-defined storage pool,
8216 the global heap, on the stack, or in a static memory area. For an
8217 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
8218 what is passed to @code{Allocate} and returned from @code{Deallocate}.
8219
8220 @node Attribute Range_Length
8221 @unnumberedsec Attribute Range_Length
8222 @findex Range_Length
8223 @noindent
8224 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
8225 the number of values represented by the subtype (zero for a null
8226 range).  The result is static for static subtypes.  @code{Range_Length}
8227 applied to the index subtype of a one dimensional array always gives the
8228 same result as @code{Length} applied to the array itself.
8229
8230 @node Attribute Ref
8231 @unnumberedsec Attribute Ref
8232 @findex Ref
8233 @noindent
8234 The @code{System.Address'Ref}
8235 (@code{System.Address} is the only permissible prefix)
8236 denotes a function identical to
8237 @code{System.Storage_Elements.To_Address} except that
8238 it is a static attribute.  See @ref{Attribute To_Address} for more details.
8239
8240 @node Attribute Result
8241 @unnumberedsec Attribute Result
8242 @findex Result
8243 @noindent
8244 @code{@var{function}'Result} can only be used with in a Postcondition pragma
8245 for a function. The prefix must be the name of the corresponding function. This
8246 is used to refer to the result of the function in the postcondition expression.
8247 For a further discussion of the use of this attribute and examples of its use,
8248 see the description of pragma Postcondition.
8249
8250 @node Attribute Safe_Emax
8251 @unnumberedsec Attribute Safe_Emax
8252 @cindex Ada 83 attributes
8253 @findex Safe_Emax
8254 @noindent
8255 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
8256 the Ada 83 reference manual for an exact description of the semantics of
8257 this attribute.
8258
8259 @node Attribute Safe_Large
8260 @unnumberedsec Attribute Safe_Large
8261 @cindex Ada 83 attributes
8262 @findex Safe_Large
8263 @noindent
8264 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
8265 the Ada 83 reference manual for an exact description of the semantics of
8266 this attribute.
8267
8268 @node Attribute Scalar_Storage_Order
8269 @unnumberedsec Attribute Scalar_Storage_Order
8270 @cindex Endianness
8271 @cindex Scalar storage order
8272 @findex Scalar_Storage_Order
8273 @noindent
8274 For every array or record type @var{S}, the representation attribute
8275 @code{Scalar_Storage_Order} denotes the order in which storage elements
8276 that make up scalar components are ordered within S:
8277
8278 @smallexample @c ada
8279    --  Component type definitions
8280
8281    subtype Yr_Type is Natural range 0 .. 127;
8282    subtype Mo_Type is Natural range 1 .. 12;
8283    subtype Da_Type is Natural range 1 .. 31;
8284
8285    --  Record declaration
8286
8287    type Date is record
8288       Years_Since_1980 : Yr_Type;
8289       Month            : Mo_Type;
8290       Day_Of_Month     : Da_Type;
8291    end record;
8292
8293    --  Record representation clause
8294
8295    for Date use record
8296       Years_Since_1980 at 0 range 0  ..  6;
8297       Month            at 0 range 7  .. 10;
8298       Day_Of_Month     at 0 range 11 .. 15;
8299    end record;
8300
8301    --  Attribute definition clauses
8302
8303    for Date'Bit_Order use System.High_Order_First;
8304    for Date'Scalar_Storage_Order use System.High_Order_First;
8305    --  If Scalar_Storage_Order is specified, it must be consistent with
8306    --  Bit_Order, so it's best to always define the latter explicitly if
8307    --  the former is used.
8308 @end smallexample
8309
8310 Other properties are
8311 as for standard representation attribute @code{Bit_Order}, as defined by
8312 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
8313
8314 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
8315 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
8316 this means that if a @code{Scalar_Storage_Order} attribute definition
8317 clause is not confirming, then the type's @code{Bit_Order} shall be
8318 specified explicitly and set to the same value.
8319
8320 For a record extension, the derived type shall have the same scalar storage
8321 order as the parent type.
8322
8323 If a component of @var{S} has itself a record or array type, then it shall also
8324 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
8325 if the component does not start on a byte boundary, then the scalar storage
8326 order specified for S and for the nested component type shall be identical.
8327
8328 No component of a type that has a @code{Scalar_Storage_Order} attribute
8329 definition may be aliased.
8330
8331 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
8332 with a value equal to @code{System.Default_Bit_Order}) has no effect.
8333
8334 If the opposite storage order is specified, then whenever the value of
8335 a scalar component of an object of type @var{S} is read, the storage
8336 elements of the enclosing machine scalar are first reversed (before
8337 retrieving the component value, possibly applying some shift and mask
8338 operatings on the enclosing machine scalar), and the opposite operation
8339 is done for writes.
8340
8341 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
8342 are relaxed. Instead, the following rules apply:
8343
8344 @itemize @bullet
8345 @item the underlying storage elements are those at positions
8346   @code{(position + first_bit / storage_element_size) ..
8347         (position + (last_bit + storage_element_size - 1) /
8348                     storage_element_size)}
8349 @item the sequence of underlying storage elements shall have
8350         a size no greater than the largest machine scalar
8351 @item the enclosing machine scalar is defined as the smallest machine
8352         scalar starting at a position no greater than
8353         @code{position + first_bit / storage_element_size} and covering
8354         storage elements at least up to @code{position + (last_bit +
8355         storage_element_size - 1) / storage_element_size}
8356 @item the position of the component is interpreted relative to that machine
8357  scalar.
8358
8359 @end itemize
8360
8361 @node Attribute Simple_Storage_Pool
8362 @unnumberedsec Attribute Simple_Storage_Pool
8363 @cindex Storage pool, simple
8364 @cindex Simple storage pool
8365 @findex Simple_Storage_Pool
8366 @noindent
8367 For every nonformal, nonderived access-to-object type @var{Acc}, the
8368 representation attribute @code{Simple_Storage_Pool} may be specified
8369 via an attribute_definition_clause (or by specifying the equivalent aspect):
8370
8371 @smallexample @c ada
8372
8373 My_Pool : My_Simple_Storage_Pool_Type;
8374
8375 type Acc is access My_Data_Type;
8376
8377 for Acc'Simple_Storage_Pool use My_Pool;
8378
8379 @end smallexample
8380
8381 @noindent
8382 The name given in an attribute_definition_clause for the
8383 @code{Simple_Storage_Pool} attribute shall denote a variable of
8384 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
8385
8386 The use of this attribute is only allowed for a prefix denoting a type
8387 for which it has been specified. The type of the attribute is the type
8388 of the variable specified as the simple storage pool of the access type,
8389 and the attribute denotes that variable.
8390
8391 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
8392 for the same access type.
8393
8394 If the @code{Simple_Storage_Pool} attribute has been specified for an access
8395 type, then applying the @code{Storage_Pool} attribute to the type is flagged
8396 with a warning and its evaluation raises the exception @code{Program_Error}.
8397
8398 If the Simple_Storage_Pool attribute has been specified for an access
8399 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
8400 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
8401 which is intended to indicate the number of storage elements reserved for
8402 the simple storage pool. If the Storage_Size function has not been defined
8403 for the simple storage pool type, then this attribute returns zero.
8404
8405 If an access type @var{S} has a specified simple storage pool of type
8406 @var{SSP}, then the evaluation of an allocator for that access type calls
8407 the primitive @code{Allocate} procedure for type @var{SSP}, passing
8408 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
8409 semantics of such allocators is the same as those defined for allocators
8410 in section 13.11 of the Ada Reference Manual, with the term
8411 ``simple storage pool'' substituted for ``storage pool''.
8412
8413 If an access type @var{S} has a specified simple storage pool of type
8414 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
8415 for that access type invokes the primitive @code{Deallocate} procedure
8416 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
8417 parameter. The detailed semantics of such unchecked deallocations is the same
8418 as defined in section 13.11.2 of the Ada Reference Manual, except that the
8419 term ``simple storage pool'' is substituted for ``storage pool''.
8420
8421 @node Attribute Small
8422 @unnumberedsec Attribute Small
8423 @cindex Ada 83 attributes
8424 @findex Small
8425 @noindent
8426 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
8427 fixed-point types.
8428 GNAT also allows this attribute to be applied to floating-point types
8429 for compatibility with Ada 83.  See
8430 the Ada 83 reference manual for an exact description of the semantics of
8431 this attribute when applied to floating-point types.
8432
8433 @node Attribute Storage_Unit
8434 @unnumberedsec Attribute Storage_Unit
8435 @findex Storage_Unit
8436 @noindent
8437 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
8438 prefix) provides the same value as @code{System.Storage_Unit}.
8439
8440 @node Attribute Stub_Type
8441 @unnumberedsec Attribute Stub_Type
8442 @findex Stub_Type
8443 @noindent
8444 The GNAT implementation of remote access-to-classwide types is
8445 organized as described in AARM section E.4 (20.t): a value of an RACW type
8446 (designating a remote object) is represented as a normal access
8447 value, pointing to a "stub" object which in turn contains the
8448 necessary information to contact the designated remote object. A
8449 call on any dispatching operation of such a stub object does the
8450 remote call, if necessary, using the information in the stub object
8451 to locate the target partition, etc.
8452
8453 For a prefix @code{T} that denotes a remote access-to-classwide type,
8454 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
8455
8456 By construction, the layout of @code{T'Stub_Type} is identical to that of
8457 type @code{RACW_Stub_Type} declared in the internal implementation-defined
8458 unit @code{System.Partition_Interface}. Use of this attribute will create
8459 an implicit dependency on this unit.
8460
8461 @node Attribute System_Allocator_Alignment
8462 @unnumberedsec Attribute System_Allocator_Alignment
8463 @cindex Alignment, allocator
8464 @findex System_Allocator_Alignment
8465 @noindent
8466 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
8467 permissible prefix) provides the observable guaranted to be honored by
8468 the system allocator (malloc). This is a static value that can be used
8469 in user storage pools based on malloc either to reject allocation
8470 with alignment too large or to enable a realignment circuitry if the
8471 alignment request is larger than this value.
8472
8473 @node Attribute Target_Name
8474 @unnumberedsec Attribute Target_Name
8475 @findex Target_Name
8476 @noindent
8477 @code{Standard'Target_Name} (@code{Standard} is the only permissible
8478 prefix) provides a static string value that identifies the target
8479 for the current compilation. For GCC implementations, this is the
8480 standard gcc target name without the terminating slash (for
8481 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
8482
8483 @node Attribute Tick
8484 @unnumberedsec Attribute Tick
8485 @findex Tick
8486 @noindent
8487 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
8488 provides the same value as @code{System.Tick},
8489
8490 @node Attribute To_Address
8491 @unnumberedsec Attribute To_Address
8492 @findex To_Address
8493 @noindent
8494 The @code{System'To_Address}
8495 (@code{System} is the only permissible prefix)
8496 denotes a function identical to
8497 @code{System.Storage_Elements.To_Address} except that
8498 it is a static attribute.  This means that if its argument is
8499 a static expression, then the result of the attribute is a
8500 static expression.  The result is that such an expression can be
8501 used in contexts (e.g.@: preelaborable packages) which require a
8502 static expression and where the function call could not be used
8503 (since the function call is always non-static, even if its
8504 argument is static).
8505
8506 @node Attribute Type_Class
8507 @unnumberedsec Attribute Type_Class
8508 @findex Type_Class
8509 @noindent
8510 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
8511 the value of the type class for the full type of @var{type}.  If
8512 @var{type} is a generic formal type, the value is the value for the
8513 corresponding actual subtype.  The value of this attribute is of type
8514 @code{System.Aux_DEC.Type_Class}, which has the following definition:
8515
8516 @smallexample @c ada
8517   type Type_Class is
8518     (Type_Class_Enumeration,
8519      Type_Class_Integer,
8520      Type_Class_Fixed_Point,
8521      Type_Class_Floating_Point,
8522      Type_Class_Array,
8523      Type_Class_Record,
8524      Type_Class_Access,
8525      Type_Class_Task,
8526      Type_Class_Address);
8527 @end smallexample
8528
8529 @noindent
8530 Protected types yield the value @code{Type_Class_Task}, which thus
8531 applies to all concurrent types.  This attribute is designed to
8532 be compatible with the DEC Ada 83 attribute of the same name.
8533
8534 @node Attribute UET_Address
8535 @unnumberedsec Attribute UET_Address
8536 @findex UET_Address
8537 @noindent
8538 The @code{UET_Address} attribute can only be used for a prefix which
8539 denotes a library package.  It yields the address of the unit exception
8540 table when zero cost exception handling is used.  This attribute is
8541 intended only for use within the GNAT implementation.  See the unit
8542 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
8543 for details on how this attribute is used in the implementation.
8544
8545 @node Attribute Unconstrained_Array
8546 @unnumberedsec Attribute Unconstrained_Array
8547 @findex Unconstrained_Array
8548 @noindent
8549 The @code{Unconstrained_Array} attribute can be used with a prefix that
8550 denotes any type or subtype. It is a static attribute that yields
8551 @code{True} if the prefix designates an unconstrained array,
8552 and @code{False} otherwise. In a generic instance, the result is
8553 still static, and yields the result of applying this test to the
8554 generic actual.
8555
8556 @node Attribute Universal_Literal_String
8557 @unnumberedsec Attribute Universal_Literal_String
8558 @cindex Named numbers, representation of
8559 @findex Universal_Literal_String
8560 @noindent
8561 The prefix of @code{Universal_Literal_String} must be a named
8562 number.  The static result is the string consisting of the characters of
8563 the number as defined in the original source.  This allows the user
8564 program to access the actual text of named numbers without intermediate
8565 conversions and without the need to enclose the strings in quotes (which
8566 would preclude their use as numbers).
8567
8568 For example, the following program prints the first 50 digits of pi:
8569
8570 @smallexample @c ada
8571 with Text_IO; use Text_IO;
8572 with Ada.Numerics;
8573 procedure Pi is
8574 begin
8575    Put (Ada.Numerics.Pi'Universal_Literal_String);
8576 end;
8577 @end smallexample
8578
8579 @node Attribute Unrestricted_Access
8580 @unnumberedsec Attribute Unrestricted_Access
8581 @cindex @code{Access}, unrestricted
8582 @findex Unrestricted_Access
8583 @noindent
8584 The @code{Unrestricted_Access} attribute is similar to @code{Access}
8585 except that all accessibility and aliased view checks are omitted.  This
8586 is a user-beware attribute.  It is similar to
8587 @code{Address}, for which it is a desirable replacement where the value
8588 desired is an access type.  In other words, its effect is identical to
8589 first applying the @code{Address} attribute and then doing an unchecked
8590 conversion to a desired access type.  In GNAT, but not necessarily in
8591 other implementations, the use of static chains for inner level
8592 subprograms means that @code{Unrestricted_Access} applied to a
8593 subprogram yields a value that can be called as long as the subprogram
8594 is in scope (normal Ada accessibility rules restrict this usage).
8595
8596 It is possible to use @code{Unrestricted_Access} for any type, but care
8597 must be exercised if it is used to create pointers to unconstrained
8598 objects. In this case, the resulting pointer has the same scope as the
8599 context of the attribute, and may not be returned to some enclosing
8600 scope. For instance, a function cannot use @code{Unrestricted_Access}
8601 to create a unconstrained pointer and then return that value to the
8602 caller.
8603
8604 @node Attribute Update
8605 @unnumberedsec Attribute Update
8606 @findex Update
8607 @noindent
8608 The @code{Update} attribute creates a copy of an array or record value
8609 with one or more modified components. The syntax is:
8610
8611 @smallexample @c ada
8612 PREFIX'Update (AGGREGATE);
8613 @end smallexample
8614
8615 @noindent
8616 where @code{PREFIX} is the name of an array or record object, and
8617 @code{AGGREGATE} is a named aggregate that does not contain an @code{others}
8618 choice. The effect is to yield a copy of the array or record value which
8619 is unchanged apart from the components mentioned in the aggregate, which
8620 are changed to the indicated value. The original value of the array or
8621 record value is not affected. For example:
8622
8623 @smallexample @c ada
8624 type Arr is Array (1 .. 5) of Integer;
8625 ...
8626 Avar1 : Arr := (1,2,3,4,5);
8627 Avar2 : Arr := Avar1'Update ((2 => 10, 3 .. 4 => 20));
8628 @end smallexample
8629
8630 @noindent
8631 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
8632 begin unmodified. Similarly:
8633
8634 @smallexample @c ada
8635 type Rec is A, B, C : Integer;
8636 ...
8637 Rvar1 : Rec := (A => 1, B => 2, C => 3);
8638 Rvar2 : Rec := Rvar1'Update ((B => 20));
8639 @end smallexample
8640
8641 @noindent
8642 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
8643 with @code{Rvar1} being unmodifed.
8644 Note that the value of the attribute reference is computed
8645 completely before it is used. This means that if you write:
8646
8647 @smallexample @c ada
8648 Avar1 := Avar1'Update ((1 => 10, 2 => Function_Call));
8649 @end smallexample
8650
8651 @noindent
8652 then the value of @code{Avar1} is not modified if @code{Function_Call}
8653 raises an exception, unlike the effect of a series of direct assignments
8654 to elements of @code{Avar1}. In general this requires that
8655 two extra complete copies of the object are required, which should be
8656 kept in mind when considering efficiency.
8657
8658 The @code{Update} attribute cannot be applied to prefixes of a limited
8659 type, and cannot reference discriminants in the case of a record type.
8660
8661 In the record case, no component can be mentioned more than once. In
8662 the array case, two overlapping ranges can appear in the aggregate,
8663 in which case the modifications are processed left to right.
8664
8665 Multi-dimensional arrays can be modified, as shown by this example:
8666
8667 @smallexample @c ada
8668 A : array (1 .. 10, 1 .. 10) of Integer;
8669 ..
8670 A := A'Update (1 => (2 => 20), 3 => (4 => 30));
8671 @end smallexample
8672
8673 @noindent
8674 which changes element (1,2) to 20 and (3,4) to 30.
8675
8676 @node Attribute Valid_Scalars
8677 @unnumberedsec Attribute Valid_Scalars
8678 @findex Valid_Scalars
8679 @noindent
8680 The @code{'Valid_Scalars} attribute is intended to make it easier to
8681 check the validity of scalar subcomponents of composite objects. It
8682 is defined for any prefix @code{X} that denotes an object.
8683 The value of this attribute is of the predefined type Boolean.
8684 @code{X'Valid_Scalars} yields True if and only if evaluation of
8685 @code{P'Valid} yields True for every scalar part P of X or if X has
8686 no scalar parts. It is not specified in what order the scalar parts
8687 are checked, nor whether any more are checked after any one of them
8688 is determined to be invalid. If the prefix @code{X} is of a class-wide
8689 type @code{T'Class} (where @code{T} is the associated specific type),
8690 or if the prefix @code{X} is of a specific tagged type @code{T}, then
8691 only the scalar parts of components of @code{T} are traversed; in other
8692 words, components of extensions of @code{T} are not traversed even if
8693 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
8694 be determined at compile time that the prefix of the attribute has no
8695 scalar parts (e.g., if the prefix is of an access type, an interface type,
8696 an undiscriminated task type, or an undiscriminated protected type).
8697
8698 @node Attribute VADS_Size
8699 @unnumberedsec Attribute VADS_Size
8700 @cindex @code{Size}, VADS compatibility
8701 @findex VADS_Size
8702 @noindent
8703 The @code{'VADS_Size} attribute is intended to make it easier to port
8704 legacy code which relies on the semantics of @code{'Size} as implemented
8705 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
8706 same semantic interpretation.  In particular, @code{'VADS_Size} applied
8707 to a predefined or other primitive type with no Size clause yields the
8708 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
8709 typical machines).  In addition @code{'VADS_Size} applied to an object
8710 gives the result that would be obtained by applying the attribute to
8711 the corresponding type.
8712
8713 @node Attribute Value_Size
8714 @unnumberedsec Attribute Value_Size
8715 @cindex @code{Size}, setting for not-first subtype
8716 @findex Value_Size
8717 @code{@var{type}'Value_Size} is the number of bits required to represent
8718 a value of the given subtype.  It is the same as @code{@var{type}'Size},
8719 but, unlike @code{Size}, may be set for non-first subtypes.
8720
8721 @node Attribute Wchar_T_Size
8722 @unnumberedsec Attribute Wchar_T_Size
8723 @findex Wchar_T_Size
8724 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
8725 prefix) provides the size in bits of the C @code{wchar_t} type
8726 primarily for constructing the definition of this type in
8727 package @code{Interfaces.C}.
8728
8729 @node Attribute Word_Size
8730 @unnumberedsec Attribute Word_Size
8731 @findex Word_Size
8732 @code{Standard'Word_Size} (@code{Standard} is the only permissible
8733 prefix) provides the value @code{System.Word_Size}.
8734
8735 @node Standard and Implementation Defined Restrictions
8736 @chapter Standard and Implementation Defined Restrictions
8737
8738 @noindent
8739 All RM defined Restriction identifiers are implemented:
8740
8741 @itemize @bullet
8742 @item language-defined restrictions (see 13.12.1)
8743 @item tasking restrictions (see D.7)
8744 @item high integrity restrictions (see H.4)
8745 @end itemize
8746
8747 @noindent
8748 GNAT implements additional restriction identifiers. All restrictions, whether
8749 language defined or GNAT-specific, are listed in the following.
8750
8751 @menu
8752 * Partition-Wide Restrictions::
8753 * Program Unit Level Restrictions::
8754 @end menu
8755
8756 @node Partition-Wide Restrictions
8757 @section Partition-Wide Restrictions
8758
8759 There are two separate lists of restriction identifiers. The first
8760 set requires consistency throughout a partition (in other words, if the
8761 restriction identifier is used for any compilation unit in the partition,
8762 then all compilation units in the partition must obey the restriction).
8763
8764 @menu
8765 * Immediate_Reclamation::
8766 * Max_Asynchronous_Select_Nesting::
8767 * Max_Entry_Queue_Length::
8768 * Max_Protected_Entries::
8769 * Max_Select_Alternatives::
8770 * Max_Storage_At_Blocking::
8771 * Max_Task_Entries::
8772 * Max_Tasks::
8773 * No_Abort_Statements::
8774 * No_Access_Parameter_Allocators::
8775 * No_Access_Subprograms::
8776 * No_Allocators::
8777 * No_Anonymous_Allocators::
8778 * No_Calendar::
8779 * No_Coextensions::
8780 * No_Default_Initialization::
8781 * No_Delay::
8782 * No_Dependence::
8783 * No_Direct_Boolean_Operators::
8784 * No_Dispatch::
8785 * No_Dispatching_Calls::
8786 * No_Dynamic_Attachment::
8787 * No_Dynamic_Priorities::
8788 * No_Entry_Calls_In_Elaboration_Code::
8789 * No_Enumeration_Maps::
8790 * No_Exception_Handlers::
8791 * No_Exception_Propagation::
8792 * No_Exception_Registration::
8793 * No_Exceptions::
8794 * No_Finalization::
8795 * No_Fixed_Point::
8796 * No_Floating_Point::
8797 * No_Implicit_Conditionals::
8798 * No_Implicit_Dynamic_Code::
8799 * No_Implicit_Heap_Allocations::
8800 * No_Implicit_Loops::
8801 * No_Initialize_Scalars::
8802 * No_IO::
8803 * No_Local_Allocators::
8804 * No_Local_Protected_Objects::
8805 * No_Local_Timing_Events::
8806 * No_Nested_Finalization::
8807 * No_Protected_Type_Allocators::
8808 * No_Protected_Types::
8809 * No_Recursion::
8810 * No_Reentrancy::
8811 * No_Relative_Delay::
8812 * No_Requeue_Statements::
8813 * No_Secondary_Stack::
8814 * No_Select_Statements::
8815 * No_Specific_Termination_Handlers::
8816 * No_Specification_of_Aspect::
8817 * No_Standard_Allocators_After_Elaboration::
8818 * No_Standard_Storage_Pools::
8819 * No_Stream_Optimizations::
8820 * No_Streams::
8821 * No_Task_Allocators::
8822 * No_Task_Attributes_Package::
8823 * No_Task_Hierarchy::
8824 * No_Task_Termination::
8825 * No_Tasking::
8826 * No_Terminate_Alternatives::
8827 * No_Unchecked_Access::
8828 * Simple_Barriers::
8829 * Static_Priorities::
8830 * Static_Storage_Size::
8831 @end menu
8832
8833 @node Immediate_Reclamation
8834 @unnumberedsubsec Immediate_Reclamation
8835 @findex Immediate_Reclamation
8836 [RM H.4] This restriction ensures that, except for storage occupied by
8837 objects created by allocators and not deallocated via unchecked
8838 deallocation, any storage reserved at run time for an object is
8839 immediately reclaimed when the object no longer exists.
8840
8841 @node Max_Asynchronous_Select_Nesting
8842 @unnumberedsubsec Max_Asynchronous_Select_Nesting
8843 @findex Max_Asynchronous_Select_Nesting
8844 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
8845 selects. Violations of this restriction with a value of zero are
8846 detected at compile time. Violations of this restriction with values
8847 other than zero cause Storage_Error to be raised.
8848
8849 @node Max_Entry_Queue_Length
8850 @unnumberedsubsec Max_Entry_Queue_Length
8851 @findex Max_Entry_Queue_Length
8852 [RM D.7] This restriction is a declaration that any protected entry compiled in
8853 the scope of the restriction has at most the specified number of
8854 tasks waiting on the entry at any one time, and so no queue is required.
8855 Note that this restriction is checked at run time. Violation of this
8856 restriction results in the raising of Program_Error exception at the point of
8857 the call.
8858
8859 @node Max_Protected_Entries
8860 @unnumberedsubsec Max_Protected_Entries
8861 @findex Max_Protected_Entries
8862 [RM D.7] Specifies the maximum number of entries per protected type. The
8863 bounds of every entry family of a protected unit shall be static, or shall be
8864 defined by a discriminant of a subtype whose corresponding bound is static.
8865
8866 @node Max_Select_Alternatives
8867 @unnumberedsubsec Max_Select_Alternatives
8868 @findex Max_Select_Alternatives
8869 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
8870
8871 @node Max_Storage_At_Blocking
8872 @unnumberedsubsec Max_Storage_At_Blocking
8873 @findex Max_Storage_At_Blocking
8874 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
8875 Storage_Size that can be retained by a blocked task. A violation of this
8876 restriction causes Storage_Error to be raised.
8877
8878 @node Max_Task_Entries
8879 @unnumberedsubsec Max_Task_Entries
8880 @findex Max_Task_Entries
8881 [RM D.7] Specifies the maximum number of entries
8882 per task.  The bounds of every entry family
8883 of a task unit shall be static, or shall be
8884 defined by a discriminant of a subtype whose
8885 corresponding bound is static.
8886
8887 @node Max_Tasks
8888 @unnumberedsubsec Max_Tasks
8889 @findex Max_Tasks
8890 [RM D.7] Specifies the maximum number of task that may be created, not
8891 counting the creation of the environment task.  Violations of this
8892 restriction with a value of zero are detected at compile
8893 time. Violations of this restriction with values other than zero cause
8894 Storage_Error to be raised.
8895
8896 @node No_Abort_Statements
8897 @unnumberedsubsec No_Abort_Statements
8898 @findex No_Abort_Statements
8899 [RM D.7] There are no abort_statements, and there are
8900 no calls to Task_Identification.Abort_Task.
8901
8902 @node No_Access_Parameter_Allocators
8903 @unnumberedsubsec No_Access_Parameter_Allocators
8904 @findex No_Access_Parameter_Allocators
8905 [RM H.4] This restriction ensures at compile time that there are no
8906 occurrences of an allocator as the actual parameter to an access
8907 parameter.
8908
8909 @node No_Access_Subprograms
8910 @unnumberedsubsec No_Access_Subprograms
8911 @findex No_Access_Subprograms
8912 [RM H.4] This restriction ensures at compile time that there are no
8913 declarations of access-to-subprogram types.
8914
8915 @node No_Allocators
8916 @unnumberedsubsec No_Allocators
8917 @findex No_Allocators
8918 [RM H.4] This restriction ensures at compile time that there are no
8919 occurrences of an allocator.
8920
8921 @node No_Anonymous_Allocators
8922 @unnumberedsubsec No_Anonymous_Allocators
8923 @findex No_Anonymous_Allocators
8924 [RM H.4] This restriction ensures at compile time that there are no
8925 occurrences of an allocator of anonymous access type.
8926
8927 @node No_Calendar
8928 @unnumberedsubsec No_Calendar
8929 @findex No_Calendar
8930 [GNAT] This restriction ensures at compile time that there is no implicit or
8931 explicit dependence on the package @code{Ada.Calendar}.
8932
8933 @node No_Coextensions
8934 @unnumberedsubsec No_Coextensions
8935 @findex No_Coextensions
8936 [RM H.4] This restriction ensures at compile time that there are no
8937 coextensions. See 3.10.2.
8938
8939 @node No_Default_Initialization
8940 @unnumberedsubsec No_Default_Initialization
8941 @findex No_Default_Initialization
8942
8943 [GNAT] This restriction prohibits any instance of default initialization
8944 of variables.  The binder implements a consistency rule which prevents
8945 any unit compiled without the restriction from with'ing a unit with the
8946 restriction (this allows the generation of initialization procedures to
8947 be skipped, since you can be sure that no call is ever generated to an
8948 initialization procedure in a unit with the restriction active). If used
8949 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
8950 is to prohibit all cases of variables declared without a specific
8951 initializer (including the case of OUT scalar parameters).
8952
8953 @node No_Delay
8954 @unnumberedsubsec No_Delay
8955 @findex No_Delay
8956 [RM H.4] This restriction ensures at compile time that there are no
8957 delay statements and no dependences on package Calendar.
8958
8959 @node No_Dependence
8960 @unnumberedsubsec No_Dependence
8961 @findex No_Dependence
8962 [RM 13.12.1] This restriction checks at compile time that there are no
8963 dependence on a library unit.
8964
8965 @node No_Direct_Boolean_Operators
8966 @unnumberedsubsec No_Direct_Boolean_Operators
8967 @findex No_Direct_Boolean_Operators
8968 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
8969 operands of type Boolean (or any type derived
8970 from Boolean). This is intended for use in safety critical programs
8971 where the certification protocol requires the use of short-circuit
8972 (and then, or else) forms for all composite boolean operations.
8973
8974 @node No_Dispatch
8975 @unnumberedsubsec No_Dispatch
8976 @findex No_Dispatch
8977 [RM H.4] This restriction ensures at compile time that there are no
8978 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
8979
8980 @node No_Dispatching_Calls
8981 @unnumberedsubsec No_Dispatching_Calls
8982 @findex No_Dispatching_Calls
8983 [GNAT] This restriction ensures at compile time that the code generated by the
8984 compiler involves no dispatching calls. The use of this restriction allows the
8985 safe use of record extensions, classwide membership tests and other classwide
8986 features not involving implicit dispatching. This restriction ensures that
8987 the code contains no indirect calls through a dispatching mechanism. Note that
8988 this includes internally-generated calls created by the compiler, for example
8989 in the implementation of class-wide objects assignments. The
8990 membership test is allowed in the presence of this restriction, because its
8991 implementation requires no dispatching.
8992 This restriction is comparable to the official Ada restriction
8993 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8994 all classwide constructs that do not imply dispatching.
8995 The following example indicates constructs that violate this restriction.
8996
8997 @smallexample
8998 package Pkg is
8999   type T is tagged record
9000     Data : Natural;
9001   end record;
9002   procedure P (X : T);
9003
9004   type DT is new T with record
9005     More_Data : Natural;
9006   end record;
9007   procedure Q (X : DT);
9008 end Pkg;
9009
9010 with Pkg; use Pkg;
9011 procedure Example is
9012   procedure Test (O : T'Class) is
9013     N : Natural  := O'Size;--  Error: Dispatching call
9014     C : T'Class := O;      --  Error: implicit Dispatching Call
9015   begin
9016     if O in DT'Class then  --  OK   : Membership test
9017        Q (DT (O));         --  OK   : Type conversion plus direct call
9018     else
9019        P (O);              --  Error: Dispatching call
9020     end if;
9021   end Test;
9022
9023   Obj : DT;
9024 begin
9025   P (Obj);                 --  OK   : Direct call
9026   P (T (Obj));             --  OK   : Type conversion plus direct call
9027   P (T'Class (Obj));       --  Error: Dispatching call
9028
9029   Test (Obj);              --  OK   : Type conversion
9030
9031   if Obj in T'Class then   --  OK   : Membership test
9032      null;
9033   end if;
9034 end Example;
9035 @end smallexample
9036
9037 @node No_Dynamic_Attachment
9038 @unnumberedsubsec No_Dynamic_Attachment
9039 @findex No_Dynamic_Attachment
9040 [RM D.7] This restriction ensures that there is no call to any of the
9041 operations defined in package Ada.Interrupts
9042 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
9043 Detach_Handler, and Reference).
9044
9045 @node No_Dynamic_Priorities
9046 @unnumberedsubsec No_Dynamic_Priorities
9047 @findex No_Dynamic_Priorities
9048 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
9049
9050 @node No_Entry_Calls_In_Elaboration_Code
9051 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
9052 @findex No_Entry_Calls_In_Elaboration_Code
9053 [GNAT] This restriction ensures at compile time that no task or protected entry
9054 calls are made during elaboration code.  As a result of the use of this
9055 restriction, the compiler can assume that no code past an accept statement
9056 in a task can be executed at elaboration time.
9057
9058 @node No_Enumeration_Maps
9059 @unnumberedsubsec No_Enumeration_Maps
9060 @findex No_Enumeration_Maps
9061 [GNAT] This restriction ensures at compile time that no operations requiring
9062 enumeration maps are used (that is Image and Value attributes applied
9063 to enumeration types).
9064
9065 @node No_Exception_Handlers
9066 @unnumberedsubsec No_Exception_Handlers
9067 @findex No_Exception_Handlers
9068 [GNAT] This restriction ensures at compile time that there are no explicit
9069 exception handlers. It also indicates that no exception propagation will
9070 be provided. In this mode, exceptions may be raised but will result in
9071 an immediate call to the last chance handler, a routine that the user
9072 must define with the following profile:
9073
9074 @smallexample @c ada
9075 procedure Last_Chance_Handler
9076   (Source_Location : System.Address; Line : Integer);
9077 pragma Export (C, Last_Chance_Handler,
9078                "__gnat_last_chance_handler");
9079 @end smallexample
9080
9081 The parameter is a C null-terminated string representing a message to be
9082 associated with the exception (typically the source location of the raise
9083 statement generated by the compiler). The Line parameter when nonzero
9084 represents the line number in the source program where the raise occurs.
9085
9086 @node No_Exception_Propagation
9087 @unnumberedsubsec No_Exception_Propagation
9088 @findex No_Exception_Propagation
9089 [GNAT] This restriction guarantees that exceptions are never propagated
9090 to an outer subprogram scope. The only case in which an exception may
9091 be raised is when the handler is statically in the same subprogram, so
9092 that the effect of a raise is essentially like a goto statement. Any
9093 other raise statement (implicit or explicit) will be considered
9094 unhandled. Exception handlers are allowed, but may not contain an
9095 exception occurrence identifier (exception choice). In addition, use of
9096 the package GNAT.Current_Exception is not permitted, and reraise
9097 statements (raise with no operand) are not permitted.
9098
9099 @node No_Exception_Registration
9100 @unnumberedsubsec No_Exception_Registration
9101 @findex No_Exception_Registration
9102 [GNAT] This restriction ensures at compile time that no stream operations for
9103 types Exception_Id or Exception_Occurrence are used. This also makes it
9104 impossible to pass exceptions to or from a partition with this restriction
9105 in a distributed environment. If this exception is active, then the generated
9106 code is simplified by omitting the otherwise-required global registration
9107 of exceptions when they are declared.
9108
9109 @node No_Exceptions
9110 @unnumberedsubsec No_Exceptions
9111 @findex No_Exceptions
9112 [RM H.4] This restriction ensures at compile time that there are no
9113 raise statements and no exception handlers.
9114
9115 @node No_Finalization
9116 @unnumberedsubsec No_Finalization
9117 @findex No_Finalization
9118 [GNAT] This restriction disables the language features described in
9119 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
9120 performed by the compiler to support these features. The following types
9121 are no longer considered controlled when this restriction is in effect:
9122 @itemize @bullet
9123 @item
9124 @code{Ada.Finalization.Controlled}
9125 @item
9126 @code{Ada.Finalization.Limited_Controlled}
9127 @item
9128 Derivations from @code{Controlled} or @code{Limited_Controlled}
9129 @item
9130 Class-wide types
9131 @item
9132 Protected types
9133 @item
9134 Task types
9135 @item
9136 Array and record types with controlled components
9137 @end itemize
9138 The compiler no longer generates code to initialize, finalize or adjust an
9139 object or a nested component, either declared on the stack or on the heap. The
9140 deallocation of a controlled object no longer finalizes its contents.
9141
9142 @node No_Fixed_Point
9143 @unnumberedsubsec No_Fixed_Point
9144 @findex No_Fixed_Point
9145 [RM H.4] This restriction ensures at compile time that there are no
9146 occurrences of fixed point types and operations.
9147
9148 @node No_Floating_Point
9149 @unnumberedsubsec No_Floating_Point
9150 @findex No_Floating_Point
9151 [RM H.4] This restriction ensures at compile time that there are no
9152 occurrences of floating point types and operations.
9153
9154 @node No_Implicit_Conditionals
9155 @unnumberedsubsec No_Implicit_Conditionals
9156 @findex No_Implicit_Conditionals
9157 [GNAT] This restriction ensures that the generated code does not contain any
9158 implicit conditionals, either by modifying the generated code where possible,
9159 or by rejecting any construct that would otherwise generate an implicit
9160 conditional. Note that this check does not include run time constraint
9161 checks, which on some targets may generate implicit conditionals as
9162 well. To control the latter, constraint checks can be suppressed in the
9163 normal manner. Constructs generating implicit conditionals include comparisons
9164 of composite objects and the Max/Min attributes.
9165
9166 @node No_Implicit_Dynamic_Code
9167 @unnumberedsubsec No_Implicit_Dynamic_Code
9168 @findex No_Implicit_Dynamic_Code
9169 @cindex trampoline
9170 [GNAT] This restriction prevents the compiler from building ``trampolines''.
9171 This is a structure that is built on the stack and contains dynamic
9172 code to be executed at run time. On some targets, a trampoline is
9173 built for the following features: @code{Access},
9174 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9175 nested task bodies; primitive operations of nested tagged types.
9176 Trampolines do not work on machines that prevent execution of stack
9177 data. For example, on windows systems, enabling DEP (data execution
9178 protection) will cause trampolines to raise an exception.
9179 Trampolines are also quite slow at run time.
9180
9181 On many targets, trampolines have been largely eliminated. Look at the
9182 version of system.ads for your target --- if it has
9183 Always_Compatible_Rep equal to False, then trampolines are largely
9184 eliminated. In particular, a trampoline is built for the following
9185 features: @code{Address} of a nested subprogram;
9186 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9187 but only if pragma Favor_Top_Level applies, or the access type has a
9188 foreign-language convention; primitive operations of nested tagged
9189 types.
9190
9191 @node No_Implicit_Heap_Allocations
9192 @unnumberedsubsec No_Implicit_Heap_Allocations
9193 @findex No_Implicit_Heap_Allocations
9194 [RM D.7] No constructs are allowed to cause implicit heap allocation.
9195
9196 @node No_Implicit_Loops
9197 @unnumberedsubsec No_Implicit_Loops
9198 @findex No_Implicit_Loops
9199 [GNAT] This restriction ensures that the generated code does not contain any
9200 implicit @code{for} loops, either by modifying
9201 the generated code where possible,
9202 or by rejecting any construct that would otherwise generate an implicit
9203 @code{for} loop. If this restriction is active, it is possible to build
9204 large array aggregates with all static components without generating an
9205 intermediate temporary, and without generating a loop to initialize individual
9206 components. Otherwise, a loop is created for arrays larger than about 5000
9207 scalar components.
9208
9209 @node No_Initialize_Scalars
9210 @unnumberedsubsec No_Initialize_Scalars
9211 @findex No_Initialize_Scalars
9212 [GNAT] This restriction ensures that no unit in the partition is compiled with
9213 pragma Initialize_Scalars. This allows the generation of more efficient
9214 code, and in particular eliminates dummy null initialization routines that
9215 are otherwise generated for some record and array types.
9216
9217 @node No_IO
9218 @unnumberedsubsec No_IO
9219 @findex No_IO
9220 [RM H.4] This restriction ensures at compile time that there are no
9221 dependences on any of the library units Sequential_IO, Direct_IO,
9222 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
9223
9224 @node No_Local_Allocators
9225 @unnumberedsubsec No_Local_Allocators
9226 @findex No_Local_Allocators
9227 [RM H.4] This restriction ensures at compile time that there are no
9228 occurrences of an allocator in subprograms, generic subprograms, tasks,
9229 and entry bodies.
9230
9231 @node No_Local_Protected_Objects
9232 @unnumberedsubsec No_Local_Protected_Objects
9233 @findex No_Local_Protected_Objects
9234 [RM D.7] This restriction ensures at compile time that protected objects are
9235 only declared at the library level.
9236
9237 @node No_Local_Timing_Events
9238 @unnumberedsubsec No_Local_Timing_Events
9239 @findex No_Local_Timing_Events
9240 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
9241 declared at the library level.
9242
9243 @node No_Nested_Finalization
9244 @unnumberedsubsec No_Nested_Finalization
9245 @findex No_Nested_Finalization
9246 [RM D.7] All objects requiring finalization are declared at the library level.
9247
9248 @node No_Protected_Type_Allocators
9249 @unnumberedsubsec No_Protected_Type_Allocators
9250 @findex No_Protected_Type_Allocators
9251 [RM D.7] This restriction ensures at compile time that there are no allocator
9252 expressions that attempt to allocate protected objects.
9253
9254 @node No_Protected_Types
9255 @unnumberedsubsec No_Protected_Types
9256 @findex No_Protected_Types
9257 [RM H.4] This restriction ensures at compile time that there are no
9258 declarations of protected types or protected objects.
9259
9260 @node No_Recursion
9261 @unnumberedsubsec No_Recursion
9262 @findex No_Recursion
9263 [RM H.4] A program execution is erroneous if a subprogram is invoked as
9264 part of its execution.
9265
9266 @node No_Reentrancy
9267 @unnumberedsubsec No_Reentrancy
9268 @findex No_Reentrancy
9269 [RM H.4] A program execution is erroneous if a subprogram is executed by
9270 two tasks at the same time.
9271
9272 @node No_Relative_Delay
9273 @unnumberedsubsec No_Relative_Delay
9274 @findex No_Relative_Delay
9275 [RM D.7] This restriction ensures at compile time that there are no delay
9276 relative statements and prevents expressions such as @code{delay 1.23;} from
9277 appearing in source code.
9278
9279 @node No_Requeue_Statements
9280 @unnumberedsubsec No_Requeue_Statements
9281 @findex No_Requeue_Statements
9282 [RM D.7] This restriction ensures at compile time that no requeue statements
9283 are permitted and prevents keyword @code{requeue} from being used in source
9284 code.
9285
9286 @node No_Secondary_Stack
9287 @unnumberedsubsec No_Secondary_Stack
9288 @findex No_Secondary_Stack
9289 [GNAT] This restriction ensures at compile time that the generated code
9290 does not contain any reference to the secondary stack.  The secondary
9291 stack is used to implement functions returning unconstrained objects
9292 (arrays or records) on some targets.
9293
9294 @node No_Select_Statements
9295 @unnumberedsubsec No_Select_Statements
9296 @findex No_Select_Statements
9297 [RM D.7] This restriction ensures at compile time no select statements of any
9298 kind are permitted, that is the keyword @code{select} may not appear.
9299
9300 @node No_Specific_Termination_Handlers
9301 @unnumberedsubsec No_Specific_Termination_Handlers
9302 @findex No_Specific_Termination_Handlers
9303 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
9304 or to Ada.Task_Termination.Specific_Handler.
9305
9306 @node No_Specification_of_Aspect
9307 @unnumberedsubsec No_Specification_of_Aspect
9308 @findex No_Specification_of_Aspect
9309 [RM 13.12.1] This restriction checks at compile time that no aspect
9310 specification, attribute definition clause, or pragma is given for a
9311 given aspect.
9312
9313 @node No_Standard_Allocators_After_Elaboration
9314 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
9315 @findex No_Standard_Allocators_After_Elaboration
9316 [RM D.7] Specifies that an allocator using a standard storage pool
9317 should never be evaluated at run time after the elaboration of the
9318 library items of the partition has completed. Otherwise, Storage_Error
9319 is raised.
9320
9321 @node No_Standard_Storage_Pools
9322 @unnumberedsubsec No_Standard_Storage_Pools
9323 @findex No_Standard_Storage_Pools
9324 [GNAT] This restriction ensures at compile time that no access types
9325 use the standard default storage pool.  Any access type declared must
9326 have an explicit Storage_Pool attribute defined specifying a
9327 user-defined storage pool.
9328
9329 @node No_Stream_Optimizations
9330 @unnumberedsubsec No_Stream_Optimizations
9331 @findex No_Stream_Optimizations
9332 [GNAT] This restriction affects the performance of stream operations on types
9333 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9334 compiler uses block reads and writes when manipulating @code{String} objects
9335 due to their supperior performance. When this restriction is in effect, the
9336 compiler performs all IO operations on a per-character basis.
9337
9338 @node No_Streams
9339 @unnumberedsubsec No_Streams
9340 @findex No_Streams
9341 [GNAT] This restriction ensures at compile/bind time that there are no
9342 stream objects created and no use of stream attributes.
9343 This restriction does not forbid dependences on the package
9344 @code{Ada.Streams}. So it is permissible to with
9345 @code{Ada.Streams} (or another package that does so itself)
9346 as long as no actual stream objects are created and no
9347 stream attributes are used.
9348
9349 Note that the use of restriction allows optimization of tagged types,
9350 since they do not need to worry about dispatching stream operations.
9351 To take maximum advantage of this space-saving optimization, any
9352 unit declaring a tagged type should be compiled with the restriction,
9353 though this is not required.
9354
9355 @node No_Task_Allocators
9356 @unnumberedsubsec No_Task_Allocators
9357 @findex No_Task_Allocators
9358 [RM D.7] There are no allocators for task types
9359 or types containing task subcomponents.
9360
9361 @node No_Task_Attributes_Package
9362 @unnumberedsubsec No_Task_Attributes_Package
9363 @findex No_Task_Attributes_Package
9364 [GNAT] This restriction ensures at compile time that there are no implicit or
9365 explicit dependencies on the package @code{Ada.Task_Attributes}.
9366
9367 @node No_Task_Hierarchy
9368 @unnumberedsubsec No_Task_Hierarchy
9369 @findex No_Task_Hierarchy
9370 [RM D.7] All (non-environment) tasks depend
9371 directly on the environment task of the partition.
9372
9373 @node No_Task_Termination
9374 @unnumberedsubsec No_Task_Termination
9375 @findex No_Task_Termination
9376 [RM D.7] Tasks which terminate are erroneous.
9377
9378 @node No_Tasking
9379 @unnumberedsubsec No_Tasking
9380 @findex No_Tasking
9381 [GNAT] This restriction prevents the declaration of tasks or task types
9382 throughout the partition.  It is similar in effect to the use of
9383 @code{Max_Tasks => 0} except that violations are caught at compile time
9384 and cause an error message to be output either by the compiler or
9385 binder.
9386
9387 @node No_Terminate_Alternatives
9388 @unnumberedsubsec No_Terminate_Alternatives
9389 @findex No_Terminate_Alternatives
9390 [RM D.7] There are no selective accepts with terminate alternatives.
9391
9392 @node No_Unchecked_Access
9393 @unnumberedsubsec No_Unchecked_Access
9394 @findex No_Unchecked_Access
9395 [RM H.4] This restriction ensures at compile time that there are no
9396 occurrences of the Unchecked_Access attribute.
9397
9398 @node Simple_Barriers
9399 @unnumberedsubsec Simple_Barriers
9400 @findex Simple_Barriers
9401 [RM D.7] This restriction ensures at compile time that barriers in entry
9402 declarations for protected types are restricted to either static boolean
9403 expressions or references to simple boolean variables defined in the private
9404 part of the protected type.  No other form of entry barriers is permitted.
9405
9406 @node Static_Priorities
9407 @unnumberedsubsec Static_Priorities
9408 @findex Static_Priorities
9409 [GNAT] This restriction ensures at compile time that all priority expressions
9410 are static, and that there are no dependences on the package
9411 @code{Ada.Dynamic_Priorities}.
9412
9413 @node Static_Storage_Size
9414 @unnumberedsubsec Static_Storage_Size
9415 @findex Static_Storage_Size
9416 [GNAT] This restriction ensures at compile time that any expression appearing
9417 in a Storage_Size pragma or attribute definition clause is static.
9418
9419 @node Program Unit Level Restrictions
9420 @section Program Unit Level Restrictions
9421
9422 @noindent
9423 The second set of restriction identifiers
9424 does not require partition-wide consistency.
9425 The restriction may be enforced for a single
9426 compilation unit without any effect on any of the
9427 other compilation units in the partition.
9428
9429 @menu
9430 * No_Elaboration_Code::
9431 * No_Entry_Queue::
9432 * No_Implementation_Aspect_Specifications::
9433 * No_Implementation_Attributes::
9434 * No_Implementation_Identifiers::
9435 * No_Implementation_Pragmas::
9436 * No_Implementation_Restrictions::
9437 * No_Implementation_Units::
9438 * No_Implicit_Aliasing::
9439 * No_Obsolescent_Features::
9440 * No_Wide_Characters::
9441 * SPARK::
9442 @end menu
9443
9444 @node No_Elaboration_Code
9445 @unnumberedsubsec No_Elaboration_Code
9446 @findex No_Elaboration_Code
9447 [GNAT] This restriction ensures at compile time that no elaboration code is
9448 generated.  Note that this is not the same condition as is enforced
9449 by pragma @code{Preelaborate}.  There are cases in which pragma
9450 @code{Preelaborate} still permits code to be generated (e.g.@: code
9451 to initialize a large array to all zeroes), and there are cases of units
9452 which do not meet the requirements for pragma @code{Preelaborate},
9453 but for which no elaboration code is generated.  Generally, it is
9454 the case that preelaborable units will meet the restrictions, with
9455 the exception of large aggregates initialized with an others_clause,
9456 and exception declarations (which generate calls to a run-time
9457 registry procedure).  This restriction is enforced on
9458 a unit by unit basis, it need not be obeyed consistently
9459 throughout a partition.
9460
9461 In the case of aggregates with others, if the aggregate has a dynamic
9462 size, there is no way to eliminate the elaboration code (such dynamic
9463 bounds would be incompatible with @code{Preelaborate} in any case). If
9464 the bounds are static, then use of this restriction actually modifies
9465 the code choice of the compiler to avoid generating a loop, and instead
9466 generate the aggregate statically if possible, no matter how many times
9467 the data for the others clause must be repeatedly generated.
9468
9469 It is not possible to precisely document
9470 the constructs which are compatible with this restriction, since,
9471 unlike most other restrictions, this is not a restriction on the
9472 source code, but a restriction on the generated object code. For
9473 example, if the source contains a declaration:
9474
9475 @smallexample
9476    Val : constant Integer := X;
9477 @end smallexample
9478
9479 @noindent
9480 where X is not a static constant, it may be possible, depending
9481 on complex optimization circuitry, for the compiler to figure
9482 out the value of X at compile time, in which case this initialization
9483 can be done by the loader, and requires no initialization code. It
9484 is not possible to document the precise conditions under which the
9485 optimizer can figure this out.
9486
9487 Note that this the implementation of this restriction requires full
9488 code generation. If it is used in conjunction with "semantics only"
9489 checking, then some cases of violations may be missed.
9490
9491 @node No_Entry_Queue
9492 @unnumberedsubsec No_Entry_Queue
9493 @findex No_Entry_Queue
9494 [GNAT] This restriction is a declaration that any protected entry compiled in
9495 the scope of the restriction has at most one task waiting on the entry
9496 at any one time, and so no queue is required.  This restriction is not
9497 checked at compile time.  A program execution is erroneous if an attempt
9498 is made to queue a second task on such an entry.
9499
9500 @node No_Implementation_Aspect_Specifications
9501 @unnumberedsubsec No_Implementation_Aspect_Specifications
9502 @findex No_Implementation_Aspect_Specifications
9503 [RM 13.12.1] This restriction checks at compile time that no
9504 GNAT-defined aspects are present.  With this restriction, the only
9505 aspects that can be used are those defined in the Ada Reference Manual.
9506
9507 @node No_Implementation_Attributes
9508 @unnumberedsubsec No_Implementation_Attributes
9509 @findex No_Implementation_Attributes
9510 [RM 13.12.1] This restriction checks at compile time that no
9511 GNAT-defined attributes are present.  With this restriction, the only
9512 attributes that can be used are those defined in the Ada Reference
9513 Manual.
9514
9515 @node No_Implementation_Identifiers
9516 @unnumberedsubsec No_Implementation_Identifiers
9517 @findex No_Implementation_Identifiers
9518 [RM 13.12.1] This restriction checks at compile time that no
9519 implementation-defined identifiers (marked with pragma Implementation_Defined)
9520 occur within language-defined packages.
9521
9522 @node No_Implementation_Pragmas
9523 @unnumberedsubsec No_Implementation_Pragmas
9524 @findex No_Implementation_Pragmas
9525 [RM 13.12.1] This restriction checks at compile time that no
9526 GNAT-defined pragmas are present.  With this restriction, the only
9527 pragmas that can be used are those defined in the Ada Reference Manual.
9528
9529 @node No_Implementation_Restrictions
9530 @unnumberedsubsec No_Implementation_Restrictions
9531 @findex No_Implementation_Restrictions
9532 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
9533 identifiers (other than @code{No_Implementation_Restrictions} itself)
9534 are present.  With this restriction, the only other restriction identifiers
9535 that can be used are those defined in the Ada Reference Manual.
9536
9537 @node No_Implementation_Units
9538 @unnumberedsubsec No_Implementation_Units
9539 @findex No_Implementation_Units
9540 [RM 13.12.1] This restriction checks at compile time that there is no
9541 mention in the context clause of any implementation-defined descendants
9542 of packages Ada, Interfaces, or System.
9543
9544 @node No_Implicit_Aliasing
9545 @unnumberedsubsec No_Implicit_Aliasing
9546 @findex No_Implicit_Aliasing
9547 [GNAT] This restriction, which is not required to be partition-wide consistent,
9548 requires an explicit aliased keyword for an object to which 'Access,
9549 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9550 the 'Unrestricted_Access attribute for objects. Note: the reason that
9551 Unrestricted_Access is forbidden is that it would require the prefix
9552 to be aliased, and in such cases, it can always be replaced by
9553 the standard attribute Unchecked_Access which is preferable.
9554
9555 @node No_Obsolescent_Features
9556 @unnumberedsubsec No_Obsolescent_Features
9557 @findex No_Obsolescent_Features
9558 [RM 13.12.1] This restriction checks at compile time that no obsolescent
9559 features are used, as defined in Annex J of the Ada Reference Manual.
9560
9561 @node No_Wide_Characters
9562 @unnumberedsubsec No_Wide_Characters
9563 @findex No_Wide_Characters
9564 [GNAT] This restriction ensures at compile time that no uses of the types
9565 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9566 wide types
9567 appear, and that no wide or wide wide string or character literals
9568 appear in the program (that is literals representing characters not in
9569 type @code{Character}).
9570
9571 @node SPARK
9572 @unnumberedsubsec SPARK
9573 @findex SPARK
9574 [GNAT] This restriction checks at compile time that some constructs
9575 forbidden in SPARK 2005 are not present. Error messages related to
9576 SPARK restriction have the form:
9577
9578 @smallexample
9579 violation of restriction "SPARK" at <file>
9580  <error message>
9581 @end smallexample
9582
9583 This is not a replacement for the semantic checks performed by the
9584 SPARK Examiner tool, as the compiler only deals currently with code,
9585 not at all with SPARK 2005 annotations and does not guarantee catching all
9586 cases of constructs forbidden by SPARK 2005.
9587
9588 Thus it may well be the case that code which passes the compiler with
9589 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
9590 the different visibility rules of the Examiner based on SPARK 2005
9591 @code{inherit} annotations.
9592
9593 This restriction can be useful in providing an initial filter for code
9594 developed using SPARK 2005, or in examining legacy code to see how far
9595 it is from meeting SPARK restrictions.
9596
9597 Note that if a unit is compiled in Ada 95 mode with SPARK restriction,
9598 violations will be reported for constructs forbidden in SPARK 95,
9599 instead of SPARK 2005.
9600
9601 @c ------------------------
9602 @node Implementation Advice
9603 @chapter Implementation Advice
9604 @noindent
9605 The main text of the Ada Reference Manual describes the required
9606 behavior of all Ada compilers, and the GNAT compiler conforms to
9607 these requirements.
9608
9609 In addition, there are sections throughout the Ada Reference Manual headed
9610 by the phrase ``Implementation advice''.  These sections are not normative,
9611 i.e., they do not specify requirements that all compilers must
9612 follow.  Rather they provide advice on generally desirable behavior.  You
9613 may wonder why they are not requirements.  The most typical answer is
9614 that they describe behavior that seems generally desirable, but cannot
9615 be provided on all systems, or which may be undesirable on some systems.
9616
9617 As far as practical, GNAT follows the implementation advice sections in
9618 the Ada Reference Manual.  This chapter contains a table giving the
9619 reference manual section number, paragraph number and several keywords
9620 for each advice.  Each entry consists of the text of the advice followed
9621 by the GNAT interpretation of this advice.  Most often, this simply says
9622 ``followed'', which means that GNAT follows the advice.  However, in a
9623 number of cases, GNAT deliberately deviates from this advice, in which
9624 case the text describes what GNAT does and why.
9625
9626 @cindex Error detection
9627 @unnumberedsec 1.1.3(20): Error Detection
9628 @sp 1
9629 @cartouche
9630 If an implementation detects the use of an unsupported Specialized Needs
9631 Annex feature at run time, it should raise @code{Program_Error} if
9632 feasible.
9633 @end cartouche
9634 Not relevant.  All specialized needs annex features are either supported,
9635 or diagnosed at compile time.
9636
9637 @cindex Child Units
9638 @unnumberedsec 1.1.3(31): Child Units
9639 @sp 1
9640 @cartouche
9641 If an implementation wishes to provide implementation-defined
9642 extensions to the functionality of a language-defined library unit, it
9643 should normally do so by adding children to the library unit.
9644 @end cartouche
9645 Followed.
9646
9647 @cindex Bounded errors
9648 @unnumberedsec 1.1.5(12): Bounded Errors
9649 @sp 1
9650 @cartouche
9651 If an implementation detects a bounded error or erroneous
9652 execution, it should raise @code{Program_Error}.
9653 @end cartouche
9654 Followed in all cases in which the implementation detects a bounded
9655 error or erroneous execution.  Not all such situations are detected at
9656 runtime.
9657
9658 @cindex Pragmas
9659 @unnumberedsec 2.8(16): Pragmas
9660 @sp 1
9661 @cartouche
9662 Normally, implementation-defined pragmas should have no semantic effect
9663 for error-free programs; that is, if the implementation-defined pragmas
9664 are removed from a working program, the program should still be legal,
9665 and should still have the same semantics.
9666 @end cartouche
9667 The following implementation defined pragmas are exceptions to this
9668 rule:
9669
9670 @table @code
9671 @item Abort_Defer
9672 Affects semantics
9673 @item Ada_83
9674 Affects legality
9675 @item Assert
9676 Affects semantics
9677 @item CPP_Class
9678 Affects semantics
9679 @item CPP_Constructor
9680 Affects semantics
9681 @item Debug
9682 Affects semantics
9683 @item Interface_Name
9684 Affects semantics
9685 @item Machine_Attribute
9686 Affects semantics
9687 @item Unimplemented_Unit
9688 Affects legality
9689 @item Unchecked_Union
9690 Affects semantics
9691 @end table
9692
9693 @noindent
9694 In each of the above cases, it is essential to the purpose of the pragma
9695 that this advice not be followed.  For details see the separate section
9696 on implementation defined pragmas.
9697
9698 @unnumberedsec 2.8(17-19): Pragmas
9699 @sp 1
9700 @cartouche
9701 Normally, an implementation should not define pragmas that can
9702 make an illegal program legal, except as follows:
9703 @end cartouche
9704 @sp 1
9705 @cartouche
9706 A pragma used to complete a declaration, such as a pragma @code{Import};
9707 @end cartouche
9708 @sp 1
9709 @cartouche
9710 A pragma used to configure the environment by adding, removing, or
9711 replacing @code{library_items}.
9712 @end cartouche
9713 See response to paragraph 16 of this same section.
9714
9715 @cindex Character Sets
9716 @cindex Alternative Character Sets
9717 @unnumberedsec 3.5.2(5): Alternative Character Sets
9718 @sp 1
9719 @cartouche
9720 If an implementation supports a mode with alternative interpretations
9721 for @code{Character} and @code{Wide_Character}, the set of graphic
9722 characters of @code{Character} should nevertheless remain a proper
9723 subset of the set of graphic characters of @code{Wide_Character}.  Any
9724 character set ``localizations'' should be reflected in the results of
9725 the subprograms defined in the language-defined package
9726 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
9727 an alternative interpretation of @code{Character}, the implementation should
9728 also support a corresponding change in what is a legal
9729 @code{identifier_letter}.
9730 @end cartouche
9731 Not all wide character modes follow this advice, in particular the JIS
9732 and IEC modes reflect standard usage in Japan, and in these encoding,
9733 the upper half of the Latin-1 set is not part of the wide-character
9734 subset, since the most significant bit is used for wide character
9735 encoding.  However, this only applies to the external forms.  Internally
9736 there is no such restriction.
9737
9738 @cindex Integer types
9739 @unnumberedsec 3.5.4(28): Integer Types
9740
9741 @sp 1
9742 @cartouche
9743 An implementation should support @code{Long_Integer} in addition to
9744 @code{Integer} if the target machine supports 32-bit (or longer)
9745 arithmetic.  No other named integer subtypes are recommended for package
9746 @code{Standard}.  Instead, appropriate named integer subtypes should be
9747 provided in the library package @code{Interfaces} (see B.2).
9748 @end cartouche
9749 @code{Long_Integer} is supported.  Other standard integer types are supported
9750 so this advice is not fully followed.  These types
9751 are supported for convenient interface to C, and so that all hardware
9752 types of the machine are easily available.
9753 @unnumberedsec 3.5.4(29): Integer Types
9754
9755 @sp 1
9756 @cartouche
9757 An implementation for a two's complement machine should support
9758 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
9759 implementation should support a non-binary modules up to @code{Integer'Last}.
9760 @end cartouche
9761 Followed.
9762
9763 @cindex Enumeration values
9764 @unnumberedsec 3.5.5(8): Enumeration Values
9765 @sp 1
9766 @cartouche
9767 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
9768 subtype, if the value of the operand does not correspond to the internal
9769 code for any enumeration literal of its type (perhaps due to an
9770 un-initialized variable), then the implementation should raise
9771 @code{Program_Error}.  This is particularly important for enumeration
9772 types with noncontiguous internal codes specified by an
9773 enumeration_representation_clause.
9774 @end cartouche
9775 Followed.
9776
9777 @cindex Float types
9778 @unnumberedsec 3.5.7(17): Float Types
9779 @sp 1
9780 @cartouche
9781 An implementation should support @code{Long_Float} in addition to
9782 @code{Float} if the target machine supports 11 or more digits of
9783 precision.  No other named floating point subtypes are recommended for
9784 package @code{Standard}.  Instead, appropriate named floating point subtypes
9785 should be provided in the library package @code{Interfaces} (see B.2).
9786 @end cartouche
9787 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
9788 former provides improved compatibility with other implementations
9789 supporting this type.  The latter corresponds to the highest precision
9790 floating-point type supported by the hardware.  On most machines, this
9791 will be the same as @code{Long_Float}, but on some machines, it will
9792 correspond to the IEEE extended form.  The notable case is all ia32
9793 (x86) implementations, where @code{Long_Long_Float} corresponds to
9794 the 80-bit extended precision format supported in hardware on this
9795 processor.  Note that the 128-bit format on SPARC is not supported,
9796 since this is a software rather than a hardware format.
9797
9798 @cindex Multidimensional arrays
9799 @cindex Arrays, multidimensional
9800 @unnumberedsec 3.6.2(11): Multidimensional Arrays
9801 @sp 1
9802 @cartouche
9803 An implementation should normally represent multidimensional arrays in
9804 row-major order, consistent with the notation used for multidimensional
9805 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
9806 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
9807 column-major order should be used instead (see B.5, ``Interfacing with
9808 Fortran'').
9809 @end cartouche
9810 Followed.
9811
9812 @findex Duration'Small
9813 @unnumberedsec 9.6(30-31): Duration'Small
9814 @sp 1
9815 @cartouche
9816 Whenever possible in an implementation, the value of @code{Duration'Small}
9817 should be no greater than 100 microseconds.
9818 @end cartouche
9819 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
9820
9821 @sp 1
9822 @cartouche
9823 The time base for @code{delay_relative_statements} should be monotonic;
9824 it need not be the same time base as used for @code{Calendar.Clock}.
9825 @end cartouche
9826 Followed.
9827
9828 @unnumberedsec 10.2.1(12): Consistent Representation
9829 @sp 1
9830 @cartouche
9831 In an implementation, a type declared in a pre-elaborated package should
9832 have the same representation in every elaboration of a given version of
9833 the package, whether the elaborations occur in distinct executions of
9834 the same program, or in executions of distinct programs or partitions
9835 that include the given version.
9836 @end cartouche
9837 Followed, except in the case of tagged types.  Tagged types involve
9838 implicit pointers to a local copy of a dispatch table, and these pointers
9839 have representations which thus depend on a particular elaboration of the
9840 package.  It is not easy to see how it would be possible to follow this
9841 advice without severely impacting efficiency of execution.
9842
9843 @cindex Exception information
9844 @unnumberedsec 11.4.1(19): Exception Information
9845 @sp 1
9846 @cartouche
9847 @code{Exception_Message} by default and @code{Exception_Information}
9848 should produce information useful for
9849 debugging.  @code{Exception_Message} should be short, about one
9850 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
9851 should not include the
9852 @code{Exception_Name}.  @code{Exception_Information} should include both
9853 the @code{Exception_Name} and the @code{Exception_Message}.
9854 @end cartouche
9855 Followed.  For each exception that doesn't have a specified
9856 @code{Exception_Message}, the compiler generates one containing the location
9857 of the raise statement.  This location has the form ``file:line'', where
9858 file is the short file name (without path information) and line is the line
9859 number in the file.  Note that in the case of the Zero Cost Exception
9860 mechanism, these messages become redundant with the Exception_Information that
9861 contains a full backtrace of the calling sequence, so they are disabled.
9862 To disable explicitly the generation of the source location message, use the
9863 Pragma @code{Discard_Names}.
9864
9865 @cindex Suppression of checks
9866 @cindex Checks, suppression of
9867 @unnumberedsec 11.5(28): Suppression of Checks
9868 @sp 1
9869 @cartouche
9870 The implementation should minimize the code executed for checks that
9871 have been suppressed.
9872 @end cartouche
9873 Followed.
9874
9875 @cindex Representation clauses
9876 @unnumberedsec 13.1 (21-24): Representation Clauses
9877 @sp 1
9878 @cartouche
9879 The recommended level of support for all representation items is
9880 qualified as follows:
9881 @end cartouche
9882 @sp 1
9883 @cartouche
9884 An implementation need not support representation items containing
9885 non-static expressions, except that an implementation should support a
9886 representation item for a given entity if each non-static expression in
9887 the representation item is a name that statically denotes a constant
9888 declared before the entity.
9889 @end cartouche
9890 Followed.  In fact, GNAT goes beyond the recommended level of support
9891 by allowing nonstatic expressions in some representation clauses even
9892 without the need to declare constants initialized with the values of
9893 such expressions.
9894 For example:
9895
9896 @smallexample @c ada
9897   X : Integer;
9898   Y : Float;
9899   for Y'Address use X'Address;>>
9900 @end smallexample
9901
9902 @sp 1
9903 @cartouche
9904 An implementation need not support a specification for the @code{Size}
9905 for a given composite subtype, nor the size or storage place for an
9906 object (including a component) of a given composite subtype, unless the
9907 constraints on the subtype and its composite subcomponents (if any) are
9908 all static constraints.
9909 @end cartouche
9910 Followed.  Size Clauses are not permitted on non-static components, as
9911 described above.
9912
9913 @sp 1
9914 @cartouche
9915 An aliased component, or a component whose type is by-reference, should
9916 always be allocated at an addressable location.
9917 @end cartouche
9918 Followed.
9919
9920 @cindex Packed types
9921 @unnumberedsec 13.2(6-8): Packed Types
9922 @sp 1
9923 @cartouche
9924 If a type is packed, then the implementation should try to minimize
9925 storage allocated to objects of the type, possibly at the expense of
9926 speed of accessing components, subject to reasonable complexity in
9927 addressing calculations.
9928 @end cartouche
9929 @sp 1
9930 @cartouche
9931 The recommended level of support pragma @code{Pack} is:
9932
9933 For a packed record type, the components should be packed as tightly as
9934 possible subject to the Sizes of the component subtypes, and subject to
9935 any @code{record_representation_clause} that applies to the type; the
9936 implementation may, but need not, reorder components or cross aligned
9937 word boundaries to improve the packing.  A component whose @code{Size} is
9938 greater than the word size may be allocated an integral number of words.
9939 @end cartouche
9940 Followed.  Tight packing of arrays is supported for all component sizes
9941 up to 64-bits. If the array component size is 1 (that is to say, if
9942 the component is a boolean type or an enumeration type with two values)
9943 then values of the type are implicitly initialized to zero. This
9944 happens both for objects of the packed type, and for objects that have a
9945 subcomponent of the packed type.
9946
9947 @sp 1
9948 @cartouche
9949 An implementation should support Address clauses for imported
9950 subprograms.
9951 @end cartouche
9952 Followed.
9953 @cindex @code{Address} clauses
9954 @unnumberedsec 13.3(14-19): Address Clauses
9955
9956 @sp 1
9957 @cartouche
9958 For an array @var{X}, @code{@var{X}'Address} should point at the first
9959 component of the array, and not at the array bounds.
9960 @end cartouche
9961 Followed.
9962
9963 @sp 1
9964 @cartouche
9965 The recommended level of support for the @code{Address} attribute is:
9966
9967 @code{@var{X}'Address} should produce a useful result if @var{X} is an
9968 object that is aliased or of a by-reference type, or is an entity whose
9969 @code{Address} has been specified.
9970 @end cartouche
9971 Followed.  A valid address will be produced even if none of those
9972 conditions have been met.  If necessary, the object is forced into
9973 memory to ensure the address is valid.
9974
9975 @sp 1
9976 @cartouche
9977 An implementation should support @code{Address} clauses for imported
9978 subprograms.
9979 @end cartouche
9980 Followed.
9981
9982 @sp 1
9983 @cartouche
9984 Objects (including subcomponents) that are aliased or of a by-reference
9985 type should be allocated on storage element boundaries.
9986 @end cartouche
9987 Followed.
9988
9989 @sp 1
9990 @cartouche
9991 If the @code{Address} of an object is specified, or it is imported or exported,
9992 then the implementation should not perform optimizations based on
9993 assumptions of no aliases.
9994 @end cartouche
9995 Followed.
9996
9997 @cindex @code{Alignment} clauses
9998 @unnumberedsec 13.3(29-35): Alignment Clauses
9999 @sp 1
10000 @cartouche
10001 The recommended level of support for the @code{Alignment} attribute for
10002 subtypes is:
10003
10004 An implementation should support specified Alignments that are factors
10005 and multiples of the number of storage elements per word, subject to the
10006 following:
10007 @end cartouche
10008 Followed.
10009
10010 @sp 1
10011 @cartouche
10012 An implementation need not support specified @code{Alignment}s for
10013 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
10014 loaded and stored by available machine instructions.
10015 @end cartouche
10016 Followed.
10017
10018 @sp 1
10019 @cartouche
10020 An implementation need not support specified @code{Alignment}s that are
10021 greater than the maximum @code{Alignment} the implementation ever returns by
10022 default.
10023 @end cartouche
10024 Followed.
10025
10026 @sp 1
10027 @cartouche
10028 The recommended level of support for the @code{Alignment} attribute for
10029 objects is:
10030
10031 Same as above, for subtypes, but in addition:
10032 @end cartouche
10033 Followed.
10034
10035 @sp 1
10036 @cartouche
10037 For stand-alone library-level objects of statically constrained
10038 subtypes, the implementation should support all @code{Alignment}s
10039 supported by the target linker.  For example, page alignment is likely to
10040 be supported for such objects, but not for subtypes.
10041 @end cartouche
10042 Followed.
10043
10044 @cindex @code{Size} clauses
10045 @unnumberedsec 13.3(42-43): Size Clauses
10046 @sp 1
10047 @cartouche
10048 The recommended level of support for the @code{Size} attribute of
10049 objects is:
10050
10051 A @code{Size} clause should be supported for an object if the specified
10052 @code{Size} is at least as large as its subtype's @code{Size}, and
10053 corresponds to a size in storage elements that is a multiple of the
10054 object's @code{Alignment} (if the @code{Alignment} is nonzero).
10055 @end cartouche
10056 Followed.
10057
10058 @unnumberedsec 13.3(50-56): Size Clauses
10059 @sp 1
10060 @cartouche
10061 If the @code{Size} of a subtype is specified, and allows for efficient
10062 independent addressability (see 9.10) on the target architecture, then
10063 the @code{Size} of the following objects of the subtype should equal the
10064 @code{Size} of the subtype:
10065
10066 Aliased objects (including components).
10067 @end cartouche
10068 Followed.
10069
10070 @sp 1
10071 @cartouche
10072 @code{Size} clause on a composite subtype should not affect the
10073 internal layout of components.
10074 @end cartouche
10075 Followed. But note that this can be overridden by use of the implementation
10076 pragma Implicit_Packing in the case of packed arrays.
10077
10078 @sp 1
10079 @cartouche
10080 The recommended level of support for the @code{Size} attribute of subtypes is:
10081 @end cartouche
10082 @sp 1
10083 @cartouche
10084 The @code{Size} (if not specified) of a static discrete or fixed point
10085 subtype should be the number of bits needed to represent each value
10086 belonging to the subtype using an unbiased representation, leaving space
10087 for a sign bit only if the subtype contains negative values.  If such a
10088 subtype is a first subtype, then an implementation should support a
10089 specified @code{Size} for it that reflects this representation.
10090 @end cartouche
10091 Followed.
10092
10093 @sp 1
10094 @cartouche
10095 For a subtype implemented with levels of indirection, the @code{Size}
10096 should include the size of the pointers, but not the size of what they
10097 point at.
10098 @end cartouche
10099 Followed.
10100
10101 @cindex @code{Component_Size} clauses
10102 @unnumberedsec 13.3(71-73): Component Size Clauses
10103 @sp 1
10104 @cartouche
10105 The recommended level of support for the @code{Component_Size}
10106 attribute is:
10107 @end cartouche
10108 @sp 1
10109 @cartouche
10110 An implementation need not support specified @code{Component_Sizes} that are
10111 less than the @code{Size} of the component subtype.
10112 @end cartouche
10113 Followed.
10114
10115 @sp 1
10116 @cartouche
10117 An implementation should support specified @code{Component_Size}s that
10118 are factors and multiples of the word size.  For such
10119 @code{Component_Size}s, the array should contain no gaps between
10120 components.  For other @code{Component_Size}s (if supported), the array
10121 should contain no gaps between components when packing is also
10122 specified; the implementation should forbid this combination in cases
10123 where it cannot support a no-gaps representation.
10124 @end cartouche
10125 Followed.
10126
10127 @cindex Enumeration representation clauses
10128 @cindex Representation clauses, enumeration
10129 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
10130 @sp 1
10131 @cartouche
10132 The recommended level of support for enumeration representation clauses
10133 is:
10134
10135 An implementation need not support enumeration representation clauses
10136 for boolean types, but should at minimum support the internal codes in
10137 the range @code{System.Min_Int.System.Max_Int}.
10138 @end cartouche
10139 Followed.
10140
10141 @cindex Record representation clauses
10142 @cindex Representation clauses, records
10143 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
10144 @sp 1
10145 @cartouche
10146 The recommended level of support for
10147 @*@code{record_representation_clauses} is:
10148
10149 An implementation should support storage places that can be extracted
10150 with a load, mask, shift sequence of machine code, and set with a load,
10151 shift, mask, store sequence, given the available machine instructions
10152 and run-time model.
10153 @end cartouche
10154 Followed.
10155
10156 @sp 1
10157 @cartouche
10158 A storage place should be supported if its size is equal to the
10159 @code{Size} of the component subtype, and it starts and ends on a
10160 boundary that obeys the @code{Alignment} of the component subtype.
10161 @end cartouche
10162 Followed.
10163
10164 @sp 1
10165 @cartouche
10166 If the default bit ordering applies to the declaration of a given type,
10167 then for a component whose subtype's @code{Size} is less than the word
10168 size, any storage place that does not cross an aligned word boundary
10169 should be supported.
10170 @end cartouche
10171 Followed.
10172
10173 @sp 1
10174 @cartouche
10175 An implementation may reserve a storage place for the tag field of a
10176 tagged type, and disallow other components from overlapping that place.
10177 @end cartouche
10178 Followed.  The storage place for the tag field is the beginning of the tagged
10179 record, and its size is Address'Size.  GNAT will reject an explicit component
10180 clause for the tag field.
10181
10182 @sp 1
10183 @cartouche
10184 An implementation need not support a @code{component_clause} for a
10185 component of an extension part if the storage place is not after the
10186 storage places of all components of the parent type, whether or not
10187 those storage places had been specified.
10188 @end cartouche
10189 Followed.  The above advice on record representation clauses is followed,
10190 and all mentioned features are implemented.
10191
10192 @cindex Storage place attributes
10193 @unnumberedsec 13.5.2(5): Storage Place Attributes
10194 @sp 1
10195 @cartouche
10196 If a component is represented using some form of pointer (such as an
10197 offset) to the actual data of the component, and this data is contiguous
10198 with the rest of the object, then the storage place attributes should
10199 reflect the place of the actual data, not the pointer.  If a component is
10200 allocated discontinuously from the rest of the object, then a warning
10201 should be generated upon reference to one of its storage place
10202 attributes.
10203 @end cartouche
10204 Followed.  There are no such components in GNAT@.
10205
10206 @cindex Bit ordering
10207 @unnumberedsec 13.5.3(7-8): Bit Ordering
10208 @sp 1
10209 @cartouche
10210 The recommended level of support for the non-default bit ordering is:
10211 @end cartouche
10212 @sp 1
10213 @cartouche
10214 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
10215 should support the non-default bit ordering in addition to the default
10216 bit ordering.
10217 @end cartouche
10218 Followed.  Word size does not equal storage size in this implementation.
10219 Thus non-default bit ordering is not supported.
10220
10221 @cindex @code{Address}, as private type
10222 @unnumberedsec 13.7(37): Address as Private
10223 @sp 1
10224 @cartouche
10225 @code{Address} should be of a private type.
10226 @end cartouche
10227 Followed.
10228
10229 @cindex Operations, on @code{Address}
10230 @cindex @code{Address}, operations of
10231 @unnumberedsec 13.7.1(16): Address Operations
10232 @sp 1
10233 @cartouche
10234 Operations in @code{System} and its children should reflect the target
10235 environment semantics as closely as is reasonable.  For example, on most
10236 machines, it makes sense for address arithmetic to ``wrap around''.
10237 Operations that do not make sense should raise @code{Program_Error}.
10238 @end cartouche
10239 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
10240 operation raises @code{Program_Error}, since all operations make sense.
10241
10242 @cindex Unchecked conversion
10243 @unnumberedsec 13.9(14-17): Unchecked Conversion
10244 @sp 1
10245 @cartouche
10246 The @code{Size} of an array object should not include its bounds; hence,
10247 the bounds should not be part of the converted data.
10248 @end cartouche
10249 Followed.
10250
10251 @sp 1
10252 @cartouche
10253 The implementation should not generate unnecessary run-time checks to
10254 ensure that the representation of @var{S} is a representation of the
10255 target type.  It should take advantage of the permission to return by
10256 reference when possible.  Restrictions on unchecked conversions should be
10257 avoided unless required by the target environment.
10258 @end cartouche
10259 Followed.  There are no restrictions on unchecked conversion.  A warning is
10260 generated if the source and target types do not have the same size since
10261 the semantics in this case may be target dependent.
10262
10263 @sp 1
10264 @cartouche
10265 The recommended level of support for unchecked conversions is:
10266 @end cartouche
10267 @sp 1
10268 @cartouche
10269 Unchecked conversions should be supported and should be reversible in
10270 the cases where this clause defines the result.  To enable meaningful use
10271 of unchecked conversion, a contiguous representation should be used for
10272 elementary subtypes, for statically constrained array subtypes whose
10273 component subtype is one of the subtypes described in this paragraph,
10274 and for record subtypes without discriminants whose component subtypes
10275 are described in this paragraph.
10276 @end cartouche
10277 Followed.
10278
10279 @cindex Heap usage, implicit
10280 @unnumberedsec 13.11(23-25): Implicit Heap Usage
10281 @sp 1
10282 @cartouche
10283 An implementation should document any cases in which it dynamically
10284 allocates heap storage for a purpose other than the evaluation of an
10285 allocator.
10286 @end cartouche
10287 Followed, the only other points at which heap storage is dynamically
10288 allocated are as follows:
10289
10290 @itemize @bullet
10291 @item
10292 At initial elaboration time, to allocate dynamically sized global
10293 objects.
10294
10295 @item
10296 To allocate space for a task when a task is created.
10297
10298 @item
10299 To extend the secondary stack dynamically when needed.  The secondary
10300 stack is used for returning variable length results.
10301 @end itemize
10302
10303 @sp 1
10304 @cartouche
10305 A default (implementation-provided) storage pool for an
10306 access-to-constant type should not have overhead to support deallocation of
10307 individual objects.
10308 @end cartouche
10309 Followed.
10310
10311 @sp 1
10312 @cartouche
10313 A storage pool for an anonymous access type should be created at the
10314 point of an allocator for the type, and be reclaimed when the designated
10315 object becomes inaccessible.
10316 @end cartouche
10317 Followed.
10318
10319 @cindex Unchecked deallocation
10320 @unnumberedsec 13.11.2(17): Unchecked De-allocation
10321 @sp 1
10322 @cartouche
10323 For a standard storage pool, @code{Free} should actually reclaim the
10324 storage.
10325 @end cartouche
10326 Followed.
10327
10328 @cindex Stream oriented attributes
10329 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
10330 @sp 1
10331 @cartouche
10332 If a stream element is the same size as a storage element, then the
10333 normal in-memory representation should be used by @code{Read} and
10334 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
10335 should use the smallest number of stream elements needed to represent
10336 all values in the base range of the scalar type.
10337 @end cartouche
10338
10339 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
10340 which specifies using the size of the first subtype.
10341 However, such an implementation is based on direct binary
10342 representations and is therefore target- and endianness-dependent.
10343 To address this issue, GNAT also supplies an alternate implementation
10344 of the stream attributes @code{Read} and @code{Write},
10345 which uses the target-independent XDR standard representation
10346 for scalar types.
10347 @cindex XDR representation
10348 @cindex @code{Read} attribute
10349 @cindex @code{Write} attribute
10350 @cindex Stream oriented attributes
10351 The XDR implementation is provided as an alternative body of the
10352 @code{System.Stream_Attributes} package, in the file
10353 @file{s-stratt-xdr.adb} in the GNAT library.
10354 There is no @file{s-stratt-xdr.ads} file.
10355 In order to install the XDR implementation, do the following:
10356 @enumerate
10357 @item Replace the default implementation of the
10358 @code{System.Stream_Attributes} package with the XDR implementation.
10359 For example on a Unix platform issue the commands:
10360 @smallexample
10361 $ mv s-stratt.adb s-stratt-default.adb
10362 $ mv s-stratt-xdr.adb s-stratt.adb
10363 @end smallexample
10364
10365 @item
10366 Rebuild the GNAT run-time library as documented in
10367 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
10368 @end enumerate
10369
10370 @unnumberedsec A.1(52): Names of Predefined Numeric Types
10371 @sp 1
10372 @cartouche
10373 If an implementation provides additional named predefined integer types,
10374 then the names should end with @samp{Integer} as in
10375 @samp{Long_Integer}.  If an implementation provides additional named
10376 predefined floating point types, then the names should end with
10377 @samp{Float} as in @samp{Long_Float}.
10378 @end cartouche
10379 Followed.
10380
10381 @findex Ada.Characters.Handling
10382 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
10383 @sp 1
10384 @cartouche
10385 If an implementation provides a localized definition of @code{Character}
10386 or @code{Wide_Character}, then the effects of the subprograms in
10387 @code{Characters.Handling} should reflect the localizations.  See also
10388 3.5.2.
10389 @end cartouche
10390 Followed.  GNAT provides no such localized definitions.
10391
10392 @cindex Bounded-length strings
10393 @unnumberedsec A.4.4(106): Bounded-Length String Handling
10394 @sp 1
10395 @cartouche
10396 Bounded string objects should not be implemented by implicit pointers
10397 and dynamic allocation.
10398 @end cartouche
10399 Followed.  No implicit pointers or dynamic allocation are used.
10400
10401 @cindex Random number generation
10402 @unnumberedsec A.5.2(46-47): Random Number Generation
10403 @sp 1
10404 @cartouche
10405 Any storage associated with an object of type @code{Generator} should be
10406 reclaimed on exit from the scope of the object.
10407 @end cartouche
10408 Followed.
10409
10410 @sp 1
10411 @cartouche
10412 If the generator period is sufficiently long in relation to the number
10413 of distinct initiator values, then each possible value of
10414 @code{Initiator} passed to @code{Reset} should initiate a sequence of
10415 random numbers that does not, in a practical sense, overlap the sequence
10416 initiated by any other value.  If this is not possible, then the mapping
10417 between initiator values and generator states should be a rapidly
10418 varying function of the initiator value.
10419 @end cartouche
10420 Followed.  The generator period is sufficiently long for the first
10421 condition here to hold true.
10422
10423 @findex Get_Immediate
10424 @unnumberedsec A.10.7(23): @code{Get_Immediate}
10425 @sp 1
10426 @cartouche
10427 The @code{Get_Immediate} procedures should be implemented with
10428 unbuffered input.  For a device such as a keyboard, input should be
10429 @dfn{available} if a key has already been typed, whereas for a disk
10430 file, input should always be available except at end of file.  For a file
10431 associated with a keyboard-like device, any line-editing features of the
10432 underlying operating system should be disabled during the execution of
10433 @code{Get_Immediate}.
10434 @end cartouche
10435 Followed on all targets except VxWorks. For VxWorks, there is no way to
10436 provide this functionality that does not result in the input buffer being
10437 flushed before the @code{Get_Immediate} call. A special unit
10438 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
10439 this functionality.
10440
10441 @findex Export
10442 @unnumberedsec B.1(39-41): Pragma @code{Export}
10443 @sp 1
10444 @cartouche
10445 If an implementation supports pragma @code{Export} to a given language,
10446 then it should also allow the main subprogram to be written in that
10447 language.  It should support some mechanism for invoking the elaboration
10448 of the Ada library units included in the system, and for invoking the
10449 finalization of the environment task.  On typical systems, the
10450 recommended mechanism is to provide two subprograms whose link names are
10451 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
10452 elaboration code for library units.  @code{adafinal} should contain the
10453 finalization code.  These subprograms should have no effect the second
10454 and subsequent time they are called.
10455 @end cartouche
10456 Followed.
10457
10458 @sp 1
10459 @cartouche
10460 Automatic elaboration of pre-elaborated packages should be
10461 provided when pragma @code{Export} is supported.
10462 @end cartouche
10463 Followed when the main program is in Ada.  If the main program is in a
10464 foreign language, then
10465 @code{adainit} must be called to elaborate pre-elaborated
10466 packages.
10467
10468 @sp 1
10469 @cartouche
10470 For each supported convention @var{L} other than @code{Intrinsic}, an
10471 implementation should support @code{Import} and @code{Export} pragmas
10472 for objects of @var{L}-compatible types and for subprograms, and pragma
10473 @code{Convention} for @var{L}-eligible types and for subprograms,
10474 presuming the other language has corresponding features.  Pragma
10475 @code{Convention} need not be supported for scalar types.
10476 @end cartouche
10477 Followed.
10478
10479 @cindex Package @code{Interfaces}
10480 @findex Interfaces
10481 @unnumberedsec B.2(12-13): Package @code{Interfaces}
10482 @sp 1
10483 @cartouche
10484 For each implementation-defined convention identifier, there should be a
10485 child package of package Interfaces with the corresponding name.  This
10486 package should contain any declarations that would be useful for
10487 interfacing to the language (implementation) represented by the
10488 convention.  Any declarations useful for interfacing to any language on
10489 the given hardware architecture should be provided directly in
10490 @code{Interfaces}.
10491 @end cartouche
10492 Followed. An additional package not defined
10493 in the Ada Reference Manual is @code{Interfaces.CPP}, used
10494 for interfacing to C++.
10495
10496 @sp 1
10497 @cartouche
10498 An implementation supporting an interface to C, COBOL, or Fortran should
10499 provide the corresponding package or packages described in the following
10500 clauses.
10501 @end cartouche
10502 Followed.  GNAT provides all the packages described in this section.
10503
10504 @cindex C, interfacing with
10505 @unnumberedsec B.3(63-71): Interfacing with C
10506 @sp 1
10507 @cartouche
10508 An implementation should support the following interface correspondences
10509 between Ada and C@.
10510 @end cartouche
10511 Followed.
10512
10513 @sp 1
10514 @cartouche
10515 An Ada procedure corresponds to a void-returning C function.
10516 @end cartouche
10517 Followed.
10518
10519 @sp 1
10520 @cartouche
10521 An Ada function corresponds to a non-void C function.
10522 @end cartouche
10523 Followed.
10524
10525 @sp 1
10526 @cartouche
10527 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
10528 function.
10529 @end cartouche
10530 Followed.
10531
10532 @sp 1
10533 @cartouche
10534 An Ada @code{in} parameter of an access-to-object type with designated
10535 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
10536 where @var{t} is the C type corresponding to the Ada type @var{T}.
10537 @end cartouche
10538 Followed.
10539
10540 @sp 1
10541 @cartouche
10542 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
10543 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
10544 argument to a C function, where @var{t} is the C type corresponding to
10545 the Ada type @var{T}.  In the case of an elementary @code{out} or
10546 @code{in out} parameter, a pointer to a temporary copy is used to
10547 preserve by-copy semantics.
10548 @end cartouche
10549 Followed.
10550
10551 @sp 1
10552 @cartouche
10553 An Ada parameter of a record type @var{T}, of any mode, is passed as a
10554 @code{@var{t}*} argument to a C function, where @var{t} is the C
10555 structure corresponding to the Ada type @var{T}.
10556 @end cartouche
10557 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
10558 pragma, or Convention, or by explicitly specifying the mechanism for a given
10559 call using an extended import or export pragma.
10560
10561 @sp 1
10562 @cartouche
10563 An Ada parameter of an array type with component type @var{T}, of any
10564 mode, is passed as a @code{@var{t}*} argument to a C function, where
10565 @var{t} is the C type corresponding to the Ada type @var{T}.
10566 @end cartouche
10567 Followed.
10568
10569 @sp 1
10570 @cartouche
10571 An Ada parameter of an access-to-subprogram type is passed as a pointer
10572 to a C function whose prototype corresponds to the designated
10573 subprogram's specification.
10574 @end cartouche
10575 Followed.
10576
10577 @cindex COBOL, interfacing with
10578 @unnumberedsec B.4(95-98): Interfacing with COBOL
10579 @sp 1
10580 @cartouche
10581 An Ada implementation should support the following interface
10582 correspondences between Ada and COBOL@.
10583 @end cartouche
10584 Followed.
10585
10586 @sp 1
10587 @cartouche
10588 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
10589 the COBOL type corresponding to @var{T}.
10590 @end cartouche
10591 Followed.
10592
10593 @sp 1
10594 @cartouche
10595 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
10596 the corresponding COBOL type.
10597 @end cartouche
10598 Followed.
10599
10600 @sp 1
10601 @cartouche
10602 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
10603 COBOL type corresponding to the Ada parameter type; for scalars, a local
10604 copy is used if necessary to ensure by-copy semantics.
10605 @end cartouche
10606 Followed.
10607
10608 @cindex Fortran, interfacing with
10609 @unnumberedsec B.5(22-26): Interfacing with Fortran
10610 @sp 1
10611 @cartouche
10612 An Ada implementation should support the following interface
10613 correspondences between Ada and Fortran:
10614 @end cartouche
10615 Followed.
10616
10617 @sp 1
10618 @cartouche
10619 An Ada procedure corresponds to a Fortran subroutine.
10620 @end cartouche
10621 Followed.
10622
10623 @sp 1
10624 @cartouche
10625 An Ada function corresponds to a Fortran function.
10626 @end cartouche
10627 Followed.
10628
10629 @sp 1
10630 @cartouche
10631 An Ada parameter of an elementary, array, or record type @var{T} is
10632 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
10633 the Fortran type corresponding to the Ada type @var{T}, and where the
10634 INTENT attribute of the corresponding dummy argument matches the Ada
10635 formal parameter mode; the Fortran implementation's parameter passing
10636 conventions are used.  For elementary types, a local copy is used if
10637 necessary to ensure by-copy semantics.
10638 @end cartouche
10639 Followed.
10640
10641 @sp 1
10642 @cartouche
10643 An Ada parameter of an access-to-subprogram type is passed as a
10644 reference to a Fortran procedure whose interface corresponds to the
10645 designated subprogram's specification.
10646 @end cartouche
10647 Followed.
10648
10649 @cindex Machine operations
10650 @unnumberedsec C.1(3-5): Access to Machine Operations
10651 @sp 1
10652 @cartouche
10653 The machine code or intrinsic support should allow access to all
10654 operations normally available to assembly language programmers for the
10655 target environment, including privileged instructions, if any.
10656 @end cartouche
10657 Followed.
10658
10659 @sp 1
10660 @cartouche
10661 The interfacing pragmas (see Annex B) should support interface to
10662 assembler; the default assembler should be associated with the
10663 convention identifier @code{Assembler}.
10664 @end cartouche
10665 Followed.
10666
10667 @sp 1
10668 @cartouche
10669 If an entity is exported to assembly language, then the implementation
10670 should allocate it at an addressable location, and should ensure that it
10671 is retained by the linking process, even if not otherwise referenced
10672 from the Ada code.  The implementation should assume that any call to a
10673 machine code or assembler subprogram is allowed to read or update every
10674 object that is specified as exported.
10675 @end cartouche
10676 Followed.
10677
10678 @unnumberedsec C.1(10-16): Access to Machine Operations
10679 @sp 1
10680 @cartouche
10681 The implementation should ensure that little or no overhead is
10682 associated with calling intrinsic and machine-code subprograms.
10683 @end cartouche
10684 Followed for both intrinsics and machine-code subprograms.
10685
10686 @sp 1
10687 @cartouche
10688 It is recommended that intrinsic subprograms be provided for convenient
10689 access to any machine operations that provide special capabilities or
10690 efficiency and that are not otherwise available through the language
10691 constructs.
10692 @end cartouche
10693 Followed.  A full set of machine operation intrinsic subprograms is provided.
10694
10695 @sp 1
10696 @cartouche
10697 Atomic read-modify-write operations---e.g.@:, test and set, compare and
10698 swap, decrement and test, enqueue/dequeue.
10699 @end cartouche
10700 Followed on any target supporting such operations.
10701
10702 @sp 1
10703 @cartouche
10704 Standard numeric functions---e.g.@:, sin, log.
10705 @end cartouche
10706 Followed on any target supporting such operations.
10707
10708 @sp 1
10709 @cartouche
10710 String manipulation operations---e.g.@:, translate and test.
10711 @end cartouche
10712 Followed on any target supporting such operations.
10713
10714 @sp 1
10715 @cartouche
10716 Vector operations---e.g.@:, compare vector against thresholds.
10717 @end cartouche
10718 Followed on any target supporting such operations.
10719
10720 @sp 1
10721 @cartouche
10722 Direct operations on I/O ports.
10723 @end cartouche
10724 Followed on any target supporting such operations.
10725
10726 @cindex Interrupt support
10727 @unnumberedsec C.3(28): Interrupt Support
10728 @sp 1
10729 @cartouche
10730 If the @code{Ceiling_Locking} policy is not in effect, the
10731 implementation should provide means for the application to specify which
10732 interrupts are to be blocked during protected actions, if the underlying
10733 system allows for a finer-grain control of interrupt blocking.
10734 @end cartouche
10735 Followed.  The underlying system does not allow for finer-grain control
10736 of interrupt blocking.
10737
10738 @cindex Protected procedure handlers
10739 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
10740 @sp 1
10741 @cartouche
10742 Whenever possible, the implementation should allow interrupt handlers to
10743 be called directly by the hardware.
10744 @end cartouche
10745 Followed on any target where the underlying operating system permits
10746 such direct calls.
10747
10748 @sp 1
10749 @cartouche
10750 Whenever practical, violations of any
10751 implementation-defined restrictions should be detected before run time.
10752 @end cartouche
10753 Followed.  Compile time warnings are given when possible.
10754
10755 @cindex Package @code{Interrupts}
10756 @findex Interrupts
10757 @unnumberedsec C.3.2(25): Package @code{Interrupts}
10758
10759 @sp 1
10760 @cartouche
10761 If implementation-defined forms of interrupt handler procedures are
10762 supported, such as protected procedures with parameters, then for each
10763 such form of a handler, a type analogous to @code{Parameterless_Handler}
10764 should be specified in a child package of @code{Interrupts}, with the
10765 same operations as in the predefined package Interrupts.
10766 @end cartouche
10767 Followed.
10768
10769 @cindex Pre-elaboration requirements
10770 @unnumberedsec C.4(14): Pre-elaboration Requirements
10771 @sp 1
10772 @cartouche
10773 It is recommended that pre-elaborated packages be implemented in such a
10774 way that there should be little or no code executed at run time for the
10775 elaboration of entities not already covered by the Implementation
10776 Requirements.
10777 @end cartouche
10778 Followed.  Executable code is generated in some cases, e.g.@: loops
10779 to initialize large arrays.
10780
10781 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
10782 @sp 1
10783 @cartouche
10784 If the pragma applies to an entity, then the implementation should
10785 reduce the amount of storage used for storing names associated with that
10786 entity.
10787 @end cartouche
10788 Followed.
10789
10790 @cindex Package @code{Task_Attributes}
10791 @findex Task_Attributes
10792 @unnumberedsec C.7.2(30): The Package Task_Attributes
10793 @sp 1
10794 @cartouche
10795 Some implementations are targeted to domains in which memory use at run
10796 time must be completely deterministic.  For such implementations, it is
10797 recommended that the storage for task attributes will be pre-allocated
10798 statically and not from the heap.  This can be accomplished by either
10799 placing restrictions on the number and the size of the task's
10800 attributes, or by using the pre-allocated storage for the first @var{N}
10801 attribute objects, and the heap for the others.  In the latter case,
10802 @var{N} should be documented.
10803 @end cartouche
10804 Not followed.  This implementation is not targeted to such a domain.
10805
10806 @cindex Locking Policies
10807 @unnumberedsec D.3(17): Locking Policies
10808
10809 @sp 1
10810 @cartouche
10811 The implementation should use names that end with @samp{_Locking} for
10812 locking policies defined by the implementation.
10813 @end cartouche
10814 Followed.  Two implementation-defined locking policies are defined,
10815 whose names (@code{Inheritance_Locking} and
10816 @code{Concurrent_Readers_Locking}) follow this suggestion.
10817
10818 @cindex Entry queuing policies
10819 @unnumberedsec D.4(16): Entry Queuing Policies
10820 @sp 1
10821 @cartouche
10822 Names that end with @samp{_Queuing} should be used
10823 for all implementation-defined queuing policies.
10824 @end cartouche
10825 Followed.  No such implementation-defined queuing policies exist.
10826
10827 @cindex Preemptive abort
10828 @unnumberedsec D.6(9-10): Preemptive Abort
10829 @sp 1
10830 @cartouche
10831 Even though the @code{abort_statement} is included in the list of
10832 potentially blocking operations (see 9.5.1), it is recommended that this
10833 statement be implemented in a way that never requires the task executing
10834 the @code{abort_statement} to block.
10835 @end cartouche
10836 Followed.
10837
10838 @sp 1
10839 @cartouche
10840 On a multi-processor, the delay associated with aborting a task on
10841 another processor should be bounded; the implementation should use
10842 periodic polling, if necessary, to achieve this.
10843 @end cartouche
10844 Followed.
10845
10846 @cindex Tasking restrictions
10847 @unnumberedsec D.7(21): Tasking Restrictions
10848 @sp 1
10849 @cartouche
10850 When feasible, the implementation should take advantage of the specified
10851 restrictions to produce a more efficient implementation.
10852 @end cartouche
10853 GNAT currently takes advantage of these restrictions by providing an optimized
10854 run time when the Ravenscar profile and the GNAT restricted run time set
10855 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
10856 pragma @code{Profile (Restricted)} for more details.
10857
10858 @cindex Time, monotonic
10859 @unnumberedsec D.8(47-49): Monotonic Time
10860 @sp 1
10861 @cartouche
10862 When appropriate, implementations should provide configuration
10863 mechanisms to change the value of @code{Tick}.
10864 @end cartouche
10865 Such configuration mechanisms are not appropriate to this implementation
10866 and are thus not supported.
10867
10868 @sp 1
10869 @cartouche
10870 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
10871 be implemented as transformations of the same time base.
10872 @end cartouche
10873 Followed.
10874
10875 @sp 1
10876 @cartouche
10877 It is recommended that the @dfn{best} time base which exists in
10878 the underlying system be available to the application through
10879 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
10880 @end cartouche
10881 Followed.
10882
10883 @cindex Partition communication subsystem
10884 @cindex PCS
10885 @unnumberedsec E.5(28-29): Partition Communication Subsystem
10886 @sp 1
10887 @cartouche
10888 Whenever possible, the PCS on the called partition should allow for
10889 multiple tasks to call the RPC-receiver with different messages and
10890 should allow them to block until the corresponding subprogram body
10891 returns.
10892 @end cartouche
10893 Followed by GLADE, a separately supplied PCS that can be used with
10894 GNAT.
10895
10896 @sp 1
10897 @cartouche
10898 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
10899 should raise @code{Storage_Error} if it runs out of space trying to
10900 write the @code{Item} into the stream.
10901 @end cartouche
10902 Followed by GLADE, a separately supplied PCS that can be used with
10903 GNAT@.
10904
10905 @cindex COBOL support
10906 @unnumberedsec F(7): COBOL Support
10907 @sp 1
10908 @cartouche
10909 If COBOL (respectively, C) is widely supported in the target
10910 environment, implementations supporting the Information Systems Annex
10911 should provide the child package @code{Interfaces.COBOL} (respectively,
10912 @code{Interfaces.C}) specified in Annex B and should support a
10913 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
10914 pragmas (see Annex B), thus allowing Ada programs to interface with
10915 programs written in that language.
10916 @end cartouche
10917 Followed.
10918
10919 @cindex Decimal radix support
10920 @unnumberedsec F.1(2): Decimal Radix Support
10921 @sp 1
10922 @cartouche
10923 Packed decimal should be used as the internal representation for objects
10924 of subtype @var{S} when @var{S}'Machine_Radix = 10.
10925 @end cartouche
10926 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
10927 representations.
10928
10929 @cindex Numerics
10930 @unnumberedsec G: Numerics
10931 @sp 2
10932 @cartouche
10933 If Fortran (respectively, C) is widely supported in the target
10934 environment, implementations supporting the Numerics Annex
10935 should provide the child package @code{Interfaces.Fortran} (respectively,
10936 @code{Interfaces.C}) specified in Annex B and should support a
10937 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
10938 pragmas (see Annex B), thus allowing Ada programs to interface with
10939 programs written in that language.
10940 @end cartouche
10941 Followed.
10942
10943 @cindex Complex types
10944 @unnumberedsec G.1.1(56-58): Complex Types
10945 @sp 2
10946 @cartouche
10947 Because the usual mathematical meaning of multiplication of a complex
10948 operand and a real operand is that of the scaling of both components of
10949 the former by the latter, an implementation should not perform this
10950 operation by first promoting the real operand to complex type and then
10951 performing a full complex multiplication.  In systems that, in the
10952 future, support an Ada binding to IEC 559:1989, the latter technique
10953 will not generate the required result when one of the components of the
10954 complex operand is infinite.  (Explicit multiplication of the infinite
10955 component by the zero component obtained during promotion yields a NaN
10956 that propagates into the final result.) Analogous advice applies in the
10957 case of multiplication of a complex operand and a pure-imaginary
10958 operand, and in the case of division of a complex operand by a real or
10959 pure-imaginary operand.
10960 @end cartouche
10961 Not followed.
10962
10963 @sp 1
10964 @cartouche
10965 Similarly, because the usual mathematical meaning of addition of a
10966 complex operand and a real operand is that the imaginary operand remains
10967 unchanged, an implementation should not perform this operation by first
10968 promoting the real operand to complex type and then performing a full
10969 complex addition.  In implementations in which the @code{Signed_Zeros}
10970 attribute of the component type is @code{True} (and which therefore
10971 conform to IEC 559:1989 in regard to the handling of the sign of zero in
10972 predefined arithmetic operations), the latter technique will not
10973 generate the required result when the imaginary component of the complex
10974 operand is a negatively signed zero.  (Explicit addition of the negative
10975 zero to the zero obtained during promotion yields a positive zero.)
10976 Analogous advice applies in the case of addition of a complex operand
10977 and a pure-imaginary operand, and in the case of subtraction of a
10978 complex operand and a real or pure-imaginary operand.
10979 @end cartouche
10980 Not followed.
10981
10982 @sp 1
10983 @cartouche
10984 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
10985 attempt to provide a rational treatment of the signs of zero results and
10986 result components.  As one example, the result of the @code{Argument}
10987 function should have the sign of the imaginary component of the
10988 parameter @code{X} when the point represented by that parameter lies on
10989 the positive real axis; as another, the sign of the imaginary component
10990 of the @code{Compose_From_Polar} function should be the same as
10991 (respectively, the opposite of) that of the @code{Argument} parameter when that
10992 parameter has a value of zero and the @code{Modulus} parameter has a
10993 nonnegative (respectively, negative) value.
10994 @end cartouche
10995 Followed.
10996
10997 @cindex Complex elementary functions
10998 @unnumberedsec G.1.2(49): Complex Elementary Functions
10999 @sp 1
11000 @cartouche
11001 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
11002 @code{True} should attempt to provide a rational treatment of the signs
11003 of zero results and result components.  For example, many of the complex
11004 elementary functions have components that are odd functions of one of
11005 the parameter components; in these cases, the result component should
11006 have the sign of the parameter component at the origin.  Other complex
11007 elementary functions have zero components whose sign is opposite that of
11008 a parameter component at the origin, or is always positive or always
11009 negative.
11010 @end cartouche
11011 Followed.
11012
11013 @cindex Accuracy requirements
11014 @unnumberedsec G.2.4(19): Accuracy Requirements
11015 @sp 1
11016 @cartouche
11017 The versions of the forward trigonometric functions without a
11018 @code{Cycle} parameter should not be implemented by calling the
11019 corresponding version with a @code{Cycle} parameter of
11020 @code{2.0*Numerics.Pi}, since this will not provide the required
11021 accuracy in some portions of the domain.  For the same reason, the
11022 version of @code{Log} without a @code{Base} parameter should not be
11023 implemented by calling the corresponding version with a @code{Base}
11024 parameter of @code{Numerics.e}.
11025 @end cartouche
11026 Followed.
11027
11028 @cindex Complex arithmetic accuracy
11029 @cindex Accuracy, complex arithmetic
11030 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
11031
11032 @sp 1
11033 @cartouche
11034 The version of the @code{Compose_From_Polar} function without a
11035 @code{Cycle} parameter should not be implemented by calling the
11036 corresponding version with a @code{Cycle} parameter of
11037 @code{2.0*Numerics.Pi}, since this will not provide the required
11038 accuracy in some portions of the domain.
11039 @end cartouche
11040 Followed.
11041
11042 @cindex Sequential elaboration policy
11043 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
11044
11045 @sp 1
11046 @cartouche
11047 If the partition elaboration policy is @code{Sequential} and the
11048 Environment task becomes permanently blocked during elaboration then the
11049 partition is deadlocked and it is recommended that the partition be
11050 immediately terminated.
11051 @end cartouche
11052 Not followed.
11053
11054 @c -----------------------------------------
11055 @node Implementation Defined Characteristics
11056 @chapter Implementation Defined Characteristics
11057
11058 @noindent
11059 In addition to the implementation dependent pragmas and attributes, and the
11060 implementation advice, there are a number of other Ada features that are
11061 potentially implementation dependent and are designated as
11062 implementation-defined. These are mentioned throughout the Ada Reference
11063 Manual, and are summarized in Annex M@.
11064
11065 A requirement for conforming Ada compilers is that they provide
11066 documentation describing how the implementation deals with each of these
11067 issues.  In this chapter, you will find each point in Annex M listed
11068 followed by a description in italic font of how GNAT
11069 handles the implementation dependence.
11070
11071 You can use this chapter as a guide to minimizing implementation
11072 dependent features in your programs if portability to other compilers
11073 and other operating systems is an important consideration.  The numbers
11074 in each section below correspond to the paragraph number in the Ada
11075 Reference Manual.
11076
11077 @sp 1
11078 @cartouche
11079 @noindent
11080 @strong{2}.  Whether or not each recommendation given in Implementation
11081 Advice is followed.  See 1.1.2(37).
11082 @end cartouche
11083 @noindent
11084 @xref{Implementation Advice}.
11085
11086 @sp 1
11087 @cartouche
11088 @noindent
11089 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
11090 @end cartouche
11091 @noindent
11092 The complexity of programs that can be processed is limited only by the
11093 total amount of available virtual memory, and disk space for the
11094 generated object files.
11095
11096 @sp 1
11097 @cartouche
11098 @noindent
11099 @strong{4}.  Variations from the standard that are impractical to avoid
11100 given the implementation's execution environment.  See 1.1.3(6).
11101 @end cartouche
11102 @noindent
11103 There are no variations from the standard.
11104
11105 @sp 1
11106 @cartouche
11107 @noindent
11108 @strong{5}.  Which @code{code_statement}s cause external
11109 interactions.  See 1.1.3(10).
11110 @end cartouche
11111 @noindent
11112 Any @code{code_statement} can potentially cause external interactions.
11113
11114 @sp 1
11115 @cartouche
11116 @noindent
11117 @strong{6}.  The coded representation for the text of an Ada
11118 program.  See 2.1(4).
11119 @end cartouche
11120 @noindent
11121 See separate section on source representation.
11122
11123 @sp 1
11124 @cartouche
11125 @noindent
11126 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
11127 @end cartouche
11128 @noindent
11129 See separate section on source representation.
11130
11131 @sp 1
11132 @cartouche
11133 @noindent
11134 @strong{8}.  The representation for an end of line.  See 2.2(2).
11135 @end cartouche
11136 @noindent
11137 See separate section on source representation.
11138
11139 @sp 1
11140 @cartouche
11141 @noindent
11142 @strong{9}.  Maximum supported line length and lexical element
11143 length.  See 2.2(15).
11144 @end cartouche
11145 @noindent
11146 The maximum line length is 255 characters and the maximum length of
11147 a lexical element is also 255 characters. This is the default setting
11148 if not overridden by the use of compiler switch @option{-gnaty} (which
11149 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
11150 line length to be specified to be any value up to 32767. The maximum
11151 length of a lexical element is the same as the maximum line length.
11152
11153 @sp 1
11154 @cartouche
11155 @noindent
11156 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
11157 @end cartouche
11158 @noindent
11159
11160 @xref{Implementation Defined Pragmas}.
11161
11162 @sp 1
11163 @cartouche
11164 @noindent
11165 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
11166 @end cartouche
11167 @noindent
11168 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
11169 parameter, checks that the optimization flag is set, and aborts if it is
11170 not.
11171
11172 @sp 1
11173 @cartouche
11174 @noindent
11175 @strong{12}.  The sequence of characters of the value returned by
11176 @code{@var{S}'Image} when some of the graphic characters of
11177 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
11178 3.5(37).
11179 @end cartouche
11180 @noindent
11181 The sequence of characters is as defined by the wide character encoding
11182 method used for the source.  See section on source representation for
11183 further details.
11184
11185 @sp 1
11186 @cartouche
11187 @noindent
11188 @strong{13}.  The predefined integer types declared in
11189 @code{Standard}.  See 3.5.4(25).
11190 @end cartouche
11191 @noindent
11192 @table @code
11193 @item Short_Short_Integer
11194 8 bit signed
11195 @item Short_Integer
11196 (Short) 16 bit signed
11197 @item Integer
11198 32 bit signed
11199 @item Long_Integer
11200 64 bit signed (on most 64 bit targets, depending on the C definition of long).
11201 32 bit signed (all other targets)
11202 @item Long_Long_Integer
11203 64 bit signed
11204 @end table
11205
11206 @sp 1
11207 @cartouche
11208 @noindent
11209 @strong{14}.  Any nonstandard integer types and the operators defined
11210 for them.  See 3.5.4(26).
11211 @end cartouche
11212 @noindent
11213 There are no nonstandard integer types.
11214
11215 @sp 1
11216 @cartouche
11217 @noindent
11218 @strong{15}.  Any nonstandard real types and the operators defined for
11219 them.  See 3.5.6(8).
11220 @end cartouche
11221 @noindent
11222 There are no nonstandard real types.
11223
11224 @sp 1
11225 @cartouche
11226 @noindent
11227 @strong{16}.  What combinations of requested decimal precision and range
11228 are supported for floating point types.  See 3.5.7(7).
11229 @end cartouche
11230 @noindent
11231 The precision and range is as defined by the IEEE standard.
11232
11233 @sp 1
11234 @cartouche
11235 @noindent
11236 @strong{17}.  The predefined floating point types declared in
11237 @code{Standard}.  See 3.5.7(16).
11238 @end cartouche
11239 @noindent
11240 @table @code
11241 @item Short_Float
11242 32 bit IEEE short
11243 @item Float
11244 (Short) 32 bit IEEE short
11245 @item Long_Float
11246 64 bit IEEE long
11247 @item Long_Long_Float
11248 64 bit IEEE long (80 bit IEEE long on x86 processors)
11249 @end table
11250
11251 @sp 1
11252 @cartouche
11253 @noindent
11254 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
11255 @end cartouche
11256 @noindent
11257 @code{Fine_Delta} is 2**(@minus{}63)
11258
11259 @sp 1
11260 @cartouche
11261 @noindent
11262 @strong{19}.  What combinations of small, range, and digits are
11263 supported for fixed point types.  See 3.5.9(10).
11264 @end cartouche
11265 @noindent
11266 Any combinations are permitted that do not result in a small less than
11267 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
11268 If the mantissa is larger than 53 bits on machines where Long_Long_Float
11269 is 64 bits (true of all architectures except ia32), then the output from
11270 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
11271 is because floating-point conversions are used to convert fixed point.
11272
11273 @sp 1
11274 @cartouche
11275 @noindent
11276 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
11277 within an unnamed @code{block_statement}.  See 3.9(10).
11278 @end cartouche
11279 @noindent
11280 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
11281 decimal integer are allocated.
11282
11283 @sp 1
11284 @cartouche
11285 @noindent
11286 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
11287 @end cartouche
11288 @noindent
11289 @xref{Implementation Defined Attributes}.
11290
11291 @sp 1
11292 @cartouche
11293 @noindent
11294 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
11295 @end cartouche
11296 @noindent
11297 There are no implementation-defined time types.
11298
11299 @sp 1
11300 @cartouche
11301 @noindent
11302 @strong{23}.  The time base associated with relative delays.
11303 @end cartouche
11304 @noindent
11305 See 9.6(20).  The time base used is that provided by the C library
11306 function @code{gettimeofday}.
11307
11308 @sp 1
11309 @cartouche
11310 @noindent
11311 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
11312 9.6(23).
11313 @end cartouche
11314 @noindent
11315 The time base used is that provided by the C library function
11316 @code{gettimeofday}.
11317
11318 @sp 1
11319 @cartouche
11320 @noindent
11321 @strong{25}.  The time zone used for package @code{Calendar}
11322 operations.  See 9.6(24).
11323 @end cartouche
11324 @noindent
11325 The time zone used by package @code{Calendar} is the current system time zone
11326 setting for local time, as accessed by the C library function
11327 @code{localtime}.
11328
11329 @sp 1
11330 @cartouche
11331 @noindent
11332 @strong{26}.  Any limit on @code{delay_until_statements} of
11333 @code{select_statements}.  See 9.6(29).
11334 @end cartouche
11335 @noindent
11336 There are no such limits.
11337
11338 @sp 1
11339 @cartouche
11340 @noindent
11341 @strong{27}.  Whether or not two non-overlapping parts of a composite
11342 object are independently addressable, in the case where packing, record
11343 layout, or @code{Component_Size} is specified for the object.  See
11344 9.10(1).
11345 @end cartouche
11346 @noindent
11347 Separate components are independently addressable if they do not share
11348 overlapping storage units.
11349
11350 @sp 1
11351 @cartouche
11352 @noindent
11353 @strong{28}.  The representation for a compilation.  See 10.1(2).
11354 @end cartouche
11355 @noindent
11356 A compilation is represented by a sequence of files presented to the
11357 compiler in a single invocation of the @command{gcc} command.
11358
11359 @sp 1
11360 @cartouche
11361 @noindent
11362 @strong{29}.  Any restrictions on compilations that contain multiple
11363 compilation_units.  See 10.1(4).
11364 @end cartouche
11365 @noindent
11366 No single file can contain more than one compilation unit, but any
11367 sequence of files can be presented to the compiler as a single
11368 compilation.
11369
11370 @sp 1
11371 @cartouche
11372 @noindent
11373 @strong{30}.  The mechanisms for creating an environment and for adding
11374 and replacing compilation units.  See 10.1.4(3).
11375 @end cartouche
11376 @noindent
11377 See separate section on compilation model.
11378
11379 @sp 1
11380 @cartouche
11381 @noindent
11382 @strong{31}.  The manner of explicitly assigning library units to a
11383 partition.  See 10.2(2).
11384 @end cartouche
11385 @noindent
11386 If a unit contains an Ada main program, then the Ada units for the partition
11387 are determined by recursive application of the rules in the Ada Reference
11388 Manual section 10.2(2-6).  In other words, the Ada units will be those that
11389 are needed by the main program, and then this definition of need is applied
11390 recursively to those units, and the partition contains the transitive
11391 closure determined by this relationship.  In short, all the necessary units
11392 are included, with no need to explicitly specify the list.  If additional
11393 units are required, e.g.@: by foreign language units, then all units must be
11394 mentioned in the context clause of one of the needed Ada units.
11395
11396 If the partition contains no main program, or if the main program is in
11397 a language other than Ada, then GNAT
11398 provides the binder options @option{-z} and @option{-n} respectively, and in
11399 this case a list of units can be explicitly supplied to the binder for
11400 inclusion in the partition (all units needed by these units will also
11401 be included automatically).  For full details on the use of these
11402 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
11403 @value{EDITION} User's Guide}.
11404
11405 @sp 1
11406 @cartouche
11407 @noindent
11408 @strong{32}.  The implementation-defined means, if any, of specifying
11409 which compilation units are needed by a given compilation unit.  See
11410 10.2(2).
11411 @end cartouche
11412 @noindent
11413 The units needed by a given compilation unit are as defined in
11414 the Ada Reference Manual section 10.2(2-6).  There are no
11415 implementation-defined pragmas or other implementation-defined
11416 means for specifying needed units.
11417
11418 @sp 1
11419 @cartouche
11420 @noindent
11421 @strong{33}.  The manner of designating the main subprogram of a
11422 partition.  See 10.2(7).
11423 @end cartouche
11424 @noindent
11425 The main program is designated by providing the name of the
11426 corresponding @file{ALI} file as the input parameter to the binder.
11427
11428 @sp 1
11429 @cartouche
11430 @noindent
11431 @strong{34}.  The order of elaboration of @code{library_items}.  See
11432 10.2(18).
11433 @end cartouche
11434 @noindent
11435 The first constraint on ordering is that it meets the requirements of
11436 Chapter 10 of the Ada Reference Manual.  This still leaves some
11437 implementation dependent choices, which are resolved by first
11438 elaborating bodies as early as possible (i.e., in preference to specs
11439 where there is a choice), and second by evaluating the immediate with
11440 clauses of a unit to determine the probably best choice, and
11441 third by elaborating in alphabetical order of unit names
11442 where a choice still remains.
11443
11444 @sp 1
11445 @cartouche
11446 @noindent
11447 @strong{35}.  Parameter passing and function return for the main
11448 subprogram.  See 10.2(21).
11449 @end cartouche
11450 @noindent
11451 The main program has no parameters.  It may be a procedure, or a function
11452 returning an integer type.  In the latter case, the returned integer
11453 value is the return code of the program (overriding any value that
11454 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
11455
11456 @sp 1
11457 @cartouche
11458 @noindent
11459 @strong{36}.  The mechanisms for building and running partitions.  See
11460 10.2(24).
11461 @end cartouche
11462 @noindent
11463 GNAT itself supports programs with only a single partition.  The GNATDIST
11464 tool provided with the GLADE package (which also includes an implementation
11465 of the PCS) provides a completely flexible method for building and running
11466 programs consisting of multiple partitions.  See the separate GLADE manual
11467 for details.
11468
11469 @sp 1
11470 @cartouche
11471 @noindent
11472 @strong{37}.  The details of program execution, including program
11473 termination.  See 10.2(25).
11474 @end cartouche
11475 @noindent
11476 See separate section on compilation model.
11477
11478 @sp 1
11479 @cartouche
11480 @noindent
11481 @strong{38}.  The semantics of any non-active partitions supported by the
11482 implementation.  See 10.2(28).
11483 @end cartouche
11484 @noindent
11485 Passive partitions are supported on targets where shared memory is
11486 provided by the operating system.  See the GLADE reference manual for
11487 further details.
11488
11489 @sp 1
11490 @cartouche
11491 @noindent
11492 @strong{39}.  The information returned by @code{Exception_Message}.  See
11493 11.4.1(10).
11494 @end cartouche
11495 @noindent
11496 Exception message returns the null string unless a specific message has
11497 been passed by the program.
11498
11499 @sp 1
11500 @cartouche
11501 @noindent
11502 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
11503 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
11504 @end cartouche
11505 @noindent
11506 Blocks have implementation defined names of the form @code{B@var{nnn}}
11507 where @var{nnn} is an integer.
11508
11509 @sp 1
11510 @cartouche
11511 @noindent
11512 @strong{41}.  The information returned by
11513 @code{Exception_Information}.  See 11.4.1(13).
11514 @end cartouche
11515 @noindent
11516 @code{Exception_Information} returns a string in the following format:
11517
11518 @smallexample
11519 @emph{Exception_Name:} nnnnn
11520 @emph{Message:} mmmmm
11521 @emph{PID:} ppp
11522 @emph{Call stack traceback locations:}
11523 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
11524 @end smallexample
11525
11526 @noindent
11527 where
11528
11529 @itemize @bullet
11530 @item
11531 @code{nnnn} is the fully qualified name of the exception in all upper
11532 case letters. This line is always present.
11533
11534 @item
11535 @code{mmmm} is the message (this line present only if message is non-null)
11536
11537 @item
11538 @code{ppp} is the Process Id value as a decimal integer (this line is
11539 present only if the Process Id is nonzero). Currently we are
11540 not making use of this field.
11541
11542 @item
11543 The Call stack traceback locations line and the following values
11544 are present only if at least one traceback location was recorded.
11545 The values are given in C style format, with lower case letters
11546 for a-f, and only as many digits present as are necessary.
11547 @end itemize
11548
11549 @noindent
11550 The line terminator sequence at the end of each line, including
11551 the last line is a single @code{LF} character (@code{16#0A#}).
11552
11553 @sp 1
11554 @cartouche
11555 @noindent
11556 @strong{42}.  Implementation-defined check names.  See 11.5(27).
11557 @end cartouche
11558 @noindent
11559 The implementation defined check name Alignment_Check controls checking of
11560 address clause values for proper alignment (that is, the address supplied
11561 must be consistent with the alignment of the type).
11562
11563 The implementation defined check name Predicate_Check controls whether
11564 predicate checks are generated.
11565
11566 The implementation defined check name Validity_Check controls whether
11567 validity checks are generated.
11568
11569 In addition, a user program can add implementation-defined check names
11570 by means of the pragma Check_Name.
11571
11572 @sp 1
11573 @cartouche
11574 @noindent
11575 @strong{43}.  The interpretation of each aspect of representation.  See
11576 13.1(20).
11577 @end cartouche
11578 @noindent
11579 See separate section on data representations.
11580
11581 @sp 1
11582 @cartouche
11583 @noindent
11584 @strong{44}.  Any restrictions placed upon representation items.  See
11585 13.1(20).
11586 @end cartouche
11587 @noindent
11588 See separate section on data representations.
11589
11590 @sp 1
11591 @cartouche
11592 @noindent
11593 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
11594 13.3(48).
11595 @end cartouche
11596 @noindent
11597 Size for an indefinite subtype is the maximum possible size, except that
11598 for the case of a subprogram parameter, the size of the parameter object
11599 is the actual size.
11600
11601 @sp 1
11602 @cartouche
11603 @noindent
11604 @strong{46}.  The default external representation for a type tag.  See
11605 13.3(75).
11606 @end cartouche
11607 @noindent
11608 The default external representation for a type tag is the fully expanded
11609 name of the type in upper case letters.
11610
11611 @sp 1
11612 @cartouche
11613 @noindent
11614 @strong{47}.  What determines whether a compilation unit is the same in
11615 two different partitions.  See 13.3(76).
11616 @end cartouche
11617 @noindent
11618 A compilation unit is the same in two different partitions if and only
11619 if it derives from the same source file.
11620
11621 @sp 1
11622 @cartouche
11623 @noindent
11624 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
11625 @end cartouche
11626 @noindent
11627 The only implementation defined component is the tag for a tagged type,
11628 which contains a pointer to the dispatching table.
11629
11630 @sp 1
11631 @cartouche
11632 @noindent
11633 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
11634 ordering.  See 13.5.3(5).
11635 @end cartouche
11636 @noindent
11637 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
11638 implementation, so no non-default bit ordering is supported.  The default
11639 bit ordering corresponds to the natural endianness of the target architecture.
11640
11641 @sp 1
11642 @cartouche
11643 @noindent
11644 @strong{50}.  The contents of the visible part of package @code{System}
11645 and its language-defined children.  See 13.7(2).
11646 @end cartouche
11647 @noindent
11648 See the definition of these packages in files @file{system.ads} and
11649 @file{s-stoele.ads}.
11650
11651 @sp 1
11652 @cartouche
11653 @noindent
11654 @strong{51}.  The contents of the visible part of package
11655 @code{System.Machine_Code}, and the meaning of
11656 @code{code_statements}.  See 13.8(7).
11657 @end cartouche
11658 @noindent
11659 See the definition and documentation in file @file{s-maccod.ads}.
11660
11661 @sp 1
11662 @cartouche
11663 @noindent
11664 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
11665 @end cartouche
11666 @noindent
11667 Unchecked conversion between types of the same size
11668 results in an uninterpreted transmission of the bits from one type
11669 to the other.  If the types are of unequal sizes, then in the case of
11670 discrete types, a shorter source is first zero or sign extended as
11671 necessary, and a shorter target is simply truncated on the left.
11672 For all non-discrete types, the source is first copied if necessary
11673 to ensure that the alignment requirements of the target are met, then
11674 a pointer is constructed to the source value, and the result is obtained
11675 by dereferencing this pointer after converting it to be a pointer to the
11676 target type. Unchecked conversions where the target subtype is an
11677 unconstrained array are not permitted. If the target alignment is
11678 greater than the source alignment, then a copy of the result is
11679 made with appropriate alignment
11680
11681 @sp 1
11682 @cartouche
11683 @noindent
11684 @strong{53}. The semantics of operations on invalid representations.
11685 See 13.9.2(10-11).
11686 @end cartouche
11687 @noindent
11688 For assignments and other operations where the use of invalid values cannot
11689 result in erroneous behavior, the compiler ignores the possibility of invalid
11690 values. An exception is raised at the point where an invalid value would
11691 result in erroneous behavior. For example executing:
11692
11693 @smallexample @c ada
11694 procedure invalidvals is
11695    X : Integer := -1;
11696    Y : Natural range 1 .. 10;
11697    for Y'Address use X'Address;
11698    Z : Natural range 1 .. 10;
11699    A : array (Natural range 1 .. 10) of Integer;
11700 begin
11701    Z := Y;     -- no exception
11702    A (Z) := 3; -- exception raised;
11703 end;
11704 @end smallexample
11705
11706 @noindent
11707 As indicated, an exception is raised on the array assignment, but not
11708 on the simple assignment of the invalid negative value from Y to Z.
11709
11710 @sp 1
11711 @cartouche
11712 @noindent
11713 @strong{53}.  The manner of choosing a storage pool for an access type
11714 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
11715 @end cartouche
11716 @noindent
11717 There are 3 different standard pools used by the compiler when
11718 @code{Storage_Pool} is not specified depending whether the type is local
11719 to a subprogram or defined at the library level and whether
11720 @code{Storage_Size}is specified or not.  See documentation in the runtime
11721 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
11722 @code{System.Pool_Local} in files @file{s-poosiz.ads},
11723 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
11724 default pools used.
11725
11726 @sp 1
11727 @cartouche
11728 @noindent
11729 @strong{54}.  Whether or not the implementation provides user-accessible
11730 names for the standard pool type(s).  See 13.11(17).
11731 @end cartouche
11732 @noindent
11733
11734 See documentation in the sources of the run time mentioned in paragraph
11735 @strong{53} .  All these pools are accessible by means of @code{with}'ing
11736 these units.
11737
11738 @sp 1
11739 @cartouche
11740 @noindent
11741 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
11742 @end cartouche
11743 @noindent
11744 @code{Storage_Size} is measured in storage units, and refers to the
11745 total space available for an access type collection, or to the primary
11746 stack space for a task.
11747
11748 @sp 1
11749 @cartouche
11750 @noindent
11751 @strong{56}.  Implementation-defined aspects of storage pools.  See
11752 13.11(22).
11753 @end cartouche
11754 @noindent
11755 See documentation in the sources of the run time mentioned in paragraph
11756 @strong{53} for details on GNAT-defined aspects of storage pools.
11757
11758 @sp 1
11759 @cartouche
11760 @noindent
11761 @strong{57}.  The set of restrictions allowed in a pragma
11762 @code{Restrictions}.  See 13.12(7).
11763 @end cartouche
11764 @noindent
11765 @xref{Standard and Implementation Defined Restrictions}.
11766
11767 @sp 1
11768 @cartouche
11769 @noindent
11770 @strong{58}.  The consequences of violating limitations on
11771 @code{Restrictions} pragmas.  See 13.12(9).
11772 @end cartouche
11773 @noindent
11774 Restrictions that can be checked at compile time result in illegalities
11775 if violated.  Currently there are no other consequences of violating
11776 restrictions.
11777
11778 @sp 1
11779 @cartouche
11780 @noindent
11781 @strong{59}.  The representation used by the @code{Read} and
11782 @code{Write} attributes of elementary types in terms of stream
11783 elements.  See 13.13.2(9).
11784 @end cartouche
11785 @noindent
11786 The representation is the in-memory representation of the base type of
11787 the type, using the number of bits corresponding to the
11788 @code{@var{type}'Size} value, and the natural ordering of the machine.
11789
11790 @sp 1
11791 @cartouche
11792 @noindent
11793 @strong{60}.  The names and characteristics of the numeric subtypes
11794 declared in the visible part of package @code{Standard}.  See A.1(3).
11795 @end cartouche
11796 @noindent
11797 See items describing the integer and floating-point types supported.
11798
11799 @sp 1
11800 @cartouche
11801 @noindent
11802 @strong{61}.  The accuracy actually achieved by the elementary
11803 functions.  See A.5.1(1).
11804 @end cartouche
11805 @noindent
11806 The elementary functions correspond to the functions available in the C
11807 library.  Only fast math mode is implemented.
11808
11809 @sp 1
11810 @cartouche
11811 @noindent
11812 @strong{62}.  The sign of a zero result from some of the operators or
11813 functions in @code{Numerics.Generic_Elementary_Functions}, when
11814 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
11815 @end cartouche
11816 @noindent
11817 The sign of zeroes follows the requirements of the IEEE 754 standard on
11818 floating-point.
11819
11820 @sp 1
11821 @cartouche
11822 @noindent
11823 @strong{63}.  The value of
11824 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
11825 @end cartouche
11826 @noindent
11827 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11828
11829 @sp 1
11830 @cartouche
11831 @noindent
11832 @strong{64}.  The value of
11833 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
11834 @end cartouche
11835 @noindent
11836 Maximum image width is 6864, see library file @file{s-rannum.ads}.
11837
11838 @sp 1
11839 @cartouche
11840 @noindent
11841 @strong{65}.  The algorithms for random number generation.  See
11842 A.5.2(32).
11843 @end cartouche
11844 @noindent
11845 The algorithm is the Mersenne Twister, as documented in the source file
11846 @file{s-rannum.adb}. This version of the algorithm has a period of
11847 2**19937-1.
11848
11849 @sp 1
11850 @cartouche
11851 @noindent
11852 @strong{66}.  The string representation of a random number generator's
11853 state.  See A.5.2(38).
11854 @end cartouche
11855 @noindent
11856 The value returned by the Image function is the concatenation of
11857 the fixed-width decimal representations of the 624 32-bit integers
11858 of the state vector.
11859
11860 @sp 1
11861 @cartouche
11862 @noindent
11863 @strong{67}.  The minimum time interval between calls to the
11864 time-dependent Reset procedure that are guaranteed to initiate different
11865 random number sequences.  See A.5.2(45).
11866 @end cartouche
11867 @noindent
11868 The minimum period between reset calls to guarantee distinct series of
11869 random numbers is one microsecond.
11870
11871 @sp 1
11872 @cartouche
11873 @noindent
11874 @strong{68}.  The values of the @code{Model_Mantissa},
11875 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
11876 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
11877 Annex is not supported.  See A.5.3(72).
11878 @end cartouche
11879 @noindent
11880 Run the compiler with @option{-gnatS} to produce a listing of package
11881 @code{Standard}, has the values of all numeric attributes.
11882
11883 @sp 1
11884 @cartouche
11885 @noindent
11886 @strong{69}.  Any implementation-defined characteristics of the
11887 input-output packages.  See A.7(14).
11888 @end cartouche
11889 @noindent
11890 There are no special implementation defined characteristics for these
11891 packages.
11892
11893 @sp 1
11894 @cartouche
11895 @noindent
11896 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
11897 A.9(10).
11898 @end cartouche
11899 @noindent
11900 All type representations are contiguous, and the @code{Buffer_Size} is
11901 the value of @code{@var{type}'Size} rounded up to the next storage unit
11902 boundary.
11903
11904 @sp 1
11905 @cartouche
11906 @noindent
11907 @strong{71}.  External files for standard input, standard output, and
11908 standard error See A.10(5).
11909 @end cartouche
11910 @noindent
11911 These files are mapped onto the files provided by the C streams
11912 libraries.  See source file @file{i-cstrea.ads} for further details.
11913
11914 @sp 1
11915 @cartouche
11916 @noindent
11917 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
11918 A.10.9(36).
11919 @end cartouche
11920 @noindent
11921 If more digits are requested in the output than are represented by the
11922 precision of the value, zeroes are output in the corresponding least
11923 significant digit positions.
11924
11925 @sp 1
11926 @cartouche
11927 @noindent
11928 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
11929 @code{Command_Name}.  See A.15(1).
11930 @end cartouche
11931 @noindent
11932 These are mapped onto the @code{argv} and @code{argc} parameters of the
11933 main program in the natural manner.
11934
11935 @sp 1
11936 @cartouche
11937 @noindent
11938 @strong{74}.  The interpretation of the @code{Form} parameter in procedure
11939 @code{Create_Directory}.  See A.16(56).
11940 @end cartouche
11941 @noindent
11942 The @code{Form} parameter is not used.
11943
11944 @sp 1
11945 @cartouche
11946 @noindent
11947 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
11948 @code{Create_Path}.  See A.16(60).
11949 @end cartouche
11950 @noindent
11951 The @code{Form} parameter is not used.
11952
11953 @sp 1
11954 @cartouche
11955 @noindent
11956 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
11957 @code{Copy_File}.  See A.16(68).
11958 @end cartouche
11959 @noindent
11960 The @code{Form} parameter is case-insensitive.
11961
11962 Two fields are recognized in the @code{Form} parameter:
11963
11964 @table @code
11965
11966 @item preserve=<value>
11967
11968 @item mode=<value>
11969
11970 @end table
11971
11972 @noindent
11973 <value> starts immediately after the character '=' and ends with the
11974 character immediately preceding the next comma (',') or with the last
11975 character of the parameter.
11976
11977 The only possible values for preserve= are:
11978
11979 @table @code
11980
11981 @item no_attributes
11982 Do not try to preserve any file attributes. This is the default if no
11983 preserve= is found in Form.
11984
11985 @item all_attributes
11986 Try to preserve all file attributes (timestamps, access rights).
11987
11988 @item timestamps
11989 Preserve the timestamp of the copied file, but not the other file attributes.
11990
11991 @end table
11992
11993 @noindent
11994 The only possible values for mode= are:
11995
11996 @table @code
11997
11998 @item copy
11999 Only do the copy if the destination file does not already exist. If it already
12000 exists, Copy_File fails.
12001
12002 @item overwrite
12003 Copy the file in all cases. Overwrite an already existing destination file.
12004
12005 @item append
12006 Append the original file to the destination file. If the destination file does
12007 not exist, the destination file is a copy of the source file. When mode=append,
12008 the field preserve=, if it exists, is not taken into account.
12009
12010 @end table
12011
12012 @noindent
12013 If the Form parameter includes one or both of the fields and the value or
12014 values are incorrect, Copy_file fails with Use_Error.
12015
12016 Examples of correct Forms:
12017
12018 @smallexample
12019 Form => "preserve=no_attributes,mode=overwrite" (the default)
12020 Form => "mode=append"
12021 Form => "mode=copy, preserve=all_attributes"
12022 @end smallexample
12023
12024 @noindent
12025 Examples of incorrect Forms
12026
12027 @smallexample
12028 Form => "preserve=junk"
12029 Form => "mode=internal, preserve=timestamps"
12030 @end smallexample
12031
12032 @sp 1
12033 @cartouche
12034 @noindent
12035 @strong{77}.  Implementation-defined convention names.  See B.1(11).
12036 @end cartouche
12037 @noindent
12038 The following convention names are supported
12039
12040 @table @code
12041 @item  Ada
12042 Ada
12043 @item Ada_Pass_By_Copy
12044 Allowed for any types except by-reference types such as limited
12045 records. Compatible with convention Ada, but causes any parameters
12046 with this convention to be passed by copy.
12047 @item Ada_Pass_By_Reference
12048 Allowed for any types except by-copy types such as scalars.
12049 Compatible with convention Ada, but causes any parameters
12050 with this convention to be passed by reference.
12051 @item Assembler
12052 Assembly language
12053 @item Asm
12054 Synonym for Assembler
12055 @item Assembly
12056 Synonym for Assembler
12057 @item C
12058 C
12059 @item C_Pass_By_Copy
12060 Allowed only for record types, like C, but also notes that record
12061 is to be passed by copy rather than reference.
12062 @item COBOL
12063 COBOL
12064 @item C_Plus_Plus (or CPP)
12065 C++
12066 @item Default
12067 Treated the same as C
12068 @item External
12069 Treated the same as C
12070 @item Fortran
12071 Fortran
12072 @item Intrinsic
12073 For support of pragma @code{Import} with convention Intrinsic, see
12074 separate section on Intrinsic Subprograms.
12075 @item Stdcall
12076 Stdcall (used for Windows implementations only).  This convention correspond
12077 to the WINAPI (previously called Pascal convention) C/C++ convention under
12078 Windows.  A routine with this convention cleans the stack before
12079 exit. This pragma cannot be applied to a dispatching call.
12080 @item DLL
12081 Synonym for Stdcall
12082 @item Win32
12083 Synonym for Stdcall
12084 @item Stubbed
12085 Stubbed is a special convention used to indicate that the body of the
12086 subprogram will be entirely ignored.  Any call to the subprogram
12087 is converted into a raise of the @code{Program_Error} exception.  If a
12088 pragma @code{Import} specifies convention @code{stubbed} then no body need
12089 be present at all.  This convention is useful during development for the
12090 inclusion of subprograms whose body has not yet been written.
12091
12092 @end table
12093 @noindent
12094 In addition, all otherwise unrecognized convention names are also
12095 treated as being synonymous with convention C@.  In all implementations
12096 except for VMS, use of such other names results in a warning.  In VMS
12097 implementations, these names are accepted silently.
12098
12099 @sp 1
12100 @cartouche
12101 @noindent
12102 @strong{78}.  The meaning of link names.  See B.1(36).
12103 @end cartouche
12104 @noindent
12105 Link names are the actual names used by the linker.
12106
12107 @sp 1
12108 @cartouche
12109 @noindent
12110 @strong{79}.  The manner of choosing link names when neither the link
12111 name nor the address of an imported or exported entity is specified.  See
12112 B.1(36).
12113 @end cartouche
12114 @noindent
12115 The default linker name is that which would be assigned by the relevant
12116 external language, interpreting the Ada name as being in all lower case
12117 letters.
12118
12119 @sp 1
12120 @cartouche
12121 @noindent
12122 @strong{80}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
12123 @end cartouche
12124 @noindent
12125 The string passed to @code{Linker_Options} is presented uninterpreted as
12126 an argument to the link command, unless it contains ASCII.NUL characters.
12127 NUL characters if they appear act as argument separators, so for example
12128
12129 @smallexample @c ada
12130 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
12131 @end smallexample
12132
12133 @noindent
12134 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
12135 linker. The order of linker options is preserved for a given unit. The final
12136 list of options passed to the linker is in reverse order of the elaboration
12137 order. For example, linker options for a body always appear before the options
12138 from the corresponding package spec.
12139
12140 @sp 1
12141 @cartouche
12142 @noindent
12143 @strong{81}.  The contents of the visible part of package
12144 @code{Interfaces} and its language-defined descendants.  See B.2(1).
12145 @end cartouche
12146 @noindent
12147 See files with prefix @file{i-} in the distributed library.
12148
12149 @sp 1
12150 @cartouche
12151 @noindent
12152 @strong{82}.  Implementation-defined children of package
12153 @code{Interfaces}.  The contents of the visible part of package
12154 @code{Interfaces}.  See B.2(11).
12155 @end cartouche
12156 @noindent
12157 See files with prefix @file{i-} in the distributed library.
12158
12159 @sp 1
12160 @cartouche
12161 @noindent
12162 @strong{83}.  The types @code{Floating}, @code{Long_Floating},
12163 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
12164 @code{COBOL_Character}; and the initialization of the variables
12165 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
12166 @code{Interfaces.COBOL}.  See B.4(50).
12167 @end cartouche
12168 @noindent
12169 @table @code
12170 @item Floating
12171 Float
12172 @item Long_Floating
12173 (Floating) Long_Float
12174 @item Binary
12175 Integer
12176 @item Long_Binary
12177 Long_Long_Integer
12178 @item Decimal_Element
12179 Character
12180 @item COBOL_Character
12181 Character
12182 @end table
12183
12184 @noindent
12185 For initialization, see the file @file{i-cobol.ads} in the distributed library.
12186
12187 @sp 1
12188 @cartouche
12189 @noindent
12190 @strong{84}.  Support for access to machine instructions.  See C.1(1).
12191 @end cartouche
12192 @noindent
12193 See documentation in file @file{s-maccod.ads} in the distributed library.
12194
12195 @sp 1
12196 @cartouche
12197 @noindent
12198 @strong{85}.  Implementation-defined aspects of access to machine
12199 operations.  See C.1(9).
12200 @end cartouche
12201 @noindent
12202 See documentation in file @file{s-maccod.ads} in the distributed library.
12203
12204 @sp 1
12205 @cartouche
12206 @noindent
12207 @strong{86}.  Implementation-defined aspects of interrupts.  See C.3(2).
12208 @end cartouche
12209 @noindent
12210 Interrupts are mapped to signals or conditions as appropriate.  See
12211 definition of unit
12212 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
12213 on the interrupts supported on a particular target.
12214
12215 @sp 1
12216 @cartouche
12217 @noindent
12218 @strong{87}.  Implementation-defined aspects of pre-elaboration.  See
12219 C.4(13).
12220 @end cartouche
12221 @noindent
12222 GNAT does not permit a partition to be restarted without reloading,
12223 except under control of the debugger.
12224
12225 @sp 1
12226 @cartouche
12227 @noindent
12228 @strong{88}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
12229 @end cartouche
12230 @noindent
12231 Pragma @code{Discard_Names} causes names of enumeration literals to
12232 be suppressed.  In the presence of this pragma, the Image attribute
12233 provides the image of the Pos of the literal, and Value accepts
12234 Pos values.
12235
12236 @sp 1
12237 @cartouche
12238 @noindent
12239 @strong{89}.  The result of the @code{Task_Identification.Image}
12240 attribute.  See C.7.1(7).
12241 @end cartouche
12242 @noindent
12243 The result of this attribute is a string that identifies
12244 the object or component that denotes a given task. If a variable @code{Var}
12245 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
12246 where the suffix
12247 is the hexadecimal representation of the virtual address of the corresponding
12248 task control block. If the variable is an array of tasks, the image of each
12249 task will have the form of an indexed component indicating the position of a
12250 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
12251 component of a record, the image of the task will have the form of a selected
12252 component. These rules are fully recursive, so that the image of a task that
12253 is a subcomponent of a composite object corresponds to the expression that
12254 designates this task.
12255 @noindent
12256 If a task is created by an allocator, its image depends on the context. If the
12257 allocator is part of an object declaration, the rules described above are used
12258 to construct its image, and this image is not affected by subsequent
12259 assignments. If the allocator appears within an expression, the image
12260 includes only the name of the task type.
12261 @noindent
12262 If the configuration pragma Discard_Names is present, or if the restriction
12263 No_Implicit_Heap_Allocation is in effect,  the image reduces to
12264 the numeric suffix, that is to say the hexadecimal representation of the
12265 virtual address of the control block of the task.
12266 @sp 1
12267 @cartouche
12268 @noindent
12269 @strong{90}.  The value of @code{Current_Task} when in a protected entry
12270 or interrupt handler.  See C.7.1(17).
12271 @end cartouche
12272 @noindent
12273 Protected entries or interrupt handlers can be executed by any
12274 convenient thread, so the value of @code{Current_Task} is undefined.
12275
12276 @sp 1
12277 @cartouche
12278 @noindent
12279 @strong{91}.  The effect of calling @code{Current_Task} from an entry
12280 body or interrupt handler.  See C.7.1(19).
12281 @end cartouche
12282 @noindent
12283 The effect of calling @code{Current_Task} from an entry body or
12284 interrupt handler is to return the identification of the task currently
12285 executing the code.
12286
12287 @sp 1
12288 @cartouche
12289 @noindent
12290 @strong{92}.  Implementation-defined aspects of
12291 @code{Task_Attributes}.  See C.7.2(19).
12292 @end cartouche
12293 @noindent
12294 There are no implementation-defined aspects of @code{Task_Attributes}.
12295
12296 @sp 1
12297 @cartouche
12298 @noindent
12299 @strong{93}.  Values of all @code{Metrics}.  See D(2).
12300 @end cartouche
12301 @noindent
12302 The metrics information for GNAT depends on the performance of the
12303 underlying operating system.  The sources of the run-time for tasking
12304 implementation, together with the output from @option{-gnatG} can be
12305 used to determine the exact sequence of operating systems calls made
12306 to implement various tasking constructs.  Together with appropriate
12307 information on the performance of the underlying operating system,
12308 on the exact target in use, this information can be used to determine
12309 the required metrics.
12310
12311 @sp 1
12312 @cartouche
12313 @noindent
12314 @strong{94}.  The declarations of @code{Any_Priority} and
12315 @code{Priority}.  See D.1(11).
12316 @end cartouche
12317 @noindent
12318 See declarations in file @file{system.ads}.
12319
12320 @sp 1
12321 @cartouche
12322 @noindent
12323 @strong{95}.  Implementation-defined execution resources.  See D.1(15).
12324 @end cartouche
12325 @noindent
12326 There are no implementation-defined execution resources.
12327
12328 @sp 1
12329 @cartouche
12330 @noindent
12331 @strong{96}.  Whether, on a multiprocessor, a task that is waiting for
12332 access to a protected object keeps its processor busy.  See D.2.1(3).
12333 @end cartouche
12334 @noindent
12335 On a multi-processor, a task that is waiting for access to a protected
12336 object does not keep its processor busy.
12337
12338 @sp 1
12339 @cartouche
12340 @noindent
12341 @strong{97}.  The affect of implementation defined execution resources
12342 on task dispatching.  See D.2.1(9).
12343 @end cartouche
12344 @noindent
12345 Tasks map to threads in the threads package used by GNAT@.  Where possible
12346 and appropriate, these threads correspond to native threads of the
12347 underlying operating system.
12348
12349 @sp 1
12350 @cartouche
12351 @noindent
12352 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
12353 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
12354 @end cartouche
12355 @noindent
12356 There are no implementation-defined policy-identifiers allowed in this
12357 pragma.
12358
12359 @sp 1
12360 @cartouche
12361 @noindent
12362 @strong{99}.  Implementation-defined aspects of priority inversion.  See
12363 D.2.2(16).
12364 @end cartouche
12365 @noindent
12366 Execution of a task cannot be preempted by the implementation processing
12367 of delay expirations for lower priority tasks.
12368
12369 @sp 1
12370 @cartouche
12371 @noindent
12372 @strong{100}.  Implementation-defined task dispatching.  See D.2.2(18).
12373 @end cartouche
12374 @noindent
12375 The policy is the same as that of the underlying threads implementation.
12376
12377 @sp 1
12378 @cartouche
12379 @noindent
12380 @strong{101}.  Implementation-defined @code{policy_identifiers} allowed
12381 in a pragma @code{Locking_Policy}.  See D.3(4).
12382 @end cartouche
12383 @noindent
12384 The two implementation defined policies permitted in GNAT are
12385 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
12386 targets that support the @code{Inheritance_Locking} policy, locking is
12387 implemented by inheritance, i.e.@: the task owning the lock operates
12388 at a priority equal to the highest priority of any task currently
12389 requesting the lock.  On targets that support the
12390 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
12391 read/write lock allowing multiple propected object functions to enter
12392 concurrently.
12393
12394 @sp 1
12395 @cartouche
12396 @noindent
12397 @strong{102}.  Default ceiling priorities.  See D.3(10).
12398 @end cartouche
12399 @noindent
12400 The ceiling priority of protected objects of the type
12401 @code{System.Interrupt_Priority'Last} as described in the Ada
12402 Reference Manual D.3(10),
12403
12404 @sp 1
12405 @cartouche
12406 @noindent
12407 @strong{103}.  The ceiling of any protected object used internally by
12408 the implementation.  See D.3(16).
12409 @end cartouche
12410 @noindent
12411 The ceiling priority of internal protected objects is
12412 @code{System.Priority'Last}.
12413
12414 @sp 1
12415 @cartouche
12416 @noindent
12417 @strong{104}.  Implementation-defined queuing policies.  See D.4(1).
12418 @end cartouche
12419 @noindent
12420 There are no implementation-defined queuing policies.
12421
12422 @sp 1
12423 @cartouche
12424 @noindent
12425 @strong{105}.  On a multiprocessor, any conditions that cause the
12426 completion of an aborted construct to be delayed later than what is
12427 specified for a single processor.  See D.6(3).
12428 @end cartouche
12429 @noindent
12430 The semantics for abort on a multi-processor is the same as on a single
12431 processor, there are no further delays.
12432
12433 @sp 1
12434 @cartouche
12435 @noindent
12436 @strong{106}.  Any operations that implicitly require heap storage
12437 allocation.  See D.7(8).
12438 @end cartouche
12439 @noindent
12440 The only operation that implicitly requires heap storage allocation is
12441 task creation.
12442
12443 @sp 1
12444 @cartouche
12445 @noindent
12446 @strong{107}.  Implementation-defined aspects of pragma
12447 @code{Restrictions}.  See D.7(20).
12448 @end cartouche
12449 @noindent
12450 There are no such implementation-defined aspects.
12451
12452 @sp 1
12453 @cartouche
12454 @noindent
12455 @strong{108}.  Implementation-defined aspects of package
12456 @code{Real_Time}.  See D.8(17).
12457 @end cartouche
12458 @noindent
12459 There are no implementation defined aspects of package @code{Real_Time}.
12460
12461 @sp 1
12462 @cartouche
12463 @noindent
12464 @strong{109}.  Implementation-defined aspects of
12465 @code{delay_statements}.  See D.9(8).
12466 @end cartouche
12467 @noindent
12468 Any difference greater than one microsecond will cause the task to be
12469 delayed (see D.9(7)).
12470
12471 @sp 1
12472 @cartouche
12473 @noindent
12474 @strong{110}.  The upper bound on the duration of interrupt blocking
12475 caused by the implementation.  See D.12(5).
12476 @end cartouche
12477 @noindent
12478 The upper bound is determined by the underlying operating system.  In
12479 no cases is it more than 10 milliseconds.
12480
12481 @sp 1
12482 @cartouche
12483 @noindent
12484 @strong{111}.  The means for creating and executing distributed
12485 programs.  See E(5).
12486 @end cartouche
12487 @noindent
12488 The GLADE package provides a utility GNATDIST for creating and executing
12489 distributed programs.  See the GLADE reference manual for further details.
12490
12491 @sp 1
12492 @cartouche
12493 @noindent
12494 @strong{112}.  Any events that can result in a partition becoming
12495 inaccessible.  See E.1(7).
12496 @end cartouche
12497 @noindent
12498 See the GLADE reference manual for full details on such events.
12499
12500 @sp 1
12501 @cartouche
12502 @noindent
12503 @strong{113}.  The scheduling policies, treatment of priorities, and
12504 management of shared resources between partitions in certain cases.  See
12505 E.1(11).
12506 @end cartouche
12507 @noindent
12508 See the GLADE reference manual for full details on these aspects of
12509 multi-partition execution.
12510
12511 @sp 1
12512 @cartouche
12513 @noindent
12514 @strong{114}.  Events that cause the version of a compilation unit to
12515 change.  See E.3(5).
12516 @end cartouche
12517 @noindent
12518 Editing the source file of a compilation unit, or the source files of
12519 any units on which it is dependent in a significant way cause the version
12520 to change.  No other actions cause the version number to change.  All changes
12521 are significant except those which affect only layout, capitalization or
12522 comments.
12523
12524 @sp 1
12525 @cartouche
12526 @noindent
12527 @strong{115}.  Whether the execution of the remote subprogram is
12528 immediately aborted as a result of cancellation.  See E.4(13).
12529 @end cartouche
12530 @noindent
12531 See the GLADE reference manual for details on the effect of abort in
12532 a distributed application.
12533
12534 @sp 1
12535 @cartouche
12536 @noindent
12537 @strong{116}.  Implementation-defined aspects of the PCS@.  See E.5(25).
12538 @end cartouche
12539 @noindent
12540 See the GLADE reference manual for a full description of all implementation
12541 defined aspects of the PCS@.
12542
12543 @sp 1
12544 @cartouche
12545 @noindent
12546 @strong{117}.  Implementation-defined interfaces in the PCS@.  See
12547 E.5(26).
12548 @end cartouche
12549 @noindent
12550 See the GLADE reference manual for a full description of all
12551 implementation defined interfaces.
12552
12553 @sp 1
12554 @cartouche
12555 @noindent
12556 @strong{118}.  The values of named numbers in the package
12557 @code{Decimal}.  See F.2(7).
12558 @end cartouche
12559 @noindent
12560 @table @code
12561 @item Max_Scale
12562 +18
12563 @item Min_Scale
12564 -18
12565 @item Min_Delta
12566 1.0E-18
12567 @item Max_Delta
12568 1.0E+18
12569 @item Max_Decimal_Digits
12570 18
12571 @end table
12572
12573 @sp 1
12574 @cartouche
12575 @noindent
12576 @strong{119}.  The value of @code{Max_Picture_Length} in the package
12577 @code{Text_IO.Editing}.  See F.3.3(16).
12578 @end cartouche
12579 @noindent
12580 64
12581
12582 @sp 1
12583 @cartouche
12584 @noindent
12585 @strong{120}.  The value of @code{Max_Picture_Length} in the package
12586 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
12587 @end cartouche
12588 @noindent
12589 64
12590
12591 @sp 1
12592 @cartouche
12593 @noindent
12594 @strong{121}.  The accuracy actually achieved by the complex elementary
12595 functions and by other complex arithmetic operations.  See G.1(1).
12596 @end cartouche
12597 @noindent
12598 Standard library functions are used for the complex arithmetic
12599 operations.  Only fast math mode is currently supported.
12600
12601 @sp 1
12602 @cartouche
12603 @noindent
12604 @strong{122}.  The sign of a zero result (or a component thereof) from
12605 any operator or function in @code{Numerics.Generic_Complex_Types}, when
12606 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
12607 @end cartouche
12608 @noindent
12609 The signs of zero values are as recommended by the relevant
12610 implementation advice.
12611
12612 @sp 1
12613 @cartouche
12614 @noindent
12615 @strong{123}.  The sign of a zero result (or a component thereof) from
12616 any operator or function in
12617 @code{Numerics.Generic_Complex_Elementary_Functions}, when
12618 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
12619 @end cartouche
12620 @noindent
12621 The signs of zero values are as recommended by the relevant
12622 implementation advice.
12623
12624 @sp 1
12625 @cartouche
12626 @noindent
12627 @strong{124}.  Whether the strict mode or the relaxed mode is the
12628 default.  See G.2(2).
12629 @end cartouche
12630 @noindent
12631 The strict mode is the default.  There is no separate relaxed mode.  GNAT
12632 provides a highly efficient implementation of strict mode.
12633
12634 @sp 1
12635 @cartouche
12636 @noindent
12637 @strong{125}.  The result interval in certain cases of fixed-to-float
12638 conversion.  See G.2.1(10).
12639 @end cartouche
12640 @noindent
12641 For cases where the result interval is implementation dependent, the
12642 accuracy is that provided by performing all operations in 64-bit IEEE
12643 floating-point format.
12644
12645 @sp 1
12646 @cartouche
12647 @noindent
12648 @strong{126}.  The result of a floating point arithmetic operation in
12649 overflow situations, when the @code{Machine_Overflows} attribute of the
12650 result type is @code{False}.  See G.2.1(13).
12651 @end cartouche
12652 @noindent
12653 Infinite and NaN values are produced as dictated by the IEEE
12654 floating-point standard.
12655
12656 Note that on machines that are not fully compliant with the IEEE
12657 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
12658 must be used for achieving IEEE conforming behavior (although at the cost
12659 of a significant performance penalty), so infinite and NaN values are
12660 properly generated.
12661
12662 @sp 1
12663 @cartouche
12664 @noindent
12665 @strong{127}.  The result interval for division (or exponentiation by a
12666 negative exponent), when the floating point hardware implements division
12667 as multiplication by a reciprocal.  See G.2.1(16).
12668 @end cartouche
12669 @noindent
12670 Not relevant, division is IEEE exact.
12671
12672 @sp 1
12673 @cartouche
12674 @noindent
12675 @strong{128}.  The definition of close result set, which determines the
12676 accuracy of certain fixed point multiplications and divisions.  See
12677 G.2.3(5).
12678 @end cartouche
12679 @noindent
12680 Operations in the close result set are performed using IEEE long format
12681 floating-point arithmetic.  The input operands are converted to
12682 floating-point, the operation is done in floating-point, and the result
12683 is converted to the target type.
12684
12685 @sp 1
12686 @cartouche
12687 @noindent
12688 @strong{129}.  Conditions on a @code{universal_real} operand of a fixed
12689 point multiplication or division for which the result shall be in the
12690 perfect result set.  See G.2.3(22).
12691 @end cartouche
12692 @noindent
12693 The result is only defined to be in the perfect result set if the result
12694 can be computed by a single scaling operation involving a scale factor
12695 representable in 64-bits.
12696
12697 @sp 1
12698 @cartouche
12699 @noindent
12700 @strong{130}.  The result of a fixed point arithmetic operation in
12701 overflow situations, when the @code{Machine_Overflows} attribute of the
12702 result type is @code{False}.  See G.2.3(27).
12703 @end cartouche
12704 @noindent
12705 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
12706 types.
12707
12708 @sp 1
12709 @cartouche
12710 @noindent
12711 @strong{131}.  The result of an elementary function reference in
12712 overflow situations, when the @code{Machine_Overflows} attribute of the
12713 result type is @code{False}.  See G.2.4(4).
12714 @end cartouche
12715 @noindent
12716 IEEE infinite and Nan values are produced as appropriate.
12717
12718 @sp 1
12719 @cartouche
12720 @noindent
12721 @strong{132}.  The value of the angle threshold, within which certain
12722 elementary functions, complex arithmetic operations, and complex
12723 elementary functions yield results conforming to a maximum relative
12724 error bound.  See G.2.4(10).
12725 @end cartouche
12726 @noindent
12727 Information on this subject is not yet available.
12728
12729 @sp 1
12730 @cartouche
12731 @noindent
12732 @strong{133}.  The accuracy of certain elementary functions for
12733 parameters beyond the angle threshold.  See G.2.4(10).
12734 @end cartouche
12735 @noindent
12736 Information on this subject is not yet available.
12737
12738 @sp 1
12739 @cartouche
12740 @noindent
12741 @strong{134}.  The result of a complex arithmetic operation or complex
12742 elementary function reference in overflow situations, when the
12743 @code{Machine_Overflows} attribute of the corresponding real type is
12744 @code{False}.  See G.2.6(5).
12745 @end cartouche
12746 @noindent
12747 IEEE infinite and Nan values are produced as appropriate.
12748
12749 @sp 1
12750 @cartouche
12751 @noindent
12752 @strong{135}.  The accuracy of certain complex arithmetic operations and
12753 certain complex elementary functions for parameters (or components
12754 thereof) beyond the angle threshold.  See G.2.6(8).
12755 @end cartouche
12756 @noindent
12757 Information on those subjects is not yet available.
12758
12759 @sp 1
12760 @cartouche
12761 @noindent
12762 @strong{136}.  Information regarding bounded errors and erroneous
12763 execution.  See H.2(1).
12764 @end cartouche
12765 @noindent
12766 Information on this subject is not yet available.
12767
12768 @sp 1
12769 @cartouche
12770 @noindent
12771 @strong{137}.  Implementation-defined aspects of pragma
12772 @code{Inspection_Point}.  See H.3.2(8).
12773 @end cartouche
12774 @noindent
12775 Pragma @code{Inspection_Point} ensures that the variable is live and can
12776 be examined by the debugger at the inspection point.
12777
12778 @sp 1
12779 @cartouche
12780 @noindent
12781 @strong{138}.  Implementation-defined aspects of pragma
12782 @code{Restrictions}.  See H.4(25).
12783 @end cartouche
12784 @noindent
12785 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
12786 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
12787 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
12788
12789 @sp 1
12790 @cartouche
12791 @noindent
12792 @strong{139}.  Any restrictions on pragma @code{Restrictions}.  See
12793 H.4(27).
12794 @end cartouche
12795 @noindent
12796 There are no restrictions on pragma @code{Restrictions}.
12797
12798 @node Intrinsic Subprograms
12799 @chapter Intrinsic Subprograms
12800 @cindex Intrinsic Subprograms
12801
12802 @menu
12803 * Intrinsic Operators::
12804 * Enclosing_Entity::
12805 * Exception_Information::
12806 * Exception_Message::
12807 * Exception_Name::
12808 * File::
12809 * Line::
12810 * Shifts and Rotates::
12811 * Source_Location::
12812 @end menu
12813
12814 @noindent
12815 GNAT allows a user application program to write the declaration:
12816
12817 @smallexample @c ada
12818    pragma Import (Intrinsic, name);
12819 @end smallexample
12820
12821 @noindent
12822 providing that the name corresponds to one of the implemented intrinsic
12823 subprograms in GNAT, and that the parameter profile of the referenced
12824 subprogram meets the requirements.  This chapter describes the set of
12825 implemented intrinsic subprograms, and the requirements on parameter profiles.
12826 Note that no body is supplied; as with other uses of pragma Import, the
12827 body is supplied elsewhere (in this case by the compiler itself).  Note
12828 that any use of this feature is potentially non-portable, since the
12829 Ada standard does not require Ada compilers to implement this feature.
12830
12831 @node Intrinsic Operators
12832 @section Intrinsic Operators
12833 @cindex Intrinsic operator
12834
12835 @noindent
12836 All the predefined numeric operators in package Standard
12837 in @code{pragma Import (Intrinsic,..)}
12838 declarations.  In the binary operator case, the operands must have the same
12839 size.  The operand or operands must also be appropriate for
12840 the operator.  For example, for addition, the operands must
12841 both be floating-point or both be fixed-point, and the
12842 right operand for @code{"**"} must have a root type of
12843 @code{Standard.Integer'Base}.
12844 You can use an intrinsic operator declaration as in the following example:
12845
12846 @smallexample @c ada
12847    type Int1 is new Integer;
12848    type Int2 is new Integer;
12849
12850    function "+" (X1 : Int1; X2 : Int2) return Int1;
12851    function "+" (X1 : Int1; X2 : Int2) return Int2;
12852    pragma Import (Intrinsic, "+");
12853 @end smallexample
12854
12855 @noindent
12856 This declaration would permit ``mixed mode'' arithmetic on items
12857 of the differing types @code{Int1} and @code{Int2}.
12858 It is also possible to specify such operators for private types, if the
12859 full views are appropriate arithmetic types.
12860
12861 @node Enclosing_Entity
12862 @section Enclosing_Entity
12863 @cindex Enclosing_Entity
12864 @noindent
12865 This intrinsic subprogram is used in the implementation of the
12866 library routine @code{GNAT.Source_Info}.  The only useful use of the
12867 intrinsic import in this case is the one in this unit, so an
12868 application program should simply call the function
12869 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
12870 the current subprogram, package, task, entry, or protected subprogram.
12871
12872 @node Exception_Information
12873 @section Exception_Information
12874 @cindex Exception_Information'
12875 @noindent
12876 This intrinsic subprogram is used in the implementation of the
12877 library routine @code{GNAT.Current_Exception}.  The only useful
12878 use of the intrinsic import in this case is the one in this unit,
12879 so an application program should simply call the function
12880 @code{GNAT.Current_Exception.Exception_Information} to obtain
12881 the exception information associated with the current exception.
12882
12883 @node Exception_Message
12884 @section Exception_Message
12885 @cindex Exception_Message
12886 @noindent
12887 This intrinsic subprogram is used in the implementation of the
12888 library routine @code{GNAT.Current_Exception}.  The only useful
12889 use of the intrinsic import in this case is the one in this unit,
12890 so an application program should simply call the function
12891 @code{GNAT.Current_Exception.Exception_Message} to obtain
12892 the message associated with the current exception.
12893
12894 @node Exception_Name
12895 @section Exception_Name
12896 @cindex Exception_Name
12897 @noindent
12898 This intrinsic subprogram is used in the implementation of the
12899 library routine @code{GNAT.Current_Exception}.  The only useful
12900 use of the intrinsic import in this case is the one in this unit,
12901 so an application program should simply call the function
12902 @code{GNAT.Current_Exception.Exception_Name} to obtain
12903 the name of the current exception.
12904
12905 @node File
12906 @section File
12907 @cindex File
12908 @noindent
12909 This intrinsic subprogram is used in the implementation of the
12910 library routine @code{GNAT.Source_Info}.  The only useful use of the
12911 intrinsic import in this case is the one in this unit, so an
12912 application program should simply call the function
12913 @code{GNAT.Source_Info.File} to obtain the name of the current
12914 file.
12915
12916 @node Line
12917 @section Line
12918 @cindex Line
12919 @noindent
12920 This intrinsic subprogram is used in the implementation of the
12921 library routine @code{GNAT.Source_Info}.  The only useful use of the
12922 intrinsic import in this case is the one in this unit, so an
12923 application program should simply call the function
12924 @code{GNAT.Source_Info.Line} to obtain the number of the current
12925 source line.
12926
12927 @node Shifts and Rotates
12928 @section Shifts and Rotates
12929 @cindex Shift_Left
12930 @cindex Shift_Right
12931 @cindex Shift_Right_Arithmetic
12932 @cindex Rotate_Left
12933 @cindex Rotate_Right
12934 @noindent
12935 In standard Ada, the shift and rotate functions are available only
12936 for the predefined modular types in package @code{Interfaces}.  However, in
12937 GNAT it is possible to define these functions for any integer
12938 type (signed or modular), as in this example:
12939
12940 @smallexample @c ada
12941    function Shift_Left
12942      (Value  : T;
12943       Amount : Natural)
12944       return   T;
12945 @end smallexample
12946
12947 @noindent
12948 The function name must be one of
12949 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
12950 Rotate_Right. T must be an integer type. T'Size must be
12951 8, 16, 32 or 64 bits; if T is modular, the modulus
12952 must be 2**8, 2**16, 2**32 or 2**64.
12953 The result type must be the same as the type of @code{Value}.
12954 The shift amount must be Natural.
12955 The formal parameter names can be anything.
12956
12957 @node Source_Location
12958 @section Source_Location
12959 @cindex Source_Location
12960 @noindent
12961 This intrinsic subprogram is used in the implementation of the
12962 library routine @code{GNAT.Source_Info}.  The only useful use of the
12963 intrinsic import in this case is the one in this unit, so an
12964 application program should simply call the function
12965 @code{GNAT.Source_Info.Source_Location} to obtain the current
12966 source file location.
12967
12968 @node Representation Clauses and Pragmas
12969 @chapter Representation Clauses and Pragmas
12970 @cindex Representation Clauses
12971
12972 @menu
12973 * Alignment Clauses::
12974 * Size Clauses::
12975 * Storage_Size Clauses::
12976 * Size of Variant Record Objects::
12977 * Biased Representation ::
12978 * Value_Size and Object_Size Clauses::
12979 * Component_Size Clauses::
12980 * Bit_Order Clauses::
12981 * Effect of Bit_Order on Byte Ordering::
12982 * Pragma Pack for Arrays::
12983 * Pragma Pack for Records::
12984 * Record Representation Clauses::
12985 * Enumeration Clauses::
12986 * Address Clauses::
12987 * Effect of Convention on Representation::
12988 * Determining the Representations chosen by GNAT::
12989 @end menu
12990
12991 @noindent
12992 @cindex Representation Clause
12993 @cindex Representation Pragma
12994 @cindex Pragma, representation
12995 This section describes the representation clauses accepted by GNAT, and
12996 their effect on the representation of corresponding data objects.
12997
12998 GNAT fully implements Annex C (Systems Programming).  This means that all
12999 the implementation advice sections in chapter 13 are fully implemented.
13000 However, these sections only require a minimal level of support for
13001 representation clauses.  GNAT provides much more extensive capabilities,
13002 and this section describes the additional capabilities provided.
13003
13004 @node Alignment Clauses
13005 @section Alignment Clauses
13006 @cindex Alignment Clause
13007
13008 @noindent
13009 GNAT requires that all alignment clauses specify a power of 2, and all
13010 default alignments are always a power of 2.  The default alignment
13011 values are as follows:
13012
13013 @itemize @bullet
13014 @item @emph{Primitive Types}.
13015 For primitive types, the alignment is the minimum of the actual size of
13016 objects of the type divided by @code{Storage_Unit},
13017 and the maximum alignment supported by the target.
13018 (This maximum alignment is given by the GNAT-specific attribute
13019 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
13020 @cindex @code{Maximum_Alignment} attribute
13021 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
13022 default alignment will be 8 on any target that supports alignments
13023 this large, but on some targets, the maximum alignment may be smaller
13024 than 8, in which case objects of type @code{Long_Float} will be maximally
13025 aligned.
13026
13027 @item @emph{Arrays}.
13028 For arrays, the alignment is equal to the alignment of the component type
13029 for the normal case where no packing or component size is given.  If the
13030 array is packed, and the packing is effective (see separate section on
13031 packed arrays), then the alignment will be one for long packed arrays,
13032 or arrays whose length is not known at compile time.  For short packed
13033 arrays, which are handled internally as modular types, the alignment
13034 will be as described for primitive types, e.g.@: a packed array of length
13035 31 bits will have an object size of four bytes, and an alignment of 4.
13036
13037 @item @emph{Records}.
13038 For the normal non-packed case, the alignment of a record is equal to
13039 the maximum alignment of any of its components.  For tagged records, this
13040 includes the implicit access type used for the tag.  If a pragma @code{Pack}
13041 is used and all components are packable (see separate section on pragma
13042 @code{Pack}), then the resulting alignment is 1, unless the layout of the
13043 record makes it profitable to increase it.
13044
13045 A special case is when:
13046 @itemize @bullet
13047 @item
13048 the size of the record is given explicitly, or a
13049 full record representation clause is given, and
13050 @item
13051 the size of the record is 2, 4, or 8 bytes.
13052 @end itemize
13053 @noindent
13054 In this case, an alignment is chosen to match the
13055 size of the record. For example, if we have:
13056
13057 @smallexample @c ada
13058    type Small is record
13059       A, B : Character;
13060    end record;
13061    for Small'Size use 16;
13062 @end smallexample
13063
13064 @noindent
13065 then the default alignment of the record type @code{Small} is 2, not 1. This
13066 leads to more efficient code when the record is treated as a unit, and also
13067 allows the type to specified as @code{Atomic} on architectures requiring
13068 strict alignment.
13069
13070 @end itemize
13071
13072 @noindent
13073 An alignment clause may specify a larger alignment than the default value
13074 up to some maximum value dependent on the target (obtainable by using the
13075 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
13076 a smaller alignment than the default value for enumeration, integer and
13077 fixed point types, as well as for record types, for example
13078
13079 @smallexample @c ada
13080   type V is record
13081      A : Integer;
13082   end record;
13083
13084   for V'alignment use 1;
13085 @end smallexample
13086
13087 @noindent
13088 @cindex Alignment, default
13089 The default alignment for the type @code{V} is 4, as a result of the
13090 Integer field in the record, but it is permissible, as shown, to
13091 override the default alignment of the record with a smaller value.
13092
13093 @cindex Alignment, subtypes
13094 Note that according to the Ada standard, an alignment clause applies only
13095 to the first named subtype. If additional subtypes are declared, then the
13096 compiler is allowed to choose any alignment it likes, and there is no way
13097 to control this choice. Consider:
13098
13099 @smallexample @c ada
13100    type R is range 1 .. 10_000;
13101    for R'Alignment use 1;
13102    subtype RS is R range 1 .. 1000;
13103 @end smallexample
13104
13105 @noindent
13106 The alignment clause specifies an alignment of 1 for the first named subtype
13107 @code{R} but this does not necessarily apply to @code{RS}. When writing
13108 portable Ada code, you should avoid writing code that explicitly or
13109 implicitly relies on the alignment of such subtypes.
13110
13111 For the GNAT compiler, if an explicit alignment clause is given, this
13112 value is also used for any subsequent subtypes. So for GNAT, in the
13113 above example, you can count on the alignment of @code{RS} being 1. But this
13114 assumption is non-portable, and other compilers may choose different
13115 alignments for the subtype @code{RS}.
13116
13117 @node Size Clauses
13118 @section Size Clauses
13119 @cindex Size Clause
13120
13121 @noindent
13122 The default size for a type @code{T} is obtainable through the
13123 language-defined attribute @code{T'Size} and also through the
13124 equivalent GNAT-defined attribute @code{T'Value_Size}.
13125 For objects of type @code{T}, GNAT will generally increase the type size
13126 so that the object size (obtainable through the GNAT-defined attribute
13127 @code{T'Object_Size})
13128 is a multiple of @code{T'Alignment * Storage_Unit}.
13129 For example
13130
13131 @smallexample @c ada
13132    type Smallint is range 1 .. 6;
13133
13134    type Rec is record
13135       Y1 : integer;
13136       Y2 : boolean;
13137    end record;
13138 @end smallexample
13139
13140 @noindent
13141 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
13142 as specified by the RM rules,
13143 but objects of this type will have a size of 8
13144 (@code{Smallint'Object_Size} = 8),
13145 since objects by default occupy an integral number
13146 of storage units.  On some targets, notably older
13147 versions of the Digital Alpha, the size of stand
13148 alone objects of this type may be 32, reflecting
13149 the inability of the hardware to do byte load/stores.
13150
13151 Similarly, the size of type @code{Rec} is 40 bits
13152 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
13153 the alignment is 4, so objects of this type will have
13154 their size increased to 64 bits so that it is a multiple
13155 of the alignment (in bits).  This decision is
13156 in accordance with the specific Implementation Advice in RM 13.3(43):
13157
13158 @quotation
13159 A @code{Size} clause should be supported for an object if the specified
13160 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
13161 to a size in storage elements that is a multiple of the object's
13162 @code{Alignment} (if the @code{Alignment} is nonzero).
13163 @end quotation
13164
13165 @noindent
13166 An explicit size clause may be used to override the default size by
13167 increasing it.  For example, if we have:
13168
13169 @smallexample @c ada
13170    type My_Boolean is new Boolean;
13171    for My_Boolean'Size use 32;
13172 @end smallexample
13173
13174 @noindent
13175 then values of this type will always be 32 bits long.  In the case of
13176 discrete types, the size can be increased up to 64 bits, with the effect
13177 that the entire specified field is used to hold the value, sign- or
13178 zero-extended as appropriate.  If more than 64 bits is specified, then
13179 padding space is allocated after the value, and a warning is issued that
13180 there are unused bits.
13181
13182 Similarly the size of records and arrays may be increased, and the effect
13183 is to add padding bits after the value.  This also causes a warning message
13184 to be generated.
13185
13186 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
13187 Size in bits, this corresponds to an object of size 256 megabytes (minus
13188 one).  This limitation is true on all targets.  The reason for this
13189 limitation is that it improves the quality of the code in many cases
13190 if it is known that a Size value can be accommodated in an object of
13191 type Integer.
13192
13193 @node Storage_Size Clauses
13194 @section Storage_Size Clauses
13195 @cindex Storage_Size Clause
13196
13197 @noindent
13198 For tasks, the @code{Storage_Size} clause specifies the amount of space
13199 to be allocated for the task stack.  This cannot be extended, and if the
13200 stack is exhausted, then @code{Storage_Error} will be raised (if stack
13201 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
13202 or a @code{Storage_Size} pragma in the task definition to set the
13203 appropriate required size.  A useful technique is to include in every
13204 task definition a pragma of the form:
13205
13206 @smallexample @c ada
13207    pragma Storage_Size (Default_Stack_Size);
13208 @end smallexample
13209
13210 @noindent
13211 Then @code{Default_Stack_Size} can be defined in a global package, and
13212 modified as required. Any tasks requiring stack sizes different from the
13213 default can have an appropriate alternative reference in the pragma.
13214
13215 You can also use the @option{-d} binder switch to modify the default stack
13216 size.
13217
13218 For access types, the @code{Storage_Size} clause specifies the maximum
13219 space available for allocation of objects of the type.  If this space is
13220 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
13221 In the case where the access type is declared local to a subprogram, the
13222 use of a @code{Storage_Size} clause triggers automatic use of a special
13223 predefined storage pool (@code{System.Pool_Size}) that ensures that all
13224 space for the pool is automatically reclaimed on exit from the scope in
13225 which the type is declared.
13226
13227 A special case recognized by the compiler is the specification of a
13228 @code{Storage_Size} of zero for an access type.  This means that no
13229 items can be allocated from the pool, and this is recognized at compile
13230 time, and all the overhead normally associated with maintaining a fixed
13231 size storage pool is eliminated.  Consider the following example:
13232
13233 @smallexample @c ada
13234    procedure p is
13235       type R is array (Natural) of Character;
13236       type P is access all R;
13237       for P'Storage_Size use 0;
13238       --  Above access type intended only for interfacing purposes
13239
13240       y : P;
13241
13242       procedure g (m : P);
13243       pragma Import (C, g);
13244
13245       --  @dots{}
13246
13247    begin
13248       --  @dots{}
13249       y := new R;
13250    end;
13251 @end smallexample
13252
13253 @noindent
13254 As indicated in this example, these dummy storage pools are often useful in
13255 connection with interfacing where no object will ever be allocated.  If you
13256 compile the above example, you get the warning:
13257
13258 @smallexample
13259    p.adb:16:09: warning: allocation from empty storage pool
13260    p.adb:16:09: warning: Storage_Error will be raised at run time
13261 @end smallexample
13262
13263 @noindent
13264 Of course in practice, there will not be any explicit allocators in the
13265 case of such an access declaration.
13266
13267 @node Size of Variant Record Objects
13268 @section Size of Variant Record Objects
13269 @cindex Size, variant record objects
13270 @cindex Variant record objects, size
13271
13272 @noindent
13273 In the case of variant record objects, there is a question whether Size gives
13274 information about a particular variant, or the maximum size required
13275 for any variant.  Consider the following program
13276
13277 @smallexample @c ada
13278 with Text_IO; use Text_IO;
13279 procedure q is
13280    type R1 (A : Boolean := False) is record
13281      case A is
13282        when True  => X : Character;
13283        when False => null;
13284      end case;
13285    end record;
13286
13287    V1 : R1 (False);
13288    V2 : R1;
13289
13290 begin
13291    Put_Line (Integer'Image (V1'Size));
13292    Put_Line (Integer'Image (V2'Size));
13293 end q;
13294 @end smallexample
13295
13296 @noindent
13297 Here we are dealing with a variant record, where the True variant
13298 requires 16 bits, and the False variant requires 8 bits.
13299 In the above example, both V1 and V2 contain the False variant,
13300 which is only 8 bits long.  However, the result of running the
13301 program is:
13302
13303 @smallexample
13304 8
13305 16
13306 @end smallexample
13307
13308 @noindent
13309 The reason for the difference here is that the discriminant value of
13310 V1 is fixed, and will always be False.  It is not possible to assign
13311 a True variant value to V1, therefore 8 bits is sufficient.  On the
13312 other hand, in the case of V2, the initial discriminant value is
13313 False (from the default), but it is possible to assign a True
13314 variant value to V2, therefore 16 bits must be allocated for V2
13315 in the general case, even fewer bits may be needed at any particular
13316 point during the program execution.
13317
13318 As can be seen from the output of this program, the @code{'Size}
13319 attribute applied to such an object in GNAT gives the actual allocated
13320 size of the variable, which is the largest size of any of the variants.
13321 The Ada Reference Manual is not completely clear on what choice should
13322 be made here, but the GNAT behavior seems most consistent with the
13323 language in the RM@.
13324
13325 In some cases, it may be desirable to obtain the size of the current
13326 variant, rather than the size of the largest variant.  This can be
13327 achieved in GNAT by making use of the fact that in the case of a
13328 subprogram parameter, GNAT does indeed return the size of the current
13329 variant (because a subprogram has no way of knowing how much space
13330 is actually allocated for the actual).
13331
13332 Consider the following modified version of the above program:
13333
13334 @smallexample @c ada
13335 with Text_IO; use Text_IO;
13336 procedure q is
13337    type R1 (A : Boolean := False) is record
13338      case A is
13339        when True  => X : Character;
13340        when False => null;
13341      end case;
13342    end record;
13343
13344    V2 : R1;
13345
13346    function Size (V : R1) return Integer is
13347    begin
13348       return V'Size;
13349    end Size;
13350
13351 begin
13352    Put_Line (Integer'Image (V2'Size));
13353    Put_Line (Integer'IMage (Size (V2)));
13354    V2 := (True, 'x');
13355    Put_Line (Integer'Image (V2'Size));
13356    Put_Line (Integer'IMage (Size (V2)));
13357 end q;
13358 @end smallexample
13359
13360 @noindent
13361 The output from this program is
13362
13363 @smallexample
13364 16
13365 8
13366 16
13367 16
13368 @end smallexample
13369
13370 @noindent
13371 Here we see that while the @code{'Size} attribute always returns
13372 the maximum size, regardless of the current variant value, the
13373 @code{Size} function does indeed return the size of the current
13374 variant value.
13375
13376 @node Biased Representation
13377 @section Biased Representation
13378 @cindex Size for biased representation
13379 @cindex Biased representation
13380
13381 @noindent
13382 In the case of scalars with a range starting at other than zero, it is
13383 possible in some cases to specify a size smaller than the default minimum
13384 value, and in such cases, GNAT uses an unsigned biased representation,
13385 in which zero is used to represent the lower bound, and successive values
13386 represent successive values of the type.
13387
13388 For example, suppose we have the declaration:
13389
13390 @smallexample @c ada
13391    type Small is range -7 .. -4;
13392    for Small'Size use 2;
13393 @end smallexample
13394
13395 @noindent
13396 Although the default size of type @code{Small} is 4, the @code{Size}
13397 clause is accepted by GNAT and results in the following representation
13398 scheme:
13399
13400 @smallexample
13401   -7 is represented as 2#00#
13402   -6 is represented as 2#01#
13403   -5 is represented as 2#10#
13404   -4 is represented as 2#11#
13405 @end smallexample
13406
13407 @noindent
13408 Biased representation is only used if the specified @code{Size} clause
13409 cannot be accepted in any other manner.  These reduced sizes that force
13410 biased representation can be used for all discrete types except for
13411 enumeration types for which a representation clause is given.
13412
13413 @node Value_Size and Object_Size Clauses
13414 @section Value_Size and Object_Size Clauses
13415 @findex Value_Size
13416 @findex Object_Size
13417 @cindex Size, of objects
13418
13419 @noindent
13420 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
13421 number of bits required to hold values of type @code{T}.
13422 Although this interpretation was allowed in Ada 83, it was not required,
13423 and this requirement in practice can cause some significant difficulties.
13424 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
13425 However, in Ada 95 and Ada 2005,
13426 @code{Natural'Size} is
13427 typically 31.  This means that code may change in behavior when moving
13428 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
13429
13430 @smallexample @c ada
13431    type Rec is record;
13432       A : Natural;
13433       B : Natural;
13434    end record;
13435
13436    for Rec use record
13437       at 0  range 0 .. Natural'Size - 1;
13438       at 0  range Natural'Size .. 2 * Natural'Size - 1;
13439    end record;
13440 @end smallexample
13441
13442 @noindent
13443 In the above code, since the typical size of @code{Natural} objects
13444 is 32 bits and @code{Natural'Size} is 31, the above code can cause
13445 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
13446 there are cases where the fact that the object size can exceed the
13447 size of the type causes surprises.
13448
13449 To help get around this problem GNAT provides two implementation
13450 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
13451 applied to a type, these attributes yield the size of the type
13452 (corresponding to the RM defined size attribute), and the size of
13453 objects of the type respectively.
13454
13455 The @code{Object_Size} is used for determining the default size of
13456 objects and components.  This size value can be referred to using the
13457 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
13458 the basis of the determination of the size.  The backend is free to
13459 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
13460 character might be stored in 32 bits on a machine with no efficient
13461 byte access instructions such as the Alpha.
13462
13463 The default rules for the value of @code{Object_Size} for
13464 discrete types are as follows:
13465
13466 @itemize @bullet
13467 @item
13468 The @code{Object_Size} for base subtypes reflect the natural hardware
13469 size in bits (run the compiler with @option{-gnatS} to find those values
13470 for numeric types). Enumeration types and fixed-point base subtypes have
13471 8, 16, 32 or 64 bits for this size, depending on the range of values
13472 to be stored.
13473
13474 @item
13475 The @code{Object_Size} of a subtype is the same as the
13476 @code{Object_Size} of
13477 the type from which it is obtained.
13478
13479 @item
13480 The @code{Object_Size} of a derived base type is copied from the parent
13481 base type, and the @code{Object_Size} of a derived first subtype is copied
13482 from the parent first subtype.
13483 @end itemize
13484
13485 @noindent
13486 The @code{Value_Size} attribute
13487 is the (minimum) number of bits required to store a value
13488 of the type.
13489 This value is used to determine how tightly to pack
13490 records or arrays with components of this type, and also affects
13491 the semantics of unchecked conversion (unchecked conversions where
13492 the @code{Value_Size} values differ generate a warning, and are potentially
13493 target dependent).
13494
13495 The default rules for the value of @code{Value_Size} are as follows:
13496
13497 @itemize @bullet
13498 @item
13499 The @code{Value_Size} for a base subtype is the minimum number of bits
13500 required to store all values of the type (including the sign bit
13501 only if negative values are possible).
13502
13503 @item
13504 If a subtype statically matches the first subtype of a given type, then it has
13505 by default the same @code{Value_Size} as the first subtype.  This is a
13506 consequence of RM 13.1(14) (``if two subtypes statically match,
13507 then their subtype-specific aspects are the same''.)
13508
13509 @item
13510 All other subtypes have a @code{Value_Size} corresponding to the minimum
13511 number of bits required to store all values of the subtype.  For
13512 dynamic bounds, it is assumed that the value can range down or up
13513 to the corresponding bound of the ancestor
13514 @end itemize
13515
13516 @noindent
13517 The RM defined attribute @code{Size} corresponds to the
13518 @code{Value_Size} attribute.
13519
13520 The @code{Size} attribute may be defined for a first-named subtype.  This sets
13521 the @code{Value_Size} of
13522 the first-named subtype to the given value, and the
13523 @code{Object_Size} of this first-named subtype to the given value padded up
13524 to an appropriate boundary.  It is a consequence of the default rules
13525 above that this @code{Object_Size} will apply to all further subtypes.  On the
13526 other hand, @code{Value_Size} is affected only for the first subtype, any
13527 dynamic subtypes obtained from it directly, and any statically matching
13528 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
13529
13530 @code{Value_Size} and
13531 @code{Object_Size} may be explicitly set for any subtype using
13532 an attribute definition clause.  Note that the use of these attributes
13533 can cause the RM 13.1(14) rule to be violated.  If two access types
13534 reference aliased objects whose subtypes have differing @code{Object_Size}
13535 values as a result of explicit attribute definition clauses, then it
13536 is erroneous to convert from one access subtype to the other.
13537
13538 At the implementation level, Esize stores the Object_Size and the
13539 RM_Size field stores the @code{Value_Size} (and hence the value of the
13540 @code{Size} attribute,
13541 which, as noted above, is equivalent to @code{Value_Size}).
13542
13543 To get a feel for the difference, consider the following examples (note
13544 that in each case the base is @code{Short_Short_Integer} with a size of 8):
13545
13546 @smallexample
13547                                        Object_Size     Value_Size
13548
13549 type x1 is range 0 .. 5;                    8               3
13550
13551 type x2 is range 0 .. 5;
13552 for x2'size use 12;                        16              12
13553
13554 subtype x3 is x2 range 0 .. 3;             16               2
13555
13556 subtype x4 is x2'base range 0 .. 10;        8               4
13557
13558 subtype x5 is x2 range 0 .. dynamic;       16               3*
13559
13560 subtype x6 is x2'base range 0 .. dynamic;   8               3*
13561
13562 @end smallexample
13563
13564 @noindent
13565 Note: the entries marked ``3*'' are not actually specified by the Ada
13566 Reference Manual, but it seems in the spirit of the RM rules to allocate
13567 the minimum number of bits (here 3, given the range for @code{x2})
13568 known to be large enough to hold the given range of values.
13569
13570 So far, so good, but GNAT has to obey the RM rules, so the question is
13571 under what conditions must the RM @code{Size} be used.
13572 The following is a list
13573 of the occasions on which the RM @code{Size} must be used:
13574
13575 @itemize @bullet
13576 @item
13577 Component size for packed arrays or records
13578
13579 @item
13580 Value of the attribute @code{Size} for a type
13581
13582 @item
13583 Warning about sizes not matching for unchecked conversion
13584 @end itemize
13585
13586 @noindent
13587 For record types, the @code{Object_Size} is always a multiple of the
13588 alignment of the type (this is true for all types). In some cases the
13589 @code{Value_Size} can be smaller. Consider:
13590
13591 @smallexample
13592    type R is record
13593      X : Integer;
13594      Y : Character;
13595    end record;
13596 @end smallexample
13597
13598 @noindent
13599 On a typical 32-bit architecture, the X component will be four bytes, and
13600 require four-byte alignment, and the Y component will be one byte. In this
13601 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
13602 required to store a value of this type, and for example, it is permissible
13603 to have a component of type R in an outer array whose component size is
13604 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
13605 since it must be rounded up so that this value is a multiple of the
13606 alignment (4 bytes = 32 bits).
13607
13608 @noindent
13609 For all other types, the @code{Object_Size}
13610 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
13611 Only @code{Size} may be specified for such types.
13612
13613 @node Component_Size Clauses
13614 @section Component_Size Clauses
13615 @cindex Component_Size Clause
13616
13617 @noindent
13618 Normally, the value specified in a component size clause must be consistent
13619 with the subtype of the array component with regard to size and alignment.
13620 In other words, the value specified must be at least equal to the size
13621 of this subtype, and must be a multiple of the alignment value.
13622
13623 In addition, component size clauses are allowed which cause the array
13624 to be packed, by specifying a smaller value.  A first case is for
13625 component size values in the range 1 through 63.  The value specified
13626 must not be smaller than the Size of the subtype.  GNAT will accurately
13627 honor all packing requests in this range.  For example, if we have:
13628
13629 @smallexample @c ada
13630 type r is array (1 .. 8) of Natural;
13631 for r'Component_Size use 31;
13632 @end smallexample
13633
13634 @noindent
13635 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
13636 Of course access to the components of such an array is considerably
13637 less efficient than if the natural component size of 32 is used.
13638 A second case is when the subtype of the component is a record type
13639 padded because of its default alignment.  For example, if we have:
13640
13641 @smallexample @c ada
13642 type r is record
13643   i : Integer;
13644   j : Integer;
13645   b : Boolean;
13646 end record;
13647
13648 type a is array (1 .. 8) of r;
13649 for a'Component_Size use 72;
13650 @end smallexample
13651
13652 @noindent
13653 then the resulting array has a length of 72 bytes, instead of 96 bytes
13654 if the alignment of the record (4) was obeyed.
13655
13656 Note that there is no point in giving both a component size clause
13657 and a pragma Pack for the same array type. if such duplicate
13658 clauses are given, the pragma Pack will be ignored.
13659
13660 @node Bit_Order Clauses
13661 @section Bit_Order Clauses
13662 @cindex Bit_Order Clause
13663 @cindex bit ordering
13664 @cindex ordering, of bits
13665
13666 @noindent
13667 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
13668 attribute.  The specification may either correspond to the default bit
13669 order for the target, in which case the specification has no effect and
13670 places no additional restrictions, or it may be for the non-standard
13671 setting (that is the opposite of the default).
13672
13673 In the case where the non-standard value is specified, the effect is
13674 to renumber bits within each byte, but the ordering of bytes is not
13675 affected.  There are certain
13676 restrictions placed on component clauses as follows:
13677
13678 @itemize @bullet
13679
13680 @item Components fitting within a single storage unit.
13681 @noindent
13682 These are unrestricted, and the effect is merely to renumber bits.  For
13683 example if we are on a little-endian machine with @code{Low_Order_First}
13684 being the default, then the following two declarations have exactly
13685 the same effect:
13686
13687 @smallexample @c ada
13688    type R1 is record
13689       A : Boolean;
13690       B : Integer range 1 .. 120;
13691    end record;
13692
13693    for R1 use record
13694       A at 0 range 0 .. 0;
13695       B at 0 range 1 .. 7;
13696    end record;
13697
13698    type R2 is record
13699       A : Boolean;
13700       B : Integer range 1 .. 120;
13701    end record;
13702
13703    for R2'Bit_Order use High_Order_First;
13704
13705    for R2 use record
13706       A at 0 range 7 .. 7;
13707       B at 0 range 0 .. 6;
13708    end record;
13709 @end smallexample
13710
13711 @noindent
13712 The useful application here is to write the second declaration with the
13713 @code{Bit_Order} attribute definition clause, and know that it will be treated
13714 the same, regardless of whether the target is little-endian or big-endian.
13715
13716 @item Components occupying an integral number of bytes.
13717 @noindent
13718 These are components that exactly fit in two or more bytes.  Such component
13719 declarations are allowed, but have no effect, since it is important to realize
13720 that the @code{Bit_Order} specification does not affect the ordering of bytes.
13721 In particular, the following attempt at getting an endian-independent integer
13722 does not work:
13723
13724 @smallexample @c ada
13725    type R2 is record
13726       A : Integer;
13727    end record;
13728
13729    for R2'Bit_Order use High_Order_First;
13730
13731    for R2 use record
13732       A at 0 range 0 .. 31;
13733    end record;
13734 @end smallexample
13735
13736 @noindent
13737 This declaration will result in a little-endian integer on a
13738 little-endian machine, and a big-endian integer on a big-endian machine.
13739 If byte flipping is required for interoperability between big- and
13740 little-endian machines, this must be explicitly programmed.  This capability
13741 is not provided by @code{Bit_Order}.
13742
13743 @item Components that are positioned across byte boundaries
13744 @noindent
13745 but do not occupy an integral number of bytes.  Given that bytes are not
13746 reordered, such fields would occupy a non-contiguous sequence of bits
13747 in memory, requiring non-trivial code to reassemble.  They are for this
13748 reason not permitted, and any component clause specifying such a layout
13749 will be flagged as illegal by GNAT@.
13750
13751 @end itemize
13752
13753 @noindent
13754 Since the misconception that Bit_Order automatically deals with all
13755 endian-related incompatibilities is a common one, the specification of
13756 a component field that is an integral number of bytes will always
13757 generate a warning.  This warning may be suppressed using @code{pragma
13758 Warnings (Off)} if desired.  The following section contains additional
13759 details regarding the issue of byte ordering.
13760
13761 @node Effect of Bit_Order on Byte Ordering
13762 @section Effect of Bit_Order on Byte Ordering
13763 @cindex byte ordering
13764 @cindex ordering, of bytes
13765
13766 @noindent
13767 In this section we will review the effect of the @code{Bit_Order} attribute
13768 definition clause on byte ordering.  Briefly, it has no effect at all, but
13769 a detailed example will be helpful.  Before giving this
13770 example, let us review the precise
13771 definition of the effect of defining @code{Bit_Order}.  The effect of a
13772 non-standard bit order is described in section 15.5.3 of the Ada
13773 Reference Manual:
13774
13775 @quotation
13776 2   A bit ordering is a method of interpreting the meaning of
13777 the storage place attributes.
13778 @end quotation
13779
13780 @noindent
13781 To understand the precise definition of storage place attributes in
13782 this context, we visit section 13.5.1 of the manual:
13783
13784 @quotation
13785 13   A record_representation_clause (without the mod_clause)
13786 specifies the layout.  The storage place attributes (see 13.5.2)
13787 are taken from the values of the position, first_bit, and last_bit
13788 expressions after normalizing those values so that first_bit is
13789 less than Storage_Unit.
13790 @end quotation
13791
13792 @noindent
13793 The critical point here is that storage places are taken from
13794 the values after normalization, not before.  So the @code{Bit_Order}
13795 interpretation applies to normalized values.  The interpretation
13796 is described in the later part of the 15.5.3 paragraph:
13797
13798 @quotation
13799 2   A bit ordering is a method of interpreting the meaning of
13800 the storage place attributes.  High_Order_First (known in the
13801 vernacular as ``big endian'') means that the first bit of a
13802 storage element (bit 0) is the most significant bit (interpreting
13803 the sequence of bits that represent a component as an unsigned
13804 integer value).  Low_Order_First (known in the vernacular as
13805 ``little endian'') means the opposite: the first bit is the
13806 least significant.
13807 @end quotation
13808
13809 @noindent
13810 Note that the numbering is with respect to the bits of a storage
13811 unit.  In other words, the specification affects only the numbering
13812 of bits within a single storage unit.
13813
13814 We can make the effect clearer by giving an example.
13815
13816 Suppose that we have an external device which presents two bytes, the first
13817 byte presented, which is the first (low addressed byte) of the two byte
13818 record is called Master, and the second byte is called Slave.
13819
13820 The left most (most significant bit is called Control for each byte, and
13821 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
13822 (least significant) bit.
13823
13824 On a big-endian machine, we can write the following representation clause
13825
13826 @smallexample @c ada
13827    type Data is record
13828       Master_Control : Bit;
13829       Master_V1      : Bit;
13830       Master_V2      : Bit;
13831       Master_V3      : Bit;
13832       Master_V4      : Bit;
13833       Master_V5      : Bit;
13834       Master_V6      : Bit;
13835       Master_V7      : Bit;
13836       Slave_Control  : Bit;
13837       Slave_V1       : Bit;
13838       Slave_V2       : Bit;
13839       Slave_V3       : Bit;
13840       Slave_V4       : Bit;
13841       Slave_V5       : Bit;
13842       Slave_V6       : Bit;
13843       Slave_V7       : Bit;
13844    end record;
13845
13846    for Data use record
13847       Master_Control at 0 range 0 .. 0;
13848       Master_V1      at 0 range 1 .. 1;
13849       Master_V2      at 0 range 2 .. 2;
13850       Master_V3      at 0 range 3 .. 3;
13851       Master_V4      at 0 range 4 .. 4;
13852       Master_V5      at 0 range 5 .. 5;
13853       Master_V6      at 0 range 6 .. 6;
13854       Master_V7      at 0 range 7 .. 7;
13855       Slave_Control  at 1 range 0 .. 0;
13856       Slave_V1       at 1 range 1 .. 1;
13857       Slave_V2       at 1 range 2 .. 2;
13858       Slave_V3       at 1 range 3 .. 3;
13859       Slave_V4       at 1 range 4 .. 4;
13860       Slave_V5       at 1 range 5 .. 5;
13861       Slave_V6       at 1 range 6 .. 6;
13862       Slave_V7       at 1 range 7 .. 7;
13863    end record;
13864 @end smallexample
13865
13866 @noindent
13867 Now if we move this to a little endian machine, then the bit ordering within
13868 the byte is backwards, so we have to rewrite the record rep clause as:
13869
13870 @smallexample @c ada
13871    for Data use record
13872       Master_Control at 0 range 7 .. 7;
13873       Master_V1      at 0 range 6 .. 6;
13874       Master_V2      at 0 range 5 .. 5;
13875       Master_V3      at 0 range 4 .. 4;
13876       Master_V4      at 0 range 3 .. 3;
13877       Master_V5      at 0 range 2 .. 2;
13878       Master_V6      at 0 range 1 .. 1;
13879       Master_V7      at 0 range 0 .. 0;
13880       Slave_Control  at 1 range 7 .. 7;
13881       Slave_V1       at 1 range 6 .. 6;
13882       Slave_V2       at 1 range 5 .. 5;
13883       Slave_V3       at 1 range 4 .. 4;
13884       Slave_V4       at 1 range 3 .. 3;
13885       Slave_V5       at 1 range 2 .. 2;
13886       Slave_V6       at 1 range 1 .. 1;
13887       Slave_V7       at 1 range 0 .. 0;
13888    end record;
13889 @end smallexample
13890
13891 @noindent
13892 It is a nuisance to have to rewrite the clause, especially if
13893 the code has to be maintained on both machines.  However,
13894 this is a case that we can handle with the
13895 @code{Bit_Order} attribute if it is implemented.
13896 Note that the implementation is not required on byte addressed
13897 machines, but it is indeed implemented in GNAT.
13898 This means that we can simply use the
13899 first record clause, together with the declaration
13900
13901 @smallexample @c ada
13902    for Data'Bit_Order use High_Order_First;
13903 @end smallexample
13904
13905 @noindent
13906 and the effect is what is desired, namely the layout is exactly the same,
13907 independent of whether the code is compiled on a big-endian or little-endian
13908 machine.
13909
13910 The important point to understand is that byte ordering is not affected.
13911 A @code{Bit_Order} attribute definition never affects which byte a field
13912 ends up in, only where it ends up in that byte.
13913 To make this clear, let us rewrite the record rep clause of the previous
13914 example as:
13915
13916 @smallexample @c ada
13917    for Data'Bit_Order use High_Order_First;
13918    for Data use record
13919       Master_Control at 0 range  0 .. 0;
13920       Master_V1      at 0 range  1 .. 1;
13921       Master_V2      at 0 range  2 .. 2;
13922       Master_V3      at 0 range  3 .. 3;
13923       Master_V4      at 0 range  4 .. 4;
13924       Master_V5      at 0 range  5 .. 5;
13925       Master_V6      at 0 range  6 .. 6;
13926       Master_V7      at 0 range  7 .. 7;
13927       Slave_Control  at 0 range  8 .. 8;
13928       Slave_V1       at 0 range  9 .. 9;
13929       Slave_V2       at 0 range 10 .. 10;
13930       Slave_V3       at 0 range 11 .. 11;
13931       Slave_V4       at 0 range 12 .. 12;
13932       Slave_V5       at 0 range 13 .. 13;
13933       Slave_V6       at 0 range 14 .. 14;
13934       Slave_V7       at 0 range 15 .. 15;
13935    end record;
13936 @end smallexample
13937
13938 @noindent
13939 This is exactly equivalent to saying (a repeat of the first example):
13940
13941 @smallexample @c ada
13942    for Data'Bit_Order use High_Order_First;
13943    for Data use record
13944       Master_Control at 0 range 0 .. 0;
13945       Master_V1      at 0 range 1 .. 1;
13946       Master_V2      at 0 range 2 .. 2;
13947       Master_V3      at 0 range 3 .. 3;
13948       Master_V4      at 0 range 4 .. 4;
13949       Master_V5      at 0 range 5 .. 5;
13950       Master_V6      at 0 range 6 .. 6;
13951       Master_V7      at 0 range 7 .. 7;
13952       Slave_Control  at 1 range 0 .. 0;
13953       Slave_V1       at 1 range 1 .. 1;
13954       Slave_V2       at 1 range 2 .. 2;
13955       Slave_V3       at 1 range 3 .. 3;
13956       Slave_V4       at 1 range 4 .. 4;
13957       Slave_V5       at 1 range 5 .. 5;
13958       Slave_V6       at 1 range 6 .. 6;
13959       Slave_V7       at 1 range 7 .. 7;
13960    end record;
13961 @end smallexample
13962
13963 @noindent
13964 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
13965 field.  The storage place attributes are obtained by normalizing the
13966 values given so that the @code{First_Bit} value is less than 8.  After
13967 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
13968 we specified in the other case.
13969
13970 Now one might expect that the @code{Bit_Order} attribute might affect
13971 bit numbering within the entire record component (two bytes in this
13972 case, thus affecting which byte fields end up in), but that is not
13973 the way this feature is defined, it only affects numbering of bits,
13974 not which byte they end up in.
13975
13976 Consequently it never makes sense to specify a starting bit number
13977 greater than 7 (for a byte addressable field) if an attribute
13978 definition for @code{Bit_Order} has been given, and indeed it
13979 may be actively confusing to specify such a value, so the compiler
13980 generates a warning for such usage.
13981
13982 If you do need to control byte ordering then appropriate conditional
13983 values must be used.  If in our example, the slave byte came first on
13984 some machines we might write:
13985
13986 @smallexample @c ada
13987    Master_Byte_First constant Boolean := @dots{};
13988
13989    Master_Byte : constant Natural :=
13990                    1 - Boolean'Pos (Master_Byte_First);
13991    Slave_Byte  : constant Natural :=
13992                    Boolean'Pos (Master_Byte_First);
13993
13994    for Data'Bit_Order use High_Order_First;
13995    for Data use record
13996       Master_Control at Master_Byte range 0 .. 0;
13997       Master_V1      at Master_Byte range 1 .. 1;
13998       Master_V2      at Master_Byte range 2 .. 2;
13999       Master_V3      at Master_Byte range 3 .. 3;
14000       Master_V4      at Master_Byte range 4 .. 4;
14001       Master_V5      at Master_Byte range 5 .. 5;
14002       Master_V6      at Master_Byte range 6 .. 6;
14003       Master_V7      at Master_Byte range 7 .. 7;
14004       Slave_Control  at Slave_Byte  range 0 .. 0;
14005       Slave_V1       at Slave_Byte  range 1 .. 1;
14006       Slave_V2       at Slave_Byte  range 2 .. 2;
14007       Slave_V3       at Slave_Byte  range 3 .. 3;
14008       Slave_V4       at Slave_Byte  range 4 .. 4;
14009       Slave_V5       at Slave_Byte  range 5 .. 5;
14010       Slave_V6       at Slave_Byte  range 6 .. 6;
14011       Slave_V7       at Slave_Byte  range 7 .. 7;
14012    end record;
14013 @end smallexample
14014
14015 @noindent
14016 Now to switch between machines, all that is necessary is
14017 to set the boolean constant @code{Master_Byte_First} in
14018 an appropriate manner.
14019
14020 @node Pragma Pack for Arrays
14021 @section Pragma Pack for Arrays
14022 @cindex Pragma Pack (for arrays)
14023
14024 @noindent
14025 Pragma @code{Pack} applied to an array has no effect unless the component type
14026 is packable.  For a component type to be packable, it must be one of the
14027 following cases:
14028
14029 @itemize @bullet
14030 @item
14031 Any scalar type
14032 @item
14033 Any type whose size is specified with a size clause
14034 @item
14035 Any packed array type with a static size
14036 @item
14037 Any record type padded because of its default alignment
14038 @end itemize
14039
14040 @noindent
14041 For all these cases, if the component subtype size is in the range
14042 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
14043 component size were specified giving the component subtype size.
14044 For example if we have:
14045
14046 @smallexample @c ada
14047    type r is range 0 .. 17;
14048
14049    type ar is array (1 .. 8) of r;
14050    pragma Pack (ar);
14051 @end smallexample
14052
14053 @noindent
14054 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
14055 and the size of the array @code{ar} will be exactly 40 bits.
14056
14057 Note that in some cases this rather fierce approach to packing can produce
14058 unexpected effects.  For example, in Ada 95 and Ada 2005,
14059 subtype @code{Natural} typically has a size of 31, meaning that if you
14060 pack an array of @code{Natural}, you get 31-bit
14061 close packing, which saves a few bits, but results in far less efficient
14062 access.  Since many other Ada compilers will ignore such a packing request,
14063 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
14064 might not be what is intended.  You can easily remove this warning by
14065 using an explicit @code{Component_Size} setting instead, which never generates
14066 a warning, since the intention of the programmer is clear in this case.
14067
14068 GNAT treats packed arrays in one of two ways.  If the size of the array is
14069 known at compile time and is less than 64 bits, then internally the array
14070 is represented as a single modular type, of exactly the appropriate number
14071 of bits.  If the length is greater than 63 bits, or is not known at compile
14072 time, then the packed array is represented as an array of bytes, and the
14073 length is always a multiple of 8 bits.
14074
14075 Note that to represent a packed array as a modular type, the alignment must
14076 be suitable for the modular type involved. For example, on typical machines
14077 a 32-bit packed array will be represented by a 32-bit modular integer with
14078 an alignment of four bytes. If you explicitly override the default alignment
14079 with an alignment clause that is too small, the modular representation
14080 cannot be used. For example, consider the following set of declarations:
14081
14082 @smallexample @c ada
14083    type R is range 1 .. 3;
14084    type S is array (1 .. 31) of R;
14085    for S'Component_Size use 2;
14086    for S'Size use 62;
14087    for S'Alignment use 1;
14088 @end smallexample
14089
14090 @noindent
14091 If the alignment clause were not present, then a 62-bit modular
14092 representation would be chosen (typically with an alignment of 4 or 8
14093 bytes depending on the target). But the default alignment is overridden
14094 with the explicit alignment clause. This means that the modular
14095 representation cannot be used, and instead the array of bytes
14096 representation must be used, meaning that the length must be a multiple
14097 of 8. Thus the above set of declarations will result in a diagnostic
14098 rejecting the size clause and noting that the minimum size allowed is 64.
14099
14100 @cindex Pragma Pack (for type Natural)
14101 @cindex Pragma Pack warning
14102
14103 One special case that is worth noting occurs when the base type of the
14104 component size is 8/16/32 and the subtype is one bit less. Notably this
14105 occurs with subtype @code{Natural}. Consider:
14106
14107 @smallexample @c ada
14108    type Arr is array (1 .. 32) of Natural;
14109    pragma Pack (Arr);
14110 @end smallexample
14111
14112 @noindent
14113 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
14114 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
14115 Ada 83 compilers did not attempt 31 bit packing.
14116
14117 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
14118 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
14119 substantial unintended performance penalty when porting legacy Ada 83 code.
14120 To help prevent this, GNAT generates a warning in such cases. If you really
14121 want 31 bit packing in a case like this, you can set the component size
14122 explicitly:
14123
14124 @smallexample @c ada
14125    type Arr is array (1 .. 32) of Natural;
14126    for Arr'Component_Size use 31;
14127 @end smallexample
14128
14129 @noindent
14130 Here 31-bit packing is achieved as required, and no warning is generated,
14131 since in this case the programmer intention is clear.
14132
14133 @node Pragma Pack for Records
14134 @section Pragma Pack for Records
14135 @cindex Pragma Pack (for records)
14136
14137 @noindent
14138 Pragma @code{Pack} applied to a record will pack the components to reduce
14139 wasted space from alignment gaps and by reducing the amount of space
14140 taken by components.  We distinguish between @emph{packable} components and
14141 @emph{non-packable} components.
14142 Components of the following types are considered packable:
14143 @itemize @bullet
14144 @item
14145 All primitive types are packable.
14146
14147 @item
14148 Small packed arrays, whose size does not exceed 64 bits, and where the
14149 size is statically known at compile time, are represented internally
14150 as modular integers, and so they are also packable.
14151
14152 @end itemize
14153
14154 @noindent
14155 All packable components occupy the exact number of bits corresponding to
14156 their @code{Size} value, and are packed with no padding bits, i.e.@: they
14157 can start on an arbitrary bit boundary.
14158
14159 All other types are non-packable, they occupy an integral number of
14160 storage units, and
14161 are placed at a boundary corresponding to their alignment requirements.
14162
14163 For example, consider the record
14164
14165 @smallexample @c ada
14166    type Rb1 is array (1 .. 13) of Boolean;
14167    pragma Pack (rb1);
14168
14169    type Rb2 is array (1 .. 65) of Boolean;
14170    pragma Pack (rb2);
14171
14172    type x2 is record
14173       l1 : Boolean;
14174       l2 : Duration;
14175       l3 : Float;
14176       l4 : Boolean;
14177       l5 : Rb1;
14178       l6 : Rb2;
14179    end record;
14180    pragma Pack (x2);
14181 @end smallexample
14182
14183 @noindent
14184 The representation for the record x2 is as follows:
14185
14186 @smallexample @c ada
14187 for x2'Size use 224;
14188 for x2 use record
14189    l1 at  0 range  0 .. 0;
14190    l2 at  0 range  1 .. 64;
14191    l3 at 12 range  0 .. 31;
14192    l4 at 16 range  0 .. 0;
14193    l5 at 16 range  1 .. 13;
14194    l6 at 18 range  0 .. 71;
14195 end record;
14196 @end smallexample
14197
14198 @noindent
14199 Studying this example, we see that the packable fields @code{l1}
14200 and @code{l2} are
14201 of length equal to their sizes, and placed at specific bit boundaries (and
14202 not byte boundaries) to
14203 eliminate padding.  But @code{l3} is of a non-packable float type, so
14204 it is on the next appropriate alignment boundary.
14205
14206 The next two fields are fully packable, so @code{l4} and @code{l5} are
14207 minimally packed with no gaps.  However, type @code{Rb2} is a packed
14208 array that is longer than 64 bits, so it is itself non-packable.  Thus
14209 the @code{l6} field is aligned to the next byte boundary, and takes an
14210 integral number of bytes, i.e.@: 72 bits.
14211
14212 @node Record Representation Clauses
14213 @section Record Representation Clauses
14214 @cindex Record Representation Clause
14215
14216 @noindent
14217 Record representation clauses may be given for all record types, including
14218 types obtained by record extension.  Component clauses are allowed for any
14219 static component.  The restrictions on component clauses depend on the type
14220 of the component.
14221
14222 @cindex Component Clause
14223 For all components of an elementary type, the only restriction on component
14224 clauses is that the size must be at least the 'Size value of the type
14225 (actually the Value_Size).  There are no restrictions due to alignment,
14226 and such components may freely cross storage boundaries.
14227
14228 Packed arrays with a size up to and including 64 bits are represented
14229 internally using a modular type with the appropriate number of bits, and
14230 thus the same lack of restriction applies.  For example, if you declare:
14231
14232 @smallexample @c ada
14233    type R is array (1 .. 49) of Boolean;
14234    pragma Pack (R);
14235    for R'Size use 49;
14236 @end smallexample
14237
14238 @noindent
14239 then a component clause for a component of type R may start on any
14240 specified bit boundary, and may specify a value of 49 bits or greater.
14241
14242 For packed bit arrays that are longer than 64 bits, there are two
14243 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
14244 including the important case of single bits or boolean values, then
14245 there are no limitations on placement of such components, and they
14246 may start and end at arbitrary bit boundaries.
14247
14248 If the component size is not a power of 2 (e.g.@: 3 or 5), then
14249 an array of this type longer than 64 bits must always be placed on
14250 on a storage unit (byte) boundary and occupy an integral number
14251 of storage units (bytes). Any component clause that does not
14252 meet this requirement will be rejected.
14253
14254 Any aliased component, or component of an aliased type, must
14255 have its normal alignment and size. A component clause that
14256 does not meet this requirement will be rejected.
14257
14258 The tag field of a tagged type always occupies an address sized field at
14259 the start of the record.  No component clause may attempt to overlay this
14260 tag. When a tagged type appears as a component, the tag field must have
14261 proper alignment
14262
14263 In the case of a record extension T1, of a type T, no component clause applied
14264 to the type T1 can specify a storage location that would overlap the first
14265 T'Size bytes of the record.
14266
14267 For all other component types, including non-bit-packed arrays,
14268 the component can be placed at an arbitrary bit boundary,
14269 so for example, the following is permitted:
14270
14271 @smallexample @c ada
14272    type R is array (1 .. 10) of Boolean;
14273    for R'Size use 80;
14274
14275    type Q is record
14276       G, H : Boolean;
14277       L, M : R;
14278    end record;
14279
14280    for Q use record
14281       G at 0 range  0 ..   0;
14282       H at 0 range  1 ..   1;
14283       L at 0 range  2 ..  81;
14284       R at 0 range 82 .. 161;
14285    end record;
14286 @end smallexample
14287
14288 @noindent
14289 Note: the above rules apply to recent releases of GNAT 5.
14290 In GNAT 3, there are more severe restrictions on larger components.
14291 For non-primitive types, including packed arrays with a size greater than
14292 64 bits, component clauses must respect the alignment requirement of the
14293 type, in particular, always starting on a byte boundary, and the length
14294 must be a multiple of the storage unit.
14295
14296 @node Enumeration Clauses
14297 @section Enumeration Clauses
14298
14299 The only restriction on enumeration clauses is that the range of values
14300 must be representable.  For the signed case, if one or more of the
14301 representation values are negative, all values must be in the range:
14302
14303 @smallexample @c ada
14304    System.Min_Int .. System.Max_Int
14305 @end smallexample
14306
14307 @noindent
14308 For the unsigned case, where all values are nonnegative, the values must
14309 be in the range:
14310
14311 @smallexample @c ada
14312    0 .. System.Max_Binary_Modulus;
14313 @end smallexample
14314
14315 @noindent
14316 A @emph{confirming} representation clause is one in which the values range
14317 from 0 in sequence, i.e.@: a clause that confirms the default representation
14318 for an enumeration type.
14319 Such a confirming representation
14320 is permitted by these rules, and is specially recognized by the compiler so
14321 that no extra overhead results from the use of such a clause.
14322
14323 If an array has an index type which is an enumeration type to which an
14324 enumeration clause has been applied, then the array is stored in a compact
14325 manner.  Consider the declarations:
14326
14327 @smallexample @c ada
14328    type r is (A, B, C);
14329    for r use (A => 1, B => 5, C => 10);
14330    type t is array (r) of Character;
14331 @end smallexample
14332
14333 @noindent
14334 The array type t corresponds to a vector with exactly three elements and
14335 has a default size equal to @code{3*Character'Size}.  This ensures efficient
14336 use of space, but means that accesses to elements of the array will incur
14337 the overhead of converting representation values to the corresponding
14338 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
14339
14340 @node Address Clauses
14341 @section Address Clauses
14342 @cindex Address Clause
14343
14344 The reference manual allows a general restriction on representation clauses,
14345 as found in RM 13.1(22):
14346
14347 @quotation
14348 An implementation need not support representation
14349 items containing nonstatic expressions, except that
14350 an implementation should support a representation item
14351 for a given entity if each nonstatic expression in the
14352 representation item is a name that statically denotes
14353 a constant declared before the entity.
14354 @end quotation
14355
14356 @noindent
14357 In practice this is applicable only to address clauses, since this is the
14358 only case in which a non-static expression is permitted by the syntax.  As
14359 the AARM notes in sections 13.1 (22.a-22.h):
14360
14361 @display
14362   22.a   Reason: This is to avoid the following sort of thing:
14363
14364   22.b        X : Integer := F(@dots{});
14365               Y : Address := G(@dots{});
14366               for X'Address use Y;
14367
14368   22.c   In the above, we have to evaluate the
14369          initialization expression for X before we
14370          know where to put the result.  This seems
14371          like an unreasonable implementation burden.
14372
14373   22.d   The above code should instead be written
14374          like this:
14375
14376   22.e        Y : constant Address := G(@dots{});
14377               X : Integer := F(@dots{});
14378               for X'Address use Y;
14379
14380   22.f   This allows the expression ``Y'' to be safely
14381          evaluated before X is created.
14382
14383   22.g   The constant could be a formal parameter of mode in.
14384
14385   22.h   An implementation can support other nonstatic
14386          expressions if it wants to.  Expressions of type
14387          Address are hardly ever static, but their value
14388          might be known at compile time anyway in many
14389          cases.
14390 @end display
14391
14392 @noindent
14393 GNAT does indeed permit many additional cases of non-static expressions.  In
14394 particular, if the type involved is elementary there are no restrictions
14395 (since in this case, holding a temporary copy of the initialization value,
14396 if one is present, is inexpensive).  In addition, if there is no implicit or
14397 explicit initialization, then there are no restrictions.  GNAT will reject
14398 only the case where all three of these conditions hold:
14399
14400 @itemize @bullet
14401
14402 @item
14403 The type of the item is non-elementary (e.g.@: a record or array).
14404
14405 @item
14406 There is explicit or implicit initialization required for the object.
14407 Note that access values are always implicitly initialized.
14408
14409 @item
14410 The address value is non-static.  Here GNAT is more permissive than the
14411 RM, and allows the address value to be the address of a previously declared
14412 stand-alone variable, as long as it does not itself have an address clause.
14413
14414 @smallexample @c ada
14415            Anchor  : Some_Initialized_Type;
14416            Overlay : Some_Initialized_Type;
14417            for Overlay'Address use Anchor'Address;
14418 @end smallexample
14419
14420 @noindent
14421 However, the prefix of the address clause cannot be an array component, or
14422 a component of a discriminated record.
14423
14424 @end itemize
14425
14426 @noindent
14427 As noted above in section 22.h, address values are typically non-static.  In
14428 particular the To_Address function, even if applied to a literal value, is
14429 a non-static function call.  To avoid this minor annoyance, GNAT provides
14430 the implementation defined attribute 'To_Address.  The following two
14431 expressions have identical values:
14432
14433 @findex Attribute
14434 @findex To_Address
14435 @smallexample @c ada
14436    To_Address (16#1234_0000#)
14437    System'To_Address (16#1234_0000#);
14438 @end smallexample
14439
14440 @noindent
14441 except that the second form is considered to be a static expression, and
14442 thus when used as an address clause value is always permitted.
14443
14444 @noindent
14445 Additionally, GNAT treats as static an address clause that is an
14446 unchecked_conversion of a static integer value.  This simplifies the porting
14447 of legacy code, and provides a portable equivalent to the GNAT attribute
14448 @code{To_Address}.
14449
14450 Another issue with address clauses is the interaction with alignment
14451 requirements.  When an address clause is given for an object, the address
14452 value must be consistent with the alignment of the object (which is usually
14453 the same as the alignment of the type of the object).  If an address clause
14454 is given that specifies an inappropriately aligned address value, then the
14455 program execution is erroneous.
14456
14457 Since this source of erroneous behavior can have unfortunate effects, GNAT
14458 checks (at compile time if possible, generating a warning, or at execution
14459 time with a run-time check) that the alignment is appropriate.  If the
14460 run-time check fails, then @code{Program_Error} is raised.  This run-time
14461 check is suppressed if range checks are suppressed, or if the special GNAT
14462 check Alignment_Check is suppressed, or if
14463 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
14464
14465 Finally, GNAT does not permit overlaying of objects of controlled types or
14466 composite types containing a controlled component. In most cases, the compiler
14467 can detect an attempt at such overlays and will generate a warning at compile
14468 time and a Program_Error exception at run time.
14469
14470 @findex Export
14471 An address clause cannot be given for an exported object.  More
14472 understandably the real restriction is that objects with an address
14473 clause cannot be exported.  This is because such variables are not
14474 defined by the Ada program, so there is no external object to export.
14475
14476 @findex Import
14477 It is permissible to give an address clause and a pragma Import for the
14478 same object.  In this case, the variable is not really defined by the
14479 Ada program, so there is no external symbol to be linked.  The link name
14480 and the external name are ignored in this case.  The reason that we allow this
14481 combination is that it provides a useful idiom to avoid unwanted
14482 initializations on objects with address clauses.
14483
14484 When an address clause is given for an object that has implicit or
14485 explicit initialization, then by default initialization takes place.  This
14486 means that the effect of the object declaration is to overwrite the
14487 memory at the specified address.  This is almost always not what the
14488 programmer wants, so GNAT will output a warning:
14489
14490 @smallexample
14491   with System;
14492   package G is
14493      type R is record
14494         M : Integer := 0;
14495      end record;
14496
14497      Ext : R;
14498      for Ext'Address use System'To_Address (16#1234_1234#);
14499          |
14500   >>> warning: implicit initialization of "Ext" may
14501       modify overlaid storage
14502   >>> warning: use pragma Import for "Ext" to suppress
14503       initialization (RM B(24))
14504
14505   end G;
14506 @end smallexample
14507
14508 @noindent
14509 As indicated by the warning message, the solution is to use a (dummy) pragma
14510 Import to suppress this initialization.  The pragma tell the compiler that the
14511 object is declared and initialized elsewhere.  The following package compiles
14512 without warnings (and the initialization is suppressed):
14513
14514 @smallexample @c ada
14515    with System;
14516    package G is
14517       type R is record
14518          M : Integer := 0;
14519       end record;
14520
14521       Ext : R;
14522       for Ext'Address use System'To_Address (16#1234_1234#);
14523       pragma Import (Ada, Ext);
14524    end G;
14525 @end smallexample
14526
14527 @noindent
14528 A final issue with address clauses involves their use for overlaying
14529 variables, as in the following example:
14530 @cindex Overlaying of objects
14531
14532 @smallexample @c ada
14533   A : Integer;
14534   B : Integer;
14535   for B'Address use A'Address;
14536 @end smallexample
14537
14538 @noindent
14539 or alternatively, using the form recommended by the RM:
14540
14541 @smallexample @c ada
14542   A    : Integer;
14543   Addr : constant Address := A'Address;
14544   B    : Integer;
14545   for B'Address use Addr;
14546 @end smallexample
14547
14548 @noindent
14549 In both of these cases, @code{A}
14550 and @code{B} become aliased to one another via the
14551 address clause. This use of address clauses to overlay
14552 variables, achieving an effect similar to unchecked
14553 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
14554 the effect is implementation defined. Furthermore, the
14555 Ada RM specifically recommends that in a situation
14556 like this, @code{B} should be subject to the following
14557 implementation advice (RM 13.3(19)):
14558
14559 @quotation
14560 19  If the Address of an object is specified, or it is imported
14561     or exported, then the implementation should not perform
14562     optimizations based on assumptions of no aliases.
14563 @end quotation
14564
14565 @noindent
14566 GNAT follows this recommendation, and goes further by also applying
14567 this recommendation to the overlaid variable (@code{A}
14568 in the above example) in this case. This means that the overlay
14569 works "as expected", in that a modification to one of the variables
14570 will affect the value of the other.
14571
14572 @node Effect of Convention on Representation
14573 @section Effect of Convention on Representation
14574 @cindex Convention, effect on representation
14575
14576 @noindent
14577 Normally the specification of a foreign language convention for a type or
14578 an object has no effect on the chosen representation.  In particular, the
14579 representation chosen for data in GNAT generally meets the standard system
14580 conventions, and for example records are laid out in a manner that is
14581 consistent with C@.  This means that specifying convention C (for example)
14582 has no effect.
14583
14584 There are four exceptions to this general rule:
14585
14586 @itemize @bullet
14587
14588 @item Convention Fortran and array subtypes
14589 If pragma Convention Fortran is specified for an array subtype, then in
14590 accordance with the implementation advice in section 3.6.2(11) of the
14591 Ada Reference Manual, the array will be stored in a Fortran-compatible
14592 column-major manner, instead of the normal default row-major order.
14593
14594 @item Convention C and enumeration types
14595 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
14596 to accommodate all values of the type.  For example, for the enumeration
14597 type declared by:
14598
14599 @smallexample @c ada
14600    type Color is (Red, Green, Blue);
14601 @end smallexample
14602
14603 @noindent
14604 8 bits is sufficient to store all values of the type, so by default, objects
14605 of type @code{Color} will be represented using 8 bits.  However, normal C
14606 convention is to use 32 bits for all enum values in C, since enum values
14607 are essentially of type int.  If pragma @code{Convention C} is specified for an
14608 Ada enumeration type, then the size is modified as necessary (usually to
14609 32 bits) to be consistent with the C convention for enum values.
14610
14611 Note that this treatment applies only to types. If Convention C is given for
14612 an enumeration object, where the enumeration type is not Convention C, then
14613 Object_Size bits are allocated. For example, for a normal enumeration type,
14614 with less than 256 elements, only 8 bits will be allocated for the object.
14615 Since this may be a surprise in terms of what C expects, GNAT will issue a
14616 warning in this situation. The warning can be suppressed by giving an explicit
14617 size clause specifying the desired size.
14618
14619 @item Convention C/Fortran and Boolean types
14620 In C, the usual convention for boolean values, that is values used for
14621 conditions, is that zero represents false, and nonzero values represent
14622 true.  In Ada, the normal convention is that two specific values, typically
14623 0/1, are used to represent false/true respectively.
14624
14625 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
14626 value represents true).
14627
14628 To accommodate the Fortran and C conventions, if a pragma Convention specifies
14629 C or Fortran convention for a derived Boolean, as in the following example:
14630
14631 @smallexample @c ada
14632    type C_Switch is new Boolean;
14633    pragma Convention (C, C_Switch);
14634 @end smallexample
14635
14636 @noindent
14637 then the GNAT generated code will treat any nonzero value as true.  For truth
14638 values generated by GNAT, the conventional value 1 will be used for True, but
14639 when one of these values is read, any nonzero value is treated as True.
14640
14641 @item Access types on OpenVMS
14642 For 64-bit OpenVMS systems, access types (other than those for unconstrained
14643 arrays) are 64-bits long. An exception to this rule is for the case of
14644 C-convention access types where there is no explicit size clause present (or
14645 inherited for derived types). In this case, GNAT chooses to make these
14646 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
14647 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
14648
14649 @end itemize
14650
14651 @node Determining the Representations chosen by GNAT
14652 @section Determining the Representations chosen by GNAT
14653 @cindex Representation, determination of
14654 @cindex @option{-gnatR} switch
14655
14656 @noindent
14657 Although the descriptions in this section are intended to be complete, it is
14658 often easier to simply experiment to see what GNAT accepts and what the
14659 effect is on the layout of types and objects.
14660
14661 As required by the Ada RM, if a representation clause is not accepted, then
14662 it must be rejected as illegal by the compiler.  However, when a
14663 representation clause or pragma is accepted, there can still be questions
14664 of what the compiler actually does.  For example, if a partial record
14665 representation clause specifies the location of some components and not
14666 others, then where are the non-specified components placed? Or if pragma
14667 @code{Pack} is used on a record, then exactly where are the resulting
14668 fields placed? The section on pragma @code{Pack} in this chapter can be
14669 used to answer the second question, but it is often easier to just see
14670 what the compiler does.
14671
14672 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
14673 with this option, then the compiler will output information on the actual
14674 representations chosen, in a format similar to source representation
14675 clauses.  For example, if we compile the package:
14676
14677 @smallexample @c ada
14678 package q is
14679    type r (x : boolean) is tagged record
14680       case x is
14681          when True => S : String (1 .. 100);
14682          when False => null;
14683       end case;
14684    end record;
14685
14686    type r2 is new r (false) with record
14687       y2 : integer;
14688    end record;
14689
14690    for r2 use record
14691       y2 at 16 range 0 .. 31;
14692    end record;
14693
14694    type x is record
14695       y : character;
14696    end record;
14697
14698    type x1 is array (1 .. 10) of x;
14699    for x1'component_size use 11;
14700
14701    type ia is access integer;
14702
14703    type Rb1 is array (1 .. 13) of Boolean;
14704    pragma Pack (rb1);
14705
14706    type Rb2 is array (1 .. 65) of Boolean;
14707    pragma Pack (rb2);
14708
14709    type x2 is record
14710       l1 : Boolean;
14711       l2 : Duration;
14712       l3 : Float;
14713       l4 : Boolean;
14714       l5 : Rb1;
14715       l6 : Rb2;
14716    end record;
14717    pragma Pack (x2);
14718 end q;
14719 @end smallexample
14720
14721 @noindent
14722 using the switch @option{-gnatR} we obtain the following output:
14723
14724 @smallexample
14725 Representation information for unit q
14726 -------------------------------------
14727
14728 for r'Size use ??;
14729 for r'Alignment use 4;
14730 for r use record
14731    x    at 4 range  0 .. 7;
14732    _tag at 0 range  0 .. 31;
14733    s    at 5 range  0 .. 799;
14734 end record;
14735
14736 for r2'Size use 160;
14737 for r2'Alignment use 4;
14738 for r2 use record
14739    x       at  4 range  0 .. 7;
14740    _tag    at  0 range  0 .. 31;
14741    _parent at  0 range  0 .. 63;
14742    y2      at 16 range  0 .. 31;
14743 end record;
14744
14745 for x'Size use 8;
14746 for x'Alignment use 1;
14747 for x use record
14748    y at 0 range  0 .. 7;
14749 end record;
14750
14751 for x1'Size use 112;
14752 for x1'Alignment use 1;
14753 for x1'Component_Size use 11;
14754
14755 for rb1'Size use 13;
14756 for rb1'Alignment use 2;
14757 for rb1'Component_Size use 1;
14758
14759 for rb2'Size use 72;
14760 for rb2'Alignment use 1;
14761 for rb2'Component_Size use 1;
14762
14763 for x2'Size use 224;
14764 for x2'Alignment use 4;
14765 for x2 use record
14766    l1 at  0 range  0 .. 0;
14767    l2 at  0 range  1 .. 64;
14768    l3 at 12 range  0 .. 31;
14769    l4 at 16 range  0 .. 0;
14770    l5 at 16 range  1 .. 13;
14771    l6 at 18 range  0 .. 71;
14772 end record;
14773 @end smallexample
14774
14775 @noindent
14776 The Size values are actually the Object_Size, i.e.@: the default size that
14777 will be allocated for objects of the type.
14778 The ?? size for type r indicates that we have a variant record, and the
14779 actual size of objects will depend on the discriminant value.
14780
14781 The Alignment values show the actual alignment chosen by the compiler
14782 for each record or array type.
14783
14784 The record representation clause for type r shows where all fields
14785 are placed, including the compiler generated tag field (whose location
14786 cannot be controlled by the programmer).
14787
14788 The record representation clause for the type extension r2 shows all the
14789 fields present, including the parent field, which is a copy of the fields
14790 of the parent type of r2, i.e.@: r1.
14791
14792 The component size and size clauses for types rb1 and rb2 show
14793 the exact effect of pragma @code{Pack} on these arrays, and the record
14794 representation clause for type x2 shows how pragma @code{Pack} affects
14795 this record type.
14796
14797 In some cases, it may be useful to cut and paste the representation clauses
14798 generated by the compiler into the original source to fix and guarantee
14799 the actual representation to be used.
14800
14801 @node Standard Library Routines
14802 @chapter Standard Library Routines
14803
14804 @noindent
14805 The Ada Reference Manual contains in Annex A a full description of an
14806 extensive set of standard library routines that can be used in any Ada
14807 program, and which must be provided by all Ada compilers.  They are
14808 analogous to the standard C library used by C programs.
14809
14810 GNAT implements all of the facilities described in annex A, and for most
14811 purposes the description in the Ada Reference Manual, or appropriate Ada
14812 text book, will be sufficient for making use of these facilities.
14813
14814 In the case of the input-output facilities,
14815 @xref{The Implementation of Standard I/O},
14816 gives details on exactly how GNAT interfaces to the
14817 file system.  For the remaining packages, the Ada Reference Manual
14818 should be sufficient.  The following is a list of the packages included,
14819 together with a brief description of the functionality that is provided.
14820
14821 For completeness, references are included to other predefined library
14822 routines defined in other sections of the Ada Reference Manual (these are
14823 cross-indexed from Annex A).
14824
14825 @table @code
14826 @item Ada (A.2)
14827 This is a parent package for all the standard library packages.  It is
14828 usually included implicitly in your program, and itself contains no
14829 useful data or routines.
14830
14831 @item Ada.Calendar (9.6)
14832 @code{Calendar} provides time of day access, and routines for
14833 manipulating times and durations.
14834
14835 @item Ada.Characters (A.3.1)
14836 This is a dummy parent package that contains no useful entities
14837
14838 @item Ada.Characters.Handling (A.3.2)
14839 This package provides some basic character handling capabilities,
14840 including classification functions for classes of characters (e.g.@: test
14841 for letters, or digits).
14842
14843 @item Ada.Characters.Latin_1 (A.3.3)
14844 This package includes a complete set of definitions of the characters
14845 that appear in type CHARACTER@.  It is useful for writing programs that
14846 will run in international environments.  For example, if you want an
14847 upper case E with an acute accent in a string, it is often better to use
14848 the definition of @code{UC_E_Acute} in this package.  Then your program
14849 will print in an understandable manner even if your environment does not
14850 support these extended characters.
14851
14852 @item Ada.Command_Line (A.15)
14853 This package provides access to the command line parameters and the name
14854 of the current program (analogous to the use of @code{argc} and @code{argv}
14855 in C), and also allows the exit status for the program to be set in a
14856 system-independent manner.
14857
14858 @item Ada.Decimal (F.2)
14859 This package provides constants describing the range of decimal numbers
14860 implemented, and also a decimal divide routine (analogous to the COBOL
14861 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
14862
14863 @item Ada.Direct_IO (A.8.4)
14864 This package provides input-output using a model of a set of records of
14865 fixed-length, containing an arbitrary definite Ada type, indexed by an
14866 integer record number.
14867
14868 @item Ada.Dynamic_Priorities (D.5)
14869 This package allows the priorities of a task to be adjusted dynamically
14870 as the task is running.
14871
14872 @item Ada.Exceptions (11.4.1)
14873 This package provides additional information on exceptions, and also
14874 contains facilities for treating exceptions as data objects, and raising
14875 exceptions with associated messages.
14876
14877 @item Ada.Finalization (7.6)
14878 This package contains the declarations and subprograms to support the
14879 use of controlled types, providing for automatic initialization and
14880 finalization (analogous to the constructors and destructors of C++)
14881
14882 @item Ada.Interrupts (C.3.2)
14883 This package provides facilities for interfacing to interrupts, which
14884 includes the set of signals or conditions that can be raised and
14885 recognized as interrupts.
14886
14887 @item Ada.Interrupts.Names (C.3.2)
14888 This package provides the set of interrupt names (actually signal
14889 or condition names) that can be handled by GNAT@.
14890
14891 @item Ada.IO_Exceptions (A.13)
14892 This package defines the set of exceptions that can be raised by use of
14893 the standard IO packages.
14894
14895 @item Ada.Numerics
14896 This package contains some standard constants and exceptions used
14897 throughout the numerics packages.  Note that the constants pi and e are
14898 defined here, and it is better to use these definitions than rolling
14899 your own.
14900
14901 @item Ada.Numerics.Complex_Elementary_Functions
14902 Provides the implementation of standard elementary functions (such as
14903 log and trigonometric functions) operating on complex numbers using the
14904 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
14905 created by the package @code{Numerics.Complex_Types}.
14906
14907 @item Ada.Numerics.Complex_Types
14908 This is a predefined instantiation of
14909 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
14910 build the type @code{Complex} and @code{Imaginary}.
14911
14912 @item Ada.Numerics.Discrete_Random
14913 This generic package provides a random number generator suitable for generating
14914 uniformly distributed values of a specified discrete subtype.
14915
14916 @item Ada.Numerics.Float_Random
14917 This package provides a random number generator suitable for generating
14918 uniformly distributed floating point values in the unit interval.
14919
14920 @item Ada.Numerics.Generic_Complex_Elementary_Functions
14921 This is a generic version of the package that provides the
14922 implementation of standard elementary functions (such as log and
14923 trigonometric functions) for an arbitrary complex type.
14924
14925 The following predefined instantiations of this package are provided:
14926
14927 @table @code
14928 @item Short_Float
14929 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
14930 @item Float
14931 @code{Ada.Numerics.Complex_Elementary_Functions}
14932 @item Long_Float
14933 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
14934 @end table
14935
14936 @item Ada.Numerics.Generic_Complex_Types
14937 This is a generic package that allows the creation of complex types,
14938 with associated complex arithmetic operations.
14939
14940 The following predefined instantiations of this package exist
14941 @table @code
14942 @item Short_Float
14943 @code{Ada.Numerics.Short_Complex_Complex_Types}
14944 @item Float
14945 @code{Ada.Numerics.Complex_Complex_Types}
14946 @item Long_Float
14947 @code{Ada.Numerics.Long_Complex_Complex_Types}
14948 @end table
14949
14950 @item Ada.Numerics.Generic_Elementary_Functions
14951 This is a generic package that provides the implementation of standard
14952 elementary functions (such as log an trigonometric functions) for an
14953 arbitrary float type.
14954
14955 The following predefined instantiations of this package exist
14956
14957 @table @code
14958 @item Short_Float
14959 @code{Ada.Numerics.Short_Elementary_Functions}
14960 @item Float
14961 @code{Ada.Numerics.Elementary_Functions}
14962 @item Long_Float
14963 @code{Ada.Numerics.Long_Elementary_Functions}
14964 @end table
14965
14966 @item Ada.Real_Time (D.8)
14967 This package provides facilities similar to those of @code{Calendar}, but
14968 operating with a finer clock suitable for real time control. Note that
14969 annex D requires that there be no backward clock jumps, and GNAT generally
14970 guarantees this behavior, but of course if the external clock on which
14971 the GNAT runtime depends is deliberately reset by some external event,
14972 then such a backward jump may occur.
14973
14974 @item Ada.Sequential_IO (A.8.1)
14975 This package provides input-output facilities for sequential files,
14976 which can contain a sequence of values of a single type, which can be
14977 any Ada type, including indefinite (unconstrained) types.
14978
14979 @item Ada.Storage_IO (A.9)
14980 This package provides a facility for mapping arbitrary Ada types to and
14981 from a storage buffer.  It is primarily intended for the creation of new
14982 IO packages.
14983
14984 @item Ada.Streams (13.13.1)
14985 This is a generic package that provides the basic support for the
14986 concept of streams as used by the stream attributes (@code{Input},
14987 @code{Output}, @code{Read} and @code{Write}).
14988
14989 @item Ada.Streams.Stream_IO (A.12.1)
14990 This package is a specialization of the type @code{Streams} defined in
14991 package @code{Streams} together with a set of operations providing
14992 Stream_IO capability.  The Stream_IO model permits both random and
14993 sequential access to a file which can contain an arbitrary set of values
14994 of one or more Ada types.
14995
14996 @item Ada.Strings (A.4.1)
14997 This package provides some basic constants used by the string handling
14998 packages.
14999
15000 @item Ada.Strings.Bounded (A.4.4)
15001 This package provides facilities for handling variable length
15002 strings.  The bounded model requires a maximum length.  It is thus
15003 somewhat more limited than the unbounded model, but avoids the use of
15004 dynamic allocation or finalization.
15005
15006 @item Ada.Strings.Fixed (A.4.3)
15007 This package provides facilities for handling fixed length strings.
15008
15009 @item Ada.Strings.Maps (A.4.2)
15010 This package provides facilities for handling character mappings and
15011 arbitrarily defined subsets of characters.  For instance it is useful in
15012 defining specialized translation tables.
15013
15014 @item Ada.Strings.Maps.Constants (A.4.6)
15015 This package provides a standard set of predefined mappings and
15016 predefined character sets.  For example, the standard upper to lower case
15017 conversion table is found in this package.  Note that upper to lower case
15018 conversion is non-trivial if you want to take the entire set of
15019 characters, including extended characters like E with an acute accent,
15020 into account.  You should use the mappings in this package (rather than
15021 adding 32 yourself) to do case mappings.
15022
15023 @item Ada.Strings.Unbounded (A.4.5)
15024 This package provides facilities for handling variable length
15025 strings.  The unbounded model allows arbitrary length strings, but
15026 requires the use of dynamic allocation and finalization.
15027
15028 @item Ada.Strings.Wide_Bounded (A.4.7)
15029 @itemx Ada.Strings.Wide_Fixed (A.4.7)
15030 @itemx Ada.Strings.Wide_Maps (A.4.7)
15031 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
15032 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
15033 These packages provide analogous capabilities to the corresponding
15034 packages without @samp{Wide_} in the name, but operate with the types
15035 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
15036 and @code{Character}.
15037
15038 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
15039 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
15040 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
15041 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
15042 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
15043 These packages provide analogous capabilities to the corresponding
15044 packages without @samp{Wide_} in the name, but operate with the types
15045 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
15046 of @code{String} and @code{Character}.
15047
15048 @item Ada.Synchronous_Task_Control (D.10)
15049 This package provides some standard facilities for controlling task
15050 communication in a synchronous manner.
15051
15052 @item Ada.Tags
15053 This package contains definitions for manipulation of the tags of tagged
15054 values.
15055
15056 @item Ada.Task_Attributes
15057 This package provides the capability of associating arbitrary
15058 task-specific data with separate tasks.
15059
15060 @item Ada.Text_IO
15061 This package provides basic text input-output capabilities for
15062 character, string and numeric data.  The subpackages of this
15063 package are listed next.
15064
15065 @item Ada.Text_IO.Decimal_IO
15066 Provides input-output facilities for decimal fixed-point types
15067
15068 @item Ada.Text_IO.Enumeration_IO
15069 Provides input-output facilities for enumeration types.
15070
15071 @item Ada.Text_IO.Fixed_IO
15072 Provides input-output facilities for ordinary fixed-point types.
15073
15074 @item Ada.Text_IO.Float_IO
15075 Provides input-output facilities for float types.  The following
15076 predefined instantiations of this generic package are available:
15077
15078 @table @code
15079 @item Short_Float
15080 @code{Short_Float_Text_IO}
15081 @item Float
15082 @code{Float_Text_IO}
15083 @item Long_Float
15084 @code{Long_Float_Text_IO}
15085 @end table
15086
15087 @item Ada.Text_IO.Integer_IO
15088 Provides input-output facilities for integer types.  The following
15089 predefined instantiations of this generic package are available:
15090
15091 @table @code
15092 @item Short_Short_Integer
15093 @code{Ada.Short_Short_Integer_Text_IO}
15094 @item Short_Integer
15095 @code{Ada.Short_Integer_Text_IO}
15096 @item Integer
15097 @code{Ada.Integer_Text_IO}
15098 @item Long_Integer
15099 @code{Ada.Long_Integer_Text_IO}
15100 @item Long_Long_Integer
15101 @code{Ada.Long_Long_Integer_Text_IO}
15102 @end table
15103
15104 @item Ada.Text_IO.Modular_IO
15105 Provides input-output facilities for modular (unsigned) types
15106
15107 @item Ada.Text_IO.Complex_IO (G.1.3)
15108 This package provides basic text input-output capabilities for complex
15109 data.
15110
15111 @item Ada.Text_IO.Editing (F.3.3)
15112 This package contains routines for edited output, analogous to the use
15113 of pictures in COBOL@.  The picture formats used by this package are a
15114 close copy of the facility in COBOL@.
15115
15116 @item Ada.Text_IO.Text_Streams (A.12.2)
15117 This package provides a facility that allows Text_IO files to be treated
15118 as streams, so that the stream attributes can be used for writing
15119 arbitrary data, including binary data, to Text_IO files.
15120
15121 @item Ada.Unchecked_Conversion (13.9)
15122 This generic package allows arbitrary conversion from one type to
15123 another of the same size, providing for breaking the type safety in
15124 special circumstances.
15125
15126 If the types have the same Size (more accurately the same Value_Size),
15127 then the effect is simply to transfer the bits from the source to the
15128 target type without any modification.  This usage is well defined, and
15129 for simple types whose representation is typically the same across
15130 all implementations, gives a portable method of performing such
15131 conversions.
15132
15133 If the types do not have the same size, then the result is implementation
15134 defined, and thus may be non-portable.  The following describes how GNAT
15135 handles such unchecked conversion cases.
15136
15137 If the types are of different sizes, and are both discrete types, then
15138 the effect is of a normal type conversion without any constraint checking.
15139 In particular if the result type has a larger size, the result will be
15140 zero or sign extended.  If the result type has a smaller size, the result
15141 will be truncated by ignoring high order bits.
15142
15143 If the types are of different sizes, and are not both discrete types,
15144 then the conversion works as though pointers were created to the source
15145 and target, and the pointer value is converted.  The effect is that bits
15146 are copied from successive low order storage units and bits of the source
15147 up to the length of the target type.
15148
15149 A warning is issued if the lengths differ, since the effect in this
15150 case is implementation dependent, and the above behavior may not match
15151 that of some other compiler.
15152
15153 A pointer to one type may be converted to a pointer to another type using
15154 unchecked conversion.  The only case in which the effect is undefined is
15155 when one or both pointers are pointers to unconstrained array types.  In
15156 this case, the bounds information may get incorrectly transferred, and in
15157 particular, GNAT uses double size pointers for such types, and it is
15158 meaningless to convert between such pointer types.  GNAT will issue a
15159 warning if the alignment of the target designated type is more strict
15160 than the alignment of the source designated type (since the result may
15161 be unaligned in this case).
15162
15163 A pointer other than a pointer to an unconstrained array type may be
15164 converted to and from System.Address.  Such usage is common in Ada 83
15165 programs, but note that Ada.Address_To_Access_Conversions is the
15166 preferred method of performing such conversions in Ada 95 and Ada 2005.
15167 Neither
15168 unchecked conversion nor Ada.Address_To_Access_Conversions should be
15169 used in conjunction with pointers to unconstrained objects, since
15170 the bounds information cannot be handled correctly in this case.
15171
15172 @item Ada.Unchecked_Deallocation (13.11.2)
15173 This generic package allows explicit freeing of storage previously
15174 allocated by use of an allocator.
15175
15176 @item Ada.Wide_Text_IO (A.11)
15177 This package is similar to @code{Ada.Text_IO}, except that the external
15178 file supports wide character representations, and the internal types are
15179 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15180 and @code{String}.  It contains generic subpackages listed next.
15181
15182 @item Ada.Wide_Text_IO.Decimal_IO
15183 Provides input-output facilities for decimal fixed-point types
15184
15185 @item Ada.Wide_Text_IO.Enumeration_IO
15186 Provides input-output facilities for enumeration types.
15187
15188 @item Ada.Wide_Text_IO.Fixed_IO
15189 Provides input-output facilities for ordinary fixed-point types.
15190
15191 @item Ada.Wide_Text_IO.Float_IO
15192 Provides input-output facilities for float types.  The following
15193 predefined instantiations of this generic package are available:
15194
15195 @table @code
15196 @item Short_Float
15197 @code{Short_Float_Wide_Text_IO}
15198 @item Float
15199 @code{Float_Wide_Text_IO}
15200 @item Long_Float
15201 @code{Long_Float_Wide_Text_IO}
15202 @end table
15203
15204 @item Ada.Wide_Text_IO.Integer_IO
15205 Provides input-output facilities for integer types.  The following
15206 predefined instantiations of this generic package are available:
15207
15208 @table @code
15209 @item Short_Short_Integer
15210 @code{Ada.Short_Short_Integer_Wide_Text_IO}
15211 @item Short_Integer
15212 @code{Ada.Short_Integer_Wide_Text_IO}
15213 @item Integer
15214 @code{Ada.Integer_Wide_Text_IO}
15215 @item Long_Integer
15216 @code{Ada.Long_Integer_Wide_Text_IO}
15217 @item Long_Long_Integer
15218 @code{Ada.Long_Long_Integer_Wide_Text_IO}
15219 @end table
15220
15221 @item Ada.Wide_Text_IO.Modular_IO
15222 Provides input-output facilities for modular (unsigned) types
15223
15224 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
15225 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15226 external file supports wide character representations.
15227
15228 @item Ada.Wide_Text_IO.Editing (F.3.4)
15229 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15230 types are @code{Wide_Character} and @code{Wide_String} instead of
15231 @code{Character} and @code{String}.
15232
15233 @item Ada.Wide_Text_IO.Streams (A.12.3)
15234 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15235 types are @code{Wide_Character} and @code{Wide_String} instead of
15236 @code{Character} and @code{String}.
15237
15238 @item Ada.Wide_Wide_Text_IO (A.11)
15239 This package is similar to @code{Ada.Text_IO}, except that the external
15240 file supports wide character representations, and the internal types are
15241 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
15242 and @code{String}.  It contains generic subpackages listed next.
15243
15244 @item Ada.Wide_Wide_Text_IO.Decimal_IO
15245 Provides input-output facilities for decimal fixed-point types
15246
15247 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
15248 Provides input-output facilities for enumeration types.
15249
15250 @item Ada.Wide_Wide_Text_IO.Fixed_IO
15251 Provides input-output facilities for ordinary fixed-point types.
15252
15253 @item Ada.Wide_Wide_Text_IO.Float_IO
15254 Provides input-output facilities for float types.  The following
15255 predefined instantiations of this generic package are available:
15256
15257 @table @code
15258 @item Short_Float
15259 @code{Short_Float_Wide_Wide_Text_IO}
15260 @item Float
15261 @code{Float_Wide_Wide_Text_IO}
15262 @item Long_Float
15263 @code{Long_Float_Wide_Wide_Text_IO}
15264 @end table
15265
15266 @item Ada.Wide_Wide_Text_IO.Integer_IO
15267 Provides input-output facilities for integer types.  The following
15268 predefined instantiations of this generic package are available:
15269
15270 @table @code
15271 @item Short_Short_Integer
15272 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
15273 @item Short_Integer
15274 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
15275 @item Integer
15276 @code{Ada.Integer_Wide_Wide_Text_IO}
15277 @item Long_Integer
15278 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
15279 @item Long_Long_Integer
15280 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
15281 @end table
15282
15283 @item Ada.Wide_Wide_Text_IO.Modular_IO
15284 Provides input-output facilities for modular (unsigned) types
15285
15286 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
15287 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
15288 external file supports wide character representations.
15289
15290 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
15291 This package is similar to @code{Ada.Text_IO.Editing}, except that the
15292 types are @code{Wide_Character} and @code{Wide_String} instead of
15293 @code{Character} and @code{String}.
15294
15295 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
15296 This package is similar to @code{Ada.Text_IO.Streams}, except that the
15297 types are @code{Wide_Character} and @code{Wide_String} instead of
15298 @code{Character} and @code{String}.
15299 @end table
15300
15301 @node The Implementation of Standard I/O
15302 @chapter The Implementation of Standard I/O
15303
15304 @noindent
15305 GNAT implements all the required input-output facilities described in
15306 A.6 through A.14.  These sections of the Ada Reference Manual describe the
15307 required behavior of these packages from the Ada point of view, and if
15308 you are writing a portable Ada program that does not need to know the
15309 exact manner in which Ada maps to the outside world when it comes to
15310 reading or writing external files, then you do not need to read this
15311 chapter.  As long as your files are all regular files (not pipes or
15312 devices), and as long as you write and read the files only from Ada, the
15313 description in the Ada Reference Manual is sufficient.
15314
15315 However, if you want to do input-output to pipes or other devices, such
15316 as the keyboard or screen, or if the files you are dealing with are
15317 either generated by some other language, or to be read by some other
15318 language, then you need to know more about the details of how the GNAT
15319 implementation of these input-output facilities behaves.
15320
15321 In this chapter we give a detailed description of exactly how GNAT
15322 interfaces to the file system.  As always, the sources of the system are
15323 available to you for answering questions at an even more detailed level,
15324 but for most purposes the information in this chapter will suffice.
15325
15326 Another reason that you may need to know more about how input-output is
15327 implemented arises when you have a program written in mixed languages
15328 where, for example, files are shared between the C and Ada sections of
15329 the same program.  GNAT provides some additional facilities, in the form
15330 of additional child library packages, that facilitate this sharing, and
15331 these additional facilities are also described in this chapter.
15332
15333 @menu
15334 * Standard I/O Packages::
15335 * FORM Strings::
15336 * Direct_IO::
15337 * Sequential_IO::
15338 * Text_IO::
15339 * Wide_Text_IO::
15340 * Wide_Wide_Text_IO::
15341 * Stream_IO::
15342 * Text Translation::
15343 * Shared Files::
15344 * Filenames encoding::
15345 * Open Modes::
15346 * Operations on C Streams::
15347 * Interfacing to C Streams::
15348 @end menu
15349
15350 @node Standard I/O Packages
15351 @section Standard I/O Packages
15352
15353 @noindent
15354 The Standard I/O packages described in Annex A for
15355
15356 @itemize @bullet
15357 @item
15358 Ada.Text_IO
15359 @item
15360 Ada.Text_IO.Complex_IO
15361 @item
15362 Ada.Text_IO.Text_Streams
15363 @item
15364 Ada.Wide_Text_IO
15365 @item
15366 Ada.Wide_Text_IO.Complex_IO
15367 @item
15368 Ada.Wide_Text_IO.Text_Streams
15369 @item
15370 Ada.Wide_Wide_Text_IO
15371 @item
15372 Ada.Wide_Wide_Text_IO.Complex_IO
15373 @item
15374 Ada.Wide_Wide_Text_IO.Text_Streams
15375 @item
15376 Ada.Stream_IO
15377 @item
15378 Ada.Sequential_IO
15379 @item
15380 Ada.Direct_IO
15381 @end itemize
15382
15383 @noindent
15384 are implemented using the C
15385 library streams facility; where
15386
15387 @itemize @bullet
15388 @item
15389 All files are opened using @code{fopen}.
15390 @item
15391 All input/output operations use @code{fread}/@code{fwrite}.
15392 @end itemize
15393
15394 @noindent
15395 There is no internal buffering of any kind at the Ada library level. The only
15396 buffering is that provided at the system level in the implementation of the
15397 library routines that support streams. This facilitates shared use of these
15398 streams by mixed language programs. Note though that system level buffering is
15399 explicitly enabled at elaboration of the standard I/O packages and that can
15400 have an impact on mixed language programs, in particular those using I/O before
15401 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
15402 the Ada elaboration routine before performing any I/O or when impractical,
15403 flush the common I/O streams and in particular Standard_Output before
15404 elaborating the Ada code.
15405
15406 @node FORM Strings
15407 @section FORM Strings
15408
15409 @noindent
15410 The format of a FORM string in GNAT is:
15411
15412 @smallexample
15413 "keyword=value,keyword=value,@dots{},keyword=value"
15414 @end smallexample
15415
15416 @noindent
15417 where letters may be in upper or lower case, and there are no spaces
15418 between values.  The order of the entries is not important.  Currently
15419 the following keywords defined.
15420
15421 @smallexample
15422 TEXT_TRANSLATION=[YES|NO]
15423 SHARED=[YES|NO]
15424 WCEM=[n|h|u|s|e|8|b]
15425 ENCODING=[UTF8|8BITS]
15426 @end smallexample
15427
15428 @noindent
15429 The use of these parameters is described later in this section. If an
15430 unrecognized keyword appears in a form string, it is silently ignored
15431 and not considered invalid.
15432
15433 @noindent
15434 For OpenVMS additional FORM string keywords are available for use with
15435 RMS services.  The syntax is:
15436
15437 @smallexample
15438 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
15439 @end smallexample
15440
15441 @noindent
15442 The following RMS keywords and values are currently defined:
15443
15444 @smallexample
15445 Context=Force_Stream_Mode|Force_Record_Mode
15446 @end smallexample
15447
15448 @noindent
15449 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
15450 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
15451
15452 @node Direct_IO
15453 @section Direct_IO
15454
15455 @noindent
15456 Direct_IO can only be instantiated for definite types.  This is a
15457 restriction of the Ada language, which means that the records are fixed
15458 length (the length being determined by @code{@var{type}'Size}, rounded
15459 up to the next storage unit boundary if necessary).
15460
15461 The records of a Direct_IO file are simply written to the file in index
15462 sequence, with the first record starting at offset zero, and subsequent
15463 records following.  There is no control information of any kind.  For
15464 example, if 32-bit integers are being written, each record takes
15465 4-bytes, so the record at index @var{K} starts at offset
15466 (@var{K}@minus{}1)*4.
15467
15468 There is no limit on the size of Direct_IO files, they are expanded as
15469 necessary to accommodate whatever records are written to the file.
15470
15471 @node Sequential_IO
15472 @section Sequential_IO
15473
15474 @noindent
15475 Sequential_IO may be instantiated with either a definite (constrained)
15476 or indefinite (unconstrained) type.
15477
15478 For the definite type case, the elements written to the file are simply
15479 the memory images of the data values with no control information of any
15480 kind.  The resulting file should be read using the same type, no validity
15481 checking is performed on input.
15482
15483 For the indefinite type case, the elements written consist of two
15484 parts.  First is the size of the data item, written as the memory image
15485 of a @code{Interfaces.C.size_t} value, followed by the memory image of
15486 the data value.  The resulting file can only be read using the same
15487 (unconstrained) type.  Normal assignment checks are performed on these
15488 read operations, and if these checks fail, @code{Data_Error} is
15489 raised.  In particular, in the array case, the lengths must match, and in
15490 the variant record case, if the variable for a particular read operation
15491 is constrained, the discriminants must match.
15492
15493 Note that it is not possible to use Sequential_IO to write variable
15494 length array items, and then read the data back into different length
15495 arrays.  For example, the following will raise @code{Data_Error}:
15496
15497 @smallexample @c ada
15498  package IO is new Sequential_IO (String);
15499  F : IO.File_Type;
15500  S : String (1..4);
15501  @dots{}
15502  IO.Create (F)
15503  IO.Write (F, "hello!")
15504  IO.Reset (F, Mode=>In_File);
15505  IO.Read (F, S);
15506  Put_Line (S);
15507
15508 @end smallexample
15509
15510 @noindent
15511 On some Ada implementations, this will print @code{hell}, but the program is
15512 clearly incorrect, since there is only one element in the file, and that
15513 element is the string @code{hello!}.
15514
15515 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
15516 using Stream_IO, and this is the preferred mechanism.  In particular, the
15517 above program fragment rewritten to use Stream_IO will work correctly.
15518
15519 @node Text_IO
15520 @section Text_IO
15521
15522 @noindent
15523 Text_IO files consist of a stream of characters containing the following
15524 special control characters:
15525
15526 @smallexample
15527 LF (line feed, 16#0A#) Line Mark
15528 FF (form feed, 16#0C#) Page Mark
15529 @end smallexample
15530
15531 @noindent
15532 A canonical Text_IO file is defined as one in which the following
15533 conditions are met:
15534
15535 @itemize @bullet
15536 @item
15537 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
15538 of the line.
15539
15540 @item
15541 The character @code{FF} is used only as a page mark, i.e.@: to mark the
15542 end of a page and consequently can appear only immediately following a
15543 @code{LF} (line mark) character.
15544
15545 @item
15546 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
15547 (line mark, page mark).  In the former case, the page mark is implicitly
15548 assumed to be present.
15549 @end itemize
15550
15551 @noindent
15552 A file written using Text_IO will be in canonical form provided that no
15553 explicit @code{LF} or @code{FF} characters are written using @code{Put}
15554 or @code{Put_Line}.  There will be no @code{FF} character at the end of
15555 the file unless an explicit @code{New_Page} operation was performed
15556 before closing the file.
15557
15558 A canonical Text_IO file that is a regular file (i.e., not a device or a
15559 pipe) can be read using any of the routines in Text_IO@.  The
15560 semantics in this case will be exactly as defined in the Ada Reference
15561 Manual, and all the routines in Text_IO are fully implemented.
15562
15563 A text file that does not meet the requirements for a canonical Text_IO
15564 file has one of the following:
15565
15566 @itemize @bullet
15567 @item
15568 The file contains @code{FF} characters not immediately following a
15569 @code{LF} character.
15570
15571 @item
15572 The file contains @code{LF} or @code{FF} characters written by
15573 @code{Put} or @code{Put_Line}, which are not logically considered to be
15574 line marks or page marks.
15575
15576 @item
15577 The file ends in a character other than @code{LF} or @code{FF},
15578 i.e.@: there is no explicit line mark or page mark at the end of the file.
15579 @end itemize
15580
15581 @noindent
15582 Text_IO can be used to read such non-standard text files but subprograms
15583 to do with line or page numbers do not have defined meanings.  In
15584 particular, a @code{FF} character that does not follow a @code{LF}
15585 character may or may not be treated as a page mark from the point of
15586 view of page and line numbering.  Every @code{LF} character is considered
15587 to end a line, and there is an implied @code{LF} character at the end of
15588 the file.
15589
15590 @menu
15591 * Text_IO Stream Pointer Positioning::
15592 * Text_IO Reading and Writing Non-Regular Files::
15593 * Get_Immediate::
15594 * Treating Text_IO Files as Streams::
15595 * Text_IO Extensions::
15596 * Text_IO Facilities for Unbounded Strings::
15597 @end menu
15598
15599 @node Text_IO Stream Pointer Positioning
15600 @subsection Stream Pointer Positioning
15601
15602 @noindent
15603 @code{Ada.Text_IO} has a definition of current position for a file that
15604 is being read.  No internal buffering occurs in Text_IO, and usually the
15605 physical position in the stream used to implement the file corresponds
15606 to this logical position defined by Text_IO@.  There are two exceptions:
15607
15608 @itemize @bullet
15609 @item
15610 After a call to @code{End_Of_Page} that returns @code{True}, the stream
15611 is positioned past the @code{LF} (line mark) that precedes the page
15612 mark.  Text_IO maintains an internal flag so that subsequent read
15613 operations properly handle the logical position which is unchanged by
15614 the @code{End_Of_Page} call.
15615
15616 @item
15617 After a call to @code{End_Of_File} that returns @code{True}, if the
15618 Text_IO file was positioned before the line mark at the end of file
15619 before the call, then the logical position is unchanged, but the stream
15620 is physically positioned right at the end of file (past the line mark,
15621 and past a possible page mark following the line mark.  Again Text_IO
15622 maintains internal flags so that subsequent read operations properly
15623 handle the logical position.
15624 @end itemize
15625
15626 @noindent
15627 These discrepancies have no effect on the observable behavior of
15628 Text_IO, but if a single Ada stream is shared between a C program and
15629 Ada program, or shared (using @samp{shared=yes} in the form string)
15630 between two Ada files, then the difference may be observable in some
15631 situations.
15632
15633 @node Text_IO Reading and Writing Non-Regular Files
15634 @subsection Reading and Writing Non-Regular Files
15635
15636 @noindent
15637 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
15638 can be used for reading and writing.  Writing is not affected and the
15639 sequence of characters output is identical to the normal file case, but
15640 for reading, the behavior of Text_IO is modified to avoid undesirable
15641 look-ahead as follows:
15642
15643 An input file that is not a regular file is considered to have no page
15644 marks.  Any @code{Ascii.FF} characters (the character normally used for a
15645 page mark) appearing in the file are considered to be data
15646 characters.  In particular:
15647
15648 @itemize @bullet
15649 @item
15650 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
15651 following a line mark.  If a page mark appears, it will be treated as a
15652 data character.
15653
15654 @item
15655 This avoids the need to wait for an extra character to be typed or
15656 entered from the pipe to complete one of these operations.
15657
15658 @item
15659 @code{End_Of_Page} always returns @code{False}
15660
15661 @item
15662 @code{End_Of_File} will return @code{False} if there is a page mark at
15663 the end of the file.
15664 @end itemize
15665
15666 @noindent
15667 Output to non-regular files is the same as for regular files.  Page marks
15668 may be written to non-regular files using @code{New_Page}, but as noted
15669 above they will not be treated as page marks on input if the output is
15670 piped to another Ada program.
15671
15672 Another important discrepancy when reading non-regular files is that the end
15673 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
15674 pressing the @key{EOT} key,
15675 then end of file
15676 is signaled once (i.e.@: the test @code{End_Of_File}
15677 will yield @code{True}, or a read will
15678 raise @code{End_Error}), but then reading can resume
15679 to read data past that end of
15680 file indication, until another end of file indication is entered.
15681
15682 @node Get_Immediate
15683 @subsection Get_Immediate
15684 @cindex Get_Immediate
15685
15686 @noindent
15687 Get_Immediate returns the next character (including control characters)
15688 from the input file.  In particular, Get_Immediate will return LF or FF
15689 characters used as line marks or page marks.  Such operations leave the
15690 file positioned past the control character, and it is thus not treated
15691 as having its normal function.  This means that page, line and column
15692 counts after this kind of Get_Immediate call are set as though the mark
15693 did not occur.  In the case where a Get_Immediate leaves the file
15694 positioned between the line mark and page mark (which is not normally
15695 possible), it is undefined whether the FF character will be treated as a
15696 page mark.
15697
15698 @node Treating Text_IO Files as Streams
15699 @subsection Treating Text_IO Files as Streams
15700 @cindex Stream files
15701
15702 @noindent
15703 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
15704 as a stream.  Data written to a Text_IO file in this stream mode is
15705 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
15706 16#0C# (@code{FF}), the resulting file may have non-standard
15707 format.  Similarly if read operations are used to read from a Text_IO
15708 file treated as a stream, then @code{LF} and @code{FF} characters may be
15709 skipped and the effect is similar to that described above for
15710 @code{Get_Immediate}.
15711
15712 @node Text_IO Extensions
15713 @subsection Text_IO Extensions
15714 @cindex Text_IO extensions
15715
15716 @noindent
15717 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
15718 to the standard @code{Text_IO} package:
15719
15720 @itemize @bullet
15721 @item function File_Exists (Name : String) return Boolean;
15722 Determines if a file of the given name exists.
15723
15724 @item function Get_Line return String;
15725 Reads a string from the standard input file.  The value returned is exactly
15726 the length of the line that was read.
15727
15728 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
15729 Similar, except that the parameter File specifies the file from which
15730 the string is to be read.
15731
15732 @end itemize
15733
15734 @node Text_IO Facilities for Unbounded Strings
15735 @subsection Text_IO Facilities for Unbounded Strings
15736 @cindex Text_IO for unbounded strings
15737 @cindex Unbounded_String, Text_IO operations
15738
15739 @noindent
15740 The package @code{Ada.Strings.Unbounded.Text_IO}
15741 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
15742 subprograms useful for Text_IO operations on unbounded strings:
15743
15744 @itemize @bullet
15745
15746 @item function Get_Line (File : File_Type) return Unbounded_String;
15747 Reads a line from the specified file
15748 and returns the result as an unbounded string.
15749
15750 @item procedure Put (File : File_Type; U : Unbounded_String);
15751 Writes the value of the given unbounded string to the specified file
15752 Similar to the effect of
15753 @code{Put (To_String (U))} except that an extra copy is avoided.
15754
15755 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
15756 Writes the value of the given unbounded string to the specified file,
15757 followed by a @code{New_Line}.
15758 Similar to the effect of @code{Put_Line (To_String (U))} except
15759 that an extra copy is avoided.
15760 @end itemize
15761
15762 @noindent
15763 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
15764 and is optional.  If the parameter is omitted, then the standard input or
15765 output file is referenced as appropriate.
15766
15767 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
15768 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
15769 @code{Wide_Text_IO} functionality for unbounded wide strings.
15770
15771 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
15772 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
15773 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
15774
15775 @node Wide_Text_IO
15776 @section Wide_Text_IO
15777
15778 @noindent
15779 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
15780 both input and output files may contain special sequences that represent
15781 wide character values.  The encoding scheme for a given file may be
15782 specified using a FORM parameter:
15783
15784 @smallexample
15785 WCEM=@var{x}
15786 @end smallexample
15787
15788 @noindent
15789 as part of the FORM string (WCEM = wide character encoding method),
15790 where @var{x} is one of the following characters
15791
15792 @table @samp
15793 @item h
15794 Hex ESC encoding
15795 @item u
15796 Upper half encoding
15797 @item s
15798 Shift-JIS encoding
15799 @item e
15800 EUC Encoding
15801 @item 8
15802 UTF-8 encoding
15803 @item b
15804 Brackets encoding
15805 @end table
15806
15807 @noindent
15808 The encoding methods match those that
15809 can be used in a source
15810 program, but there is no requirement that the encoding method used for
15811 the source program be the same as the encoding method used for files,
15812 and different files may use different encoding methods.
15813
15814 The default encoding method for the standard files, and for opened files
15815 for which no WCEM parameter is given in the FORM string matches the
15816 wide character encoding specified for the main program (the default
15817 being brackets encoding if no coding method was specified with -gnatW).
15818
15819 @table @asis
15820 @item Hex Coding
15821 In this encoding, a wide character is represented by a five character
15822 sequence:
15823
15824 @smallexample
15825 ESC a b c d
15826 @end smallexample
15827
15828 @noindent
15829 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
15830 characters (using upper case letters) of the wide character code.  For
15831 example, ESC A345 is used to represent the wide character with code
15832 16#A345#.  This scheme is compatible with use of the full
15833 @code{Wide_Character} set.
15834
15835 @item Upper Half Coding
15836 The wide character with encoding 16#abcd#, where the upper bit is on
15837 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
15838 16#cd#.  The second byte may never be a format control character, but is
15839 not required to be in the upper half.  This method can be also used for
15840 shift-JIS or EUC where the internal coding matches the external coding.
15841
15842 @item Shift JIS Coding
15843 A wide character is represented by a two character sequence 16#ab# and
15844 16#cd#, with the restrictions described for upper half encoding as
15845 described above.  The internal character code is the corresponding JIS
15846 character according to the standard algorithm for Shift-JIS
15847 conversion.  Only characters defined in the JIS code set table can be
15848 used with this encoding method.
15849
15850 @item EUC Coding
15851 A wide character is represented by a two character sequence 16#ab# and
15852 16#cd#, with both characters being in the upper half.  The internal
15853 character code is the corresponding JIS character according to the EUC
15854 encoding algorithm.  Only characters defined in the JIS code set table
15855 can be used with this encoding method.
15856
15857 @item UTF-8 Coding
15858 A wide character is represented using
15859 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
15860 10646-1/Am.2.  Depending on the character value, the representation
15861 is a one, two, or three byte sequence:
15862
15863 @smallexample
15864 16#0000#-16#007f#: 2#0xxxxxxx#
15865 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
15866 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
15867 @end smallexample
15868
15869 @noindent
15870 where the @var{xxx} bits correspond to the left-padded bits of the
15871 16-bit character value.  Note that all lower half ASCII characters
15872 are represented as ASCII bytes and all upper half characters and
15873 other wide characters are represented as sequences of upper-half
15874 (The full UTF-8 scheme allows for encoding 31-bit characters as
15875 6-byte sequences, but in this implementation, all UTF-8 sequences
15876 of four or more bytes length will raise a Constraint_Error, as
15877 will all invalid UTF-8 sequences.)
15878
15879 @item Brackets Coding
15880 In this encoding, a wide character is represented by the following eight
15881 character sequence:
15882
15883 @smallexample
15884 [ " a b c d " ]
15885 @end smallexample
15886
15887 @noindent
15888 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
15889 characters (using uppercase letters) of the wide character code.  For
15890 example, @code{["A345"]} is used to represent the wide character with code
15891 @code{16#A345#}.
15892 This scheme is compatible with use of the full Wide_Character set.
15893 On input, brackets coding can also be used for upper half characters,
15894 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
15895 is only used for wide characters with a code greater than @code{16#FF#}.
15896
15897 Note that brackets coding is not normally used in the context of
15898 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
15899 a portable way of encoding source files. In the context of Wide_Text_IO
15900 or Wide_Wide_Text_IO, it can only be used if the file does not contain
15901 any instance of the left bracket character other than to encode wide
15902 character values using the brackets encoding method. In practice it is
15903 expected that some standard wide character encoding method such
15904 as UTF-8 will be used for text input output.
15905
15906 If brackets notation is used, then any occurrence of a left bracket
15907 in the input file which is not the start of a valid wide character
15908 sequence will cause Constraint_Error to be raised. It is possible to
15909 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
15910 input will interpret this as a left bracket.
15911
15912 However, when a left bracket is output, it will be output as a left bracket
15913 and not as ["5B"]. We make this decision because for normal use of
15914 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
15915 brackets. For example, if we write:
15916
15917 @smallexample
15918    Put_Line ("Start of output [first run]");
15919 @end smallexample
15920
15921 @noindent
15922 we really do not want to have the left bracket in this message clobbered so
15923 that the output reads:
15924
15925 @smallexample
15926    Start of output ["5B"]first run]
15927 @end smallexample
15928
15929 @noindent
15930 In practice brackets encoding is reasonably useful for normal Put_Line use
15931 since we won't get confused between left brackets and wide character
15932 sequences in the output. But for input, or when files are written out
15933 and read back in, it really makes better sense to use one of the standard
15934 encoding methods such as UTF-8.
15935
15936 @end table
15937
15938 @noindent
15939 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
15940 not all wide character
15941 values can be represented.  An attempt to output a character that cannot
15942 be represented using the encoding scheme for the file causes
15943 Constraint_Error to be raised.  An invalid wide character sequence on
15944 input also causes Constraint_Error to be raised.
15945
15946 @menu
15947 * Wide_Text_IO Stream Pointer Positioning::
15948 * Wide_Text_IO Reading and Writing Non-Regular Files::
15949 @end menu
15950
15951 @node Wide_Text_IO Stream Pointer Positioning
15952 @subsection Stream Pointer Positioning
15953
15954 @noindent
15955 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
15956 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
15957 case:
15958
15959 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
15960 normal lower ASCII set (i.e.@: a character in the range:
15961
15962 @smallexample @c ada
15963 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
15964 @end smallexample
15965
15966 @noindent
15967 then although the logical position of the file pointer is unchanged by
15968 the @code{Look_Ahead} call, the stream is physically positioned past the
15969 wide character sequence.  Again this is to avoid the need for buffering
15970 or backup, and all @code{Wide_Text_IO} routines check the internal
15971 indication that this situation has occurred so that this is not visible
15972 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
15973 can be observed if the wide text file shares a stream with another file.
15974
15975 @node Wide_Text_IO Reading and Writing Non-Regular Files
15976 @subsection Reading and Writing Non-Regular Files
15977
15978 @noindent
15979 As in the case of Text_IO, when a non-regular file is read, it is
15980 assumed that the file contains no page marks (any form characters are
15981 treated as data characters), and @code{End_Of_Page} always returns
15982 @code{False}.  Similarly, the end of file indication is not sticky, so
15983 it is possible to read beyond an end of file.
15984
15985 @node Wide_Wide_Text_IO
15986 @section Wide_Wide_Text_IO
15987
15988 @noindent
15989 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
15990 both input and output files may contain special sequences that represent
15991 wide wide character values.  The encoding scheme for a given file may be
15992 specified using a FORM parameter:
15993
15994 @smallexample
15995 WCEM=@var{x}
15996 @end smallexample
15997
15998 @noindent
15999 as part of the FORM string (WCEM = wide character encoding method),
16000 where @var{x} is one of the following characters
16001
16002 @table @samp
16003 @item h
16004 Hex ESC encoding
16005 @item u
16006 Upper half encoding
16007 @item s
16008 Shift-JIS encoding
16009 @item e
16010 EUC Encoding
16011 @item 8
16012 UTF-8 encoding
16013 @item b
16014 Brackets encoding
16015 @end table
16016
16017 @noindent
16018 The encoding methods match those that
16019 can be used in a source
16020 program, but there is no requirement that the encoding method used for
16021 the source program be the same as the encoding method used for files,
16022 and different files may use different encoding methods.
16023
16024 The default encoding method for the standard files, and for opened files
16025 for which no WCEM parameter is given in the FORM string matches the
16026 wide character encoding specified for the main program (the default
16027 being brackets encoding if no coding method was specified with -gnatW).
16028
16029 @table @asis
16030
16031 @item UTF-8 Coding
16032 A wide character is represented using
16033 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
16034 10646-1/Am.2.  Depending on the character value, the representation
16035 is a one, two, three, or four byte sequence:
16036
16037 @smallexample
16038 16#000000#-16#00007f#: 2#0xxxxxxx#
16039 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
16040 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
16041 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
16042 @end smallexample
16043
16044 @noindent
16045 where the @var{xxx} bits correspond to the left-padded bits of the
16046 21-bit character value.  Note that all lower half ASCII characters
16047 are represented as ASCII bytes and all upper half characters and
16048 other wide characters are represented as sequences of upper-half
16049 characters.
16050
16051 @item Brackets Coding
16052 In this encoding, a wide wide character is represented by the following eight
16053 character sequence if is in wide character range
16054
16055 @smallexample
16056 [ " a b c d " ]
16057 @end smallexample
16058
16059 and by the following ten character sequence if not
16060
16061 @smallexample
16062 [ " a b c d e f " ]
16063 @end smallexample
16064
16065 @noindent
16066 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
16067 are the four or six hexadecimal
16068 characters (using uppercase letters) of the wide wide character code.  For
16069 example, @code{["01A345"]} is used to represent the wide wide character
16070 with code @code{16#01A345#}.
16071
16072 This scheme is compatible with use of the full Wide_Wide_Character set.
16073 On input, brackets coding can also be used for upper half characters,
16074 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
16075 is only used for wide characters with a code greater than @code{16#FF#}.
16076
16077 @end table
16078
16079 @noindent
16080 If is also possible to use the other Wide_Character encoding methods,
16081 such as Shift-JIS, but the other schemes cannot support the full range
16082 of wide wide characters.
16083 An attempt to output a character that cannot
16084 be represented using the encoding scheme for the file causes
16085 Constraint_Error to be raised.  An invalid wide character sequence on
16086 input also causes Constraint_Error to be raised.
16087
16088 @menu
16089 * Wide_Wide_Text_IO Stream Pointer Positioning::
16090 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
16091 @end menu
16092
16093 @node Wide_Wide_Text_IO Stream Pointer Positioning
16094 @subsection Stream Pointer Positioning
16095
16096 @noindent
16097 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
16098 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
16099 case:
16100
16101 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
16102 normal lower ASCII set (i.e.@: a character in the range:
16103
16104 @smallexample @c ada
16105 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
16106 @end smallexample
16107
16108 @noindent
16109 then although the logical position of the file pointer is unchanged by
16110 the @code{Look_Ahead} call, the stream is physically positioned past the
16111 wide character sequence.  Again this is to avoid the need for buffering
16112 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
16113 indication that this situation has occurred so that this is not visible
16114 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
16115 can be observed if the wide text file shares a stream with another file.
16116
16117 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
16118 @subsection Reading and Writing Non-Regular Files
16119
16120 @noindent
16121 As in the case of Text_IO, when a non-regular file is read, it is
16122 assumed that the file contains no page marks (any form characters are
16123 treated as data characters), and @code{End_Of_Page} always returns
16124 @code{False}.  Similarly, the end of file indication is not sticky, so
16125 it is possible to read beyond an end of file.
16126
16127 @node Stream_IO
16128 @section Stream_IO
16129
16130 @noindent
16131 A stream file is a sequence of bytes, where individual elements are
16132 written to the file as described in the Ada Reference Manual.  The type
16133 @code{Stream_Element} is simply a byte.  There are two ways to read or
16134 write a stream file.
16135
16136 @itemize @bullet
16137 @item
16138 The operations @code{Read} and @code{Write} directly read or write a
16139 sequence of stream elements with no control information.
16140
16141 @item
16142 The stream attributes applied to a stream file transfer data in the
16143 manner described for stream attributes.
16144 @end itemize
16145
16146 @node Text Translation
16147 @section Text Translation
16148
16149 @noindent
16150 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
16151 passed to Text_IO.Create and Text_IO.Open:
16152 @samp{Text_Translation=@var{Yes}} is the default, which means to
16153 translate LF to/from CR/LF on Windows systems.
16154 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
16155 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
16156 may be used to create Unix-style files on
16157 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
16158 systems.
16159
16160 @node Shared Files
16161 @section Shared Files
16162
16163 @noindent
16164 Section A.14 of the Ada Reference Manual allows implementations to
16165 provide a wide variety of behavior if an attempt is made to access the
16166 same external file with two or more internal files.
16167
16168 To provide a full range of functionality, while at the same time
16169 minimizing the problems of portability caused by this implementation
16170 dependence, GNAT handles file sharing as follows:
16171
16172 @itemize @bullet
16173 @item
16174 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
16175 to open two or more files with the same full name is considered an error
16176 and is not supported.  The exception @code{Use_Error} will be
16177 raised.  Note that a file that is not explicitly closed by the program
16178 remains open until the program terminates.
16179
16180 @item
16181 If the form parameter @samp{shared=no} appears in the form string, the
16182 file can be opened or created with its own separate stream identifier,
16183 regardless of whether other files sharing the same external file are
16184 opened.  The exact effect depends on how the C stream routines handle
16185 multiple accesses to the same external files using separate streams.
16186
16187 @item
16188 If the form parameter @samp{shared=yes} appears in the form string for
16189 each of two or more files opened using the same full name, the same
16190 stream is shared between these files, and the semantics are as described
16191 in Ada Reference Manual, Section A.14.
16192 @end itemize
16193
16194 @noindent
16195 When a program that opens multiple files with the same name is ported
16196 from another Ada compiler to GNAT, the effect will be that
16197 @code{Use_Error} is raised.
16198
16199 The documentation of the original compiler and the documentation of the
16200 program should then be examined to determine if file sharing was
16201 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
16202 and @code{Create} calls as required.
16203
16204 When a program is ported from GNAT to some other Ada compiler, no
16205 special attention is required unless the @samp{shared=@var{xxx}} form
16206 parameter is used in the program.  In this case, you must examine the
16207 documentation of the new compiler to see if it supports the required
16208 file sharing semantics, and form strings modified appropriately.  Of
16209 course it may be the case that the program cannot be ported if the
16210 target compiler does not support the required functionality.  The best
16211 approach in writing portable code is to avoid file sharing (and hence
16212 the use of the @samp{shared=@var{xxx}} parameter in the form string)
16213 completely.
16214
16215 One common use of file sharing in Ada 83 is the use of instantiations of
16216 Sequential_IO on the same file with different types, to achieve
16217 heterogeneous input-output.  Although this approach will work in GNAT if
16218 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
16219 for this purpose (using the stream attributes)
16220
16221 @node Filenames encoding
16222 @section Filenames encoding
16223
16224 @noindent
16225 An encoding form parameter can be used to specify the filename
16226 encoding @samp{encoding=@var{xxx}}.
16227
16228 @itemize @bullet
16229 @item
16230 If the form parameter @samp{encoding=utf8} appears in the form string, the
16231 filename must be encoded in UTF-8.
16232
16233 @item
16234 If the form parameter @samp{encoding=8bits} appears in the form
16235 string, the filename must be a standard 8bits string.
16236 @end itemize
16237
16238 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
16239 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
16240 variable. And if not set @samp{utf8} is assumed.
16241
16242 @table @samp
16243 @item CP_ACP
16244 The current system Windows ANSI code page.
16245 @item CP_UTF8
16246 UTF-8 encoding
16247 @end table
16248
16249 This encoding form parameter is only supported on the Windows
16250 platform. On the other Operating Systems the run-time is supporting
16251 UTF-8 natively.
16252
16253 @node Open Modes
16254 @section Open Modes
16255
16256 @noindent
16257 @code{Open} and @code{Create} calls result in a call to @code{fopen}
16258 using the mode shown in the following table:
16259
16260 @sp 2
16261 @center @code{Open} and @code{Create} Call Modes
16262 @smallexample
16263                                @b{OPEN }           @b{CREATE}
16264 Append_File                    "r+"             "w+"
16265 In_File                        "r"              "w+"
16266 Out_File (Direct_IO)           "r+"             "w"
16267 Out_File (all other cases)     "w"              "w"
16268 Inout_File                     "r+"             "w+"
16269 @end smallexample
16270
16271 @noindent
16272 If text file translation is required, then either @samp{b} or @samp{t}
16273 is added to the mode, depending on the setting of Text.  Text file
16274 translation refers to the mapping of CR/LF sequences in an external file
16275 to LF characters internally.  This mapping only occurs in DOS and
16276 DOS-like systems, and is not relevant to other systems.
16277
16278 A special case occurs with Stream_IO@.  As shown in the above table, the
16279 file is initially opened in @samp{r} or @samp{w} mode for the
16280 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
16281 subsequently requires switching from reading to writing or vice-versa,
16282 then the file is reopened in @samp{r+} mode to permit the required operation.
16283
16284 @node Operations on C Streams
16285 @section Operations on C Streams
16286 The package @code{Interfaces.C_Streams} provides an Ada program with direct
16287 access to the C library functions for operations on C streams:
16288
16289 @smallexample @c adanocomment
16290 package Interfaces.C_Streams is
16291   -- Note: the reason we do not use the types that are in
16292   -- Interfaces.C is that we want to avoid dragging in the
16293   -- code in this unit if possible.
16294   subtype chars is System.Address;
16295   -- Pointer to null-terminated array of characters
16296   subtype FILEs is System.Address;
16297   -- Corresponds to the C type FILE*
16298   subtype voids is System.Address;
16299   -- Corresponds to the C type void*
16300   subtype int is Integer;
16301   subtype long is Long_Integer;
16302   -- Note: the above types are subtypes deliberately, and it
16303   -- is part of this spec that the above correspondences are
16304   -- guaranteed.  This means that it is legitimate to, for
16305   -- example, use Integer instead of int.  We provide these
16306   -- synonyms for clarity, but in some cases it may be
16307   -- convenient to use the underlying types (for example to
16308   -- avoid an unnecessary dependency of a spec on the spec
16309   -- of this unit).
16310   type size_t is mod 2 ** Standard'Address_Size;
16311   NULL_Stream : constant FILEs;
16312   -- Value returned (NULL in C) to indicate an
16313   -- fdopen/fopen/tmpfile error
16314   ----------------------------------
16315   -- Constants Defined in stdio.h --
16316   ----------------------------------
16317   EOF : constant int;
16318   -- Used by a number of routines to indicate error or
16319   -- end of file
16320   IOFBF : constant int;
16321   IOLBF : constant int;
16322   IONBF : constant int;
16323   -- Used to indicate buffering mode for setvbuf call
16324   SEEK_CUR : constant int;
16325   SEEK_END : constant int;
16326   SEEK_SET : constant int;
16327   -- Used to indicate origin for fseek call
16328   function stdin return FILEs;
16329   function stdout return FILEs;
16330   function stderr return FILEs;
16331   -- Streams associated with standard files
16332   --------------------------
16333   -- Standard C functions --
16334   --------------------------
16335   -- The functions selected below are ones that are
16336   -- available in UNIX (but not necessarily in ANSI C).
16337   -- These are very thin interfaces
16338   -- which copy exactly the C headers.  For more
16339   -- documentation on these functions, see the Microsoft C
16340   -- "Run-Time Library Reference" (Microsoft Press, 1990,
16341   -- ISBN 1-55615-225-6), which includes useful information
16342   -- on system compatibility.
16343   procedure clearerr (stream : FILEs);
16344   function fclose (stream : FILEs) return int;
16345   function fdopen (handle : int; mode : chars) return FILEs;
16346   function feof (stream : FILEs) return int;
16347   function ferror (stream : FILEs) return int;
16348   function fflush (stream : FILEs) return int;
16349   function fgetc (stream : FILEs) return int;
16350   function fgets (strng : chars; n : int; stream : FILEs)
16351       return chars;
16352   function fileno (stream : FILEs) return int;
16353   function fopen (filename : chars; Mode : chars)
16354       return FILEs;
16355   -- Note: to maintain target independence, use
16356   -- text_translation_required, a boolean variable defined in
16357   -- a-sysdep.c to deal with the target dependent text
16358   -- translation requirement.  If this variable is set,
16359   -- then  b/t should be appended to the standard mode
16360   -- argument to set the text translation mode off or on
16361   -- as required.
16362   function fputc (C : int; stream : FILEs) return int;
16363   function fputs (Strng : chars; Stream : FILEs) return int;
16364   function fread
16365      (buffer : voids;
16366       size : size_t;
16367       count : size_t;
16368       stream : FILEs)
16369       return size_t;
16370   function freopen
16371      (filename : chars;
16372       mode : chars;
16373       stream : FILEs)
16374       return FILEs;
16375   function fseek
16376      (stream : FILEs;
16377       offset : long;
16378       origin : int)
16379       return int;
16380   function ftell (stream : FILEs) return long;
16381   function fwrite
16382      (buffer : voids;
16383       size : size_t;
16384       count : size_t;
16385       stream : FILEs)
16386       return size_t;
16387   function isatty (handle : int) return int;
16388   procedure mktemp (template : chars);
16389   -- The return value (which is just a pointer to template)
16390   -- is discarded
16391   procedure rewind (stream : FILEs);
16392   function rmtmp return int;
16393   function setvbuf
16394      (stream : FILEs;
16395       buffer : chars;
16396       mode : int;
16397       size : size_t)
16398       return int;
16399
16400   function tmpfile return FILEs;
16401   function ungetc (c : int; stream : FILEs) return int;
16402   function unlink (filename : chars) return int;
16403   ---------------------
16404   -- Extra functions --
16405   ---------------------
16406   -- These functions supply slightly thicker bindings than
16407   -- those above.  They are derived from functions in the
16408   -- C Run-Time Library, but may do a bit more work than
16409   -- just directly calling one of the Library functions.
16410   function is_regular_file (handle : int) return int;
16411   -- Tests if given handle is for a regular file (result 1)
16412   -- or for a non-regular file (pipe or device, result 0).
16413   ---------------------------------
16414   -- Control of Text/Binary Mode --
16415   ---------------------------------
16416   -- If text_translation_required is true, then the following
16417   -- functions may be used to dynamically switch a file from
16418   -- binary to text mode or vice versa.  These functions have
16419   -- no effect if text_translation_required is false (i.e.@: in
16420   -- normal UNIX mode).  Use fileno to get a stream handle.
16421   procedure set_binary_mode (handle : int);
16422   procedure set_text_mode (handle : int);
16423   ----------------------------
16424   -- Full Path Name support --
16425   ----------------------------
16426   procedure full_name (nam : chars; buffer : chars);
16427   -- Given a NUL terminated string representing a file
16428   -- name, returns in buffer a NUL terminated string
16429   -- representing the full path name for the file name.
16430   -- On systems where it is relevant the   drive is also
16431   -- part of the full path name.  It is the responsibility
16432   -- of the caller to pass an actual parameter for buffer
16433   -- that is big enough for any full path name.  Use
16434   -- max_path_len given below as the size of buffer.
16435   max_path_len : integer;
16436   -- Maximum length of an allowable full path name on the
16437   -- system, including a terminating NUL character.
16438 end Interfaces.C_Streams;
16439 @end smallexample
16440
16441 @node Interfacing to C Streams
16442 @section Interfacing to C Streams
16443
16444 @noindent
16445 The packages in this section permit interfacing Ada files to C Stream
16446 operations.
16447
16448 @smallexample @c ada
16449  with Interfaces.C_Streams;
16450  package Ada.Sequential_IO.C_Streams is
16451     function C_Stream (F : File_Type)
16452        return Interfaces.C_Streams.FILEs;
16453     procedure Open
16454       (File : in out File_Type;
16455        Mode : in File_Mode;
16456        C_Stream : in Interfaces.C_Streams.FILEs;
16457        Form : in String := "");
16458  end Ada.Sequential_IO.C_Streams;
16459
16460   with Interfaces.C_Streams;
16461   package Ada.Direct_IO.C_Streams is
16462      function C_Stream (F : File_Type)
16463         return Interfaces.C_Streams.FILEs;
16464      procedure Open
16465        (File : in out File_Type;
16466         Mode : in File_Mode;
16467         C_Stream : in Interfaces.C_Streams.FILEs;
16468         Form : in String := "");
16469   end Ada.Direct_IO.C_Streams;
16470
16471   with Interfaces.C_Streams;
16472   package Ada.Text_IO.C_Streams is
16473      function C_Stream (F : File_Type)
16474         return Interfaces.C_Streams.FILEs;
16475      procedure Open
16476        (File : in out File_Type;
16477         Mode : in File_Mode;
16478         C_Stream : in Interfaces.C_Streams.FILEs;
16479         Form : in String := "");
16480   end Ada.Text_IO.C_Streams;
16481
16482   with Interfaces.C_Streams;
16483   package Ada.Wide_Text_IO.C_Streams is
16484      function C_Stream (F : File_Type)
16485         return Interfaces.C_Streams.FILEs;
16486      procedure Open
16487        (File : in out File_Type;
16488         Mode : in File_Mode;
16489         C_Stream : in Interfaces.C_Streams.FILEs;
16490         Form : in String := "");
16491  end Ada.Wide_Text_IO.C_Streams;
16492
16493   with Interfaces.C_Streams;
16494   package Ada.Wide_Wide_Text_IO.C_Streams is
16495      function C_Stream (F : File_Type)
16496         return Interfaces.C_Streams.FILEs;
16497      procedure Open
16498        (File : in out File_Type;
16499         Mode : in File_Mode;
16500         C_Stream : in Interfaces.C_Streams.FILEs;
16501         Form : in String := "");
16502  end Ada.Wide_Wide_Text_IO.C_Streams;
16503
16504  with Interfaces.C_Streams;
16505  package Ada.Stream_IO.C_Streams is
16506     function C_Stream (F : File_Type)
16507        return Interfaces.C_Streams.FILEs;
16508     procedure Open
16509       (File : in out File_Type;
16510        Mode : in File_Mode;
16511        C_Stream : in Interfaces.C_Streams.FILEs;
16512        Form : in String := "");
16513  end Ada.Stream_IO.C_Streams;
16514 @end smallexample
16515
16516 @noindent
16517 In each of these six packages, the @code{C_Stream} function obtains the
16518 @code{FILE} pointer from a currently opened Ada file.  It is then
16519 possible to use the @code{Interfaces.C_Streams} package to operate on
16520 this stream, or the stream can be passed to a C program which can
16521 operate on it directly.  Of course the program is responsible for
16522 ensuring that only appropriate sequences of operations are executed.
16523
16524 One particular use of relevance to an Ada program is that the
16525 @code{setvbuf} function can be used to control the buffering of the
16526 stream used by an Ada file.  In the absence of such a call the standard
16527 default buffering is used.
16528
16529 The @code{Open} procedures in these packages open a file giving an
16530 existing C Stream instead of a file name.  Typically this stream is
16531 imported from a C program, allowing an Ada file to operate on an
16532 existing C file.
16533
16534 @node The GNAT Library
16535 @chapter The GNAT Library
16536
16537 @noindent
16538 The GNAT library contains a number of general and special purpose packages.
16539 It represents functionality that the GNAT developers have found useful, and
16540 which is made available to GNAT users.  The packages described here are fully
16541 supported, and upwards compatibility will be maintained in future releases,
16542 so you can use these facilities with the confidence that the same functionality
16543 will be available in future releases.
16544
16545 The chapter here simply gives a brief summary of the facilities available.
16546 The full documentation is found in the spec file for the package.  The full
16547 sources of these library packages, including both spec and body, are provided
16548 with all GNAT releases.  For example, to find out the full specifications of
16549 the SPITBOL pattern matching capability, including a full tutorial and
16550 extensive examples, look in the @file{g-spipat.ads} file in the library.
16551
16552 For each entry here, the package name (as it would appear in a @code{with}
16553 clause) is given, followed by the name of the corresponding spec file in
16554 parentheses.  The packages are children in four hierarchies, @code{Ada},
16555 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
16556 GNAT-specific hierarchy.
16557
16558 Note that an application program should only use packages in one of these
16559 four hierarchies if the package is defined in the Ada Reference Manual,
16560 or is listed in this section of the GNAT Programmers Reference Manual.
16561 All other units should be considered internal implementation units and
16562 should not be directly @code{with}'ed by application code.  The use of
16563 a @code{with} statement that references one of these internal implementation
16564 units makes an application potentially dependent on changes in versions
16565 of GNAT, and will generate a warning message.
16566
16567 @menu
16568 * Ada.Characters.Latin_9 (a-chlat9.ads)::
16569 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
16570 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
16571 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
16572 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
16573 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
16574 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
16575 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
16576 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
16577 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
16578 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
16579 * Ada.Command_Line.Environment (a-colien.ads)::
16580 * Ada.Command_Line.Remove (a-colire.ads)::
16581 * Ada.Command_Line.Response_File (a-clrefi.ads)::
16582 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
16583 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
16584 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
16585 * Ada.Exceptions.Traceback (a-exctra.ads)::
16586 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
16587 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
16588 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
16589 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
16590 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
16591 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
16592 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
16593 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
16594 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
16595 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
16596 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
16597 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
16598 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
16599 * GNAT.Altivec (g-altive.ads)::
16600 * GNAT.Altivec.Conversions (g-altcon.ads)::
16601 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
16602 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
16603 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
16604 * GNAT.Array_Split (g-arrspl.ads)::
16605 * GNAT.AWK (g-awk.ads)::
16606 * GNAT.Bounded_Buffers (g-boubuf.ads)::
16607 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
16608 * GNAT.Bubble_Sort (g-bubsor.ads)::
16609 * GNAT.Bubble_Sort_A (g-busora.ads)::
16610 * GNAT.Bubble_Sort_G (g-busorg.ads)::
16611 * GNAT.Byte_Order_Mark (g-byorma.ads)::
16612 * GNAT.Byte_Swapping (g-bytswa.ads)::
16613 * GNAT.Calendar (g-calend.ads)::
16614 * GNAT.Calendar.Time_IO (g-catiio.ads)::
16615 * GNAT.Case_Util (g-casuti.ads)::
16616 * GNAT.CGI (g-cgi.ads)::
16617 * GNAT.CGI.Cookie (g-cgicoo.ads)::
16618 * GNAT.CGI.Debug (g-cgideb.ads)::
16619 * GNAT.Command_Line (g-comlin.ads)::
16620 * GNAT.Compiler_Version (g-comver.ads)::
16621 * GNAT.Ctrl_C (g-ctrl_c.ads)::
16622 * GNAT.CRC32 (g-crc32.ads)::
16623 * GNAT.Current_Exception (g-curexc.ads)::
16624 * GNAT.Debug_Pools (g-debpoo.ads)::
16625 * GNAT.Debug_Utilities (g-debuti.ads)::
16626 * GNAT.Decode_String (g-decstr.ads)::
16627 * GNAT.Decode_UTF8_String (g-deutst.ads)::
16628 * GNAT.Directory_Operations (g-dirope.ads)::
16629 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
16630 * GNAT.Dynamic_HTables (g-dynhta.ads)::
16631 * GNAT.Dynamic_Tables (g-dyntab.ads)::
16632 * GNAT.Encode_String (g-encstr.ads)::
16633 * GNAT.Encode_UTF8_String (g-enutst.ads)::
16634 * GNAT.Exception_Actions (g-excact.ads)::
16635 * GNAT.Exception_Traces (g-exctra.ads)::
16636 * GNAT.Exceptions (g-except.ads)::
16637 * GNAT.Expect (g-expect.ads)::
16638 * GNAT.Expect.TTY (g-exptty.ads)::
16639 * GNAT.Float_Control (g-flocon.ads)::
16640 * GNAT.Heap_Sort (g-heasor.ads)::
16641 * GNAT.Heap_Sort_A (g-hesora.ads)::
16642 * GNAT.Heap_Sort_G (g-hesorg.ads)::
16643 * GNAT.HTable (g-htable.ads)::
16644 * GNAT.IO (g-io.ads)::
16645 * GNAT.IO_Aux (g-io_aux.ads)::
16646 * GNAT.Lock_Files (g-locfil.ads)::
16647 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
16648 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
16649 * GNAT.MD5 (g-md5.ads)::
16650 * GNAT.Memory_Dump (g-memdum.ads)::
16651 * GNAT.Most_Recent_Exception (g-moreex.ads)::
16652 * GNAT.OS_Lib (g-os_lib.ads)::
16653 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
16654 * GNAT.Random_Numbers (g-rannum.ads)::
16655 * GNAT.Regexp (g-regexp.ads)::
16656 * GNAT.Registry (g-regist.ads)::
16657 * GNAT.Regpat (g-regpat.ads)::
16658 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
16659 * GNAT.Semaphores (g-semaph.ads)::
16660 * GNAT.Serial_Communications (g-sercom.ads)::
16661 * GNAT.SHA1 (g-sha1.ads)::
16662 * GNAT.SHA224 (g-sha224.ads)::
16663 * GNAT.SHA256 (g-sha256.ads)::
16664 * GNAT.SHA384 (g-sha384.ads)::
16665 * GNAT.SHA512 (g-sha512.ads)::
16666 * GNAT.Signals (g-signal.ads)::
16667 * GNAT.Sockets (g-socket.ads)::
16668 * GNAT.Source_Info (g-souinf.ads)::
16669 * GNAT.Spelling_Checker (g-speche.ads)::
16670 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
16671 * GNAT.Spitbol.Patterns (g-spipat.ads)::
16672 * GNAT.Spitbol (g-spitbo.ads)::
16673 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
16674 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
16675 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
16676 * GNAT.SSE (g-sse.ads)::
16677 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
16678 * GNAT.Strings (g-string.ads)::
16679 * GNAT.String_Split (g-strspl.ads)::
16680 * GNAT.Table (g-table.ads)::
16681 * GNAT.Task_Lock (g-tasloc.ads)::
16682 * GNAT.Threads (g-thread.ads)::
16683 * GNAT.Time_Stamp (g-timsta.ads)::
16684 * GNAT.Traceback (g-traceb.ads)::
16685 * GNAT.Traceback.Symbolic (g-trasym.ads)::
16686 * GNAT.UTF_32 (g-utf_32.ads)::
16687 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
16688 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
16689 * GNAT.Wide_String_Split (g-wistsp.ads)::
16690 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
16691 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
16692 * Interfaces.C.Extensions (i-cexten.ads)::
16693 * Interfaces.C.Streams (i-cstrea.ads)::
16694 * Interfaces.CPP (i-cpp.ads)::
16695 * Interfaces.Packed_Decimal (i-pacdec.ads)::
16696 * Interfaces.VxWorks (i-vxwork.ads)::
16697 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
16698 * System.Address_Image (s-addima.ads)::
16699 * System.Assertions (s-assert.ads)::
16700 * System.Memory (s-memory.ads)::
16701 * System.Multiprocessors (s-multip.ads)::
16702 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
16703 * System.Partition_Interface (s-parint.ads)::
16704 * System.Pool_Global (s-pooglo.ads)::
16705 * System.Pool_Local (s-pooloc.ads)::
16706 * System.Restrictions (s-restri.ads)::
16707 * System.Rident (s-rident.ads)::
16708 * System.Strings.Stream_Ops (s-ststop.ads)::
16709 * System.Task_Info (s-tasinf.ads)::
16710 * System.Wch_Cnv (s-wchcnv.ads)::
16711 * System.Wch_Con (s-wchcon.ads)::
16712 @end menu
16713
16714 @node Ada.Characters.Latin_9 (a-chlat9.ads)
16715 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16716 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
16717 @cindex Latin_9 constants for Character
16718
16719 @noindent
16720 This child of @code{Ada.Characters}
16721 provides a set of definitions corresponding to those in the
16722 RM-defined package @code{Ada.Characters.Latin_1} but with the
16723 few modifications required for @code{Latin-9}
16724 The provision of such a package
16725 is specifically authorized by the Ada Reference Manual
16726 (RM A.3.3(27)).
16727
16728 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
16729 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16730 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
16731 @cindex Latin_1 constants for Wide_Character
16732
16733 @noindent
16734 This child of @code{Ada.Characters}
16735 provides a set of definitions corresponding to those in the
16736 RM-defined package @code{Ada.Characters.Latin_1} but with the
16737 types of the constants being @code{Wide_Character}
16738 instead of @code{Character}.  The provision of such a package
16739 is specifically authorized by the Ada Reference Manual
16740 (RM A.3.3(27)).
16741
16742 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
16743 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16744 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
16745 @cindex Latin_9 constants for Wide_Character
16746
16747 @noindent
16748 This child of @code{Ada.Characters}
16749 provides a set of definitions corresponding to those in the
16750 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16751 types of the constants being @code{Wide_Character}
16752 instead of @code{Character}.  The provision of such a package
16753 is specifically authorized by the Ada Reference Manual
16754 (RM A.3.3(27)).
16755
16756 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
16757 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16758 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
16759 @cindex Latin_1 constants for Wide_Wide_Character
16760
16761 @noindent
16762 This child of @code{Ada.Characters}
16763 provides a set of definitions corresponding to those in the
16764 RM-defined package @code{Ada.Characters.Latin_1} but with the
16765 types of the constants being @code{Wide_Wide_Character}
16766 instead of @code{Character}.  The provision of such a package
16767 is specifically authorized by the Ada Reference Manual
16768 (RM A.3.3(27)).
16769
16770 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
16771 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16772 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
16773 @cindex Latin_9 constants for Wide_Wide_Character
16774
16775 @noindent
16776 This child of @code{Ada.Characters}
16777 provides a set of definitions corresponding to those in the
16778 GNAT defined package @code{Ada.Characters.Latin_9} but with the
16779 types of the constants being @code{Wide_Wide_Character}
16780 instead of @code{Character}.  The provision of such a package
16781 is specifically authorized by the Ada Reference Manual
16782 (RM A.3.3(27)).
16783
16784 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
16785 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16786 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
16787 @cindex Formal container for doubly linked lists
16788
16789 @noindent
16790 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16791 container for doubly linked lists, meant to facilitate formal verification of
16792 code using such containers.
16793
16794 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
16795 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16796 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
16797 @cindex Formal container for hashed maps
16798
16799 @noindent
16800 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16801 container for hashed maps, meant to facilitate formal verification of
16802 code using such containers.
16803
16804 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
16805 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16806 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
16807 @cindex Formal container for hashed sets
16808
16809 @noindent
16810 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16811 container for hashed sets, meant to facilitate formal verification of
16812 code using such containers.
16813
16814 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
16815 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16816 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
16817 @cindex Formal container for ordered maps
16818
16819 @noindent
16820 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16821 container for ordered maps, meant to facilitate formal verification of
16822 code using such containers.
16823
16824 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
16825 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16826 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
16827 @cindex Formal container for ordered sets
16828
16829 @noindent
16830 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16831 container for ordered sets, meant to facilitate formal verification of
16832 code using such containers.
16833
16834 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
16835 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16836 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
16837 @cindex Formal container for vectors
16838
16839 @noindent
16840 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
16841 container for vectors, meant to facilitate formal verification of
16842 code using such containers.
16843
16844 @node Ada.Command_Line.Environment (a-colien.ads)
16845 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16846 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
16847 @cindex Environment entries
16848
16849 @noindent
16850 This child of @code{Ada.Command_Line}
16851 provides a mechanism for obtaining environment values on systems
16852 where this concept makes sense.
16853
16854 @node Ada.Command_Line.Remove (a-colire.ads)
16855 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16856 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
16857 @cindex Removing command line arguments
16858 @cindex Command line, argument removal
16859
16860 @noindent
16861 This child of @code{Ada.Command_Line}
16862 provides a mechanism for logically removing
16863 arguments from the argument list.  Once removed, an argument is not visible
16864 to further calls on the subprograms in @code{Ada.Command_Line} will not
16865 see the removed argument.
16866
16867 @node Ada.Command_Line.Response_File (a-clrefi.ads)
16868 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16869 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
16870 @cindex Response file for command line
16871 @cindex Command line, response file
16872 @cindex Command line, handling long command lines
16873
16874 @noindent
16875 This child of @code{Ada.Command_Line} provides a mechanism facilities for
16876 getting command line arguments from a text file, called a "response file".
16877 Using a response file allow passing a set of arguments to an executable longer
16878 than the maximum allowed by the system on the command line.
16879
16880 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
16881 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16882 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
16883 @cindex C Streams, Interfacing with Direct_IO
16884
16885 @noindent
16886 This package provides subprograms that allow interfacing between
16887 C streams and @code{Direct_IO}.  The stream identifier can be
16888 extracted from a file opened on the Ada side, and an Ada file
16889 can be constructed from a stream opened on the C side.
16890
16891 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
16892 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16893 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
16894 @cindex Null_Occurrence, testing for
16895
16896 @noindent
16897 This child subprogram provides a way of testing for the null
16898 exception occurrence (@code{Null_Occurrence}) without raising
16899 an exception.
16900
16901 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
16902 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16903 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
16904 @cindex Null_Occurrence, testing for
16905
16906 @noindent
16907 This child subprogram is used for handling otherwise unhandled
16908 exceptions (hence the name last chance), and perform clean ups before
16909 terminating the program. Note that this subprogram never returns.
16910
16911 @node Ada.Exceptions.Traceback (a-exctra.ads)
16912 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16913 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
16914 @cindex Traceback for Exception Occurrence
16915
16916 @noindent
16917 This child package provides the subprogram (@code{Tracebacks}) to
16918 give a traceback array of addresses based on an exception
16919 occurrence.
16920
16921 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
16922 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16923 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
16924 @cindex C Streams, Interfacing with Sequential_IO
16925
16926 @noindent
16927 This package provides subprograms that allow interfacing between
16928 C streams and @code{Sequential_IO}.  The stream identifier can be
16929 extracted from a file opened on the Ada side, and an Ada file
16930 can be constructed from a stream opened on the C side.
16931
16932 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
16933 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16934 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
16935 @cindex C Streams, Interfacing with Stream_IO
16936
16937 @noindent
16938 This package provides subprograms that allow interfacing between
16939 C streams and @code{Stream_IO}.  The stream identifier can be
16940 extracted from a file opened on the Ada side, and an Ada file
16941 can be constructed from a stream opened on the C side.
16942
16943 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
16944 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16945 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
16946 @cindex @code{Unbounded_String}, IO support
16947 @cindex @code{Text_IO}, extensions for unbounded strings
16948
16949 @noindent
16950 This package provides subprograms for Text_IO for unbounded
16951 strings, avoiding the necessity for an intermediate operation
16952 with ordinary strings.
16953
16954 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
16955 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16956 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
16957 @cindex @code{Unbounded_Wide_String}, IO support
16958 @cindex @code{Text_IO}, extensions for unbounded wide strings
16959
16960 @noindent
16961 This package provides subprograms for Text_IO for unbounded
16962 wide strings, avoiding the necessity for an intermediate operation
16963 with ordinary wide strings.
16964
16965 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
16966 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16967 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
16968 @cindex @code{Unbounded_Wide_Wide_String}, IO support
16969 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
16970
16971 @noindent
16972 This package provides subprograms for Text_IO for unbounded
16973 wide wide strings, avoiding the necessity for an intermediate operation
16974 with ordinary wide wide strings.
16975
16976 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
16977 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16978 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
16979 @cindex C Streams, Interfacing with @code{Text_IO}
16980
16981 @noindent
16982 This package provides subprograms that allow interfacing between
16983 C streams and @code{Text_IO}.  The stream identifier can be
16984 extracted from a file opened on the Ada side, and an Ada file
16985 can be constructed from a stream opened on the C side.
16986
16987 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
16988 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16989 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
16990 @cindex @code{Text_IO} resetting standard files
16991
16992 @noindent
16993 This procedure is used to reset the status of the standard files used
16994 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
16995 embedded application) where the status of the files may change during
16996 execution (for example a standard input file may be redefined to be
16997 interactive).
16998
16999 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
17000 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17001 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
17002 @cindex Unicode categorization, Wide_Character
17003
17004 @noindent
17005 This package provides subprograms that allow categorization of
17006 Wide_Character values according to Unicode categories.
17007
17008 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
17009 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17010 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
17011 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
17012
17013 @noindent
17014 This package provides subprograms that allow interfacing between
17015 C streams and @code{Wide_Text_IO}.  The stream identifier can be
17016 extracted from a file opened on the Ada side, and an Ada file
17017 can be constructed from a stream opened on the C side.
17018
17019 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
17020 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17021 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
17022 @cindex @code{Wide_Text_IO} resetting standard files
17023
17024 @noindent
17025 This procedure is used to reset the status of the standard files used
17026 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
17027 embedded application) where the status of the files may change during
17028 execution (for example a standard input file may be redefined to be
17029 interactive).
17030
17031 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
17032 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17033 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
17034 @cindex Unicode categorization, Wide_Wide_Character
17035
17036 @noindent
17037 This package provides subprograms that allow categorization of
17038 Wide_Wide_Character values according to Unicode categories.
17039
17040 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
17041 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17042 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
17043 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
17044
17045 @noindent
17046 This package provides subprograms that allow interfacing between
17047 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
17048 extracted from a file opened on the Ada side, and an Ada file
17049 can be constructed from a stream opened on the C side.
17050
17051 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
17052 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17053 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
17054 @cindex @code{Wide_Wide_Text_IO} resetting standard files
17055
17056 @noindent
17057 This procedure is used to reset the status of the standard files used
17058 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
17059 restart in an embedded application) where the status of the files may
17060 change during execution (for example a standard input file may be
17061 redefined to be interactive).
17062
17063 @node GNAT.Altivec (g-altive.ads)
17064 @section @code{GNAT.Altivec} (@file{g-altive.ads})
17065 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
17066 @cindex AltiVec
17067
17068 @noindent
17069 This is the root package of the GNAT AltiVec binding. It provides
17070 definitions of constants and types common to all the versions of the
17071 binding.
17072
17073 @node GNAT.Altivec.Conversions (g-altcon.ads)
17074 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17075 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
17076 @cindex AltiVec
17077
17078 @noindent
17079 This package provides the Vector/View conversion routines.
17080
17081 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
17082 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17083 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
17084 @cindex AltiVec
17085
17086 @noindent
17087 This package exposes the Ada interface to the AltiVec operations on
17088 vector objects. A soft emulation is included by default in the GNAT
17089 library. The hard binding is provided as a separate package. This unit
17090 is common to both bindings.
17091
17092 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
17093 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17094 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
17095 @cindex AltiVec
17096
17097 @noindent
17098 This package exposes the various vector types part of the Ada binding
17099 to AltiVec facilities.
17100
17101 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
17102 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17103 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
17104 @cindex AltiVec
17105
17106 @noindent
17107 This package provides public 'View' data types from/to which private
17108 vector representations can be converted via
17109 GNAT.Altivec.Conversions. This allows convenient access to individual
17110 vector elements and provides a simple way to initialize vector
17111 objects.
17112
17113 @node GNAT.Array_Split (g-arrspl.ads)
17114 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17115 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
17116 @cindex Array splitter
17117
17118 @noindent
17119 Useful array-manipulation routines: given a set of separators, split
17120 an array wherever the separators appear, and provide direct access
17121 to the resulting slices.
17122
17123 @node GNAT.AWK (g-awk.ads)
17124 @section @code{GNAT.AWK} (@file{g-awk.ads})
17125 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
17126 @cindex Parsing
17127 @cindex AWK
17128
17129 @noindent
17130 Provides AWK-like parsing functions, with an easy interface for parsing one
17131 or more files containing formatted data.  The file is viewed as a database
17132 where each record is a line and a field is a data element in this line.
17133
17134 @node GNAT.Bounded_Buffers (g-boubuf.ads)
17135 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17136 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
17137 @cindex Parsing
17138 @cindex Bounded Buffers
17139
17140 @noindent
17141 Provides a concurrent generic bounded buffer abstraction.  Instances are
17142 useful directly or as parts of the implementations of other abstractions,
17143 such as mailboxes.
17144
17145 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
17146 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17147 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
17148 @cindex Parsing
17149 @cindex Mailboxes
17150
17151 @noindent
17152 Provides a thread-safe asynchronous intertask mailbox communication facility.
17153
17154 @node GNAT.Bubble_Sort (g-bubsor.ads)
17155 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17156 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
17157 @cindex Sorting
17158 @cindex Bubble sort
17159
17160 @noindent
17161 Provides a general implementation of bubble sort usable for sorting arbitrary
17162 data items.  Exchange and comparison procedures are provided by passing
17163 access-to-procedure values.
17164
17165 @node GNAT.Bubble_Sort_A (g-busora.ads)
17166 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17167 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
17168 @cindex Sorting
17169 @cindex Bubble sort
17170
17171 @noindent
17172 Provides a general implementation of bubble sort usable for sorting arbitrary
17173 data items.  Move and comparison procedures are provided by passing
17174 access-to-procedure values. This is an older version, retained for
17175 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
17176
17177 @node GNAT.Bubble_Sort_G (g-busorg.ads)
17178 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17179 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
17180 @cindex Sorting
17181 @cindex Bubble sort
17182
17183 @noindent
17184 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
17185 are provided as generic parameters, this improves efficiency, especially
17186 if the procedures can be inlined, at the expense of duplicating code for
17187 multiple instantiations.
17188
17189 @node GNAT.Byte_Order_Mark (g-byorma.ads)
17190 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17191 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
17192 @cindex UTF-8 representation
17193 @cindex Wide characte representations
17194
17195 @noindent
17196 Provides a routine which given a string, reads the start of the string to
17197 see whether it is one of the standard byte order marks (BOM's) which signal
17198 the encoding of the string. The routine includes detection of special XML
17199 sequences for various UCS input formats.
17200
17201 @node GNAT.Byte_Swapping (g-bytswa.ads)
17202 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17203 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
17204 @cindex Byte swapping
17205 @cindex Endianness
17206
17207 @noindent
17208 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
17209 Machine-specific implementations are available in some cases.
17210
17211 @node GNAT.Calendar (g-calend.ads)
17212 @section @code{GNAT.Calendar} (@file{g-calend.ads})
17213 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
17214 @cindex @code{Calendar}
17215
17216 @noindent
17217 Extends the facilities provided by @code{Ada.Calendar} to include handling
17218 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
17219 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
17220 C @code{timeval} format.
17221
17222 @node GNAT.Calendar.Time_IO (g-catiio.ads)
17223 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17224 @cindex @code{Calendar}
17225 @cindex Time
17226 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
17227
17228 @node GNAT.CRC32 (g-crc32.ads)
17229 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
17230 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
17231 @cindex CRC32
17232 @cindex Cyclic Redundancy Check
17233
17234 @noindent
17235 This package implements the CRC-32 algorithm.  For a full description
17236 of this algorithm see
17237 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
17238 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
17239 Aug.@: 1988.  Sarwate, D.V@.
17240
17241 @node GNAT.Case_Util (g-casuti.ads)
17242 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
17243 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
17244 @cindex Casing utilities
17245 @cindex Character handling (@code{GNAT.Case_Util})
17246
17247 @noindent
17248 A set of simple routines for handling upper and lower casing of strings
17249 without the overhead of the full casing tables
17250 in @code{Ada.Characters.Handling}.
17251
17252 @node GNAT.CGI (g-cgi.ads)
17253 @section @code{GNAT.CGI} (@file{g-cgi.ads})
17254 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
17255 @cindex CGI (Common Gateway Interface)
17256
17257 @noindent
17258 This is a package for interfacing a GNAT program with a Web server via the
17259 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
17260 parameters, which are a set of key/value pairs sent by the Web server.  It
17261 builds a table whose index is the key and provides some services to deal
17262 with this table.
17263
17264 @node GNAT.CGI.Cookie (g-cgicoo.ads)
17265 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17266 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
17267 @cindex CGI (Common Gateway Interface) cookie support
17268 @cindex Cookie support in CGI
17269
17270 @noindent
17271 This is a package to interface a GNAT program with a Web server via the
17272 Common Gateway Interface (CGI).  It exports services to deal with Web
17273 cookies (piece of information kept in the Web client software).
17274
17275 @node GNAT.CGI.Debug (g-cgideb.ads)
17276 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17277 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
17278 @cindex CGI (Common Gateway Interface) debugging
17279
17280 @noindent
17281 This is a package to help debugging CGI (Common Gateway Interface)
17282 programs written in Ada.
17283
17284 @node GNAT.Command_Line (g-comlin.ads)
17285 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
17286 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
17287 @cindex Command line
17288
17289 @noindent
17290 Provides a high level interface to @code{Ada.Command_Line} facilities,
17291 including the ability to scan for named switches with optional parameters
17292 and expand file names using wild card notations.
17293
17294 @node GNAT.Compiler_Version (g-comver.ads)
17295 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17296 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
17297 @cindex Compiler Version
17298 @cindex Version, of compiler
17299
17300 @noindent
17301 Provides a routine for obtaining the version of the compiler used to
17302 compile the program. More accurately this is the version of the binder
17303 used to bind the program (this will normally be the same as the version
17304 of the compiler if a consistent tool set is used to compile all units
17305 of a partition).
17306
17307 @node GNAT.Ctrl_C (g-ctrl_c.ads)
17308 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17309 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
17310 @cindex Interrupt
17311
17312 @noindent
17313 Provides a simple interface to handle Ctrl-C keyboard events.
17314
17315 @node GNAT.Current_Exception (g-curexc.ads)
17316 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17317 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
17318 @cindex Current exception
17319 @cindex Exception retrieval
17320
17321 @noindent
17322 Provides access to information on the current exception that has been raised
17323 without the need for using the Ada 95 / Ada 2005 exception choice parameter
17324 specification syntax.
17325 This is particularly useful in simulating typical facilities for
17326 obtaining information about exceptions provided by Ada 83 compilers.
17327
17328 @node GNAT.Debug_Pools (g-debpoo.ads)
17329 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17330 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
17331 @cindex Debugging
17332 @cindex Debug pools
17333 @cindex Memory corruption debugging
17334
17335 @noindent
17336 Provide a debugging storage pools that helps tracking memory corruption
17337 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
17338 @value{EDITION} User's Guide}.
17339
17340 @node GNAT.Debug_Utilities (g-debuti.ads)
17341 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17342 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
17343 @cindex Debugging
17344
17345 @noindent
17346 Provides a few useful utilities for debugging purposes, including conversion
17347 to and from string images of address values. Supports both C and Ada formats
17348 for hexadecimal literals.
17349
17350 @node GNAT.Decode_String (g-decstr.ads)
17351 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
17352 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
17353 @cindex Decoding strings
17354 @cindex String decoding
17355 @cindex Wide character encoding
17356 @cindex UTF-8
17357 @cindex Unicode
17358
17359 @noindent
17360 A generic package providing routines for decoding wide character and wide wide
17361 character strings encoded as sequences of 8-bit characters using a specified
17362 encoding method. Includes validation routines, and also routines for stepping
17363 to next or previous encoded character in an encoded string.
17364 Useful in conjunction with Unicode character coding. Note there is a
17365 preinstantiation for UTF-8. See next entry.
17366
17367 @node GNAT.Decode_UTF8_String (g-deutst.ads)
17368 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17369 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
17370 @cindex Decoding strings
17371 @cindex Decoding UTF-8 strings
17372 @cindex UTF-8 string decoding
17373 @cindex Wide character decoding
17374 @cindex UTF-8
17375 @cindex Unicode
17376
17377 @noindent
17378 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
17379
17380 @node GNAT.Directory_Operations (g-dirope.ads)
17381 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17382 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
17383 @cindex Directory operations
17384
17385 @noindent
17386 Provides a set of routines for manipulating directories, including changing
17387 the current directory, making new directories, and scanning the files in a
17388 directory.
17389
17390 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
17391 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17392 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
17393 @cindex Directory operations iteration
17394
17395 @noindent
17396 A child unit of GNAT.Directory_Operations providing additional operations
17397 for iterating through directories.
17398
17399 @node GNAT.Dynamic_HTables (g-dynhta.ads)
17400 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17401 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
17402 @cindex Hash tables
17403
17404 @noindent
17405 A generic implementation of hash tables that can be used to hash arbitrary
17406 data.  Provided in two forms, a simple form with built in hash functions,
17407 and a more complex form in which the hash function is supplied.
17408
17409 @noindent
17410 This package provides a facility similar to that of @code{GNAT.HTable},
17411 except that this package declares a type that can be used to define
17412 dynamic instances of the hash table, while an instantiation of
17413 @code{GNAT.HTable} creates a single instance of the hash table.
17414
17415 @node GNAT.Dynamic_Tables (g-dyntab.ads)
17416 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17417 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
17418 @cindex Table implementation
17419 @cindex Arrays, extendable
17420
17421 @noindent
17422 A generic package providing a single dimension array abstraction where the
17423 length of the array can be dynamically modified.
17424
17425 @noindent
17426 This package provides a facility similar to that of @code{GNAT.Table},
17427 except that this package declares a type that can be used to define
17428 dynamic instances of the table, while an instantiation of
17429 @code{GNAT.Table} creates a single instance of the table type.
17430
17431 @node GNAT.Encode_String (g-encstr.ads)
17432 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
17433 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
17434 @cindex Encoding strings
17435 @cindex String encoding
17436 @cindex Wide character encoding
17437 @cindex UTF-8
17438 @cindex Unicode
17439
17440 @noindent
17441 A generic package providing routines for encoding wide character and wide
17442 wide character strings as sequences of 8-bit characters using a specified
17443 encoding method. Useful in conjunction with Unicode character coding.
17444 Note there is a preinstantiation for UTF-8. See next entry.
17445
17446 @node GNAT.Encode_UTF8_String (g-enutst.ads)
17447 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17448 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
17449 @cindex Encoding strings
17450 @cindex Encoding UTF-8 strings
17451 @cindex UTF-8 string encoding
17452 @cindex Wide character encoding
17453 @cindex UTF-8
17454 @cindex Unicode
17455
17456 @noindent
17457 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
17458
17459 @node GNAT.Exception_Actions (g-excact.ads)
17460 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17461 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
17462 @cindex Exception actions
17463
17464 @noindent
17465 Provides callbacks when an exception is raised. Callbacks can be registered
17466 for specific exceptions, or when any exception is raised. This
17467 can be used for instance to force a core dump to ease debugging.
17468
17469 @node GNAT.Exception_Traces (g-exctra.ads)
17470 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17471 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
17472 @cindex Exception traces
17473 @cindex Debugging
17474
17475 @noindent
17476 Provides an interface allowing to control automatic output upon exception
17477 occurrences.
17478
17479 @node GNAT.Exceptions (g-except.ads)
17480 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
17481 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
17482 @cindex Exceptions, Pure
17483 @cindex Pure packages, exceptions
17484
17485 @noindent
17486 Normally it is not possible to raise an exception with
17487 a message from a subprogram in a pure package, since the
17488 necessary types and subprograms are in @code{Ada.Exceptions}
17489 which is not a pure unit. @code{GNAT.Exceptions} provides a
17490 facility for getting around this limitation for a few
17491 predefined exceptions, and for example allow raising
17492 @code{Constraint_Error} with a message from a pure subprogram.
17493
17494 @node GNAT.Expect (g-expect.ads)
17495 @section @code{GNAT.Expect} (@file{g-expect.ads})
17496 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
17497
17498 @noindent
17499 Provides a set of subprograms similar to what is available
17500 with the standard Tcl Expect tool.
17501 It allows you to easily spawn and communicate with an external process.
17502 You can send commands or inputs to the process, and compare the output
17503 with some expected regular expression. Currently @code{GNAT.Expect}
17504 is implemented on all native GNAT ports except for OpenVMS@.
17505 It is not implemented for cross ports, and in particular is not
17506 implemented for VxWorks or LynxOS@.
17507
17508 @node GNAT.Expect.TTY (g-exptty.ads)
17509 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17510 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
17511
17512 @noindent
17513 As GNAT.Expect but using pseudo-terminal.
17514 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
17515 ports except for OpenVMS@. It is not implemented for cross ports, and
17516 in particular is not implemented for VxWorks or LynxOS@.
17517
17518 @node GNAT.Float_Control (g-flocon.ads)
17519 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
17520 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
17521 @cindex Floating-Point Processor
17522
17523 @noindent
17524 Provides an interface for resetting the floating-point processor into the
17525 mode required for correct semantic operation in Ada.  Some third party
17526 library calls may cause this mode to be modified, and the Reset procedure
17527 in this package can be used to reestablish the required mode.
17528
17529 @node GNAT.Heap_Sort (g-heasor.ads)
17530 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17531 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
17532 @cindex Sorting
17533
17534 @noindent
17535 Provides a general implementation of heap sort usable for sorting arbitrary
17536 data items. Exchange and comparison procedures are provided by passing
17537 access-to-procedure values.  The algorithm used is a modified heap sort
17538 that performs approximately N*log(N) comparisons in the worst case.
17539
17540 @node GNAT.Heap_Sort_A (g-hesora.ads)
17541 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17542 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
17543 @cindex Sorting
17544
17545 @noindent
17546 Provides a general implementation of heap sort usable for sorting arbitrary
17547 data items. Move and comparison procedures are provided by passing
17548 access-to-procedure values.  The algorithm used is a modified heap sort
17549 that performs approximately N*log(N) comparisons in the worst case.
17550 This differs from @code{GNAT.Heap_Sort} in having a less convenient
17551 interface, but may be slightly more efficient.
17552
17553 @node GNAT.Heap_Sort_G (g-hesorg.ads)
17554 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17555 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
17556 @cindex Sorting
17557
17558 @noindent
17559 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
17560 are provided as generic parameters, this improves efficiency, especially
17561 if the procedures can be inlined, at the expense of duplicating code for
17562 multiple instantiations.
17563
17564 @node GNAT.HTable (g-htable.ads)
17565 @section @code{GNAT.HTable} (@file{g-htable.ads})
17566 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
17567 @cindex Hash tables
17568
17569 @noindent
17570 A generic implementation of hash tables that can be used to hash arbitrary
17571 data.  Provides two approaches, one a simple static approach, and the other
17572 allowing arbitrary dynamic hash tables.
17573
17574 @node GNAT.IO (g-io.ads)
17575 @section @code{GNAT.IO} (@file{g-io.ads})
17576 @cindex @code{GNAT.IO} (@file{g-io.ads})
17577 @cindex Simple I/O
17578 @cindex Input/Output facilities
17579
17580 @noindent
17581 A simple preelaborable input-output package that provides a subset of
17582 simple Text_IO functions for reading characters and strings from
17583 Standard_Input, and writing characters, strings and integers to either
17584 Standard_Output or Standard_Error.
17585
17586 @node GNAT.IO_Aux (g-io_aux.ads)
17587 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17588 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
17589 @cindex Text_IO
17590 @cindex Input/Output facilities
17591
17592 Provides some auxiliary functions for use with Text_IO, including a test
17593 for whether a file exists, and functions for reading a line of text.
17594
17595 @node GNAT.Lock_Files (g-locfil.ads)
17596 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17597 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
17598 @cindex File locking
17599 @cindex Locking using files
17600
17601 @noindent
17602 Provides a general interface for using files as locks.  Can be used for
17603 providing program level synchronization.
17604
17605 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
17606 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17607 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
17608 @cindex Random number generation
17609
17610 @noindent
17611 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
17612 a modified version of the Blum-Blum-Shub generator.
17613
17614 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
17615 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17616 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
17617 @cindex Random number generation
17618
17619 @noindent
17620 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
17621 a modified version of the Blum-Blum-Shub generator.
17622
17623 @node GNAT.MD5 (g-md5.ads)
17624 @section @code{GNAT.MD5} (@file{g-md5.ads})
17625 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
17626 @cindex Message Digest MD5
17627
17628 @noindent
17629 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
17630
17631 @node GNAT.Memory_Dump (g-memdum.ads)
17632 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17633 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
17634 @cindex Dump Memory
17635
17636 @noindent
17637 Provides a convenient routine for dumping raw memory to either the
17638 standard output or standard error files. Uses GNAT.IO for actual
17639 output.
17640
17641 @node GNAT.Most_Recent_Exception (g-moreex.ads)
17642 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17643 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
17644 @cindex Exception, obtaining most recent
17645
17646 @noindent
17647 Provides access to the most recently raised exception.  Can be used for
17648 various logging purposes, including duplicating functionality of some
17649 Ada 83 implementation dependent extensions.
17650
17651 @node GNAT.OS_Lib (g-os_lib.ads)
17652 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17653 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
17654 @cindex Operating System interface
17655 @cindex Spawn capability
17656
17657 @noindent
17658 Provides a range of target independent operating system interface functions,
17659 including time/date management, file operations, subprocess management,
17660 including a portable spawn procedure, and access to environment variables
17661 and error return codes.
17662
17663 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
17664 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17665 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
17666 @cindex Hash functions
17667
17668 @noindent
17669 Provides a generator of static minimal perfect hash functions. No
17670 collisions occur and each item can be retrieved from the table in one
17671 probe (perfect property). The hash table size corresponds to the exact
17672 size of the key set and no larger (minimal property). The key set has to
17673 be know in advance (static property). The hash functions are also order
17674 preserving. If w2 is inserted after w1 in the generator, their
17675 hashcode are in the same order. These hashing functions are very
17676 convenient for use with realtime applications.
17677
17678 @node GNAT.Random_Numbers (g-rannum.ads)
17679 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17680 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
17681 @cindex Random number generation
17682
17683 @noindent
17684 Provides random number capabilities which extend those available in the
17685 standard Ada library and are more convenient to use.
17686
17687 @node GNAT.Regexp (g-regexp.ads)
17688 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
17689 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
17690 @cindex Regular expressions
17691 @cindex Pattern matching
17692
17693 @noindent
17694 A simple implementation of regular expressions, using a subset of regular
17695 expression syntax copied from familiar Unix style utilities.  This is the
17696 simples of the three pattern matching packages provided, and is particularly
17697 suitable for ``file globbing'' applications.
17698
17699 @node GNAT.Registry (g-regist.ads)
17700 @section @code{GNAT.Registry} (@file{g-regist.ads})
17701 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
17702 @cindex Windows Registry
17703
17704 @noindent
17705 This is a high level binding to the Windows registry.  It is possible to
17706 do simple things like reading a key value, creating a new key.  For full
17707 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
17708 package provided with the Win32Ada binding
17709
17710 @node GNAT.Regpat (g-regpat.ads)
17711 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
17712 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
17713 @cindex Regular expressions
17714 @cindex Pattern matching
17715
17716 @noindent
17717 A complete implementation of Unix-style regular expression matching, copied
17718 from the original V7 style regular expression library written in C by
17719 Henry Spencer (and binary compatible with this C library).
17720
17721 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
17722 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17723 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
17724 @cindex Secondary Stack Info
17725
17726 @noindent
17727 Provide the capability to query the high water mark of the current task's
17728 secondary stack.
17729
17730 @node GNAT.Semaphores (g-semaph.ads)
17731 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
17732 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
17733 @cindex Semaphores
17734
17735 @noindent
17736 Provides classic counting and binary semaphores using protected types.
17737
17738 @node GNAT.Serial_Communications (g-sercom.ads)
17739 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17740 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
17741 @cindex Serial_Communications
17742
17743 @noindent
17744 Provides a simple interface to send and receive data over a serial
17745 port. This is only supported on GNU/Linux and Windows.
17746
17747 @node GNAT.SHA1 (g-sha1.ads)
17748 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
17749 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
17750 @cindex Secure Hash Algorithm SHA-1
17751
17752 @noindent
17753 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
17754 and RFC 3174.
17755
17756 @node GNAT.SHA224 (g-sha224.ads)
17757 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
17758 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
17759 @cindex Secure Hash Algorithm SHA-224
17760
17761 @noindent
17762 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
17763
17764 @node GNAT.SHA256 (g-sha256.ads)
17765 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
17766 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
17767 @cindex Secure Hash Algorithm SHA-256
17768
17769 @noindent
17770 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
17771
17772 @node GNAT.SHA384 (g-sha384.ads)
17773 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
17774 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
17775 @cindex Secure Hash Algorithm SHA-384
17776
17777 @noindent
17778 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
17779
17780 @node GNAT.SHA512 (g-sha512.ads)
17781 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
17782 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
17783 @cindex Secure Hash Algorithm SHA-512
17784
17785 @noindent
17786 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
17787
17788 @node GNAT.Signals (g-signal.ads)
17789 @section @code{GNAT.Signals} (@file{g-signal.ads})
17790 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
17791 @cindex Signals
17792
17793 @noindent
17794 Provides the ability to manipulate the blocked status of signals on supported
17795 targets.
17796
17797 @node GNAT.Sockets (g-socket.ads)
17798 @section @code{GNAT.Sockets} (@file{g-socket.ads})
17799 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
17800 @cindex Sockets
17801
17802 @noindent
17803 A high level and portable interface to develop sockets based applications.
17804 This package is based on the sockets thin binding found in
17805 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
17806 on all native GNAT ports except for OpenVMS@.  It is not implemented
17807 for the LynxOS@ cross port.
17808
17809 @node GNAT.Source_Info (g-souinf.ads)
17810 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
17811 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
17812 @cindex Source Information
17813
17814 @noindent
17815 Provides subprograms that give access to source code information known at
17816 compile time, such as the current file name and line number.
17817
17818 @node GNAT.Spelling_Checker (g-speche.ads)
17819 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17820 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
17821 @cindex Spell checking
17822
17823 @noindent
17824 Provides a function for determining whether one string is a plausible
17825 near misspelling of another string.
17826
17827 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
17828 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17829 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
17830 @cindex Spell checking
17831
17832 @noindent
17833 Provides a generic function that can be instantiated with a string type for
17834 determining whether one string is a plausible near misspelling of another
17835 string.
17836
17837 @node GNAT.Spitbol.Patterns (g-spipat.ads)
17838 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17839 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
17840 @cindex SPITBOL pattern matching
17841 @cindex Pattern matching
17842
17843 @noindent
17844 A complete implementation of SNOBOL4 style pattern matching.  This is the
17845 most elaborate of the pattern matching packages provided.  It fully duplicates
17846 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
17847 efficient algorithm developed by Robert Dewar for the SPITBOL system.
17848
17849 @node GNAT.Spitbol (g-spitbo.ads)
17850 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17851 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
17852 @cindex SPITBOL interface
17853
17854 @noindent
17855 The top level package of the collection of SPITBOL-style functionality, this
17856 package provides basic SNOBOL4 string manipulation functions, such as
17857 Pad, Reverse, Trim, Substr capability, as well as a generic table function
17858 useful for constructing arbitrary mappings from strings in the style of
17859 the SNOBOL4 TABLE function.
17860
17861 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
17862 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17863 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
17864 @cindex Sets of strings
17865 @cindex SPITBOL Tables
17866
17867 @noindent
17868 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17869 for type @code{Standard.Boolean}, giving an implementation of sets of
17870 string values.
17871
17872 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
17873 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17874 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
17875 @cindex Integer maps
17876 @cindex Maps
17877 @cindex SPITBOL Tables
17878
17879 @noindent
17880 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
17881 for type @code{Standard.Integer}, giving an implementation of maps
17882 from string to integer values.
17883
17884 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
17885 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17886 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
17887 @cindex String maps
17888 @cindex Maps
17889 @cindex SPITBOL Tables
17890
17891 @noindent
17892 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
17893 a variable length string type, giving an implementation of general
17894 maps from strings to strings.
17895
17896 @node GNAT.SSE (g-sse.ads)
17897 @section @code{GNAT.SSE} (@file{g-sse.ads})
17898 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
17899
17900 @noindent
17901 Root of a set of units aimed at offering Ada bindings to a subset of
17902 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
17903 targets.  It exposes vector component types together with a general
17904 introduction to the binding contents and use.
17905
17906 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
17907 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17908 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
17909
17910 @noindent
17911 SSE vector types for use with SSE related intrinsics.
17912
17913 @node GNAT.Strings (g-string.ads)
17914 @section @code{GNAT.Strings} (@file{g-string.ads})
17915 @cindex @code{GNAT.Strings} (@file{g-string.ads})
17916
17917 @noindent
17918 Common String access types and related subprograms. Basically it
17919 defines a string access and an array of string access types.
17920
17921 @node GNAT.String_Split (g-strspl.ads)
17922 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
17923 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
17924 @cindex String splitter
17925
17926 @noindent
17927 Useful string manipulation routines: given a set of separators, split
17928 a string wherever the separators appear, and provide direct access
17929 to the resulting slices. This package is instantiated from
17930 @code{GNAT.Array_Split}.
17931
17932 @node GNAT.Table (g-table.ads)
17933 @section @code{GNAT.Table} (@file{g-table.ads})
17934 @cindex @code{GNAT.Table} (@file{g-table.ads})
17935 @cindex Table implementation
17936 @cindex Arrays, extendable
17937
17938 @noindent
17939 A generic package providing a single dimension array abstraction where the
17940 length of the array can be dynamically modified.
17941
17942 @noindent
17943 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
17944 except that this package declares a single instance of the table type,
17945 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
17946 used to define dynamic instances of the table.
17947
17948 @node GNAT.Task_Lock (g-tasloc.ads)
17949 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17950 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
17951 @cindex Task synchronization
17952 @cindex Task locking
17953 @cindex Locking
17954
17955 @noindent
17956 A very simple facility for locking and unlocking sections of code using a
17957 single global task lock.  Appropriate for use in situations where contention
17958 between tasks is very rarely expected.
17959
17960 @node GNAT.Time_Stamp (g-timsta.ads)
17961 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17962 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
17963 @cindex Time stamp
17964 @cindex Current time
17965
17966 @noindent
17967 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
17968 represents the current date and time in ISO 8601 format. This is a very simple
17969 routine with minimal code and there are no dependencies on any other unit.
17970
17971 @node GNAT.Threads (g-thread.ads)
17972 @section @code{GNAT.Threads} (@file{g-thread.ads})
17973 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
17974 @cindex Foreign threads
17975 @cindex Threads, foreign
17976
17977 @noindent
17978 Provides facilities for dealing with foreign threads which need to be known
17979 by the GNAT run-time system. Consult the documentation of this package for
17980 further details if your program has threads that are created by a non-Ada
17981 environment which then accesses Ada code.
17982
17983 @node GNAT.Traceback (g-traceb.ads)
17984 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
17985 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
17986 @cindex Trace back facilities
17987
17988 @noindent
17989 Provides a facility for obtaining non-symbolic traceback information, useful
17990 in various debugging situations.
17991
17992 @node GNAT.Traceback.Symbolic (g-trasym.ads)
17993 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17994 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
17995 @cindex Trace back facilities
17996
17997 @node GNAT.UTF_32 (g-utf_32.ads)
17998 @section @code{GNAT.UTF_32} (@file{g-table.ads})
17999 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
18000 @cindex Wide character codes
18001
18002 @noindent
18003 This is a package intended to be used in conjunction with the
18004 @code{Wide_Character} type in Ada 95 and the
18005 @code{Wide_Wide_Character} type in Ada 2005 (available
18006 in @code{GNAT} in Ada 2005 mode). This package contains
18007 Unicode categorization routines, as well as lexical
18008 categorization routines corresponding to the Ada 2005
18009 lexical rules for identifiers and strings, and also a
18010 lower case to upper case fold routine corresponding to
18011 the Ada 2005 rules for identifier equivalence.
18012
18013 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
18014 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18015 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
18016 @cindex Spell checking
18017
18018 @noindent
18019 Provides a function for determining whether one wide wide string is a plausible
18020 near misspelling of another wide wide string, where the strings are represented
18021 using the UTF_32_String type defined in System.Wch_Cnv.
18022
18023 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
18024 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18025 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
18026 @cindex Spell checking
18027
18028 @noindent
18029 Provides a function for determining whether one wide string is a plausible
18030 near misspelling of another wide string.
18031
18032 @node GNAT.Wide_String_Split (g-wistsp.ads)
18033 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18034 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
18035 @cindex Wide_String splitter
18036
18037 @noindent
18038 Useful wide string manipulation routines: given a set of separators, split
18039 a wide string wherever the separators appear, and provide direct access
18040 to the resulting slices. This package is instantiated from
18041 @code{GNAT.Array_Split}.
18042
18043 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
18044 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18045 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
18046 @cindex Spell checking
18047
18048 @noindent
18049 Provides a function for determining whether one wide wide string is a plausible
18050 near misspelling of another wide wide string.
18051
18052 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
18053 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18054 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
18055 @cindex Wide_Wide_String splitter
18056
18057 @noindent
18058 Useful wide wide string manipulation routines: given a set of separators, split
18059 a wide wide string wherever the separators appear, and provide direct access
18060 to the resulting slices. This package is instantiated from
18061 @code{GNAT.Array_Split}.
18062
18063 @node Interfaces.C.Extensions (i-cexten.ads)
18064 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18065 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
18066
18067 @noindent
18068 This package contains additional C-related definitions, intended
18069 for use with either manually or automatically generated bindings
18070 to C libraries.
18071
18072 @node Interfaces.C.Streams (i-cstrea.ads)
18073 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18074 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
18075 @cindex  C streams, interfacing
18076
18077 @noindent
18078 This package is a binding for the most commonly used operations
18079 on C streams.
18080
18081 @node Interfaces.CPP (i-cpp.ads)
18082 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
18083 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
18084 @cindex  C++ interfacing
18085 @cindex  Interfacing, to C++
18086
18087 @noindent
18088 This package provides facilities for use in interfacing to C++.  It
18089 is primarily intended to be used in connection with automated tools
18090 for the generation of C++ interfaces.
18091
18092 @node Interfaces.Packed_Decimal (i-pacdec.ads)
18093 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18094 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
18095 @cindex  IBM Packed Format
18096 @cindex  Packed Decimal
18097
18098 @noindent
18099 This package provides a set of routines for conversions to and
18100 from a packed decimal format compatible with that used on IBM
18101 mainframes.
18102
18103 @node Interfaces.VxWorks (i-vxwork.ads)
18104 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18105 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
18106 @cindex Interfacing to VxWorks
18107 @cindex VxWorks, interfacing
18108
18109 @noindent
18110 This package provides a limited binding to the VxWorks API.
18111 In particular, it interfaces with the
18112 VxWorks hardware interrupt facilities.
18113
18114 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
18115 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18116 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
18117 @cindex Interfacing to VxWorks' I/O
18118 @cindex VxWorks, I/O interfacing
18119 @cindex VxWorks, Get_Immediate
18120 @cindex Get_Immediate, VxWorks
18121
18122 @noindent
18123 This package provides a binding to the ioctl (IO/Control)
18124 function of VxWorks, defining a set of option values and
18125 function codes. A particular use of this package is
18126 to enable the use of Get_Immediate under VxWorks.
18127
18128 @node System.Address_Image (s-addima.ads)
18129 @section @code{System.Address_Image} (@file{s-addima.ads})
18130 @cindex @code{System.Address_Image} (@file{s-addima.ads})
18131 @cindex Address image
18132 @cindex Image, of an address
18133
18134 @noindent
18135 This function provides a useful debugging
18136 function that gives an (implementation dependent)
18137 string which identifies an address.
18138
18139 @node System.Assertions (s-assert.ads)
18140 @section @code{System.Assertions} (@file{s-assert.ads})
18141 @cindex @code{System.Assertions} (@file{s-assert.ads})
18142 @cindex Assertions
18143 @cindex Assert_Failure, exception
18144
18145 @noindent
18146 This package provides the declaration of the exception raised
18147 by an run-time assertion failure, as well as the routine that
18148 is used internally to raise this assertion.
18149
18150 @node System.Memory (s-memory.ads)
18151 @section @code{System.Memory} (@file{s-memory.ads})
18152 @cindex @code{System.Memory} (@file{s-memory.ads})
18153 @cindex Memory allocation
18154
18155 @noindent
18156 This package provides the interface to the low level routines used
18157 by the generated code for allocation and freeing storage for the
18158 default storage pool (analogous to the C routines malloc and free.
18159 It also provides a reallocation interface analogous to the C routine
18160 realloc. The body of this unit may be modified to provide alternative
18161 allocation mechanisms for the default pool, and in addition, direct
18162 calls to this unit may be made for low level allocation uses (for
18163 example see the body of @code{GNAT.Tables}).
18164
18165 @node System.Multiprocessors (s-multip.ads)
18166 @section @code{System.Multiprocessors} (@file{s-multip.ads})
18167 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
18168 @cindex Multiprocessor interface
18169 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18170 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18171 technically an implementation-defined addition).
18172
18173 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
18174 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18175 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
18176 @cindex Multiprocessor interface
18177 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
18178 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
18179 technically an implementation-defined addition).
18180
18181 @node System.Partition_Interface (s-parint.ads)
18182 @section @code{System.Partition_Interface} (@file{s-parint.ads})
18183 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
18184 @cindex Partition interfacing functions
18185
18186 @noindent
18187 This package provides facilities for partition interfacing.  It
18188 is used primarily in a distribution context when using Annex E
18189 with @code{GLADE}.
18190
18191 @node System.Pool_Global (s-pooglo.ads)
18192 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
18193 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
18194 @cindex Storage pool, global
18195 @cindex Global storage pool
18196
18197 @noindent
18198 This package provides a storage pool that is equivalent to the default
18199 storage pool used for access types for which no pool is specifically
18200 declared. It uses malloc/free to allocate/free and does not attempt to
18201 do any automatic reclamation.
18202
18203 @node System.Pool_Local (s-pooloc.ads)
18204 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
18205 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
18206 @cindex Storage pool, local
18207 @cindex Local storage pool
18208
18209 @noindent
18210 This package provides a storage pool that is intended for use with locally
18211 defined access types. It uses malloc/free for allocate/free, and maintains
18212 a list of allocated blocks, so that all storage allocated for the pool can
18213 be freed automatically when the pool is finalized.
18214
18215 @node System.Restrictions (s-restri.ads)
18216 @section @code{System.Restrictions} (@file{s-restri.ads})
18217 @cindex @code{System.Restrictions} (@file{s-restri.ads})
18218 @cindex Run-time restrictions access
18219
18220 @noindent
18221 This package provides facilities for accessing at run time
18222 the status of restrictions specified at compile time for
18223 the partition. Information is available both with regard
18224 to actual restrictions specified, and with regard to
18225 compiler determined information on which restrictions
18226 are violated by one or more packages in the partition.
18227
18228 @node System.Rident (s-rident.ads)
18229 @section @code{System.Rident} (@file{s-rident.ads})
18230 @cindex @code{System.Rident} (@file{s-rident.ads})
18231 @cindex Restrictions definitions
18232
18233 @noindent
18234 This package provides definitions of the restrictions
18235 identifiers supported by GNAT, and also the format of
18236 the restrictions provided in package System.Restrictions.
18237 It is not normally necessary to @code{with} this generic package
18238 since the necessary instantiation is included in
18239 package System.Restrictions.
18240
18241 @node System.Strings.Stream_Ops (s-ststop.ads)
18242 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18243 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
18244 @cindex Stream operations
18245 @cindex String stream operations
18246
18247 @noindent
18248 This package provides a set of stream subprograms for standard string types.
18249 It is intended primarily to support implicit use of such subprograms when
18250 stream attributes are applied to string types, but the subprograms in this
18251 package can be used directly by application programs.
18252
18253 @node System.Task_Info (s-tasinf.ads)
18254 @section @code{System.Task_Info} (@file{s-tasinf.ads})
18255 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
18256 @cindex Task_Info pragma
18257
18258 @noindent
18259 This package provides target dependent functionality that is used
18260 to support the @code{Task_Info} pragma
18261
18262 @node System.Wch_Cnv (s-wchcnv.ads)
18263 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18264 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
18265 @cindex Wide Character, Representation
18266 @cindex Wide String, Conversion
18267 @cindex Representation of wide characters
18268
18269 @noindent
18270 This package provides routines for converting between
18271 wide and wide wide characters and a representation as a value of type
18272 @code{Standard.String}, using a specified wide character
18273 encoding method.  It uses definitions in
18274 package @code{System.Wch_Con}.
18275
18276 @node System.Wch_Con (s-wchcon.ads)
18277 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
18278 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
18279
18280 @noindent
18281 This package provides definitions and descriptions of
18282 the various methods used for encoding wide characters
18283 in ordinary strings.  These definitions are used by
18284 the package @code{System.Wch_Cnv}.
18285
18286 @node Interfacing to Other Languages
18287 @chapter Interfacing to Other Languages
18288 @noindent
18289 The facilities in annex B of the Ada Reference Manual are fully
18290 implemented in GNAT, and in addition, a full interface to C++ is
18291 provided.
18292
18293 @menu
18294 * Interfacing to C::
18295 * Interfacing to C++::
18296 * Interfacing to COBOL::
18297 * Interfacing to Fortran::
18298 * Interfacing to non-GNAT Ada code::
18299 @end menu
18300
18301 @node Interfacing to C
18302 @section Interfacing to C
18303
18304 @noindent
18305 Interfacing to C with GNAT can use one of two approaches:
18306
18307 @itemize @bullet
18308 @item
18309 The types in the package @code{Interfaces.C} may be used.
18310 @item
18311 Standard Ada types may be used directly.  This may be less portable to
18312 other compilers, but will work on all GNAT compilers, which guarantee
18313 correspondence between the C and Ada types.
18314 @end itemize
18315
18316 @noindent
18317 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
18318 effect, since this is the default.  The following table shows the
18319 correspondence between Ada scalar types and the corresponding C types.
18320
18321 @table @code
18322 @item Integer
18323 @code{int}
18324 @item Short_Integer
18325 @code{short}
18326 @item Short_Short_Integer
18327 @code{signed char}
18328 @item Long_Integer
18329 @code{long}
18330 @item Long_Long_Integer
18331 @code{long long}
18332 @item Short_Float
18333 @code{float}
18334 @item Float
18335 @code{float}
18336 @item Long_Float
18337 @code{double}
18338 @item Long_Long_Float
18339 This is the longest floating-point type supported by the hardware.
18340 @end table
18341
18342 @noindent
18343 Additionally, there are the following general correspondences between Ada
18344 and C types:
18345 @itemize @bullet
18346 @item
18347 Ada enumeration types map to C enumeration types directly if pragma
18348 @code{Convention C} is specified, which causes them to have int
18349 length.  Without pragma @code{Convention C}, Ada enumeration types map to
18350 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
18351 @code{int}, respectively) depending on the number of values passed.
18352 This is the only case in which pragma @code{Convention C} affects the
18353 representation of an Ada type.
18354
18355 @item
18356 Ada access types map to C pointers, except for the case of pointers to
18357 unconstrained types in Ada, which have no direct C equivalent.
18358
18359 @item
18360 Ada arrays map directly to C arrays.
18361
18362 @item
18363 Ada records map directly to C structures.
18364
18365 @item
18366 Packed Ada records map to C structures where all members are bit fields
18367 of the length corresponding to the @code{@var{type}'Size} value in Ada.
18368 @end itemize
18369
18370 @node Interfacing to C++
18371 @section Interfacing to C++
18372
18373 @noindent
18374 The interface to C++ makes use of the following pragmas, which are
18375 primarily intended to be constructed automatically using a binding generator
18376 tool, although it is possible to construct them by hand.
18377
18378 Using these pragmas it is possible to achieve complete
18379 inter-operability between Ada tagged types and C++ class definitions.
18380 See @ref{Implementation Defined Pragmas}, for more details.
18381
18382 @table @code
18383 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
18384 The argument denotes an entity in the current declarative region that is
18385 declared as a tagged or untagged record type. It indicates that the type
18386 corresponds to an externally declared C++ class type, and is to be laid
18387 out the same way that C++ would lay out the type.
18388
18389 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
18390 for backward compatibility but its functionality is available
18391 using pragma @code{Import} with @code{Convention} = @code{CPP}.
18392
18393 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
18394 This pragma identifies an imported function (imported in the usual way
18395 with pragma @code{Import}) as corresponding to a C++ constructor.
18396 @end table
18397
18398 A few restrictions are placed on the use of the @code{Access} attribute
18399 in conjunction with subprograms subject to convention @code{CPP}: the
18400 attribute may be used neither on primitive operations of a tagged
18401 record type with convention @code{CPP}, imported or not, nor on
18402 subprograms imported with pragma @code{CPP_Constructor}.
18403
18404 In addition, C++ exceptions are propagated and can be handled in an
18405 @code{others} choice of an exception handler. The corresponding Ada
18406 occurrence has no message, and the simple name of the exception identity
18407 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
18408 tasks works properly when such foreign exceptions are propagated.
18409
18410 @node Interfacing to COBOL
18411 @section Interfacing to COBOL
18412
18413 @noindent
18414 Interfacing to COBOL is achieved as described in section B.4 of
18415 the Ada Reference Manual.
18416
18417 @node Interfacing to Fortran
18418 @section Interfacing to Fortran
18419
18420 @noindent
18421 Interfacing to Fortran is achieved as described in section B.5 of the
18422 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
18423 multi-dimensional array causes the array to be stored in column-major
18424 order as required for convenient interface to Fortran.
18425
18426 @node Interfacing to non-GNAT Ada code
18427 @section Interfacing to non-GNAT Ada code
18428
18429 It is possible to specify the convention @code{Ada} in a pragma
18430 @code{Import} or pragma @code{Export}.  However this refers to
18431 the calling conventions used by GNAT, which may or may not be
18432 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
18433 compiler to allow interoperation.
18434
18435 If arguments types are kept simple, and if the foreign compiler generally
18436 follows system calling conventions, then it may be possible to integrate
18437 files compiled by other Ada compilers, provided that the elaboration
18438 issues are adequately addressed (for example by eliminating the
18439 need for any load time elaboration).
18440
18441 In particular, GNAT running on VMS is designed to
18442 be highly compatible with the DEC Ada 83 compiler, so this is one
18443 case in which it is possible to import foreign units of this type,
18444 provided that the data items passed are restricted to simple scalar
18445 values or simple record types without variants, or simple array
18446 types with fixed bounds.
18447
18448 @node Specialized Needs Annexes
18449 @chapter Specialized Needs Annexes
18450
18451 @noindent
18452 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
18453 required in all implementations.  However, as described in this chapter,
18454 GNAT implements all of these annexes:
18455
18456 @table @asis
18457 @item Systems Programming (Annex C)
18458 The Systems Programming Annex is fully implemented.
18459
18460 @item Real-Time Systems (Annex D)
18461 The Real-Time Systems Annex is fully implemented.
18462
18463 @item Distributed Systems (Annex E)
18464 Stub generation is fully implemented in the GNAT compiler.  In addition,
18465 a complete compatible PCS is available as part of the GLADE system,
18466 a separate product.  When the two
18467 products are used in conjunction, this annex is fully implemented.
18468
18469 @item Information Systems (Annex F)
18470 The Information Systems annex is fully implemented.
18471
18472 @item Numerics (Annex G)
18473 The Numerics Annex is fully implemented.
18474
18475 @item Safety and Security / High-Integrity Systems (Annex H)
18476 The Safety and Security Annex (termed the High-Integrity Systems Annex
18477 in Ada 2005) is fully implemented.
18478 @end table
18479
18480 @node Implementation of Specific Ada Features
18481 @chapter Implementation of Specific Ada Features
18482
18483 @noindent
18484 This chapter describes the GNAT implementation of several Ada language
18485 facilities.
18486
18487 @menu
18488 * Machine Code Insertions::
18489 * GNAT Implementation of Tasking::
18490 * GNAT Implementation of Shared Passive Packages::
18491 * Code Generation for Array Aggregates::
18492 * The Size of Discriminated Records with Default Discriminants::
18493 * Strict Conformance to the Ada Reference Manual::
18494 @end menu
18495
18496 @node Machine Code Insertions
18497 @section Machine Code Insertions
18498 @cindex Machine Code insertions
18499
18500 @noindent
18501 Package @code{Machine_Code} provides machine code support as described
18502 in the Ada Reference Manual in two separate forms:
18503 @itemize @bullet
18504 @item
18505 Machine code statements, consisting of qualified expressions that
18506 fit the requirements of RM section 13.8.
18507 @item
18508 An intrinsic callable procedure, providing an alternative mechanism of
18509 including machine instructions in a subprogram.
18510 @end itemize
18511
18512 @noindent
18513 The two features are similar, and both are closely related to the mechanism
18514 provided by the asm instruction in the GNU C compiler.  Full understanding
18515 and use of the facilities in this package requires understanding the asm
18516 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
18517 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
18518
18519 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
18520 semantic restrictions and effects as described below.  Both are provided so
18521 that the procedure call can be used as a statement, and the function call
18522 can be used to form a code_statement.
18523
18524 The first example given in the GCC documentation is the C @code{asm}
18525 instruction:
18526 @smallexample
18527    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
18528 @end smallexample
18529
18530 @noindent
18531 The equivalent can be written for GNAT as:
18532
18533 @smallexample @c ada
18534 Asm ("fsinx %1 %0",
18535      My_Float'Asm_Output ("=f", result),
18536      My_Float'Asm_Input  ("f",  angle));
18537 @end smallexample
18538
18539 @noindent
18540 The first argument to @code{Asm} is the assembler template, and is
18541 identical to what is used in GNU C@.  This string must be a static
18542 expression.  The second argument is the output operand list.  It is
18543 either a single @code{Asm_Output} attribute reference, or a list of such
18544 references enclosed in parentheses (technically an array aggregate of
18545 such references).
18546
18547 The @code{Asm_Output} attribute denotes a function that takes two
18548 parameters.  The first is a string, the second is the name of a variable
18549 of the type designated by the attribute prefix.  The first (string)
18550 argument is required to be a static expression and designates the
18551 constraint for the parameter (e.g.@: what kind of register is
18552 required).  The second argument is the variable to be updated with the
18553 result.  The possible values for constraint are the same as those used in
18554 the RTL, and are dependent on the configuration file used to build the
18555 GCC back end.  If there are no output operands, then this argument may
18556 either be omitted, or explicitly given as @code{No_Output_Operands}.
18557
18558 The second argument of @code{@var{my_float}'Asm_Output} functions as
18559 though it were an @code{out} parameter, which is a little curious, but
18560 all names have the form of expressions, so there is no syntactic
18561 irregularity, even though normally functions would not be permitted
18562 @code{out} parameters.  The third argument is the list of input
18563 operands.  It is either a single @code{Asm_Input} attribute reference, or
18564 a list of such references enclosed in parentheses (technically an array
18565 aggregate of such references).
18566
18567 The @code{Asm_Input} attribute denotes a function that takes two
18568 parameters.  The first is a string, the second is an expression of the
18569 type designated by the prefix.  The first (string) argument is required
18570 to be a static expression, and is the constraint for the parameter,
18571 (e.g.@: what kind of register is required).  The second argument is the
18572 value to be used as the input argument.  The possible values for the
18573 constant are the same as those used in the RTL, and are dependent on
18574 the configuration file used to built the GCC back end.
18575
18576 If there are no input operands, this argument may either be omitted, or
18577 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
18578 present in the above example, is a list of register names, called the
18579 @dfn{clobber} argument.  This argument, if given, must be a static string
18580 expression, and is a space or comma separated list of names of registers
18581 that must be considered destroyed as a result of the @code{Asm} call.  If
18582 this argument is the null string (the default value), then the code
18583 generator assumes that no additional registers are destroyed.
18584
18585 The fifth argument, not present in the above example, called the
18586 @dfn{volatile} argument, is by default @code{False}.  It can be set to
18587 the literal value @code{True} to indicate to the code generator that all
18588 optimizations with respect to the instruction specified should be
18589 suppressed, and that in particular, for an instruction that has outputs,
18590 the instruction will still be generated, even if none of the outputs are
18591 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
18592 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
18593 Generally it is strongly advisable to use Volatile for any ASM statement
18594 that is missing either input or output operands, or when two or more ASM
18595 statements appear in sequence, to avoid unwanted optimizations. A warning
18596 is generated if this advice is not followed.
18597
18598 The @code{Asm} subprograms may be used in two ways.  First the procedure
18599 forms can be used anywhere a procedure call would be valid, and
18600 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
18601 be used to intersperse machine instructions with other Ada statements.
18602 Second, the function forms, which return a dummy value of the limited
18603 private type @code{Asm_Insn}, can be used in code statements, and indeed
18604 this is the only context where such calls are allowed.  Code statements
18605 appear as aggregates of the form:
18606
18607 @smallexample @c ada
18608 Asm_Insn'(Asm (@dots{}));
18609 Asm_Insn'(Asm_Volatile (@dots{}));
18610 @end smallexample
18611
18612 @noindent
18613 In accordance with RM rules, such code statements are allowed only
18614 within subprograms whose entire body consists of such statements.  It is
18615 not permissible to intermix such statements with other Ada statements.
18616
18617 Typically the form using intrinsic procedure calls is more convenient
18618 and more flexible.  The code statement form is provided to meet the RM
18619 suggestion that such a facility should be made available.  The following
18620 is the exact syntax of the call to @code{Asm}. As usual, if named notation
18621 is used, the arguments may be given in arbitrary order, following the
18622 normal rules for use of positional and named arguments)
18623
18624 @smallexample
18625 ASM_CALL ::= Asm (
18626                  [Template =>] static_string_EXPRESSION
18627                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
18628                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
18629                [,[Clobber  =>] static_string_EXPRESSION ]
18630                [,[Volatile =>] static_boolean_EXPRESSION] )
18631
18632 OUTPUT_OPERAND_LIST ::=
18633   [PREFIX.]No_Output_Operands
18634 | OUTPUT_OPERAND_ATTRIBUTE
18635 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
18636
18637 OUTPUT_OPERAND_ATTRIBUTE ::=
18638   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
18639
18640 INPUT_OPERAND_LIST ::=
18641   [PREFIX.]No_Input_Operands
18642 | INPUT_OPERAND_ATTRIBUTE
18643 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
18644
18645 INPUT_OPERAND_ATTRIBUTE ::=
18646   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
18647 @end smallexample
18648
18649 @noindent
18650 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
18651 are declared in the package @code{Machine_Code} and must be referenced
18652 according to normal visibility rules. In particular if there is no
18653 @code{use} clause for this package, then appropriate package name
18654 qualification is required.
18655
18656 @node GNAT Implementation of Tasking
18657 @section GNAT Implementation of Tasking
18658
18659 @noindent
18660 This chapter outlines the basic GNAT approach to tasking (in particular,
18661 a multi-layered library for portability) and discusses issues related
18662 to compliance with the Real-Time Systems Annex.
18663
18664 @menu
18665 * Mapping Ada Tasks onto the Underlying Kernel Threads::
18666 * Ensuring Compliance with the Real-Time Annex::
18667 @end menu
18668
18669 @node Mapping Ada Tasks onto the Underlying Kernel Threads
18670 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
18671
18672 @noindent
18673 GNAT's run-time support comprises two layers:
18674
18675 @itemize @bullet
18676 @item GNARL (GNAT Run-time Layer)
18677 @item GNULL (GNAT Low-level Library)
18678 @end itemize
18679
18680 @noindent
18681 In GNAT, Ada's tasking services rely on a platform and OS independent
18682 layer known as GNARL@.  This code is responsible for implementing the
18683 correct semantics of Ada's task creation, rendezvous, protected
18684 operations etc.
18685
18686 GNARL decomposes Ada's tasking semantics into simpler lower level
18687 operations such as create a thread, set the priority of a thread,
18688 yield, create a lock, lock/unlock, etc.  The spec for these low-level
18689 operations constitutes GNULLI, the GNULL Interface.  This interface is
18690 directly inspired from the POSIX real-time API@.
18691
18692 If the underlying executive or OS implements the POSIX standard
18693 faithfully, the GNULL Interface maps as is to the services offered by
18694 the underlying kernel.  Otherwise, some target dependent glue code maps
18695 the services offered by the underlying kernel to the semantics expected
18696 by GNARL@.
18697
18698 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
18699 key point is that each Ada task is mapped on a thread in the underlying
18700 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
18701
18702 In addition Ada task priorities map onto the underlying thread priorities.
18703 Mapping Ada tasks onto the underlying kernel threads has several advantages:
18704
18705 @itemize @bullet
18706 @item
18707 The underlying scheduler is used to schedule the Ada tasks.  This
18708 makes Ada tasks as efficient as kernel threads from a scheduling
18709 standpoint.
18710
18711 @item
18712 Interaction with code written in C containing threads is eased
18713 since at the lowest level Ada tasks and C threads map onto the same
18714 underlying kernel concept.
18715
18716 @item
18717 When an Ada task is blocked during I/O the remaining Ada tasks are
18718 able to proceed.
18719
18720 @item
18721 On multiprocessor systems Ada tasks can execute in parallel.
18722 @end itemize
18723
18724 @noindent
18725 Some threads libraries offer a mechanism to fork a new process, with the
18726 child process duplicating the threads from the parent.
18727 GNAT does not
18728 support this functionality when the parent contains more than one task.
18729 @cindex Forking a new process
18730
18731 @node Ensuring Compliance with the Real-Time Annex
18732 @subsection Ensuring Compliance with the Real-Time Annex
18733 @cindex Real-Time Systems Annex compliance
18734
18735 @noindent
18736 Although mapping Ada tasks onto
18737 the underlying threads has significant advantages, it does create some
18738 complications when it comes to respecting the scheduling semantics
18739 specified in the real-time annex (Annex D).
18740
18741 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
18742 scheduling policy states:
18743
18744 @quotation
18745 @emph{When the active priority of a ready task that is not running
18746 changes, or the setting of its base priority takes effect, the
18747 task is removed from the ready queue for its old active priority
18748 and is added at the tail of the ready queue for its new active
18749 priority, except in the case where the active priority is lowered
18750 due to the loss of inherited priority, in which case the task is
18751 added at the head of the ready queue for its new active priority.}
18752 @end quotation
18753
18754 @noindent
18755 While most kernels do put tasks at the end of the priority queue when
18756 a task changes its priority, (which respects the main
18757 FIFO_Within_Priorities requirement), almost none keep a thread at the
18758 beginning of its priority queue when its priority drops from the loss
18759 of inherited priority.
18760
18761 As a result most vendors have provided incomplete Annex D implementations.
18762
18763 The GNAT run-time, has a nice cooperative solution to this problem
18764 which ensures that accurate FIFO_Within_Priorities semantics are
18765 respected.
18766
18767 The principle is as follows.  When an Ada task T is about to start
18768 running, it checks whether some other Ada task R with the same
18769 priority as T has been suspended due to the loss of priority
18770 inheritance.  If this is the case, T yields and is placed at the end of
18771 its priority queue.  When R arrives at the front of the queue it
18772 executes.
18773
18774 Note that this simple scheme preserves the relative order of the tasks
18775 that were ready to execute in the priority queue where R has been
18776 placed at the end.
18777
18778 @node GNAT Implementation of Shared Passive Packages
18779 @section GNAT Implementation of Shared Passive Packages
18780 @cindex Shared passive packages
18781
18782 @noindent
18783 GNAT fully implements the pragma @code{Shared_Passive} for
18784 @cindex pragma @code{Shared_Passive}
18785 the purpose of designating shared passive packages.
18786 This allows the use of passive partitions in the
18787 context described in the Ada Reference Manual; i.e., for communication
18788 between separate partitions of a distributed application using the
18789 features in Annex E.
18790 @cindex Annex E
18791 @cindex Distribution Systems Annex
18792
18793 However, the implementation approach used by GNAT provides for more
18794 extensive usage as follows:
18795
18796 @table @emph
18797 @item Communication between separate programs
18798
18799 This allows separate programs to access the data in passive
18800 partitions, using protected objects for synchronization where
18801 needed. The only requirement is that the two programs have a
18802 common shared file system. It is even possible for programs
18803 running on different machines with different architectures
18804 (e.g.@: different endianness) to communicate via the data in
18805 a passive partition.
18806
18807 @item Persistence between program runs
18808
18809 The data in a passive package can persist from one run of a
18810 program to another, so that a later program sees the final
18811 values stored by a previous run of the same program.
18812
18813 @end table
18814
18815 @noindent
18816 The implementation approach used is to store the data in files. A
18817 separate stream file is created for each object in the package, and
18818 an access to an object causes the corresponding file to be read or
18819 written.
18820
18821 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
18822 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
18823 set to the directory to be used for these files.
18824 The files in this directory
18825 have names that correspond to their fully qualified names. For
18826 example, if we have the package
18827
18828 @smallexample @c ada
18829 package X is
18830   pragma Shared_Passive (X);
18831   Y : Integer;
18832   Z : Float;
18833 end X;
18834 @end smallexample
18835
18836 @noindent
18837 and the environment variable is set to @code{/stemp/}, then the files created
18838 will have the names:
18839
18840 @smallexample
18841 /stemp/x.y
18842 /stemp/x.z
18843 @end smallexample
18844
18845 @noindent
18846 These files are created when a value is initially written to the object, and
18847 the files are retained until manually deleted. This provides the persistence
18848 semantics. If no file exists, it means that no partition has assigned a value
18849 to the variable; in this case the initial value declared in the package
18850 will be used. This model ensures that there are no issues in synchronizing
18851 the elaboration process, since elaboration of passive packages elaborates the
18852 initial values, but does not create the files.
18853
18854 The files are written using normal @code{Stream_IO} access.
18855 If you want to be able
18856 to communicate between programs or partitions running on different
18857 architectures, then you should use the XDR versions of the stream attribute
18858 routines, since these are architecture independent.
18859
18860 If active synchronization is required for access to the variables in the
18861 shared passive package, then as described in the Ada Reference Manual, the
18862 package may contain protected objects used for this purpose. In this case
18863 a lock file (whose name is @file{___lock} (three underscores)
18864 is created in the shared memory directory.
18865 @cindex @file{___lock} file (for shared passive packages)
18866 This is used to provide the required locking
18867 semantics for proper protected object synchronization.
18868
18869 As of January 2003, GNAT supports shared passive packages on all platforms
18870 except for OpenVMS.
18871
18872 @node Code Generation for Array Aggregates
18873 @section Code Generation for Array Aggregates
18874
18875 @menu
18876 * Static constant aggregates with static bounds::
18877 * Constant aggregates with unconstrained nominal types::
18878 * Aggregates with static bounds::
18879 * Aggregates with non-static bounds::
18880 * Aggregates in assignment statements::
18881 @end menu
18882
18883 @noindent
18884 Aggregates have a rich syntax and allow the user to specify the values of
18885 complex data structures by means of a single construct.  As a result, the
18886 code generated for aggregates can be quite complex and involve loops, case
18887 statements and multiple assignments.  In the simplest cases, however, the
18888 compiler will recognize aggregates whose components and constraints are
18889 fully static, and in those cases the compiler will generate little or no
18890 executable code.  The following is an outline of the code that GNAT generates
18891 for various aggregate constructs.  For further details, you will find it
18892 useful to examine the output produced by the -gnatG flag to see the expanded
18893 source that is input to the code generator.  You may also want to examine
18894 the assembly code generated at various levels of optimization.
18895
18896 The code generated for aggregates depends on the context, the component values,
18897 and the type.  In the context of an object declaration the code generated is
18898 generally simpler than in the case of an assignment.  As a general rule, static
18899 component values and static subtypes also lead to simpler code.
18900
18901 @node Static constant aggregates with static bounds
18902 @subsection Static constant aggregates with static bounds
18903
18904 @noindent
18905 For the declarations:
18906 @smallexample @c ada
18907     type One_Dim is array (1..10) of integer;
18908     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
18909 @end smallexample
18910
18911 @noindent
18912 GNAT generates no executable code: the constant ar0 is placed in static memory.
18913 The same is true for constant aggregates with named associations:
18914
18915 @smallexample @c ada
18916     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
18917     Cr3 : constant One_Dim := (others => 7777);
18918 @end smallexample
18919
18920 @noindent
18921 The same is true for multidimensional constant arrays such as:
18922
18923 @smallexample @c ada
18924     type two_dim is array (1..3, 1..3) of integer;
18925     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
18926 @end smallexample
18927
18928 @noindent
18929 The same is true for arrays of one-dimensional arrays: the following are
18930 static:
18931
18932 @smallexample @c ada
18933 type ar1b  is array (1..3) of boolean;
18934 type ar_ar is array (1..3) of ar1b;
18935 None  : constant ar1b := (others => false);     --  fully static
18936 None2 : constant ar_ar := (1..3 => None);       --  fully static
18937 @end smallexample
18938
18939 @noindent
18940 However, for multidimensional aggregates with named associations, GNAT will
18941 generate assignments and loops, even if all associations are static.  The
18942 following two declarations generate a loop for the first dimension, and
18943 individual component assignments for the second dimension:
18944
18945 @smallexample @c ada
18946 Zero1: constant two_dim := (1..3 => (1..3 => 0));
18947 Zero2: constant two_dim := (others => (others => 0));
18948 @end smallexample
18949
18950 @node Constant aggregates with unconstrained nominal types
18951 @subsection Constant aggregates with unconstrained nominal types
18952
18953 @noindent
18954 In such cases the aggregate itself establishes the subtype, so that
18955 associations with @code{others} cannot be used.  GNAT determines the
18956 bounds for the actual subtype of the aggregate, and allocates the
18957 aggregate statically as well.  No code is generated for the following:
18958
18959 @smallexample @c ada
18960     type One_Unc is array (natural range <>) of integer;
18961     Cr_Unc : constant One_Unc := (12,24,36);
18962 @end smallexample
18963
18964 @node Aggregates with static bounds
18965 @subsection Aggregates with static bounds
18966
18967 @noindent
18968 In all previous examples the aggregate was the initial (and immutable) value
18969 of a constant.  If the aggregate initializes a variable, then code is generated
18970 for it as a combination of individual assignments and loops over the target
18971 object.  The declarations
18972
18973 @smallexample @c ada
18974        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
18975        Cr_Var2 : One_Dim := (others > -1);
18976 @end smallexample
18977
18978 @noindent
18979 generate the equivalent of
18980
18981 @smallexample @c ada
18982        Cr_Var1 (1) := 2;
18983        Cr_Var1 (2) := 3;
18984        Cr_Var1 (3) := 5;
18985        Cr_Var1 (4) := 11;
18986
18987        for I in Cr_Var2'range loop
18988           Cr_Var2 (I) := -1;
18989        end loop;
18990 @end smallexample
18991
18992 @node Aggregates with non-static bounds
18993 @subsection Aggregates with non-static bounds
18994
18995 @noindent
18996 If the bounds of the aggregate are not statically compatible with the bounds
18997 of the nominal subtype  of the target, then constraint checks have to be
18998 generated on the bounds.  For a multidimensional array, constraint checks may
18999 have to be applied to sub-arrays individually, if they do not have statically
19000 compatible subtypes.
19001
19002 @node Aggregates in assignment statements
19003 @subsection Aggregates in assignment statements
19004
19005 @noindent
19006 In general, aggregate assignment requires the construction of a temporary,
19007 and a copy from the temporary to the target of the assignment.  This is because
19008 it is not always possible to convert the assignment into a series of individual
19009 component assignments.  For example, consider the simple case:
19010
19011 @smallexample @c ada
19012         A := (A(2), A(1));
19013 @end smallexample
19014
19015 @noindent
19016 This cannot be converted into:
19017
19018 @smallexample @c ada
19019         A(1) := A(2);
19020         A(2) := A(1);
19021 @end smallexample
19022
19023 @noindent
19024 So the aggregate has to be built first in a separate location, and then
19025 copied into the target.  GNAT recognizes simple cases where this intermediate
19026 step is not required, and the assignments can be performed in place, directly
19027 into the target.  The following sufficient criteria are applied:
19028
19029 @itemize @bullet
19030 @item
19031 The bounds of the aggregate are static, and the associations are static.
19032 @item
19033 The components of the aggregate are static constants, names of
19034 simple variables that are not renamings, or expressions not involving
19035 indexed components whose operands obey these rules.
19036 @end itemize
19037
19038 @noindent
19039 If any of these conditions are violated, the aggregate will be built in
19040 a temporary (created either by the front-end or the code generator) and then
19041 that temporary will be copied onto the target.
19042
19043 @node The Size of Discriminated Records with Default Discriminants
19044 @section The Size of Discriminated Records with Default Discriminants
19045
19046 @noindent
19047 If a discriminated type @code{T} has discriminants with default values, it is
19048 possible to declare an object of this type without providing an explicit
19049 constraint:
19050
19051 @smallexample @c ada
19052 @group
19053 type Size is range 1..100;
19054
19055 type Rec (D : Size := 15) is record
19056    Name : String (1..D);
19057 end T;
19058
19059 Word : Rec;
19060 @end group
19061 @end smallexample
19062
19063 @noindent
19064 Such an object is said to be @emph{unconstrained}.
19065 The discriminant of the object
19066 can be modified by a full assignment to the object, as long as it preserves the
19067 relation between the value of the discriminant, and the value of the components
19068 that depend on it:
19069
19070 @smallexample @c ada
19071 @group
19072 Word := (3, "yes");
19073
19074 Word := (5, "maybe");
19075
19076 Word := (5, "no"); -- raises Constraint_Error
19077 @end group
19078 @end smallexample
19079
19080 @noindent
19081 In order to support this behavior efficiently, an unconstrained object is
19082 given the maximum size that any value of the type requires. In the case
19083 above, @code{Word} has storage for the discriminant and for
19084 a @code{String} of length 100.
19085 It is important to note that unconstrained objects do not require dynamic
19086 allocation. It would be an improper implementation to place on the heap those
19087 components whose size depends on discriminants. (This improper implementation
19088 was used by some Ada83 compilers, where the @code{Name} component above
19089 would have
19090 been stored as a pointer to a dynamic string). Following the principle that
19091 dynamic storage management should never be introduced implicitly,
19092 an Ada compiler should reserve the full size for an unconstrained declared
19093 object, and place it on the stack.
19094
19095 This maximum size approach
19096 has been a source of surprise to some users, who expect the default
19097 values of the discriminants to determine the size reserved for an
19098 unconstrained object: ``If the default is 15, why should the object occupy
19099 a larger size?''
19100 The answer, of course, is that the discriminant may be later modified,
19101 and its full range of values must be taken into account. This is why the
19102 declaration:
19103
19104 @smallexample
19105 @group
19106 type Rec (D : Positive := 15) is record
19107    Name : String (1..D);
19108 end record;
19109
19110 Too_Large : Rec;
19111 @end group
19112 @end smallexample
19113
19114 @noindent
19115 is flagged by the compiler with a warning:
19116 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
19117 because the required size includes @code{Positive'Last}
19118 bytes. As the first example indicates, the proper approach is to declare an
19119 index type of ``reasonable'' range so that unconstrained objects are not too
19120 large.
19121
19122 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
19123 created in the heap by means of an allocator, then it is @emph{not}
19124 unconstrained:
19125 it is constrained by the default values of the discriminants, and those values
19126 cannot be modified by full assignment. This is because in the presence of
19127 aliasing all views of the object (which may be manipulated by different tasks,
19128 say) must be consistent, so it is imperative that the object, once created,
19129 remain invariant.
19130
19131 @node Strict Conformance to the Ada Reference Manual
19132 @section Strict Conformance to the Ada Reference Manual
19133
19134 @noindent
19135 The dynamic semantics defined by the Ada Reference Manual impose a set of
19136 run-time checks to be generated. By default, the GNAT compiler will insert many
19137 run-time checks into the compiled code, including most of those required by the
19138 Ada Reference Manual. However, there are three checks that are not enabled
19139 in the default mode for efficiency reasons: arithmetic overflow checking for
19140 integer operations (including division by zero), checks for access before
19141 elaboration on subprogram calls, and stack overflow checking (most operating
19142 systems do not perform this check by default).
19143
19144 Strict conformance to the Ada Reference Manual can be achieved by adding
19145 three compiler options for overflow checking for integer operations
19146 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
19147 calls and generic instantiations (@option{-gnatE}), and stack overflow
19148 checking (@option{-fstack-check}).
19149
19150 Note that the result of a floating point arithmetic operation in overflow and
19151 invalid situations, when the @code{Machine_Overflows} attribute of the result
19152 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
19153 case for machines compliant with the IEEE floating-point standard, but on
19154 machines that are not fully compliant with this standard, such as Alpha, the
19155 @option{-mieee} compiler flag must be used for achieving IEEE confirming
19156 behavior (although at the cost of a significant performance penalty), so
19157 infinite and NaN values are properly generated.
19158
19159
19160 @node Implementation of Ada 2012 Features
19161 @chapter Implementation of Ada 2012 Features
19162 @cindex Ada 2012 implementation status
19163
19164 This chapter contains a complete list of Ada 2012 features that have been
19165 implemented as of GNAT version 6.4. Generally, these features are only
19166 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
19167 @cindex @option{-gnat12} option
19168 or if the configuration pragma @code{Ada_2012} is used.
19169 @cindex pragma @code{Ada_2012}
19170 @cindex configuration pragma @code{Ada_2012}
19171 @cindex @code{Ada_2012} configuration pragma
19172 However, new pragmas, attributes, and restrictions are
19173 unconditionally available, since the Ada 95 standard allows the addition of
19174 new pragmas, attributes, and restrictions (there are exceptions, which are
19175 documented in the individual descriptions), and also certain packages
19176 were made available in earlier versions of Ada.
19177
19178 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
19179 This date shows the implementation date of the feature. Any wavefront
19180 subsequent to this date will contain the indicated feature, as will any
19181 subsequent releases. A date of 0000-00-00 means that GNAT has always
19182 implemented the feature, or implemented it as soon as it appeared as a
19183 binding interpretation.
19184
19185 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
19186 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
19187 The features are ordered based on the relevant sections of the Ada
19188 Reference Manual (``RM'').  When a given AI relates to multiple points
19189 in the RM, the earliest is used.
19190
19191 A complete description of the AIs may be found in
19192 @url{www.ada-auth.org/ai05-summary.html}.
19193
19194 @itemize @bullet
19195
19196 @item
19197 @emph{AI-0176 Quantified expressions (2010-09-29)}
19198 @cindex AI-0176 (Ada 2012 feature)
19199
19200 @noindent
19201   Both universally and existentially quantified expressions are implemented.
19202   They use the new syntax for iterators proposed in AI05-139-2, as well as
19203   the standard Ada loop syntax.
19204
19205 @noindent
19206   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
19207
19208 @item
19209 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
19210 @cindex AI-0079 (Ada 2012 feature)
19211
19212 @noindent
19213   Wide characters in the unicode category @i{other_format} are now allowed in
19214   source programs between tokens, but not within a token such as an identifier.
19215
19216 @noindent
19217   RM References:  2.01 (4/2)   2.02 (7)
19218
19219 @item
19220 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
19221 @cindex AI-0091 (Ada 2012 feature)
19222
19223 @noindent
19224   Wide characters in the unicode category @i{other_format} are not permitted
19225   within  an identifier, since this can be a security problem. The error
19226   message for this case has been improved to be more specific, but GNAT has
19227   never allowed such characters to appear in identifiers.
19228
19229 @noindent
19230   RM References:  2.03 (3.1/2)   2.03 (4/2)   2.03 (5/2)   2.03 (5.1/2)   2.03 (5.2/2)   2.03 (5.3/2)   2.09 (2/2)
19231
19232 @item
19233 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
19234 @cindex AI-0100 (Ada 2012 feature)
19235
19236 @noindent
19237   This AI is an earlier version of AI-163. It simplifies the rules
19238   for legal placement of pragmas. In the case of lists that allow pragmas, if
19239   the list may have no elements, then the list may consist solely of pragmas.
19240
19241 @noindent
19242   RM References:  2.08 (7)
19243
19244 @item
19245 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
19246 @cindex AI-0163 (Ada 2012 feature)
19247
19248 @noindent
19249   A statement sequence may be composed entirely of pragmas. It is no longer
19250   necessary to add a dummy @code{null} statement to make the sequence legal.
19251
19252 @noindent
19253   RM References:  2.08 (7)   2.08 (16)
19254
19255
19256 @item
19257 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
19258 @cindex AI-0080 (Ada 2012 feature)
19259
19260 @noindent
19261   This is an editorial change only, described as non-testable in the AI.
19262
19263 @noindent
19264   RM References:  3.01 (7)
19265
19266
19267 @item
19268 @emph{AI-0183 Aspect specifications (2010-08-16)}
19269 @cindex AI-0183 (Ada 2012 feature)
19270
19271 @noindent
19272   Aspect specifications have been fully implemented except for pre and post-
19273   conditions, and type invariants, which have their own separate AI's. All
19274   forms of declarations listed in the AI are supported. The following is a
19275   list of the aspects supported (with GNAT implementation aspects marked)
19276
19277 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
19278 @item @code{Ada_2005} @tab                      -- GNAT
19279 @item @code{Ada_2012} @tab                      -- GNAT
19280 @item @code{Address} @tab
19281 @item @code{Alignment} @tab
19282 @item @code{Atomic} @tab
19283 @item @code{Atomic_Components} @tab
19284 @item @code{Bit_Order} @tab
19285 @item @code{Component_Size} @tab
19286 @item @code{Contract_Cases} @tab                -- GNAT
19287 @item @code{Discard_Names} @tab
19288 @item @code{External_Tag} @tab
19289 @item @code{Favor_Top_Level} @tab               -- GNAT
19290 @item @code{Inline} @tab
19291 @item @code{Inline_Always} @tab                 -- GNAT
19292 @item @code{Invariant} @tab                     -- GNAT
19293 @item @code{Machine_Radix} @tab
19294 @item @code{No_Return} @tab
19295 @item @code{Object_Size} @tab                   -- GNAT
19296 @item @code{Pack} @tab
19297 @item @code{Persistent_BSS} @tab                -- GNAT
19298 @item @code{Post} @tab
19299 @item @code{Pre} @tab
19300 @item @code{Predicate} @tab
19301 @item @code{Preelaborable_Initialization} @tab
19302 @item @code{Pure_Function} @tab                 -- GNAT
19303 @item @code{Remote_Access_Type} @tab            -- GNAT
19304 @item @code{Shared} @tab                        -- GNAT
19305 @item @code{Size} @tab
19306 @item @code{Storage_Pool} @tab
19307 @item @code{Storage_Size} @tab
19308 @item @code{Stream_Size} @tab
19309 @item @code{Suppress} @tab
19310 @item @code{Suppress_Debug_Info} @tab           -- GNAT
19311 @item @code{Test_Case} @tab                     -- GNAT
19312 @item @code{Type_Invariant} @tab
19313 @item @code{Unchecked_Union} @tab
19314 @item @code{Universal_Aliasing} @tab            -- GNAT
19315 @item @code{Unmodified} @tab                    -- GNAT
19316 @item @code{Unreferenced} @tab                  -- GNAT
19317 @item @code{Unreferenced_Objects} @tab          -- GNAT
19318 @item @code{Unsuppress} @tab
19319 @item @code{Value_Size} @tab                    -- GNAT
19320 @item @code{Volatile} @tab
19321 @item @code{Volatile_Components}
19322 @item @code{Warnings} @tab                      -- GNAT
19323 @end multitable
19324
19325 @noindent
19326   Note that for aspects with an expression, e.g. @code{Size}, the expression is
19327   treated like a default expression (visibility is analyzed at the point of
19328   occurrence of the aspect, but evaluation of the expression occurs at the
19329   freeze point of the entity involved).
19330
19331 @noindent
19332   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
19333   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
19334   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
19335   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
19336   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
19337   13.03.01 (0)
19338
19339
19340 @item
19341 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
19342 @cindex AI-0128 (Ada 2012 feature)
19343
19344 @noindent
19345   If an equality operator ("=") is declared for a type, then the implicitly
19346   declared inequality operator ("/=") is a primitive operation of the type.
19347   This is the only reasonable interpretation, and is the one always implemented
19348   by GNAT, but the RM was not entirely clear in making this point.
19349
19350 @noindent
19351   RM References:  3.02.03 (6)   6.06 (6)
19352
19353 @item
19354 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
19355 @cindex AI-0003 (Ada 2012 feature)
19356
19357 @noindent
19358    In Ada 2012, a qualified expression is considered to be syntactically a name,
19359    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
19360    useful in disambiguating some cases of overloading.
19361
19362 @noindent
19363   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
19364   5.04 (7)
19365
19366 @item
19367 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
19368 @cindex AI-0120 (Ada 2012 feature)
19369
19370 @noindent
19371   This is an RM editorial change only. The section that lists objects that are
19372   constant failed to include the current instance of a protected object
19373   within a protected function. This has always been treated as a constant
19374   in GNAT.
19375
19376 @noindent
19377   RM References:  3.03 (21)
19378
19379 @item
19380 @emph{AI-0008 General access to constrained objects (0000-00-00)}
19381 @cindex AI-0008 (Ada 2012 feature)
19382
19383 @noindent
19384   The wording in the RM implied that if you have a general access to a
19385   constrained object, it could be used to modify the discriminants. This was
19386   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
19387   has always done so in this situation.
19388
19389 @noindent
19390   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
19391
19392
19393 @item
19394 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
19395 @cindex AI-0093 (Ada 2012 feature)
19396
19397 @noindent
19398   This is an editorial change only, to make more widespread use of the Ada 2012
19399   ``immutably limited''.
19400
19401 @noindent
19402   RM References:  3.03 (23.4/3)
19403
19404
19405
19406 @item
19407 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
19408 @cindex AI-0096 (Ada 2012 feature)
19409
19410 @noindent
19411   In general it is illegal for a type derived from a formal limited type to be
19412   nonlimited.  This AI makes an exception to this rule: derivation is legal
19413   if it appears in the private part of the generic, and the formal type is not
19414   tagged. If the type is tagged, the legality check must be applied to the
19415   private part of the package.
19416
19417 @noindent
19418   RM References:  3.04 (5.1/2)   6.02 (7)
19419
19420
19421 @item
19422 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
19423 @cindex AI-0181 (Ada 2012 feature)
19424
19425 @noindent
19426   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
19427   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
19428   @code{Image} and @code{Value} attributes for the character types. Strictly
19429   speaking this is an inconsistency with Ada 95, but in practice the use of
19430   these attributes is so obscure that it will not cause problems.
19431
19432 @noindent
19433   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
19434
19435
19436 @item
19437 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
19438 @cindex AI-0182 (Ada 2012 feature)
19439
19440 @noindent
19441   This AI allows @code{Character'Value} to accept the string @code{'?'} where
19442   @code{?} is any character including non-graphic control characters. GNAT has
19443   always accepted such strings. It also allows strings such as
19444   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
19445   permission and raises @code{Constraint_Error}, as is certainly still
19446   permitted.
19447
19448 @noindent
19449   RM References:  3.05 (56/2)
19450
19451
19452 @item
19453 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
19454 @cindex AI-0214 (Ada 2012 feature)
19455
19456 @noindent
19457   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
19458   to have default expressions by allowing them when the type is limited. It
19459   is often useful to define a default value for a discriminant even though
19460   it can't be changed by assignment.
19461
19462 @noindent
19463   RM References:  3.07 (9.1/2)   3.07.02 (3)
19464
19465
19466 @item
19467 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
19468 @cindex AI-0102 (Ada 2012 feature)
19469
19470 @noindent
19471   It is illegal to assign an anonymous access constant to an anonymous access
19472   variable. The RM did not have a clear rule to prevent this, but GNAT has
19473   always generated an error for this usage.
19474
19475 @noindent
19476   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
19477
19478
19479 @item
19480 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
19481 @cindex AI-0158 (Ada 2012 feature)
19482
19483 @noindent
19484   This AI extends the syntax of membership tests to simplify complex conditions
19485   that can be expressed as membership in a subset of values of any type. It
19486   introduces syntax for a list of expressions that may be used in loop contexts
19487   as well.
19488
19489 @noindent
19490   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
19491
19492
19493 @item
19494 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
19495 @cindex AI-0173 (Ada 2012 feature)
19496
19497 @noindent
19498   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
19499   with the tag of an abstract type, and @code{False} otherwise.
19500
19501 @noindent
19502   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
19503
19504
19505
19506 @item
19507 @emph{AI-0076 function with controlling result (0000-00-00)}
19508 @cindex AI-0076 (Ada 2012 feature)
19509
19510 @noindent
19511   This is an editorial change only. The RM defines calls with controlling
19512   results, but uses the term ``function with controlling result'' without an
19513   explicit definition.
19514
19515 @noindent
19516   RM References:  3.09.02 (2/2)
19517
19518
19519 @item
19520 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
19521 @cindex AI-0126 (Ada 2012 feature)
19522
19523 @noindent
19524   This AI clarifies dispatching rules, and simply confirms that dispatching
19525   executes the operation of the parent type when there is no explicitly or
19526   implicitly declared operation for the descendant type. This has always been
19527   the case in all versions of GNAT.
19528
19529 @noindent
19530   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
19531
19532
19533 @item
19534 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
19535 @cindex AI-0097 (Ada 2012 feature)
19536
19537 @noindent
19538   The RM as written implied that in some cases it was possible to create an
19539   object of an abstract type, by having an abstract extension inherit a non-
19540   abstract constructor from its parent type. This mistake has been corrected
19541   in GNAT and in the RM, and this construct is now illegal.
19542
19543 @noindent
19544   RM References:  3.09.03 (4/2)
19545
19546
19547 @item
19548 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
19549 @cindex AI-0203 (Ada 2012 feature)
19550
19551 @noindent
19552   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
19553   permitted such usage.
19554
19555 @noindent
19556   RM References:  3.09.03 (8/3)
19557
19558
19559 @item
19560 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
19561 @cindex AI-0198 (Ada 2012 feature)
19562
19563 @noindent
19564   This AI resolves a conflict between two rules involving inherited abstract
19565   operations and predefined operators. If a derived numeric type inherits
19566   an abstract operator, it overrides the predefined one. This interpretation
19567   was always the one implemented in GNAT.
19568
19569 @noindent
19570   RM References:  3.09.03 (4/3)
19571
19572 @item
19573 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
19574 @cindex AI-0073 (Ada 2012 feature)
19575
19576 @noindent
19577   This AI covers a number of issues regarding returning abstract types. In
19578   particular generic functions cannot have abstract result types or access
19579   result types designated an abstract type. There are some other cases which
19580   are detailed in the AI. Note that this binding interpretation has not been
19581   retrofitted to operate before Ada 2012 mode, since it caused a significant
19582   number of regressions.
19583
19584 @noindent
19585   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
19586
19587
19588 @item
19589 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
19590 @cindex AI-0070 (Ada 2012 feature)
19591
19592 @noindent
19593   This is an editorial change only, there are no testable consequences short of
19594   checking for the absence of generated code for an interface declaration.
19595
19596 @noindent
19597   RM References:  3.09.04 (18/2)
19598
19599
19600 @item
19601 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
19602 @cindex AI-0208 (Ada 2012 feature)
19603
19604 @noindent
19605   The wording in the Ada 2005 RM concerning characteristics of incomplete views
19606   was incorrect and implied that some programs intended to be legal were now
19607   illegal. GNAT had never considered such programs illegal, so it has always
19608   implemented the intent of this AI.
19609
19610 @noindent
19611   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
19612
19613
19614 @item
19615 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
19616 @cindex AI-0162 (Ada 2012 feature)
19617
19618 @noindent
19619   Incomplete types are made more useful by allowing them to be completed by
19620   private types and private extensions.
19621
19622 @noindent
19623   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
19624
19625
19626
19627 @item
19628 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
19629 @cindex AI-0098 (Ada 2012 feature)
19630
19631 @noindent
19632   An unintentional omission in the RM implied some inconsistent restrictions on
19633   the use of anonymous access to subprogram values. These restrictions were not
19634   intentional, and have never been enforced by GNAT.
19635
19636 @noindent
19637   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
19638
19639
19640 @item
19641 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
19642 @cindex AI-0199 (Ada 2012 feature)
19643
19644 @noindent
19645   A choice list in a record aggregate can include several components of
19646   (distinct) anonymous access types as long as they have matching designated
19647   subtypes.
19648
19649 @noindent
19650   RM References:  4.03.01 (16)
19651
19652
19653 @item
19654 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
19655 @cindex AI-0220 (Ada 2012 feature)
19656
19657 @noindent
19658   This AI addresses a wording problem in the RM that appears to permit some
19659   complex cases of aggregates with non-static discriminants. GNAT has always
19660   implemented the intended semantics.
19661
19662 @noindent
19663   RM References:  4.03.01 (17)
19664
19665 @item
19666 @emph{AI-0147 Conditional expressions (2009-03-29)}
19667 @cindex AI-0147 (Ada 2012 feature)
19668
19669 @noindent
19670   Conditional expressions are permitted. The form of such an expression is:
19671
19672 @smallexample
19673     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
19674 @end smallexample
19675
19676   The parentheses can be omitted in contexts where parentheses are present
19677   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
19678   clause is omitted, @b{else True} is assumed;
19679   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
19680   @emph{(A implies B)} in standard logic.
19681
19682 @noindent
19683   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
19684   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
19685
19686
19687 @item
19688 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
19689 @cindex AI-0037 (Ada 2012 feature)
19690
19691 @noindent
19692   This AI confirms that an association of the form @code{Indx => <>} in an
19693   array aggregate must raise @code{Constraint_Error} if @code{Indx}
19694   is out of range. The RM specified a range check on other associations, but
19695   not when the value of the association was defaulted. GNAT has always inserted
19696   a constraint check on the index value.
19697
19698 @noindent
19699   RM References:  4.03.03 (29)
19700
19701
19702 @item
19703 @emph{AI-0123 Composability of equality (2010-04-13)}
19704 @cindex AI-0123 (Ada 2012 feature)
19705
19706 @noindent
19707   Equality of untagged record composes, so that the predefined equality for a
19708   composite type that includes a component of some untagged record type
19709   @code{R} uses the equality operation of @code{R} (which may be user-defined
19710   or predefined). This makes the behavior of untagged records identical to that
19711   of tagged types in this respect.
19712
19713   This change is an incompatibility with previous versions of Ada, but it
19714   corrects a non-uniformity that was often a source of confusion. Analysis of
19715   a large number of industrial programs indicates that in those rare cases
19716   where a composite type had an untagged record component with a user-defined
19717   equality, either there was no use of the composite equality, or else the code
19718   expected the same composability as for tagged types, and thus had a bug that
19719   would be fixed by this change.
19720
19721 @noindent
19722   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
19723   8.05.04 (8)
19724
19725
19726 @item
19727 @emph{AI-0088 The value of exponentiation (0000-00-00)}
19728 @cindex AI-0088 (Ada 2012 feature)
19729
19730 @noindent
19731   This AI clarifies the equivalence rule given for the dynamic semantics of
19732   exponentiation: the value of the operation can be obtained by repeated
19733   multiplication, but the operation can be implemented otherwise (for example
19734   using the familiar divide-by-two-and-square algorithm, even if this is less
19735   accurate), and does not imply repeated reads of a volatile base.
19736
19737 @noindent
19738   RM References:  4.05.06 (11)
19739
19740 @item
19741 @emph{AI-0188 Case expressions (2010-01-09)}
19742 @cindex AI-0188 (Ada 2012 feature)
19743
19744 @noindent
19745   Case expressions are permitted. This allows use of constructs such as:
19746 @smallexample
19747   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
19748 @end smallexample
19749
19750 @noindent
19751   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
19752
19753 @item
19754 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
19755 @cindex AI-0104 (Ada 2012 feature)
19756
19757 @noindent
19758   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
19759   @code{Constraint_Error} because the default value of the allocated object is
19760   @b{null}. This useless construct is illegal in Ada 2012.
19761
19762 @noindent
19763   RM References:  4.08 (2)
19764
19765 @item
19766 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
19767 @cindex AI-0157 (Ada 2012 feature)
19768
19769 @noindent
19770   Allocation and Deallocation from an empty storage pool (i.e. allocation or
19771   deallocation of a pointer for which a static storage size clause of zero
19772   has been given) is now illegal and is detected as such. GNAT
19773   previously gave a warning but not an error.
19774
19775 @noindent
19776   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
19777
19778 @item
19779 @emph{AI-0179 Statement not required after label (2010-04-10)}
19780 @cindex AI-0179 (Ada 2012 feature)
19781
19782 @noindent
19783   It is not necessary to have a statement following a label, so a label
19784   can appear at the end of a statement sequence without the need for putting a
19785   null statement afterwards, but it is not allowable to have only labels and
19786   no real statements in a statement sequence.
19787
19788 @noindent
19789   RM References:  5.01 (2)
19790
19791
19792 @item
19793 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
19794 @cindex AI-139-2 (Ada 2012 feature)
19795
19796 @noindent
19797   The new syntax for iterating over arrays and containers is now implemented.
19798   Iteration over containers is for now limited to read-only iterators. Only
19799   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
19800
19801 @noindent
19802   RM References:  5.05
19803
19804 @item
19805 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
19806 @cindex AI-0134 (Ada 2012 feature)
19807
19808 @noindent
19809   For full conformance, the profiles of anonymous-access-to-subprogram
19810   parameters must match. GNAT has always enforced this rule.
19811
19812 @noindent
19813   RM References:  6.03.01 (18)
19814
19815 @item
19816 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
19817 @cindex AI-0207 (Ada 2012 feature)
19818
19819 @noindent
19820   This AI confirms that access_to_constant indication must match for mode
19821   conformance. This was implemented in GNAT when the qualifier was originally
19822   introduced in Ada 2005.
19823
19824 @noindent
19825   RM References:  6.03.01 (16/2)
19826
19827
19828 @item
19829 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
19830 @cindex AI-0046 (Ada 2012 feature)
19831
19832 @noindent
19833   For full conformance, in the case of access parameters, the null exclusion
19834   must match (either both or neither must have @code{@b{not null}}).
19835
19836 @noindent
19837   RM References:  6.03.02 (18)
19838
19839
19840 @item
19841 @emph{AI-0118 The association of parameter associations (0000-00-00)}
19842 @cindex AI-0118 (Ada 2012 feature)
19843
19844 @noindent
19845   This AI clarifies the rules for named associations in subprogram calls and
19846   generic instantiations. The rules have been in place since Ada 83.
19847
19848 @noindent
19849   RM References:  6.04.01 (2)   12.03 (9)
19850
19851
19852 @item
19853 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
19854 @cindex AI-0196 (Ada 2012 feature)
19855
19856 @noindent
19857   Null exclusion checks are not made for @code{@b{out}} parameters when
19858   evaluating the actual parameters. GNAT has never generated these checks.
19859
19860 @noindent
19861   RM References:  6.04.01 (13)
19862
19863 @item
19864 @emph{AI-0015 Constant return objects (0000-00-00)}
19865 @cindex AI-0015 (Ada 2012 feature)
19866
19867 @noindent
19868   The return object declared in an @i{extended_return_statement} may be
19869   declared constant. This was always intended, and GNAT has always allowed it.
19870
19871 @noindent
19872   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
19873   6.05 (5.7/2)
19874
19875
19876 @item
19877 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
19878 @cindex AI-0032 (Ada 2012 feature)
19879
19880 @noindent
19881   If a function returns a class-wide type, the object of an extended return
19882   statement can be declared with a specific type that is covered by the class-
19883   wide type. This has been implemented in GNAT since the introduction of
19884   extended returns. Note AI-0103 complements this AI by imposing matching
19885   rules for constrained return types.
19886
19887 @noindent
19888   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
19889   6.05 (8/2)
19890
19891 @item
19892 @emph{AI-0103 Static matching for extended return (2010-07-23)}
19893 @cindex AI-0103 (Ada 2012 feature)
19894
19895 @noindent
19896   If the return subtype of a function is an elementary type or a constrained
19897   type, the subtype indication in an extended return statement must match
19898   statically this return subtype.
19899
19900 @noindent
19901   RM References:  6.05 (5.2/2)
19902
19903
19904 @item
19905 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
19906 @cindex AI-0058 (Ada 2012 feature)
19907
19908 @noindent
19909   The RM had some incorrect wording implying wrong treatment of abnormal
19910   completion in an extended return. GNAT has always implemented the intended
19911   correct semantics as described by this AI.
19912
19913 @noindent
19914   RM References:  6.05 (22/2)
19915
19916
19917 @item
19918 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
19919 @cindex AI-0050 (Ada 2012 feature)
19920
19921 @noindent
19922   The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
19923   not take advantage of these incorrect permissions in any case.
19924
19925 @noindent
19926   RM References:  6.05 (24/2)
19927
19928
19929 @item
19930 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
19931 @cindex AI-0125 (Ada 2012 feature)
19932
19933 @noindent
19934   In Ada 2012, the declaration of a primitive operation of a type extension
19935   or private extension can also override an inherited primitive that is not
19936   visible at the point of this declaration.
19937
19938 @noindent
19939   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
19940
19941 @item
19942 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
19943 @cindex AI-0062 (Ada 2012 feature)
19944
19945 @noindent
19946   A full constant may have a null exclusion even if its associated deferred
19947   constant does not. GNAT has always allowed this.
19948
19949 @noindent
19950   RM References:  7.04 (6/2)   7.04 (7.1/2)
19951
19952
19953 @item
19954 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
19955 @cindex AI-0178 (Ada 2012 feature)
19956
19957 @noindent
19958   This AI clarifies the role of incomplete views and plugs an omission in the
19959   RM. GNAT always correctly restricted the use of incomplete views and types.
19960
19961 @noindent
19962   RM References:  7.05 (3/2)   7.05 (6/2)
19963
19964 @item
19965 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
19966 @cindex AI-0087 (Ada 2012 feature)
19967
19968 @noindent
19969   The actual for a formal nonlimited derived type cannot be limited. In
19970   particular, a formal derived type that extends a limited interface but which
19971   is not explicitly limited cannot be instantiated with a limited type.
19972
19973 @noindent
19974   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
19975
19976 @item
19977 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
19978 @cindex AI-0099 (Ada 2012 feature)
19979
19980 @noindent
19981   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
19982   and therefore depends on the run-time characteristics of an object (i.e. its
19983   tag) and not on its nominal type. As the AI indicates: ``we do not expect
19984   this to affect any implementation''.
19985
19986 @noindent
19987   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
19988
19989
19990
19991 @item
19992 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
19993 @cindex AI-0064 (Ada 2012 feature)
19994
19995 @noindent
19996   This is an editorial change only. The intended behavior is already checked
19997   by an existing ACATS test, which GNAT has always executed correctly.
19998
19999 @noindent
20000   RM References:  7.06.01 (17.1/1)
20001
20002 @item
20003 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
20004 @cindex AI-0026 (Ada 2012 feature)
20005
20006 @noindent
20007   Record representation clauses concerning Unchecked_Union types cannot mention
20008   the discriminant of the type. The type of a component declared in the variant
20009   part of an Unchecked_Union cannot be controlled, have controlled components,
20010   nor have protected or task parts. If an Unchecked_Union type is declared
20011   within the body of a generic unit or its descendants, then the type of a
20012   component declared in the variant part cannot be a formal private type or a
20013   formal private extension declared within the same generic unit.
20014
20015 @noindent
20016   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
20017
20018
20019 @item
20020 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
20021 @cindex AI-0205 (Ada 2012 feature)
20022
20023 @noindent
20024   This AI corrects a simple omission in the RM. Return objects have always
20025   been visible within an extended return statement.
20026
20027 @noindent
20028   RM References:  8.03 (17)
20029
20030
20031 @item
20032 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
20033 @cindex AI-0042 (Ada 2012 feature)
20034
20035 @noindent
20036   This AI fixes a wording gap in the RM. An operation of a synchronized
20037   interface can be implemented by a protected or task entry, but the abstract
20038   operation is not being overridden in the usual sense, and it must be stated
20039   separately that this implementation is legal. This has always been the case
20040   in GNAT.
20041
20042 @noindent
20043   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
20044
20045 @item
20046 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
20047 @cindex AI-0030 (Ada 2012 feature)
20048
20049 @noindent
20050   Requeue is permitted to a protected, synchronized or task interface primitive
20051   providing it is known that the overriding operation is an entry. Otherwise
20052   the requeue statement has the same effect as a procedure call. Use of pragma
20053   @code{Implemented} provides a way to impose a static requirement on the
20054   overriding operation by adhering to one of the implementation kinds: entry,
20055   protected procedure or any of the above.
20056
20057 @noindent
20058   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
20059   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
20060
20061
20062 @item
20063 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
20064 @cindex AI-0201 (Ada 2012 feature)
20065
20066 @noindent
20067   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
20068   attribute, then individual components may not be addressable by independent
20069   tasks. However, if the representation clause has no effect (is confirming),
20070   then independence is not compromised. Furthermore, in GNAT, specification of
20071   other appropriately addressable component sizes (e.g. 16 for 8-bit
20072   characters) also preserves independence. GNAT now gives very clear warnings
20073   both for the declaration of such a type, and for any assignment to its components.
20074
20075 @noindent
20076   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
20077
20078 @item
20079 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
20080 @cindex AI-0009 (Ada 2012 feature)
20081
20082 @noindent
20083   This AI introduces the new pragmas @code{Independent} and
20084   @code{Independent_Components},
20085   which control guaranteeing independence of access to objects and components.
20086   The AI also requires independence not unaffected by confirming rep clauses.
20087
20088 @noindent
20089   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
20090   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
20091
20092
20093 @item
20094 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
20095 @cindex AI-0072 (Ada 2012 feature)
20096
20097 @noindent
20098   This AI clarifies that task signalling for reading @code{'Terminated} only
20099   occurs if the result is True. GNAT semantics has always been consistent with
20100   this notion of task signalling.
20101
20102 @noindent
20103   RM References:  9.10 (6.1/1)
20104
20105 @item
20106 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
20107 @cindex AI-0108 (Ada 2012 feature)
20108
20109 @noindent
20110   This AI confirms that an incomplete type from a limited view does not have
20111   discriminants. This has always been the case in GNAT.
20112
20113 @noindent
20114   RM References:  10.01.01 (12.3/2)
20115
20116 @item
20117 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
20118 @cindex AI-0129 (Ada 2012 feature)
20119
20120 @noindent
20121   This AI clarifies the description of limited views: a limited view of a
20122   package includes only one view of a type that has an incomplete declaration
20123   and a full declaration (there is no possible ambiguity in a client package).
20124   This AI also fixes an omission: a nested package in the private part has no
20125   limited view. GNAT always implemented this correctly.
20126
20127 @noindent
20128   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
20129
20130
20131
20132 @item
20133 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
20134 @cindex AI-0077 (Ada 2012 feature)
20135
20136 @noindent
20137   This AI clarifies that a declaration does not include a context clause,
20138   and confirms that it is illegal to have a context in which both a limited
20139   and a nonlimited view of a package are accessible. Such double visibility
20140   was always rejected by GNAT.
20141
20142 @noindent
20143   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
20144
20145 @item
20146 @emph{AI-0122 Private with and children of generics (0000-00-00)}
20147 @cindex AI-0122 (Ada 2012 feature)
20148
20149 @noindent
20150   This AI clarifies the visibility of private children of generic units within
20151   instantiations of a parent. GNAT has always handled this correctly.
20152
20153 @noindent
20154   RM References:  10.01.02 (12/2)
20155
20156
20157
20158 @item
20159 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
20160 @cindex AI-0040 (Ada 2012 feature)
20161
20162 @noindent
20163   This AI confirms that a limited with clause in a child unit cannot name
20164   an ancestor of the unit. This has always been checked in GNAT.
20165
20166 @noindent
20167   RM References:  10.01.02 (20/2)
20168
20169 @item
20170 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
20171 @cindex AI-0132 (Ada 2012 feature)
20172
20173 @noindent
20174   This AI fills a gap in the description of library unit pragmas. The pragma
20175   clearly must apply to a library unit, even if it does not carry the name
20176   of the enclosing unit. GNAT has always enforced the required check.
20177
20178 @noindent
20179   RM References:  10.01.05 (7)
20180
20181
20182 @item
20183 @emph{AI-0034 Categorization of limited views (0000-00-00)}
20184 @cindex AI-0034 (Ada 2012 feature)
20185
20186 @noindent
20187   The RM makes certain limited with clauses illegal because of categorization
20188   considerations, when the corresponding normal with would be legal. This is
20189   not intended, and GNAT has always implemented the recommended behavior.
20190
20191 @noindent
20192   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
20193
20194
20195 @item
20196 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
20197 @cindex AI-0035 (Ada 2012 feature)
20198
20199 @noindent
20200   This AI remedies some inconsistencies in the legality rules for Pure units.
20201   Derived access types are legal in a pure unit (on the assumption that the
20202   rule for a zero storage pool size has been enforced on the ancestor type).
20203   The rules are enforced in generic instances and in subunits. GNAT has always
20204   implemented the recommended behavior.
20205
20206 @noindent
20207   RM References:  10.02.01 (15.1/2)   10.02.01 (15.4/2)   10.02.01 (15.5/2)   10.02.01 (17/2)
20208
20209
20210 @item
20211 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
20212 @cindex AI-0219 (Ada 2012 feature)
20213
20214 @noindent
20215   This AI refines the rules for the cases with limited parameters which do not
20216   allow the implementations to omit ``redundant''. GNAT now properly conforms
20217   to the requirements of this binding interpretation.
20218
20219 @noindent
20220   RM References:  10.02.01 (18/2)
20221
20222 @item
20223 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
20224 @cindex AI-0043 (Ada 2012 feature)
20225
20226 @noindent
20227   This AI covers various omissions in the RM regarding the raising of
20228   exceptions. GNAT has always implemented the intended semantics.
20229
20230 @noindent
20231   RM References:  11.04.01 (10.1/2)   11 (2)
20232
20233
20234 @item
20235 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
20236 @cindex AI-0200 (Ada 2012 feature)
20237
20238 @noindent
20239   This AI plugs a gap in the RM which appeared to allow some obviously intended
20240   illegal instantiations. GNAT has never allowed these instantiations.
20241
20242 @noindent
20243   RM References:  12.07 (16)
20244
20245
20246 @item
20247 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
20248 @cindex AI-0112 (Ada 2012 feature)
20249
20250 @noindent
20251   This AI concerns giving names to various representation aspects, but the
20252   practical effect is simply to make the use of duplicate
20253   @code{Atomic}[@code{_Components}],
20254   @code{Volatile}[@code{_Components}] and
20255   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
20256   now performs this required check.
20257
20258 @noindent
20259   RM References:  13.01 (8)
20260
20261 @item
20262 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
20263 @cindex AI-0106 (Ada 2012 feature)
20264
20265 @noindent
20266   The RM appeared to allow representation pragmas on generic formal parameters,
20267   but this was not intended, and GNAT has never permitted this usage.
20268
20269 @noindent
20270   RM References:  13.01 (9.1/1)
20271
20272
20273 @item
20274 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
20275 @cindex AI-0012 (Ada 2012 feature)
20276
20277 @noindent
20278   It is now illegal to give an inappropriate component size or a pragma
20279   @code{Pack} that attempts to change the component size in the case of atomic
20280   or aliased components. Previously GNAT ignored such an attempt with a
20281   warning.
20282
20283 @noindent
20284   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
20285
20286
20287 @item
20288 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
20289 @cindex AI-0039 (Ada 2012 feature)
20290
20291 @noindent
20292   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
20293   for stream attributes, but these were never useful and are now illegal. GNAT
20294   has always regarded such expressions as illegal.
20295
20296 @noindent
20297   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
20298
20299
20300 @item
20301 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
20302 @cindex AI-0095 (Ada 2012 feature)
20303
20304 @noindent
20305   The prefix of @code{'Address} cannot statically denote a subprogram with
20306   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
20307   @code{Program_Error} if the prefix denotes a subprogram with convention
20308   @code{Intrinsic}.
20309
20310 @noindent
20311   RM References:  13.03 (11/1)
20312
20313
20314 @item
20315 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
20316 @cindex AI-0116 (Ada 2012 feature)
20317
20318 @noindent
20319   This AI requires that the alignment of a class-wide object be no greater
20320   than the alignment of any type in the class. GNAT has always followed this
20321   recommendation.
20322
20323 @noindent
20324   RM References:  13.03 (29)   13.11 (16)
20325
20326
20327 @item
20328 @emph{AI-0146 Type invariants (2009-09-21)}
20329 @cindex AI-0146 (Ada 2012 feature)
20330
20331 @noindent
20332   Type invariants may be specified for private types using the aspect notation.
20333   Aspect @code{Type_Invariant} may be specified for any private type,
20334   @code{Type_Invariant'Class} can
20335   only be specified for tagged types, and is inherited by any descendent of the
20336   tagged types. The invariant is a boolean expression that is tested for being
20337   true in the following situations: conversions to the private type, object
20338   declarations for the private type that are default initialized, and
20339   [@b{in}] @b{out}
20340   parameters and returned result on return from any primitive operation for
20341   the type that is visible to a client.
20342   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
20343   @code{Invariant'Class} for @code{Type_Invariant'Class}.
20344
20345 @noindent
20346   RM References:  13.03.03 (00)
20347
20348 @item
20349 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
20350 @cindex AI-0078 (Ada 2012 feature)
20351
20352 @noindent
20353   In Ada 2012, compilers are required to support unchecked conversion where the
20354   target alignment is a multiple of the source alignment. GNAT always supported
20355   this case (and indeed all cases of differing alignments, doing copies where
20356   required if the alignment was reduced).
20357
20358 @noindent
20359   RM References:  13.09 (7)
20360
20361
20362 @item
20363 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
20364 @cindex AI-0195 (Ada 2012 feature)
20365
20366 @noindent
20367   The handling of invalid values is now designated to be implementation
20368   defined. This is a documentation change only, requiring Annex M in the GNAT
20369   Reference Manual to document this handling.
20370   In GNAT, checks for invalid values are made
20371   only when necessary to avoid erroneous behavior. Operations like assignments
20372   which cannot cause erroneous behavior ignore the possibility of invalid
20373   values and do not do a check. The date given above applies only to the
20374   documentation change, this behavior has always been implemented by GNAT.
20375
20376 @noindent
20377   RM References:  13.09.01 (10)
20378
20379 @item
20380 @emph{AI-0193 Alignment of allocators (2010-09-16)}
20381 @cindex AI-0193 (Ada 2012 feature)
20382
20383 @noindent
20384   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
20385   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
20386   of size.
20387
20388 @noindent
20389   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
20390   13.11.01 (2)   13.11.01 (3)
20391
20392
20393 @item
20394 @emph{AI-0177 Parameterized expressions (2010-07-10)}
20395 @cindex AI-0177 (Ada 2012 feature)
20396
20397 @noindent
20398   The new Ada 2012 notion of parameterized expressions is implemented. The form
20399   is:
20400 @smallexample
20401   @i{function specification} @b{is} (@i{expression})
20402 @end smallexample
20403
20404 @noindent
20405   This is exactly equivalent to the
20406   corresponding function body that returns the expression, but it can appear
20407   in a package spec. Note that the expression must be parenthesized.
20408
20409 @noindent
20410   RM References:  13.11.01 (3/2)
20411
20412 @item
20413 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
20414 @cindex AI-0033 (Ada 2012 feature)
20415
20416 @noindent
20417   Neither of these two pragmas may appear within a generic template, because
20418   the generic might be instantiated at other than the library level.
20419
20420 @noindent
20421   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
20422
20423
20424 @item
20425 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
20426 @cindex AI-0161 (Ada 2012 feature)
20427
20428 @noindent
20429   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
20430   of the default stream attributes for elementary types. If this restriction is
20431   in force, then it is necessary to provide explicit subprograms for any
20432   stream attributes used.
20433
20434 @noindent
20435   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
20436
20437 @item
20438 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
20439 @cindex AI-0194 (Ada 2012 feature)
20440
20441 @noindent
20442   The @code{Stream_Size} attribute returns the default number of bits in the
20443   stream representation of the given type.
20444   This value is not affected by the presence
20445   of stream subprogram attributes for the type. GNAT has always implemented
20446   this interpretation.
20447
20448 @noindent
20449   RM References:  13.13.02 (1.2/2)
20450
20451 @item
20452 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
20453 @cindex AI-0109 (Ada 2012 feature)
20454
20455 @noindent
20456   This AI is an editorial change only. It removes the need for a tag check
20457   that can never fail.
20458
20459 @noindent
20460   RM References:  13.13.02 (34/2)
20461
20462 @item
20463 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
20464 @cindex AI-0007 (Ada 2012 feature)
20465
20466 @noindent
20467   The RM as written appeared to limit the possibilities of declaring read
20468   attribute procedures for private scalar types. This limitation was not
20469   intended, and has never been enforced by GNAT.
20470
20471 @noindent
20472   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
20473
20474
20475 @item
20476 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
20477 @cindex AI-0065 (Ada 2012 feature)
20478
20479 @noindent
20480   This AI clarifies the fact that all remote access types support external
20481   streaming. This fixes an obvious oversight in the definition of the
20482   language, and GNAT always implemented the intended correct rules.
20483
20484 @noindent
20485   RM References:  13.13.02 (52/2)
20486
20487 @item
20488 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
20489 @cindex AI-0019 (Ada 2012 feature)
20490
20491 @noindent
20492   The RM suggests that primitive subprograms of a specific tagged type are
20493   frozen when the tagged type is frozen. This would be an incompatible change
20494   and is not intended. GNAT has never attempted this kind of freezing and its
20495   behavior is consistent with the recommendation of this AI.
20496
20497 @noindent
20498   RM References:  13.14 (2)   13.14 (3/1)   13.14 (8.1/1)   13.14 (10)   13.14 (14)   13.14 (15.1/2)
20499
20500 @item
20501 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
20502 @cindex AI-0017 (Ada 2012 feature)
20503
20504 @noindent
20505   So-called ``Taft-amendment types'' (i.e., types that are completed in package
20506   bodies) are not frozen by the occurrence of bodies in the
20507   enclosing declarative part. GNAT always implemented this properly.
20508
20509 @noindent
20510   RM References:  13.14 (3/1)
20511
20512
20513 @item
20514 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
20515 @cindex AI-0060 (Ada 2012 feature)
20516
20517 @noindent
20518   This AI extends the definition of remote access types to include access
20519   to limited, synchronized, protected or task class-wide interface types.
20520   GNAT already implemented this extension.
20521
20522 @noindent
20523   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
20524
20525 @item
20526 @emph{AI-0114 Classification of letters (0000-00-00)}
20527 @cindex AI-0114 (Ada 2012 feature)
20528
20529 @noindent
20530   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
20531   181 (@code{MICRO SIGN}), and
20532   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
20533   lower case letters by Unicode.
20534   However, they are not allowed in identifiers, and they
20535   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
20536   This behavior is consistent with that defined in Ada 95.
20537
20538 @noindent
20539   RM References:  A.03.02 (59)   A.04.06 (7)
20540
20541
20542 @item
20543 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
20544 @cindex AI-0185 (Ada 2012 feature)
20545
20546 @noindent
20547   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
20548   classification functions for @code{Wide_Character} and
20549   @code{Wide_Wide_Character}, as well as providing
20550   case folding routines for @code{Wide_[Wide_]Character} and
20551   @code{Wide_[Wide_]String}.
20552
20553 @noindent
20554   RM References:  A.03.05 (0)   A.03.06 (0)
20555
20556
20557 @item
20558 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
20559 @cindex AI-0031 (Ada 2012 feature)
20560
20561 @noindent
20562   A new version of @code{Find_Token} is added to all relevant string packages,
20563   with an extra parameter @code{From}. Instead of starting at the first
20564   character of the string, the search for a matching Token starts at the
20565   character indexed by the value of @code{From}.
20566   These procedures are available in all versions of Ada
20567   but if used in versions earlier than Ada 2012 they will generate a warning
20568   that an Ada 2012 subprogram is being used.
20569
20570 @noindent
20571   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
20572   A.04.05 (46)
20573
20574
20575 @item
20576 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
20577 @cindex AI-0056 (Ada 2012 feature)
20578
20579 @noindent
20580   The wording in the Ada 2005 RM implied an incompatible handling of the
20581   @code{Index} functions, resulting in raising an exception instead of
20582   returning zero in some situations.
20583   This was not intended and has been corrected.
20584   GNAT always returned zero, and is thus consistent with this AI.
20585
20586 @noindent
20587   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
20588
20589
20590 @item
20591 @emph{AI-0137 String encoding package (2010-03-25)}
20592 @cindex AI-0137 (Ada 2012 feature)
20593
20594 @noindent
20595   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
20596   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
20597   and @code{Wide_Wide_Strings} have been
20598   implemented. These packages (whose documentation can be found in the spec
20599   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
20600   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
20601   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
20602   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
20603   UTF-16), as well as conversions between the different UTF encodings. With
20604   the exception of @code{Wide_Wide_Strings}, these packages are available in
20605   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
20606   The @code{Wide_Wide_Strings package}
20607   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
20608   mode since it uses @code{Wide_Wide_Character}).
20609
20610 @noindent
20611   RM References:  A.04.11
20612
20613 @item
20614 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
20615 @cindex AI-0038 (Ada 2012 feature)
20616
20617 @noindent
20618   These are minor errors in the description on three points. The intent on
20619   all these points has always been clear, and GNAT has always implemented the
20620   correct intended semantics.
20621
20622 @noindent
20623   RM References:  A.10.05 (37)   A.10.07 (8/1)   A.10.07 (10)   A.10.07 (12)   A.10.08 (10)   A.10.08 (24)
20624
20625 @item
20626 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
20627 @cindex AI-0044 (Ada 2012 feature)
20628
20629 @noindent
20630   This AI places restrictions on allowed instantiations of generic containers.
20631   These restrictions are not checked by the compiler, so there is nothing to
20632   change in the implementation. This affects only the RM documentation.
20633
20634 @noindent
20635   RM References:  A.18 (4/2)   A.18.02 (231/2)   A.18.03 (145/2)   A.18.06 (56/2)   A.18.08 (66/2)   A.18.09 (79/2)   A.18.26 (5/2)   A.18.26 (9/2)
20636
20637 @item
20638 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
20639 @cindex AI-0127 (Ada 2012 feature)
20640
20641 @noindent
20642   This package provides an interface for identifying the current locale.
20643
20644 @noindent
20645   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
20646   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
20647
20648
20649
20650 @item
20651 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
20652 @cindex AI-0002 (Ada 2012 feature)
20653
20654 @noindent
20655   The compiler is not required to support exporting an Ada subprogram with
20656   convention C if there are parameters or a return type of an unconstrained
20657   array type (such as @code{String}). GNAT allows such declarations but
20658   generates warnings. It is possible, but complicated, to write the
20659   corresponding C code and certainly such code would be specific to GNAT and
20660   non-portable.
20661
20662 @noindent
20663   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
20664
20665
20666 @item
20667 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
20668 @cindex AI05-0216 (Ada 2012 feature)
20669
20670 @noindent
20671   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
20672   forbid tasks declared locally within subprograms, or functions returning task
20673   objects, and that is the implementation that GNAT has always provided.
20674   However the language in the RM was not sufficiently clear on this point.
20675   Thus this is a documentation change in the RM only.
20676
20677 @noindent
20678   RM References:  D.07 (3/3)
20679
20680 @item
20681 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
20682 @cindex AI-0211 (Ada 2012 feature)
20683
20684 @noindent
20685   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
20686   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
20687
20688 @noindent
20689   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
20690
20691 @item
20692 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
20693 @cindex AI-0190 (Ada 2012 feature)
20694
20695 @noindent
20696   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
20697   used to control storage pools globally.
20698   In particular, you can force every access
20699   type that is used for allocation (@b{new}) to have an explicit storage pool,
20700   or you can declare a pool globally to be used for all access types that lack
20701   an explicit one.
20702
20703 @noindent
20704   RM References:  D.07 (8)
20705
20706 @item
20707 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
20708 @cindex AI-0189 (Ada 2012 feature)
20709
20710 @noindent
20711   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
20712   which says that no dynamic allocation will occur once elaboration is
20713   completed.
20714   In general this requires a run-time check, which is not required, and which
20715   GNAT does not attempt. But the static cases of allocators in a task body or
20716   in the body of the main program are detected and flagged at compile or bind
20717   time.
20718
20719 @noindent
20720   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
20721
20722 @item
20723 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
20724 @cindex AI-0171 (Ada 2012 feature)
20725
20726 @noindent
20727   A new package @code{System.Multiprocessors} is added, together with the
20728   definition of pragma @code{CPU} for controlling task affinity. A new no
20729   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
20730   is added to the Ravenscar profile.
20731
20732 @noindent
20733   RM References:  D.13.01 (4/2)   D.16
20734
20735
20736 @item
20737 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
20738 @cindex AI-0210 (Ada 2012 feature)
20739
20740 @noindent
20741   This is a documentation only issue regarding wording of metric requirements,
20742   that does not affect the implementation of the compiler.
20743
20744 @noindent
20745   RM References:  D.15 (24/2)
20746
20747
20748 @item
20749 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
20750 @cindex AI-0206 (Ada 2012 feature)
20751
20752 @noindent
20753   Remote types packages are now allowed to depend on preelaborated packages.
20754   This was formerly considered illegal.
20755
20756 @noindent
20757   RM References:  E.02.02 (6)
20758
20759
20760
20761 @item
20762 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
20763 @cindex AI-0152 (Ada 2012 feature)
20764
20765 @noindent
20766   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
20767   where the type of the returned value is an anonymous access type.
20768
20769 @noindent
20770   RM References:  H.04 (8/1)
20771 @end itemize
20772
20773
20774 @node Obsolescent Features
20775 @chapter Obsolescent Features
20776
20777 @noindent
20778 This chapter describes features that are provided by GNAT, but are
20779 considered obsolescent since there are preferred ways of achieving
20780 the same effect. These features are provided solely for historical
20781 compatibility purposes.
20782
20783 @menu
20784 * pragma No_Run_Time::
20785 * pragma Ravenscar::
20786 * pragma Restricted_Run_Time::
20787 @end menu
20788
20789 @node pragma No_Run_Time
20790 @section pragma No_Run_Time
20791
20792 The pragma @code{No_Run_Time} is used to achieve an affect similar
20793 to the use of the "Zero Foot Print" configurable run time, but without
20794 requiring a specially configured run time. The result of using this
20795 pragma, which must be used for all units in a partition, is to restrict
20796 the use of any language features requiring run-time support code. The
20797 preferred usage is to use an appropriately configured run-time that
20798 includes just those features that are to be made accessible.
20799
20800 @node pragma Ravenscar
20801 @section pragma Ravenscar
20802
20803 The pragma @code{Ravenscar} has exactly the same effect as pragma
20804 @code{Profile (Ravenscar)}. The latter usage is preferred since it
20805 is part of the new Ada 2005 standard.
20806
20807 @node pragma Restricted_Run_Time
20808 @section pragma Restricted_Run_Time
20809
20810 The pragma @code{Restricted_Run_Time} has exactly the same effect as
20811 pragma @code{Profile (Restricted)}. The latter usage is
20812 preferred since the Ada 2005 pragma @code{Profile} is intended for
20813 this kind of implementation dependent addition.
20814
20815 @include fdl.texi
20816 @c GNU Free Documentation License
20817
20818 @node Index,,GNU Free Documentation License, Top
20819 @unnumbered Index
20820
20821 @printindex cp
20822
20823 @contents
20824
20825 @bye
20826 tablishes the following set of restrictions:
20827 Pragma Shared