Skip several gcc.dg/builtin-dynamic-object-size tests on hppa*-*-hpux*
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob5dbc04b19a3b9900dcdace72541c2c2148daab18
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename gnat_rm.info
4 @documentencoding UTF-8
5 @ifinfo
6 @*Generated by Sphinx 5.3.0.@*
7 @end ifinfo
8 @settitle GNAT Reference Manual
9 @defindex ge
10 @paragraphindent 0
11 @exampleindent 4
12 @finalout
13 @dircategory GNU Ada Tools 
14 @direntry
15 * gnat_rm: (gnat_rm.info). gnat_rm
16 @end direntry
18 @c %**end of header
20 @copying
21 @quotation
22 GNAT Reference Manual , Dec 21, 2023
24 AdaCore
26 Copyright @copyright{} 2008-2024, Free Software Foundation
27 @end quotation
29 @end copying
31 @titlepage
32 @title GNAT Reference Manual
33 @insertcopying
34 @end titlepage
35 @contents
37 @c %** start of user preamble
39 @c %** end of user preamble
41 @ifnottex
42 @node Top
43 @top GNAT Reference Manual
44 @insertcopying
45 @end ifnottex
47 @c %**start of body
48 @anchor{gnat_rm doc}@anchor{0}
49 `GNAT, The GNU Ada Development Environment'
52 @include gcc-common.texi
53 GCC version @value{version-GCC}@*
54 AdaCore
56 Permission is granted to copy, distribute and/or modify this document
57 under the terms of the GNU Free Documentation License, Version 1.3 or
58 any later version published by the Free Software Foundation; with no
59 Invariant Sections, with the Front-Cover Texts being “GNAT Reference
60 Manual”, and with no Back-Cover Texts.  A copy of the license is
61 included in the section entitled @ref{1,,GNU Free Documentation License}.
63 @menu
64 * About This Guide:: 
65 * Implementation Defined Pragmas:: 
66 * Implementation Defined Aspects:: 
67 * Implementation Defined Attributes:: 
68 * Standard and Implementation Defined Restrictions:: 
69 * Implementation Advice:: 
70 * Implementation Defined Characteristics:: 
71 * Intrinsic Subprograms:: 
72 * Representation Clauses and Pragmas:: 
73 * Standard Library Routines:: 
74 * The Implementation of Standard I/O:: 
75 * The GNAT Library:: 
76 * Interfacing to Other Languages:: 
77 * Specialized Needs Annexes:: 
78 * Implementation of Specific Ada Features:: 
79 * Implementation of Ada 2012 Features:: 
80 * GNAT language extensions:: 
81 * Security Hardening Features:: 
82 * Obsolescent Features:: 
83 * Compatibility and Porting Guide:: 
84 * GNU Free Documentation License:: 
85 * Index:: 
87 @detailmenu
88  --- The Detailed Node Listing ---
90 About This Guide
92 * What This Reference Manual Contains:: 
93 * Conventions:: 
94 * Related Information:: 
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer:: 
99 * Pragma Abstract_State:: 
100 * Pragma Ada_83:: 
101 * Pragma Ada_95:: 
102 * Pragma Ada_05:: 
103 * Pragma Ada_2005:: 
104 * Pragma Ada_12:: 
105 * Pragma Ada_2012:: 
106 * Pragma Ada_2022:: 
107 * Pragma Aggregate_Individually_Assign:: 
108 * Pragma Allow_Integer_Address:: 
109 * Pragma Always_Terminates:: 
110 * Pragma Annotate:: 
111 * Pragma Assert:: 
112 * Pragma Assert_And_Cut:: 
113 * Pragma Assertion_Policy:: 
114 * Pragma Assume:: 
115 * Pragma Assume_No_Invalid_Values:: 
116 * Pragma Async_Readers:: 
117 * Pragma Async_Writers:: 
118 * Pragma Attribute_Definition:: 
119 * Pragma C_Pass_By_Copy:: 
120 * Pragma Check:: 
121 * Pragma Check_Float_Overflow:: 
122 * Pragma Check_Name:: 
123 * Pragma Check_Policy:: 
124 * Pragma Comment:: 
125 * Pragma Common_Object:: 
126 * Pragma Compile_Time_Error:: 
127 * Pragma Compile_Time_Warning:: 
128 * Pragma Complete_Representation:: 
129 * Pragma Complex_Representation:: 
130 * Pragma Component_Alignment:: 
131 * Pragma Constant_After_Elaboration:: 
132 * Pragma Contract_Cases:: 
133 * Pragma Convention_Identifier:: 
134 * Pragma CPP_Class:: 
135 * Pragma CPP_Constructor:: 
136 * Pragma CPP_Virtual:: 
137 * Pragma CPP_Vtable:: 
138 * Pragma CPU:: 
139 * Pragma Deadline_Floor:: 
140 * Pragma Debug:: 
141 * Pragma Debug_Policy:: 
142 * Pragma Default_Initial_Condition:: 
143 * Pragma Default_Scalar_Storage_Order:: 
144 * Pragma Default_Storage_Pool:: 
145 * Pragma Depends:: 
146 * Pragma Detect_Blocking:: 
147 * Pragma Disable_Atomic_Synchronization:: 
148 * Pragma Dispatching_Domain:: 
149 * Pragma Effective_Reads:: 
150 * Pragma Effective_Writes:: 
151 * Pragma Elaboration_Checks:: 
152 * Pragma Eliminate:: 
153 * Pragma Enable_Atomic_Synchronization:: 
154 * Pragma Export_Function:: 
155 * Pragma Export_Object:: 
156 * Pragma Export_Procedure:: 
157 * Pragma Export_Valued_Procedure:: 
158 * Pragma Extend_System:: 
159 * Pragma Extensions_Allowed:: 
160 * Pragma Extensions_Visible:: 
161 * Pragma External:: 
162 * Pragma External_Name_Casing:: 
163 * Pragma Fast_Math:: 
164 * Pragma Favor_Top_Level:: 
165 * Pragma Finalize_Storage_Only:: 
166 * Pragma Float_Representation:: 
167 * Pragma Ghost:: 
168 * Pragma Global:: 
169 * Pragma Ident:: 
170 * Pragma Ignore_Pragma:: 
171 * Pragma Implementation_Defined:: 
172 * Pragma Implemented:: 
173 * Pragma Implicit_Packing:: 
174 * Pragma Import_Function:: 
175 * Pragma Import_Object:: 
176 * Pragma Import_Procedure:: 
177 * Pragma Import_Valued_Procedure:: 
178 * Pragma Independent:: 
179 * Pragma Independent_Components:: 
180 * Pragma Initial_Condition:: 
181 * Pragma Initialize_Scalars:: 
182 * Pragma Initializes:: 
183 * Pragma Inline_Always:: 
184 * Pragma Inline_Generic:: 
185 * Pragma Interface:: 
186 * Pragma Interface_Name:: 
187 * Pragma Interrupt_Handler:: 
188 * Pragma Interrupt_State:: 
189 * Pragma Invariant:: 
190 * Pragma Keep_Names:: 
191 * Pragma License:: 
192 * Pragma Link_With:: 
193 * Pragma Linker_Alias:: 
194 * Pragma Linker_Constructor:: 
195 * Pragma Linker_Destructor:: 
196 * Pragma Linker_Section:: 
197 * Pragma Lock_Free:: 
198 * Pragma Loop_Invariant:: 
199 * Pragma Loop_Optimize:: 
200 * Pragma Loop_Variant:: 
201 * Pragma Machine_Attribute:: 
202 * Pragma Main:: 
203 * Pragma Main_Storage:: 
204 * Pragma Max_Queue_Length:: 
205 * Pragma No_Body:: 
206 * Pragma No_Caching:: 
207 * Pragma No_Component_Reordering:: 
208 * Pragma No_Elaboration_Code_All:: 
209 * Pragma No_Heap_Finalization:: 
210 * Pragma No_Inline:: 
211 * Pragma No_Return:: 
212 * Pragma No_Strict_Aliasing:: 
213 * Pragma No_Tagged_Streams:: 
214 * Pragma Normalize_Scalars:: 
215 * Pragma Obsolescent:: 
216 * Pragma Optimize_Alignment:: 
217 * Pragma Ordered:: 
218 * Pragma Overflow_Mode:: 
219 * Pragma Overriding_Renamings:: 
220 * Pragma Part_Of:: 
221 * Pragma Partition_Elaboration_Policy:: 
222 * Pragma Passive:: 
223 * Pragma Persistent_BSS:: 
224 * Pragma Post:: 
225 * Pragma Postcondition:: 
226 * Pragma Post_Class:: 
227 * Pragma Pre:: 
228 * Pragma Precondition:: 
229 * Pragma Predicate:: 
230 * Pragma Predicate_Failure:: 
231 * Pragma Preelaborable_Initialization:: 
232 * Pragma Prefix_Exception_Messages:: 
233 * Pragma Pre_Class:: 
234 * Pragma Priority_Specific_Dispatching:: 
235 * Pragma Profile:: 
236 * Pragma Profile_Warnings:: 
237 * Pragma Propagate_Exceptions:: 
238 * Pragma Provide_Shift_Operators:: 
239 * Pragma Psect_Object:: 
240 * Pragma Pure_Function:: 
241 * Pragma Rational:: 
242 * Pragma Ravenscar:: 
243 * Pragma Refined_Depends:: 
244 * Pragma Refined_Global:: 
245 * Pragma Refined_Post:: 
246 * Pragma Refined_State:: 
247 * Pragma Relative_Deadline:: 
248 * Pragma Remote_Access_Type:: 
249 * Pragma Rename_Pragma:: 
250 * Pragma Restricted_Run_Time:: 
251 * Pragma Restriction_Warnings:: 
252 * Pragma Reviewable:: 
253 * Pragma Secondary_Stack_Size:: 
254 * Pragma Share_Generic:: 
255 * Pragma Shared:: 
256 * Pragma Short_Circuit_And_Or:: 
257 * Pragma Short_Descriptors:: 
258 * Pragma Side_Effects:: 
259 * Pragma Simple_Storage_Pool_Type:: 
260 * Pragma Source_File_Name:: 
261 * Pragma Source_File_Name_Project:: 
262 * Pragma Source_Reference:: 
263 * Pragma SPARK_Mode:: 
264 * Pragma Static_Elaboration_Desired:: 
265 * Pragma Stream_Convert:: 
266 * Pragma Style_Checks:: 
267 * Pragma Subtitle:: 
268 * Pragma Suppress:: 
269 * Pragma Suppress_All:: 
270 * Pragma Suppress_Debug_Info:: 
271 * Pragma Suppress_Exception_Locations:: 
272 * Pragma Suppress_Initialization:: 
273 * Pragma Task_Name:: 
274 * Pragma Task_Storage:: 
275 * Pragma Test_Case:: 
276 * Pragma Thread_Local_Storage:: 
277 * Pragma Time_Slice:: 
278 * Pragma Title:: 
279 * Pragma Type_Invariant:: 
280 * Pragma Type_Invariant_Class:: 
281 * Pragma Unchecked_Union:: 
282 * Pragma Unevaluated_Use_Of_Old:: 
283 * Pragma User_Aspect_Definition:: 
284 * Pragma Unimplemented_Unit:: 
285 * Pragma Universal_Aliasing:: 
286 * Pragma Unmodified:: 
287 * Pragma Unreferenced:: 
288 * Pragma Unreferenced_Objects:: 
289 * Pragma Unreserve_All_Interrupts:: 
290 * Pragma Unsuppress:: 
291 * Pragma Unused:: 
292 * Pragma Use_VADS_Size:: 
293 * Pragma Validity_Checks:: 
294 * Pragma Volatile:: 
295 * Pragma Volatile_Full_Access:: 
296 * Pragma Volatile_Function:: 
297 * Pragma Warning_As_Error:: 
298 * Pragma Warnings:: 
299 * Pragma Weak_External:: 
300 * Pragma Wide_Character_Encoding:: 
302 Implementation Defined Aspects
304 * Aspect Abstract_State:: 
305 * Aspect Always_Terminates:: 
306 * Aspect Annotate:: 
307 * Aspect Async_Readers:: 
308 * Aspect Async_Writers:: 
309 * Aspect Constant_After_Elaboration:: 
310 * Aspect Contract_Cases:: 
311 * Aspect Depends:: 
312 * Aspect Default_Initial_Condition:: 
313 * Aspect Dimension:: 
314 * Aspect Dimension_System:: 
315 * Aspect Disable_Controlled:: 
316 * Aspect Effective_Reads:: 
317 * Aspect Effective_Writes:: 
318 * Aspect Extensions_Visible:: 
319 * Aspect Favor_Top_Level:: 
320 * Aspect Ghost:: 
321 * Aspect Ghost_Predicate:: 
322 * Aspect Global:: 
323 * Aspect Initial_Condition:: 
324 * Aspect Initializes:: 
325 * Aspect Inline_Always:: 
326 * Aspect Invariant:: 
327 * Aspect Invariant’Class:: 
328 * Aspect Iterable:: 
329 * Aspect Linker_Section:: 
330 * Aspect Local_Restrictions:: 
331 * Aspect Lock_Free:: 
332 * Aspect Max_Queue_Length:: 
333 * Aspect No_Caching:: 
334 * Aspect No_Elaboration_Code_All:: 
335 * Aspect No_Inline:: 
336 * Aspect No_Tagged_Streams:: 
337 * Aspect No_Task_Parts:: 
338 * Aspect Object_Size:: 
339 * Aspect Obsolescent:: 
340 * Aspect Part_Of:: 
341 * Aspect Persistent_BSS:: 
342 * Aspect Predicate:: 
343 * Aspect Pure_Function:: 
344 * Aspect Refined_Depends:: 
345 * Aspect Refined_Global:: 
346 * Aspect Refined_Post:: 
347 * Aspect Refined_State:: 
348 * Aspect Relaxed_Initialization:: 
349 * Aspect Remote_Access_Type:: 
350 * Aspect Secondary_Stack_Size:: 
351 * Aspect Scalar_Storage_Order:: 
352 * Aspect Shared:: 
353 * Aspect Side_Effects:: 
354 * Aspect Simple_Storage_Pool:: 
355 * Aspect Simple_Storage_Pool_Type:: 
356 * Aspect SPARK_Mode:: 
357 * Aspect Suppress_Debug_Info:: 
358 * Aspect Suppress_Initialization:: 
359 * Aspect Test_Case:: 
360 * Aspect Thread_Local_Storage:: 
361 * Aspect Universal_Aliasing:: 
362 * Aspect Unmodified:: 
363 * Aspect Unreferenced:: 
364 * Aspect Unreferenced_Objects:: 
365 * Aspect User_Aspect:: 
366 * Aspect Value_Size:: 
367 * Aspect Volatile_Full_Access:: 
368 * Aspect Volatile_Function:: 
369 * Aspect Warnings:: 
371 Implementation Defined Attributes
373 * Attribute Abort_Signal:: 
374 * Attribute Address_Size:: 
375 * Attribute Asm_Input:: 
376 * Attribute Asm_Output:: 
377 * Attribute Atomic_Always_Lock_Free:: 
378 * Attribute Bit:: 
379 * Attribute Bit_Position:: 
380 * Attribute Code_Address:: 
381 * Attribute Compiler_Version:: 
382 * Attribute Constrained:: 
383 * Attribute Default_Bit_Order:: 
384 * Attribute Default_Scalar_Storage_Order:: 
385 * Attribute Deref:: 
386 * Attribute Descriptor_Size:: 
387 * Attribute Elaborated:: 
388 * Attribute Elab_Body:: 
389 * Attribute Elab_Spec:: 
390 * Attribute Elab_Subp_Body:: 
391 * Attribute Emax:: 
392 * Attribute Enabled:: 
393 * Attribute Enum_Rep:: 
394 * Attribute Enum_Val:: 
395 * Attribute Epsilon:: 
396 * Attribute Fast_Math:: 
397 * Attribute Finalization_Size:: 
398 * Attribute Fixed_Value:: 
399 * Attribute From_Any:: 
400 * Attribute Has_Access_Values:: 
401 * Attribute Has_Discriminants:: 
402 * Attribute Has_Tagged_Values:: 
403 * Attribute Img:: 
404 * Attribute Initialized:: 
405 * Attribute Integer_Value:: 
406 * Attribute Invalid_Value:: 
407 * Attribute Iterable:: 
408 * Attribute Large:: 
409 * Attribute Library_Level:: 
410 * Attribute Loop_Entry:: 
411 * Attribute Machine_Size:: 
412 * Attribute Mantissa:: 
413 * Attribute Maximum_Alignment:: 
414 * Attribute Max_Integer_Size:: 
415 * Attribute Mechanism_Code:: 
416 * Attribute Null_Parameter:: 
417 * Attribute Object_Size:: 
418 * Attribute Old:: 
419 * Attribute Passed_By_Reference:: 
420 * Attribute Pool_Address:: 
421 * Attribute Range_Length:: 
422 * Attribute Restriction_Set:: 
423 * Attribute Result:: 
424 * Attribute Safe_Emax:: 
425 * Attribute Safe_Large:: 
426 * Attribute Safe_Small:: 
427 * Attribute Scalar_Storage_Order:: 
428 * Attribute Simple_Storage_Pool:: 
429 * Attribute Small:: 
430 * Attribute Small_Denominator:: 
431 * Attribute Small_Numerator:: 
432 * Attribute Storage_Unit:: 
433 * Attribute Stub_Type:: 
434 * Attribute System_Allocator_Alignment:: 
435 * Attribute Target_Name:: 
436 * Attribute To_Address:: 
437 * Attribute To_Any:: 
438 * Attribute Type_Class:: 
439 * Attribute Type_Key:: 
440 * Attribute TypeCode:: 
441 * Attribute Unconstrained_Array:: 
442 * Attribute Universal_Literal_String:: 
443 * Attribute Unrestricted_Access:: 
444 * Attribute Update:: 
445 * Attribute Valid_Value:: 
446 * Attribute Valid_Scalars:: 
447 * Attribute VADS_Size:: 
448 * Attribute Value_Size:: 
449 * Attribute Wchar_T_Size:: 
450 * Attribute Word_Size:: 
452 Standard and Implementation Defined Restrictions
454 * Partition-Wide Restrictions:: 
455 * Program Unit Level Restrictions:: 
457 Partition-Wide Restrictions
459 * Immediate_Reclamation:: 
460 * Max_Asynchronous_Select_Nesting:: 
461 * Max_Entry_Queue_Length:: 
462 * Max_Protected_Entries:: 
463 * Max_Select_Alternatives:: 
464 * Max_Storage_At_Blocking:: 
465 * Max_Task_Entries:: 
466 * Max_Tasks:: 
467 * No_Abort_Statements:: 
468 * No_Access_Parameter_Allocators:: 
469 * No_Access_Subprograms:: 
470 * No_Allocators:: 
471 * No_Anonymous_Allocators:: 
472 * No_Asynchronous_Control:: 
473 * No_Calendar:: 
474 * No_Coextensions:: 
475 * No_Default_Initialization:: 
476 * No_Delay:: 
477 * No_Dependence:: 
478 * No_Direct_Boolean_Operators:: 
479 * No_Dispatch:: 
480 * No_Dispatching_Calls:: 
481 * No_Dynamic_Attachment:: 
482 * No_Dynamic_Priorities:: 
483 * No_Entry_Calls_In_Elaboration_Code:: 
484 * No_Enumeration_Maps:: 
485 * No_Exception_Handlers:: 
486 * No_Exception_Propagation:: 
487 * No_Exception_Registration:: 
488 * No_Exceptions:: 
489 * No_Finalization:: 
490 * No_Fixed_Point:: 
491 * No_Floating_Point:: 
492 * No_Implicit_Conditionals:: 
493 * No_Implicit_Dynamic_Code:: 
494 * No_Implicit_Heap_Allocations:: 
495 * No_Implicit_Protected_Object_Allocations:: 
496 * No_Implicit_Task_Allocations:: 
497 * No_Initialize_Scalars:: 
498 * No_IO:: 
499 * No_Local_Allocators:: 
500 * No_Local_Protected_Objects:: 
501 * No_Local_Tagged_Types:: 
502 * No_Local_Timing_Events:: 
503 * No_Long_Long_Integers:: 
504 * No_Multiple_Elaboration:: 
505 * No_Nested_Finalization:: 
506 * No_Protected_Type_Allocators:: 
507 * No_Protected_Types:: 
508 * No_Recursion:: 
509 * No_Reentrancy:: 
510 * No_Relative_Delay:: 
511 * No_Requeue_Statements:: 
512 * No_Secondary_Stack:: 
513 * No_Select_Statements:: 
514 * No_Specific_Termination_Handlers:: 
515 * No_Specification_of_Aspect:: 
516 * No_Standard_Allocators_After_Elaboration:: 
517 * No_Standard_Storage_Pools:: 
518 * No_Stream_Optimizations:: 
519 * No_Streams:: 
520 * No_Tagged_Type_Registration:: 
521 * No_Task_Allocators:: 
522 * No_Task_At_Interrupt_Priority:: 
523 * No_Task_Attributes_Package:: 
524 * No_Task_Hierarchy:: 
525 * No_Task_Termination:: 
526 * No_Tasking:: 
527 * No_Terminate_Alternatives:: 
528 * No_Unchecked_Access:: 
529 * No_Unchecked_Conversion:: 
530 * No_Unchecked_Deallocation:: 
531 * No_Use_Of_Attribute:: 
532 * No_Use_Of_Entity:: 
533 * No_Use_Of_Pragma:: 
534 * Pure_Barriers:: 
535 * Simple_Barriers:: 
536 * Static_Priorities:: 
537 * Static_Storage_Size:: 
539 Program Unit Level Restrictions
541 * No_Elaboration_Code:: 
542 * No_Dynamic_Accessibility_Checks:: 
543 * No_Dynamic_Sized_Objects:: 
544 * No_Entry_Queue:: 
545 * No_Implementation_Aspect_Specifications:: 
546 * No_Implementation_Attributes:: 
547 * No_Implementation_Identifiers:: 
548 * No_Implementation_Pragmas:: 
549 * No_Implementation_Restrictions:: 
550 * No_Implementation_Units:: 
551 * No_Implicit_Aliasing:: 
552 * No_Implicit_Loops:: 
553 * No_Obsolescent_Features:: 
554 * No_Wide_Characters:: 
555 * Static_Dispatch_Tables:: 
556 * SPARK_05:: 
558 Implementation Advice
560 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection. 
561 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units. 
562 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors. 
563 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas. 
564 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas. 
565 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets. 
566 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types. 
567 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types. 
568 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values. 
569 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types. 
570 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays. 
571 * RM 9.6(30-31); Duration’Small: RM 9 6 30-31 Duration’Small. 
572 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation. 
573 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information. 
574 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks. 
575 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses. 
576 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types. 
577 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses. 
578 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses. 
579 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses. 
580 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses. 
581 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses. 
582 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses. 
583 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses. 
584 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes. 
585 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering. 
586 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private. 
587 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations. 
588 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion. 
589 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage. 
590 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation. 
591 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes. 
592 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types. 
593 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling. 
594 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling. 
595 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation. 
596 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate. 
597 * RM A.18; Containers: RM A 18 Containers. 
598 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export. 
599 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces. 
600 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C. 
601 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL. 
602 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran. 
603 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations. 
604 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations. 
605 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support. 
606 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers. 
607 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts. 
608 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements. 
609 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names. 
610 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes. 
611 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies. 
612 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies. 
613 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort. 
614 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions. 
615 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time. 
616 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem. 
617 * RM F(7); COBOL Support: RM F 7 COBOL Support. 
618 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support. 
619 * RM G; Numerics: RM G Numerics. 
620 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types. 
621 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions. 
622 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements. 
623 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy. 
624 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy. 
626 Intrinsic Subprograms
628 * Intrinsic Operators:: 
629 * Compilation_ISO_Date:: 
630 * Compilation_Date:: 
631 * Compilation_Time:: 
632 * Enclosing_Entity:: 
633 * Exception_Information:: 
634 * Exception_Message:: 
635 * Exception_Name:: 
636 * File:: 
637 * Line:: 
638 * Shifts and Rotates:: 
639 * Source_Location:: 
641 Representation Clauses and Pragmas
643 * Alignment Clauses:: 
644 * Size Clauses:: 
645 * Storage_Size Clauses:: 
646 * Size of Variant Record Objects:: 
647 * Biased Representation:: 
648 * Value_Size and Object_Size Clauses:: 
649 * Component_Size Clauses:: 
650 * Bit_Order Clauses:: 
651 * Effect of Bit_Order on Byte Ordering:: 
652 * Pragma Pack for Arrays:: 
653 * Pragma Pack for Records:: 
654 * Record Representation Clauses:: 
655 * Handling of Records with Holes:: 
656 * Enumeration Clauses:: 
657 * Address Clauses:: 
658 * Use of Address Clauses for Memory-Mapped I/O:: 
659 * Effect of Convention on Representation:: 
660 * Conventions and Anonymous Access Types:: 
661 * Determining the Representations chosen by GNAT:: 
663 The Implementation of Standard I/O
665 * Standard I/O Packages:: 
666 * FORM Strings:: 
667 * Direct_IO:: 
668 * Sequential_IO:: 
669 * Text_IO:: 
670 * Wide_Text_IO:: 
671 * Wide_Wide_Text_IO:: 
672 * Stream_IO:: 
673 * Text Translation:: 
674 * Shared Files:: 
675 * Filenames encoding:: 
676 * File content encoding:: 
677 * Open Modes:: 
678 * Operations on C Streams:: 
679 * Interfacing to C Streams:: 
681 Text_IO
683 * Stream Pointer Positioning:: 
684 * Reading and Writing Non-Regular Files:: 
685 * Get_Immediate:: 
686 * Treating Text_IO Files as Streams:: 
687 * Text_IO Extensions:: 
688 * Text_IO Facilities for Unbounded Strings:: 
690 Wide_Text_IO
692 * Stream Pointer Positioning: Stream Pointer Positioning<2>. 
693 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>. 
695 Wide_Wide_Text_IO
697 * Stream Pointer Positioning: Stream Pointer Positioning<3>. 
698 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>. 
700 The GNAT Library
702 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads. 
703 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads. 
704 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads): Ada Characters Wide_Latin_9 a-cwila9 ads. 
705 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads. 
706 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads. 
707 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads. 
708 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads. 
709 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads. 
710 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads. 
711 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads. 
712 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads. 
713 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads. 
714 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads. 
715 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads. 
716 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads. 
717 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads. 
718 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads. 
719 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads. 
720 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads. 
721 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads. 
722 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads. 
723 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads. 
724 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads. 
725 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads. 
726 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads. 
727 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads. 
728 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads. 
729 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads. 
730 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads. 
731 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads. 
732 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads. 
733 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads. 
734 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads. 
735 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads. 
736 * GNAT.Binary_Search (g-binsea.ads): GNAT Binary_Search g-binsea ads. 
737 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads. 
738 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads. 
739 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads. 
740 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads. 
741 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads. 
742 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads. 
743 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads. 
744 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads. 
745 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads. 
746 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads. 
747 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads. 
748 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads. 
749 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads. 
750 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads. 
751 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads. 
752 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads. 
753 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads. 
754 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads. 
755 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads. 
756 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads. 
757 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads. 
758 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads. 
759 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads. 
760 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads. 
761 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads. 
762 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads. 
763 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads. 
764 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads. 
765 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads. 
766 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads. 
767 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads. 
768 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads. 
769 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads. 
770 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads. 
771 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads. 
772 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads. 
773 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads. 
774 * GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads): GNAT Generic_Fast_Math_Functions g-gfmafu ads. 
775 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads. 
776 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads. 
777 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads. 
778 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads. 
779 * GNAT.IO (g-io.ads): GNAT IO g-io ads. 
780 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads. 
781 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads. 
782 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads. 
783 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads. 
784 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads. 
785 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads. 
786 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads. 
787 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads. 
788 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads. 
789 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads. 
790 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads. 
791 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads. 
792 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads. 
793 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads. 
794 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads. 
795 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads. 
796 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads. 
797 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads. 
798 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads. 
799 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads. 
800 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads. 
801 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads. 
802 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads. 
803 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads. 
804 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads. 
805 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads. 
806 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads. 
807 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads. 
808 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads. 
809 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads. 
810 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads. 
811 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads. 
812 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads. 
813 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads. 
814 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads. 
815 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads. 
816 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads. 
817 * GNAT.Table (g-table.ads): GNAT Table g-table ads. 
818 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads. 
819 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads. 
820 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads. 
821 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads. 
822 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads. 
823 * GNAT.UTF_32 (g-utf_32.ads): GNAT UTF_32 g-utf_32 ads. 
824 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads): GNAT UTF_32_Spelling_Checker g-u3spch ads. 
825 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads. 
826 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads. 
827 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads. 
828 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads. 
829 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads. 
830 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads. 
831 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads. 
832 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads. 
833 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads. 
834 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads. 
835 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads. 
836 * System.Assertions (s-assert.ads): System Assertions s-assert ads. 
837 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads. 
838 * System.Memory (s-memory.ads): System Memory s-memory ads. 
839 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads. 
840 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads. 
841 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads. 
842 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads. 
843 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads. 
844 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads. 
845 * System.Rident (s-rident.ads): System Rident s-rident ads. 
846 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads. 
847 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads. 
848 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads. 
849 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads. 
851 Interfacing to Other Languages
853 * Interfacing to C:: 
854 * Interfacing to C++:: 
855 * Interfacing to COBOL:: 
856 * Interfacing to Fortran:: 
857 * Interfacing to non-GNAT Ada code:: 
859 Implementation of Specific Ada Features
861 * Machine Code Insertions:: 
862 * GNAT Implementation of Tasking:: 
863 * GNAT Implementation of Shared Passive Packages:: 
864 * Code Generation for Array Aggregates:: 
865 * The Size of Discriminated Records with Default Discriminants:: 
866 * Image Values For Nonscalar Types:: 
867 * Strict Conformance to the Ada Reference Manual:: 
869 GNAT Implementation of Tasking
871 * Mapping Ada Tasks onto the Underlying Kernel Threads:: 
872 * Ensuring Compliance with the Real-Time Annex:: 
873 * Support for Locking Policies:: 
875 Code Generation for Array Aggregates
877 * Static constant aggregates with static bounds:: 
878 * Constant aggregates with unconstrained nominal types:: 
879 * Aggregates with static bounds:: 
880 * Aggregates with nonstatic bounds:: 
881 * Aggregates in assignment statements:: 
883 GNAT language extensions
885 * How to activate the extended GNAT Ada superset:: 
886 * Curated Extensions:: 
887 * Experimental Language Extensions:: 
889 Curated Extensions
891 * Local Declarations Without Block:: 
892 * Conditional when constructs:: 
893 * Case pattern matching:: 
894 * Fixed lower bounds for array types and subtypes:: 
895 * Prefixed-view notation for calls to primitive subprograms of untagged types:: 
896 * Expression defaults for generic formal functions:: 
897 * String interpolation:: 
898 * Constrained attribute for generic objects:: 
899 * Static aspect on intrinsic functions:: 
901 Experimental Language Extensions
903 * Pragma Storage_Model:: 
904 * Simpler accessibility model:: 
906 Security Hardening Features
908 * Register Scrubbing:: 
909 * Stack Scrubbing:: 
910 * Hardened Conditionals:: 
911 * Hardened Booleans:: 
912 * Control Flow Redundancy:: 
914 Obsolescent Features
916 * pragma No_Run_Time:: 
917 * pragma Ravenscar:: 
918 * pragma Restricted_Run_Time:: 
919 * pragma Task_Info:: 
920 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads. 
922 Compatibility and Porting Guide
924 * Writing Portable Fixed-Point Declarations:: 
925 * Compatibility with Ada 83:: 
926 * Compatibility between Ada 95 and Ada 2005:: 
927 * Implementation-dependent characteristics:: 
928 * Compatibility with Other Ada Systems:: 
929 * Representation Clauses:: 
930 * Compatibility with HP Ada 83:: 
932 Compatibility with Ada 83
934 * Legal Ada 83 programs that are illegal in Ada 95:: 
935 * More deterministic semantics:: 
936 * Changed semantics:: 
937 * Other language compatibility issues:: 
939 Implementation-dependent characteristics
941 * Implementation-defined pragmas:: 
942 * Implementation-defined attributes:: 
943 * Libraries:: 
944 * Elaboration order:: 
945 * Target-specific aspects:: 
947 @end detailmenu
948 @end menu
950 @node About This Guide,Implementation Defined Pragmas,Top,Top
951 @anchor{gnat_rm/about_this_guide doc}@anchor{2}@anchor{gnat_rm/about_this_guide about-this-guide}@anchor{3}@anchor{gnat_rm/about_this_guide gnat-reference-manual}@anchor{4}@anchor{gnat_rm/about_this_guide id1}@anchor{5}
952 @chapter About This Guide
956 This manual contains useful information in writing programs using the
957 GNAT compiler.  It includes information on implementation dependent
958 characteristics of GNAT, including all the information required by
959 Annex M of the Ada language standard.
961 GNAT implements Ada 95, Ada 2005 and Ada 2012, and it may also be
962 invoked in Ada 83 compatibility mode.
963 By default, GNAT assumes Ada 2012,
964 but you can override with a compiler switch
965 to explicitly specify the language version.
966 (Please refer to the `GNAT User’s Guide' for details on these switches.)
967 Throughout this manual, references to ‘Ada’ without a year suffix
968 apply to all the Ada versions of the language.
970 Ada is designed to be highly portable.
971 In general, a program will have the same effect even when compiled by
972 different compilers on different platforms.
973 However, since Ada is designed to be used in a
974 wide variety of applications, it also contains a number of system
975 dependent features to be used in interfacing to the external world.
977 @geindex Implementation-dependent features
979 @geindex Portability
981 Note: Any program that makes use of implementation-dependent features
982 may be non-portable.  You should follow good programming practice and
983 isolate and clearly document any sections of your program that make use
984 of these features in a non-portable manner.
986 @menu
987 * What This Reference Manual Contains:: 
988 * Conventions:: 
989 * Related Information:: 
991 @end menu
993 @node What This Reference Manual Contains,Conventions,,About This Guide
994 @anchor{gnat_rm/about_this_guide what-this-reference-manual-contains}@anchor{6}
995 @section What This Reference Manual Contains
998 This reference manual contains the following chapters:
1001 @itemize *
1003 @item 
1004 @ref{7,,Implementation Defined Pragmas}, lists GNAT implementation-dependent
1005 pragmas, which can be used to extend and enhance the functionality of the
1006 compiler.
1008 @item 
1009 @ref{8,,Implementation Defined Attributes}, lists GNAT
1010 implementation-dependent attributes, which can be used to extend and
1011 enhance the functionality of the compiler.
1013 @item 
1014 @ref{9,,Standard and Implementation Defined Restrictions}, lists GNAT
1015 implementation-dependent restrictions, which can be used to extend and
1016 enhance the functionality of the compiler.
1018 @item 
1019 @ref{a,,Implementation Advice}, provides information on generally
1020 desirable behavior which are not requirements that all compilers must
1021 follow since it cannot be provided on all systems, or which may be
1022 undesirable on some systems.
1024 @item 
1025 @ref{b,,Implementation Defined Characteristics}, provides a guide to
1026 minimizing implementation dependent features.
1028 @item 
1029 @ref{c,,Intrinsic Subprograms}, describes the intrinsic subprograms
1030 implemented by GNAT, and how they can be imported into user
1031 application programs.
1033 @item 
1034 @ref{d,,Representation Clauses and Pragmas}, describes in detail the
1035 way that GNAT represents data, and in particular the exact set
1036 of representation clauses and pragmas that is accepted.
1038 @item 
1039 @ref{e,,Standard Library Routines}, provides a listing of packages and a
1040 brief description of the functionality that is provided by Ada’s
1041 extensive set of standard library routines as implemented by GNAT.
1043 @item 
1044 @ref{f,,The Implementation of Standard I/O}, details how the GNAT
1045 implementation of the input-output facilities.
1047 @item 
1048 @ref{10,,The GNAT Library}, is a catalog of packages that complement
1049 the Ada predefined library.
1051 @item 
1052 @ref{11,,Interfacing to Other Languages}, describes how programs
1053 written in Ada using GNAT can be interfaced to other programming
1054 languages.
1056 @item 
1057 @ref{12,,Specialized Needs Annexes}, describes the GNAT implementation of all
1058 of the specialized needs annexes.
1060 @item 
1061 @ref{13,,Implementation of Specific Ada Features}, discusses issues related
1062 to GNAT’s implementation of machine code insertions, tasking, and several
1063 other features.
1065 @item 
1066 @ref{14,,Implementation of Ada 2012 Features}, describes the status of the
1067 GNAT implementation of the Ada 2012 language standard.
1069 @item 
1070 @ref{15,,Security Hardening Features} documents GNAT extensions aimed
1071 at security hardening.
1073 @item 
1074 @ref{16,,Obsolescent Features} documents implementation dependent features,
1075 including pragmas and attributes, which are considered obsolescent, since
1076 there are other preferred ways of achieving the same results. These
1077 obsolescent forms are retained for backwards compatibility.
1079 @item 
1080 @ref{17,,Compatibility and Porting Guide} presents some guidelines for
1081 developing portable Ada code, describes the compatibility issues that
1082 may arise between GNAT and other Ada compilation systems (including those
1083 for Ada 83), and shows how GNAT can expedite porting applications
1084 developed in other Ada environments.
1086 @item 
1087 @ref{1,,GNU Free Documentation License} contains the license for this document.
1088 @end itemize
1090 @geindex Ada 95 Language Reference Manual
1092 @geindex Ada 2005 Language Reference Manual
1094 This reference manual assumes a basic familiarity with the Ada 95 language, as
1095 described in the
1096 @cite{International Standard ANSI/ISO/IEC-8652:1995}.
1097 It does not require knowledge of the new features introduced by Ada 2005 or
1098 Ada 2012.
1099 All three reference manuals are included in the GNAT documentation
1100 package.
1102 @node Conventions,Related Information,What This Reference Manual Contains,About This Guide
1103 @anchor{gnat_rm/about_this_guide conventions}@anchor{18}
1104 @section Conventions
1107 @geindex Conventions
1108 @geindex typographical
1110 @geindex Typographical conventions
1112 Following are examples of the typographical and graphic conventions used
1113 in this guide:
1116 @itemize *
1118 @item 
1119 @code{Functions}, @code{utility program names}, @code{standard names},
1120 and @code{classes}.
1122 @item 
1123 @code{Option flags}
1125 @item 
1126 @code{File names}
1128 @item 
1129 @code{Variables}
1131 @item 
1132 `Emphasis'
1134 @item 
1135 [optional information or parameters]
1137 @item 
1138 Examples are described by text
1140 @example
1141 and then shown this way.
1142 @end example
1144 @item 
1145 Commands that are entered by the user are shown as preceded by a prompt string
1146 comprising the @code{$} character followed by a space.
1147 @end itemize
1149 @node Related Information,,Conventions,About This Guide
1150 @anchor{gnat_rm/about_this_guide related-information}@anchor{19}
1151 @section Related Information
1154 See the following documents for further information on GNAT:
1157 @itemize *
1159 @item 
1160 @cite{GNAT User’s Guide for Native Platforms},
1161 which provides information on how to use the
1162 GNAT development environment.
1164 @item 
1165 @cite{Ada 95 Reference Manual}, the Ada 95 programming language standard.
1167 @item 
1168 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
1169 of the Ada 95 standard.  The annotations describe
1170 detailed aspects of the design decision, and in particular contain useful
1171 sections on Ada 83 compatibility.
1173 @item 
1174 @cite{Ada 2005 Reference Manual}, the Ada 2005 programming language standard.
1176 @item 
1177 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
1178 of the Ada 2005 standard.  The annotations describe
1179 detailed aspects of the design decision.
1181 @item 
1182 @cite{Ada 2012 Reference Manual}, the Ada 2012 programming language standard.
1184 @item 
1185 @cite{DEC Ada@comma{} Technical Overview and Comparison on DIGITAL Platforms},
1186 which contains specific information on compatibility between GNAT and
1187 DEC Ada 83 systems.
1189 @item 
1190 @cite{DEC Ada@comma{} Language Reference Manual}, part number AA-PYZAB-TK, which
1191 describes in detail the pragmas and attributes provided by the DEC Ada 83
1192 compiler system.
1193 @end itemize
1195 @node Implementation Defined Pragmas,Implementation Defined Aspects,About This Guide,Top
1196 @anchor{gnat_rm/implementation_defined_pragmas doc}@anchor{1a}@anchor{gnat_rm/implementation_defined_pragmas id1}@anchor{1b}@anchor{gnat_rm/implementation_defined_pragmas implementation-defined-pragmas}@anchor{7}
1197 @chapter Implementation Defined Pragmas
1200 Ada defines a set of pragmas that can be used to supply additional
1201 information to the compiler.  These language defined pragmas are
1202 implemented in GNAT and work as described in the Ada Reference Manual.
1204 In addition, Ada allows implementations to define additional pragmas
1205 whose meaning is defined by the implementation.  GNAT provides a number
1206 of these implementation-defined pragmas, which can be used to extend
1207 and enhance the functionality of the compiler.  This section of the GNAT
1208 Reference Manual describes these additional pragmas.
1210 Note that any program using these pragmas might not be portable to other
1211 compilers (although GNAT implements this set of pragmas on all
1212 platforms).  Therefore if portability to other compilers is an important
1213 consideration, the use of these pragmas should be minimized.
1215 @menu
1216 * Pragma Abort_Defer:: 
1217 * Pragma Abstract_State:: 
1218 * Pragma Ada_83:: 
1219 * Pragma Ada_95:: 
1220 * Pragma Ada_05:: 
1221 * Pragma Ada_2005:: 
1222 * Pragma Ada_12:: 
1223 * Pragma Ada_2012:: 
1224 * Pragma Ada_2022:: 
1225 * Pragma Aggregate_Individually_Assign:: 
1226 * Pragma Allow_Integer_Address:: 
1227 * Pragma Always_Terminates:: 
1228 * Pragma Annotate:: 
1229 * Pragma Assert:: 
1230 * Pragma Assert_And_Cut:: 
1231 * Pragma Assertion_Policy:: 
1232 * Pragma Assume:: 
1233 * Pragma Assume_No_Invalid_Values:: 
1234 * Pragma Async_Readers:: 
1235 * Pragma Async_Writers:: 
1236 * Pragma Attribute_Definition:: 
1237 * Pragma C_Pass_By_Copy:: 
1238 * Pragma Check:: 
1239 * Pragma Check_Float_Overflow:: 
1240 * Pragma Check_Name:: 
1241 * Pragma Check_Policy:: 
1242 * Pragma Comment:: 
1243 * Pragma Common_Object:: 
1244 * Pragma Compile_Time_Error:: 
1245 * Pragma Compile_Time_Warning:: 
1246 * Pragma Complete_Representation:: 
1247 * Pragma Complex_Representation:: 
1248 * Pragma Component_Alignment:: 
1249 * Pragma Constant_After_Elaboration:: 
1250 * Pragma Contract_Cases:: 
1251 * Pragma Convention_Identifier:: 
1252 * Pragma CPP_Class:: 
1253 * Pragma CPP_Constructor:: 
1254 * Pragma CPP_Virtual:: 
1255 * Pragma CPP_Vtable:: 
1256 * Pragma CPU:: 
1257 * Pragma Deadline_Floor:: 
1258 * Pragma Debug:: 
1259 * Pragma Debug_Policy:: 
1260 * Pragma Default_Initial_Condition:: 
1261 * Pragma Default_Scalar_Storage_Order:: 
1262 * Pragma Default_Storage_Pool:: 
1263 * Pragma Depends:: 
1264 * Pragma Detect_Blocking:: 
1265 * Pragma Disable_Atomic_Synchronization:: 
1266 * Pragma Dispatching_Domain:: 
1267 * Pragma Effective_Reads:: 
1268 * Pragma Effective_Writes:: 
1269 * Pragma Elaboration_Checks:: 
1270 * Pragma Eliminate:: 
1271 * Pragma Enable_Atomic_Synchronization:: 
1272 * Pragma Export_Function:: 
1273 * Pragma Export_Object:: 
1274 * Pragma Export_Procedure:: 
1275 * Pragma Export_Valued_Procedure:: 
1276 * Pragma Extend_System:: 
1277 * Pragma Extensions_Allowed:: 
1278 * Pragma Extensions_Visible:: 
1279 * Pragma External:: 
1280 * Pragma External_Name_Casing:: 
1281 * Pragma Fast_Math:: 
1282 * Pragma Favor_Top_Level:: 
1283 * Pragma Finalize_Storage_Only:: 
1284 * Pragma Float_Representation:: 
1285 * Pragma Ghost:: 
1286 * Pragma Global:: 
1287 * Pragma Ident:: 
1288 * Pragma Ignore_Pragma:: 
1289 * Pragma Implementation_Defined:: 
1290 * Pragma Implemented:: 
1291 * Pragma Implicit_Packing:: 
1292 * Pragma Import_Function:: 
1293 * Pragma Import_Object:: 
1294 * Pragma Import_Procedure:: 
1295 * Pragma Import_Valued_Procedure:: 
1296 * Pragma Independent:: 
1297 * Pragma Independent_Components:: 
1298 * Pragma Initial_Condition:: 
1299 * Pragma Initialize_Scalars:: 
1300 * Pragma Initializes:: 
1301 * Pragma Inline_Always:: 
1302 * Pragma Inline_Generic:: 
1303 * Pragma Interface:: 
1304 * Pragma Interface_Name:: 
1305 * Pragma Interrupt_Handler:: 
1306 * Pragma Interrupt_State:: 
1307 * Pragma Invariant:: 
1308 * Pragma Keep_Names:: 
1309 * Pragma License:: 
1310 * Pragma Link_With:: 
1311 * Pragma Linker_Alias:: 
1312 * Pragma Linker_Constructor:: 
1313 * Pragma Linker_Destructor:: 
1314 * Pragma Linker_Section:: 
1315 * Pragma Lock_Free:: 
1316 * Pragma Loop_Invariant:: 
1317 * Pragma Loop_Optimize:: 
1318 * Pragma Loop_Variant:: 
1319 * Pragma Machine_Attribute:: 
1320 * Pragma Main:: 
1321 * Pragma Main_Storage:: 
1322 * Pragma Max_Queue_Length:: 
1323 * Pragma No_Body:: 
1324 * Pragma No_Caching:: 
1325 * Pragma No_Component_Reordering:: 
1326 * Pragma No_Elaboration_Code_All:: 
1327 * Pragma No_Heap_Finalization:: 
1328 * Pragma No_Inline:: 
1329 * Pragma No_Return:: 
1330 * Pragma No_Strict_Aliasing:: 
1331 * Pragma No_Tagged_Streams:: 
1332 * Pragma Normalize_Scalars:: 
1333 * Pragma Obsolescent:: 
1334 * Pragma Optimize_Alignment:: 
1335 * Pragma Ordered:: 
1336 * Pragma Overflow_Mode:: 
1337 * Pragma Overriding_Renamings:: 
1338 * Pragma Part_Of:: 
1339 * Pragma Partition_Elaboration_Policy:: 
1340 * Pragma Passive:: 
1341 * Pragma Persistent_BSS:: 
1342 * Pragma Post:: 
1343 * Pragma Postcondition:: 
1344 * Pragma Post_Class:: 
1345 * Pragma Pre:: 
1346 * Pragma Precondition:: 
1347 * Pragma Predicate:: 
1348 * Pragma Predicate_Failure:: 
1349 * Pragma Preelaborable_Initialization:: 
1350 * Pragma Prefix_Exception_Messages:: 
1351 * Pragma Pre_Class:: 
1352 * Pragma Priority_Specific_Dispatching:: 
1353 * Pragma Profile:: 
1354 * Pragma Profile_Warnings:: 
1355 * Pragma Propagate_Exceptions:: 
1356 * Pragma Provide_Shift_Operators:: 
1357 * Pragma Psect_Object:: 
1358 * Pragma Pure_Function:: 
1359 * Pragma Rational:: 
1360 * Pragma Ravenscar:: 
1361 * Pragma Refined_Depends:: 
1362 * Pragma Refined_Global:: 
1363 * Pragma Refined_Post:: 
1364 * Pragma Refined_State:: 
1365 * Pragma Relative_Deadline:: 
1366 * Pragma Remote_Access_Type:: 
1367 * Pragma Rename_Pragma:: 
1368 * Pragma Restricted_Run_Time:: 
1369 * Pragma Restriction_Warnings:: 
1370 * Pragma Reviewable:: 
1371 * Pragma Secondary_Stack_Size:: 
1372 * Pragma Share_Generic:: 
1373 * Pragma Shared:: 
1374 * Pragma Short_Circuit_And_Or:: 
1375 * Pragma Short_Descriptors:: 
1376 * Pragma Side_Effects:: 
1377 * Pragma Simple_Storage_Pool_Type:: 
1378 * Pragma Source_File_Name:: 
1379 * Pragma Source_File_Name_Project:: 
1380 * Pragma Source_Reference:: 
1381 * Pragma SPARK_Mode:: 
1382 * Pragma Static_Elaboration_Desired:: 
1383 * Pragma Stream_Convert:: 
1384 * Pragma Style_Checks:: 
1385 * Pragma Subtitle:: 
1386 * Pragma Suppress:: 
1387 * Pragma Suppress_All:: 
1388 * Pragma Suppress_Debug_Info:: 
1389 * Pragma Suppress_Exception_Locations:: 
1390 * Pragma Suppress_Initialization:: 
1391 * Pragma Task_Name:: 
1392 * Pragma Task_Storage:: 
1393 * Pragma Test_Case:: 
1394 * Pragma Thread_Local_Storage:: 
1395 * Pragma Time_Slice:: 
1396 * Pragma Title:: 
1397 * Pragma Type_Invariant:: 
1398 * Pragma Type_Invariant_Class:: 
1399 * Pragma Unchecked_Union:: 
1400 * Pragma Unevaluated_Use_Of_Old:: 
1401 * Pragma User_Aspect_Definition:: 
1402 * Pragma Unimplemented_Unit:: 
1403 * Pragma Universal_Aliasing:: 
1404 * Pragma Unmodified:: 
1405 * Pragma Unreferenced:: 
1406 * Pragma Unreferenced_Objects:: 
1407 * Pragma Unreserve_All_Interrupts:: 
1408 * Pragma Unsuppress:: 
1409 * Pragma Unused:: 
1410 * Pragma Use_VADS_Size:: 
1411 * Pragma Validity_Checks:: 
1412 * Pragma Volatile:: 
1413 * Pragma Volatile_Full_Access:: 
1414 * Pragma Volatile_Function:: 
1415 * Pragma Warning_As_Error:: 
1416 * Pragma Warnings:: 
1417 * Pragma Weak_External:: 
1418 * Pragma Wide_Character_Encoding:: 
1420 @end menu
1422 @node Pragma Abort_Defer,Pragma Abstract_State,,Implementation Defined Pragmas
1423 @anchor{gnat_rm/implementation_defined_pragmas pragma-abort-defer}@anchor{1c}
1424 @section Pragma Abort_Defer
1427 @geindex Deferring aborts
1429 Syntax:
1431 @example
1432 pragma Abort_Defer;
1433 @end example
1435 This pragma must appear at the start of the statement sequence of a
1436 handled sequence of statements (right after the @code{begin}).  It has
1437 the effect of deferring aborts for the sequence of statements (but not
1438 for the declarations or handlers, if any, associated with this statement
1439 sequence). This can also be useful for adding a polling point in Ada code,
1440 where asynchronous abort of tasks is checked when leaving the statement
1441 sequence, and is lighter than, for example, using @code{delay 0.0;}, since with
1442 zero-cost exception handling, propagating exceptions (implicitly used to
1443 implement task abort) cannot be done reliably in an asynchronous way.
1445 An example of usage would be:
1447 @example
1448 --  Add a polling point to check for task aborts
1450 begin
1451    pragma Abort_Defer;
1452 end;
1453 @end example
1455 @node Pragma Abstract_State,Pragma Ada_83,Pragma Abort_Defer,Implementation Defined Pragmas
1456 @anchor{gnat_rm/implementation_defined_pragmas id2}@anchor{1d}@anchor{gnat_rm/implementation_defined_pragmas pragma-abstract-state}@anchor{1e}
1457 @section Pragma Abstract_State
1460 Syntax:
1462 @example
1463 pragma Abstract_State (ABSTRACT_STATE_LIST);
1465 ABSTRACT_STATE_LIST ::=
1466      null
1467   |  STATE_NAME_WITH_OPTIONS
1468   | (STATE_NAME_WITH_OPTIONS @{, STATE_NAME_WITH_OPTIONS@} )
1470 STATE_NAME_WITH_OPTIONS ::=
1471      STATE_NAME
1472   | (STATE_NAME with OPTION_LIST)
1474 OPTION_LIST ::= OPTION @{, OPTION@}
1476 OPTION ::=
1477     SIMPLE_OPTION
1478   | NAME_VALUE_OPTION
1480 SIMPLE_OPTION ::= Ghost | Synchronous
1482 NAME_VALUE_OPTION ::=
1483     Part_Of => ABSTRACT_STATE
1484   | External [=> EXTERNAL_PROPERTY_LIST]
1486 EXTERNAL_PROPERTY_LIST ::=
1487      EXTERNAL_PROPERTY
1488   | (EXTERNAL_PROPERTY @{, EXTERNAL_PROPERTY@} )
1490 EXTERNAL_PROPERTY ::=
1491     Async_Readers    [=> static_boolean_EXPRESSION]
1492   | Async_Writers    [=> static_boolean_EXPRESSION]
1493   | Effective_Reads  [=> static_boolean_EXPRESSION]
1494   | Effective_Writes [=> static_boolean_EXPRESSION]
1495     others            => static_boolean_EXPRESSION
1497 STATE_NAME ::= defining_identifier
1499 ABSTRACT_STATE ::= name
1500 @end example
1502 For the semantics of this pragma, see the entry for aspect @code{Abstract_State} in
1503 the SPARK 2014 Reference Manual, section 7.1.4.
1505 @node Pragma Ada_83,Pragma Ada_95,Pragma Abstract_State,Implementation Defined Pragmas
1506 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-83}@anchor{1f}
1507 @section Pragma Ada_83
1510 Syntax:
1512 @example
1513 pragma Ada_83;
1514 @end example
1516 A configuration pragma that establishes Ada 83 mode for the unit to
1517 which it applies, regardless of the mode set by the command line
1518 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1519 the syntax and semantics of Ada 83, as defined in the original Ada
1520 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1521 and Ada 2005 are not recognized, optional package bodies are allowed,
1522 and generics may name types with unknown discriminants without using
1523 the @code{(<>)} notation.  In addition, some but not all of the additional
1524 restrictions of Ada 83 are enforced.
1526 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1527 Ada 83 code to be compiled and adapted to GNAT with less effort.
1528 Secondly, it aids in keeping code backwards compatible with Ada 83.
1529 However, there is no guarantee that code that is processed correctly
1530 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1531 83 compiler, since GNAT does not enforce all the additional checks
1532 required by Ada 83.
1534 @node Pragma Ada_95,Pragma Ada_05,Pragma Ada_83,Implementation Defined Pragmas
1535 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-95}@anchor{20}
1536 @section Pragma Ada_95
1539 Syntax:
1541 @example
1542 pragma Ada_95;
1543 @end example
1545 A configuration pragma that establishes Ada 95 mode for the unit to which
1546 it applies, regardless of the mode set by the command line switches.
1547 This mode is set automatically for the @code{Ada} and @code{System}
1548 packages and their children, so you need not specify it in these
1549 contexts.  This pragma is useful when writing a reusable component that
1550 itself uses Ada 95 features, but which is intended to be usable from
1551 either Ada 83 or Ada 95 programs.
1553 @node Pragma Ada_05,Pragma Ada_2005,Pragma Ada_95,Implementation Defined Pragmas
1554 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-05}@anchor{21}
1555 @section Pragma Ada_05
1558 Syntax:
1560 @example
1561 pragma Ada_05;
1562 pragma Ada_05 (local_NAME);
1563 @end example
1565 A configuration pragma that establishes Ada 2005 mode for the unit to which
1566 it applies, regardless of the mode set by the command line switches.
1567 This pragma is useful when writing a reusable component that
1568 itself uses Ada 2005 features, but which is intended to be usable from
1569 either Ada 83 or Ada 95 programs.
1571 The one argument form (which is not a configuration pragma)
1572 is used for managing the transition from
1573 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1574 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1575 mode will generate a warning. In addition, in Ada_83 or Ada_95
1576 mode, a preference rule is established which does not choose
1577 such an entity unless it is unambiguously specified. This avoids
1578 extra subprograms marked this way from generating ambiguities in
1579 otherwise legal pre-Ada_2005 programs. The one argument form is
1580 intended for exclusive use in the GNAT run-time library.
1582 @node Pragma Ada_2005,Pragma Ada_12,Pragma Ada_05,Implementation Defined Pragmas
1583 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2005}@anchor{22}
1584 @section Pragma Ada_2005
1587 Syntax:
1589 @example
1590 pragma Ada_2005;
1591 @end example
1593 This configuration pragma is a synonym for pragma Ada_05 and has the
1594 same syntax and effect.
1596 @node Pragma Ada_12,Pragma Ada_2012,Pragma Ada_2005,Implementation Defined Pragmas
1597 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-12}@anchor{23}
1598 @section Pragma Ada_12
1601 Syntax:
1603 @example
1604 pragma Ada_12;
1605 pragma Ada_12 (local_NAME);
1606 @end example
1608 A configuration pragma that establishes Ada 2012 mode for the unit to which
1609 it applies, regardless of the mode set by the command line switches.
1610 This mode is set automatically for the @code{Ada} and @code{System}
1611 packages and their children, so you need not specify it in these
1612 contexts.  This pragma is useful when writing a reusable component that
1613 itself uses Ada 2012 features, but which is intended to be usable from
1614 Ada 83, Ada 95, or Ada 2005 programs.
1616 The one argument form, which is not a configuration pragma,
1617 is used for managing the transition from Ada
1618 2005 to Ada 2012 in the run-time library. If an entity is marked
1619 as Ada_2012 only, then referencing the entity in any pre-Ada_2012
1620 mode will generate a warning. In addition, in any pre-Ada_2012
1621 mode, a preference rule is established which does not choose
1622 such an entity unless it is unambiguously specified. This avoids
1623 extra subprograms marked this way from generating ambiguities in
1624 otherwise legal pre-Ada_2012 programs. The one argument form is
1625 intended for exclusive use in the GNAT run-time library.
1627 @node Pragma Ada_2012,Pragma Ada_2022,Pragma Ada_12,Implementation Defined Pragmas
1628 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2012}@anchor{24}
1629 @section Pragma Ada_2012
1632 Syntax:
1634 @example
1635 pragma Ada_2012;
1636 @end example
1638 This configuration pragma is a synonym for pragma Ada_12 and has the
1639 same syntax and effect.
1641 @node Pragma Ada_2022,Pragma Aggregate_Individually_Assign,Pragma Ada_2012,Implementation Defined Pragmas
1642 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2022}@anchor{25}
1643 @section Pragma Ada_2022
1646 Syntax:
1648 @example
1649 pragma Ada_2022;
1650 pragma Ada_2022 (local_NAME);
1651 @end example
1653 A configuration pragma that establishes Ada 2022 mode for the unit to which
1654 it applies, regardless of the mode set by the command line switches.
1655 This mode is set automatically for the @code{Ada} and @code{System}
1656 packages and their children, so you need not specify it in these
1657 contexts.  This pragma is useful when writing a reusable component that
1658 itself uses Ada 2022 features, but which is intended to be usable from
1659 Ada 83, Ada 95, Ada 2005 or Ada 2012 programs.
1661 The one argument form, which is not a configuration pragma,
1662 is used for managing the transition from Ada
1663 2012 to Ada 2022 in the run-time library. If an entity is marked
1664 as Ada_2022 only, then referencing the entity in any pre-Ada_2022
1665 mode will generate a warning. In addition, in any pre-Ada_2012
1666 mode, a preference rule is established which does not choose
1667 such an entity unless it is unambiguously specified. This avoids
1668 extra subprograms marked this way from generating ambiguities in
1669 otherwise legal pre-Ada_2022 programs. The one argument form is
1670 intended for exclusive use in the GNAT run-time library.
1672 @node Pragma Aggregate_Individually_Assign,Pragma Allow_Integer_Address,Pragma Ada_2022,Implementation Defined Pragmas
1673 @anchor{gnat_rm/implementation_defined_pragmas pragma-aggregate-individually-assign}@anchor{26}
1674 @section Pragma Aggregate_Individually_Assign
1677 Syntax:
1679 @example
1680 pragma Aggregate_Individually_Assign;
1681 @end example
1683 Where possible, GNAT will store the binary representation of a record aggregate
1684 in memory for space and performance reasons. This configuration pragma changes
1685 this behavior so that record aggregates are instead always converted into
1686 individual assignment statements.
1688 @node Pragma Allow_Integer_Address,Pragma Always_Terminates,Pragma Aggregate_Individually_Assign,Implementation Defined Pragmas
1689 @anchor{gnat_rm/implementation_defined_pragmas pragma-allow-integer-address}@anchor{27}
1690 @section Pragma Allow_Integer_Address
1693 Syntax:
1695 @example
1696 pragma Allow_Integer_Address;
1697 @end example
1699 In almost all versions of GNAT, @code{System.Address} is a private
1700 type in accordance with the implementation advice in the RM. This
1701 means that integer values,
1702 in particular integer literals, are not allowed as address values.
1703 If the configuration pragma
1704 @code{Allow_Integer_Address} is given, then integer expressions may
1705 be used anywhere a value of type @code{System.Address} is required.
1706 The effect is to introduce an implicit unchecked conversion from the
1707 integer value to type @code{System.Address}. The reverse case of using
1708 an address where an integer type is required is handled analogously.
1709 The following example compiles without errors:
1711 @example
1712 pragma Allow_Integer_Address;
1713 with System; use System;
1714 package AddrAsInt is
1715    X : Integer;
1716    Y : Integer;
1717    for X'Address use 16#1240#;
1718    for Y use at 16#3230#;
1719    m : Address := 16#4000#;
1720    n : constant Address := 4000;
1721    p : constant Address := Address (X + Y);
1722    v : Integer := y'Address;
1723    w : constant Integer := Integer (Y'Address);
1724    type R is new integer;
1725    RR : R := 1000;
1726    Z : Integer;
1727    for Z'Address use RR;
1728 end AddrAsInt;
1729 @end example
1731 Note that pragma @code{Allow_Integer_Address} is ignored if @code{System.Address}
1732 is not a private type. In implementations of @code{GNAT} where
1733 System.Address is a visible integer type,
1734 this pragma serves no purpose but is ignored
1735 rather than rejected to allow common sets of sources to be used
1736 in the two situations.
1738 @node Pragma Always_Terminates,Pragma Annotate,Pragma Allow_Integer_Address,Implementation Defined Pragmas
1739 @anchor{gnat_rm/implementation_defined_pragmas id3}@anchor{28}@anchor{gnat_rm/implementation_defined_pragmas pragma-always-terminates}@anchor{29}
1740 @section Pragma Always_Terminates
1743 Syntax:
1745 @example
1746 pragma Always_Terminates [ (boolean_EXPRESSION) ];
1747 @end example
1749 For the semantics of this pragma, see the entry for aspect @code{Always_Terminates}
1750 in the SPARK 2014 Reference Manual, section 7.1.2.
1752 @node Pragma Annotate,Pragma Assert,Pragma Always_Terminates,Implementation Defined Pragmas
1753 @anchor{gnat_rm/implementation_defined_pragmas id4}@anchor{2a}@anchor{gnat_rm/implementation_defined_pragmas pragma-annotate}@anchor{2b}
1754 @section Pragma Annotate
1757 Syntax:
1759 @example
1760 pragma Annotate (IDENTIFIER [, IDENTIFIER @{, ARG@}] [, entity => local_NAME]);
1762 ARG ::= NAME | EXPRESSION
1763 @end example
1765 This pragma is used to annotate programs.  IDENTIFIER identifies
1766 the type of annotation.  GNAT verifies that it is an identifier, but does
1767 not otherwise analyze it. The second optional identifier is also left
1768 unanalyzed, and by convention is used to control the action of the tool to
1769 which the annotation is addressed.  The remaining ARG arguments
1770 can be either string literals or more generally expressions.
1771 String literals (and concatenations of string literals) are assumed to be
1772 either of type
1773 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1774 depending on the character literals they contain.
1775 All other kinds of arguments are analyzed as expressions, and must be
1776 unambiguous. The last argument if present must have the identifier
1777 @code{Entity} and GNAT verifies that a local name is given.
1779 The analyzed pragma is retained in the tree, but not otherwise processed
1780 by any part of the GNAT compiler, except to generate corresponding note
1781 lines in the generated ALI file. For the format of these note lines, see
1782 the compiler source file lib-writ.ads. This pragma is intended for use by
1783 external tools, including ASIS. The use of pragma Annotate does not
1784 affect the compilation process in any way. This pragma may be used as
1785 a configuration pragma.
1787 @node Pragma Assert,Pragma Assert_And_Cut,Pragma Annotate,Implementation Defined Pragmas
1788 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert}@anchor{2c}
1789 @section Pragma Assert
1792 Syntax:
1794 @example
1795 pragma Assert (
1796   boolean_EXPRESSION
1797   [, string_EXPRESSION]);
1798 @end example
1800 The effect of this pragma depends on whether the corresponding command
1801 line switch is set to activate assertions.  The pragma expands into code
1802 equivalent to the following:
1804 @example
1805 if assertions-enabled then
1806    if not boolean_EXPRESSION then
1807       System.Assertions.Raise_Assert_Failure
1808         (string_EXPRESSION);
1809    end if;
1810 end if;
1811 @end example
1813 The string argument, if given, is the message that will be associated
1814 with the exception occurrence if the exception is raised.  If no second
1815 argument is given, the default message is @code{file}:@code{nnn},
1816 where @code{file} is the name of the source file containing the assert,
1817 and @code{nnn} is the line number of the assert.
1819 Note that, as with the @code{if} statement to which it is equivalent, the
1820 type of the expression is either @code{Standard.Boolean}, or any type derived
1821 from this standard type.
1823 Assert checks can be either checked or ignored. By default they are ignored.
1824 They will be checked if either the command line switch `-gnata' is
1825 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1826 to enable @code{Assert_Checks}.
1828 If assertions are ignored, then there
1829 is no run-time effect (and in particular, any side effects from the
1830 expression will not occur at run time).  (The expression is still
1831 analyzed at compile time, and may cause types to be frozen if they are
1832 mentioned here for the first time).
1834 If assertions are checked, then the given expression is tested, and if
1835 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1836 which results in the raising of @code{Assert_Failure} with the given message.
1838 You should generally avoid side effects in the expression arguments of
1839 this pragma, because these side effects will turn on and off with the
1840 setting of the assertions mode, resulting in assertions that have an
1841 effect on the program.  However, the expressions are analyzed for
1842 semantic correctness whether or not assertions are enabled, so turning
1843 assertions on and off cannot affect the legality of a program.
1845 Note that the implementation defined policy @code{DISABLE}, given in a
1846 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1848 Note: this is a standard language-defined pragma in versions
1849 of Ada from 2005 on. In GNAT, it is implemented in all versions
1850 of Ada, and the DISABLE policy is an implementation-defined
1851 addition.
1853 @node Pragma Assert_And_Cut,Pragma Assertion_Policy,Pragma Assert,Implementation Defined Pragmas
1854 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert-and-cut}@anchor{2d}
1855 @section Pragma Assert_And_Cut
1858 Syntax:
1860 @example
1861 pragma Assert_And_Cut (
1862   boolean_EXPRESSION
1863   [, string_EXPRESSION]);
1864 @end example
1866 The effect of this pragma is identical to that of pragma @code{Assert},
1867 except that in an @code{Assertion_Policy} pragma, the identifier
1868 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1869 (or disabled).
1871 The intention is that this be used within a subprogram when the
1872 given test expresion sums up all the work done so far in the
1873 subprogram, so that the rest of the subprogram can be verified
1874 (informally or formally) using only the entry preconditions,
1875 and the expression in this pragma. This allows dividing up
1876 a subprogram into sections for the purposes of testing or
1877 formal verification. The pragma also serves as useful
1878 documentation.
1880 @node Pragma Assertion_Policy,Pragma Assume,Pragma Assert_And_Cut,Implementation Defined Pragmas
1881 @anchor{gnat_rm/implementation_defined_pragmas pragma-assertion-policy}@anchor{2e}
1882 @section Pragma Assertion_Policy
1885 Syntax:
1887 @example
1888 pragma Assertion_Policy (CHECK | DISABLE | IGNORE | SUPPRESSIBLE);
1890 pragma Assertion_Policy (
1891     ASSERTION_KIND => POLICY_IDENTIFIER
1892  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1894 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1896 RM_ASSERTION_KIND ::= Assert                    |
1897                       Static_Predicate          |
1898                       Dynamic_Predicate         |
1899                       Pre                       |
1900                       Pre'Class                 |
1901                       Post                      |
1902                       Post'Class                |
1903                       Type_Invariant            |
1904                       Type_Invariant'Class      |
1905                       Default_Initial_Condition
1907 ID_ASSERTION_KIND ::= Assertions           |
1908                       Assert_And_Cut       |
1909                       Assume               |
1910                       Contract_Cases       |
1911                       Debug                |
1912                       Ghost                |
1913                       Initial_Condition    |
1914                       Invariant            |
1915                       Invariant'Class      |
1916                       Loop_Invariant       |
1917                       Loop_Variant         |
1918                       Postcondition        |
1919                       Precondition         |
1920                       Predicate            |
1921                       Refined_Post         |
1922                       Statement_Assertions |
1923                       Subprogram_Variant
1925 POLICY_IDENTIFIER ::= Check | Disable | Ignore | Suppressible
1926 @end example
1928 This is a standard Ada 2012 pragma that is available as an
1929 implementation-defined pragma in earlier versions of Ada.
1930 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1931 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1932 are implementation defined additions recognized by the GNAT compiler.
1934 The pragma applies in both cases to pragmas and aspects with matching
1935 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1936 applies to both the @code{Precondition} pragma
1937 and the aspect @code{Precondition}. Note that the identifiers for
1938 pragmas Pre_Class and Post_Class are Pre’Class and Post’Class (not
1939 Pre_Class and Post_Class), since these pragmas are intended to be
1940 identical to the corresponding aspects.
1942 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1943 the corresponding pragma or aspect is activated.
1944 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1945 the corresponding pragma or aspect is deactivated.
1946 This pragma overrides the effect of the `-gnata' switch on the
1947 command line.
1948 If the policy is @code{SUPPRESSIBLE}, then assertions are enabled by default,
1949 however, if the `-gnatp' switch is specified all assertions are ignored.
1951 The implementation defined policy @code{DISABLE} is like
1952 @code{IGNORE} except that it completely disables semantic
1953 checking of the corresponding pragma or aspect. This is
1954 useful when the pragma or aspect argument references subprograms
1955 in a with’ed package which is replaced by a dummy package
1956 for the final build.
1958 The implementation defined assertion kind @code{Assertions} applies to all
1959 assertion kinds. The form with no assertion kind given implies this
1960 choice, so it applies to all assertion kinds (RM defined, and
1961 implementation defined).
1963 The implementation defined assertion kind @code{Statement_Assertions}
1964 applies to @code{Assert}, @code{Assert_And_Cut},
1965 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1967 @node Pragma Assume,Pragma Assume_No_Invalid_Values,Pragma Assertion_Policy,Implementation Defined Pragmas
1968 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume}@anchor{2f}
1969 @section Pragma Assume
1972 Syntax:
1974 @example
1975 pragma Assume (
1976   boolean_EXPRESSION
1977   [, string_EXPRESSION]);
1978 @end example
1980 The effect of this pragma is identical to that of pragma @code{Assert},
1981 except that in an @code{Assertion_Policy} pragma, the identifier
1982 @code{Assume} is used to control whether it is ignored or checked
1983 (or disabled).
1985 The intention is that this be used for assumptions about the
1986 external environment. So you cannot expect to verify formally
1987 or informally that the condition is met, this must be
1988 established by examining things outside the program itself.
1989 For example, we may have code that depends on the size of
1990 @code{Long_Long_Integer} being at least 64. So we could write:
1992 @example
1993 pragma Assume (Long_Long_Integer'Size >= 64);
1994 @end example
1996 This assumption cannot be proved from the program itself,
1997 but it acts as a useful run-time check that the assumption
1998 is met, and documents the need to ensure that it is met by
1999 reference to information outside the program.
2001 @node Pragma Assume_No_Invalid_Values,Pragma Async_Readers,Pragma Assume,Implementation Defined Pragmas
2002 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume-no-invalid-values}@anchor{30}
2003 @section Pragma Assume_No_Invalid_Values
2006 @geindex Invalid representations
2008 @geindex Invalid values
2010 Syntax:
2012 @example
2013 pragma Assume_No_Invalid_Values (On | Off);
2014 @end example
2016 This is a configuration pragma that controls the assumptions made by the
2017 compiler about the occurrence of invalid representations (invalid values)
2018 in the code.
2020 The default behavior (corresponding to an Off argument for this pragma), is
2021 to assume that values may in general be invalid unless the compiler can
2022 prove they are valid. Consider the following example:
2024 @example
2025 V1 : Integer range 1 .. 10;
2026 V2 : Integer range 11 .. 20;
2028 for J in V2 .. V1 loop
2029    ...
2030 end loop;
2031 @end example
2033 if V1 and V2 have valid values, then the loop is known at compile
2034 time not to execute since the lower bound must be greater than the
2035 upper bound. However in default mode, no such assumption is made,
2036 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
2037 is given, the compiler will assume that any occurrence of a variable
2038 other than in an explicit @code{'Valid} test always has a valid
2039 value, and the loop above will be optimized away.
2041 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
2042 you know your code is free of uninitialized variables and other
2043 possible sources of invalid representations, and may result in
2044 more efficient code. A program that accesses an invalid representation
2045 with this pragma in effect is erroneous, so no guarantees can be made
2046 about its behavior.
2048 It is peculiar though permissible to use this pragma in conjunction
2049 with validity checking (-gnatVa). In such cases, accessing invalid
2050 values will generally give an exception, though formally the program
2051 is erroneous so there are no guarantees that this will always be the
2052 case, and it is recommended that these two options not be used together.
2054 @node Pragma Async_Readers,Pragma Async_Writers,Pragma Assume_No_Invalid_Values,Implementation Defined Pragmas
2055 @anchor{gnat_rm/implementation_defined_pragmas id5}@anchor{31}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-readers}@anchor{32}
2056 @section Pragma Async_Readers
2059 Syntax:
2061 @example
2062 pragma Async_Readers [ (static_boolean_EXPRESSION) ];
2063 @end example
2065 For the semantics of this pragma, see the entry for aspect @code{Async_Readers} in
2066 the SPARK 2014 Reference Manual, section 7.1.2.
2068 @node Pragma Async_Writers,Pragma Attribute_Definition,Pragma Async_Readers,Implementation Defined Pragmas
2069 @anchor{gnat_rm/implementation_defined_pragmas id6}@anchor{33}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-writers}@anchor{34}
2070 @section Pragma Async_Writers
2073 Syntax:
2075 @example
2076 pragma Async_Writers [ (static_boolean_EXPRESSION) ];
2077 @end example
2079 For the semantics of this pragma, see the entry for aspect @code{Async_Writers} in
2080 the SPARK 2014 Reference Manual, section 7.1.2.
2082 @node Pragma Attribute_Definition,Pragma C_Pass_By_Copy,Pragma Async_Writers,Implementation Defined Pragmas
2083 @anchor{gnat_rm/implementation_defined_pragmas pragma-attribute-definition}@anchor{35}
2084 @section Pragma Attribute_Definition
2087 Syntax:
2089 @example
2090 pragma Attribute_Definition
2091   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
2092    [Entity     =>] LOCAL_NAME,
2093    [Expression =>] EXPRESSION | NAME);
2094 @end example
2096 If @code{Attribute} is a known attribute name, this pragma is equivalent to
2097 the attribute definition clause:
2099 @example
2100 for Entity'Attribute use Expression;
2101 @end example
2103 If @code{Attribute} is not a recognized attribute name, the pragma is
2104 ignored, and a warning is emitted. This allows source
2105 code to be written that takes advantage of some new attribute, while remaining
2106 compilable with earlier compilers.
2108 @node Pragma C_Pass_By_Copy,Pragma Check,Pragma Attribute_Definition,Implementation Defined Pragmas
2109 @anchor{gnat_rm/implementation_defined_pragmas pragma-c-pass-by-copy}@anchor{36}
2110 @section Pragma C_Pass_By_Copy
2113 @geindex Passing by copy
2115 Syntax:
2117 @example
2118 pragma C_Pass_By_Copy
2119   ([Max_Size =>] static_integer_EXPRESSION);
2120 @end example
2122 Normally the default mechanism for passing C convention records to C
2123 convention subprograms is to pass them by reference, as suggested by RM
2124 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
2125 this default, by requiring that record formal parameters be passed by
2126 copy if all of the following conditions are met:
2129 @itemize *
2131 @item 
2132 The size of the record type does not exceed the value specified for
2133 @code{Max_Size}.
2135 @item 
2136 The record type has @code{Convention C}.
2138 @item 
2139 The formal parameter has this record type, and the subprogram has a
2140 foreign (non-Ada) convention.
2141 @end itemize
2143 If these conditions are met the argument is passed by copy; i.e., in a
2144 manner consistent with what C expects if the corresponding formal in the
2145 C prototype is a struct (rather than a pointer to a struct).
2147 You can also pass records by copy by specifying the convention
2148 @code{C_Pass_By_Copy} for the record type, or by using the extended
2149 @code{Import} and @code{Export} pragmas, which allow specification of
2150 passing mechanisms on a parameter by parameter basis.
2152 @node Pragma Check,Pragma Check_Float_Overflow,Pragma C_Pass_By_Copy,Implementation Defined Pragmas
2153 @anchor{gnat_rm/implementation_defined_pragmas pragma-check}@anchor{37}
2154 @section Pragma Check
2157 @geindex Assertions
2159 @geindex Named assertions
2161 Syntax:
2163 @example
2164 pragma Check (
2165      [Name    =>] CHECK_KIND,
2166      [Check   =>] Boolean_EXPRESSION
2167   [, [Message =>] string_EXPRESSION] );
2169 CHECK_KIND ::= IDENTIFIER           |
2170                Pre'Class            |
2171                Post'Class           |
2172                Type_Invariant'Class |
2173                Invariant'Class
2174 @end example
2176 This pragma is similar to the predefined pragma @code{Assert} except that an
2177 extra identifier argument is present. In conjunction with pragma
2178 @code{Check_Policy}, this can be used to define groups of assertions that can
2179 be independently controlled. The identifier @code{Assertion} is special, it
2180 refers to the normal set of pragma @code{Assert} statements.
2182 Checks introduced by this pragma are normally deactivated by default. They can
2183 be activated either by the command line option `-gnata', which turns on
2184 all checks, or individually controlled using pragma @code{Check_Policy}.
2186 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
2187 permitted as check kinds, since this would cause confusion with the use
2188 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
2189 pragmas, where they are used to refer to sets of assertions.
2191 @node Pragma Check_Float_Overflow,Pragma Check_Name,Pragma Check,Implementation Defined Pragmas
2192 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-float-overflow}@anchor{38}
2193 @section Pragma Check_Float_Overflow
2196 @geindex Floating-point overflow
2198 Syntax:
2200 @example
2201 pragma Check_Float_Overflow;
2202 @end example
2204 In Ada, the predefined floating-point types (@code{Short_Float},
2205 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
2206 defined to be `unconstrained'. This means that even though each
2207 has a well-defined base range, an operation that delivers a result
2208 outside this base range is not required to raise an exception.
2209 This implementation permission accommodates the notion
2210 of infinities in IEEE floating-point, and corresponds to the
2211 efficient execution mode on most machines. GNAT will not raise
2212 overflow exceptions on these machines; instead it will generate
2213 infinities and NaN’s as defined in the IEEE standard.
2215 Generating infinities, although efficient, is not always desirable.
2216 Often the preferable approach is to check for overflow, even at the
2217 (perhaps considerable) expense of run-time performance.
2218 This can be accomplished by defining your own constrained floating-point subtypes – i.e., by supplying explicit
2219 range constraints – and indeed such a subtype
2220 can have the same base range as its base type. For example:
2222 @example
2223 subtype My_Float is Float range Float'Range;
2224 @end example
2226 Here @code{My_Float} has the same range as
2227 @code{Float} but is constrained, so operations on
2228 @code{My_Float} values will be checked for overflow
2229 against this range.
2231 This style will achieve the desired goal, but
2232 it is often more convenient to be able to simply use
2233 the standard predefined floating-point types as long
2234 as overflow checking could be guaranteed.
2235 The @code{Check_Float_Overflow}
2236 configuration pragma achieves this effect. If a unit is compiled
2237 subject to this configuration pragma, then all operations
2238 on predefined floating-point types including operations on
2239 base types of these floating-point types will be treated as
2240 though those types were constrained, and overflow checks
2241 will be generated. The @code{Constraint_Error}
2242 exception is raised if the result is out of range.
2244 This mode can also be set by use of the compiler
2245 switch `-gnateF'.
2247 @node Pragma Check_Name,Pragma Check_Policy,Pragma Check_Float_Overflow,Implementation Defined Pragmas
2248 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-name}@anchor{39}
2249 @section Pragma Check_Name
2252 @geindex Defining check names
2254 @geindex Check names
2255 @geindex defining
2257 Syntax:
2259 @example
2260 pragma Check_Name (check_name_IDENTIFIER);
2261 @end example
2263 This is a configuration pragma that defines a new implementation
2264 defined check name (unless IDENTIFIER matches one of the predefined
2265 check names, in which case the pragma has no effect). Check names
2266 are global to a partition, so if two or more configuration pragmas
2267 are present in a partition mentioning the same name, only one new
2268 check name is introduced.
2270 An implementation defined check name introduced with this pragma may
2271 be used in only three contexts: @code{pragma Suppress},
2272 @code{pragma Unsuppress},
2273 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
2274 any of these three cases, the check name must be visible. A check
2275 name is visible if it is in the configuration pragmas applying to
2276 the current unit, or if it appears at the start of any unit that
2277 is part of the dependency set of the current unit (e.g., units that
2278 are mentioned in @code{with} clauses).
2280 Check names introduced by this pragma are subject to control by compiler
2281 switches (in particular -gnatp) in the usual manner.
2283 @node Pragma Check_Policy,Pragma Comment,Pragma Check_Name,Implementation Defined Pragmas
2284 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-policy}@anchor{3a}
2285 @section Pragma Check_Policy
2288 @geindex Controlling assertions
2290 @geindex Assertions
2291 @geindex control
2293 @geindex Check pragma control
2295 @geindex Named assertions
2297 Syntax:
2299 @example
2300 pragma Check_Policy
2301  ([Name   =>] CHECK_KIND,
2302   [Policy =>] POLICY_IDENTIFIER);
2304 pragma Check_Policy (
2305     CHECK_KIND => POLICY_IDENTIFIER
2306  @{, CHECK_KIND => POLICY_IDENTIFIER@});
2308 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
2310 CHECK_KIND ::= IDENTIFIER           |
2311                Pre'Class            |
2312                Post'Class           |
2313                Type_Invariant'Class |
2314                Invariant'Class
2316 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
2317 avoids confusion between the two possible syntax forms for this pragma.
2319 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
2320 @end example
2322 This pragma is used to set the checking policy for assertions (specified
2323 by aspects or pragmas), the @code{Debug} pragma, or additional checks
2324 to be checked using the @code{Check} pragma. It may appear either as
2325 a configuration pragma, or within a declarative part of package. In the
2326 latter case, it applies from the point where it appears to the end of
2327 the declarative region (like pragma @code{Suppress}).
2329 The @code{Check_Policy} pragma is similar to the
2330 predefined @code{Assertion_Policy} pragma,
2331 and if the check kind corresponds to one of the assertion kinds that
2332 are allowed by @code{Assertion_Policy}, then the effect is identical.
2334 If the first argument is Debug, then the policy applies to Debug pragmas,
2335 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
2336 @code{IGNORE}, and allowing them to execute with normal semantics if
2337 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
2338 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
2339 be totally ignored and not analyzed semantically.
2341 Finally the first argument may be some other identifier than the above
2342 possibilities, in which case it controls a set of named assertions
2343 that can be checked using pragma @code{Check}. For example, if the pragma:
2345 @example
2346 pragma Check_Policy (Critical_Error, OFF);
2347 @end example
2349 is given, then subsequent @code{Check} pragmas whose first argument is also
2350 @code{Critical_Error} will be disabled.
2352 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
2353 to turn on corresponding checks. The default for a set of checks for which no
2354 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
2355 `-gnata' is given, which turns on all checks by default.
2357 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
2358 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
2359 compatibility with the standard @code{Assertion_Policy} pragma. The check
2360 policy setting @code{DISABLE} causes the second argument of a corresponding
2361 @code{Check} pragma to be completely ignored and not analyzed.
2363 @node Pragma Comment,Pragma Common_Object,Pragma Check_Policy,Implementation Defined Pragmas
2364 @anchor{gnat_rm/implementation_defined_pragmas pragma-comment}@anchor{3b}
2365 @section Pragma Comment
2368 Syntax:
2370 @example
2371 pragma Comment (static_string_EXPRESSION);
2372 @end example
2374 This is almost identical in effect to pragma @code{Ident}.  It allows the
2375 placement of a comment into the object file and hence into the
2376 executable file if the operating system permits such usage.  The
2377 difference is that @code{Comment}, unlike @code{Ident}, has
2378 no limitations on placement of the pragma (it can be placed
2379 anywhere in the main source unit), and if more than one pragma
2380 is used, all comments are retained.
2382 @node Pragma Common_Object,Pragma Compile_Time_Error,Pragma Comment,Implementation Defined Pragmas
2383 @anchor{gnat_rm/implementation_defined_pragmas pragma-common-object}@anchor{3c}
2384 @section Pragma Common_Object
2387 Syntax:
2389 @example
2390 pragma Common_Object (
2391      [Internal =>] LOCAL_NAME
2392   [, [External =>] EXTERNAL_SYMBOL]
2393   [, [Size     =>] EXTERNAL_SYMBOL] );
2395 EXTERNAL_SYMBOL ::=
2396   IDENTIFIER
2397 | static_string_EXPRESSION
2398 @end example
2400 This pragma enables the shared use of variables stored in overlaid
2401 linker areas corresponding to the use of @code{COMMON}
2402 in Fortran.  The single
2403 object @code{LOCAL_NAME} is assigned to the area designated by
2404 the @code{External} argument.
2405 You may define a record to correspond to a series
2406 of fields.  The @code{Size} argument
2407 is syntax checked in GNAT, but otherwise ignored.
2409 @code{Common_Object} is not supported on all platforms.  If no
2410 support is available, then the code generator will issue a message
2411 indicating that the necessary attribute for implementation of this
2412 pragma is not available.
2414 @node Pragma Compile_Time_Error,Pragma Compile_Time_Warning,Pragma Common_Object,Implementation Defined Pragmas
2415 @anchor{gnat_rm/implementation_defined_pragmas compile-time-error}@anchor{3d}@anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-error}@anchor{3e}
2416 @section Pragma Compile_Time_Error
2419 Syntax:
2421 @example
2422 pragma Compile_Time_Error
2423          (boolean_EXPRESSION, static_string_EXPRESSION);
2424 @end example
2426 This pragma can be used to generate additional compile time
2427 error messages. It
2428 is particularly useful in generics, where errors can be issued for
2429 specific problematic instantiations. The first parameter is a boolean
2430 expression. The pragma ensures that the value of an expression
2431 is known at compile time, and has the value False. The set of expressions
2432 whose values are known at compile time includes all static boolean
2433 expressions, and also other values which the compiler can determine
2434 at compile time (e.g., the size of a record type set by an explicit
2435 size representation clause, or the value of a variable which was
2436 initialized to a constant and is known not to have been modified).
2437 If these conditions are not met, an error message is generated using
2438 the value given as the second argument. This string value may contain
2439 embedded ASCII.LF characters to break the message into multiple lines.
2441 @node Pragma Compile_Time_Warning,Pragma Complete_Representation,Pragma Compile_Time_Error,Implementation Defined Pragmas
2442 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-warning}@anchor{3f}
2443 @section Pragma Compile_Time_Warning
2446 Syntax:
2448 @example
2449 pragma Compile_Time_Warning
2450          (boolean_EXPRESSION, static_string_EXPRESSION);
2451 @end example
2453 Same as pragma Compile_Time_Error, except a warning is issued instead
2454 of an error message. If switch `-gnatw_C' is used, a warning is only issued
2455 if the value of the expression is known to be True at compile time, not when
2456 the value of the expression is not known at compile time.
2457 Note that if this pragma is used in a package that
2458 is with’ed by a client, the client will get the warning even though it
2459 is issued by a with’ed package (normally warnings in with’ed units are
2460 suppressed, but this is a special exception to that rule).
2462 One typical use is within a generic where compile time known characteristics
2463 of formal parameters are tested, and warnings given appropriately. Another use
2464 with a first parameter of True is to warn a client about use of a package,
2465 for example that it is not fully implemented.
2467 In previous versions of the compiler, combining `-gnatwe' with
2468 Compile_Time_Warning resulted in a fatal error. Now the compiler always emits
2469 a warning. You can use @ref{3d,,Pragma Compile_Time_Error} to force the generation of
2470 an error.
2472 @node Pragma Complete_Representation,Pragma Complex_Representation,Pragma Compile_Time_Warning,Implementation Defined Pragmas
2473 @anchor{gnat_rm/implementation_defined_pragmas pragma-complete-representation}@anchor{40}
2474 @section Pragma Complete_Representation
2477 Syntax:
2479 @example
2480 pragma Complete_Representation;
2481 @end example
2483 This pragma must appear immediately within a record representation
2484 clause. Typical placements are before the first component clause
2485 or after the last component clause. The effect is to give an error
2486 message if any component is missing a component clause. This pragma
2487 may be used to ensure that a record representation clause is
2488 complete, and that this invariant is maintained if fields are
2489 added to the record in the future.
2491 @node Pragma Complex_Representation,Pragma Component_Alignment,Pragma Complete_Representation,Implementation Defined Pragmas
2492 @anchor{gnat_rm/implementation_defined_pragmas pragma-complex-representation}@anchor{41}
2493 @section Pragma Complex_Representation
2496 Syntax:
2498 @example
2499 pragma Complex_Representation
2500         ([Entity =>] LOCAL_NAME);
2501 @end example
2503 The @code{Entity} argument must be the name of a record type which has
2504 two fields of the same floating-point type.  The effect of this pragma is
2505 to force gcc to use the special internal complex representation form for
2506 this record, which may be more efficient.  Note that this may result in
2507 the code for this type not conforming to standard ABI (application
2508 binary interface) requirements for the handling of record types.  For
2509 example, in some environments, there is a requirement for passing
2510 records by pointer, and the use of this pragma may result in passing
2511 this type in floating-point registers.
2513 @node Pragma Component_Alignment,Pragma Constant_After_Elaboration,Pragma Complex_Representation,Implementation Defined Pragmas
2514 @anchor{gnat_rm/implementation_defined_pragmas pragma-component-alignment}@anchor{42}
2515 @section Pragma Component_Alignment
2518 @geindex Alignments of components
2520 @geindex Pragma Component_Alignment
2522 Syntax:
2524 @example
2525 pragma Component_Alignment (
2526      [Form =>] ALIGNMENT_CHOICE
2527   [, [Name =>] type_LOCAL_NAME]);
2529 ALIGNMENT_CHOICE ::=
2530   Component_Size
2531 | Component_Size_4
2532 | Storage_Unit
2533 | Default
2534 @end example
2536 Specifies the alignment of components in array or record types.
2537 The meaning of the @code{Form} argument is as follows:
2539 @quotation
2541 @geindex Component_Size (in pragma Component_Alignment)
2542 @end quotation
2545 @table @asis
2547 @item `Component_Size'
2549 Aligns scalar components and subcomponents of the array or record type
2550 on boundaries appropriate to their inherent size (naturally
2551 aligned).  For example, 1-byte components are aligned on byte boundaries,
2552 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2553 integer components are aligned on 4-byte boundaries and so on.  These
2554 alignment rules correspond to the normal rules for C compilers on all
2555 machines except the VAX.
2557 @geindex Component_Size_4 (in pragma Component_Alignment)
2559 @item `Component_Size_4'
2561 Naturally aligns components with a size of four or fewer
2562 bytes.  Components that are larger than 4 bytes are placed on the next
2563 4-byte boundary.
2565 @geindex Storage_Unit (in pragma Component_Alignment)
2567 @item `Storage_Unit'
2569 Specifies that array or record components are byte aligned, i.e.,
2570 aligned on boundaries determined by the value of the constant
2571 @code{System.Storage_Unit}.
2573 @geindex Default (in pragma Component_Alignment)
2575 @item `Default'
2577 Specifies that array or record components are aligned on default
2578 boundaries, appropriate to the underlying hardware or operating system or
2579 both. The @code{Default} choice is the same as @code{Component_Size} (natural
2580 alignment).
2581 @end table
2583 If the @code{Name} parameter is present, @code{type_LOCAL_NAME} must
2584 refer to a local record or array type, and the specified alignment
2585 choice applies to the specified type.  The use of
2586 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2587 @code{Component_Alignment} pragma to be ignored.  The use of
2588 @code{Component_Alignment} together with a record representation clause
2589 is only effective for fields not specified by the representation clause.
2591 If the @code{Name} parameter is absent, the pragma can be used as either
2592 a configuration pragma, in which case it applies to one or more units in
2593 accordance with the normal rules for configuration pragmas, or it can be
2594 used within a declarative part, in which case it applies to types that
2595 are declared within this declarative part, or within any nested scope
2596 within this declarative part.  In either case it specifies the alignment
2597 to be applied to any record or array type which has otherwise standard
2598 representation.
2600 If the alignment for a record or array type is not specified (using
2601 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2602 clause), the GNAT uses the default alignment as described previously.
2604 @node Pragma Constant_After_Elaboration,Pragma Contract_Cases,Pragma Component_Alignment,Implementation Defined Pragmas
2605 @anchor{gnat_rm/implementation_defined_pragmas id7}@anchor{43}@anchor{gnat_rm/implementation_defined_pragmas pragma-constant-after-elaboration}@anchor{44}
2606 @section Pragma Constant_After_Elaboration
2609 Syntax:
2611 @example
2612 pragma Constant_After_Elaboration [ (static_boolean_EXPRESSION) ];
2613 @end example
2615 For the semantics of this pragma, see the entry for aspect
2616 @code{Constant_After_Elaboration} in the SPARK 2014 Reference Manual, section 3.3.1.
2618 @node Pragma Contract_Cases,Pragma Convention_Identifier,Pragma Constant_After_Elaboration,Implementation Defined Pragmas
2619 @anchor{gnat_rm/implementation_defined_pragmas id8}@anchor{45}@anchor{gnat_rm/implementation_defined_pragmas pragma-contract-cases}@anchor{46}
2620 @section Pragma Contract_Cases
2623 @geindex Contract cases
2625 Syntax:
2627 @example
2628 pragma Contract_Cases (CONTRACT_CASE @{, CONTRACT_CASE@});
2630 CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
2632 CASE_GUARD ::= boolean_EXPRESSION | others
2634 CONSEQUENCE ::= boolean_EXPRESSION
2635 @end example
2637 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2638 that can complement or replace the contract given by a precondition and a
2639 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2640 by testing and formal verification tools. The compiler checks its validity and,
2641 depending on the assertion policy at the point of declaration of the pragma,
2642 it may insert a check in the executable. For code generation, the contract
2643 cases
2645 @example
2646 pragma Contract_Cases (
2647   Cond1 => Pred1,
2648   Cond2 => Pred2);
2649 @end example
2651 are equivalent to
2653 @example
2654 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2655 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2656 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2657 pragma Postcondition (if C1 then Pred1);
2658 pragma Postcondition (if C2 then Pred2);
2659 @end example
2661 The precondition ensures that one and only one of the case guards is
2662 satisfied on entry to the subprogram.
2663 The postcondition ensures that for the case guard that was True on entry,
2664 the corresponding consequence is True on exit. Other consequence expressions
2665 are not evaluated.
2667 A precondition @code{P} and postcondition @code{Q} can also be
2668 expressed as contract cases:
2670 @example
2671 pragma Contract_Cases (P => Q);
2672 @end example
2674 The placement and visibility rules for @code{Contract_Cases} pragmas are
2675 identical to those described for preconditions and postconditions.
2677 The compiler checks that boolean expressions given in case guards and
2678 consequences are valid, where the rules for case guards are the same as
2679 the rule for an expression in @code{Precondition} and the rules for
2680 consequences are the same as the rule for an expression in
2681 @code{Postcondition}. In particular, attributes @code{'Old} and
2682 @code{'Result} can only be used within consequence expressions.
2683 The case guard for the last contract case may be @code{others}, to denote
2684 any case not captured by the previous cases. The
2685 following is an example of use within a package spec:
2687 @example
2688 package Math_Functions is
2689    ...
2690    function Sqrt (Arg : Float) return Float;
2691    pragma Contract_Cases (((Arg in 0.0 .. 99.0) => Sqrt'Result < 10.0,
2692                            Arg >= 100.0         => Sqrt'Result >= 10.0,
2693                            others               => Sqrt'Result = 0.0));
2694    ...
2695 end Math_Functions;
2696 @end example
2698 The meaning of contract cases is that only one case should apply at each
2699 call, as determined by the corresponding case guard evaluating to True,
2700 and that the consequence for this case should hold when the subprogram
2701 returns.
2703 @node Pragma Convention_Identifier,Pragma CPP_Class,Pragma Contract_Cases,Implementation Defined Pragmas
2704 @anchor{gnat_rm/implementation_defined_pragmas pragma-convention-identifier}@anchor{47}
2705 @section Pragma Convention_Identifier
2708 @geindex Conventions
2709 @geindex synonyms
2711 Syntax:
2713 @example
2714 pragma Convention_Identifier (
2715          [Name =>]       IDENTIFIER,
2716          [Convention =>] convention_IDENTIFIER);
2717 @end example
2719 This pragma provides a mechanism for supplying synonyms for existing
2720 convention identifiers. The @code{Name} identifier can subsequently
2721 be used as a synonym for the given convention in other pragmas (including
2722 for example pragma @code{Import} or another @code{Convention_Identifier}
2723 pragma). As an example of the use of this, suppose you had legacy code
2724 which used Fortran77 as the identifier for Fortran. Then the pragma:
2726 @example
2727 pragma Convention_Identifier (Fortran77, Fortran);
2728 @end example
2730 would allow the use of the convention identifier @code{Fortran77} in
2731 subsequent code, avoiding the need to modify the sources. As another
2732 example, you could use this to parameterize convention requirements
2733 according to systems. Suppose you needed to use @code{Stdcall} on
2734 windows systems, and @code{C} on some other system, then you could
2735 define a convention identifier @code{Library} and use a single
2736 @code{Convention_Identifier} pragma to specify which convention
2737 would be used system-wide.
2739 @node Pragma CPP_Class,Pragma CPP_Constructor,Pragma Convention_Identifier,Implementation Defined Pragmas
2740 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-class}@anchor{48}
2741 @section Pragma CPP_Class
2744 @geindex Interfacing with C++
2746 Syntax:
2748 @example
2749 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2750 @end example
2752 The argument denotes an entity in the current declarative region that is
2753 declared as a record type. It indicates that the type corresponds to an
2754 externally declared C++ class type, and is to be laid out the same way
2755 that C++ would lay out the type. If the C++ class has virtual primitives
2756 then the record must be declared as a tagged record type.
2758 Types for which @code{CPP_Class} is specified do not have assignment or
2759 equality operators defined (such operations can be imported or declared
2760 as subprograms as required). Initialization is allowed only by constructor
2761 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2762 limited if not explicitly declared as limited or derived from a limited
2763 type, and an error is issued in that case.
2765 See @ref{49,,Interfacing to C++} for related information.
2767 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2768 for backward compatibility but its functionality is available
2769 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2771 @node Pragma CPP_Constructor,Pragma CPP_Virtual,Pragma CPP_Class,Implementation Defined Pragmas
2772 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-constructor}@anchor{4a}
2773 @section Pragma CPP_Constructor
2776 @geindex Interfacing with C++
2778 Syntax:
2780 @example
2781 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2782   [, [External_Name =>] static_string_EXPRESSION ]
2783   [, [Link_Name     =>] static_string_EXPRESSION ]);
2784 @end example
2786 This pragma identifies an imported function (imported in the usual way
2787 with pragma @code{Import}) as corresponding to a C++ constructor. If
2788 @code{External_Name} and @code{Link_Name} are not specified then the
2789 @code{Entity} argument is a name that must have been previously mentioned
2790 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2791 must be of one of the following forms:
2794 @itemize *
2796 @item 
2797 `function' @code{Fname} `return' T`
2799 @item 
2800 `function' @code{Fname} `return' T’Class
2802 @item 
2803 `function' @code{Fname} (…) `return' T`
2805 @item 
2806 `function' @code{Fname} (…) `return' T’Class
2807 @end itemize
2809 where @code{T} is a limited record type imported from C++ with pragma
2810 @code{Import} and @code{Convention} = @code{CPP}.
2812 The first two forms import the default constructor, used when an object
2813 of type @code{T} is created on the Ada side with no explicit constructor.
2814 The latter two forms cover all the non-default constructors of the type.
2815 See the GNAT User’s Guide for details.
2817 If no constructors are imported, it is impossible to create any objects
2818 on the Ada side and the type is implicitly declared abstract.
2820 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2821 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2822 GCC switch).
2823 See @ref{49,,Interfacing to C++} for more related information.
2825 Note: The use of functions returning class-wide types for constructors is
2826 currently obsolete. They are supported for backward compatibility. The
2827 use of functions returning the type T leave the Ada sources more clear
2828 because the imported C++ constructors always return an object of type T;
2829 that is, they never return an object whose type is a descendant of type T.
2831 @node Pragma CPP_Virtual,Pragma CPP_Vtable,Pragma CPP_Constructor,Implementation Defined Pragmas
2832 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-virtual}@anchor{4b}
2833 @section Pragma CPP_Virtual
2836 @geindex Interfacing to C++
2838 This pragma is now obsolete and, other than generating a warning if warnings
2839 on obsolescent features are enabled, is completely ignored.
2840 It is retained for compatibility
2841 purposes. It used to be required to ensure compatibility with C++, but
2842 is no longer required for that purpose because GNAT generates
2843 the same object layout as the G++ compiler by default.
2845 See @ref{49,,Interfacing to C++} for related information.
2847 @node Pragma CPP_Vtable,Pragma CPU,Pragma CPP_Virtual,Implementation Defined Pragmas
2848 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-vtable}@anchor{4c}
2849 @section Pragma CPP_Vtable
2852 @geindex Interfacing with C++
2854 This pragma is now obsolete and, other than generating a warning if warnings
2855 on obsolescent features are enabled, is completely ignored.
2856 It used to be required to ensure compatibility with C++, but
2857 is no longer required for that purpose because GNAT generates
2858 the same object layout as the G++ compiler by default.
2860 See @ref{49,,Interfacing to C++} for related information.
2862 @node Pragma CPU,Pragma Deadline_Floor,Pragma CPP_Vtable,Implementation Defined Pragmas
2863 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpu}@anchor{4d}
2864 @section Pragma CPU
2867 Syntax:
2869 @example
2870 pragma CPU (EXPRESSION);
2871 @end example
2873 This pragma is standard in Ada 2012, but is available in all earlier
2874 versions of Ada as an implementation-defined pragma.
2875 See Ada 2012 Reference Manual for details.
2877 @node Pragma Deadline_Floor,Pragma Debug,Pragma CPU,Implementation Defined Pragmas
2878 @anchor{gnat_rm/implementation_defined_pragmas pragma-deadline-floor}@anchor{4e}
2879 @section Pragma Deadline_Floor
2882 Syntax:
2884 @example
2885 pragma Deadline_Floor (time_span_EXPRESSION);
2886 @end example
2888 This pragma applies only to protected types and specifies the floor
2889 deadline inherited by a task when the task enters a protected object.
2890 It is effective only when the EDF scheduling policy is used.
2892 @node Pragma Debug,Pragma Debug_Policy,Pragma Deadline_Floor,Implementation Defined Pragmas
2893 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug}@anchor{4f}
2894 @section Pragma Debug
2897 Syntax:
2899 @example
2900 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2902 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2903   PROCEDURE_NAME
2904 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2905 @end example
2907 The procedure call argument has the syntactic form of an expression, meeting
2908 the syntactic requirements for pragmas.
2910 If debug pragmas are not enabled or if the condition is present and evaluates
2911 to False, this pragma has no effect. If debug pragmas are enabled, the
2912 semantics of the pragma is exactly equivalent to the procedure call statement
2913 corresponding to the argument with a terminating semicolon. Pragmas are
2914 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2915 intersperse calls to debug procedures in the middle of declarations. Debug
2916 pragmas can be enabled either by use of the command line switch `-gnata'
2917 or by use of the pragma @code{Check_Policy} with a first argument of
2918 @code{Debug}.
2920 @node Pragma Debug_Policy,Pragma Default_Initial_Condition,Pragma Debug,Implementation Defined Pragmas
2921 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug-policy}@anchor{50}
2922 @section Pragma Debug_Policy
2925 Syntax:
2927 @example
2928 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2929 @end example
2931 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2932 with a first argument of @code{Debug}. It is retained for historical
2933 compatibility reasons.
2935 @node Pragma Default_Initial_Condition,Pragma Default_Scalar_Storage_Order,Pragma Debug_Policy,Implementation Defined Pragmas
2936 @anchor{gnat_rm/implementation_defined_pragmas id9}@anchor{51}@anchor{gnat_rm/implementation_defined_pragmas pragma-default-initial-condition}@anchor{52}
2937 @section Pragma Default_Initial_Condition
2940 Syntax:
2942 @example
2943 pragma Default_Initial_Condition [ (null | boolean_EXPRESSION) ];
2944 @end example
2946 For the semantics of this pragma, see the entry for aspect
2947 @code{Default_Initial_Condition} in the SPARK 2014 Reference Manual, section 7.3.3.
2949 @node Pragma Default_Scalar_Storage_Order,Pragma Default_Storage_Pool,Pragma Default_Initial_Condition,Implementation Defined Pragmas
2950 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-scalar-storage-order}@anchor{53}
2951 @section Pragma Default_Scalar_Storage_Order
2954 @geindex Default_Scalar_Storage_Order
2956 @geindex Scalar_Storage_Order
2958 Syntax:
2960 @example
2961 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2962 @end example
2964 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2965 type or array type, then the scalar storage order defaults to the ordinary
2966 default for the target. But this default may be overridden using this pragma.
2967 The pragma may appear as a configuration pragma, or locally within a package
2968 spec or declarative part. In the latter case, it applies to all subsequent
2969 types declared within that package spec or declarative part.
2971 The following example shows the use of this pragma:
2973 @example
2974 pragma Default_Scalar_Storage_Order (High_Order_First);
2975 with System; use System;
2976 package DSSO1 is
2977    type H1 is record
2978       a : Integer;
2979    end record;
2981    type L2 is record
2982       a : Integer;
2983    end record;
2984    for L2'Scalar_Storage_Order use Low_Order_First;
2986    type L2a is new L2;
2988    package Inner is
2989       type H3 is record
2990          a : Integer;
2991       end record;
2993       pragma Default_Scalar_Storage_Order (Low_Order_First);
2995       type L4 is record
2996          a : Integer;
2997       end record;
2998    end Inner;
3000    type H4a is new Inner.L4;
3002    type H5 is record
3003       a : Integer;
3004    end record;
3005 end DSSO1;
3006 @end example
3008 In this example record types with names starting with `L' have @cite{Low_Order_First} scalar
3009 storage order, and record types with names starting with `H' have @code{High_Order_First}.
3010 Note that in the case of @code{H4a}, the order is not inherited
3011 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
3012 gets inherited on type derivation.
3014 If this pragma is used as a configuration pragma which appears within a
3015 configuration pragma file (as opposed to appearing explicitly at the start
3016 of a single unit), then the binder will require that all units in a partition
3017 be compiled in a similar manner, other than run-time units, which are not
3018 affected by this pragma. Note that the use of this form is discouraged because
3019 it may significantly degrade the run-time performance of the software, instead
3020 the default scalar storage order ought to be changed only on a local basis.
3022 @node Pragma Default_Storage_Pool,Pragma Depends,Pragma Default_Scalar_Storage_Order,Implementation Defined Pragmas
3023 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-storage-pool}@anchor{54}
3024 @section Pragma Default_Storage_Pool
3027 @geindex Default_Storage_Pool
3029 Syntax:
3031 @example
3032 pragma Default_Storage_Pool (storage_pool_NAME | null);
3033 @end example
3035 This pragma is standard in Ada 2012, but is available in all earlier
3036 versions of Ada as an implementation-defined pragma.
3037 See Ada 2012 Reference Manual for details.
3039 @node Pragma Depends,Pragma Detect_Blocking,Pragma Default_Storage_Pool,Implementation Defined Pragmas
3040 @anchor{gnat_rm/implementation_defined_pragmas id10}@anchor{55}@anchor{gnat_rm/implementation_defined_pragmas pragma-depends}@anchor{56}
3041 @section Pragma Depends
3044 Syntax:
3046 @example
3047 pragma Depends (DEPENDENCY_RELATION);
3049 DEPENDENCY_RELATION ::=
3050      null
3051   | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
3053 DEPENDENCY_CLAUSE ::=
3054     OUTPUT_LIST =>[+] INPUT_LIST
3055   | NULL_DEPENDENCY_CLAUSE
3057 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
3059 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
3061 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
3063 OUTPUT ::= NAME | FUNCTION_RESULT
3064 INPUT  ::= NAME
3066 where FUNCTION_RESULT is a function Result attribute_reference
3067 @end example
3069 For the semantics of this pragma, see the entry for aspect @code{Depends} in the
3070 SPARK 2014 Reference Manual, section 6.1.5.
3072 @node Pragma Detect_Blocking,Pragma Disable_Atomic_Synchronization,Pragma Depends,Implementation Defined Pragmas
3073 @anchor{gnat_rm/implementation_defined_pragmas pragma-detect-blocking}@anchor{57}
3074 @section Pragma Detect_Blocking
3077 Syntax:
3079 @example
3080 pragma Detect_Blocking;
3081 @end example
3083 This is a standard pragma in Ada 2005, that is available in all earlier
3084 versions of Ada as an implementation-defined pragma.
3086 This is a configuration pragma that forces the detection of potentially
3087 blocking operations within a protected operation, and to raise Program_Error
3088 if that happens.
3090 @node Pragma Disable_Atomic_Synchronization,Pragma Dispatching_Domain,Pragma Detect_Blocking,Implementation Defined Pragmas
3091 @anchor{gnat_rm/implementation_defined_pragmas pragma-disable-atomic-synchronization}@anchor{58}
3092 @section Pragma Disable_Atomic_Synchronization
3095 @geindex Atomic Synchronization
3097 Syntax:
3099 @example
3100 pragma Disable_Atomic_Synchronization [(Entity)];
3101 @end example
3103 Ada requires that accesses (reads or writes) of an atomic variable be
3104 regarded as synchronization points in the case of multiple tasks.
3105 Particularly in the case of multi-processors this may require special
3106 handling, e.g. the generation of memory barriers. This capability may
3107 be turned off using this pragma in cases where it is known not to be
3108 required.
3110 The placement and scope rules for this pragma are the same as those
3111 for @code{pragma Suppress}. In particular it can be used as a
3112 configuration  pragma, or in a declaration sequence where it applies
3113 till the end of the scope. If an @code{Entity} argument is present,
3114 the action applies only to that entity.
3116 @node Pragma Dispatching_Domain,Pragma Effective_Reads,Pragma Disable_Atomic_Synchronization,Implementation Defined Pragmas
3117 @anchor{gnat_rm/implementation_defined_pragmas pragma-dispatching-domain}@anchor{59}
3118 @section Pragma Dispatching_Domain
3121 Syntax:
3123 @example
3124 pragma Dispatching_Domain (EXPRESSION);
3125 @end example
3127 This pragma is standard in Ada 2012, but is available in all earlier
3128 versions of Ada as an implementation-defined pragma.
3129 See Ada 2012 Reference Manual for details.
3131 @node Pragma Effective_Reads,Pragma Effective_Writes,Pragma Dispatching_Domain,Implementation Defined Pragmas
3132 @anchor{gnat_rm/implementation_defined_pragmas id11}@anchor{5a}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-reads}@anchor{5b}
3133 @section Pragma Effective_Reads
3136 Syntax:
3138 @example
3139 pragma Effective_Reads [ (static_boolean_EXPRESSION) ];
3140 @end example
3142 For the semantics of this pragma, see the entry for aspect @code{Effective_Reads} in
3143 the SPARK 2014 Reference Manual, section 7.1.2.
3145 @node Pragma Effective_Writes,Pragma Elaboration_Checks,Pragma Effective_Reads,Implementation Defined Pragmas
3146 @anchor{gnat_rm/implementation_defined_pragmas id12}@anchor{5c}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-writes}@anchor{5d}
3147 @section Pragma Effective_Writes
3150 Syntax:
3152 @example
3153 pragma Effective_Writes [ (static_boolean_EXPRESSION) ];
3154 @end example
3156 For the semantics of this pragma, see the entry for aspect @code{Effective_Writes}
3157 in the SPARK 2014 Reference Manual, section 7.1.2.
3159 @node Pragma Elaboration_Checks,Pragma Eliminate,Pragma Effective_Writes,Implementation Defined Pragmas
3160 @anchor{gnat_rm/implementation_defined_pragmas pragma-elaboration-checks}@anchor{5e}
3161 @section Pragma Elaboration_Checks
3164 @geindex Elaboration control
3166 Syntax:
3168 @example
3169 pragma Elaboration_Checks (Dynamic | Static);
3170 @end example
3172 This is a configuration pragma which specifies the elaboration model to be
3173 used during compilation. For more information on the elaboration models of
3174 GNAT, consult the chapter on elaboration order handling in the `GNAT User’s
3175 Guide'.
3177 The pragma may appear in the following contexts:
3180 @itemize *
3182 @item 
3183 Configuration pragmas file
3185 @item 
3186 Prior to the context clauses of a compilation unit’s initial declaration
3187 @end itemize
3189 Any other placement of the pragma will result in a warning and the effects of
3190 the offending pragma will be ignored.
3192 If the pragma argument is @code{Dynamic}, then the dynamic elaboration model is in
3193 effect. If the pragma argument is @code{Static}, then the static elaboration model
3194 is in effect.
3196 @node Pragma Eliminate,Pragma Enable_Atomic_Synchronization,Pragma Elaboration_Checks,Implementation Defined Pragmas
3197 @anchor{gnat_rm/implementation_defined_pragmas pragma-eliminate}@anchor{5f}
3198 @section Pragma Eliminate
3201 @geindex Elimination of unused subprograms
3203 Syntax:
3205 @example
3206 pragma Eliminate (
3207             [  Unit_Name       => ] IDENTIFIER | SELECTED_COMPONENT ,
3208             [  Entity          => ] IDENTIFIER |
3209                                     SELECTED_COMPONENT |
3210                                     STRING_LITERAL
3211             [, Source_Location =>   SOURCE_TRACE ] );
3213         SOURCE_TRACE    ::= STRING_LITERAL
3214 @end example
3216 This pragma indicates that the given entity is not used in the program to be
3217 compiled and built, thus allowing the compiler to
3218 eliminate the code or data associated with the named entity. Any reference to
3219 an eliminated entity causes a compile-time or link-time error.
3221 The pragma has the following semantics, where @code{U} is the unit specified by
3222 the @code{Unit_Name} argument and @code{E} is the entity specified by the @code{Entity}
3223 argument:
3226 @itemize *
3228 @item 
3229 @code{E} must be a subprogram that is explicitly declared either:
3232 @itemize *
3234 @item 
3235 Within @code{U}, or
3237 @item 
3238 Within a generic package that is instantiated in @code{U}, or
3240 @item 
3241 As an instance of generic subprogram instantiated in @code{U}.
3242 @end itemize
3244 Otherwise the pragma is ignored.
3246 @item 
3247 If @code{E} is overloaded within @code{U} then, in the absence of a
3248 @code{Source_Location} argument, all overloadings are eliminated.
3250 @item 
3251 If @code{E} is overloaded within @code{U} and only some overloadings
3252 are to be eliminated, then each overloading to be eliminated
3253 must be specified in a corresponding pragma @code{Eliminate}
3254 with a @code{Source_Location} argument identifying the line where the
3255 declaration appears, as described below.
3257 @item 
3258 If @code{E} is declared as the result of a generic instantiation, then
3259 a @code{Source_Location} argument is needed, as described below.
3260 @end itemize
3262 Pragma @code{Eliminate} allows a program to be compiled in a system-independent
3263 manner, so that unused entities are eliminated but without
3264 needing to modify the source text. Normally the required set of
3265 @code{Eliminate} pragmas is constructed automatically using the @code{gnatelim} tool.
3267 Any source file change that removes, splits, or
3268 adds lines may make the set of @code{Eliminate} pragmas invalid because their
3269 @code{Source_Location} argument values may get out of date.
3271 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
3272 operation. In this case all the subprograms to which the given operation can
3273 dispatch are considered to be unused (are never called as a result of a direct
3274 or a dispatching call).
3276 The string literal given for the source location specifies the line number
3277 of the declaration of the entity, using the following syntax for @code{SOURCE_TRACE}:
3279 @example
3280 SOURCE_TRACE     ::= SOURCE_REFERENCE [ LBRACKET SOURCE_TRACE RBRACKET ]
3282 LBRACKET         ::= '['
3283 RBRACKET         ::= ']'
3285 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
3287 LINE_NUMBER      ::= DIGIT @{DIGIT@}
3288 @end example
3290 Spaces around the colon in a @code{SOURCE_REFERENCE} are optional.
3292 The source trace that is given as the @code{Source_Location} must obey the
3293 following rules (or else the pragma is ignored), where @code{U} is
3294 the unit @code{U} specified by the @code{Unit_Name} argument and @code{E} is the
3295 subprogram specified by the @code{Entity} argument:
3298 @itemize *
3300 @item 
3301 @code{FILE_NAME} is the short name (with no directory
3302 information) of the Ada source file for @code{U}, using the required syntax
3303 for the underlying file system (e.g. case is significant if the underlying
3304 operating system is case sensitive).
3305 If @code{U} is a package and @code{E} is a subprogram declared in the package
3306 specification and its full declaration appears in the package body,
3307 then the  relevant source file is the one for the package specification;
3308 analogously if @code{U} is a generic package.
3310 @item 
3311 If @code{E} is not declared in a generic instantiation (this includes
3312 generic subprogram instances), the source trace includes only one source
3313 line reference. @code{LINE_NUMBER} gives the line number of the occurrence
3314 of the declaration of @code{E} within the source file (as a decimal literal
3315 without an exponent or point).
3317 @item 
3318 If @code{E} is declared by a generic instantiation, its source trace
3319 (from left to right) starts with the source location of the
3320 declaration of @code{E} in the generic unit and ends with the source
3321 location of the instantiation, given in square brackets. This approach is
3322 applied recursively with nested instantiations: the rightmost (nested
3323 most deeply in square brackets) element of the source trace is the location
3324 of the outermost instantiation, and the leftmost element (that is, outside
3325 of any square brackets) is the location of the declaration of @code{E} in
3326 the generic unit.
3327 @end itemize
3329 Examples:
3331 @quotation
3333 @example
3334 pragma Eliminate (Pkg0, Proc);
3335 -- Eliminate (all overloadings of) Proc in Pkg0
3337 pragma Eliminate (Pkg1, Proc,
3338                   Source_Location => "pkg1.ads:8");
3339 -- Eliminate overloading of Proc at line 8 in pkg1.ads
3341 -- Assume the following file contents:
3342 --   gen_pkg.ads
3343 --   1: generic
3344 --   2:   type T is private;
3345 --   3: package Gen_Pkg is
3346 --   4:   procedure Proc(N : T);
3347 --  ...   ...
3348 --  ... end Gen_Pkg;
3350 --    q.adb
3351 --   1: with Gen_Pkg;
3352 --   2: procedure Q is
3353 --   3:   package Inst_Pkg is new Gen_Pkg(Integer);
3354 --  ...   -- No calls on Inst_Pkg.Proc
3355 --  ... end Q;
3357 -- The following pragma eliminates Inst_Pkg.Proc from Q
3358 pragma Eliminate (Q, Proc,
3359                   Source_Location => "gen_pkg.ads:4[q.adb:3]");
3360 @end example
3361 @end quotation
3363 @node Pragma Enable_Atomic_Synchronization,Pragma Export_Function,Pragma Eliminate,Implementation Defined Pragmas
3364 @anchor{gnat_rm/implementation_defined_pragmas pragma-enable-atomic-synchronization}@anchor{60}
3365 @section Pragma Enable_Atomic_Synchronization
3368 @geindex Atomic Synchronization
3370 Syntax:
3372 @example
3373 pragma Enable_Atomic_Synchronization [(Entity)];
3374 @end example
3376 Ada requires that accesses (reads or writes) of an atomic variable be
3377 regarded as synchronization points in the case of multiple tasks.
3378 Particularly in the case of multi-processors this may require special
3379 handling, e.g. the generation of memory barriers. This synchronization
3380 is performed by default, but can be turned off using
3381 @code{pragma Disable_Atomic_Synchronization}. The
3382 @code{Enable_Atomic_Synchronization} pragma can be used to turn
3383 it back on.
3385 The placement and scope rules for this pragma are the same as those
3386 for @code{pragma Unsuppress}. In particular it can be used as a
3387 configuration  pragma, or in a declaration sequence where it applies
3388 till the end of the scope. If an @code{Entity} argument is present,
3389 the action applies only to that entity.
3391 @node Pragma Export_Function,Pragma Export_Object,Pragma Enable_Atomic_Synchronization,Implementation Defined Pragmas
3392 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-function}@anchor{61}
3393 @section Pragma Export_Function
3396 @geindex Argument passing mechanisms
3398 Syntax:
3400 @example
3401 pragma Export_Function (
3402      [Internal         =>] LOCAL_NAME
3403   [, [External         =>] EXTERNAL_SYMBOL]
3404   [, [Parameter_Types  =>] PARAMETER_TYPES]
3405   [, [Result_Type      =>] result_SUBTYPE_MARK]
3406   [, [Mechanism        =>] MECHANISM]
3407   [, [Result_Mechanism =>] MECHANISM_NAME]);
3409 EXTERNAL_SYMBOL ::=
3410   IDENTIFIER
3411 | static_string_EXPRESSION
3412 | ""
3414 PARAMETER_TYPES ::=
3415   null
3416 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3418 TYPE_DESIGNATOR ::=
3419   subtype_NAME
3420 | subtype_Name ' Access
3422 MECHANISM ::=
3423   MECHANISM_NAME
3424 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3426 MECHANISM_ASSOCIATION ::=
3427   [formal_parameter_NAME =>] MECHANISM_NAME
3429 MECHANISM_NAME ::= Value | Reference
3430 @end example
3432 Use this pragma to make a function externally callable and optionally
3433 provide information on mechanisms to be used for passing parameter and
3434 result values.  We recommend, for the purposes of improving portability,
3435 this pragma always be used in conjunction with a separate pragma
3436 @code{Export}, which must precede the pragma @code{Export_Function}.
3437 GNAT does not require a separate pragma @code{Export}, but if none is
3438 present, @code{Convention Ada} is assumed, which is usually
3439 not what is wanted, so it is usually appropriate to use this
3440 pragma in conjunction with a @code{Export} or @code{Convention}
3441 pragma that specifies the desired foreign convention.
3442 Pragma @code{Export_Function}
3443 (and @code{Export}, if present) must appear in the same declarative
3444 region as the function to which they apply.
3446 The @code{internal_name} must uniquely designate the function to which the
3447 pragma applies.  If more than one function name exists of this name in
3448 the declarative part you must use the @code{Parameter_Types} and
3449 @code{Result_Type} parameters to achieve the required
3450 unique designation.  The @cite{subtype_mark}s in these parameters must
3451 exactly match the subtypes in the corresponding function specification,
3452 using positional notation to match parameters with subtype marks.
3453 The form with an @code{'Access} attribute can be used to match an
3454 anonymous access parameter.
3456 @geindex Suppressing external name
3458 Special treatment is given if the EXTERNAL is an explicit null
3459 string or a static string expressions that evaluates to the null
3460 string. In this case, no external name is generated. This form
3461 still allows the specification of parameter mechanisms.
3463 @node Pragma Export_Object,Pragma Export_Procedure,Pragma Export_Function,Implementation Defined Pragmas
3464 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-object}@anchor{62}
3465 @section Pragma Export_Object
3468 Syntax:
3470 @example
3471 pragma Export_Object (
3472       [Internal =>] LOCAL_NAME
3473    [, [External =>] EXTERNAL_SYMBOL]
3474    [, [Size     =>] EXTERNAL_SYMBOL]);
3476 EXTERNAL_SYMBOL ::=
3477   IDENTIFIER
3478 | static_string_EXPRESSION
3479 @end example
3481 This pragma designates an object as exported, and apart from the
3482 extended rules for external symbols, is identical in effect to the use of
3483 the normal @code{Export} pragma applied to an object.  You may use a
3484 separate Export pragma (and you probably should from the point of view
3485 of portability), but it is not required.  @code{Size} is syntax checked,
3486 but otherwise ignored by GNAT.
3488 @node Pragma Export_Procedure,Pragma Export_Valued_Procedure,Pragma Export_Object,Implementation Defined Pragmas
3489 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-procedure}@anchor{63}
3490 @section Pragma Export_Procedure
3493 Syntax:
3495 @example
3496 pragma Export_Procedure (
3497      [Internal        =>] LOCAL_NAME
3498   [, [External        =>] EXTERNAL_SYMBOL]
3499   [, [Parameter_Types =>] PARAMETER_TYPES]
3500   [, [Mechanism       =>] MECHANISM]);
3502 EXTERNAL_SYMBOL ::=
3503   IDENTIFIER
3504 | static_string_EXPRESSION
3505 | ""
3507 PARAMETER_TYPES ::=
3508   null
3509 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3511 TYPE_DESIGNATOR ::=
3512   subtype_NAME
3513 | subtype_Name ' Access
3515 MECHANISM ::=
3516   MECHANISM_NAME
3517 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3519 MECHANISM_ASSOCIATION ::=
3520   [formal_parameter_NAME =>] MECHANISM_NAME
3522 MECHANISM_NAME ::= Value | Reference
3523 @end example
3525 This pragma is identical to @code{Export_Function} except that it
3526 applies to a procedure rather than a function and the parameters
3527 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3528 GNAT does not require a separate pragma @code{Export}, but if none is
3529 present, @code{Convention Ada} is assumed, which is usually
3530 not what is wanted, so it is usually appropriate to use this
3531 pragma in conjunction with a @code{Export} or @code{Convention}
3532 pragma that specifies the desired foreign convention.
3534 @geindex Suppressing external name
3536 Special treatment is given if the EXTERNAL is an explicit null
3537 string or a static string expressions that evaluates to the null
3538 string. In this case, no external name is generated. This form
3539 still allows the specification of parameter mechanisms.
3541 @node Pragma Export_Valued_Procedure,Pragma Extend_System,Pragma Export_Procedure,Implementation Defined Pragmas
3542 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-valued-procedure}@anchor{64}
3543 @section Pragma Export_Valued_Procedure
3546 Syntax:
3548 @example
3549 pragma Export_Valued_Procedure (
3550      [Internal        =>] LOCAL_NAME
3551   [, [External        =>] EXTERNAL_SYMBOL]
3552   [, [Parameter_Types =>] PARAMETER_TYPES]
3553   [, [Mechanism       =>] MECHANISM]);
3555 EXTERNAL_SYMBOL ::=
3556   IDENTIFIER
3557 | static_string_EXPRESSION
3558 | ""
3560 PARAMETER_TYPES ::=
3561   null
3562 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3564 TYPE_DESIGNATOR ::=
3565   subtype_NAME
3566 | subtype_Name ' Access
3568 MECHANISM ::=
3569   MECHANISM_NAME
3570 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3572 MECHANISM_ASSOCIATION ::=
3573   [formal_parameter_NAME =>] MECHANISM_NAME
3575 MECHANISM_NAME ::= Value | Reference
3576 @end example
3578 This pragma is identical to @code{Export_Procedure} except that the
3579 first parameter of @code{LOCAL_NAME}, which must be present, must be of
3580 mode @code{out}, and externally the subprogram is treated as a function
3581 with this parameter as the result of the function.  GNAT provides for
3582 this capability to allow the use of @code{out} and @code{in out}
3583 parameters in interfacing to external functions (which are not permitted
3584 in Ada functions).
3585 GNAT does not require a separate pragma @code{Export}, but if none is
3586 present, @code{Convention Ada} is assumed, which is almost certainly
3587 not what is wanted since the whole point of this pragma is to interface
3588 with foreign language functions, so it is usually appropriate to use this
3589 pragma in conjunction with a @code{Export} or @code{Convention}
3590 pragma that specifies the desired foreign convention.
3592 @geindex Suppressing external name
3594 Special treatment is given if the EXTERNAL is an explicit null
3595 string or a static string expressions that evaluates to the null
3596 string. In this case, no external name is generated. This form
3597 still allows the specification of parameter mechanisms.
3599 @node Pragma Extend_System,Pragma Extensions_Allowed,Pragma Export_Valued_Procedure,Implementation Defined Pragmas
3600 @anchor{gnat_rm/implementation_defined_pragmas pragma-extend-system}@anchor{65}
3601 @section Pragma Extend_System
3604 @geindex System
3605 @geindex extending
3607 @geindex DEC Ada 83
3609 Syntax:
3611 @example
3612 pragma Extend_System ([Name =>] IDENTIFIER);
3613 @end example
3615 This pragma is used to provide backwards compatibility with other
3616 implementations that extend the facilities of package @code{System}.  In
3617 GNAT, @code{System} contains only the definitions that are present in
3618 the Ada RM.  However, other implementations, notably the DEC Ada 83
3619 implementation, provide many extensions to package @code{System}.
3621 For each such implementation accommodated by this pragma, GNAT provides a
3622 package @code{Aux_@var{xxx}}, e.g., @code{Aux_DEC} for the DEC Ada 83
3623 implementation, which provides the required additional definitions.  You
3624 can use this package in two ways.  You can @code{with} it in the normal
3625 way and access entities either by selection or using a @code{use}
3626 clause.  In this case no special processing is required.
3628 However, if existing code contains references such as
3629 @code{System.@var{xxx}} where `xxx' is an entity in the extended
3630 definitions provided in package @code{System}, you may use this pragma
3631 to extend visibility in @code{System} in a non-standard way that
3632 provides greater compatibility with the existing code.  Pragma
3633 @code{Extend_System} is a configuration pragma whose single argument is
3634 the name of the package containing the extended definition
3635 (e.g., @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3636 control of this pragma will be processed using special visibility
3637 processing that looks in package @code{System.Aux_@var{xxx}} where
3638 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3639 package @code{System}, but not found in package @code{System}.
3641 You can use this pragma either to access a predefined @code{System}
3642 extension supplied with the compiler, for example @code{Aux_DEC} or
3643 you can construct your own extension unit following the above
3644 definition.  Note that such a package is a child of @code{System}
3645 and thus is considered part of the implementation.
3646 To compile it you will have to use the `-gnatg' switch
3647 for compiling System units, as explained in the
3648 GNAT User’s Guide.
3650 @node Pragma Extensions_Allowed,Pragma Extensions_Visible,Pragma Extend_System,Implementation Defined Pragmas
3651 @anchor{gnat_rm/implementation_defined_pragmas id13}@anchor{66}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-allowed}@anchor{67}
3652 @section Pragma Extensions_Allowed
3655 @geindex Ada Extensions
3657 @geindex GNAT Extensions
3659 Syntax:
3661 @example
3662 pragma Extensions_Allowed (On | Off | All);
3663 @end example
3665 This configuration pragma enables (via the “On” or “All” argument) or disables
3666 (via the “Off” argument) the implementation extension mode; the pragma takes
3667 precedence over the @code{-gnatX} and @code{-gnatX0} command switches.
3669 If an argument of @code{"On"} is specified, the latest version of the Ada language
3670 is implemented (currently Ada 2022) and, in addition, a curated set of GNAT
3671 specific extensions are recognized. (See the list here
3672 @ref{68,,here})
3674 An argument of @code{"All"} has the same effect except that some extra
3675 experimental extensions are enabled (See the list here
3676 @ref{69,,here})
3678 @node Pragma Extensions_Visible,Pragma External,Pragma Extensions_Allowed,Implementation Defined Pragmas
3679 @anchor{gnat_rm/implementation_defined_pragmas id14}@anchor{6a}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-visible}@anchor{6b}
3680 @section Pragma Extensions_Visible
3683 Syntax:
3685 @example
3686 pragma Extensions_Visible [ (static_boolean_EXPRESSION) ];
3687 @end example
3689 For the semantics of this pragma, see the entry for aspect @code{Extensions_Visible}
3690 in the SPARK 2014 Reference Manual, section 6.1.7.
3692 @node Pragma External,Pragma External_Name_Casing,Pragma Extensions_Visible,Implementation Defined Pragmas
3693 @anchor{gnat_rm/implementation_defined_pragmas pragma-external}@anchor{6c}
3694 @section Pragma External
3697 Syntax:
3699 @example
3700 pragma External (
3701   [   Convention    =>] convention_IDENTIFIER,
3702   [   Entity        =>] LOCAL_NAME
3703   [, [External_Name =>] static_string_EXPRESSION ]
3704   [, [Link_Name     =>] static_string_EXPRESSION ]);
3705 @end example
3707 This pragma is identical in syntax and semantics to pragma
3708 @code{Export} as defined in the Ada Reference Manual.  It is
3709 provided for compatibility with some Ada 83 compilers that
3710 used this pragma for exactly the same purposes as pragma
3711 @code{Export} before the latter was standardized.
3713 @node Pragma External_Name_Casing,Pragma Fast_Math,Pragma External,Implementation Defined Pragmas
3714 @anchor{gnat_rm/implementation_defined_pragmas pragma-external-name-casing}@anchor{6d}
3715 @section Pragma External_Name_Casing
3718 @geindex Dec Ada 83 casing compatibility
3720 @geindex External Names
3721 @geindex casing
3723 @geindex Casing of External names
3725 Syntax:
3727 @example
3728 pragma External_Name_Casing (
3729   Uppercase | Lowercase
3730   [, Uppercase | Lowercase | As_Is]);
3731 @end example
3733 This pragma provides control over the casing of external names associated
3734 with Import and Export pragmas.  There are two cases to consider:
3737 @itemize *
3739 @item 
3740 Implicit external names
3742 Implicit external names are derived from identifiers.  The most common case
3743 arises when a standard Ada Import or Export pragma is used with only two
3744 arguments, as in:
3746 @example
3747 pragma Import (C, C_Routine);
3748 @end example
3750 Since Ada is a case-insensitive language, the spelling of the identifier in
3751 the Ada source program does not provide any information on the desired
3752 casing of the external name, and so a convention is needed.  In GNAT the
3753 default treatment is that such names are converted to all lower case
3754 letters.  This corresponds to the normal C style in many environments.
3755 The first argument of pragma @code{External_Name_Casing} can be used to
3756 control this treatment.  If @code{Uppercase} is specified, then the name
3757 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3758 then the normal default of all lower case letters will be used.
3760 This same implicit treatment is also used in the case of extended DEC Ada 83
3761 compatible Import and Export pragmas where an external name is explicitly
3762 specified using an identifier rather than a string.
3764 @item 
3765 Explicit external names
3767 Explicit external names are given as string literals.  The most common case
3768 arises when a standard Ada Import or Export pragma is used with three
3769 arguments, as in:
3771 @example
3772 pragma Import (C, C_Routine, "C_routine");
3773 @end example
3775 In this case, the string literal normally provides the exact casing required
3776 for the external name.  The second argument of pragma
3777 @code{External_Name_Casing} may be used to modify this behavior.
3778 If @code{Uppercase} is specified, then the name
3779 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3780 then the name will be forced to all lowercase letters.  A specification of
3781 @code{As_Is} provides the normal default behavior in which the casing is
3782 taken from the string provided.
3783 @end itemize
3785 This pragma may appear anywhere that a pragma is valid. In particular, it
3786 can be used as a configuration pragma in the @code{gnat.adc} file, in which
3787 case it applies to all subsequent compilations, or it can be used as a program
3788 unit pragma, in which case it only applies to the current unit, or it can
3789 be used more locally to control individual Import/Export pragmas.
3791 It was primarily intended for use with OpenVMS systems, where many
3792 compilers convert all symbols to upper case by default.  For interfacing to
3793 such compilers (e.g., the DEC C compiler), it may be convenient to use
3794 the pragma:
3796 @example
3797 pragma External_Name_Casing (Uppercase, Uppercase);
3798 @end example
3800 to enforce the upper casing of all external symbols.
3802 @node Pragma Fast_Math,Pragma Favor_Top_Level,Pragma External_Name_Casing,Implementation Defined Pragmas
3803 @anchor{gnat_rm/implementation_defined_pragmas pragma-fast-math}@anchor{6e}
3804 @section Pragma Fast_Math
3807 Syntax:
3809 @example
3810 pragma Fast_Math;
3811 @end example
3813 This is a configuration pragma which activates a mode in which speed is
3814 considered more important for floating-point operations than absolutely
3815 accurate adherence to the requirements of the standard. Currently the
3816 following operations are affected:
3819 @table @asis
3821 @item `Complex Multiplication'
3823 The normal simple formula for complex multiplication can result in intermediate
3824 overflows for numbers near the end of the range. The Ada standard requires that
3825 this situation be detected and corrected by scaling, but in Fast_Math mode such
3826 cases will simply result in overflow. Note that to take advantage of this you
3827 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3828 under control of the pragma, rather than use the preinstantiated versions.
3829 @end table
3831 @node Pragma Favor_Top_Level,Pragma Finalize_Storage_Only,Pragma Fast_Math,Implementation Defined Pragmas
3832 @anchor{gnat_rm/implementation_defined_pragmas id15}@anchor{6f}@anchor{gnat_rm/implementation_defined_pragmas pragma-favor-top-level}@anchor{70}
3833 @section Pragma Favor_Top_Level
3836 Syntax:
3838 @example
3839 pragma Favor_Top_Level (type_NAME);
3840 @end example
3842 The argument of pragma @code{Favor_Top_Level} must be a named access-to-subprogram
3843 type. This pragma is an efficiency hint to the compiler, regarding the use of
3844 @code{'Access} or @code{'Unrestricted_Access} on nested (non-library-level) subprograms.
3845 The pragma means that nested subprograms are not used with this type, or are
3846 rare, so that the generated code should be efficient in the top-level case.
3847 When this pragma is used, dynamically generated trampolines may be used on some
3848 targets for nested subprograms. See restriction @code{No_Implicit_Dynamic_Code}.
3850 @node Pragma Finalize_Storage_Only,Pragma Float_Representation,Pragma Favor_Top_Level,Implementation Defined Pragmas
3851 @anchor{gnat_rm/implementation_defined_pragmas pragma-finalize-storage-only}@anchor{71}
3852 @section Pragma Finalize_Storage_Only
3855 Syntax:
3857 @example
3858 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3859 @end example
3861 The argument of pragma @code{Finalize_Storage_Only} must denote a local type which
3862 is derived from @code{Ada.Finalization.Controlled} or @code{Limited_Controlled}. The
3863 pragma suppresses the call to @code{Finalize} for declared library-level objects
3864 of the argument type. This is mostly useful for types where finalization is
3865 only used to deal with storage reclamation since in most environments it is
3866 not necessary to reclaim memory just before terminating execution, hence the
3867 name. Note that this pragma does not suppress Finalize calls for library-level
3868 heap-allocated objects (see pragma @code{No_Heap_Finalization}).
3870 @node Pragma Float_Representation,Pragma Ghost,Pragma Finalize_Storage_Only,Implementation Defined Pragmas
3871 @anchor{gnat_rm/implementation_defined_pragmas pragma-float-representation}@anchor{72}
3872 @section Pragma Float_Representation
3875 Syntax:
3877 @example
3878 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3880 FLOAT_REP ::= VAX_Float | IEEE_Float
3881 @end example
3883 In the one argument form, this pragma is a configuration pragma which
3884 allows control over the internal representation chosen for the predefined
3885 floating point types declared in the packages @code{Standard} and
3886 @code{System}. This pragma is only provided for compatibility and has no effect.
3888 The two argument form specifies the representation to be used for
3889 the specified floating-point type. The argument must
3890 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3893 @itemize *
3895 @item 
3896 For a digits value of 6, 32-bit IEEE short format will be used.
3898 @item 
3899 For a digits value of 15, 64-bit IEEE long format will be used.
3901 @item 
3902 No other value of digits is permitted.
3903 @end itemize
3905 @node Pragma Ghost,Pragma Global,Pragma Float_Representation,Implementation Defined Pragmas
3906 @anchor{gnat_rm/implementation_defined_pragmas id16}@anchor{73}@anchor{gnat_rm/implementation_defined_pragmas pragma-ghost}@anchor{74}
3907 @section Pragma Ghost
3910 Syntax:
3912 @example
3913 pragma Ghost [ (static_boolean_EXPRESSION) ];
3914 @end example
3916 For the semantics of this pragma, see the entry for aspect @code{Ghost} in the SPARK
3917 2014 Reference Manual, section 6.9.
3919 @node Pragma Global,Pragma Ident,Pragma Ghost,Implementation Defined Pragmas
3920 @anchor{gnat_rm/implementation_defined_pragmas id17}@anchor{75}@anchor{gnat_rm/implementation_defined_pragmas pragma-global}@anchor{76}
3921 @section Pragma Global
3924 Syntax:
3926 @example
3927 pragma Global (GLOBAL_SPECIFICATION);
3929 GLOBAL_SPECIFICATION ::=
3930      null
3931   | (GLOBAL_LIST)
3932   | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
3934 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
3936 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
3937 GLOBAL_LIST   ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
3938 GLOBAL_ITEM   ::= NAME
3939 @end example
3941 For the semantics of this pragma, see the entry for aspect @code{Global} in the
3942 SPARK 2014 Reference Manual, section 6.1.4.
3944 @node Pragma Ident,Pragma Ignore_Pragma,Pragma Global,Implementation Defined Pragmas
3945 @anchor{gnat_rm/implementation_defined_pragmas pragma-ident}@anchor{77}
3946 @section Pragma Ident
3949 Syntax:
3951 @example
3952 pragma Ident (static_string_EXPRESSION);
3953 @end example
3955 This pragma is identical in effect to pragma @code{Comment}. It is provided
3956 for compatibility with other Ada compilers providing this pragma.
3958 @node Pragma Ignore_Pragma,Pragma Implementation_Defined,Pragma Ident,Implementation Defined Pragmas
3959 @anchor{gnat_rm/implementation_defined_pragmas pragma-ignore-pragma}@anchor{78}
3960 @section Pragma Ignore_Pragma
3963 Syntax:
3965 @example
3966 pragma Ignore_Pragma (pragma_IDENTIFIER);
3967 @end example
3969 This is a configuration pragma
3970 that takes a single argument that is a simple identifier. Any subsequent
3971 use of a pragma whose pragma identifier matches this argument will be
3972 silently ignored. Any preceding use of a pragma whose pragma identifier
3973 matches this argument will be parsed and then ignored.
3974 This may be useful when legacy code or code intended
3975 for compilation with some other compiler contains pragmas that match the
3976 name, but not the exact implementation, of a GNAT pragma. The use of this
3977 pragma allows such pragmas to be ignored, which may be useful in CodePeer
3978 mode, or during porting of legacy code.
3980 @node Pragma Implementation_Defined,Pragma Implemented,Pragma Ignore_Pragma,Implementation Defined Pragmas
3981 @anchor{gnat_rm/implementation_defined_pragmas pragma-implementation-defined}@anchor{79}
3982 @section Pragma Implementation_Defined
3985 Syntax:
3987 @example
3988 pragma Implementation_Defined (local_NAME);
3989 @end example
3991 This pragma marks a previously declared entity as implementation-defined.
3992 For an overloaded entity, applies to the most recent homonym.
3994 @example
3995 pragma Implementation_Defined;
3996 @end example
3998 The form with no arguments appears anywhere within a scope, most
3999 typically a package spec, and indicates that all entities that are
4000 defined within the package spec are Implementation_Defined.
4002 This pragma is used within the GNAT runtime library to identify
4003 implementation-defined entities introduced in language-defined units,
4004 for the purpose of implementing the No_Implementation_Identifiers
4005 restriction.
4007 @node Pragma Implemented,Pragma Implicit_Packing,Pragma Implementation_Defined,Implementation Defined Pragmas
4008 @anchor{gnat_rm/implementation_defined_pragmas pragma-implemented}@anchor{7a}
4009 @section Pragma Implemented
4012 Syntax:
4014 @example
4015 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
4017 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
4018 @end example
4020 This is an Ada 2012 representation pragma which applies to protected, task
4021 and synchronized interface primitives. The use of pragma Implemented provides
4022 a way to impose a static requirement on the overriding operation by adhering
4023 to one of the three implementation kinds: entry, protected procedure or any of
4024 the above. This pragma is available in all earlier versions of Ada as an
4025 implementation-defined pragma.
4027 @example
4028 type Synch_Iface is synchronized interface;
4029 procedure Prim_Op (Obj : in out Iface) is abstract;
4030 pragma Implemented (Prim_Op, By_Protected_Procedure);
4032 protected type Prot_1 is new Synch_Iface with
4033    procedure Prim_Op;  --  Legal
4034 end Prot_1;
4036 protected type Prot_2 is new Synch_Iface with
4037    entry Prim_Op;      --  Illegal
4038 end Prot_2;
4040 task type Task_Typ is new Synch_Iface with
4041    entry Prim_Op;      --  Illegal
4042 end Task_Typ;
4043 @end example
4045 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
4046 Implemented determines the runtime behavior of the requeue. Implementation kind
4047 By_Entry guarantees that the action of requeueing will proceed from an entry to
4048 another entry. Implementation kind By_Protected_Procedure transforms the
4049 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
4050 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
4051 the target’s overriding subprogram kind.
4053 @node Pragma Implicit_Packing,Pragma Import_Function,Pragma Implemented,Implementation Defined Pragmas
4054 @anchor{gnat_rm/implementation_defined_pragmas pragma-implicit-packing}@anchor{7b}
4055 @section Pragma Implicit_Packing
4058 @geindex Rational Profile
4060 Syntax:
4062 @example
4063 pragma Implicit_Packing;
4064 @end example
4066 This is a configuration pragma that requests implicit packing for packed
4067 arrays for which a size clause is given but no explicit pragma Pack or
4068 specification of Component_Size is present. It also applies to records
4069 where no record representation clause is present. Consider this example:
4071 @example
4072 type R is array (0 .. 7) of Boolean;
4073 for R'Size use 8;
4074 @end example
4076 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
4077 does not change the layout of a composite object. So the Size clause in the
4078 above example is normally rejected, since the default layout of the array uses
4079 8-bit components, and thus the array requires a minimum of 64 bits.
4081 If this declaration is compiled in a region of code covered by an occurrence
4082 of the configuration pragma Implicit_Packing, then the Size clause in this
4083 and similar examples will cause implicit packing and thus be accepted. For
4084 this implicit packing to occur, the type in question must be an array of small
4085 components whose size is known at compile time, and the Size clause must
4086 specify the exact size that corresponds to the number of elements in the array
4087 multiplied by the size in bits of the component type (both single and
4088 multi-dimensioned arrays can be controlled with this pragma).
4090 @geindex Array packing
4092 Similarly, the following example shows the use in the record case
4094 @example
4095 type r is record
4096    a, b, c, d, e, f, g, h : boolean;
4097    chr                    : character;
4098 end record;
4099 for r'size use 16;
4100 @end example
4102 Without a pragma Pack, each Boolean field requires 8 bits, so the
4103 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
4104 sufficient. The use of pragma Implicit_Packing allows this record
4105 declaration to compile without an explicit pragma Pack.
4107 @node Pragma Import_Function,Pragma Import_Object,Pragma Implicit_Packing,Implementation Defined Pragmas
4108 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-function}@anchor{7c}
4109 @section Pragma Import_Function
4112 Syntax:
4114 @example
4115 pragma Import_Function (
4116      [Internal         =>] LOCAL_NAME,
4117   [, [External         =>] EXTERNAL_SYMBOL]
4118   [, [Parameter_Types  =>] PARAMETER_TYPES]
4119   [, [Result_Type      =>] SUBTYPE_MARK]
4120   [, [Mechanism        =>] MECHANISM]
4121   [, [Result_Mechanism =>] MECHANISM_NAME]);
4123 EXTERNAL_SYMBOL ::=
4124   IDENTIFIER
4125 | static_string_EXPRESSION
4127 PARAMETER_TYPES ::=
4128   null
4129 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4131 TYPE_DESIGNATOR ::=
4132   subtype_NAME
4133 | subtype_Name ' Access
4135 MECHANISM ::=
4136   MECHANISM_NAME
4137 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4139 MECHANISM_ASSOCIATION ::=
4140   [formal_parameter_NAME =>] MECHANISM_NAME
4142 MECHANISM_NAME ::=
4143   Value
4144 | Reference
4145 @end example
4147 This pragma is used in conjunction with a pragma @code{Import} to
4148 specify additional information for an imported function.  The pragma
4149 @code{Import} (or equivalent pragma @code{Interface}) must precede the
4150 @code{Import_Function} pragma and both must appear in the same
4151 declarative part as the function specification.
4153 The @code{Internal} argument must uniquely designate
4154 the function to which the
4155 pragma applies.  If more than one function name exists of this name in
4156 the declarative part you must use the @code{Parameter_Types} and
4157 @code{Result_Type} parameters to achieve the required unique
4158 designation.  Subtype marks in these parameters must exactly match the
4159 subtypes in the corresponding function specification, using positional
4160 notation to match parameters with subtype marks.
4161 The form with an @code{'Access} attribute can be used to match an
4162 anonymous access parameter.
4164 You may optionally use the @code{Mechanism} and @code{Result_Mechanism}
4165 parameters to specify passing mechanisms for the
4166 parameters and result.  If you specify a single mechanism name, it
4167 applies to all parameters.  Otherwise you may specify a mechanism on a
4168 parameter by parameter basis using either positional or named
4169 notation.  If the mechanism is not specified, the default mechanism
4170 is used.
4172 @node Pragma Import_Object,Pragma Import_Procedure,Pragma Import_Function,Implementation Defined Pragmas
4173 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-object}@anchor{7d}
4174 @section Pragma Import_Object
4177 Syntax:
4179 @example
4180 pragma Import_Object (
4181      [Internal =>] LOCAL_NAME
4182   [, [External =>] EXTERNAL_SYMBOL]
4183   [, [Size     =>] EXTERNAL_SYMBOL]);
4185 EXTERNAL_SYMBOL ::=
4186   IDENTIFIER
4187 | static_string_EXPRESSION
4188 @end example
4190 This pragma designates an object as imported, and apart from the
4191 extended rules for external symbols, is identical in effect to the use of
4192 the normal @code{Import} pragma applied to an object.  Unlike the
4193 subprogram case, you need not use a separate @code{Import} pragma,
4194 although you may do so (and probably should do so from a portability
4195 point of view).  @code{size} is syntax checked, but otherwise ignored by
4196 GNAT.
4198 @node Pragma Import_Procedure,Pragma Import_Valued_Procedure,Pragma Import_Object,Implementation Defined Pragmas
4199 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-procedure}@anchor{7e}
4200 @section Pragma Import_Procedure
4203 Syntax:
4205 @example
4206 pragma Import_Procedure (
4207      [Internal        =>] LOCAL_NAME
4208   [, [External        =>] EXTERNAL_SYMBOL]
4209   [, [Parameter_Types =>] PARAMETER_TYPES]
4210   [, [Mechanism       =>] MECHANISM]);
4212 EXTERNAL_SYMBOL ::=
4213   IDENTIFIER
4214 | static_string_EXPRESSION
4216 PARAMETER_TYPES ::=
4217   null
4218 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4220 TYPE_DESIGNATOR ::=
4221   subtype_NAME
4222 | subtype_Name ' Access
4224 MECHANISM ::=
4225   MECHANISM_NAME
4226 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4228 MECHANISM_ASSOCIATION ::=
4229   [formal_parameter_NAME =>] MECHANISM_NAME
4231 MECHANISM_NAME ::= Value | Reference
4232 @end example
4234 This pragma is identical to @code{Import_Function} except that it
4235 applies to a procedure rather than a function and the parameters
4236 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
4238 @node Pragma Import_Valued_Procedure,Pragma Independent,Pragma Import_Procedure,Implementation Defined Pragmas
4239 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-valued-procedure}@anchor{7f}
4240 @section Pragma Import_Valued_Procedure
4243 Syntax:
4245 @example
4246 pragma Import_Valued_Procedure (
4247      [Internal        =>] LOCAL_NAME
4248   [, [External        =>] EXTERNAL_SYMBOL]
4249   [, [Parameter_Types =>] PARAMETER_TYPES]
4250   [, [Mechanism       =>] MECHANISM]);
4252 EXTERNAL_SYMBOL ::=
4253   IDENTIFIER
4254 | static_string_EXPRESSION
4256 PARAMETER_TYPES ::=
4257   null
4258 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4260 TYPE_DESIGNATOR ::=
4261   subtype_NAME
4262 | subtype_Name ' Access
4264 MECHANISM ::=
4265   MECHANISM_NAME
4266 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4268 MECHANISM_ASSOCIATION ::=
4269   [formal_parameter_NAME =>] MECHANISM_NAME
4271 MECHANISM_NAME ::= Value | Reference
4272 @end example
4274 This pragma is identical to @code{Import_Procedure} except that the
4275 first parameter of @code{LOCAL_NAME}, which must be present, must be of
4276 mode @code{out}, and externally the subprogram is treated as a function
4277 with this parameter as the result of the function.  The purpose of this
4278 capability is to allow the use of @code{out} and @code{in out}
4279 parameters in interfacing to external functions (which are not permitted
4280 in Ada functions).  You may optionally use the @code{Mechanism}
4281 parameters to specify passing mechanisms for the parameters.
4282 If you specify a single mechanism name, it applies to all parameters.
4283 Otherwise you may specify a mechanism on a parameter by parameter
4284 basis using either positional or named notation.  If the mechanism is not
4285 specified, the default mechanism is used.
4287 Note that it is important to use this pragma in conjunction with a separate
4288 pragma Import that specifies the desired convention, since otherwise the
4289 default convention is Ada, which is almost certainly not what is required.
4291 @node Pragma Independent,Pragma Independent_Components,Pragma Import_Valued_Procedure,Implementation Defined Pragmas
4292 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent}@anchor{80}
4293 @section Pragma Independent
4296 Syntax:
4298 @example
4299 pragma Independent (Local_NAME);
4300 @end example
4302 This pragma is standard in Ada 2012 mode (which also provides an aspect
4303 of the same name). It is also available as an implementation-defined
4304 pragma in all earlier versions. It specifies that the
4305 designated object or all objects of the designated type must be
4306 independently addressable. This means that separate tasks can safely
4307 manipulate such objects. For example, if two components of a record are
4308 independent, then two separate tasks may access these two components.
4309 This may place
4310 constraints on the representation of the object (for instance prohibiting
4311 tight packing).
4313 @node Pragma Independent_Components,Pragma Initial_Condition,Pragma Independent,Implementation Defined Pragmas
4314 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent-components}@anchor{81}
4315 @section Pragma Independent_Components
4318 Syntax:
4320 @example
4321 pragma Independent_Components (Local_NAME);
4322 @end example
4324 This pragma is standard in Ada 2012 mode (which also provides an aspect
4325 of the same name). It is also available as an implementation-defined
4326 pragma in all earlier versions. It specifies that the components of the
4327 designated object, or the components of each object of the designated
4328 type, must be
4329 independently addressable. This means that separate tasks can safely
4330 manipulate separate components in the composite object. This may place
4331 constraints on the representation of the object (for instance prohibiting
4332 tight packing).
4334 @node Pragma Initial_Condition,Pragma Initialize_Scalars,Pragma Independent_Components,Implementation Defined Pragmas
4335 @anchor{gnat_rm/implementation_defined_pragmas id18}@anchor{82}@anchor{gnat_rm/implementation_defined_pragmas pragma-initial-condition}@anchor{83}
4336 @section Pragma Initial_Condition
4339 Syntax:
4341 @example
4342 pragma Initial_Condition (boolean_EXPRESSION);
4343 @end example
4345 For the semantics of this pragma, see the entry for aspect @code{Initial_Condition}
4346 in the SPARK 2014 Reference Manual, section 7.1.6.
4348 @node Pragma Initialize_Scalars,Pragma Initializes,Pragma Initial_Condition,Implementation Defined Pragmas
4349 @anchor{gnat_rm/implementation_defined_pragmas pragma-initialize-scalars}@anchor{84}
4350 @section Pragma Initialize_Scalars
4353 @geindex debugging with Initialize_Scalars
4355 Syntax:
4357 @example
4358 pragma Initialize_Scalars
4359   [ ( TYPE_VALUE_PAIR @{, TYPE_VALUE_PAIR@} ) ];
4361 TYPE_VALUE_PAIR ::=
4362   SCALAR_TYPE => static_EXPRESSION
4364 SCALAR_TYPE :=
4365   Short_Float
4366 | Float
4367 | Long_Float
4368 | Long_Long_Flat
4369 | Signed_8
4370 | Signed_16
4371 | Signed_32
4372 | Signed_64
4373 | Unsigned_8
4374 | Unsigned_16
4375 | Unsigned_32
4376 | Unsigned_64
4377 @end example
4379 This pragma is similar to @code{Normalize_Scalars} conceptually but has two
4380 important differences.
4382 First, there is no requirement for the pragma to be used uniformly in all units
4383 of a partition. In particular, it is fine to use this just for some or all of
4384 the application units of a partition, without needing to recompile the run-time
4385 library. In the case where some units are compiled with the pragma, and some
4386 without, then a declaration of a variable where the type is defined in package
4387 Standard or is locally declared will always be subject to initialization, as
4388 will any declaration of a scalar variable. For composite variables, whether the
4389 variable is initialized may also depend on whether the package in which the
4390 type of the variable is declared is compiled with the pragma.
4392 The other important difference is that the programmer can control the value
4393 used for initializing scalar objects. This effect can be achieved in several
4394 different ways:
4397 @itemize *
4399 @item 
4400 At compile time, the programmer can specify the invalid value for a
4401 particular family of scalar types using the optional arguments of the pragma.
4403 The compile-time approach is intended to optimize the generated code for the
4404 pragma, by possibly using fast operations such as @code{memset}. Note that such
4405 optimizations require using values where the bytes all have the same binary
4406 representation.
4408 @item 
4409 At bind time, the programmer has several options:
4412 @itemize *
4414 @item 
4415 Initialization with invalid values (similar to Normalize_Scalars, though
4416 for Initialize_Scalars it is not always possible to determine the invalid
4417 values in complex cases like signed component fields with nonstandard
4418 sizes).
4420 @item 
4421 Initialization with high values.
4423 @item 
4424 Initialization with low values.
4426 @item 
4427 Initialization with a specific bit pattern.
4428 @end itemize
4430 See the GNAT User’s Guide for binder options for specifying these cases.
4432 The bind-time approach is intended to provide fast turnaround for testing
4433 with different values, without having to recompile the program.
4435 @item 
4436 At execution time, the programmer can specify the invalid values using an
4437 environment variable. See the GNAT User’s Guide for details.
4439 The execution-time approach is intended to provide fast turnaround for
4440 testing with different values, without having to recompile and rebind the
4441 program.
4442 @end itemize
4444 Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction
4445 with the enhanced validity checking that is now provided in GNAT, which checks
4446 for invalid values under more conditions. Using this feature (see description
4447 of the `-gnatV' flag in the GNAT User’s Guide) in conjunction with pragma
4448 @code{Initialize_Scalars} provides a powerful new tool to assist in the detection
4449 of problems caused by uninitialized variables.
4451 Note: the use of @code{Initialize_Scalars} has a fairly extensive effect on the
4452 generated code. This may cause your code to be substantially larger. It may
4453 also cause an increase in the amount of stack required, so it is probably a
4454 good idea to turn on stack checking (see description of stack checking in the
4455 GNAT User’s Guide) when using this pragma.
4457 @node Pragma Initializes,Pragma Inline_Always,Pragma Initialize_Scalars,Implementation Defined Pragmas
4458 @anchor{gnat_rm/implementation_defined_pragmas id19}@anchor{85}@anchor{gnat_rm/implementation_defined_pragmas pragma-initializes}@anchor{86}
4459 @section Pragma Initializes
4462 Syntax:
4464 @example
4465 pragma Initializes (INITIALIZATION_LIST);
4467 INITIALIZATION_LIST ::=
4468      null
4469   | (INITIALIZATION_ITEM @{, INITIALIZATION_ITEM@})
4471 INITIALIZATION_ITEM ::= name [=> INPUT_LIST]
4473 INPUT_LIST ::=
4474      null
4475   |  INPUT
4476   | (INPUT @{, INPUT@})
4478 INPUT ::= name
4479 @end example
4481 For the semantics of this pragma, see the entry for aspect @code{Initializes} in the
4482 SPARK 2014 Reference Manual, section 7.1.5.
4484 @node Pragma Inline_Always,Pragma Inline_Generic,Pragma Initializes,Implementation Defined Pragmas
4485 @anchor{gnat_rm/implementation_defined_pragmas id20}@anchor{87}@anchor{gnat_rm/implementation_defined_pragmas pragma-inline-always}@anchor{88}
4486 @section Pragma Inline_Always
4489 Syntax:
4491 @example
4492 pragma Inline_Always (NAME [, NAME]);
4493 @end example
4495 Similar to pragma @code{Inline} except that inlining is unconditional.
4496 Inline_Always instructs the compiler to inline every direct call to the
4497 subprogram or else to emit a compilation error, independently of any
4498 option, in particular `-gnatn' or `-gnatN' or the optimization level.
4499 It is an error to take the address or access of @code{NAME}. It is also an error to
4500 apply this pragma to a primitive operation of a tagged type. Thanks to such
4501 restrictions, the compiler is allowed to remove the out-of-line body of @code{NAME}.
4503 @node Pragma Inline_Generic,Pragma Interface,Pragma Inline_Always,Implementation Defined Pragmas
4504 @anchor{gnat_rm/implementation_defined_pragmas pragma-inline-generic}@anchor{89}
4505 @section Pragma Inline_Generic
4508 Syntax:
4510 @example
4511 pragma Inline_Generic (GNAME @{, GNAME@});
4513 GNAME ::= generic_unit_NAME | generic_instance_NAME
4514 @end example
4516 This pragma is provided for compatibility with Dec Ada 83. It has
4517 no effect in GNAT (which always inlines generics), other
4518 than to check that the given names are all names of generic units or
4519 generic instances.
4521 @node Pragma Interface,Pragma Interface_Name,Pragma Inline_Generic,Implementation Defined Pragmas
4522 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface}@anchor{8a}
4523 @section Pragma Interface
4526 Syntax:
4528 @example
4529 pragma Interface (
4530      [Convention    =>] convention_identifier,
4531      [Entity        =>] local_NAME
4532   [, [External_Name =>] static_string_expression]
4533   [, [Link_Name     =>] static_string_expression]);
4534 @end example
4536 This pragma is identical in syntax and semantics to
4537 the standard Ada pragma @code{Import}.  It is provided for compatibility
4538 with Ada 83.  The definition is upwards compatible both with pragma
4539 @code{Interface} as defined in the Ada 83 Reference Manual, and also
4540 with some extended implementations of this pragma in certain Ada 83
4541 implementations.  The only difference between pragma @code{Interface}
4542 and pragma @code{Import} is that there is special circuitry to allow
4543 both pragmas to appear for the same subprogram entity (normally it
4544 is illegal to have multiple @code{Import} pragmas). This is useful in
4545 maintaining Ada 83/Ada 95 compatibility and is compatible with other
4546 Ada 83 compilers.
4548 @node Pragma Interface_Name,Pragma Interrupt_Handler,Pragma Interface,Implementation Defined Pragmas
4549 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface-name}@anchor{8b}
4550 @section Pragma Interface_Name
4553 Syntax:
4555 @example
4556 pragma Interface_Name (
4557      [Entity        =>] LOCAL_NAME
4558   [, [External_Name =>] static_string_EXPRESSION]
4559   [, [Link_Name     =>] static_string_EXPRESSION]);
4560 @end example
4562 This pragma provides an alternative way of specifying the interface name
4563 for an interfaced subprogram, and is provided for compatibility with Ada
4564 83 compilers that use the pragma for this purpose.  You must provide at
4565 least one of @code{External_Name} or @code{Link_Name}.
4567 @node Pragma Interrupt_Handler,Pragma Interrupt_State,Pragma Interface_Name,Implementation Defined Pragmas
4568 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-handler}@anchor{8c}
4569 @section Pragma Interrupt_Handler
4572 Syntax:
4574 @example
4575 pragma Interrupt_Handler (procedure_LOCAL_NAME);
4576 @end example
4578 This program unit pragma is supported for parameterless protected procedures
4579 as described in Annex C of the Ada Reference Manual.
4581 @node Pragma Interrupt_State,Pragma Invariant,Pragma Interrupt_Handler,Implementation Defined Pragmas
4582 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-state}@anchor{8d}
4583 @section Pragma Interrupt_State
4586 Syntax:
4588 @example
4589 pragma Interrupt_State
4590  ([Name  =>] value,
4591   [State =>] SYSTEM | RUNTIME | USER);
4592 @end example
4594 Normally certain interrupts are reserved to the implementation.  Any attempt
4595 to attach an interrupt causes Program_Error to be raised, as described in
4596 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4597 many systems for an @code{Ctrl-C} interrupt.  Normally this interrupt is
4598 reserved to the implementation, so that @code{Ctrl-C} can be used to
4599 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
4600 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
4601 Ada exceptions, or used to implement run-time functions such as the
4602 @code{abort} statement and stack overflow checking.
4604 Pragma @code{Interrupt_State} provides a general mechanism for overriding
4605 such uses of interrupts.  It subsumes the functionality of pragma
4606 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
4607 available on Windows.  On all other platforms than VxWorks,
4608 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
4609 and may be used to mark interrupts required by the board support package
4610 as reserved.
4612 Interrupts can be in one of three states:
4615 @itemize *
4617 @item 
4618 System
4620 The interrupt is reserved (no Ada handler can be installed), and the
4621 Ada run-time may not install a handler. As a result you are guaranteed
4622 standard system default action if this interrupt is raised. This also allows
4623 installing a low level handler via C APIs such as sigaction(), outside
4624 of Ada control.
4626 @item 
4627 Runtime
4629 The interrupt is reserved (no Ada handler can be installed). The run time
4630 is allowed to install a handler for internal control purposes, but is
4631 not required to do so.
4633 @item 
4634 User
4636 The interrupt is unreserved.  The user may install an Ada handler via
4637 Ada.Interrupts and pragma Interrupt_Handler or Attach_Handler to provide
4638 some other action.
4639 @end itemize
4641 These states are the allowed values of the @code{State} parameter of the
4642 pragma.  The @code{Name} parameter is a value of the type
4643 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4644 @code{Ada.Interrupts.Names}.
4646 This is a configuration pragma, and the binder will check that there
4647 are no inconsistencies between different units in a partition in how a
4648 given interrupt is specified. It may appear anywhere a pragma is legal.
4650 The effect is to move the interrupt to the specified state.
4652 By declaring interrupts to be SYSTEM, you guarantee the standard system
4653 action, such as a core dump.
4655 By declaring interrupts to be USER, you guarantee that you can install
4656 a handler.
4658 Note that certain signals on many operating systems cannot be caught and
4659 handled by applications.  In such cases, the pragma is ignored.  See the
4660 operating system documentation, or the value of the array @code{Reserved}
4661 declared in the spec of package @code{System.OS_Interface}.
4663 Overriding the default state of signals used by the Ada runtime may interfere
4664 with an application’s runtime behavior in the cases of the synchronous signals,
4665 and in the case of the signal used to implement the @code{abort} statement.
4667 @node Pragma Invariant,Pragma Keep_Names,Pragma Interrupt_State,Implementation Defined Pragmas
4668 @anchor{gnat_rm/implementation_defined_pragmas id21}@anchor{8e}@anchor{gnat_rm/implementation_defined_pragmas pragma-invariant}@anchor{8f}
4669 @section Pragma Invariant
4672 Syntax:
4674 @example
4675 pragma Invariant
4676   ([Entity =>]    private_type_LOCAL_NAME,
4677    [Check  =>]    EXPRESSION
4678    [,[Message =>] String_Expression]);
4679 @end example
4681 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4682 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4683 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4684 requires the use of the aspect syntax, which is not available except in 2012
4685 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4686 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4687 note that the aspect Invariant is a synonym in GNAT for the aspect
4688 Type_Invariant, but there is no pragma Type_Invariant.
4690 The pragma must appear within the visible part of the package specification,
4691 after the type to which its Entity argument appears. As with the Invariant
4692 aspect, the Check expression is not analyzed until the end of the visible
4693 part of the package, so it may contain forward references. The Message
4694 argument, if present, provides the exception message used if the invariant
4695 is violated. If no Message parameter is provided, a default message that
4696 identifies the line on which the pragma appears is used.
4698 It is permissible to have multiple Invariants for the same type entity, in
4699 which case they are and’ed together. It is permissible to use this pragma
4700 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4701 invariant pragma for the same entity.
4703 For further details on the use of this pragma, see the Ada 2012 documentation
4704 of the Type_Invariant aspect.
4706 @node Pragma Keep_Names,Pragma License,Pragma Invariant,Implementation Defined Pragmas
4707 @anchor{gnat_rm/implementation_defined_pragmas pragma-keep-names}@anchor{90}
4708 @section Pragma Keep_Names
4711 Syntax:
4713 @example
4714 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4715 @end example
4717 The @code{LOCAL_NAME} argument
4718 must refer to an enumeration first subtype
4719 in the current declarative part. The effect is to retain the enumeration
4720 literal names for use by @code{Image} and @code{Value} even if a global
4721 @code{Discard_Names} pragma applies. This is useful when you want to
4722 generally suppress enumeration literal names and for example you therefore
4723 use a @code{Discard_Names} pragma in the @code{gnat.adc} file, but you
4724 want to retain the names for specific enumeration types.
4726 @node Pragma License,Pragma Link_With,Pragma Keep_Names,Implementation Defined Pragmas
4727 @anchor{gnat_rm/implementation_defined_pragmas pragma-license}@anchor{91}
4728 @section Pragma License
4731 @geindex License checking
4733 Syntax:
4735 @example
4736 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4737 @end example
4739 This pragma is provided to allow automated checking for appropriate license
4740 conditions with respect to the standard and modified GPL.  A pragma
4741 @code{License}, which is a configuration pragma that typically appears at
4742 the start of a source file or in a separate @code{gnat.adc} file, specifies
4743 the licensing conditions of a unit as follows:
4746 @itemize *
4748 @item 
4749 Unrestricted
4750 This is used for a unit that can be freely used with no license restrictions.
4751 Examples of such units are public domain units, and units from the Ada
4752 Reference Manual.
4754 @item 
4756 This is used for a unit that is licensed under the unmodified GPL, and which
4757 therefore cannot be @code{with}ed by a restricted unit.
4759 @item 
4760 Modified_GPL
4761 This is used for a unit licensed under the GNAT modified GPL that includes
4762 a special exception paragraph that specifically permits the inclusion of
4763 the unit in programs without requiring the entire program to be released
4764 under the GPL.
4766 @item 
4767 Restricted
4768 This is used for a unit that is restricted in that it is not permitted to
4769 depend on units that are licensed under the GPL.  Typical examples are
4770 proprietary code that is to be released under more restrictive license
4771 conditions.  Note that restricted units are permitted to @code{with} units
4772 which are licensed under the modified GPL (this is the whole point of the
4773 modified GPL).
4774 @end itemize
4776 Normally a unit with no @code{License} pragma is considered to have an
4777 unknown license, and no checking is done.  However, standard GNAT headers
4778 are recognized, and license information is derived from them as follows.
4780 A GNAT license header starts with a line containing 78 hyphens.  The following
4781 comment text is searched for the appearance of any of the following strings.
4783 If the string ‘GNU General Public License’ is found, then the unit is assumed
4784 to have GPL license, unless the string ‘As a special exception’ follows, in
4785 which case the license is assumed to be modified GPL.
4787 If one of the strings
4788 ‘This specification is adapted from the Ada Semantic Interface’ or
4789 ‘This specification is derived from the Ada Reference Manual’ is found
4790 then the unit is assumed to be unrestricted.
4792 These default actions means that a program with a restricted license pragma
4793 will automatically get warnings if a GPL unit is inappropriately
4794 @code{with}ed.  For example, the program:
4796 @example
4797 with Sem_Ch3;
4798 with GNAT.Sockets;
4799 procedure Secret_Stuff is
4800   ...
4801 end Secret_Stuff
4802 @end example
4804 if compiled with pragma @code{License} (@code{Restricted}) in a
4805 @code{gnat.adc} file will generate the warning:
4807 @example
4808 1.  with Sem_Ch3;
4809         |
4810    >>> license of withed unit "Sem_Ch3" is incompatible
4812 2.  with GNAT.Sockets;
4813 3.  procedure Secret_Stuff is
4814 @end example
4816 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4817 compiler and is licensed under the
4818 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4819 run time, and is therefore licensed under the modified GPL.
4821 @node Pragma Link_With,Pragma Linker_Alias,Pragma License,Implementation Defined Pragmas
4822 @anchor{gnat_rm/implementation_defined_pragmas pragma-link-with}@anchor{92}
4823 @section Pragma Link_With
4826 Syntax:
4828 @example
4829 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4830 @end example
4832 This pragma is provided for compatibility with certain Ada 83 compilers.
4833 It has exactly the same effect as pragma @code{Linker_Options} except
4834 that spaces occurring within one of the string expressions are treated
4835 as separators. For example, in the following case:
4837 @example
4838 pragma Link_With ("-labc -ldef");
4839 @end example
4841 results in passing the strings @code{-labc} and @code{-ldef} as two
4842 separate arguments to the linker. In addition pragma Link_With allows
4843 multiple arguments, with the same effect as successive pragmas.
4845 @node Pragma Linker_Alias,Pragma Linker_Constructor,Pragma Link_With,Implementation Defined Pragmas
4846 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-alias}@anchor{93}
4847 @section Pragma Linker_Alias
4850 Syntax:
4852 @example
4853 pragma Linker_Alias (
4854   [Entity =>] LOCAL_NAME,
4855   [Target =>] static_string_EXPRESSION);
4856 @end example
4858 @code{LOCAL_NAME} must refer to an object that is declared at the library
4859 level. This pragma establishes the given entity as a linker alias for the
4860 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4861 and causes @code{LOCAL_NAME} to be emitted as an alias for the symbol
4862 @code{static_string_EXPRESSION} in the object file, that is to say no space
4863 is reserved for @code{LOCAL_NAME} by the assembler and it will be resolved
4864 to the same address as @code{static_string_EXPRESSION} by the linker.
4866 The actual linker name for the target must be used (e.g., the fully
4867 encoded name with qualification in Ada, or the mangled name in C++),
4868 or it must be declared using the C convention with @code{pragma Import}
4869 or @code{pragma Export}.
4871 Not all target machines support this pragma. On some of them it is accepted
4872 only if @code{pragma Weak_External} has been applied to @code{LOCAL_NAME}.
4874 @example
4875 --  Example of the use of pragma Linker_Alias
4877 package p is
4878   i : Integer := 1;
4879   pragma Export (C, i);
4881   new_name_for_i : Integer;
4882   pragma Linker_Alias (new_name_for_i, "i");
4883 end p;
4884 @end example
4886 @node Pragma Linker_Constructor,Pragma Linker_Destructor,Pragma Linker_Alias,Implementation Defined Pragmas
4887 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-constructor}@anchor{94}
4888 @section Pragma Linker_Constructor
4891 Syntax:
4893 @example
4894 pragma Linker_Constructor (procedure_LOCAL_NAME);
4895 @end example
4897 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4898 is declared at the library level. A procedure to which this pragma is
4899 applied will be treated as an initialization routine by the linker.
4900 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4901 causes @code{procedure_LOCAL_NAME} to be invoked before the entry point
4902 of the executable is called (or immediately after the shared library is
4903 loaded if the procedure is linked in a shared library), in particular
4904 before the Ada run-time environment is set up.
4906 Because of these specific contexts, the set of operations such a procedure
4907 can perform is very limited and the type of objects it can manipulate is
4908 essentially restricted to the elementary types. In particular, it must only
4909 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4911 This pragma is used by GNAT to implement auto-initialization of shared Stand
4912 Alone Libraries, which provides a related capability without the restrictions
4913 listed above. Where possible, the use of Stand Alone Libraries is preferable
4914 to the use of this pragma.
4916 @node Pragma Linker_Destructor,Pragma Linker_Section,Pragma Linker_Constructor,Implementation Defined Pragmas
4917 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-destructor}@anchor{95}
4918 @section Pragma Linker_Destructor
4921 Syntax:
4923 @example
4924 pragma Linker_Destructor (procedure_LOCAL_NAME);
4925 @end example
4927 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4928 is declared at the library level. A procedure to which this pragma is
4929 applied will be treated as a finalization routine by the linker.
4930 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4931 causes @code{procedure_LOCAL_NAME} to be invoked after the entry point
4932 of the executable has exited (or immediately before the shared library
4933 is unloaded if the procedure is linked in a shared library), in particular
4934 after the Ada run-time environment is shut down.
4936 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4937 because of these specific contexts.
4939 @node Pragma Linker_Section,Pragma Lock_Free,Pragma Linker_Destructor,Implementation Defined Pragmas
4940 @anchor{gnat_rm/implementation_defined_pragmas id22}@anchor{96}@anchor{gnat_rm/implementation_defined_pragmas pragma-linker-section}@anchor{97}
4941 @section Pragma Linker_Section
4944 Syntax:
4946 @example
4947 pragma Linker_Section (
4948   [Entity  =>] LOCAL_NAME,
4949   [Section =>] static_string_EXPRESSION);
4950 @end example
4952 @code{LOCAL_NAME} must refer to an object, type, or subprogram that is
4953 declared at the library level. This pragma specifies the name of the
4954 linker section for the given entity. It is equivalent to
4955 @code{__attribute__((section))} in GNU C and causes @code{LOCAL_NAME} to
4956 be placed in the @code{static_string_EXPRESSION} section of the
4957 executable (assuming the linker doesn’t rename the section).
4958 GNAT also provides an implementation defined aspect of the same name.
4960 In the case of specifying this aspect for a type, the effect is to
4961 specify the corresponding section for all library-level objects of
4962 the type that do not have an explicit linker section set. Note that
4963 this only applies to whole objects, not to components of composite objects.
4965 In the case of a subprogram, the linker section applies to all previously
4966 declared matching overloaded subprograms in the current declarative part
4967 which do not already have a linker section assigned. The linker section
4968 aspect is useful in this case for specifying different linker sections
4969 for different elements of such an overloaded set.
4971 Note that an empty string specifies that no linker section is specified.
4972 This is not quite the same as omitting the pragma or aspect, since it
4973 can be used to specify that one element of an overloaded set of subprograms
4974 has the default linker section, or that one object of a type for which a
4975 linker section is specified should has the default linker section.
4977 The compiler normally places library-level entities in standard sections
4978 depending on the class: procedures and functions generally go in the
4979 @code{.text} section, initialized variables in the @code{.data} section
4980 and uninitialized variables in the @code{.bss} section.
4982 Other, special sections may exist on given target machines to map special
4983 hardware, for example I/O ports or flash memory. This pragma is a means to
4984 defer the final layout of the executable to the linker, thus fully working
4985 at the symbolic level with the compiler.
4987 Some file formats do not support arbitrary sections so not all target
4988 machines support this pragma. The use of this pragma may cause a program
4989 execution to be erroneous if it is used to place an entity into an
4990 inappropriate section (e.g., a modified variable into the @code{.text}
4991 section). See also @code{pragma Persistent_BSS}.
4993 @example
4994 --  Example of the use of pragma Linker_Section
4996 package IO_Card is
4997   Port_A : Integer;
4998   pragma Volatile (Port_A);
4999   pragma Linker_Section (Port_A, ".bss.port_a");
5001   Port_B : Integer;
5002   pragma Volatile (Port_B);
5003   pragma Linker_Section (Port_B, ".bss.port_b");
5005   type Port_Type is new Integer with Linker_Section => ".bss";
5006   PA : Port_Type with Linker_Section => ".bss.PA";
5007   PB : Port_Type; --  ends up in linker section ".bss"
5009   procedure Q with Linker_Section => "Qsection";
5010 end IO_Card;
5011 @end example
5013 @node Pragma Lock_Free,Pragma Loop_Invariant,Pragma Linker_Section,Implementation Defined Pragmas
5014 @anchor{gnat_rm/implementation_defined_pragmas id23}@anchor{98}@anchor{gnat_rm/implementation_defined_pragmas pragma-lock-free}@anchor{99}
5015 @section Pragma Lock_Free
5018 Syntax:
5019 This pragma may be specified for protected types or objects. It specifies that
5020 the implementation of protected operations must be implemented without locks.
5021 Compilation fails if the compiler cannot generate lock-free code for the
5022 operations.
5024 The current conditions required to support this pragma are:
5027 @itemize *
5029 @item 
5030 Protected type declarations may not contain entries
5032 @item 
5033 Protected subprogram declarations may not have nonelementary parameters
5034 @end itemize
5036 In addition, each protected subprogram body must satisfy:
5039 @itemize *
5041 @item 
5042 May reference only one protected component
5044 @item 
5045 May not reference nonconstant entities outside the protected subprogram
5046 scope
5048 @item 
5049 May not contain address representation items, allocators, or quantified
5050 expressions
5052 @item 
5053 May not contain delay, goto, loop, or procedure-call statements
5055 @item 
5056 May not contain exported and imported entities
5058 @item 
5059 May not dereferenced access values
5061 @item 
5062 Function calls and attribute references must be static
5063 @end itemize
5065 If the Lock_Free aspect is specified to be True for a protected unit
5066 and the Ceiling_Locking locking policy is in effect, then the run-time
5067 actions associated with the Ceiling_Locking locking policy (described in
5068 Ada RM D.3) are not performed when a protected operation of the protected
5069 unit is executed.
5071 @node Pragma Loop_Invariant,Pragma Loop_Optimize,Pragma Lock_Free,Implementation Defined Pragmas
5072 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-invariant}@anchor{9a}
5073 @section Pragma Loop_Invariant
5076 Syntax:
5078 @example
5079 pragma Loop_Invariant ( boolean_EXPRESSION );
5080 @end example
5082 The effect of this pragma is similar to that of pragma @code{Assert},
5083 except that in an @code{Assertion_Policy} pragma, the identifier
5084 @code{Loop_Invariant} is used to control whether it is ignored or checked
5085 (or disabled).
5087 @code{Loop_Invariant} can only appear as one of the items in the sequence
5088 of statements of a loop body, or nested inside block statements that
5089 appear in the sequence of statements of a loop body.
5090 The intention is that it be used to
5091 represent a “loop invariant” assertion, i.e. something that is true each
5092 time through the loop, and which can be used to show that the loop is
5093 achieving its purpose.
5095 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5096 apply to the same loop should be grouped in the same sequence of
5097 statements.
5099 To aid in writing such invariants, the special attribute @code{Loop_Entry}
5100 may be used to refer to the value of an expression on entry to the loop. This
5101 attribute can only be used within the expression of a @code{Loop_Invariant}
5102 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
5104 @node Pragma Loop_Optimize,Pragma Loop_Variant,Pragma Loop_Invariant,Implementation Defined Pragmas
5105 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-optimize}@anchor{9b}
5106 @section Pragma Loop_Optimize
5109 Syntax:
5111 @example
5112 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
5114 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
5115 @end example
5117 This pragma must appear immediately within a loop statement.  It allows the
5118 programmer to specify optimization hints for the enclosing loop.  The hints
5119 are not mutually exclusive and can be freely mixed, but not all combinations
5120 will yield a sensible outcome.
5122 There are five supported optimization hints for a loop:
5125 @itemize *
5127 @item 
5128 Ivdep
5130 The programmer asserts that there are no loop-carried dependencies
5131 which would prevent consecutive iterations of the loop from being
5132 executed simultaneously.
5134 @item 
5135 No_Unroll
5137 The loop must not be unrolled.  This is a strong hint: the compiler will not
5138 unroll a loop marked with this hint.
5140 @item 
5141 Unroll
5143 The loop should be unrolled.  This is a weak hint: the compiler will try to
5144 apply unrolling to this loop preferably to other optimizations, notably
5145 vectorization, but there is no guarantee that the loop will be unrolled.
5147 @item 
5148 No_Vector
5150 The loop must not be vectorized.  This is a strong hint: the compiler will not
5151 vectorize a loop marked with this hint.
5153 @item 
5154 Vector
5156 The loop should be vectorized.  This is a weak hint: the compiler will try to
5157 apply vectorization to this loop preferably to other optimizations, notably
5158 unrolling, but there is no guarantee that the loop will be vectorized.
5159 @end itemize
5161 These hints do not remove the need to pass the appropriate switches to the
5162 compiler in order to enable the relevant optimizations, that is to say
5163 `-funroll-loops' for unrolling and `-ftree-vectorize' for
5164 vectorization.
5166 @node Pragma Loop_Variant,Pragma Machine_Attribute,Pragma Loop_Optimize,Implementation Defined Pragmas
5167 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-variant}@anchor{9c}
5168 @section Pragma Loop_Variant
5171 Syntax:
5173 @example
5174 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
5175 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
5176 CHANGE_DIRECTION ::= Increases | Decreases
5177 @end example
5179 @code{Loop_Variant} can only appear as one of the items in the sequence
5180 of statements of a loop body, or nested inside block statements that
5181 appear in the sequence of statements of a loop body.
5182 It allows the specification of quantities which must always
5183 decrease or increase in successive iterations of the loop. In its simplest
5184 form, just one expression is specified, whose value must increase or decrease
5185 on each iteration of the loop.
5187 In a more complex form, multiple arguments can be given which are interpreted
5188 in a nesting lexicographic manner. For example:
5190 @example
5191 pragma Loop_Variant (Increases => X, Decreases => Y);
5192 @end example
5194 specifies that each time through the loop either X increases, or X stays
5195 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
5196 loop is making progress. It can be useful in helping to show informally
5197 or prove formally that the loop always terminates.
5199 @code{Loop_Variant} is an assertion whose effect can be controlled using
5200 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
5201 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
5202 to ignore the check (in which case the pragma has no effect on the program),
5203 or @code{Disable} in which case the pragma is not even checked for correct
5204 syntax.
5206 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5207 apply to the same loop should be grouped in the same sequence of
5208 statements.
5210 The @code{Loop_Entry} attribute may be used within the expressions of the
5211 @code{Loop_Variant} pragma to refer to values on entry to the loop.
5213 @node Pragma Machine_Attribute,Pragma Main,Pragma Loop_Variant,Implementation Defined Pragmas
5214 @anchor{gnat_rm/implementation_defined_pragmas pragma-machine-attribute}@anchor{9d}
5215 @section Pragma Machine_Attribute
5218 Syntax:
5220 @example
5221 pragma Machine_Attribute (
5222      [Entity         =>] LOCAL_NAME,
5223      [Attribute_Name =>] static_string_EXPRESSION
5224   [, [Info           =>] static_EXPRESSION @{, static_EXPRESSION@}] );
5225 @end example
5227 Machine-dependent attributes can be specified for types and/or
5228 declarations.  This pragma is semantically equivalent to
5229 @code{__attribute__((@var{attribute_name}))} (if @code{info} is not
5230 specified) or @code{__attribute__((@var{attribute_name(info})))}
5231 or @code{__attribute__((@var{attribute_name(info,...})))} in GNU C,
5232 where `attribute_name' is recognized by the compiler middle-end
5233 or the @code{TARGET_ATTRIBUTE_TABLE} machine specific macro.  Note
5234 that a string literal for the optional parameter @code{info} or the
5235 following ones is transformed by default into an identifier,
5236 which may make this pragma unusable for some attributes.
5237 For further information see @cite{GNU Compiler Collection (GCC) Internals}.
5239 @node Pragma Main,Pragma Main_Storage,Pragma Machine_Attribute,Implementation Defined Pragmas
5240 @anchor{gnat_rm/implementation_defined_pragmas pragma-main}@anchor{9e}
5241 @section Pragma Main
5244 Syntax:
5246 @example
5247 pragma Main
5248  (MAIN_OPTION [, MAIN_OPTION]);
5250 MAIN_OPTION ::=
5251   [Stack_Size              =>] static_integer_EXPRESSION
5252 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
5253 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
5254 @end example
5256 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
5257 no effect in GNAT, other than being syntax checked.
5259 @node Pragma Main_Storage,Pragma Max_Queue_Length,Pragma Main,Implementation Defined Pragmas
5260 @anchor{gnat_rm/implementation_defined_pragmas pragma-main-storage}@anchor{9f}
5261 @section Pragma Main_Storage
5264 Syntax:
5266 @example
5267 pragma Main_Storage
5268   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
5270 MAIN_STORAGE_OPTION ::=
5271   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
5272 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
5273 @end example
5275 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
5276 no effect in GNAT, other than being syntax checked.
5278 @node Pragma Max_Queue_Length,Pragma No_Body,Pragma Main_Storage,Implementation Defined Pragmas
5279 @anchor{gnat_rm/implementation_defined_pragmas id24}@anchor{a0}@anchor{gnat_rm/implementation_defined_pragmas pragma-max-queue-length}@anchor{a1}
5280 @section Pragma Max_Queue_Length
5283 Syntax:
5285 @example
5286 pragma Max_Entry_Queue (static_integer_EXPRESSION);
5287 @end example
5289 This pragma is used to specify the maximum callers per entry queue for
5290 individual protected entries and entry families. It accepts a single
5291 integer (-1 or more) as a parameter and must appear after the declaration of an
5292 entry.
5294 A value of -1 represents no additional restriction on queue length.
5296 @node Pragma No_Body,Pragma No_Caching,Pragma Max_Queue_Length,Implementation Defined Pragmas
5297 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-body}@anchor{a2}
5298 @section Pragma No_Body
5301 Syntax:
5303 @example
5304 pragma No_Body;
5305 @end example
5307 There are a number of cases in which a package spec does not require a body,
5308 and in fact a body is not permitted. GNAT will not permit the spec to be
5309 compiled if there is a body around. The pragma No_Body allows you to provide
5310 a body file, even in a case where no body is allowed. The body file must
5311 contain only comments and a single No_Body pragma. This is recognized by
5312 the compiler as indicating that no body is logically present.
5314 This is particularly useful during maintenance when a package is modified in
5315 such a way that a body needed before is no longer needed. The provision of a
5316 dummy body with a No_Body pragma ensures that there is no interference from
5317 earlier versions of the package body.
5319 @node Pragma No_Caching,Pragma No_Component_Reordering,Pragma No_Body,Implementation Defined Pragmas
5320 @anchor{gnat_rm/implementation_defined_pragmas id25}@anchor{a3}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-caching}@anchor{a4}
5321 @section Pragma No_Caching
5324 Syntax:
5326 @example
5327 pragma No_Caching [ (static_boolean_EXPRESSION) ];
5328 @end example
5330 For the semantics of this pragma, see the entry for aspect @code{No_Caching} in
5331 the SPARK 2014 Reference Manual, section 7.1.2.
5333 @node Pragma No_Component_Reordering,Pragma No_Elaboration_Code_All,Pragma No_Caching,Implementation Defined Pragmas
5334 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-component-reordering}@anchor{a5}
5335 @section Pragma No_Component_Reordering
5338 Syntax:
5340 @example
5341 pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
5342 @end example
5344 @code{type_LOCAL_NAME} must refer to a record type declaration in the current
5345 declarative part. The effect is to preclude any reordering of components
5346 for the layout of the record, i.e. the record is laid out by the compiler
5347 in the order in which the components are declared textually. The form with
5348 no argument is a configuration pragma which applies to all record types
5349 declared in units to which the pragma applies and there is a requirement
5350 that this pragma be used consistently within a partition.
5352 @node Pragma No_Elaboration_Code_All,Pragma No_Heap_Finalization,Pragma No_Component_Reordering,Implementation Defined Pragmas
5353 @anchor{gnat_rm/implementation_defined_pragmas id26}@anchor{a6}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-elaboration-code-all}@anchor{a7}
5354 @section Pragma No_Elaboration_Code_All
5357 Syntax:
5359 @example
5360 pragma No_Elaboration_Code_All [(program_unit_NAME)];
5361 @end example
5363 This is a program unit pragma (there is also an equivalent aspect of the
5364 same name) that establishes the restriction @code{No_Elaboration_Code} for
5365 the current unit and any extended main source units (body and subunits).
5366 It also has the effect of enforcing a transitive application of this
5367 aspect, so that if any unit is implicitly or explicitly with’ed by the
5368 current unit, it must also have the No_Elaboration_Code_All aspect set.
5369 It may be applied to package or subprogram specs or their generic versions.
5371 @node Pragma No_Heap_Finalization,Pragma No_Inline,Pragma No_Elaboration_Code_All,Implementation Defined Pragmas
5372 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-heap-finalization}@anchor{a8}
5373 @section Pragma No_Heap_Finalization
5376 Syntax:
5378 @example
5379 pragma No_Heap_Finalization [ (first_subtype_LOCAL_NAME) ];
5380 @end example
5382 Pragma @code{No_Heap_Finalization} may be used as a configuration pragma or as a
5383 type-specific pragma.
5385 In its configuration form, the pragma must appear within a configuration file
5386 such as gnat.adc, without an argument. The pragma suppresses the call to
5387 @code{Finalize} for heap-allocated objects created through library-level named
5388 access-to-object types in cases where the designated type requires finalization
5389 actions.
5391 In its type-specific form, the argument of the pragma must denote a
5392 library-level named access-to-object type. The pragma suppresses the call to
5393 @code{Finalize} for heap-allocated objects created through the specific access type
5394 in cases where the designated type requires finalization actions.
5396 It is still possible to finalize such heap-allocated objects by explicitly
5397 deallocating them.
5399 A library-level named access-to-object type declared within a generic unit will
5400 lose its @code{No_Heap_Finalization} pragma when the corresponding instance does not
5401 appear at the library level.
5403 @node Pragma No_Inline,Pragma No_Return,Pragma No_Heap_Finalization,Implementation Defined Pragmas
5404 @anchor{gnat_rm/implementation_defined_pragmas id27}@anchor{a9}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-inline}@anchor{aa}
5405 @section Pragma No_Inline
5408 Syntax:
5410 @example
5411 pragma No_Inline (NAME @{, NAME@});
5412 @end example
5414 This pragma suppresses inlining for the callable entity or the instances of
5415 the generic subprogram designated by @code{NAME}, including inlining that
5416 results from the use of pragma @code{Inline}.  This pragma is always active,
5417 in particular it is not subject to the use of option `-gnatn' or
5418 `-gnatN'.  It is illegal to specify both pragma @code{No_Inline} and
5419 pragma @code{Inline_Always} for the same @code{NAME}.
5421 @node Pragma No_Return,Pragma No_Strict_Aliasing,Pragma No_Inline,Implementation Defined Pragmas
5422 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-return}@anchor{ab}
5423 @section Pragma No_Return
5426 Syntax:
5428 @example
5429 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
5430 @end example
5432 Each @code{procedure_LOCAL_NAME} argument must refer to one or more procedure
5433 declarations in the current declarative part.  A procedure to which this
5434 pragma is applied may not contain any explicit @code{return} statements.
5435 In addition, if the procedure contains any implicit returns from falling
5436 off the end of a statement sequence, then execution of that implicit
5437 return will cause Program_Error to be raised.
5439 One use of this pragma is to identify procedures whose only purpose is to raise
5440 an exception. Another use of this pragma is to suppress incorrect warnings
5441 about missing returns in functions, where the last statement of a function
5442 statement sequence is a call to such a procedure.
5444 Note that in Ada 2005 mode, this pragma is part of the language. It is
5445 available in all earlier versions of Ada as an implementation-defined
5446 pragma.
5448 @node Pragma No_Strict_Aliasing,Pragma No_Tagged_Streams,Pragma No_Return,Implementation Defined Pragmas
5449 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-strict-aliasing}@anchor{ac}
5450 @section Pragma No_Strict_Aliasing
5453 Syntax:
5455 @example
5456 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
5457 @end example
5459 @code{type_LOCAL_NAME} must refer to an access type
5460 declaration in the current declarative part.  The effect is to inhibit
5461 strict aliasing optimization for the given type.  The form with no
5462 arguments is a configuration pragma which applies to all access types
5463 declared in units to which the pragma applies. For a detailed
5464 description of the strict aliasing optimization, and the situations
5465 in which it must be suppressed, see the section on Optimization and Strict Aliasing
5466 in the @cite{GNAT User’s Guide}.
5468 This pragma currently has no effects on access to unconstrained array types.
5470 @node Pragma No_Tagged_Streams,Pragma Normalize_Scalars,Pragma No_Strict_Aliasing,Implementation Defined Pragmas
5471 @anchor{gnat_rm/implementation_defined_pragmas id28}@anchor{ad}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-tagged-streams}@anchor{ae}
5472 @section Pragma No_Tagged_Streams
5475 Syntax:
5477 @example
5478 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
5479 @end example
5481 Normally when a tagged type is introduced using a full type declaration,
5482 part of the processing includes generating stream access routines to be
5483 used by stream attributes referencing the type (or one of its subtypes
5484 or derived types). This can involve the generation of significant amounts
5485 of code which is wasted space if stream routines are not needed for the
5486 type in question.
5488 The @code{No_Tagged_Streams} pragma causes the generation of these stream
5489 routines to be skipped, and any attempt to use stream operations on
5490 types subject to this pragma will be statically rejected as illegal.
5492 There are two forms of the pragma. The form with no arguments must appear
5493 in a declarative sequence or in the declarations of a package spec. This
5494 pragma affects all subsequent root tagged types declared in the declaration
5495 sequence, and specifies that no stream routines be generated. The form with
5496 an argument (for which there is also a corresponding aspect) specifies a
5497 single root tagged type for which stream routines are not to be generated.
5499 Once the pragma has been given for a particular root tagged type, all subtypes
5500 and derived types of this type inherit the pragma automatically, so the effect
5501 applies to a complete hierarchy (this is necessary to deal with the class-wide
5502 dispatching versions of the stream routines).
5504 When pragmas @code{Discard_Names} and @code{No_Tagged_Streams} are simultaneously
5505 applied to a tagged type its Expanded_Name and External_Tag are initialized
5506 with empty strings. This is useful to avoid exposing entity names at binary
5507 level but has a negative impact on the debuggability of tagged types.
5509 @node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas
5510 @anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{af}
5511 @section Pragma Normalize_Scalars
5514 Syntax:
5516 @example
5517 pragma Normalize_Scalars;
5518 @end example
5520 This is a language defined pragma which is fully implemented in GNAT.  The
5521 effect is to cause all scalar objects that are not otherwise initialized
5522 to be initialized.  The initial values are implementation dependent and
5523 are as follows:
5526 @table @asis
5528 @item `Standard.Character'
5530 Objects whose root type is Standard.Character are initialized to
5531 Character’Last unless the subtype range excludes NUL (in which case
5532 NUL is used). This choice will always generate an invalid value if
5533 one exists.
5535 @item `Standard.Wide_Character'
5537 Objects whose root type is Standard.Wide_Character are initialized to
5538 Wide_Character’Last unless the subtype range excludes NUL (in which case
5539 NUL is used). This choice will always generate an invalid value if
5540 one exists.
5542 @item `Standard.Wide_Wide_Character'
5544 Objects whose root type is Standard.Wide_Wide_Character are initialized to
5545 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
5546 which case NUL is used). This choice will always generate an invalid value if
5547 one exists.
5549 @item `Integer types'
5551 Objects of an integer type are treated differently depending on whether
5552 negative values are present in the subtype. If no negative values are
5553 present, then all one bits is used as the initial value except in the
5554 special case where zero is excluded from the subtype, in which case
5555 all zero bits are used. This choice will always generate an invalid
5556 value if one exists.
5558 For subtypes with negative values present, the largest negative number
5559 is used, except in the unusual case where this largest negative number
5560 is in the subtype, and the largest positive number is not, in which case
5561 the largest positive value is used. This choice will always generate
5562 an invalid value if one exists.
5564 @item `Floating-Point Types'
5566 Objects of all floating-point types are initialized to all 1-bits. For
5567 standard IEEE format, this corresponds to a NaN (not a number) which is
5568 indeed an invalid value.
5570 @item `Fixed-Point Types'
5572 Objects of all fixed-point types are treated as described above for integers,
5573 with the rules applying to the underlying integer value used to represent
5574 the fixed-point value.
5576 @item `Modular types'
5578 Objects of a modular type are initialized to all one bits, except in
5579 the special case where zero is excluded from the subtype, in which
5580 case all zero bits are used. This choice will always generate an
5581 invalid value if one exists.
5583 @item `Enumeration types'
5585 Objects of an enumeration type are initialized to all one-bits, i.e., to
5586 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
5587 whose Pos value is zero, in which case a code of zero is used. This choice
5588 will always generate an invalid value if one exists.
5589 @end table
5591 @node Pragma Obsolescent,Pragma Optimize_Alignment,Pragma Normalize_Scalars,Implementation Defined Pragmas
5592 @anchor{gnat_rm/implementation_defined_pragmas id29}@anchor{b0}@anchor{gnat_rm/implementation_defined_pragmas pragma-obsolescent}@anchor{b1}
5593 @section Pragma Obsolescent
5596 Syntax:
5598 @example
5599 pragma Obsolescent;
5601 pragma Obsolescent (
5602   [Message =>] static_string_EXPRESSION
5603 [,[Version =>] Ada_05]);
5605 pragma Obsolescent (
5606   [Entity  =>] NAME
5607 [,[Message =>] static_string_EXPRESSION
5608 [,[Version =>] Ada_05]]);
5609 @end example
5611 This pragma can occur immediately following a declaration of an entity,
5612 including the case of a record component. If no Entity argument is present,
5613 then this declaration is the one to which the pragma applies. If an Entity
5614 parameter is present, it must either match the name of the entity in this
5615 declaration, or alternatively, the pragma can immediately follow an enumeration
5616 type declaration, where the Entity argument names one of the enumeration
5617 literals.
5619 This pragma is used to indicate that the named entity
5620 is considered obsolescent and should not be used. Typically this is
5621 used when an API must be modified by eventually removing or modifying
5622 existing subprograms or other entities. The pragma can be used at an
5623 intermediate stage when the entity is still present, but will be
5624 removed later.
5626 The effect of this pragma is to output a warning message on a reference to
5627 an entity thus marked that the subprogram is obsolescent if the appropriate
5628 warning option in the compiler is activated. If the @code{Message} parameter is
5629 present, then a second warning message is given containing this text. In
5630 addition, a reference to the entity is considered to be a violation of pragma
5631 @code{Restrictions (No_Obsolescent_Features)}.
5633 This pragma can also be used as a program unit pragma for a package,
5634 in which case the entity name is the name of the package, and the
5635 pragma indicates that the entire package is considered
5636 obsolescent. In this case a client @code{with}ing such a package
5637 violates the restriction, and the @code{with} clause is
5638 flagged with warnings if the warning option is set.
5640 If the @code{Version} parameter is present (which must be exactly
5641 the identifier @code{Ada_05}, no other argument is allowed), then the
5642 indication of obsolescence applies only when compiling in Ada 2005
5643 mode. This is primarily intended for dealing with the situations
5644 in the predefined library where subprograms or packages
5645 have become defined as obsolescent in Ada 2005
5646 (e.g., in @code{Ada.Characters.Handling}), but may be used anywhere.
5648 The following examples show typical uses of this pragma:
5650 @example
5651 package p is
5652    pragma Obsolescent (p, Message => "use pp instead of p");
5653 end p;
5655 package q is
5656    procedure q2;
5657    pragma Obsolescent ("use q2new instead");
5659    type R is new integer;
5660    pragma Obsolescent
5661      (Entity  => R,
5662       Message => "use RR in Ada 2005",
5663       Version => Ada_05);
5665    type M is record
5666       F1 : Integer;
5667       F2 : Integer;
5668       pragma Obsolescent;
5669       F3 : Integer;
5670    end record;
5672    type E is (a, bc, 'd', quack);
5673    pragma Obsolescent (Entity => bc)
5674    pragma Obsolescent (Entity => 'd')
5676    function "+"
5677      (a, b : character) return character;
5678    pragma Obsolescent (Entity => "+");
5679 end;
5680 @end example
5682 Note that, as for all pragmas, if you use a pragma argument identifier,
5683 then all subsequent parameters must also use a pragma argument identifier.
5684 So if you specify @code{Entity =>} for the @code{Entity} argument, and a @code{Message}
5685 argument is present, it must be preceded by @code{Message =>}.
5687 @node Pragma Optimize_Alignment,Pragma Ordered,Pragma Obsolescent,Implementation Defined Pragmas
5688 @anchor{gnat_rm/implementation_defined_pragmas pragma-optimize-alignment}@anchor{b2}
5689 @section Pragma Optimize_Alignment
5692 @geindex Alignment
5693 @geindex default settings
5695 Syntax:
5697 @example
5698 pragma Optimize_Alignment (TIME | SPACE | OFF);
5699 @end example
5701 This is a configuration pragma which affects the choice of default alignments
5702 for types and objects where no alignment is explicitly specified. There is a
5703 time/space trade-off in the selection of these values. Large alignments result
5704 in more efficient code, at the expense of larger data space, since sizes have
5705 to be increased to match these alignments. Smaller alignments save space, but
5706 the access code is slower. The normal choice of default alignments for types
5707 and individual alignment promotions for objects (which is what you get if you
5708 do not use this pragma, or if you use an argument of OFF), tries to balance
5709 these two requirements.
5711 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5712 First any packed record is given an alignment of 1. Second, if a size is given
5713 for the type, then the alignment is chosen to avoid increasing this size. For
5714 example, consider:
5716 @example
5717 type R is record
5718    X : Integer;
5719    Y : Character;
5720 end record;
5722 for R'Size use 5*8;
5723 @end example
5725 In the default mode, this type gets an alignment of 4, so that access to the
5726 Integer field X are efficient. But this means that objects of the type end up
5727 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5728 allowed to be bigger than the size of the type, but it can waste space if for
5729 example fields of type R appear in an enclosing record. If the above type is
5730 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5732 However, there is one case in which SPACE is ignored. If a variable length
5733 record (that is a discriminated record with a component which is an array
5734 whose length depends on a discriminant), has a pragma Pack, then it is not
5735 in general possible to set the alignment of such a record to one, so the
5736 pragma is ignored in this case (with a warning).
5738 Specifying SPACE also disables alignment promotions for standalone objects,
5739 which occur when the compiler increases the alignment of a specific object
5740 without changing the alignment of its type.
5742 Specifying SPACE also disables component reordering in unpacked record types,
5743 which can result in larger sizes in order to meet alignment requirements.
5745 Specifying TIME causes larger default alignments to be chosen in the case of
5746 small types with sizes that are not a power of 2. For example, consider:
5748 @example
5749 type R is record
5750    A : Character;
5751    B : Character;
5752    C : Boolean;
5753 end record;
5755 pragma Pack (R);
5756 for R'Size use 17;
5757 @end example
5759 The default alignment for this record is normally 1, but if this type is
5760 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5761 to 4, which wastes space for objects of the type, since they are now 4 bytes
5762 long, but results in more efficient access when the whole record is referenced.
5764 As noted above, this is a configuration pragma, and there is a requirement
5765 that all units in a partition be compiled with a consistent setting of the
5766 optimization setting. This would normally be achieved by use of a configuration
5767 pragma file containing the appropriate setting. The exception to this rule is
5768 that units with an explicit configuration pragma in the same file as the source
5769 unit are excluded from the consistency check, as are all predefined units. The
5770 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5771 pragma appears at the start of the file.
5773 @node Pragma Ordered,Pragma Overflow_Mode,Pragma Optimize_Alignment,Implementation Defined Pragmas
5774 @anchor{gnat_rm/implementation_defined_pragmas pragma-ordered}@anchor{b3}
5775 @section Pragma Ordered
5778 Syntax:
5780 @example
5781 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5782 @end example
5784 Most enumeration types are from a conceptual point of view unordered.
5785 For example, consider:
5787 @example
5788 type Color is (Red, Blue, Green, Yellow);
5789 @end example
5791 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5792 but really these relations make no sense; the enumeration type merely
5793 specifies a set of possible colors, and the order is unimportant.
5795 For unordered enumeration types, it is generally a good idea if
5796 clients avoid comparisons (other than equality or inequality) and
5797 explicit ranges. (A `client' is a unit where the type is referenced,
5798 other than the unit where the type is declared, its body, and its subunits.)
5799 For example, if code buried in some client says:
5801 @example
5802 if Current_Color < Yellow then ...
5803 if Current_Color in Blue .. Green then ...
5804 @end example
5806 then the client code is relying on the order, which is undesirable.
5807 It makes the code hard to read and creates maintenance difficulties if
5808 entries have to be added to the enumeration type. Instead,
5809 the code in the client should list the possibilities, or an
5810 appropriate subtype should be declared in the unit that declares
5811 the original enumeration type. E.g., the following subtype could
5812 be declared along with the type @code{Color}:
5814 @example
5815 subtype RBG is Color range Red .. Green;
5816 @end example
5818 and then the client could write:
5820 @example
5821 if Current_Color in RBG then ...
5822 if Current_Color = Blue or Current_Color = Green then ...
5823 @end example
5825 However, some enumeration types are legitimately ordered from a conceptual
5826 point of view. For example, if you declare:
5828 @example
5829 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5830 @end example
5832 then the ordering imposed by the language is reasonable, and
5833 clients can depend on it, writing for example:
5835 @example
5836 if D in Mon .. Fri then ...
5837 if D < Wed then ...
5838 @end example
5840 The pragma `Ordered' is provided to mark enumeration types that
5841 are conceptually ordered, alerting the reader that clients may depend
5842 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5843 rather than one to mark them as unordered, since in our experience,
5844 the great majority of enumeration types are conceptually unordered.
5846 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5847 and @code{Wide_Wide_Character}
5848 are considered to be ordered types, so each is declared with a
5849 pragma @code{Ordered} in package @code{Standard}.
5851 Normally pragma @code{Ordered} serves only as documentation and a guide for
5852 coding standards, but GNAT provides a warning switch `-gnatw.u' that
5853 requests warnings for inappropriate uses (comparisons and explicit
5854 subranges) for unordered types. If this switch is used, then any
5855 enumeration type not marked with pragma @code{Ordered} will be considered
5856 as unordered, and will generate warnings for inappropriate uses.
5858 Note that generic types are not considered ordered or unordered (since the
5859 template can be instantiated for both cases), so we never generate warnings
5860 for the case of generic enumerated types.
5862 For additional information please refer to the description of the
5863 `-gnatw.u' switch in the GNAT User’s Guide.
5865 @node Pragma Overflow_Mode,Pragma Overriding_Renamings,Pragma Ordered,Implementation Defined Pragmas
5866 @anchor{gnat_rm/implementation_defined_pragmas pragma-overflow-mode}@anchor{b4}
5867 @section Pragma Overflow_Mode
5870 Syntax:
5872 @example
5873 pragma Overflow_Mode
5874  (  [General    =>] MODE
5875   [,[Assertions =>] MODE]);
5877 MODE ::= STRICT | MINIMIZED | ELIMINATED
5878 @end example
5880 This pragma sets the current overflow mode to the given setting. For details
5881 of the meaning of these modes, please refer to the
5882 ‘Overflow Check Handling in GNAT’ appendix in the
5883 GNAT User’s Guide. If only the @code{General} parameter is present,
5884 the given mode applies to all expressions. If both parameters are present,
5885 the @code{General} mode applies to expressions outside assertions, and
5886 the @code{Eliminated} mode applies to expressions within assertions.
5888 The case of the @code{MODE} parameter is ignored,
5889 so @code{MINIMIZED}, @code{Minimized} and
5890 @code{minimized} all have the same effect.
5892 The @code{Overflow_Mode} pragma has the same scoping and placement
5893 rules as pragma @code{Suppress}, so it can occur either as a
5894 configuration pragma, specifying a default for the whole
5895 program, or in a declarative scope, where it applies to the
5896 remaining declarations and statements in that scope.
5898 The pragma @code{Suppress (Overflow_Check)} suppresses
5899 overflow checking, but does not affect the overflow mode.
5901 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5902 overflow checking, but does not affect the overflow mode.
5904 @node Pragma Overriding_Renamings,Pragma Part_Of,Pragma Overflow_Mode,Implementation Defined Pragmas
5905 @anchor{gnat_rm/implementation_defined_pragmas pragma-overriding-renamings}@anchor{b5}
5906 @section Pragma Overriding_Renamings
5909 @geindex Rational profile
5911 @geindex Rational compatibility
5913 Syntax:
5915 @example
5916 pragma Overriding_Renamings;
5917 @end example
5919 This is a GNAT configuration pragma to simplify porting
5920 legacy code accepted by the Rational
5921 Ada compiler. In the presence of this pragma, a renaming declaration that
5922 renames an inherited operation declared in the same scope is legal if selected
5923 notation is used as in:
5925 @example
5926 pragma Overriding_Renamings;
5928 package R is
5929   function F (..);
5930   ...
5931   function F (..) renames R.F;
5932 end R;
5933 @end example
5935 even though
5936 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5937 declaration of the overriding operation.
5939 @node Pragma Part_Of,Pragma Partition_Elaboration_Policy,Pragma Overriding_Renamings,Implementation Defined Pragmas
5940 @anchor{gnat_rm/implementation_defined_pragmas id30}@anchor{b6}@anchor{gnat_rm/implementation_defined_pragmas pragma-part-of}@anchor{b7}
5941 @section Pragma Part_Of
5944 Syntax:
5946 @example
5947 pragma Part_Of (ABSTRACT_STATE);
5949 ABSTRACT_STATE ::= NAME
5950 @end example
5952 For the semantics of this pragma, see the entry for aspect @code{Part_Of} in the
5953 SPARK 2014 Reference Manual, section 7.2.6.
5955 @node Pragma Partition_Elaboration_Policy,Pragma Passive,Pragma Part_Of,Implementation Defined Pragmas
5956 @anchor{gnat_rm/implementation_defined_pragmas pragma-partition-elaboration-policy}@anchor{b8}
5957 @section Pragma Partition_Elaboration_Policy
5960 Syntax:
5962 @example
5963 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5965 POLICY_IDENTIFIER ::= Concurrent | Sequential
5966 @end example
5968 This pragma is standard in Ada 2005, but is available in all earlier
5969 versions of Ada as an implementation-defined pragma.
5970 See Ada 2012 Reference Manual for details.
5972 @node Pragma Passive,Pragma Persistent_BSS,Pragma Partition_Elaboration_Policy,Implementation Defined Pragmas
5973 @anchor{gnat_rm/implementation_defined_pragmas pragma-passive}@anchor{b9}
5974 @section Pragma Passive
5977 Syntax:
5979 @example
5980 pragma Passive [(Semaphore | No)];
5981 @end example
5983 Syntax checked, but otherwise ignored by GNAT.  This is recognized for
5984 compatibility with DEC Ada 83 implementations, where it is used within a
5985 task definition to request that a task be made passive.  If the argument
5986 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5987 treats the pragma as an assertion that the containing task is passive
5988 and that optimization of context switch with this task is permitted and
5989 desired.  If the argument @code{No} is present, the task must not be
5990 optimized.  GNAT does not attempt to optimize any tasks in this manner
5991 (since protected objects are available in place of passive tasks).
5993 For more information on the subject of passive tasks, see the section
5994 ‘Passive Task Optimization’ in the GNAT Users Guide.
5996 @node Pragma Persistent_BSS,Pragma Post,Pragma Passive,Implementation Defined Pragmas
5997 @anchor{gnat_rm/implementation_defined_pragmas id31}@anchor{ba}@anchor{gnat_rm/implementation_defined_pragmas pragma-persistent-bss}@anchor{bb}
5998 @section Pragma Persistent_BSS
6001 Syntax:
6003 @example
6004 pragma Persistent_BSS [(LOCAL_NAME)]
6005 @end example
6007 This pragma allows selected objects to be placed in the @code{.persistent_bss}
6008 section. On some targets the linker and loader provide for special
6009 treatment of this section, allowing a program to be reloaded without
6010 affecting the contents of this data (hence the name persistent).
6012 There are two forms of usage. If an argument is given, it must be the
6013 local name of a library-level object, with no explicit initialization
6014 and whose type is potentially persistent. If no argument is given, then
6015 the pragma is a configuration pragma, and applies to all library-level
6016 objects with no explicit initialization of potentially persistent types.
6018 A potentially persistent type is a scalar type, or an untagged,
6019 non-discriminated record, all of whose components have no explicit
6020 initialization and are themselves of a potentially persistent type,
6021 or an array, all of whose constraints are static, and whose component
6022 type is potentially persistent.
6024 If this pragma is used on a target where this feature is not supported,
6025 then the pragma will be ignored. See also @code{pragma Linker_Section}.
6027 @node Pragma Post,Pragma Postcondition,Pragma Persistent_BSS,Implementation Defined Pragmas
6028 @anchor{gnat_rm/implementation_defined_pragmas pragma-post}@anchor{bc}
6029 @section Pragma Post
6032 @geindex Post
6034 @geindex Checks
6035 @geindex postconditions
6037 Syntax:
6039 @example
6040 pragma Post (Boolean_Expression);
6041 @end example
6043 The @code{Post} pragma is intended to be an exact replacement for
6044 the language-defined
6045 @code{Post} aspect, and shares its restrictions and semantics.
6046 It must appear either immediately following the corresponding
6047 subprogram declaration (only other pragmas may intervene), or
6048 if there is no separate subprogram declaration, then it can
6049 appear at the start of the declarations in a subprogram body
6050 (preceded only by other pragmas).
6052 @node Pragma Postcondition,Pragma Post_Class,Pragma Post,Implementation Defined Pragmas
6053 @anchor{gnat_rm/implementation_defined_pragmas pragma-postcondition}@anchor{bd}
6054 @section Pragma Postcondition
6057 @geindex Postcondition
6059 @geindex Checks
6060 @geindex postconditions
6062 Syntax:
6064 @example
6065 pragma Postcondition (
6066    [Check   =>] Boolean_Expression
6067  [,[Message =>] String_Expression]);
6068 @end example
6070 The @code{Postcondition} pragma allows specification of automatic
6071 postcondition checks for subprograms. These checks are similar to
6072 assertions, but are automatically inserted just prior to the return
6073 statements of the subprogram with which they are associated (including
6074 implicit returns at the end of procedure bodies and associated
6075 exception handlers).
6077 In addition, the boolean expression which is the condition which
6078 must be true may contain references to function’Result in the case
6079 of a function to refer to the returned value.
6081 @code{Postcondition} pragmas may appear either immediately following the
6082 (separate) declaration of a subprogram, or at the start of the
6083 declarations of a subprogram body. Only other pragmas may intervene
6084 (that is appear between the subprogram declaration and its
6085 postconditions, or appear before the postcondition in the
6086 declaration sequence in a subprogram body). In the case of a
6087 postcondition appearing after a subprogram declaration, the
6088 formal arguments of the subprogram are visible, and can be
6089 referenced in the postcondition expressions.
6091 The postconditions are collected and automatically tested just
6092 before any return (implicit or explicit) in the subprogram body.
6093 A postcondition is only recognized if postconditions are active
6094 at the time the pragma is encountered. The compiler switch `gnata'
6095 turns on all postconditions by default, and pragma @code{Check_Policy}
6096 with an identifier of @code{Postcondition} can also be used to
6097 control whether postconditions are active.
6099 The general approach is that postconditions are placed in the spec
6100 if they represent functional aspects which make sense to the client.
6101 For example we might have:
6103 @example
6104 function Direction return Integer;
6105 pragma Postcondition
6106  (Direction'Result = +1
6107     or else
6108   Direction'Result = -1);
6109 @end example
6111 which serves to document that the result must be +1 or -1, and
6112 will test that this is the case at run time if postcondition
6113 checking is active.
6115 Postconditions within the subprogram body can be used to
6116 check that some internal aspect of the implementation,
6117 not visible to the client, is operating as expected.
6118 For instance if a square root routine keeps an internal
6119 counter of the number of times it is called, then we
6120 might have the following postcondition:
6122 @example
6123 Sqrt_Calls : Natural := 0;
6125 function Sqrt (Arg : Float) return Float is
6126   pragma Postcondition
6127     (Sqrt_Calls = Sqrt_Calls'Old + 1);
6128   ...
6129 end Sqrt
6130 @end example
6132 As this example, shows, the use of the @code{Old} attribute
6133 is often useful in postconditions to refer to the state on
6134 entry to the subprogram.
6136 Note that postconditions are only checked on normal returns
6137 from the subprogram. If an abnormal return results from
6138 raising an exception, then the postconditions are not checked.
6140 If a postcondition fails, then the exception
6141 @code{System.Assertions.Assert_Failure} is raised. If
6142 a message argument was supplied, then the given string
6143 will be used as the exception message. If no message
6144 argument was supplied, then the default message has
6145 the form “Postcondition failed at file_name:line”. The
6146 exception is raised in the context of the subprogram
6147 body, so it is possible to catch postcondition failures
6148 within the subprogram body itself.
6150 Within a package spec, normal visibility rules
6151 in Ada would prevent forward references within a
6152 postcondition pragma to functions defined later in
6153 the same package. This would introduce undesirable
6154 ordering constraints. To avoid this problem, all
6155 postcondition pragmas are analyzed at the end of
6156 the package spec, allowing forward references.
6158 The following example shows that this even allows
6159 mutually recursive postconditions as in:
6161 @example
6162 package Parity_Functions is
6163    function Odd  (X : Natural) return Boolean;
6164    pragma Postcondition
6165      (Odd'Result =
6166         (x = 1
6167           or else
6168         (x /= 0 and then Even (X - 1))));
6170    function Even (X : Natural) return Boolean;
6171    pragma Postcondition
6172      (Even'Result =
6173         (x = 0
6174           or else
6175         (x /= 1 and then Odd (X - 1))));
6177 end Parity_Functions;
6178 @end example
6180 There are no restrictions on the complexity or form of
6181 conditions used within @code{Postcondition} pragmas.
6182 The following example shows that it is even possible
6183 to verify performance behavior.
6185 @example
6186 package Sort is
6188    Performance : constant Float;
6189    --  Performance constant set by implementation
6190    --  to match target architecture behavior.
6192    procedure Treesort (Arg : String);
6193    --  Sorts characters of argument using N*logN sort
6194    pragma Postcondition
6195      (Float (Clock - Clock'Old) <=
6196         Float (Arg'Length) *
6197         log (Float (Arg'Length)) *
6198         Performance);
6199 end Sort;
6200 @end example
6202 Note: postcondition pragmas associated with subprograms that are
6203 marked as Inline_Always, or those marked as Inline with front-end
6204 inlining (-gnatN option set) are accepted and legality-checked
6205 by the compiler, but are ignored at run-time even if postcondition
6206 checking is enabled.
6208 Note that pragma @code{Postcondition} differs from the language-defined
6209 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
6210 multiple occurrences, allowing occurences in the body even if there
6211 is a separate spec, and allowing a second string parameter, and the
6212 use of the pragma identifier @code{Check}. Historically, pragma
6213 @code{Postcondition} was implemented prior to the development of
6214 Ada 2012, and has been retained in its original form for
6215 compatibility purposes.
6217 @node Pragma Post_Class,Pragma Pre,Pragma Postcondition,Implementation Defined Pragmas
6218 @anchor{gnat_rm/implementation_defined_pragmas pragma-post-class}@anchor{be}
6219 @section Pragma Post_Class
6222 @geindex Post
6224 @geindex Checks
6225 @geindex postconditions
6227 Syntax:
6229 @example
6230 pragma Post_Class (Boolean_Expression);
6231 @end example
6233 The @code{Post_Class} pragma is intended to be an exact replacement for
6234 the language-defined
6235 @code{Post'Class} aspect, and shares its restrictions and semantics.
6236 It must appear either immediately following the corresponding
6237 subprogram declaration (only other pragmas may intervene), or
6238 if there is no separate subprogram declaration, then it can
6239 appear at the start of the declarations in a subprogram body
6240 (preceded only by other pragmas).
6242 Note: This pragma is called @code{Post_Class} rather than
6243 @code{Post'Class} because the latter would not be strictly
6244 conforming to the allowed syntax for pragmas. The motivation
6245 for providing pragmas equivalent to the aspects is to allow a program
6246 to be written using the pragmas, and then compiled if necessary
6247 using an Ada compiler that does not recognize the pragmas or
6248 aspects, but is prepared to ignore the pragmas. The assertion
6249 policy that controls this pragma is @code{Post'Class}, not
6250 @code{Post_Class}.
6252 @node Pragma Pre,Pragma Precondition,Pragma Post_Class,Implementation Defined Pragmas
6253 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre}@anchor{bf}
6254 @section Pragma Pre
6257 @geindex Pre
6259 @geindex Checks
6260 @geindex preconditions
6262 Syntax:
6264 @example
6265 pragma Pre (Boolean_Expression);
6266 @end example
6268 The @code{Pre} pragma is intended to be an exact replacement for
6269 the language-defined
6270 @code{Pre} aspect, and shares its restrictions and semantics.
6271 It must appear either immediately following the corresponding
6272 subprogram declaration (only other pragmas may intervene), or
6273 if there is no separate subprogram declaration, then it can
6274 appear at the start of the declarations in a subprogram body
6275 (preceded only by other pragmas).
6277 @node Pragma Precondition,Pragma Predicate,Pragma Pre,Implementation Defined Pragmas
6278 @anchor{gnat_rm/implementation_defined_pragmas pragma-precondition}@anchor{c0}
6279 @section Pragma Precondition
6282 @geindex Preconditions
6284 @geindex Checks
6285 @geindex preconditions
6287 Syntax:
6289 @example
6290 pragma Precondition (
6291    [Check   =>] Boolean_Expression
6292  [,[Message =>] String_Expression]);
6293 @end example
6295 The @code{Precondition} pragma is similar to @code{Postcondition}
6296 except that the corresponding checks take place immediately upon
6297 entry to the subprogram, and if a precondition fails, the exception
6298 is raised in the context of the caller, and the attribute ‘Result
6299 cannot be used within the precondition expression.
6301 Otherwise, the placement and visibility rules are identical to those
6302 described for postconditions. The following is an example of use
6303 within a package spec:
6305 @example
6306 package Math_Functions is
6307    ...
6308    function Sqrt (Arg : Float) return Float;
6309    pragma Precondition (Arg >= 0.0)
6310    ...
6311 end Math_Functions;
6312 @end example
6314 @code{Precondition} pragmas may appear either immediately following the
6315 (separate) declaration of a subprogram, or at the start of the
6316 declarations of a subprogram body. Only other pragmas may intervene
6317 (that is appear between the subprogram declaration and its
6318 postconditions, or appear before the postcondition in the
6319 declaration sequence in a subprogram body).
6321 Note: precondition pragmas associated with subprograms that are
6322 marked as Inline_Always, or those marked as Inline with front-end
6323 inlining (-gnatN option set) are accepted and legality-checked
6324 by the compiler, but are ignored at run-time even if precondition
6325 checking is enabled.
6327 Note that pragma @code{Precondition} differs from the language-defined
6328 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
6329 multiple occurrences, allowing occurences in the body even if there
6330 is a separate spec, and allowing a second string parameter, and the
6331 use of the pragma identifier @code{Check}. Historically, pragma
6332 @code{Precondition} was implemented prior to the development of
6333 Ada 2012, and has been retained in its original form for
6334 compatibility purposes.
6336 @node Pragma Predicate,Pragma Predicate_Failure,Pragma Precondition,Implementation Defined Pragmas
6337 @anchor{gnat_rm/implementation_defined_pragmas id32}@anchor{c1}@anchor{gnat_rm/implementation_defined_pragmas pragma-predicate}@anchor{c2}
6338 @section Pragma Predicate
6341 Syntax:
6343 @example
6344 pragma Predicate
6345   ([Entity =>] type_LOCAL_NAME,
6346    [Check  =>] EXPRESSION);
6347 @end example
6349 This pragma (available in all versions of Ada in GNAT) encompasses both
6350 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
6351 Ada 2012. A predicate is regarded as static if it has an allowed form
6352 for @code{Static_Predicate} and is otherwise treated as a
6353 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
6354 pragma behave exactly as described in the Ada 2012 reference manual.
6355 For example, if we have
6357 @example
6358 type R is range 1 .. 10;
6359 subtype S is R;
6360 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
6361 subtype Q is R
6362 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
6363 @end example
6365 the effect is identical to the following Ada 2012 code:
6367 @example
6368 type R is range 1 .. 10;
6369 subtype S is R with
6370   Static_Predicate => S not in 4 .. 6;
6371 subtype Q is R with
6372   Dynamic_Predicate => F(Q) or G(Q);
6373 @end example
6375 Note that there are no pragmas @code{Dynamic_Predicate}
6376 or @code{Static_Predicate}. That is
6377 because these pragmas would affect legality and semantics of
6378 the program and thus do not have a neutral effect if ignored.
6379 The motivation behind providing pragmas equivalent to
6380 corresponding aspects is to allow a program to be written
6381 using the pragmas, and then compiled with a compiler that
6382 will ignore the pragmas. That doesn’t work in the case of
6383 static and dynamic predicates, since if the corresponding
6384 pragmas are ignored, then the behavior of the program is
6385 fundamentally changed (for example a membership test
6386 @code{A in B} would not take into account a predicate
6387 defined for subtype B). When following this approach, the
6388 use of predicates should be avoided.
6390 @node Pragma Predicate_Failure,Pragma Preelaborable_Initialization,Pragma Predicate,Implementation Defined Pragmas
6391 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate-failure}@anchor{c3}
6392 @section Pragma Predicate_Failure
6395 Syntax:
6397 @example
6398 pragma Predicate_Failure
6399   ([Entity  =>] type_LOCAL_NAME,
6400    [Message =>] String_Expression);
6401 @end example
6403 The @code{Predicate_Failure} pragma is intended to be an exact replacement for
6404 the language-defined
6405 @code{Predicate_Failure} aspect, and shares its restrictions and semantics.
6407 @node Pragma Preelaborable_Initialization,Pragma Prefix_Exception_Messages,Pragma Predicate_Failure,Implementation Defined Pragmas
6408 @anchor{gnat_rm/implementation_defined_pragmas pragma-preelaborable-initialization}@anchor{c4}
6409 @section Pragma Preelaborable_Initialization
6412 Syntax:
6414 @example
6415 pragma Preelaborable_Initialization (DIRECT_NAME);
6416 @end example
6418 This pragma is standard in Ada 2005, but is available in all earlier
6419 versions of Ada as an implementation-defined pragma.
6420 See Ada 2012 Reference Manual for details.
6422 @node Pragma Prefix_Exception_Messages,Pragma Pre_Class,Pragma Preelaborable_Initialization,Implementation Defined Pragmas
6423 @anchor{gnat_rm/implementation_defined_pragmas pragma-prefix-exception-messages}@anchor{c5}
6424 @section Pragma Prefix_Exception_Messages
6427 @geindex Prefix_Exception_Messages
6429 @geindex exception
6431 @geindex Exception_Message
6433 Syntax:
6435 @example
6436 pragma Prefix_Exception_Messages;
6437 @end example
6439 This is an implementation-defined configuration pragma that affects the
6440 behavior of raise statements with a message given as a static string
6441 constant (typically a string literal). In such cases, the string will
6442 be automatically prefixed by the name of the enclosing entity (giving
6443 the package and subprogram containing the raise statement). This helps
6444 to identify where messages are coming from, and this mode is automatic
6445 for the run-time library.
6447 The pragma has no effect if the message is computed with an expression other
6448 than a static string constant, since the assumption in this case is that
6449 the program computes exactly the string it wants. If you still want the
6450 prefixing in this case, you can always call
6451 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
6453 @node Pragma Pre_Class,Pragma Priority_Specific_Dispatching,Pragma Prefix_Exception_Messages,Implementation Defined Pragmas
6454 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre-class}@anchor{c6}
6455 @section Pragma Pre_Class
6458 @geindex Pre_Class
6460 @geindex Checks
6461 @geindex preconditions
6463 Syntax:
6465 @example
6466 pragma Pre_Class (Boolean_Expression);
6467 @end example
6469 The @code{Pre_Class} pragma is intended to be an exact replacement for
6470 the language-defined
6471 @code{Pre'Class} aspect, and shares its restrictions and semantics.
6472 It must appear either immediately following the corresponding
6473 subprogram declaration (only other pragmas may intervene), or
6474 if there is no separate subprogram declaration, then it can
6475 appear at the start of the declarations in a subprogram body
6476 (preceded only by other pragmas).
6478 Note: This pragma is called @code{Pre_Class} rather than
6479 @code{Pre'Class} because the latter would not be strictly
6480 conforming to the allowed syntax for pragmas. The motivation
6481 for providing pragmas equivalent to the aspects is to allow a program
6482 to be written using the pragmas, and then compiled if necessary
6483 using an Ada compiler that does not recognize the pragmas or
6484 aspects, but is prepared to ignore the pragmas. The assertion
6485 policy that controls this pragma is @code{Pre'Class}, not
6486 @code{Pre_Class}.
6488 @node Pragma Priority_Specific_Dispatching,Pragma Profile,Pragma Pre_Class,Implementation Defined Pragmas
6489 @anchor{gnat_rm/implementation_defined_pragmas pragma-priority-specific-dispatching}@anchor{c7}
6490 @section Pragma Priority_Specific_Dispatching
6493 Syntax:
6495 @example
6496 pragma Priority_Specific_Dispatching (
6497    POLICY_IDENTIFIER,
6498    first_priority_EXPRESSION,
6499    last_priority_EXPRESSION)
6501 POLICY_IDENTIFIER ::=
6502    EDF_Across_Priorities            |
6503    FIFO_Within_Priorities           |
6504    Non_Preemptive_Within_Priorities |
6505    Round_Robin_Within_Priorities
6506 @end example
6508 This pragma is standard in Ada 2005, but is available in all earlier
6509 versions of Ada as an implementation-defined pragma.
6510 See Ada 2012 Reference Manual for details.
6512 @node Pragma Profile,Pragma Profile_Warnings,Pragma Priority_Specific_Dispatching,Implementation Defined Pragmas
6513 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile}@anchor{c8}
6514 @section Pragma Profile
6517 Syntax:
6519 @example
6520 pragma Profile (Ravenscar | Restricted | Rational | Jorvik |
6521                 GNAT_Extended_Ravenscar | GNAT_Ravenscar_EDF );
6522 @end example
6524 This pragma is standard in Ada 2005, but is available in all earlier
6525 versions of Ada as an implementation-defined pragma. This is a
6526 configuration pragma that establishes a set of configuration pragmas
6527 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
6528 @code{Jorvik} is standard in Ada 202x.
6529 The other possibilities (@code{Restricted}, @code{Rational},
6530 @code{GNAT_Extended_Ravenscar}, @code{GNAT_Ravenscar_EDF})
6531 are implementation-defined.  @code{GNAT_Extended_Ravenscar} is an alias for @code{Jorvik}.
6533 The set of configuration pragmas is defined in the following sections.
6536 @itemize *
6538 @item 
6539 Pragma Profile (Ravenscar)
6541 The @code{Ravenscar} profile is standard in Ada 2005,
6542 but is available in all earlier
6543 versions of Ada as an implementation-defined pragma. This profile
6544 establishes the following set of configuration pragmas:
6547 @itemize *
6549 @item 
6550 @code{Task_Dispatching_Policy (FIFO_Within_Priorities)}
6552 [RM D.2.2] Tasks are dispatched following a preemptive
6553 priority-ordered scheduling policy.
6555 @item 
6556 @code{Locking_Policy (Ceiling_Locking)}
6558 [RM D.3] While tasks and interrupts execute a protected action, they inherit
6559 the ceiling priority of the corresponding protected object.
6561 @item 
6562 @code{Detect_Blocking}
6564 This pragma forces the detection of potentially blocking operations within a
6565 protected operation, and to raise Program_Error if that happens.
6566 @end itemize
6568 plus the following set of restrictions:
6571 @itemize *
6573 @item 
6574 @code{Max_Entry_Queue_Length => 1}
6576 No task can be queued on a protected entry.
6578 @item 
6579 @code{Max_Protected_Entries => 1}
6581 @item 
6582 @code{Max_Task_Entries => 0}
6584 No rendezvous statements are allowed.
6586 @item 
6587 @code{No_Abort_Statements}
6589 @item 
6590 @code{No_Dynamic_Attachment}
6592 @item 
6593 @code{No_Dynamic_Priorities}
6595 @item 
6596 @code{No_Implicit_Heap_Allocations}
6598 @item 
6599 @code{No_Local_Protected_Objects}
6601 @item 
6602 @code{No_Local_Timing_Events}
6604 @item 
6605 @code{No_Protected_Type_Allocators}
6607 @item 
6608 @code{No_Relative_Delay}
6610 @item 
6611 @code{No_Requeue_Statements}
6613 @item 
6614 @code{No_Select_Statements}
6616 @item 
6617 @code{No_Specific_Termination_Handlers}
6619 @item 
6620 @code{No_Task_Allocators}
6622 @item 
6623 @code{No_Task_Hierarchy}
6625 @item 
6626 @code{No_Task_Termination}
6628 @item 
6629 @code{Simple_Barriers}
6630 @end itemize
6632 The Ravenscar profile also includes the following restrictions that specify
6633 that there are no semantic dependencies on the corresponding predefined
6634 packages:
6637 @itemize *
6639 @item 
6640 @code{No_Dependence => Ada.Asynchronous_Task_Control}
6642 @item 
6643 @code{No_Dependence => Ada.Calendar}
6645 @item 
6646 @code{No_Dependence => Ada.Execution_Time.Group_Budget}
6648 @item 
6649 @code{No_Dependence => Ada.Execution_Time.Timers}
6651 @item 
6652 @code{No_Dependence => Ada.Task_Attributes}
6654 @item 
6655 @code{No_Dependence => System.Multiprocessors.Dispatching_Domains}
6656 @end itemize
6658 This set of configuration pragmas and restrictions correspond to the
6659 definition of the ‘Ravenscar Profile’ for limited tasking, devised and
6660 published by the @cite{International Real-Time Ada Workshop@comma{} 1997}.
6661 A description is also available at
6662 @indicateurl{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
6664 The original definition of the profile was revised at subsequent IRTAW
6665 meetings. It has been included in the ISO
6666 @cite{Guide for the Use of the Ada Programming Language in High Integrity Systems},
6667 and was made part of the Ada 2005 standard.
6668 The formal definition given by
6669 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
6670 AI-305) available at
6671 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
6672 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
6674 The above set is a superset of the restrictions provided by pragma
6675 @code{Profile (Restricted)}, it includes six additional restrictions
6676 (@code{Simple_Barriers}, @code{No_Select_Statements},
6677 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
6678 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
6679 that pragma @code{Profile (Ravenscar)}, like the pragma
6680 @code{Profile (Restricted)},
6681 automatically causes the use of a simplified,
6682 more efficient version of the tasking run-time library.
6684 @item 
6685 Pragma Profile (Jorvik)
6687 @code{Jorvik} is the new profile added to the Ada 202x draft standard,
6688 previously implemented under the name @code{GNAT_Extended_Ravenscar}.
6690 The @code{No_Implicit_Heap_Allocations} restriction has been replaced
6691 by @code{No_Implicit_Task_Allocations} and
6692 @code{No_Implicit_Protected_Object_Allocations}.
6694 The @code{Simple_Barriers} restriction has been replaced by
6695 @code{Pure_Barriers}.
6697 The @code{Max_Protected_Entries}, @code{Max_Entry_Queue_Length}, and
6698 @code{No_Relative_Delay} restrictions have been removed.
6700 Details on the rationale for @code{Jorvik} and implications for use may be
6701 found in @cite{A New Ravenscar-Based Profile} by P. Rogers, J. Ruiz,
6702 T. Gingold and P. Bernardi, in @cite{Reliable Software Technologies – Ada Europe 2017}, Springer-Verlag Lecture Notes in Computer Science,
6703 Number 10300.
6705 @item 
6706 Pragma Profile (GNAT_Ravenscar_EDF)
6708 This profile corresponds to the Ravenscar profile but using
6709 EDF_Across_Priority as the Task_Scheduling_Policy.
6711 @item 
6712 Pragma Profile (Restricted)
6714 This profile corresponds to the GNAT restricted run time. It
6715 establishes the following set of restrictions:
6718 @itemize *
6720 @item 
6721 @code{No_Abort_Statements}
6723 @item 
6724 @code{No_Entry_Queue}
6726 @item 
6727 @code{No_Task_Hierarchy}
6729 @item 
6730 @code{No_Task_Allocators}
6732 @item 
6733 @code{No_Dynamic_Priorities}
6735 @item 
6736 @code{No_Terminate_Alternatives}
6738 @item 
6739 @code{No_Dynamic_Attachment}
6741 @item 
6742 @code{No_Protected_Type_Allocators}
6744 @item 
6745 @code{No_Local_Protected_Objects}
6747 @item 
6748 @code{No_Requeue_Statements}
6750 @item 
6751 @code{No_Task_Attributes_Package}
6753 @item 
6754 @code{Max_Asynchronous_Select_Nesting =  0}
6756 @item 
6757 @code{Max_Task_Entries =  0}
6759 @item 
6760 @code{Max_Protected_Entries = 1}
6762 @item 
6763 @code{Max_Select_Alternatives = 0}
6764 @end itemize
6766 This set of restrictions causes the automatic selection of a simplified
6767 version of the run time that provides improved performance for the
6768 limited set of tasking functionality permitted by this set of restrictions.
6770 @item 
6771 Pragma Profile (Rational)
6773 The Rational profile is intended to facilitate porting legacy code that
6774 compiles with the Rational APEX compiler, even when the code includes non-
6775 conforming Ada constructs.  The profile enables the following three pragmas:
6778 @itemize *
6780 @item 
6781 @code{pragma Implicit_Packing}
6783 @item 
6784 @code{pragma Overriding_Renamings}
6786 @item 
6787 @code{pragma Use_VADS_Size}
6788 @end itemize
6789 @end itemize
6791 @node Pragma Profile_Warnings,Pragma Propagate_Exceptions,Pragma Profile,Implementation Defined Pragmas
6792 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile-warnings}@anchor{c9}
6793 @section Pragma Profile_Warnings
6796 Syntax:
6798 @example
6799 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
6800 @end example
6802 This is an implementation-defined pragma that is similar in
6803 effect to @code{pragma Profile} except that instead of
6804 generating @code{Restrictions} pragmas, it generates
6805 @code{Restriction_Warnings} pragmas. The result is that
6806 violations of the profile generate warning messages instead
6807 of error messages.
6809 @node Pragma Propagate_Exceptions,Pragma Provide_Shift_Operators,Pragma Profile_Warnings,Implementation Defined Pragmas
6810 @anchor{gnat_rm/implementation_defined_pragmas pragma-propagate-exceptions}@anchor{ca}
6811 @section Pragma Propagate_Exceptions
6814 @geindex Interfacing to C++
6816 Syntax:
6818 @example
6819 pragma Propagate_Exceptions;
6820 @end example
6822 This pragma is now obsolete and, other than generating a warning if warnings
6823 on obsolescent features are enabled, is ignored.
6824 It is retained for compatibility
6825 purposes. It used to be used in connection with optimization of
6826 a now-obsolete mechanism for implementation of exceptions.
6828 @node Pragma Provide_Shift_Operators,Pragma Psect_Object,Pragma Propagate_Exceptions,Implementation Defined Pragmas
6829 @anchor{gnat_rm/implementation_defined_pragmas pragma-provide-shift-operators}@anchor{cb}
6830 @section Pragma Provide_Shift_Operators
6833 @geindex Shift operators
6835 Syntax:
6837 @example
6838 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
6839 @end example
6841 This pragma can be applied to a first subtype local name that specifies
6842 either an unsigned or signed type. It has the effect of providing the
6843 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
6844 Rotate_Left and Rotate_Right) for the given type. It is similar to
6845 including the function declarations for these five operators, together
6846 with the pragma Import (Intrinsic, …) statements.
6848 @node Pragma Psect_Object,Pragma Pure_Function,Pragma Provide_Shift_Operators,Implementation Defined Pragmas
6849 @anchor{gnat_rm/implementation_defined_pragmas pragma-psect-object}@anchor{cc}
6850 @section Pragma Psect_Object
6853 Syntax:
6855 @example
6856 pragma Psect_Object (
6857      [Internal =>] LOCAL_NAME,
6858   [, [External =>] EXTERNAL_SYMBOL]
6859   [, [Size     =>] EXTERNAL_SYMBOL]);
6861 EXTERNAL_SYMBOL ::=
6862   IDENTIFIER
6863 | static_string_EXPRESSION
6864 @end example
6866 This pragma is identical in effect to pragma @code{Common_Object}.
6868 @node Pragma Pure_Function,Pragma Rational,Pragma Psect_Object,Implementation Defined Pragmas
6869 @anchor{gnat_rm/implementation_defined_pragmas id33}@anchor{cd}@anchor{gnat_rm/implementation_defined_pragmas pragma-pure-function}@anchor{ce}
6870 @section Pragma Pure_Function
6873 Syntax:
6875 @example
6876 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6877 @end example
6879 This pragma appears in the same declarative part as a function
6880 declaration (or a set of function declarations if more than one
6881 overloaded declaration exists, in which case the pragma applies
6882 to all entities).  It specifies that the function @code{Entity} is
6883 to be considered pure for the purposes of code generation.  This means
6884 that the compiler can assume that there are no side effects, and
6885 in particular that two identical calls produce the same result in
6886 the same context. It also means that the function can be used in
6887 an address clause.
6889 Note that, quite deliberately, there are no static checks to try
6890 to ensure that this promise is met, so @code{Pure_Function} can be used
6891 with functions that are conceptually pure, even if they do modify
6892 global variables.  For example, a square root function that is
6893 instrumented to count the number of times it is called is still
6894 conceptually pure, and can still be optimized, even though it
6895 modifies a global variable (the count).  Memo functions are another
6896 example (where a table of previous calls is kept and consulted to
6897 avoid re-computation).
6899 Note also that the normal rules excluding optimization of subprograms
6900 in pure units (when parameter types are descended from System.Address,
6901 or when the full view of a parameter type is limited), do not apply
6902 for the Pure_Function case. If you explicitly specify Pure_Function,
6903 the compiler may optimize away calls with identical arguments, and
6904 if that results in unexpected behavior, the proper action is not to
6905 use the pragma for subprograms that are not (conceptually) pure.
6907 Note: Most functions in a @code{Pure} package are automatically pure, and
6908 there is no need to use pragma @code{Pure_Function} for such functions.  One
6909 exception is any function that has at least one formal of type
6910 @code{System.Address} or a type derived from it.  Such functions are not
6911 considered pure by default, since the compiler assumes that the
6912 @code{Address} parameter may be functioning as a pointer and that the
6913 referenced data may change even if the address value does not.
6914 Similarly, imported functions are not considered to be pure by default,
6915 since there is no way of checking that they are in fact pure.  The use
6916 of pragma @code{Pure_Function} for such a function will override these default
6917 assumption, and cause the compiler to treat a designated subprogram as pure
6918 in these cases.
6920 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6921 applies to the underlying renamed function.  This can be used to
6922 disambiguate cases of overloading where some but not all functions
6923 in a set of overloaded functions are to be designated as pure.
6925 If pragma @code{Pure_Function} is applied to a library-level function, the
6926 function is also considered pure from an optimization point of view, but the
6927 unit is not a Pure unit in the categorization sense. So for example, a function
6928 thus marked is free to @code{with} non-pure units.
6930 @node Pragma Rational,Pragma Ravenscar,Pragma Pure_Function,Implementation Defined Pragmas
6931 @anchor{gnat_rm/implementation_defined_pragmas pragma-rational}@anchor{cf}
6932 @section Pragma Rational
6935 Syntax:
6937 @example
6938 pragma Rational;
6939 @end example
6941 This pragma is considered obsolescent, but is retained for
6942 compatibility purposes. It is equivalent to:
6944 @example
6945 pragma Profile (Rational);
6946 @end example
6948 @node Pragma Ravenscar,Pragma Refined_Depends,Pragma Rational,Implementation Defined Pragmas
6949 @anchor{gnat_rm/implementation_defined_pragmas pragma-ravenscar}@anchor{d0}
6950 @section Pragma Ravenscar
6953 Syntax:
6955 @example
6956 pragma Ravenscar;
6957 @end example
6959 This pragma is considered obsolescent, but is retained for
6960 compatibility purposes. It is equivalent to:
6962 @example
6963 pragma Profile (Ravenscar);
6964 @end example
6966 which is the preferred method of setting the @code{Ravenscar} profile.
6968 @node Pragma Refined_Depends,Pragma Refined_Global,Pragma Ravenscar,Implementation Defined Pragmas
6969 @anchor{gnat_rm/implementation_defined_pragmas id34}@anchor{d1}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-depends}@anchor{d2}
6970 @section Pragma Refined_Depends
6973 Syntax:
6975 @example
6976 pragma Refined_Depends (DEPENDENCY_RELATION);
6978 DEPENDENCY_RELATION ::=
6979      null
6980   | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
6982 DEPENDENCY_CLAUSE ::=
6983     OUTPUT_LIST =>[+] INPUT_LIST
6984   | NULL_DEPENDENCY_CLAUSE
6986 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
6988 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
6990 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
6992 OUTPUT ::= NAME | FUNCTION_RESULT
6993 INPUT  ::= NAME
6995 where FUNCTION_RESULT is a function Result attribute_reference
6996 @end example
6998 For the semantics of this pragma, see the entry for aspect @code{Refined_Depends} in
6999 the SPARK 2014 Reference Manual, section 6.1.5.
7001 @node Pragma Refined_Global,Pragma Refined_Post,Pragma Refined_Depends,Implementation Defined Pragmas
7002 @anchor{gnat_rm/implementation_defined_pragmas id35}@anchor{d3}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-global}@anchor{d4}
7003 @section Pragma Refined_Global
7006 Syntax:
7008 @example
7009 pragma Refined_Global (GLOBAL_SPECIFICATION);
7011 GLOBAL_SPECIFICATION ::=
7012      null
7013   | (GLOBAL_LIST)
7014   | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
7016 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
7018 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
7019 GLOBAL_LIST   ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
7020 GLOBAL_ITEM   ::= NAME
7021 @end example
7023 For the semantics of this pragma, see the entry for aspect @code{Refined_Global} in
7024 the SPARK 2014 Reference Manual, section 6.1.4.
7026 @node Pragma Refined_Post,Pragma Refined_State,Pragma Refined_Global,Implementation Defined Pragmas
7027 @anchor{gnat_rm/implementation_defined_pragmas id36}@anchor{d5}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-post}@anchor{d6}
7028 @section Pragma Refined_Post
7031 Syntax:
7033 @example
7034 pragma Refined_Post (boolean_EXPRESSION);
7035 @end example
7037 For the semantics of this pragma, see the entry for aspect @code{Refined_Post} in
7038 the SPARK 2014 Reference Manual, section 7.2.7.
7040 @node Pragma Refined_State,Pragma Relative_Deadline,Pragma Refined_Post,Implementation Defined Pragmas
7041 @anchor{gnat_rm/implementation_defined_pragmas id37}@anchor{d7}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-state}@anchor{d8}
7042 @section Pragma Refined_State
7045 Syntax:
7047 @example
7048 pragma Refined_State (REFINEMENT_LIST);
7050 REFINEMENT_LIST ::=
7051   (REFINEMENT_CLAUSE @{, REFINEMENT_CLAUSE@})
7053 REFINEMENT_CLAUSE ::= state_NAME => CONSTITUENT_LIST
7055 CONSTITUENT_LIST ::=
7056      null
7057   |  CONSTITUENT
7058   | (CONSTITUENT @{, CONSTITUENT@})
7060 CONSTITUENT ::= object_NAME | state_NAME
7061 @end example
7063 For the semantics of this pragma, see the entry for aspect @code{Refined_State} in
7064 the SPARK 2014 Reference Manual, section 7.2.2.
7066 @node Pragma Relative_Deadline,Pragma Remote_Access_Type,Pragma Refined_State,Implementation Defined Pragmas
7067 @anchor{gnat_rm/implementation_defined_pragmas pragma-relative-deadline}@anchor{d9}
7068 @section Pragma Relative_Deadline
7071 Syntax:
7073 @example
7074 pragma Relative_Deadline (time_span_EXPRESSION);
7075 @end example
7077 This pragma is standard in Ada 2005, but is available in all earlier
7078 versions of Ada as an implementation-defined pragma.
7079 See Ada 2012 Reference Manual for details.
7081 @node Pragma Remote_Access_Type,Pragma Rename_Pragma,Pragma Relative_Deadline,Implementation Defined Pragmas
7082 @anchor{gnat_rm/implementation_defined_pragmas id38}@anchor{da}@anchor{gnat_rm/implementation_defined_pragmas pragma-remote-access-type}@anchor{db}
7083 @section Pragma Remote_Access_Type
7086 Syntax:
7088 @example
7089 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
7090 @end example
7092 This pragma appears in the formal part of a generic declaration.
7093 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
7094 the use of a remote access to class-wide type as actual for a formal
7095 access type.
7097 When this pragma applies to a formal access type @code{Entity}, that
7098 type is treated as a remote access to class-wide type in the generic.
7099 It must be a formal general access type, and its designated type must
7100 be the class-wide type of a formal tagged limited private type from the
7101 same generic declaration.
7103 In the generic unit, the formal type is subject to all restrictions
7104 pertaining to remote access to class-wide types. At instantiation, the
7105 actual type must be a remote access to class-wide type.
7107 @node Pragma Rename_Pragma,Pragma Restricted_Run_Time,Pragma Remote_Access_Type,Implementation Defined Pragmas
7108 @anchor{gnat_rm/implementation_defined_pragmas pragma-rename-pragma}@anchor{dc}
7109 @section Pragma Rename_Pragma
7112 @geindex Pragmas
7113 @geindex synonyms
7115 Syntax:
7117 @example
7118 pragma Rename_Pragma (
7119          [New_Name =>] IDENTIFIER,
7120          [Renamed  =>] pragma_IDENTIFIER);
7121 @end example
7123 This pragma provides a mechanism for supplying new names for existing
7124 pragmas. The @code{New_Name} identifier can subsequently be used as a synonym for
7125 the Renamed pragma. For example, suppose you have code that was originally
7126 developed on a compiler that supports Inline_Only as an implementation defined
7127 pragma. And suppose the semantics of pragma Inline_Only are identical to (or at
7128 least very similar to) the GNAT implementation defined pragma
7129 Inline_Always. You could globally replace Inline_Only with Inline_Always.
7131 However, to avoid that source modification, you could instead add a
7132 configuration pragma:
7134 @example
7135 pragma Rename_Pragma (
7136          New_Name => Inline_Only,
7137          Renamed  => Inline_Always);
7138 @end example
7140 Then GNAT will treat “pragma Inline_Only …” as if you had written
7141 “pragma Inline_Always …”.
7143 Pragma Inline_Only will not necessarily mean the same thing as the other Ada
7144 compiler; it’s up to you to make sure the semantics are close enough.
7146 @node Pragma Restricted_Run_Time,Pragma Restriction_Warnings,Pragma Rename_Pragma,Implementation Defined Pragmas
7147 @anchor{gnat_rm/implementation_defined_pragmas pragma-restricted-run-time}@anchor{dd}
7148 @section Pragma Restricted_Run_Time
7151 Syntax:
7153 @example
7154 pragma Restricted_Run_Time;
7155 @end example
7157 This pragma is considered obsolescent, but is retained for
7158 compatibility purposes. It is equivalent to:
7160 @example
7161 pragma Profile (Restricted);
7162 @end example
7164 which is the preferred method of setting the restricted run time
7165 profile.
7167 @node Pragma Restriction_Warnings,Pragma Reviewable,Pragma Restricted_Run_Time,Implementation Defined Pragmas
7168 @anchor{gnat_rm/implementation_defined_pragmas pragma-restriction-warnings}@anchor{de}
7169 @section Pragma Restriction_Warnings
7172 Syntax:
7174 @example
7175 pragma Restriction_Warnings
7176   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
7177 @end example
7179 This pragma allows a series of restriction identifiers to be
7180 specified (the list of allowed identifiers is the same as for
7181 pragma @code{Restrictions}). For each of these identifiers
7182 the compiler checks for violations of the restriction, but
7183 generates a warning message rather than an error message
7184 if the restriction is violated.
7186 One use of this is in situations where you want to know
7187 about violations of a restriction, but you want to ignore some of
7188 these violations. Consider this example, where you want to set
7189 Ada_95 mode and enable style checks, but you want to know about
7190 any other use of implementation pragmas:
7192 @example
7193 pragma Restriction_Warnings (No_Implementation_Pragmas);
7194 pragma Warnings (Off, "violation of No_Implementation_Pragmas");
7195 pragma Ada_95;
7196 pragma Style_Checks ("2bfhkM160");
7197 pragma Warnings (On, "violation of No_Implementation_Pragmas");
7198 @end example
7200 By including the above lines in a configuration pragmas file,
7201 the Ada_95 and Style_Checks pragmas are accepted without
7202 generating a warning, but any other use of implementation
7203 defined pragmas will cause a warning to be generated.
7205 @node Pragma Reviewable,Pragma Secondary_Stack_Size,Pragma Restriction_Warnings,Implementation Defined Pragmas
7206 @anchor{gnat_rm/implementation_defined_pragmas pragma-reviewable}@anchor{df}
7207 @section Pragma Reviewable
7210 Syntax:
7212 @example
7213 pragma Reviewable;
7214 @end example
7216 This pragma is an RM-defined standard pragma, but has no effect on the
7217 program being compiled, or on the code generated for the program.
7219 To obtain the required output specified in RM H.3.1, the compiler must be
7220 run with various special switches as follows:
7223 @itemize *
7225 @item 
7226 `Where compiler-generated run-time checks remain'
7228 The switch `-gnatGL'
7229 may be used to list the expanded code in pseudo-Ada form.
7230 Runtime checks show up in the listing either as explicit
7231 checks or operators marked with @{@} to indicate a check is present.
7233 @item 
7234 `An identification of known exceptions at compile time'
7236 If the program is compiled with `-gnatwa',
7237 the compiler warning messages will indicate all cases where the compiler
7238 detects that an exception is certain to occur at run time.
7240 @item 
7241 `Possible reads of uninitialized variables'
7243 The compiler warns of many such cases, but its output is incomplete.
7244 @end itemize
7247 A supplemental static analysis tool
7248 may be used to obtain a comprehensive list of all
7249 possible points at which uninitialized data may be read.
7252 @itemize *
7254 @item 
7255 `Where run-time support routines are implicitly invoked'
7257 In the output from `-gnatGL',
7258 run-time calls are explicitly listed as calls to the relevant
7259 run-time routine.
7261 @item 
7262 `Object code listing'
7264 This may be obtained either by using the `-S' switch,
7265 or the objdump utility.
7267 @item 
7268 `Constructs known to be erroneous at compile time'
7270 These are identified by warnings issued by the compiler (use `-gnatwa').
7272 @item 
7273 `Stack usage information'
7275 Static stack usage data (maximum per-subprogram) can be obtained via the
7276 `-fstack-usage' switch to the compiler.
7277 Dynamic stack usage data (per task) can be obtained via the `-u' switch
7278 to gnatbind
7279 @end itemize
7283 @itemize *
7285 @item 
7286 `Object code listing of entire partition'
7288 This can be obtained by compiling the partition with `-S',
7289 or by applying objdump
7290 to all the object files that are part of the partition.
7292 @item 
7293 `A description of the run-time model'
7295 The full sources of the run-time are available, and the documentation of
7296 these routines describes how these run-time routines interface to the
7297 underlying operating system facilities.
7299 @item 
7300 `Control and data-flow information'
7301 @end itemize
7304 A supplemental static analysis tool
7305 may be used to obtain complete control and data-flow information, as well as
7306 comprehensive messages identifying possible problems based on this
7307 information.
7309 @node Pragma Secondary_Stack_Size,Pragma Share_Generic,Pragma Reviewable,Implementation Defined Pragmas
7310 @anchor{gnat_rm/implementation_defined_pragmas id39}@anchor{e0}@anchor{gnat_rm/implementation_defined_pragmas pragma-secondary-stack-size}@anchor{e1}
7311 @section Pragma Secondary_Stack_Size
7314 Syntax:
7316 @example
7317 pragma Secondary_Stack_Size (integer_EXPRESSION);
7318 @end example
7320 This pragma appears within the task definition of a single task declaration
7321 or a task type declaration (like pragma @code{Storage_Size}) and applies to all
7322 task objects of that type. The argument specifies the size of the secondary
7323 stack to be used by these task objects, and must be of an integer type. The
7324 secondary stack is used to handle functions that return a variable-sized
7325 result, for example a function returning an unconstrained String.
7327 Note this pragma only applies to targets using fixed secondary stacks, like
7328 VxWorks 653 and bare board targets, where a fixed block for the
7329 secondary stack is allocated from the primary stack of the task. By default,
7330 these targets assign a percentage of the primary stack for the secondary stack,
7331 as defined by @code{System.Parameter.Sec_Stack_Percentage}. With this pragma,
7332 an @code{integer_EXPRESSION} of bytes is assigned from the primary stack instead.
7334 For most targets, the pragma does not apply as the secondary stack grows on
7335 demand: allocated as a chain of blocks in the heap. The default size of these
7336 blocks can be modified via the @code{-D} binder option as described in
7337 @cite{GNAT User’s Guide}.
7339 Note that no check is made to see if the secondary stack can fit inside the
7340 primary stack.
7342 Note the pragma cannot appear when the restriction @code{No_Secondary_Stack}
7343 is in effect.
7345 @node Pragma Share_Generic,Pragma Shared,Pragma Secondary_Stack_Size,Implementation Defined Pragmas
7346 @anchor{gnat_rm/implementation_defined_pragmas pragma-share-generic}@anchor{e2}
7347 @section Pragma Share_Generic
7350 Syntax:
7352 @example
7353 pragma Share_Generic (GNAME @{, GNAME@});
7355 GNAME ::= generic_unit_NAME | generic_instance_NAME
7356 @end example
7358 This pragma is provided for compatibility with Dec Ada 83. It has
7359 no effect in GNAT (which does not implement shared generics), other
7360 than to check that the given names are all names of generic units or
7361 generic instances.
7363 @node Pragma Shared,Pragma Short_Circuit_And_Or,Pragma Share_Generic,Implementation Defined Pragmas
7364 @anchor{gnat_rm/implementation_defined_pragmas id40}@anchor{e3}@anchor{gnat_rm/implementation_defined_pragmas pragma-shared}@anchor{e4}
7365 @section Pragma Shared
7368 This pragma is provided for compatibility with Ada 83. The syntax and
7369 semantics are identical to pragma Atomic.
7371 @node Pragma Short_Circuit_And_Or,Pragma Short_Descriptors,Pragma Shared,Implementation Defined Pragmas
7372 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-circuit-and-or}@anchor{e5}
7373 @section Pragma Short_Circuit_And_Or
7376 Syntax:
7378 @example
7379 pragma Short_Circuit_And_Or;
7380 @end example
7382 This configuration pragma causes any occurrence of the AND operator applied to
7383 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
7384 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
7385 may be useful in the context of certification protocols requiring the use of
7386 short-circuited logical operators. If this configuration pragma occurs locally
7387 within the file being compiled, it applies only to the file being compiled.
7388 There is no requirement that all units in a partition use this option.
7390 @node Pragma Short_Descriptors,Pragma Side_Effects,Pragma Short_Circuit_And_Or,Implementation Defined Pragmas
7391 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-descriptors}@anchor{e6}
7392 @section Pragma Short_Descriptors
7395 Syntax:
7397 @example
7398 pragma Short_Descriptors;
7399 @end example
7401 This pragma is provided for compatibility with other Ada implementations. It
7402 is recognized but ignored by all current versions of GNAT.
7404 @node Pragma Side_Effects,Pragma Simple_Storage_Pool_Type,Pragma Short_Descriptors,Implementation Defined Pragmas
7405 @anchor{gnat_rm/implementation_defined_pragmas id41}@anchor{e7}@anchor{gnat_rm/implementation_defined_pragmas pragma-side-effects}@anchor{e8}
7406 @section Pragma Side_Effects
7409 Syntax:
7411 @example
7412 pragma Side_Effects [ (static_boolean_EXPRESSION) ];
7413 @end example
7415 For the semantics of this pragma, see the entry for aspect
7416 @code{Side_Effects} in the SPARK Reference Manual, section 6.1.11.
7418 @node Pragma Simple_Storage_Pool_Type,Pragma Source_File_Name,Pragma Side_Effects,Implementation Defined Pragmas
7419 @anchor{gnat_rm/implementation_defined_pragmas id42}@anchor{e9}@anchor{gnat_rm/implementation_defined_pragmas pragma-simple-storage-pool-type}@anchor{ea}
7420 @section Pragma Simple_Storage_Pool_Type
7423 @geindex Storage pool
7424 @geindex simple
7426 @geindex Simple storage pool
7428 Syntax:
7430 @example
7431 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
7432 @end example
7434 A type can be established as a ‘simple storage pool type’ by applying
7435 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
7436 A type named in the pragma must be a library-level immutably limited record
7437 type or limited tagged type declared immediately within a package declaration.
7438 The type can also be a limited private type whose full type is allowed as
7439 a simple storage pool type.
7441 For a simple storage pool type @code{SSP}, nonabstract primitive subprograms
7442 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
7443 are subtype conformant with the following subprogram declarations:
7445 @example
7446 procedure Allocate
7447   (Pool                     : in out SSP;
7448    Storage_Address          : out System.Address;
7449    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7450    Alignment                : System.Storage_Elements.Storage_Count);
7452 procedure Deallocate
7453   (Pool : in out SSP;
7454    Storage_Address          : System.Address;
7455    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7456    Alignment                : System.Storage_Elements.Storage_Count);
7458 function Storage_Size (Pool : SSP)
7459   return System.Storage_Elements.Storage_Count;
7460 @end example
7462 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
7463 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
7464 applying an unchecked deallocation has no effect other than to set its actual
7465 parameter to null. If @code{Storage_Size} is not declared, then the
7466 @code{Storage_Size} attribute applied to an access type associated with
7467 a pool object of type SSP returns zero. Additional operations can be declared
7468 for a simple storage pool type (such as for supporting a mark/release
7469 storage-management discipline).
7471 An object of a simple storage pool type can be associated with an access
7472 type by specifying the attribute
7473 @ref{eb,,Simple_Storage_Pool}. For example:
7475 @example
7476 My_Pool : My_Simple_Storage_Pool_Type;
7478 type Acc is access My_Data_Type;
7480 for Acc'Simple_Storage_Pool use My_Pool;
7481 @end example
7483 See attribute @ref{eb,,Simple_Storage_Pool}
7484 for further details.
7486 @node Pragma Source_File_Name,Pragma Source_File_Name_Project,Pragma Simple_Storage_Pool_Type,Implementation Defined Pragmas
7487 @anchor{gnat_rm/implementation_defined_pragmas id43}@anchor{ec}@anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name}@anchor{ed}
7488 @section Pragma Source_File_Name
7491 Syntax:
7493 @example
7494 pragma Source_File_Name (
7495   [Unit_Name     =>] unit_NAME,
7496   Spec_File_Name =>  STRING_LITERAL,
7497   [Index => INTEGER_LITERAL]);
7499 pragma Source_File_Name (
7500   [Unit_Name     =>] unit_NAME,
7501   Body_File_Name =>  STRING_LITERAL,
7502   [Index => INTEGER_LITERAL]);
7503 @end example
7505 Use this to override the normal naming convention.  It is a configuration
7506 pragma, and so has the usual applicability of configuration pragmas
7507 (i.e., it applies to either an entire partition, or to all units in a
7508 compilation, or to a single unit, depending on how it is used).
7509 @code{unit_name} is mapped to @code{file_name_literal}.  The identifier for
7510 the second argument is required, and indicates whether this is the file
7511 name for the spec or for the body.
7513 The optional Index argument should be used when a file contains multiple
7514 units, and when you do not want to use @code{gnatchop} to separate then
7515 into multiple files (which is the recommended procedure to limit the
7516 number of recompilations that are needed when some sources change).
7517 For instance, if the source file @code{source.ada} contains
7519 @example
7520 package B is
7522 end B;
7524 with B;
7525 procedure A is
7526 begin
7527    ..
7528 end A;
7529 @end example
7531 you could use the following configuration pragmas:
7533 @example
7534 pragma Source_File_Name
7535   (B, Spec_File_Name => "source.ada", Index => 1);
7536 pragma Source_File_Name
7537   (A, Body_File_Name => "source.ada", Index => 2);
7538 @end example
7540 Note that the @code{gnatname} utility can also be used to generate those
7541 configuration pragmas.
7543 Another form of the @code{Source_File_Name} pragma allows
7544 the specification of patterns defining alternative file naming schemes
7545 to apply to all files.
7547 @example
7548 pragma Source_File_Name
7549   (  [Spec_File_Name  =>] STRING_LITERAL
7550    [,[Casing          =>] CASING_SPEC]
7551    [,[Dot_Replacement =>] STRING_LITERAL]);
7553 pragma Source_File_Name
7554   (  [Body_File_Name  =>] STRING_LITERAL
7555    [,[Casing          =>] CASING_SPEC]
7556    [,[Dot_Replacement =>] STRING_LITERAL]);
7558 pragma Source_File_Name
7559   (  [Subunit_File_Name =>] STRING_LITERAL
7560    [,[Casing            =>] CASING_SPEC]
7561    [,[Dot_Replacement   =>] STRING_LITERAL]);
7563 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
7564 @end example
7566 The first argument is a pattern that contains a single asterisk indicating
7567 the point at which the unit name is to be inserted in the pattern string
7568 to form the file name.  The second argument is optional.  If present it
7569 specifies the casing of the unit name in the resulting file name string.
7570 The default is lower case.  Finally the third argument allows for systematic
7571 replacement of any dots in the unit name by the specified string literal.
7573 Note that Source_File_Name pragmas should not be used if you are using
7574 project files. The reason for this rule is that the project manager is not
7575 aware of these pragmas, and so other tools that use the project file would not
7576 be aware of the intended naming conventions. If you are using project files,
7577 file naming is controlled by Source_File_Name_Project pragmas, which are
7578 usually supplied automatically by the project manager. A pragma
7579 Source_File_Name cannot appear after a @ref{ee,,Pragma Source_File_Name_Project}.
7581 For more details on the use of the @code{Source_File_Name} pragma, see the
7582 sections on @cite{Using Other File Names} and @cite{Alternative File Naming Schemes}
7583 in the @cite{GNAT User’s Guide}.
7585 @node Pragma Source_File_Name_Project,Pragma Source_Reference,Pragma Source_File_Name,Implementation Defined Pragmas
7586 @anchor{gnat_rm/implementation_defined_pragmas id44}@anchor{ef}@anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name-project}@anchor{ee}
7587 @section Pragma Source_File_Name_Project
7590 This pragma has the same syntax and semantics as pragma Source_File_Name.
7591 It is only allowed as a stand-alone configuration pragma.
7592 It cannot appear after a @ref{ed,,Pragma Source_File_Name}, and
7593 most importantly, once pragma Source_File_Name_Project appears,
7594 no further Source_File_Name pragmas are allowed.
7596 The intention is that Source_File_Name_Project pragmas are always
7597 generated by the Project Manager in a manner consistent with the naming
7598 specified in a project file, and when naming is controlled in this manner,
7599 it is not permissible to attempt to modify this naming scheme using
7600 Source_File_Name or Source_File_Name_Project pragmas (which would not be
7601 known to the project manager).
7603 @node Pragma Source_Reference,Pragma SPARK_Mode,Pragma Source_File_Name_Project,Implementation Defined Pragmas
7604 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-reference}@anchor{f0}
7605 @section Pragma Source_Reference
7608 Syntax:
7610 @example
7611 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
7612 @end example
7614 This pragma must appear as the first line of a source file.
7615 @code{integer_literal} is the logical line number of the line following
7616 the pragma line (for use in error messages and debugging
7617 information).  @code{string_literal} is a static string constant that
7618 specifies the file name to be used in error messages and debugging
7619 information.  This is most notably used for the output of @code{gnatchop}
7620 with the `-r' switch, to make sure that the original unchopped
7621 source file is the one referred to.
7623 The second argument must be a string literal, it cannot be a static
7624 string expression other than a string literal.  This is because its value
7625 is needed for error messages issued by all phases of the compiler.
7627 @node Pragma SPARK_Mode,Pragma Static_Elaboration_Desired,Pragma Source_Reference,Implementation Defined Pragmas
7628 @anchor{gnat_rm/implementation_defined_pragmas id45}@anchor{f1}@anchor{gnat_rm/implementation_defined_pragmas pragma-spark-mode}@anchor{f2}
7629 @section Pragma SPARK_Mode
7632 Syntax:
7634 @example
7635 pragma SPARK_Mode [(On | Off)] ;
7636 @end example
7638 In general a program can have some parts that are in SPARK 2014 (and
7639 follow all the rules in the SPARK Reference Manual), and some parts
7640 that are full Ada 2012.
7642 The SPARK_Mode pragma is used to identify which parts are in SPARK
7643 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
7644 be used in the following places:
7647 @itemize *
7649 @item 
7650 As a configuration pragma, in which case it sets the default mode for
7651 all units compiled with this pragma.
7653 @item 
7654 Immediately following a library-level subprogram spec
7656 @item 
7657 Immediately within a library-level package body
7659 @item 
7660 Immediately following the @code{private} keyword of a library-level
7661 package spec
7663 @item 
7664 Immediately following the @code{begin} keyword of a library-level
7665 package body
7667 @item 
7668 Immediately within a library-level subprogram body
7669 @end itemize
7671 Normally a subprogram or package spec/body inherits the current mode
7672 that is active at the point it is declared. But this can be overridden
7673 by pragma within the spec or body as above.
7675 The basic consistency rule is that you can’t turn SPARK_Mode back
7676 @code{On}, once you have explicitly (with a pragma) turned if
7677 @code{Off}. So the following rules apply:
7679 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
7680 also have SPARK_Mode @code{Off}.
7682 For a package, we have four parts:
7685 @itemize *
7687 @item 
7688 the package public declarations
7690 @item 
7691 the package private part
7693 @item 
7694 the body of the package
7696 @item 
7697 the elaboration code after @code{begin}
7698 @end itemize
7700 For a package, the rule is that if you explicitly turn SPARK_Mode
7701 @code{Off} for any part, then all the following parts must have
7702 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
7703 SPARK_Mode (@code{Off}) in the body. For example, if we have a
7704 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
7705 default everywhere, and one particular package spec has pragma
7706 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
7707 the package body.
7709 @node Pragma Static_Elaboration_Desired,Pragma Stream_Convert,Pragma SPARK_Mode,Implementation Defined Pragmas
7710 @anchor{gnat_rm/implementation_defined_pragmas pragma-static-elaboration-desired}@anchor{f3}
7711 @section Pragma Static_Elaboration_Desired
7714 Syntax:
7716 @example
7717 pragma Static_Elaboration_Desired;
7718 @end example
7720 This pragma is used to indicate that the compiler should attempt to initialize
7721 statically the objects declared in the library unit to which the pragma applies,
7722 when these objects are initialized (explicitly or implicitly) by an aggregate.
7723 In the absence of this pragma, aggregates in object declarations are expanded
7724 into assignments and loops, even when the aggregate components are static
7725 constants. When the aggregate is present the compiler builds a static expression
7726 that requires no run-time code, so that the initialized object can be placed in
7727 read-only data space. If the components are not static, or the aggregate has
7728 more that 100 components, the compiler emits a warning that the pragma cannot
7729 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
7730 construction of larger aggregates with static components that include an others
7731 choice.)
7733 @node Pragma Stream_Convert,Pragma Style_Checks,Pragma Static_Elaboration_Desired,Implementation Defined Pragmas
7734 @anchor{gnat_rm/implementation_defined_pragmas pragma-stream-convert}@anchor{f4}
7735 @section Pragma Stream_Convert
7738 Syntax:
7740 @example
7741 pragma Stream_Convert (
7742   [Entity =>] type_LOCAL_NAME,
7743   [Read   =>] function_NAME,
7744   [Write  =>] function_NAME);
7745 @end example
7747 This pragma provides an efficient way of providing user-defined stream
7748 attributes.  Not only is it simpler to use than specifying the attributes
7749 directly, but more importantly, it allows the specification to be made in such
7750 a way that the predefined unit Ada.Streams is not loaded unless it is actually
7751 needed (i.e. unless the stream attributes are actually used); the use of
7752 the Stream_Convert pragma adds no overhead at all, unless the stream
7753 attributes are actually used on the designated type.
7755 The first argument specifies the type for which stream functions are
7756 provided.  The second parameter provides a function used to read values
7757 of this type.  It must name a function whose argument type may be any
7758 subtype, and whose returned type must be the type given as the first
7759 argument to the pragma.
7761 The meaning of the @code{Read} parameter is that if a stream attribute directly
7762 or indirectly specifies reading of the type given as the first parameter,
7763 then a value of the type given as the argument to the Read function is
7764 read from the stream, and then the Read function is used to convert this
7765 to the required target type.
7767 Similarly the @code{Write} parameter specifies how to treat write attributes
7768 that directly or indirectly apply to the type given as the first parameter.
7769 It must have an input parameter of the type specified by the first parameter,
7770 and the return type must be the same as the input type of the Read function.
7771 The effect is to first call the Write function to convert to the given stream
7772 type, and then write the result type to the stream.
7774 The Read and Write functions must not be overloaded subprograms.  If necessary
7775 renamings can be supplied to meet this requirement.
7776 The usage of this attribute is best illustrated by a simple example, taken
7777 from the GNAT implementation of package Ada.Strings.Unbounded:
7779 @example
7780 function To_Unbounded (S : String) return Unbounded_String
7781   renames To_Unbounded_String;
7783 pragma Stream_Convert
7784   (Unbounded_String, To_Unbounded, To_String);
7785 @end example
7787 The specifications of the referenced functions, as given in the Ada
7788 Reference Manual are:
7790 @example
7791 function To_Unbounded_String (Source : String)
7792   return Unbounded_String;
7794 function To_String (Source : Unbounded_String)
7795   return String;
7796 @end example
7798 The effect is that if the value of an unbounded string is written to a stream,
7799 then the representation of the item in the stream is in the same format that
7800 would be used for @code{Standard.String'Output}, and this same representation
7801 is expected when a value of this type is read from the stream. Note that the
7802 value written always includes the bounds, even for Unbounded_String’Write,
7803 since Unbounded_String is not an array type.
7805 Note that the @code{Stream_Convert} pragma is not effective in the case of
7806 a derived type of a non-limited tagged type. If such a type is specified then
7807 the pragma is silently ignored, and the default implementation of the stream
7808 attributes is used instead.
7810 @node Pragma Style_Checks,Pragma Subtitle,Pragma Stream_Convert,Implementation Defined Pragmas
7811 @anchor{gnat_rm/implementation_defined_pragmas pragma-style-checks}@anchor{f5}
7812 @section Pragma Style_Checks
7815 Syntax:
7817 @example
7818 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
7819                      On | Off [, LOCAL_NAME]);
7820 @end example
7822 This pragma is used in conjunction with compiler switches to control the
7823 built in style checking provided by GNAT.  The compiler switches, if set,
7824 provide an initial setting for the switches, and this pragma may be used
7825 to modify these settings, or the settings may be provided entirely by
7826 the use of the pragma.  This pragma can be used anywhere that a pragma
7827 is legal, including use as a configuration pragma (including use in
7828 the @code{gnat.adc} file).
7830 The form with a string literal specifies which style options are to be
7831 activated.  These are additive, so they apply in addition to any previously
7832 set style check options.  The codes for the options are the same as those
7833 used in the `-gnaty' switch to `gcc' or `gnatmake'.
7834 For example the following two methods can be used to enable
7835 layout checking:
7838 @itemize *
7840 @item 
7841 @example
7842 pragma Style_Checks ("l");
7843 @end example
7845 @item 
7846 @example
7847 gcc -c -gnatyl ...
7848 @end example
7849 @end itemize
7851 The form @code{ALL_CHECKS} activates all standard checks (its use is equivalent
7852 to the use of the @code{gnaty} switch with no options.
7853 See the @cite{GNAT User’s Guide} for details.)
7855 Note: the behavior is slightly different in GNAT mode (@code{-gnatg} used).
7856 In this case, @code{ALL_CHECKS} implies the standard set of GNAT mode style check
7857 options (i.e. equivalent to @code{-gnatyg}).
7859 The forms with @code{Off} and @code{On}
7860 can be used to temporarily disable style checks
7861 as shown in the following example:
7863 @example
7864 pragma Style_Checks ("k"); -- requires keywords in lower case
7865 pragma Style_Checks (Off); -- turn off style checks
7866 NULL;                      -- this will not generate an error message
7867 pragma Style_Checks (On);  -- turn style checks back on
7868 NULL;                      -- this will generate an error message
7869 @end example
7871 Finally the two argument form is allowed only if the first argument is
7872 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
7873 for the specified entity, as shown in the following example:
7875 @example
7876 pragma Style_Checks ("r"); -- require consistency of identifier casing
7877 Arg : Integer;
7878 Rf1 : Integer := ARG;      -- incorrect, wrong case
7879 pragma Style_Checks (Off, Arg);
7880 Rf2 : Integer := ARG;      -- OK, no error
7881 @end example
7883 @node Pragma Subtitle,Pragma Suppress,Pragma Style_Checks,Implementation Defined Pragmas
7884 @anchor{gnat_rm/implementation_defined_pragmas pragma-subtitle}@anchor{f6}
7885 @section Pragma Subtitle
7888 Syntax:
7890 @example
7891 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
7892 @end example
7894 This pragma is recognized for compatibility with other Ada compilers
7895 but is ignored by GNAT.
7897 @node Pragma Suppress,Pragma Suppress_All,Pragma Subtitle,Implementation Defined Pragmas
7898 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress}@anchor{f7}
7899 @section Pragma Suppress
7902 Syntax:
7904 @example
7905 pragma Suppress (Identifier [, [On =>] Name]);
7906 @end example
7908 This is a standard pragma, and supports all the check names required in
7909 the RM. It is included here because GNAT recognizes some additional check
7910 names that are implementation defined (as permitted by the RM):
7913 @itemize *
7915 @item 
7916 @code{Alignment_Check} can be used to suppress alignment checks
7917 on addresses used in address clauses. Such checks can also be suppressed
7918 by suppressing range checks, but the specific use of @code{Alignment_Check}
7919 allows suppression of alignment checks without suppressing other range checks.
7920 Note that @code{Alignment_Check} is suppressed by default on machines (such as
7921 the x86) with non-strict alignment.
7923 @item 
7924 @code{Atomic_Synchronization} can be used to suppress the special memory
7925 synchronization instructions that are normally generated for access to
7926 @code{Atomic} variables to ensure correct synchronization between tasks
7927 that use such variables for synchronization purposes.
7929 @item 
7930 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
7931 for a duplicated tag value when a tagged type is declared.
7933 @item 
7934 @code{Container_Checks} Can be used to suppress all checks within Ada.Containers
7935 and instances of its children, including Tampering_Check.
7937 @item 
7938 @code{Tampering_Check} Can be used to suppress tampering check in the containers.
7940 @item 
7941 @code{Predicate_Check} can be used to control whether predicate checks are
7942 active. It is applicable only to predicates for which the policy is
7943 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
7944 predicate is ignored or checked for the whole program, the use of
7945 @code{Suppress} and @code{Unsuppress} with this check name allows a given
7946 predicate to be turned on and off at specific points in the program.
7948 @item 
7949 @code{Validity_Check} can be used specifically to control validity checks.
7950 If @code{Suppress} is used to suppress validity checks, then no validity
7951 checks are performed, including those specified by the appropriate compiler
7952 switch or the @code{Validity_Checks} pragma.
7954 @item 
7955 Additional check names previously introduced by use of the @code{Check_Name}
7956 pragma are also allowed.
7957 @end itemize
7959 Note that pragma Suppress gives the compiler permission to omit
7960 checks, but does not require the compiler to omit checks. The compiler
7961 will generate checks if they are essentially free, even when they are
7962 suppressed. In particular, if the compiler can prove that a certain
7963 check will necessarily fail, it will generate code to do an
7964 unconditional ‘raise’, even if checks are suppressed. The compiler
7965 warns in this case.
7967 Of course, run-time checks are omitted whenever the compiler can prove
7968 that they will not fail, whether or not checks are suppressed.
7970 @node Pragma Suppress_All,Pragma Suppress_Debug_Info,Pragma Suppress,Implementation Defined Pragmas
7971 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-all}@anchor{f8}
7972 @section Pragma Suppress_All
7975 Syntax:
7977 @example
7978 pragma Suppress_All;
7979 @end example
7981 This pragma can appear anywhere within a unit.
7982 The effect is to apply @code{Suppress (All_Checks)} to the unit
7983 in which it appears.  This pragma is implemented for compatibility with DEC
7984 Ada 83 usage where it appears at the end of a unit, and for compatibility
7985 with Rational Ada, where it appears as a program unit pragma.
7986 The use of the standard Ada pragma @code{Suppress (All_Checks)}
7987 as a normal configuration pragma is the preferred usage in GNAT.
7989 @node Pragma Suppress_Debug_Info,Pragma Suppress_Exception_Locations,Pragma Suppress_All,Implementation Defined Pragmas
7990 @anchor{gnat_rm/implementation_defined_pragmas id46}@anchor{f9}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-debug-info}@anchor{fa}
7991 @section Pragma Suppress_Debug_Info
7994 Syntax:
7996 @example
7997 pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7998 @end example
8000 This pragma can be used to suppress generation of debug information
8001 for the specified entity. It is intended primarily for use in debugging
8002 the debugger, and navigating around debugger problems.
8004 @node Pragma Suppress_Exception_Locations,Pragma Suppress_Initialization,Pragma Suppress_Debug_Info,Implementation Defined Pragmas
8005 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-exception-locations}@anchor{fb}
8006 @section Pragma Suppress_Exception_Locations
8009 Syntax:
8011 @example
8012 pragma Suppress_Exception_Locations;
8013 @end example
8015 In normal mode, a raise statement for an exception by default generates
8016 an exception message giving the file name and line number for the location
8017 of the raise. This is useful for debugging and logging purposes, but this
8018 entails extra space for the strings for the messages. The configuration
8019 pragma @code{Suppress_Exception_Locations} can be used to suppress the
8020 generation of these strings, with the result that space is saved, but the
8021 exception message for such raises is null. This configuration pragma may
8022 appear in a global configuration pragma file, or in a specific unit as
8023 usual. It is not required that this pragma be used consistently within
8024 a partition, so it is fine to have some units within a partition compiled
8025 with this pragma and others compiled in normal mode without it.
8027 @node Pragma Suppress_Initialization,Pragma Task_Name,Pragma Suppress_Exception_Locations,Implementation Defined Pragmas
8028 @anchor{gnat_rm/implementation_defined_pragmas id47}@anchor{fc}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-initialization}@anchor{fd}
8029 @section Pragma Suppress_Initialization
8032 @geindex Suppressing initialization
8034 @geindex Initialization
8035 @geindex suppression of
8037 Syntax:
8039 @example
8040 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
8041 @end example
8043 Here variable_or_subtype_Name is the name introduced by a type declaration
8044 or subtype declaration or the name of a variable introduced by an
8045 object declaration.
8047 In the case of a type or subtype
8048 this pragma suppresses any implicit or explicit initialization
8049 for all variables of the given type or subtype,
8050 including initialization resulting from the use of pragmas
8051 Normalize_Scalars or Initialize_Scalars.
8053 This is considered a representation item, so it cannot be given after
8054 the type is frozen. It applies to all subsequent object declarations,
8055 and also any allocator that creates objects of the type.
8057 If the pragma is given for the first subtype, then it is considered
8058 to apply to the base type and all its subtypes. If the pragma is given
8059 for other than a first subtype, then it applies only to the given subtype.
8060 The pragma may not be given after the type is frozen.
8062 Note that this includes eliminating initialization of discriminants
8063 for discriminated types, and tags for tagged types. In these cases,
8064 you will have to use some non-portable mechanism (e.g. address
8065 overlays or unchecked conversion) to achieve required initialization
8066 of these fields before accessing any object of the corresponding type.
8068 For the variable case, implicit initialization for the named variable
8069 is suppressed, just as though its subtype had been given in a pragma
8070 Suppress_Initialization, as described above.
8072 @node Pragma Task_Name,Pragma Task_Storage,Pragma Suppress_Initialization,Implementation Defined Pragmas
8073 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-name}@anchor{fe}
8074 @section Pragma Task_Name
8077 Syntax
8079 @example
8080 pragma Task_Name (string_EXPRESSION);
8081 @end example
8083 This pragma appears within a task definition (like pragma
8084 @code{Priority}) and applies to the task in which it appears.  The
8085 argument must be of type String, and provides a name to be used for
8086 the task instance when the task is created.  Note that this expression
8087 is not required to be static, and in particular, it can contain
8088 references to task discriminants.  This facility can be used to
8089 provide different names for different tasks as they are created,
8090 as illustrated in the example below.
8092 The task name is recorded internally in the run-time structures
8093 and is accessible to tools like the debugger.  In addition the
8094 routine @code{Ada.Task_Identification.Image} will return this
8095 string, with a unique task address appended.
8097 @example
8098 --  Example of the use of pragma Task_Name
8100 with Ada.Task_Identification;
8101 use Ada.Task_Identification;
8102 with Text_IO; use Text_IO;
8103 procedure t3 is
8105    type Astring is access String;
8107    task type Task_Typ (Name : access String) is
8108       pragma Task_Name (Name.all);
8109    end Task_Typ;
8111    task body Task_Typ is
8112       Nam : constant String := Image (Current_Task);
8113    begin
8114       Put_Line ("-->" & Nam (1 .. 14) & "<--");
8115    end Task_Typ;
8117    type Ptr_Task is access Task_Typ;
8118    Task_Var : Ptr_Task;
8120 begin
8121    Task_Var :=
8122      new Task_Typ (new String'("This is task 1"));
8123    Task_Var :=
8124      new Task_Typ (new String'("This is task 2"));
8125 end;
8126 @end example
8128 @node Pragma Task_Storage,Pragma Test_Case,Pragma Task_Name,Implementation Defined Pragmas
8129 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-storage}@anchor{ff}
8130 @section Pragma Task_Storage
8133 Syntax:
8135 @example
8136 pragma Task_Storage (
8137   [Task_Type =>] LOCAL_NAME,
8138   [Top_Guard =>] static_integer_EXPRESSION);
8139 @end example
8141 This pragma specifies the length of the guard area for tasks.  The guard
8142 area is an additional storage area allocated to a task.  A value of zero
8143 means that either no guard area is created or a minimal guard area is
8144 created, depending on the target.  This pragma can appear anywhere a
8145 @code{Storage_Size} attribute definition clause is allowed for a task
8146 type.
8148 @node Pragma Test_Case,Pragma Thread_Local_Storage,Pragma Task_Storage,Implementation Defined Pragmas
8149 @anchor{gnat_rm/implementation_defined_pragmas id48}@anchor{100}@anchor{gnat_rm/implementation_defined_pragmas pragma-test-case}@anchor{101}
8150 @section Pragma Test_Case
8153 @geindex Test cases
8155 Syntax:
8157 @example
8158 pragma Test_Case (
8159    [Name     =>] static_string_Expression
8160   ,[Mode     =>] (Nominal | Robustness)
8161  [, Requires =>  Boolean_Expression]
8162  [, Ensures  =>  Boolean_Expression]);
8163 @end example
8165 The @code{Test_Case} pragma allows defining fine-grain specifications
8166 for use by testing tools.
8167 The compiler checks the validity of the @code{Test_Case} pragma, but its
8168 presence does not lead to any modification of the code generated by the
8169 compiler.
8171 @code{Test_Case} pragmas may only appear immediately following the
8172 (separate) declaration of a subprogram in a package declaration, inside
8173 a package spec unit. Only other pragmas may intervene (that is appear
8174 between the subprogram declaration and a test case).
8176 The compiler checks that boolean expressions given in @code{Requires} and
8177 @code{Ensures} are valid, where the rules for @code{Requires} are the
8178 same as the rule for an expression in @code{Precondition} and the rules
8179 for @code{Ensures} are the same as the rule for an expression in
8180 @code{Postcondition}. In particular, attributes @code{'Old} and
8181 @code{'Result} can only be used within the @code{Ensures}
8182 expression. The following is an example of use within a package spec:
8184 @example
8185 package Math_Functions is
8186    ...
8187    function Sqrt (Arg : Float) return Float;
8188    pragma Test_Case (Name     => "Test 1",
8189                      Mode     => Nominal,
8190                      Requires => Arg < 10000.0,
8191                      Ensures  => Sqrt'Result < 10.0);
8192    ...
8193 end Math_Functions;
8194 @end example
8196 The meaning of a test case is that there is at least one context where
8197 @code{Requires} holds such that, if the associated subprogram is executed in
8198 that context, then @code{Ensures} holds when the subprogram returns.
8199 Mode @code{Nominal} indicates that the input context should also satisfy the
8200 precondition of the subprogram, and the output context should also satisfy its
8201 postcondition. Mode @code{Robustness} indicates that the precondition and
8202 postcondition of the subprogram should be ignored for this test case.
8204 @node Pragma Thread_Local_Storage,Pragma Time_Slice,Pragma Test_Case,Implementation Defined Pragmas
8205 @anchor{gnat_rm/implementation_defined_pragmas id49}@anchor{102}@anchor{gnat_rm/implementation_defined_pragmas pragma-thread-local-storage}@anchor{103}
8206 @section Pragma Thread_Local_Storage
8209 @geindex Task specific storage
8211 @geindex TLS (Thread Local Storage)
8213 @geindex Task_Attributes
8215 Syntax:
8217 @example
8218 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
8219 @end example
8221 This pragma specifies that the specified entity, which must be
8222 a variable declared in a library-level package, is to be marked as
8223 “Thread Local Storage” (@code{TLS}). On systems supporting this (which
8224 include Windows, Solaris, GNU/Linux, and VxWorks), this causes each
8225 thread (and hence each Ada task) to see a distinct copy of the variable.
8227 The variable must not have default initialization, and if there is
8228 an explicit initialization, it must be either @code{null} for an
8229 access variable, a static expression for a scalar variable, or a fully
8230 static aggregate for a composite type, that is to say, an aggregate all
8231 of whose components are static, and which does not include packed or
8232 discriminated components.
8234 This provides a low-level mechanism similar to that provided by
8235 the @code{Ada.Task_Attributes} package, but much more efficient
8236 and is also useful in writing interface code that will interact
8237 with foreign threads.
8239 If this pragma is used on a system where @code{TLS} is not supported,
8240 then an error message will be generated and the program will be rejected.
8242 @node Pragma Time_Slice,Pragma Title,Pragma Thread_Local_Storage,Implementation Defined Pragmas
8243 @anchor{gnat_rm/implementation_defined_pragmas pragma-time-slice}@anchor{104}
8244 @section Pragma Time_Slice
8247 Syntax:
8249 @example
8250 pragma Time_Slice (static_duration_EXPRESSION);
8251 @end example
8253 For implementations of GNAT on operating systems where it is possible
8254 to supply a time slice value, this pragma may be used for this purpose.
8255 It is ignored if it is used in a system that does not allow this control,
8256 or if it appears in other than the main program unit.
8258 @node Pragma Title,Pragma Type_Invariant,Pragma Time_Slice,Implementation Defined Pragmas
8259 @anchor{gnat_rm/implementation_defined_pragmas pragma-title}@anchor{105}
8260 @section Pragma Title
8263 Syntax:
8265 @example
8266 pragma Title (TITLING_OPTION [, TITLING OPTION]);
8268 TITLING_OPTION ::=
8269   [Title    =>] STRING_LITERAL,
8270 | [Subtitle =>] STRING_LITERAL
8271 @end example
8273 Syntax checked but otherwise ignored by GNAT.  This is a listing control
8274 pragma used in DEC Ada 83 implementations to provide a title and/or
8275 subtitle for the program listing.  The program listing generated by GNAT
8276 does not have titles or subtitles.
8278 Unlike other pragmas, the full flexibility of named notation is allowed
8279 for this pragma, i.e., the parameters may be given in any order if named
8280 notation is used, and named and positional notation can be mixed
8281 following the normal rules for procedure calls in Ada.
8283 @node Pragma Type_Invariant,Pragma Type_Invariant_Class,Pragma Title,Implementation Defined Pragmas
8284 @anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant}@anchor{106}
8285 @section Pragma Type_Invariant
8288 Syntax:
8290 @example
8291 pragma Type_Invariant
8292   ([Entity =>] type_LOCAL_NAME,
8293    [Check  =>] EXPRESSION);
8294 @end example
8296 The @code{Type_Invariant} pragma is intended to be an exact
8297 replacement for the language-defined @code{Type_Invariant}
8298 aspect, and shares its restrictions and semantics. It differs
8299 from the language defined @code{Invariant} pragma in that it
8300 does not permit a string parameter, and it is
8301 controlled by the assertion identifier @code{Type_Invariant}
8302 rather than @code{Invariant}.
8304 @node Pragma Type_Invariant_Class,Pragma Unchecked_Union,Pragma Type_Invariant,Implementation Defined Pragmas
8305 @anchor{gnat_rm/implementation_defined_pragmas id50}@anchor{107}@anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant-class}@anchor{108}
8306 @section Pragma Type_Invariant_Class
8309 Syntax:
8311 @example
8312 pragma Type_Invariant_Class
8313   ([Entity =>] type_LOCAL_NAME,
8314    [Check  =>] EXPRESSION);
8315 @end example
8317 The @code{Type_Invariant_Class} pragma is intended to be an exact
8318 replacement for the language-defined @code{Type_Invariant'Class}
8319 aspect, and shares its restrictions and semantics.
8321 Note: This pragma is called @code{Type_Invariant_Class} rather than
8322 @code{Type_Invariant'Class} because the latter would not be strictly
8323 conforming to the allowed syntax for pragmas. The motivation
8324 for providing pragmas equivalent to the aspects is to allow a program
8325 to be written using the pragmas, and then compiled if necessary
8326 using an Ada compiler that does not recognize the pragmas or
8327 aspects, but is prepared to ignore the pragmas. The assertion
8328 policy that controls this pragma is @code{Type_Invariant'Class},
8329 not @code{Type_Invariant_Class}.
8331 @node Pragma Unchecked_Union,Pragma Unevaluated_Use_Of_Old,Pragma Type_Invariant_Class,Implementation Defined Pragmas
8332 @anchor{gnat_rm/implementation_defined_pragmas pragma-unchecked-union}@anchor{109}
8333 @section Pragma Unchecked_Union
8336 @geindex Unions in C
8338 Syntax:
8340 @example
8341 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
8342 @end example
8344 This pragma is used to specify a representation of a record type that is
8345 equivalent to a C union. It was introduced as a GNAT implementation defined
8346 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
8347 pragma, making it language defined, and GNAT fully implements this extended
8348 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
8349 details, consult the Ada 2012 Reference Manual, section B.3.3.
8351 @node Pragma Unevaluated_Use_Of_Old,Pragma User_Aspect_Definition,Pragma Unchecked_Union,Implementation Defined Pragmas
8352 @anchor{gnat_rm/implementation_defined_pragmas pragma-unevaluated-use-of-old}@anchor{10a}
8353 @section Pragma Unevaluated_Use_Of_Old
8356 @geindex Attribute Old
8358 @geindex Attribute Loop_Entry
8360 @geindex Unevaluated_Use_Of_Old
8362 Syntax:
8364 @example
8365 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
8366 @end example
8368 This pragma controls the processing of attributes Old and Loop_Entry.
8369 If either of these attributes is used in a potentially unevaluated
8370 expression  (e.g. the then or else parts of an if expression), then
8371 normally this usage is considered illegal if the prefix of the attribute
8372 is other than an entity name. The language requires this
8373 behavior for Old, and GNAT copies the same rule for Loop_Entry.
8375 The reason for this rule is that otherwise, we can have a situation
8376 where we save the Old value, and this results in an exception, even
8377 though we might not evaluate the attribute. Consider this example:
8379 @example
8380 package UnevalOld is
8381    K : Character;
8382    procedure U (A : String; C : Boolean)  -- ERROR
8383      with Post => (if C then A(1)'Old = K else True);
8384 end;
8385 @end example
8387 If procedure U is called with a string with a lower bound of 2, and
8388 C false, then an exception would be raised trying to evaluate A(1)
8389 on entry even though the value would not be actually used.
8391 Although the rule guarantees against this possibility, it is sometimes
8392 too restrictive. For example if we know that the string has a lower
8393 bound of 1, then we will never raise an exception.
8394 The pragma @code{Unevaluated_Use_Of_Old} can be
8395 used to modify this behavior. If the argument is @code{Error} then an
8396 error is given (this is the default RM behavior). If the argument is
8397 @code{Warn} then the usage is allowed as legal but with a warning
8398 that an exception might be raised. If the argument is @code{Allow}
8399 then the usage is allowed as legal without generating a warning.
8401 This pragma may appear as a configuration pragma, or in a declarative
8402 part or package specification. In the latter case it applies to
8403 uses up to the end of the corresponding statement sequence or
8404 sequence of package declarations.
8406 @node Pragma User_Aspect_Definition,Pragma Unimplemented_Unit,Pragma Unevaluated_Use_Of_Old,Implementation Defined Pragmas
8407 @anchor{gnat_rm/implementation_defined_pragmas pragma-user-aspect-definition}@anchor{10b}
8408 @section Pragma User_Aspect_Definition
8411 Syntax:
8413 @example
8414 pragma User_Aspect_Definition
8415   (Identifier @{, Identifier [(Identifier @{, Identifier@})]@});
8416 @end example
8418 This configuration pragma defines a new aspect, making it available for
8419 subsequent use in a User_Aspect aspect specification. The first
8420 identifier is the name of the new aspect. Any subsequent arguments
8421 specify the names of other aspects. A subsequent name for which no parenthesized
8422 arguments are given shall denote either a Boolean-valued
8423 non-representation aspect or an aspect that has been defined by another
8424 User_Aspect_Definition pragma. A name for which one or more arguments are
8425 given shall be either Annotate or Local_Restrictions (and the arguments shall
8426 be appropriate for the named aspect). This pragma, together with the
8427 User_Aspect aspect, provides a mechanism for
8428 avoiding textual duplication if some set of aspect specifications is needed
8429 in multiple places. This is somewhat analogous to how profiles allow avoiding
8430 duplication of Restrictions pragmas. The visibility rules for an aspect
8431 defined by a User_Aspect_Definition pragma are the same as for a check name
8432 introduced by a Check_Name pragma. If multiple
8433 definitions are visible for some aspect at some point, then the
8434 definitions must agree. A predefined aspect cannot be redefined.
8436 @node Pragma Unimplemented_Unit,Pragma Universal_Aliasing,Pragma User_Aspect_Definition,Implementation Defined Pragmas
8437 @anchor{gnat_rm/implementation_defined_pragmas pragma-unimplemented-unit}@anchor{10c}
8438 @section Pragma Unimplemented_Unit
8441 Syntax:
8443 @example
8444 pragma Unimplemented_Unit;
8445 @end example
8447 If this pragma occurs in a unit that is processed by the compiler, GNAT
8448 aborts with the message @code{xxx not implemented}, where
8449 @code{xxx} is the name of the current compilation unit.  This pragma is
8450 intended to allow the compiler to handle unimplemented library units in
8451 a clean manner.
8453 The abort only happens if code is being generated.  Thus you can use
8454 specs of unimplemented packages in syntax or semantic checking mode.
8456 @node Pragma Universal_Aliasing,Pragma Unmodified,Pragma Unimplemented_Unit,Implementation Defined Pragmas
8457 @anchor{gnat_rm/implementation_defined_pragmas id51}@anchor{10d}@anchor{gnat_rm/implementation_defined_pragmas pragma-universal-aliasing}@anchor{10e}
8458 @section Pragma Universal_Aliasing
8461 Syntax:
8463 @example
8464 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
8465 @end example
8467 @code{type_LOCAL_NAME} must refer to a type declaration in the current
8468 declarative part.  The effect is to inhibit strict type-based aliasing
8469 optimization for the given type.  In other words, the effect is as though
8470 access types designating this type were subject to pragma No_Strict_Aliasing.
8471 For a detailed description of the strict aliasing optimization, and the
8472 situations in which it must be suppressed, see the section on
8473 @code{Optimization and Strict Aliasing} in the @cite{GNAT User’s Guide}.
8475 @node Pragma Unmodified,Pragma Unreferenced,Pragma Universal_Aliasing,Implementation Defined Pragmas
8476 @anchor{gnat_rm/implementation_defined_pragmas id52}@anchor{10f}@anchor{gnat_rm/implementation_defined_pragmas pragma-unmodified}@anchor{110}
8477 @section Pragma Unmodified
8480 @geindex Warnings
8481 @geindex unmodified
8483 Syntax:
8485 @example
8486 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
8487 @end example
8489 This pragma signals that the assignable entities (variables,
8490 @code{out} parameters, @code{in out} parameters) whose names are listed are
8491 deliberately not assigned in the current source unit. This
8492 suppresses warnings about the
8493 entities being referenced but not assigned, and in addition a warning will be
8494 generated if one of these entities is in fact assigned in the
8495 same unit as the pragma (or in the corresponding body, or one
8496 of its subunits).
8498 This is particularly useful for clearly signaling that a particular
8499 parameter is not modified, even though the spec suggests that it might
8502 For the variable case, warnings are never given for unreferenced variables
8503 whose name contains one of the substrings
8504 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSE, TMP, TEMP} in any casing. Such names
8505 are typically to be used in cases where such warnings are expected.
8506 Thus it is never necessary to use @code{pragma Unmodified} for such
8507 variables, though it is harmless to do so.
8509 @node Pragma Unreferenced,Pragma Unreferenced_Objects,Pragma Unmodified,Implementation Defined Pragmas
8510 @anchor{gnat_rm/implementation_defined_pragmas id53}@anchor{111}@anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced}@anchor{112}
8511 @section Pragma Unreferenced
8514 @geindex Warnings
8515 @geindex unreferenced
8517 Syntax:
8519 @example
8520 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
8521 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
8522 @end example
8524 This pragma signals that the entities whose names are listed are
8525 deliberately not referenced in the current source unit after the
8526 occurrence of the pragma. This
8527 suppresses warnings about the
8528 entities being unreferenced, and in addition a warning will be
8529 generated if one of these entities is in fact subsequently referenced in the
8530 same unit as the pragma (or in the corresponding body, or one
8531 of its subunits).
8533 This is particularly useful for clearly signaling that a particular
8534 parameter is not referenced in some particular subprogram implementation
8535 and that this is deliberate. It can also be useful in the case of
8536 objects declared only for their initialization or finalization side
8537 effects.
8539 If @code{LOCAL_NAME} identifies more than one matching homonym in the
8540 current scope, then the entity most recently declared is the one to which
8541 the pragma applies. Note that in the case of accept formals, the pragma
8542 Unreferenced may appear immediately after the keyword @code{do} which
8543 allows the indication of whether or not accept formals are referenced
8544 or not to be given individually for each accept statement.
8546 The left hand side of an assignment does not count as a reference for the
8547 purpose of this pragma. Thus it is fine to assign to an entity for which
8548 pragma Unreferenced is given. However, use of an entity as an actual for
8549 an out parameter does count as a reference unless warnings for unread output
8550 parameters are enabled via @code{-gnatw.o}.
8552 Note that if a warning is desired for all calls to a given subprogram,
8553 regardless of whether they occur in the same unit as the subprogram
8554 declaration, then this pragma should not be used (calls from another
8555 unit would not be flagged); pragma Obsolescent can be used instead
8556 for this purpose, see @ref{b1,,Pragma Obsolescent}.
8558 The second form of pragma @code{Unreferenced} is used within a context
8559 clause. In this case the arguments must be unit names of units previously
8560 mentioned in @code{with} clauses (similar to the usage of pragma
8561 @code{Elaborate_All}). The effect is to suppress warnings about unreferenced
8562 units and unreferenced entities within these units.
8564 For the variable case, warnings are never given for unreferenced variables
8565 whose name contains one of the substrings
8566 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8567 are typically to be used in cases where such warnings are expected.
8568 Thus it is never necessary to use @code{pragma Unreferenced} for such
8569 variables, though it is harmless to do so.
8571 @node Pragma Unreferenced_Objects,Pragma Unreserve_All_Interrupts,Pragma Unreferenced,Implementation Defined Pragmas
8572 @anchor{gnat_rm/implementation_defined_pragmas id54}@anchor{113}@anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced-objects}@anchor{114}
8573 @section Pragma Unreferenced_Objects
8576 @geindex Warnings
8577 @geindex unreferenced
8579 Syntax:
8581 @example
8582 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
8583 @end example
8585 This pragma signals that for the types or subtypes whose names are
8586 listed, objects which are declared with one of these types or subtypes may
8587 not be referenced, and if no references appear, no warnings are given.
8589 This is particularly useful for objects which are declared solely for their
8590 initialization and finalization effect. Such variables are sometimes referred
8591 to as RAII variables (Resource Acquisition Is Initialization). Using this
8592 pragma on the relevant type (most typically a limited controlled type), the
8593 compiler will automatically suppress unwanted warnings about these variables
8594 not being referenced.
8596 @node Pragma Unreserve_All_Interrupts,Pragma Unsuppress,Pragma Unreferenced_Objects,Implementation Defined Pragmas
8597 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreserve-all-interrupts}@anchor{115}
8598 @section Pragma Unreserve_All_Interrupts
8601 Syntax:
8603 @example
8604 pragma Unreserve_All_Interrupts;
8605 @end example
8607 Normally certain interrupts are reserved to the implementation.  Any attempt
8608 to attach an interrupt causes Program_Error to be raised, as described in
8609 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
8610 many systems for a @code{Ctrl-C} interrupt.  Normally this interrupt is
8611 reserved to the implementation, so that @code{Ctrl-C} can be used to
8612 interrupt execution.
8614 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
8615 a program, then all such interrupts are unreserved.  This allows the
8616 program to handle these interrupts, but disables their standard
8617 functions.  For example, if this pragma is used, then pressing
8618 @code{Ctrl-C} will not automatically interrupt execution.  However,
8619 a program can then handle the @code{SIGINT} interrupt as it chooses.
8621 For a full list of the interrupts handled in a specific implementation,
8622 see the source code for the spec of @code{Ada.Interrupts.Names} in
8623 file @code{a-intnam.ads}.  This is a target dependent file that contains the
8624 list of interrupts recognized for a given target.  The documentation in
8625 this file also specifies what interrupts are affected by the use of
8626 the @code{Unreserve_All_Interrupts} pragma.
8628 For a more general facility for controlling what interrupts can be
8629 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
8630 of the @code{Unreserve_All_Interrupts} pragma.
8632 @node Pragma Unsuppress,Pragma Unused,Pragma Unreserve_All_Interrupts,Implementation Defined Pragmas
8633 @anchor{gnat_rm/implementation_defined_pragmas pragma-unsuppress}@anchor{116}
8634 @section Pragma Unsuppress
8637 Syntax:
8639 @example
8640 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8641 @end example
8643 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
8644 there is no corresponding pragma @code{Suppress} in effect, it has no
8645 effect.  The range of the effect is the same as for pragma
8646 @code{Suppress}.  The meaning of the arguments is identical to that used
8647 in pragma @code{Suppress}.
8649 One important application is to ensure that checks are on in cases where
8650 code depends on the checks for its correct functioning, so that the code
8651 will compile correctly even if the compiler switches are set to suppress
8652 checks. For example, in a program that depends on external names of tagged
8653 types and wants to ensure that the duplicated tag check occurs even if all
8654 run-time checks are suppressed by a compiler switch, the following
8655 configuration pragma will ensure this test is not suppressed:
8657 @example
8658 pragma Unsuppress (Duplicated_Tag_Check);
8659 @end example
8661 This pragma is standard in Ada 2005. It is available in all earlier versions
8662 of Ada as an implementation-defined pragma.
8664 Note that in addition to the checks defined in the Ada RM, GNAT recognizes a
8665 number of implementation-defined check names. See the description of pragma
8666 @code{Suppress} for full details.
8668 @node Pragma Unused,Pragma Use_VADS_Size,Pragma Unsuppress,Implementation Defined Pragmas
8669 @anchor{gnat_rm/implementation_defined_pragmas id55}@anchor{117}@anchor{gnat_rm/implementation_defined_pragmas pragma-unused}@anchor{118}
8670 @section Pragma Unused
8673 @geindex Warnings
8674 @geindex unused
8676 Syntax:
8678 @example
8679 pragma Unused (LOCAL_NAME @{, LOCAL_NAME@});
8680 @end example
8682 This pragma signals that the assignable entities (variables,
8683 @code{out} parameters, and @code{in out} parameters) whose names are listed
8684 deliberately do not get assigned or referenced in the current source unit
8685 after the occurrence of the pragma in the current source unit. This
8686 suppresses warnings about the entities that are unreferenced and/or not
8687 assigned, and, in addition, a warning will be generated if one of these
8688 entities gets assigned or subsequently referenced in the same unit as the
8689 pragma (in the corresponding body or one of its subunits).
8691 This is particularly useful for clearly signaling that a particular
8692 parameter is not modified or referenced, even though the spec suggests
8693 that it might be.
8695 For the variable case, warnings are never given for unreferenced
8696 variables whose name contains one of the substrings
8697 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8698 are typically to be used in cases where such warnings are expected.
8699 Thus it is never necessary to use @code{pragma Unused} for such
8700 variables, though it is harmless to do so.
8702 @node Pragma Use_VADS_Size,Pragma Validity_Checks,Pragma Unused,Implementation Defined Pragmas
8703 @anchor{gnat_rm/implementation_defined_pragmas pragma-use-vads-size}@anchor{119}
8704 @section Pragma Use_VADS_Size
8707 @geindex Size
8708 @geindex VADS compatibility
8710 @geindex Rational profile
8712 Syntax:
8714 @example
8715 pragma Use_VADS_Size;
8716 @end example
8718 This is a configuration pragma.  In a unit to which it applies, any use
8719 of the ‘Size attribute is automatically interpreted as a use of the
8720 ‘VADS_Size attribute.  Note that this may result in incorrect semantic
8721 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
8722 the handling of existing code which depends on the interpretation of Size
8723 as implemented in the VADS compiler.  See description of the VADS_Size
8724 attribute for further details.
8726 @node Pragma Validity_Checks,Pragma Volatile,Pragma Use_VADS_Size,Implementation Defined Pragmas
8727 @anchor{gnat_rm/implementation_defined_pragmas pragma-validity-checks}@anchor{11a}
8728 @section Pragma Validity_Checks
8731 Syntax:
8733 @example
8734 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
8735 @end example
8737 This pragma is used in conjunction with compiler switches to control the
8738 built-in validity checking provided by GNAT.  The compiler switches, if set
8739 provide an initial setting for the switches, and this pragma may be used
8740 to modify these settings, or the settings may be provided entirely by
8741 the use of the pragma.  This pragma can be used anywhere that a pragma
8742 is legal, including use as a configuration pragma (including use in
8743 the @code{gnat.adc} file).
8745 The form with a string literal specifies which validity options are to be
8746 activated.  The validity checks are first set to include only the default
8747 reference manual settings, and then a string of letters in the string
8748 specifies the exact set of options required.  The form of this string
8749 is exactly as described for the `-gnatVx' compiler switch (see the
8750 GNAT User’s Guide for details).  For example the following two
8751 methods can be used to enable validity checking for mode @code{in} and
8752 @code{in out} subprogram parameters:
8755 @itemize *
8757 @item 
8758 @example
8759 pragma Validity_Checks ("im");
8760 @end example
8762 @item 
8763 @example
8764 $ gcc -c -gnatVim ...
8765 @end example
8766 @end itemize
8768 The form ALL_CHECKS activates all standard checks (its use is equivalent
8769 to the use of the @code{gnatVa} switch).
8771 The forms with @code{Off} and @code{On} can be used to temporarily disable
8772 validity checks as shown in the following example:
8774 @example
8775 pragma Validity_Checks ("c"); -- validity checks for copies
8776 pragma Validity_Checks (Off); -- turn off validity checks
8777 A := B;                       -- B will not be validity checked
8778 pragma Validity_Checks (On);  -- turn validity checks back on
8779 A := C;                       -- C will be validity checked
8780 @end example
8782 @node Pragma Volatile,Pragma Volatile_Full_Access,Pragma Validity_Checks,Implementation Defined Pragmas
8783 @anchor{gnat_rm/implementation_defined_pragmas id56}@anchor{11b}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile}@anchor{11c}
8784 @section Pragma Volatile
8787 Syntax:
8789 @example
8790 pragma Volatile (LOCAL_NAME);
8791 @end example
8793 This pragma is defined by the Ada Reference Manual, and the GNAT
8794 implementation is fully conformant with this definition.  The reason it
8795 is mentioned in this section is that a pragma of the same name was supplied
8796 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
8797 implementation of pragma Volatile is upwards compatible with the
8798 implementation in DEC Ada 83.
8800 @node Pragma Volatile_Full_Access,Pragma Volatile_Function,Pragma Volatile,Implementation Defined Pragmas
8801 @anchor{gnat_rm/implementation_defined_pragmas id57}@anchor{11d}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-full-access}@anchor{11e}
8802 @section Pragma Volatile_Full_Access
8805 Syntax:
8807 @example
8808 pragma Volatile_Full_Access (LOCAL_NAME);
8809 @end example
8811 This is similar in effect to pragma Volatile, except that any reference to the
8812 object is guaranteed to be done only with instructions that read or write all
8813 the bits of the object. Furthermore, if the object is of a composite type,
8814 then any reference to a subcomponent of the object is guaranteed to read
8815 and/or write all the bits of the object.
8817 The intention is that this be suitable for use with memory-mapped I/O devices
8818 on some machines. Note that there are two important respects in which this is
8819 different from @code{pragma Atomic}. First a reference to a @code{Volatile_Full_Access}
8820 object is not a sequential action in the RM 9.10 sense and, therefore, does
8821 not create a synchronization point. Second, in the case of @code{pragma Atomic},
8822 there is no guarantee that all the bits will be accessed if the reference
8823 is not to the whole object; the compiler is allowed (and generally will)
8824 access only part of the object in this case.
8826 @node Pragma Volatile_Function,Pragma Warning_As_Error,Pragma Volatile_Full_Access,Implementation Defined Pragmas
8827 @anchor{gnat_rm/implementation_defined_pragmas id58}@anchor{11f}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-function}@anchor{120}
8828 @section Pragma Volatile_Function
8831 Syntax:
8833 @example
8834 pragma Volatile_Function [ (static_boolean_EXPRESSION) ];
8835 @end example
8837 For the semantics of this pragma, see the entry for aspect @code{Volatile_Function}
8838 in the SPARK 2014 Reference Manual, section 7.1.2.
8840 @node Pragma Warning_As_Error,Pragma Warnings,Pragma Volatile_Function,Implementation Defined Pragmas
8841 @anchor{gnat_rm/implementation_defined_pragmas pragma-warning-as-error}@anchor{121}
8842 @section Pragma Warning_As_Error
8845 Syntax:
8847 @example
8848 pragma Warning_As_Error (static_string_EXPRESSION);
8849 @end example
8851 This configuration pragma allows the programmer to specify a set
8852 of warnings that will be treated as errors. Any warning that
8853 matches the pattern given by the pragma argument will be treated
8854 as an error. This gives more precise control than -gnatwe,
8855 which treats warnings as errors.
8857 This pragma can apply to regular warnings (messages enabled by -gnatw)
8858 and to style warnings (messages that start with “(style)”,
8859 enabled by -gnaty).
8861 The pattern may contain asterisks, which match zero or more characters
8862 in the message. For example, you can use @code{pragma Warning_As_Error
8863 ("bits of*unused")} to treat the warning message @code{warning: 960 bits of
8864 "a" unused} as an error. All characters other than asterisk are treated
8865 as literal characters in the match. The match is case insensitive; for
8866 example XYZ matches xyz.
8868 Note that the pattern matches if it occurs anywhere within the warning
8869 message string (it is not necessary to put an asterisk at the start and
8870 the end of the message, since this is implied).
8872 Another possibility for the static_string_EXPRESSION which works whether
8873 or not error tags are enabled (`-gnatw.d') is to use a single
8874 `-gnatw' tag string, enclosed in brackets,
8875 as shown in the example below, to treat one category of warnings as errors.
8876 Note that if you want to treat multiple categories of warnings as errors,
8877 you can use multiple pragma Warning_As_Error.
8879 The above use of patterns to match the message applies only to warning
8880 messages generated by the front end. This pragma can also be applied to
8881 warnings provided by the back end and mentioned in @ref{122,,Pragma Warnings}.
8882 By using a single full `-Wxxx' switch in the pragma, such warnings
8883 can also be treated as errors.
8885 The pragma can appear either in a global configuration pragma file
8886 (e.g. @code{gnat.adc}), or at the start of a file. Given a global
8887 configuration pragma file containing:
8889 @example
8890 pragma Warning_As_Error ("[-gnatwj]");
8891 @end example
8893 which will treat all obsolescent feature warnings as errors, the
8894 following program compiles as shown (compile options here are
8895 `-gnatwa.d -gnatl -gnatj55').
8897 @example
8898     1. pragma Warning_As_Error ("*never assigned*");
8899     2. function Warnerr return String is
8900     3.    X : Integer;
8901           |
8902        >>> error: variable "X" is never read and
8903            never assigned [-gnatwv] [warning-as-error]
8905     4.    Y : Integer;
8906           |
8907        >>> warning: variable "Y" is assigned but
8908            never read [-gnatwu]
8910     5. begin
8911     6.    Y := 0;
8912     7.    return %ABC%;
8913                  |
8914        >>> error: use of "%" is an obsolescent
8915            feature (RM J.2(4)), use """ instead
8916            [-gnatwj] [warning-as-error]
8918     8. end;
8920 8 lines: No errors, 3 warnings (2 treated as errors)
8921 @end example
8923 Note that this pragma does not affect the set of warnings issued in
8924 any way, it merely changes the effect of a matching warning if one
8925 is produced as a result of other warnings options. As shown in this
8926 example, if the pragma results in a warning being treated as an error,
8927 the tag is changed from “warning:” to “error:” and the string
8928 “[warning-as-error]” is appended to the end of the message.
8930 @node Pragma Warnings,Pragma Weak_External,Pragma Warning_As_Error,Implementation Defined Pragmas
8931 @anchor{gnat_rm/implementation_defined_pragmas id59}@anchor{123}@anchor{gnat_rm/implementation_defined_pragmas pragma-warnings}@anchor{122}
8932 @section Pragma Warnings
8935 Syntax:
8937 @example
8938 pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
8940 DETAILS ::= On | Off
8941 DETAILS ::= On | Off, local_NAME
8942 DETAILS ::= static_string_EXPRESSION
8943 DETAILS ::= On | Off, static_string_EXPRESSION
8945 TOOL_NAME ::= GNAT | GNATprove
8947 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
8948 @end example
8950 Note: in Ada 83 mode, a string literal may be used in place of a static string
8951 expression (which does not exist in Ada 83).
8953 Note if the second argument of @code{DETAILS} is a @code{local_NAME} then the
8954 second form is always understood. If the intention is to use
8955 the fourth form, then you can write @code{NAME & ""} to force the
8956 interpretation as a `static_string_EXPRESSION'.
8958 Note: if the first argument is a valid @code{TOOL_NAME}, it will be interpreted
8959 that way. The use of the @code{TOOL_NAME} argument is relevant only to users
8960 of SPARK and GNATprove, see last part of this section for details.
8962 Normally warnings are enabled, with the output being controlled by
8963 the command line switch.  Warnings (@code{Off}) turns off generation of
8964 warnings until a Warnings (@code{On}) is encountered or the end of the
8965 current unit.  If generation of warnings is turned off using this
8966 pragma, then some or all of the warning messages are suppressed,
8967 regardless of the setting of the command line switches.
8969 The @code{Reason} parameter may optionally appear as the last argument
8970 in any of the forms of this pragma. It is intended purely for the
8971 purposes of documenting the reason for the @code{Warnings} pragma.
8972 The compiler will check that the argument is a static string but
8973 otherwise ignore this argument. Other tools may provide specialized
8974 processing for this string.
8976 The form with a single argument (or two arguments if Reason present),
8977 where the first argument is @code{ON} or @code{OFF}
8978 may be used as a configuration pragma.
8980 If the @code{LOCAL_NAME} parameter is present, warnings are suppressed for
8981 the specified entity.  This suppression is effective from the point where
8982 it occurs till the end of the extended scope of the variable (similar to
8983 the scope of @code{Suppress}). This form cannot be used as a configuration
8984 pragma.
8986 In the case where the first argument is other than @code{ON} or
8987 @code{OFF},
8988 the third form with a single static_string_EXPRESSION argument (and possible
8989 reason) provides more precise
8990 control over which warnings are active. The string is a list of letters
8991 specifying which warnings are to be activated and which deactivated. The
8992 code for these letters is the same as the string used in the command
8993 line switch controlling warnings. For a brief summary, use the gnatmake
8994 command with no arguments, which will generate usage information containing
8995 the list of warnings switches supported. For
8996 full details see the section on @code{Warning Message Control} in the
8997 @cite{GNAT User’s Guide}.
8998 This form can also be used as a configuration pragma.
9000 The warnings controlled by the @code{-gnatw} switch are generated by the
9001 front end of the compiler. The GCC back end can provide additional warnings
9002 and they are controlled by the @code{-W} switch. Such warnings can be
9003 identified by the appearance of a string of the form @code{[-W@{xxx@}]} in the
9004 message which designates the @code{-W`xxx'} switch that controls the message.
9005 The form with a single `static_string_EXPRESSION' argument also works for these
9006 warnings, but the string must be a single full @code{-W`xxx'} switch in this
9007 case. The above reference lists a few examples of these additional warnings.
9009 The specified warnings will be in effect until the end of the program
9010 or another pragma @code{Warnings} is encountered. The effect of the pragma is
9011 cumulative. Initially the set of warnings is the standard default set
9012 as possibly modified by compiler switches. Then each pragma Warning
9013 modifies this set of warnings as specified. This form of the pragma may
9014 also be used as a configuration pragma.
9016 The fourth form, with an @code{On|Off} parameter and a string, is used to
9017 control individual messages, based on their text. The string argument
9018 is a pattern that is used to match against the text of individual
9019 warning messages (not including the initial “warning: ” tag).
9021 The pattern may contain asterisks, which match zero or more characters in
9022 the message. For example, you can use
9023 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
9024 message @code{warning: 960 bits of "a" unused}. No other regular
9025 expression notations are permitted. All characters other than asterisk in
9026 these three specific cases are treated as literal characters in the match.
9027 The match is case insensitive, for example XYZ matches xyz.
9029 Note that the pattern matches if it occurs anywhere within the warning
9030 message string (it is not necessary to put an asterisk at the start and
9031 the end of the message, since this is implied).
9033 The above use of patterns to match the message applies only to warning
9034 messages generated by the front end. This form of the pragma with a string
9035 argument can also be used to control warnings provided by the back end and
9036 mentioned above. By using a single full @code{-W`xxx'} switch in the pragma,
9037 such warnings can be turned on and off.
9039 There are two ways to use the pragma in this form. The OFF form can be used
9040 as a configuration pragma. The effect is to suppress all warnings (if any)
9041 that match the pattern string throughout the compilation (or match the
9042 -W switch in the back end case).
9044 The second usage is to suppress a warning locally, and in this case, two
9045 pragmas must appear in sequence:
9047 @example
9048 pragma Warnings (Off, Pattern);
9049 ... code where given warning is to be suppressed
9050 pragma Warnings (On, Pattern);
9051 @end example
9053 In this usage, the pattern string must match in the Off and On
9054 pragmas, and (if `-gnatw.w' is given) at least one matching
9055 warning must be suppressed.
9057 Note: if the ON form is not found, then the effect of the OFF form extends
9058 until the end of the file (pragma Warnings is purely textual, so its effect
9059 does not stop at the end of the enclosing scope).
9061 Note: to write a string that will match any warning, use the string
9062 @code{"***"}. It will not work to use a single asterisk or two
9063 asterisks since this looks like an operator name. This form with three
9064 asterisks is similar in effect to specifying @code{pragma Warnings (Off)} except (if @code{-gnatw.w} is given) that a matching
9065 @code{pragma Warnings (On, "***")} will be required. This can be
9066 helpful in avoiding forgetting to turn warnings back on.
9068 Note: the debug flag @code{-gnatd.i} can be
9069 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
9070 be useful in checking whether obsolete pragmas in existing programs are hiding
9071 real problems.
9073 Note: pragma Warnings does not affect the processing of style messages. See
9074 separate entry for pragma Style_Checks for control of style messages.
9076 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
9077 use the version of the pragma with a @code{TOOL_NAME} parameter.
9079 If present, @code{TOOL_NAME} is the name of a tool, currently either @code{GNAT} for the
9080 compiler or @code{GNATprove} for the formal verification tool. A given tool only
9081 takes into account pragma Warnings that do not specify a tool name, or that
9082 specify the matching tool name. This makes it possible to disable warnings
9083 selectively for each tool, and as a consequence to detect useless pragma
9084 Warnings with switch @code{-gnatw.w}.
9086 @node Pragma Weak_External,Pragma Wide_Character_Encoding,Pragma Warnings,Implementation Defined Pragmas
9087 @anchor{gnat_rm/implementation_defined_pragmas pragma-weak-external}@anchor{124}
9088 @section Pragma Weak_External
9091 Syntax:
9093 @example
9094 pragma Weak_External ([Entity =>] LOCAL_NAME);
9095 @end example
9097 @code{LOCAL_NAME} must refer to an object that is declared at the library
9098 level. This pragma specifies that the given entity should be marked as a
9099 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
9100 in GNU C and causes @code{LOCAL_NAME} to be emitted as a weak symbol instead
9101 of a regular symbol, that is to say a symbol that does not have to be
9102 resolved by the linker if used in conjunction with a pragma Import.
9104 When a weak symbol is not resolved by the linker, its address is set to
9105 zero. This is useful in writing interfaces to external modules that may
9106 or may not be linked in the final executable, for example depending on
9107 configuration settings.
9109 If a program references at run time an entity to which this pragma has been
9110 applied, and the corresponding symbol was not resolved at link time, then
9111 the execution of the program is erroneous. It is not erroneous to take the
9112 Address of such an entity, for example to guard potential references,
9113 as shown in the example below.
9115 Some file formats do not support weak symbols so not all target machines
9116 support this pragma.
9118 @example
9119 --  Example of the use of pragma Weak_External
9121 package External_Module is
9122   key : Integer;
9123   pragma Import (C, key);
9124   pragma Weak_External (key);
9125   function Present return boolean;
9126 end External_Module;
9128 with System; use System;
9129 package body External_Module is
9130   function Present return boolean is
9131   begin
9132     return key'Address /= System.Null_Address;
9133   end Present;
9134 end External_Module;
9135 @end example
9137 @node Pragma Wide_Character_Encoding,,Pragma Weak_External,Implementation Defined Pragmas
9138 @anchor{gnat_rm/implementation_defined_pragmas pragma-wide-character-encoding}@anchor{125}
9139 @section Pragma Wide_Character_Encoding
9142 Syntax:
9144 @example
9145 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
9146 @end example
9148 This pragma specifies the wide character encoding to be used in program
9149 source text appearing subsequently. It is a configuration pragma, but may
9150 also be used at any point that a pragma is allowed, and it is permissible
9151 to have more than one such pragma in a file, allowing multiple encodings
9152 to appear within the same file.
9154 However, note that the pragma cannot immediately precede the relevant
9155 wide character, because then the previous encoding will still be in
9156 effect, causing “illegal character” errors.
9158 The argument can be an identifier or a character literal. In the identifier
9159 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
9160 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
9161 case it is correspondingly one of the characters @code{h}, @code{u},
9162 @code{s}, @code{e}, @code{8}, or @code{b}.
9164 Note that when the pragma is used within a file, it affects only the
9165 encoding within that file, and does not affect withed units, specs,
9166 or subunits.
9168 @node Implementation Defined Aspects,Implementation Defined Attributes,Implementation Defined Pragmas,Top
9169 @anchor{gnat_rm/implementation_defined_aspects doc}@anchor{126}@anchor{gnat_rm/implementation_defined_aspects id1}@anchor{127}@anchor{gnat_rm/implementation_defined_aspects implementation-defined-aspects}@anchor{128}
9170 @chapter Implementation Defined Aspects
9173 Ada defines (throughout the Ada 2012 reference manual, summarized
9174 in Annex K) a set of aspects that can be specified for certain entities.
9175 These language defined aspects are implemented in GNAT in Ada 2012 mode
9176 and work as described in the Ada 2012 Reference Manual.
9178 In addition, Ada 2012 allows implementations to define additional aspects
9179 whose meaning is defined by the implementation.  GNAT provides
9180 a number of these implementation-defined aspects which can be used
9181 to extend and enhance the functionality of the compiler.  This section of
9182 the GNAT reference manual describes these additional aspects.
9184 Note that any program using these aspects may not be portable to
9185 other compilers (although GNAT implements this set of aspects on all
9186 platforms).  Therefore if portability to other compilers is an important
9187 consideration, you should minimize the use of these aspects.
9189 Note that for many of these aspects, the effect is essentially similar
9190 to the use of a pragma or attribute specification with the same name
9191 applied to the entity. For example, if we write:
9193 @example
9194 type R is range 1 .. 100
9195   with Value_Size => 10;
9196 @end example
9198 then the effect is the same as:
9200 @example
9201 type R is range 1 .. 100;
9202 for R'Value_Size use 10;
9203 @end example
9205 and if we write:
9207 @example
9208 type R is new Integer
9209   with Shared => True;
9210 @end example
9212 then the effect is the same as:
9214 @example
9215 type R is new Integer;
9216 pragma Shared (R);
9217 @end example
9219 In the documentation below, such cases are simply marked
9220 as being boolean aspects equivalent to the corresponding pragma
9221 or attribute definition clause.
9223 @menu
9224 * Aspect Abstract_State:: 
9225 * Aspect Always_Terminates:: 
9226 * Aspect Annotate:: 
9227 * Aspect Async_Readers:: 
9228 * Aspect Async_Writers:: 
9229 * Aspect Constant_After_Elaboration:: 
9230 * Aspect Contract_Cases:: 
9231 * Aspect Depends:: 
9232 * Aspect Default_Initial_Condition:: 
9233 * Aspect Dimension:: 
9234 * Aspect Dimension_System:: 
9235 * Aspect Disable_Controlled:: 
9236 * Aspect Effective_Reads:: 
9237 * Aspect Effective_Writes:: 
9238 * Aspect Extensions_Visible:: 
9239 * Aspect Favor_Top_Level:: 
9240 * Aspect Ghost:: 
9241 * Aspect Ghost_Predicate:: 
9242 * Aspect Global:: 
9243 * Aspect Initial_Condition:: 
9244 * Aspect Initializes:: 
9245 * Aspect Inline_Always:: 
9246 * Aspect Invariant:: 
9247 * Aspect Invariant’Class:: 
9248 * Aspect Iterable:: 
9249 * Aspect Linker_Section:: 
9250 * Aspect Local_Restrictions:: 
9251 * Aspect Lock_Free:: 
9252 * Aspect Max_Queue_Length:: 
9253 * Aspect No_Caching:: 
9254 * Aspect No_Elaboration_Code_All:: 
9255 * Aspect No_Inline:: 
9256 * Aspect No_Tagged_Streams:: 
9257 * Aspect No_Task_Parts:: 
9258 * Aspect Object_Size:: 
9259 * Aspect Obsolescent:: 
9260 * Aspect Part_Of:: 
9261 * Aspect Persistent_BSS:: 
9262 * Aspect Predicate:: 
9263 * Aspect Pure_Function:: 
9264 * Aspect Refined_Depends:: 
9265 * Aspect Refined_Global:: 
9266 * Aspect Refined_Post:: 
9267 * Aspect Refined_State:: 
9268 * Aspect Relaxed_Initialization:: 
9269 * Aspect Remote_Access_Type:: 
9270 * Aspect Secondary_Stack_Size:: 
9271 * Aspect Scalar_Storage_Order:: 
9272 * Aspect Shared:: 
9273 * Aspect Side_Effects:: 
9274 * Aspect Simple_Storage_Pool:: 
9275 * Aspect Simple_Storage_Pool_Type:: 
9276 * Aspect SPARK_Mode:: 
9277 * Aspect Suppress_Debug_Info:: 
9278 * Aspect Suppress_Initialization:: 
9279 * Aspect Test_Case:: 
9280 * Aspect Thread_Local_Storage:: 
9281 * Aspect Universal_Aliasing:: 
9282 * Aspect Unmodified:: 
9283 * Aspect Unreferenced:: 
9284 * Aspect Unreferenced_Objects:: 
9285 * Aspect User_Aspect:: 
9286 * Aspect Value_Size:: 
9287 * Aspect Volatile_Full_Access:: 
9288 * Aspect Volatile_Function:: 
9289 * Aspect Warnings:: 
9291 @end menu
9293 @node Aspect Abstract_State,Aspect Always_Terminates,,Implementation Defined Aspects
9294 @anchor{gnat_rm/implementation_defined_aspects aspect-abstract-state}@anchor{129}
9295 @section Aspect Abstract_State
9298 @geindex Abstract_State
9300 This aspect is equivalent to @ref{1e,,pragma Abstract_State}.
9302 @node Aspect Always_Terminates,Aspect Annotate,Aspect Abstract_State,Implementation Defined Aspects
9303 @anchor{gnat_rm/implementation_defined_aspects aspect-always-terminates}@anchor{12a}
9304 @section Aspect Always_Terminates
9307 @geindex Always_Terminates
9309 This boolean aspect is equivalent to @ref{29,,pragma Always_Terminates}.
9311 @node Aspect Annotate,Aspect Async_Readers,Aspect Always_Terminates,Implementation Defined Aspects
9312 @anchor{gnat_rm/implementation_defined_aspects aspect-annotate}@anchor{12b}
9313 @section Aspect Annotate
9316 @geindex Annotate
9318 There are three forms of this aspect (where ID is an identifier,
9319 and ARG is a general expression),
9320 corresponding to @ref{2b,,pragma Annotate}.
9323 @table @asis
9325 @item `Annotate => ID'
9327 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9329 @item `Annotate => (ID)'
9331 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9333 @item `Annotate => (ID ,ID @{, ARG@})'
9335 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
9336 @end table
9338 @node Aspect Async_Readers,Aspect Async_Writers,Aspect Annotate,Implementation Defined Aspects
9339 @anchor{gnat_rm/implementation_defined_aspects aspect-async-readers}@anchor{12c}
9340 @section Aspect Async_Readers
9343 @geindex Async_Readers
9345 This boolean aspect is equivalent to @ref{32,,pragma Async_Readers}.
9347 @node Aspect Async_Writers,Aspect Constant_After_Elaboration,Aspect Async_Readers,Implementation Defined Aspects
9348 @anchor{gnat_rm/implementation_defined_aspects aspect-async-writers}@anchor{12d}
9349 @section Aspect Async_Writers
9352 @geindex Async_Writers
9354 This boolean aspect is equivalent to @ref{34,,pragma Async_Writers}.
9356 @node Aspect Constant_After_Elaboration,Aspect Contract_Cases,Aspect Async_Writers,Implementation Defined Aspects
9357 @anchor{gnat_rm/implementation_defined_aspects aspect-constant-after-elaboration}@anchor{12e}
9358 @section Aspect Constant_After_Elaboration
9361 @geindex Constant_After_Elaboration
9363 This aspect is equivalent to @ref{44,,pragma Constant_After_Elaboration}.
9365 @node Aspect Contract_Cases,Aspect Depends,Aspect Constant_After_Elaboration,Implementation Defined Aspects
9366 @anchor{gnat_rm/implementation_defined_aspects aspect-contract-cases}@anchor{12f}
9367 @section Aspect Contract_Cases
9370 @geindex Contract_Cases
9372 This aspect is equivalent to @ref{46,,pragma Contract_Cases}, the sequence
9373 of clauses being enclosed in parentheses so that syntactically it is an
9374 aggregate.
9376 @node Aspect Depends,Aspect Default_Initial_Condition,Aspect Contract_Cases,Implementation Defined Aspects
9377 @anchor{gnat_rm/implementation_defined_aspects aspect-depends}@anchor{130}
9378 @section Aspect Depends
9381 @geindex Depends
9383 This aspect is equivalent to @ref{56,,pragma Depends}.
9385 @node Aspect Default_Initial_Condition,Aspect Dimension,Aspect Depends,Implementation Defined Aspects
9386 @anchor{gnat_rm/implementation_defined_aspects aspect-default-initial-condition}@anchor{131}
9387 @section Aspect Default_Initial_Condition
9390 @geindex Default_Initial_Condition
9392 This aspect is equivalent to @ref{52,,pragma Default_Initial_Condition}.
9394 @node Aspect Dimension,Aspect Dimension_System,Aspect Default_Initial_Condition,Implementation Defined Aspects
9395 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension}@anchor{132}
9396 @section Aspect Dimension
9399 @geindex Dimension
9401 The @code{Dimension} aspect is used to specify the dimensions of a given
9402 subtype of a dimensioned numeric type. The aspect also specifies a symbol
9403 used when doing formatted output of dimensioned quantities. The syntax is:
9405 @example
9406 with Dimension =>
9407   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
9409 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
9411 DIMENSION_VALUE ::=
9412   RATIONAL
9413 | others               => RATIONAL
9414 | DISCRETE_CHOICE_LIST => RATIONAL
9416 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
9417 @end example
9419 This aspect can only be applied to a subtype whose parent type has
9420 a @code{Dimension_System} aspect. The aspect must specify values for
9421 all dimensions of the system. The rational values are the powers of the
9422 corresponding dimensions that are used by the compiler to verify that
9423 physical (numeric) computations are dimensionally consistent. For example,
9424 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
9425 For further examples of the usage
9426 of this aspect, see package @code{System.Dim.Mks}.
9427 Note that when the dimensioned type is an integer type, then any
9428 dimension value must be an integer literal.
9430 @node Aspect Dimension_System,Aspect Disable_Controlled,Aspect Dimension,Implementation Defined Aspects
9431 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension-system}@anchor{133}
9432 @section Aspect Dimension_System
9435 @geindex Dimension_System
9437 The @code{Dimension_System} aspect is used to define a system of
9438 dimensions that will be used in subsequent subtype declarations with
9439 @code{Dimension} aspects that reference this system. The syntax is:
9441 @example
9442 with Dimension_System => (DIMENSION @{, DIMENSION@});
9444 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
9445                [Unit_Symbol =>] SYMBOL,
9446                [Dim_Symbol  =>] SYMBOL)
9448 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
9449 @end example
9451 This aspect is applied to a type, which must be a numeric derived type
9452 (typically a floating-point type), that
9453 will represent values within the dimension system. Each @code{DIMENSION}
9454 corresponds to one particular dimension. A maximum of 7 dimensions may
9455 be specified. @code{Unit_Name} is the name of the dimension (for example
9456 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
9457 of this dimension (for example @code{m} for @code{Meter}).
9458 @code{Dim_Symbol} gives
9459 the identification within the dimension system (typically this is a
9460 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
9461 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
9462 The @code{Dim_Symbol} is used in error messages when numeric operations have
9463 inconsistent dimensions.
9465 GNAT provides the standard definition of the International MKS system in
9466 the run-time package @code{System.Dim.Mks}. You can easily define
9467 similar packages for cgs units or British units, and define conversion factors
9468 between values in different systems. The MKS system is characterized by the
9469 following aspect:
9471 @example
9472 type Mks_Type is new Long_Long_Float with
9473   Dimension_System => (
9474     (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
9475     (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
9476     (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
9477     (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
9478     (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@@'),
9479     (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
9480     (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
9481 @end example
9483 Note that in the above type definition, we use the @code{at} symbol (@code{@@}) to
9484 represent a theta character (avoiding the use of extended Latin-1
9485 characters in this context).
9487 See section ‘Performing Dimensionality Analysis in GNAT’ in the GNAT Users
9488 Guide for detailed examples of use of the dimension system.
9490 @node Aspect Disable_Controlled,Aspect Effective_Reads,Aspect Dimension_System,Implementation Defined Aspects
9491 @anchor{gnat_rm/implementation_defined_aspects aspect-disable-controlled}@anchor{134}
9492 @section Aspect Disable_Controlled
9495 @geindex Disable_Controlled
9497 The aspect  @code{Disable_Controlled} is defined for controlled record types. If
9498 active, this aspect causes suppression of all related calls to @code{Initialize},
9499 @code{Adjust}, and @code{Finalize}. The intended use is for conditional compilation,
9500 where for example you might want a record to be controlled or not depending on
9501 whether some run-time check is enabled or suppressed.
9503 @node Aspect Effective_Reads,Aspect Effective_Writes,Aspect Disable_Controlled,Implementation Defined Aspects
9504 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-reads}@anchor{135}
9505 @section Aspect Effective_Reads
9508 @geindex Effective_Reads
9510 This aspect is equivalent to @ref{5b,,pragma Effective_Reads}.
9512 @node Aspect Effective_Writes,Aspect Extensions_Visible,Aspect Effective_Reads,Implementation Defined Aspects
9513 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-writes}@anchor{136}
9514 @section Aspect Effective_Writes
9517 @geindex Effective_Writes
9519 This aspect is equivalent to @ref{5d,,pragma Effective_Writes}.
9521 @node Aspect Extensions_Visible,Aspect Favor_Top_Level,Aspect Effective_Writes,Implementation Defined Aspects
9522 @anchor{gnat_rm/implementation_defined_aspects aspect-extensions-visible}@anchor{137}
9523 @section Aspect Extensions_Visible
9526 @geindex Extensions_Visible
9528 This aspect is equivalent to @ref{6b,,pragma Extensions_Visible}.
9530 @node Aspect Favor_Top_Level,Aspect Ghost,Aspect Extensions_Visible,Implementation Defined Aspects
9531 @anchor{gnat_rm/implementation_defined_aspects aspect-favor-top-level}@anchor{138}
9532 @section Aspect Favor_Top_Level
9535 @geindex Favor_Top_Level
9537 This boolean aspect is equivalent to @ref{70,,pragma Favor_Top_Level}.
9539 @node Aspect Ghost,Aspect Ghost_Predicate,Aspect Favor_Top_Level,Implementation Defined Aspects
9540 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost}@anchor{139}
9541 @section Aspect Ghost
9544 @geindex Ghost
9546 This aspect is equivalent to @ref{74,,pragma Ghost}.
9548 @node Aspect Ghost_Predicate,Aspect Global,Aspect Ghost,Implementation Defined Aspects
9549 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost-predicate}@anchor{13a}
9550 @section Aspect Ghost_Predicate
9553 @geindex Ghost_Predicate
9555 This aspect introduces a subtype predicate that can reference ghost
9556 entities. The subtype cannot appear as a subtype_mark in a membership test.
9558 For the detailed semantics of this aspect, see the entry for subtype predicates
9559 in the SPARK Reference Manual, section 3.2.4.
9561 @node Aspect Global,Aspect Initial_Condition,Aspect Ghost_Predicate,Implementation Defined Aspects
9562 @anchor{gnat_rm/implementation_defined_aspects aspect-global}@anchor{13b}
9563 @section Aspect Global
9566 @geindex Global
9568 This aspect is equivalent to @ref{76,,pragma Global}.
9570 @node Aspect Initial_Condition,Aspect Initializes,Aspect Global,Implementation Defined Aspects
9571 @anchor{gnat_rm/implementation_defined_aspects aspect-initial-condition}@anchor{13c}
9572 @section Aspect Initial_Condition
9575 @geindex Initial_Condition
9577 This aspect is equivalent to @ref{83,,pragma Initial_Condition}.
9579 @node Aspect Initializes,Aspect Inline_Always,Aspect Initial_Condition,Implementation Defined Aspects
9580 @anchor{gnat_rm/implementation_defined_aspects aspect-initializes}@anchor{13d}
9581 @section Aspect Initializes
9584 @geindex Initializes
9586 This aspect is equivalent to @ref{86,,pragma Initializes}.
9588 @node Aspect Inline_Always,Aspect Invariant,Aspect Initializes,Implementation Defined Aspects
9589 @anchor{gnat_rm/implementation_defined_aspects aspect-inline-always}@anchor{13e}
9590 @section Aspect Inline_Always
9593 @geindex Inline_Always
9595 This boolean aspect is equivalent to @ref{88,,pragma Inline_Always}.
9597 @node Aspect Invariant,Aspect Invariant’Class,Aspect Inline_Always,Implementation Defined Aspects
9598 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant}@anchor{13f}
9599 @section Aspect Invariant
9602 @geindex Invariant
9604 This aspect is equivalent to @ref{8f,,pragma Invariant}. It is a
9605 synonym for the language defined aspect @code{Type_Invariant} except
9606 that it is separately controllable using pragma @code{Assertion_Policy}.
9608 @node Aspect Invariant’Class,Aspect Iterable,Aspect Invariant,Implementation Defined Aspects
9609 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant-class}@anchor{140}
9610 @section Aspect Invariant’Class
9613 @geindex Invariant'Class
9615 This aspect is equivalent to @ref{108,,pragma Type_Invariant_Class}. It is a
9616 synonym for the language defined aspect @code{Type_Invariant'Class} except
9617 that it is separately controllable using pragma @code{Assertion_Policy}.
9619 @node Aspect Iterable,Aspect Linker_Section,Aspect Invariant’Class,Implementation Defined Aspects
9620 @anchor{gnat_rm/implementation_defined_aspects aspect-iterable}@anchor{141}
9621 @section Aspect Iterable
9624 @geindex Iterable
9626 This aspect provides a light-weight mechanism for loops and quantified
9627 expressions over container types, without the overhead imposed by the tampering
9628 checks of standard Ada 2012 iterators. The value of the aspect is an aggregate
9629 with six named components, of which the last three are optional: @code{First},
9630 @code{Next}, @code{Has_Element}, @code{Element}, @code{Last}, and @code{Previous}.
9631 When only the first three components are specified, only the
9632 @code{for .. in} form of iteration over cursors is available. When @code{Element}
9633 is specified, both this form and the @code{for .. of} form of iteration over
9634 elements are available. If the last two components are specified, reverse
9635 iterations over the container can be specified (analogous to what can be done
9636 over predefined containers that support the @code{Reverse_Iterator} interface).
9637 The following is a typical example of use:
9639 @example
9640 type List is private with
9641     Iterable => (First       => First_Cursor,
9642                  Next        => Advance,
9643                  Has_Element => Cursor_Has_Element
9644                [,Element     => Get_Element]
9645                [,Last        => Last_Cursor]
9646                [,Previous    => Retreat]);
9647 @end example
9650 @itemize *
9652 @item 
9653 The values of @code{First} and @code{Last} are primitive operations of the
9654 container type that return a @code{Cursor}, which must be a type declared in
9655 the container package or visible from it. For example:
9656 @end itemize
9658 @example
9659 function First_Cursor (Cont : Container) return Cursor;
9660 function Last_Cursor  (Cont : Container) return Cursor;
9661 @end example
9664 @itemize *
9666 @item 
9667 The values of @code{Next} and @code{Previous} are primitive operations of the container type that take
9668 both a container and a cursor and yield a cursor. For example:
9669 @end itemize
9671 @example
9672 function Advance (Cont : Container; Position : Cursor) return Cursor;
9673 function Retreat (Cont : Container; Position : Cursor) return Cursor;
9674 @end example
9677 @itemize *
9679 @item 
9680 The value of @code{Has_Element} is a primitive operation of the container type
9681 that takes both a container and a cursor and yields a boolean. For example:
9682 @end itemize
9684 @example
9685 function Cursor_Has_Element (Cont : Container; Position : Cursor) return Boolean;
9686 @end example
9689 @itemize *
9691 @item 
9692 The value of @code{Element} is a primitive operation of the container type that
9693 takes both a container and a cursor and yields an @code{Element_Type}, which must
9694 be a type declared in the container package or visible from it. For example:
9695 @end itemize
9697 @example
9698 function Get_Element (Cont : Container; Position : Cursor) return Element_Type;
9699 @end example
9701 This aspect is used in the GNAT-defined formal container packages.
9703 @node Aspect Linker_Section,Aspect Local_Restrictions,Aspect Iterable,Implementation Defined Aspects
9704 @anchor{gnat_rm/implementation_defined_aspects aspect-linker-section}@anchor{142}
9705 @section Aspect Linker_Section
9708 @geindex Linker_Section
9710 This aspect is equivalent to @ref{97,,pragma Linker_Section}.
9712 @node Aspect Local_Restrictions,Aspect Lock_Free,Aspect Linker_Section,Implementation Defined Aspects
9713 @anchor{gnat_rm/implementation_defined_aspects aspect-local-restrictions}@anchor{143}
9714 @section Aspect Local_Restrictions
9717 @geindex Local_Restrictions
9719 This aspect may be specified for a subprogram (and for other declarations
9720 as described below). It is used to specify that a particular subprogram does
9721 not violate one or more local restrictions, nor can it call a subprogram
9722 that is not subject to the same requirement. Positional aggregate syntax
9723 (with parentheses, not square brackets) may be used to specify more than one
9724 local restriction, as in
9726 @example
9727 procedure Do_Something
9728   with Local_Restrictions => (Some_Restriction, Another_Restriction);
9729 @end example
9731 Parentheses are currently required even in the case of specifying a single
9732 local restriction (this requirement may be relaxed in the future).
9733 Supported local restrictions currently include (only) No_Heap_Allocations and
9734 No_Secondary_Stack.
9735 No_Secondary_Stack corresponds to the GNAT-defined (global) restriction
9736 of the same name. No_Heap_Allocations corresponds to the conjunction of the
9737 Ada-defined restrictions No_Allocators and No_Implicit_Heap_Allocations.
9739 Additional requirements are imposed in order to ensure that restriction
9740 violations cannot be achieved via overriding dispatching operations,
9741 calling through an access-to-subprogram value, calling a generic formal
9742 subprogram, or calling through a subprogram renaming.
9743 For a dispatching operation, an overrider must be subject to (at least) the
9744 same restrictions as the overridden inherited subprogram; similarly, the
9745 actual subprogram corresponding to a generic formal subprogram
9746 in an instantiation must be subject to (at least) the same restrictions
9747 as the formal subprogram. A call through an access-to-subprogram value
9748 is conservatively assumed to violate all local restrictions; tasking-related
9749 constructs (notably entry calls) are treated similarly. A renaming-as-body is
9750 treated like a subprogram body containing a call to the renamed subprogram.
9752 The Local_Restrictions aspect can be specified for a package specification,
9753 in which case the aspect specification also applies to all eligible entities
9754 declared with the package. This includes types. Default initialization of an
9755 object of a given type is treated like a call to an implicitly-declared
9756 initialization subprogram. Such a “call” is subject to the same local
9757 restriction checks as any other call. If a type is subject to a local
9758 restriction, then any violations of that restriction within the default
9759 initialization expressions (if any) of the type are rejected. This may
9760 include “calls” to the default initialization subprograms of other types.
9762 Local_Restrictions aspect specifications are additive (for example, in the
9763 case of a declaration that occurs within nested packages that each have
9764 a Local_Restrictions specification).
9766 @node Aspect Lock_Free,Aspect Max_Queue_Length,Aspect Local_Restrictions,Implementation Defined Aspects
9767 @anchor{gnat_rm/implementation_defined_aspects aspect-lock-free}@anchor{144}
9768 @section Aspect Lock_Free
9771 @geindex Lock_Free
9773 This boolean aspect is equivalent to @ref{99,,pragma Lock_Free}.
9775 @node Aspect Max_Queue_Length,Aspect No_Caching,Aspect Lock_Free,Implementation Defined Aspects
9776 @anchor{gnat_rm/implementation_defined_aspects aspect-max-queue-length}@anchor{145}
9777 @section Aspect Max_Queue_Length
9780 @geindex Max_Queue_Length
9782 This aspect is equivalent to @ref{a1,,pragma Max_Queue_Length}.
9784 @node Aspect No_Caching,Aspect No_Elaboration_Code_All,Aspect Max_Queue_Length,Implementation Defined Aspects
9785 @anchor{gnat_rm/implementation_defined_aspects aspect-no-caching}@anchor{146}
9786 @section Aspect No_Caching
9789 @geindex No_Caching
9791 This boolean aspect is equivalent to @ref{a4,,pragma No_Caching}.
9793 @node Aspect No_Elaboration_Code_All,Aspect No_Inline,Aspect No_Caching,Implementation Defined Aspects
9794 @anchor{gnat_rm/implementation_defined_aspects aspect-no-elaboration-code-all}@anchor{147}
9795 @section Aspect No_Elaboration_Code_All
9798 @geindex No_Elaboration_Code_All
9800 This aspect is equivalent to @ref{a7,,pragma No_Elaboration_Code_All}
9801 for a program unit.
9803 @node Aspect No_Inline,Aspect No_Tagged_Streams,Aspect No_Elaboration_Code_All,Implementation Defined Aspects
9804 @anchor{gnat_rm/implementation_defined_aspects aspect-no-inline}@anchor{148}
9805 @section Aspect No_Inline
9808 @geindex No_Inline
9810 This boolean aspect is equivalent to @ref{aa,,pragma No_Inline}.
9812 @node Aspect No_Tagged_Streams,Aspect No_Task_Parts,Aspect No_Inline,Implementation Defined Aspects
9813 @anchor{gnat_rm/implementation_defined_aspects aspect-no-tagged-streams}@anchor{149}
9814 @section Aspect No_Tagged_Streams
9817 @geindex No_Tagged_Streams
9819 This aspect is equivalent to @ref{ae,,pragma No_Tagged_Streams} with an
9820 argument specifying a root tagged type (thus this aspect can only be
9821 applied to such a type).
9823 @node Aspect No_Task_Parts,Aspect Object_Size,Aspect No_Tagged_Streams,Implementation Defined Aspects
9824 @anchor{gnat_rm/implementation_defined_aspects aspect-no-task-parts}@anchor{14a}
9825 @section Aspect No_Task_Parts
9828 @geindex No_Task_Parts
9830 Applies to a type. If True, requires that the type and any descendants
9831 do not have any task parts. The rules for this aspect are the same as
9832 for the language-defined No_Controlled_Parts aspect (see RM-H.4.1),
9833 replacing “controlled” with “task”.
9835 If No_Task_Parts is True for a type T, then the compiler can optimize
9836 away certain tasking-related code that would otherwise be needed
9837 for T’Class, because descendants of T might contain tasks.
9839 @node Aspect Object_Size,Aspect Obsolescent,Aspect No_Task_Parts,Implementation Defined Aspects
9840 @anchor{gnat_rm/implementation_defined_aspects aspect-object-size}@anchor{14b}
9841 @section Aspect Object_Size
9844 @geindex Object_Size
9846 This aspect is equivalent to @ref{14c,,attribute Object_Size}.
9848 @node Aspect Obsolescent,Aspect Part_Of,Aspect Object_Size,Implementation Defined Aspects
9849 @anchor{gnat_rm/implementation_defined_aspects aspect-obsolescent}@anchor{14d}
9850 @section Aspect Obsolescent
9853 @geindex Obsolescent
9855 This aspect is equivalent to @ref{b1,,pragma Obsolescent}. Note that the
9856 evaluation of this aspect happens at the point of occurrence, it is not
9857 delayed until the freeze point.
9859 @node Aspect Part_Of,Aspect Persistent_BSS,Aspect Obsolescent,Implementation Defined Aspects
9860 @anchor{gnat_rm/implementation_defined_aspects aspect-part-of}@anchor{14e}
9861 @section Aspect Part_Of
9864 @geindex Part_Of
9866 This aspect is equivalent to @ref{b7,,pragma Part_Of}.
9868 @node Aspect Persistent_BSS,Aspect Predicate,Aspect Part_Of,Implementation Defined Aspects
9869 @anchor{gnat_rm/implementation_defined_aspects aspect-persistent-bss}@anchor{14f}
9870 @section Aspect Persistent_BSS
9873 @geindex Persistent_BSS
9875 This boolean aspect is equivalent to @ref{bb,,pragma Persistent_BSS}.
9877 @node Aspect Predicate,Aspect Pure_Function,Aspect Persistent_BSS,Implementation Defined Aspects
9878 @anchor{gnat_rm/implementation_defined_aspects aspect-predicate}@anchor{150}
9879 @section Aspect Predicate
9882 @geindex Predicate
9884 This aspect is equivalent to @ref{c2,,pragma Predicate}. It is thus
9885 similar to the language defined aspects @code{Dynamic_Predicate}
9886 and @code{Static_Predicate} except that whether the resulting
9887 predicate is static or dynamic is controlled by the form of the
9888 expression. It is also separately controllable using pragma
9889 @code{Assertion_Policy}.
9891 @node Aspect Pure_Function,Aspect Refined_Depends,Aspect Predicate,Implementation Defined Aspects
9892 @anchor{gnat_rm/implementation_defined_aspects aspect-pure-function}@anchor{151}
9893 @section Aspect Pure_Function
9896 @geindex Pure_Function
9898 This boolean aspect is equivalent to @ref{ce,,pragma Pure_Function}.
9900 @node Aspect Refined_Depends,Aspect Refined_Global,Aspect Pure_Function,Implementation Defined Aspects
9901 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-depends}@anchor{152}
9902 @section Aspect Refined_Depends
9905 @geindex Refined_Depends
9907 This aspect is equivalent to @ref{d2,,pragma Refined_Depends}.
9909 @node Aspect Refined_Global,Aspect Refined_Post,Aspect Refined_Depends,Implementation Defined Aspects
9910 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-global}@anchor{153}
9911 @section Aspect Refined_Global
9914 @geindex Refined_Global
9916 This aspect is equivalent to @ref{d4,,pragma Refined_Global}.
9918 @node Aspect Refined_Post,Aspect Refined_State,Aspect Refined_Global,Implementation Defined Aspects
9919 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-post}@anchor{154}
9920 @section Aspect Refined_Post
9923 @geindex Refined_Post
9925 This aspect is equivalent to @ref{d6,,pragma Refined_Post}.
9927 @node Aspect Refined_State,Aspect Relaxed_Initialization,Aspect Refined_Post,Implementation Defined Aspects
9928 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-state}@anchor{155}
9929 @section Aspect Refined_State
9932 @geindex Refined_State
9934 This aspect is equivalent to @ref{d8,,pragma Refined_State}.
9936 @node Aspect Relaxed_Initialization,Aspect Remote_Access_Type,Aspect Refined_State,Implementation Defined Aspects
9937 @anchor{gnat_rm/implementation_defined_aspects aspect-relaxed-initialization}@anchor{156}
9938 @section Aspect Relaxed_Initialization
9941 @geindex Refined_Initialization
9943 For the syntax and semantics of this aspect, see the SPARK 2014 Reference
9944 Manual, section 6.10.
9946 @node Aspect Remote_Access_Type,Aspect Secondary_Stack_Size,Aspect Relaxed_Initialization,Implementation Defined Aspects
9947 @anchor{gnat_rm/implementation_defined_aspects aspect-remote-access-type}@anchor{157}
9948 @section Aspect Remote_Access_Type
9951 @geindex Remote_Access_Type
9953 This aspect is equivalent to @ref{db,,pragma Remote_Access_Type}.
9955 @node Aspect Secondary_Stack_Size,Aspect Scalar_Storage_Order,Aspect Remote_Access_Type,Implementation Defined Aspects
9956 @anchor{gnat_rm/implementation_defined_aspects aspect-secondary-stack-size}@anchor{158}
9957 @section Aspect Secondary_Stack_Size
9960 @geindex Secondary_Stack_Size
9962 This aspect is equivalent to @ref{e1,,pragma Secondary_Stack_Size}.
9964 @node Aspect Scalar_Storage_Order,Aspect Shared,Aspect Secondary_Stack_Size,Implementation Defined Aspects
9965 @anchor{gnat_rm/implementation_defined_aspects aspect-scalar-storage-order}@anchor{159}
9966 @section Aspect Scalar_Storage_Order
9969 @geindex Scalar_Storage_Order
9971 This aspect is equivalent to a @ref{15a,,attribute Scalar_Storage_Order}.
9973 @node Aspect Shared,Aspect Side_Effects,Aspect Scalar_Storage_Order,Implementation Defined Aspects
9974 @anchor{gnat_rm/implementation_defined_aspects aspect-shared}@anchor{15b}
9975 @section Aspect Shared
9978 @geindex Shared
9980 This boolean aspect is equivalent to @ref{e4,,pragma Shared}
9981 and is thus a synonym for aspect @code{Atomic}.
9983 @node Aspect Side_Effects,Aspect Simple_Storage_Pool,Aspect Shared,Implementation Defined Aspects
9984 @anchor{gnat_rm/implementation_defined_aspects aspect-side-effects}@anchor{15c}
9985 @section Aspect Side_Effects
9988 @geindex Side_Effects
9990 This aspect is equivalent to @ref{e8,,pragma Side_Effects}.
9992 @node Aspect Simple_Storage_Pool,Aspect Simple_Storage_Pool_Type,Aspect Side_Effects,Implementation Defined Aspects
9993 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool}@anchor{15d}
9994 @section Aspect Simple_Storage_Pool
9997 @geindex Simple_Storage_Pool
9999 This aspect is equivalent to @ref{eb,,attribute Simple_Storage_Pool}.
10001 @node Aspect Simple_Storage_Pool_Type,Aspect SPARK_Mode,Aspect Simple_Storage_Pool,Implementation Defined Aspects
10002 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool-type}@anchor{15e}
10003 @section Aspect Simple_Storage_Pool_Type
10006 @geindex Simple_Storage_Pool_Type
10008 This boolean aspect is equivalent to @ref{ea,,pragma Simple_Storage_Pool_Type}.
10010 @node Aspect SPARK_Mode,Aspect Suppress_Debug_Info,Aspect Simple_Storage_Pool_Type,Implementation Defined Aspects
10011 @anchor{gnat_rm/implementation_defined_aspects aspect-spark-mode}@anchor{15f}
10012 @section Aspect SPARK_Mode
10015 @geindex SPARK_Mode
10017 This aspect is equivalent to @ref{f2,,pragma SPARK_Mode} and
10018 may be specified for either or both of the specification and body
10019 of a subprogram or package.
10021 @node Aspect Suppress_Debug_Info,Aspect Suppress_Initialization,Aspect SPARK_Mode,Implementation Defined Aspects
10022 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-debug-info}@anchor{160}
10023 @section Aspect Suppress_Debug_Info
10026 @geindex Suppress_Debug_Info
10028 This boolean aspect is equivalent to @ref{fa,,pragma Suppress_Debug_Info}.
10030 @node Aspect Suppress_Initialization,Aspect Test_Case,Aspect Suppress_Debug_Info,Implementation Defined Aspects
10031 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-initialization}@anchor{161}
10032 @section Aspect Suppress_Initialization
10035 @geindex Suppress_Initialization
10037 This boolean aspect is equivalent to @ref{fd,,pragma Suppress_Initialization}.
10039 @node Aspect Test_Case,Aspect Thread_Local_Storage,Aspect Suppress_Initialization,Implementation Defined Aspects
10040 @anchor{gnat_rm/implementation_defined_aspects aspect-test-case}@anchor{162}
10041 @section Aspect Test_Case
10044 @geindex Test_Case
10046 This aspect is equivalent to @ref{101,,pragma Test_Case}.
10048 @node Aspect Thread_Local_Storage,Aspect Universal_Aliasing,Aspect Test_Case,Implementation Defined Aspects
10049 @anchor{gnat_rm/implementation_defined_aspects aspect-thread-local-storage}@anchor{163}
10050 @section Aspect Thread_Local_Storage
10053 @geindex Thread_Local_Storage
10055 This boolean aspect is equivalent to @ref{103,,pragma Thread_Local_Storage}.
10057 @node Aspect Universal_Aliasing,Aspect Unmodified,Aspect Thread_Local_Storage,Implementation Defined Aspects
10058 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-aliasing}@anchor{164}
10059 @section Aspect Universal_Aliasing
10062 @geindex Universal_Aliasing
10064 This boolean aspect is equivalent to @ref{10e,,pragma Universal_Aliasing}.
10066 @node Aspect Unmodified,Aspect Unreferenced,Aspect Universal_Aliasing,Implementation Defined Aspects
10067 @anchor{gnat_rm/implementation_defined_aspects aspect-unmodified}@anchor{165}
10068 @section Aspect Unmodified
10071 @geindex Unmodified
10073 This boolean aspect is equivalent to @ref{110,,pragma Unmodified}.
10075 @node Aspect Unreferenced,Aspect Unreferenced_Objects,Aspect Unmodified,Implementation Defined Aspects
10076 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced}@anchor{166}
10077 @section Aspect Unreferenced
10080 @geindex Unreferenced
10082 This boolean aspect is equivalent to @ref{112,,pragma Unreferenced}.
10084 When using the @code{-gnat2022} switch, this aspect is also supported on formal
10085 parameters, which is in particular the only form possible for expression
10086 functions.
10088 @node Aspect Unreferenced_Objects,Aspect User_Aspect,Aspect Unreferenced,Implementation Defined Aspects
10089 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced-objects}@anchor{167}
10090 @section Aspect Unreferenced_Objects
10093 @geindex Unreferenced_Objects
10095 This boolean aspect is equivalent to @ref{114,,pragma Unreferenced_Objects}.
10097 @node Aspect User_Aspect,Aspect Value_Size,Aspect Unreferenced_Objects,Implementation Defined Aspects
10098 @anchor{gnat_rm/implementation_defined_aspects aspect-user-aspect}@anchor{168}
10099 @section Aspect User_Aspect
10102 @geindex User_Aspect
10104 This aspect takes an argument that is the name of an aspect defined by a
10105 User_Aspect_Definition configuration pragma.
10106 A User_Aspect aspect specification is semantically equivalent to
10107 replicating the set of aspect specifications associated with the named
10108 pragma-defined aspect.
10110 @node Aspect Value_Size,Aspect Volatile_Full_Access,Aspect User_Aspect,Implementation Defined Aspects
10111 @anchor{gnat_rm/implementation_defined_aspects aspect-value-size}@anchor{169}
10112 @section Aspect Value_Size
10115 @geindex Value_Size
10117 This aspect is equivalent to @ref{16a,,attribute Value_Size}.
10119 @node Aspect Volatile_Full_Access,Aspect Volatile_Function,Aspect Value_Size,Implementation Defined Aspects
10120 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-full-access}@anchor{16b}
10121 @section Aspect Volatile_Full_Access
10124 @geindex Volatile_Full_Access
10126 This boolean aspect is equivalent to @ref{11e,,pragma Volatile_Full_Access}.
10128 @node Aspect Volatile_Function,Aspect Warnings,Aspect Volatile_Full_Access,Implementation Defined Aspects
10129 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-function}@anchor{16c}
10130 @section Aspect Volatile_Function
10133 @geindex Volatile_Function
10135 This boolean aspect is equivalent to @ref{120,,pragma Volatile_Function}.
10137 @node Aspect Warnings,,Aspect Volatile_Function,Implementation Defined Aspects
10138 @anchor{gnat_rm/implementation_defined_aspects aspect-warnings}@anchor{16d}
10139 @section Aspect Warnings
10142 @geindex Warnings
10144 This aspect is equivalent to the two argument form of @ref{122,,pragma Warnings},
10145 where the first argument is @code{ON} or @code{OFF} and the second argument
10146 is the entity.
10148 @node Implementation Defined Attributes,Standard and Implementation Defined Restrictions,Implementation Defined Aspects,Top
10149 @anchor{gnat_rm/implementation_defined_attributes doc}@anchor{16e}@anchor{gnat_rm/implementation_defined_attributes id1}@anchor{16f}@anchor{gnat_rm/implementation_defined_attributes implementation-defined-attributes}@anchor{8}
10150 @chapter Implementation Defined Attributes
10153 Ada defines (throughout the Ada reference manual,
10154 summarized in Annex K),
10155 a set of attributes that provide useful additional functionality in all
10156 areas of the language.  These language defined attributes are implemented
10157 in GNAT and work as described in the Ada Reference Manual.
10159 In addition, Ada allows implementations to define additional
10160 attributes whose meaning is defined by the implementation.  GNAT provides
10161 a number of these implementation-dependent attributes which can be used
10162 to extend and enhance the functionality of the compiler.  This section of
10163 the GNAT reference manual describes these additional attributes.  It also
10164 describes additional implementation-dependent features of standard
10165 language-defined attributes.
10167 Note that any program using these attributes may not be portable to
10168 other compilers (although GNAT implements this set of attributes on all
10169 platforms).  Therefore if portability to other compilers is an important
10170 consideration, you should minimize the use of these attributes.
10172 @menu
10173 * Attribute Abort_Signal:: 
10174 * Attribute Address_Size:: 
10175 * Attribute Asm_Input:: 
10176 * Attribute Asm_Output:: 
10177 * Attribute Atomic_Always_Lock_Free:: 
10178 * Attribute Bit:: 
10179 * Attribute Bit_Position:: 
10180 * Attribute Code_Address:: 
10181 * Attribute Compiler_Version:: 
10182 * Attribute Constrained:: 
10183 * Attribute Default_Bit_Order:: 
10184 * Attribute Default_Scalar_Storage_Order:: 
10185 * Attribute Deref:: 
10186 * Attribute Descriptor_Size:: 
10187 * Attribute Elaborated:: 
10188 * Attribute Elab_Body:: 
10189 * Attribute Elab_Spec:: 
10190 * Attribute Elab_Subp_Body:: 
10191 * Attribute Emax:: 
10192 * Attribute Enabled:: 
10193 * Attribute Enum_Rep:: 
10194 * Attribute Enum_Val:: 
10195 * Attribute Epsilon:: 
10196 * Attribute Fast_Math:: 
10197 * Attribute Finalization_Size:: 
10198 * Attribute Fixed_Value:: 
10199 * Attribute From_Any:: 
10200 * Attribute Has_Access_Values:: 
10201 * Attribute Has_Discriminants:: 
10202 * Attribute Has_Tagged_Values:: 
10203 * Attribute Img:: 
10204 * Attribute Initialized:: 
10205 * Attribute Integer_Value:: 
10206 * Attribute Invalid_Value:: 
10207 * Attribute Iterable:: 
10208 * Attribute Large:: 
10209 * Attribute Library_Level:: 
10210 * Attribute Loop_Entry:: 
10211 * Attribute Machine_Size:: 
10212 * Attribute Mantissa:: 
10213 * Attribute Maximum_Alignment:: 
10214 * Attribute Max_Integer_Size:: 
10215 * Attribute Mechanism_Code:: 
10216 * Attribute Null_Parameter:: 
10217 * Attribute Object_Size:: 
10218 * Attribute Old:: 
10219 * Attribute Passed_By_Reference:: 
10220 * Attribute Pool_Address:: 
10221 * Attribute Range_Length:: 
10222 * Attribute Restriction_Set:: 
10223 * Attribute Result:: 
10224 * Attribute Safe_Emax:: 
10225 * Attribute Safe_Large:: 
10226 * Attribute Safe_Small:: 
10227 * Attribute Scalar_Storage_Order:: 
10228 * Attribute Simple_Storage_Pool:: 
10229 * Attribute Small:: 
10230 * Attribute Small_Denominator:: 
10231 * Attribute Small_Numerator:: 
10232 * Attribute Storage_Unit:: 
10233 * Attribute Stub_Type:: 
10234 * Attribute System_Allocator_Alignment:: 
10235 * Attribute Target_Name:: 
10236 * Attribute To_Address:: 
10237 * Attribute To_Any:: 
10238 * Attribute Type_Class:: 
10239 * Attribute Type_Key:: 
10240 * Attribute TypeCode:: 
10241 * Attribute Unconstrained_Array:: 
10242 * Attribute Universal_Literal_String:: 
10243 * Attribute Unrestricted_Access:: 
10244 * Attribute Update:: 
10245 * Attribute Valid_Value:: 
10246 * Attribute Valid_Scalars:: 
10247 * Attribute VADS_Size:: 
10248 * Attribute Value_Size:: 
10249 * Attribute Wchar_T_Size:: 
10250 * Attribute Word_Size:: 
10252 @end menu
10254 @node Attribute Abort_Signal,Attribute Address_Size,,Implementation Defined Attributes
10255 @anchor{gnat_rm/implementation_defined_attributes attribute-abort-signal}@anchor{170}
10256 @section Attribute Abort_Signal
10259 @geindex Abort_Signal
10261 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
10262 prefix) provides the entity for the special exception used to signal
10263 task abort or asynchronous transfer of control.  Normally this attribute
10264 should only be used in the tasking runtime (it is highly peculiar, and
10265 completely outside the normal semantics of Ada, for a user program to
10266 intercept the abort exception).
10268 @node Attribute Address_Size,Attribute Asm_Input,Attribute Abort_Signal,Implementation Defined Attributes
10269 @anchor{gnat_rm/implementation_defined_attributes attribute-address-size}@anchor{171}
10270 @section Attribute Address_Size
10273 @geindex Size of `@w{`}Address`@w{`}
10275 @geindex Address_Size
10277 @code{Standard'Address_Size} (@code{Standard} is the only allowed
10278 prefix) is a static constant giving the number of bits in an
10279 @code{Address}. It is the same value as System.Address’Size,
10280 but has the advantage of being static, while a direct
10281 reference to System.Address’Size is nonstatic because Address
10282 is a private type.
10284 @node Attribute Asm_Input,Attribute Asm_Output,Attribute Address_Size,Implementation Defined Attributes
10285 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-input}@anchor{172}
10286 @section Attribute Asm_Input
10289 @geindex Asm_Input
10291 The @code{Asm_Input} attribute denotes a function that takes two
10292 parameters.  The first is a string, the second is an expression of the
10293 type designated by the prefix.  The first (string) argument is required
10294 to be a static expression, and is the constraint for the parameter,
10295 (e.g., what kind of register is required).  The second argument is the
10296 value to be used as the input argument.  The possible values for the
10297 constant are the same as those used in the RTL, and are dependent on
10298 the configuration file used to built the GCC back end.
10299 @ref{173,,Machine Code Insertions}
10301 @node Attribute Asm_Output,Attribute Atomic_Always_Lock_Free,Attribute Asm_Input,Implementation Defined Attributes
10302 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-output}@anchor{174}
10303 @section Attribute Asm_Output
10306 @geindex Asm_Output
10308 The @code{Asm_Output} attribute denotes a function that takes two
10309 parameters.  The first is a string, the second is the name of a variable
10310 of the type designated by the attribute prefix.  The first (string)
10311 argument is required to be a static expression and designates the
10312 constraint for the parameter (e.g., what kind of register is
10313 required).  The second argument is the variable to be updated with the
10314 result.  The possible values for constraint are the same as those used in
10315 the RTL, and are dependent on the configuration file used to build the
10316 GCC back end.  If there are no output operands, then this argument may
10317 either be omitted, or explicitly given as @code{No_Output_Operands}.
10318 @ref{173,,Machine Code Insertions}
10320 @node Attribute Atomic_Always_Lock_Free,Attribute Bit,Attribute Asm_Output,Implementation Defined Attributes
10321 @anchor{gnat_rm/implementation_defined_attributes attribute-atomic-always-lock-free}@anchor{175}
10322 @section Attribute Atomic_Always_Lock_Free
10325 @geindex Atomic_Always_Lock_Free
10327 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
10328 The result is a Boolean value which is True if the type has discriminants,
10329 and False otherwise.  The result indicate whether atomic operations are
10330 supported by the target for the given type.
10332 @node Attribute Bit,Attribute Bit_Position,Attribute Atomic_Always_Lock_Free,Implementation Defined Attributes
10333 @anchor{gnat_rm/implementation_defined_attributes attribute-bit}@anchor{176}
10334 @section Attribute Bit
10337 @geindex Bit
10339 @code{obj'Bit}, where @code{obj} is any object, yields the bit
10340 offset within the storage unit (byte) that contains the first bit of
10341 storage allocated for the object.  The value of this attribute is of the
10342 type `universal_integer' and is always a nonnegative number smaller
10343 than @code{System.Storage_Unit}.
10345 For an object that is a variable or a constant allocated in a register,
10346 the value is zero.  (The use of this attribute does not force the
10347 allocation of a variable to memory).
10349 For an object that is a formal parameter, this attribute applies
10350 to either the matching actual parameter or to a copy of the
10351 matching actual parameter.
10353 For an access object the value is zero.  Note that
10354 @code{obj.all'Bit} is subject to an @code{Access_Check} for the
10355 designated object.  Similarly for a record component
10356 @code{X.C'Bit} is subject to a discriminant check and
10357 @code{X(I).Bit} and @code{X(I1..I2)'Bit}
10358 are subject to index checks.
10360 This attribute is designed to be compatible with the DEC Ada 83 definition
10361 and implementation of the @code{Bit} attribute.
10363 @node Attribute Bit_Position,Attribute Code_Address,Attribute Bit,Implementation Defined Attributes
10364 @anchor{gnat_rm/implementation_defined_attributes attribute-bit-position}@anchor{177}
10365 @section Attribute Bit_Position
10368 @geindex Bit_Position
10370 @code{R.C'Bit_Position}, where @code{R} is a record object and @code{C} is one
10371 of the fields of the record type, yields the bit
10372 offset within the record contains the first bit of
10373 storage allocated for the object.  The value of this attribute is of the
10374 type `universal_integer'.  The value depends only on the field
10375 @code{C} and is independent of the alignment of
10376 the containing record @code{R}.
10378 @node Attribute Code_Address,Attribute Compiler_Version,Attribute Bit_Position,Implementation Defined Attributes
10379 @anchor{gnat_rm/implementation_defined_attributes attribute-code-address}@anchor{178}
10380 @section Attribute Code_Address
10383 @geindex Code_Address
10385 @geindex Subprogram address
10387 @geindex Address of subprogram code
10389 The @code{'Address}
10390 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
10391 intended effect seems to be to provide
10392 an address value which can be used to call the subprogram by means of
10393 an address clause as in the following example:
10395 @example
10396 procedure K is ...
10398 procedure L;
10399 for L'Address use K'Address;
10400 pragma Import (Ada, L);
10401 @end example
10403 A call to @code{L} is then expected to result in a call to @code{K}.
10404 In Ada 83, where there were no access-to-subprogram values, this was
10405 a common work-around for getting the effect of an indirect call.
10406 GNAT implements the above use of @code{Address} and the technique
10407 illustrated by the example code works correctly.
10409 However, for some purposes, it is useful to have the address of the start
10410 of the generated code for the subprogram.  On some architectures, this is
10411 not necessarily the same as the @code{Address} value described above.
10412 For example, the @code{Address} value may reference a subprogram
10413 descriptor rather than the subprogram itself.
10415 The @code{'Code_Address} attribute, which can only be applied to
10416 subprogram entities, always returns the address of the start of the
10417 generated code of the specified subprogram, which may or may not be
10418 the same value as is returned by the corresponding @code{'Address}
10419 attribute.
10421 @node Attribute Compiler_Version,Attribute Constrained,Attribute Code_Address,Implementation Defined Attributes
10422 @anchor{gnat_rm/implementation_defined_attributes attribute-compiler-version}@anchor{179}
10423 @section Attribute Compiler_Version
10426 @geindex Compiler_Version
10428 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
10429 prefix) yields a static string identifying the version of the compiler
10430 being used to compile the unit containing the attribute reference.
10432 @node Attribute Constrained,Attribute Default_Bit_Order,Attribute Compiler_Version,Implementation Defined Attributes
10433 @anchor{gnat_rm/implementation_defined_attributes attribute-constrained}@anchor{17a}
10434 @section Attribute Constrained
10437 @geindex Constrained
10439 In addition to the usage of this attribute in the Ada RM, GNAT
10440 also permits the use of the @code{'Constrained} attribute
10441 in a generic template
10442 for any type, including types without discriminants. The value of this
10443 attribute in the generic instance when applied to a scalar type or a
10444 record type without discriminants is always @code{True}. This usage is
10445 compatible with older Ada compilers, including notably DEC Ada.
10447 @node Attribute Default_Bit_Order,Attribute Default_Scalar_Storage_Order,Attribute Constrained,Implementation Defined Attributes
10448 @anchor{gnat_rm/implementation_defined_attributes attribute-default-bit-order}@anchor{17b}
10449 @section Attribute Default_Bit_Order
10452 @geindex Big endian
10454 @geindex Little endian
10456 @geindex Default_Bit_Order
10458 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
10459 allowed prefix), provides the value @code{System.Default_Bit_Order}
10460 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
10461 @code{Low_Order_First}).  This is used to construct the definition of
10462 @code{Default_Bit_Order} in package @code{System}.
10464 @node Attribute Default_Scalar_Storage_Order,Attribute Deref,Attribute Default_Bit_Order,Implementation Defined Attributes
10465 @anchor{gnat_rm/implementation_defined_attributes attribute-default-scalar-storage-order}@anchor{17c}
10466 @section Attribute Default_Scalar_Storage_Order
10469 @geindex Big endian
10471 @geindex Little endian
10473 @geindex Default_Scalar_Storage_Order
10475 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
10476 allowed prefix), provides the current value of the default scalar storage
10477 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
10478 equal to @code{Default_Bit_Order} if unspecified) as a
10479 @code{System.Bit_Order} value. This is a static attribute.
10481 @node Attribute Deref,Attribute Descriptor_Size,Attribute Default_Scalar_Storage_Order,Implementation Defined Attributes
10482 @anchor{gnat_rm/implementation_defined_attributes attribute-deref}@anchor{17d}
10483 @section Attribute Deref
10486 @geindex Deref
10488 The attribute @code{typ'Deref(expr)} where @code{expr} is of type @code{System.Address} yields
10489 the variable of type @code{typ} that is located at the given address. It is similar
10490 to @code{(totyp (expr).all)}, where @code{totyp} is an unchecked conversion from address to
10491 a named access-to-@cite{typ} type, except that it yields a variable, so it can be
10492 used on the left side of an assignment.
10494 @node Attribute Descriptor_Size,Attribute Elaborated,Attribute Deref,Implementation Defined Attributes
10495 @anchor{gnat_rm/implementation_defined_attributes attribute-descriptor-size}@anchor{17e}
10496 @section Attribute Descriptor_Size
10499 @geindex Descriptor
10501 @geindex Dope vector
10503 @geindex Descriptor_Size
10505 Nonstatic attribute @code{Descriptor_Size} returns the size in bits of the
10506 descriptor allocated for a type.  The result is non-zero only for unconstrained
10507 array types and the returned value is of type universal integer.  In GNAT, an
10508 array descriptor contains bounds information and is located immediately before
10509 the first element of the array.
10511 @example
10512 type Unconstr_Array is array (Short_Short_Integer range <>) of Positive;
10513 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
10514 @end example
10516 The attribute takes into account any padding due to the alignment of the
10517 component type. In the example above, the descriptor contains two values
10518 of type @code{Short_Short_Integer} representing the low and high bound. But,
10519 since @code{Positive} has an alignment of 4, the size of the descriptor is
10520 @code{2 * Short_Short_Integer'Size} rounded up to the next multiple of 32,
10521 which yields a size of 32 bits, i.e. including 16 bits of padding.
10523 @node Attribute Elaborated,Attribute Elab_Body,Attribute Descriptor_Size,Implementation Defined Attributes
10524 @anchor{gnat_rm/implementation_defined_attributes attribute-elaborated}@anchor{17f}
10525 @section Attribute Elaborated
10528 @geindex Elaborated
10530 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
10531 value is a Boolean which indicates whether or not the given unit has been
10532 elaborated.  This attribute is primarily intended for internal use by the
10533 generated code for dynamic elaboration checking, but it can also be used
10534 in user programs.  The value will always be True once elaboration of all
10535 units has been completed.  An exception is for units which need no
10536 elaboration, the value is always False for such units.
10538 @node Attribute Elab_Body,Attribute Elab_Spec,Attribute Elaborated,Implementation Defined Attributes
10539 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-body}@anchor{180}
10540 @section Attribute Elab_Body
10543 @geindex Elab_Body
10545 This attribute can only be applied to a program unit name.  It returns
10546 the entity for the corresponding elaboration procedure for elaborating
10547 the body of the referenced unit.  This is used in the main generated
10548 elaboration procedure by the binder and is not normally used in any
10549 other context.  However, there may be specialized situations in which it
10550 is useful to be able to call this elaboration procedure from Ada code,
10551 e.g., if it is necessary to do selective re-elaboration to fix some
10552 error.
10554 @node Attribute Elab_Spec,Attribute Elab_Subp_Body,Attribute Elab_Body,Implementation Defined Attributes
10555 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-spec}@anchor{181}
10556 @section Attribute Elab_Spec
10559 @geindex Elab_Spec
10561 This attribute can only be applied to a program unit name.  It returns
10562 the entity for the corresponding elaboration procedure for elaborating
10563 the spec of the referenced unit.  This is used in the main
10564 generated elaboration procedure by the binder and is not normally used
10565 in any other context.  However, there may be specialized situations in
10566 which it is useful to be able to call this elaboration procedure from
10567 Ada code, e.g., if it is necessary to do selective re-elaboration to fix
10568 some error.
10570 @node Attribute Elab_Subp_Body,Attribute Emax,Attribute Elab_Spec,Implementation Defined Attributes
10571 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-subp-body}@anchor{182}
10572 @section Attribute Elab_Subp_Body
10575 @geindex Elab_Subp_Body
10577 This attribute can only be applied to a library level subprogram
10578 name and is only allowed in CodePeer mode. It returns the entity
10579 for the corresponding elaboration procedure for elaborating the body
10580 of the referenced subprogram unit. This is used in the main generated
10581 elaboration procedure by the binder in CodePeer mode only and is unrecognized
10582 otherwise.
10584 @node Attribute Emax,Attribute Enabled,Attribute Elab_Subp_Body,Implementation Defined Attributes
10585 @anchor{gnat_rm/implementation_defined_attributes attribute-emax}@anchor{183}
10586 @section Attribute Emax
10589 @geindex Ada 83 attributes
10591 @geindex Emax
10593 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
10594 the Ada 83 reference manual for an exact description of the semantics of
10595 this attribute.
10597 @node Attribute Enabled,Attribute Enum_Rep,Attribute Emax,Implementation Defined Attributes
10598 @anchor{gnat_rm/implementation_defined_attributes attribute-enabled}@anchor{184}
10599 @section Attribute Enabled
10602 @geindex Enabled
10604 The @code{Enabled} attribute allows an application program to check at compile
10605 time to see if the designated check is currently enabled. The prefix is a
10606 simple identifier, referencing any predefined check name (other than
10607 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
10608 no argument is given for the attribute, the check is for the general state
10609 of the check, if an argument is given, then it is an entity name, and the
10610 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
10611 given naming the entity (if not, then the argument is ignored).
10613 Note that instantiations inherit the check status at the point of the
10614 instantiation, so a useful idiom is to have a library package that
10615 introduces a check name with @code{pragma Check_Name}, and then contains
10616 generic packages or subprograms which use the @code{Enabled} attribute
10617 to see if the check is enabled. A user of this package can then issue
10618 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
10619 the package or subprogram, controlling whether the check will be present.
10621 @node Attribute Enum_Rep,Attribute Enum_Val,Attribute Enabled,Implementation Defined Attributes
10622 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-rep}@anchor{185}
10623 @section Attribute Enum_Rep
10626 @geindex Representation of enums
10628 @geindex Enum_Rep
10630 Note that this attribute is now standard in Ada 202x and is available
10631 as an implementation defined attribute for earlier Ada versions.
10633 For every enumeration subtype @code{S}, @code{S'Enum_Rep} denotes a
10634 function with the following spec:
10636 @example
10637 function S'Enum_Rep (Arg : S'Base) return <Universal_Integer>;
10638 @end example
10640 It is also allowable to apply @code{Enum_Rep} directly to an object of an
10641 enumeration type or to a non-overloaded enumeration
10642 literal.  In this case @code{S'Enum_Rep} is equivalent to
10643 @code{typ'Enum_Rep(S)} where @code{typ} is the type of the
10644 enumeration literal or object.
10646 The function returns the representation value for the given enumeration
10647 value.  This will be equal to value of the @code{Pos} attribute in the
10648 absence of an enumeration representation clause.  This is a static
10649 attribute (i.e., the result is static if the argument is static).
10651 @code{S'Enum_Rep} can also be used with integer types and objects,
10652 in which case it simply returns the integer value.  The reason for this
10653 is to allow it to be used for @code{(<>)} discrete formal arguments in
10654 a generic unit that can be instantiated with either enumeration types
10655 or integer types.  Note that if @code{Enum_Rep} is used on a modular
10656 type whose upper bound exceeds the upper bound of the largest signed
10657 integer type, and the argument is a variable, so that the universal
10658 integer calculation is done at run time, then the call to @code{Enum_Rep}
10659 may raise @code{Constraint_Error}.
10661 @node Attribute Enum_Val,Attribute Epsilon,Attribute Enum_Rep,Implementation Defined Attributes
10662 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-val}@anchor{186}
10663 @section Attribute Enum_Val
10666 @geindex Representation of enums
10668 @geindex Enum_Val
10670 Note that this attribute is now standard in Ada 202x and is available
10671 as an implementation defined attribute for earlier Ada versions.
10673 For every enumeration subtype @code{S}, @code{S'Enum_Val} denotes a
10674 function with the following spec:
10676 @example
10677 function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;
10678 @end example
10680 The function returns the enumeration value whose representation matches the
10681 argument, or raises Constraint_Error if no enumeration literal of the type
10682 has the matching value.
10683 This will be equal to value of the @code{Val} attribute in the
10684 absence of an enumeration representation clause.  This is a static
10685 attribute (i.e., the result is static if the argument is static).
10687 @node Attribute Epsilon,Attribute Fast_Math,Attribute Enum_Val,Implementation Defined Attributes
10688 @anchor{gnat_rm/implementation_defined_attributes attribute-epsilon}@anchor{187}
10689 @section Attribute Epsilon
10692 @geindex Ada 83 attributes
10694 @geindex Epsilon
10696 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
10697 the Ada 83 reference manual for an exact description of the semantics of
10698 this attribute.
10700 @node Attribute Fast_Math,Attribute Finalization_Size,Attribute Epsilon,Implementation Defined Attributes
10701 @anchor{gnat_rm/implementation_defined_attributes attribute-fast-math}@anchor{188}
10702 @section Attribute Fast_Math
10705 @geindex Fast_Math
10707 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
10708 prefix) yields a static Boolean value that is True if pragma
10709 @code{Fast_Math} is active, and False otherwise.
10711 @node Attribute Finalization_Size,Attribute Fixed_Value,Attribute Fast_Math,Implementation Defined Attributes
10712 @anchor{gnat_rm/implementation_defined_attributes attribute-finalization-size}@anchor{189}
10713 @section Attribute Finalization_Size
10716 @geindex Finalization_Size
10718 The prefix of attribute @code{Finalization_Size} must be an object or
10719 a non-class-wide type. This attribute returns the size of any hidden data
10720 reserved by the compiler to handle finalization-related actions. The type of
10721 the attribute is `universal_integer'.
10723 @code{Finalization_Size} yields a value of zero for a type with no controlled
10724 parts, an object whose type has no controlled parts, or an object of a
10725 class-wide type whose tag denotes a type with no controlled parts.
10727 Note that only heap-allocated objects contain finalization data.
10729 @node Attribute Fixed_Value,Attribute From_Any,Attribute Finalization_Size,Implementation Defined Attributes
10730 @anchor{gnat_rm/implementation_defined_attributes attribute-fixed-value}@anchor{18a}
10731 @section Attribute Fixed_Value
10734 @geindex Fixed_Value
10736 For every fixed-point type @code{S}, @code{S'Fixed_Value} denotes a
10737 function with the following specification:
10739 @example
10740 function S'Fixed_Value (Arg : <Universal_Integer>) return S;
10741 @end example
10743 The value returned is the fixed-point value @code{V} such that:
10745 @example
10746 V = Arg * S'Small
10747 @end example
10749 The effect is thus similar to first converting the argument to the
10750 integer type used to represent @code{S}, and then doing an unchecked
10751 conversion to the fixed-point type.  The difference is
10752 that there are full range checks, to ensure that the result is in range.
10753 This attribute is primarily intended for use in implementation of the
10754 input-output functions for fixed-point values.
10756 @node Attribute From_Any,Attribute Has_Access_Values,Attribute Fixed_Value,Implementation Defined Attributes
10757 @anchor{gnat_rm/implementation_defined_attributes attribute-from-any}@anchor{18b}
10758 @section Attribute From_Any
10761 @geindex From_Any
10763 This internal attribute is used for the generation of remote subprogram
10764 stubs in the context of the Distributed Systems Annex.
10766 @node Attribute Has_Access_Values,Attribute Has_Discriminants,Attribute From_Any,Implementation Defined Attributes
10767 @anchor{gnat_rm/implementation_defined_attributes attribute-has-access-values}@anchor{18c}
10768 @section Attribute Has_Access_Values
10771 @geindex Access values
10772 @geindex testing for
10774 @geindex Has_Access_Values
10776 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
10777 is a Boolean value which is True if the is an access type, or is a composite
10778 type with a component (at any nesting depth) that is an access type, and is
10779 False otherwise.
10780 The intended use of this attribute is in conjunction with generic
10781 definitions.  If the attribute is applied to a generic private type, it
10782 indicates whether or not the corresponding actual type has access values.
10784 @node Attribute Has_Discriminants,Attribute Has_Tagged_Values,Attribute Has_Access_Values,Implementation Defined Attributes
10785 @anchor{gnat_rm/implementation_defined_attributes attribute-has-discriminants}@anchor{18d}
10786 @section Attribute Has_Discriminants
10789 @geindex Discriminants
10790 @geindex testing for
10792 @geindex Has_Discriminants
10794 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
10795 is a Boolean value which is True if the type has discriminants, and False
10796 otherwise.  The intended use of this attribute is in conjunction with generic
10797 definitions.  If the attribute is applied to a generic private type, it
10798 indicates whether or not the corresponding actual type has discriminants.
10800 @node Attribute Has_Tagged_Values,Attribute Img,Attribute Has_Discriminants,Implementation Defined Attributes
10801 @anchor{gnat_rm/implementation_defined_attributes attribute-has-tagged-values}@anchor{18e}
10802 @section Attribute Has_Tagged_Values
10805 @geindex Tagged values
10806 @geindex testing for
10808 @geindex Has_Tagged_Values
10810 The prefix of the @code{Has_Tagged_Values} attribute is a type. The result is a
10811 Boolean value which is True if the type is a composite type (array or record)
10812 that is either a tagged type or has a subcomponent that is tagged, and is False
10813 otherwise. The intended use of this attribute is in conjunction with generic
10814 definitions. If the attribute is applied to a generic private type, it
10815 indicates whether or not the corresponding actual type has access values.
10817 @node Attribute Img,Attribute Initialized,Attribute Has_Tagged_Values,Implementation Defined Attributes
10818 @anchor{gnat_rm/implementation_defined_attributes attribute-img}@anchor{18f}
10819 @section Attribute Img
10822 @geindex Img
10824 The @code{Img} attribute differs from @code{Image} in that, while both can be
10825 applied directly to an object, @code{Img} cannot be applied to types.
10827 Example usage of the attribute:
10829 @example
10830 Put_Line ("X = " & X'Img);
10831 @end example
10833 which has the same meaning as the more verbose:
10835 @example
10836 Put_Line ("X = " & T'Image (X));
10837 @end example
10839 where @code{T} is the (sub)type of the object @code{X}.
10841 Note that technically, in analogy to @code{Image},
10842 @code{X'Img} returns a parameterless function
10843 that returns the appropriate string when called. This means that
10844 @code{X'Img} can be renamed as a function-returning-string, or used
10845 in an instantiation as a function parameter.
10847 @node Attribute Initialized,Attribute Integer_Value,Attribute Img,Implementation Defined Attributes
10848 @anchor{gnat_rm/implementation_defined_attributes attribute-initialized}@anchor{190}
10849 @section Attribute Initialized
10852 @geindex Initialized
10854 For the syntax and semantics of this attribute, see the SPARK 2014 Reference
10855 Manual, section 6.10.
10857 @node Attribute Integer_Value,Attribute Invalid_Value,Attribute Initialized,Implementation Defined Attributes
10858 @anchor{gnat_rm/implementation_defined_attributes attribute-integer-value}@anchor{191}
10859 @section Attribute Integer_Value
10862 @geindex Integer_Value
10864 For every integer type @code{S}, @code{S'Integer_Value} denotes a
10865 function with the following spec:
10867 @example
10868 function S'Integer_Value (Arg : <Universal_Fixed>) return S;
10869 @end example
10871 The value returned is the integer value @code{V}, such that:
10873 @example
10874 Arg = V * T'Small
10875 @end example
10877 where @code{T} is the type of @code{Arg}.
10878 The effect is thus similar to first doing an unchecked conversion from
10879 the fixed-point type to its corresponding implementation type, and then
10880 converting the result to the target integer type.  The difference is
10881 that there are full range checks, to ensure that the result is in range.
10882 This attribute is primarily intended for use in implementation of the
10883 standard input-output functions for fixed-point values.
10885 @node Attribute Invalid_Value,Attribute Iterable,Attribute Integer_Value,Implementation Defined Attributes
10886 @anchor{gnat_rm/implementation_defined_attributes attribute-invalid-value}@anchor{192}
10887 @section Attribute Invalid_Value
10890 @geindex Invalid_Value
10892 For every scalar type S, S’Invalid_Value returns an undefined value of the
10893 type. If possible this value is an invalid representation for the type. The
10894 value returned is identical to the value used to initialize an otherwise
10895 uninitialized value of the type if pragma Initialize_Scalars is used,
10896 including the ability to modify the value with the binder -Sxx flag and
10897 relevant environment variables at run time.
10899 @node Attribute Iterable,Attribute Large,Attribute Invalid_Value,Implementation Defined Attributes
10900 @anchor{gnat_rm/implementation_defined_attributes attribute-iterable}@anchor{193}
10901 @section Attribute Iterable
10904 @geindex Iterable
10906 Equivalent to Aspect Iterable.
10908 @node Attribute Large,Attribute Library_Level,Attribute Iterable,Implementation Defined Attributes
10909 @anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{194}
10910 @section Attribute Large
10913 @geindex Ada 83 attributes
10915 @geindex Large
10917 The @code{Large} attribute is provided for compatibility with Ada 83.  See
10918 the Ada 83 reference manual for an exact description of the semantics of
10919 this attribute.
10921 @node Attribute Library_Level,Attribute Loop_Entry,Attribute Large,Implementation Defined Attributes
10922 @anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{195}
10923 @section Attribute Library_Level
10926 @geindex Library_Level
10928 @code{P'Library_Level}, where P is an entity name,
10929 returns a Boolean value which is True if the entity is declared
10930 at the library level, and False otherwise. Note that within a
10931 generic instantiation, the name of the generic unit denotes the
10932 instance, which means that this attribute can be used to test
10933 if a generic is instantiated at the library level, as shown
10934 in this example:
10936 @example
10937 generic
10938   ...
10939 package Gen is
10940   pragma Compile_Time_Error
10941     (not Gen'Library_Level,
10942      "Gen can only be instantiated at library level");
10943   ...
10944 end Gen;
10945 @end example
10947 @node Attribute Loop_Entry,Attribute Machine_Size,Attribute Library_Level,Implementation Defined Attributes
10948 @anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{196}
10949 @section Attribute Loop_Entry
10952 @geindex Loop_Entry
10954 Syntax:
10956 @example
10957 X'Loop_Entry [(loop_name)]
10958 @end example
10960 The @code{Loop_Entry} attribute is used to refer to the value that an
10961 expression had upon entry to a given loop in much the same way that the
10962 @code{Old} attribute in a subprogram postcondition can be used to refer
10963 to the value an expression had upon entry to the subprogram. The
10964 relevant loop is either identified by the given loop name, or it is the
10965 innermost enclosing loop when no loop name is given.
10967 A @code{Loop_Entry} attribute can only occur within an @code{Assert},
10968 @code{Assert_And_Cut}, @code{Assume}, @code{Loop_Variant} or @code{Loop_Invariant} pragma.
10969 In addition, such a pragma must be one of the items in the sequence
10970 of statements of a loop body, or nested inside block statements that
10971 appear in the sequence of statements of a loop body.
10972 A common use of @code{Loop_Entry} is to compare the current value of objects with
10973 their initial value at loop entry, in a @code{Loop_Invariant} pragma.
10975 The effect of using @code{X'Loop_Entry} is the same as declaring
10976 a constant initialized with the initial value of @code{X} at loop
10977 entry. This copy is not performed if the loop is not entered, or if the
10978 corresponding pragmas are ignored or disabled.
10980 @node Attribute Machine_Size,Attribute Mantissa,Attribute Loop_Entry,Implementation Defined Attributes
10981 @anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{197}
10982 @section Attribute Machine_Size
10985 @geindex Machine_Size
10987 This attribute is identical to the @code{Object_Size} attribute.  It is
10988 provided for compatibility with the DEC Ada 83 attribute of this name.
10990 @node Attribute Mantissa,Attribute Maximum_Alignment,Attribute Machine_Size,Implementation Defined Attributes
10991 @anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{198}
10992 @section Attribute Mantissa
10995 @geindex Ada 83 attributes
10997 @geindex Mantissa
10999 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
11000 the Ada 83 reference manual for an exact description of the semantics of
11001 this attribute.
11003 @node Attribute Maximum_Alignment,Attribute Max_Integer_Size,Attribute Mantissa,Implementation Defined Attributes
11004 @anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{199}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{19a}
11005 @section Attribute Maximum_Alignment
11008 @geindex Alignment
11009 @geindex maximum
11011 @geindex Maximum_Alignment
11013 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
11014 allowed prefix) provides the maximum useful alignment value for the
11015 target.  This is a static value that can be used to specify the alignment
11016 for an object, guaranteeing that it is properly aligned in all
11017 cases.
11019 @node Attribute Max_Integer_Size,Attribute Mechanism_Code,Attribute Maximum_Alignment,Implementation Defined Attributes
11020 @anchor{gnat_rm/implementation_defined_attributes attribute-max-integer-size}@anchor{19b}
11021 @section Attribute Max_Integer_Size
11024 @geindex Max_Integer_Size
11026 @code{Standard'Max_Integer_Size} (@code{Standard} is the only allowed
11027 prefix) provides the size of the largest supported integer type for
11028 the target. The result is a static constant.
11030 @node Attribute Mechanism_Code,Attribute Null_Parameter,Attribute Max_Integer_Size,Implementation Defined Attributes
11031 @anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{19c}
11032 @section Attribute Mechanism_Code
11035 @geindex Return values
11036 @geindex passing mechanism
11038 @geindex Parameters
11039 @geindex passing mechanism
11041 @geindex Mechanism_Code
11043 @code{func'Mechanism_Code} yields an integer code for the
11044 mechanism used for the result of function @code{func}, and
11045 @code{subprog'Mechanism_Code (n)} yields the mechanism
11046 used for formal parameter number `n' (a static integer value, with 1
11047 meaning the first parameter) of subprogram @code{subprog}.  The code returned is:
11050 @table @asis
11052 @item `1'
11054 by copy (value)
11056 @item `2'
11058 by reference
11059 @end table
11061 @node Attribute Null_Parameter,Attribute Object_Size,Attribute Mechanism_Code,Implementation Defined Attributes
11062 @anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{19d}
11063 @section Attribute Null_Parameter
11066 @geindex Zero address
11067 @geindex passing
11069 @geindex Null_Parameter
11071 A reference @code{T'Null_Parameter} denotes an imaginary object of
11072 type or subtype @code{T} allocated at machine address zero.  The attribute
11073 is allowed only as the default expression of a formal parameter, or as
11074 an actual expression of a subprogram call.  In either case, the
11075 subprogram must be imported.
11077 The identity of the object is represented by the address zero in the
11078 argument list, independent of the passing mechanism (explicit or
11079 default).
11081 This capability is needed to specify that a zero address should be
11082 passed for a record or other composite object passed by reference.
11083 There is no way of indicating this without the @code{Null_Parameter}
11084 attribute.
11086 @node Attribute Object_Size,Attribute Old,Attribute Null_Parameter,Implementation Defined Attributes
11087 @anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{14c}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{19e}
11088 @section Attribute Object_Size
11091 @geindex Size
11092 @geindex used for objects
11094 @geindex Object_Size
11096 The size of an object is not necessarily the same as the size of the type
11097 of an object.  This is because by default object sizes are increased to be
11098 a multiple of the alignment of the object.  For example,
11099 @code{Natural'Size} is
11100 31, but by default objects of type @code{Natural} will have a size of 32 bits.
11101 Similarly, a record containing an integer and a character:
11103 @example
11104 type Rec is record
11105    I : Integer;
11106    C : Character;
11107 end record;
11108 @end example
11110 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
11111 alignment will be 4, because of the
11112 integer field, and so the default size of record objects for this type
11113 will be 64 (8 bytes).
11115 If the alignment of the above record is specified to be 1, then the
11116 object size will be 40 (5 bytes). This is true by default, and also
11117 an object size of 40 can be explicitly specified in this case.
11119 A consequence of this capability is that different object sizes can be
11120 given to subtypes that would otherwise be considered in Ada to be
11121 statically matching.  But it makes no sense to consider such subtypes
11122 as statically matching.  Consequently, GNAT adds a rule
11123 to the static matching rules that requires object sizes to match.
11124 Consider this example:
11126 @example
11127  1. procedure BadAVConvert is
11128  2.    type R is new Integer;
11129  3.    subtype R1 is R range 1 .. 10;
11130  4.    subtype R2 is R range 1 .. 10;
11131  5.    for R1'Object_Size use 8;
11132  6.    for R2'Object_Size use 16;
11133  7.    type R1P is access all R1;
11134  8.    type R2P is access all R2;
11135  9.    R1PV : R1P := new R1'(4);
11136 10.    R2PV : R2P;
11137 11. begin
11138 12.    R2PV := R2P (R1PV);
11139                |
11140        >>> target designated subtype not compatible with
11141            type "R1" defined at line 3
11143 13. end;
11144 @end example
11146 In the absence of lines 5 and 6,
11147 types @code{R1} and @code{R2} statically match and
11148 hence the conversion on line 12 is legal. But since lines 5 and 6
11149 cause the object sizes to differ, GNAT considers that types
11150 @code{R1} and @code{R2} are not statically matching, and line 12
11151 generates the diagnostic shown above.
11153 Similar additional checks are performed in other contexts requiring
11154 statically matching subtypes.
11156 @node Attribute Old,Attribute Passed_By_Reference,Attribute Object_Size,Implementation Defined Attributes
11157 @anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{19f}
11158 @section Attribute Old
11161 @geindex Old
11163 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
11164 within @code{Post} aspect), GNAT also permits the use of this attribute
11165 in implementation defined pragmas @code{Postcondition},
11166 @code{Contract_Cases} and @code{Test_Case}. Also usages of
11167 @code{Old} which would be illegal according to the Ada 2012 RM
11168 definition are allowed under control of
11169 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
11171 @node Attribute Passed_By_Reference,Attribute Pool_Address,Attribute Old,Implementation Defined Attributes
11172 @anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{1a0}
11173 @section Attribute Passed_By_Reference
11176 @geindex Parameters
11177 @geindex when passed by reference
11179 @geindex Passed_By_Reference
11181 @code{typ'Passed_By_Reference} for any subtype @cite{typ} returns
11182 a value of type @code{Boolean} value that is @code{True} if the type is
11183 normally passed by reference and @code{False} if the type is normally
11184 passed by copy in calls.  For scalar types, the result is always @code{False}
11185 and is static.  For non-scalar types, the result is nonstatic.
11187 @node Attribute Pool_Address,Attribute Range_Length,Attribute Passed_By_Reference,Implementation Defined Attributes
11188 @anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{1a1}
11189 @section Attribute Pool_Address
11192 @geindex Pool_Address
11194 @code{X'Pool_Address} for any object @code{X} returns the address
11195 of X within its storage pool. This is the same as
11196 @code{X'Address}, except that for an unconstrained array whose
11197 bounds are allocated just before the first component,
11198 @code{X'Pool_Address} returns the address of those bounds,
11199 whereas @code{X'Address} returns the address of the first
11200 component.
11202 Here, we are interpreting ‘storage pool’ broadly to mean
11203 @code{wherever the object is allocated}, which could be a
11204 user-defined storage pool,
11205 the global heap, on the stack, or in a static memory area.
11206 For an object created by @code{new}, @code{Ptr.all'Pool_Address} is
11207 what is passed to @code{Allocate} and returned from @code{Deallocate}.
11209 @node Attribute Range_Length,Attribute Restriction_Set,Attribute Pool_Address,Implementation Defined Attributes
11210 @anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{1a2}
11211 @section Attribute Range_Length
11214 @geindex Range_Length
11216 @code{typ'Range_Length} for any discrete type @cite{typ} yields
11217 the number of values represented by the subtype (zero for a null
11218 range).  The result is static for static subtypes.  @code{Range_Length}
11219 applied to the index subtype of a one dimensional array always gives the
11220 same result as @code{Length} applied to the array itself.
11222 @node Attribute Restriction_Set,Attribute Result,Attribute Range_Length,Implementation Defined Attributes
11223 @anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{1a3}
11224 @section Attribute Restriction_Set
11227 @geindex Restriction_Set
11229 @geindex Restrictions
11231 This attribute allows compile time testing of restrictions that
11232 are currently in effect. It is primarily intended for specializing
11233 code in the run-time based on restrictions that are active (e.g.
11234 don’t need to save fpt registers if restriction No_Floating_Point
11235 is known to be in effect), but can be used anywhere.
11237 There are two forms:
11239 @example
11240 System'Restriction_Set (partition_boolean_restriction_NAME)
11241 System'Restriction_Set (No_Dependence => library_unit_NAME);
11242 @end example
11244 In the case of the first form, the only restriction names
11245 allowed are parameterless restrictions that are checked
11246 for consistency at bind time. For a complete list see the
11247 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
11249 The result returned is True if the restriction is known to
11250 be in effect, and False if the restriction is known not to
11251 be in effect. An important guarantee is that the value of
11252 a Restriction_Set attribute is known to be consistent throughout
11253 all the code of a partition.
11255 This is trivially achieved if the entire partition is compiled
11256 with a consistent set of restriction pragmas. However, the
11257 compilation model does not require this. It is possible to
11258 compile one set of units with one set of pragmas, and another
11259 set of units with another set of pragmas. It is even possible
11260 to compile a spec with one set of pragmas, and then WITH the
11261 same spec with a different set of pragmas. Inconsistencies
11262 in the actual use of the restriction are checked at bind time.
11264 In order to achieve the guarantee of consistency for the
11265 Restriction_Set pragma, we consider that a use of the pragma
11266 that yields False is equivalent to a violation of the
11267 restriction.
11269 So for example if you write
11271 @example
11272 if System'Restriction_Set (No_Floating_Point) then
11273    ...
11274 else
11275    ...
11276 end if;
11277 @end example
11279 And the result is False, so that the else branch is executed,
11280 you can assume that this restriction is not set for any unit
11281 in the partition. This is checked by considering this use of
11282 the restriction pragma to be a violation of the restriction
11283 No_Floating_Point. This means that no other unit can attempt
11284 to set this restriction (if some unit does attempt to set it,
11285 the binder will refuse to bind the partition).
11287 Technical note: The restriction name and the unit name are
11288 intepreted entirely syntactically, as in the corresponding
11289 Restrictions pragma, they are not analyzed semantically,
11290 so they do not have a type.
11292 @node Attribute Result,Attribute Safe_Emax,Attribute Restriction_Set,Implementation Defined Attributes
11293 @anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{1a4}
11294 @section Attribute Result
11297 @geindex Result
11299 @code{function'Result} can only be used with in a Postcondition pragma
11300 for a function. The prefix must be the name of the corresponding function. This
11301 is used to refer to the result of the function in the postcondition expression.
11302 For a further discussion of the use of this attribute and examples of its use,
11303 see the description of pragma Postcondition.
11305 @node Attribute Safe_Emax,Attribute Safe_Large,Attribute Result,Implementation Defined Attributes
11306 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{1a5}
11307 @section Attribute Safe_Emax
11310 @geindex Ada 83 attributes
11312 @geindex Safe_Emax
11314 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
11315 the Ada 83 reference manual for an exact description of the semantics of
11316 this attribute.
11318 @node Attribute Safe_Large,Attribute Safe_Small,Attribute Safe_Emax,Implementation Defined Attributes
11319 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{1a6}
11320 @section Attribute Safe_Large
11323 @geindex Ada 83 attributes
11325 @geindex Safe_Large
11327 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
11328 the Ada 83 reference manual for an exact description of the semantics of
11329 this attribute.
11331 @node Attribute Safe_Small,Attribute Scalar_Storage_Order,Attribute Safe_Large,Implementation Defined Attributes
11332 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{1a7}
11333 @section Attribute Safe_Small
11336 @geindex Ada 83 attributes
11338 @geindex Safe_Small
11340 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
11341 the Ada 83 reference manual for an exact description of the semantics of
11342 this attribute.
11344 @node Attribute Scalar_Storage_Order,Attribute Simple_Storage_Pool,Attribute Safe_Small,Implementation Defined Attributes
11345 @anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{15a}@anchor{gnat_rm/implementation_defined_attributes id4}@anchor{1a8}
11346 @section Attribute Scalar_Storage_Order
11349 @geindex Endianness
11351 @geindex Scalar storage order
11353 @geindex Scalar_Storage_Order
11355 For every array or record type @code{S}, the representation attribute
11356 @code{Scalar_Storage_Order} denotes the order in which storage elements
11357 that make up scalar components are ordered within S. The value given must
11358 be a static expression of type System.Bit_Order. The following is an example
11359 of the use of this feature:
11361 @example
11362 --  Component type definitions
11364 subtype Yr_Type is Natural range 0 .. 127;
11365 subtype Mo_Type is Natural range 1 .. 12;
11366 subtype Da_Type is Natural range 1 .. 31;
11368 --  Record declaration
11370 type Date is record
11371    Years_Since_1980 : Yr_Type;
11372    Month            : Mo_Type;
11373    Day_Of_Month     : Da_Type;
11374 end record;
11376 --  Record representation clause
11378 for Date use record
11379    Years_Since_1980 at 0 range 0  ..  6;
11380    Month            at 0 range 7  .. 10;
11381    Day_Of_Month     at 0 range 11 .. 15;
11382 end record;
11384 --  Attribute definition clauses
11386 for Date'Bit_Order use System.High_Order_First;
11387 for Date'Scalar_Storage_Order use System.High_Order_First;
11388 --  If Scalar_Storage_Order is specified, it must be consistent with
11389 --  Bit_Order, so it's best to always define the latter explicitly if
11390 --  the former is used.
11391 @end example
11393 Other properties are as for the standard representation attribute @code{Bit_Order}
11394 defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
11396 For a record type @code{T}, if @code{T'Scalar_Storage_Order} is
11397 specified explicitly, it shall be equal to @code{T'Bit_Order}. Note:
11398 this means that if a @code{Scalar_Storage_Order} attribute definition
11399 clause is not confirming, then the type’s @code{Bit_Order} shall be
11400 specified explicitly and set to the same value.
11402 Derived types inherit an explicitly set scalar storage order from their parent
11403 types. This may be overridden for the derived type by giving an explicit scalar
11404 storage order for it. However, for a record extension, the derived type must
11405 have the same scalar storage order as the parent type.
11407 A component of a record type that is itself a record or an array and that does
11408 not start and end on a byte boundary must have have the same scalar storage
11409 order as the record type. A component of a bit-packed array type that is itself
11410 a record or an array must have the same scalar storage order as the array type.
11412 No component of a type that has an explicit @code{Scalar_Storage_Order}
11413 attribute definition may be aliased.
11415 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
11416 with a value equal to @code{System.Default_Bit_Order}) has no effect.
11418 If the opposite storage order is specified, then whenever the value of
11419 a scalar component of an object of type @code{S} is read, the storage
11420 elements of the enclosing machine scalar are first reversed (before
11421 retrieving the component value, possibly applying some shift and mask
11422 operatings on the enclosing machine scalar), and the opposite operation
11423 is done for writes.
11425 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
11426 are relaxed. Instead, the following rules apply:
11429 @itemize *
11431 @item 
11432 the underlying storage elements are those at positions
11433 @code{(position + first_bit / storage_element_size) .. (position + (last_bit + storage_element_size - 1) / storage_element_size)}
11435 @item 
11436 the sequence of underlying storage elements shall have
11437 a size no greater than the largest machine scalar
11439 @item 
11440 the enclosing machine scalar is defined as the smallest machine
11441 scalar starting at a position no greater than
11442 @code{position + first_bit / storage_element_size} and covering
11443 storage elements at least up to @code{position + (last_bit + storage_element_size - 1) / storage_element_size}
11445 @item 
11446 the position of the component is interpreted relative to that machine
11447 scalar.
11448 @end itemize
11450 If no scalar storage order is specified for a type (either directly, or by
11451 inheritance in the case of a derived type), then the default is normally
11452 the native ordering of the target, but this default can be overridden using
11453 pragma @code{Default_Scalar_Storage_Order}.
11455 If a component of @code{T} is itself of a record or array type, the specfied
11456 @code{Scalar_Storage_Order} does `not' apply to that nested type: an explicit
11457 attribute definition clause must be provided for the component type as well
11458 if desired.
11460 Representation changes that explicitly or implicitly toggle the scalar storage
11461 order are not supported and may result in erroneous execution of the program,
11462 except when performed by means of an instance of @code{Ada.Unchecked_Conversion}.
11464 In particular, overlays are not supported and a warning is given for them:
11466 @example
11467 type Rec_LE is record
11468    I : Integer;
11469 end record;
11471 for Rec_LE use record
11472    I at 0 range 0 .. 31;
11473 end record;
11475 for Rec_LE'Bit_Order use System.Low_Order_First;
11476 for Rec_LE'Scalar_Storage_Order use System.Low_Order_First;
11478 type Rec_BE is record
11479    I : Integer;
11480 end record;
11482 for Rec_BE use record
11483    I at 0 range 0 .. 31;
11484 end record;
11486 for Rec_BE'Bit_Order use System.High_Order_First;
11487 for Rec_BE'Scalar_Storage_Order use System.High_Order_First;
11489 R_LE : Rec_LE;
11491 R_BE : Rec_BE;
11492 for R_BE'Address use R_LE'Address;
11493 @end example
11495 @code{warning: overlay changes scalar storage order [enabled by default]}
11497 In most cases, such representation changes ought to be replaced by an
11498 instantiation of a function or procedure provided by @code{GNAT.Byte_Swapping}.
11500 Note that the scalar storage order only affects the in-memory data
11501 representation. It has no effect on the representation used by stream
11502 attributes.
11504 Note that debuggers may be unable to display the correct value of scalar
11505 components of a type for which the opposite storage order is specified.
11507 @node Attribute Simple_Storage_Pool,Attribute Small,Attribute Scalar_Storage_Order,Implementation Defined Attributes
11508 @anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{eb}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{1a9}
11509 @section Attribute Simple_Storage_Pool
11512 @geindex Storage pool
11513 @geindex simple
11515 @geindex Simple storage pool
11517 @geindex Simple_Storage_Pool
11519 For every nonformal, nonderived access-to-object type @code{Acc}, the
11520 representation attribute @code{Simple_Storage_Pool} may be specified
11521 via an attribute_definition_clause (or by specifying the equivalent aspect):
11523 @example
11524 My_Pool : My_Simple_Storage_Pool_Type;
11526 type Acc is access My_Data_Type;
11528 for Acc'Simple_Storage_Pool use My_Pool;
11529 @end example
11531 The name given in an attribute_definition_clause for the
11532 @code{Simple_Storage_Pool} attribute shall denote a variable of
11533 a ‘simple storage pool type’ (see pragma @cite{Simple_Storage_Pool_Type}).
11535 The use of this attribute is only allowed for a prefix denoting a type
11536 for which it has been specified. The type of the attribute is the type
11537 of the variable specified as the simple storage pool of the access type,
11538 and the attribute denotes that variable.
11540 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
11541 for the same access type.
11543 If the @code{Simple_Storage_Pool} attribute has been specified for an access
11544 type, then applying the @code{Storage_Pool} attribute to the type is flagged
11545 with a warning and its evaluation raises the exception @code{Program_Error}.
11547 If the Simple_Storage_Pool attribute has been specified for an access
11548 type @code{S}, then the evaluation of the attribute @code{S'Storage_Size}
11549 returns the result of calling @code{Storage_Size (S'Simple_Storage_Pool)},
11550 which is intended to indicate the number of storage elements reserved for
11551 the simple storage pool. If the Storage_Size function has not been defined
11552 for the simple storage pool type, then this attribute returns zero.
11554 If an access type @code{S} has a specified simple storage pool of type
11555 @code{SSP}, then the evaluation of an allocator for that access type calls
11556 the primitive @code{Allocate} procedure for type @code{SSP}, passing
11557 @code{S'Simple_Storage_Pool} as the pool parameter. The detailed
11558 semantics of such allocators is the same as those defined for allocators
11559 in section 13.11 of the @cite{Ada Reference Manual}, with the term
11560 `simple storage pool' substituted for `storage pool'.
11562 If an access type @code{S} has a specified simple storage pool of type
11563 @code{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
11564 for that access type invokes the primitive @code{Deallocate} procedure
11565 for type @code{SSP}, passing @code{S'Simple_Storage_Pool} as the pool
11566 parameter. The detailed semantics of such unchecked deallocations is the same
11567 as defined in section 13.11.2 of the Ada Reference Manual, except that the
11568 term `simple storage pool' is substituted for `storage pool'.
11570 @node Attribute Small,Attribute Small_Denominator,Attribute Simple_Storage_Pool,Implementation Defined Attributes
11571 @anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1aa}
11572 @section Attribute Small
11575 @geindex Ada 83 attributes
11577 @geindex Small
11579 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
11580 fixed-point types.
11581 GNAT also allows this attribute to be applied to floating-point types
11582 for compatibility with Ada 83.  See
11583 the Ada 83 reference manual for an exact description of the semantics of
11584 this attribute when applied to floating-point types.
11586 @node Attribute Small_Denominator,Attribute Small_Numerator,Attribute Small,Implementation Defined Attributes
11587 @anchor{gnat_rm/implementation_defined_attributes attribute-small-denominator}@anchor{1ab}
11588 @section Attribute Small_Denominator
11591 @geindex Small
11593 @geindex Small_Denominator
11595 @code{typ'Small_Denominator} for any fixed-point subtype @cite{typ} yields the
11596 denominator in the representation of @code{typ'Small} as a rational number
11597 with coprime factors (i.e. as an irreducible fraction).
11599 @node Attribute Small_Numerator,Attribute Storage_Unit,Attribute Small_Denominator,Implementation Defined Attributes
11600 @anchor{gnat_rm/implementation_defined_attributes attribute-small-numerator}@anchor{1ac}
11601 @section Attribute Small_Numerator
11604 @geindex Small
11606 @geindex Small_Numerator
11608 @code{typ'Small_Numerator} for any fixed-point subtype @cite{typ} yields the
11609 numerator in the representation of @code{typ'Small} as a rational number
11610 with coprime factors (i.e. as an irreducible fraction).
11612 @node Attribute Storage_Unit,Attribute Stub_Type,Attribute Small_Numerator,Implementation Defined Attributes
11613 @anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1ad}
11614 @section Attribute Storage_Unit
11617 @geindex Storage_Unit
11619 @code{Standard'Storage_Unit} (@code{Standard} is the only allowed
11620 prefix) provides the same value as @code{System.Storage_Unit}.
11622 @node Attribute Stub_Type,Attribute System_Allocator_Alignment,Attribute Storage_Unit,Implementation Defined Attributes
11623 @anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1ae}
11624 @section Attribute Stub_Type
11627 @geindex Stub_Type
11629 The GNAT implementation of remote access-to-classwide types is
11630 organized as described in AARM section E.4 (20.t): a value of an RACW type
11631 (designating a remote object) is represented as a normal access
11632 value, pointing to a “stub” object which in turn contains the
11633 necessary information to contact the designated remote object. A
11634 call on any dispatching operation of such a stub object does the
11635 remote call, if necessary, using the information in the stub object
11636 to locate the target partition, etc.
11638 For a prefix @code{T} that denotes a remote access-to-classwide type,
11639 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
11641 By construction, the layout of @code{T'Stub_Type} is identical to that of
11642 type @code{RACW_Stub_Type} declared in the internal implementation-defined
11643 unit @code{System.Partition_Interface}. Use of this attribute will create
11644 an implicit dependency on this unit.
11646 @node Attribute System_Allocator_Alignment,Attribute Target_Name,Attribute Stub_Type,Implementation Defined Attributes
11647 @anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1af}
11648 @section Attribute System_Allocator_Alignment
11651 @geindex Alignment
11652 @geindex allocator
11654 @geindex System_Allocator_Alignment
11656 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
11657 allowed prefix) provides the observable guaranteed to be honored by
11658 the system allocator (malloc). This is a static value that can be used
11659 in user storage pools based on malloc either to reject allocation
11660 with alignment too large or to enable a realignment circuitry if the
11661 alignment request is larger than this value.
11663 @node Attribute Target_Name,Attribute To_Address,Attribute System_Allocator_Alignment,Implementation Defined Attributes
11664 @anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1b0}
11665 @section Attribute Target_Name
11668 @geindex Target_Name
11670 @code{Standard'Target_Name} (@code{Standard} is the only allowed
11671 prefix) provides a static string value that identifies the target
11672 for the current compilation. For GCC implementations, this is the
11673 standard gcc target name without the terminating slash (for
11674 example, GNAT 5.0 on windows yields “i586-pc-mingw32msv”).
11676 @node Attribute To_Address,Attribute To_Any,Attribute Target_Name,Implementation Defined Attributes
11677 @anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1b1}
11678 @section Attribute To_Address
11681 @geindex To_Address
11683 The @code{System'To_Address}
11684 (@code{System} is the only allowed prefix)
11685 denotes a function identical to
11686 @code{System.Storage_Elements.To_Address} except that
11687 it is a static attribute.  This means that if its argument is
11688 a static expression, then the result of the attribute is a
11689 static expression.  This means that such an expression can be
11690 used in contexts (e.g., preelaborable packages) which require a
11691 static expression and where the function call could not be used
11692 (since the function call is always nonstatic, even if its
11693 argument is static). The argument must be in the range
11694 -(2**(m-1)) .. 2**m-1, where m is the memory size
11695 (typically 32 or 64). Negative values are intepreted in a
11696 modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on
11697 a 32 bits machine).
11699 @node Attribute To_Any,Attribute Type_Class,Attribute To_Address,Implementation Defined Attributes
11700 @anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1b2}
11701 @section Attribute To_Any
11704 @geindex To_Any
11706 This internal attribute is used for the generation of remote subprogram
11707 stubs in the context of the Distributed Systems Annex.
11709 @node Attribute Type_Class,Attribute Type_Key,Attribute To_Any,Implementation Defined Attributes
11710 @anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1b3}
11711 @section Attribute Type_Class
11714 @geindex Type_Class
11716 @code{typ'Type_Class} for any type or subtype @cite{typ} yields
11717 the value of the type class for the full type of @cite{typ}.  If
11718 @cite{typ} is a generic formal type, the value is the value for the
11719 corresponding actual subtype.  The value of this attribute is of type
11720 @code{System.Aux_DEC.Type_Class}, which has the following definition:
11722 @example
11723 type Type_Class is
11724   (Type_Class_Enumeration,
11725    Type_Class_Integer,
11726    Type_Class_Fixed_Point,
11727    Type_Class_Floating_Point,
11728    Type_Class_Array,
11729    Type_Class_Record,
11730    Type_Class_Access,
11731    Type_Class_Task,
11732    Type_Class_Address);
11733 @end example
11735 Protected types yield the value @code{Type_Class_Task}, which thus
11736 applies to all concurrent types.  This attribute is designed to
11737 be compatible with the DEC Ada 83 attribute of the same name.
11739 @node Attribute Type_Key,Attribute TypeCode,Attribute Type_Class,Implementation Defined Attributes
11740 @anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1b4}
11741 @section Attribute Type_Key
11744 @geindex Type_Key
11746 The @code{Type_Key} attribute is applicable to a type or subtype and
11747 yields a value of type Standard.String containing encoded information
11748 about the type or subtype. This provides improved compatibility with
11749 other implementations that support this attribute.
11751 @node Attribute TypeCode,Attribute Unconstrained_Array,Attribute Type_Key,Implementation Defined Attributes
11752 @anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1b5}
11753 @section Attribute TypeCode
11756 @geindex TypeCode
11758 This internal attribute is used for the generation of remote subprogram
11759 stubs in the context of the Distributed Systems Annex.
11761 @node Attribute Unconstrained_Array,Attribute Universal_Literal_String,Attribute TypeCode,Implementation Defined Attributes
11762 @anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1b6}
11763 @section Attribute Unconstrained_Array
11766 @geindex Unconstrained_Array
11768 The @code{Unconstrained_Array} attribute can be used with a prefix that
11769 denotes any type or subtype. It is a static attribute that yields
11770 @code{True} if the prefix designates an unconstrained array,
11771 and @code{False} otherwise. In a generic instance, the result is
11772 still static, and yields the result of applying this test to the
11773 generic actual.
11775 @node Attribute Universal_Literal_String,Attribute Unrestricted_Access,Attribute Unconstrained_Array,Implementation Defined Attributes
11776 @anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1b7}
11777 @section Attribute Universal_Literal_String
11780 @geindex Named numbers
11781 @geindex representation of
11783 @geindex Universal_Literal_String
11785 The prefix of @code{Universal_Literal_String} must be a named
11786 number.  The static result is the string consisting of the characters of
11787 the number as defined in the original source.  This allows the user
11788 program to access the actual text of named numbers without intermediate
11789 conversions and without the need to enclose the strings in quotes (which
11790 would preclude their use as numbers).
11792 For example, the following program prints the first 50 digits of pi:
11794 @example
11795 with Text_IO; use Text_IO;
11796 with Ada.Numerics;
11797 procedure Pi is
11798 begin
11799    Put (Ada.Numerics.Pi'Universal_Literal_String);
11800 end;
11801 @end example
11803 @node Attribute Unrestricted_Access,Attribute Update,Attribute Universal_Literal_String,Implementation Defined Attributes
11804 @anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1b8}
11805 @section Attribute Unrestricted_Access
11808 @geindex Access
11809 @geindex unrestricted
11811 @geindex Unrestricted_Access
11813 The @code{Unrestricted_Access} attribute is similar to @code{Access}
11814 except that all accessibility and aliased view checks are omitted.  This
11815 is a user-beware attribute.
11817 For objects, it is similar to @code{Address}, for which it is a
11818 desirable replacement where the value desired is an access type.
11819 In other words, its effect is similar to first applying the
11820 @code{Address} attribute and then doing an unchecked conversion to a
11821 desired access type.
11823 For subprograms, @code{P'Unrestricted_Access} may be used where
11824 @code{P'Access} would be illegal, to construct a value of a
11825 less-nested named access type that designates a more-nested
11826 subprogram. This value may be used in indirect calls, so long as the
11827 more-nested subprogram still exists; once the subprogram containing it
11828 has returned, such calls are erroneous. For example:
11830 @example
11831 package body P is
11833    type Less_Nested is not null access procedure;
11834    Global : Less_Nested;
11836    procedure P1 is
11837    begin
11838       Global.all;
11839    end P1;
11841    procedure P2 is
11842       Local_Var : Integer;
11844       procedure More_Nested is
11845       begin
11846          ... Local_Var ...
11847       end More_Nested;
11848    begin
11849       Global := More_Nested'Unrestricted_Access;
11850       P1;
11851    end P2;
11853 end P;
11854 @end example
11856 When P1 is called from P2, the call via Global is OK, but if P1 were
11857 called after P2 returns, it would be an erroneous use of a dangling
11858 pointer.
11860 For objects, it is possible to use @code{Unrestricted_Access} for any
11861 type. However, if the result is of an access-to-unconstrained array
11862 subtype, then the resulting pointer has the same scope as the context
11863 of the attribute, and must not be returned to some enclosing scope.
11864 For instance, if a function uses @code{Unrestricted_Access} to create
11865 an access-to-unconstrained-array and returns that value to the caller,
11866 the result will involve dangling pointers. In addition, it is only
11867 valid to create pointers to unconstrained arrays using this attribute
11868 if the pointer has the normal default ‘fat’ representation where a
11869 pointer has two components, one points to the array and one points to
11870 the bounds. If a size clause is used to force ‘thin’ representation
11871 for a pointer to unconstrained where there is only space for a single
11872 pointer, then the resulting pointer is not usable.
11874 In the simple case where a direct use of Unrestricted_Access attempts
11875 to make a thin pointer for a non-aliased object, the compiler will
11876 reject the use as illegal, as shown in the following example:
11878 @example
11879 with System; use System;
11880 procedure SliceUA2 is
11881    type A is access all String;
11882    for A'Size use Standard'Address_Size;
11884    procedure P (Arg : A) is
11885    begin
11886       null;
11887    end P;
11889    X : String := "hello world!";
11890    X2 : aliased String := "hello world!";
11892    AV : A := X'Unrestricted_Access;    -- ERROR
11893              |
11894 >>> illegal use of Unrestricted_Access attribute
11895 >>> attempt to generate thin pointer to unaliased object
11897 begin
11898    P (X'Unrestricted_Access);          -- ERROR
11899       |
11900 >>> illegal use of Unrestricted_Access attribute
11901 >>> attempt to generate thin pointer to unaliased object
11903    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
11904       |
11905 >>> illegal use of Unrestricted_Access attribute
11906 >>> attempt to generate thin pointer to unaliased object
11908    P (X2'Unrestricted_Access);         -- OK
11909 end;
11910 @end example
11912 but other cases cannot be detected by the compiler, and are
11913 considered to be erroneous. Consider the following example:
11915 @example
11916 with System; use System;
11917 with System; use System;
11918 procedure SliceUA is
11919    type AF is access all String;
11921    type A is access all String;
11922    for A'Size use Standard'Address_Size;
11924    procedure P (Arg : A) is
11925    begin
11926       if Arg'Length /= 6 then
11927          raise Program_Error;
11928       end if;
11929    end P;
11931    X : String := "hello world!";
11932    Y : AF := X (7 .. 12)'Unrestricted_Access;
11934 begin
11935    P (A (Y));
11936 end;
11937 @end example
11939 A normal unconstrained array value
11940 or a constrained array object marked as aliased has the bounds in memory
11941 just before the array, so a thin pointer can retrieve both the data and
11942 the bounds.  But in this case, the non-aliased object @code{X} does not have the
11943 bounds before the string.  If the size clause for type @code{A}
11944 were not present, then the pointer
11945 would be a fat pointer, where one component is a pointer to the bounds,
11946 and all would be well.  But with the size clause present, the conversion from
11947 fat pointer to thin pointer in the call loses the bounds, and so this
11948 is erroneous, and the program likely raises a @code{Program_Error} exception.
11950 In general, it is advisable to completely
11951 avoid mixing the use of thin pointers and the use of
11952 @code{Unrestricted_Access} where the designated type is an
11953 unconstrained array.  The use of thin pointers should be restricted to
11954 cases of porting legacy code that implicitly assumes the size of pointers,
11955 and such code should not in any case be using this attribute.
11957 Another erroneous situation arises if the attribute is
11958 applied to a constant. The resulting pointer can be used to access the
11959 constant, but the effect of trying to modify a constant in this manner
11960 is not well-defined. Consider this example:
11962 @example
11963 P : constant Integer := 4;
11964 type R is access all Integer;
11965 RV : R := P'Unrestricted_Access;
11967 RV.all := 3;
11968 @end example
11970 Here we attempt to modify the constant P from 4 to 3, but the compiler may
11971 or may not notice this attempt, and subsequent references to P may yield
11972 either the value 3 or the value 4 or the assignment may blow up if the
11973 compiler decides to put P in read-only memory. One particular case where
11974 @code{Unrestricted_Access} can be used in this way is to modify the
11975 value of an @code{in} parameter:
11977 @example
11978 procedure K (S : in String) is
11979    type R is access all Character;
11980    RV : R := S (3)'Unrestricted_Access;
11981 begin
11982    RV.all := 'a';
11983 end;
11984 @end example
11986 In general this is a risky approach. It may appear to “work” but such uses of
11987 @code{Unrestricted_Access} are potentially non-portable, even from one version
11988 of GNAT to another, so are best avoided if possible.
11990 @node Attribute Update,Attribute Valid_Value,Attribute Unrestricted_Access,Implementation Defined Attributes
11991 @anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1b9}
11992 @section Attribute Update
11995 @geindex Update
11997 The @code{Update} attribute creates a copy of an array or record value
11998 with one or more modified components. The syntax is:
12000 @example
12001 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
12002 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
12003 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
12004                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
12006 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
12007 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
12008 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
12009 @end example
12011 where @code{PREFIX} is the name of an array or record object, the
12012 association list in parentheses does not contain an @code{others}
12013 choice and the box symbol @code{<>} may not appear in any
12014 expression. The effect is to yield a copy of the array or record value
12015 which is unchanged apart from the components mentioned in the
12016 association list, which are changed to the indicated value. The
12017 original value of the array or record value is not affected. For
12018 example:
12020 @example
12021 type Arr is Array (1 .. 5) of Integer;
12023 Avar1 : Arr := (1,2,3,4,5);
12024 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
12025 @end example
12027 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
12028 begin unmodified. Similarly:
12030 @example
12031 type Rec is A, B, C : Integer;
12033 Rvar1 : Rec := (A => 1, B => 2, C => 3);
12034 Rvar2 : Rec := Rvar1'Update (B => 20);
12035 @end example
12037 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
12038 with @code{Rvar1} being unmodifed.
12039 Note that the value of the attribute reference is computed
12040 completely before it is used. This means that if you write:
12042 @example
12043 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
12044 @end example
12046 then the value of @code{Avar1} is not modified if @code{Function_Call}
12047 raises an exception, unlike the effect of a series of direct assignments
12048 to elements of @code{Avar1}. In general this requires that
12049 two extra complete copies of the object are required, which should be
12050 kept in mind when considering efficiency.
12052 The @code{Update} attribute cannot be applied to prefixes of a limited
12053 type, and cannot reference discriminants in the case of a record type.
12054 The accessibility level of an Update attribute result object is defined
12055 as for an aggregate.
12057 In the record case, no component can be mentioned more than once. In
12058 the array case, two overlapping ranges can appear in the association list,
12059 in which case the modifications are processed left to right.
12061 Multi-dimensional arrays can be modified, as shown by this example:
12063 @example
12064 A : array (1 .. 10, 1 .. 10) of Integer;
12066 A := A'Update ((1, 2) => 20, (3, 4) => 30);
12067 @end example
12069 which changes element (1,2) to 20 and (3,4) to 30.
12071 @node Attribute Valid_Value,Attribute Valid_Scalars,Attribute Update,Implementation Defined Attributes
12072 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-value}@anchor{1ba}
12073 @section Attribute Valid_Value
12076 @geindex Valid_Value
12078 The @code{'Valid_Value} attribute is defined for enumeration types other than
12079 those in package Standard. This attribute is a function that takes
12080 a String, and returns Boolean. @code{T'Valid_Value (S)} returns True
12081 if and only if @code{T'Value (S)} would not raise Constraint_Error.
12083 @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Valid_Value,Implementation Defined Attributes
12084 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1bb}
12085 @section Attribute Valid_Scalars
12088 @geindex Valid_Scalars
12090 The @code{'Valid_Scalars} attribute is intended to make it easier to check the
12091 validity of scalar subcomponents of composite objects. The attribute is defined
12092 for any prefix @code{P} which denotes an object. Prefix @code{P} can be any type
12093 except for tagged private or @code{Unchecked_Union} types. The value of the
12094 attribute is of type @code{Boolean}.
12096 @code{P'Valid_Scalars} yields @code{True} if and only if the evaluation of
12097 @code{C'Valid} yields @code{True} for every scalar subcomponent @code{C} of @code{P}, or if
12098 @code{P} has no scalar subcomponents. Attribute @code{'Valid_Scalars} is equivalent
12099 to attribute @code{'Valid} for scalar types.
12101 It is not specified in what order the subcomponents are checked, nor whether
12102 any more are checked after any one of them is determined to be invalid. If the
12103 prefix @code{P} is of a class-wide type @code{T'Class} (where @code{T} is the associated
12104 specific type), or if the prefix @code{P} is of a specific tagged type @code{T}, then
12105 only the subcomponents of @code{T} are checked; in other words, components of
12106 extensions of @code{T} are not checked even if @code{T'Class (P)'Tag /= T'Tag}.
12108 The compiler will issue a warning if it can be determined at compile time that
12109 the prefix of the attribute has no scalar subcomponents.
12111 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case of
12112 a large variant record. If the attribute is called in many places in the same
12113 program applied to objects of the same type, it can reduce program size to
12114 write a function with a single use of the attribute, and then call that
12115 function from multiple places.
12117 @node Attribute VADS_Size,Attribute Value_Size,Attribute Valid_Scalars,Implementation Defined Attributes
12118 @anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1bc}
12119 @section Attribute VADS_Size
12122 @geindex Size
12123 @geindex VADS compatibility
12125 @geindex VADS_Size
12127 The @code{'VADS_Size} attribute is intended to make it easier to port
12128 legacy code which relies on the semantics of @code{'Size} as implemented
12129 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
12130 same semantic interpretation.  In particular, @code{'VADS_Size} applied
12131 to a predefined or other primitive type with no Size clause yields the
12132 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
12133 typical machines).  In addition @code{'VADS_Size} applied to an object
12134 gives the result that would be obtained by applying the attribute to
12135 the corresponding type.
12137 @node Attribute Value_Size,Attribute Wchar_T_Size,Attribute VADS_Size,Implementation Defined Attributes
12138 @anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{16a}@anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1bd}
12139 @section Attribute Value_Size
12142 @geindex Size
12143 @geindex setting for not-first subtype
12145 @geindex Value_Size
12147 @code{type'Value_Size} is the number of bits required to represent
12148 a value of the given subtype.  It is the same as @code{type'Size},
12149 but, unlike @code{Size}, may be set for non-first subtypes.
12151 @node Attribute Wchar_T_Size,Attribute Word_Size,Attribute Value_Size,Implementation Defined Attributes
12152 @anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1be}
12153 @section Attribute Wchar_T_Size
12156 @geindex Wchar_T_Size
12158 @code{Standard'Wchar_T_Size} (@code{Standard} is the only allowed
12159 prefix) provides the size in bits of the C @code{wchar_t} type
12160 primarily for constructing the definition of this type in
12161 package @code{Interfaces.C}. The result is a static constant.
12163 @node Attribute Word_Size,,Attribute Wchar_T_Size,Implementation Defined Attributes
12164 @anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1bf}
12165 @section Attribute Word_Size
12168 @geindex Word_Size
12170 @code{Standard'Word_Size} (@code{Standard} is the only allowed
12171 prefix) provides the value @code{System.Word_Size}. The result is
12172 a static constant.
12174 @node Standard and Implementation Defined Restrictions,Implementation Advice,Implementation Defined Attributes,Top
12175 @anchor{gnat_rm/standard_and_implementation_defined_restrictions doc}@anchor{1c0}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1c1}@anchor{gnat_rm/standard_and_implementation_defined_restrictions standard-and-implementation-defined-restrictions}@anchor{9}
12176 @chapter Standard and Implementation Defined Restrictions
12179 All Ada Reference Manual-defined Restriction identifiers are implemented:
12182 @itemize *
12184 @item 
12185 language-defined restrictions (see 13.12.1)
12187 @item 
12188 tasking restrictions (see D.7)
12190 @item 
12191 high integrity restrictions (see H.4)
12192 @end itemize
12194 GNAT implements additional restriction identifiers. All restrictions, whether
12195 language defined or GNAT-specific, are listed in the following.
12197 @menu
12198 * Partition-Wide Restrictions:: 
12199 * Program Unit Level Restrictions:: 
12201 @end menu
12203 @node Partition-Wide Restrictions,Program Unit Level Restrictions,,Standard and Implementation Defined Restrictions
12204 @anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1c2}@anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1c3}
12205 @section Partition-Wide Restrictions
12208 There are two separate lists of restriction identifiers. The first
12209 set requires consistency throughout a partition (in other words, if the
12210 restriction identifier is used for any compilation unit in the partition,
12211 then all compilation units in the partition must obey the restriction).
12213 @menu
12214 * Immediate_Reclamation:: 
12215 * Max_Asynchronous_Select_Nesting:: 
12216 * Max_Entry_Queue_Length:: 
12217 * Max_Protected_Entries:: 
12218 * Max_Select_Alternatives:: 
12219 * Max_Storage_At_Blocking:: 
12220 * Max_Task_Entries:: 
12221 * Max_Tasks:: 
12222 * No_Abort_Statements:: 
12223 * No_Access_Parameter_Allocators:: 
12224 * No_Access_Subprograms:: 
12225 * No_Allocators:: 
12226 * No_Anonymous_Allocators:: 
12227 * No_Asynchronous_Control:: 
12228 * No_Calendar:: 
12229 * No_Coextensions:: 
12230 * No_Default_Initialization:: 
12231 * No_Delay:: 
12232 * No_Dependence:: 
12233 * No_Direct_Boolean_Operators:: 
12234 * No_Dispatch:: 
12235 * No_Dispatching_Calls:: 
12236 * No_Dynamic_Attachment:: 
12237 * No_Dynamic_Priorities:: 
12238 * No_Entry_Calls_In_Elaboration_Code:: 
12239 * No_Enumeration_Maps:: 
12240 * No_Exception_Handlers:: 
12241 * No_Exception_Propagation:: 
12242 * No_Exception_Registration:: 
12243 * No_Exceptions:: 
12244 * No_Finalization:: 
12245 * No_Fixed_Point:: 
12246 * No_Floating_Point:: 
12247 * No_Implicit_Conditionals:: 
12248 * No_Implicit_Dynamic_Code:: 
12249 * No_Implicit_Heap_Allocations:: 
12250 * No_Implicit_Protected_Object_Allocations:: 
12251 * No_Implicit_Task_Allocations:: 
12252 * No_Initialize_Scalars:: 
12253 * No_IO:: 
12254 * No_Local_Allocators:: 
12255 * No_Local_Protected_Objects:: 
12256 * No_Local_Tagged_Types:: 
12257 * No_Local_Timing_Events:: 
12258 * No_Long_Long_Integers:: 
12259 * No_Multiple_Elaboration:: 
12260 * No_Nested_Finalization:: 
12261 * No_Protected_Type_Allocators:: 
12262 * No_Protected_Types:: 
12263 * No_Recursion:: 
12264 * No_Reentrancy:: 
12265 * No_Relative_Delay:: 
12266 * No_Requeue_Statements:: 
12267 * No_Secondary_Stack:: 
12268 * No_Select_Statements:: 
12269 * No_Specific_Termination_Handlers:: 
12270 * No_Specification_of_Aspect:: 
12271 * No_Standard_Allocators_After_Elaboration:: 
12272 * No_Standard_Storage_Pools:: 
12273 * No_Stream_Optimizations:: 
12274 * No_Streams:: 
12275 * No_Tagged_Type_Registration:: 
12276 * No_Task_Allocators:: 
12277 * No_Task_At_Interrupt_Priority:: 
12278 * No_Task_Attributes_Package:: 
12279 * No_Task_Hierarchy:: 
12280 * No_Task_Termination:: 
12281 * No_Tasking:: 
12282 * No_Terminate_Alternatives:: 
12283 * No_Unchecked_Access:: 
12284 * No_Unchecked_Conversion:: 
12285 * No_Unchecked_Deallocation:: 
12286 * No_Use_Of_Attribute:: 
12287 * No_Use_Of_Entity:: 
12288 * No_Use_Of_Pragma:: 
12289 * Pure_Barriers:: 
12290 * Simple_Barriers:: 
12291 * Static_Priorities:: 
12292 * Static_Storage_Size:: 
12294 @end menu
12296 @node Immediate_Reclamation,Max_Asynchronous_Select_Nesting,,Partition-Wide Restrictions
12297 @anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1c4}
12298 @subsection Immediate_Reclamation
12301 @geindex Immediate_Reclamation
12303 [RM H.4] This restriction ensures that, except for storage occupied by
12304 objects created by allocators and not deallocated via unchecked
12305 deallocation, any storage reserved at run time for an object is
12306 immediately reclaimed when the object no longer exists.
12308 @node Max_Asynchronous_Select_Nesting,Max_Entry_Queue_Length,Immediate_Reclamation,Partition-Wide Restrictions
12309 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1c5}
12310 @subsection Max_Asynchronous_Select_Nesting
12313 @geindex Max_Asynchronous_Select_Nesting
12315 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
12316 selects. Violations of this restriction with a value of zero are
12317 detected at compile time. Violations of this restriction with values
12318 other than zero cause Storage_Error to be raised.
12320 @node Max_Entry_Queue_Length,Max_Protected_Entries,Max_Asynchronous_Select_Nesting,Partition-Wide Restrictions
12321 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1c6}
12322 @subsection Max_Entry_Queue_Length
12325 @geindex Max_Entry_Queue_Length
12327 [RM D.7] This restriction is a declaration that any protected entry compiled in
12328 the scope of the restriction has at most the specified number of
12329 tasks waiting on the entry at any one time, and so no queue is required.
12330 Note that this restriction is checked at run time. Violation of this
12331 restriction results in the raising of Program_Error exception at the point of
12332 the call.
12334 @geindex Max_Entry_Queue_Depth
12336 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
12337 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
12338 compatibility purposes (and a warning will be generated for its use if
12339 warnings on obsolescent features are activated).
12341 @node Max_Protected_Entries,Max_Select_Alternatives,Max_Entry_Queue_Length,Partition-Wide Restrictions
12342 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1c7}
12343 @subsection Max_Protected_Entries
12346 @geindex Max_Protected_Entries
12348 [RM D.7] Specifies the maximum number of entries per protected type. The
12349 bounds of every entry family of a protected unit shall be static, or shall be
12350 defined by a discriminant of a subtype whose corresponding bound is static.
12352 @node Max_Select_Alternatives,Max_Storage_At_Blocking,Max_Protected_Entries,Partition-Wide Restrictions
12353 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1c8}
12354 @subsection Max_Select_Alternatives
12357 @geindex Max_Select_Alternatives
12359 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
12361 @node Max_Storage_At_Blocking,Max_Task_Entries,Max_Select_Alternatives,Partition-Wide Restrictions
12362 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1c9}
12363 @subsection Max_Storage_At_Blocking
12366 @geindex Max_Storage_At_Blocking
12368 [RM D.7] Specifies the maximum portion (in storage elements) of a task’s
12369 Storage_Size that can be retained by a blocked task. A violation of this
12370 restriction causes Storage_Error to be raised.
12372 @node Max_Task_Entries,Max_Tasks,Max_Storage_At_Blocking,Partition-Wide Restrictions
12373 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1ca}
12374 @subsection Max_Task_Entries
12377 @geindex Max_Task_Entries
12379 [RM D.7] Specifies the maximum number of entries
12380 per task.  The bounds of every entry family
12381 of a task unit shall be static, or shall be
12382 defined by a discriminant of a subtype whose
12383 corresponding bound is static.
12385 @node Max_Tasks,No_Abort_Statements,Max_Task_Entries,Partition-Wide Restrictions
12386 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1cb}
12387 @subsection Max_Tasks
12390 @geindex Max_Tasks
12392 [RM D.7] Specifies the maximum number of task that may be created, not
12393 counting the creation of the environment task.  Violations of this
12394 restriction with a value of zero are detected at compile
12395 time. Violations of this restriction with values other than zero cause
12396 Storage_Error to be raised.
12398 @node No_Abort_Statements,No_Access_Parameter_Allocators,Max_Tasks,Partition-Wide Restrictions
12399 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1cc}
12400 @subsection No_Abort_Statements
12403 @geindex No_Abort_Statements
12405 [RM D.7] There are no abort_statements, and there are
12406 no calls to Task_Identification.Abort_Task.
12408 @node No_Access_Parameter_Allocators,No_Access_Subprograms,No_Abort_Statements,Partition-Wide Restrictions
12409 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1cd}
12410 @subsection No_Access_Parameter_Allocators
12413 @geindex No_Access_Parameter_Allocators
12415 [RM H.4] This restriction ensures at compile time that there are no
12416 occurrences of an allocator as the actual parameter to an access
12417 parameter.
12419 @node No_Access_Subprograms,No_Allocators,No_Access_Parameter_Allocators,Partition-Wide Restrictions
12420 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1ce}
12421 @subsection No_Access_Subprograms
12424 @geindex No_Access_Subprograms
12426 [RM H.4] This restriction ensures at compile time that there are no
12427 declarations of access-to-subprogram types.
12429 @node No_Allocators,No_Anonymous_Allocators,No_Access_Subprograms,Partition-Wide Restrictions
12430 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1cf}
12431 @subsection No_Allocators
12434 @geindex No_Allocators
12436 [RM H.4] This restriction ensures at compile time that there are no
12437 occurrences of an allocator.
12439 @node No_Anonymous_Allocators,No_Asynchronous_Control,No_Allocators,Partition-Wide Restrictions
12440 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1d0}
12441 @subsection No_Anonymous_Allocators
12444 @geindex No_Anonymous_Allocators
12446 [RM H.4] This restriction ensures at compile time that there are no
12447 occurrences of an allocator of anonymous access type.
12449 @node No_Asynchronous_Control,No_Calendar,No_Anonymous_Allocators,Partition-Wide Restrictions
12450 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1d1}
12451 @subsection No_Asynchronous_Control
12454 @geindex No_Asynchronous_Control
12456 [RM J.13] This restriction ensures at compile time that there are no semantic
12457 dependences on the predefined package Asynchronous_Task_Control.
12459 @node No_Calendar,No_Coextensions,No_Asynchronous_Control,Partition-Wide Restrictions
12460 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1d2}
12461 @subsection No_Calendar
12464 @geindex No_Calendar
12466 [GNAT] This restriction ensures at compile time that there are no semantic
12467 dependences on package Calendar.
12469 @node No_Coextensions,No_Default_Initialization,No_Calendar,Partition-Wide Restrictions
12470 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1d3}
12471 @subsection No_Coextensions
12474 @geindex No_Coextensions
12476 [RM H.4] This restriction ensures at compile time that there are no
12477 coextensions. See 3.10.2.
12479 @node No_Default_Initialization,No_Delay,No_Coextensions,Partition-Wide Restrictions
12480 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1d4}
12481 @subsection No_Default_Initialization
12484 @geindex No_Default_Initialization
12486 [GNAT] This restriction prohibits any instance of default initialization
12487 of variables.  The binder implements a consistency rule which prevents
12488 any unit compiled without the restriction from with’ing a unit with the
12489 restriction (this allows the generation of initialization procedures to
12490 be skipped, since you can be sure that no call is ever generated to an
12491 initialization procedure in a unit with the restriction active). If used
12492 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
12493 is to prohibit all cases of variables declared without a specific
12494 initializer (including the case of OUT scalar parameters).
12496 @node No_Delay,No_Dependence,No_Default_Initialization,Partition-Wide Restrictions
12497 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1d5}
12498 @subsection No_Delay
12501 @geindex No_Delay
12503 [RM H.4] This restriction ensures at compile time that there are no
12504 delay statements and no semantic dependences on package Calendar.
12506 @node No_Dependence,No_Direct_Boolean_Operators,No_Delay,Partition-Wide Restrictions
12507 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1d6}
12508 @subsection No_Dependence
12511 @geindex No_Dependence
12513 [RM 13.12.1] This restriction ensures at compile time that there are no
12514 dependences on a library unit. For GNAT, this includes implicit implementation
12515 dependences on units of the runtime library that are created by the compiler
12516 to support specific constructs of the language. Here are some examples:
12519 @itemize *
12521 @item 
12522 @code{System.Arith_64}: 64-bit arithmetics for 32-bit platforms,
12524 @item 
12525 @code{System.Arith_128}: 128-bit arithmetics for 64-bit platforms,
12527 @item 
12528 @code{System.Memory}: heap memory allocation routines,
12530 @item 
12531 @code{System.Memory_Compare}: memory comparison routine (aka @code{memcmp} for C),
12533 @item 
12534 @code{System.Memory_Copy}: memory copy routine (aka @code{memcpy} for C),
12536 @item 
12537 @code{System.Memory_Move}: memoy move routine (aka @code{memmove} for C),
12539 @item 
12540 @code{System.Memory_Set}: memory set routine (aka @code{memset} for C),
12542 @item 
12543 @code{System.Stack_Checking[.Operations]}: stack checking without MMU,
12545 @item 
12546 @code{System.GCC}: support routines from the GCC library.
12547 @end itemize
12549 @node No_Direct_Boolean_Operators,No_Dispatch,No_Dependence,Partition-Wide Restrictions
12550 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1d7}
12551 @subsection No_Direct_Boolean_Operators
12554 @geindex No_Direct_Boolean_Operators
12556 [GNAT] This restriction ensures that no logical operators (and/or/xor)
12557 are used on operands of type Boolean (or any type derived from Boolean).
12558 This is intended for use in safety critical programs where the certification
12559 protocol requires the use of short-circuit (and then, or else) forms for all
12560 composite boolean operations.
12562 @node No_Dispatch,No_Dispatching_Calls,No_Direct_Boolean_Operators,Partition-Wide Restrictions
12563 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1d8}
12564 @subsection No_Dispatch
12567 @geindex No_Dispatch
12569 [RM H.4] This restriction ensures at compile time that there are no
12570 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
12572 @node No_Dispatching_Calls,No_Dynamic_Attachment,No_Dispatch,Partition-Wide Restrictions
12573 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1d9}
12574 @subsection No_Dispatching_Calls
12577 @geindex No_Dispatching_Calls
12579 [GNAT] This restriction ensures at compile time that the code generated by the
12580 compiler involves no dispatching calls. The use of this restriction allows the
12581 safe use of record extensions, classwide membership tests and other classwide
12582 features not involving implicit dispatching. This restriction ensures that
12583 the code contains no indirect calls through a dispatching mechanism. Note that
12584 this includes internally-generated calls created by the compiler, for example
12585 in the implementation of class-wide objects assignments. The
12586 membership test is allowed in the presence of this restriction, because its
12587 implementation requires no dispatching.
12588 This restriction is comparable to the official Ada restriction
12589 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
12590 all classwide constructs that do not imply dispatching.
12591 The following example indicates constructs that violate this restriction.
12593 @example
12594 package Pkg is
12595   type T is tagged record
12596     Data : Natural;
12597   end record;
12598   procedure P (X : T);
12600   type DT is new T with record
12601     More_Data : Natural;
12602   end record;
12603   procedure Q (X : DT);
12604 end Pkg;
12606 with Pkg; use Pkg;
12607 procedure Example is
12608   procedure Test (O : T'Class) is
12609     N : Natural := O'Size; --  Error: Dispatching call
12610     C : T'Class := O;      --  Error: implicit Dispatching Call
12611   begin
12612     if O in DT'Class then  --  OK   : Membership test
12613        Q (DT (O));         --  OK   : Type conversion plus direct call
12614     else
12615        P (O);              --  Error: Dispatching call
12616     end if;
12617   end Test;
12619   Obj : DT;
12620 begin
12621   P (Obj);                 --  OK   : Direct call
12622   P (T (Obj));             --  OK   : Type conversion plus direct call
12623   P (T'Class (Obj));       --  Error: Dispatching call
12625   Test (Obj);              --  OK   : Type conversion
12627   if Obj in T'Class then   --  OK   : Membership test
12628      null;
12629   end if;
12630 end Example;
12631 @end example
12633 @node No_Dynamic_Attachment,No_Dynamic_Priorities,No_Dispatching_Calls,Partition-Wide Restrictions
12634 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1da}
12635 @subsection No_Dynamic_Attachment
12638 @geindex No_Dynamic_Attachment
12640 [RM D.7] This restriction ensures that there is no call to any of the
12641 operations defined in package Ada.Interrupts
12642 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
12643 Detach_Handler, and Reference).
12645 @geindex No_Dynamic_Interrupts
12647 The restriction @code{No_Dynamic_Interrupts} is recognized as a
12648 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
12649 compatibility purposes (and a warning will be generated for its use if
12650 warnings on obsolescent features are activated).
12652 @node No_Dynamic_Priorities,No_Entry_Calls_In_Elaboration_Code,No_Dynamic_Attachment,Partition-Wide Restrictions
12653 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1db}
12654 @subsection No_Dynamic_Priorities
12657 @geindex No_Dynamic_Priorities
12659 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
12661 @node No_Entry_Calls_In_Elaboration_Code,No_Enumeration_Maps,No_Dynamic_Priorities,Partition-Wide Restrictions
12662 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1dc}
12663 @subsection No_Entry_Calls_In_Elaboration_Code
12666 @geindex No_Entry_Calls_In_Elaboration_Code
12668 [GNAT] This restriction ensures at compile time that no task or protected entry
12669 calls are made during elaboration code.  As a result of the use of this
12670 restriction, the compiler can assume that no code past an accept statement
12671 in a task can be executed at elaboration time.
12673 @node No_Enumeration_Maps,No_Exception_Handlers,No_Entry_Calls_In_Elaboration_Code,Partition-Wide Restrictions
12674 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1dd}
12675 @subsection No_Enumeration_Maps
12678 @geindex No_Enumeration_Maps
12680 [GNAT] This restriction ensures at compile time that no operations requiring
12681 enumeration maps are used (that is Image and Value attributes applied
12682 to enumeration types).
12684 @node No_Exception_Handlers,No_Exception_Propagation,No_Enumeration_Maps,Partition-Wide Restrictions
12685 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1de}
12686 @subsection No_Exception_Handlers
12689 @geindex No_Exception_Handlers
12691 [GNAT] This restriction ensures at compile time that there are no explicit
12692 exception handlers. It also indicates that no exception propagation will
12693 be provided. In this mode, exceptions may be raised but will result in
12694 an immediate call to the last chance handler, a routine that the user
12695 must define with the following profile:
12697 @example
12698 procedure Last_Chance_Handler
12699   (Source_Location : System.Address; Line : Integer);
12700 pragma Export (C, Last_Chance_Handler,
12701                "__gnat_last_chance_handler");
12702 @end example
12704 The parameter is a C null-terminated string representing a message to be
12705 associated with the exception (typically the source location of the raise
12706 statement generated by the compiler). The Line parameter when nonzero
12707 represents the line number in the source program where the raise occurs.
12709 @node No_Exception_Propagation,No_Exception_Registration,No_Exception_Handlers,Partition-Wide Restrictions
12710 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1df}
12711 @subsection No_Exception_Propagation
12714 @geindex No_Exception_Propagation
12716 [GNAT] This restriction guarantees that exceptions are never propagated
12717 to an outer subprogram scope. The only case in which an exception may
12718 be raised is when the handler is statically in the same subprogram, so
12719 that the effect of a raise is essentially like a goto statement. Any
12720 other raise statement (implicit or explicit) will be considered
12721 unhandled. Exception handlers are allowed, but may not contain an
12722 exception occurrence identifier (exception choice). In addition, use of
12723 the package GNAT.Current_Exception is not permitted, and reraise
12724 statements (raise with no operand) are not permitted.
12726 @node No_Exception_Registration,No_Exceptions,No_Exception_Propagation,Partition-Wide Restrictions
12727 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1e0}
12728 @subsection No_Exception_Registration
12731 @geindex No_Exception_Registration
12733 [GNAT] This restriction ensures at compile time that no stream operations for
12734 types Exception_Id or Exception_Occurrence are used. This also makes it
12735 impossible to pass exceptions to or from a partition with this restriction
12736 in a distributed environment. If this restriction is active, the generated
12737 code is simplified by omitting the otherwise-required global registration
12738 of exceptions when they are declared.
12740 @node No_Exceptions,No_Finalization,No_Exception_Registration,Partition-Wide Restrictions
12741 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1e1}
12742 @subsection No_Exceptions
12745 @geindex No_Exceptions
12747 [RM H.4] This restriction ensures at compile time that there are no
12748 raise statements and no exception handlers and also suppresses the
12749 generation of language-defined run-time checks.
12751 @node No_Finalization,No_Fixed_Point,No_Exceptions,Partition-Wide Restrictions
12752 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1e2}
12753 @subsection No_Finalization
12756 @geindex No_Finalization
12758 [GNAT] This restriction disables the language features described in
12759 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
12760 performed by the compiler to support these features. The following types
12761 are no longer considered controlled when this restriction is in effect:
12764 @itemize *
12766 @item 
12767 @code{Ada.Finalization.Controlled}
12769 @item 
12770 @code{Ada.Finalization.Limited_Controlled}
12772 @item 
12773 Derivations from @code{Controlled} or @code{Limited_Controlled}
12775 @item 
12776 Class-wide types
12778 @item 
12779 Protected types
12781 @item 
12782 Task types
12784 @item 
12785 Array and record types with controlled components
12786 @end itemize
12788 The compiler no longer generates code to initialize, finalize or adjust an
12789 object or a nested component, either declared on the stack or on the heap. The
12790 deallocation of a controlled object no longer finalizes its contents.
12792 @node No_Fixed_Point,No_Floating_Point,No_Finalization,Partition-Wide Restrictions
12793 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1e3}
12794 @subsection No_Fixed_Point
12797 @geindex No_Fixed_Point
12799 [RM H.4] This restriction ensures at compile time that there are no
12800 occurrences of fixed point types and operations.
12802 @node No_Floating_Point,No_Implicit_Conditionals,No_Fixed_Point,Partition-Wide Restrictions
12803 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1e4}
12804 @subsection No_Floating_Point
12807 @geindex No_Floating_Point
12809 [RM H.4] This restriction ensures at compile time that there are no
12810 occurrences of floating point types and operations.
12812 @node No_Implicit_Conditionals,No_Implicit_Dynamic_Code,No_Floating_Point,Partition-Wide Restrictions
12813 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1e5}
12814 @subsection No_Implicit_Conditionals
12817 @geindex No_Implicit_Conditionals
12819 [GNAT] This restriction ensures that the generated code does not contain any
12820 implicit conditionals, either by modifying the generated code where possible,
12821 or by rejecting any construct that would otherwise generate an implicit
12822 conditional. Note that this check does not include run time constraint
12823 checks, which on some targets may generate implicit conditionals as
12824 well. To control the latter, constraint checks can be suppressed in the
12825 normal manner. Constructs generating implicit conditionals include comparisons
12826 of composite objects and the Max/Min attributes.
12828 @node No_Implicit_Dynamic_Code,No_Implicit_Heap_Allocations,No_Implicit_Conditionals,Partition-Wide Restrictions
12829 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1e6}
12830 @subsection No_Implicit_Dynamic_Code
12833 @geindex No_Implicit_Dynamic_Code
12835 @geindex trampoline
12837 [GNAT] This restriction prevents the compiler from building ‘trampolines’.
12838 This is a structure that is built on the stack and contains dynamic
12839 code to be executed at run time. On some targets, a trampoline is
12840 built for the following features: @code{Access},
12841 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
12842 nested task bodies; primitive operations of nested tagged types.
12843 Trampolines do not work on machines that prevent execution of stack
12844 data. For example, on windows systems, enabling DEP (data execution
12845 protection) will cause trampolines to raise an exception.
12846 Trampolines are also quite slow at run time.
12848 On many targets, trampolines have been largely eliminated. Look at the
12849 version of system.ads for your target — if it has
12850 Always_Compatible_Rep equal to False, then trampolines are largely
12851 eliminated. In particular, a trampoline is built for the following
12852 features: @code{Address} of a nested subprogram;
12853 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
12854 but only if pragma Favor_Top_Level applies, or the access type has a
12855 foreign-language convention; primitive operations of nested tagged
12856 types.
12858 @node No_Implicit_Heap_Allocations,No_Implicit_Protected_Object_Allocations,No_Implicit_Dynamic_Code,Partition-Wide Restrictions
12859 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1e7}
12860 @subsection No_Implicit_Heap_Allocations
12863 @geindex No_Implicit_Heap_Allocations
12865 [RM D.7] No constructs are allowed to cause implicit heap allocation.
12867 @node No_Implicit_Protected_Object_Allocations,No_Implicit_Task_Allocations,No_Implicit_Heap_Allocations,Partition-Wide Restrictions
12868 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1e8}
12869 @subsection No_Implicit_Protected_Object_Allocations
12872 @geindex No_Implicit_Protected_Object_Allocations
12874 [GNAT] No constructs are allowed to cause implicit heap allocation of a
12875 protected object.
12877 @node No_Implicit_Task_Allocations,No_Initialize_Scalars,No_Implicit_Protected_Object_Allocations,Partition-Wide Restrictions
12878 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1e9}
12879 @subsection No_Implicit_Task_Allocations
12882 @geindex No_Implicit_Task_Allocations
12884 [GNAT] No constructs are allowed to cause implicit heap allocation of a task.
12886 @node No_Initialize_Scalars,No_IO,No_Implicit_Task_Allocations,Partition-Wide Restrictions
12887 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1ea}
12888 @subsection No_Initialize_Scalars
12891 @geindex No_Initialize_Scalars
12893 [GNAT] This restriction ensures that no unit in the partition is compiled with
12894 pragma Initialize_Scalars. This allows the generation of more efficient
12895 code, and in particular eliminates dummy null initialization routines that
12896 are otherwise generated for some record and array types.
12898 @node No_IO,No_Local_Allocators,No_Initialize_Scalars,Partition-Wide Restrictions
12899 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1eb}
12900 @subsection No_IO
12903 @geindex No_IO
12905 [RM H.4] This restriction ensures at compile time that there are no
12906 dependences on any of the library units Sequential_IO, Direct_IO,
12907 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
12909 @node No_Local_Allocators,No_Local_Protected_Objects,No_IO,Partition-Wide Restrictions
12910 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1ec}
12911 @subsection No_Local_Allocators
12914 @geindex No_Local_Allocators
12916 [RM H.4] This restriction ensures at compile time that there are no
12917 occurrences of an allocator in subprograms, generic subprograms, tasks,
12918 and entry bodies.
12920 @node No_Local_Protected_Objects,No_Local_Tagged_Types,No_Local_Allocators,Partition-Wide Restrictions
12921 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1ed}
12922 @subsection No_Local_Protected_Objects
12925 @geindex No_Local_Protected_Objects
12927 [RM D.7] This restriction ensures at compile time that protected objects are
12928 only declared at the library level.
12930 @node No_Local_Tagged_Types,No_Local_Timing_Events,No_Local_Protected_Objects,Partition-Wide Restrictions
12931 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-tagged-types}@anchor{1ee}
12932 @subsection No_Local_Tagged_Types
12935 @geindex No_Local_Tagged_Types
12937 [GNAT] This restriction ensures at compile time that tagged types are only
12938 declared at the library level.
12940 @node No_Local_Timing_Events,No_Long_Long_Integers,No_Local_Tagged_Types,Partition-Wide Restrictions
12941 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1ef}
12942 @subsection No_Local_Timing_Events
12945 @geindex No_Local_Timing_Events
12947 [RM D.7] All objects of type Ada.Real_Time.Timing_Events.Timing_Event are
12948 declared at the library level.
12950 @node No_Long_Long_Integers,No_Multiple_Elaboration,No_Local_Timing_Events,Partition-Wide Restrictions
12951 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1f0}
12952 @subsection No_Long_Long_Integers
12955 @geindex No_Long_Long_Integers
12957 [GNAT] This partition-wide restriction forbids any explicit reference to
12958 type Standard.Long_Long_Integer, and also forbids declaring range types whose
12959 implicit base type is Long_Long_Integer, and modular types whose size exceeds
12960 Long_Integer’Size.
12962 @node No_Multiple_Elaboration,No_Nested_Finalization,No_Long_Long_Integers,Partition-Wide Restrictions
12963 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1f1}
12964 @subsection No_Multiple_Elaboration
12967 @geindex No_Multiple_Elaboration
12969 [GNAT] When this restriction is active and the static elaboration model is
12970 used, and -fpreserve-control-flow is not used, the compiler is allowed to
12971 suppress the elaboration counter normally associated with the unit, even if
12972 the unit has elaboration code. This counter is typically used to check for
12973 access before elaboration and to control multiple elaboration attempts. If the
12974 restriction is used, then the situations in which multiple elaboration is
12975 possible, including non-Ada main programs and Stand Alone libraries, are not
12976 permitted and will be diagnosed by the binder.
12978 @node No_Nested_Finalization,No_Protected_Type_Allocators,No_Multiple_Elaboration,Partition-Wide Restrictions
12979 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1f2}
12980 @subsection No_Nested_Finalization
12983 @geindex No_Nested_Finalization
12985 [RM D.7] All objects requiring finalization are declared at the library level.
12987 @node No_Protected_Type_Allocators,No_Protected_Types,No_Nested_Finalization,Partition-Wide Restrictions
12988 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1f3}
12989 @subsection No_Protected_Type_Allocators
12992 @geindex No_Protected_Type_Allocators
12994 [RM D.7] This restriction ensures at compile time that there are no allocator
12995 expressions that attempt to allocate protected objects.
12997 @node No_Protected_Types,No_Recursion,No_Protected_Type_Allocators,Partition-Wide Restrictions
12998 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1f4}
12999 @subsection No_Protected_Types
13002 @geindex No_Protected_Types
13004 [RM H.4] This restriction ensures at compile time that there are no
13005 declarations of protected types or protected objects.
13007 @node No_Recursion,No_Reentrancy,No_Protected_Types,Partition-Wide Restrictions
13008 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1f5}
13009 @subsection No_Recursion
13012 @geindex No_Recursion
13014 [RM H.4] A program execution is erroneous if a subprogram is invoked as
13015 part of its execution.
13017 @node No_Reentrancy,No_Relative_Delay,No_Recursion,Partition-Wide Restrictions
13018 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1f6}
13019 @subsection No_Reentrancy
13022 @geindex No_Reentrancy
13024 [RM H.4] A program execution is erroneous if a subprogram is executed by
13025 two tasks at the same time.
13027 @node No_Relative_Delay,No_Requeue_Statements,No_Reentrancy,Partition-Wide Restrictions
13028 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1f7}
13029 @subsection No_Relative_Delay
13032 @geindex No_Relative_Delay
13034 [RM D.7] This restriction ensures at compile time that there are no delay
13035 relative statements and prevents expressions such as @code{delay 1.23;} from
13036 appearing in source code.
13038 @node No_Requeue_Statements,No_Secondary_Stack,No_Relative_Delay,Partition-Wide Restrictions
13039 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1f8}
13040 @subsection No_Requeue_Statements
13043 @geindex No_Requeue_Statements
13045 [RM D.7] This restriction ensures at compile time that no requeue statements
13046 are permitted and prevents keyword @code{requeue} from being used in source
13047 code.
13049 @geindex No_Requeue
13051 The restriction @code{No_Requeue} is recognized as a
13052 synonym for @code{No_Requeue_Statements}. This is retained for historical
13053 compatibility purposes (and a warning will be generated for its use if
13054 warnings on oNobsolescent features are activated).
13056 @node No_Secondary_Stack,No_Select_Statements,No_Requeue_Statements,Partition-Wide Restrictions
13057 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1f9}
13058 @subsection No_Secondary_Stack
13061 @geindex No_Secondary_Stack
13063 [GNAT] This restriction ensures at compile time that the generated code
13064 does not contain any reference to the secondary stack.  The secondary
13065 stack is used to implement functions returning unconstrained objects
13066 (arrays or records) on some targets. Suppresses the allocation of
13067 secondary stacks for tasks (excluding the environment task) at run time.
13069 @node No_Select_Statements,No_Specific_Termination_Handlers,No_Secondary_Stack,Partition-Wide Restrictions
13070 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1fa}
13071 @subsection No_Select_Statements
13074 @geindex No_Select_Statements
13076 [RM D.7] This restriction ensures at compile time no select statements of any
13077 kind are permitted, that is the keyword @code{select} may not appear.
13079 @node No_Specific_Termination_Handlers,No_Specification_of_Aspect,No_Select_Statements,Partition-Wide Restrictions
13080 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1fb}
13081 @subsection No_Specific_Termination_Handlers
13084 @geindex No_Specific_Termination_Handlers
13086 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
13087 or to Ada.Task_Termination.Specific_Handler.
13089 @node No_Specification_of_Aspect,No_Standard_Allocators_After_Elaboration,No_Specific_Termination_Handlers,Partition-Wide Restrictions
13090 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{1fc}
13091 @subsection No_Specification_of_Aspect
13094 @geindex No_Specification_of_Aspect
13096 [RM 13.12.1] This restriction checks at compile time that no aspect
13097 specification, attribute definition clause, or pragma is given for a
13098 given aspect.
13100 @node No_Standard_Allocators_After_Elaboration,No_Standard_Storage_Pools,No_Specification_of_Aspect,Partition-Wide Restrictions
13101 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{1fd}
13102 @subsection No_Standard_Allocators_After_Elaboration
13105 @geindex No_Standard_Allocators_After_Elaboration
13107 [RM D.7] Specifies that an allocator using a standard storage pool
13108 should never be evaluated at run time after the elaboration of the
13109 library items of the partition has completed. Otherwise, Storage_Error
13110 is raised.
13112 @node No_Standard_Storage_Pools,No_Stream_Optimizations,No_Standard_Allocators_After_Elaboration,Partition-Wide Restrictions
13113 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{1fe}
13114 @subsection No_Standard_Storage_Pools
13117 @geindex No_Standard_Storage_Pools
13119 [GNAT] This restriction ensures at compile time that no access types
13120 use the standard default storage pool.  Any access type declared must
13121 have an explicit Storage_Pool attribute defined specifying a
13122 user-defined storage pool.
13124 @node No_Stream_Optimizations,No_Streams,No_Standard_Storage_Pools,Partition-Wide Restrictions
13125 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{1ff}
13126 @subsection No_Stream_Optimizations
13129 @geindex No_Stream_Optimizations
13131 [GNAT] This restriction affects the performance of stream operations on types
13132 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
13133 compiler uses block reads and writes when manipulating @code{String} objects
13134 due to their superior performance. When this restriction is in effect, the
13135 compiler performs all IO operations on a per-character basis.
13137 @node No_Streams,No_Tagged_Type_Registration,No_Stream_Optimizations,Partition-Wide Restrictions
13138 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{200}
13139 @subsection No_Streams
13142 @geindex No_Streams
13144 [GNAT] This restriction ensures at compile/bind time that there are no
13145 stream objects created and no use of stream attributes.
13146 This restriction does not forbid dependences on the package
13147 @code{Ada.Streams}. So it is permissible to with
13148 @code{Ada.Streams} (or another package that does so itself)
13149 as long as no actual stream objects are created and no
13150 stream attributes are used.
13152 Note that the use of restriction allows optimization of tagged types,
13153 since they do not need to worry about dispatching stream operations.
13154 To take maximum advantage of this space-saving optimization, any
13155 unit declaring a tagged type should be compiled with the restriction,
13156 though this is not required.
13158 @node No_Tagged_Type_Registration,No_Task_Allocators,No_Streams,Partition-Wide Restrictions
13159 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tagged-type-registration}@anchor{201}
13160 @subsection No_Tagged_Type_Registration
13163 @geindex No_Tagged_Type_Registration
13165 [GNAT] If this restriction is active, then class-wide streaming
13166 attributes are not supported. In addition, the subprograms in
13167 Ada.Tags are not supported.
13168 If this restriction is active, the generated code is simplified by
13169 omitting the otherwise-required global registration of tagged types when they
13170 are declared. This restriction may be necessary in order to also apply
13171 the No_Elaboration_Code restriction.
13173 @node No_Task_Allocators,No_Task_At_Interrupt_Priority,No_Tagged_Type_Registration,Partition-Wide Restrictions
13174 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{202}
13175 @subsection No_Task_Allocators
13178 @geindex No_Task_Allocators
13180 [RM D.7] There are no allocators for task types
13181 or types containing task subcomponents.
13183 @node No_Task_At_Interrupt_Priority,No_Task_Attributes_Package,No_Task_Allocators,Partition-Wide Restrictions
13184 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{203}
13185 @subsection No_Task_At_Interrupt_Priority
13188 @geindex No_Task_At_Interrupt_Priority
13190 [GNAT] This restriction ensures at compile time that there is no
13191 Interrupt_Priority aspect or pragma for a task or a task type. As
13192 a consequence, the tasks are always created with a priority below
13193 that an interrupt priority.
13195 @node No_Task_Attributes_Package,No_Task_Hierarchy,No_Task_At_Interrupt_Priority,Partition-Wide Restrictions
13196 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{204}
13197 @subsection No_Task_Attributes_Package
13200 @geindex No_Task_Attributes_Package
13202 [GNAT] This restriction ensures at compile time that there are no implicit or
13203 explicit dependencies on the package @code{Ada.Task_Attributes}.
13205 @geindex No_Task_Attributes
13207 The restriction @code{No_Task_Attributes} is recognized as a synonym
13208 for @code{No_Task_Attributes_Package}. This is retained for historical
13209 compatibility purposes (and a warning will be generated for its use if
13210 warnings on obsolescent features are activated).
13212 @node No_Task_Hierarchy,No_Task_Termination,No_Task_Attributes_Package,Partition-Wide Restrictions
13213 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{205}
13214 @subsection No_Task_Hierarchy
13217 @geindex No_Task_Hierarchy
13219 [RM D.7] All (non-environment) tasks depend
13220 directly on the environment task of the partition.
13222 @node No_Task_Termination,No_Tasking,No_Task_Hierarchy,Partition-Wide Restrictions
13223 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{206}
13224 @subsection No_Task_Termination
13227 @geindex No_Task_Termination
13229 [RM D.7] Tasks that terminate are erroneous.
13231 @node No_Tasking,No_Terminate_Alternatives,No_Task_Termination,Partition-Wide Restrictions
13232 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{207}
13233 @subsection No_Tasking
13236 @geindex No_Tasking
13238 [GNAT] This restriction prevents the declaration of tasks or task types
13239 throughout the partition.  It is similar in effect to the use of
13240 @code{Max_Tasks => 0} except that violations are caught at compile time
13241 and cause an error message to be output either by the compiler or
13242 binder.
13244 @node No_Terminate_Alternatives,No_Unchecked_Access,No_Tasking,Partition-Wide Restrictions
13245 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{208}
13246 @subsection No_Terminate_Alternatives
13249 @geindex No_Terminate_Alternatives
13251 [RM D.7] There are no selective accepts with terminate alternatives.
13253 @node No_Unchecked_Access,No_Unchecked_Conversion,No_Terminate_Alternatives,Partition-Wide Restrictions
13254 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{209}
13255 @subsection No_Unchecked_Access
13258 @geindex No_Unchecked_Access
13260 [RM H.4] This restriction ensures at compile time that there are no
13261 occurrences of the Unchecked_Access attribute.
13263 @node No_Unchecked_Conversion,No_Unchecked_Deallocation,No_Unchecked_Access,Partition-Wide Restrictions
13264 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{20a}
13265 @subsection No_Unchecked_Conversion
13268 @geindex No_Unchecked_Conversion
13270 [RM J.13] This restriction ensures at compile time that there are no semantic
13271 dependences on the predefined generic function Unchecked_Conversion.
13273 @node No_Unchecked_Deallocation,No_Use_Of_Attribute,No_Unchecked_Conversion,Partition-Wide Restrictions
13274 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{20b}
13275 @subsection No_Unchecked_Deallocation
13278 @geindex No_Unchecked_Deallocation
13280 [RM J.13] This restriction ensures at compile time that there are no semantic
13281 dependences on the predefined generic procedure Unchecked_Deallocation.
13283 @node No_Use_Of_Attribute,No_Use_Of_Entity,No_Unchecked_Deallocation,Partition-Wide Restrictions
13284 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-attribute}@anchor{20c}
13285 @subsection No_Use_Of_Attribute
13288 @geindex No_Use_Of_Attribute
13290 [RM 13.12.1] This is a standard Ada 2012 restriction that is GNAT defined in
13291 earlier versions of Ada.
13293 @node No_Use_Of_Entity,No_Use_Of_Pragma,No_Use_Of_Attribute,Partition-Wide Restrictions
13294 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{20d}
13295 @subsection No_Use_Of_Entity
13298 @geindex No_Use_Of_Entity
13300 [GNAT] This restriction ensures at compile time that there are no references
13301 to the entity given in the form
13303 @example
13304 No_Use_Of_Entity => Name
13305 @end example
13307 where @code{Name} is the fully qualified entity, for example
13309 @example
13310 No_Use_Of_Entity => Ada.Text_IO.Put_Line
13311 @end example
13313 @node No_Use_Of_Pragma,Pure_Barriers,No_Use_Of_Entity,Partition-Wide Restrictions
13314 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-pragma}@anchor{20e}
13315 @subsection No_Use_Of_Pragma
13318 @geindex No_Use_Of_Pragma
13320 [RM 13.12.1] This is a standard Ada 2012 restriction that is GNAT defined in
13321 earlier versions of Ada.
13323 @node Pure_Barriers,Simple_Barriers,No_Use_Of_Pragma,Partition-Wide Restrictions
13324 @anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{20f}
13325 @subsection Pure_Barriers
13328 @geindex Pure_Barriers
13330 [GNAT] This restriction ensures at compile time that protected entry
13331 barriers are restricted to:
13334 @itemize *
13336 @item 
13337 components of the protected object (excluding selection from dereferences),
13339 @item 
13340 constant declarations,
13342 @item 
13343 named numbers,
13345 @item 
13346 enumeration literals,
13348 @item 
13349 integer literals,
13351 @item 
13352 real literals,
13354 @item 
13355 character literals,
13357 @item 
13358 implicitly defined comparison operators,
13360 @item 
13361 uses of the Standard.”not” operator,
13363 @item 
13364 short-circuit operator,
13366 @item 
13367 the Count attribute
13368 @end itemize
13370 This restriction is a relaxation of the Simple_Barriers restriction,
13371 but still ensures absence of side effects, exceptions, and recursion
13372 during the evaluation of the barriers.
13374 @node Simple_Barriers,Static_Priorities,Pure_Barriers,Partition-Wide Restrictions
13375 @anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{210}
13376 @subsection Simple_Barriers
13379 @geindex Simple_Barriers
13381 [RM D.7] This restriction ensures at compile time that barriers in entry
13382 declarations for protected types are restricted to either static boolean
13383 expressions or references to simple boolean variables defined in the private
13384 part of the protected type.  No other form of entry barriers is permitted.
13386 @geindex Boolean_Entry_Barriers
13388 The restriction @code{Boolean_Entry_Barriers} is recognized as a
13389 synonym for @code{Simple_Barriers}. This is retained for historical
13390 compatibility purposes (and a warning will be generated for its use if
13391 warnings on obsolescent features are activated).
13393 @node Static_Priorities,Static_Storage_Size,Simple_Barriers,Partition-Wide Restrictions
13394 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{211}
13395 @subsection Static_Priorities
13398 @geindex Static_Priorities
13400 [GNAT] This restriction ensures at compile time that all priority expressions
13401 are static, and that there are no dependences on the package
13402 @code{Ada.Dynamic_Priorities}.
13404 @node Static_Storage_Size,,Static_Priorities,Partition-Wide Restrictions
13405 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{212}
13406 @subsection Static_Storage_Size
13409 @geindex Static_Storage_Size
13411 [GNAT] This restriction ensures at compile time that any expression appearing
13412 in a Storage_Size pragma or attribute definition clause is static.
13414 @node Program Unit Level Restrictions,,Partition-Wide Restrictions,Standard and Implementation Defined Restrictions
13415 @anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{213}@anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{214}
13416 @section Program Unit Level Restrictions
13419 The second set of restriction identifiers
13420 does not require partition-wide consistency.
13421 The restriction may be enforced for a single
13422 compilation unit without any effect on any of the
13423 other compilation units in the partition.
13425 @menu
13426 * No_Elaboration_Code:: 
13427 * No_Dynamic_Accessibility_Checks:: 
13428 * No_Dynamic_Sized_Objects:: 
13429 * No_Entry_Queue:: 
13430 * No_Implementation_Aspect_Specifications:: 
13431 * No_Implementation_Attributes:: 
13432 * No_Implementation_Identifiers:: 
13433 * No_Implementation_Pragmas:: 
13434 * No_Implementation_Restrictions:: 
13435 * No_Implementation_Units:: 
13436 * No_Implicit_Aliasing:: 
13437 * No_Implicit_Loops:: 
13438 * No_Obsolescent_Features:: 
13439 * No_Wide_Characters:: 
13440 * Static_Dispatch_Tables:: 
13441 * SPARK_05:: 
13443 @end menu
13445 @node No_Elaboration_Code,No_Dynamic_Accessibility_Checks,,Program Unit Level Restrictions
13446 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{215}
13447 @subsection No_Elaboration_Code
13450 @geindex No_Elaboration_Code
13452 [GNAT] This restriction ensures at compile time that no elaboration code is
13453 generated.  Note that this is not the same condition as is enforced
13454 by pragma @code{Preelaborate}.  There are cases in which pragma
13455 @code{Preelaborate} still permits code to be generated (e.g., code
13456 to initialize a large array to all zeroes), and there are cases of units
13457 which do not meet the requirements for pragma @code{Preelaborate},
13458 but for which no elaboration code is generated.  Generally, it is
13459 the case that preelaborable units will meet the restrictions, with
13460 the exception of large aggregates initialized with an others_clause,
13461 and exception declarations (which generate calls to a run-time
13462 registry procedure).  This restriction is enforced on
13463 a unit by unit basis, it need not be obeyed consistently
13464 throughout a partition.
13466 In the case of aggregates with others, if the aggregate has a dynamic
13467 size, there is no way to eliminate the elaboration code (such dynamic
13468 bounds would be incompatible with @code{Preelaborate} in any case). If
13469 the bounds are static, then use of this restriction actually modifies
13470 the code choice of the compiler to avoid generating a loop, and instead
13471 generate the aggregate statically if possible, no matter how many times
13472 the data for the others clause must be repeatedly generated.
13474 It is not possible to precisely document
13475 the constructs which are compatible with this restriction, since,
13476 unlike most other restrictions, this is not a restriction on the
13477 source code, but a restriction on the generated object code. For
13478 example, if the source contains a declaration:
13480 @example
13481 Val : constant Integer := X;
13482 @end example
13484 where X is not a static constant, it may be possible, depending
13485 on complex optimization circuitry, for the compiler to figure
13486 out the value of X at compile time, in which case this initialization
13487 can be done by the loader, and requires no initialization code. It
13488 is not possible to document the precise conditions under which the
13489 optimizer can figure this out.
13491 Note that this the implementation of this restriction requires full
13492 code generation. If it is used in conjunction with “semantics only”
13493 checking, then some cases of violations may be missed.
13495 When this restriction is active, we are not requesting control-flow
13496 preservation with -fpreserve-control-flow, and the static elaboration model is
13497 used, the compiler is allowed to suppress the elaboration counter normally
13498 associated with the unit. This counter is typically used to check for access
13499 before elaboration and to control multiple elaboration attempts.
13501 @node No_Dynamic_Accessibility_Checks,No_Dynamic_Sized_Objects,No_Elaboration_Code,Program Unit Level Restrictions
13502 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-accessibility-checks}@anchor{216}
13503 @subsection No_Dynamic_Accessibility_Checks
13506 @geindex No_Dynamic_Accessibility_Checks
13508 [GNAT] No dynamic accessibility checks are generated when this restriction is
13509 in effect. Instead, dangling references are prevented via more conservative
13510 compile-time checking. More specifically, existing compile-time checks are
13511 enforced but with more conservative assumptions about the accessibility levels
13512 of the relevant entities. These conservative assumptions eliminate the need for
13513 dynamic accessibility checks.
13515 These new rules for computing (at compile-time) the accessibility level of an
13516 anonymous access type T are as follows:
13519 @itemize *
13521 @item 
13522 If T is a function result type then, from the caller’s perspective, its level
13523 is that of the innermost master enclosing the function call. From the callee’s
13524 perspective, the level of parameters and local variables of the callee is
13525 statically deeper than the level of T.
13527 For any other accessibility level L such that the level of parameters and local
13528 variables of the callee is statically deeper than L, the level of T (from the
13529 callee’s perspective) is also statically deeper than L.
13531 @item 
13532 If T is the type of a formal parameter then, from the caller’s perspective,
13533 its level is at least as deep as that of the type of the corresponding actual
13534 parameter (whatever that actual parameter might be). From the callee’s
13535 perspective, the level of parameters and local variables of the callee is
13536 statically deeper than the level of T.
13538 @item 
13539 If T is the type of a discriminant then its level is that of the discriminated
13540 type.
13542 @item 
13543 If T is the type of a stand-alone object then its level is the level of the
13544 object.
13546 @item 
13547 In all other cases, the level of T is as defined by the existing rules of Ada.
13548 @end itemize
13550 @node No_Dynamic_Sized_Objects,No_Entry_Queue,No_Dynamic_Accessibility_Checks,Program Unit Level Restrictions
13551 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{217}
13552 @subsection No_Dynamic_Sized_Objects
13555 @geindex No_Dynamic_Sized_Objects
13557 [GNAT] This restriction disallows certain constructs that might lead to the
13558 creation of dynamic-sized composite objects (or array or discriminated type).
13559 An array subtype indication is illegal if the bounds are not static
13560 or references to discriminants of an enclosing type.
13561 A discriminated subtype indication is illegal if the type has
13562 discriminant-dependent array components or a variant part, and the
13563 discriminants are not static. In addition, array and record aggregates are
13564 illegal in corresponding cases. Note that this restriction does not forbid
13565 access discriminants. It is often a good idea to combine this restriction
13566 with No_Secondary_Stack.
13568 @node No_Entry_Queue,No_Implementation_Aspect_Specifications,No_Dynamic_Sized_Objects,Program Unit Level Restrictions
13569 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{218}
13570 @subsection No_Entry_Queue
13573 @geindex No_Entry_Queue
13575 [GNAT] This restriction is a declaration that any protected entry compiled in
13576 the scope of the restriction has at most one task waiting on the entry
13577 at any one time, and so no queue is required.  This restriction is not
13578 checked at compile time.  A program execution is erroneous if an attempt
13579 is made to queue a second task on such an entry.
13581 @node No_Implementation_Aspect_Specifications,No_Implementation_Attributes,No_Entry_Queue,Program Unit Level Restrictions
13582 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{219}
13583 @subsection No_Implementation_Aspect_Specifications
13586 @geindex No_Implementation_Aspect_Specifications
13588 [RM 13.12.1] This restriction checks at compile time that no
13589 GNAT-defined aspects are present.  With this restriction, the only
13590 aspects that can be used are those defined in the Ada Reference Manual.
13592 @node No_Implementation_Attributes,No_Implementation_Identifiers,No_Implementation_Aspect_Specifications,Program Unit Level Restrictions
13593 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{21a}
13594 @subsection No_Implementation_Attributes
13597 @geindex No_Implementation_Attributes
13599 [RM 13.12.1] This restriction checks at compile time that no
13600 GNAT-defined attributes are present.  With this restriction, the only
13601 attributes that can be used are those defined in the Ada Reference
13602 Manual.
13604 @node No_Implementation_Identifiers,No_Implementation_Pragmas,No_Implementation_Attributes,Program Unit Level Restrictions
13605 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{21b}
13606 @subsection No_Implementation_Identifiers
13609 @geindex No_Implementation_Identifiers
13611 [RM 13.12.1] This restriction checks at compile time that no
13612 implementation-defined identifiers (marked with pragma Implementation_Defined)
13613 occur within language-defined packages.
13615 @node No_Implementation_Pragmas,No_Implementation_Restrictions,No_Implementation_Identifiers,Program Unit Level Restrictions
13616 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{21c}
13617 @subsection No_Implementation_Pragmas
13620 @geindex No_Implementation_Pragmas
13622 [RM 13.12.1] This restriction checks at compile time that no
13623 GNAT-defined pragmas are present.  With this restriction, the only
13624 pragmas that can be used are those defined in the Ada Reference Manual.
13626 @node No_Implementation_Restrictions,No_Implementation_Units,No_Implementation_Pragmas,Program Unit Level Restrictions
13627 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{21d}
13628 @subsection No_Implementation_Restrictions
13631 @geindex No_Implementation_Restrictions
13633 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
13634 identifiers (other than @code{No_Implementation_Restrictions} itself)
13635 are present.  With this restriction, the only other restriction identifiers
13636 that can be used are those defined in the Ada Reference Manual.
13638 @node No_Implementation_Units,No_Implicit_Aliasing,No_Implementation_Restrictions,Program Unit Level Restrictions
13639 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{21e}
13640 @subsection No_Implementation_Units
13643 @geindex No_Implementation_Units
13645 [RM 13.12.1] This restriction checks at compile time that there is no
13646 mention in the context clause of any implementation-defined descendants
13647 of packages Ada, Interfaces, or System.
13649 @node No_Implicit_Aliasing,No_Implicit_Loops,No_Implementation_Units,Program Unit Level Restrictions
13650 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{21f}
13651 @subsection No_Implicit_Aliasing
13654 @geindex No_Implicit_Aliasing
13656 [GNAT] This restriction, which is not required to be partition-wide consistent,
13657 requires an explicit aliased keyword for an object to which ‘Access,
13658 ‘Unchecked_Access, or ‘Address is applied, and forbids entirely the use of
13659 the ‘Unrestricted_Access attribute for objects. Note: the reason that
13660 Unrestricted_Access is forbidden is that it would require the prefix
13661 to be aliased, and in such cases, it can always be replaced by
13662 the standard attribute Unchecked_Access which is preferable.
13664 @node No_Implicit_Loops,No_Obsolescent_Features,No_Implicit_Aliasing,Program Unit Level Restrictions
13665 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{220}
13666 @subsection No_Implicit_Loops
13669 @geindex No_Implicit_Loops
13671 [GNAT] This restriction ensures that the generated code of the unit marked
13672 with this restriction does not contain any implicit @code{for} loops, either by
13673 modifying the generated code where possible, or by rejecting any construct
13674 that would otherwise generate an implicit @code{for} loop. If this restriction is
13675 active, it is possible to build large array aggregates with all static
13676 components without generating an intermediate temporary, and without generating
13677 a loop to initialize individual components. Otherwise, a loop is created for
13678 arrays larger than about 5000 scalar components. Note that if this restriction
13679 is set in the spec of a package, it will not apply to its body.
13681 @node No_Obsolescent_Features,No_Wide_Characters,No_Implicit_Loops,Program Unit Level Restrictions
13682 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{221}
13683 @subsection No_Obsolescent_Features
13686 @geindex No_Obsolescent_Features
13688 [RM 13.12.1] This restriction checks at compile time that no obsolescent
13689 features are used, as defined in Annex J of the Ada Reference Manual.
13691 @node No_Wide_Characters,Static_Dispatch_Tables,No_Obsolescent_Features,Program Unit Level Restrictions
13692 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{222}
13693 @subsection No_Wide_Characters
13696 @geindex No_Wide_Characters
13698 [GNAT] This restriction ensures at compile time that no uses of the types
13699 @code{Wide_Character} or @code{Wide_String} or corresponding wide
13700 wide types
13701 appear, and that no wide or wide wide string or character literals
13702 appear in the program (that is literals representing characters not in
13703 type @code{Character}).
13705 @node Static_Dispatch_Tables,SPARK_05,No_Wide_Characters,Program Unit Level Restrictions
13706 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{223}
13707 @subsection Static_Dispatch_Tables
13710 @geindex Static_Dispatch_Tables
13712 [GNAT] This restriction checks at compile time that all the artifacts
13713 associated with dispatch tables can be placed in read-only memory.
13715 @node SPARK_05,,Static_Dispatch_Tables,Program Unit Level Restrictions
13716 @anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{224}
13717 @subsection SPARK_05
13720 @geindex SPARK_05
13722 [GNAT] This restriction no longer has any effect and is superseded by
13723 SPARK 2014, whose restrictions are checked by the tool GNATprove. To check that
13724 a codebase respects SPARK 2014 restrictions, mark the code with pragma or
13725 aspect @code{SPARK_Mode}, and run the tool GNATprove at Stone assurance level, as
13726 follows:
13728 @example
13729 gnatprove -P project.gpr --mode=stone
13730 @end example
13732 or equivalently:
13734 @example
13735 gnatprove -P project.gpr --mode=check_all
13736 @end example
13738 @node Implementation Advice,Implementation Defined Characteristics,Standard and Implementation Defined Restrictions,Top
13739 @anchor{gnat_rm/implementation_advice doc}@anchor{225}@anchor{gnat_rm/implementation_advice id1}@anchor{226}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a}
13740 @chapter Implementation Advice
13743 The main text of the Ada Reference Manual describes the required
13744 behavior of all Ada compilers, and the GNAT compiler conforms to
13745 these requirements.
13747 In addition, there are sections throughout the Ada Reference Manual headed
13748 by the phrase ‘Implementation advice’.  These sections are not normative,
13749 i.e., they do not specify requirements that all compilers must
13750 follow.  Rather they provide advice on generally desirable behavior.
13751 They are not requirements, because they describe behavior that cannot
13752 be provided on all systems, or may be undesirable on some systems.
13754 As far as practical, GNAT follows the implementation advice in
13755 the Ada Reference Manual.  Each such RM section corresponds to a section
13756 in this chapter whose title specifies the
13757 RM section number and paragraph number and the subject of
13758 the advice.  The contents of each section consists of the RM text within
13759 quotation marks,
13760 followed by the GNAT interpretation of the advice.  Most often, this simply says
13761 ‘followed’, which means that GNAT follows the advice.  However, in a
13762 number of cases, GNAT deliberately deviates from this advice, in which
13763 case the text describes what GNAT does and why.
13765 @geindex Error detection
13767 @menu
13768 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection. 
13769 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units. 
13770 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors. 
13771 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas. 
13772 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas. 
13773 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets. 
13774 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types. 
13775 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types. 
13776 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values. 
13777 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types. 
13778 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays. 
13779 * RM 9.6(30-31); Duration’Small: RM 9 6 30-31 Duration’Small. 
13780 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation. 
13781 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information. 
13782 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks. 
13783 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses. 
13784 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types. 
13785 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses. 
13786 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses. 
13787 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses. 
13788 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses. 
13789 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses. 
13790 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses. 
13791 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses. 
13792 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes. 
13793 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering. 
13794 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private. 
13795 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations. 
13796 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion. 
13797 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage. 
13798 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation. 
13799 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes. 
13800 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types. 
13801 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling. 
13802 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling. 
13803 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation. 
13804 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate. 
13805 * RM A.18; Containers: RM A 18 Containers. 
13806 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export. 
13807 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces. 
13808 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C. 
13809 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL. 
13810 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran. 
13811 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations. 
13812 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations. 
13813 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support. 
13814 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers. 
13815 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts. 
13816 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements. 
13817 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names. 
13818 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes. 
13819 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies. 
13820 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies. 
13821 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort. 
13822 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions. 
13823 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time. 
13824 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem. 
13825 * RM F(7); COBOL Support: RM F 7 COBOL Support. 
13826 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support. 
13827 * RM G; Numerics: RM G Numerics. 
13828 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types. 
13829 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions. 
13830 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements. 
13831 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy. 
13832 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy. 
13834 @end menu
13836 @node RM 1 1 3 20 Error Detection,RM 1 1 3 31 Child Units,,Implementation Advice
13837 @anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{227}
13838 @section RM 1.1.3(20): Error Detection
13841 @quotation
13843 “If an implementation detects the use of an unsupported Specialized Needs
13844 Annex feature at run time, it should raise @code{Program_Error} if
13845 feasible.”
13846 @end quotation
13848 Not relevant.  All specialized needs annex features are either supported,
13849 or diagnosed at compile time.
13851 @geindex Child Units
13853 @node RM 1 1 3 31 Child Units,RM 1 1 5 12 Bounded Errors,RM 1 1 3 20 Error Detection,Implementation Advice
13854 @anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{228}
13855 @section RM 1.1.3(31): Child Units
13858 @quotation
13860 “If an implementation wishes to provide implementation-defined
13861 extensions to the functionality of a language-defined library unit, it
13862 should normally do so by adding children to the library unit.”
13863 @end quotation
13865 Followed.
13867 @geindex Bounded errors
13869 @node RM 1 1 5 12 Bounded Errors,RM 2 8 16 Pragmas,RM 1 1 3 31 Child Units,Implementation Advice
13870 @anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{229}
13871 @section RM 1.1.5(12): Bounded Errors
13874 @quotation
13876 “If an implementation detects a bounded error or erroneous
13877 execution, it should raise @code{Program_Error}.”
13878 @end quotation
13880 Followed in all cases in which the implementation detects a bounded
13881 error or erroneous execution.  Not all such situations are detected at
13882 runtime.
13884 @geindex Pragmas
13886 @node RM 2 8 16 Pragmas,RM 2 8 17-19 Pragmas,RM 1 1 5 12 Bounded Errors,Implementation Advice
13887 @anchor{gnat_rm/implementation_advice id2}@anchor{22a}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{22b}
13888 @section RM 2.8(16): Pragmas
13891 @quotation
13893 “Normally, implementation-defined pragmas should have no semantic effect
13894 for error-free programs; that is, if the implementation-defined pragmas
13895 are removed from a working program, the program should still be legal,
13896 and should still have the same semantics.”
13897 @end quotation
13899 The following implementation defined pragmas are exceptions to this
13900 rule:
13903 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxx} 
13904 @headitem
13906 Pragma
13908 @tab
13910 Explanation
13912 @item
13914 `Abort_Defer'
13916 @tab
13918 Affects semantics
13920 @item
13922 `Ada_83'
13924 @tab
13926 Affects legality
13928 @item
13930 `Assert'
13932 @tab
13934 Affects semantics
13936 @item
13938 `CPP_Class'
13940 @tab
13942 Affects semantics
13944 @item
13946 `CPP_Constructor'
13948 @tab
13950 Affects semantics
13952 @item
13954 `Debug'
13956 @tab
13958 Affects semantics
13960 @item
13962 `Interface_Name'
13964 @tab
13966 Affects semantics
13968 @item
13970 `Machine_Attribute'
13972 @tab
13974 Affects semantics
13976 @item
13978 `Unimplemented_Unit'
13980 @tab
13982 Affects legality
13984 @item
13986 `Unchecked_Union'
13988 @tab
13990 Affects semantics
13992 @end multitable
13995 In each of the above cases, it is essential to the purpose of the pragma
13996 that this advice not be followed.  For details see
13997 @ref{7,,Implementation Defined Pragmas}.
13999 @node RM 2 8 17-19 Pragmas,RM 3 5 2 5 Alternative Character Sets,RM 2 8 16 Pragmas,Implementation Advice
14000 @anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{22c}
14001 @section RM 2.8(17-19): Pragmas
14004 @quotation
14006 “Normally, an implementation should not define pragmas that can
14007 make an illegal program legal, except as follows:
14010 @itemize *
14012 @item 
14013 A pragma used to complete a declaration, such as a pragma @code{Import};
14015 @item 
14016 A pragma used to configure the environment by adding, removing, or
14017 replacing @code{library_items}.”
14018 @end itemize
14019 @end quotation
14021 See @ref{22b,,RM 2.8(16); Pragmas}.
14023 @geindex Character Sets
14025 @geindex Alternative Character Sets
14027 @node RM 3 5 2 5 Alternative Character Sets,RM 3 5 4 28 Integer Types,RM 2 8 17-19 Pragmas,Implementation Advice
14028 @anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{22d}
14029 @section RM 3.5.2(5): Alternative Character Sets
14032 @quotation
14034 “If an implementation supports a mode with alternative interpretations
14035 for @code{Character} and @code{Wide_Character}, the set of graphic
14036 characters of @code{Character} should nevertheless remain a proper
14037 subset of the set of graphic characters of @code{Wide_Character}.  Any
14038 character set ‘localizations’ should be reflected in the results of
14039 the subprograms defined in the language-defined package
14040 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
14041 an alternative interpretation of @code{Character}, the implementation should
14042 also support a corresponding change in what is a legal
14043 @code{identifier_letter}.”
14044 @end quotation
14046 Not all wide character modes follow this advice, in particular the JIS
14047 and IEC modes reflect standard usage in Japan, and in these encoding,
14048 the upper half of the Latin-1 set is not part of the wide-character
14049 subset, since the most significant bit is used for wide character
14050 encoding.  However, this only applies to the external forms.  Internally
14051 there is no such restriction.
14053 @geindex Integer types
14055 @node RM 3 5 4 28 Integer Types,RM 3 5 4 29 Integer Types,RM 3 5 2 5 Alternative Character Sets,Implementation Advice
14056 @anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{22e}
14057 @section RM 3.5.4(28): Integer Types
14060 @quotation
14062 “An implementation should support @code{Long_Integer} in addition to
14063 @code{Integer} if the target machine supports 32-bit (or longer)
14064 arithmetic.  No other named integer subtypes are recommended for package
14065 @code{Standard}.  Instead, appropriate named integer subtypes should be
14066 provided in the library package @code{Interfaces} (see B.2).”
14067 @end quotation
14069 @code{Long_Integer} is supported.  Other standard integer types are supported
14070 so this advice is not fully followed.  These types
14071 are supported for convenient interface to C, and so that all hardware
14072 types of the machine are easily available.
14074 @node RM 3 5 4 29 Integer Types,RM 3 5 5 8 Enumeration Values,RM 3 5 4 28 Integer Types,Implementation Advice
14075 @anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{22f}
14076 @section RM 3.5.4(29): Integer Types
14079 @quotation
14081 “An implementation for a two’s complement machine should support
14082 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
14083 implementation should support a non-binary modules up to @code{Integer'Last}.”
14084 @end quotation
14086 Followed.
14088 @geindex Enumeration values
14090 @node RM 3 5 5 8 Enumeration Values,RM 3 5 7 17 Float Types,RM 3 5 4 29 Integer Types,Implementation Advice
14091 @anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{230}
14092 @section RM 3.5.5(8): Enumeration Values
14095 @quotation
14097 “For the evaluation of a call on @code{S'Pos} for an enumeration
14098 subtype, if the value of the operand does not correspond to the internal
14099 code for any enumeration literal of its type (perhaps due to an
14100 un-initialized variable), then the implementation should raise
14101 @code{Program_Error}.  This is particularly important for enumeration
14102 types with noncontiguous internal codes specified by an
14103 enumeration_representation_clause.”
14104 @end quotation
14106 Followed.
14108 @geindex Float types
14110 @node RM 3 5 7 17 Float Types,RM 3 6 2 11 Multidimensional Arrays,RM 3 5 5 8 Enumeration Values,Implementation Advice
14111 @anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{231}
14112 @section RM 3.5.7(17): Float Types
14115 @quotation
14117 “An implementation should support @code{Long_Float} in addition to
14118 @code{Float} if the target machine supports 11 or more digits of
14119 precision.  No other named floating point subtypes are recommended for
14120 package @code{Standard}.  Instead, appropriate named floating point subtypes
14121 should be provided in the library package @code{Interfaces} (see B.2).”
14122 @end quotation
14124 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
14125 former provides improved compatibility with other implementations
14126 supporting this type.  The latter corresponds to the highest precision
14127 floating-point type supported by the hardware.  On most machines, this
14128 will be the same as @code{Long_Float}, but on some machines, it will
14129 correspond to the IEEE extended form.  The notable case is all x86
14130 implementations, where @code{Long_Long_Float} corresponds to the 80-bit
14131 extended precision format supported in hardware on this processor.
14132 Note that the 128-bit format on SPARC is not supported, since this
14133 is a software rather than a hardware format.
14135 @geindex Multidimensional arrays
14137 @geindex Arrays
14138 @geindex multidimensional
14140 @node RM 3 6 2 11 Multidimensional Arrays,RM 9 6 30-31 Duration’Small,RM 3 5 7 17 Float Types,Implementation Advice
14141 @anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{232}
14142 @section RM 3.6.2(11): Multidimensional Arrays
14145 @quotation
14147 “An implementation should normally represent multidimensional arrays in
14148 row-major order, consistent with the notation used for multidimensional
14149 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
14150 (@code{Fortran}, …) applies to a multidimensional array type, then
14151 column-major order should be used instead (see B.5, `Interfacing with Fortran').”
14152 @end quotation
14154 Followed.
14156 @geindex Duration'Small
14158 @node RM 9 6 30-31 Duration’Small,RM 10 2 1 12 Consistent Representation,RM 3 6 2 11 Multidimensional Arrays,Implementation Advice
14159 @anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{233}
14160 @section RM 9.6(30-31): Duration’Small
14163 @quotation
14165 “Whenever possible in an implementation, the value of @code{Duration'Small}
14166 should be no greater than 100 microseconds.”
14167 @end quotation
14169 Followed.  (@code{Duration'Small} = 10**(-9)).
14171 @quotation
14173 “The time base for @code{delay_relative_statements} should be monotonic;
14174 it need not be the same time base as used for @code{Calendar.Clock}.”
14175 @end quotation
14177 Followed.
14179 @node RM 10 2 1 12 Consistent Representation,RM 11 4 1 19 Exception Information,RM 9 6 30-31 Duration’Small,Implementation Advice
14180 @anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{234}
14181 @section RM 10.2.1(12): Consistent Representation
14184 @quotation
14186 “In an implementation, a type declared in a pre-elaborated package should
14187 have the same representation in every elaboration of a given version of
14188 the package, whether the elaborations occur in distinct executions of
14189 the same program, or in executions of distinct programs or partitions
14190 that include the given version.”
14191 @end quotation
14193 Followed, except in the case of tagged types.  Tagged types involve
14194 implicit pointers to a local copy of a dispatch table, and these pointers
14195 have representations which thus depend on a particular elaboration of the
14196 package.  It is not easy to see how it would be possible to follow this
14197 advice without severely impacting efficiency of execution.
14199 @geindex Exception information
14201 @node RM 11 4 1 19 Exception Information,RM 11 5 28 Suppression of Checks,RM 10 2 1 12 Consistent Representation,Implementation Advice
14202 @anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{235}
14203 @section RM 11.4.1(19): Exception Information
14206 @quotation
14208 “@code{Exception_Message} by default and @code{Exception_Information}
14209 should produce information useful for
14210 debugging.  @code{Exception_Message} should be short, about one
14211 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
14212 should not include the
14213 @code{Exception_Name}.  @code{Exception_Information} should include both
14214 the @code{Exception_Name} and the @code{Exception_Message}.”
14215 @end quotation
14217 Followed.  For each exception that doesn’t have a specified
14218 @code{Exception_Message}, the compiler generates one containing the location
14219 of the raise statement.  This location has the form ‘file_name:line’, where
14220 file_name is the short file name (without path information) and line is the line
14221 number in the file.  Note that in the case of the Zero Cost Exception
14222 mechanism, these messages become redundant with the Exception_Information that
14223 contains a full backtrace of the calling sequence, so they are disabled.
14224 To disable explicitly the generation of the source location message, use the
14225 Pragma @code{Discard_Names}.
14227 @geindex Suppression of checks
14229 @geindex Checks
14230 @geindex suppression of
14232 @node RM 11 5 28 Suppression of Checks,RM 13 1 21-24 Representation Clauses,RM 11 4 1 19 Exception Information,Implementation Advice
14233 @anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{236}
14234 @section RM 11.5(28): Suppression of Checks
14237 @quotation
14239 “The implementation should minimize the code executed for checks that
14240 have been suppressed.”
14241 @end quotation
14243 Followed.
14245 @geindex Representation clauses
14247 @node RM 13 1 21-24 Representation Clauses,RM 13 2 6-8 Packed Types,RM 11 5 28 Suppression of Checks,Implementation Advice
14248 @anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{237}
14249 @section RM 13.1 (21-24): Representation Clauses
14252 @quotation
14254 “The recommended level of support for all representation items is
14255 qualified as follows:
14257 An implementation need not support representation items containing
14258 nonstatic expressions, except that an implementation should support a
14259 representation item for a given entity if each nonstatic expression in
14260 the representation item is a name that statically denotes a constant
14261 declared before the entity.”
14262 @end quotation
14264 Followed.  In fact, GNAT goes beyond the recommended level of support
14265 by allowing nonstatic expressions in some representation clauses even
14266 without the need to declare constants initialized with the values of
14267 such expressions.
14268 For example:
14270 @example
14271   X : Integer;
14272   Y : Float;
14273   for Y'Address use X'Address;>>
14276 "An implementation need not support a specification for the `@w{`}Size`@w{`}
14277 for a given composite subtype, nor the size or storage place for an
14278 object (including a component) of a given composite subtype, unless the
14279 constraints on the subtype and its composite subcomponents (if any) are
14280 all static constraints."
14281 @end example
14283 Followed.  Size Clauses are not permitted on nonstatic components, as
14284 described above.
14286 @quotation
14288 “An aliased component, or a component whose type is by-reference, should
14289 always be allocated at an addressable location.”
14290 @end quotation
14292 Followed.
14294 @geindex Packed types
14296 @node RM 13 2 6-8 Packed Types,RM 13 3 14-19 Address Clauses,RM 13 1 21-24 Representation Clauses,Implementation Advice
14297 @anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{238}
14298 @section RM 13.2(6-8): Packed Types
14301 @quotation
14303 “If a type is packed, then the implementation should try to minimize
14304 storage allocated to objects of the type, possibly at the expense of
14305 speed of accessing components, subject to reasonable complexity in
14306 addressing calculations.
14308 The recommended level of support pragma @code{Pack} is:
14310 For a packed record type, the components should be packed as tightly as
14311 possible subject to the Sizes of the component subtypes, and subject to
14312 any `record_representation_clause' that applies to the type; the
14313 implementation may, but need not, reorder components or cross aligned
14314 word boundaries to improve the packing.  A component whose @code{Size} is
14315 greater than the word size may be allocated an integral number of words.”
14316 @end quotation
14318 Followed.  Tight packing of arrays is supported for all component sizes
14319 up to 64-bits. If the array component size is 1 (that is to say, if
14320 the component is a boolean type or an enumeration type with two values)
14321 then values of the type are implicitly initialized to zero. This
14322 happens both for objects of the packed type, and for objects that have a
14323 subcomponent of the packed type.
14325 @geindex Address clauses
14327 @node RM 13 3 14-19 Address Clauses,RM 13 3 29-35 Alignment Clauses,RM 13 2 6-8 Packed Types,Implementation Advice
14328 @anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{239}
14329 @section RM 13.3(14-19): Address Clauses
14332 @quotation
14334 “For an array @code{X}, @code{X'Address} should point at the first
14335 component of the array, and not at the array bounds.”
14336 @end quotation
14338 Followed.
14340 @quotation
14342 “The recommended level of support for the @code{Address} attribute is:
14344 @code{X'Address} should produce a useful result if @code{X} is an
14345 object that is aliased or of a by-reference type, or is an entity whose
14346 @code{Address} has been specified.”
14347 @end quotation
14349 Followed.  A valid address will be produced even if none of those
14350 conditions have been met.  If necessary, the object is forced into
14351 memory to ensure the address is valid.
14353 @quotation
14355 “An implementation should support @code{Address} clauses for imported
14356 subprograms.”
14357 @end quotation
14359 Followed.
14361 @quotation
14363 “Objects (including subcomponents) that are aliased or of a by-reference
14364 type should be allocated on storage element boundaries.”
14365 @end quotation
14367 Followed.
14369 @quotation
14371 “If the @code{Address} of an object is specified, or it is imported or exported,
14372 then the implementation should not perform optimizations based on
14373 assumptions of no aliases.”
14374 @end quotation
14376 Followed.
14378 @geindex Alignment clauses
14380 @node RM 13 3 29-35 Alignment Clauses,RM 13 3 42-43 Size Clauses,RM 13 3 14-19 Address Clauses,Implementation Advice
14381 @anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{23a}
14382 @section RM 13.3(29-35): Alignment Clauses
14385 @quotation
14387 “The recommended level of support for the @code{Alignment} attribute for
14388 subtypes is:
14390 An implementation should support specified Alignments that are factors
14391 and multiples of the number of storage elements per word, subject to the
14392 following:”
14393 @end quotation
14395 Followed.
14397 @quotation
14399 “An implementation need not support specified Alignments for
14400 combinations of Sizes and Alignments that cannot be easily
14401 loaded and stored by available machine instructions.”
14402 @end quotation
14404 Followed.
14406 @quotation
14408 “An implementation need not support specified Alignments that are
14409 greater than the maximum @code{Alignment} the implementation ever returns by
14410 default.”
14411 @end quotation
14413 Followed.
14415 @quotation
14417 “The recommended level of support for the @code{Alignment} attribute for
14418 objects is:
14420 Same as above, for subtypes, but in addition:”
14421 @end quotation
14423 Followed.
14425 @quotation
14427 “For stand-alone library-level objects of statically constrained
14428 subtypes, the implementation should support all alignments
14429 supported by the target linker.  For example, page alignment is likely to
14430 be supported for such objects, but not for subtypes.”
14431 @end quotation
14433 Followed.
14435 @geindex Size clauses
14437 @node RM 13 3 42-43 Size Clauses,RM 13 3 50-56 Size Clauses,RM 13 3 29-35 Alignment Clauses,Implementation Advice
14438 @anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{23b}
14439 @section RM 13.3(42-43): Size Clauses
14442 @quotation
14444 “The recommended level of support for the @code{Size} attribute of
14445 objects is:
14447 A @code{Size} clause should be supported for an object if the specified
14448 @code{Size} is at least as large as its subtype’s @code{Size}, and
14449 corresponds to a size in storage elements that is a multiple of the
14450 object’s @code{Alignment} (if the @code{Alignment} is nonzero).”
14451 @end quotation
14453 Followed.
14455 @node RM 13 3 50-56 Size Clauses,RM 13 3 71-73 Component Size Clauses,RM 13 3 42-43 Size Clauses,Implementation Advice
14456 @anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{23c}
14457 @section RM 13.3(50-56): Size Clauses
14460 @quotation
14462 “If the @code{Size} of a subtype is specified, and allows for efficient
14463 independent addressability (see 9.10) on the target architecture, then
14464 the @code{Size} of the following objects of the subtype should equal the
14465 @code{Size} of the subtype:
14467 Aliased objects (including components).”
14468 @end quotation
14470 Followed.
14472 @quotation
14474 “@cite{Size} clause on a composite subtype should not affect the
14475 internal layout of components.”
14476 @end quotation
14478 Followed. But note that this can be overridden by use of the implementation
14479 pragma Implicit_Packing in the case of packed arrays.
14481 @quotation
14483 “The recommended level of support for the @code{Size} attribute of subtypes is:
14485 The @code{Size} (if not specified) of a static discrete or fixed point
14486 subtype should be the number of bits needed to represent each value
14487 belonging to the subtype using an unbiased representation, leaving space
14488 for a sign bit only if the subtype contains negative values.  If such a
14489 subtype is a first subtype, then an implementation should support a
14490 specified @code{Size} for it that reflects this representation.”
14491 @end quotation
14493 Followed.
14495 @quotation
14497 “For a subtype implemented with levels of indirection, the @code{Size}
14498 should include the size of the pointers, but not the size of what they
14499 point at.”
14500 @end quotation
14502 Followed.
14504 @geindex Component_Size clauses
14506 @node RM 13 3 71-73 Component Size Clauses,RM 13 4 9-10 Enumeration Representation Clauses,RM 13 3 50-56 Size Clauses,Implementation Advice
14507 @anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{23d}
14508 @section RM 13.3(71-73): Component Size Clauses
14511 @quotation
14513 “The recommended level of support for the @code{Component_Size}
14514 attribute is:
14516 An implementation need not support specified @code{Component_Sizes} that are
14517 less than the @code{Size} of the component subtype.”
14518 @end quotation
14520 Followed.
14522 @quotation
14524 “An implementation should support specified Component_Sizes that
14525 are factors and multiples of the word size.  For such
14526 Component_Sizes, the array should contain no gaps between
14527 components.  For other Component_Sizes (if supported), the array
14528 should contain no gaps between components when packing is also
14529 specified; the implementation should forbid this combination in cases
14530 where it cannot support a no-gaps representation.”
14531 @end quotation
14533 Followed.
14535 @geindex Enumeration representation clauses
14537 @geindex Representation clauses
14538 @geindex enumeration
14540 @node RM 13 4 9-10 Enumeration Representation Clauses,RM 13 5 1 17-22 Record Representation Clauses,RM 13 3 71-73 Component Size Clauses,Implementation Advice
14541 @anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{23e}
14542 @section RM 13.4(9-10): Enumeration Representation Clauses
14545 @quotation
14547 “The recommended level of support for enumeration representation clauses
14550 An implementation need not support enumeration representation clauses
14551 for boolean types, but should at minimum support the internal codes in
14552 the range @code{System.Min_Int .. System.Max_Int}.”
14553 @end quotation
14555 Followed.
14557 @geindex Record representation clauses
14559 @geindex Representation clauses
14560 @geindex records
14562 @node RM 13 5 1 17-22 Record Representation Clauses,RM 13 5 2 5 Storage Place Attributes,RM 13 4 9-10 Enumeration Representation Clauses,Implementation Advice
14563 @anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{23f}
14564 @section RM 13.5.1(17-22): Record Representation Clauses
14567 @quotation
14569 “The recommended level of support for
14570 `record_representation_clause's is:
14572 An implementation should support storage places that can be extracted
14573 with a load, mask, shift sequence of machine code, and set with a load,
14574 shift, mask, store sequence, given the available machine instructions
14575 and run-time model.”
14576 @end quotation
14578 Followed.
14580 @quotation
14582 “A storage place should be supported if its size is equal to the
14583 @code{Size} of the component subtype, and it starts and ends on a
14584 boundary that obeys the @code{Alignment} of the component subtype.”
14585 @end quotation
14587 Followed.
14589 @quotation
14591 “If the default bit ordering applies to the declaration of a given type,
14592 then for a component whose subtype’s @code{Size} is less than the word
14593 size, any storage place that does not cross an aligned word boundary
14594 should be supported.”
14595 @end quotation
14597 Followed.
14599 @quotation
14601 “An implementation may reserve a storage place for the tag field of a
14602 tagged type, and disallow other components from overlapping that place.”
14603 @end quotation
14605 Followed.  The storage place for the tag field is the beginning of the tagged
14606 record, and its size is Address’Size.  GNAT will reject an explicit component
14607 clause for the tag field.
14609 @quotation
14611 “An implementation need not support a `component_clause' for a
14612 component of an extension part if the storage place is not after the
14613 storage places of all components of the parent type, whether or not
14614 those storage places had been specified.”
14615 @end quotation
14617 Followed.  The above advice on record representation clauses is followed,
14618 and all mentioned features are implemented.
14620 @geindex Storage place attributes
14622 @node RM 13 5 2 5 Storage Place Attributes,RM 13 5 3 7-8 Bit Ordering,RM 13 5 1 17-22 Record Representation Clauses,Implementation Advice
14623 @anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{240}
14624 @section RM 13.5.2(5): Storage Place Attributes
14627 @quotation
14629 “If a component is represented using some form of pointer (such as an
14630 offset) to the actual data of the component, and this data is contiguous
14631 with the rest of the object, then the storage place attributes should
14632 reflect the place of the actual data, not the pointer.  If a component is
14633 allocated discontinuously from the rest of the object, then a warning
14634 should be generated upon reference to one of its storage place
14635 attributes.”
14636 @end quotation
14638 Followed.  There are no such components in GNAT.
14640 @geindex Bit ordering
14642 @node RM 13 5 3 7-8 Bit Ordering,RM 13 7 37 Address as Private,RM 13 5 2 5 Storage Place Attributes,Implementation Advice
14643 @anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{241}
14644 @section RM 13.5.3(7-8): Bit Ordering
14647 @quotation
14649 “The recommended level of support for the non-default bit ordering is:
14651 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
14652 should support the non-default bit ordering in addition to the default
14653 bit ordering.”
14654 @end quotation
14656 Followed.  Word size does not equal storage size in this implementation.
14657 Thus non-default bit ordering is not supported.
14659 @geindex Address
14660 @geindex as private type
14662 @node RM 13 7 37 Address as Private,RM 13 7 1 16 Address Operations,RM 13 5 3 7-8 Bit Ordering,Implementation Advice
14663 @anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{242}
14664 @section RM 13.7(37): Address as Private
14667 @quotation
14669 “@cite{Address} should be of a private type.”
14670 @end quotation
14672 Followed.
14674 @geindex Operations
14675 @geindex on `@w{`}Address`@w{`}
14677 @geindex Address
14678 @geindex operations of
14680 @node RM 13 7 1 16 Address Operations,RM 13 9 14-17 Unchecked Conversion,RM 13 7 37 Address as Private,Implementation Advice
14681 @anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{243}
14682 @section RM 13.7.1(16): Address Operations
14685 @quotation
14687 “Operations in @code{System} and its children should reflect the target
14688 environment semantics as closely as is reasonable.  For example, on most
14689 machines, it makes sense for address arithmetic to ‘wrap around’.
14690 Operations that do not make sense should raise @code{Program_Error}.”
14691 @end quotation
14693 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
14694 operation raises @code{Program_Error}, since all operations make sense.
14696 @geindex Unchecked conversion
14698 @node RM 13 9 14-17 Unchecked Conversion,RM 13 11 23-25 Implicit Heap Usage,RM 13 7 1 16 Address Operations,Implementation Advice
14699 @anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{244}
14700 @section RM 13.9(14-17): Unchecked Conversion
14703 @quotation
14705 “The @code{Size} of an array object should not include its bounds; hence,
14706 the bounds should not be part of the converted data.”
14707 @end quotation
14709 Followed.
14711 @quotation
14713 “The implementation should not generate unnecessary run-time checks to
14714 ensure that the representation of @code{S} is a representation of the
14715 target type.  It should take advantage of the permission to return by
14716 reference when possible.  Restrictions on unchecked conversions should be
14717 avoided unless required by the target environment.”
14718 @end quotation
14720 Followed.  There are no restrictions on unchecked conversion.  A warning is
14721 generated if the source and target types do not have the same size since
14722 the semantics in this case may be target dependent.
14724 @quotation
14726 “The recommended level of support for unchecked conversions is:
14728 Unchecked conversions should be supported and should be reversible in
14729 the cases where this clause defines the result.  To enable meaningful use
14730 of unchecked conversion, a contiguous representation should be used for
14731 elementary subtypes, for statically constrained array subtypes whose
14732 component subtype is one of the subtypes described in this paragraph,
14733 and for record subtypes without discriminants whose component subtypes
14734 are described in this paragraph.”
14735 @end quotation
14737 Followed.
14739 @geindex Heap usage
14740 @geindex implicit
14742 @node RM 13 11 23-25 Implicit Heap Usage,RM 13 11 2 17 Unchecked Deallocation,RM 13 9 14-17 Unchecked Conversion,Implementation Advice
14743 @anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{245}
14744 @section RM 13.11(23-25): Implicit Heap Usage
14747 @quotation
14749 “An implementation should document any cases in which it dynamically
14750 allocates heap storage for a purpose other than the evaluation of an
14751 allocator.”
14752 @end quotation
14754 Followed, the only other points at which heap storage is dynamically
14755 allocated are as follows:
14758 @itemize *
14760 @item 
14761 At initial elaboration time, to allocate dynamically sized global
14762 objects.
14764 @item 
14765 To allocate space for a task when a task is created.
14767 @item 
14768 To extend the secondary stack dynamically when needed.  The secondary
14769 stack is used for returning variable length results.
14770 @end itemize
14773 @quotation
14775 “A default (implementation-provided) storage pool for an
14776 access-to-constant type should not have overhead to support deallocation of
14777 individual objects.”
14778 @end quotation
14780 Followed.
14782 @quotation
14784 “A storage pool for an anonymous access type should be created at the
14785 point of an allocator for the type, and be reclaimed when the designated
14786 object becomes inaccessible.”
14787 @end quotation
14789 Followed.
14791 @geindex Unchecked deallocation
14793 @node RM 13 11 2 17 Unchecked Deallocation,RM 13 13 2 1 6 Stream Oriented Attributes,RM 13 11 23-25 Implicit Heap Usage,Implementation Advice
14794 @anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{246}
14795 @section RM 13.11.2(17): Unchecked Deallocation
14798 @quotation
14800 “For a standard storage pool, @code{Free} should actually reclaim the
14801 storage.”
14802 @end quotation
14804 Followed.
14806 @geindex Stream oriented attributes
14808 @node RM 13 13 2 1 6 Stream Oriented Attributes,RM A 1 52 Names of Predefined Numeric Types,RM 13 11 2 17 Unchecked Deallocation,Implementation Advice
14809 @anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{247}
14810 @section RM 13.13.2(1.6): Stream Oriented Attributes
14813 @quotation
14815 “If not specified, the value of Stream_Size for an elementary type
14816 should be the number of bits that corresponds to the minimum number of
14817 stream elements required by the first subtype of the type, rounded up
14818 to the nearest factor or multiple of the word size that is also a
14819 multiple of the stream element size.”
14820 @end quotation
14822 Followed, except that the number of stream elements is 1, 2, 3, 4 or 8.
14823 The Stream_Size may be used to override the default choice.
14825 The default implementation is based on direct binary representations and is
14826 therefore target- and endianness-dependent.  To address this issue, GNAT also
14827 supplies an alternate implementation of the stream attributes @code{Read} and
14828 @code{Write}, which uses the target-independent XDR standard representation for
14829 scalar types. This XDR alternative can be enabled via the binder switch -xdr.
14831 @geindex XDR representation
14833 @geindex Read attribute
14835 @geindex Write attribute
14837 @geindex Stream oriented attributes
14839 @node RM A 1 52 Names of Predefined Numeric Types,RM A 3 2 49 Ada Characters Handling,RM 13 13 2 1 6 Stream Oriented Attributes,Implementation Advice
14840 @anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{248}
14841 @section RM A.1(52): Names of Predefined Numeric Types
14844 @quotation
14846 “If an implementation provides additional named predefined integer types,
14847 then the names should end with @code{Integer} as in
14848 @code{Long_Integer}.  If an implementation provides additional named
14849 predefined floating point types, then the names should end with
14850 @code{Float} as in @code{Long_Float}.”
14851 @end quotation
14853 Followed.
14855 @geindex Ada.Characters.Handling
14857 @node RM A 3 2 49 Ada Characters Handling,RM A 4 4 106 Bounded-Length String Handling,RM A 1 52 Names of Predefined Numeric Types,Implementation Advice
14858 @anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{249}
14859 @section RM A.3.2(49): @code{Ada.Characters.Handling}
14862 @quotation
14864 “If an implementation provides a localized definition of @code{Character}
14865 or @code{Wide_Character}, then the effects of the subprograms in
14866 @code{Characters.Handling} should reflect the localizations.
14867 See also 3.5.2.”
14868 @end quotation
14870 Followed.  GNAT provides no such localized definitions.
14872 @geindex Bounded-length strings
14874 @node RM A 4 4 106 Bounded-Length String Handling,RM A 5 2 46-47 Random Number Generation,RM A 3 2 49 Ada Characters Handling,Implementation Advice
14875 @anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{24a}
14876 @section RM A.4.4(106): Bounded-Length String Handling
14879 @quotation
14881 “Bounded string objects should not be implemented by implicit pointers
14882 and dynamic allocation.”
14883 @end quotation
14885 Followed.  No implicit pointers or dynamic allocation are used.
14887 @geindex Random number generation
14889 @node RM A 5 2 46-47 Random Number Generation,RM A 10 7 23 Get_Immediate,RM A 4 4 106 Bounded-Length String Handling,Implementation Advice
14890 @anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{24b}
14891 @section RM A.5.2(46-47): Random Number Generation
14894 @quotation
14896 “Any storage associated with an object of type @code{Generator} should be
14897 reclaimed on exit from the scope of the object.”
14898 @end quotation
14900 Followed.
14902 @quotation
14904 “If the generator period is sufficiently long in relation to the number
14905 of distinct initiator values, then each possible value of
14906 @code{Initiator} passed to @code{Reset} should initiate a sequence of
14907 random numbers that does not, in a practical sense, overlap the sequence
14908 initiated by any other value.  If this is not possible, then the mapping
14909 between initiator values and generator states should be a rapidly
14910 varying function of the initiator value.”
14911 @end quotation
14913 Followed.  The generator period is sufficiently long for the first
14914 condition here to hold true.
14916 @geindex Get_Immediate
14918 @node RM A 10 7 23 Get_Immediate,RM A 18 Containers,RM A 5 2 46-47 Random Number Generation,Implementation Advice
14919 @anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{24c}
14920 @section RM A.10.7(23): @code{Get_Immediate}
14923 @quotation
14925 “The @code{Get_Immediate} procedures should be implemented with
14926 unbuffered input.  For a device such as a keyboard, input should be
14927 available if a key has already been typed, whereas for a disk
14928 file, input should always be available except at end of file.  For a file
14929 associated with a keyboard-like device, any line-editing features of the
14930 underlying operating system should be disabled during the execution of
14931 @code{Get_Immediate}.”
14932 @end quotation
14934 Followed on all targets except VxWorks. For VxWorks, there is no way to
14935 provide this functionality that does not result in the input buffer being
14936 flushed before the @code{Get_Immediate} call. A special unit
14937 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
14938 this functionality.
14940 @geindex Containers
14942 @node RM A 18 Containers,RM B 1 39-41 Pragma Export,RM A 10 7 23 Get_Immediate,Implementation Advice
14943 @anchor{gnat_rm/implementation_advice rm-a-18-containers}@anchor{24d}
14944 @section RM A.18: @code{Containers}
14947 All implementation advice pertaining to Ada.Containers and its
14948 child units (that is, all implementation advice occurring within
14949 section A.18 and its subsections) is followed except for A.18.24(17):
14951 @quotation
14953 “Bounded ordered set objects should be implemented without implicit pointers or dynamic allocation. “
14954 @end quotation
14956 The implementations of the two Reference_Preserving_Key functions of
14957 the generic package Ada.Containers.Bounded_Ordered_Sets each currently make
14958 use of dynamic allocation; other operations on bounded ordered set objects
14959 follow the implementation advice.
14961 @geindex Export
14963 @node RM B 1 39-41 Pragma Export,RM B 2 12-13 Package Interfaces,RM A 18 Containers,Implementation Advice
14964 @anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{24e}
14965 @section RM B.1(39-41): Pragma @code{Export}
14968 @quotation
14970 “If an implementation supports pragma @code{Export} to a given language,
14971 then it should also allow the main subprogram to be written in that
14972 language.  It should support some mechanism for invoking the elaboration
14973 of the Ada library units included in the system, and for invoking the
14974 finalization of the environment task.  On typical systems, the
14975 recommended mechanism is to provide two subprograms whose link names are
14976 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
14977 elaboration code for library units.  @code{adafinal} should contain the
14978 finalization code.  These subprograms should have no effect the second
14979 and subsequent time they are called.”
14980 @end quotation
14982 Followed.
14984 @quotation
14986 “Automatic elaboration of pre-elaborated packages should be
14987 provided when pragma @code{Export} is supported.”
14988 @end quotation
14990 Followed when the main program is in Ada.  If the main program is in a
14991 foreign language, then
14992 @code{adainit} must be called to elaborate pre-elaborated
14993 packages.
14995 @quotation
14997 “For each supported convention `L' other than @code{Intrinsic}, an
14998 implementation should support @code{Import} and @code{Export} pragmas
14999 for objects of `L'-compatible types and for subprograms, and pragma
15000 @cite{Convention} for `L'-eligible types and for subprograms,
15001 presuming the other language has corresponding features.  Pragma
15002 @code{Convention} need not be supported for scalar types.”
15003 @end quotation
15005 Followed.
15007 @geindex Package Interfaces
15009 @geindex Interfaces
15011 @node RM B 2 12-13 Package Interfaces,RM B 3 63-71 Interfacing with C,RM B 1 39-41 Pragma Export,Implementation Advice
15012 @anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{24f}
15013 @section RM B.2(12-13): Package @code{Interfaces}
15016 @quotation
15018 “For each implementation-defined convention identifier, there should be a
15019 child package of package Interfaces with the corresponding name.  This
15020 package should contain any declarations that would be useful for
15021 interfacing to the language (implementation) represented by the
15022 convention.  Any declarations useful for interfacing to any language on
15023 the given hardware architecture should be provided directly in
15024 @code{Interfaces}.”
15025 @end quotation
15027 Followed.
15029 @quotation
15031 “An implementation supporting an interface to C, COBOL, or Fortran should
15032 provide the corresponding package or packages described in the following
15033 clauses.”
15034 @end quotation
15036 Followed.  GNAT provides all the packages described in this section.
15038 @geindex C
15039 @geindex interfacing with
15041 @node RM B 3 63-71 Interfacing with C,RM B 4 95-98 Interfacing with COBOL,RM B 2 12-13 Package Interfaces,Implementation Advice
15042 @anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{250}
15043 @section RM B.3(63-71): Interfacing with C
15046 @quotation
15048 “An implementation should support the following interface correspondences
15049 between Ada and C.”
15050 @end quotation
15052 Followed.
15054 @quotation
15056 “An Ada procedure corresponds to a void-returning C function.”
15057 @end quotation
15059 Followed.
15061 @quotation
15063 “An Ada function corresponds to a non-void C function.”
15064 @end quotation
15066 Followed.
15068 @quotation
15070 “An Ada @code{in} scalar parameter is passed as a scalar argument to a C
15071 function.”
15072 @end quotation
15074 Followed.
15076 @quotation
15078 “An Ada @code{in} parameter of an access-to-object type with designated
15079 type @code{T} is passed as a @code{t*} argument to a C function,
15080 where @code{t} is the C type corresponding to the Ada type @code{T}.”
15081 @end quotation
15083 Followed.
15085 @quotation
15087 “An Ada access @code{T} parameter, or an Ada @code{out} or @code{in out}
15088 parameter of an elementary type @code{T}, is passed as a @code{t*}
15089 argument to a C function, where @code{t} is the C type corresponding to
15090 the Ada type @code{T}.  In the case of an elementary @code{out} or
15091 @code{in out} parameter, a pointer to a temporary copy is used to
15092 preserve by-copy semantics.”
15093 @end quotation
15095 Followed.
15097 @quotation
15099 “An Ada parameter of a record type @code{T}, of any mode, is passed as a
15100 @code{t*} argument to a C function, where @code{t} is the C
15101 structure corresponding to the Ada type @code{T}.”
15102 @end quotation
15104 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
15105 pragma, or Convention, or by explicitly specifying the mechanism for a given
15106 call using an extended import or export pragma.
15108 @quotation
15110 “An Ada parameter of an array type with component type @code{T}, of any
15111 mode, is passed as a @code{t*} argument to a C function, where
15112 @code{t} is the C type corresponding to the Ada type @code{T}.”
15113 @end quotation
15115 Followed.
15117 @quotation
15119 “An Ada parameter of an access-to-subprogram type is passed as a pointer
15120 to a C function whose prototype corresponds to the designated
15121 subprogram’s specification.”
15122 @end quotation
15124 Followed.
15126 @geindex COBOL
15127 @geindex interfacing with
15129 @node RM B 4 95-98 Interfacing with COBOL,RM B 5 22-26 Interfacing with Fortran,RM B 3 63-71 Interfacing with C,Implementation Advice
15130 @anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{251}
15131 @section RM B.4(95-98): Interfacing with COBOL
15134 @quotation
15136 “An Ada implementation should support the following interface
15137 correspondences between Ada and COBOL.”
15138 @end quotation
15140 Followed.
15142 @quotation
15144 “An Ada access @code{T} parameter is passed as a @code{BY REFERENCE} data item of
15145 the COBOL type corresponding to @code{T}.”
15146 @end quotation
15148 Followed.
15150 @quotation
15152 “An Ada in scalar parameter is passed as a @code{BY CONTENT} data item of
15153 the corresponding COBOL type.”
15154 @end quotation
15156 Followed.
15158 @quotation
15160 “Any other Ada parameter is passed as a @code{BY REFERENCE} data item of the
15161 COBOL type corresponding to the Ada parameter type; for scalars, a local
15162 copy is used if necessary to ensure by-copy semantics.”
15163 @end quotation
15165 Followed.
15167 @geindex Fortran
15168 @geindex interfacing with
15170 @node RM B 5 22-26 Interfacing with Fortran,RM C 1 3-5 Access to Machine Operations,RM B 4 95-98 Interfacing with COBOL,Implementation Advice
15171 @anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{252}
15172 @section RM B.5(22-26): Interfacing with Fortran
15175 @quotation
15177 “An Ada implementation should support the following interface
15178 correspondences between Ada and Fortran:”
15179 @end quotation
15181 Followed.
15183 @quotation
15185 “An Ada procedure corresponds to a Fortran subroutine.”
15186 @end quotation
15188 Followed.
15190 @quotation
15192 “An Ada function corresponds to a Fortran function.”
15193 @end quotation
15195 Followed.
15197 @quotation
15199 “An Ada parameter of an elementary, array, or record type @code{T} is
15200 passed as a @code{T} argument to a Fortran procedure, where @code{T} is
15201 the Fortran type corresponding to the Ada type @code{T}, and where the
15202 INTENT attribute of the corresponding dummy argument matches the Ada
15203 formal parameter mode; the Fortran implementation’s parameter passing
15204 conventions are used.  For elementary types, a local copy is used if
15205 necessary to ensure by-copy semantics.”
15206 @end quotation
15208 Followed.
15210 @quotation
15212 “An Ada parameter of an access-to-subprogram type is passed as a
15213 reference to a Fortran procedure whose interface corresponds to the
15214 designated subprogram’s specification.”
15215 @end quotation
15217 Followed.
15219 @geindex Machine operations
15221 @node RM C 1 3-5 Access to Machine Operations,RM C 1 10-16 Access to Machine Operations,RM B 5 22-26 Interfacing with Fortran,Implementation Advice
15222 @anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{253}
15223 @section RM C.1(3-5): Access to Machine Operations
15226 @quotation
15228 “The machine code or intrinsic support should allow access to all
15229 operations normally available to assembly language programmers for the
15230 target environment, including privileged instructions, if any.”
15231 @end quotation
15233 Followed.
15235 @quotation
15237 “The interfacing pragmas (see Annex B) should support interface to
15238 assembler; the default assembler should be associated with the
15239 convention identifier @code{Assembler}.”
15240 @end quotation
15242 Followed.
15244 @quotation
15246 “If an entity is exported to assembly language, then the implementation
15247 should allocate it at an addressable location, and should ensure that it
15248 is retained by the linking process, even if not otherwise referenced
15249 from the Ada code.  The implementation should assume that any call to a
15250 machine code or assembler subprogram is allowed to read or update every
15251 object that is specified as exported.”
15252 @end quotation
15254 Followed.
15256 @node RM C 1 10-16 Access to Machine Operations,RM C 3 28 Interrupt Support,RM C 1 3-5 Access to Machine Operations,Implementation Advice
15257 @anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{254}
15258 @section RM C.1(10-16): Access to Machine Operations
15261 @quotation
15263 “The implementation should ensure that little or no overhead is
15264 associated with calling intrinsic and machine-code subprograms.”
15265 @end quotation
15267 Followed for both intrinsics and machine-code subprograms.
15269 @quotation
15271 “It is recommended that intrinsic subprograms be provided for convenient
15272 access to any machine operations that provide special capabilities or
15273 efficiency and that are not otherwise available through the language
15274 constructs.”
15275 @end quotation
15277 Followed.  A full set of machine operation intrinsic subprograms is provided.
15279 @quotation
15281 “Atomic read-modify-write operations—e.g., test and set, compare and
15282 swap, decrement and test, enqueue/dequeue.”
15283 @end quotation
15285 Followed on any target supporting such operations.
15287 @quotation
15289 “Standard numeric functions—e.g.:, sin, log.”
15290 @end quotation
15292 Followed on any target supporting such operations.
15294 @quotation
15296 “String manipulation operations—e.g.:, translate and test.”
15297 @end quotation
15299 Followed on any target supporting such operations.
15301 @quotation
15303 “Vector operations—e.g.:, compare vector against thresholds.”
15304 @end quotation
15306 Followed on any target supporting such operations.
15308 @quotation
15310 “Direct operations on I/O ports.”
15311 @end quotation
15313 Followed on any target supporting such operations.
15315 @geindex Interrupt support
15317 @node RM C 3 28 Interrupt Support,RM C 3 1 20-21 Protected Procedure Handlers,RM C 1 10-16 Access to Machine Operations,Implementation Advice
15318 @anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{255}
15319 @section RM C.3(28): Interrupt Support
15322 @quotation
15324 “If the @code{Ceiling_Locking} policy is not in effect, the
15325 implementation should provide means for the application to specify which
15326 interrupts are to be blocked during protected actions, if the underlying
15327 system allows for a finer-grain control of interrupt blocking.”
15328 @end quotation
15330 Followed.  The underlying system does not allow for finer-grain control
15331 of interrupt blocking.
15333 @geindex Protected procedure handlers
15335 @node RM C 3 1 20-21 Protected Procedure Handlers,RM C 3 2 25 Package Interrupts,RM C 3 28 Interrupt Support,Implementation Advice
15336 @anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{256}
15337 @section RM C.3.1(20-21): Protected Procedure Handlers
15340 @quotation
15342 “Whenever possible, the implementation should allow interrupt handlers to
15343 be called directly by the hardware.”
15344 @end quotation
15346 Followed on any target where the underlying operating system permits
15347 such direct calls.
15349 @quotation
15351 “Whenever practical, violations of any
15352 implementation-defined restrictions should be detected before run time.”
15353 @end quotation
15355 Followed.  Compile time warnings are given when possible.
15357 @geindex Package `@w{`}Interrupts`@w{`}
15359 @geindex Interrupts
15361 @node RM C 3 2 25 Package Interrupts,RM C 4 14 Pre-elaboration Requirements,RM C 3 1 20-21 Protected Procedure Handlers,Implementation Advice
15362 @anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{257}
15363 @section RM C.3.2(25): Package @code{Interrupts}
15366 @quotation
15368 “If implementation-defined forms of interrupt handler procedures are
15369 supported, such as protected procedures with parameters, then for each
15370 such form of a handler, a type analogous to @code{Parameterless_Handler}
15371 should be specified in a child package of @code{Interrupts}, with the
15372 same operations as in the predefined package Interrupts.”
15373 @end quotation
15375 Followed.
15377 @geindex Pre-elaboration requirements
15379 @node RM C 4 14 Pre-elaboration Requirements,RM C 5 8 Pragma Discard_Names,RM C 3 2 25 Package Interrupts,Implementation Advice
15380 @anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{258}
15381 @section RM C.4(14): Pre-elaboration Requirements
15384 @quotation
15386 “It is recommended that pre-elaborated packages be implemented in such a
15387 way that there should be little or no code executed at run time for the
15388 elaboration of entities not already covered by the Implementation
15389 Requirements.”
15390 @end quotation
15392 Followed.  Executable code is generated in some cases, e.g., loops
15393 to initialize large arrays.
15395 @node RM C 5 8 Pragma Discard_Names,RM C 7 2 30 The Package Task_Attributes,RM C 4 14 Pre-elaboration Requirements,Implementation Advice
15396 @anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{259}
15397 @section RM C.5(8): Pragma @code{Discard_Names}
15400 @quotation
15402 “If the pragma applies to an entity, then the implementation should
15403 reduce the amount of storage used for storing names associated with that
15404 entity.”
15405 @end quotation
15407 Followed.
15409 @geindex Package Task_Attributes
15411 @geindex Task_Attributes
15413 @node RM C 7 2 30 The Package Task_Attributes,RM D 3 17 Locking Policies,RM C 5 8 Pragma Discard_Names,Implementation Advice
15414 @anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{25a}
15415 @section RM C.7.2(30): The Package Task_Attributes
15418 @quotation
15420 “Some implementations are targeted to domains in which memory use at run
15421 time must be completely deterministic.  For such implementations, it is
15422 recommended that the storage for task attributes will be pre-allocated
15423 statically and not from the heap.  This can be accomplished by either
15424 placing restrictions on the number and the size of the task’s
15425 attributes, or by using the pre-allocated storage for the first @code{N}
15426 attribute objects, and the heap for the others.  In the latter case,
15427 @code{N} should be documented.”
15428 @end quotation
15430 Not followed.  This implementation is not targeted to such a domain.
15432 @geindex Locking Policies
15434 @node RM D 3 17 Locking Policies,RM D 4 16 Entry Queuing Policies,RM C 7 2 30 The Package Task_Attributes,Implementation Advice
15435 @anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{25b}
15436 @section RM D.3(17): Locking Policies
15439 @quotation
15441 “The implementation should use names that end with @code{_Locking} for
15442 locking policies defined by the implementation.”
15443 @end quotation
15445 Followed.  Two implementation-defined locking policies are defined,
15446 whose names (@code{Inheritance_Locking} and
15447 @code{Concurrent_Readers_Locking}) follow this suggestion.
15449 @geindex Entry queuing policies
15451 @node RM D 4 16 Entry Queuing Policies,RM D 6 9-10 Preemptive Abort,RM D 3 17 Locking Policies,Implementation Advice
15452 @anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{25c}
15453 @section RM D.4(16): Entry Queuing Policies
15456 @quotation
15458 “Names that end with @code{_Queuing} should be used
15459 for all implementation-defined queuing policies.”
15460 @end quotation
15462 Followed.  No such implementation-defined queuing policies exist.
15464 @geindex Preemptive abort
15466 @node RM D 6 9-10 Preemptive Abort,RM D 7 21 Tasking Restrictions,RM D 4 16 Entry Queuing Policies,Implementation Advice
15467 @anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{25d}
15468 @section RM D.6(9-10): Preemptive Abort
15471 @quotation
15473 “Even though the `abort_statement' is included in the list of
15474 potentially blocking operations (see 9.5.1), it is recommended that this
15475 statement be implemented in a way that never requires the task executing
15476 the `abort_statement' to block.”
15477 @end quotation
15479 Followed.
15481 @quotation
15483 “On a multi-processor, the delay associated with aborting a task on
15484 another processor should be bounded; the implementation should use
15485 periodic polling, if necessary, to achieve this.”
15486 @end quotation
15488 Followed.
15490 @geindex Tasking restrictions
15492 @node RM D 7 21 Tasking Restrictions,RM D 8 47-49 Monotonic Time,RM D 6 9-10 Preemptive Abort,Implementation Advice
15493 @anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{25e}
15494 @section RM D.7(21): Tasking Restrictions
15497 @quotation
15499 “When feasible, the implementation should take advantage of the specified
15500 restrictions to produce a more efficient implementation.”
15501 @end quotation
15503 GNAT currently takes advantage of these restrictions by providing an optimized
15504 run time when the Ravenscar profile and the GNAT restricted run time set
15505 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
15506 pragma @code{Profile (Restricted)} for more details.
15508 @geindex Time
15509 @geindex monotonic
15511 @node RM D 8 47-49 Monotonic Time,RM E 5 28-29 Partition Communication Subsystem,RM D 7 21 Tasking Restrictions,Implementation Advice
15512 @anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{25f}
15513 @section RM D.8(47-49): Monotonic Time
15516 @quotation
15518 “When appropriate, implementations should provide configuration
15519 mechanisms to change the value of @code{Tick}.”
15520 @end quotation
15522 Such configuration mechanisms are not appropriate to this implementation
15523 and are thus not supported.
15525 @quotation
15527 “It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
15528 be implemented as transformations of the same time base.”
15529 @end quotation
15531 Followed.
15533 @quotation
15535 “It is recommended that the best time base which exists in
15536 the underlying system be available to the application through
15537 @code{Clock}.  @cite{Best} may mean highest accuracy or largest range.”
15538 @end quotation
15540 Followed.
15542 @geindex Partition communication subsystem
15544 @geindex PCS
15546 @node RM E 5 28-29 Partition Communication Subsystem,RM F 7 COBOL Support,RM D 8 47-49 Monotonic Time,Implementation Advice
15547 @anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{260}
15548 @section RM E.5(28-29): Partition Communication Subsystem
15551 @quotation
15553 “Whenever possible, the PCS on the called partition should allow for
15554 multiple tasks to call the RPC-receiver with different messages and
15555 should allow them to block until the corresponding subprogram body
15556 returns.”
15557 @end quotation
15559 Followed by GLADE, a separately supplied PCS that can be used with
15560 GNAT.
15562 @quotation
15564 “The @code{Write} operation on a stream of type @code{Params_Stream_Type}
15565 should raise @code{Storage_Error} if it runs out of space trying to
15566 write the @code{Item} into the stream.”
15567 @end quotation
15569 Followed by GLADE, a separately supplied PCS that can be used with
15570 GNAT.
15572 @geindex COBOL support
15574 @node RM F 7 COBOL Support,RM F 1 2 Decimal Radix Support,RM E 5 28-29 Partition Communication Subsystem,Implementation Advice
15575 @anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{261}
15576 @section RM F(7): COBOL Support
15579 @quotation
15581 “If COBOL (respectively, C) is widely supported in the target
15582 environment, implementations supporting the Information Systems Annex
15583 should provide the child package @code{Interfaces.COBOL} (respectively,
15584 @code{Interfaces.C}) specified in Annex B and should support a
15585 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
15586 pragmas (see Annex B), thus allowing Ada programs to interface with
15587 programs written in that language.”
15588 @end quotation
15590 Followed.
15592 @geindex Decimal radix support
15594 @node RM F 1 2 Decimal Radix Support,RM G Numerics,RM F 7 COBOL Support,Implementation Advice
15595 @anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{262}
15596 @section RM F.1(2): Decimal Radix Support
15599 @quotation
15601 “Packed decimal should be used as the internal representation for objects
15602 of subtype @code{S} when @code{S}’Machine_Radix = 10.”
15603 @end quotation
15605 Not followed.  GNAT ignores @code{S}’Machine_Radix and always uses binary
15606 representations.
15608 @geindex Numerics
15610 @node RM G Numerics,RM G 1 1 56-58 Complex Types,RM F 1 2 Decimal Radix Support,Implementation Advice
15611 @anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{263}
15612 @section RM G: Numerics
15615 @quotation
15617 “If Fortran (respectively, C) is widely supported in the target
15618 environment, implementations supporting the Numerics Annex
15619 should provide the child package @code{Interfaces.Fortran} (respectively,
15620 @code{Interfaces.C}) specified in Annex B and should support a
15621 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
15622 pragmas (see Annex B), thus allowing Ada programs to interface with
15623 programs written in that language.”
15624 @end quotation
15626 Followed.
15628 @geindex Complex types
15630 @node RM G 1 1 56-58 Complex Types,RM G 1 2 49 Complex Elementary Functions,RM G Numerics,Implementation Advice
15631 @anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{264}
15632 @section RM G.1.1(56-58): Complex Types
15635 @quotation
15637 “Because the usual mathematical meaning of multiplication of a complex
15638 operand and a real operand is that of the scaling of both components of
15639 the former by the latter, an implementation should not perform this
15640 operation by first promoting the real operand to complex type and then
15641 performing a full complex multiplication.  In systems that, in the
15642 future, support an Ada binding to IEC 559:1989, the latter technique
15643 will not generate the required result when one of the components of the
15644 complex operand is infinite.  (Explicit multiplication of the infinite
15645 component by the zero component obtained during promotion yields a NaN
15646 that propagates into the final result.) Analogous advice applies in the
15647 case of multiplication of a complex operand and a pure-imaginary
15648 operand, and in the case of division of a complex operand by a real or
15649 pure-imaginary operand.”
15650 @end quotation
15652 Not followed.
15654 @quotation
15656 “Similarly, because the usual mathematical meaning of addition of a
15657 complex operand and a real operand is that the imaginary operand remains
15658 unchanged, an implementation should not perform this operation by first
15659 promoting the real operand to complex type and then performing a full
15660 complex addition.  In implementations in which the @code{Signed_Zeros}
15661 attribute of the component type is @code{True} (and which therefore
15662 conform to IEC 559:1989 in regard to the handling of the sign of zero in
15663 predefined arithmetic operations), the latter technique will not
15664 generate the required result when the imaginary component of the complex
15665 operand is a negatively signed zero.  (Explicit addition of the negative
15666 zero to the zero obtained during promotion yields a positive zero.)
15667 Analogous advice applies in the case of addition of a complex operand
15668 and a pure-imaginary operand, and in the case of subtraction of a
15669 complex operand and a real or pure-imaginary operand.”
15670 @end quotation
15672 Not followed.
15674 @quotation
15676 “Implementations in which @code{Real'Signed_Zeros} is @code{True} should
15677 attempt to provide a rational treatment of the signs of zero results and
15678 result components.  As one example, the result of the @code{Argument}
15679 function should have the sign of the imaginary component of the
15680 parameter @code{X} when the point represented by that parameter lies on
15681 the positive real axis; as another, the sign of the imaginary component
15682 of the @code{Compose_From_Polar} function should be the same as
15683 (respectively, the opposite of) that of the @code{Argument} parameter when that
15684 parameter has a value of zero and the @code{Modulus} parameter has a
15685 nonnegative (respectively, negative) value.”
15686 @end quotation
15688 Followed.
15690 @geindex Complex elementary functions
15692 @node RM G 1 2 49 Complex Elementary Functions,RM G 2 4 19 Accuracy Requirements,RM G 1 1 56-58 Complex Types,Implementation Advice
15693 @anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{265}
15694 @section RM G.1.2(49): Complex Elementary Functions
15697 @quotation
15699 “Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
15700 @code{True} should attempt to provide a rational treatment of the signs
15701 of zero results and result components.  For example, many of the complex
15702 elementary functions have components that are odd functions of one of
15703 the parameter components; in these cases, the result component should
15704 have the sign of the parameter component at the origin.  Other complex
15705 elementary functions have zero components whose sign is opposite that of
15706 a parameter component at the origin, or is always positive or always
15707 negative.”
15708 @end quotation
15710 Followed.
15712 @geindex Accuracy requirements
15714 @node RM G 2 4 19 Accuracy Requirements,RM G 2 6 15 Complex Arithmetic Accuracy,RM G 1 2 49 Complex Elementary Functions,Implementation Advice
15715 @anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{266}
15716 @section RM G.2.4(19): Accuracy Requirements
15719 @quotation
15721 “The versions of the forward trigonometric functions without a
15722 @code{Cycle} parameter should not be implemented by calling the
15723 corresponding version with a @code{Cycle} parameter of
15724 @code{2.0*Numerics.Pi}, since this will not provide the required
15725 accuracy in some portions of the domain.  For the same reason, the
15726 version of @code{Log} without a @code{Base} parameter should not be
15727 implemented by calling the corresponding version with a @code{Base}
15728 parameter of @code{Numerics.e}.”
15729 @end quotation
15731 Followed.
15733 @geindex Complex arithmetic accuracy
15735 @geindex Accuracy
15736 @geindex complex arithmetic
15738 @node RM G 2 6 15 Complex Arithmetic Accuracy,RM H 6 15/2 Pragma Partition_Elaboration_Policy,RM G 2 4 19 Accuracy Requirements,Implementation Advice
15739 @anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{267}
15740 @section RM G.2.6(15): Complex Arithmetic Accuracy
15743 @quotation
15745 “The version of the @code{Compose_From_Polar} function without a
15746 @code{Cycle} parameter should not be implemented by calling the
15747 corresponding version with a @code{Cycle} parameter of
15748 @code{2.0*Numerics.Pi}, since this will not provide the required
15749 accuracy in some portions of the domain.”
15750 @end quotation
15752 Followed.
15754 @geindex Sequential elaboration policy
15756 @node RM H 6 15/2 Pragma Partition_Elaboration_Policy,,RM G 2 6 15 Complex Arithmetic Accuracy,Implementation Advice
15757 @anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{268}
15758 @section RM H.6(15/2): Pragma Partition_Elaboration_Policy
15761 @quotation
15763 “If the partition elaboration policy is @code{Sequential} and the
15764 Environment task becomes permanently blocked during elaboration then the
15765 partition is deadlocked and it is recommended that the partition be
15766 immediately terminated.”
15767 @end quotation
15769 Not followed.
15771 @node Implementation Defined Characteristics,Intrinsic Subprograms,Implementation Advice,Top
15772 @anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{269}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{26a}@anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b}
15773 @chapter Implementation Defined Characteristics
15776 In addition to the implementation dependent pragmas and attributes, and the
15777 implementation advice, there are a number of other Ada features that are
15778 potentially implementation dependent and are designated as
15779 implementation-defined. These are mentioned throughout the Ada Reference
15780 Manual, and are summarized in Annex M.
15782 A requirement for conforming Ada compilers is that they provide
15783 documentation describing how the implementation deals with each of these
15784 issues.  In this chapter you will find each point in Annex M listed,
15785 followed by a description of how GNAT handles the implementation dependence.
15787 You can use this chapter as a guide to minimizing implementation
15788 dependent features in your programs if portability to other compilers
15789 and other operating systems is an important consideration.  The numbers
15790 in each entry below correspond to the paragraph numbers in the Ada
15791 Reference Manual.
15794 @itemize *
15796 @item 
15797 “Whether or not each recommendation given in Implementation
15798 Advice is followed.  See 1.1.2(37).”
15799 @end itemize
15801 See @ref{a,,Implementation Advice}.
15804 @itemize *
15806 @item 
15807 “Capacity limitations of the implementation.  See 1.1.3(3).”
15808 @end itemize
15810 The complexity of programs that can be processed is limited only by the
15811 total amount of available virtual memory, and disk space for the
15812 generated object files.
15815 @itemize *
15817 @item 
15818 “Variations from the standard that are impractical to avoid
15819 given the implementation’s execution environment.  See 1.1.3(6).”
15820 @end itemize
15822 There are no variations from the standard.
15825 @itemize *
15827 @item 
15828 “Which code_statements cause external
15829 interactions.  See 1.1.3(10).”
15830 @end itemize
15832 Any `code_statement' can potentially cause external interactions.
15835 @itemize *
15837 @item 
15838 “The coded representation for the text of an Ada
15839 program.  See 2.1(4).”
15840 @end itemize
15842 See separate section on source representation.
15845 @itemize *
15847 @item 
15848 “The semantics of an Ada program whose text is not in
15849 Normalization Form C.  See 2.1(4).”
15850 @end itemize
15852 See separate section on source representation.
15855 @itemize *
15857 @item 
15858 “The representation for an end of line.  See 2.2(2).”
15859 @end itemize
15861 See separate section on source representation.
15864 @itemize *
15866 @item 
15867 “Maximum supported line length and lexical element
15868 length.  See 2.2(15).”
15869 @end itemize
15871 The maximum line length is 255 characters and the maximum length of
15872 a lexical element is also 255 characters. This is the default setting
15873 if not overridden by the use of compiler switch `-gnaty' (which
15874 sets the maximum to 79) or `-gnatyMnn' which allows the maximum
15875 line length to be specified to be any value up to 32767. The maximum
15876 length of a lexical element is the same as the maximum line length.
15879 @itemize *
15881 @item 
15882 “Implementation defined pragmas.  See 2.8(14).”
15883 @end itemize
15885 See @ref{7,,Implementation Defined Pragmas}.
15888 @itemize *
15890 @item 
15891 “Effect of pragma @code{Optimize}.  See 2.8(27).”
15892 @end itemize
15894 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
15895 parameter, checks that the optimization flag is set, and aborts if it is
15896 not.
15899 @itemize *
15901 @item 
15902 “The message string associated with the Assertion_Error exception raised
15903 by the failure of a predicate check if there is no applicable
15904 Predicate_Failure aspect.  See 3.2.4(31).”
15905 @end itemize
15907 In the case of a Dynamic_Predicate aspect, the string is
15908 “Dynamic_Predicate failed at <source position>”, where
15909 “<source position>” might be something like “foo.adb:123”.
15910 The Static_Predicate case is handled analogously.
15913 @itemize *
15915 @item 
15916 “The predefined integer types declared in
15917 @code{Standard}.  See 3.5.4(25).”
15918 @end itemize
15921 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
15922 @headitem
15924 Type
15926 @tab
15928 Representation
15930 @item
15932 `Short_Short_Integer'
15934 @tab
15936 8-bit signed
15938 @item
15940 `Short_Integer'
15942 @tab
15944 16-bit signed
15946 @item
15948 `Integer'
15950 @tab
15952 32-bit signed
15954 @item
15956 `Long_Integer'
15958 @tab
15960 64-bit signed (on most 64-bit targets,
15961 depending on the C definition of long)
15962 32-bit signed (on all other targets)
15964 @item
15966 `Long_Long_Integer'
15968 @tab
15970 64-bit signed
15972 @item
15974 `Long_Long_Long_Integer'
15976 @tab
15978 128-bit signed (on 64-bit targets)
15979 64-bit signed (on 32-bit targets)
15981 @end multitable
15985 @itemize *
15987 @item 
15988 “Any nonstandard integer types and the operators defined
15989 for them.  See 3.5.4(26).”
15990 @end itemize
15992 There are no nonstandard integer types.
15995 @itemize *
15997 @item 
15998 “Any nonstandard real types and the operators defined for
15999 them.  See 3.5.6(8).”
16000 @end itemize
16002 There are no nonstandard real types.
16005 @itemize *
16007 @item 
16008 “What combinations of requested decimal precision and range
16009 are supported for floating point types.  See 3.5.7(7).”
16010 @end itemize
16012 The precision and range are defined by the IEEE Standard for Floating-Point
16013 Arithmetic (IEEE 754-2019).
16016 @itemize *
16018 @item 
16019 “The predefined floating point types declared in
16020 @code{Standard}.  See 3.5.7(16).”
16021 @end itemize
16024 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
16025 @headitem
16027 Type
16029 @tab
16031 Representation
16033 @item
16035 `Short_Float'
16037 @tab
16039 IEEE Binary32 (Single)
16041 @item
16043 `Float'
16045 @tab
16047 IEEE Binary32 (Single)
16049 @item
16051 `Long_Float'
16053 @tab
16055 IEEE Binary64 (Double)
16057 @item
16059 `Long_Long_Float'
16061 @tab
16063 IEEE Binary64 (Double) on non-x86 architectures
16064 IEEE 80-bit Extended on x86 architecture
16066 @end multitable
16069 The default rounding mode specified by the IEEE 754 Standard is assumed both
16070 for static and dynamic computations (that is, round to nearest, ties to even).
16071 The input routines yield correctly rounded values for Short_Float, Float, and
16072 Long_Float at least. The output routines can compute up to twice as many exact
16073 digits as the value of @code{T'Digits} for any type, for example 30 digits for
16074 Long_Float; if more digits are requested, zeros are printed.
16077 @itemize *
16079 @item 
16080 “The small of an ordinary fixed point type.  See 3.5.9(8).”
16081 @end itemize
16083 The small is the largest power of two that does not exceed the delta.
16086 @itemize *
16088 @item 
16089 “What combinations of small, range, and digits are
16090 supported for fixed point types.  See 3.5.9(10).”
16091 @end itemize
16093 For an ordinary fixed point type, on 32-bit platforms, the small must lie in
16094 2.0**(-80) .. 2.0**80 and the range in -9.0E+36 .. 9.0E+36; any combination
16095 is permitted that does not result in a mantissa larger than 63 bits.
16097 On 64-bit platforms, the small must lie in 2.0**(-127) .. 2.0**127 and the
16098 range in -1.0E+76 .. 1.0E+76; any combination is permitted that does not
16099 result in a mantissa larger than 63 bits, and any combination is permitted
16100 that results in a mantissa between 64 and 127 bits if the small is the
16101 ratio of two integers that lie in 1 .. 2.0**127.
16103 If the small is the ratio of two integers with 64-bit magnitude on 32-bit
16104 platforms and 128-bit magnitude on 64-bit platforms, which is the case if
16105 no @code{small} clause is provided, then the operations of the fixed point
16106 type are entirely implemented by means of integer instructions.  In the
16107 other cases, some operations, in particular input and output, may be
16108 implemented by means of floating-point instructions and may be affected
16109 by accuracy issues on architectures other than x86.
16111 For a decimal fixed point type, on 32-bit platforms, the small must lie in
16112 1.0E-18 .. 1.0E+18 and the digits in 1 .. 18.  On 64-bit platforms, the
16113 small must lie in 1.0E-38 .. 1.0E+38 and the digits in 1 .. 38.
16116 @itemize *
16118 @item 
16119 “The result of @code{Tags.Expanded_Name} for types declared
16120 within an unnamed `block_statement'.  See 3.9(10).”
16121 @end itemize
16123 Block numbers of the form @code{B@var{nnn}}, where `nnn' is a
16124 decimal integer are allocated.
16127 @itemize *
16129 @item 
16130 “The sequence of characters of the value returned by Tags.Expanded_Name
16131 (respectively, Tags.Wide_Expanded_Name) when some of the graphic
16132 characters of Tags.Wide_Wide_Expanded_Name are not defined in Character
16133 (respectively, Wide_Character).  See 3.9(10.1).”
16134 @end itemize
16136 This is handled in the same way as the implementation-defined behavior
16137 referenced in A.4.12(34).
16140 @itemize *
16142 @item 
16143 “Implementation-defined attributes.  See 4.1.4(12).”
16144 @end itemize
16146 See @ref{8,,Implementation Defined Attributes}.
16149 @itemize *
16151 @item 
16152 “The value of the parameter to Empty for some container aggregates.
16153 See 4.3.5(40).”
16154 @end itemize
16156 As per the suggestion given in the Annotated Ada RM, the default value
16157 of the formal parameter is used if one exists and zero is used otherwise.
16160 @itemize *
16162 @item 
16163 “The maximum number of chunks for a parallel reduction expression without
16164 a chunk_specification.  See 4.5.10(21).”
16165 @end itemize
16167 Feature unimplemented.
16170 @itemize *
16172 @item 
16173 “Rounding of real static expressions which are exactly half-way between
16174 two machine numbers.  See 4.9(38).”
16175 @end itemize
16177 Round to even is used in all such cases.
16180 @itemize *
16182 @item 
16183 “The maximum number of chunks for a parallel generalized iterator without
16184 a chunk_specification.  See 5.5.2(10).”
16185 @end itemize
16187 Feature unimplemented.
16190 @itemize *
16192 @item 
16193 “The number of chunks for an array component iterator.  See 5.5.2(11).”
16194 @end itemize
16196 Feature unimplemented.
16199 @itemize *
16201 @item 
16202 “Any extensions of the Global aspect.  See 6.1.2(43).”
16203 @end itemize
16205 Feature unimplemented.
16208 @itemize *
16210 @item 
16211 “The circumstances the implementation passes in the null value for a view
16212 conversion of an access type used as an out parameter.  See 6.4.1(19).”
16213 @end itemize
16215 Difficult to characterize.
16218 @itemize *
16220 @item 
16221 “Any extensions of the Default_Initial_Condition aspect.  See 7.3.3(11).”
16222 @end itemize
16224 SPARK allows specifying `null' as the Default_Initial_Condition
16225 aspect of a type. See the SPARK reference manual for further details.
16228 @itemize *
16230 @item 
16231 “Any implementation-defined time types.  See 9.6(6).”
16232 @end itemize
16234 There are no implementation-defined time types.
16237 @itemize *
16239 @item 
16240 “The time base associated with relative delays.  See 9.6(20).”
16241 @end itemize
16243 See 9.6(20).  The time base used is that provided by the C library
16244 function @code{gettimeofday}.
16247 @itemize *
16249 @item 
16250 “The time base of the type @code{Calendar.Time}.  See 9.6(23).”
16251 @end itemize
16253 The time base used is that provided by the C library function
16254 @code{gettimeofday}.
16257 @itemize *
16259 @item 
16260 “The time zone used for package @code{Calendar}
16261 operations.  See 9.6(24).”
16262 @end itemize
16264 The time zone used by package @code{Calendar} is the current system time zone
16265 setting for local time, as accessed by the C library function
16266 @code{localtime}.
16269 @itemize *
16271 @item 
16272 “Any limit on `delay_until_statements' of
16273 `select_statements'.  See 9.6(29).”
16274 @end itemize
16276 There are no such limits.
16279 @itemize *
16281 @item 
16282 “The result of Calendar.Formatting.Image if its argument represents more
16283 than 100 hours.  See 9.6.1(86).”
16284 @end itemize
16286 Calendar.Time_Error is raised.
16289 @itemize *
16291 @item 
16292 “Implementation-defined conflict check policies.  See 9.10.1(5).”
16293 @end itemize
16295 There are no implementation-defined conflict check policies.
16298 @itemize *
16300 @item 
16301 “The representation for a compilation.  See 10.1(2).”
16302 @end itemize
16304 A compilation is represented by a sequence of files presented to the
16305 compiler in a single invocation of the `gcc' command.
16308 @itemize *
16310 @item 
16311 “Any restrictions on compilations that contain multiple
16312 compilation_units.  See 10.1(4).”
16313 @end itemize
16315 No single file can contain more than one compilation unit, but any
16316 sequence of files can be presented to the compiler as a single
16317 compilation.
16320 @itemize *
16322 @item 
16323 “The mechanisms for creating an environment and for adding
16324 and replacing compilation units.  See 10.1.4(3).”
16325 @end itemize
16327 See separate section on compilation model.
16330 @itemize *
16332 @item 
16333 “The manner of explicitly assigning library units to a
16334 partition.  See 10.2(2).”
16335 @end itemize
16337 If a unit contains an Ada main program, then the Ada units for the partition
16338 are determined by recursive application of the rules in the Ada Reference
16339 Manual section 10.2(2-6).  In other words, the Ada units will be those that
16340 are needed by the main program, and then this definition of need is applied
16341 recursively to those units, and the partition contains the transitive
16342 closure determined by this relationship.  In short, all the necessary units
16343 are included, with no need to explicitly specify the list.  If additional
16344 units are required, e.g., by foreign language units, then all units must be
16345 mentioned in the context clause of one of the needed Ada units.
16347 If the partition contains no main program, or if the main program is in
16348 a language other than Ada, then GNAT
16349 provides the binder options `-z' and `-n' respectively, and in
16350 this case a list of units can be explicitly supplied to the binder for
16351 inclusion in the partition (all units needed by these units will also
16352 be included automatically).  For full details on the use of these
16353 options, refer to `GNAT Make Program gnatmake' in the
16354 @cite{GNAT User’s Guide}.
16357 @itemize *
16359 @item 
16360 “The implementation-defined means, if any, of specifying which compilation
16361 units are needed by a given compilation unit.  See 10.2(2).”
16362 @end itemize
16364 The units needed by a given compilation unit are as defined in
16365 the Ada Reference Manual section 10.2(2-6).  There are no
16366 implementation-defined pragmas or other implementation-defined
16367 means for specifying needed units.
16370 @itemize *
16372 @item 
16373 “The manner of designating the main subprogram of a
16374 partition.  See 10.2(7).”
16375 @end itemize
16377 The main program is designated by providing the name of the
16378 corresponding @code{ALI} file as the input parameter to the binder.
16381 @itemize *
16383 @item 
16384 “The order of elaboration of `library_items'.  See 10.2(18).”
16385 @end itemize
16387 The first constraint on ordering is that it meets the requirements of
16388 Chapter 10 of the Ada Reference Manual.  This still leaves some
16389 implementation-dependent choices, which are resolved by analyzing
16390 the elaboration code of each unit and identifying implicit
16391 elaboration-order dependencies.
16394 @itemize *
16396 @item 
16397 “Parameter passing and function return for the main
16398 subprogram.  See 10.2(21).”
16399 @end itemize
16401 The main program has no parameters.  It may be a procedure, or a function
16402 returning an integer type.  In the latter case, the returned integer
16403 value is the return code of the program (overriding any value that
16404 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
16407 @itemize *
16409 @item 
16410 “The mechanisms for building and running partitions.  See 10.2(24).”
16411 @end itemize
16413 GNAT itself supports programs with only a single partition. The GNATDIST
16414 tool provided with the GLADE package (which also includes an implementation
16415 of the PCS) provides a completely flexible method for building and running
16416 programs consisting of multiple partitions. See the separate GLADE manual
16417 for details.
16420 @itemize *
16422 @item 
16423 “The details of program execution, including program
16424 termination.  See 10.2(25).”
16425 @end itemize
16427 See separate section on compilation model.
16430 @itemize *
16432 @item 
16433 “The semantics of any non-active partitions supported by the
16434 implementation.  See 10.2(28).”
16435 @end itemize
16437 Passive partitions are supported on targets where shared memory is
16438 provided by the operating system. See the GLADE reference manual for
16439 further details.
16442 @itemize *
16444 @item 
16445 “The information returned by @code{Exception_Message}.  See 11.4.1(10).”
16446 @end itemize
16448 Exception message returns the null string unless a specific message has
16449 been passed by the program.
16452 @itemize *
16454 @item 
16455 “The result of @code{Exceptions.Exception_Name} for types
16456 declared within an unnamed `block_statement'.  See 11.4.1(12).”
16457 @end itemize
16459 Blocks have implementation defined names of the form @code{B@var{nnn}}
16460 where `nnn' is an integer.
16463 @itemize *
16465 @item 
16466 “The information returned by
16467 @code{Exception_Information}.  See 11.4.1(13).”
16468 @end itemize
16470 @code{Exception_Information} returns a string in the following format:
16472 @example
16473 *Exception_Name:* nnnnn
16474 *Message:* mmmmm
16475 *PID:* ppp
16476 *Load address:* 0xhhhh
16477 *Call stack traceback locations:*
16478 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
16479 @end example
16481 where
16483 @quotation
16486 @itemize *
16488 @item 
16489 @code{nnnn} is the fully qualified name of the exception in all upper
16490 case letters. This line is always present.
16492 @item 
16493 @code{mmmm} is the message (this line present only if message is non-null)
16495 @item 
16496 @code{ppp} is the Process Id value as a decimal integer (this line is
16497 present only if the Process Id is nonzero). Currently we are
16498 not making use of this field.
16500 @item 
16501 The Load address line, the Call stack traceback locations line and the
16502 following values are present only if at least one traceback location was
16503 recorded. The Load address indicates the address at which the main executable
16504 was loaded; this line may not be present if operating system hasn’t relocated
16505 the main executable. The values are given in C style format, with lower case
16506 letters for a-f, and only as many digits present as are necessary.
16507 The line terminator sequence at the end of each line, including
16508 the last line is a single @code{LF} character (@code{16#0A#}).
16509 @end itemize
16510 @end quotation
16513 @itemize *
16515 @item 
16516 “The sequence of characters of the value returned by
16517 Exceptions.Exception_Name (respectively, Exceptions.Wide_Exception_Name)
16518 when some of the graphic characters of Exceptions.Wide_Wide_Exception_Name
16519 are not defined in Character (respectively, Wide_Character).
16520 See 11.4.1(12.1).”
16521 @end itemize
16523 This is handled in the same way as the implementation-defined behavior
16524 referenced in A.4.12(34).
16527 @itemize *
16529 @item 
16530 “The information returned by Exception_Information.  See 11.4.1(13).”
16531 @end itemize
16533 The exception name and the source location at which the exception was
16534 raised are included.
16537 @itemize *
16539 @item 
16540 “Implementation-defined policy_identifiers and assertion_aspect_marks
16541 allowed in a pragma Assertion_Policy.  See 11.4.2(9).”
16542 @end itemize
16544 Implementation-defined assertion_aspect_marks include Assert_And_Cut,
16545 Assume, Contract_Cases, Debug, Ghost, Initial_Condition, Loop_Invariant,
16546 Loop_Variant, Postcondition, Precondition, Predicate, Refined_Post,
16547 Statement_Assertions, and Subprogram_Variant. Implementation-defined
16548 policy_identifiers include Ignore and Suppressible.
16551 @itemize *
16553 @item 
16554 “The default assertion policy.  See 11.4.2(10).”
16555 @end itemize
16557 The default assertion policy is Ignore, although this can be overridden
16558 via compiler switches such as “-gnata”.
16561 @itemize *
16563 @item 
16564 “Implementation-defined check names.  See 11.5(27).”
16565 @end itemize
16567 The implementation defined check names include Alignment_Check,
16568 Atomic_Synchronization, Duplicated_Tag_Check, Container_Checks,
16569 Tampering_Check, Predicate_Check, and Validity_Check. In addition, a user
16570 program can add implementation-defined check names by means of the pragma
16571 Check_Name. See the description of pragma @code{Suppress} for full details.
16574 @itemize *
16576 @item 
16577 “Existence and meaning of second parameter of pragma Unsuppress.
16578 See 11.5(27.1).”
16579 @end itemize
16581 The legality rules for and semantics of the second parameter of pragma
16582 Unsuppress match those for the second argument of pragma Suppress.
16585 @itemize *
16587 @item 
16588 “The cases that cause conflicts between the representation of the
16589 ancestors of a type_declaration.  See 13.1(13.1).”
16590 @end itemize
16592 No such cases exist.
16595 @itemize *
16597 @item 
16598 “The interpretation of each representation aspect.  See 13.1(20).”
16599 @end itemize
16601 See separate section on data representations.
16604 @itemize *
16606 @item 
16607 “Any restrictions placed upon the specification of representation aspects.
16608 See 13.1(20).”
16609 @end itemize
16611 See separate section on data representations.
16614 @itemize *
16616 @item 
16617 “Implementation-defined aspects, including the syntax for specifying
16618 such aspects and the legality rules for such aspects.  See 13.1.1(38).”
16619 @end itemize
16621 See @ref{128,,Implementation Defined Aspects}.
16624 @itemize *
16626 @item 
16627 “The set of machine scalars.  See 13.3(8.1).”
16628 @end itemize
16630 See separate section on data representations.
16633 @itemize *
16635 @item 
16636 “The meaning of @code{Size} for indefinite subtypes.  See 13.3(48).”
16637 @end itemize
16639 The Size attribute of an indefinite subtype is not less than the Size
16640 attribute of any object of that type.
16643 @itemize *
16645 @item 
16646 “The meaning of Object_Size for indefinite subtypes.  See 13.3(58).”
16647 @end itemize
16649 The Object_Size attribute of an indefinite subtype is not less than the
16650 Object_Size attribute of any object of that type.
16653 @itemize *
16655 @item 
16656 “The default external representation for a type tag.  See 13.3(75).”
16657 @end itemize
16659 The default external representation for a type tag is the fully expanded
16660 name of the type in upper case letters.
16663 @itemize *
16665 @item 
16666 “What determines whether a compilation unit is the same in
16667 two different partitions.  See 13.3(76).”
16668 @end itemize
16670 A compilation unit is the same in two different partitions if and only
16671 if it derives from the same source file.
16674 @itemize *
16676 @item 
16677 “Implementation-defined components.  See 13.5.1(15).”
16678 @end itemize
16680 The only implementation defined component is the tag for a tagged type,
16681 which contains a pointer to the dispatching table.
16684 @itemize *
16686 @item 
16687 “If @code{Word_Size} = @code{Storage_Unit}, the default bit
16688 ordering.  See 13.5.3(5).”
16689 @end itemize
16691 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
16692 implementation, so no non-default bit ordering is supported.  The default
16693 bit ordering corresponds to the natural endianness of the target architecture.
16696 @itemize *
16698 @item 
16699 “The contents of the visible part of package @code{System}.  See 13.7(2).”
16700 @end itemize
16702 See the definition of package System in @code{system.ads}.
16703 Note that two declarations are added to package System.
16705 @example
16706 Max_Priority           : constant Positive := Priority'Last;
16707 Max_Interrupt_Priority : constant Positive := Interrupt_Priority'Last;
16708 @end example
16711 @itemize *
16713 @item 
16714 “The range of Storage_Elements.Storage_Offset, the modulus of
16715 Storage_Elements.Storage_Element, and the declaration of
16716 Storage_Elements.Integer_Address.  See 13.7.1(11).”
16717 @end itemize
16719 See the definition of package System.Storage_Elements in @code{s-stoele.ads}.
16722 @itemize *
16724 @item 
16725 “The contents of the visible part of package @code{System.Machine_Code},
16726 and the meaning of `code_statements'.  See 13.8(7).”
16727 @end itemize
16729 See the definition and documentation in file @code{s-maccod.ads}.
16732 @itemize *
16734 @item 
16735 “The result of unchecked conversion for instances with scalar result
16736 types whose result is not defined by the language.  See 13.9(11).”
16737 @end itemize
16739 Unchecked conversion between types of the same size
16740 results in an uninterpreted transmission of the bits from one type
16741 to the other.  If the types are of unequal sizes, then in the case of
16742 discrete types, a shorter source is first zero or sign extended as
16743 necessary, and a shorter target is simply truncated on the left.
16744 For all non-discrete types, the source is first copied if necessary
16745 to ensure that the alignment requirements of the target are met, then
16746 a pointer is constructed to the source value, and the result is obtained
16747 by dereferencing this pointer after converting it to be a pointer to the
16748 target type. Unchecked conversions where the target subtype is an
16749 unconstrained array are not permitted. If the target alignment is
16750 greater than the source alignment, then a copy of the result is
16751 made with appropriate alignment
16754 @itemize *
16756 @item 
16757 “The result of unchecked conversion for instances with nonscalar result
16758 types whose result is not defined by the language.  See 13.9(11).”
16759 @end itemize
16761 See preceding definition for the scalar result case.
16764 @itemize *
16766 @item 
16767 “Whether or not the implementation provides user-accessible
16768 names for the standard pool type(s).  See 13.11(17).”
16769 @end itemize
16771 There are 3 different standard pools used by the compiler when
16772 @code{Storage_Pool} is not specified depending whether the type is local
16773 to a subprogram or defined at the library level and whether
16774 @code{Storage_Size`@w{`}is specified or not. See documentation in the runtime
16775 library units `@w{`}System.Pool_Global}, @code{System.Pool_Size} and
16776 @code{System.Pool_Local} in files @code{s-poosiz.ads},
16777 @code{s-pooglo.ads} and @code{s-pooloc.ads} for full details on the
16778 default pools used.  All these pools are accessible by means of @cite{with}ing
16779 these units.
16782 @itemize *
16784 @item 
16785 “The meaning of @code{Storage_Size} when neither the Storage_Size nor the
16786 Storage_Pool is specified for an access type.  See 13.11(18).”
16787 @end itemize
16789 @code{Storage_Size} is measured in storage units, and refers to the
16790 total space available for an access type collection, or to the primary
16791 stack space for a task.
16794 @itemize *
16796 @item 
16797 “The effect of specifying aspect Default_Storage_Pool on an instance
16798 of a language-defined generic unit.  See 13.11.3(5).”
16799 @end itemize
16801 Instances of language-defined generic units are treated the same as other
16802 instances with respect to the Default_Storage_Pool aspect.
16805 @itemize *
16807 @item 
16808 “Implementation-defined restrictions allowed in a pragma
16809 @code{Restrictions}.  See 13.12(8.7).”
16810 @end itemize
16812 See @ref{9,,Standard and Implementation Defined Restrictions}.
16815 @itemize *
16817 @item 
16818 “The consequences of violating limitations on
16819 @code{Restrictions} pragmas.  See 13.12(9).”
16820 @end itemize
16822 Restrictions that can be checked at compile time are enforced at
16823 compile time; violations are illegal. For other restrictions, any
16824 violation during program execution results in erroneous execution.
16827 @itemize *
16829 @item 
16830 “Implementation-defined usage profiles allowed in a pragma Profile.
16831 See 13.12(15).”
16832 @end itemize
16834 See @ref{7,,Implementation Defined Pragmas}.
16837 @itemize *
16839 @item 
16840 “The contents of the stream elements read and written by the Read and
16841 Write attributes of elementary types.  See 13.13.2(9).”
16842 @end itemize
16844 The representation is the in-memory representation of the base type of
16845 the type, using the number of bits corresponding to the
16846 @code{type'Size} value, and the natural ordering of the machine.
16849 @itemize *
16851 @item 
16852 “The names and characteristics of the numeric subtypes
16853 declared in the visible part of package @code{Standard}.  See A.1(3).”
16854 @end itemize
16856 See items describing the integer and floating-point types supported.
16859 @itemize *
16861 @item 
16862 “The values returned by Strings.Hash.  See A.4.9(3).”
16863 @end itemize
16865 This hash function has predictable collisions and is subject to
16866 equivalent substring attacks. It is not suitable for construction of a
16867 hash table keyed on possibly malicious user input.
16870 @itemize *
16872 @item 
16873 “The value returned by a call to a Text_Buffer Get procedure if any
16874 character in the returned sequence is not defined in Character.
16875 See A.4.12(34).”
16876 @end itemize
16878 The contents of a buffer is represented internally as a UTF_8 string.
16879 The value return by Text_Buffer.Get is the result of passing that
16880 UTF_8 string to UTF_Encoding.Strings.Decode.
16883 @itemize *
16885 @item 
16886 “The value returned by a call to a Text_Buffer Wide_Get procedure if
16887 any character in the returned sequence is not defined in Wide_Character.
16888 See A.4.12(34).”
16889 @end itemize
16891 The contents of a buffer is represented internally as a UTF_8 string.
16892 The value return by Text_Buffer.Wide_Get is the result of passing that
16893 UTF_8 string to UTF_Encoding.Wide_Strings.Decode.
16896 @itemize *
16898 @item 
16899 “The accuracy actually achieved by the elementary
16900 functions.  See A.5.1(1).”
16901 @end itemize
16903 The elementary functions correspond to the functions available in the C
16904 library.  Only fast math mode is implemented.
16907 @itemize *
16909 @item 
16910 “The sign of a zero result from some of the operators or
16911 functions in @code{Numerics.Generic_Elementary_Functions}, when
16912 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).”
16913 @end itemize
16915 The sign of zeroes follows the requirements of the IEEE 754 standard on
16916 floating-point.
16919 @itemize *
16921 @item 
16922 “The value of
16923 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).”
16924 @end itemize
16926 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16929 @itemize *
16931 @item 
16932 “The value of
16933 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).”
16934 @end itemize
16936 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16939 @itemize *
16941 @item 
16942 “The string representation of a random number generator’s
16943 state.  See A.5.2(38).”
16944 @end itemize
16946 The value returned by the Image function is the concatenation of
16947 the fixed-width decimal representations of the 624 32-bit integers
16948 of the state vector.
16951 @itemize *
16953 @item 
16954 “The values of the @code{Model_Mantissa},
16955 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
16956 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
16957 Annex is not supported.  See A.5.3(72).”
16958 @end itemize
16960 Running the compiler with `-gnatS' to produce a listing of package
16961 @code{Standard} displays the values of these attributes.
16964 @itemize *
16966 @item 
16967 “The value of @code{Buffer_Size} in @code{Storage_IO}.  See A.9(10).”
16968 @end itemize
16970 All type representations are contiguous, and the @code{Buffer_Size} is
16971 the value of @code{type'Size} rounded up to the next storage unit
16972 boundary.
16975 @itemize *
16977 @item 
16978 “External files for standard input, standard output, and
16979 standard error See A.10(5).”
16980 @end itemize
16982 These files are mapped onto the files provided by the C streams
16983 libraries. See source file @code{i-cstrea.ads} for further details.
16986 @itemize *
16988 @item 
16989 “The accuracy of the value produced by @code{Put}.  See A.10.9(36).”
16990 @end itemize
16992 If more digits are requested in the output than are represented by the
16993 precision of the value, zeroes are output in the corresponding least
16994 significant digit positions.
16997 @itemize *
16999 @item 
17000 “Current size for a stream file for which positioning is not supported.
17001 See A.12.1(1.1).”
17002 @end itemize
17004 Positioning is supported.
17007 @itemize *
17009 @item 
17010 “The meaning of @code{Argument_Count}, @code{Argument}, and
17011 @code{Command_Name}.  See A.15(1).”
17012 @end itemize
17014 These are mapped onto the @code{argv} and @code{argc} parameters of the
17015 main program in the natural manner.
17018 @itemize *
17020 @item 
17021 “The interpretation of file names and directory names.  See A.16(46).”
17022 @end itemize
17024 These names are interpreted consistently with the underlying file system.
17027 @itemize *
17029 @item 
17030 “The maxium value for a file size in Directories.  See A.16(87).”
17031 @end itemize
17033 Directories.File_Size’Last is equal to Long_Long_Integer’Last .
17036 @itemize *
17038 @item 
17039 “The result for Directories.Size for a directory or special file.
17040 See A.16(93).”
17041 @end itemize
17043 Name_Error is raised.
17046 @itemize *
17048 @item 
17049 “The result for Directories.Modification_Time for a directory or special file.
17050 See A.16(93).”
17051 @end itemize
17053 Name_Error is raised.
17056 @itemize *
17058 @item 
17059 “The interpretation of a nonnull search pattern in Directories.
17060 See A.16(104).”
17061 @end itemize
17063 When the @code{Pattern} parameter is not the null string, it is interpreted
17064 according to the syntax of regular expressions as defined in the
17065 @code{GNAT.Regexp} package.
17067 See @ref{26b,,GNAT.Regexp (g-regexp.ads)}.
17070 @itemize *
17072 @item 
17073 “The results of a Directories search if the contents of the directory are
17074 altered while a search is in progress.  See A.16(110).”
17075 @end itemize
17077 The effect of a call to Get_Next_Entry is determined by the current
17078 state of the directory.
17081 @itemize *
17083 @item 
17084 “The definition and meaning of an environment variable.  See A.17(1).”
17085 @end itemize
17087 This definition is determined by the underlying operating system.
17090 @itemize *
17092 @item 
17093 “The circumstances where an environment variable cannot be defined.
17094 See A.17(16).”
17095 @end itemize
17097 There are no such implementation-defined circumstances.
17100 @itemize *
17102 @item 
17103 “Environment names for which Set has the effect of Clear.  See A.17(17).”
17104 @end itemize
17106 There are no such names.
17109 @itemize *
17111 @item 
17112 “The value of Containers.Hash_Type’Modulus. The value of
17113 Containers.Count_Type’Last.  See A.18.1(7).”
17114 @end itemize
17116 Containers.Hash_Type’Modulus is 2**32.
17117 Containers.Count_Type’Last is 2**31 - 1.
17120 @itemize *
17122 @item 
17123 “Implementation-defined convention names.  See B.1(11).”
17124 @end itemize
17126 The following convention names are supported
17129 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
17130 @headitem
17132 Convention Name
17134 @tab
17136 Interpretation
17138 @item
17140 `Ada'
17142 @tab
17146 @item
17148 `Ada_Pass_By_Copy'
17150 @tab
17152 Allowed for any types except by-reference types such as limited
17153 records. Compatible with convention Ada, but causes any parameters
17154 with this convention to be passed by copy.
17156 @item
17158 `Ada_Pass_By_Reference'
17160 @tab
17162 Allowed for any types except by-copy types such as scalars.
17163 Compatible with convention Ada, but causes any parameters
17164 with this convention to be passed by reference.
17166 @item
17168 `Assembler'
17170 @tab
17172 Assembly language
17174 @item
17176 `Asm'
17178 @tab
17180 Synonym for Assembler
17182 @item
17184 `Assembly'
17186 @tab
17188 Synonym for Assembler
17190 @item
17194 @tab
17198 @item
17200 `C_Pass_By_Copy'
17202 @tab
17204 Allowed only for record types, like C, but also notes that record
17205 is to be passed by copy rather than reference.
17207 @item
17209 `COBOL'
17211 @tab
17213 COBOL
17215 @item
17217 `C_Plus_Plus (or CPP)'
17219 @tab
17223 @item
17225 `Default'
17227 @tab
17229 Treated the same as C
17231 @item
17233 `External'
17235 @tab
17237 Treated the same as C
17239 @item
17241 `Fortran'
17243 @tab
17245 Fortran
17247 @item
17249 `Intrinsic'
17251 @tab
17253 For support of pragma @code{Import} with convention Intrinsic, see
17254 separate section on Intrinsic Subprograms.
17256 @item
17258 `Stdcall'
17260 @tab
17262 Stdcall (used for Windows implementations only).  This convention correspond
17263 to the WINAPI (previously called Pascal convention) C/C++ convention under
17264 Windows.  A routine with this convention cleans the stack before
17265 exit. This pragma cannot be applied to a dispatching call.
17267 @item
17269 `DLL'
17271 @tab
17273 Synonym for Stdcall
17275 @item
17277 `Win32'
17279 @tab
17281 Synonym for Stdcall
17283 @item
17285 `Stubbed'
17287 @tab
17289 Stubbed is a special convention used to indicate that the body of the
17290 subprogram will be entirely ignored.  Any call to the subprogram
17291 is converted into a raise of the @code{Program_Error} exception.  If a
17292 pragma @code{Import} specifies convention @code{stubbed} then no body need
17293 be present at all.  This convention is useful during development for the
17294 inclusion of subprograms whose body has not yet been written.
17295 In addition, all otherwise unrecognized convention names are also
17296 treated as being synonymous with convention C.  In all implementations,
17297 use of such other names results in a warning.
17299 @end multitable
17303 @itemize *
17305 @item 
17306 “The meaning of link names.  See B.1(36).”
17307 @end itemize
17309 Link names are the actual names used by the linker.
17312 @itemize *
17314 @item 
17315 “The manner of choosing link names when neither the link name nor the
17316 address of an imported or exported entity is specified.  See B.1(36).”
17317 @end itemize
17319 The default linker name is that which would be assigned by the relevant
17320 external language, interpreting the Ada name as being in all lower case
17321 letters.
17324 @itemize *
17326 @item 
17327 “The effect of pragma @code{Linker_Options}.  See B.1(37).”
17328 @end itemize
17330 The string passed to @code{Linker_Options} is presented uninterpreted as
17331 an argument to the link command, unless it contains ASCII.NUL characters.
17332 NUL characters if they appear act as argument separators, so for example
17334 @example
17335 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
17336 @end example
17338 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
17339 linker. The order of linker options is preserved for a given unit. The final
17340 list of options passed to the linker is in reverse order of the elaboration
17341 order. For example, linker options for a body always appear before the options
17342 from the corresponding package spec.
17345 @itemize *
17347 @item 
17348 “The contents of the visible part of package
17349 @code{Interfaces} and its language-defined descendants.  See B.2(1).”
17350 @end itemize
17352 See files with prefix @code{i-} in the distributed library.
17355 @itemize *
17357 @item 
17358 “Implementation-defined children of package
17359 @code{Interfaces}.  The contents of the visible part of package
17360 @code{Interfaces}.  See B.2(11).”
17361 @end itemize
17363 See files with prefix @code{i-} in the distributed library.
17366 @itemize *
17368 @item 
17369 “The definitions of certain types and constants in Interfaces.C.
17370 See B.3(41).”
17371 @end itemize
17373 See source file @code{i-c.ads}.
17376 @itemize *
17378 @item 
17379 “The types @code{Floating}, @code{Long_Floating},
17380 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
17381 @code{COBOL_Character}; and the initialization of the variables
17382 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
17383 @code{Interfaces.COBOL}.  See B.4(50).”
17384 @end itemize
17387 @multitable {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
17388 @headitem
17390 COBOL
17392 @tab
17396 @item
17398 `Floating'
17400 @tab
17402 Float
17404 @item
17406 `Long_Floating'
17408 @tab
17410 (Floating) Long_Float
17412 @item
17414 `Binary'
17416 @tab
17418 Integer
17420 @item
17422 `Long_Binary'
17424 @tab
17426 Long_Long_Integer
17428 @item
17430 `Decimal_Element'
17432 @tab
17434 Character
17436 @item
17438 `COBOL_Character'
17440 @tab
17442 Character
17444 @end multitable
17447 For initialization, see the file @code{i-cobol.ads} in the distributed library.
17450 @itemize *
17452 @item 
17453 “The types Fortran_Integer, Real, Double_Precision, and Character_Set
17454 in Interfaces.Fortran.  See B.5(17).”
17455 @end itemize
17457 See source file @code{i-fortra.ads}. These types are derived, respectively,
17458 from Integer, Float, Long_Float, and Character.
17461 @itemize *
17463 @item 
17464 “Implementation-defined intrinsic subprograms.  See C.1(1).”
17465 @end itemize
17467 See separate section on Intrinsic Subprograms.
17470 @itemize *
17472 @item 
17473 “Any restrictions on a protected procedure or its containing type when an
17474 aspect Attach_handler or Interrupt_Handler is specified.  See C.3.1(17).”
17475 @end itemize
17477 There are no such restrictions.
17480 @itemize *
17482 @item 
17483 “Any other forms of interrupt handler supported by the Attach_Handler and
17484 Interrupt_Handler aspects.  See C.3.1(19).”
17485 @end itemize
17487 There are no such forms.
17490 @itemize *
17492 @item 
17493 “The semantics of some attributes and functions of an entity for which
17494 aspect Discard_Names is True.  See C.5(7).”
17495 @end itemize
17497 If Discard_Names is True for an enumeration type, the Image attribute
17498 provides the image of the Pos of the literal, and Value accepts
17499 Pos values.
17501 If both of the aspects`@w{`}Discard_Names`@w{`} and @code{No_Tagged_Streams} are true
17502 for a tagged type, its Expanded_Name and External_Tag values are
17503 empty strings. This is useful to avoid exposing entity names at binary
17504 level.
17507 @itemize *
17509 @item 
17510 “The modulus and size of Test_and_Set_Flag.  See C.6.3(8).”
17511 @end itemize
17513 The modulus is 2**8. The size is 8.
17516 @itemize *
17518 @item 
17519 “The value used to represent the set value for Atomic_Test_and_Set.
17520 See C.6.3(10).”
17521 @end itemize
17523 The value is 1.
17526 @itemize *
17528 @item 
17529 “The result of the @code{Task_Identification.Image}
17530 attribute.  See C.7.1(7).”
17531 @end itemize
17533 The result of this attribute is a string that identifies
17534 the object or component that denotes a given task. If a variable @code{Var}
17535 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
17536 where the suffix `XXXXXXXX'
17537 is the hexadecimal representation of the virtual address of the corresponding
17538 task control block. If the variable is an array of tasks, the image of each
17539 task will have the form of an indexed component indicating the position of a
17540 given task in the array, e.g., @code{Group(5)_@var{XXXXXXX}}. If the task is a
17541 component of a record, the image of the task will have the form of a selected
17542 component. These rules are fully recursive, so that the image of a task that
17543 is a subcomponent of a composite object corresponds to the expression that
17544 designates this task.
17546 If a task is created by an allocator, its image depends on the context. If the
17547 allocator is part of an object declaration, the rules described above are used
17548 to construct its image, and this image is not affected by subsequent
17549 assignments. If the allocator appears within an expression, the image
17550 includes only the name of the task type.
17552 If the configuration pragma Discard_Names is present, or if the restriction
17553 No_Implicit_Heap_Allocation is in effect,  the image reduces to
17554 the numeric suffix, that is to say the hexadecimal representation of the
17555 virtual address of the control block of the task.
17558 @itemize *
17560 @item 
17561 “The value of @code{Current_Task} when in a protected entry
17562 or interrupt handler.  See C.7.1(17).”
17563 @end itemize
17565 Protected entries or interrupt handlers can be executed by any
17566 convenient thread, so the value of @code{Current_Task} is undefined.
17569 @itemize *
17571 @item 
17572 “Granularity of locking for Task_Attributes.  See C.7.2(16).”
17573 @end itemize
17575 No locking is needed if the formal type Attribute has the size and
17576 alignment of either Integer or System.Address and the bit representation
17577 of Initial_Value is all zeroes. Otherwise, locking is performed.
17580 @itemize *
17582 @item 
17583 “The declarations of @code{Any_Priority} and
17584 @code{Priority}.  See D.1(11).”
17585 @end itemize
17587 See declarations in file @code{system.ads}.
17590 @itemize *
17592 @item 
17593 “Implementation-defined execution resources.  See D.1(15).”
17594 @end itemize
17596 There are no implementation-defined execution resources.
17599 @itemize *
17601 @item 
17602 “Whether, on a multiprocessor, a task that is waiting for
17603 access to a protected object keeps its processor busy.  See D.2.1(3).”
17604 @end itemize
17606 On a multi-processor, a task that is waiting for access to a protected
17607 object does not keep its processor busy.
17610 @itemize *
17612 @item 
17613 “The affect of implementation defined execution resources
17614 on task dispatching.  See D.2.1(9).”
17615 @end itemize
17617 Tasks map to threads in the threads package used by GNAT.  Where possible
17618 and appropriate, these threads correspond to native threads of the
17619 underlying operating system.
17622 @itemize *
17624 @item 
17625 “Implementation-defined task dispatching policies.  See D.2.2(3).”
17626 @end itemize
17628 There are no implementation-defined task dispatching policies.
17631 @itemize *
17633 @item 
17634 “The value of Default_Quantum in Dispatching.Round_Robin.  See D.2.5(4).”
17635 @end itemize
17637 The value is 10 milliseconds.
17640 @itemize *
17642 @item 
17643 “Implementation-defined `policy_identifiers' allowed
17644 in a pragma @code{Locking_Policy}.  See D.3(4).”
17645 @end itemize
17647 The two implementation defined policies permitted in GNAT are
17648 @code{Inheritance_Locking} and  @code{Concurrent_Readers_Locking}. On
17649 targets that support the @code{Inheritance_Locking} policy, locking is
17650 implemented by inheritance, i.e., the task owning the lock operates
17651 at a priority equal to the highest priority of any task currently
17652 requesting the lock. On targets that support the
17653 @code{Concurrent_Readers_Locking} policy, locking is implemented with a
17654 read/write lock allowing multiple protected object functions to enter
17655 concurrently.
17658 @itemize *
17660 @item 
17661 “Default ceiling priorities.  See D.3(10).”
17662 @end itemize
17664 The ceiling priority of protected objects of the type
17665 @code{System.Interrupt_Priority'Last} as described in the Ada
17666 Reference Manual D.3(10),
17669 @itemize *
17671 @item 
17672 “The ceiling of any protected object used internally by
17673 the implementation.  See D.3(16).”
17674 @end itemize
17676 The ceiling priority of internal protected objects is
17677 @code{System.Priority'Last}.
17680 @itemize *
17682 @item 
17683 “Implementation-defined queuing policies.  See D.4(1).”
17684 @end itemize
17686 There are no implementation-defined queuing policies.
17689 @itemize *
17691 @item 
17692 “Implementation-defined admission policies.  See D.4.1(1).”
17693 @end itemize
17695 There are no implementation-defined admission policies.
17698 @itemize *
17700 @item 
17701 “Any operations that implicitly require heap storage
17702 allocation.  See D.7(8).”
17703 @end itemize
17705 The only operation that implicitly requires heap storage allocation is
17706 task creation.
17709 @itemize *
17711 @item 
17712 “When restriction No_Dynamic_CPU_Assignment applies to a partition, the
17713 processor on which a task with a CPU value of a Not_A_Specific_CPU will
17714 execute.  See D.7(10).”
17715 @end itemize
17717 Unknown.
17720 @itemize *
17722 @item 
17723 “When restriction No_Task_Termination applies to a partition, what happens
17724 when a task terminates.  See D.7(15.1).”
17725 @end itemize
17727 Execution is erroneous in that case.
17730 @itemize *
17732 @item 
17733 “The behavior when restriction Max_Storage_At_Blocking is violated.
17734 See D.7(17).”
17735 @end itemize
17737 Execution is erroneous in that case.
17740 @itemize *
17742 @item 
17743 “The behavior when restriction Max_Asynchronous_Select_Nesting is violated.
17744 See D.7(18).”
17745 @end itemize
17747 Execution is erroneous in that case.
17750 @itemize *
17752 @item 
17753 “The behavior when restriction Max_Tasks is violated.  See D.7(19).”
17754 @end itemize
17756 Execution is erroneous in that case.
17759 @itemize *
17761 @item 
17762 “Whether the use of pragma Restrictions results in a reduction in program
17763 code or data size or execution time.  See D.7(20).”
17764 @end itemize
17766 Yes it can, but the precise circumstances and properties of such reductions
17767 are difficult to characterize.
17770 @itemize *
17772 @item 
17773 “The value of Barrier_Limit’Last in Synchronous_Barriers.  See D.10.1(4).”
17774 @end itemize
17776 Synchronous_Barriers.Barrier_Limit’Last is Integer’Last .
17779 @itemize *
17781 @item 
17782 “When an aborted task that is waiting on a Synchronous_Barrier is aborted.
17783 See D.10.1(13).”
17784 @end itemize
17786 Difficult to characterize.
17789 @itemize *
17791 @item 
17792 “The value of Min_Handler_Ceiling in Execution_Time.Group_Budgets.
17793 See D.14.2(7).”
17794 @end itemize
17796 See source file @code{a-etgrbu.ads}.
17799 @itemize *
17801 @item 
17802 “The value of CPU_Range’Last in System.Multiprocessors.  See D.16(4).”
17803 @end itemize
17805 See source file @code{s-multip.ads}.
17808 @itemize *
17810 @item 
17811 “The processor on which the environment task executes in the absence
17812 of a value for the aspect CPU.  See D.16(13).”
17813 @end itemize
17815 Unknown.
17818 @itemize *
17820 @item 
17821 “The means for creating and executing distributed
17822 programs.  See E(5).”
17823 @end itemize
17825 The GLADE package provides a utility GNATDIST for creating and executing
17826 distributed programs. See the GLADE reference manual for further details.
17829 @itemize *
17831 @item 
17832 “Any events that can result in a partition becoming
17833 inaccessible.  See E.1(7).”
17834 @end itemize
17836 See the GLADE reference manual for full details on such events.
17839 @itemize *
17841 @item 
17842 “The scheduling policies, treatment of priorities, and management of
17843 shared resources between partitions in certain cases.  See E.1(11).”
17844 @end itemize
17846 See the GLADE reference manual for full details on these aspects of
17847 multi-partition execution.
17850 @itemize *
17852 @item 
17853 “Whether the execution of the remote subprogram is
17854 immediately aborted as a result of cancellation.  See E.4(13).”
17855 @end itemize
17857 See the GLADE reference manual for details on the effect of abort in
17858 a distributed application.
17861 @itemize *
17863 @item 
17864 “The range of type System.RPC.Partition_Id.  See E.5(14).”
17865 @end itemize
17867 System.RPC.Partition_ID’Last is Integer’Last. See source file @code{s-rpc.ads}.
17870 @itemize *
17872 @item 
17873 “Implementation-defined interfaces in the PCS.  See E.5(26).”
17874 @end itemize
17876 See the GLADE reference manual for a full description of all
17877 implementation defined interfaces.
17880 @itemize *
17882 @item 
17883 “The values of named numbers in the package
17884 @code{Decimal}.  See F.2(7).”
17885 @end itemize
17888 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxx} 
17889 @headitem
17891 Named Number
17893 @tab
17895 Value
17897 @item
17899 `Max_Scale'
17901 @tab
17905 @item
17907 `Min_Scale'
17909 @tab
17913 @item
17915 `Min_Delta'
17917 @tab
17919 1.0E-18
17921 @item
17923 `Max_Delta'
17925 @tab
17927 1.0E+18
17929 @item
17931 `Max_Decimal_Digits'
17933 @tab
17937 @end multitable
17941 @itemize *
17943 @item 
17944 “The value of @code{Max_Picture_Length} in the package
17945 @code{Text_IO.Editing}.  See F.3.3(16).”
17949 @item 
17950 “The value of @code{Max_Picture_Length} in the package
17951 @code{Wide_Text_IO.Editing}.  See F.3.4(5).”
17955 @item 
17956 “The accuracy actually achieved by the complex elementary
17957 functions and by other complex arithmetic operations.  See G.1(1).”
17958 @end itemize
17960 Standard library functions are used for the complex arithmetic
17961 operations.  Only fast math mode is currently supported.
17964 @itemize *
17966 @item 
17967 “The sign of a zero result (or a component thereof) from
17968 any operator or function in @code{Numerics.Generic_Complex_Types}, when
17969 @code{Real'Signed_Zeros} is True.  See G.1.1(53).”
17970 @end itemize
17972 The signs of zero values are as recommended by the relevant
17973 implementation advice.
17976 @itemize *
17978 @item 
17979 “The sign of a zero result (or a component thereof) from
17980 any operator or function in
17981 @code{Numerics.Generic_Complex_Elementary_Functions}, when
17982 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).”
17983 @end itemize
17985 The signs of zero values are as recommended by the relevant
17986 implementation advice.
17989 @itemize *
17991 @item 
17992 “Whether the strict mode or the relaxed mode is the
17993 default.  See G.2(2).”
17994 @end itemize
17996 The strict mode is the default.  There is no separate relaxed mode.  GNAT
17997 provides a highly efficient implementation of strict mode.
18000 @itemize *
18002 @item 
18003 “The result interval in certain cases of fixed-to-float
18004 conversion.  See G.2.1(10).”
18005 @end itemize
18007 For cases where the result interval is implementation dependent, the
18008 accuracy is that provided by performing all operations in 64-bit IEEE
18009 floating-point format.
18012 @itemize *
18014 @item 
18015 “The result of a floating point arithmetic operation in
18016 overflow situations, when the @code{Machine_Overflows} attribute of the
18017 result type is @code{False}.  See G.2.1(13).”
18018 @end itemize
18020 Infinite and NaN values are produced as dictated by the IEEE
18021 floating-point standard.
18022 Note that on machines that are not fully compliant with the IEEE
18023 floating-point standard, such as Alpha, the `-mieee' compiler flag
18024 must be used for achieving IEEE conforming behavior (although at the cost
18025 of a significant performance penalty), so infinite and NaN values are
18026 properly generated.
18029 @itemize *
18031 @item 
18032 “The result interval for division (or exponentiation by a
18033 negative exponent), when the floating point hardware implements division
18034 as multiplication by a reciprocal.  See G.2.1(16).”
18035 @end itemize
18037 Not relevant, division is IEEE exact.
18040 @itemize *
18042 @item 
18043 “The definition of close result set, which determines the accuracy of
18044 certain fixed point multiplications and divisions.  See G.2.3(5).”
18045 @end itemize
18047 Operations in the close result set are performed using IEEE long format
18048 floating-point arithmetic.  The input operands are converted to
18049 floating-point, the operation is done in floating-point, and the result
18050 is converted to the target type.
18053 @itemize *
18055 @item 
18056 “Conditions on a `universal_real' operand of a fixed
18057 point multiplication or division for which the result shall be in the
18058 perfect result set.  See G.2.3(22).”
18059 @end itemize
18061 The result is only defined to be in the perfect result set if the result
18062 can be computed by a single scaling operation involving a scale factor
18063 representable in 64 bits.
18066 @itemize *
18068 @item 
18069 “The result of a fixed point arithmetic operation in
18070 overflow situations, when the @code{Machine_Overflows} attribute of the
18071 result type is @code{False}.  See G.2.3(27).”
18072 @end itemize
18074 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
18075 types.
18078 @itemize *
18080 @item 
18081 “The result of an elementary function reference in
18082 overflow situations, when the @code{Machine_Overflows} attribute of the
18083 result type is @code{False}.  See G.2.4(4).”
18084 @end itemize
18086 IEEE infinite and Nan values are produced as appropriate.
18089 @itemize *
18091 @item 
18092 “The value of the angle threshold, within which certain
18093 elementary functions, complex arithmetic operations, and complex
18094 elementary functions yield results conforming to a maximum relative
18095 error bound.  See G.2.4(10).”
18096 @end itemize
18098 Information on this subject is not yet available.
18101 @itemize *
18103 @item 
18104 “The accuracy of certain elementary functions for
18105 parameters beyond the angle threshold.  See G.2.4(10).”
18106 @end itemize
18108 Information on this subject is not yet available.
18111 @itemize *
18113 @item 
18114 “The result of a complex arithmetic operation or complex
18115 elementary function reference in overflow situations, when the
18116 @code{Machine_Overflows} attribute of the corresponding real type is
18117 @code{False}.  See G.2.6(5).”
18118 @end itemize
18120 IEEE infinite and Nan values are produced as appropriate.
18123 @itemize *
18125 @item 
18126 “The accuracy of certain complex arithmetic operations and
18127 certain complex elementary functions for parameters (or components
18128 thereof) beyond the angle threshold.  See G.2.6(8).”
18129 @end itemize
18131 Information on those subjects is not yet available.
18134 @itemize *
18136 @item 
18137 “The accuracy requirements for the subprograms Solve, Inverse,
18138 Determinant, Eigenvalues and Eigensystem for type Real_Matrix.
18139 See G.3.1(81).”
18140 @end itemize
18142 Information on those subjects is not yet available.
18145 @itemize *
18147 @item 
18148 “The accuracy requirements for the subprograms Solve, Inverse,
18149 Determinant, Eigenvalues and Eigensystem for type Complex_Matrix.
18150 See G.3.2(149).”
18151 @end itemize
18153 Information on those subjects is not yet available.
18156 @itemize *
18158 @item 
18159 “The consequences of violating No_Hidden_Indirect_Globals.  See H.4(23.9).”
18160 @end itemize
18162 Execution is erroneous in that case.
18164 @node Intrinsic Subprograms,Representation Clauses and Pragmas,Implementation Defined Characteristics,Top
18165 @anchor{gnat_rm/intrinsic_subprograms doc}@anchor{26c}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{26d}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c}
18166 @chapter Intrinsic Subprograms
18169 @geindex Intrinsic Subprograms
18171 GNAT allows a user application program to write the declaration:
18173 @example
18174 pragma Import (Intrinsic, name);
18175 @end example
18177 providing that the name corresponds to one of the implemented intrinsic
18178 subprograms in GNAT, and that the parameter profile of the referenced
18179 subprogram meets the requirements.  This chapter describes the set of
18180 implemented intrinsic subprograms, and the requirements on parameter profiles.
18181 Note that no body is supplied; as with other uses of pragma Import, the
18182 body is supplied elsewhere (in this case by the compiler itself).  Note
18183 that any use of this feature is potentially non-portable, since the
18184 Ada standard does not require Ada compilers to implement this feature.
18186 @menu
18187 * Intrinsic Operators:: 
18188 * Compilation_ISO_Date:: 
18189 * Compilation_Date:: 
18190 * Compilation_Time:: 
18191 * Enclosing_Entity:: 
18192 * Exception_Information:: 
18193 * Exception_Message:: 
18194 * Exception_Name:: 
18195 * File:: 
18196 * Line:: 
18197 * Shifts and Rotates:: 
18198 * Source_Location:: 
18200 @end menu
18202 @node Intrinsic Operators,Compilation_ISO_Date,,Intrinsic Subprograms
18203 @anchor{gnat_rm/intrinsic_subprograms id2}@anchor{26e}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{26f}
18204 @section Intrinsic Operators
18207 @geindex Intrinsic operator
18209 All the predefined numeric operators in package Standard
18210 in @code{pragma Import (Intrinsic,..)}
18211 declarations.  In the binary operator case, the operands must have the same
18212 size.  The operand or operands must also be appropriate for
18213 the operator.  For example, for addition, the operands must
18214 both be floating-point or both be fixed-point, and the
18215 right operand for @code{"**"} must have a root type of
18216 @code{Standard.Integer'Base}.
18217 You can use an intrinsic operator declaration as in the following example:
18219 @example
18220 type Int1 is new Integer;
18221 type Int2 is new Integer;
18223 function "+" (X1 : Int1; X2 : Int2) return Int1;
18224 function "+" (X1 : Int1; X2 : Int2) return Int2;
18225 pragma Import (Intrinsic, "+");
18226 @end example
18228 This declaration would permit ‘mixed mode’ arithmetic on items
18229 of the differing types @code{Int1} and @code{Int2}.
18230 It is also possible to specify such operators for private types, if the
18231 full views are appropriate arithmetic types.
18233 @node Compilation_ISO_Date,Compilation_Date,Intrinsic Operators,Intrinsic Subprograms
18234 @anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{270}@anchor{gnat_rm/intrinsic_subprograms id3}@anchor{271}
18235 @section Compilation_ISO_Date
18238 @geindex Compilation_ISO_Date
18240 This intrinsic subprogram is used in the implementation of the
18241 library package @code{GNAT.Source_Info}.  The only useful use of the
18242 intrinsic import in this case is the one in this unit, so an
18243 application program should simply call the function
18244 @code{GNAT.Source_Info.Compilation_ISO_Date} to obtain the date of
18245 the current compilation (in local time format YYYY-MM-DD).
18247 @node Compilation_Date,Compilation_Time,Compilation_ISO_Date,Intrinsic Subprograms
18248 @anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{272}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{273}
18249 @section Compilation_Date
18252 @geindex Compilation_Date
18254 Same as Compilation_ISO_Date, except the string is in the form
18255 MMM DD YYYY.
18257 @node Compilation_Time,Enclosing_Entity,Compilation_Date,Intrinsic Subprograms
18258 @anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{274}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{275}
18259 @section Compilation_Time
18262 @geindex Compilation_Time
18264 This intrinsic subprogram is used in the implementation of the
18265 library package @code{GNAT.Source_Info}.  The only useful use of the
18266 intrinsic import in this case is the one in this unit, so an
18267 application program should simply call the function
18268 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
18269 the current compilation (in local time format HH:MM:SS).
18271 @node Enclosing_Entity,Exception_Information,Compilation_Time,Intrinsic Subprograms
18272 @anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{276}@anchor{gnat_rm/intrinsic_subprograms id6}@anchor{277}
18273 @section Enclosing_Entity
18276 @geindex Enclosing_Entity
18278 This intrinsic subprogram is used in the implementation of the
18279 library package @code{GNAT.Source_Info}.  The only useful use of the
18280 intrinsic import in this case is the one in this unit, so an
18281 application program should simply call the function
18282 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
18283 the current subprogram, package, task, entry, or protected subprogram.
18285 @node Exception_Information,Exception_Message,Enclosing_Entity,Intrinsic Subprograms
18286 @anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{278}@anchor{gnat_rm/intrinsic_subprograms id7}@anchor{279}
18287 @section Exception_Information
18290 @geindex Exception_Information'
18292 This intrinsic subprogram is used in the implementation of the
18293 library package @code{GNAT.Current_Exception}.  The only useful
18294 use of the intrinsic import in this case is the one in this unit,
18295 so an application program should simply call the function
18296 @code{GNAT.Current_Exception.Exception_Information} to obtain
18297 the exception information associated with the current exception.
18299 @node Exception_Message,Exception_Name,Exception_Information,Intrinsic Subprograms
18300 @anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{27a}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{27b}
18301 @section Exception_Message
18304 @geindex Exception_Message
18306 This intrinsic subprogram is used in the implementation of the
18307 library package @code{GNAT.Current_Exception}.  The only useful
18308 use of the intrinsic import in this case is the one in this unit,
18309 so an application program should simply call the function
18310 @code{GNAT.Current_Exception.Exception_Message} to obtain
18311 the message associated with the current exception.
18313 @node Exception_Name,File,Exception_Message,Intrinsic Subprograms
18314 @anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{27c}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{27d}
18315 @section Exception_Name
18318 @geindex Exception_Name
18320 This intrinsic subprogram is used in the implementation of the
18321 library package @code{GNAT.Current_Exception}.  The only useful
18322 use of the intrinsic import in this case is the one in this unit,
18323 so an application program should simply call the function
18324 @code{GNAT.Current_Exception.Exception_Name} to obtain
18325 the name of the current exception.
18327 @node File,Line,Exception_Name,Intrinsic Subprograms
18328 @anchor{gnat_rm/intrinsic_subprograms file}@anchor{27e}@anchor{gnat_rm/intrinsic_subprograms id10}@anchor{27f}
18329 @section File
18332 @geindex File
18334 This intrinsic subprogram is used in the implementation of the
18335 library package @code{GNAT.Source_Info}.  The only useful use of the
18336 intrinsic import in this case is the one in this unit, so an
18337 application program should simply call the function
18338 @code{GNAT.Source_Info.File} to obtain the name of the current
18339 file.
18341 @node Line,Shifts and Rotates,File,Intrinsic Subprograms
18342 @anchor{gnat_rm/intrinsic_subprograms id11}@anchor{280}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{281}
18343 @section Line
18346 @geindex Line
18348 This intrinsic subprogram is used in the implementation of the
18349 library package @code{GNAT.Source_Info}.  The only useful use of the
18350 intrinsic import in this case is the one in this unit, so an
18351 application program should simply call the function
18352 @code{GNAT.Source_Info.Line} to obtain the number of the current
18353 source line.
18355 @node Shifts and Rotates,Source_Location,Line,Intrinsic Subprograms
18356 @anchor{gnat_rm/intrinsic_subprograms id12}@anchor{282}@anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{283}
18357 @section Shifts and Rotates
18360 @geindex Shift_Left
18362 @geindex Shift_Right
18364 @geindex Shift_Right_Arithmetic
18366 @geindex Rotate_Left
18368 @geindex Rotate_Right
18370 In standard Ada, the shift and rotate functions are available only
18371 for the predefined modular types in package @code{Interfaces}.  However, in
18372 GNAT it is possible to define these functions for any integer
18373 type (signed or modular), as in this example:
18375 @example
18376 function Shift_Left
18377   (Value  : T;
18378    Amount : Natural) return T
18379 with Import, Convention => Intrinsic;
18380 @end example
18382 The function name must be one of
18383 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
18384 Rotate_Right. T must be an integer type. T’Size must be
18385 8, 16, 32 or 64 bits; if T is modular, the modulus
18386 must be 2**8, 2**16, 2**32 or 2**64.
18387 The result type must be the same as the type of @code{Value}.
18388 The shift amount must be Natural.
18389 The formal parameter names can be anything.
18391 A more convenient way of providing these shift operators is to use the
18392 Provide_Shift_Operators pragma, which provides the function declarations and
18393 corresponding pragma Import’s for all five shift functions. For signed types
18394 the semantics of these operators is to interpret the bitwise result of the
18395 corresponding operator for modular type. In particular, shifting a negative
18396 number may change its sign bit to positive.
18398 @node Source_Location,,Shifts and Rotates,Intrinsic Subprograms
18399 @anchor{gnat_rm/intrinsic_subprograms id13}@anchor{284}@anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{285}
18400 @section Source_Location
18403 @geindex Source_Location
18405 This intrinsic subprogram is used in the implementation of the
18406 library routine @code{GNAT.Source_Info}.  The only useful use of the
18407 intrinsic import in this case is the one in this unit, so an
18408 application program should simply call the function
18409 @code{GNAT.Source_Info.Source_Location} to obtain the current
18410 source file location.
18412 @node Representation Clauses and Pragmas,Standard Library Routines,Intrinsic Subprograms,Top
18413 @anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{286}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{287}@anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d}
18414 @chapter Representation Clauses and Pragmas
18417 @geindex Representation Clauses
18419 @geindex Representation Clause
18421 @geindex Representation Pragma
18423 @geindex Pragma
18424 @geindex representation
18426 This section describes the representation clauses accepted by GNAT, and
18427 their effect on the representation of corresponding data objects.
18429 GNAT fully implements Annex C (Systems Programming).  This means that all
18430 the implementation advice sections in chapter 13 are fully implemented.
18431 However, these sections only require a minimal level of support for
18432 representation clauses.  GNAT provides much more extensive capabilities,
18433 and this section describes the additional capabilities provided.
18435 @menu
18436 * Alignment Clauses:: 
18437 * Size Clauses:: 
18438 * Storage_Size Clauses:: 
18439 * Size of Variant Record Objects:: 
18440 * Biased Representation:: 
18441 * Value_Size and Object_Size Clauses:: 
18442 * Component_Size Clauses:: 
18443 * Bit_Order Clauses:: 
18444 * Effect of Bit_Order on Byte Ordering:: 
18445 * Pragma Pack for Arrays:: 
18446 * Pragma Pack for Records:: 
18447 * Record Representation Clauses:: 
18448 * Handling of Records with Holes:: 
18449 * Enumeration Clauses:: 
18450 * Address Clauses:: 
18451 * Use of Address Clauses for Memory-Mapped I/O:: 
18452 * Effect of Convention on Representation:: 
18453 * Conventions and Anonymous Access Types:: 
18454 * Determining the Representations chosen by GNAT:: 
18456 @end menu
18458 @node Alignment Clauses,Size Clauses,,Representation Clauses and Pragmas
18459 @anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{288}@anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{289}
18460 @section Alignment Clauses
18463 @geindex Alignment Clause
18465 GNAT requires that all alignment clauses specify 0 or a power of 2, and
18466 all default alignments are always a power of 2. Specifying 0 is the
18467 same as specifying 1.
18469 The default alignment values are as follows:
18472 @itemize *
18474 @item 
18475 `Elementary Types'.
18477 For elementary types, the alignment is the minimum of the actual size of
18478 objects of the type divided by @code{Storage_Unit},
18479 and the maximum alignment supported by the target.
18480 (This maximum alignment is given by the GNAT-specific attribute
18481 @code{Standard'Maximum_Alignment}; see @ref{199,,Attribute Maximum_Alignment}.)
18483 @geindex Maximum_Alignment attribute
18485 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
18486 default alignment will be 8 on any target that supports alignments
18487 this large, but on some targets, the maximum alignment may be smaller
18488 than 8, in which case objects of type @code{Long_Float} will be maximally
18489 aligned.
18491 @item 
18492 `Arrays'.
18494 For arrays, the alignment is equal to the alignment of the component type
18495 for the normal case where no packing or component size is given.  If the
18496 array is packed, and the packing is effective (see separate section on
18497 packed arrays), then the alignment will be either 4, 2, or 1 for long packed
18498 arrays or arrays whose length is not known at compile time, depending on
18499 whether the component size is divisible by 4, 2, or is odd.  For short packed
18500 arrays, which are handled internally as modular types, the alignment
18501 will be as described for elementary types, e.g. a packed array of length
18502 31 bits will have an object size of four bytes, and an alignment of 4.
18504 @item 
18505 `Records'.
18507 For the normal unpacked case, the alignment of a record is equal to
18508 the maximum alignment of any of its components.  For tagged records, this
18509 includes the implicit access type used for the tag.  If a pragma @code{Pack}
18510 is used and all components are packable (see separate section on pragma
18511 @code{Pack}), then the resulting alignment is 1, unless the layout of the
18512 record makes it profitable to increase it.
18514 A special case is when:
18517 @itemize *
18519 @item 
18520 the size of the record is given explicitly, or a
18521 full record representation clause is given, and
18523 @item 
18524 the size of the record is 2, 4, or 8 bytes.
18525 @end itemize
18527 In this case, an alignment is chosen to match the
18528 size of the record. For example, if we have:
18530 @example
18531 type Small is record
18532    A, B : Character;
18533 end record;
18534 for Small'Size use 16;
18535 @end example
18537 then the default alignment of the record type @code{Small} is 2, not 1. This
18538 leads to more efficient code when the record is treated as a unit, and also
18539 allows the type to specified as @code{Atomic} on architectures requiring
18540 strict alignment.
18541 @end itemize
18543 An alignment clause may specify a larger alignment than the default value
18544 up to some maximum value dependent on the target (obtainable by using the
18545 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
18546 a smaller alignment than the default value for enumeration, integer and
18547 fixed point types, as well as for record types, for example
18549 @example
18550 type V is record
18551    A : Integer;
18552 end record;
18554 for V'alignment use 1;
18555 @end example
18557 @geindex Alignment
18558 @geindex default
18560 The default alignment for the type @code{V} is 4, as a result of the
18561 Integer field in the record, but it is permissible, as shown, to
18562 override the default alignment of the record with a smaller value.
18564 @geindex Alignment
18565 @geindex subtypes
18567 Note that according to the Ada standard, an alignment clause applies only
18568 to the first named subtype. If additional subtypes are declared, then the
18569 compiler is allowed to choose any alignment it likes, and there is no way
18570 to control this choice. Consider:
18572 @example
18573 type R is range 1 .. 10_000;
18574 for R'Alignment use 1;
18575 subtype RS is R range 1 .. 1000;
18576 @end example
18578 The alignment clause specifies an alignment of 1 for the first named subtype
18579 @code{R} but this does not necessarily apply to @code{RS}. When writing
18580 portable Ada code, you should avoid writing code that explicitly or
18581 implicitly relies on the alignment of such subtypes.
18583 For the GNAT compiler, if an explicit alignment clause is given, this
18584 value is also used for any subsequent subtypes. So for GNAT, in the
18585 above example, you can count on the alignment of @code{RS} being 1. But this
18586 assumption is non-portable, and other compilers may choose different
18587 alignments for the subtype @code{RS}.
18589 @node Size Clauses,Storage_Size Clauses,Alignment Clauses,Representation Clauses and Pragmas
18590 @anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{28a}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{28b}
18591 @section Size Clauses
18594 @geindex Size Clause
18596 The default size for a type @code{T} is obtainable through the
18597 language-defined attribute @code{T'Size} and also through the
18598 equivalent GNAT-defined attribute @code{T'Value_Size}.
18599 For objects of type @code{T}, GNAT will generally increase the type size
18600 so that the object size (obtainable through the GNAT-defined attribute
18601 @code{T'Object_Size})
18602 is a multiple of @code{T'Alignment * Storage_Unit}.
18604 For example:
18606 @example
18607 type Smallint is range 1 .. 6;
18609 type Rec is record
18610    Y1 : integer;
18611    Y2 : boolean;
18612 end record;
18613 @end example
18615 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
18616 as specified by the RM rules,
18617 but objects of this type will have a size of 8
18618 (@code{Smallint'Object_Size} = 8),
18619 since objects by default occupy an integral number
18620 of storage units.  On some targets, notably older
18621 versions of the Digital Alpha, the size of stand
18622 alone objects of this type may be 32, reflecting
18623 the inability of the hardware to do byte load/stores.
18625 Similarly, the size of type @code{Rec} is 40 bits
18626 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
18627 the alignment is 4, so objects of this type will have
18628 their size increased to 64 bits so that it is a multiple
18629 of the alignment (in bits).  This decision is
18630 in accordance with the specific Implementation Advice in RM 13.3(43):
18632 @quotation
18634 “A @code{Size} clause should be supported for an object if the specified
18635 @code{Size} is at least as large as its subtype’s @code{Size}, and corresponds
18636 to a size in storage elements that is a multiple of the object’s
18637 @code{Alignment} (if the @code{Alignment} is nonzero).”
18638 @end quotation
18640 An explicit size clause may be used to override the default size by
18641 increasing it.  For example, if we have:
18643 @example
18644 type My_Boolean is new Boolean;
18645 for My_Boolean'Size use 32;
18646 @end example
18648 then values of this type will always be 32-bit long.  In the case of discrete
18649 types, the size can be increased up to 64 bits on 32-bit targets and 128 bits
18650 on 64-bit targets, with the effect that the entire specified field is used to
18651 hold the value, sign- or zero-extended as appropriate.  If more than 64 bits
18652 or 128 bits resp. is specified, then padding space is allocated after the
18653 value, and a warning is issued that there are unused bits.
18655 Similarly the size of records and arrays may be increased, and the effect
18656 is to add padding bits after the value.  This also causes a warning message
18657 to be generated.
18659 The largest Size value permitted in GNAT is 2**31-1.  Since this is a
18660 Size in bits, this corresponds to an object of size 256 megabytes (minus
18661 one).  This limitation is true on all targets.  The reason for this
18662 limitation is that it improves the quality of the code in many cases
18663 if it is known that a Size value can be accommodated in an object of
18664 type Integer.
18666 @node Storage_Size Clauses,Size of Variant Record Objects,Size Clauses,Representation Clauses and Pragmas
18667 @anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{28c}@anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{28d}
18668 @section Storage_Size Clauses
18671 @geindex Storage_Size Clause
18673 For tasks, the @code{Storage_Size} clause specifies the amount of space
18674 to be allocated for the task stack.  This cannot be extended, and if the
18675 stack is exhausted, then @code{Storage_Error} will be raised (if stack
18676 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
18677 or a @code{Storage_Size} pragma in the task definition to set the
18678 appropriate required size.  A useful technique is to include in every
18679 task definition a pragma of the form:
18681 @example
18682 pragma Storage_Size (Default_Stack_Size);
18683 @end example
18685 Then @code{Default_Stack_Size} can be defined in a global package, and
18686 modified as required. Any tasks requiring stack sizes different from the
18687 default can have an appropriate alternative reference in the pragma.
18689 You can also use the `-d' binder switch to modify the default stack
18690 size.
18692 For access types, the @code{Storage_Size} clause specifies the maximum
18693 space available for allocation of objects of the type.  If this space is
18694 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
18695 In the case where the access type is declared local to a subprogram, the
18696 use of a @code{Storage_Size} clause triggers automatic use of a special
18697 predefined storage pool (@code{System.Pool_Size}) that ensures that all
18698 space for the pool is automatically reclaimed on exit from the scope in
18699 which the type is declared.
18701 A special case recognized by the compiler is the specification of a
18702 @code{Storage_Size} of zero for an access type.  This means that no
18703 items can be allocated from the pool, and this is recognized at compile
18704 time, and all the overhead normally associated with maintaining a fixed
18705 size storage pool is eliminated.  Consider the following example:
18707 @example
18708 procedure p is
18709    type R is array (Natural) of Character;
18710    type P is access all R;
18711    for P'Storage_Size use 0;
18712    --  Above access type intended only for interfacing purposes
18714    y : P;
18716    procedure g (m : P);
18717    pragma Import (C, g);
18719    --  ...
18721 begin
18722    --  ...
18723    y := new R;
18724 end;
18725 @end example
18727 As indicated in this example, these dummy storage pools are often useful in
18728 connection with interfacing where no object will ever be allocated.  If you
18729 compile the above example, you get the warning:
18731 @example
18732 p.adb:16:09: warning: allocation from empty storage pool
18733 p.adb:16:09: warning: Storage_Error will be raised at run time
18734 @end example
18736 Of course in practice, there will not be any explicit allocators in the
18737 case of such an access declaration.
18739 @node Size of Variant Record Objects,Biased Representation,Storage_Size Clauses,Representation Clauses and Pragmas
18740 @anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{28e}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{28f}
18741 @section Size of Variant Record Objects
18744 @geindex Size
18745 @geindex variant record objects
18747 @geindex Variant record objects
18748 @geindex size
18750 In the case of variant record objects, there is a question whether Size gives
18751 information about a particular variant, or the maximum size required
18752 for any variant.  Consider the following program
18754 @example
18755 with Text_IO; use Text_IO;
18756 procedure q is
18757    type R1 (A : Boolean := False) is record
18758      case A is
18759        when True  => X : Character;
18760        when False => null;
18761      end case;
18762    end record;
18764    V1 : R1 (False);
18765    V2 : R1;
18767 begin
18768    Put_Line (Integer'Image (V1'Size));
18769    Put_Line (Integer'Image (V2'Size));
18770 end q;
18771 @end example
18773 Here we are dealing with a variant record, where the True variant
18774 requires 16 bits, and the False variant requires 8 bits.
18775 In the above example, both V1 and V2 contain the False variant,
18776 which is only 8 bits long.  However, the result of running the
18777 program is:
18779 @example
18782 @end example
18784 The reason for the difference here is that the discriminant value of
18785 V1 is fixed, and will always be False.  It is not possible to assign
18786 a True variant value to V1, therefore 8 bits is sufficient.  On the
18787 other hand, in the case of V2, the initial discriminant value is
18788 False (from the default), but it is possible to assign a True
18789 variant value to V2, therefore 16 bits must be allocated for V2
18790 in the general case, even fewer bits may be needed at any particular
18791 point during the program execution.
18793 As can be seen from the output of this program, the @code{'Size}
18794 attribute applied to such an object in GNAT gives the actual allocated
18795 size of the variable, which is the largest size of any of the variants.
18796 The Ada Reference Manual is not completely clear on what choice should
18797 be made here, but the GNAT behavior seems most consistent with the
18798 language in the RM.
18800 In some cases, it may be desirable to obtain the size of the current
18801 variant, rather than the size of the largest variant.  This can be
18802 achieved in GNAT by making use of the fact that in the case of a
18803 subprogram parameter, GNAT does indeed return the size of the current
18804 variant (because a subprogram has no way of knowing how much space
18805 is actually allocated for the actual).
18807 Consider the following modified version of the above program:
18809 @example
18810 with Text_IO; use Text_IO;
18811 procedure q is
18812    type R1 (A : Boolean := False) is record
18813      case A is
18814        when True  => X : Character;
18815        when False => null;
18816      end case;
18817    end record;
18819    V2 : R1;
18821    function Size (V : R1) return Integer is
18822    begin
18823       return V'Size;
18824    end Size;
18826 begin
18827    Put_Line (Integer'Image (V2'Size));
18828    Put_Line (Integer'Image (Size (V2)));
18829    V2 := (True, 'x');
18830    Put_Line (Integer'Image (V2'Size));
18831    Put_Line (Integer'Image (Size (V2)));
18832 end q;
18833 @end example
18835 The output from this program is
18837 @example
18842 @end example
18844 Here we see that while the @code{'Size} attribute always returns
18845 the maximum size, regardless of the current variant value, the
18846 @code{Size} function does indeed return the size of the current
18847 variant value.
18849 @node Biased Representation,Value_Size and Object_Size Clauses,Size of Variant Record Objects,Representation Clauses and Pragmas
18850 @anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{290}@anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{291}
18851 @section Biased Representation
18854 @geindex Size for biased representation
18856 @geindex Biased representation
18858 In the case of scalars with a range starting at other than zero, it is
18859 possible in some cases to specify a size smaller than the default minimum
18860 value, and in such cases, GNAT uses an unsigned biased representation,
18861 in which zero is used to represent the lower bound, and successive values
18862 represent successive values of the type.
18864 For example, suppose we have the declaration:
18866 @example
18867 type Small is range -7 .. -4;
18868 for Small'Size use 2;
18869 @end example
18871 Although the default size of type @code{Small} is 4, the @code{Size}
18872 clause is accepted by GNAT and results in the following representation
18873 scheme:
18875 @example
18876 -7 is represented as 2#00#
18877 -6 is represented as 2#01#
18878 -5 is represented as 2#10#
18879 -4 is represented as 2#11#
18880 @end example
18882 Biased representation is only used if the specified @code{Size} clause
18883 cannot be accepted in any other manner.  These reduced sizes that force
18884 biased representation can be used for all discrete types except for
18885 enumeration types for which a representation clause is given.
18887 @node Value_Size and Object_Size Clauses,Component_Size Clauses,Biased Representation,Representation Clauses and Pragmas
18888 @anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{292}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{293}
18889 @section Value_Size and Object_Size Clauses
18892 @geindex Value_Size
18894 @geindex Object_Size
18896 @geindex Size
18897 @geindex of objects
18899 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
18900 number of bits required to hold values of type @code{T}.
18901 Although this interpretation was allowed in Ada 83, it was not required,
18902 and this requirement in practice can cause some significant difficulties.
18903 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
18904 However, in Ada 95 and Ada 2005,
18905 @code{Natural'Size} is
18906 typically 31.  This means that code may change in behavior when moving
18907 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
18909 @example
18910 type Rec is record
18911    A : Natural;
18912    B : Natural;
18913 end record;
18915 for Rec use record
18916    A at 0 range 0 .. Natural'Size - 1;
18917    B at 0 range Natural'Size .. 2 * Natural'Size - 1;
18918 end record;
18919 @end example
18921 In the above code, since the typical size of @code{Natural} objects
18922 is 32 bits and @code{Natural'Size} is 31, the above code can cause
18923 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
18924 there are cases where the fact that the object size can exceed the
18925 size of the type causes surprises.
18927 To help get around this problem GNAT provides two implementation
18928 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
18929 applied to a type, these attributes yield the size of the type
18930 (corresponding to the RM defined size attribute), and the size of
18931 objects of the type respectively.
18933 The @code{Object_Size} is used for determining the default size of
18934 objects and components.  This size value can be referred to using the
18935 @code{Object_Size} attribute.  The phrase ‘is used’ here means that it is
18936 the basis of the determination of the size.  The backend is free to
18937 pad this up if necessary for efficiency, e.g., an 8-bit stand-alone
18938 character might be stored in 32 bits on a machine with no efficient
18939 byte access instructions such as the Alpha.
18941 The default rules for the value of @code{Object_Size} for
18942 discrete types are as follows:
18945 @itemize *
18947 @item 
18948 The @code{Object_Size} for base subtypes reflect the natural hardware
18949 size in bits (run the compiler with `-gnatS' to find those values
18950 for numeric types). Enumeration types and fixed-point base subtypes have
18951 8, 16, 32, or 64 bits for this size, depending on the range of values
18952 to be stored.
18954 @item 
18955 The @code{Object_Size} of a subtype is the same as the
18956 @code{Object_Size} of
18957 the type from which it is obtained.
18959 @item 
18960 The @code{Object_Size} of a derived base type is copied from the parent
18961 base type, and the @code{Object_Size} of a derived first subtype is copied
18962 from the parent first subtype.
18963 @end itemize
18965 The @code{Value_Size} attribute
18966 is the (minimum) number of bits required to store a value
18967 of the type.
18968 This value is used to determine how tightly to pack
18969 records or arrays with components of this type, and also affects
18970 the semantics of unchecked conversion (unchecked conversions where
18971 the @code{Value_Size} values differ generate a warning, and are potentially
18972 target dependent).
18974 The default rules for the value of @code{Value_Size} are as follows:
18977 @itemize *
18979 @item 
18980 The @code{Value_Size} for a base subtype is the minimum number of bits
18981 required to store all values of the type (including the sign bit
18982 only if negative values are possible).
18984 @item 
18985 If a subtype statically matches the first subtype of a given type, then it has
18986 by default the same @code{Value_Size} as the first subtype.  (This is a
18987 consequence of RM 13.1(14): “if two subtypes statically match,
18988 then their subtype-specific aspects are the same”.)
18990 @item 
18991 All other subtypes have a @code{Value_Size} corresponding to the minimum
18992 number of bits required to store all values of the subtype.  For
18993 dynamic bounds, it is assumed that the value can range down or up
18994 to the corresponding bound of the ancestor
18995 @end itemize
18997 The RM defined attribute @code{Size} corresponds to the
18998 @code{Value_Size} attribute.
19000 The @code{Size} attribute may be defined for a first-named subtype.  This sets
19001 the @code{Value_Size} of
19002 the first-named subtype to the given value, and the
19003 @code{Object_Size} of this first-named subtype to the given value padded up
19004 to an appropriate boundary.  It is a consequence of the default rules
19005 above that this @code{Object_Size} will apply to all further subtypes.  On the
19006 other hand, @code{Value_Size} is affected only for the first subtype, any
19007 dynamic subtypes obtained from it directly, and any statically matching
19008 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
19010 @code{Value_Size} and
19011 @code{Object_Size} may be explicitly set for any subtype using
19012 an attribute definition clause.  Note that the use of these attributes
19013 can cause the RM 13.1(14) rule to be violated.  If two access types
19014 reference aliased objects whose subtypes have differing @code{Object_Size}
19015 values as a result of explicit attribute definition clauses, then it
19016 is illegal to convert from one access subtype to the other. For a more
19017 complete description of this additional legality rule, see the
19018 description of the @code{Object_Size} attribute.
19020 To get a feel for the difference, consider the following examples (note
19021 that in each case the base is @code{Short_Short_Integer} with a size of 8):
19024 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} 
19025 @headitem
19027 Type or subtype declaration
19029 @tab
19031 Object_Size
19033 @tab
19035 Value_Size
19037 @item
19039 @code{type x1 is range 0 .. 5;}
19041 @tab
19045 @tab
19049 @item
19051 @code{type x2 is range 0 .. 5;}
19052 @code{for x2'size use 12;}
19054 @tab
19058 @tab
19062 @item
19064 @code{subtype x3 is x2 range 0 .. 3;}
19066 @tab
19070 @tab
19074 @item
19076 @code{subtype x4 is x2'base range 0 .. 10;}
19078 @tab
19082 @tab
19086 @item
19088 @code{dynamic : x2'Base range -64 .. +63;}
19090 @tab
19092 @tab
19094 @item
19096 @code{subtype x5 is x2 range 0 .. dynamic;}
19098 @tab
19102 @tab
19106 @item
19108 @code{subtype x6 is x2'base range 0 .. dynamic;}
19110 @tab
19114 @tab
19118 @end multitable
19121 Note: the entries marked ‘*’ are not actually specified by the Ada
19122 Reference Manual, which has nothing to say about size in the dynamic
19123 case. What GNAT does is to allocate sufficient bits to accommodate any
19124 possible dynamic values for the bounds at run-time.
19126 So far, so good, but GNAT has to obey the RM rules, so the question is
19127 under what conditions must the RM @code{Size} be used.
19128 The following is a list
19129 of the occasions on which the RM @code{Size} must be used:
19132 @itemize *
19134 @item 
19135 Component size for packed arrays or records
19137 @item 
19138 Value of the attribute @code{Size} for a type
19140 @item 
19141 Warning about sizes not matching for unchecked conversion
19142 @end itemize
19144 For record types, the @code{Object_Size} is always a multiple of the
19145 alignment of the type (this is true for all types). In some cases the
19146 @code{Value_Size} can be smaller. Consider:
19148 @example
19149 type R is record
19150   X : Integer;
19151   Y : Character;
19152 end record;
19153 @end example
19155 On a typical 32-bit architecture, the X component will occupy four bytes
19156 and the Y component will occupy one byte, for a total of 5 bytes. As a
19157 result @code{R'Value_Size} will be 40 (bits) since this is the minimum size
19158 required to store a value of this type. For example, it is permissible
19159 to have a component of type R in an array whose component size is
19160 specified to be 40 bits.
19162 However, @code{R'Object_Size} will be 64 (bits). The difference is due to
19163 the alignment requirement for objects of the record type. The X
19164 component will require four-byte alignment because that is what type
19165 Integer requires, whereas the Y component, a Character, will only
19166 require 1-byte alignment. Since the alignment required for X is the
19167 greatest of all the components’ alignments, that is the alignment
19168 required for the enclosing record type, i.e., 4 bytes or 32 bits. As
19169 indicated above, the actual object size must be rounded up so that it is
19170 a multiple of the alignment value. Therefore, 40 bits rounded up to the
19171 next multiple of 32 yields 64 bits.
19173 For all other types, the @code{Object_Size}
19174 and @code{Value_Size} are the same (and equivalent to the RM attribute @code{Size}).
19175 Only @code{Size} may be specified for such types.
19177 Note that @code{Value_Size} can be used to force biased representation
19178 for a particular subtype. Consider this example:
19180 @example
19181 type R is (A, B, C, D, E, F);
19182 subtype RAB is R range A .. B;
19183 subtype REF is R range E .. F;
19184 @end example
19186 By default, @code{RAB}
19187 has a size of 1 (sufficient to accommodate the representation
19188 of @code{A} and @code{B}, 0 and 1), and @code{REF}
19189 has a size of 3 (sufficient to accommodate the representation
19190 of @code{E} and @code{F}, 4 and 5). But if we add the
19191 following @code{Value_Size} attribute definition clause:
19193 @example
19194 for REF'Value_Size use 1;
19195 @end example
19197 then biased representation is forced for @code{REF},
19198 and 0 will represent @code{E} and 1 will represent @code{F}.
19199 A warning is issued when a @code{Value_Size} attribute
19200 definition clause forces biased representation. This
19201 warning can be turned off using @code{-gnatw.B}.
19203 @node Component_Size Clauses,Bit_Order Clauses,Value_Size and Object_Size Clauses,Representation Clauses and Pragmas
19204 @anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{294}@anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{295}
19205 @section Component_Size Clauses
19208 @geindex Component_Size Clause
19210 Normally, the value specified in a component size clause must be consistent
19211 with the subtype of the array component with regard to size and alignment.
19212 In other words, the value specified must be at least equal to the size
19213 of this subtype, and must be a multiple of the alignment value.
19215 In addition, component size clauses are allowed which cause the array
19216 to be packed, by specifying a smaller value.  A first case is for
19217 component size values in the range 1 through 63 on 32-bit targets,
19218 and 1 through 127 on 64-bit targets.  The value specified may not
19219 be smaller than the Size of the subtype.  GNAT will accurately
19220 honor all packing requests in this range.  For example, if we have:
19222 @example
19223 type r is array (1 .. 8) of Natural;
19224 for r'Component_Size use 31;
19225 @end example
19227 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
19228 Of course access to the components of such an array is considerably
19229 less efficient than if the natural component size of 32 is used.
19230 A second case is when the subtype of the component is a record type
19231 padded because of its default alignment.  For example, if we have:
19233 @example
19234 type r is record
19235   i : Integer;
19236   j : Integer;
19237   b : Boolean;
19238 end record;
19240 type a is array (1 .. 8) of r;
19241 for a'Component_Size use 72;
19242 @end example
19244 then the resulting array has a length of 72 bytes, instead of 96 bytes
19245 if the alignment of the record (4) was obeyed.
19247 Note that there is no point in giving both a component size clause
19248 and a pragma Pack for the same array type. if such duplicate
19249 clauses are given, the pragma Pack will be ignored.
19251 @node Bit_Order Clauses,Effect of Bit_Order on Byte Ordering,Component_Size Clauses,Representation Clauses and Pragmas
19252 @anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{296}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{297}
19253 @section Bit_Order Clauses
19256 @geindex Bit_Order Clause
19258 @geindex bit ordering
19260 @geindex ordering
19261 @geindex of bits
19263 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
19264 attribute.  The specification may either correspond to the default bit
19265 order for the target, in which case the specification has no effect and
19266 places no additional restrictions, or it may be for the non-standard
19267 setting (that is the opposite of the default).
19269 In the case where the non-standard value is specified, the effect is
19270 to renumber bits within each byte, but the ordering of bytes is not
19271 affected.  There are certain
19272 restrictions placed on component clauses as follows:
19275 @itemize *
19277 @item 
19278 Components fitting within a single storage unit.
19280 These are unrestricted, and the effect is merely to renumber bits.  For
19281 example if we are on a little-endian machine with @code{Low_Order_First}
19282 being the default, then the following two declarations have exactly
19283 the same effect:
19285 @example
19286 type R1 is record
19287    A : Boolean;
19288    B : Integer range 1 .. 120;
19289 end record;
19291 for R1 use record
19292    A at 0 range 0 .. 0;
19293    B at 0 range 1 .. 7;
19294 end record;
19296 type R2 is record
19297    A : Boolean;
19298    B : Integer range 1 .. 120;
19299 end record;
19301 for R2'Bit_Order use High_Order_First;
19303 for R2 use record
19304    A at 0 range 7 .. 7;
19305    B at 0 range 0 .. 6;
19306 end record;
19307 @end example
19309 The useful application here is to write the second declaration with the
19310 @code{Bit_Order} attribute definition clause, and know that it will be treated
19311 the same, regardless of whether the target is little-endian or big-endian.
19313 @item 
19314 Components occupying an integral number of bytes.
19316 These are components that exactly fit in two or more bytes.  Such component
19317 declarations are allowed, but have no effect, since it is important to realize
19318 that the @code{Bit_Order} specification does not affect the ordering of bytes.
19319 In particular, the following attempt at getting an endian-independent integer
19320 does not work:
19322 @example
19323 type R2 is record
19324    A : Integer;
19325 end record;
19327 for R2'Bit_Order use High_Order_First;
19329 for R2 use record
19330    A at 0 range 0 .. 31;
19331 end record;
19332 @end example
19334 This declaration will result in a little-endian integer on a
19335 little-endian machine, and a big-endian integer on a big-endian machine.
19336 If byte flipping is required for interoperability between big- and
19337 little-endian machines, this must be explicitly programmed.  This capability
19338 is not provided by @code{Bit_Order}.
19340 @item 
19341 Components that are positioned across byte boundaries.
19343 but do not occupy an integral number of bytes.  Given that bytes are not
19344 reordered, such fields would occupy a non-contiguous sequence of bits
19345 in memory, requiring non-trivial code to reassemble.  They are for this
19346 reason not permitted, and any component clause specifying such a layout
19347 will be flagged as illegal by GNAT.
19348 @end itemize
19350 Since the misconception that Bit_Order automatically deals with all
19351 endian-related incompatibilities is a common one, the specification of
19352 a component field that is an integral number of bytes will always
19353 generate a warning.  This warning may be suppressed using @code{pragma Warnings (Off)}
19354 if desired.  The following section contains additional
19355 details regarding the issue of byte ordering.
19357 @node Effect of Bit_Order on Byte Ordering,Pragma Pack for Arrays,Bit_Order Clauses,Representation Clauses and Pragmas
19358 @anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{298}@anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{299}
19359 @section Effect of Bit_Order on Byte Ordering
19362 @geindex byte ordering
19364 @geindex ordering
19365 @geindex of bytes
19367 In this section we will review the effect of the @code{Bit_Order} attribute
19368 definition clause on byte ordering.  Briefly, it has no effect at all, but
19369 a detailed example will be helpful.  Before giving this
19370 example, let us review the precise
19371 definition of the effect of defining @code{Bit_Order}.  The effect of a
19372 non-standard bit order is described in section 13.5.3 of the Ada
19373 Reference Manual:
19375 @quotation
19377 “2   A bit ordering is a method of interpreting the meaning of
19378 the storage place attributes.”
19379 @end quotation
19381 To understand the precise definition of storage place attributes in
19382 this context, we visit section 13.5.1 of the manual:
19384 @quotation
19386 “13   A record_representation_clause (without the mod_clause)
19387 specifies the layout.  The storage place attributes (see 13.5.2)
19388 are taken from the values of the position, first_bit, and last_bit
19389 expressions after normalizing those values so that first_bit is
19390 less than Storage_Unit.”
19391 @end quotation
19393 The critical point here is that storage places are taken from
19394 the values after normalization, not before.  So the @code{Bit_Order}
19395 interpretation applies to normalized values.  The interpretation
19396 is described in the later part of the 13.5.3 paragraph:
19398 @quotation
19400 “2   A bit ordering is a method of interpreting the meaning of
19401 the storage place attributes.  High_Order_First (known in the
19402 vernacular as ‘big endian’) means that the first bit of a
19403 storage element (bit 0) is the most significant bit (interpreting
19404 the sequence of bits that represent a component as an unsigned
19405 integer value).  Low_Order_First (known in the vernacular as
19406 ‘little endian’) means the opposite: the first bit is the
19407 least significant.”
19408 @end quotation
19410 Note that the numbering is with respect to the bits of a storage
19411 unit.  In other words, the specification affects only the numbering
19412 of bits within a single storage unit.
19414 We can make the effect clearer by giving an example.
19416 Suppose that we have an external device which presents two bytes, the first
19417 byte presented, which is the first (low addressed byte) of the two byte
19418 record is called Master, and the second byte is called Slave.
19420 The left most (most significant) bit is called Control for each byte, and
19421 the remaining 7 bits are called V1, V2, … V7, where V7 is the rightmost
19422 (least significant) bit.
19424 On a big-endian machine, we can write the following representation clause
19426 @example
19427 type Data is record
19428    Master_Control : Bit;
19429    Master_V1      : Bit;
19430    Master_V2      : Bit;
19431    Master_V3      : Bit;
19432    Master_V4      : Bit;
19433    Master_V5      : Bit;
19434    Master_V6      : Bit;
19435    Master_V7      : Bit;
19436    Slave_Control  : Bit;
19437    Slave_V1       : Bit;
19438    Slave_V2       : Bit;
19439    Slave_V3       : Bit;
19440    Slave_V4       : Bit;
19441    Slave_V5       : Bit;
19442    Slave_V6       : Bit;
19443    Slave_V7       : Bit;
19444 end record;
19446 for Data use record
19447    Master_Control at 0 range 0 .. 0;
19448    Master_V1      at 0 range 1 .. 1;
19449    Master_V2      at 0 range 2 .. 2;
19450    Master_V3      at 0 range 3 .. 3;
19451    Master_V4      at 0 range 4 .. 4;
19452    Master_V5      at 0 range 5 .. 5;
19453    Master_V6      at 0 range 6 .. 6;
19454    Master_V7      at 0 range 7 .. 7;
19455    Slave_Control  at 1 range 0 .. 0;
19456    Slave_V1       at 1 range 1 .. 1;
19457    Slave_V2       at 1 range 2 .. 2;
19458    Slave_V3       at 1 range 3 .. 3;
19459    Slave_V4       at 1 range 4 .. 4;
19460    Slave_V5       at 1 range 5 .. 5;
19461    Slave_V6       at 1 range 6 .. 6;
19462    Slave_V7       at 1 range 7 .. 7;
19463 end record;
19464 @end example
19466 Now if we move this to a little endian machine, then the bit ordering within
19467 the byte is backwards, so we have to rewrite the record rep clause as:
19469 @example
19470 for Data use record
19471    Master_Control at 0 range 7 .. 7;
19472    Master_V1      at 0 range 6 .. 6;
19473    Master_V2      at 0 range 5 .. 5;
19474    Master_V3      at 0 range 4 .. 4;
19475    Master_V4      at 0 range 3 .. 3;
19476    Master_V5      at 0 range 2 .. 2;
19477    Master_V6      at 0 range 1 .. 1;
19478    Master_V7      at 0 range 0 .. 0;
19479    Slave_Control  at 1 range 7 .. 7;
19480    Slave_V1       at 1 range 6 .. 6;
19481    Slave_V2       at 1 range 5 .. 5;
19482    Slave_V3       at 1 range 4 .. 4;
19483    Slave_V4       at 1 range 3 .. 3;
19484    Slave_V5       at 1 range 2 .. 2;
19485    Slave_V6       at 1 range 1 .. 1;
19486    Slave_V7       at 1 range 0 .. 0;
19487 end record;
19488 @end example
19490 It is a nuisance to have to rewrite the clause, especially if
19491 the code has to be maintained on both machines.  However,
19492 this is a case that we can handle with the
19493 @code{Bit_Order} attribute if it is implemented.
19494 Note that the implementation is not required on byte addressed
19495 machines, but it is indeed implemented in GNAT.
19496 This means that we can simply use the
19497 first record clause, together with the declaration
19499 @example
19500 for Data'Bit_Order use High_Order_First;
19501 @end example
19503 and the effect is what is desired, namely the layout is exactly the same,
19504 independent of whether the code is compiled on a big-endian or little-endian
19505 machine.
19507 The important point to understand is that byte ordering is not affected.
19508 A @code{Bit_Order} attribute definition never affects which byte a field
19509 ends up in, only where it ends up in that byte.
19510 To make this clear, let us rewrite the record rep clause of the previous
19511 example as:
19513 @example
19514 for Data'Bit_Order use High_Order_First;
19515 for Data use record
19516    Master_Control at 0 range  0 .. 0;
19517    Master_V1      at 0 range  1 .. 1;
19518    Master_V2      at 0 range  2 .. 2;
19519    Master_V3      at 0 range  3 .. 3;
19520    Master_V4      at 0 range  4 .. 4;
19521    Master_V5      at 0 range  5 .. 5;
19522    Master_V6      at 0 range  6 .. 6;
19523    Master_V7      at 0 range  7 .. 7;
19524    Slave_Control  at 0 range  8 .. 8;
19525    Slave_V1       at 0 range  9 .. 9;
19526    Slave_V2       at 0 range 10 .. 10;
19527    Slave_V3       at 0 range 11 .. 11;
19528    Slave_V4       at 0 range 12 .. 12;
19529    Slave_V5       at 0 range 13 .. 13;
19530    Slave_V6       at 0 range 14 .. 14;
19531    Slave_V7       at 0 range 15 .. 15;
19532 end record;
19533 @end example
19535 This is exactly equivalent to saying (a repeat of the first example):
19537 @example
19538 for Data'Bit_Order use High_Order_First;
19539 for Data use record
19540    Master_Control at 0 range 0 .. 0;
19541    Master_V1      at 0 range 1 .. 1;
19542    Master_V2      at 0 range 2 .. 2;
19543    Master_V3      at 0 range 3 .. 3;
19544    Master_V4      at 0 range 4 .. 4;
19545    Master_V5      at 0 range 5 .. 5;
19546    Master_V6      at 0 range 6 .. 6;
19547    Master_V7      at 0 range 7 .. 7;
19548    Slave_Control  at 1 range 0 .. 0;
19549    Slave_V1       at 1 range 1 .. 1;
19550    Slave_V2       at 1 range 2 .. 2;
19551    Slave_V3       at 1 range 3 .. 3;
19552    Slave_V4       at 1 range 4 .. 4;
19553    Slave_V5       at 1 range 5 .. 5;
19554    Slave_V6       at 1 range 6 .. 6;
19555    Slave_V7       at 1 range 7 .. 7;
19556 end record;
19557 @end example
19559 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
19560 field.  The storage place attributes are obtained by normalizing the
19561 values given so that the @code{First_Bit} value is less than 8.  After
19562 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
19563 we specified in the other case.
19565 Now one might expect that the @code{Bit_Order} attribute might affect
19566 bit numbering within the entire record component (two bytes in this
19567 case, thus affecting which byte fields end up in), but that is not
19568 the way this feature is defined, it only affects numbering of bits,
19569 not which byte they end up in.
19571 Consequently it never makes sense to specify a starting bit number
19572 greater than 7 (for a byte addressable field) if an attribute
19573 definition for @code{Bit_Order} has been given, and indeed it
19574 may be actively confusing to specify such a value, so the compiler
19575 generates a warning for such usage.
19577 If you do need to control byte ordering then appropriate conditional
19578 values must be used.  If in our example, the slave byte came first on
19579 some machines we might write:
19581 @example
19582 Master_Byte_First constant Boolean := ...;
19584 Master_Byte : constant Natural :=
19585                 1 - Boolean'Pos (Master_Byte_First);
19586 Slave_Byte  : constant Natural :=
19587                 Boolean'Pos (Master_Byte_First);
19589 for Data'Bit_Order use High_Order_First;
19590 for Data use record
19591    Master_Control at Master_Byte range 0 .. 0;
19592    Master_V1      at Master_Byte range 1 .. 1;
19593    Master_V2      at Master_Byte range 2 .. 2;
19594    Master_V3      at Master_Byte range 3 .. 3;
19595    Master_V4      at Master_Byte range 4 .. 4;
19596    Master_V5      at Master_Byte range 5 .. 5;
19597    Master_V6      at Master_Byte range 6 .. 6;
19598    Master_V7      at Master_Byte range 7 .. 7;
19599    Slave_Control  at Slave_Byte  range 0 .. 0;
19600    Slave_V1       at Slave_Byte  range 1 .. 1;
19601    Slave_V2       at Slave_Byte  range 2 .. 2;
19602    Slave_V3       at Slave_Byte  range 3 .. 3;
19603    Slave_V4       at Slave_Byte  range 4 .. 4;
19604    Slave_V5       at Slave_Byte  range 5 .. 5;
19605    Slave_V6       at Slave_Byte  range 6 .. 6;
19606    Slave_V7       at Slave_Byte  range 7 .. 7;
19607 end record;
19608 @end example
19610 Now to switch between machines, all that is necessary is
19611 to set the boolean constant @code{Master_Byte_First} in
19612 an appropriate manner.
19614 @node Pragma Pack for Arrays,Pragma Pack for Records,Effect of Bit_Order on Byte Ordering,Representation Clauses and Pragmas
19615 @anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{29a}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{29b}
19616 @section Pragma Pack for Arrays
19619 @geindex Pragma Pack (for arrays)
19621 Pragma @code{Pack} applied to an array has an effect that depends upon whether the
19622 component type is `packable'.  For a component type to be `packable', it must
19623 be one of the following cases:
19626 @itemize *
19628 @item 
19629 Any elementary type.
19631 @item 
19632 Any small packed array type with a static size.
19634 @item 
19635 Any small simple record type with a static size.
19636 @end itemize
19638 For all these cases, if the component subtype size is in the range
19639 1 through 63 on 32-bit targets, and 1 through 127 on 64-bit targets,
19640 then the effect of the pragma @code{Pack} is exactly as though a
19641 component size were specified giving the component subtype size.
19643 All other types are non-packable, they occupy an integral number of storage
19644 units and the only effect of pragma Pack is to remove alignment gaps.
19646 For example if we have:
19648 @example
19649 type r is range 0 .. 17;
19651 type ar is array (1 .. 8) of r;
19652 pragma Pack (ar);
19653 @end example
19655 Then the component size of @code{ar} will be set to 5 (i.e., to @code{r'size},
19656 and the size of the array @code{ar} will be exactly 40 bits).
19658 Note that in some cases this rather fierce approach to packing can produce
19659 unexpected effects.  For example, in Ada 95 and Ada 2005,
19660 subtype @code{Natural} typically has a size of 31, meaning that if you
19661 pack an array of @code{Natural}, you get 31-bit
19662 close packing, which saves a few bits, but results in far less efficient
19663 access.  Since many other Ada compilers will ignore such a packing request,
19664 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
19665 might not be what is intended.  You can easily remove this warning by
19666 using an explicit @code{Component_Size} setting instead, which never generates
19667 a warning, since the intention of the programmer is clear in this case.
19669 GNAT treats packed arrays in one of two ways.  If the size of the array is
19670 known at compile time and is at most 64 bits on 32-bit targets, and at most
19671 128 bits on 64-bit targets, then internally the array is represented as a
19672 single modular type, of exactly the appropriate number of bits.  If the
19673 length is greater than 64 bits on 32-bit targets, and greater than 128
19674 bits on 64-bit targets, or is not known at compile time, then the packed
19675 array is represented as an array of bytes, and its length is always a
19676 multiple of 8 bits.
19678 Note that to represent a packed array as a modular type, the alignment must
19679 be suitable for the modular type involved. For example, on typical machines
19680 a 32-bit packed array will be represented by a 32-bit modular integer with
19681 an alignment of four bytes. If you explicitly override the default alignment
19682 with an alignment clause that is too small, the modular representation
19683 cannot be used. For example, consider the following set of declarations:
19685 @example
19686 type R is range 1 .. 3;
19687 type S is array (1 .. 31) of R;
19688 for S'Component_Size use 2;
19689 for S'Size use 62;
19690 for S'Alignment use 1;
19691 @end example
19693 If the alignment clause were not present, then a 62-bit modular
19694 representation would be chosen (typically with an alignment of 4 or 8
19695 bytes depending on the target). But the default alignment is overridden
19696 with the explicit alignment clause. This means that the modular
19697 representation cannot be used, and instead the array of bytes
19698 representation must be used, meaning that the length must be a multiple
19699 of 8. Thus the above set of declarations will result in a diagnostic
19700 rejecting the size clause and noting that the minimum size allowed is 64.
19702 @geindex Pragma Pack (for type Natural)
19704 @geindex Pragma Pack warning
19706 One special case that is worth noting occurs when the base type of the
19707 component size is 8/16/32 and the subtype is one bit less. Notably this
19708 occurs with subtype @code{Natural}. Consider:
19710 @example
19711 type Arr is array (1 .. 32) of Natural;
19712 pragma Pack (Arr);
19713 @end example
19715 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
19716 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
19717 Ada 83 compilers did not attempt 31 bit packing.
19719 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
19720 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
19721 substantial unintended performance penalty when porting legacy Ada 83 code.
19722 To help prevent this, GNAT generates a warning in such cases. If you really
19723 want 31 bit packing in a case like this, you can set the component size
19724 explicitly:
19726 @example
19727 type Arr is array (1 .. 32) of Natural;
19728 for Arr'Component_Size use 31;
19729 @end example
19731 Here 31-bit packing is achieved as required, and no warning is generated,
19732 since in this case the programmer intention is clear.
19734 @node Pragma Pack for Records,Record Representation Clauses,Pragma Pack for Arrays,Representation Clauses and Pragmas
19735 @anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{29c}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{29d}
19736 @section Pragma Pack for Records
19739 @geindex Pragma Pack (for records)
19741 Pragma @code{Pack} applied to a record will pack the components to reduce
19742 wasted space from alignment gaps and by reducing the amount of space
19743 taken by components.  We distinguish between `packable' components and
19744 `non-packable' components.
19745 Components of the following types are considered packable:
19748 @itemize *
19750 @item 
19751 Components of an elementary type are packable unless they are aliased,
19752 independent or atomic.
19754 @item 
19755 Small packed arrays, where the size is statically known, are represented
19756 internally as modular integers, and so they are also packable.
19758 @item 
19759 Small simple records, where the size is statically known, are also packable.
19760 @end itemize
19762 For all these cases, if the @code{'Size} value is in the range 1 through 64 on
19763 32-bit targets, and 1 through 128 on 64-bit targets, the components occupy
19764 the exact number of bits corresponding to this value and are packed with no
19765 padding bits, i.e. they can start on an arbitrary bit boundary.
19767 All other types are non-packable, they occupy an integral number of storage
19768 units and the only effect of pragma @code{Pack} is to remove alignment gaps.
19770 For example, consider the record
19772 @example
19773 type Rb1 is array (1 .. 13) of Boolean;
19774 pragma Pack (Rb1);
19776 type Rb2 is array (1 .. 65) of Boolean;
19777 pragma Pack (Rb2);
19779 type AF is new Float with Atomic;
19781 type X2 is record
19782    L1 : Boolean;
19783    L2 : Duration;
19784    L3 : AF;
19785    L4 : Boolean;
19786    L5 : Rb1;
19787    L6 : Rb2;
19788 end record;
19789 pragma Pack (X2);
19790 @end example
19792 The representation for the record @code{X2} is as follows on 32-bit targets:
19794 @example
19795 for X2'Size use 224;
19796 for X2 use record
19797    L1 at  0 range  0 .. 0;
19798    L2 at  0 range  1 .. 64;
19799    L3 at 12 range  0 .. 31;
19800    L4 at 16 range  0 .. 0;
19801    L5 at 16 range  1 .. 13;
19802    L6 at 18 range  0 .. 71;
19803 end record;
19804 @end example
19806 Studying this example, we see that the packable fields @code{L1}
19807 and @code{L2} are of length equal to their sizes, and placed at
19808 specific bit boundaries (and not byte boundaries) to eliminate
19809 padding.  But @code{L3} is of a non-packable float type (because
19810 it is aliased), so it is on the next appropriate alignment boundary.
19812 The next two fields are fully packable, so @code{L4} and @code{L5} are
19813 minimally packed with no gaps.  However, type @code{Rb2} is a packed
19814 array that is longer than 64 bits, so it is itself non-packable on
19815 32-bit targets.  Thus the @code{L6} field is aligned to the next byte
19816 boundary, and takes an integral number of bytes, i.e., 72 bits.
19818 @node Record Representation Clauses,Handling of Records with Holes,Pragma Pack for Records,Representation Clauses and Pragmas
19819 @anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{29e}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{29f}
19820 @section Record Representation Clauses
19823 @geindex Record Representation Clause
19825 Record representation clauses may be given for all record types, including
19826 types obtained by record extension.  Component clauses are allowed for any
19827 static component.  The restrictions on component clauses depend on the type
19828 of the component.
19830 @geindex Component Clause
19832 For all components of an elementary type, the only restriction on component
19833 clauses is that the size must be at least the @code{'Size} value of the type
19834 (actually the Value_Size).  There are no restrictions due to alignment,
19835 and such components may freely cross storage boundaries.
19837 Packed arrays with a size up to and including 64 bits on 32-bit targets,
19838 and up to and including 128 bits on 64-bit targets, are represented
19839 internally using a modular type with the appropriate number of bits, and
19840 thus the same lack of restriction applies.  For example, if you declare:
19842 @example
19843 type R is array (1 .. 49) of Boolean;
19844 pragma Pack (R);
19845 for R'Size use 49;
19846 @end example
19848 then a component clause for a component of type @code{R} may start on any
19849 specified bit boundary, and may specify a value of 49 bits or greater.
19851 For packed bit arrays that are longer than 64 bits on 32-bit targets,
19852 and longer than 128 bits on 64-bit targets, there are two cases. If the
19853 component size is a power of 2 (1,2,4,8,16,32,64 bits), including the
19854 important case of single bits or boolean values, then there are no
19855 limitations on placement of such components, and they may start and
19856 end at arbitrary bit boundaries.
19858 If the component size is not a power of 2 (e.g., 3 or 5), then an array
19859 of this type must always be placed on on a storage unit (byte) boundary
19860 and occupy an integral number of storage units (bytes). Any component
19861 clause that does not meet this requirement will be rejected.
19863 Any aliased component, or component of an aliased type, must have its
19864 normal alignment and size. A component clause that does not meet this
19865 requirement will be rejected.
19867 The tag field of a tagged type always occupies an address sized field at
19868 the start of the record.  No component clause may attempt to overlay this
19869 tag. When a tagged type appears as a component, the tag field must have
19870 proper alignment
19872 In the case of a record extension @code{T1}, of a type @code{T}, no component
19873 clause applied to the type @code{T1} can specify a storage location that
19874 would overlap the first @code{T'Object_Size} bits of the record.
19876 For all other component types, including non-bit-packed arrays,
19877 the component can be placed at an arbitrary bit boundary,
19878 so for example, the following is permitted:
19880 @example
19881 type R is array (1 .. 10) of Boolean;
19882 for R'Size use 80;
19884 type Q is record
19885    G, H : Boolean;
19886    L, M : R;
19887 end record;
19889 for Q use record
19890    G at 0 range  0 ..   0;
19891    H at 0 range  1 ..   1;
19892    L at 0 range  2 ..  81;
19893    R at 0 range 82 .. 161;
19894 end record;
19895 @end example
19897 @node Handling of Records with Holes,Enumeration Clauses,Record Representation Clauses,Representation Clauses and Pragmas
19898 @anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{2a0}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{2a1}
19899 @section Handling of Records with Holes
19902 @geindex Handling of Records with Holes
19904 As a result of alignment considerations, records may contain “holes”
19905 or gaps which do not correspond to the data bits of any of the components.
19906 Record representation clauses can also result in holes in records.
19908 GNAT does not attempt to clear these holes, so in record objects,
19909 they should be considered to hold undefined rubbish. The generated
19910 equality routine just tests components so does not access these
19911 undefined bits, and assignment and copy operations may or may not
19912 preserve the contents of these holes (for assignments, the holes
19913 in the target will in practice contain either the bits that are
19914 present in the holes in the source, or the bits that were present
19915 in the target before the assignment).
19917 If it is necessary to ensure that holes in records have all zero
19918 bits, then record objects for which this initialization is desired
19919 should be explicitly set to all zero values using Unchecked_Conversion
19920 or address overlays. For example
19922 @example
19923 type HRec is record
19924    C : Character;
19925    I : Integer;
19926 end record;
19927 @end example
19929 On typical machines, integers need to be aligned on a four-byte
19930 boundary, resulting in three bytes of undefined rubbish following
19931 the 8-bit field for C. To ensure that the hole in a variable of
19932 type HRec is set to all zero bits,
19933 you could for example do:
19935 @example
19936 type Base is record
19937    Dummy1, Dummy2 : Integer := 0;
19938 end record;
19940 BaseVar : Base;
19941 RealVar : Hrec;
19942 for RealVar'Address use BaseVar'Address;
19943 @end example
19945 Now the 8-bytes of the value of RealVar start out containing all zero
19946 bits. A safer approach is to just define dummy fields, avoiding the
19947 holes, as in:
19949 @example
19950 type HRec is record
19951    C      : Character;
19952    Dummy1 : Short_Short_Integer := 0;
19953    Dummy2 : Short_Short_Integer := 0;
19954    Dummy3 : Short_Short_Integer := 0;
19955    I      : Integer;
19956 end record;
19957 @end example
19959 And to make absolutely sure that the intent of this is followed, you
19960 can use representation clauses:
19962 @example
19963 for Hrec use record
19964    C      at 0 range 0 .. 7;
19965    Dummy1 at 1 range 0 .. 7;
19966    Dummy2 at 2 range 0 .. 7;
19967    Dummy3 at 3 range 0 .. 7;
19968    I      at 4 range 0 .. 31;
19969 end record;
19970 for Hrec'Size use 64;
19971 @end example
19973 @node Enumeration Clauses,Address Clauses,Handling of Records with Holes,Representation Clauses and Pragmas
19974 @anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{2a2}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{2a3}
19975 @section Enumeration Clauses
19978 The only restriction on enumeration clauses is that the range of values
19979 must be representable.  For the signed case, if one or more of the
19980 representation values are negative, all values must be in the range:
19982 @example
19983 System.Min_Int .. System.Max_Int
19984 @end example
19986 For the unsigned case, where all values are nonnegative, the values must
19987 be in the range:
19989 @example
19990 0 .. System.Max_Binary_Modulus;
19991 @end example
19993 A `confirming' representation clause is one in which the values range
19994 from 0 in sequence, i.e., a clause that confirms the default representation
19995 for an enumeration type.
19996 Such a confirming representation
19997 is permitted by these rules, and is specially recognized by the compiler so
19998 that no extra overhead results from the use of such a clause.
20000 If an array has an index type which is an enumeration type to which an
20001 enumeration clause has been applied, then the array is stored in a compact
20002 manner.  Consider the declarations:
20004 @example
20005 type r is (A, B, C);
20006 for r use (A => 1, B => 5, C => 10);
20007 type t is array (r) of Character;
20008 @end example
20010 The array type t corresponds to a vector with exactly three elements and
20011 has a default size equal to @code{3*Character'Size}.  This ensures efficient
20012 use of space, but means that accesses to elements of the array will incur
20013 the overhead of converting representation values to the corresponding
20014 positional values, (i.e., the value delivered by the @code{Pos} attribute).
20016 @node Address Clauses,Use of Address Clauses for Memory-Mapped I/O,Enumeration Clauses,Representation Clauses and Pragmas
20017 @anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{2a4}@anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{2a5}
20018 @section Address Clauses
20021 @geindex Address Clause
20023 The reference manual allows a general restriction on representation clauses,
20024 as found in RM 13.1(22):
20026 @quotation
20028 “An implementation need not support representation
20029 items containing nonstatic expressions, except that
20030 an implementation should support a representation item
20031 for a given entity if each nonstatic expression in the
20032 representation item is a name that statically denotes
20033 a constant declared before the entity.”
20034 @end quotation
20036 In practice this is applicable only to address clauses, since this is the
20037 only case in which a nonstatic expression is permitted by the syntax.  As
20038 the AARM notes in sections 13.1 (22.a-22.h):
20040 @quotation
20042 22.a   Reason: This is to avoid the following sort of thing:
20044 22.b        X : Integer := F(…);
20045 Y : Address := G(…);
20046 for X’Address use Y;
20048 22.c   In the above, we have to evaluate the
20049 initialization expression for X before we
20050 know where to put the result.  This seems
20051 like an unreasonable implementation burden.
20053 22.d   The above code should instead be written
20054 like this:
20056 22.e        Y : constant Address := G(…);
20057 X : Integer := F(…);
20058 for X’Address use Y;
20060 22.f   This allows the expression ‘Y’ to be safely
20061 evaluated before X is created.
20063 22.g   The constant could be a formal parameter of mode in.
20065 22.h   An implementation can support other nonstatic
20066 expressions if it wants to.  Expressions of type
20067 Address are hardly ever static, but their value
20068 might be known at compile time anyway in many
20069 cases.
20070 @end quotation
20072 GNAT does indeed permit many additional cases of nonstatic expressions.  In
20073 particular, if the type involved is elementary there are no restrictions
20074 (since in this case, holding a temporary copy of the initialization value,
20075 if one is present, is inexpensive).  In addition, if there is no implicit or
20076 explicit initialization, then there are no restrictions.  GNAT will reject
20077 only the case where all three of these conditions hold:
20080 @itemize *
20082 @item 
20083 The type of the item is non-elementary (e.g., a record or array).
20085 @item 
20086 There is explicit or implicit initialization required for the object.
20087 Note that access values are always implicitly initialized.
20089 @item 
20090 The address value is nonstatic.  Here GNAT is more permissive than the
20091 RM, and allows the address value to be the address of a previously declared
20092 stand-alone variable, as long as it does not itself have an address clause.
20094 @example
20095 Anchor  : Some_Initialized_Type;
20096 Overlay : Some_Initialized_Type;
20097 for Overlay'Address use Anchor'Address;
20098 @end example
20100 However, the prefix of the address clause cannot be an array component, or
20101 a component of a discriminated record.
20102 @end itemize
20104 As noted above in section 22.h, address values are typically nonstatic.  In
20105 particular the To_Address function, even if applied to a literal value, is
20106 a nonstatic function call.  To avoid this minor annoyance, GNAT provides
20107 the implementation defined attribute ‘To_Address.  The following two
20108 expressions have identical values:
20110 @geindex Attribute
20112 @geindex To_Address
20114 @example
20115 To_Address (16#1234_0000#)
20116 System'To_Address (16#1234_0000#);
20117 @end example
20119 except that the second form is considered to be a static expression, and
20120 thus when used as an address clause value is always permitted.
20122 Additionally, GNAT treats as static an address clause that is an
20123 unchecked_conversion of a static integer value.  This simplifies the porting
20124 of legacy code, and provides a portable equivalent to the GNAT attribute
20125 @code{To_Address}.
20127 Another issue with address clauses is the interaction with alignment
20128 requirements.  When an address clause is given for an object, the address
20129 value must be consistent with the alignment of the object (which is usually
20130 the same as the alignment of the type of the object).  If an address clause
20131 is given that specifies an inappropriately aligned address value, then the
20132 program execution is erroneous.
20134 Since this source of erroneous behavior can have unfortunate effects on
20135 machines with strict alignment requirements, GNAT
20136 checks (at compile time if possible, generating a warning, or at execution
20137 time with a run-time check) that the alignment is appropriate.  If the
20138 run-time check fails, then @code{Program_Error} is raised.  This run-time
20139 check is suppressed if range checks are suppressed, or if the special GNAT
20140 check Alignment_Check is suppressed, or if
20141 @code{pragma Restrictions (No_Elaboration_Code)} is in effect. It is also
20142 suppressed by default on non-strict alignment machines (such as the x86).
20144 In some cases, GNAT does not support an address specification (using either
20145 form of aspect specification syntax) for the declaration of an object that has
20146 an indefinite nominal subtype. An object declaration has an indefinite
20147 nominal subtype if it takes its bounds (for an array type), discriminant
20148 values (for a discriminated type whose discriminants lack defaults), or tag
20149 (for a class-wide type) from its initial value, as in
20151 @example
20152 X : String := Some_Function_Call;
20153 -- String has no constraint, so bounds for X come from function call
20154 @end example
20156 This restriction does not apply if the size of the object’s initial value is
20157 known at compile time and the type of the object is not class-wide.
20159 @geindex Export
20161 An address clause cannot be given for an exported object.  More
20162 understandably the real restriction is that objects with an address
20163 clause cannot be exported.  This is because such variables are not
20164 defined by the Ada program, so there is no external object to export.
20166 @geindex Import
20168 It is permissible to give an address clause and a pragma Import for the
20169 same object.  In this case, the variable is not really defined by the
20170 Ada program, so there is no external symbol to be linked.  The link name
20171 and the external name are ignored in this case.  The reason that we allow this
20172 combination is that it provides a useful idiom to avoid unwanted
20173 initializations on objects with address clauses.
20175 When an address clause is given for an object that has implicit or
20176 explicit initialization, then by default initialization takes place.  This
20177 means that the effect of the object declaration is to overwrite the
20178 memory at the specified address.  This is almost always not what the
20179 programmer wants, so GNAT will output a warning:
20181 @example
20182 with System;
20183 package G is
20184    type R is record
20185       M : Integer := 0;
20186    end record;
20188    Ext : R;
20189    for Ext'Address use System'To_Address (16#1234_1234#);
20190        |
20191 >>> warning: implicit initialization of "Ext" may
20192     modify overlaid storage
20193 >>> warning: use pragma Import for "Ext" to suppress
20194     initialization (RM B(24))
20196 end G;
20197 @end example
20199 As indicated by the warning message, the solution is to use a (dummy) pragma
20200 Import to suppress this initialization.  The pragma tell the compiler that the
20201 object is declared and initialized elsewhere.  The following package compiles
20202 without warnings (and the initialization is suppressed):
20204 @example
20205 with System;
20206 package G is
20207    type R is record
20208       M : Integer := 0;
20209    end record;
20211    Ext : R;
20212    for Ext'Address use System'To_Address (16#1234_1234#);
20213    pragma Import (Ada, Ext);
20214 end G;
20215 @end example
20217 A final issue with address clauses involves their use for overlaying
20218 variables, as in the following example:
20220 @geindex Overlaying of objects
20222 @example
20223 A : Integer;
20224 B : Integer;
20225 for B'Address use A'Address;
20226 @end example
20228 or alternatively, using the form recommended by the RM:
20230 @example
20231 A    : Integer;
20232 Addr : constant Address := A'Address;
20233 B    : Integer;
20234 for B'Address use Addr;
20235 @end example
20237 In both of these cases, @code{A} and @code{B} become aliased to one another
20238 via the address clause. This use of address clauses to overlay
20239 variables, achieving an effect similar to unchecked conversion
20240 was erroneous in Ada 83, but in Ada 95 and Ada 2005
20241 the effect is implementation defined. Furthermore, the
20242 Ada RM specifically recommends that in a situation
20243 like this, @code{B} should be subject to the following
20244 implementation advice (RM 13.3(19)):
20246 @quotation
20248 “19  If the Address of an object is specified, or it is imported
20249 or exported, then the implementation should not perform
20250 optimizations based on assumptions of no aliases.”
20251 @end quotation
20253 GNAT follows this recommendation, and goes further by also applying
20254 this recommendation to the overlaid variable (@code{A} in the above example)
20255 in this case. This means that the overlay works “as expected”, in that
20256 a modification to one of the variables will affect the value of the other.
20258 More generally, GNAT interprets this recommendation conservatively for
20259 address clauses: in the cases other than overlays, it considers that the
20260 object is effectively subject to pragma @code{Volatile} and implements the
20261 associated semantics.
20263 Note that when address clause overlays are used in this way, there is an
20264 issue of unintentional initialization, as shown by this example:
20266 @example
20267 package Overwrite_Record is
20268    type R is record
20269       A : Character := 'C';
20270       B : Character := 'A';
20271    end record;
20272    X : Short_Integer := 3;
20273    Y : R;
20274    for Y'Address use X'Address;
20275        |
20276 >>> warning: default initialization of "Y" may
20277     modify "X", use pragma Import for "Y" to
20278     suppress initialization (RM B.1(24))
20280 end Overwrite_Record;
20281 @end example
20283 Here the default initialization of @code{Y} will clobber the value
20284 of @code{X}, which justifies the warning. The warning notes that
20285 this effect can be eliminated by adding a @code{pragma Import}
20286 which suppresses the initialization:
20288 @example
20289 package Overwrite_Record is
20290    type R is record
20291       A : Character := 'C';
20292       B : Character := 'A';
20293    end record;
20294    X : Short_Integer := 3;
20295    Y : R;
20296    for Y'Address use X'Address;
20297    pragma Import (Ada, Y);
20298 end Overwrite_Record;
20299 @end example
20301 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
20302 be initialized when they would not otherwise have been in the absence
20303 of the use of this pragma. This may cause an overlay to have this
20304 unintended clobbering effect. The compiler avoids this for scalar
20305 types, but not for composite objects (where in general the effect
20306 of @code{Initialize_Scalars} is part of the initialization routine
20307 for the composite object):
20309 @example
20310 pragma Initialize_Scalars;
20311 with Ada.Text_IO;  use Ada.Text_IO;
20312 procedure Overwrite_Array is
20313    type Arr is array (1 .. 5) of Integer;
20314    X : Arr := (others => 1);
20315    A : Arr;
20316    for A'Address use X'Address;
20317        |
20318 >>> warning: default initialization of "A" may
20319     modify "X", use pragma Import for "A" to
20320     suppress initialization (RM B.1(24))
20322 begin
20323    if X /= Arr'(others => 1) then
20324       Put_Line ("X was clobbered");
20325    else
20326       Put_Line ("X was not clobbered");
20327    end if;
20328 end Overwrite_Array;
20329 @end example
20331 The above program generates the warning as shown, and at execution
20332 time, prints @code{X was clobbered}. If the @code{pragma Import} is
20333 added as suggested:
20335 @example
20336 pragma Initialize_Scalars;
20337 with Ada.Text_IO;  use Ada.Text_IO;
20338 procedure Overwrite_Array is
20339    type Arr is array (1 .. 5) of Integer;
20340    X : Arr := (others => 1);
20341    A : Arr;
20342    for A'Address use X'Address;
20343    pragma Import (Ada, A);
20344 begin
20345    if X /= Arr'(others => 1) then
20346       Put_Line ("X was clobbered");
20347    else
20348       Put_Line ("X was not clobbered");
20349    end if;
20350 end Overwrite_Array;
20351 @end example
20353 then the program compiles without the warning and when run will generate
20354 the output @code{X was not clobbered}.
20356 @node Use of Address Clauses for Memory-Mapped I/O,Effect of Convention on Representation,Address Clauses,Representation Clauses and Pragmas
20357 @anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{2a6}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{2a7}
20358 @section Use of Address Clauses for Memory-Mapped I/O
20361 @geindex Memory-mapped I/O
20363 A common pattern is to use an address clause to map an atomic variable to
20364 a location in memory that corresponds to a memory-mapped I/O operation or
20365 operations, for example:
20367 @example
20368 type Mem_Word is record
20369    A,B,C,D : Byte;
20370 end record;
20371 pragma Atomic (Mem_Word);
20372 for Mem_Word_Size use 32;
20374 Mem : Mem_Word;
20375 for Mem'Address use some-address;
20377 Temp := Mem;
20378 Temp.A := 32;
20379 Mem := Temp;
20380 @end example
20382 For a full access (reference or modification) of the variable (Mem) in this
20383 case, as in the above examples, GNAT guarantees that the entire atomic word
20384 will be accessed, in accordance with the RM C.6(15) clause.
20386 A problem arises with a component access such as:
20388 @example
20389 Mem.A := 32;
20390 @end example
20392 Note that the component A is not declared as atomic. This means that it is
20393 not clear what this assignment means. It could correspond to full word read
20394 and write as given in the first example, or on architectures that supported
20395 such an operation it might be a single byte store instruction. The RM does
20396 not have anything to say in this situation, and GNAT does not make any
20397 guarantee. The code generated may vary from target to target. GNAT will issue
20398 a warning in such a case:
20400 @example
20401 Mem.A := 32;
20403 >>> warning: access to non-atomic component of atomic array,
20404     may cause unexpected accesses to atomic object
20405 @end example
20407 It is best to be explicit in this situation, by either declaring the
20408 components to be atomic if you want the byte store, or explicitly writing
20409 the full word access sequence if that is what the hardware requires.
20410 Alternatively, if the full word access sequence is required, GNAT also
20411 provides the pragma @code{Volatile_Full_Access} which can be used in lieu of
20412 pragma @code{Atomic} and will give the additional guarantee.
20414 @node Effect of Convention on Representation,Conventions and Anonymous Access Types,Use of Address Clauses for Memory-Mapped I/O,Representation Clauses and Pragmas
20415 @anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{2a8}@anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{2a9}
20416 @section Effect of Convention on Representation
20419 @geindex Convention
20420 @geindex effect on representation
20422 Normally the specification of a foreign language convention for a type or
20423 an object has no effect on the chosen representation.  In particular, the
20424 representation chosen for data in GNAT generally meets the standard system
20425 conventions, and for example records are laid out in a manner that is
20426 consistent with C.  This means that specifying convention C (for example)
20427 has no effect.
20429 There are four exceptions to this general rule:
20432 @itemize *
20434 @item 
20435 `Convention Fortran and array subtypes'.
20437 If pragma Convention Fortran is specified for an array subtype, then in
20438 accordance with the implementation advice in section 3.6.2(11) of the
20439 Ada Reference Manual, the array will be stored in a Fortran-compatible
20440 column-major manner, instead of the normal default row-major order.
20442 @item 
20443 `Convention C and enumeration types'
20445 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
20446 to accommodate all values of the type.  For example, for the enumeration
20447 type declared by:
20449 @example
20450 type Color is (Red, Green, Blue);
20451 @end example
20453 8 bits is sufficient to store all values of the type, so by default, objects
20454 of type @code{Color} will be represented using 8 bits.  However, normal C
20455 convention is to use 32 bits for all enum values in C, since enum values
20456 are essentially of type int.  If pragma @code{Convention C} is specified for an
20457 Ada enumeration type, then the size is modified as necessary (usually to
20458 32 bits) to be consistent with the C convention for enum values.
20460 Note that this treatment applies only to types. If Convention C is given for
20461 an enumeration object, where the enumeration type is not Convention C, then
20462 Object_Size bits are allocated. For example, for a normal enumeration type,
20463 with less than 256 elements, only 8 bits will be allocated for the object.
20464 Since this may be a surprise in terms of what C expects, GNAT will issue a
20465 warning in this situation. The warning can be suppressed by giving an explicit
20466 size clause specifying the desired size.
20468 @item 
20469 `Convention C/Fortran and Boolean types'
20471 In C, the usual convention for boolean values, that is values used for
20472 conditions, is that zero represents false, and nonzero values represent
20473 true.  In Ada, the normal convention is that two specific values, typically
20474 0/1, are used to represent false/true respectively.
20476 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
20477 value represents true).
20479 To accommodate the Fortran and C conventions, if a pragma Convention specifies
20480 C or Fortran convention for a derived Boolean, as in the following example:
20482 @example
20483 type C_Switch is new Boolean;
20484 pragma Convention (C, C_Switch);
20485 @end example
20487 then the GNAT generated code will treat any nonzero value as true.  For truth
20488 values generated by GNAT, the conventional value 1 will be used for True, but
20489 when one of these values is read, any nonzero value is treated as True.
20490 @end itemize
20492 @node Conventions and Anonymous Access Types,Determining the Representations chosen by GNAT,Effect of Convention on Representation,Representation Clauses and Pragmas
20493 @anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{2aa}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{2ab}
20494 @section Conventions and Anonymous Access Types
20497 @geindex Anonymous access types
20499 @geindex Convention for anonymous access types
20501 The RM is not entirely clear on convention handling in a number of cases,
20502 and in particular, it is not clear on the convention to be given to
20503 anonymous access types in general, and in particular what is to be
20504 done for the case of anonymous access-to-subprogram.
20506 In GNAT, we decide that if an explicit Convention is applied
20507 to an object or component, and its type is such an anonymous type,
20508 then the convention will apply to this anonymous type as well. This
20509 seems to make sense since it is anomolous in any case to have a
20510 different convention for an object and its type, and there is clearly
20511 no way to explicitly specify a convention for an anonymous type, since
20512 it doesn’t have a name to specify!
20514 Furthermore, we decide that if a convention is applied to a record type,
20515 then this convention is inherited by any of its components that are of an
20516 anonymous access type which do not have an explicitly specified convention.
20518 The following program shows these conventions in action:
20520 @example
20521 package ConvComp is
20522    type Foo is range 1 .. 10;
20523    type T1 is record
20524       A : access function (X : Foo) return Integer;
20525       B : Integer;
20526    end record;
20527    pragma Convention (C, T1);
20529    type T2 is record
20530       A : access function (X : Foo) return Integer;
20531       pragma Convention  (C, A);
20532       B : Integer;
20533    end record;
20534    pragma Convention (COBOL, T2);
20536    type T3 is record
20537       A : access function (X : Foo) return Integer;
20538       pragma Convention  (COBOL, A);
20539       B : Integer;
20540    end record;
20541    pragma Convention (C, T3);
20543    type T4 is record
20544       A : access function (X : Foo) return Integer;
20545       B : Integer;
20546    end record;
20547    pragma Convention (COBOL, T4);
20549    function F (X : Foo) return Integer;
20550    pragma Convention (C, F);
20552    function F (X : Foo) return Integer is (13);
20554    TV1 : T1 := (F'Access, 12);  -- OK
20555    TV2 : T2 := (F'Access, 13);  -- OK
20557    TV3 : T3 := (F'Access, 13);  -- ERROR
20558                 |
20559 >>> subprogram "F" has wrong convention
20560 >>> does not match access to subprogram declared at line 17
20561      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
20562                 |
20563 >>> subprogram "F" has wrong convention
20564 >>> does not match access to subprogram declared at line 24
20565      39. end ConvComp;
20566 @end example
20568 @node Determining the Representations chosen by GNAT,,Conventions and Anonymous Access Types,Representation Clauses and Pragmas
20569 @anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{2ac}@anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{2ad}
20570 @section Determining the Representations chosen by GNAT
20573 @geindex Representation
20574 @geindex determination of
20576 @geindex -gnatR (gcc)
20578 Although the descriptions in this section are intended to be complete, it is
20579 often easier to simply experiment to see what GNAT accepts and what the
20580 effect is on the layout of types and objects.
20582 As required by the Ada RM, if a representation clause is not accepted, then
20583 it must be rejected as illegal by the compiler.  However, when a
20584 representation clause or pragma is accepted, there can still be questions
20585 of what the compiler actually does.  For example, if a partial record
20586 representation clause specifies the location of some components and not
20587 others, then where are the non-specified components placed? Or if pragma
20588 @code{Pack} is used on a record, then exactly where are the resulting
20589 fields placed? The section on pragma @code{Pack} in this chapter can be
20590 used to answer the second question, but it is often easier to just see
20591 what the compiler does.
20593 For this purpose, GNAT provides the option `-gnatR'.  If you compile
20594 with this option, then the compiler will output information on the actual
20595 representations chosen, in a format similar to source representation
20596 clauses.  For example, if we compile the package:
20598 @example
20599 package q is
20600    type r (x : boolean) is tagged record
20601       case x is
20602          when True => S : String (1 .. 100);
20603          when False => null;
20604       end case;
20605    end record;
20607    type r2 is new r (false) with record
20608       y2 : integer;
20609    end record;
20611    for r2 use record
20612       y2 at 16 range 0 .. 31;
20613    end record;
20615    type x is record
20616       y : character;
20617    end record;
20619    type x1 is array (1 .. 10) of x;
20620    for x1'component_size use 11;
20622    type ia is access integer;
20624    type Rb1 is array (1 .. 13) of Boolean;
20625    pragma Pack (rb1);
20627    type Rb2 is array (1 .. 65) of Boolean;
20628    pragma Pack (rb2);
20630    type x2 is record
20631       l1 : Boolean;
20632       l2 : Duration;
20633       l3 : Float;
20634       l4 : Boolean;
20635       l5 : Rb1;
20636       l6 : Rb2;
20637    end record;
20638    pragma Pack (x2);
20639 end q;
20640 @end example
20642 using the switch `-gnatR' we obtain the following output:
20644 @example
20645 Representation information for unit q
20646 -------------------------------------
20648 for r'Size use ??;
20649 for r'Alignment use 4;
20650 for r use record
20651    x    at 4 range  0 .. 7;
20652    _tag at 0 range  0 .. 31;
20653    s    at 5 range  0 .. 799;
20654 end record;
20656 for r2'Size use 160;
20657 for r2'Alignment use 4;
20658 for r2 use record
20659    x       at  4 range  0 .. 7;
20660    _tag    at  0 range  0 .. 31;
20661    _parent at  0 range  0 .. 63;
20662    y2      at 16 range  0 .. 31;
20663 end record;
20665 for x'Size use 8;
20666 for x'Alignment use 1;
20667 for x use record
20668    y at 0 range  0 .. 7;
20669 end record;
20671 for x1'Size use 112;
20672 for x1'Alignment use 1;
20673 for x1'Component_Size use 11;
20675 for rb1'Size use 13;
20676 for rb1'Alignment use 2;
20677 for rb1'Component_Size use 1;
20679 for rb2'Size use 72;
20680 for rb2'Alignment use 1;
20681 for rb2'Component_Size use 1;
20683 for x2'Size use 224;
20684 for x2'Alignment use 4;
20685 for x2 use record
20686    l1 at  0 range  0 .. 0;
20687    l2 at  0 range  1 .. 64;
20688    l3 at 12 range  0 .. 31;
20689    l4 at 16 range  0 .. 0;
20690    l5 at 16 range  1 .. 13;
20691    l6 at 18 range  0 .. 71;
20692 end record;
20693 @end example
20695 The Size values are actually the Object_Size, i.e., the default size that
20696 will be allocated for objects of the type.
20697 The @code{??} size for type r indicates that we have a variant record, and the
20698 actual size of objects will depend on the discriminant value.
20700 The Alignment values show the actual alignment chosen by the compiler
20701 for each record or array type.
20703 The record representation clause for type r shows where all fields
20704 are placed, including the compiler generated tag field (whose location
20705 cannot be controlled by the programmer).
20707 The record representation clause for the type extension r2 shows all the
20708 fields present, including the parent field, which is a copy of the fields
20709 of the parent type of r2, i.e., r1.
20711 The component size and size clauses for types rb1 and rb2 show
20712 the exact effect of pragma @code{Pack} on these arrays, and the record
20713 representation clause for type x2 shows how pragma @cite{Pack} affects
20714 this record type.
20716 In some cases, it may be useful to cut and paste the representation clauses
20717 generated by the compiler into the original source to fix and guarantee
20718 the actual representation to be used.
20720 @node Standard Library Routines,The Implementation of Standard I/O,Representation Clauses and Pragmas,Top
20721 @anchor{gnat_rm/standard_library_routines doc}@anchor{2ae}@anchor{gnat_rm/standard_library_routines id1}@anchor{2af}@anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e}
20722 @chapter Standard Library Routines
20725 The Ada Reference Manual contains in Annex A a full description of an
20726 extensive set of standard library routines that can be used in any Ada
20727 program, and which must be provided by all Ada compilers.  They are
20728 analogous to the standard C library used by C programs.
20730 GNAT implements all of the facilities described in annex A, and for most
20731 purposes the description in the Ada Reference Manual, or appropriate Ada
20732 text book, will be sufficient for making use of these facilities.
20734 In the case of the input-output facilities,
20735 @ref{f,,The Implementation of Standard I/O},
20736 gives details on exactly how GNAT interfaces to the
20737 file system.  For the remaining packages, the Ada Reference Manual
20738 should be sufficient.  The following is a list of the packages included,
20739 together with a brief description of the functionality that is provided.
20741 For completeness, references are included to other predefined library
20742 routines defined in other sections of the Ada Reference Manual (these are
20743 cross-indexed from Annex A). For further details see the relevant
20744 package declarations in the run-time library. In particular, a few units
20745 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
20746 and in this case the package declaration contains comments explaining why
20747 the unit is not implemented.
20750 @table @asis
20752 @item @code{Ada} `(A.2)'
20754 This is a parent package for all the standard library packages.  It is
20755 usually included implicitly in your program, and itself contains no
20756 useful data or routines.
20758 @item @code{Ada.Assertions} `(11.4.2)'
20760 @code{Assertions} provides the @code{Assert} subprograms, and also
20761 the declaration of the @code{Assertion_Error} exception.
20763 @item @code{Ada.Asynchronous_Task_Control} `(D.11)'
20765 @code{Asynchronous_Task_Control} provides low level facilities for task
20766 synchronization. It is typically not implemented. See package spec for details.
20768 @item @code{Ada.Calendar} `(9.6)'
20770 @code{Calendar} provides time of day access, and routines for
20771 manipulating times and durations.
20773 @item @code{Ada.Calendar.Arithmetic} `(9.6.1)'
20775 This package provides additional arithmetic
20776 operations for @code{Calendar}.
20778 @item @code{Ada.Calendar.Formatting} `(9.6.1)'
20780 This package provides formatting operations for @code{Calendar}.
20782 @item @code{Ada.Calendar.Time_Zones} `(9.6.1)'
20784 This package provides additional @code{Calendar} facilities
20785 for handling time zones.
20787 @item @code{Ada.Characters} `(A.3.1)'
20789 This is a dummy parent package that contains no useful entities
20791 @item @code{Ada.Characters.Conversions} `(A.3.2)'
20793 This package provides character conversion functions.
20795 @item @code{Ada.Characters.Handling} `(A.3.2)'
20797 This package provides some basic character handling capabilities,
20798 including classification functions for classes of characters (e.g., test
20799 for letters, or digits).
20801 @item @code{Ada.Characters.Latin_1} `(A.3.3)'
20803 This package includes a complete set of definitions of the characters
20804 that appear in type CHARACTER.  It is useful for writing programs that
20805 will run in international environments.  For example, if you want an
20806 upper case E with an acute accent in a string, it is often better to use
20807 the definition of @code{UC_E_Acute} in this package.  Then your program
20808 will print in an understandable manner even if your environment does not
20809 support these extended characters.
20811 @item @code{Ada.Command_Line} `(A.15)'
20813 This package provides access to the command line parameters and the name
20814 of the current program (analogous to the use of @code{argc} and @code{argv}
20815 in C), and also allows the exit status for the program to be set in a
20816 system-independent manner.
20818 @item @code{Ada.Complex_Text_IO} `(G.1.3)'
20820 This package provides text input and output of complex numbers.
20822 @item @code{Ada.Containers} `(A.18.1)'
20824 A top level package providing a few basic definitions used by all the
20825 following specific child packages that provide specific kinds of
20826 containers.
20827 @end table
20829 @code{Ada.Containers.Bounded_Priority_Queues} `(A.18.31)'
20831 @code{Ada.Containers.Bounded_Synchronized_Queues} `(A.18.29)'
20833 @code{Ada.Containers.Doubly_Linked_Lists} `(A.18.3)'
20835 @code{Ada.Containers.Generic_Array_Sort} `(A.18.26)'
20837 @code{Ada.Containers.Generic_Constrained_Array_Sort} `(A.18.26)'
20839 @code{Ada.Containers.Generic_Sort} `(A.18.26)'
20841 @code{Ada.Containers.Hashed_Maps} `(A.18.5)'
20843 @code{Ada.Containers.Hashed_Sets} `(A.18.8)'
20845 @code{Ada.Containers.Indefinite_Doubly_Linked_Lists} `(A.18.12)'
20847 @code{Ada.Containers.Indefinite_Hashed_Maps} `(A.18.13)'
20849 @code{Ada.Containers.Indefinite_Hashed_Sets} `(A.18.15)'
20851 @code{Ada.Containers.Indefinite_Holders} `(A.18.18)'
20853 @code{Ada.Containers.Indefinite_Multiway_Trees} `(A.18.17)'
20855 @code{Ada.Containers.Indefinite_Ordered_Maps} `(A.18.14)'
20857 @code{Ada.Containers.Indefinite_Ordered_Sets} `(A.18.16)'
20859 @code{Ada.Containers.Indefinite_Vectors} `(A.18.11)'
20861 @code{Ada.Containers.Multiway_Trees} `(A.18.10)'
20863 @code{Ada.Containers.Ordered_Maps} `(A.18.6)'
20865 @code{Ada.Containers.Ordered_Sets} `(A.18.9)'
20867 @code{Ada.Containers.Synchronized_Queue_Interfaces} `(A.18.27)'
20869 @code{Ada.Containers.Unbounded_Priority_Queues} `(A.18.30)'
20871 @code{Ada.Containers.Unbounded_Synchronized_Queues} `(A.18.28)'
20873 @code{Ada.Containers.Vectors} `(A.18.2)'
20876 @table @asis
20878 @item @code{Ada.Directories} `(A.16)'
20880 This package provides operations on directories.
20882 @item @code{Ada.Directories.Hierarchical_File_Names} `(A.16.1)'
20884 This package provides additional directory operations handling
20885 hierarchical file names.
20887 @item @code{Ada.Directories.Information} `(A.16)'
20889 This is an implementation defined package for additional directory
20890 operations, which is not implemented in GNAT.
20892 @item @code{Ada.Decimal} `(F.2)'
20894 This package provides constants describing the range of decimal numbers
20895 implemented, and also a decimal divide routine (analogous to the COBOL
20896 verb DIVIDE … GIVING … REMAINDER …)
20898 @item @code{Ada.Direct_IO} `(A.8.4)'
20900 This package provides input-output using a model of a set of records of
20901 fixed-length, containing an arbitrary definite Ada type, indexed by an
20902 integer record number.
20904 @item @code{Ada.Dispatching} `(D.2.1)'
20906 A parent package containing definitions for task dispatching operations.
20908 @item @code{Ada.Dispatching.EDF} `(D.2.6)'
20910 Not implemented in GNAT.
20912 @item @code{Ada.Dispatching.Non_Preemptive} `(D.2.4)'
20914 Not implemented in GNAT.
20916 @item @code{Ada.Dispatching.Round_Robin} `(D.2.5)'
20918 Not implemented in GNAT.
20920 @item @code{Ada.Dynamic_Priorities} `(D.5)'
20922 This package allows the priorities of a task to be adjusted dynamically
20923 as the task is running.
20925 @item @code{Ada.Environment_Variables} `(A.17)'
20927 This package provides facilities for accessing environment variables.
20929 @item @code{Ada.Exceptions} `(11.4.1)'
20931 This package provides additional information on exceptions, and also
20932 contains facilities for treating exceptions as data objects, and raising
20933 exceptions with associated messages.
20935 @item @code{Ada.Execution_Time} `(D.14)'
20937 This package provides CPU clock functionalities. It is not implemented on
20938 all targets (see package spec for details).
20940 @item @code{Ada.Execution_Time.Group_Budgets} `(D.14.2)'
20942 Not implemented in GNAT.
20944 @item @code{Ada.Execution_Time.Timers} `(D.14.1)’'
20946 Not implemented in GNAT.
20948 @item @code{Ada.Finalization} `(7.6)'
20950 This package contains the declarations and subprograms to support the
20951 use of controlled types, providing for automatic initialization and
20952 finalization (analogous to the constructors and destructors of C++).
20954 @item @code{Ada.Float_Text_IO} `(A.10.9)'
20956 A library level instantiation of Text_IO.Float_IO for type Float.
20958 @item @code{Ada.Float_Wide_Text_IO} `(A.10.9)'
20960 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
20962 @item @code{Ada.Float_Wide_Wide_Text_IO} `(A.10.9)'
20964 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
20966 @item @code{Ada.Integer_Text_IO} `(A.10.9)'
20968 A library level instantiation of Text_IO.Integer_IO for type Integer.
20970 @item @code{Ada.Integer_Wide_Text_IO} `(A.10.9)'
20972 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
20974 @item @code{Ada.Integer_Wide_Wide_Text_IO} `(A.10.9)'
20976 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
20978 @item @code{Ada.Interrupts} `(C.3.2)'
20980 This package provides facilities for interfacing to interrupts, which
20981 includes the set of signals or conditions that can be raised and
20982 recognized as interrupts.
20984 @item @code{Ada.Interrupts.Names} `(C.3.2)'
20986 This package provides the set of interrupt names (actually signal
20987 or condition names) that can be handled by GNAT.
20989 @item @code{Ada.IO_Exceptions} `(A.13)'
20991 This package defines the set of exceptions that can be raised by use of
20992 the standard IO packages.
20994 @item @code{Ada.Iterator_Interfaces} `(5.5.1)'
20996 This package provides a generic interface to generalized iterators.
20998 @item @code{Ada.Locales} `(A.19)'
21000 This package provides declarations providing information (Language
21001 and Country) about the current locale.
21003 @item @code{Ada.Numerics}
21005 This package contains some standard constants and exceptions used
21006 throughout the numerics packages.  Note that the constants pi and e are
21007 defined here, and it is better to use these definitions than rolling
21008 your own.
21010 @item @code{Ada.Numerics.Complex_Arrays} `(G.3.2)'
21012 Provides operations on arrays of complex numbers.
21014 @item @code{Ada.Numerics.Complex_Elementary_Functions}
21016 Provides the implementation of standard elementary functions (such as
21017 log and trigonometric functions) operating on complex numbers using the
21018 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
21019 created by the package @code{Numerics.Complex_Types}.
21021 @item @code{Ada.Numerics.Complex_Types}
21023 This is a predefined instantiation of
21024 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
21025 build the type @code{Complex} and @code{Imaginary}.
21027 @item @code{Ada.Numerics.Discrete_Random}
21029 This generic package provides a random number generator suitable for generating
21030 uniformly distributed values of a specified discrete subtype.
21032 @item @code{Ada.Numerics.Float_Random}
21034 This package provides a random number generator suitable for generating
21035 uniformly distributed floating point values in the unit interval.
21037 @item @code{Ada.Numerics.Generic_Complex_Elementary_Functions}
21039 This is a generic version of the package that provides the
21040 implementation of standard elementary functions (such as log and
21041 trigonometric functions) for an arbitrary complex type.
21043 The following predefined instantiations of this package are provided:
21046 @itemize *
21048 @item 
21049 @code{Short_Float}
21051 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
21053 @item 
21054 @code{Float}
21056 @code{Ada.Numerics.Complex_Elementary_Functions}
21058 @item 
21059 @code{Long_Float}
21061 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
21062 @end itemize
21064 @item @code{Ada.Numerics.Generic_Complex_Types}
21066 This is a generic package that allows the creation of complex types,
21067 with associated complex arithmetic operations.
21069 The following predefined instantiations of this package exist
21072 @itemize *
21074 @item 
21075 @code{Short_Float}
21077 @code{Ada.Numerics.Short_Complex_Complex_Types}
21079 @item 
21080 @code{Float}
21082 @code{Ada.Numerics.Complex_Complex_Types}
21084 @item 
21085 @code{Long_Float}
21087 @code{Ada.Numerics.Long_Complex_Complex_Types}
21088 @end itemize
21090 @item @code{Ada.Numerics.Generic_Elementary_Functions}
21092 This is a generic package that provides the implementation of standard
21093 elementary functions (such as log an trigonometric functions) for an
21094 arbitrary float type.
21096 The following predefined instantiations of this package exist
21099 @itemize *
21101 @item 
21102 @code{Short_Float}
21104 @code{Ada.Numerics.Short_Elementary_Functions}
21106 @item 
21107 @code{Float}
21109 @code{Ada.Numerics.Elementary_Functions}
21111 @item 
21112 @code{Long_Float}
21114 @code{Ada.Numerics.Long_Elementary_Functions}
21115 @end itemize
21117 @item @code{Ada.Numerics.Generic_Real_Arrays} `(G.3.1)'
21119 Generic operations on arrays of reals
21121 @item @code{Ada.Numerics.Real_Arrays} `(G.3.1)'
21123 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
21125 @item @code{Ada.Real_Time} `(D.8)'
21127 This package provides facilities similar to those of @code{Calendar}, but
21128 operating with a finer clock suitable for real time control. Note that
21129 annex D requires that there be no backward clock jumps, and GNAT generally
21130 guarantees this behavior, but of course if the external clock on which
21131 the GNAT runtime depends is deliberately reset by some external event,
21132 then such a backward jump may occur.
21134 @item @code{Ada.Real_Time.Timing_Events} `(D.15)'
21136 Not implemented in GNAT.
21138 @item @code{Ada.Sequential_IO} `(A.8.1)'
21140 This package provides input-output facilities for sequential files,
21141 which can contain a sequence of values of a single type, which can be
21142 any Ada type, including indefinite (unconstrained) types.
21144 @item @code{Ada.Storage_IO} `(A.9)'
21146 This package provides a facility for mapping arbitrary Ada types to and
21147 from a storage buffer.  It is primarily intended for the creation of new
21148 IO packages.
21150 @item @code{Ada.Streams} `(13.13.1)'
21152 This is a generic package that provides the basic support for the
21153 concept of streams as used by the stream attributes (@code{Input},
21154 @code{Output}, @code{Read} and @code{Write}).
21156 @item @code{Ada.Streams.Stream_IO} `(A.12.1)'
21158 This package is a specialization of the type @code{Streams} defined in
21159 package @code{Streams} together with a set of operations providing
21160 Stream_IO capability.  The Stream_IO model permits both random and
21161 sequential access to a file which can contain an arbitrary set of values
21162 of one or more Ada types.
21164 @item @code{Ada.Strings} `(A.4.1)'
21166 This package provides some basic constants used by the string handling
21167 packages.
21169 @item @code{Ada.Strings.Bounded} `(A.4.4)'
21171 This package provides facilities for handling variable length
21172 strings.  The bounded model requires a maximum length.  It is thus
21173 somewhat more limited than the unbounded model, but avoids the use of
21174 dynamic allocation or finalization.
21176 @item @code{Ada.Strings.Bounded.Equal_Case_Insensitive} `(A.4.10)'
21178 Provides case-insensitive comparisons of bounded strings
21180 @item @code{Ada.Strings.Bounded.Hash} `(A.4.9)'
21182 This package provides a generic hash function for bounded strings
21184 @item @code{Ada.Strings.Bounded.Hash_Case_Insensitive} `(A.4.9)'
21186 This package provides a generic hash function for bounded strings that
21187 converts the string to be hashed to lower case.
21189 @item @code{Ada.Strings.Bounded.Less_Case_Insensitive} `(A.4.10)'
21191 This package provides a comparison function for bounded strings that works
21192 in a case insensitive manner by converting to lower case before the comparison.
21194 @item @code{Ada.Strings.Fixed} `(A.4.3)'
21196 This package provides facilities for handling fixed length strings.
21198 @item @code{Ada.Strings.Fixed.Equal_Case_Insensitive} `(A.4.10)'
21200 This package provides an equality function for fixed strings that compares
21201 the strings after converting both to lower case.
21203 @item @code{Ada.Strings.Fixed.Hash_Case_Insensitive} `(A.4.9)'
21205 This package provides a case insensitive hash function for fixed strings that
21206 converts the string to lower case before computing the hash.
21208 @item @code{Ada.Strings.Fixed.Less_Case_Insensitive} `(A.4.10)'
21210 This package provides a comparison function for fixed strings that works
21211 in a case insensitive manner by converting to lower case before the comparison.
21213 @item @code{Ada.Strings.Hash} `(A.4.9)'
21215 This package provides a hash function for strings.
21217 @item @code{Ada.Strings.Hash_Case_Insensitive} `(A.4.9)'
21219 This package provides a hash function for strings that is case insensitive.
21220 The string is converted to lower case before computing the hash.
21222 @item @code{Ada.Strings.Less_Case_Insensitive} `(A.4.10)'
21224 This package provides a comparison function for\strings that works
21225 in a case insensitive manner by converting to lower case before the comparison.
21227 @item @code{Ada.Strings.Maps} `(A.4.2)'
21229 This package provides facilities for handling character mappings and
21230 arbitrarily defined subsets of characters.  For instance it is useful in
21231 defining specialized translation tables.
21233 @item @code{Ada.Strings.Maps.Constants} `(A.4.6)'
21235 This package provides a standard set of predefined mappings and
21236 predefined character sets.  For example, the standard upper to lower case
21237 conversion table is found in this package.  Note that upper to lower case
21238 conversion is non-trivial if you want to take the entire set of
21239 characters, including extended characters like E with an acute accent,
21240 into account.  You should use the mappings in this package (rather than
21241 adding 32 yourself) to do case mappings.
21243 @item @code{Ada.Strings.Unbounded} `(A.4.5)'
21245 This package provides facilities for handling variable length
21246 strings.  The unbounded model allows arbitrary length strings, but
21247 requires the use of dynamic allocation and finalization.
21249 @item @code{Ada.Strings.Unbounded.Equal_Case_Insensitive} `(A.4.10)'
21251 Provides case-insensitive comparisons of unbounded strings
21253 @item @code{Ada.Strings.Unbounded.Hash} `(A.4.9)'
21255 This package provides a generic hash function for unbounded strings
21257 @item @code{Ada.Strings.Unbounded.Hash_Case_Insensitive} `(A.4.9)'
21259 This package provides a generic hash function for unbounded strings that
21260 converts the string to be hashed to lower case.
21262 @item @code{Ada.Strings.Unbounded.Less_Case_Insensitive} `(A.4.10)'
21264 This package provides a comparison function for unbounded strings that works
21265 in a case insensitive manner by converting to lower case before the comparison.
21267 @item @code{Ada.Strings.UTF_Encoding} `(A.4.11)'
21269 This package provides basic definitions for dealing with UTF-encoded strings.
21271 @item @code{Ada.Strings.UTF_Encoding.Conversions} `(A.4.11)'
21273 This package provides conversion functions for UTF-encoded strings.
21274 @end table
21276 @code{Ada.Strings.UTF_Encoding.Strings} `(A.4.11)'
21278 @code{Ada.Strings.UTF_Encoding.Wide_Strings} `(A.4.11)'
21281 @table @asis
21283 @item @code{Ada.Strings.UTF_Encoding.Wide_Wide_Strings} `(A.4.11)'
21285 These packages provide facilities for handling UTF encodings for
21286 Strings, Wide_Strings and Wide_Wide_Strings.
21287 @end table
21289 @code{Ada.Strings.Wide_Bounded} `(A.4.7)'
21291 @code{Ada.Strings.Wide_Fixed} `(A.4.7)'
21293 @code{Ada.Strings.Wide_Maps} `(A.4.7)'
21296 @table @asis
21298 @item @code{Ada.Strings.Wide_Unbounded} `(A.4.7)'
21300 These packages provide analogous capabilities to the corresponding
21301 packages without @code{Wide_} in the name, but operate with the types
21302 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
21303 and @code{Character}. Versions of all the child packages are available.
21304 @end table
21306 @code{Ada.Strings.Wide_Wide_Bounded} `(A.4.7)'
21308 @code{Ada.Strings.Wide_Wide_Fixed} `(A.4.7)'
21310 @code{Ada.Strings.Wide_Wide_Maps} `(A.4.7)'
21313 @table @asis
21315 @item @code{Ada.Strings.Wide_Wide_Unbounded} `(A.4.7)'
21317 These packages provide analogous capabilities to the corresponding
21318 packages without @code{Wide_} in the name, but operate with the types
21319 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
21320 of @code{String} and @code{Character}.
21322 @item @code{Ada.Synchronous_Barriers} `(D.10.1)'
21324 This package provides facilities for synchronizing tasks at a low level
21325 with barriers.
21327 @item @code{Ada.Synchronous_Task_Control} `(D.10)'
21329 This package provides some standard facilities for controlling task
21330 communication in a synchronous manner.
21332 @item @code{Ada.Synchronous_Task_Control.EDF} `(D.10)'
21334 Not implemented in GNAT.
21336 @item @code{Ada.Tags}
21338 This package contains definitions for manipulation of the tags of tagged
21339 values.
21341 @item @code{Ada.Tags.Generic_Dispatching_Constructor} `(3.9)'
21343 This package provides a way of constructing tagged class-wide values given
21344 only the tag value.
21346 @item @code{Ada.Task_Attributes} `(C.7.2)'
21348 This package provides the capability of associating arbitrary
21349 task-specific data with separate tasks.
21351 @item @code{Ada.Task_Identification} `(C.7.1)'
21353 This package provides capabilities for task identification.
21355 @item @code{Ada.Task_Termination} `(C.7.3)'
21357 This package provides control over task termination.
21359 @item @code{Ada.Text_IO}
21361 This package provides basic text input-output capabilities for
21362 character, string and numeric data.  The subpackages of this
21363 package are listed next. Note that although these are defined
21364 as subpackages in the RM, they are actually transparently
21365 implemented as child packages in GNAT, meaning that they
21366 are only loaded if needed.
21368 @item @code{Ada.Text_IO.Decimal_IO}
21370 Provides input-output facilities for decimal fixed-point types
21372 @item @code{Ada.Text_IO.Enumeration_IO}
21374 Provides input-output facilities for enumeration types.
21376 @item @code{Ada.Text_IO.Fixed_IO}
21378 Provides input-output facilities for ordinary fixed-point types.
21380 @item @code{Ada.Text_IO.Float_IO}
21382 Provides input-output facilities for float types.  The following
21383 predefined instantiations of this generic package are available:
21386 @itemize *
21388 @item 
21389 @code{Short_Float}
21391 @code{Short_Float_Text_IO}
21393 @item 
21394 @code{Float}
21396 @code{Float_Text_IO}
21398 @item 
21399 @code{Long_Float}
21401 @code{Long_Float_Text_IO}
21402 @end itemize
21404 @item @code{Ada.Text_IO.Integer_IO}
21406 Provides input-output facilities for integer types.  The following
21407 predefined instantiations of this generic package are available:
21410 @itemize *
21412 @item 
21413 @code{Short_Short_Integer}
21415 @code{Ada.Short_Short_Integer_Text_IO}
21417 @item 
21418 @code{Short_Integer}
21420 @code{Ada.Short_Integer_Text_IO}
21422 @item 
21423 @code{Integer}
21425 @code{Ada.Integer_Text_IO}
21427 @item 
21428 @code{Long_Integer}
21430 @code{Ada.Long_Integer_Text_IO}
21432 @item 
21433 @code{Long_Long_Integer}
21435 @code{Ada.Long_Long_Integer_Text_IO}
21436 @end itemize
21438 @item @code{Ada.Text_IO.Modular_IO}
21440 Provides input-output facilities for modular (unsigned) types.
21442 @item @code{Ada.Text_IO.Bounded_IO (A.10.11)}
21444 Provides input-output facilities for bounded strings.
21446 @item @code{Ada.Text_IO.Complex_IO (G.1.3)}
21448 This package provides basic text input-output capabilities for complex
21449 data.
21451 @item @code{Ada.Text_IO.Editing (F.3.3)}
21453 This package contains routines for edited output, analogous to the use
21454 of pictures in COBOL.  The picture formats used by this package are a
21455 close copy of the facility in COBOL.
21457 @item @code{Ada.Text_IO.Text_Streams (A.12.2)}
21459 This package provides a facility that allows Text_IO files to be treated
21460 as streams, so that the stream attributes can be used for writing
21461 arbitrary data, including binary data, to Text_IO files.
21463 @item @code{Ada.Text_IO.Unbounded_IO (A.10.12)}
21465 This package provides input-output facilities for unbounded strings.
21467 @item @code{Ada.Unchecked_Conversion (13.9)}
21469 This generic package allows arbitrary conversion from one type to
21470 another of the same size, providing for breaking the type safety in
21471 special circumstances.
21473 If the types have the same Size (more accurately the same Value_Size),
21474 then the effect is simply to transfer the bits from the source to the
21475 target type without any modification.  This usage is well defined, and
21476 for simple types whose representation is typically the same across
21477 all implementations, gives a portable method of performing such
21478 conversions.
21480 If the types do not have the same size, then the result is implementation
21481 defined, and thus may be non-portable.  The following describes how GNAT
21482 handles such unchecked conversion cases.
21484 If the types are of different sizes, and are both discrete types, then
21485 the effect is of a normal type conversion without any constraint checking.
21486 In particular if the result type has a larger size, the result will be
21487 zero or sign extended.  If the result type has a smaller size, the result
21488 will be truncated by ignoring high order bits.
21490 If the types are of different sizes, and are not both discrete types,
21491 then the conversion works as though pointers were created to the source
21492 and target, and the pointer value is converted.  The effect is that bits
21493 are copied from successive low order storage units and bits of the source
21494 up to the length of the target type.
21496 A warning is issued if the lengths differ, since the effect in this
21497 case is implementation dependent, and the above behavior may not match
21498 that of some other compiler.
21500 A pointer to one type may be converted to a pointer to another type using
21501 unchecked conversion.  The only case in which the effect is undefined is
21502 when one or both pointers are pointers to unconstrained array types.  In
21503 this case, the bounds information may get incorrectly transferred, and in
21504 particular, GNAT uses double size pointers for such types, and it is
21505 meaningless to convert between such pointer types.  GNAT will issue a
21506 warning if the alignment of the target designated type is more strict
21507 than the alignment of the source designated type (since the result may
21508 be unaligned in this case).
21510 A pointer other than a pointer to an unconstrained array type may be
21511 converted to and from System.Address.  Such usage is common in Ada 83
21512 programs, but note that Ada.Address_To_Access_Conversions is the
21513 preferred method of performing such conversions in Ada 95 and Ada 2005.
21514 Neither
21515 unchecked conversion nor Ada.Address_To_Access_Conversions should be
21516 used in conjunction with pointers to unconstrained objects, since
21517 the bounds information cannot be handled correctly in this case.
21519 @item @code{Ada.Unchecked_Deallocation} `(13.11.2)'
21521 This generic package allows explicit freeing of storage previously
21522 allocated by use of an allocator.
21524 @item @code{Ada.Wide_Text_IO} `(A.11)'
21526 This package is similar to @code{Ada.Text_IO}, except that the external
21527 file supports wide character representations, and the internal types are
21528 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21529 and @code{String}. The corresponding set of nested packages and child
21530 packages are defined.
21532 @item @code{Ada.Wide_Wide_Text_IO} `(A.11)'
21534 This package is similar to @code{Ada.Text_IO}, except that the external
21535 file supports wide character representations, and the internal types are
21536 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21537 and @code{String}. The corresponding set of nested packages and child
21538 packages are defined.
21539 @end table
21541 For packages in Interfaces and System, all the RM defined packages are
21542 available in GNAT, see the Ada 2012 RM for full details.
21544 @node The Implementation of Standard I/O,The GNAT Library,Standard Library Routines,Top
21545 @anchor{gnat_rm/the_implementation_of_standard_i_o doc}@anchor{2b0}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{2b1}@anchor{gnat_rm/the_implementation_of_standard_i_o the-implementation-of-standard-i-o}@anchor{f}
21546 @chapter The Implementation of Standard I/O
21549 GNAT implements all the required input-output facilities described in
21550 A.6 through A.14.  These sections of the Ada Reference Manual describe the
21551 required behavior of these packages from the Ada point of view, and if
21552 you are writing a portable Ada program that does not need to know the
21553 exact manner in which Ada maps to the outside world when it comes to
21554 reading or writing external files, then you do not need to read this
21555 chapter.  As long as your files are all regular files (not pipes or
21556 devices), and as long as you write and read the files only from Ada, the
21557 description in the Ada Reference Manual is sufficient.
21559 However, if you want to do input-output to pipes or other devices, such
21560 as the keyboard or screen, or if the files you are dealing with are
21561 either generated by some other language, or to be read by some other
21562 language, then you need to know more about the details of how the GNAT
21563 implementation of these input-output facilities behaves.
21565 In this chapter we give a detailed description of exactly how GNAT
21566 interfaces to the file system.  As always, the sources of the system are
21567 available to you for answering questions at an even more detailed level,
21568 but for most purposes the information in this chapter will suffice.
21570 Another reason that you may need to know more about how input-output is
21571 implemented arises when you have a program written in mixed languages
21572 where, for example, files are shared between the C and Ada sections of
21573 the same program.  GNAT provides some additional facilities, in the form
21574 of additional child library packages, that facilitate this sharing, and
21575 these additional facilities are also described in this chapter.
21577 @menu
21578 * Standard I/O Packages:: 
21579 * FORM Strings:: 
21580 * Direct_IO:: 
21581 * Sequential_IO:: 
21582 * Text_IO:: 
21583 * Wide_Text_IO:: 
21584 * Wide_Wide_Text_IO:: 
21585 * Stream_IO:: 
21586 * Text Translation:: 
21587 * Shared Files:: 
21588 * Filenames encoding:: 
21589 * File content encoding:: 
21590 * Open Modes:: 
21591 * Operations on C Streams:: 
21592 * Interfacing to C Streams:: 
21594 @end menu
21596 @node Standard I/O Packages,FORM Strings,,The Implementation of Standard I/O
21597 @anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2b2}@anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{2b3}
21598 @section Standard I/O Packages
21601 The Standard I/O packages described in Annex A for
21604 @itemize *
21606 @item 
21607 Ada.Text_IO
21609 @item 
21610 Ada.Text_IO.Complex_IO
21612 @item 
21613 Ada.Text_IO.Text_Streams
21615 @item 
21616 Ada.Wide_Text_IO
21618 @item 
21619 Ada.Wide_Text_IO.Complex_IO
21621 @item 
21622 Ada.Wide_Text_IO.Text_Streams
21624 @item 
21625 Ada.Wide_Wide_Text_IO
21627 @item 
21628 Ada.Wide_Wide_Text_IO.Complex_IO
21630 @item 
21631 Ada.Wide_Wide_Text_IO.Text_Streams
21633 @item 
21634 Ada.Stream_IO
21636 @item 
21637 Ada.Sequential_IO
21639 @item 
21640 Ada.Direct_IO
21641 @end itemize
21643 are implemented using the C
21644 library streams facility; where
21647 @itemize *
21649 @item 
21650 All files are opened using @code{fopen}.
21652 @item 
21653 All input/output operations use @code{fread}/@code{fwrite}.
21654 @end itemize
21656 There is no internal buffering of any kind at the Ada library level. The only
21657 buffering is that provided at the system level in the implementation of the
21658 library routines that support streams. This facilitates shared use of these
21659 streams by mixed language programs. Note though that system level buffering is
21660 explicitly enabled at elaboration of the standard I/O packages and that can
21661 have an impact on mixed language programs, in particular those using I/O before
21662 calling the Ada elaboration routine (e.g., adainit). It is recommended to call
21663 the Ada elaboration routine before performing any I/O or when impractical,
21664 flush the common I/O streams and in particular Standard_Output before
21665 elaborating the Ada code.
21667 @node FORM Strings,Direct_IO,Standard I/O Packages,The Implementation of Standard I/O
21668 @anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2b4}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2b5}
21669 @section FORM Strings
21672 The format of a FORM string in GNAT is:
21674 @example
21675 "keyword=value,keyword=value,...,keyword=value"
21676 @end example
21678 where letters may be in upper or lower case, and there are no spaces
21679 between values.  The order of the entries is not important.  Currently
21680 the following keywords defined.
21682 @example
21683 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
21684 SHARED=[YES|NO]
21685 WCEM=[n|h|u|s|e|8|b]
21686 ENCODING=[UTF8|8BITS]
21687 @end example
21689 The use of these parameters is described later in this section. If an
21690 unrecognized keyword appears in a form string, it is silently ignored
21691 and not considered invalid.
21693 @node Direct_IO,Sequential_IO,FORM Strings,The Implementation of Standard I/O
21694 @anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2b6}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2b7}
21695 @section Direct_IO
21698 Direct_IO can only be instantiated for definite types.  This is a
21699 restriction of the Ada language, which means that the records are fixed
21700 length (the length being determined by @code{type'Size}, rounded
21701 up to the next storage unit boundary if necessary).
21703 The records of a Direct_IO file are simply written to the file in index
21704 sequence, with the first record starting at offset zero, and subsequent
21705 records following.  There is no control information of any kind.  For
21706 example, if 32-bit integers are being written, each record takes
21707 4-bytes, so the record at index @code{K} starts at offset @code{(K-1)*4}.
21709 There is no limit on the size of Direct_IO files, they are expanded as
21710 necessary to accommodate whatever records are written to the file.
21712 @node Sequential_IO,Text_IO,Direct_IO,The Implementation of Standard I/O
21713 @anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2b8}@anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2b9}
21714 @section Sequential_IO
21717 Sequential_IO may be instantiated with either a definite (constrained)
21718 or indefinite (unconstrained) type.
21720 For the definite type case, the elements written to the file are simply
21721 the memory images of the data values with no control information of any
21722 kind.  The resulting file should be read using the same type, no validity
21723 checking is performed on input.
21725 For the indefinite type case, the elements written consist of two
21726 parts.  First is the size of the data item, written as the memory image
21727 of a @code{Interfaces.C.size_t} value, followed by the memory image of
21728 the data value.  The resulting file can only be read using the same
21729 (unconstrained) type.  Normal assignment checks are performed on these
21730 read operations, and if these checks fail, @code{Data_Error} is
21731 raised.  In particular, in the array case, the lengths must match, and in
21732 the variant record case, if the variable for a particular read operation
21733 is constrained, the discriminants must match.
21735 Note that it is not possible to use Sequential_IO to write variable
21736 length array items, and then read the data back into different length
21737 arrays.  For example, the following will raise @code{Data_Error}:
21739 @example
21740 package IO is new Sequential_IO (String);
21741 F : IO.File_Type;
21742 S : String (1..4);
21744 IO.Create (F)
21745 IO.Write (F, "hello!")
21746 IO.Reset (F, Mode=>In_File);
21747 IO.Read (F, S);
21748 Put_Line (S);
21749 @end example
21751 On some Ada implementations, this will print @code{hell}, but the program is
21752 clearly incorrect, since there is only one element in the file, and that
21753 element is the string @code{hello!}.
21755 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
21756 using Stream_IO, and this is the preferred mechanism.  In particular, the
21757 above program fragment rewritten to use Stream_IO will work correctly.
21759 @node Text_IO,Wide_Text_IO,Sequential_IO,The Implementation of Standard I/O
21760 @anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2ba}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2bb}
21761 @section Text_IO
21764 Text_IO files consist of a stream of characters containing the following
21765 special control characters:
21767 @example
21768 LF (line feed, 16#0A#) Line Mark
21769 FF (form feed, 16#0C#) Page Mark
21770 @end example
21772 A canonical Text_IO file is defined as one in which the following
21773 conditions are met:
21776 @itemize *
21778 @item 
21779 The character @code{LF} is used only as a line mark, i.e., to mark the end
21780 of the line.
21782 @item 
21783 The character @code{FF} is used only as a page mark, i.e., to mark the
21784 end of a page and consequently can appear only immediately following a
21785 @code{LF} (line mark) character.
21787 @item 
21788 The file ends with either @code{LF} (line mark) or @code{LF}-@cite{FF}
21789 (line mark, page mark).  In the former case, the page mark is implicitly
21790 assumed to be present.
21791 @end itemize
21793 A file written using Text_IO will be in canonical form provided that no
21794 explicit @code{LF} or @code{FF} characters are written using @code{Put}
21795 or @code{Put_Line}.  There will be no @code{FF} character at the end of
21796 the file unless an explicit @code{New_Page} operation was performed
21797 before closing the file.
21799 A canonical Text_IO file that is a regular file (i.e., not a device or a
21800 pipe) can be read using any of the routines in Text_IO.  The
21801 semantics in this case will be exactly as defined in the Ada Reference
21802 Manual, and all the routines in Text_IO are fully implemented.
21804 A text file that does not meet the requirements for a canonical Text_IO
21805 file has one of the following:
21808 @itemize *
21810 @item 
21811 The file contains @code{FF} characters not immediately following a
21812 @code{LF} character.
21814 @item 
21815 The file contains @code{LF} or @code{FF} characters written by
21816 @code{Put} or @code{Put_Line}, which are not logically considered to be
21817 line marks or page marks.
21819 @item 
21820 The file ends in a character other than @code{LF} or @code{FF},
21821 i.e., there is no explicit line mark or page mark at the end of the file.
21822 @end itemize
21824 Text_IO can be used to read such non-standard text files but subprograms
21825 to do with line or page numbers do not have defined meanings.  In
21826 particular, a @code{FF} character that does not follow a @code{LF}
21827 character may or may not be treated as a page mark from the point of
21828 view of page and line numbering.  Every @code{LF} character is considered
21829 to end a line, and there is an implied @code{LF} character at the end of
21830 the file.
21832 @menu
21833 * Stream Pointer Positioning:: 
21834 * Reading and Writing Non-Regular Files:: 
21835 * Get_Immediate:: 
21836 * Treating Text_IO Files as Streams:: 
21837 * Text_IO Extensions:: 
21838 * Text_IO Facilities for Unbounded Strings:: 
21840 @end menu
21842 @node Stream Pointer Positioning,Reading and Writing Non-Regular Files,,Text_IO
21843 @anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2bc}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2bd}
21844 @subsection Stream Pointer Positioning
21847 @code{Ada.Text_IO} has a definition of current position for a file that
21848 is being read.  No internal buffering occurs in Text_IO, and usually the
21849 physical position in the stream used to implement the file corresponds
21850 to this logical position defined by Text_IO.  There are two exceptions:
21853 @itemize *
21855 @item 
21856 After a call to @code{End_Of_Page} that returns @code{True}, the stream
21857 is positioned past the @code{LF} (line mark) that precedes the page
21858 mark.  Text_IO maintains an internal flag so that subsequent read
21859 operations properly handle the logical position which is unchanged by
21860 the @code{End_Of_Page} call.
21862 @item 
21863 After a call to @code{End_Of_File} that returns @code{True}, if the
21864 Text_IO file was positioned before the line mark at the end of file
21865 before the call, then the logical position is unchanged, but the stream
21866 is physically positioned right at the end of file (past the line mark,
21867 and past a possible page mark following the line mark.  Again Text_IO
21868 maintains internal flags so that subsequent read operations properly
21869 handle the logical position.
21870 @end itemize
21872 These discrepancies have no effect on the observable behavior of
21873 Text_IO, but if a single Ada stream is shared between a C program and
21874 Ada program, or shared (using @code{shared=yes} in the form string)
21875 between two Ada files, then the difference may be observable in some
21876 situations.
21878 @node Reading and Writing Non-Regular Files,Get_Immediate,Stream Pointer Positioning,Text_IO
21879 @anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2be}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2bf}
21880 @subsection Reading and Writing Non-Regular Files
21883 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
21884 can be used for reading and writing.  Writing is not affected and the
21885 sequence of characters output is identical to the normal file case, but
21886 for reading, the behavior of Text_IO is modified to avoid undesirable
21887 look-ahead as follows:
21889 An input file that is not a regular file is considered to have no page
21890 marks.  Any @code{Ascii.FF} characters (the character normally used for a
21891 page mark) appearing in the file are considered to be data
21892 characters.  In particular:
21895 @itemize *
21897 @item 
21898 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
21899 following a line mark.  If a page mark appears, it will be treated as a
21900 data character.
21902 @item 
21903 This avoids the need to wait for an extra character to be typed or
21904 entered from the pipe to complete one of these operations.
21906 @item 
21907 @code{End_Of_Page} always returns @code{False}
21909 @item 
21910 @code{End_Of_File} will return @code{False} if there is a page mark at
21911 the end of the file.
21912 @end itemize
21914 Output to non-regular files is the same as for regular files.  Page marks
21915 may be written to non-regular files using @code{New_Page}, but as noted
21916 above they will not be treated as page marks on input if the output is
21917 piped to another Ada program.
21919 Another important discrepancy when reading non-regular files is that the end
21920 of file indication is not ‘sticky’.  If an end of file is entered, e.g., by
21921 pressing the @code{EOT} key,
21922 then end of file
21923 is signaled once (i.e., the test @code{End_Of_File}
21924 will yield @code{True}, or a read will
21925 raise @code{End_Error}), but then reading can resume
21926 to read data past that end of
21927 file indication, until another end of file indication is entered.
21929 @node Get_Immediate,Treating Text_IO Files as Streams,Reading and Writing Non-Regular Files,Text_IO
21930 @anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2c0}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2c1}
21931 @subsection Get_Immediate
21934 @geindex Get_Immediate
21936 Get_Immediate returns the next character (including control characters)
21937 from the input file.  In particular, Get_Immediate will return LF or FF
21938 characters used as line marks or page marks.  Such operations leave the
21939 file positioned past the control character, and it is thus not treated
21940 as having its normal function.  This means that page, line and column
21941 counts after this kind of Get_Immediate call are set as though the mark
21942 did not occur.  In the case where a Get_Immediate leaves the file
21943 positioned between the line mark and page mark (which is not normally
21944 possible), it is undefined whether the FF character will be treated as a
21945 page mark.
21947 @node Treating Text_IO Files as Streams,Text_IO Extensions,Get_Immediate,Text_IO
21948 @anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2c2}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2c3}
21949 @subsection Treating Text_IO Files as Streams
21952 @geindex Stream files
21954 The package @code{Text_IO.Streams} allows a @code{Text_IO} file to be treated
21955 as a stream.  Data written to a @code{Text_IO} file in this stream mode is
21956 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
21957 16#0C# (@code{FF}), the resulting file may have non-standard
21958 format.  Similarly if read operations are used to read from a Text_IO
21959 file treated as a stream, then @code{LF} and @code{FF} characters may be
21960 skipped and the effect is similar to that described above for
21961 @code{Get_Immediate}.
21963 @node Text_IO Extensions,Text_IO Facilities for Unbounded Strings,Treating Text_IO Files as Streams,Text_IO
21964 @anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2c4}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2c5}
21965 @subsection Text_IO Extensions
21968 @geindex Text_IO extensions
21970 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
21971 to the standard @code{Text_IO} package:
21974 @itemize *
21976 @item 
21977 function File_Exists (Name : String) return Boolean;
21978 Determines if a file of the given name exists.
21980 @item 
21981 function Get_Line return String;
21982 Reads a string from the standard input file.  The value returned is exactly
21983 the length of the line that was read.
21985 @item 
21986 function Get_Line (File : Ada.Text_IO.File_Type) return String;
21987 Similar, except that the parameter File specifies the file from which
21988 the string is to be read.
21989 @end itemize
21991 @node Text_IO Facilities for Unbounded Strings,,Text_IO Extensions,Text_IO
21992 @anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2c6}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2c7}
21993 @subsection Text_IO Facilities for Unbounded Strings
21996 @geindex Text_IO for unbounded strings
21998 @geindex Unbounded_String
21999 @geindex Text_IO operations
22001 The package @code{Ada.Strings.Unbounded.Text_IO}
22002 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
22003 subprograms useful for Text_IO operations on unbounded strings:
22006 @itemize *
22008 @item 
22009 function Get_Line (File : File_Type) return Unbounded_String;
22010 Reads a line from the specified file
22011 and returns the result as an unbounded string.
22013 @item 
22014 procedure Put (File : File_Type; U : Unbounded_String);
22015 Writes the value of the given unbounded string to the specified file
22016 Similar to the effect of
22017 @code{Put (To_String (U))} except that an extra copy is avoided.
22019 @item 
22020 procedure Put_Line (File : File_Type; U : Unbounded_String);
22021 Writes the value of the given unbounded string to the specified file,
22022 followed by a @code{New_Line}.
22023 Similar to the effect of @code{Put_Line (To_String (U))} except
22024 that an extra copy is avoided.
22025 @end itemize
22027 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
22028 and is optional.  If the parameter is omitted, then the standard input or
22029 output file is referenced as appropriate.
22031 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
22032 files @code{a-swuwti.ads} and @code{a-swuwti.adb} provides similar extended
22033 @code{Wide_Text_IO} functionality for unbounded wide strings.
22035 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
22036 files @code{a-szuzti.ads} and @code{a-szuzti.adb} provides similar extended
22037 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
22039 @node Wide_Text_IO,Wide_Wide_Text_IO,Text_IO,The Implementation of Standard I/O
22040 @anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2c8}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2c9}
22041 @section Wide_Text_IO
22044 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
22045 both input and output files may contain special sequences that represent
22046 wide character values.  The encoding scheme for a given file may be
22047 specified using a FORM parameter:
22049 @example
22050 WCEM=`x`
22051 @end example
22053 as part of the FORM string (WCEM = wide character encoding method),
22054 where @code{x} is one of the following characters
22057 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
22058 @headitem
22060 Character
22062 @tab
22064 Encoding
22066 @item
22070 @tab
22072 Hex ESC encoding
22074 @item
22078 @tab
22080 Upper half encoding
22082 @item
22086 @tab
22088 Shift-JIS encoding
22090 @item
22094 @tab
22096 EUC Encoding
22098 @item
22102 @tab
22104 UTF-8 encoding
22106 @item
22110 @tab
22112 Brackets encoding
22114 @end multitable
22117 The encoding methods match those that
22118 can be used in a source
22119 program, but there is no requirement that the encoding method used for
22120 the source program be the same as the encoding method used for files,
22121 and different files may use different encoding methods.
22123 The default encoding method for the standard files, and for opened files
22124 for which no WCEM parameter is given in the FORM string matches the
22125 wide character encoding specified for the main program (the default
22126 being brackets encoding if no coding method was specified with -gnatW).
22129 @table @asis
22131 @item `Hex Coding'
22133 In this encoding, a wide character is represented by a five character
22134 sequence:
22135 @end table
22137 @example
22138 ESC a b c d
22139 @end example
22142 @quotation
22144 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22145 characters (using upper case letters) of the wide character code.  For
22146 example, ESC A345 is used to represent the wide character with code
22147 16#A345#.  This scheme is compatible with use of the full
22148 @code{Wide_Character} set.
22149 @end quotation
22152 @table @asis
22154 @item `Upper Half Coding'
22156 The wide character with encoding 16#abcd#, where the upper bit is on
22157 (i.e., a is in the range 8-F) is represented as two bytes 16#ab# and
22158 16#cd#.  The second byte may never be a format control character, but is
22159 not required to be in the upper half.  This method can be also used for
22160 shift-JIS or EUC where the internal coding matches the external coding.
22162 @item `Shift JIS Coding'
22164 A wide character is represented by a two character sequence 16#ab# and
22165 16#cd#, with the restrictions described for upper half encoding as
22166 described above.  The internal character code is the corresponding JIS
22167 character according to the standard algorithm for Shift-JIS
22168 conversion.  Only characters defined in the JIS code set table can be
22169 used with this encoding method.
22171 @item `EUC Coding'
22173 A wide character is represented by a two character sequence 16#ab# and
22174 16#cd#, with both characters being in the upper half.  The internal
22175 character code is the corresponding JIS character according to the EUC
22176 encoding algorithm.  Only characters defined in the JIS code set table
22177 can be used with this encoding method.
22179 @item `UTF-8 Coding'
22181 A wide character is represented using
22182 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22183 10646-1/Am.2.  Depending on the character value, the representation
22184 is a one, two, or three byte sequence:
22185 @end table
22187 @example
22188 16#0000#-16#007f#: 2#0xxxxxxx#
22189 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
22190 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22191 @end example
22194 @quotation
22196 where the @code{xxx} bits correspond to the left-padded bits of the
22197 16-bit character value.  Note that all lower half ASCII characters
22198 are represented as ASCII bytes and all upper half characters and
22199 other wide characters are represented as sequences of upper-half
22200 (The full UTF-8 scheme allows for encoding 31-bit characters as
22201 6-byte sequences, but in this implementation, all UTF-8 sequences
22202 of four or more bytes length will raise a Constraint_Error, as
22203 will all invalid UTF-8 sequences.)
22204 @end quotation
22207 @table @asis
22209 @item `Brackets Coding'
22211 In this encoding, a wide character is represented by the following eight
22212 character sequence:
22213 @end table
22215 @example
22216 [ " a b c d " ]
22217 @end example
22220 @quotation
22222 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22223 characters (using uppercase letters) of the wide character code.  For
22224 example, @code{["A345"]} is used to represent the wide character with code
22225 @code{16#A345#}.
22226 This scheme is compatible with use of the full Wide_Character set.
22227 On input, brackets coding can also be used for upper half characters,
22228 e.g., @code{["C1"]} for lower case a.  However, on output, brackets notation
22229 is only used for wide characters with a code greater than @code{16#FF#}.
22231 Note that brackets coding is not normally used in the context of
22232 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
22233 a portable way of encoding source files. In the context of Wide_Text_IO
22234 or Wide_Wide_Text_IO, it can only be used if the file does not contain
22235 any instance of the left bracket character other than to encode wide
22236 character values using the brackets encoding method. In practice it is
22237 expected that some standard wide character encoding method such
22238 as UTF-8 will be used for text input output.
22240 If brackets notation is used, then any occurrence of a left bracket
22241 in the input file which is not the start of a valid wide character
22242 sequence will cause Constraint_Error to be raised. It is possible to
22243 encode a left bracket as [“5B”] and Wide_Text_IO and Wide_Wide_Text_IO
22244 input will interpret this as a left bracket.
22246 However, when a left bracket is output, it will be output as a left bracket
22247 and not as [“5B”]. We make this decision because for normal use of
22248 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
22249 brackets. For example, if we write:
22251 @example
22252 Put_Line ("Start of output [first run]");
22253 @end example
22255 we really do not want to have the left bracket in this message clobbered so
22256 that the output reads:
22257 @end quotation
22259 @example
22260 Start of output ["5B"]first run]
22261 @end example
22264 @quotation
22266 In practice brackets encoding is reasonably useful for normal Put_Line use
22267 since we won’t get confused between left brackets and wide character
22268 sequences in the output. But for input, or when files are written out
22269 and read back in, it really makes better sense to use one of the standard
22270 encoding methods such as UTF-8.
22271 @end quotation
22273 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
22274 not all wide character
22275 values can be represented.  An attempt to output a character that cannot
22276 be represented using the encoding scheme for the file causes
22277 Constraint_Error to be raised.  An invalid wide character sequence on
22278 input also causes Constraint_Error to be raised.
22280 @menu
22281 * Stream Pointer Positioning: Stream Pointer Positioning<2>. 
22282 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>. 
22284 @end menu
22286 @node Stream Pointer Positioning<2>,Reading and Writing Non-Regular Files<2>,,Wide_Text_IO
22287 @anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2ca}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2cb}
22288 @subsection Stream Pointer Positioning
22291 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22292 of stream pointer positioning (@ref{2bb,,Text_IO}).  There is one additional
22293 case:
22295 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
22296 normal lower ASCII set, i.e. a character in the range:
22298 @example
22299 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
22300 @end example
22302 then although the logical position of the file pointer is unchanged by
22303 the @code{Look_Ahead} call, the stream is physically positioned past the
22304 wide character sequence.  Again this is to avoid the need for buffering
22305 or backup, and all @code{Wide_Text_IO} routines check the internal
22306 indication that this situation has occurred so that this is not visible
22307 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
22308 can be observed if the wide text file shares a stream with another file.
22310 @node Reading and Writing Non-Regular Files<2>,,Stream Pointer Positioning<2>,Wide_Text_IO
22311 @anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2cc}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2cd}
22312 @subsection Reading and Writing Non-Regular Files
22315 As in the case of Text_IO, when a non-regular file is read, it is
22316 assumed that the file contains no page marks (any form characters are
22317 treated as data characters), and @code{End_Of_Page} always returns
22318 @code{False}.  Similarly, the end of file indication is not sticky, so
22319 it is possible to read beyond an end of file.
22321 @node Wide_Wide_Text_IO,Stream_IO,Wide_Text_IO,The Implementation of Standard I/O
22322 @anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2ce}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2cf}
22323 @section Wide_Wide_Text_IO
22326 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
22327 both input and output files may contain special sequences that represent
22328 wide wide character values.  The encoding scheme for a given file may be
22329 specified using a FORM parameter:
22331 @example
22332 WCEM=`x`
22333 @end example
22335 as part of the FORM string (WCEM = wide character encoding method),
22336 where @code{x} is one of the following characters
22339 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
22340 @headitem
22342 Character
22344 @tab
22346 Encoding
22348 @item
22352 @tab
22354 Hex ESC encoding
22356 @item
22360 @tab
22362 Upper half encoding
22364 @item
22368 @tab
22370 Shift-JIS encoding
22372 @item
22376 @tab
22378 EUC Encoding
22380 @item
22384 @tab
22386 UTF-8 encoding
22388 @item
22392 @tab
22394 Brackets encoding
22396 @end multitable
22399 The encoding methods match those that
22400 can be used in a source
22401 program, but there is no requirement that the encoding method used for
22402 the source program be the same as the encoding method used for files,
22403 and different files may use different encoding methods.
22405 The default encoding method for the standard files, and for opened files
22406 for which no WCEM parameter is given in the FORM string matches the
22407 wide character encoding specified for the main program (the default
22408 being brackets encoding if no coding method was specified with -gnatW).
22411 @table @asis
22413 @item `UTF-8 Coding'
22415 A wide character is represented using
22416 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22417 10646-1/Am.2.  Depending on the character value, the representation
22418 is a one, two, three, or four byte sequence:
22419 @end table
22421 @example
22422 16#000000#-16#00007f#: 2#0xxxxxxx#
22423 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
22424 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22425 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
22426 @end example
22429 @quotation
22431 where the @code{xxx} bits correspond to the left-padded bits of the
22432 21-bit character value.  Note that all lower half ASCII characters
22433 are represented as ASCII bytes and all upper half characters and
22434 other wide characters are represented as sequences of upper-half
22435 characters.
22436 @end quotation
22439 @table @asis
22441 @item `Brackets Coding'
22443 In this encoding, a wide wide character is represented by the following eight
22444 character sequence if is in wide character range
22445 @end table
22447 @example
22448 [ " a b c d " ]
22449 @end example
22452 @quotation
22454 and by the following ten character sequence if not
22455 @end quotation
22457 @example
22458 [ " a b c d e f " ]
22459 @end example
22462 @quotation
22464 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
22465 are the four or six hexadecimal
22466 characters (using uppercase letters) of the wide wide character code.  For
22467 example, @code{["01A345"]} is used to represent the wide wide character
22468 with code @code{16#01A345#}.
22470 This scheme is compatible with use of the full Wide_Wide_Character set.
22471 On input, brackets coding can also be used for upper half characters,
22472 e.g., @code{["C1"]} for lower case a.  However, on output, brackets notation
22473 is only used for wide characters with a code greater than @code{16#FF#}.
22474 @end quotation
22476 If is also possible to use the other Wide_Character encoding methods,
22477 such as Shift-JIS, but the other schemes cannot support the full range
22478 of wide wide characters.
22479 An attempt to output a character that cannot
22480 be represented using the encoding scheme for the file causes
22481 Constraint_Error to be raised.  An invalid wide character sequence on
22482 input also causes Constraint_Error to be raised.
22484 @menu
22485 * Stream Pointer Positioning: Stream Pointer Positioning<3>. 
22486 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>. 
22488 @end menu
22490 @node Stream Pointer Positioning<3>,Reading and Writing Non-Regular Files<3>,,Wide_Wide_Text_IO
22491 @anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2d0}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2d1}
22492 @subsection Stream Pointer Positioning
22495 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22496 of stream pointer positioning (@ref{2bb,,Text_IO}).  There is one additional
22497 case:
22499 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
22500 normal lower ASCII set, i.e. a character in the range:
22502 @example
22503 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
22504 @end example
22506 then although the logical position of the file pointer is unchanged by
22507 the @code{Look_Ahead} call, the stream is physically positioned past the
22508 wide character sequence.  Again this is to avoid the need for buffering
22509 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
22510 indication that this situation has occurred so that this is not visible
22511 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
22512 can be observed if the wide text file shares a stream with another file.
22514 @node Reading and Writing Non-Regular Files<3>,,Stream Pointer Positioning<3>,Wide_Wide_Text_IO
22515 @anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2d2}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2d3}
22516 @subsection Reading and Writing Non-Regular Files
22519 As in the case of Text_IO, when a non-regular file is read, it is
22520 assumed that the file contains no page marks (any form characters are
22521 treated as data characters), and @code{End_Of_Page} always returns
22522 @code{False}.  Similarly, the end of file indication is not sticky, so
22523 it is possible to read beyond an end of file.
22525 @node Stream_IO,Text Translation,Wide_Wide_Text_IO,The Implementation of Standard I/O
22526 @anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2d4}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2d5}
22527 @section Stream_IO
22530 A stream file is a sequence of bytes, where individual elements are
22531 written to the file as described in the Ada Reference Manual.  The type
22532 @code{Stream_Element} is simply a byte.  There are two ways to read or
22533 write a stream file.
22536 @itemize *
22538 @item 
22539 The operations @code{Read} and @code{Write} directly read or write a
22540 sequence of stream elements with no control information.
22542 @item 
22543 The stream attributes applied to a stream file transfer data in the
22544 manner described for stream attributes.
22545 @end itemize
22547 @node Text Translation,Shared Files,Stream_IO,The Implementation of Standard I/O
22548 @anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2d6}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2d7}
22549 @section Text Translation
22552 @code{Text_Translation=xxx} may be used as the Form parameter
22553 passed to Text_IO.Create and Text_IO.Open. @code{Text_Translation=xxx}
22554 has no effect on Unix systems. Possible values are:
22557 @itemize *
22559 @item 
22560 @code{Yes} or @code{Text} is the default, which means to
22561 translate LF to/from CR/LF on Windows systems.
22563 @code{No} disables this translation; i.e. it
22564 uses binary mode. For output files, @code{Text_Translation=No}
22565 may be used to create Unix-style files on
22566 Windows.
22568 @item 
22569 @code{wtext} translation enabled in Unicode mode.
22570 (corresponds to _O_WTEXT).
22572 @item 
22573 @code{u8text} translation enabled in Unicode UTF-8 mode.
22574 (corresponds to O_U8TEXT).
22576 @item 
22577 @code{u16text} translation enabled in Unicode UTF-16
22578 mode. (corresponds to_O_U16TEXT).
22579 @end itemize
22581 @node Shared Files,Filenames encoding,Text Translation,The Implementation of Standard I/O
22582 @anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2d8}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2d9}
22583 @section Shared Files
22586 Section A.14 of the Ada Reference Manual allows implementations to
22587 provide a wide variety of behavior if an attempt is made to access the
22588 same external file with two or more internal files.
22590 To provide a full range of functionality, while at the same time
22591 minimizing the problems of portability caused by this implementation
22592 dependence, GNAT handles file sharing as follows:
22595 @itemize *
22597 @item 
22598 In the absence of a @code{shared=xxx} form parameter, an attempt
22599 to open two or more files with the same full name is considered an error
22600 and is not supported.  The exception @code{Use_Error} will be
22601 raised.  Note that a file that is not explicitly closed by the program
22602 remains open until the program terminates.
22604 @item 
22605 If the form parameter @code{shared=no} appears in the form string, the
22606 file can be opened or created with its own separate stream identifier,
22607 regardless of whether other files sharing the same external file are
22608 opened.  The exact effect depends on how the C stream routines handle
22609 multiple accesses to the same external files using separate streams.
22611 @item 
22612 If the form parameter @code{shared=yes} appears in the form string for
22613 each of two or more files opened using the same full name, the same
22614 stream is shared between these files, and the semantics are as described
22615 in Ada Reference Manual, Section A.14.
22616 @end itemize
22618 When a program that opens multiple files with the same name is ported
22619 from another Ada compiler to GNAT, the effect will be that
22620 @code{Use_Error} is raised.
22622 The documentation of the original compiler and the documentation of the
22623 program should then be examined to determine if file sharing was
22624 expected, and @code{shared=xxx} parameters added to @code{Open}
22625 and @code{Create} calls as required.
22627 When a program is ported from GNAT to some other Ada compiler, no
22628 special attention is required unless the @code{shared=xxx} form
22629 parameter is used in the program.  In this case, you must examine the
22630 documentation of the new compiler to see if it supports the required
22631 file sharing semantics, and form strings modified appropriately.  Of
22632 course it may be the case that the program cannot be ported if the
22633 target compiler does not support the required functionality.  The best
22634 approach in writing portable code is to avoid file sharing (and hence
22635 the use of the @code{shared=xxx} parameter in the form string)
22636 completely.
22638 One common use of file sharing in Ada 83 is the use of instantiations of
22639 Sequential_IO on the same file with different types, to achieve
22640 heterogeneous input-output.  Although this approach will work in GNAT if
22641 @code{shared=yes} is specified, it is preferable in Ada to use Stream_IO
22642 for this purpose (using the stream attributes)
22644 @node Filenames encoding,File content encoding,Shared Files,The Implementation of Standard I/O
22645 @anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2da}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2db}
22646 @section Filenames encoding
22649 An encoding form parameter can be used to specify the filename
22650 encoding @code{encoding=xxx}.
22653 @itemize *
22655 @item 
22656 If the form parameter @code{encoding=utf8} appears in the form string, the
22657 filename must be encoded in UTF-8.
22659 @item 
22660 If the form parameter @code{encoding=8bits} appears in the form
22661 string, the filename must be a standard 8bits string.
22662 @end itemize
22664 In the absence of a @code{encoding=xxx} form parameter, the
22665 encoding is controlled by the @code{GNAT_CODE_PAGE} environment
22666 variable. And if not set @code{utf8} is assumed.
22669 @table @asis
22671 @item `CP_ACP'
22673 The current system Windows ANSI code page.
22675 @item `CP_UTF8'
22677 UTF-8 encoding
22678 @end table
22680 This encoding form parameter is only supported on the Windows
22681 platform. On the other Operating Systems the run-time is supporting
22682 UTF-8 natively.
22684 @node File content encoding,Open Modes,Filenames encoding,The Implementation of Standard I/O
22685 @anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2dc}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2dd}
22686 @section File content encoding
22689 For text files it is possible to specify the encoding to use. This is
22690 controlled by the by the @code{GNAT_CCS_ENCODING} environment
22691 variable. And if not set @code{TEXT} is assumed.
22693 The possible values are those supported on Windows:
22696 @table @asis
22698 @item `TEXT'
22700 Translated text mode
22702 @item `WTEXT'
22704 Translated unicode encoding
22706 @item `U16TEXT'
22708 Unicode 16-bit encoding
22710 @item `U8TEXT'
22712 Unicode 8-bit encoding
22713 @end table
22715 This encoding is only supported on the Windows platform.
22717 @node Open Modes,Operations on C Streams,File content encoding,The Implementation of Standard I/O
22718 @anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2de}@anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2df}
22719 @section Open Modes
22722 @code{Open} and @code{Create} calls result in a call to @code{fopen}
22723 using the mode shown in the following table:
22726 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxx} 
22727 @headitem
22729 @code{Open} and @code{Create} Call Modes
22731 @tab
22733 @tab
22735 @item
22737 @tab
22739 `OPEN'
22741 @tab
22743 `CREATE'
22745 @item
22747 Append_File
22749 @tab
22751 “r+”
22753 @tab
22755 “w+”
22757 @item
22759 In_File
22761 @tab
22763 “r”
22765 @tab
22767 “w+”
22769 @item
22771 Out_File (Direct_IO)
22773 @tab
22775 “r+”
22777 @tab
22779 “w”
22781 @item
22783 Out_File (all other cases)
22785 @tab
22787 “w”
22789 @tab
22791 “w”
22793 @item
22795 Inout_File
22797 @tab
22799 “r+”
22801 @tab
22803 “w+”
22805 @end multitable
22808 If text file translation is required, then either @code{b} or @code{t}
22809 is added to the mode, depending on the setting of Text.  Text file
22810 translation refers to the mapping of CR/LF sequences in an external file
22811 to LF characters internally.  This mapping only occurs in DOS and
22812 DOS-like systems, and is not relevant to other systems.
22814 A special case occurs with Stream_IO.  As shown in the above table, the
22815 file is initially opened in @code{r} or @code{w} mode for the
22816 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
22817 subsequently requires switching from reading to writing or vice-versa,
22818 then the file is reopened in @code{r+} mode to permit the required operation.
22820 @node Operations on C Streams,Interfacing to C Streams,Open Modes,The Implementation of Standard I/O
22821 @anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2e0}@anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2e1}
22822 @section Operations on C Streams
22825 The package @code{Interfaces.C_Streams} provides an Ada program with direct
22826 access to the C library functions for operations on C streams:
22828 @example
22829 package Interfaces.C_Streams is
22830   -- Note: the reason we do not use the types that are in
22831   -- Interfaces.C is that we want to avoid dragging in the
22832   -- code in this unit if possible.
22833   subtype chars is System.Address;
22834   -- Pointer to null-terminated array of characters
22835   subtype FILEs is System.Address;
22836   -- Corresponds to the C type FILE*
22837   subtype voids is System.Address;
22838   -- Corresponds to the C type void*
22839   subtype int is Integer;
22840   subtype long is Long_Integer;
22841   -- Note: the above types are subtypes deliberately, and it
22842   -- is part of this spec that the above correspondences are
22843   -- guaranteed.  This means that it is legitimate to, for
22844   -- example, use Integer instead of int.  We provide these
22845   -- synonyms for clarity, but in some cases it may be
22846   -- convenient to use the underlying types (for example to
22847   -- avoid an unnecessary dependency of a spec on the spec
22848   -- of this unit).
22849   type size_t is mod 2 ** Standard'Address_Size;
22850   NULL_Stream : constant FILEs;
22851   -- Value returned (NULL in C) to indicate an
22852   -- fdopen/fopen/tmpfile error
22853   ----------------------------------
22854   -- Constants Defined in stdio.h --
22855   ----------------------------------
22856   EOF : constant int;
22857   -- Used by a number of routines to indicate error or
22858   -- end of file
22859   IOFBF : constant int;
22860   IOLBF : constant int;
22861   IONBF : constant int;
22862   -- Used to indicate buffering mode for setvbuf call
22863   SEEK_CUR : constant int;
22864   SEEK_END : constant int;
22865   SEEK_SET : constant int;
22866   -- Used to indicate origin for fseek call
22867   function stdin return FILEs;
22868   function stdout return FILEs;
22869   function stderr return FILEs;
22870   -- Streams associated with standard files
22871   --------------------------
22872   -- Standard C functions --
22873   --------------------------
22874   -- The functions selected below are ones that are
22875   -- available in UNIX (but not necessarily in ANSI C).
22876   -- These are very thin interfaces
22877   -- which copy exactly the C headers.  For more
22878   -- documentation on these functions, see the Microsoft C
22879   -- "Run-Time Library Reference" (Microsoft Press, 1990,
22880   -- ISBN 1-55615-225-6), which includes useful information
22881   -- on system compatibility.
22882   procedure clearerr (stream : FILEs);
22883   function fclose (stream : FILEs) return int;
22884   function fdopen (handle : int; mode : chars) return FILEs;
22885   function feof (stream : FILEs) return int;
22886   function ferror (stream : FILEs) return int;
22887   function fflush (stream : FILEs) return int;
22888   function fgetc (stream : FILEs) return int;
22889   function fgets (strng : chars; n : int; stream : FILEs)
22890       return chars;
22891   function fileno (stream : FILEs) return int;
22892   function fopen (filename : chars; Mode : chars)
22893       return FILEs;
22894   -- Note: to maintain target independence, use
22895   -- text_translation_required, a boolean variable defined in
22896   -- a-sysdep.c to deal with the target dependent text
22897   -- translation requirement.  If this variable is set,
22898   -- then  b/t should be appended to the standard mode
22899   -- argument to set the text translation mode off or on
22900   -- as required.
22901   function fputc (C : int; stream : FILEs) return int;
22902   function fputs (Strng : chars; Stream : FILEs) return int;
22903   function fread
22904      (buffer : voids;
22905       size : size_t;
22906       count : size_t;
22907       stream : FILEs)
22908       return size_t;
22909   function freopen
22910      (filename : chars;
22911       mode : chars;
22912       stream : FILEs)
22913       return FILEs;
22914   function fseek
22915      (stream : FILEs;
22916       offset : long;
22917       origin : int)
22918       return int;
22919   function ftell (stream : FILEs) return long;
22920   function fwrite
22921      (buffer : voids;
22922       size : size_t;
22923       count : size_t;
22924       stream : FILEs)
22925       return size_t;
22926   function isatty (handle : int) return int;
22927   procedure mktemp (template : chars);
22928   -- The return value (which is just a pointer to template)
22929   -- is discarded
22930   procedure rewind (stream : FILEs);
22931   function rmtmp return int;
22932   function setvbuf
22933      (stream : FILEs;
22934       buffer : chars;
22935       mode : int;
22936       size : size_t)
22937       return int;
22939   function tmpfile return FILEs;
22940   function ungetc (c : int; stream : FILEs) return int;
22941   function unlink (filename : chars) return int;
22942   ---------------------
22943   -- Extra functions --
22944   ---------------------
22945   -- These functions supply slightly thicker bindings than
22946   -- those above.  They are derived from functions in the
22947   -- C Run-Time Library, but may do a bit more work than
22948   -- just directly calling one of the Library functions.
22949   function is_regular_file (handle : int) return int;
22950   -- Tests if given handle is for a regular file (result 1)
22951   -- or for a non-regular file (pipe or device, result 0).
22952   ---------------------------------
22953   -- Control of Text/Binary Mode --
22954   ---------------------------------
22955   -- If text_translation_required is true, then the following
22956   -- functions may be used to dynamically switch a file from
22957   -- binary to text mode or vice versa.  These functions have
22958   -- no effect if text_translation_required is false (i.e., in
22959   -- normal UNIX mode).  Use fileno to get a stream handle.
22960   procedure set_binary_mode (handle : int);
22961   procedure set_text_mode (handle : int);
22962   ----------------------------
22963   -- Full Path Name support --
22964   ----------------------------
22965   procedure full_name (nam : chars; buffer : chars);
22966   -- Given a NUL terminated string representing a file
22967   -- name, returns in buffer a NUL terminated string
22968   -- representing the full path name for the file name.
22969   -- On systems where it is relevant the   drive is also
22970   -- part of the full path name.  It is the responsibility
22971   -- of the caller to pass an actual parameter for buffer
22972   -- that is big enough for any full path name.  Use
22973   -- max_path_len given below as the size of buffer.
22974   max_path_len : integer;
22975   -- Maximum length of an allowable full path name on the
22976   -- system, including a terminating NUL character.
22977 end Interfaces.C_Streams;
22978 @end example
22980 @node Interfacing to C Streams,,Operations on C Streams,The Implementation of Standard I/O
22981 @anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2e2}@anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2e3}
22982 @section Interfacing to C Streams
22985 The packages in this section permit interfacing Ada files to C Stream
22986 operations.
22988 @example
22989 with Interfaces.C_Streams;
22990 package Ada.Sequential_IO.C_Streams is
22991    function C_Stream (F : File_Type)
22992       return Interfaces.C_Streams.FILEs;
22993    procedure Open
22994      (File : in out File_Type;
22995       Mode : in File_Mode;
22996       C_Stream : in Interfaces.C_Streams.FILEs;
22997       Form : in String := "");
22998 end Ada.Sequential_IO.C_Streams;
23000  with Interfaces.C_Streams;
23001  package Ada.Direct_IO.C_Streams is
23002     function C_Stream (F : File_Type)
23003        return Interfaces.C_Streams.FILEs;
23004     procedure Open
23005       (File : in out File_Type;
23006        Mode : in File_Mode;
23007        C_Stream : in Interfaces.C_Streams.FILEs;
23008        Form : in String := "");
23009  end Ada.Direct_IO.C_Streams;
23011  with Interfaces.C_Streams;
23012  package Ada.Text_IO.C_Streams is
23013     function C_Stream (F : File_Type)
23014        return Interfaces.C_Streams.FILEs;
23015     procedure Open
23016       (File : in out File_Type;
23017        Mode : in File_Mode;
23018        C_Stream : in Interfaces.C_Streams.FILEs;
23019        Form : in String := "");
23020  end Ada.Text_IO.C_Streams;
23022  with Interfaces.C_Streams;
23023  package Ada.Wide_Text_IO.C_Streams is
23024     function C_Stream (F : File_Type)
23025        return Interfaces.C_Streams.FILEs;
23026     procedure Open
23027       (File : in out File_Type;
23028        Mode : in File_Mode;
23029        C_Stream : in Interfaces.C_Streams.FILEs;
23030        Form : in String := "");
23031 end Ada.Wide_Text_IO.C_Streams;
23033  with Interfaces.C_Streams;
23034  package Ada.Wide_Wide_Text_IO.C_Streams is
23035     function C_Stream (F : File_Type)
23036        return Interfaces.C_Streams.FILEs;
23037     procedure Open
23038       (File : in out File_Type;
23039        Mode : in File_Mode;
23040        C_Stream : in Interfaces.C_Streams.FILEs;
23041        Form : in String := "");
23042 end Ada.Wide_Wide_Text_IO.C_Streams;
23044 with Interfaces.C_Streams;
23045 package Ada.Stream_IO.C_Streams is
23046    function C_Stream (F : File_Type)
23047       return Interfaces.C_Streams.FILEs;
23048    procedure Open
23049      (File : in out File_Type;
23050       Mode : in File_Mode;
23051       C_Stream : in Interfaces.C_Streams.FILEs;
23052       Form : in String := "");
23053 end Ada.Stream_IO.C_Streams;
23054 @end example
23056 In each of these six packages, the @code{C_Stream} function obtains the
23057 @code{FILE} pointer from a currently opened Ada file.  It is then
23058 possible to use the @code{Interfaces.C_Streams} package to operate on
23059 this stream, or the stream can be passed to a C program which can
23060 operate on it directly.  Of course the program is responsible for
23061 ensuring that only appropriate sequences of operations are executed.
23063 One particular use of relevance to an Ada program is that the
23064 @code{setvbuf} function can be used to control the buffering of the
23065 stream used by an Ada file.  In the absence of such a call the standard
23066 default buffering is used.
23068 The @code{Open} procedures in these packages open a file giving an
23069 existing C Stream instead of a file name.  Typically this stream is
23070 imported from a C program, allowing an Ada file to operate on an
23071 existing C file.
23073 @node The GNAT Library,Interfacing to Other Languages,The Implementation of Standard I/O,Top
23074 @anchor{gnat_rm/the_gnat_library doc}@anchor{2e4}@anchor{gnat_rm/the_gnat_library id1}@anchor{2e5}@anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10}
23075 @chapter The GNAT Library
23078 The GNAT library contains a number of general and special purpose packages.
23079 It represents functionality that the GNAT developers have found useful, and
23080 which is made available to GNAT users.  The packages described here are fully
23081 supported, and upwards compatibility will be maintained in future releases,
23082 so you can use these facilities with the confidence that the same functionality
23083 will be available in future releases.
23085 The chapter here simply gives a brief summary of the facilities available.
23086 The full documentation is found in the spec file for the package.  The full
23087 sources of these library packages, including both spec and body, are provided
23088 with all GNAT releases.  For example, to find out the full specifications of
23089 the SPITBOL pattern matching capability, including a full tutorial and
23090 extensive examples, look in the @code{g-spipat.ads} file in the library.
23092 For each entry here, the package name (as it would appear in a @code{with}
23093 clause) is given, followed by the name of the corresponding spec file in
23094 parentheses.  The packages are children in four hierarchies, @code{Ada},
23095 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
23096 GNAT-specific hierarchy.
23098 Note that an application program should only use packages in one of these
23099 four hierarchies if the package is defined in the Ada Reference Manual,
23100 or is listed in this section of the GNAT Programmers Reference Manual.
23101 All other units should be considered internal implementation units and
23102 should not be directly @code{with}ed by application code.  The use of
23103 a @code{with} clause that references one of these internal implementation
23104 units makes an application potentially dependent on changes in versions
23105 of GNAT, and will generate a warning message.
23107 @menu
23108 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads. 
23109 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads. 
23110 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads): Ada Characters Wide_Latin_9 a-cwila9 ads. 
23111 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads. 
23112 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads. 
23113 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads. 
23114 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads. 
23115 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads. 
23116 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads. 
23117 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads. 
23118 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads. 
23119 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads. 
23120 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads. 
23121 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads. 
23122 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads. 
23123 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads. 
23124 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads. 
23125 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads. 
23126 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads. 
23127 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads. 
23128 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads. 
23129 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads. 
23130 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads. 
23131 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads. 
23132 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads. 
23133 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads. 
23134 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads. 
23135 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads. 
23136 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads. 
23137 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads. 
23138 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads. 
23139 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads. 
23140 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads. 
23141 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads. 
23142 * GNAT.Binary_Search (g-binsea.ads): GNAT Binary_Search g-binsea ads. 
23143 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads. 
23144 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads. 
23145 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads. 
23146 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads. 
23147 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads. 
23148 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads. 
23149 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads. 
23150 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads. 
23151 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads. 
23152 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads. 
23153 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads. 
23154 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads. 
23155 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads. 
23156 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads. 
23157 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads. 
23158 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads. 
23159 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads. 
23160 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads. 
23161 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads. 
23162 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads. 
23163 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads. 
23164 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads. 
23165 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads. 
23166 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads. 
23167 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads. 
23168 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads. 
23169 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads. 
23170 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads. 
23171 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads. 
23172 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads. 
23173 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads. 
23174 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads. 
23175 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads. 
23176 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads. 
23177 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads. 
23178 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads. 
23179 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads. 
23180 * GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads): GNAT Generic_Fast_Math_Functions g-gfmafu ads. 
23181 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads. 
23182 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads. 
23183 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads. 
23184 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads. 
23185 * GNAT.IO (g-io.ads): GNAT IO g-io ads. 
23186 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads. 
23187 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads. 
23188 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads. 
23189 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads. 
23190 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads. 
23191 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads. 
23192 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads. 
23193 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads. 
23194 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads. 
23195 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads. 
23196 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads. 
23197 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads. 
23198 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads. 
23199 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads. 
23200 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads. 
23201 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads. 
23202 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads. 
23203 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads. 
23204 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads. 
23205 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads. 
23206 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads. 
23207 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads. 
23208 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads. 
23209 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads. 
23210 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads. 
23211 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads. 
23212 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads. 
23213 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads. 
23214 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads. 
23215 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads. 
23216 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads. 
23217 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads. 
23218 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads. 
23219 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads. 
23220 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads. 
23221 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads. 
23222 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads. 
23223 * GNAT.Table (g-table.ads): GNAT Table g-table ads. 
23224 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads. 
23225 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads. 
23226 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads. 
23227 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads. 
23228 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads. 
23229 * GNAT.UTF_32 (g-utf_32.ads): GNAT UTF_32 g-utf_32 ads. 
23230 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads): GNAT UTF_32_Spelling_Checker g-u3spch ads. 
23231 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads. 
23232 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads. 
23233 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads. 
23234 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads. 
23235 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads. 
23236 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads. 
23237 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads. 
23238 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads. 
23239 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads. 
23240 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads. 
23241 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads. 
23242 * System.Assertions (s-assert.ads): System Assertions s-assert ads. 
23243 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads. 
23244 * System.Memory (s-memory.ads): System Memory s-memory ads. 
23245 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads. 
23246 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads. 
23247 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads. 
23248 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads. 
23249 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads. 
23250 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads. 
23251 * System.Rident (s-rident.ads): System Rident s-rident ads. 
23252 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads. 
23253 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads. 
23254 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads. 
23255 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads. 
23257 @end menu
23259 @node Ada Characters Latin_9 a-chlat9 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,,The GNAT Library
23260 @anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2e6}@anchor{gnat_rm/the_gnat_library id2}@anchor{2e7}
23261 @section @code{Ada.Characters.Latin_9} (@code{a-chlat9.ads})
23264 @geindex Ada.Characters.Latin_9 (a-chlat9.ads)
23266 @geindex Latin_9 constants for Character
23268 This child of @code{Ada.Characters}
23269 provides a set of definitions corresponding to those in the
23270 RM-defined package @code{Ada.Characters.Latin_1} but with the
23271 few modifications required for @code{Latin-9}.
23272 The provision of such a package
23273 is specifically authorized by the Ada Reference Manual
23274 (RM A.3.3(27)).
23276 @node Ada Characters Wide_Latin_1 a-cwila1 ads,Ada Characters Wide_Latin_9 a-cwila9 ads,Ada Characters Latin_9 a-chlat9 ads,The GNAT Library
23277 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2e8}@anchor{gnat_rm/the_gnat_library id3}@anchor{2e9}
23278 @section @code{Ada.Characters.Wide_Latin_1} (@code{a-cwila1.ads})
23281 @geindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
23283 @geindex Latin_1 constants for Wide_Character
23285 This child of @code{Ada.Characters}
23286 provides a set of definitions corresponding to those in the
23287 RM-defined package @code{Ada.Characters.Latin_1} but with the
23288 types of the constants being @code{Wide_Character}
23289 instead of @code{Character}.  The provision of such a package
23290 is specifically authorized by the Ada Reference Manual
23291 (RM A.3.3(27)).
23293 @node Ada Characters Wide_Latin_9 a-cwila9 ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,The GNAT Library
23294 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila9-ads}@anchor{2ea}@anchor{gnat_rm/the_gnat_library id4}@anchor{2eb}
23295 @section @code{Ada.Characters.Wide_Latin_9} (@code{a-cwila9.ads})
23298 @geindex Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
23300 @geindex Latin_9 constants for Wide_Character
23302 This child of @code{Ada.Characters}
23303 provides a set of definitions corresponding to those in the
23304 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23305 types of the constants being @code{Wide_Character}
23306 instead of @code{Character}.  The provision of such a package
23307 is specifically authorized by the Ada Reference Manual
23308 (RM A.3.3(27)).
23310 @node Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Characters Wide_Latin_9 a-cwila9 ads,The GNAT Library
23311 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2ec}@anchor{gnat_rm/the_gnat_library id5}@anchor{2ed}
23312 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@code{a-chzla1.ads})
23315 @geindex Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
23317 @geindex Latin_1 constants for Wide_Wide_Character
23319 This child of @code{Ada.Characters}
23320 provides a set of definitions corresponding to those in the
23321 RM-defined package @code{Ada.Characters.Latin_1} but with the
23322 types of the constants being @code{Wide_Wide_Character}
23323 instead of @code{Character}.  The provision of such a package
23324 is specifically authorized by the Ada Reference Manual
23325 (RM A.3.3(27)).
23327 @node Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Containers Bounded_Holders a-coboho ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,The GNAT Library
23328 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2ee}@anchor{gnat_rm/the_gnat_library id6}@anchor{2ef}
23329 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@code{a-chzla9.ads})
23332 @geindex Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
23334 @geindex Latin_9 constants for Wide_Wide_Character
23336 This child of @code{Ada.Characters}
23337 provides a set of definitions corresponding to those in the
23338 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23339 types of the constants being @code{Wide_Wide_Character}
23340 instead of @code{Character}.  The provision of such a package
23341 is specifically authorized by the Ada Reference Manual
23342 (RM A.3.3(27)).
23344 @node Ada Containers Bounded_Holders a-coboho ads,Ada Command_Line Environment a-colien ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,The GNAT Library
23345 @anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2f0}@anchor{gnat_rm/the_gnat_library id7}@anchor{2f1}
23346 @section @code{Ada.Containers.Bounded_Holders} (@code{a-coboho.ads})
23349 @geindex Ada.Containers.Bounded_Holders (a-coboho.ads)
23351 @geindex Formal container for vectors
23353 This child of @code{Ada.Containers} defines a modified version of
23354 Indefinite_Holders that avoids heap allocation.
23356 @node Ada Command_Line Environment a-colien ads,Ada Command_Line Remove a-colire ads,Ada Containers Bounded_Holders a-coboho ads,The GNAT Library
23357 @anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2f2}@anchor{gnat_rm/the_gnat_library id8}@anchor{2f3}
23358 @section @code{Ada.Command_Line.Environment} (@code{a-colien.ads})
23361 @geindex Ada.Command_Line.Environment (a-colien.ads)
23363 @geindex Environment entries
23365 This child of @code{Ada.Command_Line}
23366 provides a mechanism for obtaining environment values on systems
23367 where this concept makes sense.
23369 @node Ada Command_Line Remove a-colire ads,Ada Command_Line Response_File a-clrefi ads,Ada Command_Line Environment a-colien ads,The GNAT Library
23370 @anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f4}@anchor{gnat_rm/the_gnat_library id9}@anchor{2f5}
23371 @section @code{Ada.Command_Line.Remove} (@code{a-colire.ads})
23374 @geindex Ada.Command_Line.Remove (a-colire.ads)
23376 @geindex Removing command line arguments
23378 @geindex Command line
23379 @geindex argument removal
23381 This child of @code{Ada.Command_Line}
23382 provides a mechanism for logically removing
23383 arguments from the argument list.  Once removed, an argument is not visible
23384 to further calls to the subprograms in @code{Ada.Command_Line}. These calls
23385 will not see the removed argument.
23387 @node Ada Command_Line Response_File a-clrefi ads,Ada Direct_IO C_Streams a-diocst ads,Ada Command_Line Remove a-colire ads,The GNAT Library
23388 @anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2f6}@anchor{gnat_rm/the_gnat_library id10}@anchor{2f7}
23389 @section @code{Ada.Command_Line.Response_File} (@code{a-clrefi.ads})
23392 @geindex Ada.Command_Line.Response_File (a-clrefi.ads)
23394 @geindex Response file for command line
23396 @geindex Command line
23397 @geindex response file
23399 @geindex Command line
23400 @geindex handling long command lines
23402 This child of @code{Ada.Command_Line} provides a mechanism facilities for
23403 getting command line arguments from a text file, called a “response file”.
23404 Using a response file allow passing a set of arguments to an executable longer
23405 than the maximum allowed by the system on the command line.
23407 @node Ada Direct_IO C_Streams a-diocst ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Command_Line Response_File a-clrefi ads,The GNAT Library
23408 @anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2f8}@anchor{gnat_rm/the_gnat_library id11}@anchor{2f9}
23409 @section @code{Ada.Direct_IO.C_Streams} (@code{a-diocst.ads})
23412 @geindex Ada.Direct_IO.C_Streams (a-diocst.ads)
23414 @geindex C Streams
23415 @geindex Interfacing with Direct_IO
23417 This package provides subprograms that allow interfacing between
23418 C streams and @code{Direct_IO}.  The stream identifier can be
23419 extracted from a file opened on the Ada side, and an Ada file
23420 can be constructed from a stream opened on the C side.
23422 @node Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Direct_IO C_Streams a-diocst ads,The GNAT Library
23423 @anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2fa}@anchor{gnat_rm/the_gnat_library id12}@anchor{2fb}
23424 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@code{a-einuoc.ads})
23427 @geindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
23429 @geindex Null_Occurrence
23430 @geindex testing for
23432 This child subprogram provides a way of testing for the null
23433 exception occurrence (@code{Null_Occurrence}) without raising
23434 an exception.
23436 @node Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Exceptions Traceback a-exctra ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,The GNAT Library
23437 @anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{2fc}@anchor{gnat_rm/the_gnat_library id13}@anchor{2fd}
23438 @section @code{Ada.Exceptions.Last_Chance_Handler} (@code{a-elchha.ads})
23441 @geindex Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
23443 @geindex Null_Occurrence
23444 @geindex testing for
23446 This child subprogram is used for handling otherwise unhandled
23447 exceptions (hence the name last chance), and perform clean ups before
23448 terminating the program. Note that this subprogram never returns.
23450 @node Ada Exceptions Traceback a-exctra ads,Ada Sequential_IO C_Streams a-siocst ads,Ada Exceptions Last_Chance_Handler a-elchha ads,The GNAT Library
23451 @anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{2fe}@anchor{gnat_rm/the_gnat_library id14}@anchor{2ff}
23452 @section @code{Ada.Exceptions.Traceback} (@code{a-exctra.ads})
23455 @geindex Ada.Exceptions.Traceback (a-exctra.ads)
23457 @geindex Traceback for Exception Occurrence
23459 This child package provides the subprogram (@code{Tracebacks}) to
23460 give a traceback array of addresses based on an exception
23461 occurrence.
23463 @node Ada Sequential_IO C_Streams a-siocst ads,Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Exceptions Traceback a-exctra ads,The GNAT Library
23464 @anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{300}@anchor{gnat_rm/the_gnat_library id15}@anchor{301}
23465 @section @code{Ada.Sequential_IO.C_Streams} (@code{a-siocst.ads})
23468 @geindex Ada.Sequential_IO.C_Streams (a-siocst.ads)
23470 @geindex C Streams
23471 @geindex Interfacing with Sequential_IO
23473 This package provides subprograms that allow interfacing between
23474 C streams and @code{Sequential_IO}.  The stream identifier can be
23475 extracted from a file opened on the Ada side, and an Ada file
23476 can be constructed from a stream opened on the C side.
23478 @node Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Strings Unbounded Text_IO a-suteio ads,Ada Sequential_IO C_Streams a-siocst ads,The GNAT Library
23479 @anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{302}@anchor{gnat_rm/the_gnat_library id16}@anchor{303}
23480 @section @code{Ada.Streams.Stream_IO.C_Streams} (@code{a-ssicst.ads})
23483 @geindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
23485 @geindex C Streams
23486 @geindex Interfacing with Stream_IO
23488 This package provides subprograms that allow interfacing between
23489 C streams and @code{Stream_IO}.  The stream identifier can be
23490 extracted from a file opened on the Ada side, and an Ada file
23491 can be constructed from a stream opened on the C side.
23493 @node Ada Strings Unbounded Text_IO a-suteio ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Streams Stream_IO C_Streams a-ssicst ads,The GNAT Library
23494 @anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{304}@anchor{gnat_rm/the_gnat_library id17}@anchor{305}
23495 @section @code{Ada.Strings.Unbounded.Text_IO} (@code{a-suteio.ads})
23498 @geindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
23500 @geindex Unbounded_String
23501 @geindex IO support
23503 @geindex Text_IO
23504 @geindex extensions for unbounded strings
23506 This package provides subprograms for Text_IO for unbounded
23507 strings, avoiding the necessity for an intermediate operation
23508 with ordinary strings.
23510 @node Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Strings Unbounded Text_IO a-suteio ads,The GNAT Library
23511 @anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{306}@anchor{gnat_rm/the_gnat_library id18}@anchor{307}
23512 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@code{a-swuwti.ads})
23515 @geindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
23517 @geindex Unbounded_Wide_String
23518 @geindex IO support
23520 @geindex Text_IO
23521 @geindex extensions for unbounded wide strings
23523 This package provides subprograms for Text_IO for unbounded
23524 wide strings, avoiding the necessity for an intermediate operation
23525 with ordinary wide strings.
23527 @node Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Task_Initialization a-tasini ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,The GNAT Library
23528 @anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{308}@anchor{gnat_rm/the_gnat_library id19}@anchor{309}
23529 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@code{a-szuzti.ads})
23532 @geindex Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
23534 @geindex Unbounded_Wide_Wide_String
23535 @geindex IO support
23537 @geindex Text_IO
23538 @geindex extensions for unbounded wide wide strings
23540 This package provides subprograms for Text_IO for unbounded
23541 wide wide strings, avoiding the necessity for an intermediate operation
23542 with ordinary wide wide strings.
23544 @node Ada Task_Initialization a-tasini ads,Ada Text_IO C_Streams a-tiocst ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,The GNAT Library
23545 @anchor{gnat_rm/the_gnat_library ada-task-initialization-a-tasini-ads}@anchor{30a}@anchor{gnat_rm/the_gnat_library id20}@anchor{30b}
23546 @section @code{Ada.Task_Initialization} (@code{a-tasini.ads})
23549 @geindex Ada.Task_Initialization (a-tasini.ads)
23551 This package provides a way to set a global initialization handler that
23552 is automatically invoked whenever a task is activated. Handlers are
23553 parameterless procedures. Note that such a handler is only invoked for
23554 those tasks activated after the handler is set.
23556 @node Ada Text_IO C_Streams a-tiocst ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Task_Initialization a-tasini ads,The GNAT Library
23557 @anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{30c}@anchor{gnat_rm/the_gnat_library id21}@anchor{30d}
23558 @section @code{Ada.Text_IO.C_Streams} (@code{a-tiocst.ads})
23561 @geindex Ada.Text_IO.C_Streams (a-tiocst.ads)
23563 @geindex C Streams
23564 @geindex Interfacing with `@w{`}Text_IO`@w{`}
23566 This package provides subprograms that allow interfacing between
23567 C streams and @code{Text_IO}.  The stream identifier can be
23568 extracted from a file opened on the Ada side, and an Ada file
23569 can be constructed from a stream opened on the C side.
23571 @node Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Wide_Characters Unicode a-wichun ads,Ada Text_IO C_Streams a-tiocst ads,The GNAT Library
23572 @anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{30e}@anchor{gnat_rm/the_gnat_library id22}@anchor{30f}
23573 @section @code{Ada.Text_IO.Reset_Standard_Files} (@code{a-tirsfi.ads})
23576 @geindex Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
23578 @geindex Text_IO resetting standard files
23580 This procedure is used to reset the status of the standard files used
23581 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
23582 embedded application) where the status of the files may change during
23583 execution (for example a standard input file may be redefined to be
23584 interactive).
23586 @node Ada Wide_Characters Unicode a-wichun ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,The GNAT Library
23587 @anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{310}@anchor{gnat_rm/the_gnat_library id23}@anchor{311}
23588 @section @code{Ada.Wide_Characters.Unicode} (@code{a-wichun.ads})
23591 @geindex Ada.Wide_Characters.Unicode (a-wichun.ads)
23593 @geindex Unicode categorization
23594 @geindex Wide_Character
23596 This package provides subprograms that allow categorization of
23597 Wide_Character values according to Unicode categories.
23599 @node Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Characters Unicode a-wichun ads,The GNAT Library
23600 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{312}@anchor{gnat_rm/the_gnat_library id24}@anchor{313}
23601 @section @code{Ada.Wide_Text_IO.C_Streams} (@code{a-wtcstr.ads})
23604 @geindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
23606 @geindex C Streams
23607 @geindex Interfacing with `@w{`}Wide_Text_IO`@w{`}
23609 This package provides subprograms that allow interfacing between
23610 C streams and @code{Wide_Text_IO}.  The stream identifier can be
23611 extracted from a file opened on the Ada side, and an Ada file
23612 can be constructed from a stream opened on the C side.
23614 @node Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,The GNAT Library
23615 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{314}@anchor{gnat_rm/the_gnat_library id25}@anchor{315}
23616 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@code{a-wrstfi.ads})
23619 @geindex Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
23621 @geindex Wide_Text_IO resetting standard files
23623 This procedure is used to reset the status of the standard files used
23624 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
23625 embedded application) where the status of the files may change during
23626 execution (for example a standard input file may be redefined to be
23627 interactive).
23629 @node Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,The GNAT Library
23630 @anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{316}@anchor{gnat_rm/the_gnat_library id26}@anchor{317}
23631 @section @code{Ada.Wide_Wide_Characters.Unicode} (@code{a-zchuni.ads})
23634 @geindex Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
23636 @geindex Unicode categorization
23637 @geindex Wide_Wide_Character
23639 This package provides subprograms that allow categorization of
23640 Wide_Wide_Character values according to Unicode categories.
23642 @node Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,The GNAT Library
23643 @anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{318}@anchor{gnat_rm/the_gnat_library id27}@anchor{319}
23644 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@code{a-ztcstr.ads})
23647 @geindex Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
23649 @geindex C Streams
23650 @geindex Interfacing with `@w{`}Wide_Wide_Text_IO`@w{`}
23652 This package provides subprograms that allow interfacing between
23653 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
23654 extracted from a file opened on the Ada side, and an Ada file
23655 can be constructed from a stream opened on the C side.
23657 @node Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,GNAT Altivec g-altive ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,The GNAT Library
23658 @anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{31a}@anchor{gnat_rm/the_gnat_library id28}@anchor{31b}
23659 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@code{a-zrstfi.ads})
23662 @geindex Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
23664 @geindex Wide_Wide_Text_IO resetting standard files
23666 This procedure is used to reset the status of the standard files used
23667 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
23668 restart in an embedded application) where the status of the files may
23669 change during execution (for example a standard input file may be
23670 redefined to be interactive).
23672 @node GNAT Altivec g-altive ads,GNAT Altivec Conversions g-altcon ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,The GNAT Library
23673 @anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{31c}@anchor{gnat_rm/the_gnat_library id29}@anchor{31d}
23674 @section @code{GNAT.Altivec} (@code{g-altive.ads})
23677 @geindex GNAT.Altivec (g-altive.ads)
23679 @geindex AltiVec
23681 This is the root package of the GNAT AltiVec binding. It provides
23682 definitions of constants and types common to all the versions of the
23683 binding.
23685 @node GNAT Altivec Conversions g-altcon ads,GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec g-altive ads,The GNAT Library
23686 @anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{31e}@anchor{gnat_rm/the_gnat_library id30}@anchor{31f}
23687 @section @code{GNAT.Altivec.Conversions} (@code{g-altcon.ads})
23690 @geindex GNAT.Altivec.Conversions (g-altcon.ads)
23692 @geindex AltiVec
23694 This package provides the Vector/View conversion routines.
23696 @node GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Conversions g-altcon ads,The GNAT Library
23697 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{320}@anchor{gnat_rm/the_gnat_library id31}@anchor{321}
23698 @section @code{GNAT.Altivec.Vector_Operations} (@code{g-alveop.ads})
23701 @geindex GNAT.Altivec.Vector_Operations (g-alveop.ads)
23703 @geindex AltiVec
23705 This package exposes the Ada interface to the AltiVec operations on
23706 vector objects. A soft emulation is included by default in the GNAT
23707 library. The hard binding is provided as a separate package. This unit
23708 is common to both bindings.
23710 @node GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Vector_Views g-alvevi ads,GNAT Altivec Vector_Operations g-alveop ads,The GNAT Library
23711 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{322}@anchor{gnat_rm/the_gnat_library id32}@anchor{323}
23712 @section @code{GNAT.Altivec.Vector_Types} (@code{g-alvety.ads})
23715 @geindex GNAT.Altivec.Vector_Types (g-alvety.ads)
23717 @geindex AltiVec
23719 This package exposes the various vector types part of the Ada binding
23720 to AltiVec facilities.
23722 @node GNAT Altivec Vector_Views g-alvevi ads,GNAT Array_Split g-arrspl ads,GNAT Altivec Vector_Types g-alvety ads,The GNAT Library
23723 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{324}@anchor{gnat_rm/the_gnat_library id33}@anchor{325}
23724 @section @code{GNAT.Altivec.Vector_Views} (@code{g-alvevi.ads})
23727 @geindex GNAT.Altivec.Vector_Views (g-alvevi.ads)
23729 @geindex AltiVec
23731 This package provides public ‘View’ data types from/to which private
23732 vector representations can be converted via
23733 GNAT.Altivec.Conversions. This allows convenient access to individual
23734 vector elements and provides a simple way to initialize vector
23735 objects.
23737 @node GNAT Array_Split g-arrspl ads,GNAT AWK g-awk ads,GNAT Altivec Vector_Views g-alvevi ads,The GNAT Library
23738 @anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{326}@anchor{gnat_rm/the_gnat_library id34}@anchor{327}
23739 @section @code{GNAT.Array_Split} (@code{g-arrspl.ads})
23742 @geindex GNAT.Array_Split (g-arrspl.ads)
23744 @geindex Array splitter
23746 Useful array-manipulation routines: given a set of separators, split
23747 an array wherever the separators appear, and provide direct access
23748 to the resulting slices.
23750 @node GNAT AWK g-awk ads,GNAT Binary_Search g-binsea ads,GNAT Array_Split g-arrspl ads,The GNAT Library
23751 @anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{328}@anchor{gnat_rm/the_gnat_library id35}@anchor{329}
23752 @section @code{GNAT.AWK} (@code{g-awk.ads})
23755 @geindex GNAT.AWK (g-awk.ads)
23757 @geindex Parsing
23759 @geindex AWK
23761 Provides AWK-like parsing functions, with an easy interface for parsing one
23762 or more files containing formatted data.  The file is viewed as a database
23763 where each record is a line and a field is a data element in this line.
23765 @node GNAT Binary_Search g-binsea ads,GNAT Bind_Environment g-binenv ads,GNAT AWK g-awk ads,The GNAT Library
23766 @anchor{gnat_rm/the_gnat_library gnat-binary-search-g-binsea-ads}@anchor{32a}@anchor{gnat_rm/the_gnat_library id36}@anchor{32b}
23767 @section @code{GNAT.Binary_Search} (@code{g-binsea.ads})
23770 @geindex GNAT.Binary_Search (g-binsea.ads)
23772 @geindex Binary search
23774 Allow binary search of a sorted array (or of an array-like container;
23775 the generic does not reference the array directly).
23777 @node GNAT Bind_Environment g-binenv ads,GNAT Branch_Prediction g-brapre ads,GNAT Binary_Search g-binsea ads,The GNAT Library
23778 @anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{32c}@anchor{gnat_rm/the_gnat_library id37}@anchor{32d}
23779 @section @code{GNAT.Bind_Environment} (@code{g-binenv.ads})
23782 @geindex GNAT.Bind_Environment (g-binenv.ads)
23784 @geindex Bind environment
23786 Provides access to key=value associations captured at bind time.
23787 These associations can be specified using the @code{-V} binder command
23788 line switch.
23790 @node GNAT Branch_Prediction g-brapre ads,GNAT Bounded_Buffers g-boubuf ads,GNAT Bind_Environment g-binenv ads,The GNAT Library
23791 @anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{32e}@anchor{gnat_rm/the_gnat_library id38}@anchor{32f}
23792 @section @code{GNAT.Branch_Prediction} (@code{g-brapre.ads})
23795 @geindex GNAT.Branch_Prediction (g-brapre.ads)
23797 @geindex Branch Prediction
23799 Provides routines giving hints to the branch predictor of the code generator.
23801 @node GNAT Bounded_Buffers g-boubuf ads,GNAT Bounded_Mailboxes g-boumai ads,GNAT Branch_Prediction g-brapre ads,The GNAT Library
23802 @anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{330}@anchor{gnat_rm/the_gnat_library id39}@anchor{331}
23803 @section @code{GNAT.Bounded_Buffers} (@code{g-boubuf.ads})
23806 @geindex GNAT.Bounded_Buffers (g-boubuf.ads)
23808 @geindex Parsing
23810 @geindex Bounded Buffers
23812 Provides a concurrent generic bounded buffer abstraction.  Instances are
23813 useful directly or as parts of the implementations of other abstractions,
23814 such as mailboxes.
23816 @node GNAT Bounded_Mailboxes g-boumai ads,GNAT Bubble_Sort g-bubsor ads,GNAT Bounded_Buffers g-boubuf ads,The GNAT Library
23817 @anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{332}@anchor{gnat_rm/the_gnat_library id40}@anchor{333}
23818 @section @code{GNAT.Bounded_Mailboxes} (@code{g-boumai.ads})
23821 @geindex GNAT.Bounded_Mailboxes (g-boumai.ads)
23823 @geindex Parsing
23825 @geindex Mailboxes
23827 Provides a thread-safe asynchronous intertask mailbox communication facility.
23829 @node GNAT Bubble_Sort g-bubsor ads,GNAT Bubble_Sort_A g-busora ads,GNAT Bounded_Mailboxes g-boumai ads,The GNAT Library
23830 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{334}@anchor{gnat_rm/the_gnat_library id41}@anchor{335}
23831 @section @code{GNAT.Bubble_Sort} (@code{g-bubsor.ads})
23834 @geindex GNAT.Bubble_Sort (g-bubsor.ads)
23836 @geindex Sorting
23838 @geindex Bubble sort
23840 Provides a general implementation of bubble sort usable for sorting arbitrary
23841 data items.  Exchange and comparison procedures are provided by passing
23842 access-to-procedure values.
23844 @node GNAT Bubble_Sort_A g-busora ads,GNAT Bubble_Sort_G g-busorg ads,GNAT Bubble_Sort g-bubsor ads,The GNAT Library
23845 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{336}@anchor{gnat_rm/the_gnat_library id42}@anchor{337}
23846 @section @code{GNAT.Bubble_Sort_A} (@code{g-busora.ads})
23849 @geindex GNAT.Bubble_Sort_A (g-busora.ads)
23851 @geindex Sorting
23853 @geindex Bubble sort
23855 Provides a general implementation of bubble sort usable for sorting arbitrary
23856 data items.  Move and comparison procedures are provided by passing
23857 access-to-procedure values. This is an older version, retained for
23858 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
23860 @node GNAT Bubble_Sort_G g-busorg ads,GNAT Byte_Order_Mark g-byorma ads,GNAT Bubble_Sort_A g-busora ads,The GNAT Library
23861 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{338}@anchor{gnat_rm/the_gnat_library id43}@anchor{339}
23862 @section @code{GNAT.Bubble_Sort_G} (@code{g-busorg.ads})
23865 @geindex GNAT.Bubble_Sort_G (g-busorg.ads)
23867 @geindex Sorting
23869 @geindex Bubble sort
23871 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
23872 are provided as generic parameters, this improves efficiency, especially
23873 if the procedures can be inlined, at the expense of duplicating code for
23874 multiple instantiations.
23876 @node GNAT Byte_Order_Mark g-byorma ads,GNAT Byte_Swapping g-bytswa ads,GNAT Bubble_Sort_G g-busorg ads,The GNAT Library
23877 @anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{33a}@anchor{gnat_rm/the_gnat_library id44}@anchor{33b}
23878 @section @code{GNAT.Byte_Order_Mark} (@code{g-byorma.ads})
23881 @geindex GNAT.Byte_Order_Mark (g-byorma.ads)
23883 @geindex UTF-8 representation
23885 @geindex Wide characte representations
23887 Provides a routine which given a string, reads the start of the string to
23888 see whether it is one of the standard byte order marks (BOM’s) which signal
23889 the encoding of the string. The routine includes detection of special XML
23890 sequences for various UCS input formats.
23892 @node GNAT Byte_Swapping g-bytswa ads,GNAT Calendar g-calend ads,GNAT Byte_Order_Mark g-byorma ads,The GNAT Library
23893 @anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{33c}@anchor{gnat_rm/the_gnat_library id45}@anchor{33d}
23894 @section @code{GNAT.Byte_Swapping} (@code{g-bytswa.ads})
23897 @geindex GNAT.Byte_Swapping (g-bytswa.ads)
23899 @geindex Byte swapping
23901 @geindex Endianness
23903 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
23904 Machine-specific implementations are available in some cases.
23906 @node GNAT Calendar g-calend ads,GNAT Calendar Time_IO g-catiio ads,GNAT Byte_Swapping g-bytswa ads,The GNAT Library
23907 @anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{33e}@anchor{gnat_rm/the_gnat_library id46}@anchor{33f}
23908 @section @code{GNAT.Calendar} (@code{g-calend.ads})
23911 @geindex GNAT.Calendar (g-calend.ads)
23913 @geindex Calendar
23915 Extends the facilities provided by @code{Ada.Calendar} to include handling
23916 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
23917 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
23918 C @code{timeval} format.
23920 @node GNAT Calendar Time_IO g-catiio ads,GNAT CRC32 g-crc32 ads,GNAT Calendar g-calend ads,The GNAT Library
23921 @anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{340}@anchor{gnat_rm/the_gnat_library id47}@anchor{341}
23922 @section @code{GNAT.Calendar.Time_IO} (@code{g-catiio.ads})
23925 @geindex Calendar
23927 @geindex Time
23929 @geindex GNAT.Calendar.Time_IO (g-catiio.ads)
23931 @node GNAT CRC32 g-crc32 ads,GNAT Case_Util g-casuti ads,GNAT Calendar Time_IO g-catiio ads,The GNAT Library
23932 @anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{342}@anchor{gnat_rm/the_gnat_library id48}@anchor{343}
23933 @section @code{GNAT.CRC32} (@code{g-crc32.ads})
23936 @geindex GNAT.CRC32 (g-crc32.ads)
23938 @geindex CRC32
23940 @geindex Cyclic Redundancy Check
23942 This package implements the CRC-32 algorithm.  For a full description
23943 of this algorithm see
23944 `Computation of Cyclic Redundancy Checks via Table Look-Up',
23945 @cite{Communications of the ACM}, Vol. 31 No. 8, pp. 1008-1013,
23946 Aug. 1988.  Sarwate, D.V.
23948 @node GNAT Case_Util g-casuti ads,GNAT CGI g-cgi ads,GNAT CRC32 g-crc32 ads,The GNAT Library
23949 @anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{344}@anchor{gnat_rm/the_gnat_library id49}@anchor{345}
23950 @section @code{GNAT.Case_Util} (@code{g-casuti.ads})
23953 @geindex GNAT.Case_Util (g-casuti.ads)
23955 @geindex Casing utilities
23957 @geindex Character handling (`@w{`}GNAT.Case_Util`@w{`})
23959 A set of simple routines for handling upper and lower casing of strings
23960 without the overhead of the full casing tables
23961 in @code{Ada.Characters.Handling}.
23963 @node GNAT CGI g-cgi ads,GNAT CGI Cookie g-cgicoo ads,GNAT Case_Util g-casuti ads,The GNAT Library
23964 @anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{346}@anchor{gnat_rm/the_gnat_library id50}@anchor{347}
23965 @section @code{GNAT.CGI} (@code{g-cgi.ads})
23968 @geindex GNAT.CGI (g-cgi.ads)
23970 @geindex CGI (Common Gateway Interface)
23972 This is a package for interfacing a GNAT program with a Web server via the
23973 Common Gateway Interface (CGI).  Basically this package parses the CGI
23974 parameters, which are a set of key/value pairs sent by the Web server.  It
23975 builds a table whose index is the key and provides some services to deal
23976 with this table.
23978 @node GNAT CGI Cookie g-cgicoo ads,GNAT CGI Debug g-cgideb ads,GNAT CGI g-cgi ads,The GNAT Library
23979 @anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{348}@anchor{gnat_rm/the_gnat_library id51}@anchor{349}
23980 @section @code{GNAT.CGI.Cookie} (@code{g-cgicoo.ads})
23983 @geindex GNAT.CGI.Cookie (g-cgicoo.ads)
23985 @geindex CGI (Common Gateway Interface) cookie support
23987 @geindex Cookie support in CGI
23989 This is a package to interface a GNAT program with a Web server via the
23990 Common Gateway Interface (CGI).  It exports services to deal with Web
23991 cookies (piece of information kept in the Web client software).
23993 @node GNAT CGI Debug g-cgideb ads,GNAT Command_Line g-comlin ads,GNAT CGI Cookie g-cgicoo ads,The GNAT Library
23994 @anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{34a}@anchor{gnat_rm/the_gnat_library id52}@anchor{34b}
23995 @section @code{GNAT.CGI.Debug} (@code{g-cgideb.ads})
23998 @geindex GNAT.CGI.Debug (g-cgideb.ads)
24000 @geindex CGI (Common Gateway Interface) debugging
24002 This is a package to help debugging CGI (Common Gateway Interface)
24003 programs written in Ada.
24005 @node GNAT Command_Line g-comlin ads,GNAT Compiler_Version g-comver ads,GNAT CGI Debug g-cgideb ads,The GNAT Library
24006 @anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{34c}@anchor{gnat_rm/the_gnat_library id53}@anchor{34d}
24007 @section @code{GNAT.Command_Line} (@code{g-comlin.ads})
24010 @geindex GNAT.Command_Line (g-comlin.ads)
24012 @geindex Command line
24014 Provides a high level interface to @code{Ada.Command_Line} facilities,
24015 including the ability to scan for named switches with optional parameters
24016 and expand file names using wildcard notations.
24018 @node GNAT Compiler_Version g-comver ads,GNAT Ctrl_C g-ctrl_c ads,GNAT Command_Line g-comlin ads,The GNAT Library
24019 @anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{34e}@anchor{gnat_rm/the_gnat_library id54}@anchor{34f}
24020 @section @code{GNAT.Compiler_Version} (@code{g-comver.ads})
24023 @geindex GNAT.Compiler_Version (g-comver.ads)
24025 @geindex Compiler Version
24027 @geindex Version
24028 @geindex of compiler
24030 Provides a routine for obtaining the version of the compiler used to
24031 compile the program. More accurately this is the version of the binder
24032 used to bind the program (this will normally be the same as the version
24033 of the compiler if a consistent tool set is used to compile all units
24034 of a partition).
24036 @node GNAT Ctrl_C g-ctrl_c ads,GNAT Current_Exception g-curexc ads,GNAT Compiler_Version g-comver ads,The GNAT Library
24037 @anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{350}@anchor{gnat_rm/the_gnat_library id55}@anchor{351}
24038 @section @code{GNAT.Ctrl_C} (@code{g-ctrl_c.ads})
24041 @geindex GNAT.Ctrl_C (g-ctrl_c.ads)
24043 @geindex Interrupt
24045 Provides a simple interface to handle Ctrl-C keyboard events.
24047 @node GNAT Current_Exception g-curexc ads,GNAT Debug_Pools g-debpoo ads,GNAT Ctrl_C g-ctrl_c ads,The GNAT Library
24048 @anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{352}@anchor{gnat_rm/the_gnat_library id56}@anchor{353}
24049 @section @code{GNAT.Current_Exception} (@code{g-curexc.ads})
24052 @geindex GNAT.Current_Exception (g-curexc.ads)
24054 @geindex Current exception
24056 @geindex Exception retrieval
24058 Provides access to information on the current exception that has been raised
24059 without the need for using the Ada 95 / Ada 2005 exception choice parameter
24060 specification syntax.
24061 This is particularly useful in simulating typical facilities for
24062 obtaining information about exceptions provided by Ada 83 compilers.
24064 @node GNAT Debug_Pools g-debpoo ads,GNAT Debug_Utilities g-debuti ads,GNAT Current_Exception g-curexc ads,The GNAT Library
24065 @anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{354}@anchor{gnat_rm/the_gnat_library id57}@anchor{355}
24066 @section @code{GNAT.Debug_Pools} (@code{g-debpoo.ads})
24069 @geindex GNAT.Debug_Pools (g-debpoo.ads)
24071 @geindex Debugging
24073 @geindex Debug pools
24075 @geindex Memory corruption debugging
24077 Provides a debugging storage pools that helps tracking memory corruption
24078 problems.
24079 See @code{The GNAT Debug_Pool Facility} section in the @cite{GNAT User’s Guide}.
24081 @node GNAT Debug_Utilities g-debuti ads,GNAT Decode_String g-decstr ads,GNAT Debug_Pools g-debpoo ads,The GNAT Library
24082 @anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{356}@anchor{gnat_rm/the_gnat_library id58}@anchor{357}
24083 @section @code{GNAT.Debug_Utilities} (@code{g-debuti.ads})
24086 @geindex GNAT.Debug_Utilities (g-debuti.ads)
24088 @geindex Debugging
24090 Provides a few useful utilities for debugging purposes, including conversion
24091 to and from string images of address values. Supports both C and Ada formats
24092 for hexadecimal literals.
24094 @node GNAT Decode_String g-decstr ads,GNAT Decode_UTF8_String g-deutst ads,GNAT Debug_Utilities g-debuti ads,The GNAT Library
24095 @anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{358}@anchor{gnat_rm/the_gnat_library id59}@anchor{359}
24096 @section @code{GNAT.Decode_String} (@code{g-decstr.ads})
24099 @geindex GNAT.Decode_String (g-decstr.ads)
24101 @geindex Decoding strings
24103 @geindex String decoding
24105 @geindex Wide character encoding
24107 @geindex UTF-8
24109 @geindex Unicode
24111 A generic package providing routines for decoding wide character and wide wide
24112 character strings encoded as sequences of 8-bit characters using a specified
24113 encoding method. Includes validation routines, and also routines for stepping
24114 to next or previous encoded character in an encoded string.
24115 Useful in conjunction with Unicode character coding. Note there is a
24116 preinstantiation for UTF-8. See next entry.
24118 @node GNAT Decode_UTF8_String g-deutst ads,GNAT Directory_Operations g-dirope ads,GNAT Decode_String g-decstr ads,The GNAT Library
24119 @anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{35a}@anchor{gnat_rm/the_gnat_library id60}@anchor{35b}
24120 @section @code{GNAT.Decode_UTF8_String} (@code{g-deutst.ads})
24123 @geindex GNAT.Decode_UTF8_String (g-deutst.ads)
24125 @geindex Decoding strings
24127 @geindex Decoding UTF-8 strings
24129 @geindex UTF-8 string decoding
24131 @geindex Wide character decoding
24133 @geindex UTF-8
24135 @geindex Unicode
24137 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
24139 @node GNAT Directory_Operations g-dirope ads,GNAT Directory_Operations Iteration g-diopit ads,GNAT Decode_UTF8_String g-deutst ads,The GNAT Library
24140 @anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{35c}@anchor{gnat_rm/the_gnat_library id61}@anchor{35d}
24141 @section @code{GNAT.Directory_Operations} (@code{g-dirope.ads})
24144 @geindex GNAT.Directory_Operations (g-dirope.ads)
24146 @geindex Directory operations
24148 Provides a set of routines for manipulating directories, including changing
24149 the current directory, making new directories, and scanning the files in a
24150 directory.
24152 @node GNAT Directory_Operations Iteration g-diopit ads,GNAT Dynamic_HTables g-dynhta ads,GNAT Directory_Operations g-dirope ads,The GNAT Library
24153 @anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{35e}@anchor{gnat_rm/the_gnat_library id62}@anchor{35f}
24154 @section @code{GNAT.Directory_Operations.Iteration} (@code{g-diopit.ads})
24157 @geindex GNAT.Directory_Operations.Iteration (g-diopit.ads)
24159 @geindex Directory operations iteration
24161 A child unit of GNAT.Directory_Operations providing additional operations
24162 for iterating through directories.
24164 @node GNAT Dynamic_HTables g-dynhta ads,GNAT Dynamic_Tables g-dyntab ads,GNAT Directory_Operations Iteration g-diopit ads,The GNAT Library
24165 @anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{360}@anchor{gnat_rm/the_gnat_library id63}@anchor{361}
24166 @section @code{GNAT.Dynamic_HTables} (@code{g-dynhta.ads})
24169 @geindex GNAT.Dynamic_HTables (g-dynhta.ads)
24171 @geindex Hash tables
24173 A generic implementation of hash tables that can be used to hash arbitrary
24174 data.  Provided in two forms, a simple form with built in hash functions,
24175 and a more complex form in which the hash function is supplied.
24177 This package provides a facility similar to that of @code{GNAT.HTable},
24178 except that this package declares a type that can be used to define
24179 dynamic instances of the hash table, while an instantiation of
24180 @code{GNAT.HTable} creates a single instance of the hash table.
24182 @node GNAT Dynamic_Tables g-dyntab ads,GNAT Encode_String g-encstr ads,GNAT Dynamic_HTables g-dynhta ads,The GNAT Library
24183 @anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{362}@anchor{gnat_rm/the_gnat_library id64}@anchor{363}
24184 @section @code{GNAT.Dynamic_Tables} (@code{g-dyntab.ads})
24187 @geindex GNAT.Dynamic_Tables (g-dyntab.ads)
24189 @geindex Table implementation
24191 @geindex Arrays
24192 @geindex extendable
24194 A generic package providing a single dimension array abstraction where the
24195 length of the array can be dynamically modified.
24197 This package provides a facility similar to that of @code{GNAT.Table},
24198 except that this package declares a type that can be used to define
24199 dynamic instances of the table, while an instantiation of
24200 @code{GNAT.Table} creates a single instance of the table type.
24202 @node GNAT Encode_String g-encstr ads,GNAT Encode_UTF8_String g-enutst ads,GNAT Dynamic_Tables g-dyntab ads,The GNAT Library
24203 @anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{364}@anchor{gnat_rm/the_gnat_library id65}@anchor{365}
24204 @section @code{GNAT.Encode_String} (@code{g-encstr.ads})
24207 @geindex GNAT.Encode_String (g-encstr.ads)
24209 @geindex Encoding strings
24211 @geindex String encoding
24213 @geindex Wide character encoding
24215 @geindex UTF-8
24217 @geindex Unicode
24219 A generic package providing routines for encoding wide character and wide
24220 wide character strings as sequences of 8-bit characters using a specified
24221 encoding method. Useful in conjunction with Unicode character coding.
24222 Note there is a preinstantiation for UTF-8. See next entry.
24224 @node GNAT Encode_UTF8_String g-enutst ads,GNAT Exception_Actions g-excact ads,GNAT Encode_String g-encstr ads,The GNAT Library
24225 @anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{366}@anchor{gnat_rm/the_gnat_library id66}@anchor{367}
24226 @section @code{GNAT.Encode_UTF8_String} (@code{g-enutst.ads})
24229 @geindex GNAT.Encode_UTF8_String (g-enutst.ads)
24231 @geindex Encoding strings
24233 @geindex Encoding UTF-8 strings
24235 @geindex UTF-8 string encoding
24237 @geindex Wide character encoding
24239 @geindex UTF-8
24241 @geindex Unicode
24243 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
24245 @node GNAT Exception_Actions g-excact ads,GNAT Exception_Traces g-exctra ads,GNAT Encode_UTF8_String g-enutst ads,The GNAT Library
24246 @anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{368}@anchor{gnat_rm/the_gnat_library id67}@anchor{369}
24247 @section @code{GNAT.Exception_Actions} (@code{g-excact.ads})
24250 @geindex GNAT.Exception_Actions (g-excact.ads)
24252 @geindex Exception actions
24254 Provides callbacks when an exception is raised. Callbacks can be registered
24255 for specific exceptions, or when any exception is raised. This
24256 can be used for instance to force a core dump to ease debugging.
24258 @node GNAT Exception_Traces g-exctra ads,GNAT Exceptions g-except ads,GNAT Exception_Actions g-excact ads,The GNAT Library
24259 @anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{36a}@anchor{gnat_rm/the_gnat_library id68}@anchor{36b}
24260 @section @code{GNAT.Exception_Traces} (@code{g-exctra.ads})
24263 @geindex GNAT.Exception_Traces (g-exctra.ads)
24265 @geindex Exception traces
24267 @geindex Debugging
24269 Provides an interface allowing to control automatic output upon exception
24270 occurrences.
24272 @node GNAT Exceptions g-except ads,GNAT Expect g-expect ads,GNAT Exception_Traces g-exctra ads,The GNAT Library
24273 @anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{36c}@anchor{gnat_rm/the_gnat_library id69}@anchor{36d}
24274 @section @code{GNAT.Exceptions} (@code{g-except.ads})
24277 @geindex GNAT.Exceptions (g-except.ads)
24279 @geindex Exceptions
24280 @geindex Pure
24282 @geindex Pure packages
24283 @geindex exceptions
24285 Normally it is not possible to raise an exception with
24286 a message from a subprogram in a pure package, since the
24287 necessary types and subprograms are in @code{Ada.Exceptions}
24288 which is not a pure unit. @code{GNAT.Exceptions} provides a
24289 facility for getting around this limitation for a few
24290 predefined exceptions, and for example allows raising
24291 @code{Constraint_Error} with a message from a pure subprogram.
24293 @node GNAT Expect g-expect ads,GNAT Expect TTY g-exptty ads,GNAT Exceptions g-except ads,The GNAT Library
24294 @anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{36e}@anchor{gnat_rm/the_gnat_library id70}@anchor{36f}
24295 @section @code{GNAT.Expect} (@code{g-expect.ads})
24298 @geindex GNAT.Expect (g-expect.ads)
24300 Provides a set of subprograms similar to what is available
24301 with the standard Tcl Expect tool.
24302 It allows you to easily spawn and communicate with an external process.
24303 You can send commands or inputs to the process, and compare the output
24304 with some expected regular expression. Currently @code{GNAT.Expect}
24305 is implemented on all native GNAT ports.
24306 It is not implemented for cross ports, and in particular is not
24307 implemented for VxWorks or LynxOS.
24309 @node GNAT Expect TTY g-exptty ads,GNAT Float_Control g-flocon ads,GNAT Expect g-expect ads,The GNAT Library
24310 @anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{370}@anchor{gnat_rm/the_gnat_library id71}@anchor{371}
24311 @section @code{GNAT.Expect.TTY} (@code{g-exptty.ads})
24314 @geindex GNAT.Expect.TTY (g-exptty.ads)
24316 As GNAT.Expect but using pseudo-terminal.
24317 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
24318 ports. It is not implemented for cross ports, and
24319 in particular is not implemented for VxWorks or LynxOS.
24321 @node GNAT Float_Control g-flocon ads,GNAT Formatted_String g-forstr ads,GNAT Expect TTY g-exptty ads,The GNAT Library
24322 @anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{372}@anchor{gnat_rm/the_gnat_library id72}@anchor{373}
24323 @section @code{GNAT.Float_Control} (@code{g-flocon.ads})
24326 @geindex GNAT.Float_Control (g-flocon.ads)
24328 @geindex Floating-Point Processor
24330 Provides an interface for resetting the floating-point processor into the
24331 mode required for correct semantic operation in Ada.  Some third party
24332 library calls may cause this mode to be modified, and the Reset procedure
24333 in this package can be used to reestablish the required mode.
24335 @node GNAT Formatted_String g-forstr ads,GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Float_Control g-flocon ads,The GNAT Library
24336 @anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{374}@anchor{gnat_rm/the_gnat_library id73}@anchor{375}
24337 @section @code{GNAT.Formatted_String} (@code{g-forstr.ads})
24340 @geindex GNAT.Formatted_String (g-forstr.ads)
24342 @geindex Formatted String
24344 Provides support for C/C++ printf() formatted strings. The format is
24345 copied from the printf() routine and should therefore give identical
24346 output. Some generic routines are provided to be able to use types
24347 derived from Integer, Float or enumerations as values for the
24348 formatted string.
24350 @node GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Heap_Sort g-heasor ads,GNAT Formatted_String g-forstr ads,The GNAT Library
24351 @anchor{gnat_rm/the_gnat_library gnat-generic-fast-math-functions-g-gfmafu-ads}@anchor{376}@anchor{gnat_rm/the_gnat_library id74}@anchor{377}
24352 @section @code{GNAT.Generic_Fast_Math_Functions} (@code{g-gfmafu.ads})
24355 @geindex GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads)
24357 @geindex Mathematical functions
24359 Provides direct access to the underlying implementation of the common
24360 mathematical functions, generally from the system mathematical library.
24361 This differs from @code{Ada.Numerics.Generic_Elementary_Functions} in that
24362 the implementation may deviate from the semantics specified for these
24363 functions in the Reference Manual, for example @code{Numerics.Argument_Error}
24364 is not raised. On selected platforms, some of these functions may also
24365 have a vector implementation that can be automatically used by the
24366 compiler when auto-vectorization is enabled.
24368 @node GNAT Heap_Sort g-heasor ads,GNAT Heap_Sort_A g-hesora ads,GNAT Generic_Fast_Math_Functions g-gfmafu ads,The GNAT Library
24369 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{378}@anchor{gnat_rm/the_gnat_library id75}@anchor{379}
24370 @section @code{GNAT.Heap_Sort} (@code{g-heasor.ads})
24373 @geindex GNAT.Heap_Sort (g-heasor.ads)
24375 @geindex Sorting
24377 Provides a general implementation of heap sort usable for sorting arbitrary
24378 data items. Exchange and comparison procedures are provided by passing
24379 access-to-procedure values.  The algorithm used is a modified heap sort
24380 that performs approximately N*log(N) comparisons in the worst case.
24382 @node GNAT Heap_Sort_A g-hesora ads,GNAT Heap_Sort_G g-hesorg ads,GNAT Heap_Sort g-heasor ads,The GNAT Library
24383 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{37a}@anchor{gnat_rm/the_gnat_library id76}@anchor{37b}
24384 @section @code{GNAT.Heap_Sort_A} (@code{g-hesora.ads})
24387 @geindex GNAT.Heap_Sort_A (g-hesora.ads)
24389 @geindex Sorting
24391 Provides a general implementation of heap sort usable for sorting arbitrary
24392 data items. Move and comparison procedures are provided by passing
24393 access-to-procedure values.  The algorithm used is a modified heap sort
24394 that performs approximately N*log(N) comparisons in the worst case.
24395 This differs from @code{GNAT.Heap_Sort} in having a less convenient
24396 interface, but may be slightly more efficient.
24398 @node GNAT Heap_Sort_G g-hesorg ads,GNAT HTable g-htable ads,GNAT Heap_Sort_A g-hesora ads,The GNAT Library
24399 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{37c}@anchor{gnat_rm/the_gnat_library id77}@anchor{37d}
24400 @section @code{GNAT.Heap_Sort_G} (@code{g-hesorg.ads})
24403 @geindex GNAT.Heap_Sort_G (g-hesorg.ads)
24405 @geindex Sorting
24407 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
24408 are provided as generic parameters, this improves efficiency, especially
24409 if the procedures can be inlined, at the expense of duplicating code for
24410 multiple instantiations.
24412 @node GNAT HTable g-htable ads,GNAT IO g-io ads,GNAT Heap_Sort_G g-hesorg ads,The GNAT Library
24413 @anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{37e}@anchor{gnat_rm/the_gnat_library id78}@anchor{37f}
24414 @section @code{GNAT.HTable} (@code{g-htable.ads})
24417 @geindex GNAT.HTable (g-htable.ads)
24419 @geindex Hash tables
24421 A generic implementation of hash tables that can be used to hash arbitrary
24422 data.  Provides two approaches, one a simple static approach, and the other
24423 allowing arbitrary dynamic hash tables.
24425 @node GNAT IO g-io ads,GNAT IO_Aux g-io_aux ads,GNAT HTable g-htable ads,The GNAT Library
24426 @anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{380}@anchor{gnat_rm/the_gnat_library id79}@anchor{381}
24427 @section @code{GNAT.IO} (@code{g-io.ads})
24430 @geindex GNAT.IO (g-io.ads)
24432 @geindex Simple I/O
24434 @geindex Input/Output facilities
24436 A simple preelaborable input-output package that provides a subset of
24437 simple Text_IO functions for reading characters and strings from
24438 Standard_Input, and writing characters, strings and integers to either
24439 Standard_Output or Standard_Error.
24441 @node GNAT IO_Aux g-io_aux ads,GNAT Lock_Files g-locfil ads,GNAT IO g-io ads,The GNAT Library
24442 @anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{382}@anchor{gnat_rm/the_gnat_library id80}@anchor{383}
24443 @section @code{GNAT.IO_Aux} (@code{g-io_aux.ads})
24446 @geindex GNAT.IO_Aux (g-io_aux.ads)
24448 @geindex Text_IO
24450 @geindex Input/Output facilities
24452 Provides some auxiliary functions for use with Text_IO, including a test
24453 for whether a file exists, and functions for reading a line of text.
24455 @node GNAT Lock_Files g-locfil ads,GNAT MBBS_Discrete_Random g-mbdira ads,GNAT IO_Aux g-io_aux ads,The GNAT Library
24456 @anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{384}@anchor{gnat_rm/the_gnat_library id81}@anchor{385}
24457 @section @code{GNAT.Lock_Files} (@code{g-locfil.ads})
24460 @geindex GNAT.Lock_Files (g-locfil.ads)
24462 @geindex File locking
24464 @geindex Locking using files
24466 Provides a general interface for using files as locks.  Can be used for
24467 providing program level synchronization.
24469 @node GNAT MBBS_Discrete_Random g-mbdira ads,GNAT MBBS_Float_Random g-mbflra ads,GNAT Lock_Files g-locfil ads,The GNAT Library
24470 @anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{386}@anchor{gnat_rm/the_gnat_library id82}@anchor{387}
24471 @section @code{GNAT.MBBS_Discrete_Random} (@code{g-mbdira.ads})
24474 @geindex GNAT.MBBS_Discrete_Random (g-mbdira.ads)
24476 @geindex Random number generation
24478 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
24479 a modified version of the Blum-Blum-Shub generator.
24481 @node GNAT MBBS_Float_Random g-mbflra ads,GNAT MD5 g-md5 ads,GNAT MBBS_Discrete_Random g-mbdira ads,The GNAT Library
24482 @anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{388}@anchor{gnat_rm/the_gnat_library id83}@anchor{389}
24483 @section @code{GNAT.MBBS_Float_Random} (@code{g-mbflra.ads})
24486 @geindex GNAT.MBBS_Float_Random (g-mbflra.ads)
24488 @geindex Random number generation
24490 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
24491 a modified version of the Blum-Blum-Shub generator.
24493 @node GNAT MD5 g-md5 ads,GNAT Memory_Dump g-memdum ads,GNAT MBBS_Float_Random g-mbflra ads,The GNAT Library
24494 @anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{38a}@anchor{gnat_rm/the_gnat_library id84}@anchor{38b}
24495 @section @code{GNAT.MD5} (@code{g-md5.ads})
24498 @geindex GNAT.MD5 (g-md5.ads)
24500 @geindex Message Digest MD5
24502 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
24503 the HMAC-MD5 message authentication function as described in RFC 2104 and
24504 FIPS PUB 198.
24506 @node GNAT Memory_Dump g-memdum ads,GNAT Most_Recent_Exception g-moreex ads,GNAT MD5 g-md5 ads,The GNAT Library
24507 @anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{38c}@anchor{gnat_rm/the_gnat_library id85}@anchor{38d}
24508 @section @code{GNAT.Memory_Dump} (@code{g-memdum.ads})
24511 @geindex GNAT.Memory_Dump (g-memdum.ads)
24513 @geindex Dump Memory
24515 Provides a convenient routine for dumping raw memory to either the
24516 standard output or standard error files. Uses GNAT.IO for actual
24517 output.
24519 @node GNAT Most_Recent_Exception g-moreex ads,GNAT OS_Lib g-os_lib ads,GNAT Memory_Dump g-memdum ads,The GNAT Library
24520 @anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{38e}@anchor{gnat_rm/the_gnat_library id86}@anchor{38f}
24521 @section @code{GNAT.Most_Recent_Exception} (@code{g-moreex.ads})
24524 @geindex GNAT.Most_Recent_Exception (g-moreex.ads)
24526 @geindex Exception
24527 @geindex obtaining most recent
24529 Provides access to the most recently raised exception.  Can be used for
24530 various logging purposes, including duplicating functionality of some
24531 Ada 83 implementation dependent extensions.
24533 @node GNAT OS_Lib g-os_lib ads,GNAT Perfect_Hash_Generators g-pehage ads,GNAT Most_Recent_Exception g-moreex ads,The GNAT Library
24534 @anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{390}@anchor{gnat_rm/the_gnat_library id87}@anchor{391}
24535 @section @code{GNAT.OS_Lib} (@code{g-os_lib.ads})
24538 @geindex GNAT.OS_Lib (g-os_lib.ads)
24540 @geindex Operating System interface
24542 @geindex Spawn capability
24544 Provides a range of target independent operating system interface functions,
24545 including time/date management, file operations, subprocess management,
24546 including a portable spawn procedure, and access to environment variables
24547 and error return codes.
24549 @node GNAT Perfect_Hash_Generators g-pehage ads,GNAT Random_Numbers g-rannum ads,GNAT OS_Lib g-os_lib ads,The GNAT Library
24550 @anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{392}@anchor{gnat_rm/the_gnat_library id88}@anchor{393}
24551 @section @code{GNAT.Perfect_Hash_Generators} (@code{g-pehage.ads})
24554 @geindex GNAT.Perfect_Hash_Generators (g-pehage.ads)
24556 @geindex Hash functions
24558 Provides a generator of static minimal perfect hash functions. No
24559 collisions occur and each item can be retrieved from the table in one
24560 probe (perfect property). The hash table size corresponds to the exact
24561 size of the key set and no larger (minimal property). The key set has to
24562 be known in advance (static property). The hash functions are also order
24563 preserving. If w2 is inserted after w1 in the generator, their
24564 hashcode are in the same order. These hashing functions are very
24565 convenient for use with realtime applications.
24567 @node GNAT Random_Numbers g-rannum ads,GNAT Regexp g-regexp ads,GNAT Perfect_Hash_Generators g-pehage ads,The GNAT Library
24568 @anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{394}@anchor{gnat_rm/the_gnat_library id89}@anchor{395}
24569 @section @code{GNAT.Random_Numbers} (@code{g-rannum.ads})
24572 @geindex GNAT.Random_Numbers (g-rannum.ads)
24574 @geindex Random number generation
24576 Provides random number capabilities which extend those available in the
24577 standard Ada library and are more convenient to use.
24579 @node GNAT Regexp g-regexp ads,GNAT Registry g-regist ads,GNAT Random_Numbers g-rannum ads,The GNAT Library
24580 @anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{26b}@anchor{gnat_rm/the_gnat_library id90}@anchor{396}
24581 @section @code{GNAT.Regexp} (@code{g-regexp.ads})
24584 @geindex GNAT.Regexp (g-regexp.ads)
24586 @geindex Regular expressions
24588 @geindex Pattern matching
24590 A simple implementation of regular expressions, using a subset of regular
24591 expression syntax copied from familiar Unix style utilities.  This is the
24592 simplest of the three pattern matching packages provided, and is particularly
24593 suitable for ‘file globbing’ applications.
24595 @node GNAT Registry g-regist ads,GNAT Regpat g-regpat ads,GNAT Regexp g-regexp ads,The GNAT Library
24596 @anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{397}@anchor{gnat_rm/the_gnat_library id91}@anchor{398}
24597 @section @code{GNAT.Registry} (@code{g-regist.ads})
24600 @geindex GNAT.Registry (g-regist.ads)
24602 @geindex Windows Registry
24604 This is a high level binding to the Windows registry.  It is possible to
24605 do simple things like reading a key value, creating a new key.  For full
24606 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
24607 package provided with the Win32Ada binding
24609 @node GNAT Regpat g-regpat ads,GNAT Rewrite_Data g-rewdat ads,GNAT Registry g-regist ads,The GNAT Library
24610 @anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{399}@anchor{gnat_rm/the_gnat_library id92}@anchor{39a}
24611 @section @code{GNAT.Regpat} (@code{g-regpat.ads})
24614 @geindex GNAT.Regpat (g-regpat.ads)
24616 @geindex Regular expressions
24618 @geindex Pattern matching
24620 A complete implementation of Unix-style regular expression matching, copied
24621 from the original V7 style regular expression library written in C by
24622 Henry Spencer (and binary compatible with this C library).
24624 @node GNAT Rewrite_Data g-rewdat ads,GNAT Secondary_Stack_Info g-sestin ads,GNAT Regpat g-regpat ads,The GNAT Library
24625 @anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{39b}@anchor{gnat_rm/the_gnat_library id93}@anchor{39c}
24626 @section @code{GNAT.Rewrite_Data} (@code{g-rewdat.ads})
24629 @geindex GNAT.Rewrite_Data (g-rewdat.ads)
24631 @geindex Rewrite data
24633 A unit to rewrite on-the-fly string occurrences in a stream of
24634 data. The implementation has a very minimal memory footprint as the
24635 full content to be processed is not loaded into memory all at once. This makes
24636 this interface usable for large files or socket streams.
24638 @node GNAT Secondary_Stack_Info g-sestin ads,GNAT Semaphores g-semaph ads,GNAT Rewrite_Data g-rewdat ads,The GNAT Library
24639 @anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{39d}@anchor{gnat_rm/the_gnat_library id94}@anchor{39e}
24640 @section @code{GNAT.Secondary_Stack_Info} (@code{g-sestin.ads})
24643 @geindex GNAT.Secondary_Stack_Info (g-sestin.ads)
24645 @geindex Secondary Stack Info
24647 Provides the capability to query the high water mark of the current task’s
24648 secondary stack.
24650 @node GNAT Semaphores g-semaph ads,GNAT Serial_Communications g-sercom ads,GNAT Secondary_Stack_Info g-sestin ads,The GNAT Library
24651 @anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{39f}@anchor{gnat_rm/the_gnat_library id95}@anchor{3a0}
24652 @section @code{GNAT.Semaphores} (@code{g-semaph.ads})
24655 @geindex GNAT.Semaphores (g-semaph.ads)
24657 @geindex Semaphores
24659 Provides classic counting and binary semaphores using protected types.
24661 @node GNAT Serial_Communications g-sercom ads,GNAT SHA1 g-sha1 ads,GNAT Semaphores g-semaph ads,The GNAT Library
24662 @anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{3a1}@anchor{gnat_rm/the_gnat_library id96}@anchor{3a2}
24663 @section @code{GNAT.Serial_Communications} (@code{g-sercom.ads})
24666 @geindex GNAT.Serial_Communications (g-sercom.ads)
24668 @geindex Serial_Communications
24670 Provides a simple interface to send and receive data over a serial
24671 port. This is only supported on GNU/Linux and Windows.
24673 @node GNAT SHA1 g-sha1 ads,GNAT SHA224 g-sha224 ads,GNAT Serial_Communications g-sercom ads,The GNAT Library
24674 @anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{3a3}@anchor{gnat_rm/the_gnat_library id97}@anchor{3a4}
24675 @section @code{GNAT.SHA1} (@code{g-sha1.ads})
24678 @geindex GNAT.SHA1 (g-sha1.ads)
24680 @geindex Secure Hash Algorithm SHA-1
24682 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
24683 and RFC 3174, and the HMAC-SHA1 message authentication function as described
24684 in RFC 2104 and FIPS PUB 198.
24686 @node GNAT SHA224 g-sha224 ads,GNAT SHA256 g-sha256 ads,GNAT SHA1 g-sha1 ads,The GNAT Library
24687 @anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a5}@anchor{gnat_rm/the_gnat_library id98}@anchor{3a6}
24688 @section @code{GNAT.SHA224} (@code{g-sha224.ads})
24691 @geindex GNAT.SHA224 (g-sha224.ads)
24693 @geindex Secure Hash Algorithm SHA-224
24695 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
24696 and the HMAC-SHA224 message authentication function as described
24697 in RFC 2104 and FIPS PUB 198.
24699 @node GNAT SHA256 g-sha256 ads,GNAT SHA384 g-sha384 ads,GNAT SHA224 g-sha224 ads,The GNAT Library
24700 @anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3a7}@anchor{gnat_rm/the_gnat_library id99}@anchor{3a8}
24701 @section @code{GNAT.SHA256} (@code{g-sha256.ads})
24704 @geindex GNAT.SHA256 (g-sha256.ads)
24706 @geindex Secure Hash Algorithm SHA-256
24708 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
24709 and the HMAC-SHA256 message authentication function as described
24710 in RFC 2104 and FIPS PUB 198.
24712 @node GNAT SHA384 g-sha384 ads,GNAT SHA512 g-sha512 ads,GNAT SHA256 g-sha256 ads,The GNAT Library
24713 @anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3a9}@anchor{gnat_rm/the_gnat_library id100}@anchor{3aa}
24714 @section @code{GNAT.SHA384} (@code{g-sha384.ads})
24717 @geindex GNAT.SHA384 (g-sha384.ads)
24719 @geindex Secure Hash Algorithm SHA-384
24721 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
24722 and the HMAC-SHA384 message authentication function as described
24723 in RFC 2104 and FIPS PUB 198.
24725 @node GNAT SHA512 g-sha512 ads,GNAT Signals g-signal ads,GNAT SHA384 g-sha384 ads,The GNAT Library
24726 @anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3ab}@anchor{gnat_rm/the_gnat_library id101}@anchor{3ac}
24727 @section @code{GNAT.SHA512} (@code{g-sha512.ads})
24730 @geindex GNAT.SHA512 (g-sha512.ads)
24732 @geindex Secure Hash Algorithm SHA-512
24734 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
24735 and the HMAC-SHA512 message authentication function as described
24736 in RFC 2104 and FIPS PUB 198.
24738 @node GNAT Signals g-signal ads,GNAT Sockets g-socket ads,GNAT SHA512 g-sha512 ads,The GNAT Library
24739 @anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3ad}@anchor{gnat_rm/the_gnat_library id102}@anchor{3ae}
24740 @section @code{GNAT.Signals} (@code{g-signal.ads})
24743 @geindex GNAT.Signals (g-signal.ads)
24745 @geindex Signals
24747 Provides the ability to manipulate the blocked status of signals on supported
24748 targets.
24750 @node GNAT Sockets g-socket ads,GNAT Source_Info g-souinf ads,GNAT Signals g-signal ads,The GNAT Library
24751 @anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3af}@anchor{gnat_rm/the_gnat_library id103}@anchor{3b0}
24752 @section @code{GNAT.Sockets} (@code{g-socket.ads})
24755 @geindex GNAT.Sockets (g-socket.ads)
24757 @geindex Sockets
24759 A high level and portable interface to develop sockets based applications.
24760 This package is based on the sockets thin binding found in
24761 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
24762 on all native GNAT ports and on VxWorks cross ports.  It is not implemented for
24763 the LynxOS cross port.
24765 @node GNAT Source_Info g-souinf ads,GNAT Spelling_Checker g-speche ads,GNAT Sockets g-socket ads,The GNAT Library
24766 @anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3b1}@anchor{gnat_rm/the_gnat_library id104}@anchor{3b2}
24767 @section @code{GNAT.Source_Info} (@code{g-souinf.ads})
24770 @geindex GNAT.Source_Info (g-souinf.ads)
24772 @geindex Source Information
24774 Provides subprograms that give access to source code information known at
24775 compile time, such as the current file name and line number. Also provides
24776 subprograms yielding the date and time of the current compilation (like the
24777 C macros @code{__DATE__} and @code{__TIME__})
24779 @node GNAT Spelling_Checker g-speche ads,GNAT Spelling_Checker_Generic g-spchge ads,GNAT Source_Info g-souinf ads,The GNAT Library
24780 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b3}@anchor{gnat_rm/the_gnat_library id105}@anchor{3b4}
24781 @section @code{GNAT.Spelling_Checker} (@code{g-speche.ads})
24784 @geindex GNAT.Spelling_Checker (g-speche.ads)
24786 @geindex Spell checking
24788 Provides a function for determining whether one string is a plausible
24789 near misspelling of another string.
24791 @node GNAT Spelling_Checker_Generic g-spchge ads,GNAT Spitbol Patterns g-spipat ads,GNAT Spelling_Checker g-speche ads,The GNAT Library
24792 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b5}@anchor{gnat_rm/the_gnat_library id106}@anchor{3b6}
24793 @section @code{GNAT.Spelling_Checker_Generic} (@code{g-spchge.ads})
24796 @geindex GNAT.Spelling_Checker_Generic (g-spchge.ads)
24798 @geindex Spell checking
24800 Provides a generic function that can be instantiated with a string type for
24801 determining whether one string is a plausible near misspelling of another
24802 string.
24804 @node GNAT Spitbol Patterns g-spipat ads,GNAT Spitbol g-spitbo ads,GNAT Spelling_Checker_Generic g-spchge ads,The GNAT Library
24805 @anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3b7}@anchor{gnat_rm/the_gnat_library id107}@anchor{3b8}
24806 @section @code{GNAT.Spitbol.Patterns} (@code{g-spipat.ads})
24809 @geindex GNAT.Spitbol.Patterns (g-spipat.ads)
24811 @geindex SPITBOL pattern matching
24813 @geindex Pattern matching
24815 A complete implementation of SNOBOL4 style pattern matching.  This is the
24816 most elaborate of the pattern matching packages provided.  It fully duplicates
24817 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
24818 efficient algorithm developed by Robert Dewar for the SPITBOL system.
24820 @node GNAT Spitbol g-spitbo ads,GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Patterns g-spipat ads,The GNAT Library
24821 @anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3b9}@anchor{gnat_rm/the_gnat_library id108}@anchor{3ba}
24822 @section @code{GNAT.Spitbol} (@code{g-spitbo.ads})
24825 @geindex GNAT.Spitbol (g-spitbo.ads)
24827 @geindex SPITBOL interface
24829 The top level package of the collection of SPITBOL-style functionality, this
24830 package provides basic SNOBOL4 string manipulation functions, such as
24831 Pad, Reverse, Trim, Substr capability, as well as a generic table function
24832 useful for constructing arbitrary mappings from strings in the style of
24833 the SNOBOL4 TABLE function.
24835 @node GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol g-spitbo ads,The GNAT Library
24836 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3bb}@anchor{gnat_rm/the_gnat_library id109}@anchor{3bc}
24837 @section @code{GNAT.Spitbol.Table_Boolean} (@code{g-sptabo.ads})
24840 @geindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
24842 @geindex Sets of strings
24844 @geindex SPITBOL Tables
24846 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24847 for type @code{Standard.Boolean}, giving an implementation of sets of
24848 string values.
24850 @node GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol Table_VString g-sptavs ads,GNAT Spitbol Table_Boolean g-sptabo ads,The GNAT Library
24851 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3bd}@anchor{gnat_rm/the_gnat_library id110}@anchor{3be}
24852 @section @code{GNAT.Spitbol.Table_Integer} (@code{g-sptain.ads})
24855 @geindex GNAT.Spitbol.Table_Integer (g-sptain.ads)
24857 @geindex Integer maps
24859 @geindex Maps
24861 @geindex SPITBOL Tables
24863 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24864 for type @code{Standard.Integer}, giving an implementation of maps
24865 from string to integer values.
24867 @node GNAT Spitbol Table_VString g-sptavs ads,GNAT SSE g-sse ads,GNAT Spitbol Table_Integer g-sptain ads,The GNAT Library
24868 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3bf}@anchor{gnat_rm/the_gnat_library id111}@anchor{3c0}
24869 @section @code{GNAT.Spitbol.Table_VString} (@code{g-sptavs.ads})
24872 @geindex GNAT.Spitbol.Table_VString (g-sptavs.ads)
24874 @geindex String maps
24876 @geindex Maps
24878 @geindex SPITBOL Tables
24880 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
24881 a variable length string type, giving an implementation of general
24882 maps from strings to strings.
24884 @node GNAT SSE g-sse ads,GNAT SSE Vector_Types g-ssvety ads,GNAT Spitbol Table_VString g-sptavs ads,The GNAT Library
24885 @anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3c1}@anchor{gnat_rm/the_gnat_library id112}@anchor{3c2}
24886 @section @code{GNAT.SSE} (@code{g-sse.ads})
24889 @geindex GNAT.SSE (g-sse.ads)
24891 Root of a set of units aimed at offering Ada bindings to a subset of
24892 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
24893 targets.  It exposes vector component types together with a general
24894 introduction to the binding contents and use.
24896 @node GNAT SSE Vector_Types g-ssvety ads,GNAT String_Hash g-strhas ads,GNAT SSE g-sse ads,The GNAT Library
24897 @anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3c3}@anchor{gnat_rm/the_gnat_library id113}@anchor{3c4}
24898 @section @code{GNAT.SSE.Vector_Types} (@code{g-ssvety.ads})
24901 @geindex GNAT.SSE.Vector_Types (g-ssvety.ads)
24903 SSE vector types for use with SSE related intrinsics.
24905 @node GNAT String_Hash g-strhas ads,GNAT Strings g-string ads,GNAT SSE Vector_Types g-ssvety ads,The GNAT Library
24906 @anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c5}@anchor{gnat_rm/the_gnat_library id114}@anchor{3c6}
24907 @section @code{GNAT.String_Hash} (@code{g-strhas.ads})
24910 @geindex GNAT.String_Hash (g-strhas.ads)
24912 @geindex Hash functions
24914 Provides a generic hash function working on arrays of scalars. Both the scalar
24915 type and the hash result type are parameters.
24917 @node GNAT Strings g-string ads,GNAT String_Split g-strspl ads,GNAT String_Hash g-strhas ads,The GNAT Library
24918 @anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3c7}@anchor{gnat_rm/the_gnat_library id115}@anchor{3c8}
24919 @section @code{GNAT.Strings} (@code{g-string.ads})
24922 @geindex GNAT.Strings (g-string.ads)
24924 Common String access types and related subprograms. Basically it
24925 defines a string access and an array of string access types.
24927 @node GNAT String_Split g-strspl ads,GNAT Table g-table ads,GNAT Strings g-string ads,The GNAT Library
24928 @anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3c9}@anchor{gnat_rm/the_gnat_library id116}@anchor{3ca}
24929 @section @code{GNAT.String_Split} (@code{g-strspl.ads})
24932 @geindex GNAT.String_Split (g-strspl.ads)
24934 @geindex String splitter
24936 Useful string manipulation routines: given a set of separators, split
24937 a string wherever the separators appear, and provide direct access
24938 to the resulting slices. This package is instantiated from
24939 @code{GNAT.Array_Split}.
24941 @node GNAT Table g-table ads,GNAT Task_Lock g-tasloc ads,GNAT String_Split g-strspl ads,The GNAT Library
24942 @anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3cb}@anchor{gnat_rm/the_gnat_library id117}@anchor{3cc}
24943 @section @code{GNAT.Table} (@code{g-table.ads})
24946 @geindex GNAT.Table (g-table.ads)
24948 @geindex Table implementation
24950 @geindex Arrays
24951 @geindex extendable
24953 A generic package providing a single dimension array abstraction where the
24954 length of the array can be dynamically modified.
24956 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
24957 except that this package declares a single instance of the table type,
24958 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
24959 used to define dynamic instances of the table.
24961 @node GNAT Task_Lock g-tasloc ads,GNAT Time_Stamp g-timsta ads,GNAT Table g-table ads,The GNAT Library
24962 @anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3cd}@anchor{gnat_rm/the_gnat_library id118}@anchor{3ce}
24963 @section @code{GNAT.Task_Lock} (@code{g-tasloc.ads})
24966 @geindex GNAT.Task_Lock (g-tasloc.ads)
24968 @geindex Task synchronization
24970 @geindex Task locking
24972 @geindex Locking
24974 A very simple facility for locking and unlocking sections of code using a
24975 single global task lock.  Appropriate for use in situations where contention
24976 between tasks is very rarely expected.
24978 @node GNAT Time_Stamp g-timsta ads,GNAT Threads g-thread ads,GNAT Task_Lock g-tasloc ads,The GNAT Library
24979 @anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3cf}@anchor{gnat_rm/the_gnat_library id119}@anchor{3d0}
24980 @section @code{GNAT.Time_Stamp} (@code{g-timsta.ads})
24983 @geindex GNAT.Time_Stamp (g-timsta.ads)
24985 @geindex Time stamp
24987 @geindex Current time
24989 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
24990 represents the current date and time in ISO 8601 format. This is a very simple
24991 routine with minimal code and there are no dependencies on any other unit.
24993 @node GNAT Threads g-thread ads,GNAT Traceback g-traceb ads,GNAT Time_Stamp g-timsta ads,The GNAT Library
24994 @anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3d1}@anchor{gnat_rm/the_gnat_library id120}@anchor{3d2}
24995 @section @code{GNAT.Threads} (@code{g-thread.ads})
24998 @geindex GNAT.Threads (g-thread.ads)
25000 @geindex Foreign threads
25002 @geindex Threads
25003 @geindex foreign
25005 Provides facilities for dealing with foreign threads which need to be known
25006 by the GNAT run-time system. Consult the documentation of this package for
25007 further details if your program has threads that are created by a non-Ada
25008 environment which then accesses Ada code.
25010 @node GNAT Traceback g-traceb ads,GNAT Traceback Symbolic g-trasym ads,GNAT Threads g-thread ads,The GNAT Library
25011 @anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d3}@anchor{gnat_rm/the_gnat_library id121}@anchor{3d4}
25012 @section @code{GNAT.Traceback} (@code{g-traceb.ads})
25015 @geindex GNAT.Traceback (g-traceb.ads)
25017 @geindex Trace back facilities
25019 Provides a facility for obtaining non-symbolic traceback information, useful
25020 in various debugging situations.
25022 @node GNAT Traceback Symbolic g-trasym ads,GNAT UTF_32 g-utf_32 ads,GNAT Traceback g-traceb ads,The GNAT Library
25023 @anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d5}@anchor{gnat_rm/the_gnat_library id122}@anchor{3d6}
25024 @section @code{GNAT.Traceback.Symbolic} (@code{g-trasym.ads})
25027 @geindex GNAT.Traceback.Symbolic (g-trasym.ads)
25029 @geindex Trace back facilities
25031 @node GNAT UTF_32 g-utf_32 ads,GNAT UTF_32_Spelling_Checker g-u3spch ads,GNAT Traceback Symbolic g-trasym ads,The GNAT Library
25032 @anchor{gnat_rm/the_gnat_library gnat-utf-32-g-utf-32-ads}@anchor{3d7}@anchor{gnat_rm/the_gnat_library id123}@anchor{3d8}
25033 @section @code{GNAT.UTF_32} (@code{g-utf_32.ads})
25036 @geindex GNAT.UTF_32 (g-utf_32.ads)
25038 @geindex Wide character codes
25040 This is a package intended to be used in conjunction with the
25041 @code{Wide_Character} type in Ada 95 and the
25042 @code{Wide_Wide_Character} type in Ada 2005 (available
25043 in @code{GNAT} in Ada 2005 mode). This package contains
25044 Unicode categorization routines, as well as lexical
25045 categorization routines corresponding to the Ada 2005
25046 lexical rules for identifiers and strings, and also a
25047 lower case to upper case fold routine corresponding to
25048 the Ada 2005 rules for identifier equivalence.
25050 @node GNAT UTF_32_Spelling_Checker g-u3spch ads,GNAT Wide_Spelling_Checker g-wispch ads,GNAT UTF_32 g-utf_32 ads,The GNAT Library
25051 @anchor{gnat_rm/the_gnat_library gnat-utf-32-spelling-checker-g-u3spch-ads}@anchor{3d9}@anchor{gnat_rm/the_gnat_library id124}@anchor{3da}
25052 @section @code{GNAT.UTF_32_Spelling_Checker} (@code{g-u3spch.ads})
25055 @geindex GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
25057 @geindex Spell checking
25059 Provides a function for determining whether one wide wide string is a plausible
25060 near misspelling of another wide wide string, where the strings are represented
25061 using the UTF_32_String type defined in System.Wch_Cnv.
25063 @node GNAT Wide_Spelling_Checker g-wispch ads,GNAT Wide_String_Split g-wistsp ads,GNAT UTF_32_Spelling_Checker g-u3spch ads,The GNAT Library
25064 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3db}@anchor{gnat_rm/the_gnat_library id125}@anchor{3dc}
25065 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-wispch.ads})
25068 @geindex GNAT.Wide_Spelling_Checker (g-wispch.ads)
25070 @geindex Spell checking
25072 Provides a function for determining whether one wide string is a plausible
25073 near misspelling of another wide string.
25075 @node GNAT Wide_String_Split g-wistsp ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Spelling_Checker g-wispch ads,The GNAT Library
25076 @anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3dd}@anchor{gnat_rm/the_gnat_library id126}@anchor{3de}
25077 @section @code{GNAT.Wide_String_Split} (@code{g-wistsp.ads})
25080 @geindex GNAT.Wide_String_Split (g-wistsp.ads)
25082 @geindex Wide_String splitter
25084 Useful wide string manipulation routines: given a set of separators, split
25085 a wide string wherever the separators appear, and provide direct access
25086 to the resulting slices. This package is instantiated from
25087 @code{GNAT.Array_Split}.
25089 @node GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Wide_String_Split g-zistsp ads,GNAT Wide_String_Split g-wistsp ads,The GNAT Library
25090 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3df}@anchor{gnat_rm/the_gnat_library id127}@anchor{3e0}
25091 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@code{g-zspche.ads})
25094 @geindex GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
25096 @geindex Spell checking
25098 Provides a function for determining whether one wide wide string is a plausible
25099 near misspelling of another wide wide string.
25101 @node GNAT Wide_Wide_String_Split g-zistsp ads,Interfaces C Extensions i-cexten ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,The GNAT Library
25102 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3e1}@anchor{gnat_rm/the_gnat_library id128}@anchor{3e2}
25103 @section @code{GNAT.Wide_Wide_String_Split} (@code{g-zistsp.ads})
25106 @geindex GNAT.Wide_Wide_String_Split (g-zistsp.ads)
25108 @geindex Wide_Wide_String splitter
25110 Useful wide wide string manipulation routines: given a set of separators, split
25111 a wide wide string wherever the separators appear, and provide direct access
25112 to the resulting slices. This package is instantiated from
25113 @code{GNAT.Array_Split}.
25115 @node Interfaces C Extensions i-cexten ads,Interfaces C Streams i-cstrea ads,GNAT Wide_Wide_String_Split g-zistsp ads,The GNAT Library
25116 @anchor{gnat_rm/the_gnat_library id129}@anchor{3e3}@anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3e4}
25117 @section @code{Interfaces.C.Extensions} (@code{i-cexten.ads})
25120 @geindex Interfaces.C.Extensions (i-cexten.ads)
25122 This package contains additional C-related definitions, intended
25123 for use with either manually or automatically generated bindings
25124 to C libraries.
25126 @node Interfaces C Streams i-cstrea ads,Interfaces Packed_Decimal i-pacdec ads,Interfaces C Extensions i-cexten ads,The GNAT Library
25127 @anchor{gnat_rm/the_gnat_library id130}@anchor{3e5}@anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3e6}
25128 @section @code{Interfaces.C.Streams} (@code{i-cstrea.ads})
25131 @geindex Interfaces.C.Streams (i-cstrea.ads)
25133 @geindex C streams
25134 @geindex interfacing
25136 This package is a binding for the most commonly used operations
25137 on C streams.
25139 @node Interfaces Packed_Decimal i-pacdec ads,Interfaces VxWorks i-vxwork ads,Interfaces C Streams i-cstrea ads,The GNAT Library
25140 @anchor{gnat_rm/the_gnat_library id131}@anchor{3e7}@anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3e8}
25141 @section @code{Interfaces.Packed_Decimal} (@code{i-pacdec.ads})
25144 @geindex Interfaces.Packed_Decimal (i-pacdec.ads)
25146 @geindex IBM Packed Format
25148 @geindex Packed Decimal
25150 This package provides a set of routines for conversions to and
25151 from a packed decimal format compatible with that used on IBM
25152 mainframes.
25154 @node Interfaces VxWorks i-vxwork ads,Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces Packed_Decimal i-pacdec ads,The GNAT Library
25155 @anchor{gnat_rm/the_gnat_library id132}@anchor{3e9}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3ea}
25156 @section @code{Interfaces.VxWorks} (@code{i-vxwork.ads})
25159 @geindex Interfaces.VxWorks (i-vxwork.ads)
25161 @geindex Interfacing to VxWorks
25163 @geindex VxWorks
25164 @geindex interfacing
25166 This package provides a limited binding to the VxWorks API.
25167 In particular, it interfaces with the
25168 VxWorks hardware interrupt facilities.
25170 @node Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces VxWorks IO i-vxwoio ads,Interfaces VxWorks i-vxwork ads,The GNAT Library
25171 @anchor{gnat_rm/the_gnat_library id133}@anchor{3eb}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-int-connection-i-vxinco-ads}@anchor{3ec}
25172 @section @code{Interfaces.VxWorks.Int_Connection} (@code{i-vxinco.ads})
25175 @geindex Interfaces.VxWorks.Int_Connection (i-vxinco.ads)
25177 @geindex Interfacing to VxWorks
25179 @geindex VxWorks
25180 @geindex interfacing
25182 This package provides a way for users to replace the use of
25183 intConnect() with a custom routine for installing interrupt
25184 handlers.
25186 @node Interfaces VxWorks IO i-vxwoio ads,System Address_Image s-addima ads,Interfaces VxWorks Int_Connection i-vxinco ads,The GNAT Library
25187 @anchor{gnat_rm/the_gnat_library id134}@anchor{3ed}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3ee}
25188 @section @code{Interfaces.VxWorks.IO} (@code{i-vxwoio.ads})
25191 @geindex Interfaces.VxWorks.IO (i-vxwoio.ads)
25193 @geindex Interfacing to VxWorks' I/O
25195 @geindex VxWorks
25196 @geindex I/O interfacing
25198 @geindex VxWorks
25199 @geindex Get_Immediate
25201 @geindex Get_Immediate
25202 @geindex VxWorks
25204 This package provides a binding to the ioctl (IO/Control)
25205 function of VxWorks, defining a set of option values and
25206 function codes. A particular use of this package is
25207 to enable the use of Get_Immediate under VxWorks.
25209 @node System Address_Image s-addima ads,System Assertions s-assert ads,Interfaces VxWorks IO i-vxwoio ads,The GNAT Library
25210 @anchor{gnat_rm/the_gnat_library id135}@anchor{3ef}@anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3f0}
25211 @section @code{System.Address_Image} (@code{s-addima.ads})
25214 @geindex System.Address_Image (s-addima.ads)
25216 @geindex Address image
25218 @geindex Image
25219 @geindex of an address
25221 This function provides a useful debugging
25222 function that gives an (implementation dependent)
25223 string which identifies an address.
25225 @node System Assertions s-assert ads,System Atomic_Counters s-atocou ads,System Address_Image s-addima ads,The GNAT Library
25226 @anchor{gnat_rm/the_gnat_library id136}@anchor{3f1}@anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3f2}
25227 @section @code{System.Assertions} (@code{s-assert.ads})
25230 @geindex System.Assertions (s-assert.ads)
25232 @geindex Assertions
25234 @geindex Assert_Failure
25235 @geindex exception
25237 This package provides the declaration of the exception raised
25238 by an run-time assertion failure, as well as the routine that
25239 is used internally to raise this assertion.
25241 @node System Atomic_Counters s-atocou ads,System Memory s-memory ads,System Assertions s-assert ads,The GNAT Library
25242 @anchor{gnat_rm/the_gnat_library id137}@anchor{3f3}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f4}
25243 @section @code{System.Atomic_Counters} (@code{s-atocou.ads})
25246 @geindex System.Atomic_Counters (s-atocou.ads)
25248 This package provides the declaration of an atomic counter type,
25249 together with efficient routines (using hardware
25250 synchronization primitives) for incrementing, decrementing,
25251 and testing of these counters. This package is implemented
25252 on most targets, including all Alpha, AARCH64, ARM, ia64, PowerPC, SPARC V9,
25253 x86, and x86_64 platforms.
25255 @node System Memory s-memory ads,System Multiprocessors s-multip ads,System Atomic_Counters s-atocou ads,The GNAT Library
25256 @anchor{gnat_rm/the_gnat_library id138}@anchor{3f5}@anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f6}
25257 @section @code{System.Memory} (@code{s-memory.ads})
25260 @geindex System.Memory (s-memory.ads)
25262 @geindex Memory allocation
25264 This package provides the interface to the low level routines used
25265 by the generated code for allocation and freeing storage for the
25266 default storage pool (analogous to the C routines malloc and free).
25267 It also provides a reallocation interface analogous to the C routine
25268 realloc. The body of this unit may be modified to provide alternative
25269 allocation mechanisms for the default pool, and in addition, direct
25270 calls to this unit may be made for low level allocation uses (for
25271 example see the body of @code{GNAT.Tables}).
25273 @node System Multiprocessors s-multip ads,System Multiprocessors Dispatching_Domains s-mudido ads,System Memory s-memory ads,The GNAT Library
25274 @anchor{gnat_rm/the_gnat_library id139}@anchor{3f7}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3f8}
25275 @section @code{System.Multiprocessors} (@code{s-multip.ads})
25278 @geindex System.Multiprocessors (s-multip.ads)
25280 @geindex Multiprocessor interface
25282 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25283 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25284 technically an implementation-defined addition).
25286 @node System Multiprocessors Dispatching_Domains s-mudido ads,System Partition_Interface s-parint ads,System Multiprocessors s-multip ads,The GNAT Library
25287 @anchor{gnat_rm/the_gnat_library id140}@anchor{3f9}@anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3fa}
25288 @section @code{System.Multiprocessors.Dispatching_Domains} (@code{s-mudido.ads})
25291 @geindex System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
25293 @geindex Multiprocessor interface
25295 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25296 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25297 technically an implementation-defined addition).
25299 @node System Partition_Interface s-parint ads,System Pool_Global s-pooglo ads,System Multiprocessors Dispatching_Domains s-mudido ads,The GNAT Library
25300 @anchor{gnat_rm/the_gnat_library id141}@anchor{3fb}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3fc}
25301 @section @code{System.Partition_Interface} (@code{s-parint.ads})
25304 @geindex System.Partition_Interface (s-parint.ads)
25306 @geindex Partition interfacing functions
25308 This package provides facilities for partition interfacing.  It
25309 is used primarily in a distribution context when using Annex E
25310 with @code{GLADE}.
25312 @node System Pool_Global s-pooglo ads,System Pool_Local s-pooloc ads,System Partition_Interface s-parint ads,The GNAT Library
25313 @anchor{gnat_rm/the_gnat_library id142}@anchor{3fd}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{3fe}
25314 @section @code{System.Pool_Global} (@code{s-pooglo.ads})
25317 @geindex System.Pool_Global (s-pooglo.ads)
25319 @geindex Storage pool
25320 @geindex global
25322 @geindex Global storage pool
25324 This package provides a storage pool that is equivalent to the default
25325 storage pool used for access types for which no pool is specifically
25326 declared. It uses malloc/free to allocate/free and does not attempt to
25327 do any automatic reclamation.
25329 @node System Pool_Local s-pooloc ads,System Restrictions s-restri ads,System Pool_Global s-pooglo ads,The GNAT Library
25330 @anchor{gnat_rm/the_gnat_library id143}@anchor{3ff}@anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{400}
25331 @section @code{System.Pool_Local} (@code{s-pooloc.ads})
25334 @geindex System.Pool_Local (s-pooloc.ads)
25336 @geindex Storage pool
25337 @geindex local
25339 @geindex Local storage pool
25341 This package provides a storage pool that is intended for use with locally
25342 defined access types. It uses malloc/free for allocate/free, and maintains
25343 a list of allocated blocks, so that all storage allocated for the pool can
25344 be freed automatically when the pool is finalized.
25346 @node System Restrictions s-restri ads,System Rident s-rident ads,System Pool_Local s-pooloc ads,The GNAT Library
25347 @anchor{gnat_rm/the_gnat_library id144}@anchor{401}@anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{402}
25348 @section @code{System.Restrictions} (@code{s-restri.ads})
25351 @geindex System.Restrictions (s-restri.ads)
25353 @geindex Run-time restrictions access
25355 This package provides facilities for accessing at run time
25356 the status of restrictions specified at compile time for
25357 the partition. Information is available both with regard
25358 to actual restrictions specified, and with regard to
25359 compiler determined information on which restrictions
25360 are violated by one or more packages in the partition.
25362 @node System Rident s-rident ads,System Strings Stream_Ops s-ststop ads,System Restrictions s-restri ads,The GNAT Library
25363 @anchor{gnat_rm/the_gnat_library id145}@anchor{403}@anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{404}
25364 @section @code{System.Rident} (@code{s-rident.ads})
25367 @geindex System.Rident (s-rident.ads)
25369 @geindex Restrictions definitions
25371 This package provides definitions of the restrictions
25372 identifiers supported by GNAT, and also the format of
25373 the restrictions provided in package System.Restrictions.
25374 It is not normally necessary to @code{with} this generic package
25375 since the necessary instantiation is included in
25376 package System.Restrictions.
25378 @node System Strings Stream_Ops s-ststop ads,System Unsigned_Types s-unstyp ads,System Rident s-rident ads,The GNAT Library
25379 @anchor{gnat_rm/the_gnat_library id146}@anchor{405}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{406}
25380 @section @code{System.Strings.Stream_Ops} (@code{s-ststop.ads})
25383 @geindex System.Strings.Stream_Ops (s-ststop.ads)
25385 @geindex Stream operations
25387 @geindex String stream operations
25389 This package provides a set of stream subprograms for standard string types.
25390 It is intended primarily to support implicit use of such subprograms when
25391 stream attributes are applied to string types, but the subprograms in this
25392 package can be used directly by application programs.
25394 @node System Unsigned_Types s-unstyp ads,System Wch_Cnv s-wchcnv ads,System Strings Stream_Ops s-ststop ads,The GNAT Library
25395 @anchor{gnat_rm/the_gnat_library id147}@anchor{407}@anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{408}
25396 @section @code{System.Unsigned_Types} (@code{s-unstyp.ads})
25399 @geindex System.Unsigned_Types (s-unstyp.ads)
25401 This package contains definitions of standard unsigned types that
25402 correspond in size to the standard signed types declared in Standard,
25403 and (unlike the types in Interfaces) have corresponding names. It
25404 also contains some related definitions for other specialized types
25405 used by the compiler in connection with packed array types.
25407 @node System Wch_Cnv s-wchcnv ads,System Wch_Con s-wchcon ads,System Unsigned_Types s-unstyp ads,The GNAT Library
25408 @anchor{gnat_rm/the_gnat_library id148}@anchor{409}@anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{40a}
25409 @section @code{System.Wch_Cnv} (@code{s-wchcnv.ads})
25412 @geindex System.Wch_Cnv (s-wchcnv.ads)
25414 @geindex Wide Character
25415 @geindex Representation
25417 @geindex Wide String
25418 @geindex Conversion
25420 @geindex Representation of wide characters
25422 This package provides routines for converting between
25423 wide and wide wide characters and a representation as a value of type
25424 @code{Standard.String}, using a specified wide character
25425 encoding method.  It uses definitions in
25426 package @code{System.Wch_Con}.
25428 @node System Wch_Con s-wchcon ads,,System Wch_Cnv s-wchcnv ads,The GNAT Library
25429 @anchor{gnat_rm/the_gnat_library id149}@anchor{40b}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{40c}
25430 @section @code{System.Wch_Con} (@code{s-wchcon.ads})
25433 @geindex System.Wch_Con (s-wchcon.ads)
25435 This package provides definitions and descriptions of
25436 the various methods used for encoding wide characters
25437 in ordinary strings.  These definitions are used by
25438 the package @code{System.Wch_Cnv}.
25440 @node Interfacing to Other Languages,Specialized Needs Annexes,The GNAT Library,Top
25441 @anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{40d}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{40e}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11}
25442 @chapter Interfacing to Other Languages
25445 The facilities in Annex B of the Ada Reference Manual are fully
25446 implemented in GNAT, and in addition, a full interface to C++ is
25447 provided.
25449 @menu
25450 * Interfacing to C:: 
25451 * Interfacing to C++:: 
25452 * Interfacing to COBOL:: 
25453 * Interfacing to Fortran:: 
25454 * Interfacing to non-GNAT Ada code:: 
25456 @end menu
25458 @node Interfacing to C,Interfacing to C++,,Interfacing to Other Languages
25459 @anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{40f}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{410}
25460 @section Interfacing to C
25463 Interfacing to C with GNAT can use one of two approaches:
25466 @itemize *
25468 @item 
25469 The types in the package @code{Interfaces.C} may be used.
25471 @item 
25472 Standard Ada types may be used directly.  This may be less portable to
25473 other compilers, but will work on all GNAT compilers, which guarantee
25474 correspondence between the C and Ada types.
25475 @end itemize
25477 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
25478 effect, since this is the default.  The following table shows the
25479 correspondence between Ada scalar types and the corresponding C types.
25482 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
25483 @headitem
25485 Ada Type
25487 @tab
25489 C Type
25491 @item
25493 @code{Integer}
25495 @tab
25497 @code{int}
25499 @item
25501 @code{Short_Integer}
25503 @tab
25505 @code{short}
25507 @item
25509 @code{Short_Short_Integer}
25511 @tab
25513 @code{signed char}
25515 @item
25517 @code{Long_Integer}
25519 @tab
25521 @code{long}
25523 @item
25525 @code{Long_Long_Integer}
25527 @tab
25529 @code{long long}
25531 @item
25533 @code{Short_Float}
25535 @tab
25537 @code{float}
25539 @item
25541 @code{Float}
25543 @tab
25545 @code{float}
25547 @item
25549 @code{Long_Float}
25551 @tab
25553 @code{double}
25555 @item
25557 @code{Long_Long_Float}
25559 @tab
25561 This is the longest floating-point type supported by the hardware.
25563 @end multitable
25566 Additionally, there are the following general correspondences between Ada
25567 and C types:
25570 @itemize *
25572 @item 
25573 Ada enumeration types map to C enumeration types directly if pragma
25574 @code{Convention C} is specified, which causes them to have a length of
25575 32 bits, except for boolean types which map to C99 @code{bool} and for
25576 which the length is 8 bits.
25577 Without pragma @code{Convention C}, Ada enumeration types map to
25578 8, 16, or 32 bits (i.e., C types @code{signed char}, @code{short},
25579 @code{int}, respectively) depending on the number of values passed.
25580 This is the only case in which pragma @code{Convention C} affects the
25581 representation of an Ada type.
25583 @item 
25584 Ada access types map to C pointers, except for the case of pointers to
25585 unconstrained types in Ada, which have no direct C equivalent.
25587 @item 
25588 Ada arrays map directly to C arrays.
25590 @item 
25591 Ada records map directly to C structures.
25593 @item 
25594 Packed Ada records map to C structures where all members are bit fields
25595 of the length corresponding to the @code{type'Size} value in Ada.
25596 @end itemize
25598 @node Interfacing to C++,Interfacing to COBOL,Interfacing to C,Interfacing to Other Languages
25599 @anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{49}@anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{411}
25600 @section Interfacing to C++
25603 The interface to C++ makes use of the following pragmas, which are
25604 primarily intended to be constructed automatically using a binding generator
25605 tool, although it is possible to construct them by hand.
25607 Using these pragmas it is possible to achieve complete
25608 inter-operability between Ada tagged types and C++ class definitions.
25609 See @ref{7,,Implementation Defined Pragmas}, for more details.
25612 @table @asis
25614 @item @code{pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})}
25616 The argument denotes an entity in the current declarative region that is
25617 declared as a tagged or untagged record type. It indicates that the type
25618 corresponds to an externally declared C++ class type, and is to be laid
25619 out the same way that C++ would lay out the type.
25621 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
25622 for backward compatibility but its functionality is available
25623 using pragma @code{Import} with @code{Convention} = @code{CPP}.
25625 @item @code{pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})}
25627 This pragma identifies an imported function (imported in the usual way
25628 with pragma @code{Import}) as corresponding to a C++ constructor.
25629 @end table
25631 A few restrictions are placed on the use of the @code{Access} attribute
25632 in conjunction with subprograms subject to convention @code{CPP}: the
25633 attribute may be used neither on primitive operations of a tagged
25634 record type with convention @code{CPP}, imported or not, nor on
25635 subprograms imported with pragma @code{CPP_Constructor}.
25637 In addition, C++ exceptions are propagated and can be handled in an
25638 @code{others} choice of an exception handler. The corresponding Ada
25639 occurrence has no message, and the simple name of the exception identity
25640 contains @code{Foreign_Exception}. Finalization and awaiting dependent
25641 tasks works properly when such foreign exceptions are propagated.
25643 It is also possible to import a C++ exception using the following syntax:
25645 @example
25646 LOCAL_NAME : exception;
25647 pragma Import (Cpp,
25648   [Entity =>] LOCAL_NAME,
25649   [External_Name =>] static_string_EXPRESSION);
25650 @end example
25652 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
25653 cover a specific C++ exception in an exception handler.
25655 @node Interfacing to COBOL,Interfacing to Fortran,Interfacing to C++,Interfacing to Other Languages
25656 @anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{412}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{413}
25657 @section Interfacing to COBOL
25660 Interfacing to COBOL is achieved as described in section B.4 of
25661 the Ada Reference Manual.
25663 @node Interfacing to Fortran,Interfacing to non-GNAT Ada code,Interfacing to COBOL,Interfacing to Other Languages
25664 @anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{414}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{415}
25665 @section Interfacing to Fortran
25668 Interfacing to Fortran is achieved as described in section B.5 of the
25669 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
25670 multi-dimensional array causes the array to be stored in column-major
25671 order as required for convenient interface to Fortran.
25673 @node Interfacing to non-GNAT Ada code,,Interfacing to Fortran,Interfacing to Other Languages
25674 @anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{416}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{417}
25675 @section Interfacing to non-GNAT Ada code
25678 It is possible to specify the convention @code{Ada} in a pragma
25679 @code{Import} or pragma @code{Export}.  However this refers to
25680 the calling conventions used by GNAT, which may or may not be
25681 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
25682 compiler to allow interoperation.
25684 If arguments types are kept simple, and if the foreign compiler generally
25685 follows system calling conventions, then it may be possible to integrate
25686 files compiled by other Ada compilers, provided that the elaboration
25687 issues are adequately addressed (for example by eliminating the
25688 need for any load time elaboration).
25690 In particular, GNAT running on VMS is designed to
25691 be highly compatible with the DEC Ada 83 compiler, so this is one
25692 case in which it is possible to import foreign units of this type,
25693 provided that the data items passed are restricted to simple scalar
25694 values or simple record types without variants, or simple array
25695 types with fixed bounds.
25697 @node Specialized Needs Annexes,Implementation of Specific Ada Features,Interfacing to Other Languages,Top
25698 @anchor{gnat_rm/specialized_needs_annexes doc}@anchor{418}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{419}@anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12}
25699 @chapter Specialized Needs Annexes
25702 Ada 95, Ada 2005, and Ada 2012 define a number of Specialized Needs Annexes, which are not
25703 required in all implementations.  However, as described in this chapter,
25704 GNAT implements all of these annexes:
25707 @table @asis
25709 @item `Systems Programming (Annex C)'
25711 The Systems Programming Annex is fully implemented.
25713 @item `Real-Time Systems (Annex D)'
25715 The Real-Time Systems Annex is fully implemented.
25717 @item `Distributed Systems (Annex E)'
25719 Stub generation is fully implemented in the GNAT compiler.  In addition,
25720 a complete compatible PCS is available as part of the GLADE system,
25721 a separate product.  When the two
25722 products are used in conjunction, this annex is fully implemented.
25724 @item `Information Systems (Annex F)'
25726 The Information Systems annex is fully implemented.
25728 @item `Numerics (Annex G)'
25730 The Numerics Annex is fully implemented.
25732 @item `Safety and Security / High-Integrity Systems (Annex H)'
25734 The Safety and Security Annex (termed the High-Integrity Systems Annex
25735 in Ada 2005) is fully implemented.
25736 @end table
25738 @node Implementation of Specific Ada Features,Implementation of Ada 2012 Features,Specialized Needs Annexes,Top
25739 @anchor{gnat_rm/implementation_of_specific_ada_features doc}@anchor{41a}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{41b}@anchor{gnat_rm/implementation_of_specific_ada_features implementation-of-specific-ada-features}@anchor{13}
25740 @chapter Implementation of Specific Ada Features
25743 This chapter describes the GNAT implementation of several Ada language
25744 facilities.
25746 @menu
25747 * Machine Code Insertions:: 
25748 * GNAT Implementation of Tasking:: 
25749 * GNAT Implementation of Shared Passive Packages:: 
25750 * Code Generation for Array Aggregates:: 
25751 * The Size of Discriminated Records with Default Discriminants:: 
25752 * Image Values For Nonscalar Types:: 
25753 * Strict Conformance to the Ada Reference Manual:: 
25755 @end menu
25757 @node Machine Code Insertions,GNAT Implementation of Tasking,,Implementation of Specific Ada Features
25758 @anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{41c}@anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{173}
25759 @section Machine Code Insertions
25762 @geindex Machine Code insertions
25764 Package @code{Machine_Code} provides machine code support as described
25765 in the Ada Reference Manual in two separate forms:
25768 @itemize *
25770 @item 
25771 Machine code statements, consisting of qualified expressions that
25772 fit the requirements of RM section 13.8.
25774 @item 
25775 An intrinsic callable procedure, providing an alternative mechanism of
25776 including machine instructions in a subprogram.
25777 @end itemize
25779 The two features are similar, and both are closely related to the mechanism
25780 provided by the asm instruction in the GNU C compiler.  Full understanding
25781 and use of the facilities in this package requires understanding the asm
25782 instruction, see the section on Extended Asm in
25783 @cite{Using_the_GNU_Compiler_Collection_(GCC)}.
25785 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
25786 semantic restrictions and effects as described below.  Both are provided so
25787 that the procedure call can be used as a statement, and the function call
25788 can be used to form a code_statement.
25790 Consider this C @code{asm} instruction:
25792 @example
25793 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
25794 @end example
25796 The equivalent can be written for GNAT as:
25798 @example
25799 Asm ("fsinx %1 %0",
25800      My_Float'Asm_Output ("=f", result),
25801      My_Float'Asm_Input  ("f",  angle));
25802 @end example
25804 The first argument to @code{Asm} is the assembler template, and is
25805 identical to what is used in GNU C.  This string must be a static
25806 expression.  The second argument is the output operand list.  It is
25807 either a single @code{Asm_Output} attribute reference, or a list of such
25808 references enclosed in parentheses (technically an array aggregate of
25809 such references).
25811 The @code{Asm_Output} attribute denotes a function that takes two
25812 parameters.  The first is a string, the second is the name of a variable
25813 of the type designated by the attribute prefix.  The first (string)
25814 argument is required to be a static expression and designates the
25815 constraint (see the section on Constraints in
25816 @cite{Using_the_GNU_Compiler_Collection_(GCC)})
25817 for the parameter; e.g., what kind of register is required.  The second
25818 argument is the variable to be written or updated with the
25819 result.  The possible values for constraint are the same as those used in
25820 the RTL, and are dependent on the configuration file used to build the
25821 GCC back end.  If there are no output operands, then this argument may
25822 either be omitted, or explicitly given as @code{No_Output_Operands}.
25823 No support is provided for GNU C’s symbolic names for output parameters.
25825 The second argument of @code{my_float'Asm_Output} functions as
25826 though it were an @code{out} parameter, which is a little curious, but
25827 all names have the form of expressions, so there is no syntactic
25828 irregularity, even though normally functions would not be permitted
25829 @code{out} parameters.  The third argument is the list of input
25830 operands.  It is either a single @code{Asm_Input} attribute reference, or
25831 a list of such references enclosed in parentheses (technically an array
25832 aggregate of such references).
25834 The @code{Asm_Input} attribute denotes a function that takes two
25835 parameters.  The first is a string, the second is an expression of the
25836 type designated by the prefix.  The first (string) argument is required
25837 to be a static expression, and is the constraint for the parameter,
25838 (e.g., what kind of register is required).  The second argument is the
25839 value to be used as the input argument.  The possible values for the
25840 constraint are the same as those used in the RTL, and are dependent on
25841 the configuration file used to built the GCC back end.
25842 No support is provided for GNU C’s symbolic names for input parameters.
25844 If there are no input operands, this argument may either be omitted, or
25845 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
25846 present in the above example, is a list of register names, called the
25847 `clobber' argument.  This argument, if given, must be a static string
25848 expression, and is a space or comma separated list of names of registers
25849 that must be considered destroyed as a result of the @code{Asm} call.  If
25850 this argument is the null string (the default value), then the code
25851 generator assumes that no additional registers are destroyed.
25852 In addition to registers, the special clobbers @code{memory} and
25853 @code{cc} as described in the GNU C docs are both supported.
25855 The fifth argument, not present in the above example, called the
25856 `volatile' argument, is by default @code{False}.  It can be set to
25857 the literal value @code{True} to indicate to the code generator that all
25858 optimizations with respect to the instruction specified should be
25859 suppressed, and in particular an instruction that has outputs
25860 will still be generated, even if none of the outputs are
25861 used.  See @cite{Using_the_GNU_Compiler_Collection_(GCC)}
25862 for the full description.
25863 Generally it is strongly advisable to use Volatile for any ASM statement
25864 that is missing either input or output operands or to avoid unwanted
25865 optimizations. A warning is generated if this advice is not followed.
25867 No support is provided for GNU C’s @code{asm goto} feature.
25869 The @code{Asm} subprograms may be used in two ways.  First the procedure
25870 forms can be used anywhere a procedure call would be valid, and
25871 correspond to what the RM calls ‘intrinsic’ routines.  Such calls can
25872 be used to intersperse machine instructions with other Ada statements.
25873 Second, the function forms, which return a dummy value of the limited
25874 private type @code{Asm_Insn}, can be used in code statements, and indeed
25875 this is the only context where such calls are allowed.  Code statements
25876 appear as aggregates of the form:
25878 @example
25879 Asm_Insn'(Asm (...));
25880 Asm_Insn'(Asm_Volatile (...));
25881 @end example
25883 In accordance with RM rules, such code statements are allowed only
25884 within subprograms whose entire body consists of such statements.  It is
25885 not permissible to intermix such statements with other Ada statements.
25887 Typically the form using intrinsic procedure calls is more convenient
25888 and more flexible.  The code statement form is provided to meet the RM
25889 suggestion that such a facility should be made available.  The following
25890 is the exact syntax of the call to @code{Asm}. As usual, if named notation
25891 is used, the arguments may be given in arbitrary order, following the
25892 normal rules for use of positional and named arguments:
25894 @example
25895 ASM_CALL ::= Asm (
25896                  [Template =>] static_string_EXPRESSION
25897                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
25898                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
25899                [,[Clobber  =>] static_string_EXPRESSION ]
25900                [,[Volatile =>] static_boolean_EXPRESSION] )
25902 OUTPUT_OPERAND_LIST ::=
25903   [PREFIX.]No_Output_Operands
25904 | OUTPUT_OPERAND_ATTRIBUTE
25905 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
25907 OUTPUT_OPERAND_ATTRIBUTE ::=
25908   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
25910 INPUT_OPERAND_LIST ::=
25911   [PREFIX.]No_Input_Operands
25912 | INPUT_OPERAND_ATTRIBUTE
25913 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
25915 INPUT_OPERAND_ATTRIBUTE ::=
25916   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
25917 @end example
25919 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
25920 are declared in the package @code{Machine_Code} and must be referenced
25921 according to normal visibility rules. In particular if there is no
25922 @code{use} clause for this package, then appropriate package name
25923 qualification is required.
25925 @node GNAT Implementation of Tasking,GNAT Implementation of Shared Passive Packages,Machine Code Insertions,Implementation of Specific Ada Features
25926 @anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41d}@anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{41e}
25927 @section GNAT Implementation of Tasking
25930 This chapter outlines the basic GNAT approach to tasking (in particular,
25931 a multi-layered library for portability) and discusses issues related
25932 to compliance with the Real-Time Systems Annex.
25934 @menu
25935 * Mapping Ada Tasks onto the Underlying Kernel Threads:: 
25936 * Ensuring Compliance with the Real-Time Annex:: 
25937 * Support for Locking Policies:: 
25939 @end menu
25941 @node Mapping Ada Tasks onto the Underlying Kernel Threads,Ensuring Compliance with the Real-Time Annex,,GNAT Implementation of Tasking
25942 @anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{41f}@anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{420}
25943 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
25946 GNAT’s run-time support comprises two layers:
25949 @itemize *
25951 @item 
25952 GNARL (GNAT Run-time Layer)
25954 @item 
25955 GNULL (GNAT Low-level Library)
25956 @end itemize
25958 In GNAT, Ada’s tasking services rely on a platform and OS independent
25959 layer known as GNARL.  This code is responsible for implementing the
25960 correct semantics of Ada’s task creation, rendezvous, protected
25961 operations etc.
25963 GNARL decomposes Ada’s tasking semantics into simpler lower level
25964 operations such as create a thread, set the priority of a thread,
25965 yield, create a lock, lock/unlock, etc.  The spec for these low-level
25966 operations constitutes GNULLI, the GNULL Interface.  This interface is
25967 directly inspired from the POSIX real-time API.
25969 If the underlying executive or OS implements the POSIX standard
25970 faithfully, the GNULL Interface maps as is to the services offered by
25971 the underlying kernel.  Otherwise, some target dependent glue code maps
25972 the services offered by the underlying kernel to the semantics expected
25973 by GNARL.
25975 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
25976 key point is that each Ada task is mapped on a thread in the underlying
25977 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
25979 In addition Ada task priorities map onto the underlying thread priorities.
25980 Mapping Ada tasks onto the underlying kernel threads has several advantages:
25983 @itemize *
25985 @item 
25986 The underlying scheduler is used to schedule the Ada tasks.  This
25987 makes Ada tasks as efficient as kernel threads from a scheduling
25988 standpoint.
25990 @item 
25991 Interaction with code written in C containing threads is eased
25992 since at the lowest level Ada tasks and C threads map onto the same
25993 underlying kernel concept.
25995 @item 
25996 When an Ada task is blocked during I/O the remaining Ada tasks are
25997 able to proceed.
25999 @item 
26000 On multiprocessor systems Ada tasks can execute in parallel.
26001 @end itemize
26003 Some threads libraries offer a mechanism to fork a new process, with the
26004 child process duplicating the threads from the parent.
26005 GNAT does not
26006 support this functionality when the parent contains more than one task.
26008 @geindex Forking a new process
26010 @node Ensuring Compliance with the Real-Time Annex,Support for Locking Policies,Mapping Ada Tasks onto the Underlying Kernel Threads,GNAT Implementation of Tasking
26011 @anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{421}@anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{422}
26012 @subsection Ensuring Compliance with the Real-Time Annex
26015 @geindex Real-Time Systems Annex compliance
26017 Although mapping Ada tasks onto
26018 the underlying threads has significant advantages, it does create some
26019 complications when it comes to respecting the scheduling semantics
26020 specified in the real-time annex (Annex D).
26022 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
26023 scheduling policy states:
26025 @quotation
26027 `When the active priority of a ready task that is not running
26028 changes, or the setting of its base priority takes effect, the
26029 task is removed from the ready queue for its old active priority
26030 and is added at the tail of the ready queue for its new active
26031 priority, except in the case where the active priority is lowered
26032 due to the loss of inherited priority, in which case the task is
26033 added at the head of the ready queue for its new active priority.'
26034 @end quotation
26036 While most kernels do put tasks at the end of the priority queue when
26037 a task changes its priority, (which respects the main
26038 FIFO_Within_Priorities requirement), almost none keep a thread at the
26039 beginning of its priority queue when its priority drops from the loss
26040 of inherited priority.
26042 As a result most vendors have provided incomplete Annex D implementations.
26044 The GNAT run-time, has a nice cooperative solution to this problem
26045 which ensures that accurate FIFO_Within_Priorities semantics are
26046 respected.
26048 The principle is as follows.  When an Ada task T is about to start
26049 running, it checks whether some other Ada task R with the same
26050 priority as T has been suspended due to the loss of priority
26051 inheritance.  If this is the case, T yields and is placed at the end of
26052 its priority queue.  When R arrives at the front of the queue it
26053 executes.
26055 Note that this simple scheme preserves the relative order of the tasks
26056 that were ready to execute in the priority queue where R has been
26057 placed at the end.
26059 @c Support_for_Locking_Policies
26061 @node Support for Locking Policies,,Ensuring Compliance with the Real-Time Annex,GNAT Implementation of Tasking
26062 @anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{423}
26063 @subsection Support for Locking Policies
26066 This section specifies which policies specified by pragma Locking_Policy
26067 are supported on which platforms.
26069 GNAT supports the standard @code{Ceiling_Locking} policy, and the
26070 implementation defined @code{Inheritance_Locking} and
26071 @code{Concurrent_Readers_Locking} policies.
26073 @code{Ceiling_Locking} is supported on all platforms if the operating system
26074 supports it. In particular, @code{Ceiling_Locking} is not supported on
26075 VxWorks.
26076 @code{Inheritance_Locking} is supported on
26077 Linux,
26078 Darwin (Mac OS X),
26079 LynxOS 178,
26080 and VxWorks.
26081 @code{Concurrent_Readers_Locking} is supported on Linux.
26083 Notes about @code{Ceiling_Locking} on Linux:
26084 If the process is running as ‘root’, ceiling locking is used.
26085 If the capabilities facility is installed
26086 (“sudo apt-get –assume-yes install libcap-dev” on Ubuntu,
26087 for example),
26088 and the program is linked against that library
26089 (“-largs -lcap”),
26090 and the executable file has the cap_sys_nice capability
26091 (“sudo /sbin/setcap cap_sys_nice=ep executable_file_name”),
26092 then ceiling locking is used.
26093 Otherwise, the @code{Ceiling_Locking} policy is ignored.
26095 @node GNAT Implementation of Shared Passive Packages,Code Generation for Array Aggregates,GNAT Implementation of Tasking,Implementation of Specific Ada Features
26096 @anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{424}@anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{425}
26097 @section GNAT Implementation of Shared Passive Packages
26100 @geindex Shared passive packages
26102 GNAT fully implements the 
26103 @geindex pragma Shared_Passive
26104 pragma
26105 @code{Shared_Passive} for
26106 the purpose of designating shared passive packages.
26107 This allows the use of passive partitions in the
26108 context described in the Ada Reference Manual; i.e., for communication
26109 between separate partitions of a distributed application using the
26110 features in Annex E.
26112 @geindex Annex E
26114 @geindex Distribution Systems Annex
26116 However, the implementation approach used by GNAT provides for more
26117 extensive usage as follows:
26120 @table @asis
26122 @item `Communication between separate programs'
26124 This allows separate programs to access the data in passive
26125 partitions, using protected objects for synchronization where
26126 needed. The only requirement is that the two programs have a
26127 common shared file system. It is even possible for programs
26128 running on different machines with different architectures
26129 (e.g., different endianness) to communicate via the data in
26130 a passive partition.
26132 @item `Persistence between program runs'
26134 The data in a passive package can persist from one run of a
26135 program to another, so that a later program sees the final
26136 values stored by a previous run of the same program.
26137 @end table
26139 The implementation approach used is to store the data in files. A
26140 separate stream file is created for each object in the package, and
26141 an access to an object causes the corresponding file to be read or
26142 written.
26144 @geindex SHARED_MEMORY_DIRECTORY environment variable
26146 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
26147 set to the directory to be used for these files.
26148 The files in this directory
26149 have names that correspond to their fully qualified names. For
26150 example, if we have the package
26152 @example
26153 package X is
26154   pragma Shared_Passive (X);
26155   Y : Integer;
26156   Z : Float;
26157 end X;
26158 @end example
26160 and the environment variable is set to @code{/stemp/}, then the files created
26161 will have the names:
26163 @example
26164 /stemp/x.y
26165 /stemp/x.z
26166 @end example
26168 These files are created when a value is initially written to the object, and
26169 the files are retained until manually deleted. This provides the persistence
26170 semantics. If no file exists, it means that no partition has assigned a value
26171 to the variable; in this case the initial value declared in the package
26172 will be used. This model ensures that there are no issues in synchronizing
26173 the elaboration process, since elaboration of passive packages elaborates the
26174 initial values, but does not create the files.
26176 The files are written using normal @code{Stream_IO} access.
26177 If you want to be able
26178 to communicate between programs or partitions running on different
26179 architectures, then you should use the XDR versions of the stream attribute
26180 routines, since these are architecture independent.
26182 If active synchronization is required for access to the variables in the
26183 shared passive package, then as described in the Ada Reference Manual, the
26184 package may contain protected objects used for this purpose. In this case
26185 a lock file (whose name is @code{___lock}, with three underscores)
26186 is created in the shared memory directory.
26188 @geindex ___lock file (for shared passive packages)
26190 This is used to provide the required locking
26191 semantics for proper protected object synchronization.
26193 @node Code Generation for Array Aggregates,The Size of Discriminated Records with Default Discriminants,GNAT Implementation of Shared Passive Packages,Implementation of Specific Ada Features
26194 @anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{426}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{427}
26195 @section Code Generation for Array Aggregates
26198 Aggregates have a rich syntax and allow the user to specify the values of
26199 complex data structures by means of a single construct.  As a result, the
26200 code generated for aggregates can be quite complex and involve loops, case
26201 statements and multiple assignments.  In the simplest cases, however, the
26202 compiler will recognize aggregates whose components and constraints are
26203 fully static, and in those cases the compiler will generate little or no
26204 executable code.  The following is an outline of the code that GNAT generates
26205 for various aggregate constructs.  For further details, you will find it
26206 useful to examine the output produced by the -gnatG flag to see the expanded
26207 source that is input to the code generator.  You may also want to examine
26208 the assembly code generated at various levels of optimization.
26210 The code generated for aggregates depends on the context, the component values,
26211 and the type.  In the context of an object declaration the code generated is
26212 generally simpler than in the case of an assignment.  As a general rule, static
26213 component values and static subtypes also lead to simpler code.
26215 @menu
26216 * Static constant aggregates with static bounds:: 
26217 * Constant aggregates with unconstrained nominal types:: 
26218 * Aggregates with static bounds:: 
26219 * Aggregates with nonstatic bounds:: 
26220 * Aggregates in assignment statements:: 
26222 @end menu
26224 @node Static constant aggregates with static bounds,Constant aggregates with unconstrained nominal types,,Code Generation for Array Aggregates
26225 @anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{428}@anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{429}
26226 @subsection Static constant aggregates with static bounds
26229 For the declarations:
26231 @example
26232 type One_Dim is array (1..10) of integer;
26233 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
26234 @end example
26236 GNAT generates no executable code: the constant ar0 is placed in static memory.
26237 The same is true for constant aggregates with named associations:
26239 @example
26240 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
26241 Cr3 : constant One_Dim := (others => 7777);
26242 @end example
26244 The same is true for multidimensional constant arrays such as:
26246 @example
26247 type two_dim is array (1..3, 1..3) of integer;
26248 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
26249 @end example
26251 The same is true for arrays of one-dimensional arrays: the following are
26252 static:
26254 @example
26255 type ar1b  is array (1..3) of boolean;
26256 type ar_ar is array (1..3) of ar1b;
26257 None  : constant ar1b := (others => false);     --  fully static
26258 None2 : constant ar_ar := (1..3 => None);       --  fully static
26259 @end example
26261 However, for multidimensional aggregates with named associations, GNAT will
26262 generate assignments and loops, even if all associations are static.  The
26263 following two declarations generate a loop for the first dimension, and
26264 individual component assignments for the second dimension:
26266 @example
26267 Zero1: constant two_dim := (1..3 => (1..3 => 0));
26268 Zero2: constant two_dim := (others => (others => 0));
26269 @end example
26271 @node Constant aggregates with unconstrained nominal types,Aggregates with static bounds,Static constant aggregates with static bounds,Code Generation for Array Aggregates
26272 @anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{42a}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{42b}
26273 @subsection Constant aggregates with unconstrained nominal types
26276 In such cases the aggregate itself establishes the subtype, so that
26277 associations with @code{others} cannot be used.  GNAT determines the
26278 bounds for the actual subtype of the aggregate, and allocates the
26279 aggregate statically as well.  No code is generated for the following:
26281 @example
26282 type One_Unc is array (natural range <>) of integer;
26283 Cr_Unc : constant One_Unc := (12,24,36);
26284 @end example
26286 @node Aggregates with static bounds,Aggregates with nonstatic bounds,Constant aggregates with unconstrained nominal types,Code Generation for Array Aggregates
26287 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{42c}@anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{42d}
26288 @subsection Aggregates with static bounds
26291 In all previous examples the aggregate was the initial (and immutable) value
26292 of a constant.  If the aggregate initializes a variable, then code is generated
26293 for it as a combination of individual assignments and loops over the target
26294 object.  The declarations
26296 @example
26297 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
26298 Cr_Var2 : One_Dim := (others > -1);
26299 @end example
26301 generate the equivalent of
26303 @example
26304 Cr_Var1 (1) := 2;
26305 Cr_Var1 (2) := 3;
26306 Cr_Var1 (3) := 5;
26307 Cr_Var1 (4) := 11;
26309 for I in Cr_Var2'range loop
26310    Cr_Var2 (I) := -1;
26311 end loop;
26312 @end example
26314 @node Aggregates with nonstatic bounds,Aggregates in assignment statements,Aggregates with static bounds,Code Generation for Array Aggregates
26315 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{42e}@anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{42f}
26316 @subsection Aggregates with nonstatic bounds
26319 If the bounds of the aggregate are not statically compatible with the bounds
26320 of the nominal subtype  of the target, then constraint checks have to be
26321 generated on the bounds.  For a multidimensional array, constraint checks may
26322 have to be applied to sub-arrays individually, if they do not have statically
26323 compatible subtypes.
26325 @node Aggregates in assignment statements,,Aggregates with nonstatic bounds,Code Generation for Array Aggregates
26326 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{430}@anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{431}
26327 @subsection Aggregates in assignment statements
26330 In general, aggregate assignment requires the construction of a temporary,
26331 and a copy from the temporary to the target of the assignment.  This is because
26332 it is not always possible to convert the assignment into a series of individual
26333 component assignments.  For example, consider the simple case:
26335 @example
26336 A := (A(2), A(1));
26337 @end example
26339 This cannot be converted into:
26341 @example
26342 A(1) := A(2);
26343 A(2) := A(1);
26344 @end example
26346 So the aggregate has to be built first in a separate location, and then
26347 copied into the target.  GNAT recognizes simple cases where this intermediate
26348 step is not required, and the assignments can be performed in place, directly
26349 into the target.  The following sufficient criteria are applied:
26352 @itemize *
26354 @item 
26355 The bounds of the aggregate are static, and the associations are static.
26357 @item 
26358 The components of the aggregate are static constants, names of
26359 simple variables that are not renamings, or expressions not involving
26360 indexed components whose operands obey these rules.
26361 @end itemize
26363 If any of these conditions are violated, the aggregate will be built in
26364 a temporary (created either by the front-end or the code generator) and then
26365 that temporary will be copied onto the target.
26367 @node The Size of Discriminated Records with Default Discriminants,Image Values For Nonscalar Types,Code Generation for Array Aggregates,Implementation of Specific Ada Features
26368 @anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{432}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{433}
26369 @section The Size of Discriminated Records with Default Discriminants
26372 If a discriminated type @code{T} has discriminants with default values, it is
26373 possible to declare an object of this type without providing an explicit
26374 constraint:
26376 @example
26377 type Size is range 1..100;
26379 type Rec (D : Size := 15) is record
26380    Name : String (1..D);
26381 end T;
26383 Word : Rec;
26384 @end example
26386 Such an object is said to be `unconstrained'.
26387 The discriminant of the object
26388 can be modified by a full assignment to the object, as long as it preserves the
26389 relation between the value of the discriminant, and the value of the components
26390 that depend on it:
26392 @example
26393 Word := (3, "yes");
26395 Word := (5, "maybe");
26397 Word := (5, "no"); -- raises Constraint_Error
26398 @end example
26400 In order to support this behavior efficiently, an unconstrained object is
26401 given the maximum size that any value of the type requires. In the case
26402 above, @code{Word} has storage for the discriminant and for
26403 a @code{String} of length 100.
26404 It is important to note that unconstrained objects do not require dynamic
26405 allocation. It would be an improper implementation to place on the heap those
26406 components whose size depends on discriminants. (This improper implementation
26407 was used by some Ada83 compilers, where the @code{Name} component above
26408 would have
26409 been stored as a pointer to a dynamic string). Following the principle that
26410 dynamic storage management should never be introduced implicitly,
26411 an Ada compiler should reserve the full size for an unconstrained declared
26412 object, and place it on the stack.
26414 This maximum size approach
26415 has been a source of surprise to some users, who expect the default
26416 values of the discriminants to determine the size reserved for an
26417 unconstrained object: “If the default is 15, why should the object occupy
26418 a larger size?”
26419 The answer, of course, is that the discriminant may be later modified,
26420 and its full range of values must be taken into account. This is why the
26421 declaration:
26423 @example
26424 type Rec (D : Positive := 15) is record
26425    Name : String (1..D);
26426 end record;
26428 Too_Large : Rec;
26429 @end example
26431 is flagged by the compiler with a warning:
26432 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
26433 because the required size includes @code{Positive'Last}
26434 bytes. As the first example indicates, the proper approach is to declare an
26435 index type of ‘reasonable’ range so that unconstrained objects are not too
26436 large.
26438 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
26439 created in the heap by means of an allocator, then it is `not'
26440 unconstrained:
26441 it is constrained by the default values of the discriminants, and those values
26442 cannot be modified by full assignment. This is because in the presence of
26443 aliasing all views of the object (which may be manipulated by different tasks,
26444 say) must be consistent, so it is imperative that the object, once created,
26445 remain invariant.
26447 @node Image Values For Nonscalar Types,Strict Conformance to the Ada Reference Manual,The Size of Discriminated Records with Default Discriminants,Implementation of Specific Ada Features
26448 @anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{434}@anchor{gnat_rm/implementation_of_specific_ada_features image-values-for-nonscalar-types}@anchor{435}
26449 @section Image Values For Nonscalar Types
26452 Ada 2022 defines the Image, Wide_Image, and Wide_Wide image attributes
26453 for nonscalar types; earlier Ada versions defined these attributes only
26454 for scalar types. Ada RM 4.10 provides some general guidance regarding
26455 the default implementation of these attributes and the GNAT compiler
26456 follows that guidance. However, beyond that the precise details of the
26457 image text generated in these cases are deliberately not documented and are
26458 subject to change. In particular, users should not rely on formatting details
26459 (such as spaces or line breaking), record field order, image values for access
26460 types, image values for types that have ancestor or subcomponent types
26461 declared in non-Ada2022 code, image values for predefined types, or the
26462 compiler’s choices regarding the implementation permissions described in
26463 Ada RM 4.10. This list is not intended to be exhaustive. If more precise
26464 control of image text is required for some type T, then T’Put_Image should be
26465 explicitly specified.
26467 @node Strict Conformance to the Ada Reference Manual,,Image Values For Nonscalar Types,Implementation of Specific Ada Features
26468 @anchor{gnat_rm/implementation_of_specific_ada_features id15}@anchor{436}@anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{437}
26469 @section Strict Conformance to the Ada Reference Manual
26472 The dynamic semantics defined by the Ada Reference Manual impose a set of
26473 run-time checks to be generated. By default, the GNAT compiler will insert many
26474 run-time checks into the compiled code, including most of those required by the
26475 Ada Reference Manual. However, there are two checks that are not enabled in
26476 the default mode for efficiency reasons: checks for access before elaboration
26477 on subprogram calls, and stack overflow checking (most operating systems do not
26478 perform this check by default).
26480 Strict conformance to the Ada Reference Manual can be achieved by adding two
26481 compiler options for dynamic checks for access-before-elaboration on subprogram
26482 calls and generic instantiations (`-gnatE'), and stack overflow checking
26483 (`-fstack-check').
26485 Note that the result of a floating point arithmetic operation in overflow and
26486 invalid situations, when the @code{Machine_Overflows} attribute of the result
26487 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
26488 case for machines compliant with the IEEE floating-point standard, but on
26489 machines that are not fully compliant with this standard, such as Alpha, the
26490 `-mieee' compiler flag must be used for achieving IEEE confirming
26491 behavior (although at the cost of a significant performance penalty), so
26492 infinite and NaN values are properly generated.
26494 @node Implementation of Ada 2012 Features,GNAT language extensions,Implementation of Specific Ada Features,Top
26495 @anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{438}@anchor{gnat_rm/implementation_of_ada_2012_features id1}@anchor{439}@anchor{gnat_rm/implementation_of_ada_2012_features implementation-of-ada-2012-features}@anchor{14}
26496 @chapter Implementation of Ada 2012 Features
26499 @geindex Ada 2012 implementation status
26501 @geindex -gnat12 option (gcc)
26503 @geindex pragma Ada_2012
26505 @geindex configuration pragma Ada_2012
26507 @geindex Ada_2012 configuration pragma
26509 This chapter contains a complete list of Ada 2012 features that have been
26510 implemented.
26511 Generally, these features are only
26512 available if the `-gnat12' (Ada 2012 features enabled) option is set,
26513 which is the default behavior,
26514 or if the configuration pragma @code{Ada_2012} is used.
26516 However, new pragmas, attributes, and restrictions are
26517 unconditionally available, since the Ada 95 standard allows the addition of
26518 new pragmas, attributes, and restrictions (there are exceptions, which are
26519 documented in the individual descriptions), and also certain packages
26520 were made available in earlier versions of Ada.
26522 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
26523 This date shows the implementation date of the feature. Any wavefront
26524 subsequent to this date will contain the indicated feature, as will any
26525 subsequent releases. A date of 0000-00-00 means that GNAT has always
26526 implemented the feature, or implemented it as soon as it appeared as a
26527 binding interpretation.
26529 Each feature corresponds to an Ada Issue (‘AI’) approved by the Ada
26530 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
26531 The features are ordered based on the relevant sections of the Ada
26532 Reference Manual (“RM”).  When a given AI relates to multiple points
26533 in the RM, the earliest is used.
26535 A complete description of the AIs may be found in
26536 @indicateurl{http://www.ada-auth.org/ai05-summary.html}.
26538 @geindex AI-0176 (Ada 2012 feature)
26541 @itemize *
26543 @item 
26544 `AI-0176 Quantified expressions (2010-09-29)'
26546 Both universally and existentially quantified expressions are implemented.
26547 They use the new syntax for iterators proposed in AI05-139-2, as well as
26548 the standard Ada loop syntax.
26550 RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
26551 @end itemize
26553 @geindex AI-0079 (Ada 2012 feature)
26556 @itemize *
26558 @item 
26559 `AI-0079 Allow other_format characters in source (2010-07-10)'
26561 Wide characters in the unicode category `other_format' are now allowed in
26562 source programs between tokens, but not within a token such as an identifier.
26564 RM References:  2.01 (4/2)   2.02 (7)
26565 @end itemize
26567 @geindex AI-0091 (Ada 2012 feature)
26570 @itemize *
26572 @item 
26573 `AI-0091 Do not allow other_format in identifiers (0000-00-00)'
26575 Wide characters in the unicode category `other_format' are not permitted
26576 within  an identifier, since this can be a security problem. The error
26577 message for this case has been improved to be more specific, but GNAT has
26578 never allowed such characters to appear in identifiers.
26580 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)
26581 @end itemize
26583 @geindex AI-0100 (Ada 2012 feature)
26586 @itemize *
26588 @item 
26589 `AI-0100 Placement of pragmas  (2010-07-01)'
26591 This AI is an earlier version of AI-163. It simplifies the rules
26592 for legal placement of pragmas. In the case of lists that allow pragmas, if
26593 the list may have no elements, then the list may consist solely of pragmas.
26595 RM References:  2.08 (7)
26596 @end itemize
26598 @geindex AI-0163 (Ada 2012 feature)
26601 @itemize *
26603 @item 
26604 `AI-0163 Pragmas in place of null (2010-07-01)'
26606 A statement sequence may be composed entirely of pragmas. It is no longer
26607 necessary to add a dummy @code{null} statement to make the sequence legal.
26609 RM References:  2.08 (7)   2.08 (16)
26610 @end itemize
26612 @geindex AI-0080 (Ada 2012 feature)
26615 @itemize *
26617 @item 
26618 `AI-0080 ‘View of’ not needed if clear from context (0000-00-00)'
26620 This is an editorial change only, described as non-testable in the AI.
26622 RM References:  3.01 (7)
26623 @end itemize
26625 @geindex AI-0183 (Ada 2012 feature)
26628 @itemize *
26630 @item 
26631 `AI-0183 Aspect specifications (2010-08-16)'
26633 Aspect specifications have been fully implemented except for pre and post-
26634 conditions, and type invariants, which have their own separate AI’s. All
26635 forms of declarations listed in the AI are supported. The following is a
26636 list of the aspects supported (with GNAT implementation aspects marked)
26637 @end itemize
26640 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxx} 
26641 @headitem
26643 Supported Aspect
26645 @tab
26647 Source
26649 @item
26651 @code{Ada_2005}
26653 @tab
26655 – GNAT
26657 @item
26659 @code{Ada_2012}
26661 @tab
26663 – GNAT
26665 @item
26667 @code{Address}
26669 @tab
26671 @item
26673 @code{Alignment}
26675 @tab
26677 @item
26679 @code{Atomic}
26681 @tab
26683 @item
26685 @code{Atomic_Components}
26687 @tab
26689 @item
26691 @code{Bit_Order}
26693 @tab
26695 @item
26697 @code{Component_Size}
26699 @tab
26701 @item
26703 @code{Contract_Cases}
26705 @tab
26707 – GNAT
26709 @item
26711 @code{Discard_Names}
26713 @tab
26715 @item
26717 @code{External_Tag}
26719 @tab
26721 @item
26723 @code{Favor_Top_Level}
26725 @tab
26727 – GNAT
26729 @item
26731 @code{Inline}
26733 @tab
26735 @item
26737 @code{Inline_Always}
26739 @tab
26741 – GNAT
26743 @item
26745 @code{Invariant}
26747 @tab
26749 – GNAT
26751 @item
26753 @code{Machine_Radix}
26755 @tab
26757 @item
26759 @code{No_Return}
26761 @tab
26763 @item
26765 @code{Object_Size}
26767 @tab
26769 – GNAT
26771 @item
26773 @code{Pack}
26775 @tab
26777 @item
26779 @code{Persistent_BSS}
26781 @tab
26783 – GNAT
26785 @item
26787 @code{Post}
26789 @tab
26791 @item
26793 @code{Pre}
26795 @tab
26797 @item
26799 @code{Predicate}
26801 @tab
26803 @item
26805 @code{Preelaborable_Initialization}
26807 @tab
26809 @item
26811 @code{Pure_Function}
26813 @tab
26815 – GNAT
26817 @item
26819 @code{Remote_Access_Type}
26821 @tab
26823 – GNAT
26825 @item
26827 @code{Shared}
26829 @tab
26831 – GNAT
26833 @item
26835 @code{Size}
26837 @tab
26839 @item
26841 @code{Storage_Pool}
26843 @tab
26845 @item
26847 @code{Storage_Size}
26849 @tab
26851 @item
26853 @code{Stream_Size}
26855 @tab
26857 @item
26859 @code{Suppress}
26861 @tab
26863 @item
26865 @code{Suppress_Debug_Info}
26867 @tab
26869 – GNAT
26871 @item
26873 @code{Test_Case}
26875 @tab
26877 – GNAT
26879 @item
26881 @code{Thread_Local_Storage}
26883 @tab
26885 – GNAT
26887 @item
26889 @code{Type_Invariant}
26891 @tab
26893 @item
26895 @code{Unchecked_Union}
26897 @tab
26899 @item
26901 @code{Universal_Aliasing}
26903 @tab
26905 – GNAT
26907 @item
26909 @code{Unmodified}
26911 @tab
26913 – GNAT
26915 @item
26917 @code{Unreferenced}
26919 @tab
26921 – GNAT
26923 @item
26925 @code{Unreferenced_Objects}
26927 @tab
26929 – GNAT
26931 @item
26933 @code{Unsuppress}
26935 @tab
26937 @item
26939 @code{Value_Size}
26941 @tab
26943 – GNAT
26945 @item
26947 @code{Volatile}
26949 @tab
26951 @item
26953 @code{Volatile_Components}
26955 @tab
26957 @item
26959 @code{Warnings}
26961 @tab
26963 – GNAT
26965 @end multitable
26968 @quotation
26970 Note that for aspects with an expression, e.g. @code{Size}, the expression is
26971 treated like a default expression (visibility is analyzed at the point of
26972 occurrence of the aspect, but evaluation of the expression occurs at the
26973 freeze point of the entity involved).
26975 RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
26976 3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
26977 (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
26978 9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
26979 12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
26980 13.03.01 (0)
26981 @end quotation
26983 @geindex AI-0128 (Ada 2012 feature)
26986 @itemize *
26988 @item 
26989 `AI-0128 Inequality is a primitive operation (0000-00-00)'
26991 If an equality operator (“=”) is declared for a type, then the implicitly
26992 declared inequality operator (“/=”) is a primitive operation of the type.
26993 This is the only reasonable interpretation, and is the one always implemented
26994 by GNAT, but the RM was not entirely clear in making this point.
26996 RM References:  3.02.03 (6)   6.06 (6)
26997 @end itemize
26999 @geindex AI-0003 (Ada 2012 feature)
27002 @itemize *
27004 @item 
27005 `AI-0003 Qualified expressions as names (2010-07-11)'
27007 In Ada 2012, a qualified expression is considered to be syntactically a name,
27008 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
27009 useful in disambiguating some cases of overloading.
27011 RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
27012 5.04 (7)
27013 @end itemize
27015 @geindex AI-0120 (Ada 2012 feature)
27018 @itemize *
27020 @item 
27021 `AI-0120 Constant instance of protected object (0000-00-00)'
27023 This is an RM editorial change only. The section that lists objects that are
27024 constant failed to include the current instance of a protected object
27025 within a protected function. This has always been treated as a constant
27026 in GNAT.
27028 RM References:  3.03 (21)
27029 @end itemize
27031 @geindex AI-0008 (Ada 2012 feature)
27034 @itemize *
27036 @item 
27037 `AI-0008 General access to constrained objects (0000-00-00)'
27039 The wording in the RM implied that if you have a general access to a
27040 constrained object, it could be used to modify the discriminants. This was
27041 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
27042 has always done so in this situation.
27044 RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
27045 @end itemize
27047 @geindex AI-0093 (Ada 2012 feature)
27050 @itemize *
27052 @item 
27053 `AI-0093 Additional rules use immutably limited (0000-00-00)'
27055 This is an editorial change only, to make more widespread use of the Ada 2012
27056 ‘immutably limited’.
27058 RM References:  3.03 (23.4/3)
27059 @end itemize
27061 @geindex AI-0096 (Ada 2012 feature)
27064 @itemize *
27066 @item 
27067 `AI-0096 Deriving from formal private types (2010-07-20)'
27069 In general it is illegal for a type derived from a formal limited type to be
27070 nonlimited.  This AI makes an exception to this rule: derivation is legal
27071 if it appears in the private part of the generic, and the formal type is not
27072 tagged. If the type is tagged, the legality check must be applied to the
27073 private part of the package.
27075 RM References:  3.04 (5.1/2)   6.02 (7)
27076 @end itemize
27078 @geindex AI-0181 (Ada 2012 feature)
27081 @itemize *
27083 @item 
27084 `AI-0181 Soft hyphen is a non-graphic character (2010-07-23)'
27086 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
27087 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
27088 @code{Image} and @code{Value} attributes for the character types. Strictly
27089 speaking this is an inconsistency with Ada 95, but in practice the use of
27090 these attributes is so obscure that it will not cause problems.
27092 RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
27093 @end itemize
27095 @geindex AI-0182 (Ada 2012 feature)
27098 @itemize *
27100 @item 
27101 `AI-0182 Additional forms for' @code{Character'Value} `(0000-00-00)'
27103 This AI allows @code{Character'Value} to accept the string @code{'?'} where
27104 @code{?} is any character including non-graphic control characters. GNAT has
27105 always accepted such strings. It also allows strings such as
27106 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
27107 permission and raises @code{Constraint_Error}, as is certainly still
27108 permitted.
27110 RM References:  3.05 (56/2)
27111 @end itemize
27113 @geindex AI-0214 (Ada 2012 feature)
27116 @itemize *
27118 @item 
27119 `AI-0214 Defaulted discriminants for limited tagged (2010-10-01)'
27121 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
27122 to have default expressions by allowing them when the type is limited. It
27123 is often useful to define a default value for a discriminant even though
27124 it can’t be changed by assignment.
27126 RM References:  3.07 (9.1/2)   3.07.02 (3)
27127 @end itemize
27129 @geindex AI-0102 (Ada 2012 feature)
27132 @itemize *
27134 @item 
27135 `AI-0102 Some implicit conversions are illegal (0000-00-00)'
27137 It is illegal to assign an anonymous access constant to an anonymous access
27138 variable. The RM did not have a clear rule to prevent this, but GNAT has
27139 always generated an error for this usage.
27141 RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
27142 @end itemize
27144 @geindex AI-0158 (Ada 2012 feature)
27147 @itemize *
27149 @item 
27150 `AI-0158 Generalizing membership tests (2010-09-16)'
27152 This AI extends the syntax of membership tests to simplify complex conditions
27153 that can be expressed as membership in a subset of values of any type. It
27154 introduces syntax for a list of expressions that may be used in loop contexts
27155 as well.
27157 RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
27158 @end itemize
27160 @geindex AI-0173 (Ada 2012 feature)
27163 @itemize *
27165 @item 
27166 `AI-0173 Testing if tags represent abstract types (2010-07-03)'
27168 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
27169 with the tag of an abstract type, and @code{False} otherwise.
27171 RM References:  3.09 (7.4/2)   3.09 (12.4/2)
27172 @end itemize
27174 @geindex AI-0076 (Ada 2012 feature)
27177 @itemize *
27179 @item 
27180 `AI-0076 function with controlling result (0000-00-00)'
27182 This is an editorial change only. The RM defines calls with controlling
27183 results, but uses the term ‘function with controlling result’ without an
27184 explicit definition.
27186 RM References:  3.09.02 (2/2)
27187 @end itemize
27189 @geindex AI-0126 (Ada 2012 feature)
27192 @itemize *
27194 @item 
27195 `AI-0126 Dispatching with no declared operation (0000-00-00)'
27197 This AI clarifies dispatching rules, and simply confirms that dispatching
27198 executes the operation of the parent type when there is no explicitly or
27199 implicitly declared operation for the descendant type. This has always been
27200 the case in all versions of GNAT.
27202 RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
27203 @end itemize
27205 @geindex AI-0097 (Ada 2012 feature)
27208 @itemize *
27210 @item 
27211 `AI-0097 Treatment of abstract null extension (2010-07-19)'
27213 The RM as written implied that in some cases it was possible to create an
27214 object of an abstract type, by having an abstract extension inherit a non-
27215 abstract constructor from its parent type. This mistake has been corrected
27216 in GNAT and in the RM, and this construct is now illegal.
27218 RM References:  3.09.03 (4/2)
27219 @end itemize
27221 @geindex AI-0203 (Ada 2012 feature)
27224 @itemize *
27226 @item 
27227 `AI-0203 Extended return cannot be abstract (0000-00-00)'
27229 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
27230 permitted such usage.
27232 RM References:  3.09.03 (8/3)
27233 @end itemize
27235 @geindex AI-0198 (Ada 2012 feature)
27238 @itemize *
27240 @item 
27241 `AI-0198 Inheriting abstract operators  (0000-00-00)'
27243 This AI resolves a conflict between two rules involving inherited abstract
27244 operations and predefined operators. If a derived numeric type inherits
27245 an abstract operator, it overrides the predefined one. This interpretation
27246 was always the one implemented in GNAT.
27248 RM References:  3.09.03 (4/3)
27249 @end itemize
27251 @geindex AI-0073 (Ada 2012 feature)
27254 @itemize *
27256 @item 
27257 `AI-0073 Functions returning abstract types (2010-07-10)'
27259 This AI covers a number of issues regarding returning abstract types. In
27260 particular generic functions cannot have abstract result types or access
27261 result types designated an abstract type. There are some other cases which
27262 are detailed in the AI. Note that this binding interpretation has not been
27263 retrofitted to operate before Ada 2012 mode, since it caused a significant
27264 number of regressions.
27266 RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
27267 @end itemize
27269 @geindex AI-0070 (Ada 2012 feature)
27272 @itemize *
27274 @item 
27275 `AI-0070 Elaboration of interface types (0000-00-00)'
27277 This is an editorial change only, there are no testable consequences short of
27278 checking for the absence of generated code for an interface declaration.
27280 RM References:  3.09.04 (18/2)
27281 @end itemize
27283 @geindex AI-0208 (Ada 2012 feature)
27286 @itemize *
27288 @item 
27289 `AI-0208 Characteristics of incomplete views (0000-00-00)'
27291 The wording in the Ada 2005 RM concerning characteristics of incomplete views
27292 was incorrect and implied that some programs intended to be legal were now
27293 illegal. GNAT had never considered such programs illegal, so it has always
27294 implemented the intent of this AI.
27296 RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
27297 @end itemize
27299 @geindex AI-0162 (Ada 2012 feature)
27302 @itemize *
27304 @item 
27305 `AI-0162 Incomplete type completed by partial view (2010-09-15)'
27307 Incomplete types are made more useful by allowing them to be completed by
27308 private types and private extensions.
27310 RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
27311 @end itemize
27313 @geindex AI-0098 (Ada 2012 feature)
27316 @itemize *
27318 @item 
27319 `AI-0098 Anonymous subprogram access restrictions (0000-00-00)'
27321 An unintentional omission in the RM implied some inconsistent restrictions on
27322 the use of anonymous access to subprogram values. These restrictions were not
27323 intentional, and have never been enforced by GNAT.
27325 RM References:  3.10.01 (6)   3.10.01 (9.2/2)
27326 @end itemize
27328 @geindex AI-0199 (Ada 2012 feature)
27331 @itemize *
27333 @item 
27334 `AI-0199 Aggregate with anonymous access components (2010-07-14)'
27336 A choice list in a record aggregate can include several components of
27337 (distinct) anonymous access types as long as they have matching designated
27338 subtypes.
27340 RM References:  4.03.01 (16)
27341 @end itemize
27343 @geindex AI-0220 (Ada 2012 feature)
27346 @itemize *
27348 @item 
27349 `AI-0220 Needed components for aggregates (0000-00-00)'
27351 This AI addresses a wording problem in the RM that appears to permit some
27352 complex cases of aggregates with nonstatic discriminants. GNAT has always
27353 implemented the intended semantics.
27355 RM References:  4.03.01 (17)
27356 @end itemize
27358 @geindex AI-0147 (Ada 2012 feature)
27361 @itemize *
27363 @item 
27364 `AI-0147 Conditional expressions (2009-03-29)'
27366 Conditional expressions are permitted. The form of such an expression is:
27368 @example
27369 (if expr then expr @{elsif expr then expr@} [else expr])
27370 @end example
27372 The parentheses can be omitted in contexts where parentheses are present
27373 anyway, such as subprogram arguments and pragma arguments. If the `else'
27374 clause is omitted, `else' `True' is assumed;
27375 thus @code{(if A then B)} is a way to conveniently represent
27376 `(A implies B)' in standard logic.
27378 RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
27379 4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
27380 @end itemize
27382 @geindex AI-0037 (Ada 2012 feature)
27385 @itemize *
27387 @item 
27388 `AI-0037 Out-of-range box associations in aggregate (0000-00-00)'
27390 This AI confirms that an association of the form @code{Indx => <>} in an
27391 array aggregate must raise @code{Constraint_Error} if @code{Indx}
27392 is out of range. The RM specified a range check on other associations, but
27393 not when the value of the association was defaulted. GNAT has always inserted
27394 a constraint check on the index value.
27396 RM References:  4.03.03 (29)
27397 @end itemize
27399 @geindex AI-0123 (Ada 2012 feature)
27402 @itemize *
27404 @item 
27405 `AI-0123 Composability of equality (2010-04-13)'
27407 Equality of untagged record composes, so that the predefined equality for a
27408 composite type that includes a component of some untagged record type
27409 @code{R} uses the equality operation of @code{R} (which may be user-defined
27410 or predefined). This makes the behavior of untagged records identical to that
27411 of tagged types in this respect.
27413 This change is an incompatibility with previous versions of Ada, but it
27414 corrects a non-uniformity that was often a source of confusion. Analysis of
27415 a large number of industrial programs indicates that in those rare cases
27416 where a composite type had an untagged record component with a user-defined
27417 equality, either there was no use of the composite equality, or else the code
27418 expected the same composability as for tagged types, and thus had a bug that
27419 would be fixed by this change.
27421 RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
27422 8.05.04 (8)
27423 @end itemize
27425 @geindex AI-0088 (Ada 2012 feature)
27428 @itemize *
27430 @item 
27431 `AI-0088 The value of exponentiation (0000-00-00)'
27433 This AI clarifies the equivalence rule given for the dynamic semantics of
27434 exponentiation: the value of the operation can be obtained by repeated
27435 multiplication, but the operation can be implemented otherwise (for example
27436 using the familiar divide-by-two-and-square algorithm, even if this is less
27437 accurate), and does not imply repeated reads of a volatile base.
27439 RM References:  4.05.06 (11)
27440 @end itemize
27442 @geindex AI-0188 (Ada 2012 feature)
27445 @itemize *
27447 @item 
27448 `AI-0188 Case expressions (2010-01-09)'
27450 Case expressions are permitted. This allows use of constructs such as:
27452 @example
27453 X := (case Y is when 1 => 2, when 2 => 3, when others => 31)
27454 @end example
27456 RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
27457 @end itemize
27459 @geindex AI-0104 (Ada 2012 feature)
27462 @itemize *
27464 @item 
27465 `AI-0104 Null exclusion and uninitialized allocator (2010-07-15)'
27467 The assignment @code{Ptr := new not null Some_Ptr;} will raise
27468 @code{Constraint_Error} because the default value of the allocated object is
27469 `null'. This useless construct is illegal in Ada 2012.
27471 RM References:  4.08 (2)
27472 @end itemize
27474 @geindex AI-0157 (Ada 2012 feature)
27477 @itemize *
27479 @item 
27480 `AI-0157 Allocation/Deallocation from empty pool (2010-07-11)'
27482 Allocation and Deallocation from an empty storage pool (i.e. allocation or
27483 deallocation of a pointer for which a static storage size clause of zero
27484 has been given) is now illegal and is detected as such. GNAT
27485 previously gave a warning but not an error.
27487 RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
27488 @end itemize
27490 @geindex AI-0179 (Ada 2012 feature)
27493 @itemize *
27495 @item 
27496 `AI-0179 Statement not required after label (2010-04-10)'
27498 It is not necessary to have a statement following a label, so a label
27499 can appear at the end of a statement sequence without the need for putting a
27500 null statement afterwards, but it is not allowable to have only labels and
27501 no real statements in a statement sequence.
27503 RM References:  5.01 (2)
27504 @end itemize
27506 @geindex AI-0139-2 (Ada 2012 feature)
27509 @itemize *
27511 @item 
27512 `AI-0139-2 Syntactic sugar for iterators (2010-09-29)'
27514 The new syntax for iterating over arrays and containers is now implemented.
27515 Iteration over containers is for now limited to read-only iterators. Only
27516 default iterators are supported, with the syntax:  @code{for Elem of C}.
27518 RM References:  5.05
27519 @end itemize
27521 @geindex AI-0134 (Ada 2012 feature)
27524 @itemize *
27526 @item 
27527 `AI-0134 Profiles must match for full conformance (0000-00-00)'
27529 For full conformance, the profiles of anonymous-access-to-subprogram
27530 parameters must match. GNAT has always enforced this rule.
27532 RM References:  6.03.01 (18)
27533 @end itemize
27535 @geindex AI-0207 (Ada 2012 feature)
27538 @itemize *
27540 @item 
27541 `AI-0207 Mode conformance and access constant (0000-00-00)'
27543 This AI confirms that access_to_constant indication must match for mode
27544 conformance. This was implemented in GNAT when the qualifier was originally
27545 introduced in Ada 2005.
27547 RM References:  6.03.01 (16/2)
27548 @end itemize
27550 @geindex AI-0046 (Ada 2012 feature)
27553 @itemize *
27555 @item 
27556 `AI-0046 Null exclusion match for full conformance (2010-07-17)'
27558 For full conformance, in the case of access parameters, the null exclusion
27559 must match (either both or neither must have @code{not null}).
27561 RM References:  6.03.02 (18)
27562 @end itemize
27564 @geindex AI-0118 (Ada 2012 feature)
27567 @itemize *
27569 @item 
27570 `AI-0118 The association of parameter associations (0000-00-00)'
27572 This AI clarifies the rules for named associations in subprogram calls and
27573 generic instantiations. The rules have been in place since Ada 83.
27575 RM References:  6.04.01 (2)   12.03 (9)
27576 @end itemize
27578 @geindex AI-0196 (Ada 2012 feature)
27581 @itemize *
27583 @item 
27584 `AI-0196 Null exclusion tests for out parameters (0000-00-00)'
27586 Null exclusion checks are not made for @code{out} parameters when
27587 evaluating the actual parameters. GNAT has never generated these checks.
27589 RM References:  6.04.01 (13)
27590 @end itemize
27592 @geindex AI-0015 (Ada 2012 feature)
27595 @itemize *
27597 @item 
27598 `AI-0015 Constant return objects (0000-00-00)'
27600 The return object declared in an `extended_return_statement' may be
27601 declared constant. This was always intended, and GNAT has always allowed it.
27603 RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
27604 6.05 (5.7/2)
27605 @end itemize
27607 @geindex AI-0032 (Ada 2012 feature)
27610 @itemize *
27612 @item 
27613 `AI-0032 Extended return for class-wide functions (0000-00-00)'
27615 If a function returns a class-wide type, the object of an extended return
27616 statement can be declared with a specific type that is covered by the class-
27617 wide type. This has been implemented in GNAT since the introduction of
27618 extended returns. Note AI-0103 complements this AI by imposing matching
27619 rules for constrained return types.
27621 RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
27622 6.05 (8/2)
27623 @end itemize
27625 @geindex AI-0103 (Ada 2012 feature)
27628 @itemize *
27630 @item 
27631 `AI-0103 Static matching for extended return (2010-07-23)'
27633 If the return subtype of a function is an elementary type or a constrained
27634 type, the subtype indication in an extended return statement must match
27635 statically this return subtype.
27637 RM References:  6.05 (5.2/2)
27638 @end itemize
27640 @geindex AI-0058 (Ada 2012 feature)
27643 @itemize *
27645 @item 
27646 `AI-0058 Abnormal completion of an extended return (0000-00-00)'
27648 The RM had some incorrect wording implying wrong treatment of abnormal
27649 completion in an extended return. GNAT has always implemented the intended
27650 correct semantics as described by this AI.
27652 RM References:  6.05 (22/2)
27653 @end itemize
27655 @geindex AI-0050 (Ada 2012 feature)
27658 @itemize *
27660 @item 
27661 `AI-0050 Raising Constraint_Error early for function call (0000-00-00)'
27663 The implementation permissions for raising @code{Constraint_Error} early on a function call
27664 when it was clear an exception would be raised were over-permissive and allowed
27665 mishandling of discriminants in some cases. GNAT did
27666 not take advantage of these incorrect permissions in any case.
27668 RM References:  6.05 (24/2)
27669 @end itemize
27671 @geindex AI-0125 (Ada 2012 feature)
27674 @itemize *
27676 @item 
27677 `AI-0125 Nonoverridable operations of an ancestor (2010-09-28)'
27679 In Ada 2012, the declaration of a primitive operation of a type extension
27680 or private extension can also override an inherited primitive that is not
27681 visible at the point of this declaration.
27683 RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
27684 @end itemize
27686 @geindex AI-0062 (Ada 2012 feature)
27689 @itemize *
27691 @item 
27692 `AI-0062 Null exclusions and deferred constants (0000-00-00)'
27694 A full constant may have a null exclusion even if its associated deferred
27695 constant does not. GNAT has always allowed this.
27697 RM References:  7.04 (6/2)   7.04 (7.1/2)
27698 @end itemize
27700 @geindex AI-0178 (Ada 2012 feature)
27703 @itemize *
27705 @item 
27706 `AI-0178 Incomplete views are limited (0000-00-00)'
27708 This AI clarifies the role of incomplete views and plugs an omission in the
27709 RM. GNAT always correctly restricted the use of incomplete views and types.
27711 RM References:  7.05 (3/2)   7.05 (6/2)
27712 @end itemize
27714 @geindex AI-0087 (Ada 2012 feature)
27717 @itemize *
27719 @item 
27720 `AI-0087 Actual for formal nonlimited derived type (2010-07-15)'
27722 The actual for a formal nonlimited derived type cannot be limited. In
27723 particular, a formal derived type that extends a limited interface but which
27724 is not explicitly limited cannot be instantiated with a limited type.
27726 RM References:  7.05 (5/2)   12.05.01 (5.1/2)
27727 @end itemize
27729 @geindex AI-0099 (Ada 2012 feature)
27732 @itemize *
27734 @item 
27735 `AI-0099 Tag determines whether finalization needed (0000-00-00)'
27737 This AI clarifies that ‘needs finalization’ is part of dynamic semantics,
27738 and therefore depends on the run-time characteristics of an object (i.e. its
27739 tag) and not on its nominal type. As the AI indicates: “we do not expect
27740 this to affect any implementation’’.
27742 RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
27743 @end itemize
27745 @geindex AI-0064 (Ada 2012 feature)
27748 @itemize *
27750 @item 
27751 `AI-0064 Redundant finalization rule (0000-00-00)'
27753 This is an editorial change only. The intended behavior is already checked
27754 by an existing ACATS test, which GNAT has always executed correctly.
27756 RM References:  7.06.01 (17.1/1)
27757 @end itemize
27759 @geindex AI-0026 (Ada 2012 feature)
27762 @itemize *
27764 @item 
27765 `AI-0026 Missing rules for Unchecked_Union (2010-07-07)'
27767 Record representation clauses concerning Unchecked_Union types cannot mention
27768 the discriminant of the type. The type of a component declared in the variant
27769 part of an Unchecked_Union cannot be controlled, have controlled components,
27770 nor have protected or task parts. If an Unchecked_Union type is declared
27771 within the body of a generic unit or its descendants, then the type of a
27772 component declared in the variant part cannot be a formal private type or a
27773 formal private extension declared within the same generic unit.
27775 RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
27776 @end itemize
27778 @geindex AI-0205 (Ada 2012 feature)
27781 @itemize *
27783 @item 
27784 `AI-0205 Extended return declares visible name (0000-00-00)'
27786 This AI corrects a simple omission in the RM. Return objects have always
27787 been visible within an extended return statement.
27789 RM References:  8.03 (17)
27790 @end itemize
27792 @geindex AI-0042 (Ada 2012 feature)
27795 @itemize *
27797 @item 
27798 `AI-0042 Overriding versus implemented-by (0000-00-00)'
27800 This AI fixes a wording gap in the RM. An operation of a synchronized
27801 interface can be implemented by a protected or task entry, but the abstract
27802 operation is not being overridden in the usual sense, and it must be stated
27803 separately that this implementation is legal. This has always been the case
27804 in GNAT.
27806 RM References:  9.01 (9.2/2)   9.04 (11.1/2)
27807 @end itemize
27809 @geindex AI-0030 (Ada 2012 feature)
27812 @itemize *
27814 @item 
27815 `AI-0030 Requeue on synchronized interfaces (2010-07-19)'
27817 Requeue is permitted to a protected, synchronized or task interface primitive
27818 providing it is known that the overriding operation is an entry. Otherwise
27819 the requeue statement has the same effect as a procedure call. Use of pragma
27820 @code{Implemented} provides a way to impose a static requirement on the
27821 overriding operation by adhering to one of the implementation kinds: entry,
27822 protected procedure or any of the above.
27824 RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
27825 9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
27826 @end itemize
27828 @geindex AI-0201 (Ada 2012 feature)
27831 @itemize *
27833 @item 
27834 `AI-0201 Independence of atomic object components (2010-07-22)'
27836 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
27837 attribute, then individual components may not be addressable by independent
27838 tasks. However, if the representation clause has no effect (is confirming),
27839 then independence is not compromised. Furthermore, in GNAT, specification of
27840 other appropriately addressable component sizes (e.g. 16 for 8-bit
27841 characters) also preserves independence. GNAT now gives very clear warnings
27842 both for the declaration of such a type, and for any assignment to its components.
27844 RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
27845 @end itemize
27847 @geindex AI-0009 (Ada 2012 feature)
27850 @itemize *
27852 @item 
27853 `AI-0009 Pragma Independent[_Components] (2010-07-23)'
27855 This AI introduces the new pragmas @code{Independent} and
27856 @code{Independent_Components},
27857 which control guaranteeing independence of access to objects and components.
27858 The AI also requires independence not unaffected by confirming rep clauses.
27860 RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
27861 C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
27862 @end itemize
27864 @geindex AI-0072 (Ada 2012 feature)
27867 @itemize *
27869 @item 
27870 `AI-0072 Task signalling using ‘Terminated (0000-00-00)'
27872 This AI clarifies that task signalling for reading @code{'Terminated} only
27873 occurs if the result is True. GNAT semantics has always been consistent with
27874 this notion of task signalling.
27876 RM References:  9.10 (6.1/1)
27877 @end itemize
27879 @geindex AI-0108 (Ada 2012 feature)
27882 @itemize *
27884 @item 
27885 `AI-0108 Limited incomplete view and discriminants (0000-00-00)'
27887 This AI confirms that an incomplete type from a limited view does not have
27888 discriminants. This has always been the case in GNAT.
27890 RM References:  10.01.01 (12.3/2)
27891 @end itemize
27893 @geindex AI-0129 (Ada 2012 feature)
27896 @itemize *
27898 @item 
27899 `AI-0129 Limited views and incomplete types (0000-00-00)'
27901 This AI clarifies the description of limited views: a limited view of a
27902 package includes only one view of a type that has an incomplete declaration
27903 and a full declaration (there is no possible ambiguity in a client package).
27904 This AI also fixes an omission: a nested package in the private part has no
27905 limited view. GNAT always implemented this correctly.
27907 RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
27908 @end itemize
27910 @geindex AI-0077 (Ada 2012 feature)
27913 @itemize *
27915 @item 
27916 `AI-0077 Limited withs and scope of declarations (0000-00-00)'
27918 This AI clarifies that a declaration does not include a context clause,
27919 and confirms that it is illegal to have a context in which both a limited
27920 and a nonlimited view of a package are accessible. Such double visibility
27921 was always rejected by GNAT.
27923 RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
27924 @end itemize
27926 @geindex AI-0122 (Ada 2012 feature)
27929 @itemize *
27931 @item 
27932 `AI-0122 Private with and children of generics (0000-00-00)'
27934 This AI clarifies the visibility of private children of generic units within
27935 instantiations of a parent. GNAT has always handled this correctly.
27937 RM References:  10.01.02 (12/2)
27938 @end itemize
27940 @geindex AI-0040 (Ada 2012 feature)
27943 @itemize *
27945 @item 
27946 `AI-0040 Limited with clauses on descendant (0000-00-00)'
27948 This AI confirms that a limited with clause in a child unit cannot name
27949 an ancestor of the unit. This has always been checked in GNAT.
27951 RM References:  10.01.02 (20/2)
27952 @end itemize
27954 @geindex AI-0132 (Ada 2012 feature)
27957 @itemize *
27959 @item 
27960 `AI-0132 Placement of library unit pragmas (0000-00-00)'
27962 This AI fills a gap in the description of library unit pragmas. The pragma
27963 clearly must apply to a library unit, even if it does not carry the name
27964 of the enclosing unit. GNAT has always enforced the required check.
27966 RM References:  10.01.05 (7)
27967 @end itemize
27969 @geindex AI-0034 (Ada 2012 feature)
27972 @itemize *
27974 @item 
27975 `AI-0034 Categorization of limited views (0000-00-00)'
27977 The RM makes certain limited with clauses illegal because of categorization
27978 considerations, when the corresponding normal with would be legal. This is
27979 not intended, and GNAT has always implemented the recommended behavior.
27981 RM References:  10.02.01 (11/1)   10.02.01 (17/2)
27982 @end itemize
27984 @geindex AI-0035 (Ada 2012 feature)
27987 @itemize *
27989 @item 
27990 `AI-0035 Inconsistencies with Pure units (0000-00-00)'
27992 This AI remedies some inconsistencies in the legality rules for Pure units.
27993 Derived access types are legal in a pure unit (on the assumption that the
27994 rule for a zero storage pool size has been enforced on the ancestor type).
27995 The rules are enforced in generic instances and in subunits. GNAT has always
27996 implemented the recommended behavior.
27998 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)
27999 @end itemize
28001 @geindex AI-0219 (Ada 2012 feature)
28004 @itemize *
28006 @item 
28007 `AI-0219 Pure permissions and limited parameters (2010-05-25)'
28009 This AI refines the rules for the cases with limited parameters which do not
28010 allow the implementations to omit ‘redundant’. GNAT now properly conforms
28011 to the requirements of this binding interpretation.
28013 RM References:  10.02.01 (18/2)
28014 @end itemize
28016 @geindex AI-0043 (Ada 2012 feature)
28019 @itemize *
28021 @item 
28022 `AI-0043 Rules about raising exceptions (0000-00-00)'
28024 This AI covers various omissions in the RM regarding the raising of
28025 exceptions. GNAT has always implemented the intended semantics.
28027 RM References:  11.04.01 (10.1/2)   11 (2)
28028 @end itemize
28030 @geindex AI-0200 (Ada 2012 feature)
28033 @itemize *
28035 @item 
28036 `AI-0200 Mismatches in formal package declarations (0000-00-00)'
28038 This AI plugs a gap in the RM which appeared to allow some obviously intended
28039 illegal instantiations. GNAT has never allowed these instantiations.
28041 RM References:  12.07 (16)
28042 @end itemize
28044 @geindex AI-0112 (Ada 2012 feature)
28047 @itemize *
28049 @item 
28050 `AI-0112 Detection of duplicate pragmas (2010-07-24)'
28052 This AI concerns giving names to various representation aspects, but the
28053 practical effect is simply to make the use of duplicate
28054 @code{Atomic[_Components]},
28055 @code{Volatile[_Components]}, and
28056 @code{Independent[_Components]} pragmas illegal, and GNAT
28057 now performs this required check.
28059 RM References:  13.01 (8)
28060 @end itemize
28062 @geindex AI-0106 (Ada 2012 feature)
28065 @itemize *
28067 @item 
28068 `AI-0106 No representation pragmas on generic formals (0000-00-00)'
28070 The RM appeared to allow representation pragmas on generic formal parameters,
28071 but this was not intended, and GNAT has never permitted this usage.
28073 RM References:  13.01 (9.1/1)
28074 @end itemize
28076 @geindex AI-0012 (Ada 2012 feature)
28079 @itemize *
28081 @item 
28082 `AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)'
28084 It is now illegal to give an inappropriate component size or a pragma
28085 @code{Pack} that attempts to change the component size in the case of atomic
28086 or aliased components. Previously GNAT ignored such an attempt with a
28087 warning.
28089 RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
28090 @end itemize
28092 @geindex AI-0039 (Ada 2012 feature)
28095 @itemize *
28097 @item 
28098 `AI-0039 Stream attributes cannot be dynamic (0000-00-00)'
28100 The RM permitted the use of dynamic expressions (such as @code{ptr.all})`
28101 for stream attributes, but these were never useful and are now illegal. GNAT
28102 has always regarded such expressions as illegal.
28104 RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
28105 @end itemize
28107 @geindex AI-0095 (Ada 2012 feature)
28110 @itemize *
28112 @item 
28113 `AI-0095 Address of intrinsic subprograms (0000-00-00)'
28115 The prefix of @code{'Address} cannot statically denote a subprogram with
28116 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
28117 @code{Program_Error} if the prefix denotes a subprogram with convention
28118 @code{Intrinsic}.
28120 RM References:  13.03 (11/1)
28121 @end itemize
28123 @geindex AI-0116 (Ada 2012 feature)
28126 @itemize *
28128 @item 
28129 `AI-0116 Alignment of class-wide objects (0000-00-00)'
28131 This AI requires that the alignment of a class-wide object be no greater
28132 than the alignment of any type in the class. GNAT has always followed this
28133 recommendation.
28135 RM References:  13.03 (29)   13.11 (16)
28136 @end itemize
28138 @geindex AI-0146 (Ada 2012 feature)
28141 @itemize *
28143 @item 
28144 `AI-0146 Type invariants (2009-09-21)'
28146 Type invariants may be specified for private types using the aspect notation.
28147 Aspect @code{Type_Invariant} may be specified for any private type,
28148 @code{Type_Invariant'Class} can
28149 only be specified for tagged types, and is inherited by any descendent of the
28150 tagged types. The invariant is a boolean expression that is tested for being
28151 true in the following situations: conversions to the private type, object
28152 declarations for the private type that are default initialized, and
28153 [`in'] `out'
28154 parameters and returned result on return from any primitive operation for
28155 the type that is visible to a client.
28156 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
28157 @code{Invariant'Class} for @code{Type_Invariant'Class}.
28159 RM References:  13.03.03 (00)
28160 @end itemize
28162 @geindex AI-0078 (Ada 2012 feature)
28165 @itemize *
28167 @item 
28168 `AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)'
28170 In Ada 2012, compilers are required to support unchecked conversion where the
28171 target alignment is a multiple of the source alignment. GNAT always supported
28172 this case (and indeed all cases of differing alignments, doing copies where
28173 required if the alignment was reduced).
28175 RM References:  13.09 (7)
28176 @end itemize
28178 @geindex AI-0195 (Ada 2012 feature)
28181 @itemize *
28183 @item 
28184 `AI-0195 Invalid value handling is implementation defined (2010-07-03)'
28186 The handling of invalid values is now designated to be implementation
28187 defined. This is a documentation change only, requiring Annex M in the GNAT
28188 Reference Manual to document this handling.
28189 In GNAT, checks for invalid values are made
28190 only when necessary to avoid erroneous behavior. Operations like assignments
28191 which cannot cause erroneous behavior ignore the possibility of invalid
28192 values and do not do a check. The date given above applies only to the
28193 documentation change, this behavior has always been implemented by GNAT.
28195 RM References:  13.09.01 (10)
28196 @end itemize
28198 @geindex AI-0193 (Ada 2012 feature)
28201 @itemize *
28203 @item 
28204 `AI-0193 Alignment of allocators (2010-09-16)'
28206 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
28207 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
28208 of size.
28210 RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
28211 13.11.01 (2)   13.11.01 (3)
28212 @end itemize
28214 @geindex AI-0177 (Ada 2012 feature)
28217 @itemize *
28219 @item 
28220 `AI-0177 Parameterized expressions (2010-07-10)'
28222 The new Ada 2012 notion of parameterized expressions is implemented. The form
28225 @example
28226 function-specification is (expression)
28227 @end example
28229 This is exactly equivalent to the
28230 corresponding function body that returns the expression, but it can appear
28231 in a package spec. Note that the expression must be parenthesized.
28233 RM References:  13.11.01 (3/2)
28234 @end itemize
28236 @geindex AI-0033 (Ada 2012 feature)
28239 @itemize *
28241 @item 
28242 `AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)'
28244 Neither of these two pragmas may appear within a generic template, because
28245 the generic might be instantiated at other than the library level.
28247 RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
28248 @end itemize
28250 @geindex AI-0161 (Ada 2012 feature)
28253 @itemize *
28255 @item 
28256 `AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)'
28258 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
28259 of the default stream attributes for elementary types. If this restriction is
28260 in force, then it is necessary to provide explicit subprograms for any
28261 stream attributes used.
28263 RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
28264 @end itemize
28266 @geindex AI-0194 (Ada 2012 feature)
28269 @itemize *
28271 @item 
28272 `AI-0194 Value of Stream_Size attribute (0000-00-00)'
28274 The @code{Stream_Size} attribute returns the default number of bits in the
28275 stream representation of the given type.
28276 This value is not affected by the presence
28277 of stream subprogram attributes for the type. GNAT has always implemented
28278 this interpretation.
28280 RM References:  13.13.02 (1.2/2)
28281 @end itemize
28283 @geindex AI-0109 (Ada 2012 feature)
28286 @itemize *
28288 @item 
28289 `AI-0109 Redundant check in S’Class’Input (0000-00-00)'
28291 This AI is an editorial change only. It removes the need for a tag check
28292 that can never fail.
28294 RM References:  13.13.02 (34/2)
28295 @end itemize
28297 @geindex AI-0007 (Ada 2012 feature)
28300 @itemize *
28302 @item 
28303 `AI-0007 Stream read and private scalar types (0000-00-00)'
28305 The RM as written appeared to limit the possibilities of declaring read
28306 attribute procedures for private scalar types. This limitation was not
28307 intended, and has never been enforced by GNAT.
28309 RM References:  13.13.02 (50/2)   13.13.02 (51/2)
28310 @end itemize
28312 @geindex AI-0065 (Ada 2012 feature)
28315 @itemize *
28317 @item 
28318 `AI-0065 Remote access types and external streaming (0000-00-00)'
28320 This AI clarifies the fact that all remote access types support external
28321 streaming. This fixes an obvious oversight in the definition of the
28322 language, and GNAT always implemented the intended correct rules.
28324 RM References:  13.13.02 (52/2)
28325 @end itemize
28327 @geindex AI-0019 (Ada 2012 feature)
28330 @itemize *
28332 @item 
28333 `AI-0019 Freezing of primitives for tagged types (0000-00-00)'
28335 The RM suggests that primitive subprograms of a specific tagged type are
28336 frozen when the tagged type is frozen. This would be an incompatible change
28337 and is not intended. GNAT has never attempted this kind of freezing and its
28338 behavior is consistent with the recommendation of this AI.
28340 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)
28341 @end itemize
28343 @geindex AI-0017 (Ada 2012 feature)
28346 @itemize *
28348 @item 
28349 `AI-0017 Freezing and incomplete types (0000-00-00)'
28351 So-called ‘Taft-amendment types’ (i.e., types that are completed in package
28352 bodies) are not frozen by the occurrence of bodies in the
28353 enclosing declarative part. GNAT always implemented this properly.
28355 RM References:  13.14 (3/1)
28356 @end itemize
28358 @geindex AI-0060 (Ada 2012 feature)
28361 @itemize *
28363 @item 
28364 `AI-0060 Extended definition of remote access types (0000-00-00)'
28366 This AI extends the definition of remote access types to include access
28367 to limited, synchronized, protected or task class-wide interface types.
28368 GNAT already implemented this extension.
28370 RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
28371 @end itemize
28373 @geindex AI-0114 (Ada 2012 feature)
28376 @itemize *
28378 @item 
28379 `AI-0114 Classification of letters (0000-00-00)'
28381 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
28382 181 (@code{MICRO SIGN}), and
28383 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
28384 lower case letters by Unicode.
28385 However, they are not allowed in identifiers, and they
28386 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
28387 This behavior is consistent with that defined in Ada 95.
28389 RM References:  A.03.02 (59)   A.04.06 (7)
28390 @end itemize
28392 @geindex AI-0185 (Ada 2012 feature)
28395 @itemize *
28397 @item 
28398 `AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)'
28400 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
28401 classification functions for @code{Wide_Character} and
28402 @code{Wide_Wide_Character}, as well as providing
28403 case folding routines for @code{Wide_[Wide_]Character} and
28404 @code{Wide_[Wide_]String}.
28406 RM References:  A.03.05 (0)   A.03.06 (0)
28407 @end itemize
28409 @geindex AI-0031 (Ada 2012 feature)
28412 @itemize *
28414 @item 
28415 `AI-0031 Add From parameter to Find_Token (2010-07-25)'
28417 A new version of @code{Find_Token} is added to all relevant string packages,
28418 with an extra parameter @code{From}. Instead of starting at the first
28419 character of the string, the search for a matching Token starts at the
28420 character indexed by the value of @code{From}.
28421 These procedures are available in all versions of Ada
28422 but if used in versions earlier than Ada 2012 they will generate a warning
28423 that an Ada 2012 subprogram is being used.
28425 RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
28426 A.04.05 (46)
28427 @end itemize
28429 @geindex AI-0056 (Ada 2012 feature)
28432 @itemize *
28434 @item 
28435 `AI-0056 Index on null string returns zero (0000-00-00)'
28437 The wording in the Ada 2005 RM implied an incompatible handling of the
28438 @code{Index} functions, resulting in raising an exception instead of
28439 returning zero in some situations.
28440 This was not intended and has been corrected.
28441 GNAT always returned zero, and is thus consistent with this AI.
28443 RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
28444 @end itemize
28446 @geindex AI-0137 (Ada 2012 feature)
28449 @itemize *
28451 @item 
28452 `AI-0137 String encoding package (2010-03-25)'
28454 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
28455 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
28456 and @code{Wide_Wide_Strings} have been
28457 implemented. These packages (whose documentation can be found in the spec
28458 files @code{a-stuten.ads}, @code{a-suenco.ads}, @code{a-suenst.ads},
28459 @code{a-suewst.ads}, @code{a-suezst.ads}) allow encoding and decoding of
28460 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
28461 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
28462 UTF-16), as well as conversions between the different UTF encodings. With
28463 the exception of @code{Wide_Wide_Strings}, these packages are available in
28464 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
28465 The @code{Wide_Wide_Strings} package
28466 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
28467 mode since it uses @code{Wide_Wide_Character}).
28469 RM References:  A.04.11
28470 @end itemize
28472 @geindex AI-0038 (Ada 2012 feature)
28475 @itemize *
28477 @item 
28478 `AI-0038 Minor errors in Text_IO (0000-00-00)'
28480 These are minor errors in the description on three points. The intent on
28481 all these points has always been clear, and GNAT has always implemented the
28482 correct intended semantics.
28484 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)
28485 @end itemize
28487 @geindex AI-0044 (Ada 2012 feature)
28490 @itemize *
28492 @item 
28493 `AI-0044 Restrictions on container instantiations (0000-00-00)'
28495 This AI places restrictions on allowed instantiations of generic containers.
28496 These restrictions are not checked by the compiler, so there is nothing to
28497 change in the implementation. This affects only the RM documentation.
28499 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)
28500 @end itemize
28502 @geindex AI-0127 (Ada 2012 feature)
28505 @itemize *
28507 @item 
28508 `AI-0127 Adding Locale Capabilities (2010-09-29)'
28510 This package provides an interface for identifying the current locale.
28512 RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
28513 A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
28514 @end itemize
28516 @geindex AI-0002 (Ada 2012 feature)
28519 @itemize *
28521 @item 
28522 `AI-0002 Export C with unconstrained arrays (0000-00-00)'
28524 The compiler is not required to support exporting an Ada subprogram with
28525 convention C if there are parameters or a return type of an unconstrained
28526 array type (such as @code{String}). GNAT allows such declarations but
28527 generates warnings. It is possible, but complicated, to write the
28528 corresponding C code and certainly such code would be specific to GNAT and
28529 non-portable.
28531 RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
28532 @end itemize
28534 @geindex AI05-0216 (Ada 2012 feature)
28537 @itemize *
28539 @item 
28540 `AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)'
28542 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
28543 forbid tasks declared locally within subprograms, or functions returning task
28544 objects, and that is the implementation that GNAT has always provided.
28545 However the language in the RM was not sufficiently clear on this point.
28546 Thus this is a documentation change in the RM only.
28548 RM References:  D.07 (3/3)
28549 @end itemize
28551 @geindex AI-0211 (Ada 2012 feature)
28554 @itemize *
28556 @item 
28557 `AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)'
28559 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
28560 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
28562 RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
28563 @end itemize
28565 @geindex AI-0190 (Ada 2012 feature)
28568 @itemize *
28570 @item 
28571 `AI-0190 pragma Default_Storage_Pool (2010-09-15)'
28573 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
28574 used to control storage pools globally.
28575 In particular, you can force every access
28576 type that is used for allocation (`new') to have an explicit storage pool,
28577 or you can declare a pool globally to be used for all access types that lack
28578 an explicit one.
28580 RM References:  D.07 (8)
28581 @end itemize
28583 @geindex AI-0189 (Ada 2012 feature)
28586 @itemize *
28588 @item 
28589 `AI-0189 No_Allocators_After_Elaboration (2010-01-23)'
28591 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
28592 which says that no dynamic allocation will occur once elaboration is
28593 completed.
28594 In general this requires a run-time check, which is not required, and which
28595 GNAT does not attempt. But the static cases of allocators in a task body or
28596 in the body of the main program are detected and flagged at compile or bind
28597 time.
28599 RM References:  D.07 (19.1/2)   H.04 (23.3/2)
28600 @end itemize
28602 @geindex AI-0171 (Ada 2012 feature)
28605 @itemize *
28607 @item 
28608 `AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)'
28610 A new package @code{System.Multiprocessors} is added, together with the
28611 definition of pragma @code{CPU} for controlling task affinity. A new no
28612 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
28613 is added to the Ravenscar profile.
28615 RM References:  D.13.01 (4/2)   D.16
28616 @end itemize
28618 @geindex AI-0210 (Ada 2012 feature)
28621 @itemize *
28623 @item 
28624 `AI-0210 Correct Timing_Events metric (0000-00-00)'
28626 This is a documentation only issue regarding wording of metric requirements,
28627 that does not affect the implementation of the compiler.
28629 RM References:  D.15 (24/2)
28630 @end itemize
28632 @geindex AI-0206 (Ada 2012 feature)
28635 @itemize *
28637 @item 
28638 `AI-0206 Remote types packages and preelaborate (2010-07-24)'
28640 Remote types packages are now allowed to depend on preelaborated packages.
28641 This was formerly considered illegal.
28643 RM References:  E.02.02 (6)
28644 @end itemize
28646 @geindex AI-0152 (Ada 2012 feature)
28649 @itemize *
28651 @item 
28652 `AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)'
28654 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
28655 where the type of the returned value is an anonymous access type.
28657 RM References:  H.04 (8/1)
28658 @end itemize
28660 @node GNAT language extensions,Security Hardening Features,Implementation of Ada 2012 Features,Top
28661 @anchor{gnat_rm/gnat_language_extensions doc}@anchor{43a}@anchor{gnat_rm/gnat_language_extensions gnat-language-extensions}@anchor{43b}@anchor{gnat_rm/gnat_language_extensions id1}@anchor{43c}
28662 @chapter GNAT language extensions
28665 The GNAT compiler implements a certain number of language extensions on top of
28666 the latest Ada standard, implementing its own extended superset of Ada.
28668 There are two sets of language extensions:
28671 @itemize *
28673 @item 
28674 The first is the curated set. The features in that set are features that we
28675 consider being worthy additions to the Ada language, and that we want to make
28676 available to users early on.
28678 @item 
28679 The second is the experimental set. It includes the first, but also
28680 experimental features, that are here because they’re still in an early
28681 prototyping phase.
28682 @end itemize
28684 @menu
28685 * How to activate the extended GNAT Ada superset:: 
28686 * Curated Extensions:: 
28687 * Experimental Language Extensions:: 
28689 @end menu
28691 @node How to activate the extended GNAT Ada superset,Curated Extensions,,GNAT language extensions
28692 @anchor{gnat_rm/gnat_language_extensions how-to-activate-the-extended-gnat-ada-superset}@anchor{43d}
28693 @section How to activate the extended GNAT Ada superset
28696 There are two ways to activate the extended GNAT Ada superset:
28699 @itemize *
28701 @item 
28702 The @ref{67,,Pragma Extensions_Allowed}. To activate
28703 the curated set of extensions, you should use
28704 @end itemize
28706 @example
28707 pragma Extensions_Allowed (On)
28708 @end example
28710 As a configuration pragma, you can either put it at the beginning of a source
28711 file, or in a @code{.adc} file corresponding to your project.
28714 @itemize *
28716 @item 
28717 The @code{-gnatX} option, that you can pass to the compiler directly, will
28718 activate the curated subset of extensions.
28719 @end itemize
28721 @cartouche
28722 @quotation Attention 
28723 You can activate the extended set of extensions by using either
28724 the @code{-gnatX0} command line flag, or the pragma @code{Extensions_Allowed} with
28725 @code{All} as an argument. However, it is not recommended you use this subset
28726 for serious projects, and is only means as a playground/technology preview.
28727 @end quotation
28728 @end cartouche
28730 @node Curated Extensions,Experimental Language Extensions,How to activate the extended GNAT Ada superset,GNAT language extensions
28731 @anchor{gnat_rm/gnat_language_extensions curated-extensions}@anchor{43e}@anchor{gnat_rm/gnat_language_extensions curated-language-extensions}@anchor{68}
28732 @section Curated Extensions
28735 @menu
28736 * Local Declarations Without Block:: 
28737 * Conditional when constructs:: 
28738 * Case pattern matching:: 
28739 * Fixed lower bounds for array types and subtypes:: 
28740 * Prefixed-view notation for calls to primitive subprograms of untagged types:: 
28741 * Expression defaults for generic formal functions:: 
28742 * String interpolation:: 
28743 * Constrained attribute for generic objects:: 
28744 * Static aspect on intrinsic functions:: 
28746 @end menu
28748 @node Local Declarations Without Block,Conditional when constructs,,Curated Extensions
28749 @anchor{gnat_rm/gnat_language_extensions local-declarations-without-block}@anchor{43f}
28750 @subsection Local Declarations Without Block
28753 A basic_declarative_item may appear at the place of any statement.
28754 This avoids the heavy syntax of block_statements just to declare
28755 something locally.
28757 Link to the original RFC:
28758 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-local-vars-without-block.md}
28759 For example:
28761 @example
28762 if X > 5 then
28763    X := X + 1;
28765    Squared : constant Integer := X**2;
28767    X := X + Squared;
28768 end if;
28769 @end example
28771 @node Conditional when constructs,Case pattern matching,Local Declarations Without Block,Curated Extensions
28772 @anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{440}
28773 @subsection Conditional when constructs
28776 This feature extends the use of @code{when} as a way to condition a control-flow
28777 related statement, to all control-flow related statements.
28779 To do a conditional return in a procedure the following syntax should be used:
28781 @example
28782 procedure P (Condition : Boolean) is
28783 begin
28784    return when Condition;
28785 end;
28786 @end example
28788 This will return from the procedure if @code{Condition} is true.
28790 When being used in a function the conditional part comes after the return value:
28792 @example
28793 function Is_Null (I : Integer) return Boolean is
28794 begin
28795    return True when I = 0;
28796    return False;
28797 end;
28798 @end example
28800 In a similar way to the @code{exit when} a @code{goto ... when} can be employed:
28802 @example
28803 procedure Low_Level_Optimized is
28804    Flags : Bitmapping;
28805 begin
28806    Do_1 (Flags);
28807    goto Cleanup when Flags (1);
28809    Do_2 (Flags);
28810    goto Cleanup when Flags (32);
28812    --  ...
28814 <<Cleanup>>
28815    --  ...
28816 end;
28817 @end example
28819 @c code-block
28821 To use a conditional raise construct:
28823 @example
28824 procedure Foo is
28825 begin
28826    raise Error when Imported_C_Func /= 0;
28827 end;
28828 @end example
28830 An exception message can also be added:
28832 @example
28833 procedure Foo is
28834 begin
28835    raise Error with "Unix Error"
28836      when Imported_C_Func /= 0;
28837 end;
28838 @end example
28840 Link to the original RFC:
28841 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-conditional-when-constructs.rst}
28843 @node Case pattern matching,Fixed lower bounds for array types and subtypes,Conditional when constructs,Curated Extensions
28844 @anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{441}
28845 @subsection Case pattern matching
28848 The selector for a case statement (but not yet for a case expression) may be of a composite type, subject to
28849 some restrictions (described below). Aggregate syntax is used for choices
28850 of such a case statement; however, in cases where a “normal” aggregate would
28851 require a discrete value, a discrete subtype may be used instead; box
28852 notation can also be used to match all values.
28854 Consider this example:
28856 @example
28857 type Rec is record
28858    F1, F2 : Integer;
28859 end record;
28861 procedure Caser_1 (X : Rec) is
28862 begin
28863    case X is
28864       when (F1 => Positive, F2 => Positive) =>
28865          Do_This;
28866       when (F1 => Natural, F2 => <>) | (F1 => <>, F2 => Natural) =>
28867          Do_That;
28868       when others =>
28869           Do_The_Other_Thing;
28870    end case;
28871 end Caser_1;
28872 @end example
28874 If @code{Caser_1} is called and both components of X are positive, then
28875 @code{Do_This} will be called; otherwise, if either component is nonnegative
28876 then @code{Do_That} will be called; otherwise, @code{Do_The_Other_Thing} will be
28877 called.
28879 In addition, pattern bindings are supported. This is a mechanism
28880 for binding a name to a component of a matching value for use within
28881 an alternative of a case statement. For a component association
28882 that occurs within a case choice, the expression may be followed by
28883 @code{is <identifier>}. In the special case of a “box” component association,
28884 the identifier may instead be provided within the box. Either of these
28885 indicates that the given identifier denotes (a constant view of) the matching
28886 subcomponent of the case selector.
28888 @cartouche
28889 @quotation Attention 
28890 Binding is not yet supported for arrays or subcomponents
28891 thereof.
28892 @end quotation
28893 @end cartouche
28895 Consider this example (which uses type @code{Rec} from the previous example):
28897 @example
28898 procedure Caser_2 (X : Rec) is
28899 begin
28900    case X is
28901       when (F1 => Positive is Abc, F2 => Positive) =>
28902          Do_This (Abc)
28903       when (F1 => Natural is N1, F2 => <N2>) |
28904            (F1 => <N2>, F2 => Natural is N1) =>
28905          Do_That (Param_1 => N1, Param_2 => N2);
28906       when others =>
28907          Do_The_Other_Thing;
28908    end case;
28909 end Caser_2;
28910 @end example
28912 This example is the same as the previous one with respect to determining
28913 whether @code{Do_This}, @code{Do_That}, or @code{Do_The_Other_Thing} will be called. But
28914 for this version, @code{Do_This} takes a parameter and @code{Do_That} takes two
28915 parameters. If @code{Do_This} is called, the actual parameter in the call will be
28916 @code{X.F1}.
28918 If @code{Do_That} is called, the situation is more complex because there are two
28919 choices for that alternative. If @code{Do_That} is called because the first choice
28920 matched (i.e., because @code{X.F1} is nonnegative and either @code{X.F1} or @code{X.F2}
28921 is zero or negative), then the actual parameters of the call will be (in order)
28922 @code{X.F1} and @code{X.F2}. If @code{Do_That} is called because the second choice
28923 matched (and the first one did not), then the actual parameters will be
28924 reversed.
28926 Within the choice list for single alternative, each choice must define the same
28927 set of bindings and the component subtypes for for a given identifer must all
28928 statically match. Currently, the case of a binding for a nondiscrete component
28929 is not implemented.
28931 If the set of values that match the choice(s) of an earlier alternative
28932 overlaps the corresponding set of a later alternative, then the first set shall
28933 be a proper subset of the second (and the later alternative will not be
28934 executed if the earlier alternative “matches”). All possible values of the
28935 composite type shall be covered. The composite type of the selector shall be an
28936 array or record type that is neither limited nor class-wide. Currently, a “when
28937 others =>” case choice is required; it is intended that this requirement will
28938 be relaxed at some point.
28940 If a subcomponent’s subtype does not meet certain restrictions, then the only
28941 value that can be specified for that subcomponent in a case choice expression
28942 is a “box” component association (which matches all possible values for the
28943 subcomponent). This restriction applies if:
28946 @itemize -
28948 @item 
28949 the component subtype is not a record, array, or discrete type; or
28951 @item 
28952 the component subtype is subject to a non-static constraint or has a
28953 predicate; or:
28955 @item 
28956 the component type is an enumeration type that is subject to an enumeration
28957 representation clause; or
28959 @item 
28960 the component type is a multidimensional array type or an array type with a
28961 nonstatic index subtype.
28962 @end itemize
28964 Support for casing on arrays (and on records that contain arrays) is
28965 currently subject to some restrictions. Non-positional
28966 array aggregates are not supported as (or within) case choices. Likewise
28967 for array type and subtype names. The current implementation exceeds
28968 compile-time capacity limits in some annoyingly common scenarios; the
28969 message generated in such cases is usually “Capacity exceeded in compiling
28970 case statement with composite selector type”.
28972 Link to the original RFC:
28973 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-pattern-matching.rst}
28975 @node Fixed lower bounds for array types and subtypes,Prefixed-view notation for calls to primitive subprograms of untagged types,Case pattern matching,Curated Extensions
28976 @anchor{gnat_rm/gnat_language_extensions fixed-lower-bounds-for-array-types-and-subtypes}@anchor{442}
28977 @subsection Fixed lower bounds for array types and subtypes
28980 Unconstrained array types and subtypes can be specified with a lower bound that
28981 is fixed to a certain value, by writing an index range that uses the syntax
28982 @code{<lower-bound-expression> .. <>}. This guarantees that all objects of the
28983 type or subtype will have the specified lower bound.
28985 For example, a matrix type with fixed lower bounds of zero for each dimension
28986 can be declared by the following:
28988 @example
28989 type Matrix is
28990   array (Natural range 0 .. <>, Natural range 0 .. <>) of Integer;
28991 @end example
28993 Objects of type @code{Matrix} declared with an index constraint must have index
28994 ranges starting at zero:
28996 @example
28997 M1 : Matrix (0 .. 9, 0 .. 19);
28998 M2 : Matrix (2 .. 11, 3 .. 22);  -- Warning about bounds; will raise CE
28999 @end example
29001 Similarly, a subtype of @code{String} can be declared that specifies the lower
29002 bound of objects of that subtype to be @code{1}:
29004 @quotation
29006 @example
29007 subtype String_1 is String (1 .. <>);
29008 @end example
29009 @end quotation
29011 If a string slice is passed to a formal of subtype @code{String_1} in a call to a
29012 subprogram @code{S}, the slice’s bounds will “slide” so that the lower bound is
29013 @code{1}.
29015 Within @code{S}, the lower bound of the formal is known to be @code{1}, so, unlike a
29016 normal unconstrained @code{String} formal, there is no need to worry about
29017 accounting for other possible lower-bound values. Sliding of bounds also occurs
29018 in other contexts, such as for object declarations with an unconstrained
29019 subtype with fixed lower bound, as well as in subtype conversions.
29021 Use of this feature increases safety by simplifying code, and can also improve
29022 the efficiency of indexing operations, since the compiler statically knows the
29023 lower bound of unconstrained array formals when the formal’s subtype has index
29024 ranges with static fixed lower bounds.
29026 Link to the original RFC:
29027 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-fixed-lower-bound.rst}
29029 @node Prefixed-view notation for calls to primitive subprograms of untagged types,Expression defaults for generic formal functions,Fixed lower bounds for array types and subtypes,Curated Extensions
29030 @anchor{gnat_rm/gnat_language_extensions prefixed-view-notation-for-calls-to-primitive-subprograms-of-untagged-types}@anchor{443}
29031 @subsection Prefixed-view notation for calls to primitive subprograms of untagged types
29034 When operating on an untagged type, if it has any primitive operations, and the
29035 first parameter of an operation is of the type (or is an access parameter with
29036 an anonymous type that designates the type), you may invoke these operations
29037 using an @code{object.op(...)} notation, where the parameter that would normally be
29038 the first parameter is brought out front, and the remaining parameters (if any)
29039 appear within parentheses after the name of the primitive operation.
29041 This same notation is already available for tagged types. This extension allows
29042 for untagged types. It is allowed for all primitive operations of the type
29043 independent of whether they were originally declared in a package spec or its
29044 private part, or were inherited and/or overridden as part of a derived type
29045 declaration occuring anywhere, so long as the first parameter is of the type,
29046 or an access parameter designating the type.
29048 For example:
29050 @example
29051 generic
29052    type Elem_Type is private;
29053 package Vectors is
29054     type Vector is private;
29055     procedure Add_Element (V : in out Vector; Elem : Elem_Type);
29056     function Nth_Element (V : Vector; N : Positive) return Elem_Type;
29057     function Length (V : Vector) return Natural;
29058 private
29059     function Capacity (V : Vector) return Natural;
29060        --  Return number of elements that may be added without causing
29061        --  any new allocation of space
29063     type Vector is ...
29064       with Type_Invariant => Vector.Length <= Vector.Capacity;
29065     ...
29066 end Vectors;
29068 package Int_Vecs is new Vectors(Integer);
29070 V : Int_Vecs.Vector;
29072 V.Add_Element(42);
29073 V.Add_Element(-33);
29075 pragma Assert (V.Length = 2);
29076 pragma Assert (V.Nth_Element(1) = 42);
29077 @end example
29079 Link to the original RFC:
29080 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-prefixed-untagged.rst}
29082 @node Expression defaults for generic formal functions,String interpolation,Prefixed-view notation for calls to primitive subprograms of untagged types,Curated Extensions
29083 @anchor{gnat_rm/gnat_language_extensions expression-defaults-for-generic-formal-functions}@anchor{444}
29084 @subsection Expression defaults for generic formal functions
29087 The declaration of a generic formal function is allowed to specify
29088 an expression as a default, using the syntax of an expression function.
29090 Here is an example of this feature:
29092 @example
29093 generic
29094    type T is private;
29095    with function Copy (Item : T) return T is (Item); -- Defaults to Item
29096 package Stacks is
29098    type Stack is limited private;
29100    procedure Push (S : in out Stack; X : T); -- Calls Copy on X
29101    function Pop (S : in out Stack) return T; -- Calls Copy to return item
29103 private
29104    -- ...
29105 end Stacks;
29106 @end example
29108 Link to the original RFC:
29109 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-expression-functions-as-default-for-generic-formal-function-parameters.rst}
29111 @node String interpolation,Constrained attribute for generic objects,Expression defaults for generic formal functions,Curated Extensions
29112 @anchor{gnat_rm/gnat_language_extensions string-interpolation}@anchor{445}
29113 @subsection String interpolation
29116 The syntax for string literals is extended to support string interpolation.
29118 Within an interpolated string literal, an arbitrary expression, when
29119 enclosed in @code{@{ ... @}}, is expanded at run time into the result of calling
29120 @code{'Image} on the result of evaluating the expression enclosed by the brace
29121 characters, unless it is already a string or a single character.
29123 Here is an example of this feature where the expressions @code{Name} and @code{X + Y}
29124 will be evaluated and included in the string.
29126 @example
29127 procedure Test_Interpolation is
29128    X    : Integer := 12;
29129    Y    : Integer := 15;
29130    Name : String := "Leo";
29131 begin
29132    Put_Line (f"The name is @{Name@} and the sum is @{X + Y@}.");
29133 end Test_Interpolation;
29134 @end example
29136 In addition, an escape character (@code{\}) is provided for inserting certain
29137 standard control characters (such as @code{\t} for tabulation or @code{\n} for
29138 newline) or to escape characters with special significance to the
29139 interpolated string syntax, namely @code{"}, @code{@{}, @code{@}},and @code{\} itself.
29142 @multitable {xxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
29143 @item
29145 escaped_character
29147 @tab
29149 meaning
29151 @item
29153 @code{\a}
29155 @tab
29157 ALERT
29159 @item
29161 @code{\b}
29163 @tab
29165 BACKSPACE
29167 @item
29169 @code{\f}
29171 @tab
29173 FORM FEED
29175 @item
29177 @code{\n}
29179 @tab
29181 LINE FEED
29183 @item
29185 @code{\r}
29187 @tab
29189 CARRIAGE RETURN
29191 @item
29193 @code{\t}
29195 @tab
29197 CHARACTER TABULATION
29199 @item
29201 @code{\v}
29203 @tab
29205 LINE TABULATION
29207 @item
29209 @code{\0}
29211 @tab
29215 @item
29217 @code{\\}
29219 @tab
29221 @code{\}
29223 @item
29225 @code{\"}
29227 @tab
29229 @code{"}
29231 @item
29233 @code{\@{}
29235 @tab
29237 @code{@{}
29239 @item
29241 @code{\@}}
29243 @tab
29245 @code{@}}
29247 @end multitable
29250 Note that, unlike normal string literals, doubled characters have no
29251 special significance. So to include a double-quote or a brace character
29252 in an interpolated string, they must be preceded by a @code{\}.
29253 For example:
29255 @example
29256 Put_Line
29257   (f"X = @{X@} and Y = @{Y@} and X+Y = @{X+Y@};\n" &
29258    f" a double quote is \" and" &
29259    f" an open brace is \@{");
29260 @end example
29262 Finally, a syntax is provided for creating multi-line string literals,
29263 without having to explicitly use an escape sequence such as @code{\n}. For
29264 example:
29266 @example
29267 Put_Line
29268   (f"This is a multi-line"
29269     "string literal"
29270     "There is no ambiguity about how many"
29271     "spaces are included in each line");
29272 @end example
29274 Here is a link to the original RFC   :
29275 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst}
29277 @node Constrained attribute for generic objects,Static aspect on intrinsic functions,String interpolation,Curated Extensions
29278 @anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{446}
29279 @subsection Constrained attribute for generic objects
29282 The @code{Constrained} attribute is permitted for objects of generic types. The
29283 result indicates whether the corresponding actual is constrained.
29285 @node Static aspect on intrinsic functions,,Constrained attribute for generic objects,Curated Extensions
29286 @anchor{gnat_rm/gnat_language_extensions static-aspect-on-intrinsic-functions}@anchor{447}
29287 @subsection @code{Static} aspect on intrinsic functions
29290 The Ada 202x @code{Static} aspect can be specified on Intrinsic imported functions
29291 and the compiler will evaluate some of these intrinsics statically, in
29292 particular the @code{Shift_Left} and @code{Shift_Right} intrinsics.
29294 @node Experimental Language Extensions,,Curated Extensions,GNAT language extensions
29295 @anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{69}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{448}
29296 @section Experimental Language Extensions
29299 @menu
29300 * Pragma Storage_Model:: 
29301 * Simpler accessibility model:: 
29303 @end menu
29305 @node Pragma Storage_Model,Simpler accessibility model,,Experimental Language Extensions
29306 @anchor{gnat_rm/gnat_language_extensions pragma-storage-model}@anchor{449}
29307 @subsection Pragma Storage_Model
29310 This feature proposes to redesign the concepts of Storage Pools into a more
29311 efficient model allowing higher performances and easier integration with low
29312 footprint embedded run-times.
29314 It also extends it to support distributed memory models, in particular to
29315 support interactions with GPU.
29317 Here is a link to the full RFC:
29318 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-storage-model.rst}
29320 @node Simpler accessibility model,,Pragma Storage_Model,Experimental Language Extensions
29321 @anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{44a}
29322 @subsection Simpler accessibility model
29325 The goal of this feature is to restore a common understanding of accessibility
29326 rules for implementers and users alike. The new rules should both be effective
29327 at preventing errors and feel natural and compatible in an Ada environment
29328 while removing dynamic accessibility checking.
29330 Here is a link to the full RFC:
29331 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-simpler-accessibility.md}
29333 @node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top
29334 @anchor{gnat_rm/security_hardening_features doc}@anchor{44b}@anchor{gnat_rm/security_hardening_features id1}@anchor{44c}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
29335 @chapter Security Hardening Features
29338 This chapter describes Ada extensions aimed at security hardening that
29339 are provided by GNAT.
29341 The features in this chapter are currently experimental and subject to
29342 change.
29344 @c Register Scrubbing:
29346 @menu
29347 * Register Scrubbing:: 
29348 * Stack Scrubbing:: 
29349 * Hardened Conditionals:: 
29350 * Hardened Booleans:: 
29351 * Control Flow Redundancy:: 
29353 @end menu
29355 @node Register Scrubbing,Stack Scrubbing,,Security Hardening Features
29356 @anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{44d}
29357 @section Register Scrubbing
29360 GNAT can generate code to zero-out hardware registers before returning
29361 from a subprogram.
29363 It can be enabled with the @code{-fzero-call-used-regs=`choice'}
29364 command-line option, to affect all subprograms in a compilation, and
29365 with a @code{Machine_Attribute} pragma, to affect only specific
29366 subprograms.
29368 @example
29369 procedure Foo;
29370 pragma Machine_Attribute (Foo, "zero_call_used_regs", "used");
29371 --  Before returning, Foo scrubs only call-clobbered registers
29372 --  that it uses itself.
29374 function Bar return Integer;
29375 pragma Machine_Attribute (Bar, "zero_call_used_regs", "all");
29376 --  Before returning, Bar scrubs all call-clobbered registers.
29378 function Baz return Integer;
29379 pragma Machine_Attribute (Bar, "zero_call_used_regs", "leafy");
29380 --  Before returning, Bar scrubs call-clobbered registers, either
29381 --  those it uses itself, if it can be identified as a leaf
29382 --  function, or all of them otherwise.
29383 @end example
29385 For usage and more details on the command-line option, on the
29386 @code{zero_call_used_regs} attribute, and on their use with other
29387 programming languages, see @cite{Using the GNU Compiler Collection (GCC)}.
29389 @c Stack Scrubbing:
29391 @node Stack Scrubbing,Hardened Conditionals,Register Scrubbing,Security Hardening Features
29392 @anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{44e}
29393 @section Stack Scrubbing
29396 GNAT can generate code to zero-out stack frames used by subprograms.
29398 It can be activated with the @code{Machine_Attribute} pragma, on
29399 specific subprograms and variables, or their types.  (This attribute
29400 always applies to a type, even when it is associated with a subprogram
29401 or a variable.)
29403 @example
29404 function Foo returns Integer;
29405 pragma Machine_Attribute (Foo, "strub");
29406 --  Foo and its callers are modified so as to scrub the stack
29407 --  space used by Foo after it returns.  Shorthand for:
29408 --  pragma Machine_Attribute (Foo, "strub", "at-calls");
29410 procedure Bar;
29411 pragma Machine_Attribute (Bar, "strub", "internal");
29412 --  Bar is turned into a wrapper for its original body,
29413 --  and they scrub the stack used by the original body.
29415 Var : Integer;
29416 pragma Machine_Attribute (Var, "strub");
29417 --  Reading from Var in a subprogram enables stack scrubbing
29418 --  of the stack space used by the subprogram.  Furthermore, if
29419 --  Var is declared within a subprogram, this also enables
29420 --  scrubbing of the stack space used by that subprogram.
29421 @end example
29423 Given these declarations, Foo has its type and body modified as
29424 follows:
29426 @example
29427 function Foo (<WaterMark> : in out System.Address) returns Integer
29429   --  ...
29430 begin
29431   <__strub_update> (<WaterMark>);  --  Updates the stack WaterMark.
29432   --  ...
29433 end;
29434 @end example
29436 whereas its callers are modified from:
29438 @example
29439 X := Foo;
29440 @end example
29444 @example
29445 declare
29446   <WaterMark> : System.Address;
29447 begin
29448   <__strub_enter> (<WaterMark>);  -- Initialize <WaterMark>.
29449   X := Foo (<WaterMark>);
29450   <__strub_leave> (<WaterMark>);  -- Scrubs stack up to <WaterMark>.
29451 end;
29452 @end example
29454 As for Bar, because it is strubbed in internal mode, its callers are
29455 not modified.  Its definition is modified roughly as follows:
29457 @example
29458 procedure Bar is
29459   <WaterMark> : System.Address;
29460   procedure Strubbed_Bar (<WaterMark> : in out System.Address) is
29461   begin
29462     <__strub_update> (<WaterMark>);  --  Updates the stack WaterMark.
29463     -- original Bar body.
29464   end Strubbed_Bar;
29465 begin
29466   <__strub_enter> (<WaterMark>);  -- Initialize <WaterMark>.
29467   Strubbed_Bar (<WaterMark>);
29468   <__strub_leave> (<WaterMark>);  -- Scrubs stack up to <WaterMark>.
29469 end Bar;
29470 @end example
29472 There are also @code{-fstrub=`choice'} command-line options to
29473 control default settings.  For usage and more details on the
29474 command-line options, on the @code{strub} attribute, and their use with
29475 other programming languages, see @cite{Using the GNU Compiler Collection (GCC)}.
29477 Note that Ada secondary stacks are not scrubbed.  The restriction
29478 @code{No_Secondary_Stack} avoids their use, and thus their accidental
29479 preservation of data that should be scrubbed.
29481 Attributes @code{Access} and @code{Unconstrained_Access} of variables and
29482 constants with @code{strub} enabled require types with @code{strub} enabled;
29483 there is no way to express an access-to-strub type otherwise.
29484 @code{Unchecked_Access} bypasses this constraint, but the resulting
29485 access type designates a non-strub type.
29487 @example
29488 VI : aliased Integer;
29489 pragma Machine_Attribute (VI, "strub");
29490 XsVI : access Integer := VI'Access; -- Error.
29491 UXsVI : access Integer := VI'Unchecked_Access; -- OK,
29492 --  UXsVI does *not* enable strub in subprograms that
29493 --  dereference it to obtain the UXsVI.all value.
29495 type Strub_Int is new Integer;
29496 pragma Machine_Attribute (Strub_Int, "strub");
29497 VSI : aliased Strub_Int;
29498 XsVSI : access Strub_Int := VSI'Access; -- OK,
29499 --  VSI and XsVSI.all both enable strub in subprograms that
29500 --  read their values.
29501 @end example
29503 Every access-to-subprogram type, renaming, and overriding and
29504 overridden dispatching operations that may refer to a subprogram with
29505 an attribute-modified interface must be annotated with the same
29506 interface-modifying attribute.  Access-to-subprogram types can be
29507 explicitly converted to different strub modes, as long as they are
29508 interface-compatible (i.e., adding or removing @code{at-calls} is not
29509 allowed).  For example, a @code{strub}-@code{disabled} subprogram can be
29510 turned @code{callable} through such an explicit conversion:
29512 @example
29513 type TBar is access procedure;
29515 type TBar_Callable is access procedure;
29516 pragma Machine_Attribute (TBar_Callable, "strub", "callable");
29517 --  The attribute modifies the procedure type, rather than the
29518 --  access type, because of the extra argument after "strub",
29519 --  only applicable to subprogram types.
29521 Bar_Callable_Ptr : constant TBar_Callable
29522            := TBar_Callable (TBar'(Bar'Access));
29524 procedure Bar_Callable renames Bar_Callable_Ptr.all;
29525 pragma Machine_Attribute (Bar_Callable, "strub", "callable");
29526 @end example
29528 Note that the renaming declaration is expanded to a full subprogram
29529 body, it won’t be just an alias.  Only if it is inlined will it be as
29530 efficient as a call by dereferencing the access-to-subprogram constant
29531 Bar_Callable_Ptr.
29533 @c Hardened Conditionals:
29535 @node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features
29536 @anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{44f}
29537 @section Hardened Conditionals
29540 GNAT can harden conditionals to protect against control-flow attacks.
29542 This is accomplished by two complementary transformations, each
29543 activated by a separate command-line option.
29545 The option @code{-fharden-compares} enables hardening of compares
29546 that compute results stored in variables, adding verification that the
29547 reversed compare yields the opposite result, turning:
29549 @example
29550 B := X = Y;
29551 @end example
29553 into:
29555 @example
29556 B := X = Y;
29557 declare
29558   NotB : Boolean := X /= Y; -- Computed independently of B.
29559 begin
29560   if B = NotB then
29561     <__builtin_trap>;
29562   end if;
29563 end;
29564 @end example
29566 The option @code{-fharden-conditional-branches} enables hardening
29567 of compares that guard conditional branches, adding verification of
29568 the reversed compare to both execution paths, turning:
29570 @example
29571 if X = Y then
29572   X := Z + 1;
29573 else
29574   Y := Z - 1;
29575 end if;
29576 @end example
29578 into:
29580 @example
29581 if X = Y then
29582   if X /= Y then -- Computed independently of X = Y.
29583     <__builtin_trap>;
29584   end if;
29585   X := Z + 1;
29586 else
29587   if X /= Y then -- Computed independently of X = Y.
29588     null;
29589   else
29590     <__builtin_trap>;
29591   end if;
29592   Y := Z - 1;
29593 end if;
29594 @end example
29596 These transformations are introduced late in the compilation pipeline,
29597 long after boolean expressions are decomposed into separate compares,
29598 each one turned into either a conditional branch or a compare whose
29599 result is stored in a boolean variable or temporary.  Compiler
29600 optimizations, if enabled, may also turn conditional branches into
29601 stored compares, and vice-versa, or into operations with implied
29602 conditionals (e.g. MIN and MAX).  Conditionals may also be optimized
29603 out entirely, if their value can be determined at compile time, and
29604 occasionally multiple compares can be combined into one.
29606 It is thus difficult to predict which of these two options will affect
29607 a specific compare operation expressed in source code.  Using both
29608 options ensures that every compare that is neither optimized out nor
29609 optimized into implied conditionals will be hardened.
29611 The addition of reversed compares can be observed by enabling the dump
29612 files of the corresponding passes, through command-line options
29613 @code{-fdump-tree-hardcmp} and @code{-fdump-tree-hardcbr},
29614 respectively.
29616 They are separate options, however, because of the significantly
29617 different performance impact of the hardening transformations.
29619 For usage and more details on the command-line options, see
29620 @cite{Using the GNU Compiler Collection (GCC)}.  These options can
29621 be used with other programming languages supported by GCC.
29623 @c Hardened Booleans:
29625 @node Hardened Booleans,Control Flow Redundancy,Hardened Conditionals,Security Hardening Features
29626 @anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{450}
29627 @section Hardened Booleans
29630 Ada has built-in support for introducing boolean types with
29631 alternative representations, using representation clauses:
29633 @example
29634 type HBool is new Boolean;
29635 for HBool use (16#5a#, 16#a5#);
29636 for HBool'Size use 8;
29637 @end example
29639 When validity checking is enabled, the compiler will check that
29640 variables of such types hold values corresponding to the selected
29641 representations.
29643 There are multiple strategies for where to introduce validity checking
29644 (see @code{-gnatV} options).  Their goal is to guard against
29645 various kinds of programming errors, and GNAT strives to omit checks
29646 when program logic rules out an invalid value, and optimizers may
29647 further remove checks found to be redundant.
29649 For additional hardening, the @code{hardbool} @code{Machine_Attribute}
29650 pragma can be used to annotate boolean types with representation
29651 clauses, so that expressions of such types used as conditions are
29652 checked even when compiling with @code{-gnatVT}:
29654 @example
29655 pragma Machine_Attribute (HBool, "hardbool");
29657 function To_Boolean (X : HBool) returns Boolean is (Boolean (X));
29658 @end example
29660 is compiled roughly like:
29662 @example
29663 function To_Boolean (X : HBool) returns Boolean is
29664 begin
29665   if X not in True | False then
29666     raise Constraint_Error;
29667   elsif X in True then
29668     return True;
29669   else
29670     return False;
29671   end if;
29672 end To_Boolean;
29673 @end example
29675 Note that @code{-gnatVn} will disable even @code{hardbool} testing.
29677 Analogous behavior is available as a GCC extension to the C and
29678 Objective C programming languages, through the @code{hardbool} attribute,
29679 with the difference that, instead of raising a Constraint_Error
29680 exception, when a hardened boolean variable is found to hold a value
29681 that stands for neither True nor False, the program traps.  For usage
29682 and more details on that attribute, see @cite{Using the GNU Compiler Collection (GCC)}.
29684 @c Control Flow Redundancy:
29686 @node Control Flow Redundancy,,Hardened Booleans,Security Hardening Features
29687 @anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{451}
29688 @section Control Flow Redundancy
29691 GNAT can guard against unexpected execution flows, such as branching
29692 into the middle of subprograms, as in Return Oriented Programming
29693 exploits.
29695 In units compiled with @code{-fharden-control-flow-redundancy},
29696 subprograms are instrumented so that, every time they are called,
29697 basic blocks take note as control flows through them, and, before
29698 returning, subprograms verify that the taken notes are consistent with
29699 the control-flow graph.
29701 The performance impact of verification on leaf subprograms can be much
29702 higher, while the averted risks are much lower on them.
29703 Instrumentation can be disabled for leaf subprograms with
29704 @code{-fhardcfr-skip-leaf}.
29706 Functions with too many basic blocks, or with multiple return points,
29707 call a run-time function to perform the verification.  Other functions
29708 perform the verification inline before returning.
29710 Optimizing the inlined verification can be quite time consuming, so
29711 the default upper limit for the inline mode is set at 16 blocks.
29712 Command-line option @code{--param hardcfr-max-inline-blocks=} can
29713 override it.
29715 Even though typically sparse control-flow graphs exhibit run-time
29716 verification time nearly proportional to the block count of a
29717 subprogram, it may become very significant for generated subprograms
29718 with thousands of blocks.  Command-line option
29719 @code{--param hardcfr-max-blocks=} can set an upper limit for
29720 instrumentation.
29722 For each block that is marked as visited, the mechanism checks that at
29723 least one of its predecessors, and at least one of its successors, are
29724 also marked as visited.
29726 Verification is performed just before a subprogram returns.  The
29727 following fragment:
29729 @example
29730 if X then
29731   Y := F (Z);
29732   return;
29733 end if;
29734 @end example
29736 gets turned into:
29738 @example
29739 type Visited_Bitmap is array (1..N) of Boolean with Pack;
29740 Visited : aliased Visited_Bitmap := (others => False);
29741 --  Bitmap of visited blocks.  N is the basic block count.
29742 [...]
29743 --  Basic block #I
29744 Visited(I) := True;
29745 if X then
29746   --  Basic block #J
29747   Visited(J) := True;
29748   Y := F (Z);
29749   CFR.Check (N, Visited'Access, CFG'Access);
29750   --  CFR is a hypothetical package whose Check procedure calls
29751   --  libgcc's __hardcfr_check, that traps if the Visited bitmap
29752   --  does not hold a valid path in CFG, the run-time
29753   --  representation of the control flow graph in the enclosing
29754   --  subprogram.
29755   return;
29756 end if;
29757 --  Basic block #K
29758 Visited(K) := True;
29759 @end example
29761 Verification would also be performed before tail calls, if any
29762 front-ends marked them as mandatory or desirable, but none do.
29763 Regular calls are optimized into tail calls too late for this
29764 transformation to act on it.
29766 In order to avoid adding verification after potential tail calls,
29767 which would prevent tail-call optimization, we recognize returning
29768 calls, i.e., calls whose result, if any, is returned by the calling
29769 subprogram to its caller immediately after the call returns.
29770 Verification is performed before such calls, whether or not they are
29771 ultimately optimized to tail calls.  This behavior is enabled by
29772 default whenever sibcall optimization is enabled (see
29773 @code{-foptimize-sibling-calls}); it may be disabled with
29774 @code{-fno-hardcfr-check-returning-calls}, or enabled with
29775 @code{-fhardcfr-check-returning-calls}, regardless of the
29776 optimization, but the lack of other optimizations may prevent calls
29777 from being recognized as returning calls:
29779 @example
29780 --  CFR.Check here, with -fhardcfr-check-returning-calls.
29781 P (X);
29782 --  CFR.Check here, with -fno-hardcfr-check-returning-calls.
29783 return;
29784 @end example
29788 @example
29789 --  CFR.Check here, with -fhardcfr-check-returning-calls.
29790 R := F (X);
29791 --  CFR.Check here, with -fno-hardcfr-check-returning-calls.
29792 return R;
29793 @end example
29795 Any subprogram from which an exception may escape, i.e., that may
29796 raise or propagate an exception that isn’t handled internally, is
29797 conceptually enclosed by a cleanup handler that performs verification,
29798 unless this is disabled with @code{-fno-hardcfr-check-exceptions}.
29799 With this feature enabled, a subprogram body containing:
29801 @example
29802 --  ...
29803   Y := F (X);  -- May raise exceptions.
29804 --  ...
29805   raise E;  -- Not handled internally.
29806 --  ...
29807 @end example
29809 gets modified as follows:
29811 @example
29812 begin
29813   --  ...
29814     Y := F (X);  -- May raise exceptions.
29815   --  ...
29816     raise E;  -- Not handled internally.
29817   --  ...
29818 exception
29819   when others =>
29820     CFR.Check (N, Visited'Access, CFG'Access);
29821     raise;
29822 end;
29823 @end example
29825 Verification may also be performed before No_Return calls, whether all
29826 of them, with @code{-fhardcfr-check-noreturn-calls=always}; all but
29827 internal subprograms involved in exception-raising or -reraising or
29828 subprograms explicitly marked with both @code{No_Return} and
29829 @code{Machine_Attribute} @code{expected_throw} pragmas, with
29830 @code{-fhardcfr-check-noreturn-calls=no-xthrow} (default); only
29831 nothrow ones, with @code{-fhardcfr-check-noreturn-calls=nothrow};
29832 or none, with @code{-fhardcfr-check-noreturn-calls=never}.
29834 When a No_Return call returns control to its caller through an
29835 exception, verification may have already been performed before the
29836 call, if @code{-fhardcfr-check-noreturn-calls=always} or
29837 @code{-fhardcfr-check-noreturn-calls=no-xthrow} is in effect.  The
29838 compiler arranges for already-checked No_Return calls without a
29839 preexisting handler to bypass the implicitly-added cleanup handler and
29840 thus the redundant check, but a local exception or cleanup handler, if
29841 present, will modify the set of visited blocks, and checking will take
29842 place again when the caller reaches the next verification point,
29843 whether it is a return or reraise statement after the exception is
29844 otherwise handled, or even another No_Return call.
29846 The instrumentation for hardening with control flow redundancy can be
29847 observed in dump files generated by the command-line option
29848 @code{-fdump-tree-hardcfr}.
29850 For more details on the control flow redundancy command-line options,
29851 see @cite{Using the GNU Compiler Collection (GCC)}.  These options
29852 can be used with other programming languages supported by GCC.
29854 @node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top
29855 @anchor{gnat_rm/obsolescent_features doc}@anchor{452}@anchor{gnat_rm/obsolescent_features id1}@anchor{453}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
29856 @chapter Obsolescent Features
29859 This chapter describes features that are provided by GNAT, but are
29860 considered obsolescent since there are preferred ways of achieving
29861 the same effect. These features are provided solely for historical
29862 compatibility purposes.
29864 @menu
29865 * pragma No_Run_Time:: 
29866 * pragma Ravenscar:: 
29867 * pragma Restricted_Run_Time:: 
29868 * pragma Task_Info:: 
29869 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads. 
29871 @end menu
29873 @node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
29874 @anchor{gnat_rm/obsolescent_features id2}@anchor{454}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{455}
29875 @section pragma No_Run_Time
29878 The pragma @code{No_Run_Time} is used to achieve an affect similar
29879 to the use of the “Zero Foot Print” configurable run time, but without
29880 requiring a specially configured run time. The result of using this
29881 pragma, which must be used for all units in a partition, is to restrict
29882 the use of any language features requiring run-time support code. The
29883 preferred usage is to use an appropriately configured run-time that
29884 includes just those features that are to be made accessible.
29886 @node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
29887 @anchor{gnat_rm/obsolescent_features id3}@anchor{456}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{457}
29888 @section pragma Ravenscar
29891 The pragma @code{Ravenscar} has exactly the same effect as pragma
29892 @code{Profile (Ravenscar)}. The latter usage is preferred since it
29893 is part of the new Ada 2005 standard.
29895 @node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
29896 @anchor{gnat_rm/obsolescent_features id4}@anchor{458}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{459}
29897 @section pragma Restricted_Run_Time
29900 The pragma @code{Restricted_Run_Time} has exactly the same effect as
29901 pragma @code{Profile (Restricted)}. The latter usage is
29902 preferred since the Ada 2005 pragma @code{Profile} is intended for
29903 this kind of implementation dependent addition.
29905 @node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
29906 @anchor{gnat_rm/obsolescent_features id5}@anchor{45a}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{45b}
29907 @section pragma Task_Info
29910 The functionality provided by pragma @code{Task_Info} is now part of the
29911 Ada language. The @code{CPU} aspect and the package
29912 @code{System.Multiprocessors} offer a less system-dependent way to specify
29913 task affinity or to query the number of processors.
29915 Syntax
29917 @example
29918 pragma Task_Info (EXPRESSION);
29919 @end example
29921 This pragma appears within a task definition (like pragma
29922 @code{Priority}) and applies to the task in which it appears.  The
29923 argument must be of type @code{System.Task_Info.Task_Info_Type}.
29924 The @code{Task_Info} pragma provides system dependent control over
29925 aspects of tasking implementation, for example, the ability to map
29926 tasks to specific processors.  For details on the facilities available
29927 for the version of GNAT that you are using, see the documentation
29928 in the spec of package System.Task_Info in the runtime
29929 library.
29931 @node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
29932 @anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{45c}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{45d}
29933 @section package System.Task_Info (@code{s-tasinf.ads})
29936 This package provides target dependent functionality that is used
29937 to support the @code{Task_Info} pragma. The predefined Ada package
29938 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
29939 standard replacement for GNAT’s @code{Task_Info} functionality.
29941 @node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
29942 @anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{45e}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{45f}
29943 @chapter Compatibility and Porting Guide
29946 This chapter presents some guidelines for developing portable Ada code,
29947 describes the compatibility issues that may arise between
29948 GNAT and other Ada compilation systems (including those for Ada 83),
29949 and shows how GNAT can expedite porting
29950 applications developed in other Ada environments.
29952 @menu
29953 * Writing Portable Fixed-Point Declarations:: 
29954 * Compatibility with Ada 83:: 
29955 * Compatibility between Ada 95 and Ada 2005:: 
29956 * Implementation-dependent characteristics:: 
29957 * Compatibility with Other Ada Systems:: 
29958 * Representation Clauses:: 
29959 * Compatibility with HP Ada 83:: 
29961 @end menu
29963 @node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
29964 @anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{460}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{461}
29965 @section Writing Portable Fixed-Point Declarations
29968 The Ada Reference Manual gives an implementation freedom to choose bounds
29969 that are narrower by @code{Small} from the given bounds.
29970 For example, if we write
29972 @example
29973 type F1 is delta 1.0 range -128.0 .. +128.0;
29974 @end example
29976 then the implementation is allowed to choose -128.0 .. +127.0 if it
29977 likes, but is not required to do so.
29979 This leads to possible portability problems, so let’s have a closer
29980 look at this, and figure out how to avoid these problems.
29982 First, why does this freedom exist, and why would an implementation
29983 take advantage of it? To answer this, take a closer look at the type
29984 declaration for @code{F1} above. If the compiler uses the given bounds,
29985 it would need 9 bits to hold the largest positive value (and typically
29986 that means 16 bits on all machines). But if the implementation chooses
29987 the +127.0 bound then it can fit values of the type in 8 bits.
29989 Why not make the user write +127.0 if that’s what is wanted?
29990 The rationale is that if you are thinking of fixed point
29991 as a kind of ‘poor man’s floating-point’, then you don’t want
29992 to be thinking about the scaled integers that are used in its
29993 representation. Let’s take another example:
29995 @example
29996 type F2 is delta 2.0**(-15) range -1.0 .. +1.0;
29997 @end example
29999 Looking at this declaration, it seems casually as though
30000 it should fit in 16 bits, but again that extra positive value
30001 +1.0 has the scaled integer equivalent of 2**15 which is one too
30002 big for signed 16 bits. The implementation can treat this as:
30004 @example
30005 type F2 is delta 2.0**(-15) range -1.0 .. +1.0-(2.0**(-15));
30006 @end example
30008 and the Ada language design team felt that this was too annoying
30009 to require. We don’t need to debate this decision at this point,
30010 since it is well established (the rule about narrowing the ranges
30011 dates to Ada 83).
30013 But the important point is that an implementation is not required
30014 to do this narrowing, so we have a potential portability problem.
30015 We could imagine three types of implementation:
30018 @enumerate a
30020 @item 
30021 those that narrow the range automatically if they can figure
30022 out that the narrower range will allow storage in a smaller machine unit,
30024 @item 
30025 those that will narrow only if forced to by a @code{'Size} clause, and
30027 @item 
30028 those that will never narrow.
30029 @end enumerate
30031 Now if we are language theoreticians, we can imagine a fourth
30032 approach: to narrow all the time, e.g. to treat
30034 @example
30035 type F3 is delta 1.0 range -10.0 .. +23.0;
30036 @end example
30038 as though it had been written:
30040 @example
30041 type F3 is delta 1.0 range -9.0 .. +22.0;
30042 @end example
30044 But although technically allowed, such a behavior would be hostile and silly,
30045 and no real compiler would do this. All real compilers will fall into one of
30046 the categories (a), (b) or (c) above.
30048 So, how do you get the compiler to do what you want? The answer is give the
30049 actual bounds you want, and then use a @code{'Small} clause and a
30050 @code{'Size} clause to absolutely pin down what the compiler does.
30051 E.g., for @code{F2} above, we will write:
30053 @example
30054 My_Small : constant := 2.0**(-15);
30055 My_First : constant := -1.0;
30056 My_Last  : constant := +1.0 - My_Small;
30058 type F2 is delta My_Small range My_First .. My_Last;
30059 @end example
30061 and then add
30063 @example
30064 for F2'Small use my_Small;
30065 for F2'Size  use 16;
30066 @end example
30068 In practice all compilers will do the same thing here and will give you
30069 what you want, so the above declarations are fully portable. If you really
30070 want to play language lawyer and guard against ludicrous behavior by the
30071 compiler you could add
30073 @example
30074 Test1 : constant := 1 / Boolean'Pos (F2'First = My_First);
30075 Test2 : constant := 1 / Boolean'Pos (F2'Last  = My_Last);
30076 @end example
30078 One or other or both are allowed to be illegal if the compiler is
30079 behaving in a silly manner, but at least the silly compiler will not
30080 get away with silently messing with your (very clear) intentions.
30082 If you follow this scheme you will be guaranteed that your fixed-point
30083 types will be portable.
30085 @node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
30086 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{462}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{463}
30087 @section Compatibility with Ada 83
30090 @geindex Compatibility (between Ada 83 and Ada 95 / Ada 2005 / Ada 2012)
30092 Ada 95 and the subsequent revisions Ada 2005 and Ada 2012
30093 are highly upwards compatible with Ada 83.  In
30094 particular, the design intention was that the difficulties associated
30095 with moving from Ada 83 to later versions of the standard should be no greater
30096 than those that occur when moving from one Ada 83 system to another.
30098 However, there are a number of points at which there are minor
30099 incompatibilities.  The @cite{Ada 95 Annotated Reference Manual} contains
30100 full details of these issues as they relate to Ada 95,
30101 and should be consulted for a complete treatment.
30102 In practice the
30103 following subsections treat the most likely issues to be encountered.
30105 @menu
30106 * Legal Ada 83 programs that are illegal in Ada 95:: 
30107 * More deterministic semantics:: 
30108 * Changed semantics:: 
30109 * Other language compatibility issues:: 
30111 @end menu
30113 @node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
30114 @anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{464}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{465}
30115 @subsection Legal Ada 83 programs that are illegal in Ada 95
30118 Some legal Ada 83 programs are illegal (i.e., they will fail to compile) in
30119 Ada 95 and later versions of the standard:
30122 @itemize *
30124 @item 
30125 `Character literals'
30127 Some uses of character literals are ambiguous.  Since Ada 95 has introduced
30128 @code{Wide_Character} as a new predefined character type, some uses of
30129 character literals that were legal in Ada 83 are illegal in Ada 95.
30130 For example:
30132 @example
30133 for Char in 'A' .. 'Z' loop ... end loop;
30134 @end example
30136 The problem is that ‘A’ and ‘Z’ could be from either
30137 @code{Character} or @code{Wide_Character}.  The simplest correction
30138 is to make the type explicit; e.g.:
30140 @example
30141 for Char in Character range 'A' .. 'Z' loop ... end loop;
30142 @end example
30144 @item 
30145 `New reserved words'
30147 The identifiers @code{abstract}, @code{aliased}, @code{protected},
30148 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
30149 Existing Ada 83 code using any of these identifiers must be edited to
30150 use some alternative name.
30152 @item 
30153 `Freezing rules'
30155 The rules in Ada 95 are slightly different with regard to the point at
30156 which entities are frozen, and representation pragmas and clauses are
30157 not permitted past the freeze point.  This shows up most typically in
30158 the form of an error message complaining that a representation item
30159 appears too late, and the appropriate corrective action is to move
30160 the item nearer to the declaration of the entity to which it refers.
30162 A particular case is that representation pragmas
30163 cannot be applied to a subprogram body.  If necessary, a separate subprogram
30164 declaration must be introduced to which the pragma can be applied.
30166 @item 
30167 `Optional bodies for library packages'
30169 In Ada 83, a package that did not require a package body was nevertheless
30170 allowed to have one.  This lead to certain surprises in compiling large
30171 systems (situations in which the body could be unexpectedly ignored by the
30172 binder).  In Ada 95, if a package does not require a body then it is not
30173 permitted to have a body.  To fix this problem, simply remove a redundant
30174 body if it is empty, or, if it is non-empty, introduce a dummy declaration
30175 into the spec that makes the body required.  One approach is to add a private
30176 part to the package declaration (if necessary), and define a parameterless
30177 procedure called @code{Requires_Body}, which must then be given a dummy
30178 procedure body in the package body, which then becomes required.
30179 Another approach (assuming that this does not introduce elaboration
30180 circularities) is to add an @code{Elaborate_Body} pragma to the package spec,
30181 since one effect of this pragma is to require the presence of a package body.
30183 @item 
30184 `Numeric_Error is the same exception as Constraint_Error'
30186 In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
30187 This means that it is illegal to have separate exception handlers for
30188 the two exceptions.  The fix is simply to remove the handler for the
30189 @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
30190 @code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
30192 @item 
30193 `Indefinite subtypes in generics'
30195 In Ada 83, it was permissible to pass an indefinite type (e.g, @code{String})
30196 as the actual for a generic formal private type, but then the instantiation
30197 would be illegal if there were any instances of declarations of variables
30198 of this type in the generic body.  In Ada 95, to avoid this clear violation
30199 of the methodological principle known as the ‘contract model’,
30200 the generic declaration explicitly indicates whether
30201 or not such instantiations are permitted.  If a generic formal parameter
30202 has explicit unknown discriminants, indicated by using @code{(<>)} after the
30203 subtype name, then it can be instantiated with indefinite types, but no
30204 stand-alone variables can be declared of this type.  Any attempt to declare
30205 such a variable will result in an illegality at the time the generic is
30206 declared.  If the @code{(<>)} notation is not used, then it is illegal
30207 to instantiate the generic with an indefinite type.
30208 This is the potential incompatibility issue when porting Ada 83 code to Ada 95.
30209 It will show up as a compile time error, and
30210 the fix is usually simply to add the @code{(<>)} to the generic declaration.
30211 @end itemize
30213 @node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
30214 @anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{466}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{467}
30215 @subsection More deterministic semantics
30219 @itemize *
30221 @item 
30222 `Conversions'
30224 Conversions from real types to integer types round away from 0.  In Ada 83
30225 the conversion Integer(2.5) could deliver either 2 or 3 as its value.  This
30226 implementation freedom was intended to support unbiased rounding in
30227 statistical applications, but in practice it interfered with portability.
30228 In Ada 95 the conversion semantics are unambiguous, and rounding away from 0
30229 is required.  Numeric code may be affected by this change in semantics.
30230 Note, though, that this issue is no worse than already existed in Ada 83
30231 when porting code from one vendor to another.
30233 @item 
30234 `Tasking'
30236 The Real-Time Annex introduces a set of policies that define the behavior of
30237 features that were implementation dependent in Ada 83, such as the order in
30238 which open select branches are executed.
30239 @end itemize
30241 @node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
30242 @anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{468}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{469}
30243 @subsection Changed semantics
30246 The worst kind of incompatibility is one where a program that is legal in
30247 Ada 83 is also legal in Ada 95 but can have an effect in Ada 95 that was not
30248 possible in Ada 83.  Fortunately this is extremely rare, but the one
30249 situation that you should be alert to is the change in the predefined type
30250 @code{Character} from 7-bit ASCII to 8-bit Latin-1.
30252 @quotation
30254 @geindex Latin-1
30255 @end quotation
30258 @itemize *
30260 @item 
30261 `Range of type `@w{`}Character`@w{`}'
30263 The range of @code{Standard.Character} is now the full 256 characters
30264 of Latin-1, whereas in most Ada 83 implementations it was restricted
30265 to 128 characters. Although some of the effects of
30266 this change will be manifest in compile-time rejection of legal
30267 Ada 83 programs it is possible for a working Ada 83 program to have
30268 a different effect in Ada 95, one that was not permitted in Ada 83.
30269 As an example, the expression
30270 @code{Character'Pos(Character'Last)} returned @code{127} in Ada 83 and now
30271 delivers @code{255} as its value.
30272 In general, you should look at the logic of any
30273 character-processing Ada 83 program and see whether it needs to be adapted
30274 to work correctly with Latin-1.  Note that the predefined Ada 95 API has a
30275 character handling package that may be relevant if code needs to be adapted
30276 to account for the additional Latin-1 elements.
30277 The desirable fix is to
30278 modify the program to accommodate the full character set, but in some cases
30279 it may be convenient to define a subtype or derived type of Character that
30280 covers only the restricted range.
30281 @end itemize
30283 @node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
30284 @anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{46a}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{46b}
30285 @subsection Other language compatibility issues
30289 @itemize *
30291 @item 
30292 `-gnat83' switch
30294 All implementations of GNAT provide a switch that causes GNAT to operate
30295 in Ada 83 mode.  In this mode, some but not all compatibility problems
30296 of the type described above are handled automatically.  For example, the
30297 new reserved words introduced in Ada 95 and Ada 2005 are treated simply
30298 as identifiers as in Ada 83.  However,
30299 in practice, it is usually advisable to make the necessary modifications
30300 to the program to remove the need for using this switch.
30301 See the @code{Compiling Different Versions of Ada} section in
30302 the @cite{GNAT User’s Guide}.
30304 @item 
30305 Support for removed Ada 83 pragmas and attributes
30307 A number of pragmas and attributes from Ada 83 were removed from Ada 95,
30308 generally because they were replaced by other mechanisms.  Ada 95 and Ada 2005
30309 compilers are allowed, but not required, to implement these missing
30310 elements.  In contrast with some other compilers, GNAT implements all
30311 such pragmas and attributes, eliminating this compatibility concern.  These
30312 include @code{pragma Interface} and the floating point type attributes
30313 (@code{Emax}, @code{Mantissa}, etc.), among other items.
30314 @end itemize
30316 @node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
30317 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{46c}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{46d}
30318 @section Compatibility between Ada 95 and Ada 2005
30321 @geindex Compatibility between Ada 95 and Ada 2005
30323 Although Ada 2005 was designed to be upwards compatible with Ada 95, there are
30324 a number of incompatibilities. Several are enumerated below;
30325 for a complete description please see the
30326 @cite{Annotated Ada 2005 Reference Manual}, or section 9.1.1 in
30327 @cite{Rationale for Ada 2005}.
30330 @itemize *
30332 @item 
30333 `New reserved words.'
30335 The words @code{interface}, @code{overriding} and @code{synchronized} are
30336 reserved in Ada 2005.
30337 A pre-Ada 2005 program that uses any of these as an identifier will be
30338 illegal.
30340 @item 
30341 `New declarations in predefined packages.'
30343 A number of packages in the predefined environment contain new declarations:
30344 @code{Ada.Exceptions}, @code{Ada.Real_Time}, @code{Ada.Strings},
30345 @code{Ada.Strings.Fixed}, @code{Ada.Strings.Bounded},
30346 @code{Ada.Strings.Unbounded}, @code{Ada.Strings.Wide_Fixed},
30347 @code{Ada.Strings.Wide_Bounded}, @code{Ada.Strings.Wide_Unbounded},
30348 @code{Ada.Tags}, @code{Ada.Text_IO}, and @code{Interfaces.C}.
30349 If an Ada 95 program does a @code{with} and @code{use} of any of these
30350 packages, the new declarations may cause name clashes.
30352 @item 
30353 `Access parameters.'
30355 A nondispatching subprogram with an access parameter cannot be renamed
30356 as a dispatching operation.  This was permitted in Ada 95.
30358 @item 
30359 `Access types, discriminants, and constraints.'
30361 Rule changes in this area have led to some incompatibilities; for example,
30362 constrained subtypes of some access types are not permitted in Ada 2005.
30364 @item 
30365 `Aggregates for limited types.'
30367 The allowance of aggregates for limited types in Ada 2005 raises the
30368 possibility of ambiguities in legal Ada 95 programs, since additional types
30369 now need to be considered in expression resolution.
30371 @item 
30372 `Fixed-point multiplication and division.'
30374 Certain expressions involving ‘*’ or ‘/’ for a fixed-point type, which
30375 were legal in Ada 95 and invoked the predefined versions of these operations,
30376 are now ambiguous.
30377 The ambiguity may be resolved either by applying a type conversion to the
30378 expression, or by explicitly invoking the operation from package
30379 @code{Standard}.
30381 @item 
30382 `Return-by-reference types.'
30384 The Ada 95 return-by-reference mechanism has been removed.  Instead, the user
30385 can declare a function returning a value from an anonymous access type.
30386 @end itemize
30388 @node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
30389 @anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{46e}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{46f}
30390 @section Implementation-dependent characteristics
30393 Although the Ada language defines the semantics of each construct as
30394 precisely as practical, in some situations (for example for reasons of
30395 efficiency, or where the effect is heavily dependent on the host or target
30396 platform) the implementation is allowed some freedom.  In porting Ada 83
30397 code to GNAT, you need to be aware of whether / how the existing code
30398 exercised such implementation dependencies.  Such characteristics fall into
30399 several categories, and GNAT offers specific support in assisting the
30400 transition from certain Ada 83 compilers.
30402 @menu
30403 * Implementation-defined pragmas:: 
30404 * Implementation-defined attributes:: 
30405 * Libraries:: 
30406 * Elaboration order:: 
30407 * Target-specific aspects:: 
30409 @end menu
30411 @node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
30412 @anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{470}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{471}
30413 @subsection Implementation-defined pragmas
30416 Ada compilers are allowed to supplement the language-defined pragmas, and
30417 these are a potential source of non-portability.  All GNAT-defined pragmas
30418 are described in @ref{7,,Implementation Defined Pragmas},
30419 and these include several that are specifically
30420 intended to correspond to other vendors’ Ada 83 pragmas.
30421 For migrating from VADS, the pragma @code{Use_VADS_Size} may be useful.
30422 For compatibility with HP Ada 83, GNAT supplies the pragmas
30423 @code{Extend_System}, @code{Ident}, @code{Inline_Generic},
30424 @code{Interface_Name}, @code{Passive}, @code{Suppress_All},
30425 and @code{Volatile}.
30426 Other relevant pragmas include @code{External} and @code{Link_With}.
30427 Some vendor-specific
30428 Ada 83 pragmas (@code{Share_Generic}, @code{Subtitle}, and @code{Title}) are
30429 recognized, thus
30430 avoiding compiler rejection of units that contain such pragmas; they are not
30431 relevant in a GNAT context and hence are not otherwise implemented.
30433 @node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
30434 @anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{472}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{473}
30435 @subsection Implementation-defined attributes
30438 Analogous to pragmas, the set of attributes may be extended by an
30439 implementation.  All GNAT-defined attributes are described in
30440 @ref{8,,Implementation Defined Attributes},
30441 and these include several that are specifically intended
30442 to correspond to other vendors’ Ada 83 attributes.  For migrating from VADS,
30443 the attribute @code{VADS_Size} may be useful.  For compatibility with HP
30444 Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
30445 @code{Type_Class}.
30447 @node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
30448 @anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{474}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{475}
30449 @subsection Libraries
30452 Vendors may supply libraries to supplement the standard Ada API.  If Ada 83
30453 code uses vendor-specific libraries then there are several ways to manage
30454 this in Ada 95 and later versions of the standard:
30457 @itemize *
30459 @item 
30460 If the source code for the libraries (specs and bodies) are
30461 available, then the libraries can be migrated in the same way as the
30462 application.
30464 @item 
30465 If the source code for the specs but not the bodies are
30466 available, then you can reimplement the bodies.
30468 @item 
30469 Some features introduced by Ada 95 obviate the need for library support.  For
30470 example most Ada 83 vendors supplied a package for unsigned integers.  The
30471 Ada 95 modular type feature is the preferred way to handle this need, so
30472 instead of migrating or reimplementing the unsigned integer package it may
30473 be preferable to retrofit the application using modular types.
30474 @end itemize
30476 @node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
30477 @anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{476}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{477}
30478 @subsection Elaboration order
30481 The implementation can choose any elaboration order consistent with the unit
30482 dependency relationship.  This freedom means that some orders can result in
30483 Program_Error being raised due to an ‘Access Before Elaboration’: an attempt
30484 to invoke a subprogram before its body has been elaborated, or to instantiate
30485 a generic before the generic body has been elaborated.  By default GNAT
30486 attempts to choose a safe order (one that will not encounter access before
30487 elaboration problems) by implicitly inserting @code{Elaborate} or
30488 @code{Elaborate_All} pragmas where
30489 needed.  However, this can lead to the creation of elaboration circularities
30490 and a resulting rejection of the program by gnatbind.  This issue is
30491 thoroughly described in the `Elaboration Order Handling in GNAT' appendix
30492 in the @cite{GNAT User’s Guide}.
30493 In brief, there are several
30494 ways to deal with this situation:
30497 @itemize *
30499 @item 
30500 Modify the program to eliminate the circularities, e.g., by moving
30501 elaboration-time code into explicitly-invoked procedures
30503 @item 
30504 Constrain the elaboration order by including explicit @code{Elaborate_Body} or
30505 @code{Elaborate} pragmas, and then inhibit the generation of implicit
30506 @code{Elaborate_All}
30507 pragmas either globally (as an effect of the `-gnatE' switch) or locally
30508 (by selectively suppressing elaboration checks via pragma
30509 @code{Suppress(Elaboration_Check)} when it is safe to do so).
30510 @end itemize
30512 @node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
30513 @anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{478}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{479}
30514 @subsection Target-specific aspects
30517 Low-level applications need to deal with machine addresses, data
30518 representations, interfacing with assembler code, and similar issues.  If
30519 such an Ada 83 application is being ported to different target hardware (for
30520 example where the byte endianness has changed) then you will need to
30521 carefully examine the program logic; the porting effort will heavily depend
30522 on the robustness of the original design.  Moreover, Ada 95 (and thus
30523 Ada 2005 and Ada 2012) are sometimes
30524 incompatible with typical Ada 83 compiler practices regarding implicit
30525 packing, the meaning of the Size attribute, and the size of access values.
30526 GNAT’s approach to these issues is described in @ref{47a,,Representation Clauses}.
30528 @node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
30529 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{47b}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{47c}
30530 @section Compatibility with Other Ada Systems
30533 If programs avoid the use of implementation dependent and
30534 implementation defined features, as documented in the
30535 @cite{Ada Reference Manual}, there should be a high degree of portability between
30536 GNAT and other Ada systems.  The following are specific items which
30537 have proved troublesome in moving Ada 95 programs from GNAT to other Ada 95
30538 compilers, but do not affect porting code to GNAT.
30539 (As of January 2007, GNAT is the only compiler available for Ada 2005;
30540 the following issues may or may not arise for Ada 2005 programs
30541 when other compilers appear.)
30544 @itemize *
30546 @item 
30547 `Ada 83 Pragmas and Attributes'
30549 Ada 95 compilers are allowed, but not required, to implement the missing
30550 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
30551 GNAT implements all such pragmas and attributes, eliminating this as
30552 a compatibility concern, but some other Ada 95 compilers reject these
30553 pragmas and attributes.
30555 @item 
30556 `Specialized Needs Annexes'
30558 GNAT implements the full set of special needs annexes.  At the
30559 current time, it is the only Ada 95 compiler to do so.  This means that
30560 programs making use of these features may not be portable to other Ada
30561 95 compilation systems.
30563 @item 
30564 `Representation Clauses'
30566 Some other Ada 95 compilers implement only the minimal set of
30567 representation clauses required by the Ada 95 reference manual.  GNAT goes
30568 far beyond this minimal set, as described in the next section.
30569 @end itemize
30571 @node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
30572 @anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{47d}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{47a}
30573 @section Representation Clauses
30576 The Ada 83 reference manual was quite vague in describing both the minimal
30577 required implementation of representation clauses, and also their precise
30578 effects.  Ada 95 (and thus also Ada 2005) are much more explicit, but the
30579 minimal set of capabilities required is still quite limited.
30581 GNAT implements the full required set of capabilities in
30582 Ada 95 and Ada 2005, but also goes much further, and in particular
30583 an effort has been made to be compatible with existing Ada 83 usage to the
30584 greatest extent possible.
30586 A few cases exist in which Ada 83 compiler behavior is incompatible with
30587 the requirements in Ada 95 (and thus also Ada 2005).  These are instances of
30588 intentional or accidental dependence on specific implementation dependent
30589 characteristics of these Ada 83 compilers.  The following is a list of
30590 the cases most likely to arise in existing Ada 83 code.
30593 @itemize *
30595 @item 
30596 `Implicit Packing'
30598 Some Ada 83 compilers allowed a Size specification to cause implicit
30599 packing of an array or record.  This could cause expensive implicit
30600 conversions for change of representation in the presence of derived
30601 types, and the Ada design intends to avoid this possibility.
30602 Subsequent AI’s were issued to make it clear that such implicit
30603 change of representation in response to a Size clause is inadvisable,
30604 and this recommendation is represented explicitly in the Ada 95 (and Ada 2005)
30605 Reference Manuals as implementation advice that is followed by GNAT.
30606 The problem will show up as an error
30607 message rejecting the size clause.  The fix is simply to provide
30608 the explicit pragma @code{Pack}, or for more fine tuned control, provide
30609 a Component_Size clause.
30611 @item 
30612 `Meaning of Size Attribute'
30614 The Size attribute in Ada 95 (and Ada 2005) for discrete types is defined as
30615 the minimal number of bits required to hold values of the type.  For example,
30616 on a 32-bit machine, the size of @code{Natural} will typically be 31 and not
30617 32 (since no sign bit is required).  Some Ada 83 compilers gave 31, and
30618 some 32 in this situation.  This problem will usually show up as a compile
30619 time error, but not always.  It is a good idea to check all uses of the
30620 ‘Size attribute when porting Ada 83 code.  The GNAT specific attribute
30621 Object_Size can provide a useful way of duplicating the behavior of
30622 some Ada 83 compiler systems.
30624 @item 
30625 `Size of Access Types'
30627 A common assumption in Ada 83 code is that an access type is in fact a pointer,
30628 and that therefore it will be the same size as a System.Address value.  This
30629 assumption is true for GNAT in most cases with one exception.  For the case of
30630 a pointer to an unconstrained array type (where the bounds may vary from one
30631 value of the access type to another), the default is to use a ‘fat pointer’,
30632 which is represented as two separate pointers, one to the bounds, and one to
30633 the array.  This representation has a number of advantages, including improved
30634 efficiency.  However, it may cause some difficulties in porting existing Ada 83
30635 code which makes the assumption that, for example, pointers fit in 32 bits on
30636 a machine with 32-bit addressing.
30638 To get around this problem, GNAT also permits the use of ‘thin pointers’ for
30639 access types in this case (where the designated type is an unconstrained array
30640 type).  These thin pointers are indeed the same size as a System.Address value.
30641 To specify a thin pointer, use a size clause for the type, for example:
30643 @example
30644 type X is access all String;
30645 for X'Size use Standard'Address_Size;
30646 @end example
30648 which will cause the type X to be represented using a single pointer.
30649 When using this representation, the bounds are right behind the array.
30650 This representation is slightly less efficient, and does not allow quite
30651 such flexibility in the use of foreign pointers or in using the
30652 Unrestricted_Access attribute to create pointers to non-aliased objects.
30653 But for any standard portable use of the access type it will work in
30654 a functionally correct manner and allow porting of existing code.
30655 Note that another way of forcing a thin pointer representation
30656 is to use a component size clause for the element size in an array,
30657 or a record representation clause for an access field in a record.
30659 See the documentation of Unrestricted_Access in the GNAT RM for a
30660 full discussion of possible problems using this attribute in conjunction
30661 with thin pointers.
30662 @end itemize
30664 @node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
30665 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{47e}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{47f}
30666 @section Compatibility with HP Ada 83
30669 All the HP Ada 83 pragmas and attributes are recognized, although only a subset
30670 of them can sensibly be implemented.  The description of pragmas in
30671 @ref{7,,Implementation Defined Pragmas} indicates whether or not they are
30672 applicable to GNAT.
30675 @itemize *
30677 @item 
30678 `Default floating-point representation'
30680 In GNAT, the default floating-point format is IEEE, whereas in HP Ada 83,
30681 it is VMS format.
30683 @item 
30684 `System'
30686 the package System in GNAT exactly corresponds to the definition in the
30687 Ada 95 reference manual, which means that it excludes many of the
30688 HP Ada 83 extensions.  However, a separate package Aux_DEC is provided
30689 that contains the additional definitions, and a special pragma,
30690 Extend_System allows this package to be treated transparently as an
30691 extension of package System.
30692 @end itemize
30694 @node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
30695 @anchor{share/gnu_free_documentation_license doc}@anchor{480}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{481}
30696 @chapter GNU Free Documentation License
30699 Version 1.3, 3 November 2008
30701 Copyright  2000, 2001, 2002, 2007, 2008  Free Software Foundation, Inc
30702 @indicateurl{https://fsf.org/}
30704 Everyone is permitted to copy and distribute verbatim copies of this
30705 license document, but changing it is not allowed.
30707 `Preamble'
30709 The purpose of this License is to make a manual, textbook, or other
30710 functional and useful document “free” in the sense of freedom: to
30711 assure everyone the effective freedom to copy and redistribute it,
30712 with or without modifying it, either commercially or noncommercially.
30713 Secondarily, this License preserves for the author and publisher a way
30714 to get credit for their work, while not being considered responsible
30715 for modifications made by others.
30717 This License is a kind of “copyleft”, which means that derivative
30718 works of the document must themselves be free in the same sense.  It
30719 complements the GNU General Public License, which is a copyleft
30720 license designed for free software.
30722 We have designed this License in order to use it for manuals for free
30723 software, because free software needs free documentation: a free
30724 program should come with manuals providing the same freedoms that the
30725 software does.  But this License is not limited to software manuals;
30726 it can be used for any textual work, regardless of subject matter or
30727 whether it is published as a printed book.  We recommend this License
30728 principally for works whose purpose is instruction or reference.
30730 `1. APPLICABILITY AND DEFINITIONS'
30732 This License applies to any manual or other work, in any medium, that
30733 contains a notice placed by the copyright holder saying it can be
30734 distributed under the terms of this License.  Such a notice grants a
30735 world-wide, royalty-free license, unlimited in duration, to use that
30736 work under the conditions stated herein.  The `Document', below,
30737 refers to any such manual or work.  Any member of the public is a
30738 licensee, and is addressed as “`you'”.  You accept the license if you
30739 copy, modify or distribute the work in a way requiring permission
30740 under copyright law.
30742 A “`Modified Version'” of the Document means any work containing the
30743 Document or a portion of it, either copied verbatim, or with
30744 modifications and/or translated into another language.
30746 A “`Secondary Section'” is a named appendix or a front-matter section of
30747 the Document that deals exclusively with the relationship of the
30748 publishers or authors of the Document to the Document’s overall subject
30749 (or to related matters) and contains nothing that could fall directly
30750 within that overall subject.  (Thus, if the Document is in part a
30751 textbook of mathematics, a Secondary Section may not explain any
30752 mathematics.)  The relationship could be a matter of historical
30753 connection with the subject or with related matters, or of legal,
30754 commercial, philosophical, ethical or political position regarding
30755 them.
30757 The “`Invariant Sections'” are certain Secondary Sections whose titles
30758 are designated, as being those of Invariant Sections, in the notice
30759 that says that the Document is released under this License.  If a
30760 section does not fit the above definition of Secondary then it is not
30761 allowed to be designated as Invariant.  The Document may contain zero
30762 Invariant Sections.  If the Document does not identify any Invariant
30763 Sections then there are none.
30765 The “`Cover Texts'” are certain short passages of text that are listed,
30766 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
30767 the Document is released under this License.  A Front-Cover Text may
30768 be at most 5 words, and a Back-Cover Text may be at most 25 words.
30770 A “`Transparent'” copy of the Document means a machine-readable copy,
30771 represented in a format whose specification is available to the
30772 general public, that is suitable for revising the document
30773 straightforwardly with generic text editors or (for images composed of
30774 pixels) generic paint programs or (for drawings) some widely available
30775 drawing editor, and that is suitable for input to text formatters or
30776 for automatic translation to a variety of formats suitable for input
30777 to text formatters.  A copy made in an otherwise Transparent file
30778 format whose markup, or absence of markup, has been arranged to thwart
30779 or discourage subsequent modification by readers is not Transparent.
30780 An image format is not Transparent if used for any substantial amount
30781 of text.  A copy that is not “Transparent” is called `Opaque'.
30783 Examples of suitable formats for Transparent copies include plain
30784 ASCII without markup, Texinfo input format, LaTeX input format, SGML
30785 or XML using a publicly available DTD, and standard-conforming simple
30786 HTML, PostScript or PDF designed for human modification.  Examples of
30787 transparent image formats include PNG, XCF and JPG.  Opaque formats
30788 include proprietary formats that can be read and edited only by
30789 proprietary word processors, SGML or XML for which the DTD and/or
30790 processing tools are not generally available, and the
30791 machine-generated HTML, PostScript or PDF produced by some word
30792 processors for output purposes only.
30794 The “`Title Page'” means, for a printed book, the title page itself,
30795 plus such following pages as are needed to hold, legibly, the material
30796 this License requires to appear in the title page.  For works in
30797 formats which do not have any title page as such, “Title Page” means
30798 the text near the most prominent appearance of the work’s title,
30799 preceding the beginning of the body of the text.
30801 The “`publisher'” means any person or entity that distributes
30802 copies of the Document to the public.
30804 A section “`Entitled XYZ'” means a named subunit of the Document whose
30805 title either is precisely XYZ or contains XYZ in parentheses following
30806 text that translates XYZ in another language.  (Here XYZ stands for a
30807 specific section name mentioned below, such as “`Acknowledgements'”,
30808 “`Dedications'”, “`Endorsements'”, or “`History'”.)
30809 To “`Preserve the Title'”
30810 of such a section when you modify the Document means that it remains a
30811 section “Entitled XYZ” according to this definition.
30813 The Document may include Warranty Disclaimers next to the notice which
30814 states that this License applies to the Document.  These Warranty
30815 Disclaimers are considered to be included by reference in this
30816 License, but only as regards disclaiming warranties: any other
30817 implication that these Warranty Disclaimers may have is void and has
30818 no effect on the meaning of this License.
30820 `2. VERBATIM COPYING'
30822 You may copy and distribute the Document in any medium, either
30823 commercially or noncommercially, provided that this License, the
30824 copyright notices, and the license notice saying this License applies
30825 to the Document are reproduced in all copies, and that you add no other
30826 conditions whatsoever to those of this License.  You may not use
30827 technical measures to obstruct or control the reading or further
30828 copying of the copies you make or distribute.  However, you may accept
30829 compensation in exchange for copies.  If you distribute a large enough
30830 number of copies you must also follow the conditions in section 3.
30832 You may also lend copies, under the same conditions stated above, and
30833 you may publicly display copies.
30835 `3. COPYING IN QUANTITY'
30837 If you publish printed copies (or copies in media that commonly have
30838 printed covers) of the Document, numbering more than 100, and the
30839 Document’s license notice requires Cover Texts, you must enclose the
30840 copies in covers that carry, clearly and legibly, all these Cover
30841 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
30842 the back cover.  Both covers must also clearly and legibly identify
30843 you as the publisher of these copies.  The front cover must present
30844 the full title with all words of the title equally prominent and
30845 visible.  You may add other material on the covers in addition.
30846 Copying with changes limited to the covers, as long as they preserve
30847 the title of the Document and satisfy these conditions, can be treated
30848 as verbatim copying in other respects.
30850 If the required texts for either cover are too voluminous to fit
30851 legibly, you should put the first ones listed (as many as fit
30852 reasonably) on the actual cover, and continue the rest onto adjacent
30853 pages.
30855 If you publish or distribute Opaque copies of the Document numbering
30856 more than 100, you must either include a machine-readable Transparent
30857 copy along with each Opaque copy, or state in or with each Opaque copy
30858 a computer-network location from which the general network-using
30859 public has access to download using public-standard network protocols
30860 a complete Transparent copy of the Document, free of added material.
30861 If you use the latter option, you must take reasonably prudent steps,
30862 when you begin distribution of Opaque copies in quantity, to ensure
30863 that this Transparent copy will remain thus accessible at the stated
30864 location until at least one year after the last time you distribute an
30865 Opaque copy (directly or through your agents or retailers) of that
30866 edition to the public.
30868 It is requested, but not required, that you contact the authors of the
30869 Document well before redistributing any large number of copies, to give
30870 them a chance to provide you with an updated version of the Document.
30872 `4. MODIFICATIONS'
30874 You may copy and distribute a Modified Version of the Document under
30875 the conditions of sections 2 and 3 above, provided that you release
30876 the Modified Version under precisely this License, with the Modified
30877 Version filling the role of the Document, thus licensing distribution
30878 and modification of the Modified Version to whoever possesses a copy
30879 of it.  In addition, you must do these things in the Modified Version:
30882 @enumerate A
30884 @item 
30885 Use in the Title Page (and on the covers, if any) a title distinct
30886 from that of the Document, and from those of previous versions
30887 (which should, if there were any, be listed in the History section
30888 of the Document).  You may use the same title as a previous version
30889 if the original publisher of that version gives permission.
30891 @item 
30892 List on the Title Page, as authors, one or more persons or entities
30893 responsible for authorship of the modifications in the Modified
30894 Version, together with at least five of the principal authors of the
30895 Document (all of its principal authors, if it has fewer than five),
30896 unless they release you from this requirement.
30898 @item 
30899 State on the Title page the name of the publisher of the
30900 Modified Version, as the publisher.
30902 @item 
30903 Preserve all the copyright notices of the Document.
30905 @item 
30906 Add an appropriate copyright notice for your modifications
30907 adjacent to the other copyright notices.
30909 @item 
30910 Include, immediately after the copyright notices, a license notice
30911 giving the public permission to use the Modified Version under the
30912 terms of this License, in the form shown in the Addendum below.
30914 @item 
30915 Preserve in that license notice the full lists of Invariant Sections
30916 and required Cover Texts given in the Document’s license notice.
30918 @item 
30919 Include an unaltered copy of this License.
30921 @item 
30922 Preserve the section Entitled “History”, Preserve its Title, and add
30923 to it an item stating at least the title, year, new authors, and
30924 publisher of the Modified Version as given on the Title Page.  If
30925 there is no section Entitled “History” in the Document, create one
30926 stating the title, year, authors, and publisher of the Document as
30927 given on its Title Page, then add an item describing the Modified
30928 Version as stated in the previous sentence.
30930 @item 
30931 Preserve the network location, if any, given in the Document for
30932 public access to a Transparent copy of the Document, and likewise
30933 the network locations given in the Document for previous versions
30934 it was based on.  These may be placed in the “History” section.
30935 You may omit a network location for a work that was published at
30936 least four years before the Document itself, or if the original
30937 publisher of the version it refers to gives permission.
30939 @item 
30940 For any section Entitled “Acknowledgements” or “Dedications”,
30941 Preserve the Title of the section, and preserve in the section all
30942 the substance and tone of each of the contributor acknowledgements
30943 and/or dedications given therein.
30945 @item 
30946 Preserve all the Invariant Sections of the Document,
30947 unaltered in their text and in their titles.  Section numbers
30948 or the equivalent are not considered part of the section titles.
30950 @item 
30951 Delete any section Entitled “Endorsements”.  Such a section
30952 may not be included in the Modified Version.
30954 @item 
30955 Do not retitle any existing section to be Entitled “Endorsements”
30956 or to conflict in title with any Invariant Section.
30958 @item 
30959 Preserve any Warranty Disclaimers.
30960 @end enumerate
30962 If the Modified Version includes new front-matter sections or
30963 appendices that qualify as Secondary Sections and contain no material
30964 copied from the Document, you may at your option designate some or all
30965 of these sections as invariant.  To do this, add their titles to the
30966 list of Invariant Sections in the Modified Version’s license notice.
30967 These titles must be distinct from any other section titles.
30969 You may add a section Entitled “Endorsements”, provided it contains
30970 nothing but endorsements of your Modified Version by various
30971 parties—for example, statements of peer review or that the text has
30972 been approved by an organization as the authoritative definition of a
30973 standard.
30975 You may add a passage of up to five words as a Front-Cover Text, and a
30976 passage of up to 25 words as a Back-Cover Text, to the end of the list
30977 of Cover Texts in the Modified Version.  Only one passage of
30978 Front-Cover Text and one of Back-Cover Text may be added by (or
30979 through arrangements made by) any one entity.  If the Document already
30980 includes a cover text for the same cover, previously added by you or
30981 by arrangement made by the same entity you are acting on behalf of,
30982 you may not add another; but you may replace the old one, on explicit
30983 permission from the previous publisher that added the old one.
30985 The author(s) and publisher(s) of the Document do not by this License
30986 give permission to use their names for publicity for or to assert or
30987 imply endorsement of any Modified Version.
30989 `5. COMBINING DOCUMENTS'
30991 You may combine the Document with other documents released under this
30992 License, under the terms defined in section 4 above for modified
30993 versions, provided that you include in the combination all of the
30994 Invariant Sections of all of the original documents, unmodified, and
30995 list them all as Invariant Sections of your combined work in its
30996 license notice, and that you preserve all their Warranty Disclaimers.
30998 The combined work need only contain one copy of this License, and
30999 multiple identical Invariant Sections may be replaced with a single
31000 copy.  If there are multiple Invariant Sections with the same name but
31001 different contents, make the title of each such section unique by
31002 adding at the end of it, in parentheses, the name of the original
31003 author or publisher of that section if known, or else a unique number.
31004 Make the same adjustment to the section titles in the list of
31005 Invariant Sections in the license notice of the combined work.
31007 In the combination, you must combine any sections Entitled “History”
31008 in the various original documents, forming one section Entitled
31009 “History”; likewise combine any sections Entitled “Acknowledgements”,
31010 and any sections Entitled “Dedications”.  You must delete all sections
31011 Entitled “Endorsements”.
31013 `6. COLLECTIONS OF DOCUMENTS'
31015 You may make a collection consisting of the Document and other documents
31016 released under this License, and replace the individual copies of this
31017 License in the various documents with a single copy that is included in
31018 the collection, provided that you follow the rules of this License for
31019 verbatim copying of each of the documents in all other respects.
31021 You may extract a single document from such a collection, and distribute
31022 it individually under this License, provided you insert a copy of this
31023 License into the extracted document, and follow this License in all
31024 other respects regarding verbatim copying of that document.
31026 `7. AGGREGATION WITH INDEPENDENT WORKS'
31028 A compilation of the Document or its derivatives with other separate
31029 and independent documents or works, in or on a volume of a storage or
31030 distribution medium, is called an “aggregate” if the copyright
31031 resulting from the compilation is not used to limit the legal rights
31032 of the compilation’s users beyond what the individual works permit.
31033 When the Document is included in an aggregate, this License does not
31034 apply to the other works in the aggregate which are not themselves
31035 derivative works of the Document.
31037 If the Cover Text requirement of section 3 is applicable to these
31038 copies of the Document, then if the Document is less than one half of
31039 the entire aggregate, the Document’s Cover Texts may be placed on
31040 covers that bracket the Document within the aggregate, or the
31041 electronic equivalent of covers if the Document is in electronic form.
31042 Otherwise they must appear on printed covers that bracket the whole
31043 aggregate.
31045 `8. TRANSLATION'
31047 Translation is considered a kind of modification, so you may
31048 distribute translations of the Document under the terms of section 4.
31049 Replacing Invariant Sections with translations requires special
31050 permission from their copyright holders, but you may include
31051 translations of some or all Invariant Sections in addition to the
31052 original versions of these Invariant Sections.  You may include a
31053 translation of this License, and all the license notices in the
31054 Document, and any Warranty Disclaimers, provided that you also include
31055 the original English version of this License and the original versions
31056 of those notices and disclaimers.  In case of a disagreement between
31057 the translation and the original version of this License or a notice
31058 or disclaimer, the original version will prevail.
31060 If a section in the Document is Entitled “Acknowledgements”,
31061 “Dedications”, or “History”, the requirement (section 4) to Preserve
31062 its Title (section 1) will typically require changing the actual
31063 title.
31065 `9. TERMINATION'
31067 You may not copy, modify, sublicense, or distribute the Document
31068 except as expressly provided under this License.  Any attempt
31069 otherwise to copy, modify, sublicense, or distribute it is void, and
31070 will automatically terminate your rights under this License.
31072 However, if you cease all violation of this License, then your license
31073 from a particular copyright holder is reinstated (a) provisionally,
31074 unless and until the copyright holder explicitly and finally
31075 terminates your license, and (b) permanently, if the copyright holder
31076 fails to notify you of the violation by some reasonable means prior to
31077 60 days after the cessation.
31079 Moreover, your license from a particular copyright holder is
31080 reinstated permanently if the copyright holder notifies you of the
31081 violation by some reasonable means, this is the first time you have
31082 received notice of violation of this License (for any work) from that
31083 copyright holder, and you cure the violation prior to 30 days after
31084 your receipt of the notice.
31086 Termination of your rights under this section does not terminate the
31087 licenses of parties who have received copies or rights from you under
31088 this License.  If your rights have been terminated and not permanently
31089 reinstated, receipt of a copy of some or all of the same material does
31090 not give you any rights to use it.
31092 `10. FUTURE REVISIONS OF THIS LICENSE'
31094 The Free Software Foundation may publish new, revised versions
31095 of the GNU Free Documentation License from time to time.  Such new
31096 versions will be similar in spirit to the present version, but may
31097 differ in detail to address new problems or concerns.  See
31098 @indicateurl{https://www.gnu.org/copyleft/}.
31100 Each version of the License is given a distinguishing version number.
31101 If the Document specifies that a particular numbered version of this
31102 License “or any later version” applies to it, you have the option of
31103 following the terms and conditions either of that specified version or
31104 of any later version that has been published (not as a draft) by the
31105 Free Software Foundation.  If the Document does not specify a version
31106 number of this License, you may choose any version ever published (not
31107 as a draft) by the Free Software Foundation.  If the Document
31108 specifies that a proxy can decide which future versions of this
31109 License can be used, that proxy’s public statement of acceptance of a
31110 version permanently authorizes you to choose that version for the
31111 Document.
31113 `11. RELICENSING'
31115 “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
31116 World Wide Web server that publishes copyrightable works and also
31117 provides prominent facilities for anybody to edit those works.  A
31118 public wiki that anybody can edit is an example of such a server.  A
31119 “Massive Multiauthor Collaboration” (or “MMC”) contained in the
31120 site means any set of copyrightable works thus published on the MMC
31121 site.
31123 “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
31124 license published by Creative Commons Corporation, a not-for-profit
31125 corporation with a principal place of business in San Francisco,
31126 California, as well as future copyleft versions of that license
31127 published by that same organization.
31129 “Incorporate” means to publish or republish a Document, in whole or
31130 in part, as part of another Document.
31132 An MMC is “eligible for relicensing” if it is licensed under this
31133 License, and if all works that were first published under this License
31134 somewhere other than this MMC, and subsequently incorporated in whole
31135 or in part into the MMC, (1) had no cover texts or invariant sections,
31136 and (2) were thus incorporated prior to November 1, 2008.
31138 The operator of an MMC Site may republish an MMC contained in the site
31139 under CC-BY-SA on the same site at any time before August 1, 2009,
31140 provided the MMC is eligible for relicensing.
31142 `ADDENDUM: How to use this License for your documents'
31144 To use this License in a document you have written, include a copy of
31145 the License in the document and put the following copyright and
31146 license notices just after the title page:
31148 @quotation
31150 Copyright © YEAR  YOUR NAME.
31151 Permission is granted to copy, distribute and/or modify this document
31152 under the terms of the GNU Free Documentation License, Version 1.3
31153 or any later version published by the Free Software Foundation;
31154 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
31155 A copy of the license is included in the section entitled “GNU
31156 Free Documentation License”.
31157 @end quotation
31159 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
31160 replace the “with … Texts.” line with this:
31162 @quotation
31164 with the Invariant Sections being LIST THEIR TITLES, with the
31165 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
31166 @end quotation
31168 If you have Invariant Sections without Cover Texts, or some other
31169 combination of the three, merge those two alternatives to suit the
31170 situation.
31172 If your document contains nontrivial examples of program code, we
31173 recommend releasing these examples in parallel under your choice of
31174 free software license, such as the GNU General Public License,
31175 to permit their use in free software.
31177 @node Index,,GNU Free Documentation License,Top
31178 @unnumbered Index
31181 @printindex ge
31184 @c %**end of body
31185 @bye