hppa: Revise REG+D address support to allow long displacements before reload
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob52ddb27fd014fe481bf63e35536700e1c9b79ac8
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 , Oct 26, 2023
24 AdaCore
26 Copyright @copyright{} 2008-2023, 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 Annotate:: 
110 * Pragma Assert:: 
111 * Pragma Assert_And_Cut:: 
112 * Pragma Assertion_Policy:: 
113 * Pragma Assume:: 
114 * Pragma Assume_No_Invalid_Values:: 
115 * Pragma Async_Readers:: 
116 * Pragma Async_Writers:: 
117 * Pragma Attribute_Definition:: 
118 * Pragma C_Pass_By_Copy:: 
119 * Pragma Check:: 
120 * Pragma Check_Float_Overflow:: 
121 * Pragma Check_Name:: 
122 * Pragma Check_Policy:: 
123 * Pragma Comment:: 
124 * Pragma Common_Object:: 
125 * Pragma Compile_Time_Error:: 
126 * Pragma Compile_Time_Warning:: 
127 * Pragma Complete_Representation:: 
128 * Pragma Complex_Representation:: 
129 * Pragma Component_Alignment:: 
130 * Pragma Constant_After_Elaboration:: 
131 * Pragma Contract_Cases:: 
132 * Pragma Convention_Identifier:: 
133 * Pragma CPP_Class:: 
134 * Pragma CPP_Constructor:: 
135 * Pragma CPP_Virtual:: 
136 * Pragma CPP_Vtable:: 
137 * Pragma CPU:: 
138 * Pragma Deadline_Floor:: 
139 * Pragma Debug:: 
140 * Pragma Debug_Policy:: 
141 * Pragma Default_Initial_Condition:: 
142 * Pragma Default_Scalar_Storage_Order:: 
143 * Pragma Default_Storage_Pool:: 
144 * Pragma Depends:: 
145 * Pragma Detect_Blocking:: 
146 * Pragma Disable_Atomic_Synchronization:: 
147 * Pragma Dispatching_Domain:: 
148 * Pragma Effective_Reads:: 
149 * Pragma Effective_Writes:: 
150 * Pragma Elaboration_Checks:: 
151 * Pragma Eliminate:: 
152 * Pragma Enable_Atomic_Synchronization:: 
153 * Pragma Export_Function:: 
154 * Pragma Export_Object:: 
155 * Pragma Export_Procedure:: 
156 * Pragma Export_Valued_Procedure:: 
157 * Pragma Extend_System:: 
158 * Pragma Extensions_Allowed:: 
159 * Pragma Extensions_Visible:: 
160 * Pragma External:: 
161 * Pragma External_Name_Casing:: 
162 * Pragma Fast_Math:: 
163 * Pragma Favor_Top_Level:: 
164 * Pragma Finalize_Storage_Only:: 
165 * Pragma Float_Representation:: 
166 * Pragma Ghost:: 
167 * Pragma Global:: 
168 * Pragma Ident:: 
169 * Pragma Ignore_Pragma:: 
170 * Pragma Implementation_Defined:: 
171 * Pragma Implemented:: 
172 * Pragma Implicit_Packing:: 
173 * Pragma Import_Function:: 
174 * Pragma Import_Object:: 
175 * Pragma Import_Procedure:: 
176 * Pragma Import_Valued_Procedure:: 
177 * Pragma Independent:: 
178 * Pragma Independent_Components:: 
179 * Pragma Initial_Condition:: 
180 * Pragma Initialize_Scalars:: 
181 * Pragma Initializes:: 
182 * Pragma Inline_Always:: 
183 * Pragma Inline_Generic:: 
184 * Pragma Interface:: 
185 * Pragma Interface_Name:: 
186 * Pragma Interrupt_Handler:: 
187 * Pragma Interrupt_State:: 
188 * Pragma Invariant:: 
189 * Pragma Keep_Names:: 
190 * Pragma License:: 
191 * Pragma Link_With:: 
192 * Pragma Linker_Alias:: 
193 * Pragma Linker_Constructor:: 
194 * Pragma Linker_Destructor:: 
195 * Pragma Linker_Section:: 
196 * Pragma Lock_Free:: 
197 * Pragma Loop_Invariant:: 
198 * Pragma Loop_Optimize:: 
199 * Pragma Loop_Variant:: 
200 * Pragma Machine_Attribute:: 
201 * Pragma Main:: 
202 * Pragma Main_Storage:: 
203 * Pragma Max_Queue_Length:: 
204 * Pragma No_Body:: 
205 * Pragma No_Caching:: 
206 * Pragma No_Component_Reordering:: 
207 * Pragma No_Elaboration_Code_All:: 
208 * Pragma No_Heap_Finalization:: 
209 * Pragma No_Inline:: 
210 * Pragma No_Return:: 
211 * Pragma No_Strict_Aliasing:: 
212 * Pragma No_Tagged_Streams:: 
213 * Pragma Normalize_Scalars:: 
214 * Pragma Obsolescent:: 
215 * Pragma Optimize_Alignment:: 
216 * Pragma Ordered:: 
217 * Pragma Overflow_Mode:: 
218 * Pragma Overriding_Renamings:: 
219 * Pragma Part_Of:: 
220 * Pragma Partition_Elaboration_Policy:: 
221 * Pragma Passive:: 
222 * Pragma Persistent_BSS:: 
223 * Pragma Post:: 
224 * Pragma Postcondition:: 
225 * Pragma Post_Class:: 
226 * Pragma Pre:: 
227 * Pragma Precondition:: 
228 * Pragma Predicate:: 
229 * Pragma Predicate_Failure:: 
230 * Pragma Preelaborable_Initialization:: 
231 * Pragma Prefix_Exception_Messages:: 
232 * Pragma Pre_Class:: 
233 * Pragma Priority_Specific_Dispatching:: 
234 * Pragma Profile:: 
235 * Pragma Profile_Warnings:: 
236 * Pragma Propagate_Exceptions:: 
237 * Pragma Provide_Shift_Operators:: 
238 * Pragma Psect_Object:: 
239 * Pragma Pure_Function:: 
240 * Pragma Rational:: 
241 * Pragma Ravenscar:: 
242 * Pragma Refined_Depends:: 
243 * Pragma Refined_Global:: 
244 * Pragma Refined_Post:: 
245 * Pragma Refined_State:: 
246 * Pragma Relative_Deadline:: 
247 * Pragma Remote_Access_Type:: 
248 * Pragma Rename_Pragma:: 
249 * Pragma Restricted_Run_Time:: 
250 * Pragma Restriction_Warnings:: 
251 * Pragma Reviewable:: 
252 * Pragma Secondary_Stack_Size:: 
253 * Pragma Share_Generic:: 
254 * Pragma Shared:: 
255 * Pragma Short_Circuit_And_Or:: 
256 * Pragma Short_Descriptors:: 
257 * Pragma Side_Effects:: 
258 * Pragma Simple_Storage_Pool_Type:: 
259 * Pragma Source_File_Name:: 
260 * Pragma Source_File_Name_Project:: 
261 * Pragma Source_Reference:: 
262 * Pragma SPARK_Mode:: 
263 * Pragma Static_Elaboration_Desired:: 
264 * Pragma Stream_Convert:: 
265 * Pragma Style_Checks:: 
266 * Pragma Subtitle:: 
267 * Pragma Suppress:: 
268 * Pragma Suppress_All:: 
269 * Pragma Suppress_Debug_Info:: 
270 * Pragma Suppress_Exception_Locations:: 
271 * Pragma Suppress_Initialization:: 
272 * Pragma Task_Name:: 
273 * Pragma Task_Storage:: 
274 * Pragma Test_Case:: 
275 * Pragma Thread_Local_Storage:: 
276 * Pragma Time_Slice:: 
277 * Pragma Title:: 
278 * Pragma Type_Invariant:: 
279 * Pragma Type_Invariant_Class:: 
280 * Pragma Unchecked_Union:: 
281 * Pragma Unevaluated_Use_Of_Old:: 
282 * Pragma User_Aspect_Definition:: 
283 * Pragma Unimplemented_Unit:: 
284 * Pragma Universal_Aliasing:: 
285 * Pragma Unmodified:: 
286 * Pragma Unreferenced:: 
287 * Pragma Unreferenced_Objects:: 
288 * Pragma Unreserve_All_Interrupts:: 
289 * Pragma Unsuppress:: 
290 * Pragma Unused:: 
291 * Pragma Use_VADS_Size:: 
292 * Pragma Validity_Checks:: 
293 * Pragma Volatile:: 
294 * Pragma Volatile_Full_Access:: 
295 * Pragma Volatile_Function:: 
296 * Pragma Warning_As_Error:: 
297 * Pragma Warnings:: 
298 * Pragma Weak_External:: 
299 * Pragma Wide_Character_Encoding:: 
301 Implementation Defined Aspects
303 * Aspect Abstract_State:: 
304 * Aspect Annotate:: 
305 * Aspect Async_Readers:: 
306 * Aspect Async_Writers:: 
307 * Aspect Constant_After_Elaboration:: 
308 * Aspect Contract_Cases:: 
309 * Aspect Depends:: 
310 * Aspect Default_Initial_Condition:: 
311 * Aspect Dimension:: 
312 * Aspect Dimension_System:: 
313 * Aspect Disable_Controlled:: 
314 * Aspect Effective_Reads:: 
315 * Aspect Effective_Writes:: 
316 * Aspect Extensions_Visible:: 
317 * Aspect Favor_Top_Level:: 
318 * Aspect Ghost:: 
319 * Aspect Ghost_Predicate:: 
320 * Aspect Global:: 
321 * Aspect Initial_Condition:: 
322 * Aspect Initializes:: 
323 * Aspect Inline_Always:: 
324 * Aspect Invariant:: 
325 * Aspect Invariant’Class:: 
326 * Aspect Iterable:: 
327 * Aspect Linker_Section:: 
328 * Aspect Local_Restrictions:: 
329 * Aspect Lock_Free:: 
330 * Aspect Max_Queue_Length:: 
331 * Aspect No_Caching:: 
332 * Aspect No_Elaboration_Code_All:: 
333 * Aspect No_Inline:: 
334 * Aspect No_Tagged_Streams:: 
335 * Aspect No_Task_Parts:: 
336 * Aspect Object_Size:: 
337 * Aspect Obsolescent:: 
338 * Aspect Part_Of:: 
339 * Aspect Persistent_BSS:: 
340 * Aspect Predicate:: 
341 * Aspect Pure_Function:: 
342 * Aspect Refined_Depends:: 
343 * Aspect Refined_Global:: 
344 * Aspect Refined_Post:: 
345 * Aspect Refined_State:: 
346 * Aspect Relaxed_Initialization:: 
347 * Aspect Remote_Access_Type:: 
348 * Aspect Secondary_Stack_Size:: 
349 * Aspect Scalar_Storage_Order:: 
350 * Aspect Shared:: 
351 * Aspect Side_Effects:: 
352 * Aspect Simple_Storage_Pool:: 
353 * Aspect Simple_Storage_Pool_Type:: 
354 * Aspect SPARK_Mode:: 
355 * Aspect Suppress_Debug_Info:: 
356 * Aspect Suppress_Initialization:: 
357 * Aspect Test_Case:: 
358 * Aspect Thread_Local_Storage:: 
359 * Aspect Universal_Aliasing:: 
360 * Aspect Unmodified:: 
361 * Aspect Unreferenced:: 
362 * Aspect Unreferenced_Objects:: 
363 * Aspect User_Aspect:: 
364 * Aspect Value_Size:: 
365 * Aspect Volatile_Full_Access:: 
366 * Aspect Volatile_Function:: 
367 * Aspect Warnings:: 
369 Implementation Defined Attributes
371 * Attribute Abort_Signal:: 
372 * Attribute Address_Size:: 
373 * Attribute Asm_Input:: 
374 * Attribute Asm_Output:: 
375 * Attribute Atomic_Always_Lock_Free:: 
376 * Attribute Bit:: 
377 * Attribute Bit_Position:: 
378 * Attribute Code_Address:: 
379 * Attribute Compiler_Version:: 
380 * Attribute Constrained:: 
381 * Attribute Default_Bit_Order:: 
382 * Attribute Default_Scalar_Storage_Order:: 
383 * Attribute Deref:: 
384 * Attribute Descriptor_Size:: 
385 * Attribute Elaborated:: 
386 * Attribute Elab_Body:: 
387 * Attribute Elab_Spec:: 
388 * Attribute Elab_Subp_Body:: 
389 * Attribute Emax:: 
390 * Attribute Enabled:: 
391 * Attribute Enum_Rep:: 
392 * Attribute Enum_Val:: 
393 * Attribute Epsilon:: 
394 * Attribute Fast_Math:: 
395 * Attribute Finalization_Size:: 
396 * Attribute Fixed_Value:: 
397 * Attribute From_Any:: 
398 * Attribute Has_Access_Values:: 
399 * Attribute Has_Discriminants:: 
400 * Attribute Has_Tagged_Values:: 
401 * Attribute Img:: 
402 * Attribute Initialized:: 
403 * Attribute Integer_Value:: 
404 * Attribute Invalid_Value:: 
405 * Attribute Iterable:: 
406 * Attribute Large:: 
407 * Attribute Library_Level:: 
408 * Attribute Loop_Entry:: 
409 * Attribute Machine_Size:: 
410 * Attribute Mantissa:: 
411 * Attribute Maximum_Alignment:: 
412 * Attribute Max_Integer_Size:: 
413 * Attribute Mechanism_Code:: 
414 * Attribute Null_Parameter:: 
415 * Attribute Object_Size:: 
416 * Attribute Old:: 
417 * Attribute Passed_By_Reference:: 
418 * Attribute Pool_Address:: 
419 * Attribute Range_Length:: 
420 * Attribute Restriction_Set:: 
421 * Attribute Result:: 
422 * Attribute Safe_Emax:: 
423 * Attribute Safe_Large:: 
424 * Attribute Safe_Small:: 
425 * Attribute Scalar_Storage_Order:: 
426 * Attribute Simple_Storage_Pool:: 
427 * Attribute Small:: 
428 * Attribute Small_Denominator:: 
429 * Attribute Small_Numerator:: 
430 * Attribute Storage_Unit:: 
431 * Attribute Stub_Type:: 
432 * Attribute System_Allocator_Alignment:: 
433 * Attribute Target_Name:: 
434 * Attribute To_Address:: 
435 * Attribute To_Any:: 
436 * Attribute Type_Class:: 
437 * Attribute Type_Key:: 
438 * Attribute TypeCode:: 
439 * Attribute Unconstrained_Array:: 
440 * Attribute Universal_Literal_String:: 
441 * Attribute Unrestricted_Access:: 
442 * Attribute Update:: 
443 * Attribute Valid_Value:: 
444 * Attribute Valid_Scalars:: 
445 * Attribute VADS_Size:: 
446 * Attribute Value_Size:: 
447 * Attribute Wchar_T_Size:: 
448 * Attribute Word_Size:: 
450 Standard and Implementation Defined Restrictions
452 * Partition-Wide Restrictions:: 
453 * Program Unit Level Restrictions:: 
455 Partition-Wide Restrictions
457 * Immediate_Reclamation:: 
458 * Max_Asynchronous_Select_Nesting:: 
459 * Max_Entry_Queue_Length:: 
460 * Max_Protected_Entries:: 
461 * Max_Select_Alternatives:: 
462 * Max_Storage_At_Blocking:: 
463 * Max_Task_Entries:: 
464 * Max_Tasks:: 
465 * No_Abort_Statements:: 
466 * No_Access_Parameter_Allocators:: 
467 * No_Access_Subprograms:: 
468 * No_Allocators:: 
469 * No_Anonymous_Allocators:: 
470 * No_Asynchronous_Control:: 
471 * No_Calendar:: 
472 * No_Coextensions:: 
473 * No_Default_Initialization:: 
474 * No_Delay:: 
475 * No_Dependence:: 
476 * No_Direct_Boolean_Operators:: 
477 * No_Dispatch:: 
478 * No_Dispatching_Calls:: 
479 * No_Dynamic_Attachment:: 
480 * No_Dynamic_Priorities:: 
481 * No_Entry_Calls_In_Elaboration_Code:: 
482 * No_Enumeration_Maps:: 
483 * No_Exception_Handlers:: 
484 * No_Exception_Propagation:: 
485 * No_Exception_Registration:: 
486 * No_Exceptions:: 
487 * No_Finalization:: 
488 * No_Fixed_Point:: 
489 * No_Floating_Point:: 
490 * No_Implicit_Conditionals:: 
491 * No_Implicit_Dynamic_Code:: 
492 * No_Implicit_Heap_Allocations:: 
493 * No_Implicit_Protected_Object_Allocations:: 
494 * No_Implicit_Task_Allocations:: 
495 * No_Initialize_Scalars:: 
496 * No_IO:: 
497 * No_Local_Allocators:: 
498 * No_Local_Protected_Objects:: 
499 * No_Local_Tagged_Types:: 
500 * No_Local_Timing_Events:: 
501 * No_Long_Long_Integers:: 
502 * No_Multiple_Elaboration:: 
503 * No_Nested_Finalization:: 
504 * No_Protected_Type_Allocators:: 
505 * No_Protected_Types:: 
506 * No_Recursion:: 
507 * No_Reentrancy:: 
508 * No_Relative_Delay:: 
509 * No_Requeue_Statements:: 
510 * No_Secondary_Stack:: 
511 * No_Select_Statements:: 
512 * No_Specific_Termination_Handlers:: 
513 * No_Specification_of_Aspect:: 
514 * No_Standard_Allocators_After_Elaboration:: 
515 * No_Standard_Storage_Pools:: 
516 * No_Stream_Optimizations:: 
517 * No_Streams:: 
518 * No_Tagged_Type_Registration:: 
519 * No_Task_Allocators:: 
520 * No_Task_At_Interrupt_Priority:: 
521 * No_Task_Attributes_Package:: 
522 * No_Task_Hierarchy:: 
523 * No_Task_Termination:: 
524 * No_Tasking:: 
525 * No_Terminate_Alternatives:: 
526 * No_Unchecked_Access:: 
527 * No_Unchecked_Conversion:: 
528 * No_Unchecked_Deallocation:: 
529 * No_Use_Of_Attribute:: 
530 * No_Use_Of_Entity:: 
531 * No_Use_Of_Pragma:: 
532 * Pure_Barriers:: 
533 * Simple_Barriers:: 
534 * Static_Priorities:: 
535 * Static_Storage_Size:: 
537 Program Unit Level Restrictions
539 * No_Elaboration_Code:: 
540 * No_Dynamic_Accessibility_Checks:: 
541 * No_Dynamic_Sized_Objects:: 
542 * No_Entry_Queue:: 
543 * No_Implementation_Aspect_Specifications:: 
544 * No_Implementation_Attributes:: 
545 * No_Implementation_Identifiers:: 
546 * No_Implementation_Pragmas:: 
547 * No_Implementation_Restrictions:: 
548 * No_Implementation_Units:: 
549 * No_Implicit_Aliasing:: 
550 * No_Implicit_Loops:: 
551 * No_Obsolescent_Features:: 
552 * No_Wide_Characters:: 
553 * Static_Dispatch_Tables:: 
554 * SPARK_05:: 
556 Implementation Advice
558 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection. 
559 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units. 
560 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors. 
561 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas. 
562 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas. 
563 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets. 
564 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types. 
565 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types. 
566 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values. 
567 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types. 
568 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays. 
569 * RM 9.6(30-31); Duration’Small: RM 9 6 30-31 Duration’Small. 
570 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation. 
571 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information. 
572 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks. 
573 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses. 
574 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types. 
575 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses. 
576 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses. 
577 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses. 
578 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses. 
579 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses. 
580 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses. 
581 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses. 
582 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes. 
583 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering. 
584 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private. 
585 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations. 
586 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion. 
587 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage. 
588 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation. 
589 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes. 
590 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types. 
591 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling. 
592 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling. 
593 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation. 
594 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate. 
595 * RM A.18; Containers: RM A 18 Containers. 
596 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export. 
597 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces. 
598 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C. 
599 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL. 
600 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran. 
601 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations. 
602 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations. 
603 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support. 
604 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers. 
605 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts. 
606 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements. 
607 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names. 
608 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes. 
609 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies. 
610 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies. 
611 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort. 
612 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions. 
613 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time. 
614 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem. 
615 * RM F(7); COBOL Support: RM F 7 COBOL Support. 
616 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support. 
617 * RM G; Numerics: RM G Numerics. 
618 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types. 
619 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions. 
620 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements. 
621 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy. 
622 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy. 
624 Intrinsic Subprograms
626 * Intrinsic Operators:: 
627 * Compilation_ISO_Date:: 
628 * Compilation_Date:: 
629 * Compilation_Time:: 
630 * Enclosing_Entity:: 
631 * Exception_Information:: 
632 * Exception_Message:: 
633 * Exception_Name:: 
634 * File:: 
635 * Line:: 
636 * Shifts and Rotates:: 
637 * Source_Location:: 
639 Representation Clauses and Pragmas
641 * Alignment Clauses:: 
642 * Size Clauses:: 
643 * Storage_Size Clauses:: 
644 * Size of Variant Record Objects:: 
645 * Biased Representation:: 
646 * Value_Size and Object_Size Clauses:: 
647 * Component_Size Clauses:: 
648 * Bit_Order Clauses:: 
649 * Effect of Bit_Order on Byte Ordering:: 
650 * Pragma Pack for Arrays:: 
651 * Pragma Pack for Records:: 
652 * Record Representation Clauses:: 
653 * Handling of Records with Holes:: 
654 * Enumeration Clauses:: 
655 * Address Clauses:: 
656 * Use of Address Clauses for Memory-Mapped I/O:: 
657 * Effect of Convention on Representation:: 
658 * Conventions and Anonymous Access Types:: 
659 * Determining the Representations chosen by GNAT:: 
661 The Implementation of Standard I/O
663 * Standard I/O Packages:: 
664 * FORM Strings:: 
665 * Direct_IO:: 
666 * Sequential_IO:: 
667 * Text_IO:: 
668 * Wide_Text_IO:: 
669 * Wide_Wide_Text_IO:: 
670 * Stream_IO:: 
671 * Text Translation:: 
672 * Shared Files:: 
673 * Filenames encoding:: 
674 * File content encoding:: 
675 * Open Modes:: 
676 * Operations on C Streams:: 
677 * Interfacing to C Streams:: 
679 Text_IO
681 * Stream Pointer Positioning:: 
682 * Reading and Writing Non-Regular Files:: 
683 * Get_Immediate:: 
684 * Treating Text_IO Files as Streams:: 
685 * Text_IO Extensions:: 
686 * Text_IO Facilities for Unbounded Strings:: 
688 Wide_Text_IO
690 * Stream Pointer Positioning: Stream Pointer Positioning<2>. 
691 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>. 
693 Wide_Wide_Text_IO
695 * Stream Pointer Positioning: Stream Pointer Positioning<3>. 
696 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>. 
698 The GNAT Library
700 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads. 
701 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads. 
702 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads): Ada Characters Wide_Latin_9 a-cwila9 ads. 
703 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads. 
704 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads. 
705 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads. 
706 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads. 
707 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads. 
708 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads. 
709 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads. 
710 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads. 
711 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads. 
712 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads. 
713 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads. 
714 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads. 
715 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads. 
716 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads. 
717 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads. 
718 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads. 
719 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads. 
720 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads. 
721 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads. 
722 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads. 
723 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads. 
724 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads. 
725 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads. 
726 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads. 
727 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads. 
728 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads. 
729 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads. 
730 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads. 
731 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads. 
732 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads. 
733 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads. 
734 * GNAT.Binary_Search (g-binsea.ads): GNAT Binary_Search g-binsea ads. 
735 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads. 
736 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads. 
737 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads. 
738 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads. 
739 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads. 
740 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads. 
741 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads. 
742 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads. 
743 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads. 
744 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads. 
745 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads. 
746 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads. 
747 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads. 
748 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads. 
749 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads. 
750 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads. 
751 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads. 
752 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads. 
753 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads. 
754 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads. 
755 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads. 
756 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads. 
757 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads. 
758 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads. 
759 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads. 
760 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads. 
761 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads. 
762 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads. 
763 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads. 
764 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads. 
765 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads. 
766 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads. 
767 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads. 
768 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads. 
769 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads. 
770 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads. 
771 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads. 
772 * GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads): GNAT Generic_Fast_Math_Functions g-gfmafu ads. 
773 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads. 
774 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads. 
775 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads. 
776 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads. 
777 * GNAT.IO (g-io.ads): GNAT IO g-io ads. 
778 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads. 
779 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads. 
780 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads. 
781 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads. 
782 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads. 
783 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads. 
784 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads. 
785 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads. 
786 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads. 
787 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads. 
788 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads. 
789 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads. 
790 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads. 
791 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads. 
792 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads. 
793 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads. 
794 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads. 
795 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads. 
796 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads. 
797 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads. 
798 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads. 
799 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads. 
800 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads. 
801 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads. 
802 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads. 
803 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads. 
804 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads. 
805 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads. 
806 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads. 
807 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads. 
808 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads. 
809 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads. 
810 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads. 
811 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads. 
812 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads. 
813 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads. 
814 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads. 
815 * GNAT.Table (g-table.ads): GNAT Table g-table ads. 
816 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads. 
817 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads. 
818 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads. 
819 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads. 
820 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads. 
821 * GNAT.UTF_32 (g-utf_32.ads): GNAT UTF_32 g-utf_32 ads. 
822 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads): GNAT UTF_32_Spelling_Checker g-u3spch ads. 
823 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads. 
824 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads. 
825 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads. 
826 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads. 
827 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads. 
828 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads. 
829 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads. 
830 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads. 
831 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads. 
832 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads. 
833 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads. 
834 * System.Assertions (s-assert.ads): System Assertions s-assert ads. 
835 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads. 
836 * System.Memory (s-memory.ads): System Memory s-memory ads. 
837 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads. 
838 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads. 
839 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads. 
840 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads. 
841 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads. 
842 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads. 
843 * System.Rident (s-rident.ads): System Rident s-rident ads. 
844 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads. 
845 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads. 
846 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads. 
847 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads. 
849 Interfacing to Other Languages
851 * Interfacing to C:: 
852 * Interfacing to C++:: 
853 * Interfacing to COBOL:: 
854 * Interfacing to Fortran:: 
855 * Interfacing to non-GNAT Ada code:: 
857 Implementation of Specific Ada Features
859 * Machine Code Insertions:: 
860 * GNAT Implementation of Tasking:: 
861 * GNAT Implementation of Shared Passive Packages:: 
862 * Code Generation for Array Aggregates:: 
863 * The Size of Discriminated Records with Default Discriminants:: 
864 * Image Values For Nonscalar Types:: 
865 * Strict Conformance to the Ada Reference Manual:: 
867 GNAT Implementation of Tasking
869 * Mapping Ada Tasks onto the Underlying Kernel Threads:: 
870 * Ensuring Compliance with the Real-Time Annex:: 
871 * Support for Locking Policies:: 
873 Code Generation for Array Aggregates
875 * Static constant aggregates with static bounds:: 
876 * Constant aggregates with unconstrained nominal types:: 
877 * Aggregates with static bounds:: 
878 * Aggregates with nonstatic bounds:: 
879 * Aggregates in assignment statements:: 
881 GNAT language extensions
883 * How to activate the extended GNAT Ada superset:: 
884 * Curated Extensions:: 
885 * Experimental Language Extensions:: 
887 Curated Extensions
889 * Local Declarations Without Block:: 
890 * Conditional when constructs:: 
891 * Case pattern matching:: 
892 * Fixed lower bounds for array types and subtypes:: 
893 * Prefixed-view notation for calls to primitive subprograms of untagged types:: 
894 * Expression defaults for generic formal functions:: 
895 * String interpolation:: 
896 * Constrained attribute for generic objects:: 
897 * Static aspect on intrinsic functions:: 
899 Experimental Language Extensions
901 * Pragma Storage_Model:: 
902 * Simpler accessibility model:: 
904 Security Hardening Features
906 * Register Scrubbing:: 
907 * Stack Scrubbing:: 
908 * Hardened Conditionals:: 
909 * Hardened Booleans:: 
910 * Control Flow Redundancy:: 
912 Obsolescent Features
914 * pragma No_Run_Time:: 
915 * pragma Ravenscar:: 
916 * pragma Restricted_Run_Time:: 
917 * pragma Task_Info:: 
918 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads. 
920 Compatibility and Porting Guide
922 * Writing Portable Fixed-Point Declarations:: 
923 * Compatibility with Ada 83:: 
924 * Compatibility between Ada 95 and Ada 2005:: 
925 * Implementation-dependent characteristics:: 
926 * Compatibility with Other Ada Systems:: 
927 * Representation Clauses:: 
928 * Compatibility with HP Ada 83:: 
930 Compatibility with Ada 83
932 * Legal Ada 83 programs that are illegal in Ada 95:: 
933 * More deterministic semantics:: 
934 * Changed semantics:: 
935 * Other language compatibility issues:: 
937 Implementation-dependent characteristics
939 * Implementation-defined pragmas:: 
940 * Implementation-defined attributes:: 
941 * Libraries:: 
942 * Elaboration order:: 
943 * Target-specific aspects:: 
945 @end detailmenu
946 @end menu
948 @node About This Guide,Implementation Defined Pragmas,Top,Top
949 @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}
950 @chapter About This Guide
954 This manual contains useful information in writing programs using the
955 GNAT compiler.  It includes information on implementation dependent
956 characteristics of GNAT, including all the information required by
957 Annex M of the Ada language standard.
959 GNAT implements Ada 95, Ada 2005 and Ada 2012, and it may also be
960 invoked in Ada 83 compatibility mode.
961 By default, GNAT assumes Ada 2012,
962 but you can override with a compiler switch
963 to explicitly specify the language version.
964 (Please refer to the `GNAT User’s Guide' for details on these switches.)
965 Throughout this manual, references to ‘Ada’ without a year suffix
966 apply to all the Ada versions of the language.
968 Ada is designed to be highly portable.
969 In general, a program will have the same effect even when compiled by
970 different compilers on different platforms.
971 However, since Ada is designed to be used in a
972 wide variety of applications, it also contains a number of system
973 dependent features to be used in interfacing to the external world.
975 @geindex Implementation-dependent features
977 @geindex Portability
979 Note: Any program that makes use of implementation-dependent features
980 may be non-portable.  You should follow good programming practice and
981 isolate and clearly document any sections of your program that make use
982 of these features in a non-portable manner.
984 @menu
985 * What This Reference Manual Contains:: 
986 * Conventions:: 
987 * Related Information:: 
989 @end menu
991 @node What This Reference Manual Contains,Conventions,,About This Guide
992 @anchor{gnat_rm/about_this_guide what-this-reference-manual-contains}@anchor{6}
993 @section What This Reference Manual Contains
996 This reference manual contains the following chapters:
999 @itemize *
1001 @item 
1002 @ref{7,,Implementation Defined Pragmas}, lists GNAT implementation-dependent
1003 pragmas, which can be used to extend and enhance the functionality of the
1004 compiler.
1006 @item 
1007 @ref{8,,Implementation Defined Attributes}, lists GNAT
1008 implementation-dependent attributes, which can be used to extend and
1009 enhance the functionality of the compiler.
1011 @item 
1012 @ref{9,,Standard and Implementation Defined Restrictions}, lists GNAT
1013 implementation-dependent restrictions, which can be used to extend and
1014 enhance the functionality of the compiler.
1016 @item 
1017 @ref{a,,Implementation Advice}, provides information on generally
1018 desirable behavior which are not requirements that all compilers must
1019 follow since it cannot be provided on all systems, or which may be
1020 undesirable on some systems.
1022 @item 
1023 @ref{b,,Implementation Defined Characteristics}, provides a guide to
1024 minimizing implementation dependent features.
1026 @item 
1027 @ref{c,,Intrinsic Subprograms}, describes the intrinsic subprograms
1028 implemented by GNAT, and how they can be imported into user
1029 application programs.
1031 @item 
1032 @ref{d,,Representation Clauses and Pragmas}, describes in detail the
1033 way that GNAT represents data, and in particular the exact set
1034 of representation clauses and pragmas that is accepted.
1036 @item 
1037 @ref{e,,Standard Library Routines}, provides a listing of packages and a
1038 brief description of the functionality that is provided by Ada’s
1039 extensive set of standard library routines as implemented by GNAT.
1041 @item 
1042 @ref{f,,The Implementation of Standard I/O}, details how the GNAT
1043 implementation of the input-output facilities.
1045 @item 
1046 @ref{10,,The GNAT Library}, is a catalog of packages that complement
1047 the Ada predefined library.
1049 @item 
1050 @ref{11,,Interfacing to Other Languages}, describes how programs
1051 written in Ada using GNAT can be interfaced to other programming
1052 languages.
1054 @item 
1055 @ref{12,,Specialized Needs Annexes}, describes the GNAT implementation of all
1056 of the specialized needs annexes.
1058 @item 
1059 @ref{13,,Implementation of Specific Ada Features}, discusses issues related
1060 to GNAT’s implementation of machine code insertions, tasking, and several
1061 other features.
1063 @item 
1064 @ref{14,,Implementation of Ada 2012 Features}, describes the status of the
1065 GNAT implementation of the Ada 2012 language standard.
1067 @item 
1068 @ref{15,,Security Hardening Features} documents GNAT extensions aimed
1069 at security hardening.
1071 @item 
1072 @ref{16,,Obsolescent Features} documents implementation dependent features,
1073 including pragmas and attributes, which are considered obsolescent, since
1074 there are other preferred ways of achieving the same results. These
1075 obsolescent forms are retained for backwards compatibility.
1077 @item 
1078 @ref{17,,Compatibility and Porting Guide} presents some guidelines for
1079 developing portable Ada code, describes the compatibility issues that
1080 may arise between GNAT and other Ada compilation systems (including those
1081 for Ada 83), and shows how GNAT can expedite porting applications
1082 developed in other Ada environments.
1084 @item 
1085 @ref{1,,GNU Free Documentation License} contains the license for this document.
1086 @end itemize
1088 @geindex Ada 95 Language Reference Manual
1090 @geindex Ada 2005 Language Reference Manual
1092 This reference manual assumes a basic familiarity with the Ada 95 language, as
1093 described in the
1094 @cite{International Standard ANSI/ISO/IEC-8652:1995}.
1095 It does not require knowledge of the new features introduced by Ada 2005 or
1096 Ada 2012.
1097 All three reference manuals are included in the GNAT documentation
1098 package.
1100 @node Conventions,Related Information,What This Reference Manual Contains,About This Guide
1101 @anchor{gnat_rm/about_this_guide conventions}@anchor{18}
1102 @section Conventions
1105 @geindex Conventions
1106 @geindex typographical
1108 @geindex Typographical conventions
1110 Following are examples of the typographical and graphic conventions used
1111 in this guide:
1114 @itemize *
1116 @item 
1117 @code{Functions}, @code{utility program names}, @code{standard names},
1118 and @code{classes}.
1120 @item 
1121 @code{Option flags}
1123 @item 
1124 @code{File names}
1126 @item 
1127 @code{Variables}
1129 @item 
1130 `Emphasis'
1132 @item 
1133 [optional information or parameters]
1135 @item 
1136 Examples are described by text
1138 @example
1139 and then shown this way.
1140 @end example
1142 @item 
1143 Commands that are entered by the user are shown as preceded by a prompt string
1144 comprising the @code{$} character followed by a space.
1145 @end itemize
1147 @node Related Information,,Conventions,About This Guide
1148 @anchor{gnat_rm/about_this_guide related-information}@anchor{19}
1149 @section Related Information
1152 See the following documents for further information on GNAT:
1155 @itemize *
1157 @item 
1158 @cite{GNAT User’s Guide for Native Platforms},
1159 which provides information on how to use the
1160 GNAT development environment.
1162 @item 
1163 @cite{Ada 95 Reference Manual}, the Ada 95 programming language standard.
1165 @item 
1166 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
1167 of the Ada 95 standard.  The annotations describe
1168 detailed aspects of the design decision, and in particular contain useful
1169 sections on Ada 83 compatibility.
1171 @item 
1172 @cite{Ada 2005 Reference Manual}, the Ada 2005 programming language standard.
1174 @item 
1175 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
1176 of the Ada 2005 standard.  The annotations describe
1177 detailed aspects of the design decision.
1179 @item 
1180 @cite{Ada 2012 Reference Manual}, the Ada 2012 programming language standard.
1182 @item 
1183 @cite{DEC Ada@comma{} Technical Overview and Comparison on DIGITAL Platforms},
1184 which contains specific information on compatibility between GNAT and
1185 DEC Ada 83 systems.
1187 @item 
1188 @cite{DEC Ada@comma{} Language Reference Manual}, part number AA-PYZAB-TK, which
1189 describes in detail the pragmas and attributes provided by the DEC Ada 83
1190 compiler system.
1191 @end itemize
1193 @node Implementation Defined Pragmas,Implementation Defined Aspects,About This Guide,Top
1194 @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}
1195 @chapter Implementation Defined Pragmas
1198 Ada defines a set of pragmas that can be used to supply additional
1199 information to the compiler.  These language defined pragmas are
1200 implemented in GNAT and work as described in the Ada Reference Manual.
1202 In addition, Ada allows implementations to define additional pragmas
1203 whose meaning is defined by the implementation.  GNAT provides a number
1204 of these implementation-defined pragmas, which can be used to extend
1205 and enhance the functionality of the compiler.  This section of the GNAT
1206 Reference Manual describes these additional pragmas.
1208 Note that any program using these pragmas might not be portable to other
1209 compilers (although GNAT implements this set of pragmas on all
1210 platforms).  Therefore if portability to other compilers is an important
1211 consideration, the use of these pragmas should be minimized.
1213 @menu
1214 * Pragma Abort_Defer:: 
1215 * Pragma Abstract_State:: 
1216 * Pragma Ada_83:: 
1217 * Pragma Ada_95:: 
1218 * Pragma Ada_05:: 
1219 * Pragma Ada_2005:: 
1220 * Pragma Ada_12:: 
1221 * Pragma Ada_2012:: 
1222 * Pragma Ada_2022:: 
1223 * Pragma Aggregate_Individually_Assign:: 
1224 * Pragma Allow_Integer_Address:: 
1225 * Pragma Annotate:: 
1226 * Pragma Assert:: 
1227 * Pragma Assert_And_Cut:: 
1228 * Pragma Assertion_Policy:: 
1229 * Pragma Assume:: 
1230 * Pragma Assume_No_Invalid_Values:: 
1231 * Pragma Async_Readers:: 
1232 * Pragma Async_Writers:: 
1233 * Pragma Attribute_Definition:: 
1234 * Pragma C_Pass_By_Copy:: 
1235 * Pragma Check:: 
1236 * Pragma Check_Float_Overflow:: 
1237 * Pragma Check_Name:: 
1238 * Pragma Check_Policy:: 
1239 * Pragma Comment:: 
1240 * Pragma Common_Object:: 
1241 * Pragma Compile_Time_Error:: 
1242 * Pragma Compile_Time_Warning:: 
1243 * Pragma Complete_Representation:: 
1244 * Pragma Complex_Representation:: 
1245 * Pragma Component_Alignment:: 
1246 * Pragma Constant_After_Elaboration:: 
1247 * Pragma Contract_Cases:: 
1248 * Pragma Convention_Identifier:: 
1249 * Pragma CPP_Class:: 
1250 * Pragma CPP_Constructor:: 
1251 * Pragma CPP_Virtual:: 
1252 * Pragma CPP_Vtable:: 
1253 * Pragma CPU:: 
1254 * Pragma Deadline_Floor:: 
1255 * Pragma Debug:: 
1256 * Pragma Debug_Policy:: 
1257 * Pragma Default_Initial_Condition:: 
1258 * Pragma Default_Scalar_Storage_Order:: 
1259 * Pragma Default_Storage_Pool:: 
1260 * Pragma Depends:: 
1261 * Pragma Detect_Blocking:: 
1262 * Pragma Disable_Atomic_Synchronization:: 
1263 * Pragma Dispatching_Domain:: 
1264 * Pragma Effective_Reads:: 
1265 * Pragma Effective_Writes:: 
1266 * Pragma Elaboration_Checks:: 
1267 * Pragma Eliminate:: 
1268 * Pragma Enable_Atomic_Synchronization:: 
1269 * Pragma Export_Function:: 
1270 * Pragma Export_Object:: 
1271 * Pragma Export_Procedure:: 
1272 * Pragma Export_Valued_Procedure:: 
1273 * Pragma Extend_System:: 
1274 * Pragma Extensions_Allowed:: 
1275 * Pragma Extensions_Visible:: 
1276 * Pragma External:: 
1277 * Pragma External_Name_Casing:: 
1278 * Pragma Fast_Math:: 
1279 * Pragma Favor_Top_Level:: 
1280 * Pragma Finalize_Storage_Only:: 
1281 * Pragma Float_Representation:: 
1282 * Pragma Ghost:: 
1283 * Pragma Global:: 
1284 * Pragma Ident:: 
1285 * Pragma Ignore_Pragma:: 
1286 * Pragma Implementation_Defined:: 
1287 * Pragma Implemented:: 
1288 * Pragma Implicit_Packing:: 
1289 * Pragma Import_Function:: 
1290 * Pragma Import_Object:: 
1291 * Pragma Import_Procedure:: 
1292 * Pragma Import_Valued_Procedure:: 
1293 * Pragma Independent:: 
1294 * Pragma Independent_Components:: 
1295 * Pragma Initial_Condition:: 
1296 * Pragma Initialize_Scalars:: 
1297 * Pragma Initializes:: 
1298 * Pragma Inline_Always:: 
1299 * Pragma Inline_Generic:: 
1300 * Pragma Interface:: 
1301 * Pragma Interface_Name:: 
1302 * Pragma Interrupt_Handler:: 
1303 * Pragma Interrupt_State:: 
1304 * Pragma Invariant:: 
1305 * Pragma Keep_Names:: 
1306 * Pragma License:: 
1307 * Pragma Link_With:: 
1308 * Pragma Linker_Alias:: 
1309 * Pragma Linker_Constructor:: 
1310 * Pragma Linker_Destructor:: 
1311 * Pragma Linker_Section:: 
1312 * Pragma Lock_Free:: 
1313 * Pragma Loop_Invariant:: 
1314 * Pragma Loop_Optimize:: 
1315 * Pragma Loop_Variant:: 
1316 * Pragma Machine_Attribute:: 
1317 * Pragma Main:: 
1318 * Pragma Main_Storage:: 
1319 * Pragma Max_Queue_Length:: 
1320 * Pragma No_Body:: 
1321 * Pragma No_Caching:: 
1322 * Pragma No_Component_Reordering:: 
1323 * Pragma No_Elaboration_Code_All:: 
1324 * Pragma No_Heap_Finalization:: 
1325 * Pragma No_Inline:: 
1326 * Pragma No_Return:: 
1327 * Pragma No_Strict_Aliasing:: 
1328 * Pragma No_Tagged_Streams:: 
1329 * Pragma Normalize_Scalars:: 
1330 * Pragma Obsolescent:: 
1331 * Pragma Optimize_Alignment:: 
1332 * Pragma Ordered:: 
1333 * Pragma Overflow_Mode:: 
1334 * Pragma Overriding_Renamings:: 
1335 * Pragma Part_Of:: 
1336 * Pragma Partition_Elaboration_Policy:: 
1337 * Pragma Passive:: 
1338 * Pragma Persistent_BSS:: 
1339 * Pragma Post:: 
1340 * Pragma Postcondition:: 
1341 * Pragma Post_Class:: 
1342 * Pragma Pre:: 
1343 * Pragma Precondition:: 
1344 * Pragma Predicate:: 
1345 * Pragma Predicate_Failure:: 
1346 * Pragma Preelaborable_Initialization:: 
1347 * Pragma Prefix_Exception_Messages:: 
1348 * Pragma Pre_Class:: 
1349 * Pragma Priority_Specific_Dispatching:: 
1350 * Pragma Profile:: 
1351 * Pragma Profile_Warnings:: 
1352 * Pragma Propagate_Exceptions:: 
1353 * Pragma Provide_Shift_Operators:: 
1354 * Pragma Psect_Object:: 
1355 * Pragma Pure_Function:: 
1356 * Pragma Rational:: 
1357 * Pragma Ravenscar:: 
1358 * Pragma Refined_Depends:: 
1359 * Pragma Refined_Global:: 
1360 * Pragma Refined_Post:: 
1361 * Pragma Refined_State:: 
1362 * Pragma Relative_Deadline:: 
1363 * Pragma Remote_Access_Type:: 
1364 * Pragma Rename_Pragma:: 
1365 * Pragma Restricted_Run_Time:: 
1366 * Pragma Restriction_Warnings:: 
1367 * Pragma Reviewable:: 
1368 * Pragma Secondary_Stack_Size:: 
1369 * Pragma Share_Generic:: 
1370 * Pragma Shared:: 
1371 * Pragma Short_Circuit_And_Or:: 
1372 * Pragma Short_Descriptors:: 
1373 * Pragma Side_Effects:: 
1374 * Pragma Simple_Storage_Pool_Type:: 
1375 * Pragma Source_File_Name:: 
1376 * Pragma Source_File_Name_Project:: 
1377 * Pragma Source_Reference:: 
1378 * Pragma SPARK_Mode:: 
1379 * Pragma Static_Elaboration_Desired:: 
1380 * Pragma Stream_Convert:: 
1381 * Pragma Style_Checks:: 
1382 * Pragma Subtitle:: 
1383 * Pragma Suppress:: 
1384 * Pragma Suppress_All:: 
1385 * Pragma Suppress_Debug_Info:: 
1386 * Pragma Suppress_Exception_Locations:: 
1387 * Pragma Suppress_Initialization:: 
1388 * Pragma Task_Name:: 
1389 * Pragma Task_Storage:: 
1390 * Pragma Test_Case:: 
1391 * Pragma Thread_Local_Storage:: 
1392 * Pragma Time_Slice:: 
1393 * Pragma Title:: 
1394 * Pragma Type_Invariant:: 
1395 * Pragma Type_Invariant_Class:: 
1396 * Pragma Unchecked_Union:: 
1397 * Pragma Unevaluated_Use_Of_Old:: 
1398 * Pragma User_Aspect_Definition:: 
1399 * Pragma Unimplemented_Unit:: 
1400 * Pragma Universal_Aliasing:: 
1401 * Pragma Unmodified:: 
1402 * Pragma Unreferenced:: 
1403 * Pragma Unreferenced_Objects:: 
1404 * Pragma Unreserve_All_Interrupts:: 
1405 * Pragma Unsuppress:: 
1406 * Pragma Unused:: 
1407 * Pragma Use_VADS_Size:: 
1408 * Pragma Validity_Checks:: 
1409 * Pragma Volatile:: 
1410 * Pragma Volatile_Full_Access:: 
1411 * Pragma Volatile_Function:: 
1412 * Pragma Warning_As_Error:: 
1413 * Pragma Warnings:: 
1414 * Pragma Weak_External:: 
1415 * Pragma Wide_Character_Encoding:: 
1417 @end menu
1419 @node Pragma Abort_Defer,Pragma Abstract_State,,Implementation Defined Pragmas
1420 @anchor{gnat_rm/implementation_defined_pragmas pragma-abort-defer}@anchor{1c}
1421 @section Pragma Abort_Defer
1424 @geindex Deferring aborts
1426 Syntax:
1428 @example
1429 pragma Abort_Defer;
1430 @end example
1432 This pragma must appear at the start of the statement sequence of a
1433 handled sequence of statements (right after the @code{begin}).  It has
1434 the effect of deferring aborts for the sequence of statements (but not
1435 for the declarations or handlers, if any, associated with this statement
1436 sequence). This can also be useful for adding a polling point in Ada code,
1437 where asynchronous abort of tasks is checked when leaving the statement
1438 sequence, and is lighter than, for example, using @code{delay 0.0;}, since with
1439 zero-cost exception handling, propagating exceptions (implicitly used to
1440 implement task abort) cannot be done reliably in an asynchronous way.
1442 An example of usage would be:
1444 @example
1445 --  Add a polling point to check for task aborts
1447 begin
1448    pragma Abort_Defer;
1449 end;
1450 @end example
1452 @node Pragma Abstract_State,Pragma Ada_83,Pragma Abort_Defer,Implementation Defined Pragmas
1453 @anchor{gnat_rm/implementation_defined_pragmas id2}@anchor{1d}@anchor{gnat_rm/implementation_defined_pragmas pragma-abstract-state}@anchor{1e}
1454 @section Pragma Abstract_State
1457 Syntax:
1459 @example
1460 pragma Abstract_State (ABSTRACT_STATE_LIST);
1462 ABSTRACT_STATE_LIST ::=
1463      null
1464   |  STATE_NAME_WITH_OPTIONS
1465   | (STATE_NAME_WITH_OPTIONS @{, STATE_NAME_WITH_OPTIONS@} )
1467 STATE_NAME_WITH_OPTIONS ::=
1468      STATE_NAME
1469   | (STATE_NAME with OPTION_LIST)
1471 OPTION_LIST ::= OPTION @{, OPTION@}
1473 OPTION ::=
1474     SIMPLE_OPTION
1475   | NAME_VALUE_OPTION
1477 SIMPLE_OPTION ::= Ghost | Synchronous
1479 NAME_VALUE_OPTION ::=
1480     Part_Of => ABSTRACT_STATE
1481   | External [=> EXTERNAL_PROPERTY_LIST]
1483 EXTERNAL_PROPERTY_LIST ::=
1484      EXTERNAL_PROPERTY
1485   | (EXTERNAL_PROPERTY @{, EXTERNAL_PROPERTY@} )
1487 EXTERNAL_PROPERTY ::=
1488     Async_Readers    [=> static_boolean_EXPRESSION]
1489   | Async_Writers    [=> static_boolean_EXPRESSION]
1490   | Effective_Reads  [=> static_boolean_EXPRESSION]
1491   | Effective_Writes [=> static_boolean_EXPRESSION]
1492     others            => static_boolean_EXPRESSION
1494 STATE_NAME ::= defining_identifier
1496 ABSTRACT_STATE ::= name
1497 @end example
1499 For the semantics of this pragma, see the entry for aspect @code{Abstract_State} in
1500 the SPARK 2014 Reference Manual, section 7.1.4.
1502 @node Pragma Ada_83,Pragma Ada_95,Pragma Abstract_State,Implementation Defined Pragmas
1503 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-83}@anchor{1f}
1504 @section Pragma Ada_83
1507 Syntax:
1509 @example
1510 pragma Ada_83;
1511 @end example
1513 A configuration pragma that establishes Ada 83 mode for the unit to
1514 which it applies, regardless of the mode set by the command line
1515 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1516 the syntax and semantics of Ada 83, as defined in the original Ada
1517 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1518 and Ada 2005 are not recognized, optional package bodies are allowed,
1519 and generics may name types with unknown discriminants without using
1520 the @code{(<>)} notation.  In addition, some but not all of the additional
1521 restrictions of Ada 83 are enforced.
1523 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1524 Ada 83 code to be compiled and adapted to GNAT with less effort.
1525 Secondly, it aids in keeping code backwards compatible with Ada 83.
1526 However, there is no guarantee that code that is processed correctly
1527 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1528 83 compiler, since GNAT does not enforce all the additional checks
1529 required by Ada 83.
1531 @node Pragma Ada_95,Pragma Ada_05,Pragma Ada_83,Implementation Defined Pragmas
1532 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-95}@anchor{20}
1533 @section Pragma Ada_95
1536 Syntax:
1538 @example
1539 pragma Ada_95;
1540 @end example
1542 A configuration pragma that establishes Ada 95 mode for the unit to which
1543 it applies, regardless of the mode set by the command line switches.
1544 This mode is set automatically for the @code{Ada} and @code{System}
1545 packages and their children, so you need not specify it in these
1546 contexts.  This pragma is useful when writing a reusable component that
1547 itself uses Ada 95 features, but which is intended to be usable from
1548 either Ada 83 or Ada 95 programs.
1550 @node Pragma Ada_05,Pragma Ada_2005,Pragma Ada_95,Implementation Defined Pragmas
1551 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-05}@anchor{21}
1552 @section Pragma Ada_05
1555 Syntax:
1557 @example
1558 pragma Ada_05;
1559 pragma Ada_05 (local_NAME);
1560 @end example
1562 A configuration pragma that establishes Ada 2005 mode for the unit to which
1563 it applies, regardless of the mode set by the command line switches.
1564 This pragma is useful when writing a reusable component that
1565 itself uses Ada 2005 features, but which is intended to be usable from
1566 either Ada 83 or Ada 95 programs.
1568 The one argument form (which is not a configuration pragma)
1569 is used for managing the transition from
1570 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1571 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1572 mode will generate a warning. In addition, in Ada_83 or Ada_95
1573 mode, a preference rule is established which does not choose
1574 such an entity unless it is unambiguously specified. This avoids
1575 extra subprograms marked this way from generating ambiguities in
1576 otherwise legal pre-Ada_2005 programs. The one argument form is
1577 intended for exclusive use in the GNAT run-time library.
1579 @node Pragma Ada_2005,Pragma Ada_12,Pragma Ada_05,Implementation Defined Pragmas
1580 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2005}@anchor{22}
1581 @section Pragma Ada_2005
1584 Syntax:
1586 @example
1587 pragma Ada_2005;
1588 @end example
1590 This configuration pragma is a synonym for pragma Ada_05 and has the
1591 same syntax and effect.
1593 @node Pragma Ada_12,Pragma Ada_2012,Pragma Ada_2005,Implementation Defined Pragmas
1594 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-12}@anchor{23}
1595 @section Pragma Ada_12
1598 Syntax:
1600 @example
1601 pragma Ada_12;
1602 pragma Ada_12 (local_NAME);
1603 @end example
1605 A configuration pragma that establishes Ada 2012 mode for the unit to which
1606 it applies, regardless of the mode set by the command line switches.
1607 This mode is set automatically for the @code{Ada} and @code{System}
1608 packages and their children, so you need not specify it in these
1609 contexts.  This pragma is useful when writing a reusable component that
1610 itself uses Ada 2012 features, but which is intended to be usable from
1611 Ada 83, Ada 95, or Ada 2005 programs.
1613 The one argument form, which is not a configuration pragma,
1614 is used for managing the transition from Ada
1615 2005 to Ada 2012 in the run-time library. If an entity is marked
1616 as Ada_2012 only, then referencing the entity in any pre-Ada_2012
1617 mode will generate a warning. In addition, in any pre-Ada_2012
1618 mode, a preference rule is established which does not choose
1619 such an entity unless it is unambiguously specified. This avoids
1620 extra subprograms marked this way from generating ambiguities in
1621 otherwise legal pre-Ada_2012 programs. The one argument form is
1622 intended for exclusive use in the GNAT run-time library.
1624 @node Pragma Ada_2012,Pragma Ada_2022,Pragma Ada_12,Implementation Defined Pragmas
1625 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2012}@anchor{24}
1626 @section Pragma Ada_2012
1629 Syntax:
1631 @example
1632 pragma Ada_2012;
1633 @end example
1635 This configuration pragma is a synonym for pragma Ada_12 and has the
1636 same syntax and effect.
1638 @node Pragma Ada_2022,Pragma Aggregate_Individually_Assign,Pragma Ada_2012,Implementation Defined Pragmas
1639 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2022}@anchor{25}
1640 @section Pragma Ada_2022
1643 Syntax:
1645 @example
1646 pragma Ada_2022;
1647 pragma Ada_2022 (local_NAME);
1648 @end example
1650 A configuration pragma that establishes Ada 2022 mode for the unit to which
1651 it applies, regardless of the mode set by the command line switches.
1652 This mode is set automatically for the @code{Ada} and @code{System}
1653 packages and their children, so you need not specify it in these
1654 contexts.  This pragma is useful when writing a reusable component that
1655 itself uses Ada 2022 features, but which is intended to be usable from
1656 Ada 83, Ada 95, Ada 2005 or Ada 2012 programs.
1658 The one argument form, which is not a configuration pragma,
1659 is used for managing the transition from Ada
1660 2012 to Ada 2022 in the run-time library. If an entity is marked
1661 as Ada_2022 only, then referencing the entity in any pre-Ada_2022
1662 mode will generate a warning. In addition, in any pre-Ada_2012
1663 mode, a preference rule is established which does not choose
1664 such an entity unless it is unambiguously specified. This avoids
1665 extra subprograms marked this way from generating ambiguities in
1666 otherwise legal pre-Ada_2022 programs. The one argument form is
1667 intended for exclusive use in the GNAT run-time library.
1669 @node Pragma Aggregate_Individually_Assign,Pragma Allow_Integer_Address,Pragma Ada_2022,Implementation Defined Pragmas
1670 @anchor{gnat_rm/implementation_defined_pragmas pragma-aggregate-individually-assign}@anchor{26}
1671 @section Pragma Aggregate_Individually_Assign
1674 Syntax:
1676 @example
1677 pragma Aggregate_Individually_Assign;
1678 @end example
1680 Where possible, GNAT will store the binary representation of a record aggregate
1681 in memory for space and performance reasons. This configuration pragma changes
1682 this behavior so that record aggregates are instead always converted into
1683 individual assignment statements.
1685 @node Pragma Allow_Integer_Address,Pragma Annotate,Pragma Aggregate_Individually_Assign,Implementation Defined Pragmas
1686 @anchor{gnat_rm/implementation_defined_pragmas pragma-allow-integer-address}@anchor{27}
1687 @section Pragma Allow_Integer_Address
1690 Syntax:
1692 @example
1693 pragma Allow_Integer_Address;
1694 @end example
1696 In almost all versions of GNAT, @code{System.Address} is a private
1697 type in accordance with the implementation advice in the RM. This
1698 means that integer values,
1699 in particular integer literals, are not allowed as address values.
1700 If the configuration pragma
1701 @code{Allow_Integer_Address} is given, then integer expressions may
1702 be used anywhere a value of type @code{System.Address} is required.
1703 The effect is to introduce an implicit unchecked conversion from the
1704 integer value to type @code{System.Address}. The reverse case of using
1705 an address where an integer type is required is handled analogously.
1706 The following example compiles without errors:
1708 @example
1709 pragma Allow_Integer_Address;
1710 with System; use System;
1711 package AddrAsInt is
1712    X : Integer;
1713    Y : Integer;
1714    for X'Address use 16#1240#;
1715    for Y use at 16#3230#;
1716    m : Address := 16#4000#;
1717    n : constant Address := 4000;
1718    p : constant Address := Address (X + Y);
1719    v : Integer := y'Address;
1720    w : constant Integer := Integer (Y'Address);
1721    type R is new integer;
1722    RR : R := 1000;
1723    Z : Integer;
1724    for Z'Address use RR;
1725 end AddrAsInt;
1726 @end example
1728 Note that pragma @code{Allow_Integer_Address} is ignored if @code{System.Address}
1729 is not a private type. In implementations of @code{GNAT} where
1730 System.Address is a visible integer type,
1731 this pragma serves no purpose but is ignored
1732 rather than rejected to allow common sets of sources to be used
1733 in the two situations.
1735 @node Pragma Annotate,Pragma Assert,Pragma Allow_Integer_Address,Implementation Defined Pragmas
1736 @anchor{gnat_rm/implementation_defined_pragmas id3}@anchor{28}@anchor{gnat_rm/implementation_defined_pragmas pragma-annotate}@anchor{29}
1737 @section Pragma Annotate
1740 Syntax:
1742 @example
1743 pragma Annotate (IDENTIFIER [, IDENTIFIER @{, ARG@}] [, entity => local_NAME]);
1745 ARG ::= NAME | EXPRESSION
1746 @end example
1748 This pragma is used to annotate programs.  IDENTIFIER identifies
1749 the type of annotation.  GNAT verifies that it is an identifier, but does
1750 not otherwise analyze it. The second optional identifier is also left
1751 unanalyzed, and by convention is used to control the action of the tool to
1752 which the annotation is addressed.  The remaining ARG arguments
1753 can be either string literals or more generally expressions.
1754 String literals (and concatenations of string literals) are assumed to be
1755 either of type
1756 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1757 depending on the character literals they contain.
1758 All other kinds of arguments are analyzed as expressions, and must be
1759 unambiguous. The last argument if present must have the identifier
1760 @code{Entity} and GNAT verifies that a local name is given.
1762 The analyzed pragma is retained in the tree, but not otherwise processed
1763 by any part of the GNAT compiler, except to generate corresponding note
1764 lines in the generated ALI file. For the format of these note lines, see
1765 the compiler source file lib-writ.ads. This pragma is intended for use by
1766 external tools, including ASIS. The use of pragma Annotate does not
1767 affect the compilation process in any way. This pragma may be used as
1768 a configuration pragma.
1770 @node Pragma Assert,Pragma Assert_And_Cut,Pragma Annotate,Implementation Defined Pragmas
1771 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert}@anchor{2a}
1772 @section Pragma Assert
1775 Syntax:
1777 @example
1778 pragma Assert (
1779   boolean_EXPRESSION
1780   [, string_EXPRESSION]);
1781 @end example
1783 The effect of this pragma depends on whether the corresponding command
1784 line switch is set to activate assertions.  The pragma expands into code
1785 equivalent to the following:
1787 @example
1788 if assertions-enabled then
1789    if not boolean_EXPRESSION then
1790       System.Assertions.Raise_Assert_Failure
1791         (string_EXPRESSION);
1792    end if;
1793 end if;
1794 @end example
1796 The string argument, if given, is the message that will be associated
1797 with the exception occurrence if the exception is raised.  If no second
1798 argument is given, the default message is @code{file}:@code{nnn},
1799 where @code{file} is the name of the source file containing the assert,
1800 and @code{nnn} is the line number of the assert.
1802 Note that, as with the @code{if} statement to which it is equivalent, the
1803 type of the expression is either @code{Standard.Boolean}, or any type derived
1804 from this standard type.
1806 Assert checks can be either checked or ignored. By default they are ignored.
1807 They will be checked if either the command line switch `-gnata' is
1808 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1809 to enable @code{Assert_Checks}.
1811 If assertions are ignored, then there
1812 is no run-time effect (and in particular, any side effects from the
1813 expression will not occur at run time).  (The expression is still
1814 analyzed at compile time, and may cause types to be frozen if they are
1815 mentioned here for the first time).
1817 If assertions are checked, then the given expression is tested, and if
1818 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1819 which results in the raising of @code{Assert_Failure} with the given message.
1821 You should generally avoid side effects in the expression arguments of
1822 this pragma, because these side effects will turn on and off with the
1823 setting of the assertions mode, resulting in assertions that have an
1824 effect on the program.  However, the expressions are analyzed for
1825 semantic correctness whether or not assertions are enabled, so turning
1826 assertions on and off cannot affect the legality of a program.
1828 Note that the implementation defined policy @code{DISABLE}, given in a
1829 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1831 Note: this is a standard language-defined pragma in versions
1832 of Ada from 2005 on. In GNAT, it is implemented in all versions
1833 of Ada, and the DISABLE policy is an implementation-defined
1834 addition.
1836 @node Pragma Assert_And_Cut,Pragma Assertion_Policy,Pragma Assert,Implementation Defined Pragmas
1837 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert-and-cut}@anchor{2b}
1838 @section Pragma Assert_And_Cut
1841 Syntax:
1843 @example
1844 pragma Assert_And_Cut (
1845   boolean_EXPRESSION
1846   [, string_EXPRESSION]);
1847 @end example
1849 The effect of this pragma is identical to that of pragma @code{Assert},
1850 except that in an @code{Assertion_Policy} pragma, the identifier
1851 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1852 (or disabled).
1854 The intention is that this be used within a subprogram when the
1855 given test expresion sums up all the work done so far in the
1856 subprogram, so that the rest of the subprogram can be verified
1857 (informally or formally) using only the entry preconditions,
1858 and the expression in this pragma. This allows dividing up
1859 a subprogram into sections for the purposes of testing or
1860 formal verification. The pragma also serves as useful
1861 documentation.
1863 @node Pragma Assertion_Policy,Pragma Assume,Pragma Assert_And_Cut,Implementation Defined Pragmas
1864 @anchor{gnat_rm/implementation_defined_pragmas pragma-assertion-policy}@anchor{2c}
1865 @section Pragma Assertion_Policy
1868 Syntax:
1870 @example
1871 pragma Assertion_Policy (CHECK | DISABLE | IGNORE | SUPPRESSIBLE);
1873 pragma Assertion_Policy (
1874     ASSERTION_KIND => POLICY_IDENTIFIER
1875  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1877 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1879 RM_ASSERTION_KIND ::= Assert                    |
1880                       Static_Predicate          |
1881                       Dynamic_Predicate         |
1882                       Pre                       |
1883                       Pre'Class                 |
1884                       Post                      |
1885                       Post'Class                |
1886                       Type_Invariant            |
1887                       Type_Invariant'Class      |
1888                       Default_Initial_Condition
1890 ID_ASSERTION_KIND ::= Assertions           |
1891                       Assert_And_Cut       |
1892                       Assume               |
1893                       Contract_Cases       |
1894                       Debug                |
1895                       Ghost                |
1896                       Initial_Condition    |
1897                       Invariant            |
1898                       Invariant'Class      |
1899                       Loop_Invariant       |
1900                       Loop_Variant         |
1901                       Postcondition        |
1902                       Precondition         |
1903                       Predicate            |
1904                       Refined_Post         |
1905                       Statement_Assertions |
1906                       Subprogram_Variant
1908 POLICY_IDENTIFIER ::= Check | Disable | Ignore | Suppressible
1909 @end example
1911 This is a standard Ada 2012 pragma that is available as an
1912 implementation-defined pragma in earlier versions of Ada.
1913 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1914 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1915 are implementation defined additions recognized by the GNAT compiler.
1917 The pragma applies in both cases to pragmas and aspects with matching
1918 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1919 applies to both the @code{Precondition} pragma
1920 and the aspect @code{Precondition}. Note that the identifiers for
1921 pragmas Pre_Class and Post_Class are Pre’Class and Post’Class (not
1922 Pre_Class and Post_Class), since these pragmas are intended to be
1923 identical to the corresponding aspects.
1925 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1926 the corresponding pragma or aspect is activated.
1927 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1928 the corresponding pragma or aspect is deactivated.
1929 This pragma overrides the effect of the `-gnata' switch on the
1930 command line.
1931 If the policy is @code{SUPPRESSIBLE}, then assertions are enabled by default,
1932 however, if the `-gnatp' switch is specified all assertions are ignored.
1934 The implementation defined policy @code{DISABLE} is like
1935 @code{IGNORE} except that it completely disables semantic
1936 checking of the corresponding pragma or aspect. This is
1937 useful when the pragma or aspect argument references subprograms
1938 in a with’ed package which is replaced by a dummy package
1939 for the final build.
1941 The implementation defined assertion kind @code{Assertions} applies to all
1942 assertion kinds. The form with no assertion kind given implies this
1943 choice, so it applies to all assertion kinds (RM defined, and
1944 implementation defined).
1946 The implementation defined assertion kind @code{Statement_Assertions}
1947 applies to @code{Assert}, @code{Assert_And_Cut},
1948 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1950 @node Pragma Assume,Pragma Assume_No_Invalid_Values,Pragma Assertion_Policy,Implementation Defined Pragmas
1951 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume}@anchor{2d}
1952 @section Pragma Assume
1955 Syntax:
1957 @example
1958 pragma Assume (
1959   boolean_EXPRESSION
1960   [, string_EXPRESSION]);
1961 @end example
1963 The effect of this pragma is identical to that of pragma @code{Assert},
1964 except that in an @code{Assertion_Policy} pragma, the identifier
1965 @code{Assume} is used to control whether it is ignored or checked
1966 (or disabled).
1968 The intention is that this be used for assumptions about the
1969 external environment. So you cannot expect to verify formally
1970 or informally that the condition is met, this must be
1971 established by examining things outside the program itself.
1972 For example, we may have code that depends on the size of
1973 @code{Long_Long_Integer} being at least 64. So we could write:
1975 @example
1976 pragma Assume (Long_Long_Integer'Size >= 64);
1977 @end example
1979 This assumption cannot be proved from the program itself,
1980 but it acts as a useful run-time check that the assumption
1981 is met, and documents the need to ensure that it is met by
1982 reference to information outside the program.
1984 @node Pragma Assume_No_Invalid_Values,Pragma Async_Readers,Pragma Assume,Implementation Defined Pragmas
1985 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume-no-invalid-values}@anchor{2e}
1986 @section Pragma Assume_No_Invalid_Values
1989 @geindex Invalid representations
1991 @geindex Invalid values
1993 Syntax:
1995 @example
1996 pragma Assume_No_Invalid_Values (On | Off);
1997 @end example
1999 This is a configuration pragma that controls the assumptions made by the
2000 compiler about the occurrence of invalid representations (invalid values)
2001 in the code.
2003 The default behavior (corresponding to an Off argument for this pragma), is
2004 to assume that values may in general be invalid unless the compiler can
2005 prove they are valid. Consider the following example:
2007 @example
2008 V1 : Integer range 1 .. 10;
2009 V2 : Integer range 11 .. 20;
2011 for J in V2 .. V1 loop
2012    ...
2013 end loop;
2014 @end example
2016 if V1 and V2 have valid values, then the loop is known at compile
2017 time not to execute since the lower bound must be greater than the
2018 upper bound. However in default mode, no such assumption is made,
2019 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
2020 is given, the compiler will assume that any occurrence of a variable
2021 other than in an explicit @code{'Valid} test always has a valid
2022 value, and the loop above will be optimized away.
2024 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
2025 you know your code is free of uninitialized variables and other
2026 possible sources of invalid representations, and may result in
2027 more efficient code. A program that accesses an invalid representation
2028 with this pragma in effect is erroneous, so no guarantees can be made
2029 about its behavior.
2031 It is peculiar though permissible to use this pragma in conjunction
2032 with validity checking (-gnatVa). In such cases, accessing invalid
2033 values will generally give an exception, though formally the program
2034 is erroneous so there are no guarantees that this will always be the
2035 case, and it is recommended that these two options not be used together.
2037 @node Pragma Async_Readers,Pragma Async_Writers,Pragma Assume_No_Invalid_Values,Implementation Defined Pragmas
2038 @anchor{gnat_rm/implementation_defined_pragmas id4}@anchor{2f}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-readers}@anchor{30}
2039 @section Pragma Async_Readers
2042 Syntax:
2044 @example
2045 pragma Async_Readers [ (static_boolean_EXPRESSION) ];
2046 @end example
2048 For the semantics of this pragma, see the entry for aspect @code{Async_Readers} in
2049 the SPARK 2014 Reference Manual, section 7.1.2.
2051 @node Pragma Async_Writers,Pragma Attribute_Definition,Pragma Async_Readers,Implementation Defined Pragmas
2052 @anchor{gnat_rm/implementation_defined_pragmas id5}@anchor{31}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-writers}@anchor{32}
2053 @section Pragma Async_Writers
2056 Syntax:
2058 @example
2059 pragma Async_Writers [ (static_boolean_EXPRESSION) ];
2060 @end example
2062 For the semantics of this pragma, see the entry for aspect @code{Async_Writers} in
2063 the SPARK 2014 Reference Manual, section 7.1.2.
2065 @node Pragma Attribute_Definition,Pragma C_Pass_By_Copy,Pragma Async_Writers,Implementation Defined Pragmas
2066 @anchor{gnat_rm/implementation_defined_pragmas pragma-attribute-definition}@anchor{33}
2067 @section Pragma Attribute_Definition
2070 Syntax:
2072 @example
2073 pragma Attribute_Definition
2074   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
2075    [Entity     =>] LOCAL_NAME,
2076    [Expression =>] EXPRESSION | NAME);
2077 @end example
2079 If @code{Attribute} is a known attribute name, this pragma is equivalent to
2080 the attribute definition clause:
2082 @example
2083 for Entity'Attribute use Expression;
2084 @end example
2086 If @code{Attribute} is not a recognized attribute name, the pragma is
2087 ignored, and a warning is emitted. This allows source
2088 code to be written that takes advantage of some new attribute, while remaining
2089 compilable with earlier compilers.
2091 @node Pragma C_Pass_By_Copy,Pragma Check,Pragma Attribute_Definition,Implementation Defined Pragmas
2092 @anchor{gnat_rm/implementation_defined_pragmas pragma-c-pass-by-copy}@anchor{34}
2093 @section Pragma C_Pass_By_Copy
2096 @geindex Passing by copy
2098 Syntax:
2100 @example
2101 pragma C_Pass_By_Copy
2102   ([Max_Size =>] static_integer_EXPRESSION);
2103 @end example
2105 Normally the default mechanism for passing C convention records to C
2106 convention subprograms is to pass them by reference, as suggested by RM
2107 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
2108 this default, by requiring that record formal parameters be passed by
2109 copy if all of the following conditions are met:
2112 @itemize *
2114 @item 
2115 The size of the record type does not exceed the value specified for
2116 @code{Max_Size}.
2118 @item 
2119 The record type has @code{Convention C}.
2121 @item 
2122 The formal parameter has this record type, and the subprogram has a
2123 foreign (non-Ada) convention.
2124 @end itemize
2126 If these conditions are met the argument is passed by copy; i.e., in a
2127 manner consistent with what C expects if the corresponding formal in the
2128 C prototype is a struct (rather than a pointer to a struct).
2130 You can also pass records by copy by specifying the convention
2131 @code{C_Pass_By_Copy} for the record type, or by using the extended
2132 @code{Import} and @code{Export} pragmas, which allow specification of
2133 passing mechanisms on a parameter by parameter basis.
2135 @node Pragma Check,Pragma Check_Float_Overflow,Pragma C_Pass_By_Copy,Implementation Defined Pragmas
2136 @anchor{gnat_rm/implementation_defined_pragmas pragma-check}@anchor{35}
2137 @section Pragma Check
2140 @geindex Assertions
2142 @geindex Named assertions
2144 Syntax:
2146 @example
2147 pragma Check (
2148      [Name    =>] CHECK_KIND,
2149      [Check   =>] Boolean_EXPRESSION
2150   [, [Message =>] string_EXPRESSION] );
2152 CHECK_KIND ::= IDENTIFIER           |
2153                Pre'Class            |
2154                Post'Class           |
2155                Type_Invariant'Class |
2156                Invariant'Class
2157 @end example
2159 This pragma is similar to the predefined pragma @code{Assert} except that an
2160 extra identifier argument is present. In conjunction with pragma
2161 @code{Check_Policy}, this can be used to define groups of assertions that can
2162 be independently controlled. The identifier @code{Assertion} is special, it
2163 refers to the normal set of pragma @code{Assert} statements.
2165 Checks introduced by this pragma are normally deactivated by default. They can
2166 be activated either by the command line option `-gnata', which turns on
2167 all checks, or individually controlled using pragma @code{Check_Policy}.
2169 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
2170 permitted as check kinds, since this would cause confusion with the use
2171 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
2172 pragmas, where they are used to refer to sets of assertions.
2174 @node Pragma Check_Float_Overflow,Pragma Check_Name,Pragma Check,Implementation Defined Pragmas
2175 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-float-overflow}@anchor{36}
2176 @section Pragma Check_Float_Overflow
2179 @geindex Floating-point overflow
2181 Syntax:
2183 @example
2184 pragma Check_Float_Overflow;
2185 @end example
2187 In Ada, the predefined floating-point types (@code{Short_Float},
2188 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
2189 defined to be `unconstrained'. This means that even though each
2190 has a well-defined base range, an operation that delivers a result
2191 outside this base range is not required to raise an exception.
2192 This implementation permission accommodates the notion
2193 of infinities in IEEE floating-point, and corresponds to the
2194 efficient execution mode on most machines. GNAT will not raise
2195 overflow exceptions on these machines; instead it will generate
2196 infinities and NaN’s as defined in the IEEE standard.
2198 Generating infinities, although efficient, is not always desirable.
2199 Often the preferable approach is to check for overflow, even at the
2200 (perhaps considerable) expense of run-time performance.
2201 This can be accomplished by defining your own constrained floating-point subtypes – i.e., by supplying explicit
2202 range constraints – and indeed such a subtype
2203 can have the same base range as its base type. For example:
2205 @example
2206 subtype My_Float is Float range Float'Range;
2207 @end example
2209 Here @code{My_Float} has the same range as
2210 @code{Float} but is constrained, so operations on
2211 @code{My_Float} values will be checked for overflow
2212 against this range.
2214 This style will achieve the desired goal, but
2215 it is often more convenient to be able to simply use
2216 the standard predefined floating-point types as long
2217 as overflow checking could be guaranteed.
2218 The @code{Check_Float_Overflow}
2219 configuration pragma achieves this effect. If a unit is compiled
2220 subject to this configuration pragma, then all operations
2221 on predefined floating-point types including operations on
2222 base types of these floating-point types will be treated as
2223 though those types were constrained, and overflow checks
2224 will be generated. The @code{Constraint_Error}
2225 exception is raised if the result is out of range.
2227 This mode can also be set by use of the compiler
2228 switch `-gnateF'.
2230 @node Pragma Check_Name,Pragma Check_Policy,Pragma Check_Float_Overflow,Implementation Defined Pragmas
2231 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-name}@anchor{37}
2232 @section Pragma Check_Name
2235 @geindex Defining check names
2237 @geindex Check names
2238 @geindex defining
2240 Syntax:
2242 @example
2243 pragma Check_Name (check_name_IDENTIFIER);
2244 @end example
2246 This is a configuration pragma that defines a new implementation
2247 defined check name (unless IDENTIFIER matches one of the predefined
2248 check names, in which case the pragma has no effect). Check names
2249 are global to a partition, so if two or more configuration pragmas
2250 are present in a partition mentioning the same name, only one new
2251 check name is introduced.
2253 An implementation defined check name introduced with this pragma may
2254 be used in only three contexts: @code{pragma Suppress},
2255 @code{pragma Unsuppress},
2256 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
2257 any of these three cases, the check name must be visible. A check
2258 name is visible if it is in the configuration pragmas applying to
2259 the current unit, or if it appears at the start of any unit that
2260 is part of the dependency set of the current unit (e.g., units that
2261 are mentioned in @code{with} clauses).
2263 Check names introduced by this pragma are subject to control by compiler
2264 switches (in particular -gnatp) in the usual manner.
2266 @node Pragma Check_Policy,Pragma Comment,Pragma Check_Name,Implementation Defined Pragmas
2267 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-policy}@anchor{38}
2268 @section Pragma Check_Policy
2271 @geindex Controlling assertions
2273 @geindex Assertions
2274 @geindex control
2276 @geindex Check pragma control
2278 @geindex Named assertions
2280 Syntax:
2282 @example
2283 pragma Check_Policy
2284  ([Name   =>] CHECK_KIND,
2285   [Policy =>] POLICY_IDENTIFIER);
2287 pragma Check_Policy (
2288     CHECK_KIND => POLICY_IDENTIFIER
2289  @{, CHECK_KIND => POLICY_IDENTIFIER@});
2291 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
2293 CHECK_KIND ::= IDENTIFIER           |
2294                Pre'Class            |
2295                Post'Class           |
2296                Type_Invariant'Class |
2297                Invariant'Class
2299 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
2300 avoids confusion between the two possible syntax forms for this pragma.
2302 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
2303 @end example
2305 This pragma is used to set the checking policy for assertions (specified
2306 by aspects or pragmas), the @code{Debug} pragma, or additional checks
2307 to be checked using the @code{Check} pragma. It may appear either as
2308 a configuration pragma, or within a declarative part of package. In the
2309 latter case, it applies from the point where it appears to the end of
2310 the declarative region (like pragma @code{Suppress}).
2312 The @code{Check_Policy} pragma is similar to the
2313 predefined @code{Assertion_Policy} pragma,
2314 and if the check kind corresponds to one of the assertion kinds that
2315 are allowed by @code{Assertion_Policy}, then the effect is identical.
2317 If the first argument is Debug, then the policy applies to Debug pragmas,
2318 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
2319 @code{IGNORE}, and allowing them to execute with normal semantics if
2320 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
2321 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
2322 be totally ignored and not analyzed semantically.
2324 Finally the first argument may be some other identifier than the above
2325 possibilities, in which case it controls a set of named assertions
2326 that can be checked using pragma @code{Check}. For example, if the pragma:
2328 @example
2329 pragma Check_Policy (Critical_Error, OFF);
2330 @end example
2332 is given, then subsequent @code{Check} pragmas whose first argument is also
2333 @code{Critical_Error} will be disabled.
2335 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
2336 to turn on corresponding checks. The default for a set of checks for which no
2337 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
2338 `-gnata' is given, which turns on all checks by default.
2340 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
2341 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
2342 compatibility with the standard @code{Assertion_Policy} pragma. The check
2343 policy setting @code{DISABLE} causes the second argument of a corresponding
2344 @code{Check} pragma to be completely ignored and not analyzed.
2346 @node Pragma Comment,Pragma Common_Object,Pragma Check_Policy,Implementation Defined Pragmas
2347 @anchor{gnat_rm/implementation_defined_pragmas pragma-comment}@anchor{39}
2348 @section Pragma Comment
2351 Syntax:
2353 @example
2354 pragma Comment (static_string_EXPRESSION);
2355 @end example
2357 This is almost identical in effect to pragma @code{Ident}.  It allows the
2358 placement of a comment into the object file and hence into the
2359 executable file if the operating system permits such usage.  The
2360 difference is that @code{Comment}, unlike @code{Ident}, has
2361 no limitations on placement of the pragma (it can be placed
2362 anywhere in the main source unit), and if more than one pragma
2363 is used, all comments are retained.
2365 @node Pragma Common_Object,Pragma Compile_Time_Error,Pragma Comment,Implementation Defined Pragmas
2366 @anchor{gnat_rm/implementation_defined_pragmas pragma-common-object}@anchor{3a}
2367 @section Pragma Common_Object
2370 Syntax:
2372 @example
2373 pragma Common_Object (
2374      [Internal =>] LOCAL_NAME
2375   [, [External =>] EXTERNAL_SYMBOL]
2376   [, [Size     =>] EXTERNAL_SYMBOL] );
2378 EXTERNAL_SYMBOL ::=
2379   IDENTIFIER
2380 | static_string_EXPRESSION
2381 @end example
2383 This pragma enables the shared use of variables stored in overlaid
2384 linker areas corresponding to the use of @code{COMMON}
2385 in Fortran.  The single
2386 object @code{LOCAL_NAME} is assigned to the area designated by
2387 the @code{External} argument.
2388 You may define a record to correspond to a series
2389 of fields.  The @code{Size} argument
2390 is syntax checked in GNAT, but otherwise ignored.
2392 @code{Common_Object} is not supported on all platforms.  If no
2393 support is available, then the code generator will issue a message
2394 indicating that the necessary attribute for implementation of this
2395 pragma is not available.
2397 @node Pragma Compile_Time_Error,Pragma Compile_Time_Warning,Pragma Common_Object,Implementation Defined Pragmas
2398 @anchor{gnat_rm/implementation_defined_pragmas compile-time-error}@anchor{3b}@anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-error}@anchor{3c}
2399 @section Pragma Compile_Time_Error
2402 Syntax:
2404 @example
2405 pragma Compile_Time_Error
2406          (boolean_EXPRESSION, static_string_EXPRESSION);
2407 @end example
2409 This pragma can be used to generate additional compile time
2410 error messages. It
2411 is particularly useful in generics, where errors can be issued for
2412 specific problematic instantiations. The first parameter is a boolean
2413 expression. The pragma ensures that the value of an expression
2414 is known at compile time, and has the value False. The set of expressions
2415 whose values are known at compile time includes all static boolean
2416 expressions, and also other values which the compiler can determine
2417 at compile time (e.g., the size of a record type set by an explicit
2418 size representation clause, or the value of a variable which was
2419 initialized to a constant and is known not to have been modified).
2420 If these conditions are not met, an error message is generated using
2421 the value given as the second argument. This string value may contain
2422 embedded ASCII.LF characters to break the message into multiple lines.
2424 @node Pragma Compile_Time_Warning,Pragma Complete_Representation,Pragma Compile_Time_Error,Implementation Defined Pragmas
2425 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-warning}@anchor{3d}
2426 @section Pragma Compile_Time_Warning
2429 Syntax:
2431 @example
2432 pragma Compile_Time_Warning
2433          (boolean_EXPRESSION, static_string_EXPRESSION);
2434 @end example
2436 Same as pragma Compile_Time_Error, except a warning is issued instead
2437 of an error message. If switch `-gnatw_C' is used, a warning is only issued
2438 if the value of the expression is known to be True at compile time, not when
2439 the value of the expression is not known at compile time.
2440 Note that if this pragma is used in a package that
2441 is with’ed by a client, the client will get the warning even though it
2442 is issued by a with’ed package (normally warnings in with’ed units are
2443 suppressed, but this is a special exception to that rule).
2445 One typical use is within a generic where compile time known characteristics
2446 of formal parameters are tested, and warnings given appropriately. Another use
2447 with a first parameter of True is to warn a client about use of a package,
2448 for example that it is not fully implemented.
2450 In previous versions of the compiler, combining `-gnatwe' with
2451 Compile_Time_Warning resulted in a fatal error. Now the compiler always emits
2452 a warning. You can use @ref{3b,,Pragma Compile_Time_Error} to force the generation of
2453 an error.
2455 @node Pragma Complete_Representation,Pragma Complex_Representation,Pragma Compile_Time_Warning,Implementation Defined Pragmas
2456 @anchor{gnat_rm/implementation_defined_pragmas pragma-complete-representation}@anchor{3e}
2457 @section Pragma Complete_Representation
2460 Syntax:
2462 @example
2463 pragma Complete_Representation;
2464 @end example
2466 This pragma must appear immediately within a record representation
2467 clause. Typical placements are before the first component clause
2468 or after the last component clause. The effect is to give an error
2469 message if any component is missing a component clause. This pragma
2470 may be used to ensure that a record representation clause is
2471 complete, and that this invariant is maintained if fields are
2472 added to the record in the future.
2474 @node Pragma Complex_Representation,Pragma Component_Alignment,Pragma Complete_Representation,Implementation Defined Pragmas
2475 @anchor{gnat_rm/implementation_defined_pragmas pragma-complex-representation}@anchor{3f}
2476 @section Pragma Complex_Representation
2479 Syntax:
2481 @example
2482 pragma Complex_Representation
2483         ([Entity =>] LOCAL_NAME);
2484 @end example
2486 The @code{Entity} argument must be the name of a record type which has
2487 two fields of the same floating-point type.  The effect of this pragma is
2488 to force gcc to use the special internal complex representation form for
2489 this record, which may be more efficient.  Note that this may result in
2490 the code for this type not conforming to standard ABI (application
2491 binary interface) requirements for the handling of record types.  For
2492 example, in some environments, there is a requirement for passing
2493 records by pointer, and the use of this pragma may result in passing
2494 this type in floating-point registers.
2496 @node Pragma Component_Alignment,Pragma Constant_After_Elaboration,Pragma Complex_Representation,Implementation Defined Pragmas
2497 @anchor{gnat_rm/implementation_defined_pragmas pragma-component-alignment}@anchor{40}
2498 @section Pragma Component_Alignment
2501 @geindex Alignments of components
2503 @geindex Pragma Component_Alignment
2505 Syntax:
2507 @example
2508 pragma Component_Alignment (
2509      [Form =>] ALIGNMENT_CHOICE
2510   [, [Name =>] type_LOCAL_NAME]);
2512 ALIGNMENT_CHOICE ::=
2513   Component_Size
2514 | Component_Size_4
2515 | Storage_Unit
2516 | Default
2517 @end example
2519 Specifies the alignment of components in array or record types.
2520 The meaning of the @code{Form} argument is as follows:
2522 @quotation
2524 @geindex Component_Size (in pragma Component_Alignment)
2525 @end quotation
2528 @table @asis
2530 @item `Component_Size'
2532 Aligns scalar components and subcomponents of the array or record type
2533 on boundaries appropriate to their inherent size (naturally
2534 aligned).  For example, 1-byte components are aligned on byte boundaries,
2535 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2536 integer components are aligned on 4-byte boundaries and so on.  These
2537 alignment rules correspond to the normal rules for C compilers on all
2538 machines except the VAX.
2540 @geindex Component_Size_4 (in pragma Component_Alignment)
2542 @item `Component_Size_4'
2544 Naturally aligns components with a size of four or fewer
2545 bytes.  Components that are larger than 4 bytes are placed on the next
2546 4-byte boundary.
2548 @geindex Storage_Unit (in pragma Component_Alignment)
2550 @item `Storage_Unit'
2552 Specifies that array or record components are byte aligned, i.e.,
2553 aligned on boundaries determined by the value of the constant
2554 @code{System.Storage_Unit}.
2556 @geindex Default (in pragma Component_Alignment)
2558 @item `Default'
2560 Specifies that array or record components are aligned on default
2561 boundaries, appropriate to the underlying hardware or operating system or
2562 both. The @code{Default} choice is the same as @code{Component_Size} (natural
2563 alignment).
2564 @end table
2566 If the @code{Name} parameter is present, @code{type_LOCAL_NAME} must
2567 refer to a local record or array type, and the specified alignment
2568 choice applies to the specified type.  The use of
2569 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2570 @code{Component_Alignment} pragma to be ignored.  The use of
2571 @code{Component_Alignment} together with a record representation clause
2572 is only effective for fields not specified by the representation clause.
2574 If the @code{Name} parameter is absent, the pragma can be used as either
2575 a configuration pragma, in which case it applies to one or more units in
2576 accordance with the normal rules for configuration pragmas, or it can be
2577 used within a declarative part, in which case it applies to types that
2578 are declared within this declarative part, or within any nested scope
2579 within this declarative part.  In either case it specifies the alignment
2580 to be applied to any record or array type which has otherwise standard
2581 representation.
2583 If the alignment for a record or array type is not specified (using
2584 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2585 clause), the GNAT uses the default alignment as described previously.
2587 @node Pragma Constant_After_Elaboration,Pragma Contract_Cases,Pragma Component_Alignment,Implementation Defined Pragmas
2588 @anchor{gnat_rm/implementation_defined_pragmas id6}@anchor{41}@anchor{gnat_rm/implementation_defined_pragmas pragma-constant-after-elaboration}@anchor{42}
2589 @section Pragma Constant_After_Elaboration
2592 Syntax:
2594 @example
2595 pragma Constant_After_Elaboration [ (static_boolean_EXPRESSION) ];
2596 @end example
2598 For the semantics of this pragma, see the entry for aspect
2599 @code{Constant_After_Elaboration} in the SPARK 2014 Reference Manual, section 3.3.1.
2601 @node Pragma Contract_Cases,Pragma Convention_Identifier,Pragma Constant_After_Elaboration,Implementation Defined Pragmas
2602 @anchor{gnat_rm/implementation_defined_pragmas id7}@anchor{43}@anchor{gnat_rm/implementation_defined_pragmas pragma-contract-cases}@anchor{44}
2603 @section Pragma Contract_Cases
2606 @geindex Contract cases
2608 Syntax:
2610 @example
2611 pragma Contract_Cases (CONTRACT_CASE @{, CONTRACT_CASE@});
2613 CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
2615 CASE_GUARD ::= boolean_EXPRESSION | others
2617 CONSEQUENCE ::= boolean_EXPRESSION
2618 @end example
2620 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2621 that can complement or replace the contract given by a precondition and a
2622 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2623 by testing and formal verification tools. The compiler checks its validity and,
2624 depending on the assertion policy at the point of declaration of the pragma,
2625 it may insert a check in the executable. For code generation, the contract
2626 cases
2628 @example
2629 pragma Contract_Cases (
2630   Cond1 => Pred1,
2631   Cond2 => Pred2);
2632 @end example
2634 are equivalent to
2636 @example
2637 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2638 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2639 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2640 pragma Postcondition (if C1 then Pred1);
2641 pragma Postcondition (if C2 then Pred2);
2642 @end example
2644 The precondition ensures that one and only one of the case guards is
2645 satisfied on entry to the subprogram.
2646 The postcondition ensures that for the case guard that was True on entry,
2647 the corresponding consequence is True on exit. Other consequence expressions
2648 are not evaluated.
2650 A precondition @code{P} and postcondition @code{Q} can also be
2651 expressed as contract cases:
2653 @example
2654 pragma Contract_Cases (P => Q);
2655 @end example
2657 The placement and visibility rules for @code{Contract_Cases} pragmas are
2658 identical to those described for preconditions and postconditions.
2660 The compiler checks that boolean expressions given in case guards and
2661 consequences are valid, where the rules for case guards are the same as
2662 the rule for an expression in @code{Precondition} and the rules for
2663 consequences are the same as the rule for an expression in
2664 @code{Postcondition}. In particular, attributes @code{'Old} and
2665 @code{'Result} can only be used within consequence expressions.
2666 The case guard for the last contract case may be @code{others}, to denote
2667 any case not captured by the previous cases. The
2668 following is an example of use within a package spec:
2670 @example
2671 package Math_Functions is
2672    ...
2673    function Sqrt (Arg : Float) return Float;
2674    pragma Contract_Cases (((Arg in 0.0 .. 99.0) => Sqrt'Result < 10.0,
2675                            Arg >= 100.0         => Sqrt'Result >= 10.0,
2676                            others               => Sqrt'Result = 0.0));
2677    ...
2678 end Math_Functions;
2679 @end example
2681 The meaning of contract cases is that only one case should apply at each
2682 call, as determined by the corresponding case guard evaluating to True,
2683 and that the consequence for this case should hold when the subprogram
2684 returns.
2686 @node Pragma Convention_Identifier,Pragma CPP_Class,Pragma Contract_Cases,Implementation Defined Pragmas
2687 @anchor{gnat_rm/implementation_defined_pragmas pragma-convention-identifier}@anchor{45}
2688 @section Pragma Convention_Identifier
2691 @geindex Conventions
2692 @geindex synonyms
2694 Syntax:
2696 @example
2697 pragma Convention_Identifier (
2698          [Name =>]       IDENTIFIER,
2699          [Convention =>] convention_IDENTIFIER);
2700 @end example
2702 This pragma provides a mechanism for supplying synonyms for existing
2703 convention identifiers. The @code{Name} identifier can subsequently
2704 be used as a synonym for the given convention in other pragmas (including
2705 for example pragma @code{Import} or another @code{Convention_Identifier}
2706 pragma). As an example of the use of this, suppose you had legacy code
2707 which used Fortran77 as the identifier for Fortran. Then the pragma:
2709 @example
2710 pragma Convention_Identifier (Fortran77, Fortran);
2711 @end example
2713 would allow the use of the convention identifier @code{Fortran77} in
2714 subsequent code, avoiding the need to modify the sources. As another
2715 example, you could use this to parameterize convention requirements
2716 according to systems. Suppose you needed to use @code{Stdcall} on
2717 windows systems, and @code{C} on some other system, then you could
2718 define a convention identifier @code{Library} and use a single
2719 @code{Convention_Identifier} pragma to specify which convention
2720 would be used system-wide.
2722 @node Pragma CPP_Class,Pragma CPP_Constructor,Pragma Convention_Identifier,Implementation Defined Pragmas
2723 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-class}@anchor{46}
2724 @section Pragma CPP_Class
2727 @geindex Interfacing with C++
2729 Syntax:
2731 @example
2732 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2733 @end example
2735 The argument denotes an entity in the current declarative region that is
2736 declared as a record type. It indicates that the type corresponds to an
2737 externally declared C++ class type, and is to be laid out the same way
2738 that C++ would lay out the type. If the C++ class has virtual primitives
2739 then the record must be declared as a tagged record type.
2741 Types for which @code{CPP_Class} is specified do not have assignment or
2742 equality operators defined (such operations can be imported or declared
2743 as subprograms as required). Initialization is allowed only by constructor
2744 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2745 limited if not explicitly declared as limited or derived from a limited
2746 type, and an error is issued in that case.
2748 See @ref{47,,Interfacing to C++} for related information.
2750 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2751 for backward compatibility but its functionality is available
2752 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2754 @node Pragma CPP_Constructor,Pragma CPP_Virtual,Pragma CPP_Class,Implementation Defined Pragmas
2755 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-constructor}@anchor{48}
2756 @section Pragma CPP_Constructor
2759 @geindex Interfacing with C++
2761 Syntax:
2763 @example
2764 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2765   [, [External_Name =>] static_string_EXPRESSION ]
2766   [, [Link_Name     =>] static_string_EXPRESSION ]);
2767 @end example
2769 This pragma identifies an imported function (imported in the usual way
2770 with pragma @code{Import}) as corresponding to a C++ constructor. If
2771 @code{External_Name} and @code{Link_Name} are not specified then the
2772 @code{Entity} argument is a name that must have been previously mentioned
2773 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2774 must be of one of the following forms:
2777 @itemize *
2779 @item 
2780 `function' @code{Fname} `return' T`
2782 @item 
2783 `function' @code{Fname} `return' T’Class
2785 @item 
2786 `function' @code{Fname} (…) `return' T`
2788 @item 
2789 `function' @code{Fname} (…) `return' T’Class
2790 @end itemize
2792 where @code{T} is a limited record type imported from C++ with pragma
2793 @code{Import} and @code{Convention} = @code{CPP}.
2795 The first two forms import the default constructor, used when an object
2796 of type @code{T} is created on the Ada side with no explicit constructor.
2797 The latter two forms cover all the non-default constructors of the type.
2798 See the GNAT User’s Guide for details.
2800 If no constructors are imported, it is impossible to create any objects
2801 on the Ada side and the type is implicitly declared abstract.
2803 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2804 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2805 GCC switch).
2806 See @ref{47,,Interfacing to C++} for more related information.
2808 Note: The use of functions returning class-wide types for constructors is
2809 currently obsolete. They are supported for backward compatibility. The
2810 use of functions returning the type T leave the Ada sources more clear
2811 because the imported C++ constructors always return an object of type T;
2812 that is, they never return an object whose type is a descendant of type T.
2814 @node Pragma CPP_Virtual,Pragma CPP_Vtable,Pragma CPP_Constructor,Implementation Defined Pragmas
2815 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-virtual}@anchor{49}
2816 @section Pragma CPP_Virtual
2819 @geindex Interfacing to C++
2821 This pragma is now obsolete and, other than generating a warning if warnings
2822 on obsolescent features are enabled, is completely ignored.
2823 It is retained for compatibility
2824 purposes. It used to be required to ensure compatibility with C++, but
2825 is no longer required for that purpose because GNAT generates
2826 the same object layout as the G++ compiler by default.
2828 See @ref{47,,Interfacing to C++} for related information.
2830 @node Pragma CPP_Vtable,Pragma CPU,Pragma CPP_Virtual,Implementation Defined Pragmas
2831 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-vtable}@anchor{4a}
2832 @section Pragma CPP_Vtable
2835 @geindex Interfacing with C++
2837 This pragma is now obsolete and, other than generating a warning if warnings
2838 on obsolescent features are enabled, is completely ignored.
2839 It used to be required to ensure compatibility with C++, but
2840 is no longer required for that purpose because GNAT generates
2841 the same object layout as the G++ compiler by default.
2843 See @ref{47,,Interfacing to C++} for related information.
2845 @node Pragma CPU,Pragma Deadline_Floor,Pragma CPP_Vtable,Implementation Defined Pragmas
2846 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpu}@anchor{4b}
2847 @section Pragma CPU
2850 Syntax:
2852 @example
2853 pragma CPU (EXPRESSION);
2854 @end example
2856 This pragma is standard in Ada 2012, but is available in all earlier
2857 versions of Ada as an implementation-defined pragma.
2858 See Ada 2012 Reference Manual for details.
2860 @node Pragma Deadline_Floor,Pragma Debug,Pragma CPU,Implementation Defined Pragmas
2861 @anchor{gnat_rm/implementation_defined_pragmas pragma-deadline-floor}@anchor{4c}
2862 @section Pragma Deadline_Floor
2865 Syntax:
2867 @example
2868 pragma Deadline_Floor (time_span_EXPRESSION);
2869 @end example
2871 This pragma applies only to protected types and specifies the floor
2872 deadline inherited by a task when the task enters a protected object.
2873 It is effective only when the EDF scheduling policy is used.
2875 @node Pragma Debug,Pragma Debug_Policy,Pragma Deadline_Floor,Implementation Defined Pragmas
2876 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug}@anchor{4d}
2877 @section Pragma Debug
2880 Syntax:
2882 @example
2883 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2885 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2886   PROCEDURE_NAME
2887 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2888 @end example
2890 The procedure call argument has the syntactic form of an expression, meeting
2891 the syntactic requirements for pragmas.
2893 If debug pragmas are not enabled or if the condition is present and evaluates
2894 to False, this pragma has no effect. If debug pragmas are enabled, the
2895 semantics of the pragma is exactly equivalent to the procedure call statement
2896 corresponding to the argument with a terminating semicolon. Pragmas are
2897 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2898 intersperse calls to debug procedures in the middle of declarations. Debug
2899 pragmas can be enabled either by use of the command line switch `-gnata'
2900 or by use of the pragma @code{Check_Policy} with a first argument of
2901 @code{Debug}.
2903 @node Pragma Debug_Policy,Pragma Default_Initial_Condition,Pragma Debug,Implementation Defined Pragmas
2904 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug-policy}@anchor{4e}
2905 @section Pragma Debug_Policy
2908 Syntax:
2910 @example
2911 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2912 @end example
2914 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2915 with a first argument of @code{Debug}. It is retained for historical
2916 compatibility reasons.
2918 @node Pragma Default_Initial_Condition,Pragma Default_Scalar_Storage_Order,Pragma Debug_Policy,Implementation Defined Pragmas
2919 @anchor{gnat_rm/implementation_defined_pragmas id8}@anchor{4f}@anchor{gnat_rm/implementation_defined_pragmas pragma-default-initial-condition}@anchor{50}
2920 @section Pragma Default_Initial_Condition
2923 Syntax:
2925 @example
2926 pragma Default_Initial_Condition [ (null | boolean_EXPRESSION) ];
2927 @end example
2929 For the semantics of this pragma, see the entry for aspect
2930 @code{Default_Initial_Condition} in the SPARK 2014 Reference Manual, section 7.3.3.
2932 @node Pragma Default_Scalar_Storage_Order,Pragma Default_Storage_Pool,Pragma Default_Initial_Condition,Implementation Defined Pragmas
2933 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-scalar-storage-order}@anchor{51}
2934 @section Pragma Default_Scalar_Storage_Order
2937 @geindex Default_Scalar_Storage_Order
2939 @geindex Scalar_Storage_Order
2941 Syntax:
2943 @example
2944 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2945 @end example
2947 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2948 type or array type, then the scalar storage order defaults to the ordinary
2949 default for the target. But this default may be overridden using this pragma.
2950 The pragma may appear as a configuration pragma, or locally within a package
2951 spec or declarative part. In the latter case, it applies to all subsequent
2952 types declared within that package spec or declarative part.
2954 The following example shows the use of this pragma:
2956 @example
2957 pragma Default_Scalar_Storage_Order (High_Order_First);
2958 with System; use System;
2959 package DSSO1 is
2960    type H1 is record
2961       a : Integer;
2962    end record;
2964    type L2 is record
2965       a : Integer;
2966    end record;
2967    for L2'Scalar_Storage_Order use Low_Order_First;
2969    type L2a is new L2;
2971    package Inner is
2972       type H3 is record
2973          a : Integer;
2974       end record;
2976       pragma Default_Scalar_Storage_Order (Low_Order_First);
2978       type L4 is record
2979          a : Integer;
2980       end record;
2981    end Inner;
2983    type H4a is new Inner.L4;
2985    type H5 is record
2986       a : Integer;
2987    end record;
2988 end DSSO1;
2989 @end example
2991 In this example record types with names starting with `L' have @cite{Low_Order_First} scalar
2992 storage order, and record types with names starting with `H' have @code{High_Order_First}.
2993 Note that in the case of @code{H4a}, the order is not inherited
2994 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2995 gets inherited on type derivation.
2997 If this pragma is used as a configuration pragma which appears within a
2998 configuration pragma file (as opposed to appearing explicitly at the start
2999 of a single unit), then the binder will require that all units in a partition
3000 be compiled in a similar manner, other than run-time units, which are not
3001 affected by this pragma. Note that the use of this form is discouraged because
3002 it may significantly degrade the run-time performance of the software, instead
3003 the default scalar storage order ought to be changed only on a local basis.
3005 @node Pragma Default_Storage_Pool,Pragma Depends,Pragma Default_Scalar_Storage_Order,Implementation Defined Pragmas
3006 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-storage-pool}@anchor{52}
3007 @section Pragma Default_Storage_Pool
3010 @geindex Default_Storage_Pool
3012 Syntax:
3014 @example
3015 pragma Default_Storage_Pool (storage_pool_NAME | null);
3016 @end example
3018 This pragma is standard in Ada 2012, but is available in all earlier
3019 versions of Ada as an implementation-defined pragma.
3020 See Ada 2012 Reference Manual for details.
3022 @node Pragma Depends,Pragma Detect_Blocking,Pragma Default_Storage_Pool,Implementation Defined Pragmas
3023 @anchor{gnat_rm/implementation_defined_pragmas id9}@anchor{53}@anchor{gnat_rm/implementation_defined_pragmas pragma-depends}@anchor{54}
3024 @section Pragma Depends
3027 Syntax:
3029 @example
3030 pragma Depends (DEPENDENCY_RELATION);
3032 DEPENDENCY_RELATION ::=
3033      null
3034   | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
3036 DEPENDENCY_CLAUSE ::=
3037     OUTPUT_LIST =>[+] INPUT_LIST
3038   | NULL_DEPENDENCY_CLAUSE
3040 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
3042 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
3044 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
3046 OUTPUT ::= NAME | FUNCTION_RESULT
3047 INPUT  ::= NAME
3049 where FUNCTION_RESULT is a function Result attribute_reference
3050 @end example
3052 For the semantics of this pragma, see the entry for aspect @code{Depends} in the
3053 SPARK 2014 Reference Manual, section 6.1.5.
3055 @node Pragma Detect_Blocking,Pragma Disable_Atomic_Synchronization,Pragma Depends,Implementation Defined Pragmas
3056 @anchor{gnat_rm/implementation_defined_pragmas pragma-detect-blocking}@anchor{55}
3057 @section Pragma Detect_Blocking
3060 Syntax:
3062 @example
3063 pragma Detect_Blocking;
3064 @end example
3066 This is a standard pragma in Ada 2005, that is available in all earlier
3067 versions of Ada as an implementation-defined pragma.
3069 This is a configuration pragma that forces the detection of potentially
3070 blocking operations within a protected operation, and to raise Program_Error
3071 if that happens.
3073 @node Pragma Disable_Atomic_Synchronization,Pragma Dispatching_Domain,Pragma Detect_Blocking,Implementation Defined Pragmas
3074 @anchor{gnat_rm/implementation_defined_pragmas pragma-disable-atomic-synchronization}@anchor{56}
3075 @section Pragma Disable_Atomic_Synchronization
3078 @geindex Atomic Synchronization
3080 Syntax:
3082 @example
3083 pragma Disable_Atomic_Synchronization [(Entity)];
3084 @end example
3086 Ada requires that accesses (reads or writes) of an atomic variable be
3087 regarded as synchronization points in the case of multiple tasks.
3088 Particularly in the case of multi-processors this may require special
3089 handling, e.g. the generation of memory barriers. This capability may
3090 be turned off using this pragma in cases where it is known not to be
3091 required.
3093 The placement and scope rules for this pragma are the same as those
3094 for @code{pragma Suppress}. In particular it can be used as a
3095 configuration  pragma, or in a declaration sequence where it applies
3096 till the end of the scope. If an @code{Entity} argument is present,
3097 the action applies only to that entity.
3099 @node Pragma Dispatching_Domain,Pragma Effective_Reads,Pragma Disable_Atomic_Synchronization,Implementation Defined Pragmas
3100 @anchor{gnat_rm/implementation_defined_pragmas pragma-dispatching-domain}@anchor{57}
3101 @section Pragma Dispatching_Domain
3104 Syntax:
3106 @example
3107 pragma Dispatching_Domain (EXPRESSION);
3108 @end example
3110 This pragma is standard in Ada 2012, but is available in all earlier
3111 versions of Ada as an implementation-defined pragma.
3112 See Ada 2012 Reference Manual for details.
3114 @node Pragma Effective_Reads,Pragma Effective_Writes,Pragma Dispatching_Domain,Implementation Defined Pragmas
3115 @anchor{gnat_rm/implementation_defined_pragmas id10}@anchor{58}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-reads}@anchor{59}
3116 @section Pragma Effective_Reads
3119 Syntax:
3121 @example
3122 pragma Effective_Reads [ (static_boolean_EXPRESSION) ];
3123 @end example
3125 For the semantics of this pragma, see the entry for aspect @code{Effective_Reads} in
3126 the SPARK 2014 Reference Manual, section 7.1.2.
3128 @node Pragma Effective_Writes,Pragma Elaboration_Checks,Pragma Effective_Reads,Implementation Defined Pragmas
3129 @anchor{gnat_rm/implementation_defined_pragmas id11}@anchor{5a}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-writes}@anchor{5b}
3130 @section Pragma Effective_Writes
3133 Syntax:
3135 @example
3136 pragma Effective_Writes [ (static_boolean_EXPRESSION) ];
3137 @end example
3139 For the semantics of this pragma, see the entry for aspect @code{Effective_Writes}
3140 in the SPARK 2014 Reference Manual, section 7.1.2.
3142 @node Pragma Elaboration_Checks,Pragma Eliminate,Pragma Effective_Writes,Implementation Defined Pragmas
3143 @anchor{gnat_rm/implementation_defined_pragmas pragma-elaboration-checks}@anchor{5c}
3144 @section Pragma Elaboration_Checks
3147 @geindex Elaboration control
3149 Syntax:
3151 @example
3152 pragma Elaboration_Checks (Dynamic | Static);
3153 @end example
3155 This is a configuration pragma which specifies the elaboration model to be
3156 used during compilation. For more information on the elaboration models of
3157 GNAT, consult the chapter on elaboration order handling in the `GNAT User’s
3158 Guide'.
3160 The pragma may appear in the following contexts:
3163 @itemize *
3165 @item 
3166 Configuration pragmas file
3168 @item 
3169 Prior to the context clauses of a compilation unit’s initial declaration
3170 @end itemize
3172 Any other placement of the pragma will result in a warning and the effects of
3173 the offending pragma will be ignored.
3175 If the pragma argument is @code{Dynamic}, then the dynamic elaboration model is in
3176 effect. If the pragma argument is @code{Static}, then the static elaboration model
3177 is in effect.
3179 @node Pragma Eliminate,Pragma Enable_Atomic_Synchronization,Pragma Elaboration_Checks,Implementation Defined Pragmas
3180 @anchor{gnat_rm/implementation_defined_pragmas pragma-eliminate}@anchor{5d}
3181 @section Pragma Eliminate
3184 @geindex Elimination of unused subprograms
3186 Syntax:
3188 @example
3189 pragma Eliminate (
3190             [  Unit_Name       => ] IDENTIFIER | SELECTED_COMPONENT ,
3191             [  Entity          => ] IDENTIFIER |
3192                                     SELECTED_COMPONENT |
3193                                     STRING_LITERAL
3194             [, Source_Location =>   SOURCE_TRACE ] );
3196         SOURCE_TRACE    ::= STRING_LITERAL
3197 @end example
3199 This pragma indicates that the given entity is not used in the program to be
3200 compiled and built, thus allowing the compiler to
3201 eliminate the code or data associated with the named entity. Any reference to
3202 an eliminated entity causes a compile-time or link-time error.
3204 The pragma has the following semantics, where @code{U} is the unit specified by
3205 the @code{Unit_Name} argument and @code{E} is the entity specified by the @code{Entity}
3206 argument:
3209 @itemize *
3211 @item 
3212 @code{E} must be a subprogram that is explicitly declared either:
3215 @itemize *
3217 @item 
3218 Within @code{U}, or
3220 @item 
3221 Within a generic package that is instantiated in @code{U}, or
3223 @item 
3224 As an instance of generic subprogram instantiated in @code{U}.
3225 @end itemize
3227 Otherwise the pragma is ignored.
3229 @item 
3230 If @code{E} is overloaded within @code{U} then, in the absence of a
3231 @code{Source_Location} argument, all overloadings are eliminated.
3233 @item 
3234 If @code{E} is overloaded within @code{U} and only some overloadings
3235 are to be eliminated, then each overloading to be eliminated
3236 must be specified in a corresponding pragma @code{Eliminate}
3237 with a @code{Source_Location} argument identifying the line where the
3238 declaration appears, as described below.
3240 @item 
3241 If @code{E} is declared as the result of a generic instantiation, then
3242 a @code{Source_Location} argument is needed, as described below.
3243 @end itemize
3245 Pragma @code{Eliminate} allows a program to be compiled in a system-independent
3246 manner, so that unused entities are eliminated but without
3247 needing to modify the source text. Normally the required set of
3248 @code{Eliminate} pragmas is constructed automatically using the @code{gnatelim} tool.
3250 Any source file change that removes, splits, or
3251 adds lines may make the set of @code{Eliminate} pragmas invalid because their
3252 @code{Source_Location} argument values may get out of date.
3254 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
3255 operation. In this case all the subprograms to which the given operation can
3256 dispatch are considered to be unused (are never called as a result of a direct
3257 or a dispatching call).
3259 The string literal given for the source location specifies the line number
3260 of the declaration of the entity, using the following syntax for @code{SOURCE_TRACE}:
3262 @example
3263 SOURCE_TRACE     ::= SOURCE_REFERENCE [ LBRACKET SOURCE_TRACE RBRACKET ]
3265 LBRACKET         ::= '['
3266 RBRACKET         ::= ']'
3268 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
3270 LINE_NUMBER      ::= DIGIT @{DIGIT@}
3271 @end example
3273 Spaces around the colon in a @code{SOURCE_REFERENCE} are optional.
3275 The source trace that is given as the @code{Source_Location} must obey the
3276 following rules (or else the pragma is ignored), where @code{U} is
3277 the unit @code{U} specified by the @code{Unit_Name} argument and @code{E} is the
3278 subprogram specified by the @code{Entity} argument:
3281 @itemize *
3283 @item 
3284 @code{FILE_NAME} is the short name (with no directory
3285 information) of the Ada source file for @code{U}, using the required syntax
3286 for the underlying file system (e.g. case is significant if the underlying
3287 operating system is case sensitive).
3288 If @code{U} is a package and @code{E} is a subprogram declared in the package
3289 specification and its full declaration appears in the package body,
3290 then the  relevant source file is the one for the package specification;
3291 analogously if @code{U} is a generic package.
3293 @item 
3294 If @code{E} is not declared in a generic instantiation (this includes
3295 generic subprogram instances), the source trace includes only one source
3296 line reference. @code{LINE_NUMBER} gives the line number of the occurrence
3297 of the declaration of @code{E} within the source file (as a decimal literal
3298 without an exponent or point).
3300 @item 
3301 If @code{E} is declared by a generic instantiation, its source trace
3302 (from left to right) starts with the source location of the
3303 declaration of @code{E} in the generic unit and ends with the source
3304 location of the instantiation, given in square brackets. This approach is
3305 applied recursively with nested instantiations: the rightmost (nested
3306 most deeply in square brackets) element of the source trace is the location
3307 of the outermost instantiation, and the leftmost element (that is, outside
3308 of any square brackets) is the location of the declaration of @code{E} in
3309 the generic unit.
3310 @end itemize
3312 Examples:
3314 @quotation
3316 @example
3317 pragma Eliminate (Pkg0, Proc);
3318 -- Eliminate (all overloadings of) Proc in Pkg0
3320 pragma Eliminate (Pkg1, Proc,
3321                   Source_Location => "pkg1.ads:8");
3322 -- Eliminate overloading of Proc at line 8 in pkg1.ads
3324 -- Assume the following file contents:
3325 --   gen_pkg.ads
3326 --   1: generic
3327 --   2:   type T is private;
3328 --   3: package Gen_Pkg is
3329 --   4:   procedure Proc(N : T);
3330 --  ...   ...
3331 --  ... end Gen_Pkg;
3333 --    q.adb
3334 --   1: with Gen_Pkg;
3335 --   2: procedure Q is
3336 --   3:   package Inst_Pkg is new Gen_Pkg(Integer);
3337 --  ...   -- No calls on Inst_Pkg.Proc
3338 --  ... end Q;
3340 -- The following pragma eliminates Inst_Pkg.Proc from Q
3341 pragma Eliminate (Q, Proc,
3342                   Source_Location => "gen_pkg.ads:4[q.adb:3]");
3343 @end example
3344 @end quotation
3346 @node Pragma Enable_Atomic_Synchronization,Pragma Export_Function,Pragma Eliminate,Implementation Defined Pragmas
3347 @anchor{gnat_rm/implementation_defined_pragmas pragma-enable-atomic-synchronization}@anchor{5e}
3348 @section Pragma Enable_Atomic_Synchronization
3351 @geindex Atomic Synchronization
3353 Syntax:
3355 @example
3356 pragma Enable_Atomic_Synchronization [(Entity)];
3357 @end example
3359 Ada requires that accesses (reads or writes) of an atomic variable be
3360 regarded as synchronization points in the case of multiple tasks.
3361 Particularly in the case of multi-processors this may require special
3362 handling, e.g. the generation of memory barriers. This synchronization
3363 is performed by default, but can be turned off using
3364 @code{pragma Disable_Atomic_Synchronization}. The
3365 @code{Enable_Atomic_Synchronization} pragma can be used to turn
3366 it back on.
3368 The placement and scope rules for this pragma are the same as those
3369 for @code{pragma Unsuppress}. In particular it can be used as a
3370 configuration  pragma, or in a declaration sequence where it applies
3371 till the end of the scope. If an @code{Entity} argument is present,
3372 the action applies only to that entity.
3374 @node Pragma Export_Function,Pragma Export_Object,Pragma Enable_Atomic_Synchronization,Implementation Defined Pragmas
3375 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-function}@anchor{5f}
3376 @section Pragma Export_Function
3379 @geindex Argument passing mechanisms
3381 Syntax:
3383 @example
3384 pragma Export_Function (
3385      [Internal         =>] LOCAL_NAME
3386   [, [External         =>] EXTERNAL_SYMBOL]
3387   [, [Parameter_Types  =>] PARAMETER_TYPES]
3388   [, [Result_Type      =>] result_SUBTYPE_MARK]
3389   [, [Mechanism        =>] MECHANISM]
3390   [, [Result_Mechanism =>] MECHANISM_NAME]);
3392 EXTERNAL_SYMBOL ::=
3393   IDENTIFIER
3394 | static_string_EXPRESSION
3395 | ""
3397 PARAMETER_TYPES ::=
3398   null
3399 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3401 TYPE_DESIGNATOR ::=
3402   subtype_NAME
3403 | subtype_Name ' Access
3405 MECHANISM ::=
3406   MECHANISM_NAME
3407 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3409 MECHANISM_ASSOCIATION ::=
3410   [formal_parameter_NAME =>] MECHANISM_NAME
3412 MECHANISM_NAME ::= Value | Reference
3413 @end example
3415 Use this pragma to make a function externally callable and optionally
3416 provide information on mechanisms to be used for passing parameter and
3417 result values.  We recommend, for the purposes of improving portability,
3418 this pragma always be used in conjunction with a separate pragma
3419 @code{Export}, which must precede the pragma @code{Export_Function}.
3420 GNAT does not require a separate pragma @code{Export}, but if none is
3421 present, @code{Convention Ada} is assumed, which is usually
3422 not what is wanted, so it is usually appropriate to use this
3423 pragma in conjunction with a @code{Export} or @code{Convention}
3424 pragma that specifies the desired foreign convention.
3425 Pragma @code{Export_Function}
3426 (and @code{Export}, if present) must appear in the same declarative
3427 region as the function to which they apply.
3429 The @code{internal_name} must uniquely designate the function to which the
3430 pragma applies.  If more than one function name exists of this name in
3431 the declarative part you must use the @code{Parameter_Types} and
3432 @code{Result_Type} parameters to achieve the required
3433 unique designation.  The @cite{subtype_mark}s in these parameters must
3434 exactly match the subtypes in the corresponding function specification,
3435 using positional notation to match parameters with subtype marks.
3436 The form with an @code{'Access} attribute can be used to match an
3437 anonymous access parameter.
3439 @geindex Suppressing external name
3441 Special treatment is given if the EXTERNAL is an explicit null
3442 string or a static string expressions that evaluates to the null
3443 string. In this case, no external name is generated. This form
3444 still allows the specification of parameter mechanisms.
3446 @node Pragma Export_Object,Pragma Export_Procedure,Pragma Export_Function,Implementation Defined Pragmas
3447 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-object}@anchor{60}
3448 @section Pragma Export_Object
3451 Syntax:
3453 @example
3454 pragma Export_Object (
3455       [Internal =>] LOCAL_NAME
3456    [, [External =>] EXTERNAL_SYMBOL]
3457    [, [Size     =>] EXTERNAL_SYMBOL]);
3459 EXTERNAL_SYMBOL ::=
3460   IDENTIFIER
3461 | static_string_EXPRESSION
3462 @end example
3464 This pragma designates an object as exported, and apart from the
3465 extended rules for external symbols, is identical in effect to the use of
3466 the normal @code{Export} pragma applied to an object.  You may use a
3467 separate Export pragma (and you probably should from the point of view
3468 of portability), but it is not required.  @code{Size} is syntax checked,
3469 but otherwise ignored by GNAT.
3471 @node Pragma Export_Procedure,Pragma Export_Valued_Procedure,Pragma Export_Object,Implementation Defined Pragmas
3472 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-procedure}@anchor{61}
3473 @section Pragma Export_Procedure
3476 Syntax:
3478 @example
3479 pragma Export_Procedure (
3480      [Internal        =>] LOCAL_NAME
3481   [, [External        =>] EXTERNAL_SYMBOL]
3482   [, [Parameter_Types =>] PARAMETER_TYPES]
3483   [, [Mechanism       =>] MECHANISM]);
3485 EXTERNAL_SYMBOL ::=
3486   IDENTIFIER
3487 | static_string_EXPRESSION
3488 | ""
3490 PARAMETER_TYPES ::=
3491   null
3492 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3494 TYPE_DESIGNATOR ::=
3495   subtype_NAME
3496 | subtype_Name ' Access
3498 MECHANISM ::=
3499   MECHANISM_NAME
3500 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3502 MECHANISM_ASSOCIATION ::=
3503   [formal_parameter_NAME =>] MECHANISM_NAME
3505 MECHANISM_NAME ::= Value | Reference
3506 @end example
3508 This pragma is identical to @code{Export_Function} except that it
3509 applies to a procedure rather than a function and the parameters
3510 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3511 GNAT does not require a separate pragma @code{Export}, but if none is
3512 present, @code{Convention Ada} is assumed, which is usually
3513 not what is wanted, so it is usually appropriate to use this
3514 pragma in conjunction with a @code{Export} or @code{Convention}
3515 pragma that specifies the desired foreign convention.
3517 @geindex Suppressing external name
3519 Special treatment is given if the EXTERNAL is an explicit null
3520 string or a static string expressions that evaluates to the null
3521 string. In this case, no external name is generated. This form
3522 still allows the specification of parameter mechanisms.
3524 @node Pragma Export_Valued_Procedure,Pragma Extend_System,Pragma Export_Procedure,Implementation Defined Pragmas
3525 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-valued-procedure}@anchor{62}
3526 @section Pragma Export_Valued_Procedure
3529 Syntax:
3531 @example
3532 pragma Export_Valued_Procedure (
3533      [Internal        =>] LOCAL_NAME
3534   [, [External        =>] EXTERNAL_SYMBOL]
3535   [, [Parameter_Types =>] PARAMETER_TYPES]
3536   [, [Mechanism       =>] MECHANISM]);
3538 EXTERNAL_SYMBOL ::=
3539   IDENTIFIER
3540 | static_string_EXPRESSION
3541 | ""
3543 PARAMETER_TYPES ::=
3544   null
3545 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3547 TYPE_DESIGNATOR ::=
3548   subtype_NAME
3549 | subtype_Name ' Access
3551 MECHANISM ::=
3552   MECHANISM_NAME
3553 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3555 MECHANISM_ASSOCIATION ::=
3556   [formal_parameter_NAME =>] MECHANISM_NAME
3558 MECHANISM_NAME ::= Value | Reference
3559 @end example
3561 This pragma is identical to @code{Export_Procedure} except that the
3562 first parameter of @code{LOCAL_NAME}, which must be present, must be of
3563 mode @code{out}, and externally the subprogram is treated as a function
3564 with this parameter as the result of the function.  GNAT provides for
3565 this capability to allow the use of @code{out} and @code{in out}
3566 parameters in interfacing to external functions (which are not permitted
3567 in Ada functions).
3568 GNAT does not require a separate pragma @code{Export}, but if none is
3569 present, @code{Convention Ada} is assumed, which is almost certainly
3570 not what is wanted since the whole point of this pragma is to interface
3571 with foreign language functions, so it is usually appropriate to use this
3572 pragma in conjunction with a @code{Export} or @code{Convention}
3573 pragma that specifies the desired foreign convention.
3575 @geindex Suppressing external name
3577 Special treatment is given if the EXTERNAL is an explicit null
3578 string or a static string expressions that evaluates to the null
3579 string. In this case, no external name is generated. This form
3580 still allows the specification of parameter mechanisms.
3582 @node Pragma Extend_System,Pragma Extensions_Allowed,Pragma Export_Valued_Procedure,Implementation Defined Pragmas
3583 @anchor{gnat_rm/implementation_defined_pragmas pragma-extend-system}@anchor{63}
3584 @section Pragma Extend_System
3587 @geindex System
3588 @geindex extending
3590 @geindex DEC Ada 83
3592 Syntax:
3594 @example
3595 pragma Extend_System ([Name =>] IDENTIFIER);
3596 @end example
3598 This pragma is used to provide backwards compatibility with other
3599 implementations that extend the facilities of package @code{System}.  In
3600 GNAT, @code{System} contains only the definitions that are present in
3601 the Ada RM.  However, other implementations, notably the DEC Ada 83
3602 implementation, provide many extensions to package @code{System}.
3604 For each such implementation accommodated by this pragma, GNAT provides a
3605 package @code{Aux_@var{xxx}}, e.g., @code{Aux_DEC} for the DEC Ada 83
3606 implementation, which provides the required additional definitions.  You
3607 can use this package in two ways.  You can @code{with} it in the normal
3608 way and access entities either by selection or using a @code{use}
3609 clause.  In this case no special processing is required.
3611 However, if existing code contains references such as
3612 @code{System.@var{xxx}} where `xxx' is an entity in the extended
3613 definitions provided in package @code{System}, you may use this pragma
3614 to extend visibility in @code{System} in a non-standard way that
3615 provides greater compatibility with the existing code.  Pragma
3616 @code{Extend_System} is a configuration pragma whose single argument is
3617 the name of the package containing the extended definition
3618 (e.g., @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3619 control of this pragma will be processed using special visibility
3620 processing that looks in package @code{System.Aux_@var{xxx}} where
3621 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3622 package @code{System}, but not found in package @code{System}.
3624 You can use this pragma either to access a predefined @code{System}
3625 extension supplied with the compiler, for example @code{Aux_DEC} or
3626 you can construct your own extension unit following the above
3627 definition.  Note that such a package is a child of @code{System}
3628 and thus is considered part of the implementation.
3629 To compile it you will have to use the `-gnatg' switch
3630 for compiling System units, as explained in the
3631 GNAT User’s Guide.
3633 @node Pragma Extensions_Allowed,Pragma Extensions_Visible,Pragma Extend_System,Implementation Defined Pragmas
3634 @anchor{gnat_rm/implementation_defined_pragmas id12}@anchor{64}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-allowed}@anchor{65}
3635 @section Pragma Extensions_Allowed
3638 @geindex Ada Extensions
3640 @geindex GNAT Extensions
3642 Syntax:
3644 @example
3645 pragma Extensions_Allowed (On | Off | All);
3646 @end example
3648 This configuration pragma enables (via the “On” or “All” argument) or disables
3649 (via the “Off” argument) the implementation extension mode; the pragma takes
3650 precedence over the @code{-gnatX} and @code{-gnatX0} command switches.
3652 If an argument of @code{"On"} is specified, the latest version of the Ada language
3653 is implemented (currently Ada 2022) and, in addition, a curated set of GNAT
3654 specific extensions are recognized. (See the list here
3655 @ref{66,,here})
3657 An argument of @code{"All"} has the same effect except that some extra
3658 experimental extensions are enabled (See the list here
3659 @ref{67,,here})
3661 @node Pragma Extensions_Visible,Pragma External,Pragma Extensions_Allowed,Implementation Defined Pragmas
3662 @anchor{gnat_rm/implementation_defined_pragmas id13}@anchor{68}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-visible}@anchor{69}
3663 @section Pragma Extensions_Visible
3666 Syntax:
3668 @example
3669 pragma Extensions_Visible [ (static_boolean_EXPRESSION) ];
3670 @end example
3672 For the semantics of this pragma, see the entry for aspect @code{Extensions_Visible}
3673 in the SPARK 2014 Reference Manual, section 6.1.7.
3675 @node Pragma External,Pragma External_Name_Casing,Pragma Extensions_Visible,Implementation Defined Pragmas
3676 @anchor{gnat_rm/implementation_defined_pragmas pragma-external}@anchor{6a}
3677 @section Pragma External
3680 Syntax:
3682 @example
3683 pragma External (
3684   [   Convention    =>] convention_IDENTIFIER,
3685   [   Entity        =>] LOCAL_NAME
3686   [, [External_Name =>] static_string_EXPRESSION ]
3687   [, [Link_Name     =>] static_string_EXPRESSION ]);
3688 @end example
3690 This pragma is identical in syntax and semantics to pragma
3691 @code{Export} as defined in the Ada Reference Manual.  It is
3692 provided for compatibility with some Ada 83 compilers that
3693 used this pragma for exactly the same purposes as pragma
3694 @code{Export} before the latter was standardized.
3696 @node Pragma External_Name_Casing,Pragma Fast_Math,Pragma External,Implementation Defined Pragmas
3697 @anchor{gnat_rm/implementation_defined_pragmas pragma-external-name-casing}@anchor{6b}
3698 @section Pragma External_Name_Casing
3701 @geindex Dec Ada 83 casing compatibility
3703 @geindex External Names
3704 @geindex casing
3706 @geindex Casing of External names
3708 Syntax:
3710 @example
3711 pragma External_Name_Casing (
3712   Uppercase | Lowercase
3713   [, Uppercase | Lowercase | As_Is]);
3714 @end example
3716 This pragma provides control over the casing of external names associated
3717 with Import and Export pragmas.  There are two cases to consider:
3720 @itemize *
3722 @item 
3723 Implicit external names
3725 Implicit external names are derived from identifiers.  The most common case
3726 arises when a standard Ada Import or Export pragma is used with only two
3727 arguments, as in:
3729 @example
3730 pragma Import (C, C_Routine);
3731 @end example
3733 Since Ada is a case-insensitive language, the spelling of the identifier in
3734 the Ada source program does not provide any information on the desired
3735 casing of the external name, and so a convention is needed.  In GNAT the
3736 default treatment is that such names are converted to all lower case
3737 letters.  This corresponds to the normal C style in many environments.
3738 The first argument of pragma @code{External_Name_Casing} can be used to
3739 control this treatment.  If @code{Uppercase} is specified, then the name
3740 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3741 then the normal default of all lower case letters will be used.
3743 This same implicit treatment is also used in the case of extended DEC Ada 83
3744 compatible Import and Export pragmas where an external name is explicitly
3745 specified using an identifier rather than a string.
3747 @item 
3748 Explicit external names
3750 Explicit external names are given as string literals.  The most common case
3751 arises when a standard Ada Import or Export pragma is used with three
3752 arguments, as in:
3754 @example
3755 pragma Import (C, C_Routine, "C_routine");
3756 @end example
3758 In this case, the string literal normally provides the exact casing required
3759 for the external name.  The second argument of pragma
3760 @code{External_Name_Casing} may be used to modify this behavior.
3761 If @code{Uppercase} is specified, then the name
3762 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3763 then the name will be forced to all lowercase letters.  A specification of
3764 @code{As_Is} provides the normal default behavior in which the casing is
3765 taken from the string provided.
3766 @end itemize
3768 This pragma may appear anywhere that a pragma is valid. In particular, it
3769 can be used as a configuration pragma in the @code{gnat.adc} file, in which
3770 case it applies to all subsequent compilations, or it can be used as a program
3771 unit pragma, in which case it only applies to the current unit, or it can
3772 be used more locally to control individual Import/Export pragmas.
3774 It was primarily intended for use with OpenVMS systems, where many
3775 compilers convert all symbols to upper case by default.  For interfacing to
3776 such compilers (e.g., the DEC C compiler), it may be convenient to use
3777 the pragma:
3779 @example
3780 pragma External_Name_Casing (Uppercase, Uppercase);
3781 @end example
3783 to enforce the upper casing of all external symbols.
3785 @node Pragma Fast_Math,Pragma Favor_Top_Level,Pragma External_Name_Casing,Implementation Defined Pragmas
3786 @anchor{gnat_rm/implementation_defined_pragmas pragma-fast-math}@anchor{6c}
3787 @section Pragma Fast_Math
3790 Syntax:
3792 @example
3793 pragma Fast_Math;
3794 @end example
3796 This is a configuration pragma which activates a mode in which speed is
3797 considered more important for floating-point operations than absolutely
3798 accurate adherence to the requirements of the standard. Currently the
3799 following operations are affected:
3802 @table @asis
3804 @item `Complex Multiplication'
3806 The normal simple formula for complex multiplication can result in intermediate
3807 overflows for numbers near the end of the range. The Ada standard requires that
3808 this situation be detected and corrected by scaling, but in Fast_Math mode such
3809 cases will simply result in overflow. Note that to take advantage of this you
3810 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3811 under control of the pragma, rather than use the preinstantiated versions.
3812 @end table
3814 @node Pragma Favor_Top_Level,Pragma Finalize_Storage_Only,Pragma Fast_Math,Implementation Defined Pragmas
3815 @anchor{gnat_rm/implementation_defined_pragmas id14}@anchor{6d}@anchor{gnat_rm/implementation_defined_pragmas pragma-favor-top-level}@anchor{6e}
3816 @section Pragma Favor_Top_Level
3819 Syntax:
3821 @example
3822 pragma Favor_Top_Level (type_NAME);
3823 @end example
3825 The argument of pragma @code{Favor_Top_Level} must be a named access-to-subprogram
3826 type. This pragma is an efficiency hint to the compiler, regarding the use of
3827 @code{'Access} or @code{'Unrestricted_Access} on nested (non-library-level) subprograms.
3828 The pragma means that nested subprograms are not used with this type, or are
3829 rare, so that the generated code should be efficient in the top-level case.
3830 When this pragma is used, dynamically generated trampolines may be used on some
3831 targets for nested subprograms. See restriction @code{No_Implicit_Dynamic_Code}.
3833 @node Pragma Finalize_Storage_Only,Pragma Float_Representation,Pragma Favor_Top_Level,Implementation Defined Pragmas
3834 @anchor{gnat_rm/implementation_defined_pragmas pragma-finalize-storage-only}@anchor{6f}
3835 @section Pragma Finalize_Storage_Only
3838 Syntax:
3840 @example
3841 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3842 @end example
3844 The argument of pragma @code{Finalize_Storage_Only} must denote a local type which
3845 is derived from @code{Ada.Finalization.Controlled} or @code{Limited_Controlled}. The
3846 pragma suppresses the call to @code{Finalize} for declared library-level objects
3847 of the argument type. This is mostly useful for types where finalization is
3848 only used to deal with storage reclamation since in most environments it is
3849 not necessary to reclaim memory just before terminating execution, hence the
3850 name. Note that this pragma does not suppress Finalize calls for library-level
3851 heap-allocated objects (see pragma @code{No_Heap_Finalization}).
3853 @node Pragma Float_Representation,Pragma Ghost,Pragma Finalize_Storage_Only,Implementation Defined Pragmas
3854 @anchor{gnat_rm/implementation_defined_pragmas pragma-float-representation}@anchor{70}
3855 @section Pragma Float_Representation
3858 Syntax:
3860 @example
3861 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3863 FLOAT_REP ::= VAX_Float | IEEE_Float
3864 @end example
3866 In the one argument form, this pragma is a configuration pragma which
3867 allows control over the internal representation chosen for the predefined
3868 floating point types declared in the packages @code{Standard} and
3869 @code{System}. This pragma is only provided for compatibility and has no effect.
3871 The two argument form specifies the representation to be used for
3872 the specified floating-point type. The argument must
3873 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3876 @itemize *
3878 @item 
3879 For a digits value of 6, 32-bit IEEE short format will be used.
3881 @item 
3882 For a digits value of 15, 64-bit IEEE long format will be used.
3884 @item 
3885 No other value of digits is permitted.
3886 @end itemize
3888 @node Pragma Ghost,Pragma Global,Pragma Float_Representation,Implementation Defined Pragmas
3889 @anchor{gnat_rm/implementation_defined_pragmas id15}@anchor{71}@anchor{gnat_rm/implementation_defined_pragmas pragma-ghost}@anchor{72}
3890 @section Pragma Ghost
3893 Syntax:
3895 @example
3896 pragma Ghost [ (static_boolean_EXPRESSION) ];
3897 @end example
3899 For the semantics of this pragma, see the entry for aspect @code{Ghost} in the SPARK
3900 2014 Reference Manual, section 6.9.
3902 @node Pragma Global,Pragma Ident,Pragma Ghost,Implementation Defined Pragmas
3903 @anchor{gnat_rm/implementation_defined_pragmas id16}@anchor{73}@anchor{gnat_rm/implementation_defined_pragmas pragma-global}@anchor{74}
3904 @section Pragma Global
3907 Syntax:
3909 @example
3910 pragma Global (GLOBAL_SPECIFICATION);
3912 GLOBAL_SPECIFICATION ::=
3913      null
3914   | (GLOBAL_LIST)
3915   | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
3917 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
3919 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
3920 GLOBAL_LIST   ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
3921 GLOBAL_ITEM   ::= NAME
3922 @end example
3924 For the semantics of this pragma, see the entry for aspect @code{Global} in the
3925 SPARK 2014 Reference Manual, section 6.1.4.
3927 @node Pragma Ident,Pragma Ignore_Pragma,Pragma Global,Implementation Defined Pragmas
3928 @anchor{gnat_rm/implementation_defined_pragmas pragma-ident}@anchor{75}
3929 @section Pragma Ident
3932 Syntax:
3934 @example
3935 pragma Ident (static_string_EXPRESSION);
3936 @end example
3938 This pragma is identical in effect to pragma @code{Comment}. It is provided
3939 for compatibility with other Ada compilers providing this pragma.
3941 @node Pragma Ignore_Pragma,Pragma Implementation_Defined,Pragma Ident,Implementation Defined Pragmas
3942 @anchor{gnat_rm/implementation_defined_pragmas pragma-ignore-pragma}@anchor{76}
3943 @section Pragma Ignore_Pragma
3946 Syntax:
3948 @example
3949 pragma Ignore_Pragma (pragma_IDENTIFIER);
3950 @end example
3952 This is a configuration pragma
3953 that takes a single argument that is a simple identifier. Any subsequent
3954 use of a pragma whose pragma identifier matches this argument will be
3955 silently ignored. This may be useful when legacy code or code intended
3956 for compilation with some other compiler contains pragmas that match the
3957 name, but not the exact implementation, of a GNAT pragma. The use of this
3958 pragma allows such pragmas to be ignored, which may be useful in CodePeer
3959 mode, or during porting of legacy code.
3961 @node Pragma Implementation_Defined,Pragma Implemented,Pragma Ignore_Pragma,Implementation Defined Pragmas
3962 @anchor{gnat_rm/implementation_defined_pragmas pragma-implementation-defined}@anchor{77}
3963 @section Pragma Implementation_Defined
3966 Syntax:
3968 @example
3969 pragma Implementation_Defined (local_NAME);
3970 @end example
3972 This pragma marks a previously declared entity as implementation-defined.
3973 For an overloaded entity, applies to the most recent homonym.
3975 @example
3976 pragma Implementation_Defined;
3977 @end example
3979 The form with no arguments appears anywhere within a scope, most
3980 typically a package spec, and indicates that all entities that are
3981 defined within the package spec are Implementation_Defined.
3983 This pragma is used within the GNAT runtime library to identify
3984 implementation-defined entities introduced in language-defined units,
3985 for the purpose of implementing the No_Implementation_Identifiers
3986 restriction.
3988 @node Pragma Implemented,Pragma Implicit_Packing,Pragma Implementation_Defined,Implementation Defined Pragmas
3989 @anchor{gnat_rm/implementation_defined_pragmas pragma-implemented}@anchor{78}
3990 @section Pragma Implemented
3993 Syntax:
3995 @example
3996 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3998 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3999 @end example
4001 This is an Ada 2012 representation pragma which applies to protected, task
4002 and synchronized interface primitives. The use of pragma Implemented provides
4003 a way to impose a static requirement on the overriding operation by adhering
4004 to one of the three implementation kinds: entry, protected procedure or any of
4005 the above. This pragma is available in all earlier versions of Ada as an
4006 implementation-defined pragma.
4008 @example
4009 type Synch_Iface is synchronized interface;
4010 procedure Prim_Op (Obj : in out Iface) is abstract;
4011 pragma Implemented (Prim_Op, By_Protected_Procedure);
4013 protected type Prot_1 is new Synch_Iface with
4014    procedure Prim_Op;  --  Legal
4015 end Prot_1;
4017 protected type Prot_2 is new Synch_Iface with
4018    entry Prim_Op;      --  Illegal
4019 end Prot_2;
4021 task type Task_Typ is new Synch_Iface with
4022    entry Prim_Op;      --  Illegal
4023 end Task_Typ;
4024 @end example
4026 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
4027 Implemented determines the runtime behavior of the requeue. Implementation kind
4028 By_Entry guarantees that the action of requeueing will proceed from an entry to
4029 another entry. Implementation kind By_Protected_Procedure transforms the
4030 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
4031 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
4032 the target’s overriding subprogram kind.
4034 @node Pragma Implicit_Packing,Pragma Import_Function,Pragma Implemented,Implementation Defined Pragmas
4035 @anchor{gnat_rm/implementation_defined_pragmas pragma-implicit-packing}@anchor{79}
4036 @section Pragma Implicit_Packing
4039 @geindex Rational Profile
4041 Syntax:
4043 @example
4044 pragma Implicit_Packing;
4045 @end example
4047 This is a configuration pragma that requests implicit packing for packed
4048 arrays for which a size clause is given but no explicit pragma Pack or
4049 specification of Component_Size is present. It also applies to records
4050 where no record representation clause is present. Consider this example:
4052 @example
4053 type R is array (0 .. 7) of Boolean;
4054 for R'Size use 8;
4055 @end example
4057 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
4058 does not change the layout of a composite object. So the Size clause in the
4059 above example is normally rejected, since the default layout of the array uses
4060 8-bit components, and thus the array requires a minimum of 64 bits.
4062 If this declaration is compiled in a region of code covered by an occurrence
4063 of the configuration pragma Implicit_Packing, then the Size clause in this
4064 and similar examples will cause implicit packing and thus be accepted. For
4065 this implicit packing to occur, the type in question must be an array of small
4066 components whose size is known at compile time, and the Size clause must
4067 specify the exact size that corresponds to the number of elements in the array
4068 multiplied by the size in bits of the component type (both single and
4069 multi-dimensioned arrays can be controlled with this pragma).
4071 @geindex Array packing
4073 Similarly, the following example shows the use in the record case
4075 @example
4076 type r is record
4077    a, b, c, d, e, f, g, h : boolean;
4078    chr                    : character;
4079 end record;
4080 for r'size use 16;
4081 @end example
4083 Without a pragma Pack, each Boolean field requires 8 bits, so the
4084 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
4085 sufficient. The use of pragma Implicit_Packing allows this record
4086 declaration to compile without an explicit pragma Pack.
4088 @node Pragma Import_Function,Pragma Import_Object,Pragma Implicit_Packing,Implementation Defined Pragmas
4089 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-function}@anchor{7a}
4090 @section Pragma Import_Function
4093 Syntax:
4095 @example
4096 pragma Import_Function (
4097      [Internal         =>] LOCAL_NAME,
4098   [, [External         =>] EXTERNAL_SYMBOL]
4099   [, [Parameter_Types  =>] PARAMETER_TYPES]
4100   [, [Result_Type      =>] SUBTYPE_MARK]
4101   [, [Mechanism        =>] MECHANISM]
4102   [, [Result_Mechanism =>] MECHANISM_NAME]);
4104 EXTERNAL_SYMBOL ::=
4105   IDENTIFIER
4106 | static_string_EXPRESSION
4108 PARAMETER_TYPES ::=
4109   null
4110 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4112 TYPE_DESIGNATOR ::=
4113   subtype_NAME
4114 | subtype_Name ' Access
4116 MECHANISM ::=
4117   MECHANISM_NAME
4118 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4120 MECHANISM_ASSOCIATION ::=
4121   [formal_parameter_NAME =>] MECHANISM_NAME
4123 MECHANISM_NAME ::=
4124   Value
4125 | Reference
4126 @end example
4128 This pragma is used in conjunction with a pragma @code{Import} to
4129 specify additional information for an imported function.  The pragma
4130 @code{Import} (or equivalent pragma @code{Interface}) must precede the
4131 @code{Import_Function} pragma and both must appear in the same
4132 declarative part as the function specification.
4134 The @code{Internal} argument must uniquely designate
4135 the function to which the
4136 pragma applies.  If more than one function name exists of this name in
4137 the declarative part you must use the @code{Parameter_Types} and
4138 @code{Result_Type} parameters to achieve the required unique
4139 designation.  Subtype marks in these parameters must exactly match the
4140 subtypes in the corresponding function specification, using positional
4141 notation to match parameters with subtype marks.
4142 The form with an @code{'Access} attribute can be used to match an
4143 anonymous access parameter.
4145 You may optionally use the @code{Mechanism} and @code{Result_Mechanism}
4146 parameters to specify passing mechanisms for the
4147 parameters and result.  If you specify a single mechanism name, it
4148 applies to all parameters.  Otherwise you may specify a mechanism on a
4149 parameter by parameter basis using either positional or named
4150 notation.  If the mechanism is not specified, the default mechanism
4151 is used.
4153 @node Pragma Import_Object,Pragma Import_Procedure,Pragma Import_Function,Implementation Defined Pragmas
4154 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-object}@anchor{7b}
4155 @section Pragma Import_Object
4158 Syntax:
4160 @example
4161 pragma Import_Object (
4162      [Internal =>] LOCAL_NAME
4163   [, [External =>] EXTERNAL_SYMBOL]
4164   [, [Size     =>] EXTERNAL_SYMBOL]);
4166 EXTERNAL_SYMBOL ::=
4167   IDENTIFIER
4168 | static_string_EXPRESSION
4169 @end example
4171 This pragma designates an object as imported, and apart from the
4172 extended rules for external symbols, is identical in effect to the use of
4173 the normal @code{Import} pragma applied to an object.  Unlike the
4174 subprogram case, you need not use a separate @code{Import} pragma,
4175 although you may do so (and probably should do so from a portability
4176 point of view).  @code{size} is syntax checked, but otherwise ignored by
4177 GNAT.
4179 @node Pragma Import_Procedure,Pragma Import_Valued_Procedure,Pragma Import_Object,Implementation Defined Pragmas
4180 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-procedure}@anchor{7c}
4181 @section Pragma Import_Procedure
4184 Syntax:
4186 @example
4187 pragma Import_Procedure (
4188      [Internal        =>] LOCAL_NAME
4189   [, [External        =>] EXTERNAL_SYMBOL]
4190   [, [Parameter_Types =>] PARAMETER_TYPES]
4191   [, [Mechanism       =>] MECHANISM]);
4193 EXTERNAL_SYMBOL ::=
4194   IDENTIFIER
4195 | static_string_EXPRESSION
4197 PARAMETER_TYPES ::=
4198   null
4199 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4201 TYPE_DESIGNATOR ::=
4202   subtype_NAME
4203 | subtype_Name ' Access
4205 MECHANISM ::=
4206   MECHANISM_NAME
4207 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4209 MECHANISM_ASSOCIATION ::=
4210   [formal_parameter_NAME =>] MECHANISM_NAME
4212 MECHANISM_NAME ::= Value | Reference
4213 @end example
4215 This pragma is identical to @code{Import_Function} except that it
4216 applies to a procedure rather than a function and the parameters
4217 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
4219 @node Pragma Import_Valued_Procedure,Pragma Independent,Pragma Import_Procedure,Implementation Defined Pragmas
4220 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-valued-procedure}@anchor{7d}
4221 @section Pragma Import_Valued_Procedure
4224 Syntax:
4226 @example
4227 pragma Import_Valued_Procedure (
4228      [Internal        =>] LOCAL_NAME
4229   [, [External        =>] EXTERNAL_SYMBOL]
4230   [, [Parameter_Types =>] PARAMETER_TYPES]
4231   [, [Mechanism       =>] MECHANISM]);
4233 EXTERNAL_SYMBOL ::=
4234   IDENTIFIER
4235 | static_string_EXPRESSION
4237 PARAMETER_TYPES ::=
4238   null
4239 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4241 TYPE_DESIGNATOR ::=
4242   subtype_NAME
4243 | subtype_Name ' Access
4245 MECHANISM ::=
4246   MECHANISM_NAME
4247 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4249 MECHANISM_ASSOCIATION ::=
4250   [formal_parameter_NAME =>] MECHANISM_NAME
4252 MECHANISM_NAME ::= Value | Reference
4253 @end example
4255 This pragma is identical to @code{Import_Procedure} except that the
4256 first parameter of @code{LOCAL_NAME}, which must be present, must be of
4257 mode @code{out}, and externally the subprogram is treated as a function
4258 with this parameter as the result of the function.  The purpose of this
4259 capability is to allow the use of @code{out} and @code{in out}
4260 parameters in interfacing to external functions (which are not permitted
4261 in Ada functions).  You may optionally use the @code{Mechanism}
4262 parameters to specify passing mechanisms for the parameters.
4263 If you specify a single mechanism name, it applies to all parameters.
4264 Otherwise you may specify a mechanism on a parameter by parameter
4265 basis using either positional or named notation.  If the mechanism is not
4266 specified, the default mechanism is used.
4268 Note that it is important to use this pragma in conjunction with a separate
4269 pragma Import that specifies the desired convention, since otherwise the
4270 default convention is Ada, which is almost certainly not what is required.
4272 @node Pragma Independent,Pragma Independent_Components,Pragma Import_Valued_Procedure,Implementation Defined Pragmas
4273 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent}@anchor{7e}
4274 @section Pragma Independent
4277 Syntax:
4279 @example
4280 pragma Independent (Local_NAME);
4281 @end example
4283 This pragma is standard in Ada 2012 mode (which also provides an aspect
4284 of the same name). It is also available as an implementation-defined
4285 pragma in all earlier versions. It specifies that the
4286 designated object or all objects of the designated type must be
4287 independently addressable. This means that separate tasks can safely
4288 manipulate such objects. For example, if two components of a record are
4289 independent, then two separate tasks may access these two components.
4290 This may place
4291 constraints on the representation of the object (for instance prohibiting
4292 tight packing).
4294 @node Pragma Independent_Components,Pragma Initial_Condition,Pragma Independent,Implementation Defined Pragmas
4295 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent-components}@anchor{7f}
4296 @section Pragma Independent_Components
4299 Syntax:
4301 @example
4302 pragma Independent_Components (Local_NAME);
4303 @end example
4305 This pragma is standard in Ada 2012 mode (which also provides an aspect
4306 of the same name). It is also available as an implementation-defined
4307 pragma in all earlier versions. It specifies that the components of the
4308 designated object, or the components of each object of the designated
4309 type, must be
4310 independently addressable. This means that separate tasks can safely
4311 manipulate separate components in the composite object. This may place
4312 constraints on the representation of the object (for instance prohibiting
4313 tight packing).
4315 @node Pragma Initial_Condition,Pragma Initialize_Scalars,Pragma Independent_Components,Implementation Defined Pragmas
4316 @anchor{gnat_rm/implementation_defined_pragmas id17}@anchor{80}@anchor{gnat_rm/implementation_defined_pragmas pragma-initial-condition}@anchor{81}
4317 @section Pragma Initial_Condition
4320 Syntax:
4322 @example
4323 pragma Initial_Condition (boolean_EXPRESSION);
4324 @end example
4326 For the semantics of this pragma, see the entry for aspect @code{Initial_Condition}
4327 in the SPARK 2014 Reference Manual, section 7.1.6.
4329 @node Pragma Initialize_Scalars,Pragma Initializes,Pragma Initial_Condition,Implementation Defined Pragmas
4330 @anchor{gnat_rm/implementation_defined_pragmas pragma-initialize-scalars}@anchor{82}
4331 @section Pragma Initialize_Scalars
4334 @geindex debugging with Initialize_Scalars
4336 Syntax:
4338 @example
4339 pragma Initialize_Scalars
4340   [ ( TYPE_VALUE_PAIR @{, TYPE_VALUE_PAIR@} ) ];
4342 TYPE_VALUE_PAIR ::=
4343   SCALAR_TYPE => static_EXPRESSION
4345 SCALAR_TYPE :=
4346   Short_Float
4347 | Float
4348 | Long_Float
4349 | Long_Long_Flat
4350 | Signed_8
4351 | Signed_16
4352 | Signed_32
4353 | Signed_64
4354 | Unsigned_8
4355 | Unsigned_16
4356 | Unsigned_32
4357 | Unsigned_64
4358 @end example
4360 This pragma is similar to @code{Normalize_Scalars} conceptually but has two
4361 important differences.
4363 First, there is no requirement for the pragma to be used uniformly in all units
4364 of a partition. In particular, it is fine to use this just for some or all of
4365 the application units of a partition, without needing to recompile the run-time
4366 library. In the case where some units are compiled with the pragma, and some
4367 without, then a declaration of a variable where the type is defined in package
4368 Standard or is locally declared will always be subject to initialization, as
4369 will any declaration of a scalar variable. For composite variables, whether the
4370 variable is initialized may also depend on whether the package in which the
4371 type of the variable is declared is compiled with the pragma.
4373 The other important difference is that the programmer can control the value
4374 used for initializing scalar objects. This effect can be achieved in several
4375 different ways:
4378 @itemize *
4380 @item 
4381 At compile time, the programmer can specify the invalid value for a
4382 particular family of scalar types using the optional arguments of the pragma.
4384 The compile-time approach is intended to optimize the generated code for the
4385 pragma, by possibly using fast operations such as @code{memset}. Note that such
4386 optimizations require using values where the bytes all have the same binary
4387 representation.
4389 @item 
4390 At bind time, the programmer has several options:
4393 @itemize *
4395 @item 
4396 Initialization with invalid values (similar to Normalize_Scalars, though
4397 for Initialize_Scalars it is not always possible to determine the invalid
4398 values in complex cases like signed component fields with nonstandard
4399 sizes).
4401 @item 
4402 Initialization with high values.
4404 @item 
4405 Initialization with low values.
4407 @item 
4408 Initialization with a specific bit pattern.
4409 @end itemize
4411 See the GNAT User’s Guide for binder options for specifying these cases.
4413 The bind-time approach is intended to provide fast turnaround for testing
4414 with different values, without having to recompile the program.
4416 @item 
4417 At execution time, the programmer can specify the invalid values using an
4418 environment variable. See the GNAT User’s Guide for details.
4420 The execution-time approach is intended to provide fast turnaround for
4421 testing with different values, without having to recompile and rebind the
4422 program.
4423 @end itemize
4425 Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction
4426 with the enhanced validity checking that is now provided in GNAT, which checks
4427 for invalid values under more conditions. Using this feature (see description
4428 of the `-gnatV' flag in the GNAT User’s Guide) in conjunction with pragma
4429 @code{Initialize_Scalars} provides a powerful new tool to assist in the detection
4430 of problems caused by uninitialized variables.
4432 Note: the use of @code{Initialize_Scalars} has a fairly extensive effect on the
4433 generated code. This may cause your code to be substantially larger. It may
4434 also cause an increase in the amount of stack required, so it is probably a
4435 good idea to turn on stack checking (see description of stack checking in the
4436 GNAT User’s Guide) when using this pragma.
4438 @node Pragma Initializes,Pragma Inline_Always,Pragma Initialize_Scalars,Implementation Defined Pragmas
4439 @anchor{gnat_rm/implementation_defined_pragmas id18}@anchor{83}@anchor{gnat_rm/implementation_defined_pragmas pragma-initializes}@anchor{84}
4440 @section Pragma Initializes
4443 Syntax:
4445 @example
4446 pragma Initializes (INITIALIZATION_LIST);
4448 INITIALIZATION_LIST ::=
4449      null
4450   | (INITIALIZATION_ITEM @{, INITIALIZATION_ITEM@})
4452 INITIALIZATION_ITEM ::= name [=> INPUT_LIST]
4454 INPUT_LIST ::=
4455      null
4456   |  INPUT
4457   | (INPUT @{, INPUT@})
4459 INPUT ::= name
4460 @end example
4462 For the semantics of this pragma, see the entry for aspect @code{Initializes} in the
4463 SPARK 2014 Reference Manual, section 7.1.5.
4465 @node Pragma Inline_Always,Pragma Inline_Generic,Pragma Initializes,Implementation Defined Pragmas
4466 @anchor{gnat_rm/implementation_defined_pragmas id19}@anchor{85}@anchor{gnat_rm/implementation_defined_pragmas pragma-inline-always}@anchor{86}
4467 @section Pragma Inline_Always
4470 Syntax:
4472 @example
4473 pragma Inline_Always (NAME [, NAME]);
4474 @end example
4476 Similar to pragma @code{Inline} except that inlining is unconditional.
4477 Inline_Always instructs the compiler to inline every direct call to the
4478 subprogram or else to emit a compilation error, independently of any
4479 option, in particular `-gnatn' or `-gnatN' or the optimization level.
4480 It is an error to take the address or access of @code{NAME}. It is also an error to
4481 apply this pragma to a primitive operation of a tagged type. Thanks to such
4482 restrictions, the compiler is allowed to remove the out-of-line body of @code{NAME}.
4484 @node Pragma Inline_Generic,Pragma Interface,Pragma Inline_Always,Implementation Defined Pragmas
4485 @anchor{gnat_rm/implementation_defined_pragmas pragma-inline-generic}@anchor{87}
4486 @section Pragma Inline_Generic
4489 Syntax:
4491 @example
4492 pragma Inline_Generic (GNAME @{, GNAME@});
4494 GNAME ::= generic_unit_NAME | generic_instance_NAME
4495 @end example
4497 This pragma is provided for compatibility with Dec Ada 83. It has
4498 no effect in GNAT (which always inlines generics), other
4499 than to check that the given names are all names of generic units or
4500 generic instances.
4502 @node Pragma Interface,Pragma Interface_Name,Pragma Inline_Generic,Implementation Defined Pragmas
4503 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface}@anchor{88}
4504 @section Pragma Interface
4507 Syntax:
4509 @example
4510 pragma Interface (
4511      [Convention    =>] convention_identifier,
4512      [Entity        =>] local_NAME
4513   [, [External_Name =>] static_string_expression]
4514   [, [Link_Name     =>] static_string_expression]);
4515 @end example
4517 This pragma is identical in syntax and semantics to
4518 the standard Ada pragma @code{Import}.  It is provided for compatibility
4519 with Ada 83.  The definition is upwards compatible both with pragma
4520 @code{Interface} as defined in the Ada 83 Reference Manual, and also
4521 with some extended implementations of this pragma in certain Ada 83
4522 implementations.  The only difference between pragma @code{Interface}
4523 and pragma @code{Import} is that there is special circuitry to allow
4524 both pragmas to appear for the same subprogram entity (normally it
4525 is illegal to have multiple @code{Import} pragmas). This is useful in
4526 maintaining Ada 83/Ada 95 compatibility and is compatible with other
4527 Ada 83 compilers.
4529 @node Pragma Interface_Name,Pragma Interrupt_Handler,Pragma Interface,Implementation Defined Pragmas
4530 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface-name}@anchor{89}
4531 @section Pragma Interface_Name
4534 Syntax:
4536 @example
4537 pragma Interface_Name (
4538      [Entity        =>] LOCAL_NAME
4539   [, [External_Name =>] static_string_EXPRESSION]
4540   [, [Link_Name     =>] static_string_EXPRESSION]);
4541 @end example
4543 This pragma provides an alternative way of specifying the interface name
4544 for an interfaced subprogram, and is provided for compatibility with Ada
4545 83 compilers that use the pragma for this purpose.  You must provide at
4546 least one of @code{External_Name} or @code{Link_Name}.
4548 @node Pragma Interrupt_Handler,Pragma Interrupt_State,Pragma Interface_Name,Implementation Defined Pragmas
4549 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-handler}@anchor{8a}
4550 @section Pragma Interrupt_Handler
4553 Syntax:
4555 @example
4556 pragma Interrupt_Handler (procedure_LOCAL_NAME);
4557 @end example
4559 This program unit pragma is supported for parameterless protected procedures
4560 as described in Annex C of the Ada Reference Manual.
4562 @node Pragma Interrupt_State,Pragma Invariant,Pragma Interrupt_Handler,Implementation Defined Pragmas
4563 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-state}@anchor{8b}
4564 @section Pragma Interrupt_State
4567 Syntax:
4569 @example
4570 pragma Interrupt_State
4571  ([Name  =>] value,
4572   [State =>] SYSTEM | RUNTIME | USER);
4573 @end example
4575 Normally certain interrupts are reserved to the implementation.  Any attempt
4576 to attach an interrupt causes Program_Error to be raised, as described in
4577 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4578 many systems for an @code{Ctrl-C} interrupt.  Normally this interrupt is
4579 reserved to the implementation, so that @code{Ctrl-C} can be used to
4580 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
4581 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
4582 Ada exceptions, or used to implement run-time functions such as the
4583 @code{abort} statement and stack overflow checking.
4585 Pragma @code{Interrupt_State} provides a general mechanism for overriding
4586 such uses of interrupts.  It subsumes the functionality of pragma
4587 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
4588 available on Windows.  On all other platforms than VxWorks,
4589 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
4590 and may be used to mark interrupts required by the board support package
4591 as reserved.
4593 Interrupts can be in one of three states:
4596 @itemize *
4598 @item 
4599 System
4601 The interrupt is reserved (no Ada handler can be installed), and the
4602 Ada run-time may not install a handler. As a result you are guaranteed
4603 standard system default action if this interrupt is raised. This also allows
4604 installing a low level handler via C APIs such as sigaction(), outside
4605 of Ada control.
4607 @item 
4608 Runtime
4610 The interrupt is reserved (no Ada handler can be installed). The run time
4611 is allowed to install a handler for internal control purposes, but is
4612 not required to do so.
4614 @item 
4615 User
4617 The interrupt is unreserved.  The user may install an Ada handler via
4618 Ada.Interrupts and pragma Interrupt_Handler or Attach_Handler to provide
4619 some other action.
4620 @end itemize
4622 These states are the allowed values of the @code{State} parameter of the
4623 pragma.  The @code{Name} parameter is a value of the type
4624 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4625 @code{Ada.Interrupts.Names}.
4627 This is a configuration pragma, and the binder will check that there
4628 are no inconsistencies between different units in a partition in how a
4629 given interrupt is specified. It may appear anywhere a pragma is legal.
4631 The effect is to move the interrupt to the specified state.
4633 By declaring interrupts to be SYSTEM, you guarantee the standard system
4634 action, such as a core dump.
4636 By declaring interrupts to be USER, you guarantee that you can install
4637 a handler.
4639 Note that certain signals on many operating systems cannot be caught and
4640 handled by applications.  In such cases, the pragma is ignored.  See the
4641 operating system documentation, or the value of the array @code{Reserved}
4642 declared in the spec of package @code{System.OS_Interface}.
4644 Overriding the default state of signals used by the Ada runtime may interfere
4645 with an application’s runtime behavior in the cases of the synchronous signals,
4646 and in the case of the signal used to implement the @code{abort} statement.
4648 @node Pragma Invariant,Pragma Keep_Names,Pragma Interrupt_State,Implementation Defined Pragmas
4649 @anchor{gnat_rm/implementation_defined_pragmas id20}@anchor{8c}@anchor{gnat_rm/implementation_defined_pragmas pragma-invariant}@anchor{8d}
4650 @section Pragma Invariant
4653 Syntax:
4655 @example
4656 pragma Invariant
4657   ([Entity =>]    private_type_LOCAL_NAME,
4658    [Check  =>]    EXPRESSION
4659    [,[Message =>] String_Expression]);
4660 @end example
4662 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4663 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4664 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4665 requires the use of the aspect syntax, which is not available except in 2012
4666 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4667 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4668 note that the aspect Invariant is a synonym in GNAT for the aspect
4669 Type_Invariant, but there is no pragma Type_Invariant.
4671 The pragma must appear within the visible part of the package specification,
4672 after the type to which its Entity argument appears. As with the Invariant
4673 aspect, the Check expression is not analyzed until the end of the visible
4674 part of the package, so it may contain forward references. The Message
4675 argument, if present, provides the exception message used if the invariant
4676 is violated. If no Message parameter is provided, a default message that
4677 identifies the line on which the pragma appears is used.
4679 It is permissible to have multiple Invariants for the same type entity, in
4680 which case they are and’ed together. It is permissible to use this pragma
4681 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4682 invariant pragma for the same entity.
4684 For further details on the use of this pragma, see the Ada 2012 documentation
4685 of the Type_Invariant aspect.
4687 @node Pragma Keep_Names,Pragma License,Pragma Invariant,Implementation Defined Pragmas
4688 @anchor{gnat_rm/implementation_defined_pragmas pragma-keep-names}@anchor{8e}
4689 @section Pragma Keep_Names
4692 Syntax:
4694 @example
4695 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4696 @end example
4698 The @code{LOCAL_NAME} argument
4699 must refer to an enumeration first subtype
4700 in the current declarative part. The effect is to retain the enumeration
4701 literal names for use by @code{Image} and @code{Value} even if a global
4702 @code{Discard_Names} pragma applies. This is useful when you want to
4703 generally suppress enumeration literal names and for example you therefore
4704 use a @code{Discard_Names} pragma in the @code{gnat.adc} file, but you
4705 want to retain the names for specific enumeration types.
4707 @node Pragma License,Pragma Link_With,Pragma Keep_Names,Implementation Defined Pragmas
4708 @anchor{gnat_rm/implementation_defined_pragmas pragma-license}@anchor{8f}
4709 @section Pragma License
4712 @geindex License checking
4714 Syntax:
4716 @example
4717 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4718 @end example
4720 This pragma is provided to allow automated checking for appropriate license
4721 conditions with respect to the standard and modified GPL.  A pragma
4722 @code{License}, which is a configuration pragma that typically appears at
4723 the start of a source file or in a separate @code{gnat.adc} file, specifies
4724 the licensing conditions of a unit as follows:
4727 @itemize *
4729 @item 
4730 Unrestricted
4731 This is used for a unit that can be freely used with no license restrictions.
4732 Examples of such units are public domain units, and units from the Ada
4733 Reference Manual.
4735 @item 
4737 This is used for a unit that is licensed under the unmodified GPL, and which
4738 therefore cannot be @code{with}ed by a restricted unit.
4740 @item 
4741 Modified_GPL
4742 This is used for a unit licensed under the GNAT modified GPL that includes
4743 a special exception paragraph that specifically permits the inclusion of
4744 the unit in programs without requiring the entire program to be released
4745 under the GPL.
4747 @item 
4748 Restricted
4749 This is used for a unit that is restricted in that it is not permitted to
4750 depend on units that are licensed under the GPL.  Typical examples are
4751 proprietary code that is to be released under more restrictive license
4752 conditions.  Note that restricted units are permitted to @code{with} units
4753 which are licensed under the modified GPL (this is the whole point of the
4754 modified GPL).
4755 @end itemize
4757 Normally a unit with no @code{License} pragma is considered to have an
4758 unknown license, and no checking is done.  However, standard GNAT headers
4759 are recognized, and license information is derived from them as follows.
4761 A GNAT license header starts with a line containing 78 hyphens.  The following
4762 comment text is searched for the appearance of any of the following strings.
4764 If the string ‘GNU General Public License’ is found, then the unit is assumed
4765 to have GPL license, unless the string ‘As a special exception’ follows, in
4766 which case the license is assumed to be modified GPL.
4768 If one of the strings
4769 ‘This specification is adapted from the Ada Semantic Interface’ or
4770 ‘This specification is derived from the Ada Reference Manual’ is found
4771 then the unit is assumed to be unrestricted.
4773 These default actions means that a program with a restricted license pragma
4774 will automatically get warnings if a GPL unit is inappropriately
4775 @code{with}ed.  For example, the program:
4777 @example
4778 with Sem_Ch3;
4779 with GNAT.Sockets;
4780 procedure Secret_Stuff is
4781   ...
4782 end Secret_Stuff
4783 @end example
4785 if compiled with pragma @code{License} (@code{Restricted}) in a
4786 @code{gnat.adc} file will generate the warning:
4788 @example
4789 1.  with Sem_Ch3;
4790         |
4791    >>> license of withed unit "Sem_Ch3" is incompatible
4793 2.  with GNAT.Sockets;
4794 3.  procedure Secret_Stuff is
4795 @end example
4797 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4798 compiler and is licensed under the
4799 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4800 run time, and is therefore licensed under the modified GPL.
4802 @node Pragma Link_With,Pragma Linker_Alias,Pragma License,Implementation Defined Pragmas
4803 @anchor{gnat_rm/implementation_defined_pragmas pragma-link-with}@anchor{90}
4804 @section Pragma Link_With
4807 Syntax:
4809 @example
4810 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4811 @end example
4813 This pragma is provided for compatibility with certain Ada 83 compilers.
4814 It has exactly the same effect as pragma @code{Linker_Options} except
4815 that spaces occurring within one of the string expressions are treated
4816 as separators. For example, in the following case:
4818 @example
4819 pragma Link_With ("-labc -ldef");
4820 @end example
4822 results in passing the strings @code{-labc} and @code{-ldef} as two
4823 separate arguments to the linker. In addition pragma Link_With allows
4824 multiple arguments, with the same effect as successive pragmas.
4826 @node Pragma Linker_Alias,Pragma Linker_Constructor,Pragma Link_With,Implementation Defined Pragmas
4827 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-alias}@anchor{91}
4828 @section Pragma Linker_Alias
4831 Syntax:
4833 @example
4834 pragma Linker_Alias (
4835   [Entity =>] LOCAL_NAME,
4836   [Target =>] static_string_EXPRESSION);
4837 @end example
4839 @code{LOCAL_NAME} must refer to an object that is declared at the library
4840 level. This pragma establishes the given entity as a linker alias for the
4841 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4842 and causes @code{LOCAL_NAME} to be emitted as an alias for the symbol
4843 @code{static_string_EXPRESSION} in the object file, that is to say no space
4844 is reserved for @code{LOCAL_NAME} by the assembler and it will be resolved
4845 to the same address as @code{static_string_EXPRESSION} by the linker.
4847 The actual linker name for the target must be used (e.g., the fully
4848 encoded name with qualification in Ada, or the mangled name in C++),
4849 or it must be declared using the C convention with @code{pragma Import}
4850 or @code{pragma Export}.
4852 Not all target machines support this pragma. On some of them it is accepted
4853 only if @code{pragma Weak_External} has been applied to @code{LOCAL_NAME}.
4855 @example
4856 --  Example of the use of pragma Linker_Alias
4858 package p is
4859   i : Integer := 1;
4860   pragma Export (C, i);
4862   new_name_for_i : Integer;
4863   pragma Linker_Alias (new_name_for_i, "i");
4864 end p;
4865 @end example
4867 @node Pragma Linker_Constructor,Pragma Linker_Destructor,Pragma Linker_Alias,Implementation Defined Pragmas
4868 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-constructor}@anchor{92}
4869 @section Pragma Linker_Constructor
4872 Syntax:
4874 @example
4875 pragma Linker_Constructor (procedure_LOCAL_NAME);
4876 @end example
4878 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4879 is declared at the library level. A procedure to which this pragma is
4880 applied will be treated as an initialization routine by the linker.
4881 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4882 causes @code{procedure_LOCAL_NAME} to be invoked before the entry point
4883 of the executable is called (or immediately after the shared library is
4884 loaded if the procedure is linked in a shared library), in particular
4885 before the Ada run-time environment is set up.
4887 Because of these specific contexts, the set of operations such a procedure
4888 can perform is very limited and the type of objects it can manipulate is
4889 essentially restricted to the elementary types. In particular, it must only
4890 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4892 This pragma is used by GNAT to implement auto-initialization of shared Stand
4893 Alone Libraries, which provides a related capability without the restrictions
4894 listed above. Where possible, the use of Stand Alone Libraries is preferable
4895 to the use of this pragma.
4897 @node Pragma Linker_Destructor,Pragma Linker_Section,Pragma Linker_Constructor,Implementation Defined Pragmas
4898 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-destructor}@anchor{93}
4899 @section Pragma Linker_Destructor
4902 Syntax:
4904 @example
4905 pragma Linker_Destructor (procedure_LOCAL_NAME);
4906 @end example
4908 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4909 is declared at the library level. A procedure to which this pragma is
4910 applied will be treated as a finalization routine by the linker.
4911 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4912 causes @code{procedure_LOCAL_NAME} to be invoked after the entry point
4913 of the executable has exited (or immediately before the shared library
4914 is unloaded if the procedure is linked in a shared library), in particular
4915 after the Ada run-time environment is shut down.
4917 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4918 because of these specific contexts.
4920 @node Pragma Linker_Section,Pragma Lock_Free,Pragma Linker_Destructor,Implementation Defined Pragmas
4921 @anchor{gnat_rm/implementation_defined_pragmas id21}@anchor{94}@anchor{gnat_rm/implementation_defined_pragmas pragma-linker-section}@anchor{95}
4922 @section Pragma Linker_Section
4925 Syntax:
4927 @example
4928 pragma Linker_Section (
4929   [Entity  =>] LOCAL_NAME,
4930   [Section =>] static_string_EXPRESSION);
4931 @end example
4933 @code{LOCAL_NAME} must refer to an object, type, or subprogram that is
4934 declared at the library level. This pragma specifies the name of the
4935 linker section for the given entity. It is equivalent to
4936 @code{__attribute__((section))} in GNU C and causes @code{LOCAL_NAME} to
4937 be placed in the @code{static_string_EXPRESSION} section of the
4938 executable (assuming the linker doesn’t rename the section).
4939 GNAT also provides an implementation defined aspect of the same name.
4941 In the case of specifying this aspect for a type, the effect is to
4942 specify the corresponding section for all library-level objects of
4943 the type that do not have an explicit linker section set. Note that
4944 this only applies to whole objects, not to components of composite objects.
4946 In the case of a subprogram, the linker section applies to all previously
4947 declared matching overloaded subprograms in the current declarative part
4948 which do not already have a linker section assigned. The linker section
4949 aspect is useful in this case for specifying different linker sections
4950 for different elements of such an overloaded set.
4952 Note that an empty string specifies that no linker section is specified.
4953 This is not quite the same as omitting the pragma or aspect, since it
4954 can be used to specify that one element of an overloaded set of subprograms
4955 has the default linker section, or that one object of a type for which a
4956 linker section is specified should has the default linker section.
4958 The compiler normally places library-level entities in standard sections
4959 depending on the class: procedures and functions generally go in the
4960 @code{.text} section, initialized variables in the @code{.data} section
4961 and uninitialized variables in the @code{.bss} section.
4963 Other, special sections may exist on given target machines to map special
4964 hardware, for example I/O ports or flash memory. This pragma is a means to
4965 defer the final layout of the executable to the linker, thus fully working
4966 at the symbolic level with the compiler.
4968 Some file formats do not support arbitrary sections so not all target
4969 machines support this pragma. The use of this pragma may cause a program
4970 execution to be erroneous if it is used to place an entity into an
4971 inappropriate section (e.g., a modified variable into the @code{.text}
4972 section). See also @code{pragma Persistent_BSS}.
4974 @example
4975 --  Example of the use of pragma Linker_Section
4977 package IO_Card is
4978   Port_A : Integer;
4979   pragma Volatile (Port_A);
4980   pragma Linker_Section (Port_A, ".bss.port_a");
4982   Port_B : Integer;
4983   pragma Volatile (Port_B);
4984   pragma Linker_Section (Port_B, ".bss.port_b");
4986   type Port_Type is new Integer with Linker_Section => ".bss";
4987   PA : Port_Type with Linker_Section => ".bss.PA";
4988   PB : Port_Type; --  ends up in linker section ".bss"
4990   procedure Q with Linker_Section => "Qsection";
4991 end IO_Card;
4992 @end example
4994 @node Pragma Lock_Free,Pragma Loop_Invariant,Pragma Linker_Section,Implementation Defined Pragmas
4995 @anchor{gnat_rm/implementation_defined_pragmas id22}@anchor{96}@anchor{gnat_rm/implementation_defined_pragmas pragma-lock-free}@anchor{97}
4996 @section Pragma Lock_Free
4999 Syntax:
5000 This pragma may be specified for protected types or objects. It specifies that
5001 the implementation of protected operations must be implemented without locks.
5002 Compilation fails if the compiler cannot generate lock-free code for the
5003 operations.
5005 The current conditions required to support this pragma are:
5008 @itemize *
5010 @item 
5011 Protected type declarations may not contain entries
5013 @item 
5014 Protected subprogram declarations may not have nonelementary parameters
5015 @end itemize
5017 In addition, each protected subprogram body must satisfy:
5020 @itemize *
5022 @item 
5023 May reference only one protected component
5025 @item 
5026 May not reference nonconstant entities outside the protected subprogram
5027 scope
5029 @item 
5030 May not contain address representation items, allocators, or quantified
5031 expressions
5033 @item 
5034 May not contain delay, goto, loop, or procedure-call statements
5036 @item 
5037 May not contain exported and imported entities
5039 @item 
5040 May not dereferenced access values
5042 @item 
5043 Function calls and attribute references must be static
5044 @end itemize
5046 If the Lock_Free aspect is specified to be True for a protected unit
5047 and the Ceiling_Locking locking policy is in effect, then the run-time
5048 actions associated with the Ceiling_Locking locking policy (described in
5049 Ada RM D.3) are not performed when a protected operation of the protected
5050 unit is executed.
5052 @node Pragma Loop_Invariant,Pragma Loop_Optimize,Pragma Lock_Free,Implementation Defined Pragmas
5053 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-invariant}@anchor{98}
5054 @section Pragma Loop_Invariant
5057 Syntax:
5059 @example
5060 pragma Loop_Invariant ( boolean_EXPRESSION );
5061 @end example
5063 The effect of this pragma is similar to that of pragma @code{Assert},
5064 except that in an @code{Assertion_Policy} pragma, the identifier
5065 @code{Loop_Invariant} is used to control whether it is ignored or checked
5066 (or disabled).
5068 @code{Loop_Invariant} can only appear as one of the items in the sequence
5069 of statements of a loop body, or nested inside block statements that
5070 appear in the sequence of statements of a loop body.
5071 The intention is that it be used to
5072 represent a “loop invariant” assertion, i.e. something that is true each
5073 time through the loop, and which can be used to show that the loop is
5074 achieving its purpose.
5076 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5077 apply to the same loop should be grouped in the same sequence of
5078 statements.
5080 To aid in writing such invariants, the special attribute @code{Loop_Entry}
5081 may be used to refer to the value of an expression on entry to the loop. This
5082 attribute can only be used within the expression of a @code{Loop_Invariant}
5083 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
5085 @node Pragma Loop_Optimize,Pragma Loop_Variant,Pragma Loop_Invariant,Implementation Defined Pragmas
5086 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-optimize}@anchor{99}
5087 @section Pragma Loop_Optimize
5090 Syntax:
5092 @example
5093 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
5095 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
5096 @end example
5098 This pragma must appear immediately within a loop statement.  It allows the
5099 programmer to specify optimization hints for the enclosing loop.  The hints
5100 are not mutually exclusive and can be freely mixed, but not all combinations
5101 will yield a sensible outcome.
5103 There are five supported optimization hints for a loop:
5106 @itemize *
5108 @item 
5109 Ivdep
5111 The programmer asserts that there are no loop-carried dependencies
5112 which would prevent consecutive iterations of the loop from being
5113 executed simultaneously.
5115 @item 
5116 No_Unroll
5118 The loop must not be unrolled.  This is a strong hint: the compiler will not
5119 unroll a loop marked with this hint.
5121 @item 
5122 Unroll
5124 The loop should be unrolled.  This is a weak hint: the compiler will try to
5125 apply unrolling to this loop preferably to other optimizations, notably
5126 vectorization, but there is no guarantee that the loop will be unrolled.
5128 @item 
5129 No_Vector
5131 The loop must not be vectorized.  This is a strong hint: the compiler will not
5132 vectorize a loop marked with this hint.
5134 @item 
5135 Vector
5137 The loop should be vectorized.  This is a weak hint: the compiler will try to
5138 apply vectorization to this loop preferably to other optimizations, notably
5139 unrolling, but there is no guarantee that the loop will be vectorized.
5140 @end itemize
5142 These hints do not remove the need to pass the appropriate switches to the
5143 compiler in order to enable the relevant optimizations, that is to say
5144 `-funroll-loops' for unrolling and `-ftree-vectorize' for
5145 vectorization.
5147 @node Pragma Loop_Variant,Pragma Machine_Attribute,Pragma Loop_Optimize,Implementation Defined Pragmas
5148 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-variant}@anchor{9a}
5149 @section Pragma Loop_Variant
5152 Syntax:
5154 @example
5155 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
5156 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
5157 CHANGE_DIRECTION ::= Increases | Decreases
5158 @end example
5160 @code{Loop_Variant} can only appear as one of the items in the sequence
5161 of statements of a loop body, or nested inside block statements that
5162 appear in the sequence of statements of a loop body.
5163 It allows the specification of quantities which must always
5164 decrease or increase in successive iterations of the loop. In its simplest
5165 form, just one expression is specified, whose value must increase or decrease
5166 on each iteration of the loop.
5168 In a more complex form, multiple arguments can be given which are interpreted
5169 in a nesting lexicographic manner. For example:
5171 @example
5172 pragma Loop_Variant (Increases => X, Decreases => Y);
5173 @end example
5175 specifies that each time through the loop either X increases, or X stays
5176 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
5177 loop is making progress. It can be useful in helping to show informally
5178 or prove formally that the loop always terminates.
5180 @code{Loop_Variant} is an assertion whose effect can be controlled using
5181 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
5182 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
5183 to ignore the check (in which case the pragma has no effect on the program),
5184 or @code{Disable} in which case the pragma is not even checked for correct
5185 syntax.
5187 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5188 apply to the same loop should be grouped in the same sequence of
5189 statements.
5191 The @code{Loop_Entry} attribute may be used within the expressions of the
5192 @code{Loop_Variant} pragma to refer to values on entry to the loop.
5194 @node Pragma Machine_Attribute,Pragma Main,Pragma Loop_Variant,Implementation Defined Pragmas
5195 @anchor{gnat_rm/implementation_defined_pragmas pragma-machine-attribute}@anchor{9b}
5196 @section Pragma Machine_Attribute
5199 Syntax:
5201 @example
5202 pragma Machine_Attribute (
5203      [Entity         =>] LOCAL_NAME,
5204      [Attribute_Name =>] static_string_EXPRESSION
5205   [, [Info           =>] static_EXPRESSION @{, static_EXPRESSION@}] );
5206 @end example
5208 Machine-dependent attributes can be specified for types and/or
5209 declarations.  This pragma is semantically equivalent to
5210 @code{__attribute__((@var{attribute_name}))} (if @code{info} is not
5211 specified) or @code{__attribute__((@var{attribute_name(info})))}
5212 or @code{__attribute__((@var{attribute_name(info,...})))} in GNU C,
5213 where `attribute_name' is recognized by the compiler middle-end
5214 or the @code{TARGET_ATTRIBUTE_TABLE} machine specific macro.  Note
5215 that a string literal for the optional parameter @code{info} or the
5216 following ones is transformed by default into an identifier,
5217 which may make this pragma unusable for some attributes.
5218 For further information see @cite{GNU Compiler Collection (GCC) Internals}.
5220 @node Pragma Main,Pragma Main_Storage,Pragma Machine_Attribute,Implementation Defined Pragmas
5221 @anchor{gnat_rm/implementation_defined_pragmas pragma-main}@anchor{9c}
5222 @section Pragma Main
5225 Syntax:
5227 @example
5228 pragma Main
5229  (MAIN_OPTION [, MAIN_OPTION]);
5231 MAIN_OPTION ::=
5232   [Stack_Size              =>] static_integer_EXPRESSION
5233 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
5234 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
5235 @end example
5237 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
5238 no effect in GNAT, other than being syntax checked.
5240 @node Pragma Main_Storage,Pragma Max_Queue_Length,Pragma Main,Implementation Defined Pragmas
5241 @anchor{gnat_rm/implementation_defined_pragmas pragma-main-storage}@anchor{9d}
5242 @section Pragma Main_Storage
5245 Syntax:
5247 @example
5248 pragma Main_Storage
5249   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
5251 MAIN_STORAGE_OPTION ::=
5252   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
5253 | [TOP_GUARD       =>] static_SIMPLE_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 Max_Queue_Length,Pragma No_Body,Pragma Main_Storage,Implementation Defined Pragmas
5260 @anchor{gnat_rm/implementation_defined_pragmas id23}@anchor{9e}@anchor{gnat_rm/implementation_defined_pragmas pragma-max-queue-length}@anchor{9f}
5261 @section Pragma Max_Queue_Length
5264 Syntax:
5266 @example
5267 pragma Max_Entry_Queue (static_integer_EXPRESSION);
5268 @end example
5270 This pragma is used to specify the maximum callers per entry queue for
5271 individual protected entries and entry families. It accepts a single
5272 integer (-1 or more) as a parameter and must appear after the declaration of an
5273 entry.
5275 A value of -1 represents no additional restriction on queue length.
5277 @node Pragma No_Body,Pragma No_Caching,Pragma Max_Queue_Length,Implementation Defined Pragmas
5278 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-body}@anchor{a0}
5279 @section Pragma No_Body
5282 Syntax:
5284 @example
5285 pragma No_Body;
5286 @end example
5288 There are a number of cases in which a package spec does not require a body,
5289 and in fact a body is not permitted. GNAT will not permit the spec to be
5290 compiled if there is a body around. The pragma No_Body allows you to provide
5291 a body file, even in a case where no body is allowed. The body file must
5292 contain only comments and a single No_Body pragma. This is recognized by
5293 the compiler as indicating that no body is logically present.
5295 This is particularly useful during maintenance when a package is modified in
5296 such a way that a body needed before is no longer needed. The provision of a
5297 dummy body with a No_Body pragma ensures that there is no interference from
5298 earlier versions of the package body.
5300 @node Pragma No_Caching,Pragma No_Component_Reordering,Pragma No_Body,Implementation Defined Pragmas
5301 @anchor{gnat_rm/implementation_defined_pragmas id24}@anchor{a1}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-caching}@anchor{a2}
5302 @section Pragma No_Caching
5305 Syntax:
5307 @example
5308 pragma No_Caching [ (static_boolean_EXPRESSION) ];
5309 @end example
5311 For the semantics of this pragma, see the entry for aspect @code{No_Caching} in
5312 the SPARK 2014 Reference Manual, section 7.1.2.
5314 @node Pragma No_Component_Reordering,Pragma No_Elaboration_Code_All,Pragma No_Caching,Implementation Defined Pragmas
5315 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-component-reordering}@anchor{a3}
5316 @section Pragma No_Component_Reordering
5319 Syntax:
5321 @example
5322 pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
5323 @end example
5325 @code{type_LOCAL_NAME} must refer to a record type declaration in the current
5326 declarative part. The effect is to preclude any reordering of components
5327 for the layout of the record, i.e. the record is laid out by the compiler
5328 in the order in which the components are declared textually. The form with
5329 no argument is a configuration pragma which applies to all record types
5330 declared in units to which the pragma applies and there is a requirement
5331 that this pragma be used consistently within a partition.
5333 @node Pragma No_Elaboration_Code_All,Pragma No_Heap_Finalization,Pragma No_Component_Reordering,Implementation Defined Pragmas
5334 @anchor{gnat_rm/implementation_defined_pragmas id25}@anchor{a4}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-elaboration-code-all}@anchor{a5}
5335 @section Pragma No_Elaboration_Code_All
5338 Syntax:
5340 @example
5341 pragma No_Elaboration_Code_All [(program_unit_NAME)];
5342 @end example
5344 This is a program unit pragma (there is also an equivalent aspect of the
5345 same name) that establishes the restriction @code{No_Elaboration_Code} for
5346 the current unit and any extended main source units (body and subunits).
5347 It also has the effect of enforcing a transitive application of this
5348 aspect, so that if any unit is implicitly or explicitly with’ed by the
5349 current unit, it must also have the No_Elaboration_Code_All aspect set.
5350 It may be applied to package or subprogram specs or their generic versions.
5352 @node Pragma No_Heap_Finalization,Pragma No_Inline,Pragma No_Elaboration_Code_All,Implementation Defined Pragmas
5353 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-heap-finalization}@anchor{a6}
5354 @section Pragma No_Heap_Finalization
5357 Syntax:
5359 @example
5360 pragma No_Heap_Finalization [ (first_subtype_LOCAL_NAME) ];
5361 @end example
5363 Pragma @code{No_Heap_Finalization} may be used as a configuration pragma or as a
5364 type-specific pragma.
5366 In its configuration form, the pragma must appear within a configuration file
5367 such as gnat.adc, without an argument. The pragma suppresses the call to
5368 @code{Finalize} for heap-allocated objects created through library-level named
5369 access-to-object types in cases where the designated type requires finalization
5370 actions.
5372 In its type-specific form, the argument of the pragma must denote a
5373 library-level named access-to-object type. The pragma suppresses the call to
5374 @code{Finalize} for heap-allocated objects created through the specific access type
5375 in cases where the designated type requires finalization actions.
5377 It is still possible to finalize such heap-allocated objects by explicitly
5378 deallocating them.
5380 A library-level named access-to-object type declared within a generic unit will
5381 lose its @code{No_Heap_Finalization} pragma when the corresponding instance does not
5382 appear at the library level.
5384 @node Pragma No_Inline,Pragma No_Return,Pragma No_Heap_Finalization,Implementation Defined Pragmas
5385 @anchor{gnat_rm/implementation_defined_pragmas id26}@anchor{a7}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-inline}@anchor{a8}
5386 @section Pragma No_Inline
5389 Syntax:
5391 @example
5392 pragma No_Inline (NAME @{, NAME@});
5393 @end example
5395 This pragma suppresses inlining for the callable entity or the instances of
5396 the generic subprogram designated by @code{NAME}, including inlining that
5397 results from the use of pragma @code{Inline}.  This pragma is always active,
5398 in particular it is not subject to the use of option `-gnatn' or
5399 `-gnatN'.  It is illegal to specify both pragma @code{No_Inline} and
5400 pragma @code{Inline_Always} for the same @code{NAME}.
5402 @node Pragma No_Return,Pragma No_Strict_Aliasing,Pragma No_Inline,Implementation Defined Pragmas
5403 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-return}@anchor{a9}
5404 @section Pragma No_Return
5407 Syntax:
5409 @example
5410 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
5411 @end example
5413 Each @code{procedure_LOCAL_NAME} argument must refer to one or more procedure
5414 declarations in the current declarative part.  A procedure to which this
5415 pragma is applied may not contain any explicit @code{return} statements.
5416 In addition, if the procedure contains any implicit returns from falling
5417 off the end of a statement sequence, then execution of that implicit
5418 return will cause Program_Error to be raised.
5420 One use of this pragma is to identify procedures whose only purpose is to raise
5421 an exception. Another use of this pragma is to suppress incorrect warnings
5422 about missing returns in functions, where the last statement of a function
5423 statement sequence is a call to such a procedure.
5425 Note that in Ada 2005 mode, this pragma is part of the language. It is
5426 available in all earlier versions of Ada as an implementation-defined
5427 pragma.
5429 @node Pragma No_Strict_Aliasing,Pragma No_Tagged_Streams,Pragma No_Return,Implementation Defined Pragmas
5430 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-strict-aliasing}@anchor{aa}
5431 @section Pragma No_Strict_Aliasing
5434 Syntax:
5436 @example
5437 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
5438 @end example
5440 @code{type_LOCAL_NAME} must refer to an access type
5441 declaration in the current declarative part.  The effect is to inhibit
5442 strict aliasing optimization for the given type.  The form with no
5443 arguments is a configuration pragma which applies to all access types
5444 declared in units to which the pragma applies. For a detailed
5445 description of the strict aliasing optimization, and the situations
5446 in which it must be suppressed, see the section on Optimization and Strict Aliasing
5447 in the @cite{GNAT User’s Guide}.
5449 This pragma currently has no effects on access to unconstrained array types.
5451 @node Pragma No_Tagged_Streams,Pragma Normalize_Scalars,Pragma No_Strict_Aliasing,Implementation Defined Pragmas
5452 @anchor{gnat_rm/implementation_defined_pragmas id27}@anchor{ab}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-tagged-streams}@anchor{ac}
5453 @section Pragma No_Tagged_Streams
5456 Syntax:
5458 @example
5459 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
5460 @end example
5462 Normally when a tagged type is introduced using a full type declaration,
5463 part of the processing includes generating stream access routines to be
5464 used by stream attributes referencing the type (or one of its subtypes
5465 or derived types). This can involve the generation of significant amounts
5466 of code which is wasted space if stream routines are not needed for the
5467 type in question.
5469 The @code{No_Tagged_Streams} pragma causes the generation of these stream
5470 routines to be skipped, and any attempt to use stream operations on
5471 types subject to this pragma will be statically rejected as illegal.
5473 There are two forms of the pragma. The form with no arguments must appear
5474 in a declarative sequence or in the declarations of a package spec. This
5475 pragma affects all subsequent root tagged types declared in the declaration
5476 sequence, and specifies that no stream routines be generated. The form with
5477 an argument (for which there is also a corresponding aspect) specifies a
5478 single root tagged type for which stream routines are not to be generated.
5480 Once the pragma has been given for a particular root tagged type, all subtypes
5481 and derived types of this type inherit the pragma automatically, so the effect
5482 applies to a complete hierarchy (this is necessary to deal with the class-wide
5483 dispatching versions of the stream routines).
5485 When pragmas @code{Discard_Names} and @code{No_Tagged_Streams} are simultaneously
5486 applied to a tagged type its Expanded_Name and External_Tag are initialized
5487 with empty strings. This is useful to avoid exposing entity names at binary
5488 level but has a negative impact on the debuggability of tagged types.
5490 @node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas
5491 @anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{ad}
5492 @section Pragma Normalize_Scalars
5495 Syntax:
5497 @example
5498 pragma Normalize_Scalars;
5499 @end example
5501 This is a language defined pragma which is fully implemented in GNAT.  The
5502 effect is to cause all scalar objects that are not otherwise initialized
5503 to be initialized.  The initial values are implementation dependent and
5504 are as follows:
5507 @table @asis
5509 @item `Standard.Character'
5511 Objects whose root type is Standard.Character are initialized to
5512 Character’Last unless the subtype range excludes NUL (in which case
5513 NUL is used). This choice will always generate an invalid value if
5514 one exists.
5516 @item `Standard.Wide_Character'
5518 Objects whose root type is Standard.Wide_Character are initialized to
5519 Wide_Character’Last unless the subtype range excludes NUL (in which case
5520 NUL is used). This choice will always generate an invalid value if
5521 one exists.
5523 @item `Standard.Wide_Wide_Character'
5525 Objects whose root type is Standard.Wide_Wide_Character are initialized to
5526 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
5527 which case NUL is used). This choice will always generate an invalid value if
5528 one exists.
5530 @item `Integer types'
5532 Objects of an integer type are treated differently depending on whether
5533 negative values are present in the subtype. If no negative values are
5534 present, then all one bits is used as the initial value except in the
5535 special case where zero is excluded from the subtype, in which case
5536 all zero bits are used. This choice will always generate an invalid
5537 value if one exists.
5539 For subtypes with negative values present, the largest negative number
5540 is used, except in the unusual case where this largest negative number
5541 is in the subtype, and the largest positive number is not, in which case
5542 the largest positive value is used. This choice will always generate
5543 an invalid value if one exists.
5545 @item `Floating-Point Types'
5547 Objects of all floating-point types are initialized to all 1-bits. For
5548 standard IEEE format, this corresponds to a NaN (not a number) which is
5549 indeed an invalid value.
5551 @item `Fixed-Point Types'
5553 Objects of all fixed-point types are treated as described above for integers,
5554 with the rules applying to the underlying integer value used to represent
5555 the fixed-point value.
5557 @item `Modular types'
5559 Objects of a modular type are initialized to all one bits, except in
5560 the special case where zero is excluded from the subtype, in which
5561 case all zero bits are used. This choice will always generate an
5562 invalid value if one exists.
5564 @item `Enumeration types'
5566 Objects of an enumeration type are initialized to all one-bits, i.e., to
5567 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
5568 whose Pos value is zero, in which case a code of zero is used. This choice
5569 will always generate an invalid value if one exists.
5570 @end table
5572 @node Pragma Obsolescent,Pragma Optimize_Alignment,Pragma Normalize_Scalars,Implementation Defined Pragmas
5573 @anchor{gnat_rm/implementation_defined_pragmas id28}@anchor{ae}@anchor{gnat_rm/implementation_defined_pragmas pragma-obsolescent}@anchor{af}
5574 @section Pragma Obsolescent
5577 Syntax:
5579 @example
5580 pragma Obsolescent;
5582 pragma Obsolescent (
5583   [Message =>] static_string_EXPRESSION
5584 [,[Version =>] Ada_05]);
5586 pragma Obsolescent (
5587   [Entity  =>] NAME
5588 [,[Message =>] static_string_EXPRESSION
5589 [,[Version =>] Ada_05]]);
5590 @end example
5592 This pragma can occur immediately following a declaration of an entity,
5593 including the case of a record component. If no Entity argument is present,
5594 then this declaration is the one to which the pragma applies. If an Entity
5595 parameter is present, it must either match the name of the entity in this
5596 declaration, or alternatively, the pragma can immediately follow an enumeration
5597 type declaration, where the Entity argument names one of the enumeration
5598 literals.
5600 This pragma is used to indicate that the named entity
5601 is considered obsolescent and should not be used. Typically this is
5602 used when an API must be modified by eventually removing or modifying
5603 existing subprograms or other entities. The pragma can be used at an
5604 intermediate stage when the entity is still present, but will be
5605 removed later.
5607 The effect of this pragma is to output a warning message on a reference to
5608 an entity thus marked that the subprogram is obsolescent if the appropriate
5609 warning option in the compiler is activated. If the @code{Message} parameter is
5610 present, then a second warning message is given containing this text. In
5611 addition, a reference to the entity is considered to be a violation of pragma
5612 @code{Restrictions (No_Obsolescent_Features)}.
5614 This pragma can also be used as a program unit pragma for a package,
5615 in which case the entity name is the name of the package, and the
5616 pragma indicates that the entire package is considered
5617 obsolescent. In this case a client @code{with}ing such a package
5618 violates the restriction, and the @code{with} clause is
5619 flagged with warnings if the warning option is set.
5621 If the @code{Version} parameter is present (which must be exactly
5622 the identifier @code{Ada_05}, no other argument is allowed), then the
5623 indication of obsolescence applies only when compiling in Ada 2005
5624 mode. This is primarily intended for dealing with the situations
5625 in the predefined library where subprograms or packages
5626 have become defined as obsolescent in Ada 2005
5627 (e.g., in @code{Ada.Characters.Handling}), but may be used anywhere.
5629 The following examples show typical uses of this pragma:
5631 @example
5632 package p is
5633    pragma Obsolescent (p, Message => "use pp instead of p");
5634 end p;
5636 package q is
5637    procedure q2;
5638    pragma Obsolescent ("use q2new instead");
5640    type R is new integer;
5641    pragma Obsolescent
5642      (Entity  => R,
5643       Message => "use RR in Ada 2005",
5644       Version => Ada_05);
5646    type M is record
5647       F1 : Integer;
5648       F2 : Integer;
5649       pragma Obsolescent;
5650       F3 : Integer;
5651    end record;
5653    type E is (a, bc, 'd', quack);
5654    pragma Obsolescent (Entity => bc)
5655    pragma Obsolescent (Entity => 'd')
5657    function "+"
5658      (a, b : character) return character;
5659    pragma Obsolescent (Entity => "+");
5660 end;
5661 @end example
5663 Note that, as for all pragmas, if you use a pragma argument identifier,
5664 then all subsequent parameters must also use a pragma argument identifier.
5665 So if you specify @code{Entity =>} for the @code{Entity} argument, and a @code{Message}
5666 argument is present, it must be preceded by @code{Message =>}.
5668 @node Pragma Optimize_Alignment,Pragma Ordered,Pragma Obsolescent,Implementation Defined Pragmas
5669 @anchor{gnat_rm/implementation_defined_pragmas pragma-optimize-alignment}@anchor{b0}
5670 @section Pragma Optimize_Alignment
5673 @geindex Alignment
5674 @geindex default settings
5676 Syntax:
5678 @example
5679 pragma Optimize_Alignment (TIME | SPACE | OFF);
5680 @end example
5682 This is a configuration pragma which affects the choice of default alignments
5683 for types and objects where no alignment is explicitly specified. There is a
5684 time/space trade-off in the selection of these values. Large alignments result
5685 in more efficient code, at the expense of larger data space, since sizes have
5686 to be increased to match these alignments. Smaller alignments save space, but
5687 the access code is slower. The normal choice of default alignments for types
5688 and individual alignment promotions for objects (which is what you get if you
5689 do not use this pragma, or if you use an argument of OFF), tries to balance
5690 these two requirements.
5692 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5693 First any packed record is given an alignment of 1. Second, if a size is given
5694 for the type, then the alignment is chosen to avoid increasing this size. For
5695 example, consider:
5697 @example
5698 type R is record
5699    X : Integer;
5700    Y : Character;
5701 end record;
5703 for R'Size use 5*8;
5704 @end example
5706 In the default mode, this type gets an alignment of 4, so that access to the
5707 Integer field X are efficient. But this means that objects of the type end up
5708 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5709 allowed to be bigger than the size of the type, but it can waste space if for
5710 example fields of type R appear in an enclosing record. If the above type is
5711 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5713 However, there is one case in which SPACE is ignored. If a variable length
5714 record (that is a discriminated record with a component which is an array
5715 whose length depends on a discriminant), has a pragma Pack, then it is not
5716 in general possible to set the alignment of such a record to one, so the
5717 pragma is ignored in this case (with a warning).
5719 Specifying SPACE also disables alignment promotions for standalone objects,
5720 which occur when the compiler increases the alignment of a specific object
5721 without changing the alignment of its type.
5723 Specifying SPACE also disables component reordering in unpacked record types,
5724 which can result in larger sizes in order to meet alignment requirements.
5726 Specifying TIME causes larger default alignments to be chosen in the case of
5727 small types with sizes that are not a power of 2. For example, consider:
5729 @example
5730 type R is record
5731    A : Character;
5732    B : Character;
5733    C : Boolean;
5734 end record;
5736 pragma Pack (R);
5737 for R'Size use 17;
5738 @end example
5740 The default alignment for this record is normally 1, but if this type is
5741 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5742 to 4, which wastes space for objects of the type, since they are now 4 bytes
5743 long, but results in more efficient access when the whole record is referenced.
5745 As noted above, this is a configuration pragma, and there is a requirement
5746 that all units in a partition be compiled with a consistent setting of the
5747 optimization setting. This would normally be achieved by use of a configuration
5748 pragma file containing the appropriate setting. The exception to this rule is
5749 that units with an explicit configuration pragma in the same file as the source
5750 unit are excluded from the consistency check, as are all predefined units. The
5751 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5752 pragma appears at the start of the file.
5754 @node Pragma Ordered,Pragma Overflow_Mode,Pragma Optimize_Alignment,Implementation Defined Pragmas
5755 @anchor{gnat_rm/implementation_defined_pragmas pragma-ordered}@anchor{b1}
5756 @section Pragma Ordered
5759 Syntax:
5761 @example
5762 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5763 @end example
5765 Most enumeration types are from a conceptual point of view unordered.
5766 For example, consider:
5768 @example
5769 type Color is (Red, Blue, Green, Yellow);
5770 @end example
5772 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5773 but really these relations make no sense; the enumeration type merely
5774 specifies a set of possible colors, and the order is unimportant.
5776 For unordered enumeration types, it is generally a good idea if
5777 clients avoid comparisons (other than equality or inequality) and
5778 explicit ranges. (A `client' is a unit where the type is referenced,
5779 other than the unit where the type is declared, its body, and its subunits.)
5780 For example, if code buried in some client says:
5782 @example
5783 if Current_Color < Yellow then ...
5784 if Current_Color in Blue .. Green then ...
5785 @end example
5787 then the client code is relying on the order, which is undesirable.
5788 It makes the code hard to read and creates maintenance difficulties if
5789 entries have to be added to the enumeration type. Instead,
5790 the code in the client should list the possibilities, or an
5791 appropriate subtype should be declared in the unit that declares
5792 the original enumeration type. E.g., the following subtype could
5793 be declared along with the type @code{Color}:
5795 @example
5796 subtype RBG is Color range Red .. Green;
5797 @end example
5799 and then the client could write:
5801 @example
5802 if Current_Color in RBG then ...
5803 if Current_Color = Blue or Current_Color = Green then ...
5804 @end example
5806 However, some enumeration types are legitimately ordered from a conceptual
5807 point of view. For example, if you declare:
5809 @example
5810 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5811 @end example
5813 then the ordering imposed by the language is reasonable, and
5814 clients can depend on it, writing for example:
5816 @example
5817 if D in Mon .. Fri then ...
5818 if D < Wed then ...
5819 @end example
5821 The pragma `Ordered' is provided to mark enumeration types that
5822 are conceptually ordered, alerting the reader that clients may depend
5823 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5824 rather than one to mark them as unordered, since in our experience,
5825 the great majority of enumeration types are conceptually unordered.
5827 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5828 and @code{Wide_Wide_Character}
5829 are considered to be ordered types, so each is declared with a
5830 pragma @code{Ordered} in package @code{Standard}.
5832 Normally pragma @code{Ordered} serves only as documentation and a guide for
5833 coding standards, but GNAT provides a warning switch `-gnatw.u' that
5834 requests warnings for inappropriate uses (comparisons and explicit
5835 subranges) for unordered types. If this switch is used, then any
5836 enumeration type not marked with pragma @code{Ordered} will be considered
5837 as unordered, and will generate warnings for inappropriate uses.
5839 Note that generic types are not considered ordered or unordered (since the
5840 template can be instantiated for both cases), so we never generate warnings
5841 for the case of generic enumerated types.
5843 For additional information please refer to the description of the
5844 `-gnatw.u' switch in the GNAT User’s Guide.
5846 @node Pragma Overflow_Mode,Pragma Overriding_Renamings,Pragma Ordered,Implementation Defined Pragmas
5847 @anchor{gnat_rm/implementation_defined_pragmas pragma-overflow-mode}@anchor{b2}
5848 @section Pragma Overflow_Mode
5851 Syntax:
5853 @example
5854 pragma Overflow_Mode
5855  (  [General    =>] MODE
5856   [,[Assertions =>] MODE]);
5858 MODE ::= STRICT | MINIMIZED | ELIMINATED
5859 @end example
5861 This pragma sets the current overflow mode to the given setting. For details
5862 of the meaning of these modes, please refer to the
5863 ‘Overflow Check Handling in GNAT’ appendix in the
5864 GNAT User’s Guide. If only the @code{General} parameter is present,
5865 the given mode applies to all expressions. If both parameters are present,
5866 the @code{General} mode applies to expressions outside assertions, and
5867 the @code{Eliminated} mode applies to expressions within assertions.
5869 The case of the @code{MODE} parameter is ignored,
5870 so @code{MINIMIZED}, @code{Minimized} and
5871 @code{minimized} all have the same effect.
5873 The @code{Overflow_Mode} pragma has the same scoping and placement
5874 rules as pragma @code{Suppress}, so it can occur either as a
5875 configuration pragma, specifying a default for the whole
5876 program, or in a declarative scope, where it applies to the
5877 remaining declarations and statements in that scope.
5879 The pragma @code{Suppress (Overflow_Check)} suppresses
5880 overflow checking, but does not affect the overflow mode.
5882 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5883 overflow checking, but does not affect the overflow mode.
5885 @node Pragma Overriding_Renamings,Pragma Part_Of,Pragma Overflow_Mode,Implementation Defined Pragmas
5886 @anchor{gnat_rm/implementation_defined_pragmas pragma-overriding-renamings}@anchor{b3}
5887 @section Pragma Overriding_Renamings
5890 @geindex Rational profile
5892 @geindex Rational compatibility
5894 Syntax:
5896 @example
5897 pragma Overriding_Renamings;
5898 @end example
5900 This is a GNAT configuration pragma to simplify porting
5901 legacy code accepted by the Rational
5902 Ada compiler. In the presence of this pragma, a renaming declaration that
5903 renames an inherited operation declared in the same scope is legal if selected
5904 notation is used as in:
5906 @example
5907 pragma Overriding_Renamings;
5909 package R is
5910   function F (..);
5911   ...
5912   function F (..) renames R.F;
5913 end R;
5914 @end example
5916 even though
5917 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5918 declaration of the overriding operation.
5920 @node Pragma Part_Of,Pragma Partition_Elaboration_Policy,Pragma Overriding_Renamings,Implementation Defined Pragmas
5921 @anchor{gnat_rm/implementation_defined_pragmas id29}@anchor{b4}@anchor{gnat_rm/implementation_defined_pragmas pragma-part-of}@anchor{b5}
5922 @section Pragma Part_Of
5925 Syntax:
5927 @example
5928 pragma Part_Of (ABSTRACT_STATE);
5930 ABSTRACT_STATE ::= NAME
5931 @end example
5933 For the semantics of this pragma, see the entry for aspect @code{Part_Of} in the
5934 SPARK 2014 Reference Manual, section 7.2.6.
5936 @node Pragma Partition_Elaboration_Policy,Pragma Passive,Pragma Part_Of,Implementation Defined Pragmas
5937 @anchor{gnat_rm/implementation_defined_pragmas pragma-partition-elaboration-policy}@anchor{b6}
5938 @section Pragma Partition_Elaboration_Policy
5941 Syntax:
5943 @example
5944 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5946 POLICY_IDENTIFIER ::= Concurrent | Sequential
5947 @end example
5949 This pragma is standard in Ada 2005, but is available in all earlier
5950 versions of Ada as an implementation-defined pragma.
5951 See Ada 2012 Reference Manual for details.
5953 @node Pragma Passive,Pragma Persistent_BSS,Pragma Partition_Elaboration_Policy,Implementation Defined Pragmas
5954 @anchor{gnat_rm/implementation_defined_pragmas pragma-passive}@anchor{b7}
5955 @section Pragma Passive
5958 Syntax:
5960 @example
5961 pragma Passive [(Semaphore | No)];
5962 @end example
5964 Syntax checked, but otherwise ignored by GNAT.  This is recognized for
5965 compatibility with DEC Ada 83 implementations, where it is used within a
5966 task definition to request that a task be made passive.  If the argument
5967 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5968 treats the pragma as an assertion that the containing task is passive
5969 and that optimization of context switch with this task is permitted and
5970 desired.  If the argument @code{No} is present, the task must not be
5971 optimized.  GNAT does not attempt to optimize any tasks in this manner
5972 (since protected objects are available in place of passive tasks).
5974 For more information on the subject of passive tasks, see the section
5975 ‘Passive Task Optimization’ in the GNAT Users Guide.
5977 @node Pragma Persistent_BSS,Pragma Post,Pragma Passive,Implementation Defined Pragmas
5978 @anchor{gnat_rm/implementation_defined_pragmas id30}@anchor{b8}@anchor{gnat_rm/implementation_defined_pragmas pragma-persistent-bss}@anchor{b9}
5979 @section Pragma Persistent_BSS
5982 Syntax:
5984 @example
5985 pragma Persistent_BSS [(LOCAL_NAME)]
5986 @end example
5988 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5989 section. On some targets the linker and loader provide for special
5990 treatment of this section, allowing a program to be reloaded without
5991 affecting the contents of this data (hence the name persistent).
5993 There are two forms of usage. If an argument is given, it must be the
5994 local name of a library-level object, with no explicit initialization
5995 and whose type is potentially persistent. If no argument is given, then
5996 the pragma is a configuration pragma, and applies to all library-level
5997 objects with no explicit initialization of potentially persistent types.
5999 A potentially persistent type is a scalar type, or an untagged,
6000 non-discriminated record, all of whose components have no explicit
6001 initialization and are themselves of a potentially persistent type,
6002 or an array, all of whose constraints are static, and whose component
6003 type is potentially persistent.
6005 If this pragma is used on a target where this feature is not supported,
6006 then the pragma will be ignored. See also @code{pragma Linker_Section}.
6008 @node Pragma Post,Pragma Postcondition,Pragma Persistent_BSS,Implementation Defined Pragmas
6009 @anchor{gnat_rm/implementation_defined_pragmas pragma-post}@anchor{ba}
6010 @section Pragma Post
6013 @geindex Post
6015 @geindex Checks
6016 @geindex postconditions
6018 Syntax:
6020 @example
6021 pragma Post (Boolean_Expression);
6022 @end example
6024 The @code{Post} pragma is intended to be an exact replacement for
6025 the language-defined
6026 @code{Post} aspect, and shares its restrictions and semantics.
6027 It must appear either immediately following the corresponding
6028 subprogram declaration (only other pragmas may intervene), or
6029 if there is no separate subprogram declaration, then it can
6030 appear at the start of the declarations in a subprogram body
6031 (preceded only by other pragmas).
6033 @node Pragma Postcondition,Pragma Post_Class,Pragma Post,Implementation Defined Pragmas
6034 @anchor{gnat_rm/implementation_defined_pragmas pragma-postcondition}@anchor{bb}
6035 @section Pragma Postcondition
6038 @geindex Postcondition
6040 @geindex Checks
6041 @geindex postconditions
6043 Syntax:
6045 @example
6046 pragma Postcondition (
6047    [Check   =>] Boolean_Expression
6048  [,[Message =>] String_Expression]);
6049 @end example
6051 The @code{Postcondition} pragma allows specification of automatic
6052 postcondition checks for subprograms. These checks are similar to
6053 assertions, but are automatically inserted just prior to the return
6054 statements of the subprogram with which they are associated (including
6055 implicit returns at the end of procedure bodies and associated
6056 exception handlers).
6058 In addition, the boolean expression which is the condition which
6059 must be true may contain references to function’Result in the case
6060 of a function to refer to the returned value.
6062 @code{Postcondition} pragmas may appear either immediately following the
6063 (separate) declaration of a subprogram, or at the start of the
6064 declarations of a subprogram body. Only other pragmas may intervene
6065 (that is appear between the subprogram declaration and its
6066 postconditions, or appear before the postcondition in the
6067 declaration sequence in a subprogram body). In the case of a
6068 postcondition appearing after a subprogram declaration, the
6069 formal arguments of the subprogram are visible, and can be
6070 referenced in the postcondition expressions.
6072 The postconditions are collected and automatically tested just
6073 before any return (implicit or explicit) in the subprogram body.
6074 A postcondition is only recognized if postconditions are active
6075 at the time the pragma is encountered. The compiler switch `gnata'
6076 turns on all postconditions by default, and pragma @code{Check_Policy}
6077 with an identifier of @code{Postcondition} can also be used to
6078 control whether postconditions are active.
6080 The general approach is that postconditions are placed in the spec
6081 if they represent functional aspects which make sense to the client.
6082 For example we might have:
6084 @example
6085 function Direction return Integer;
6086 pragma Postcondition
6087  (Direction'Result = +1
6088     or else
6089   Direction'Result = -1);
6090 @end example
6092 which serves to document that the result must be +1 or -1, and
6093 will test that this is the case at run time if postcondition
6094 checking is active.
6096 Postconditions within the subprogram body can be used to
6097 check that some internal aspect of the implementation,
6098 not visible to the client, is operating as expected.
6099 For instance if a square root routine keeps an internal
6100 counter of the number of times it is called, then we
6101 might have the following postcondition:
6103 @example
6104 Sqrt_Calls : Natural := 0;
6106 function Sqrt (Arg : Float) return Float is
6107   pragma Postcondition
6108     (Sqrt_Calls = Sqrt_Calls'Old + 1);
6109   ...
6110 end Sqrt
6111 @end example
6113 As this example, shows, the use of the @code{Old} attribute
6114 is often useful in postconditions to refer to the state on
6115 entry to the subprogram.
6117 Note that postconditions are only checked on normal returns
6118 from the subprogram. If an abnormal return results from
6119 raising an exception, then the postconditions are not checked.
6121 If a postcondition fails, then the exception
6122 @code{System.Assertions.Assert_Failure} is raised. If
6123 a message argument was supplied, then the given string
6124 will be used as the exception message. If no message
6125 argument was supplied, then the default message has
6126 the form “Postcondition failed at file_name:line”. The
6127 exception is raised in the context of the subprogram
6128 body, so it is possible to catch postcondition failures
6129 within the subprogram body itself.
6131 Within a package spec, normal visibility rules
6132 in Ada would prevent forward references within a
6133 postcondition pragma to functions defined later in
6134 the same package. This would introduce undesirable
6135 ordering constraints. To avoid this problem, all
6136 postcondition pragmas are analyzed at the end of
6137 the package spec, allowing forward references.
6139 The following example shows that this even allows
6140 mutually recursive postconditions as in:
6142 @example
6143 package Parity_Functions is
6144    function Odd  (X : Natural) return Boolean;
6145    pragma Postcondition
6146      (Odd'Result =
6147         (x = 1
6148           or else
6149         (x /= 0 and then Even (X - 1))));
6151    function Even (X : Natural) return Boolean;
6152    pragma Postcondition
6153      (Even'Result =
6154         (x = 0
6155           or else
6156         (x /= 1 and then Odd (X - 1))));
6158 end Parity_Functions;
6159 @end example
6161 There are no restrictions on the complexity or form of
6162 conditions used within @code{Postcondition} pragmas.
6163 The following example shows that it is even possible
6164 to verify performance behavior.
6166 @example
6167 package Sort is
6169    Performance : constant Float;
6170    --  Performance constant set by implementation
6171    --  to match target architecture behavior.
6173    procedure Treesort (Arg : String);
6174    --  Sorts characters of argument using N*logN sort
6175    pragma Postcondition
6176      (Float (Clock - Clock'Old) <=
6177         Float (Arg'Length) *
6178         log (Float (Arg'Length)) *
6179         Performance);
6180 end Sort;
6181 @end example
6183 Note: postcondition pragmas associated with subprograms that are
6184 marked as Inline_Always, or those marked as Inline with front-end
6185 inlining (-gnatN option set) are accepted and legality-checked
6186 by the compiler, but are ignored at run-time even if postcondition
6187 checking is enabled.
6189 Note that pragma @code{Postcondition} differs from the language-defined
6190 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
6191 multiple occurrences, allowing occurences in the body even if there
6192 is a separate spec, and allowing a second string parameter, and the
6193 use of the pragma identifier @code{Check}. Historically, pragma
6194 @code{Postcondition} was implemented prior to the development of
6195 Ada 2012, and has been retained in its original form for
6196 compatibility purposes.
6198 @node Pragma Post_Class,Pragma Pre,Pragma Postcondition,Implementation Defined Pragmas
6199 @anchor{gnat_rm/implementation_defined_pragmas pragma-post-class}@anchor{bc}
6200 @section Pragma Post_Class
6203 @geindex Post
6205 @geindex Checks
6206 @geindex postconditions
6208 Syntax:
6210 @example
6211 pragma Post_Class (Boolean_Expression);
6212 @end example
6214 The @code{Post_Class} pragma is intended to be an exact replacement for
6215 the language-defined
6216 @code{Post'Class} aspect, and shares its restrictions and semantics.
6217 It must appear either immediately following the corresponding
6218 subprogram declaration (only other pragmas may intervene), or
6219 if there is no separate subprogram declaration, then it can
6220 appear at the start of the declarations in a subprogram body
6221 (preceded only by other pragmas).
6223 Note: This pragma is called @code{Post_Class} rather than
6224 @code{Post'Class} because the latter would not be strictly
6225 conforming to the allowed syntax for pragmas. The motivation
6226 for providing pragmas equivalent to the aspects is to allow a program
6227 to be written using the pragmas, and then compiled if necessary
6228 using an Ada compiler that does not recognize the pragmas or
6229 aspects, but is prepared to ignore the pragmas. The assertion
6230 policy that controls this pragma is @code{Post'Class}, not
6231 @code{Post_Class}.
6233 @node Pragma Pre,Pragma Precondition,Pragma Post_Class,Implementation Defined Pragmas
6234 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre}@anchor{bd}
6235 @section Pragma Pre
6238 @geindex Pre
6240 @geindex Checks
6241 @geindex preconditions
6243 Syntax:
6245 @example
6246 pragma Pre (Boolean_Expression);
6247 @end example
6249 The @code{Pre} pragma is intended to be an exact replacement for
6250 the language-defined
6251 @code{Pre} aspect, and shares its restrictions and semantics.
6252 It must appear either immediately following the corresponding
6253 subprogram declaration (only other pragmas may intervene), or
6254 if there is no separate subprogram declaration, then it can
6255 appear at the start of the declarations in a subprogram body
6256 (preceded only by other pragmas).
6258 @node Pragma Precondition,Pragma Predicate,Pragma Pre,Implementation Defined Pragmas
6259 @anchor{gnat_rm/implementation_defined_pragmas pragma-precondition}@anchor{be}
6260 @section Pragma Precondition
6263 @geindex Preconditions
6265 @geindex Checks
6266 @geindex preconditions
6268 Syntax:
6270 @example
6271 pragma Precondition (
6272    [Check   =>] Boolean_Expression
6273  [,[Message =>] String_Expression]);
6274 @end example
6276 The @code{Precondition} pragma is similar to @code{Postcondition}
6277 except that the corresponding checks take place immediately upon
6278 entry to the subprogram, and if a precondition fails, the exception
6279 is raised in the context of the caller, and the attribute ‘Result
6280 cannot be used within the precondition expression.
6282 Otherwise, the placement and visibility rules are identical to those
6283 described for postconditions. The following is an example of use
6284 within a package spec:
6286 @example
6287 package Math_Functions is
6288    ...
6289    function Sqrt (Arg : Float) return Float;
6290    pragma Precondition (Arg >= 0.0)
6291    ...
6292 end Math_Functions;
6293 @end example
6295 @code{Precondition} pragmas may appear either immediately following the
6296 (separate) declaration of a subprogram, or at the start of the
6297 declarations of a subprogram body. Only other pragmas may intervene
6298 (that is appear between the subprogram declaration and its
6299 postconditions, or appear before the postcondition in the
6300 declaration sequence in a subprogram body).
6302 Note: precondition pragmas associated with subprograms that are
6303 marked as Inline_Always, or those marked as Inline with front-end
6304 inlining (-gnatN option set) are accepted and legality-checked
6305 by the compiler, but are ignored at run-time even if precondition
6306 checking is enabled.
6308 Note that pragma @code{Precondition} differs from the language-defined
6309 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
6310 multiple occurrences, allowing occurences in the body even if there
6311 is a separate spec, and allowing a second string parameter, and the
6312 use of the pragma identifier @code{Check}. Historically, pragma
6313 @code{Precondition} was implemented prior to the development of
6314 Ada 2012, and has been retained in its original form for
6315 compatibility purposes.
6317 @node Pragma Predicate,Pragma Predicate_Failure,Pragma Precondition,Implementation Defined Pragmas
6318 @anchor{gnat_rm/implementation_defined_pragmas id31}@anchor{bf}@anchor{gnat_rm/implementation_defined_pragmas pragma-predicate}@anchor{c0}
6319 @section Pragma Predicate
6322 Syntax:
6324 @example
6325 pragma Predicate
6326   ([Entity =>] type_LOCAL_NAME,
6327    [Check  =>] EXPRESSION);
6328 @end example
6330 This pragma (available in all versions of Ada in GNAT) encompasses both
6331 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
6332 Ada 2012. A predicate is regarded as static if it has an allowed form
6333 for @code{Static_Predicate} and is otherwise treated as a
6334 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
6335 pragma behave exactly as described in the Ada 2012 reference manual.
6336 For example, if we have
6338 @example
6339 type R is range 1 .. 10;
6340 subtype S is R;
6341 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
6342 subtype Q is R
6343 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
6344 @end example
6346 the effect is identical to the following Ada 2012 code:
6348 @example
6349 type R is range 1 .. 10;
6350 subtype S is R with
6351   Static_Predicate => S not in 4 .. 6;
6352 subtype Q is R with
6353   Dynamic_Predicate => F(Q) or G(Q);
6354 @end example
6356 Note that there are no pragmas @code{Dynamic_Predicate}
6357 or @code{Static_Predicate}. That is
6358 because these pragmas would affect legality and semantics of
6359 the program and thus do not have a neutral effect if ignored.
6360 The motivation behind providing pragmas equivalent to
6361 corresponding aspects is to allow a program to be written
6362 using the pragmas, and then compiled with a compiler that
6363 will ignore the pragmas. That doesn’t work in the case of
6364 static and dynamic predicates, since if the corresponding
6365 pragmas are ignored, then the behavior of the program is
6366 fundamentally changed (for example a membership test
6367 @code{A in B} would not take into account a predicate
6368 defined for subtype B). When following this approach, the
6369 use of predicates should be avoided.
6371 @node Pragma Predicate_Failure,Pragma Preelaborable_Initialization,Pragma Predicate,Implementation Defined Pragmas
6372 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate-failure}@anchor{c1}
6373 @section Pragma Predicate_Failure
6376 Syntax:
6378 @example
6379 pragma Predicate_Failure
6380   ([Entity  =>] type_LOCAL_NAME,
6381    [Message =>] String_Expression);
6382 @end example
6384 The @code{Predicate_Failure} pragma is intended to be an exact replacement for
6385 the language-defined
6386 @code{Predicate_Failure} aspect, and shares its restrictions and semantics.
6388 @node Pragma Preelaborable_Initialization,Pragma Prefix_Exception_Messages,Pragma Predicate_Failure,Implementation Defined Pragmas
6389 @anchor{gnat_rm/implementation_defined_pragmas pragma-preelaborable-initialization}@anchor{c2}
6390 @section Pragma Preelaborable_Initialization
6393 Syntax:
6395 @example
6396 pragma Preelaborable_Initialization (DIRECT_NAME);
6397 @end example
6399 This pragma is standard in Ada 2005, but is available in all earlier
6400 versions of Ada as an implementation-defined pragma.
6401 See Ada 2012 Reference Manual for details.
6403 @node Pragma Prefix_Exception_Messages,Pragma Pre_Class,Pragma Preelaborable_Initialization,Implementation Defined Pragmas
6404 @anchor{gnat_rm/implementation_defined_pragmas pragma-prefix-exception-messages}@anchor{c3}
6405 @section Pragma Prefix_Exception_Messages
6408 @geindex Prefix_Exception_Messages
6410 @geindex exception
6412 @geindex Exception_Message
6414 Syntax:
6416 @example
6417 pragma Prefix_Exception_Messages;
6418 @end example
6420 This is an implementation-defined configuration pragma that affects the
6421 behavior of raise statements with a message given as a static string
6422 constant (typically a string literal). In such cases, the string will
6423 be automatically prefixed by the name of the enclosing entity (giving
6424 the package and subprogram containing the raise statement). This helps
6425 to identify where messages are coming from, and this mode is automatic
6426 for the run-time library.
6428 The pragma has no effect if the message is computed with an expression other
6429 than a static string constant, since the assumption in this case is that
6430 the program computes exactly the string it wants. If you still want the
6431 prefixing in this case, you can always call
6432 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
6434 @node Pragma Pre_Class,Pragma Priority_Specific_Dispatching,Pragma Prefix_Exception_Messages,Implementation Defined Pragmas
6435 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre-class}@anchor{c4}
6436 @section Pragma Pre_Class
6439 @geindex Pre_Class
6441 @geindex Checks
6442 @geindex preconditions
6444 Syntax:
6446 @example
6447 pragma Pre_Class (Boolean_Expression);
6448 @end example
6450 The @code{Pre_Class} pragma is intended to be an exact replacement for
6451 the language-defined
6452 @code{Pre'Class} aspect, and shares its restrictions and semantics.
6453 It must appear either immediately following the corresponding
6454 subprogram declaration (only other pragmas may intervene), or
6455 if there is no separate subprogram declaration, then it can
6456 appear at the start of the declarations in a subprogram body
6457 (preceded only by other pragmas).
6459 Note: This pragma is called @code{Pre_Class} rather than
6460 @code{Pre'Class} because the latter would not be strictly
6461 conforming to the allowed syntax for pragmas. The motivation
6462 for providing pragmas equivalent to the aspects is to allow a program
6463 to be written using the pragmas, and then compiled if necessary
6464 using an Ada compiler that does not recognize the pragmas or
6465 aspects, but is prepared to ignore the pragmas. The assertion
6466 policy that controls this pragma is @code{Pre'Class}, not
6467 @code{Pre_Class}.
6469 @node Pragma Priority_Specific_Dispatching,Pragma Profile,Pragma Pre_Class,Implementation Defined Pragmas
6470 @anchor{gnat_rm/implementation_defined_pragmas pragma-priority-specific-dispatching}@anchor{c5}
6471 @section Pragma Priority_Specific_Dispatching
6474 Syntax:
6476 @example
6477 pragma Priority_Specific_Dispatching (
6478    POLICY_IDENTIFIER,
6479    first_priority_EXPRESSION,
6480    last_priority_EXPRESSION)
6482 POLICY_IDENTIFIER ::=
6483    EDF_Across_Priorities            |
6484    FIFO_Within_Priorities           |
6485    Non_Preemptive_Within_Priorities |
6486    Round_Robin_Within_Priorities
6487 @end example
6489 This pragma is standard in Ada 2005, but is available in all earlier
6490 versions of Ada as an implementation-defined pragma.
6491 See Ada 2012 Reference Manual for details.
6493 @node Pragma Profile,Pragma Profile_Warnings,Pragma Priority_Specific_Dispatching,Implementation Defined Pragmas
6494 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile}@anchor{c6}
6495 @section Pragma Profile
6498 Syntax:
6500 @example
6501 pragma Profile (Ravenscar | Restricted | Rational | Jorvik |
6502                 GNAT_Extended_Ravenscar | GNAT_Ravenscar_EDF );
6503 @end example
6505 This pragma is standard in Ada 2005, but is available in all earlier
6506 versions of Ada as an implementation-defined pragma. This is a
6507 configuration pragma that establishes a set of configuration pragmas
6508 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
6509 @code{Jorvik} is standard in Ada 202x.
6510 The other possibilities (@code{Restricted}, @code{Rational},
6511 @code{GNAT_Extended_Ravenscar}, @code{GNAT_Ravenscar_EDF})
6512 are implementation-defined.  @code{GNAT_Extended_Ravenscar} is an alias for @code{Jorvik}.
6514 The set of configuration pragmas is defined in the following sections.
6517 @itemize *
6519 @item 
6520 Pragma Profile (Ravenscar)
6522 The @code{Ravenscar} profile is standard in Ada 2005,
6523 but is available in all earlier
6524 versions of Ada as an implementation-defined pragma. This profile
6525 establishes the following set of configuration pragmas:
6528 @itemize *
6530 @item 
6531 @code{Task_Dispatching_Policy (FIFO_Within_Priorities)}
6533 [RM D.2.2] Tasks are dispatched following a preemptive
6534 priority-ordered scheduling policy.
6536 @item 
6537 @code{Locking_Policy (Ceiling_Locking)}
6539 [RM D.3] While tasks and interrupts execute a protected action, they inherit
6540 the ceiling priority of the corresponding protected object.
6542 @item 
6543 @code{Detect_Blocking}
6545 This pragma forces the detection of potentially blocking operations within a
6546 protected operation, and to raise Program_Error if that happens.
6547 @end itemize
6549 plus the following set of restrictions:
6552 @itemize *
6554 @item 
6555 @code{Max_Entry_Queue_Length => 1}
6557 No task can be queued on a protected entry.
6559 @item 
6560 @code{Max_Protected_Entries => 1}
6562 @item 
6563 @code{Max_Task_Entries => 0}
6565 No rendezvous statements are allowed.
6567 @item 
6568 @code{No_Abort_Statements}
6570 @item 
6571 @code{No_Dynamic_Attachment}
6573 @item 
6574 @code{No_Dynamic_Priorities}
6576 @item 
6577 @code{No_Implicit_Heap_Allocations}
6579 @item 
6580 @code{No_Local_Protected_Objects}
6582 @item 
6583 @code{No_Local_Timing_Events}
6585 @item 
6586 @code{No_Protected_Type_Allocators}
6588 @item 
6589 @code{No_Relative_Delay}
6591 @item 
6592 @code{No_Requeue_Statements}
6594 @item 
6595 @code{No_Select_Statements}
6597 @item 
6598 @code{No_Specific_Termination_Handlers}
6600 @item 
6601 @code{No_Task_Allocators}
6603 @item 
6604 @code{No_Task_Hierarchy}
6606 @item 
6607 @code{No_Task_Termination}
6609 @item 
6610 @code{Simple_Barriers}
6611 @end itemize
6613 The Ravenscar profile also includes the following restrictions that specify
6614 that there are no semantic dependencies on the corresponding predefined
6615 packages:
6618 @itemize *
6620 @item 
6621 @code{No_Dependence => Ada.Asynchronous_Task_Control}
6623 @item 
6624 @code{No_Dependence => Ada.Calendar}
6626 @item 
6627 @code{No_Dependence => Ada.Execution_Time.Group_Budget}
6629 @item 
6630 @code{No_Dependence => Ada.Execution_Time.Timers}
6632 @item 
6633 @code{No_Dependence => Ada.Task_Attributes}
6635 @item 
6636 @code{No_Dependence => System.Multiprocessors.Dispatching_Domains}
6637 @end itemize
6639 This set of configuration pragmas and restrictions correspond to the
6640 definition of the ‘Ravenscar Profile’ for limited tasking, devised and
6641 published by the @cite{International Real-Time Ada Workshop@comma{} 1997}.
6642 A description is also available at
6643 @indicateurl{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
6645 The original definition of the profile was revised at subsequent IRTAW
6646 meetings. It has been included in the ISO
6647 @cite{Guide for the Use of the Ada Programming Language in High Integrity Systems},
6648 and was made part of the Ada 2005 standard.
6649 The formal definition given by
6650 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
6651 AI-305) available at
6652 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
6653 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
6655 The above set is a superset of the restrictions provided by pragma
6656 @code{Profile (Restricted)}, it includes six additional restrictions
6657 (@code{Simple_Barriers}, @code{No_Select_Statements},
6658 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
6659 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
6660 that pragma @code{Profile (Ravenscar)}, like the pragma
6661 @code{Profile (Restricted)},
6662 automatically causes the use of a simplified,
6663 more efficient version of the tasking run-time library.
6665 @item 
6666 Pragma Profile (Jorvik)
6668 @code{Jorvik} is the new profile added to the Ada 202x draft standard,
6669 previously implemented under the name @code{GNAT_Extended_Ravenscar}.
6671 The @code{No_Implicit_Heap_Allocations} restriction has been replaced
6672 by @code{No_Implicit_Task_Allocations} and
6673 @code{No_Implicit_Protected_Object_Allocations}.
6675 The @code{Simple_Barriers} restriction has been replaced by
6676 @code{Pure_Barriers}.
6678 The @code{Max_Protected_Entries}, @code{Max_Entry_Queue_Length}, and
6679 @code{No_Relative_Delay} restrictions have been removed.
6681 Details on the rationale for @code{Jorvik} and implications for use may be
6682 found in @cite{A New Ravenscar-Based Profile} by P. Rogers, J. Ruiz,
6683 T. Gingold and P. Bernardi, in @cite{Reliable Software Technologies – Ada Europe 2017}, Springer-Verlag Lecture Notes in Computer Science,
6684 Number 10300.
6686 @item 
6687 Pragma Profile (GNAT_Ravenscar_EDF)
6689 This profile corresponds to the Ravenscar profile but using
6690 EDF_Across_Priority as the Task_Scheduling_Policy.
6692 @item 
6693 Pragma Profile (Restricted)
6695 This profile corresponds to the GNAT restricted run time. It
6696 establishes the following set of restrictions:
6699 @itemize *
6701 @item 
6702 @code{No_Abort_Statements}
6704 @item 
6705 @code{No_Entry_Queue}
6707 @item 
6708 @code{No_Task_Hierarchy}
6710 @item 
6711 @code{No_Task_Allocators}
6713 @item 
6714 @code{No_Dynamic_Priorities}
6716 @item 
6717 @code{No_Terminate_Alternatives}
6719 @item 
6720 @code{No_Dynamic_Attachment}
6722 @item 
6723 @code{No_Protected_Type_Allocators}
6725 @item 
6726 @code{No_Local_Protected_Objects}
6728 @item 
6729 @code{No_Requeue_Statements}
6731 @item 
6732 @code{No_Task_Attributes_Package}
6734 @item 
6735 @code{Max_Asynchronous_Select_Nesting =  0}
6737 @item 
6738 @code{Max_Task_Entries =  0}
6740 @item 
6741 @code{Max_Protected_Entries = 1}
6743 @item 
6744 @code{Max_Select_Alternatives = 0}
6745 @end itemize
6747 This set of restrictions causes the automatic selection of a simplified
6748 version of the run time that provides improved performance for the
6749 limited set of tasking functionality permitted by this set of restrictions.
6751 @item 
6752 Pragma Profile (Rational)
6754 The Rational profile is intended to facilitate porting legacy code that
6755 compiles with the Rational APEX compiler, even when the code includes non-
6756 conforming Ada constructs.  The profile enables the following three pragmas:
6759 @itemize *
6761 @item 
6762 @code{pragma Implicit_Packing}
6764 @item 
6765 @code{pragma Overriding_Renamings}
6767 @item 
6768 @code{pragma Use_VADS_Size}
6769 @end itemize
6770 @end itemize
6772 @node Pragma Profile_Warnings,Pragma Propagate_Exceptions,Pragma Profile,Implementation Defined Pragmas
6773 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile-warnings}@anchor{c7}
6774 @section Pragma Profile_Warnings
6777 Syntax:
6779 @example
6780 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
6781 @end example
6783 This is an implementation-defined pragma that is similar in
6784 effect to @code{pragma Profile} except that instead of
6785 generating @code{Restrictions} pragmas, it generates
6786 @code{Restriction_Warnings} pragmas. The result is that
6787 violations of the profile generate warning messages instead
6788 of error messages.
6790 @node Pragma Propagate_Exceptions,Pragma Provide_Shift_Operators,Pragma Profile_Warnings,Implementation Defined Pragmas
6791 @anchor{gnat_rm/implementation_defined_pragmas pragma-propagate-exceptions}@anchor{c8}
6792 @section Pragma Propagate_Exceptions
6795 @geindex Interfacing to C++
6797 Syntax:
6799 @example
6800 pragma Propagate_Exceptions;
6801 @end example
6803 This pragma is now obsolete and, other than generating a warning if warnings
6804 on obsolescent features are enabled, is ignored.
6805 It is retained for compatibility
6806 purposes. It used to be used in connection with optimization of
6807 a now-obsolete mechanism for implementation of exceptions.
6809 @node Pragma Provide_Shift_Operators,Pragma Psect_Object,Pragma Propagate_Exceptions,Implementation Defined Pragmas
6810 @anchor{gnat_rm/implementation_defined_pragmas pragma-provide-shift-operators}@anchor{c9}
6811 @section Pragma Provide_Shift_Operators
6814 @geindex Shift operators
6816 Syntax:
6818 @example
6819 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
6820 @end example
6822 This pragma can be applied to a first subtype local name that specifies
6823 either an unsigned or signed type. It has the effect of providing the
6824 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
6825 Rotate_Left and Rotate_Right) for the given type. It is similar to
6826 including the function declarations for these five operators, together
6827 with the pragma Import (Intrinsic, …) statements.
6829 @node Pragma Psect_Object,Pragma Pure_Function,Pragma Provide_Shift_Operators,Implementation Defined Pragmas
6830 @anchor{gnat_rm/implementation_defined_pragmas pragma-psect-object}@anchor{ca}
6831 @section Pragma Psect_Object
6834 Syntax:
6836 @example
6837 pragma Psect_Object (
6838      [Internal =>] LOCAL_NAME,
6839   [, [External =>] EXTERNAL_SYMBOL]
6840   [, [Size     =>] EXTERNAL_SYMBOL]);
6842 EXTERNAL_SYMBOL ::=
6843   IDENTIFIER
6844 | static_string_EXPRESSION
6845 @end example
6847 This pragma is identical in effect to pragma @code{Common_Object}.
6849 @node Pragma Pure_Function,Pragma Rational,Pragma Psect_Object,Implementation Defined Pragmas
6850 @anchor{gnat_rm/implementation_defined_pragmas id32}@anchor{cb}@anchor{gnat_rm/implementation_defined_pragmas pragma-pure-function}@anchor{cc}
6851 @section Pragma Pure_Function
6854 Syntax:
6856 @example
6857 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6858 @end example
6860 This pragma appears in the same declarative part as a function
6861 declaration (or a set of function declarations if more than one
6862 overloaded declaration exists, in which case the pragma applies
6863 to all entities).  It specifies that the function @code{Entity} is
6864 to be considered pure for the purposes of code generation.  This means
6865 that the compiler can assume that there are no side effects, and
6866 in particular that two identical calls produce the same result in
6867 the same context. It also means that the function can be used in
6868 an address clause.
6870 Note that, quite deliberately, there are no static checks to try
6871 to ensure that this promise is met, so @code{Pure_Function} can be used
6872 with functions that are conceptually pure, even if they do modify
6873 global variables.  For example, a square root function that is
6874 instrumented to count the number of times it is called is still
6875 conceptually pure, and can still be optimized, even though it
6876 modifies a global variable (the count).  Memo functions are another
6877 example (where a table of previous calls is kept and consulted to
6878 avoid re-computation).
6880 Note also that the normal rules excluding optimization of subprograms
6881 in pure units (when parameter types are descended from System.Address,
6882 or when the full view of a parameter type is limited), do not apply
6883 for the Pure_Function case. If you explicitly specify Pure_Function,
6884 the compiler may optimize away calls with identical arguments, and
6885 if that results in unexpected behavior, the proper action is not to
6886 use the pragma for subprograms that are not (conceptually) pure.
6888 Note: Most functions in a @code{Pure} package are automatically pure, and
6889 there is no need to use pragma @code{Pure_Function} for such functions.  One
6890 exception is any function that has at least one formal of type
6891 @code{System.Address} or a type derived from it.  Such functions are not
6892 considered pure by default, since the compiler assumes that the
6893 @code{Address} parameter may be functioning as a pointer and that the
6894 referenced data may change even if the address value does not.
6895 Similarly, imported functions are not considered to be pure by default,
6896 since there is no way of checking that they are in fact pure.  The use
6897 of pragma @code{Pure_Function} for such a function will override these default
6898 assumption, and cause the compiler to treat a designated subprogram as pure
6899 in these cases.
6901 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6902 applies to the underlying renamed function.  This can be used to
6903 disambiguate cases of overloading where some but not all functions
6904 in a set of overloaded functions are to be designated as pure.
6906 If pragma @code{Pure_Function} is applied to a library-level function, the
6907 function is also considered pure from an optimization point of view, but the
6908 unit is not a Pure unit in the categorization sense. So for example, a function
6909 thus marked is free to @code{with} non-pure units.
6911 @node Pragma Rational,Pragma Ravenscar,Pragma Pure_Function,Implementation Defined Pragmas
6912 @anchor{gnat_rm/implementation_defined_pragmas pragma-rational}@anchor{cd}
6913 @section Pragma Rational
6916 Syntax:
6918 @example
6919 pragma Rational;
6920 @end example
6922 This pragma is considered obsolescent, but is retained for
6923 compatibility purposes. It is equivalent to:
6925 @example
6926 pragma Profile (Rational);
6927 @end example
6929 @node Pragma Ravenscar,Pragma Refined_Depends,Pragma Rational,Implementation Defined Pragmas
6930 @anchor{gnat_rm/implementation_defined_pragmas pragma-ravenscar}@anchor{ce}
6931 @section Pragma Ravenscar
6934 Syntax:
6936 @example
6937 pragma Ravenscar;
6938 @end example
6940 This pragma is considered obsolescent, but is retained for
6941 compatibility purposes. It is equivalent to:
6943 @example
6944 pragma Profile (Ravenscar);
6945 @end example
6947 which is the preferred method of setting the @code{Ravenscar} profile.
6949 @node Pragma Refined_Depends,Pragma Refined_Global,Pragma Ravenscar,Implementation Defined Pragmas
6950 @anchor{gnat_rm/implementation_defined_pragmas id33}@anchor{cf}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-depends}@anchor{d0}
6951 @section Pragma Refined_Depends
6954 Syntax:
6956 @example
6957 pragma Refined_Depends (DEPENDENCY_RELATION);
6959 DEPENDENCY_RELATION ::=
6960      null
6961   | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
6963 DEPENDENCY_CLAUSE ::=
6964     OUTPUT_LIST =>[+] INPUT_LIST
6965   | NULL_DEPENDENCY_CLAUSE
6967 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
6969 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
6971 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
6973 OUTPUT ::= NAME | FUNCTION_RESULT
6974 INPUT  ::= NAME
6976 where FUNCTION_RESULT is a function Result attribute_reference
6977 @end example
6979 For the semantics of this pragma, see the entry for aspect @code{Refined_Depends} in
6980 the SPARK 2014 Reference Manual, section 6.1.5.
6982 @node Pragma Refined_Global,Pragma Refined_Post,Pragma Refined_Depends,Implementation Defined Pragmas
6983 @anchor{gnat_rm/implementation_defined_pragmas id34}@anchor{d1}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-global}@anchor{d2}
6984 @section Pragma Refined_Global
6987 Syntax:
6989 @example
6990 pragma Refined_Global (GLOBAL_SPECIFICATION);
6992 GLOBAL_SPECIFICATION ::=
6993      null
6994   | (GLOBAL_LIST)
6995   | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
6997 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
6999 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
7000 GLOBAL_LIST   ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
7001 GLOBAL_ITEM   ::= NAME
7002 @end example
7004 For the semantics of this pragma, see the entry for aspect @code{Refined_Global} in
7005 the SPARK 2014 Reference Manual, section 6.1.4.
7007 @node Pragma Refined_Post,Pragma Refined_State,Pragma Refined_Global,Implementation Defined Pragmas
7008 @anchor{gnat_rm/implementation_defined_pragmas id35}@anchor{d3}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-post}@anchor{d4}
7009 @section Pragma Refined_Post
7012 Syntax:
7014 @example
7015 pragma Refined_Post (boolean_EXPRESSION);
7016 @end example
7018 For the semantics of this pragma, see the entry for aspect @code{Refined_Post} in
7019 the SPARK 2014 Reference Manual, section 7.2.7.
7021 @node Pragma Refined_State,Pragma Relative_Deadline,Pragma Refined_Post,Implementation Defined Pragmas
7022 @anchor{gnat_rm/implementation_defined_pragmas id36}@anchor{d5}@anchor{gnat_rm/implementation_defined_pragmas pragma-refined-state}@anchor{d6}
7023 @section Pragma Refined_State
7026 Syntax:
7028 @example
7029 pragma Refined_State (REFINEMENT_LIST);
7031 REFINEMENT_LIST ::=
7032   (REFINEMENT_CLAUSE @{, REFINEMENT_CLAUSE@})
7034 REFINEMENT_CLAUSE ::= state_NAME => CONSTITUENT_LIST
7036 CONSTITUENT_LIST ::=
7037      null
7038   |  CONSTITUENT
7039   | (CONSTITUENT @{, CONSTITUENT@})
7041 CONSTITUENT ::= object_NAME | state_NAME
7042 @end example
7044 For the semantics of this pragma, see the entry for aspect @code{Refined_State} in
7045 the SPARK 2014 Reference Manual, section 7.2.2.
7047 @node Pragma Relative_Deadline,Pragma Remote_Access_Type,Pragma Refined_State,Implementation Defined Pragmas
7048 @anchor{gnat_rm/implementation_defined_pragmas pragma-relative-deadline}@anchor{d7}
7049 @section Pragma Relative_Deadline
7052 Syntax:
7054 @example
7055 pragma Relative_Deadline (time_span_EXPRESSION);
7056 @end example
7058 This pragma is standard in Ada 2005, but is available in all earlier
7059 versions of Ada as an implementation-defined pragma.
7060 See Ada 2012 Reference Manual for details.
7062 @node Pragma Remote_Access_Type,Pragma Rename_Pragma,Pragma Relative_Deadline,Implementation Defined Pragmas
7063 @anchor{gnat_rm/implementation_defined_pragmas id37}@anchor{d8}@anchor{gnat_rm/implementation_defined_pragmas pragma-remote-access-type}@anchor{d9}
7064 @section Pragma Remote_Access_Type
7067 Syntax:
7069 @example
7070 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
7071 @end example
7073 This pragma appears in the formal part of a generic declaration.
7074 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
7075 the use of a remote access to class-wide type as actual for a formal
7076 access type.
7078 When this pragma applies to a formal access type @code{Entity}, that
7079 type is treated as a remote access to class-wide type in the generic.
7080 It must be a formal general access type, and its designated type must
7081 be the class-wide type of a formal tagged limited private type from the
7082 same generic declaration.
7084 In the generic unit, the formal type is subject to all restrictions
7085 pertaining to remote access to class-wide types. At instantiation, the
7086 actual type must be a remote access to class-wide type.
7088 @node Pragma Rename_Pragma,Pragma Restricted_Run_Time,Pragma Remote_Access_Type,Implementation Defined Pragmas
7089 @anchor{gnat_rm/implementation_defined_pragmas pragma-rename-pragma}@anchor{da}
7090 @section Pragma Rename_Pragma
7093 @geindex Pragmas
7094 @geindex synonyms
7096 Syntax:
7098 @example
7099 pragma Rename_Pragma (
7100          [New_Name =>] IDENTIFIER,
7101          [Renamed  =>] pragma_IDENTIFIER);
7102 @end example
7104 This pragma provides a mechanism for supplying new names for existing
7105 pragmas. The @code{New_Name} identifier can subsequently be used as a synonym for
7106 the Renamed pragma. For example, suppose you have code that was originally
7107 developed on a compiler that supports Inline_Only as an implementation defined
7108 pragma. And suppose the semantics of pragma Inline_Only are identical to (or at
7109 least very similar to) the GNAT implementation defined pragma
7110 Inline_Always. You could globally replace Inline_Only with Inline_Always.
7112 However, to avoid that source modification, you could instead add a
7113 configuration pragma:
7115 @example
7116 pragma Rename_Pragma (
7117          New_Name => Inline_Only,
7118          Renamed  => Inline_Always);
7119 @end example
7121 Then GNAT will treat “pragma Inline_Only …” as if you had written
7122 “pragma Inline_Always …”.
7124 Pragma Inline_Only will not necessarily mean the same thing as the other Ada
7125 compiler; it’s up to you to make sure the semantics are close enough.
7127 @node Pragma Restricted_Run_Time,Pragma Restriction_Warnings,Pragma Rename_Pragma,Implementation Defined Pragmas
7128 @anchor{gnat_rm/implementation_defined_pragmas pragma-restricted-run-time}@anchor{db}
7129 @section Pragma Restricted_Run_Time
7132 Syntax:
7134 @example
7135 pragma Restricted_Run_Time;
7136 @end example
7138 This pragma is considered obsolescent, but is retained for
7139 compatibility purposes. It is equivalent to:
7141 @example
7142 pragma Profile (Restricted);
7143 @end example
7145 which is the preferred method of setting the restricted run time
7146 profile.
7148 @node Pragma Restriction_Warnings,Pragma Reviewable,Pragma Restricted_Run_Time,Implementation Defined Pragmas
7149 @anchor{gnat_rm/implementation_defined_pragmas pragma-restriction-warnings}@anchor{dc}
7150 @section Pragma Restriction_Warnings
7153 Syntax:
7155 @example
7156 pragma Restriction_Warnings
7157   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
7158 @end example
7160 This pragma allows a series of restriction identifiers to be
7161 specified (the list of allowed identifiers is the same as for
7162 pragma @code{Restrictions}). For each of these identifiers
7163 the compiler checks for violations of the restriction, but
7164 generates a warning message rather than an error message
7165 if the restriction is violated.
7167 One use of this is in situations where you want to know
7168 about violations of a restriction, but you want to ignore some of
7169 these violations. Consider this example, where you want to set
7170 Ada_95 mode and enable style checks, but you want to know about
7171 any other use of implementation pragmas:
7173 @example
7174 pragma Restriction_Warnings (No_Implementation_Pragmas);
7175 pragma Warnings (Off, "violation of No_Implementation_Pragmas");
7176 pragma Ada_95;
7177 pragma Style_Checks ("2bfhkM160");
7178 pragma Warnings (On, "violation of No_Implementation_Pragmas");
7179 @end example
7181 By including the above lines in a configuration pragmas file,
7182 the Ada_95 and Style_Checks pragmas are accepted without
7183 generating a warning, but any other use of implementation
7184 defined pragmas will cause a warning to be generated.
7186 @node Pragma Reviewable,Pragma Secondary_Stack_Size,Pragma Restriction_Warnings,Implementation Defined Pragmas
7187 @anchor{gnat_rm/implementation_defined_pragmas pragma-reviewable}@anchor{dd}
7188 @section Pragma Reviewable
7191 Syntax:
7193 @example
7194 pragma Reviewable;
7195 @end example
7197 This pragma is an RM-defined standard pragma, but has no effect on the
7198 program being compiled, or on the code generated for the program.
7200 To obtain the required output specified in RM H.3.1, the compiler must be
7201 run with various special switches as follows:
7204 @itemize *
7206 @item 
7207 `Where compiler-generated run-time checks remain'
7209 The switch `-gnatGL'
7210 may be used to list the expanded code in pseudo-Ada form.
7211 Runtime checks show up in the listing either as explicit
7212 checks or operators marked with @{@} to indicate a check is present.
7214 @item 
7215 `An identification of known exceptions at compile time'
7217 If the program is compiled with `-gnatwa',
7218 the compiler warning messages will indicate all cases where the compiler
7219 detects that an exception is certain to occur at run time.
7221 @item 
7222 `Possible reads of uninitialized variables'
7224 The compiler warns of many such cases, but its output is incomplete.
7225 @end itemize
7228 A supplemental static analysis tool
7229 may be used to obtain a comprehensive list of all
7230 possible points at which uninitialized data may be read.
7233 @itemize *
7235 @item 
7236 `Where run-time support routines are implicitly invoked'
7238 In the output from `-gnatGL',
7239 run-time calls are explicitly listed as calls to the relevant
7240 run-time routine.
7242 @item 
7243 `Object code listing'
7245 This may be obtained either by using the `-S' switch,
7246 or the objdump utility.
7248 @item 
7249 `Constructs known to be erroneous at compile time'
7251 These are identified by warnings issued by the compiler (use `-gnatwa').
7253 @item 
7254 `Stack usage information'
7256 Static stack usage data (maximum per-subprogram) can be obtained via the
7257 `-fstack-usage' switch to the compiler.
7258 Dynamic stack usage data (per task) can be obtained via the `-u' switch
7259 to gnatbind
7260 @end itemize
7264 @itemize *
7266 @item 
7267 `Object code listing of entire partition'
7269 This can be obtained by compiling the partition with `-S',
7270 or by applying objdump
7271 to all the object files that are part of the partition.
7273 @item 
7274 `A description of the run-time model'
7276 The full sources of the run-time are available, and the documentation of
7277 these routines describes how these run-time routines interface to the
7278 underlying operating system facilities.
7280 @item 
7281 `Control and data-flow information'
7282 @end itemize
7285 A supplemental static analysis tool
7286 may be used to obtain complete control and data-flow information, as well as
7287 comprehensive messages identifying possible problems based on this
7288 information.
7290 @node Pragma Secondary_Stack_Size,Pragma Share_Generic,Pragma Reviewable,Implementation Defined Pragmas
7291 @anchor{gnat_rm/implementation_defined_pragmas id38}@anchor{de}@anchor{gnat_rm/implementation_defined_pragmas pragma-secondary-stack-size}@anchor{df}
7292 @section Pragma Secondary_Stack_Size
7295 Syntax:
7297 @example
7298 pragma Secondary_Stack_Size (integer_EXPRESSION);
7299 @end example
7301 This pragma appears within the task definition of a single task declaration
7302 or a task type declaration (like pragma @code{Storage_Size}) and applies to all
7303 task objects of that type. The argument specifies the size of the secondary
7304 stack to be used by these task objects, and must be of an integer type. The
7305 secondary stack is used to handle functions that return a variable-sized
7306 result, for example a function returning an unconstrained String.
7308 Note this pragma only applies to targets using fixed secondary stacks, like
7309 VxWorks 653 and bare board targets, where a fixed block for the
7310 secondary stack is allocated from the primary stack of the task. By default,
7311 these targets assign a percentage of the primary stack for the secondary stack,
7312 as defined by @code{System.Parameter.Sec_Stack_Percentage}. With this pragma,
7313 an @code{integer_EXPRESSION} of bytes is assigned from the primary stack instead.
7315 For most targets, the pragma does not apply as the secondary stack grows on
7316 demand: allocated as a chain of blocks in the heap. The default size of these
7317 blocks can be modified via the @code{-D} binder option as described in
7318 @cite{GNAT User’s Guide}.
7320 Note that no check is made to see if the secondary stack can fit inside the
7321 primary stack.
7323 Note the pragma cannot appear when the restriction @code{No_Secondary_Stack}
7324 is in effect.
7326 @node Pragma Share_Generic,Pragma Shared,Pragma Secondary_Stack_Size,Implementation Defined Pragmas
7327 @anchor{gnat_rm/implementation_defined_pragmas pragma-share-generic}@anchor{e0}
7328 @section Pragma Share_Generic
7331 Syntax:
7333 @example
7334 pragma Share_Generic (GNAME @{, GNAME@});
7336 GNAME ::= generic_unit_NAME | generic_instance_NAME
7337 @end example
7339 This pragma is provided for compatibility with Dec Ada 83. It has
7340 no effect in GNAT (which does not implement shared generics), other
7341 than to check that the given names are all names of generic units or
7342 generic instances.
7344 @node Pragma Shared,Pragma Short_Circuit_And_Or,Pragma Share_Generic,Implementation Defined Pragmas
7345 @anchor{gnat_rm/implementation_defined_pragmas id39}@anchor{e1}@anchor{gnat_rm/implementation_defined_pragmas pragma-shared}@anchor{e2}
7346 @section Pragma Shared
7349 This pragma is provided for compatibility with Ada 83. The syntax and
7350 semantics are identical to pragma Atomic.
7352 @node Pragma Short_Circuit_And_Or,Pragma Short_Descriptors,Pragma Shared,Implementation Defined Pragmas
7353 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-circuit-and-or}@anchor{e3}
7354 @section Pragma Short_Circuit_And_Or
7357 Syntax:
7359 @example
7360 pragma Short_Circuit_And_Or;
7361 @end example
7363 This configuration pragma causes any occurrence of the AND operator applied to
7364 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
7365 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
7366 may be useful in the context of certification protocols requiring the use of
7367 short-circuited logical operators. If this configuration pragma occurs locally
7368 within the file being compiled, it applies only to the file being compiled.
7369 There is no requirement that all units in a partition use this option.
7371 @node Pragma Short_Descriptors,Pragma Side_Effects,Pragma Short_Circuit_And_Or,Implementation Defined Pragmas
7372 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-descriptors}@anchor{e4}
7373 @section Pragma Short_Descriptors
7376 Syntax:
7378 @example
7379 pragma Short_Descriptors;
7380 @end example
7382 This pragma is provided for compatibility with other Ada implementations. It
7383 is recognized but ignored by all current versions of GNAT.
7385 @node Pragma Side_Effects,Pragma Simple_Storage_Pool_Type,Pragma Short_Descriptors,Implementation Defined Pragmas
7386 @anchor{gnat_rm/implementation_defined_pragmas id40}@anchor{e5}@anchor{gnat_rm/implementation_defined_pragmas pragma-side-effects}@anchor{e6}
7387 @section Pragma Side_Effects
7390 Syntax:
7392 @example
7393 pragma Side_Effects [ (static_boolean_EXPRESSION) ];
7394 @end example
7396 For the semantics of this pragma, see the entry for aspect
7397 @code{Side_Effects} in the SPARK Reference Manual, section 6.1.11.
7399 @node Pragma Simple_Storage_Pool_Type,Pragma Source_File_Name,Pragma Side_Effects,Implementation Defined Pragmas
7400 @anchor{gnat_rm/implementation_defined_pragmas id41}@anchor{e7}@anchor{gnat_rm/implementation_defined_pragmas pragma-simple-storage-pool-type}@anchor{e8}
7401 @section Pragma Simple_Storage_Pool_Type
7404 @geindex Storage pool
7405 @geindex simple
7407 @geindex Simple storage pool
7409 Syntax:
7411 @example
7412 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
7413 @end example
7415 A type can be established as a ‘simple storage pool type’ by applying
7416 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
7417 A type named in the pragma must be a library-level immutably limited record
7418 type or limited tagged type declared immediately within a package declaration.
7419 The type can also be a limited private type whose full type is allowed as
7420 a simple storage pool type.
7422 For a simple storage pool type @code{SSP}, nonabstract primitive subprograms
7423 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
7424 are subtype conformant with the following subprogram declarations:
7426 @example
7427 procedure Allocate
7428   (Pool                     : in out SSP;
7429    Storage_Address          : out System.Address;
7430    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7431    Alignment                : System.Storage_Elements.Storage_Count);
7433 procedure Deallocate
7434   (Pool : in out SSP;
7435    Storage_Address          : System.Address;
7436    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7437    Alignment                : System.Storage_Elements.Storage_Count);
7439 function Storage_Size (Pool : SSP)
7440   return System.Storage_Elements.Storage_Count;
7441 @end example
7443 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
7444 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
7445 applying an unchecked deallocation has no effect other than to set its actual
7446 parameter to null. If @code{Storage_Size} is not declared, then the
7447 @code{Storage_Size} attribute applied to an access type associated with
7448 a pool object of type SSP returns zero. Additional operations can be declared
7449 for a simple storage pool type (such as for supporting a mark/release
7450 storage-management discipline).
7452 An object of a simple storage pool type can be associated with an access
7453 type by specifying the attribute
7454 @ref{e9,,Simple_Storage_Pool}. For example:
7456 @example
7457 My_Pool : My_Simple_Storage_Pool_Type;
7459 type Acc is access My_Data_Type;
7461 for Acc'Simple_Storage_Pool use My_Pool;
7462 @end example
7464 See attribute @ref{e9,,Simple_Storage_Pool}
7465 for further details.
7467 @node Pragma Source_File_Name,Pragma Source_File_Name_Project,Pragma Simple_Storage_Pool_Type,Implementation Defined Pragmas
7468 @anchor{gnat_rm/implementation_defined_pragmas id42}@anchor{ea}@anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name}@anchor{eb}
7469 @section Pragma Source_File_Name
7472 Syntax:
7474 @example
7475 pragma Source_File_Name (
7476   [Unit_Name     =>] unit_NAME,
7477   Spec_File_Name =>  STRING_LITERAL,
7478   [Index => INTEGER_LITERAL]);
7480 pragma Source_File_Name (
7481   [Unit_Name     =>] unit_NAME,
7482   Body_File_Name =>  STRING_LITERAL,
7483   [Index => INTEGER_LITERAL]);
7484 @end example
7486 Use this to override the normal naming convention.  It is a configuration
7487 pragma, and so has the usual applicability of configuration pragmas
7488 (i.e., it applies to either an entire partition, or to all units in a
7489 compilation, or to a single unit, depending on how it is used).
7490 @code{unit_name} is mapped to @code{file_name_literal}.  The identifier for
7491 the second argument is required, and indicates whether this is the file
7492 name for the spec or for the body.
7494 The optional Index argument should be used when a file contains multiple
7495 units, and when you do not want to use @code{gnatchop} to separate then
7496 into multiple files (which is the recommended procedure to limit the
7497 number of recompilations that are needed when some sources change).
7498 For instance, if the source file @code{source.ada} contains
7500 @example
7501 package B is
7503 end B;
7505 with B;
7506 procedure A is
7507 begin
7508    ..
7509 end A;
7510 @end example
7512 you could use the following configuration pragmas:
7514 @example
7515 pragma Source_File_Name
7516   (B, Spec_File_Name => "source.ada", Index => 1);
7517 pragma Source_File_Name
7518   (A, Body_File_Name => "source.ada", Index => 2);
7519 @end example
7521 Note that the @code{gnatname} utility can also be used to generate those
7522 configuration pragmas.
7524 Another form of the @code{Source_File_Name} pragma allows
7525 the specification of patterns defining alternative file naming schemes
7526 to apply to all files.
7528 @example
7529 pragma Source_File_Name
7530   (  [Spec_File_Name  =>] STRING_LITERAL
7531    [,[Casing          =>] CASING_SPEC]
7532    [,[Dot_Replacement =>] STRING_LITERAL]);
7534 pragma Source_File_Name
7535   (  [Body_File_Name  =>] STRING_LITERAL
7536    [,[Casing          =>] CASING_SPEC]
7537    [,[Dot_Replacement =>] STRING_LITERAL]);
7539 pragma Source_File_Name
7540   (  [Subunit_File_Name =>] STRING_LITERAL
7541    [,[Casing            =>] CASING_SPEC]
7542    [,[Dot_Replacement   =>] STRING_LITERAL]);
7544 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
7545 @end example
7547 The first argument is a pattern that contains a single asterisk indicating
7548 the point at which the unit name is to be inserted in the pattern string
7549 to form the file name.  The second argument is optional.  If present it
7550 specifies the casing of the unit name in the resulting file name string.
7551 The default is lower case.  Finally the third argument allows for systematic
7552 replacement of any dots in the unit name by the specified string literal.
7554 Note that Source_File_Name pragmas should not be used if you are using
7555 project files. The reason for this rule is that the project manager is not
7556 aware of these pragmas, and so other tools that use the project file would not
7557 be aware of the intended naming conventions. If you are using project files,
7558 file naming is controlled by Source_File_Name_Project pragmas, which are
7559 usually supplied automatically by the project manager. A pragma
7560 Source_File_Name cannot appear after a @ref{ec,,Pragma Source_File_Name_Project}.
7562 For more details on the use of the @code{Source_File_Name} pragma, see the
7563 sections on @cite{Using Other File Names} and @cite{Alternative File Naming Schemes}
7564 in the @cite{GNAT User’s Guide}.
7566 @node Pragma Source_File_Name_Project,Pragma Source_Reference,Pragma Source_File_Name,Implementation Defined Pragmas
7567 @anchor{gnat_rm/implementation_defined_pragmas id43}@anchor{ed}@anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name-project}@anchor{ec}
7568 @section Pragma Source_File_Name_Project
7571 This pragma has the same syntax and semantics as pragma Source_File_Name.
7572 It is only allowed as a stand-alone configuration pragma.
7573 It cannot appear after a @ref{eb,,Pragma Source_File_Name}, and
7574 most importantly, once pragma Source_File_Name_Project appears,
7575 no further Source_File_Name pragmas are allowed.
7577 The intention is that Source_File_Name_Project pragmas are always
7578 generated by the Project Manager in a manner consistent with the naming
7579 specified in a project file, and when naming is controlled in this manner,
7580 it is not permissible to attempt to modify this naming scheme using
7581 Source_File_Name or Source_File_Name_Project pragmas (which would not be
7582 known to the project manager).
7584 @node Pragma Source_Reference,Pragma SPARK_Mode,Pragma Source_File_Name_Project,Implementation Defined Pragmas
7585 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-reference}@anchor{ee}
7586 @section Pragma Source_Reference
7589 Syntax:
7591 @example
7592 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
7593 @end example
7595 This pragma must appear as the first line of a source file.
7596 @code{integer_literal} is the logical line number of the line following
7597 the pragma line (for use in error messages and debugging
7598 information).  @code{string_literal} is a static string constant that
7599 specifies the file name to be used in error messages and debugging
7600 information.  This is most notably used for the output of @code{gnatchop}
7601 with the `-r' switch, to make sure that the original unchopped
7602 source file is the one referred to.
7604 The second argument must be a string literal, it cannot be a static
7605 string expression other than a string literal.  This is because its value
7606 is needed for error messages issued by all phases of the compiler.
7608 @node Pragma SPARK_Mode,Pragma Static_Elaboration_Desired,Pragma Source_Reference,Implementation Defined Pragmas
7609 @anchor{gnat_rm/implementation_defined_pragmas id44}@anchor{ef}@anchor{gnat_rm/implementation_defined_pragmas pragma-spark-mode}@anchor{f0}
7610 @section Pragma SPARK_Mode
7613 Syntax:
7615 @example
7616 pragma SPARK_Mode [(On | Off)] ;
7617 @end example
7619 In general a program can have some parts that are in SPARK 2014 (and
7620 follow all the rules in the SPARK Reference Manual), and some parts
7621 that are full Ada 2012.
7623 The SPARK_Mode pragma is used to identify which parts are in SPARK
7624 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
7625 be used in the following places:
7628 @itemize *
7630 @item 
7631 As a configuration pragma, in which case it sets the default mode for
7632 all units compiled with this pragma.
7634 @item 
7635 Immediately following a library-level subprogram spec
7637 @item 
7638 Immediately within a library-level package body
7640 @item 
7641 Immediately following the @code{private} keyword of a library-level
7642 package spec
7644 @item 
7645 Immediately following the @code{begin} keyword of a library-level
7646 package body
7648 @item 
7649 Immediately within a library-level subprogram body
7650 @end itemize
7652 Normally a subprogram or package spec/body inherits the current mode
7653 that is active at the point it is declared. But this can be overridden
7654 by pragma within the spec or body as above.
7656 The basic consistency rule is that you can’t turn SPARK_Mode back
7657 @code{On}, once you have explicitly (with a pragma) turned if
7658 @code{Off}. So the following rules apply:
7660 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
7661 also have SPARK_Mode @code{Off}.
7663 For a package, we have four parts:
7666 @itemize *
7668 @item 
7669 the package public declarations
7671 @item 
7672 the package private part
7674 @item 
7675 the body of the package
7677 @item 
7678 the elaboration code after @code{begin}
7679 @end itemize
7681 For a package, the rule is that if you explicitly turn SPARK_Mode
7682 @code{Off} for any part, then all the following parts must have
7683 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
7684 SPARK_Mode (@code{Off}) in the body. For example, if we have a
7685 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
7686 default everywhere, and one particular package spec has pragma
7687 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
7688 the package body.
7690 @node Pragma Static_Elaboration_Desired,Pragma Stream_Convert,Pragma SPARK_Mode,Implementation Defined Pragmas
7691 @anchor{gnat_rm/implementation_defined_pragmas pragma-static-elaboration-desired}@anchor{f1}
7692 @section Pragma Static_Elaboration_Desired
7695 Syntax:
7697 @example
7698 pragma Static_Elaboration_Desired;
7699 @end example
7701 This pragma is used to indicate that the compiler should attempt to initialize
7702 statically the objects declared in the library unit to which the pragma applies,
7703 when these objects are initialized (explicitly or implicitly) by an aggregate.
7704 In the absence of this pragma, aggregates in object declarations are expanded
7705 into assignments and loops, even when the aggregate components are static
7706 constants. When the aggregate is present the compiler builds a static expression
7707 that requires no run-time code, so that the initialized object can be placed in
7708 read-only data space. If the components are not static, or the aggregate has
7709 more that 100 components, the compiler emits a warning that the pragma cannot
7710 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
7711 construction of larger aggregates with static components that include an others
7712 choice.)
7714 @node Pragma Stream_Convert,Pragma Style_Checks,Pragma Static_Elaboration_Desired,Implementation Defined Pragmas
7715 @anchor{gnat_rm/implementation_defined_pragmas pragma-stream-convert}@anchor{f2}
7716 @section Pragma Stream_Convert
7719 Syntax:
7721 @example
7722 pragma Stream_Convert (
7723   [Entity =>] type_LOCAL_NAME,
7724   [Read   =>] function_NAME,
7725   [Write  =>] function_NAME);
7726 @end example
7728 This pragma provides an efficient way of providing user-defined stream
7729 attributes.  Not only is it simpler to use than specifying the attributes
7730 directly, but more importantly, it allows the specification to be made in such
7731 a way that the predefined unit Ada.Streams is not loaded unless it is actually
7732 needed (i.e. unless the stream attributes are actually used); the use of
7733 the Stream_Convert pragma adds no overhead at all, unless the stream
7734 attributes are actually used on the designated type.
7736 The first argument specifies the type for which stream functions are
7737 provided.  The second parameter provides a function used to read values
7738 of this type.  It must name a function whose argument type may be any
7739 subtype, and whose returned type must be the type given as the first
7740 argument to the pragma.
7742 The meaning of the @code{Read} parameter is that if a stream attribute directly
7743 or indirectly specifies reading of the type given as the first parameter,
7744 then a value of the type given as the argument to the Read function is
7745 read from the stream, and then the Read function is used to convert this
7746 to the required target type.
7748 Similarly the @code{Write} parameter specifies how to treat write attributes
7749 that directly or indirectly apply to the type given as the first parameter.
7750 It must have an input parameter of the type specified by the first parameter,
7751 and the return type must be the same as the input type of the Read function.
7752 The effect is to first call the Write function to convert to the given stream
7753 type, and then write the result type to the stream.
7755 The Read and Write functions must not be overloaded subprograms.  If necessary
7756 renamings can be supplied to meet this requirement.
7757 The usage of this attribute is best illustrated by a simple example, taken
7758 from the GNAT implementation of package Ada.Strings.Unbounded:
7760 @example
7761 function To_Unbounded (S : String) return Unbounded_String
7762   renames To_Unbounded_String;
7764 pragma Stream_Convert
7765   (Unbounded_String, To_Unbounded, To_String);
7766 @end example
7768 The specifications of the referenced functions, as given in the Ada
7769 Reference Manual are:
7771 @example
7772 function To_Unbounded_String (Source : String)
7773   return Unbounded_String;
7775 function To_String (Source : Unbounded_String)
7776   return String;
7777 @end example
7779 The effect is that if the value of an unbounded string is written to a stream,
7780 then the representation of the item in the stream is in the same format that
7781 would be used for @code{Standard.String'Output}, and this same representation
7782 is expected when a value of this type is read from the stream. Note that the
7783 value written always includes the bounds, even for Unbounded_String’Write,
7784 since Unbounded_String is not an array type.
7786 Note that the @code{Stream_Convert} pragma is not effective in the case of
7787 a derived type of a non-limited tagged type. If such a type is specified then
7788 the pragma is silently ignored, and the default implementation of the stream
7789 attributes is used instead.
7791 @node Pragma Style_Checks,Pragma Subtitle,Pragma Stream_Convert,Implementation Defined Pragmas
7792 @anchor{gnat_rm/implementation_defined_pragmas pragma-style-checks}@anchor{f3}
7793 @section Pragma Style_Checks
7796 Syntax:
7798 @example
7799 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
7800                      On | Off [, LOCAL_NAME]);
7801 @end example
7803 This pragma is used in conjunction with compiler switches to control the
7804 built in style checking provided by GNAT.  The compiler switches, if set,
7805 provide an initial setting for the switches, and this pragma may be used
7806 to modify these settings, or the settings may be provided entirely by
7807 the use of the pragma.  This pragma can be used anywhere that a pragma
7808 is legal, including use as a configuration pragma (including use in
7809 the @code{gnat.adc} file).
7811 The form with a string literal specifies which style options are to be
7812 activated.  These are additive, so they apply in addition to any previously
7813 set style check options.  The codes for the options are the same as those
7814 used in the `-gnaty' switch to `gcc' or `gnatmake'.
7815 For example the following two methods can be used to enable
7816 layout checking:
7819 @itemize *
7821 @item 
7822 @example
7823 pragma Style_Checks ("l");
7824 @end example
7826 @item 
7827 @example
7828 gcc -c -gnatyl ...
7829 @end example
7830 @end itemize
7832 The form @code{ALL_CHECKS} activates all standard checks (its use is equivalent
7833 to the use of the @code{gnaty} switch with no options.
7834 See the @cite{GNAT User’s Guide} for details.)
7836 Note: the behavior is slightly different in GNAT mode (@code{-gnatg} used).
7837 In this case, @code{ALL_CHECKS} implies the standard set of GNAT mode style check
7838 options (i.e. equivalent to @code{-gnatyg}).
7840 The forms with @code{Off} and @code{On}
7841 can be used to temporarily disable style checks
7842 as shown in the following example:
7844 @example
7845 pragma Style_Checks ("k"); -- requires keywords in lower case
7846 pragma Style_Checks (Off); -- turn off style checks
7847 NULL;                      -- this will not generate an error message
7848 pragma Style_Checks (On);  -- turn style checks back on
7849 NULL;                      -- this will generate an error message
7850 @end example
7852 Finally the two argument form is allowed only if the first argument is
7853 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
7854 for the specified entity, as shown in the following example:
7856 @example
7857 pragma Style_Checks ("r"); -- require consistency of identifier casing
7858 Arg : Integer;
7859 Rf1 : Integer := ARG;      -- incorrect, wrong case
7860 pragma Style_Checks (Off, Arg);
7861 Rf2 : Integer := ARG;      -- OK, no error
7862 @end example
7864 @node Pragma Subtitle,Pragma Suppress,Pragma Style_Checks,Implementation Defined Pragmas
7865 @anchor{gnat_rm/implementation_defined_pragmas pragma-subtitle}@anchor{f4}
7866 @section Pragma Subtitle
7869 Syntax:
7871 @example
7872 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
7873 @end example
7875 This pragma is recognized for compatibility with other Ada compilers
7876 but is ignored by GNAT.
7878 @node Pragma Suppress,Pragma Suppress_All,Pragma Subtitle,Implementation Defined Pragmas
7879 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress}@anchor{f5}
7880 @section Pragma Suppress
7883 Syntax:
7885 @example
7886 pragma Suppress (Identifier [, [On =>] Name]);
7887 @end example
7889 This is a standard pragma, and supports all the check names required in
7890 the RM. It is included here because GNAT recognizes some additional check
7891 names that are implementation defined (as permitted by the RM):
7894 @itemize *
7896 @item 
7897 @code{Alignment_Check} can be used to suppress alignment checks
7898 on addresses used in address clauses. Such checks can also be suppressed
7899 by suppressing range checks, but the specific use of @code{Alignment_Check}
7900 allows suppression of alignment checks without suppressing other range checks.
7901 Note that @code{Alignment_Check} is suppressed by default on machines (such as
7902 the x86) with non-strict alignment.
7904 @item 
7905 @code{Atomic_Synchronization} can be used to suppress the special memory
7906 synchronization instructions that are normally generated for access to
7907 @code{Atomic} variables to ensure correct synchronization between tasks
7908 that use such variables for synchronization purposes.
7910 @item 
7911 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
7912 for a duplicated tag value when a tagged type is declared.
7914 @item 
7915 @code{Container_Checks} Can be used to suppress all checks within Ada.Containers
7916 and instances of its children, including Tampering_Check.
7918 @item 
7919 @code{Tampering_Check} Can be used to suppress tampering check in the containers.
7921 @item 
7922 @code{Predicate_Check} can be used to control whether predicate checks are
7923 active. It is applicable only to predicates for which the policy is
7924 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
7925 predicate is ignored or checked for the whole program, the use of
7926 @code{Suppress} and @code{Unsuppress} with this check name allows a given
7927 predicate to be turned on and off at specific points in the program.
7929 @item 
7930 @code{Validity_Check} can be used specifically to control validity checks.
7931 If @code{Suppress} is used to suppress validity checks, then no validity
7932 checks are performed, including those specified by the appropriate compiler
7933 switch or the @code{Validity_Checks} pragma.
7935 @item 
7936 Additional check names previously introduced by use of the @code{Check_Name}
7937 pragma are also allowed.
7938 @end itemize
7940 Note that pragma Suppress gives the compiler permission to omit
7941 checks, but does not require the compiler to omit checks. The compiler
7942 will generate checks if they are essentially free, even when they are
7943 suppressed. In particular, if the compiler can prove that a certain
7944 check will necessarily fail, it will generate code to do an
7945 unconditional ‘raise’, even if checks are suppressed. The compiler
7946 warns in this case.
7948 Of course, run-time checks are omitted whenever the compiler can prove
7949 that they will not fail, whether or not checks are suppressed.
7951 @node Pragma Suppress_All,Pragma Suppress_Debug_Info,Pragma Suppress,Implementation Defined Pragmas
7952 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-all}@anchor{f6}
7953 @section Pragma Suppress_All
7956 Syntax:
7958 @example
7959 pragma Suppress_All;
7960 @end example
7962 This pragma can appear anywhere within a unit.
7963 The effect is to apply @code{Suppress (All_Checks)} to the unit
7964 in which it appears.  This pragma is implemented for compatibility with DEC
7965 Ada 83 usage where it appears at the end of a unit, and for compatibility
7966 with Rational Ada, where it appears as a program unit pragma.
7967 The use of the standard Ada pragma @code{Suppress (All_Checks)}
7968 as a normal configuration pragma is the preferred usage in GNAT.
7970 @node Pragma Suppress_Debug_Info,Pragma Suppress_Exception_Locations,Pragma Suppress_All,Implementation Defined Pragmas
7971 @anchor{gnat_rm/implementation_defined_pragmas id45}@anchor{f7}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-debug-info}@anchor{f8}
7972 @section Pragma Suppress_Debug_Info
7975 Syntax:
7977 @example
7978 pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7979 @end example
7981 This pragma can be used to suppress generation of debug information
7982 for the specified entity. It is intended primarily for use in debugging
7983 the debugger, and navigating around debugger problems.
7985 @node Pragma Suppress_Exception_Locations,Pragma Suppress_Initialization,Pragma Suppress_Debug_Info,Implementation Defined Pragmas
7986 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-exception-locations}@anchor{f9}
7987 @section Pragma Suppress_Exception_Locations
7990 Syntax:
7992 @example
7993 pragma Suppress_Exception_Locations;
7994 @end example
7996 In normal mode, a raise statement for an exception by default generates
7997 an exception message giving the file name and line number for the location
7998 of the raise. This is useful for debugging and logging purposes, but this
7999 entails extra space for the strings for the messages. The configuration
8000 pragma @code{Suppress_Exception_Locations} can be used to suppress the
8001 generation of these strings, with the result that space is saved, but the
8002 exception message for such raises is null. This configuration pragma may
8003 appear in a global configuration pragma file, or in a specific unit as
8004 usual. It is not required that this pragma be used consistently within
8005 a partition, so it is fine to have some units within a partition compiled
8006 with this pragma and others compiled in normal mode without it.
8008 @node Pragma Suppress_Initialization,Pragma Task_Name,Pragma Suppress_Exception_Locations,Implementation Defined Pragmas
8009 @anchor{gnat_rm/implementation_defined_pragmas id46}@anchor{fa}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-initialization}@anchor{fb}
8010 @section Pragma Suppress_Initialization
8013 @geindex Suppressing initialization
8015 @geindex Initialization
8016 @geindex suppression of
8018 Syntax:
8020 @example
8021 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
8022 @end example
8024 Here variable_or_subtype_Name is the name introduced by a type declaration
8025 or subtype declaration or the name of a variable introduced by an
8026 object declaration.
8028 In the case of a type or subtype
8029 this pragma suppresses any implicit or explicit initialization
8030 for all variables of the given type or subtype,
8031 including initialization resulting from the use of pragmas
8032 Normalize_Scalars or Initialize_Scalars.
8034 This is considered a representation item, so it cannot be given after
8035 the type is frozen. It applies to all subsequent object declarations,
8036 and also any allocator that creates objects of the type.
8038 If the pragma is given for the first subtype, then it is considered
8039 to apply to the base type and all its subtypes. If the pragma is given
8040 for other than a first subtype, then it applies only to the given subtype.
8041 The pragma may not be given after the type is frozen.
8043 Note that this includes eliminating initialization of discriminants
8044 for discriminated types, and tags for tagged types. In these cases,
8045 you will have to use some non-portable mechanism (e.g. address
8046 overlays or unchecked conversion) to achieve required initialization
8047 of these fields before accessing any object of the corresponding type.
8049 For the variable case, implicit initialization for the named variable
8050 is suppressed, just as though its subtype had been given in a pragma
8051 Suppress_Initialization, as described above.
8053 @node Pragma Task_Name,Pragma Task_Storage,Pragma Suppress_Initialization,Implementation Defined Pragmas
8054 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-name}@anchor{fc}
8055 @section Pragma Task_Name
8058 Syntax
8060 @example
8061 pragma Task_Name (string_EXPRESSION);
8062 @end example
8064 This pragma appears within a task definition (like pragma
8065 @code{Priority}) and applies to the task in which it appears.  The
8066 argument must be of type String, and provides a name to be used for
8067 the task instance when the task is created.  Note that this expression
8068 is not required to be static, and in particular, it can contain
8069 references to task discriminants.  This facility can be used to
8070 provide different names for different tasks as they are created,
8071 as illustrated in the example below.
8073 The task name is recorded internally in the run-time structures
8074 and is accessible to tools like the debugger.  In addition the
8075 routine @code{Ada.Task_Identification.Image} will return this
8076 string, with a unique task address appended.
8078 @example
8079 --  Example of the use of pragma Task_Name
8081 with Ada.Task_Identification;
8082 use Ada.Task_Identification;
8083 with Text_IO; use Text_IO;
8084 procedure t3 is
8086    type Astring is access String;
8088    task type Task_Typ (Name : access String) is
8089       pragma Task_Name (Name.all);
8090    end Task_Typ;
8092    task body Task_Typ is
8093       Nam : constant String := Image (Current_Task);
8094    begin
8095       Put_Line ("-->" & Nam (1 .. 14) & "<--");
8096    end Task_Typ;
8098    type Ptr_Task is access Task_Typ;
8099    Task_Var : Ptr_Task;
8101 begin
8102    Task_Var :=
8103      new Task_Typ (new String'("This is task 1"));
8104    Task_Var :=
8105      new Task_Typ (new String'("This is task 2"));
8106 end;
8107 @end example
8109 @node Pragma Task_Storage,Pragma Test_Case,Pragma Task_Name,Implementation Defined Pragmas
8110 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-storage}@anchor{fd}
8111 @section Pragma Task_Storage
8114 Syntax:
8116 @example
8117 pragma Task_Storage (
8118   [Task_Type =>] LOCAL_NAME,
8119   [Top_Guard =>] static_integer_EXPRESSION);
8120 @end example
8122 This pragma specifies the length of the guard area for tasks.  The guard
8123 area is an additional storage area allocated to a task.  A value of zero
8124 means that either no guard area is created or a minimal guard area is
8125 created, depending on the target.  This pragma can appear anywhere a
8126 @code{Storage_Size} attribute definition clause is allowed for a task
8127 type.
8129 @node Pragma Test_Case,Pragma Thread_Local_Storage,Pragma Task_Storage,Implementation Defined Pragmas
8130 @anchor{gnat_rm/implementation_defined_pragmas id47}@anchor{fe}@anchor{gnat_rm/implementation_defined_pragmas pragma-test-case}@anchor{ff}
8131 @section Pragma Test_Case
8134 @geindex Test cases
8136 Syntax:
8138 @example
8139 pragma Test_Case (
8140    [Name     =>] static_string_Expression
8141   ,[Mode     =>] (Nominal | Robustness)
8142  [, Requires =>  Boolean_Expression]
8143  [, Ensures  =>  Boolean_Expression]);
8144 @end example
8146 The @code{Test_Case} pragma allows defining fine-grain specifications
8147 for use by testing tools.
8148 The compiler checks the validity of the @code{Test_Case} pragma, but its
8149 presence does not lead to any modification of the code generated by the
8150 compiler.
8152 @code{Test_Case} pragmas may only appear immediately following the
8153 (separate) declaration of a subprogram in a package declaration, inside
8154 a package spec unit. Only other pragmas may intervene (that is appear
8155 between the subprogram declaration and a test case).
8157 The compiler checks that boolean expressions given in @code{Requires} and
8158 @code{Ensures} are valid, where the rules for @code{Requires} are the
8159 same as the rule for an expression in @code{Precondition} and the rules
8160 for @code{Ensures} are the same as the rule for an expression in
8161 @code{Postcondition}. In particular, attributes @code{'Old} and
8162 @code{'Result} can only be used within the @code{Ensures}
8163 expression. The following is an example of use within a package spec:
8165 @example
8166 package Math_Functions is
8167    ...
8168    function Sqrt (Arg : Float) return Float;
8169    pragma Test_Case (Name     => "Test 1",
8170                      Mode     => Nominal,
8171                      Requires => Arg < 10000.0,
8172                      Ensures  => Sqrt'Result < 10.0);
8173    ...
8174 end Math_Functions;
8175 @end example
8177 The meaning of a test case is that there is at least one context where
8178 @code{Requires} holds such that, if the associated subprogram is executed in
8179 that context, then @code{Ensures} holds when the subprogram returns.
8180 Mode @code{Nominal} indicates that the input context should also satisfy the
8181 precondition of the subprogram, and the output context should also satisfy its
8182 postcondition. Mode @code{Robustness} indicates that the precondition and
8183 postcondition of the subprogram should be ignored for this test case.
8185 @node Pragma Thread_Local_Storage,Pragma Time_Slice,Pragma Test_Case,Implementation Defined Pragmas
8186 @anchor{gnat_rm/implementation_defined_pragmas id48}@anchor{100}@anchor{gnat_rm/implementation_defined_pragmas pragma-thread-local-storage}@anchor{101}
8187 @section Pragma Thread_Local_Storage
8190 @geindex Task specific storage
8192 @geindex TLS (Thread Local Storage)
8194 @geindex Task_Attributes
8196 Syntax:
8198 @example
8199 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
8200 @end example
8202 This pragma specifies that the specified entity, which must be
8203 a variable declared in a library-level package, is to be marked as
8204 “Thread Local Storage” (@code{TLS}). On systems supporting this (which
8205 include Windows, Solaris, GNU/Linux, and VxWorks), this causes each
8206 thread (and hence each Ada task) to see a distinct copy of the variable.
8208 The variable must not have default initialization, and if there is
8209 an explicit initialization, it must be either @code{null} for an
8210 access variable, a static expression for a scalar variable, or a fully
8211 static aggregate for a composite type, that is to say, an aggregate all
8212 of whose components are static, and which does not include packed or
8213 discriminated components.
8215 This provides a low-level mechanism similar to that provided by
8216 the @code{Ada.Task_Attributes} package, but much more efficient
8217 and is also useful in writing interface code that will interact
8218 with foreign threads.
8220 If this pragma is used on a system where @code{TLS} is not supported,
8221 then an error message will be generated and the program will be rejected.
8223 @node Pragma Time_Slice,Pragma Title,Pragma Thread_Local_Storage,Implementation Defined Pragmas
8224 @anchor{gnat_rm/implementation_defined_pragmas pragma-time-slice}@anchor{102}
8225 @section Pragma Time_Slice
8228 Syntax:
8230 @example
8231 pragma Time_Slice (static_duration_EXPRESSION);
8232 @end example
8234 For implementations of GNAT on operating systems where it is possible
8235 to supply a time slice value, this pragma may be used for this purpose.
8236 It is ignored if it is used in a system that does not allow this control,
8237 or if it appears in other than the main program unit.
8239 @node Pragma Title,Pragma Type_Invariant,Pragma Time_Slice,Implementation Defined Pragmas
8240 @anchor{gnat_rm/implementation_defined_pragmas pragma-title}@anchor{103}
8241 @section Pragma Title
8244 Syntax:
8246 @example
8247 pragma Title (TITLING_OPTION [, TITLING OPTION]);
8249 TITLING_OPTION ::=
8250   [Title    =>] STRING_LITERAL,
8251 | [Subtitle =>] STRING_LITERAL
8252 @end example
8254 Syntax checked but otherwise ignored by GNAT.  This is a listing control
8255 pragma used in DEC Ada 83 implementations to provide a title and/or
8256 subtitle for the program listing.  The program listing generated by GNAT
8257 does not have titles or subtitles.
8259 Unlike other pragmas, the full flexibility of named notation is allowed
8260 for this pragma, i.e., the parameters may be given in any order if named
8261 notation is used, and named and positional notation can be mixed
8262 following the normal rules for procedure calls in Ada.
8264 @node Pragma Type_Invariant,Pragma Type_Invariant_Class,Pragma Title,Implementation Defined Pragmas
8265 @anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant}@anchor{104}
8266 @section Pragma Type_Invariant
8269 Syntax:
8271 @example
8272 pragma Type_Invariant
8273   ([Entity =>] type_LOCAL_NAME,
8274    [Check  =>] EXPRESSION);
8275 @end example
8277 The @code{Type_Invariant} pragma is intended to be an exact
8278 replacement for the language-defined @code{Type_Invariant}
8279 aspect, and shares its restrictions and semantics. It differs
8280 from the language defined @code{Invariant} pragma in that it
8281 does not permit a string parameter, and it is
8282 controlled by the assertion identifier @code{Type_Invariant}
8283 rather than @code{Invariant}.
8285 @node Pragma Type_Invariant_Class,Pragma Unchecked_Union,Pragma Type_Invariant,Implementation Defined Pragmas
8286 @anchor{gnat_rm/implementation_defined_pragmas id49}@anchor{105}@anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant-class}@anchor{106}
8287 @section Pragma Type_Invariant_Class
8290 Syntax:
8292 @example
8293 pragma Type_Invariant_Class
8294   ([Entity =>] type_LOCAL_NAME,
8295    [Check  =>] EXPRESSION);
8296 @end example
8298 The @code{Type_Invariant_Class} pragma is intended to be an exact
8299 replacement for the language-defined @code{Type_Invariant'Class}
8300 aspect, and shares its restrictions and semantics.
8302 Note: This pragma is called @code{Type_Invariant_Class} rather than
8303 @code{Type_Invariant'Class} because the latter would not be strictly
8304 conforming to the allowed syntax for pragmas. The motivation
8305 for providing pragmas equivalent to the aspects is to allow a program
8306 to be written using the pragmas, and then compiled if necessary
8307 using an Ada compiler that does not recognize the pragmas or
8308 aspects, but is prepared to ignore the pragmas. The assertion
8309 policy that controls this pragma is @code{Type_Invariant'Class},
8310 not @code{Type_Invariant_Class}.
8312 @node Pragma Unchecked_Union,Pragma Unevaluated_Use_Of_Old,Pragma Type_Invariant_Class,Implementation Defined Pragmas
8313 @anchor{gnat_rm/implementation_defined_pragmas pragma-unchecked-union}@anchor{107}
8314 @section Pragma Unchecked_Union
8317 @geindex Unions in C
8319 Syntax:
8321 @example
8322 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
8323 @end example
8325 This pragma is used to specify a representation of a record type that is
8326 equivalent to a C union. It was introduced as a GNAT implementation defined
8327 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
8328 pragma, making it language defined, and GNAT fully implements this extended
8329 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
8330 details, consult the Ada 2012 Reference Manual, section B.3.3.
8332 @node Pragma Unevaluated_Use_Of_Old,Pragma User_Aspect_Definition,Pragma Unchecked_Union,Implementation Defined Pragmas
8333 @anchor{gnat_rm/implementation_defined_pragmas pragma-unevaluated-use-of-old}@anchor{108}
8334 @section Pragma Unevaluated_Use_Of_Old
8337 @geindex Attribute Old
8339 @geindex Attribute Loop_Entry
8341 @geindex Unevaluated_Use_Of_Old
8343 Syntax:
8345 @example
8346 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
8347 @end example
8349 This pragma controls the processing of attributes Old and Loop_Entry.
8350 If either of these attributes is used in a potentially unevaluated
8351 expression  (e.g. the then or else parts of an if expression), then
8352 normally this usage is considered illegal if the prefix of the attribute
8353 is other than an entity name. The language requires this
8354 behavior for Old, and GNAT copies the same rule for Loop_Entry.
8356 The reason for this rule is that otherwise, we can have a situation
8357 where we save the Old value, and this results in an exception, even
8358 though we might not evaluate the attribute. Consider this example:
8360 @example
8361 package UnevalOld is
8362    K : Character;
8363    procedure U (A : String; C : Boolean)  -- ERROR
8364      with Post => (if C then A(1)'Old = K else True);
8365 end;
8366 @end example
8368 If procedure U is called with a string with a lower bound of 2, and
8369 C false, then an exception would be raised trying to evaluate A(1)
8370 on entry even though the value would not be actually used.
8372 Although the rule guarantees against this possibility, it is sometimes
8373 too restrictive. For example if we know that the string has a lower
8374 bound of 1, then we will never raise an exception.
8375 The pragma @code{Unevaluated_Use_Of_Old} can be
8376 used to modify this behavior. If the argument is @code{Error} then an
8377 error is given (this is the default RM behavior). If the argument is
8378 @code{Warn} then the usage is allowed as legal but with a warning
8379 that an exception might be raised. If the argument is @code{Allow}
8380 then the usage is allowed as legal without generating a warning.
8382 This pragma may appear as a configuration pragma, or in a declarative
8383 part or package specification. In the latter case it applies to
8384 uses up to the end of the corresponding statement sequence or
8385 sequence of package declarations.
8387 @node Pragma User_Aspect_Definition,Pragma Unimplemented_Unit,Pragma Unevaluated_Use_Of_Old,Implementation Defined Pragmas
8388 @anchor{gnat_rm/implementation_defined_pragmas pragma-user-aspect-definition}@anchor{109}
8389 @section Pragma User_Aspect_Definition
8392 Syntax:
8394 @example
8395 pragma User_Aspect_Definition
8396   (Identifier @{, Identifier [(Identifier @{, Identifier@})]@});
8397 @end example
8399 This configuration pragma defines a new aspect, making it available for
8400 subsequent use in a User_Aspect aspect specification. The first
8401 identifier is the name of the new aspect. Any subsequent arguments
8402 specify the names of other aspects. A subsequent name for which no parenthesized
8403 arguments are given shall denote either a Boolean-valued
8404 non-representation aspect or an aspect that has been defined by another
8405 User_Aspect_Definition pragma. A name for which one or more arguments are
8406 given shall be either Annotate or Local_Restrictions (and the arguments shall
8407 be appropriate for the named aspect). This pragma, together with the
8408 User_Aspect aspect, provides a mechanism for
8409 avoiding textual duplication if some set of aspect specifications is needed
8410 in multiple places. This is somewhat analogous to how profiles allow avoiding
8411 duplication of Restrictions pragmas. The visibility rules for an aspect
8412 defined by a User_Aspect_Definition pragma are the same as for a check name
8413 introduced by a Check_Name pragma. If multiple
8414 definitions are visible for some aspect at some point, then the
8415 definitions must agree. A predefined aspect cannot be redefined.
8417 @node Pragma Unimplemented_Unit,Pragma Universal_Aliasing,Pragma User_Aspect_Definition,Implementation Defined Pragmas
8418 @anchor{gnat_rm/implementation_defined_pragmas pragma-unimplemented-unit}@anchor{10a}
8419 @section Pragma Unimplemented_Unit
8422 Syntax:
8424 @example
8425 pragma Unimplemented_Unit;
8426 @end example
8428 If this pragma occurs in a unit that is processed by the compiler, GNAT
8429 aborts with the message @code{xxx not implemented}, where
8430 @code{xxx} is the name of the current compilation unit.  This pragma is
8431 intended to allow the compiler to handle unimplemented library units in
8432 a clean manner.
8434 The abort only happens if code is being generated.  Thus you can use
8435 specs of unimplemented packages in syntax or semantic checking mode.
8437 @node Pragma Universal_Aliasing,Pragma Unmodified,Pragma Unimplemented_Unit,Implementation Defined Pragmas
8438 @anchor{gnat_rm/implementation_defined_pragmas id50}@anchor{10b}@anchor{gnat_rm/implementation_defined_pragmas pragma-universal-aliasing}@anchor{10c}
8439 @section Pragma Universal_Aliasing
8442 Syntax:
8444 @example
8445 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
8446 @end example
8448 @code{type_LOCAL_NAME} must refer to a type declaration in the current
8449 declarative part.  The effect is to inhibit strict type-based aliasing
8450 optimization for the given type.  In other words, the effect is as though
8451 access types designating this type were subject to pragma No_Strict_Aliasing.
8452 For a detailed description of the strict aliasing optimization, and the
8453 situations in which it must be suppressed, see the section on
8454 @code{Optimization and Strict Aliasing} in the @cite{GNAT User’s Guide}.
8456 @node Pragma Unmodified,Pragma Unreferenced,Pragma Universal_Aliasing,Implementation Defined Pragmas
8457 @anchor{gnat_rm/implementation_defined_pragmas id51}@anchor{10d}@anchor{gnat_rm/implementation_defined_pragmas pragma-unmodified}@anchor{10e}
8458 @section Pragma Unmodified
8461 @geindex Warnings
8462 @geindex unmodified
8464 Syntax:
8466 @example
8467 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
8468 @end example
8470 This pragma signals that the assignable entities (variables,
8471 @code{out} parameters, @code{in out} parameters) whose names are listed are
8472 deliberately not assigned in the current source unit. This
8473 suppresses warnings about the
8474 entities being referenced but not assigned, and in addition a warning will be
8475 generated if one of these entities is in fact assigned in the
8476 same unit as the pragma (or in the corresponding body, or one
8477 of its subunits).
8479 This is particularly useful for clearly signaling that a particular
8480 parameter is not modified, even though the spec suggests that it might
8483 For the variable case, warnings are never given for unreferenced variables
8484 whose name contains one of the substrings
8485 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSE, TMP, TEMP} in any casing. Such names
8486 are typically to be used in cases where such warnings are expected.
8487 Thus it is never necessary to use @code{pragma Unmodified} for such
8488 variables, though it is harmless to do so.
8490 @node Pragma Unreferenced,Pragma Unreferenced_Objects,Pragma Unmodified,Implementation Defined Pragmas
8491 @anchor{gnat_rm/implementation_defined_pragmas id52}@anchor{10f}@anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced}@anchor{110}
8492 @section Pragma Unreferenced
8495 @geindex Warnings
8496 @geindex unreferenced
8498 Syntax:
8500 @example
8501 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
8502 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
8503 @end example
8505 This pragma signals that the entities whose names are listed are
8506 deliberately not referenced in the current source unit after the
8507 occurrence of the pragma. This
8508 suppresses warnings about the
8509 entities being unreferenced, and in addition a warning will be
8510 generated if one of these entities is in fact subsequently referenced in the
8511 same unit as the pragma (or in the corresponding body, or one
8512 of its subunits).
8514 This is particularly useful for clearly signaling that a particular
8515 parameter is not referenced in some particular subprogram implementation
8516 and that this is deliberate. It can also be useful in the case of
8517 objects declared only for their initialization or finalization side
8518 effects.
8520 If @code{LOCAL_NAME} identifies more than one matching homonym in the
8521 current scope, then the entity most recently declared is the one to which
8522 the pragma applies. Note that in the case of accept formals, the pragma
8523 Unreferenced may appear immediately after the keyword @code{do} which
8524 allows the indication of whether or not accept formals are referenced
8525 or not to be given individually for each accept statement.
8527 The left hand side of an assignment does not count as a reference for the
8528 purpose of this pragma. Thus it is fine to assign to an entity for which
8529 pragma Unreferenced is given. However, use of an entity as an actual for
8530 an out parameter does count as a reference unless warnings for unread output
8531 parameters are enabled via @code{-gnatw.o}.
8533 Note that if a warning is desired for all calls to a given subprogram,
8534 regardless of whether they occur in the same unit as the subprogram
8535 declaration, then this pragma should not be used (calls from another
8536 unit would not be flagged); pragma Obsolescent can be used instead
8537 for this purpose, see @ref{af,,Pragma Obsolescent}.
8539 The second form of pragma @code{Unreferenced} is used within a context
8540 clause. In this case the arguments must be unit names of units previously
8541 mentioned in @code{with} clauses (similar to the usage of pragma
8542 @code{Elaborate_All}). The effect is to suppress warnings about unreferenced
8543 units and unreferenced entities within these units.
8545 For the variable case, warnings are never given for unreferenced variables
8546 whose name contains one of the substrings
8547 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8548 are typically to be used in cases where such warnings are expected.
8549 Thus it is never necessary to use @code{pragma Unreferenced} for such
8550 variables, though it is harmless to do so.
8552 @node Pragma Unreferenced_Objects,Pragma Unreserve_All_Interrupts,Pragma Unreferenced,Implementation Defined Pragmas
8553 @anchor{gnat_rm/implementation_defined_pragmas id53}@anchor{111}@anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced-objects}@anchor{112}
8554 @section Pragma Unreferenced_Objects
8557 @geindex Warnings
8558 @geindex unreferenced
8560 Syntax:
8562 @example
8563 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
8564 @end example
8566 This pragma signals that for the types or subtypes whose names are
8567 listed, objects which are declared with one of these types or subtypes may
8568 not be referenced, and if no references appear, no warnings are given.
8570 This is particularly useful for objects which are declared solely for their
8571 initialization and finalization effect. Such variables are sometimes referred
8572 to as RAII variables (Resource Acquisition Is Initialization). Using this
8573 pragma on the relevant type (most typically a limited controlled type), the
8574 compiler will automatically suppress unwanted warnings about these variables
8575 not being referenced.
8577 @node Pragma Unreserve_All_Interrupts,Pragma Unsuppress,Pragma Unreferenced_Objects,Implementation Defined Pragmas
8578 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreserve-all-interrupts}@anchor{113}
8579 @section Pragma Unreserve_All_Interrupts
8582 Syntax:
8584 @example
8585 pragma Unreserve_All_Interrupts;
8586 @end example
8588 Normally certain interrupts are reserved to the implementation.  Any attempt
8589 to attach an interrupt causes Program_Error to be raised, as described in
8590 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
8591 many systems for a @code{Ctrl-C} interrupt.  Normally this interrupt is
8592 reserved to the implementation, so that @code{Ctrl-C} can be used to
8593 interrupt execution.
8595 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
8596 a program, then all such interrupts are unreserved.  This allows the
8597 program to handle these interrupts, but disables their standard
8598 functions.  For example, if this pragma is used, then pressing
8599 @code{Ctrl-C} will not automatically interrupt execution.  However,
8600 a program can then handle the @code{SIGINT} interrupt as it chooses.
8602 For a full list of the interrupts handled in a specific implementation,
8603 see the source code for the spec of @code{Ada.Interrupts.Names} in
8604 file @code{a-intnam.ads}.  This is a target dependent file that contains the
8605 list of interrupts recognized for a given target.  The documentation in
8606 this file also specifies what interrupts are affected by the use of
8607 the @code{Unreserve_All_Interrupts} pragma.
8609 For a more general facility for controlling what interrupts can be
8610 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
8611 of the @code{Unreserve_All_Interrupts} pragma.
8613 @node Pragma Unsuppress,Pragma Unused,Pragma Unreserve_All_Interrupts,Implementation Defined Pragmas
8614 @anchor{gnat_rm/implementation_defined_pragmas pragma-unsuppress}@anchor{114}
8615 @section Pragma Unsuppress
8618 Syntax:
8620 @example
8621 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8622 @end example
8624 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
8625 there is no corresponding pragma @code{Suppress} in effect, it has no
8626 effect.  The range of the effect is the same as for pragma
8627 @code{Suppress}.  The meaning of the arguments is identical to that used
8628 in pragma @code{Suppress}.
8630 One important application is to ensure that checks are on in cases where
8631 code depends on the checks for its correct functioning, so that the code
8632 will compile correctly even if the compiler switches are set to suppress
8633 checks. For example, in a program that depends on external names of tagged
8634 types and wants to ensure that the duplicated tag check occurs even if all
8635 run-time checks are suppressed by a compiler switch, the following
8636 configuration pragma will ensure this test is not suppressed:
8638 @example
8639 pragma Unsuppress (Duplicated_Tag_Check);
8640 @end example
8642 This pragma is standard in Ada 2005. It is available in all earlier versions
8643 of Ada as an implementation-defined pragma.
8645 Note that in addition to the checks defined in the Ada RM, GNAT recognizes a
8646 number of implementation-defined check names. See the description of pragma
8647 @code{Suppress} for full details.
8649 @node Pragma Unused,Pragma Use_VADS_Size,Pragma Unsuppress,Implementation Defined Pragmas
8650 @anchor{gnat_rm/implementation_defined_pragmas id54}@anchor{115}@anchor{gnat_rm/implementation_defined_pragmas pragma-unused}@anchor{116}
8651 @section Pragma Unused
8654 @geindex Warnings
8655 @geindex unused
8657 Syntax:
8659 @example
8660 pragma Unused (LOCAL_NAME @{, LOCAL_NAME@});
8661 @end example
8663 This pragma signals that the assignable entities (variables,
8664 @code{out} parameters, and @code{in out} parameters) whose names are listed
8665 deliberately do not get assigned or referenced in the current source unit
8666 after the occurrence of the pragma in the current source unit. This
8667 suppresses warnings about the entities that are unreferenced and/or not
8668 assigned, and, in addition, a warning will be generated if one of these
8669 entities gets assigned or subsequently referenced in the same unit as the
8670 pragma (in the corresponding body or one of its subunits).
8672 This is particularly useful for clearly signaling that a particular
8673 parameter is not modified or referenced, even though the spec suggests
8674 that it might be.
8676 For the variable case, warnings are never given for unreferenced
8677 variables whose name contains one of the substrings
8678 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8679 are typically to be used in cases where such warnings are expected.
8680 Thus it is never necessary to use @code{pragma Unused} for such
8681 variables, though it is harmless to do so.
8683 @node Pragma Use_VADS_Size,Pragma Validity_Checks,Pragma Unused,Implementation Defined Pragmas
8684 @anchor{gnat_rm/implementation_defined_pragmas pragma-use-vads-size}@anchor{117}
8685 @section Pragma Use_VADS_Size
8688 @geindex Size
8689 @geindex VADS compatibility
8691 @geindex Rational profile
8693 Syntax:
8695 @example
8696 pragma Use_VADS_Size;
8697 @end example
8699 This is a configuration pragma.  In a unit to which it applies, any use
8700 of the ‘Size attribute is automatically interpreted as a use of the
8701 ‘VADS_Size attribute.  Note that this may result in incorrect semantic
8702 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
8703 the handling of existing code which depends on the interpretation of Size
8704 as implemented in the VADS compiler.  See description of the VADS_Size
8705 attribute for further details.
8707 @node Pragma Validity_Checks,Pragma Volatile,Pragma Use_VADS_Size,Implementation Defined Pragmas
8708 @anchor{gnat_rm/implementation_defined_pragmas pragma-validity-checks}@anchor{118}
8709 @section Pragma Validity_Checks
8712 Syntax:
8714 @example
8715 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
8716 @end example
8718 This pragma is used in conjunction with compiler switches to control the
8719 built-in validity checking provided by GNAT.  The compiler switches, if set
8720 provide an initial setting for the switches, and this pragma may be used
8721 to modify these settings, or the settings may be provided entirely by
8722 the use of the pragma.  This pragma can be used anywhere that a pragma
8723 is legal, including use as a configuration pragma (including use in
8724 the @code{gnat.adc} file).
8726 The form with a string literal specifies which validity options are to be
8727 activated.  The validity checks are first set to include only the default
8728 reference manual settings, and then a string of letters in the string
8729 specifies the exact set of options required.  The form of this string
8730 is exactly as described for the `-gnatVx' compiler switch (see the
8731 GNAT User’s Guide for details).  For example the following two
8732 methods can be used to enable validity checking for mode @code{in} and
8733 @code{in out} subprogram parameters:
8736 @itemize *
8738 @item 
8739 @example
8740 pragma Validity_Checks ("im");
8741 @end example
8743 @item 
8744 @example
8745 $ gcc -c -gnatVim ...
8746 @end example
8747 @end itemize
8749 The form ALL_CHECKS activates all standard checks (its use is equivalent
8750 to the use of the @code{gnatVa} switch).
8752 The forms with @code{Off} and @code{On} can be used to temporarily disable
8753 validity checks as shown in the following example:
8755 @example
8756 pragma Validity_Checks ("c"); -- validity checks for copies
8757 pragma Validity_Checks (Off); -- turn off validity checks
8758 A := B;                       -- B will not be validity checked
8759 pragma Validity_Checks (On);  -- turn validity checks back on
8760 A := C;                       -- C will be validity checked
8761 @end example
8763 @node Pragma Volatile,Pragma Volatile_Full_Access,Pragma Validity_Checks,Implementation Defined Pragmas
8764 @anchor{gnat_rm/implementation_defined_pragmas id55}@anchor{119}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile}@anchor{11a}
8765 @section Pragma Volatile
8768 Syntax:
8770 @example
8771 pragma Volatile (LOCAL_NAME);
8772 @end example
8774 This pragma is defined by the Ada Reference Manual, and the GNAT
8775 implementation is fully conformant with this definition.  The reason it
8776 is mentioned in this section is that a pragma of the same name was supplied
8777 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
8778 implementation of pragma Volatile is upwards compatible with the
8779 implementation in DEC Ada 83.
8781 @node Pragma Volatile_Full_Access,Pragma Volatile_Function,Pragma Volatile,Implementation Defined Pragmas
8782 @anchor{gnat_rm/implementation_defined_pragmas id56}@anchor{11b}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-full-access}@anchor{11c}
8783 @section Pragma Volatile_Full_Access
8786 Syntax:
8788 @example
8789 pragma Volatile_Full_Access (LOCAL_NAME);
8790 @end example
8792 This is similar in effect to pragma Volatile, except that any reference to the
8793 object is guaranteed to be done only with instructions that read or write all
8794 the bits of the object. Furthermore, if the object is of a composite type,
8795 then any reference to a subcomponent of the object is guaranteed to read
8796 and/or write all the bits of the object.
8798 The intention is that this be suitable for use with memory-mapped I/O devices
8799 on some machines. Note that there are two important respects in which this is
8800 different from @code{pragma Atomic}. First a reference to a @code{Volatile_Full_Access}
8801 object is not a sequential action in the RM 9.10 sense and, therefore, does
8802 not create a synchronization point. Second, in the case of @code{pragma Atomic},
8803 there is no guarantee that all the bits will be accessed if the reference
8804 is not to the whole object; the compiler is allowed (and generally will)
8805 access only part of the object in this case.
8807 @node Pragma Volatile_Function,Pragma Warning_As_Error,Pragma Volatile_Full_Access,Implementation Defined Pragmas
8808 @anchor{gnat_rm/implementation_defined_pragmas id57}@anchor{11d}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-function}@anchor{11e}
8809 @section Pragma Volatile_Function
8812 Syntax:
8814 @example
8815 pragma Volatile_Function [ (static_boolean_EXPRESSION) ];
8816 @end example
8818 For the semantics of this pragma, see the entry for aspect @code{Volatile_Function}
8819 in the SPARK 2014 Reference Manual, section 7.1.2.
8821 @node Pragma Warning_As_Error,Pragma Warnings,Pragma Volatile_Function,Implementation Defined Pragmas
8822 @anchor{gnat_rm/implementation_defined_pragmas pragma-warning-as-error}@anchor{11f}
8823 @section Pragma Warning_As_Error
8826 Syntax:
8828 @example
8829 pragma Warning_As_Error (static_string_EXPRESSION);
8830 @end example
8832 This configuration pragma allows the programmer to specify a set
8833 of warnings that will be treated as errors. Any warning that
8834 matches the pattern given by the pragma argument will be treated
8835 as an error. This gives more precise control than -gnatwe,
8836 which treats warnings as errors.
8838 This pragma can apply to regular warnings (messages enabled by -gnatw)
8839 and to style warnings (messages that start with “(style)”,
8840 enabled by -gnaty).
8842 The pattern may contain asterisks, which match zero or more characters
8843 in the message. For example, you can use @code{pragma Warning_As_Error
8844 ("bits of*unused")} to treat the warning message @code{warning: 960 bits of
8845 "a" unused} as an error. All characters other than asterisk are treated
8846 as literal characters in the match. The match is case insensitive; for
8847 example XYZ matches xyz.
8849 Note that the pattern matches if it occurs anywhere within the warning
8850 message string (it is not necessary to put an asterisk at the start and
8851 the end of the message, since this is implied).
8853 Another possibility for the static_string_EXPRESSION which works whether
8854 or not error tags are enabled (`-gnatw.d') is to use a single
8855 `-gnatw' tag string, enclosed in brackets,
8856 as shown in the example below, to treat one category of warnings as errors.
8857 Note that if you want to treat multiple categories of warnings as errors,
8858 you can use multiple pragma Warning_As_Error.
8860 The above use of patterns to match the message applies only to warning
8861 messages generated by the front end. This pragma can also be applied to
8862 warnings provided by the back end and mentioned in @ref{120,,Pragma Warnings}.
8863 By using a single full `-Wxxx' switch in the pragma, such warnings
8864 can also be treated as errors.
8866 The pragma can appear either in a global configuration pragma file
8867 (e.g. @code{gnat.adc}), or at the start of a file. Given a global
8868 configuration pragma file containing:
8870 @example
8871 pragma Warning_As_Error ("[-gnatwj]");
8872 @end example
8874 which will treat all obsolescent feature warnings as errors, the
8875 following program compiles as shown (compile options here are
8876 `-gnatwa.d -gnatl -gnatj55').
8878 @example
8879     1. pragma Warning_As_Error ("*never assigned*");
8880     2. function Warnerr return String is
8881     3.    X : Integer;
8882           |
8883        >>> error: variable "X" is never read and
8884            never assigned [-gnatwv] [warning-as-error]
8886     4.    Y : Integer;
8887           |
8888        >>> warning: variable "Y" is assigned but
8889            never read [-gnatwu]
8891     5. begin
8892     6.    Y := 0;
8893     7.    return %ABC%;
8894                  |
8895        >>> error: use of "%" is an obsolescent
8896            feature (RM J.2(4)), use """ instead
8897            [-gnatwj] [warning-as-error]
8899     8. end;
8901 8 lines: No errors, 3 warnings (2 treated as errors)
8902 @end example
8904 Note that this pragma does not affect the set of warnings issued in
8905 any way, it merely changes the effect of a matching warning if one
8906 is produced as a result of other warnings options. As shown in this
8907 example, if the pragma results in a warning being treated as an error,
8908 the tag is changed from “warning:” to “error:” and the string
8909 “[warning-as-error]” is appended to the end of the message.
8911 @node Pragma Warnings,Pragma Weak_External,Pragma Warning_As_Error,Implementation Defined Pragmas
8912 @anchor{gnat_rm/implementation_defined_pragmas id58}@anchor{121}@anchor{gnat_rm/implementation_defined_pragmas pragma-warnings}@anchor{120}
8913 @section Pragma Warnings
8916 Syntax:
8918 @example
8919 pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
8921 DETAILS ::= On | Off
8922 DETAILS ::= On | Off, local_NAME
8923 DETAILS ::= static_string_EXPRESSION
8924 DETAILS ::= On | Off, static_string_EXPRESSION
8926 TOOL_NAME ::= GNAT | GNATprove
8928 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
8929 @end example
8931 Note: in Ada 83 mode, a string literal may be used in place of a static string
8932 expression (which does not exist in Ada 83).
8934 Note if the second argument of @code{DETAILS} is a @code{local_NAME} then the
8935 second form is always understood. If the intention is to use
8936 the fourth form, then you can write @code{NAME & ""} to force the
8937 interpretation as a `static_string_EXPRESSION'.
8939 Note: if the first argument is a valid @code{TOOL_NAME}, it will be interpreted
8940 that way. The use of the @code{TOOL_NAME} argument is relevant only to users
8941 of SPARK and GNATprove, see last part of this section for details.
8943 Normally warnings are enabled, with the output being controlled by
8944 the command line switch.  Warnings (@code{Off}) turns off generation of
8945 warnings until a Warnings (@code{On}) is encountered or the end of the
8946 current unit.  If generation of warnings is turned off using this
8947 pragma, then some or all of the warning messages are suppressed,
8948 regardless of the setting of the command line switches.
8950 The @code{Reason} parameter may optionally appear as the last argument
8951 in any of the forms of this pragma. It is intended purely for the
8952 purposes of documenting the reason for the @code{Warnings} pragma.
8953 The compiler will check that the argument is a static string but
8954 otherwise ignore this argument. Other tools may provide specialized
8955 processing for this string.
8957 The form with a single argument (or two arguments if Reason present),
8958 where the first argument is @code{ON} or @code{OFF}
8959 may be used as a configuration pragma.
8961 If the @code{LOCAL_NAME} parameter is present, warnings are suppressed for
8962 the specified entity.  This suppression is effective from the point where
8963 it occurs till the end of the extended scope of the variable (similar to
8964 the scope of @code{Suppress}). This form cannot be used as a configuration
8965 pragma.
8967 In the case where the first argument is other than @code{ON} or
8968 @code{OFF},
8969 the third form with a single static_string_EXPRESSION argument (and possible
8970 reason) provides more precise
8971 control over which warnings are active. The string is a list of letters
8972 specifying which warnings are to be activated and which deactivated. The
8973 code for these letters is the same as the string used in the command
8974 line switch controlling warnings. For a brief summary, use the gnatmake
8975 command with no arguments, which will generate usage information containing
8976 the list of warnings switches supported. For
8977 full details see the section on @code{Warning Message Control} in the
8978 @cite{GNAT User’s Guide}.
8979 This form can also be used as a configuration pragma.
8981 The warnings controlled by the @code{-gnatw} switch are generated by the
8982 front end of the compiler. The GCC back end can provide additional warnings
8983 and they are controlled by the @code{-W} switch. Such warnings can be
8984 identified by the appearance of a string of the form @code{[-W@{xxx@}]} in the
8985 message which designates the @code{-W`xxx'} switch that controls the message.
8986 The form with a single `static_string_EXPRESSION' argument also works for these
8987 warnings, but the string must be a single full @code{-W`xxx'} switch in this
8988 case. The above reference lists a few examples of these additional warnings.
8990 The specified warnings will be in effect until the end of the program
8991 or another pragma @code{Warnings} is encountered. The effect of the pragma is
8992 cumulative. Initially the set of warnings is the standard default set
8993 as possibly modified by compiler switches. Then each pragma Warning
8994 modifies this set of warnings as specified. This form of the pragma may
8995 also be used as a configuration pragma.
8997 The fourth form, with an @code{On|Off} parameter and a string, is used to
8998 control individual messages, based on their text. The string argument
8999 is a pattern that is used to match against the text of individual
9000 warning messages (not including the initial “warning: ” tag).
9002 The pattern may contain asterisks, which match zero or more characters in
9003 the message. For example, you can use
9004 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
9005 message @code{warning: 960 bits of "a" unused}. No other regular
9006 expression notations are permitted. All characters other than asterisk in
9007 these three specific cases are treated as literal characters in the match.
9008 The match is case insensitive, for example XYZ matches xyz.
9010 Note that the pattern matches if it occurs anywhere within the warning
9011 message string (it is not necessary to put an asterisk at the start and
9012 the end of the message, since this is implied).
9014 The above use of patterns to match the message applies only to warning
9015 messages generated by the front end. This form of the pragma with a string
9016 argument can also be used to control warnings provided by the back end and
9017 mentioned above. By using a single full @code{-W`xxx'} switch in the pragma,
9018 such warnings can be turned on and off.
9020 There are two ways to use the pragma in this form. The OFF form can be used
9021 as a configuration pragma. The effect is to suppress all warnings (if any)
9022 that match the pattern string throughout the compilation (or match the
9023 -W switch in the back end case).
9025 The second usage is to suppress a warning locally, and in this case, two
9026 pragmas must appear in sequence:
9028 @example
9029 pragma Warnings (Off, Pattern);
9030 ... code where given warning is to be suppressed
9031 pragma Warnings (On, Pattern);
9032 @end example
9034 In this usage, the pattern string must match in the Off and On
9035 pragmas, and (if `-gnatw.w' is given) at least one matching
9036 warning must be suppressed.
9038 Note: if the ON form is not found, then the effect of the OFF form extends
9039 until the end of the file (pragma Warnings is purely textual, so its effect
9040 does not stop at the end of the enclosing scope).
9042 Note: to write a string that will match any warning, use the string
9043 @code{"***"}. It will not work to use a single asterisk or two
9044 asterisks since this looks like an operator name. This form with three
9045 asterisks is similar in effect to specifying @code{pragma Warnings (Off)} except (if @code{-gnatw.w} is given) that a matching
9046 @code{pragma Warnings (On, "***")} will be required. This can be
9047 helpful in avoiding forgetting to turn warnings back on.
9049 Note: the debug flag @code{-gnatd.i} can be
9050 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
9051 be useful in checking whether obsolete pragmas in existing programs are hiding
9052 real problems.
9054 Note: pragma Warnings does not affect the processing of style messages. See
9055 separate entry for pragma Style_Checks for control of style messages.
9057 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
9058 use the version of the pragma with a @code{TOOL_NAME} parameter.
9060 If present, @code{TOOL_NAME} is the name of a tool, currently either @code{GNAT} for the
9061 compiler or @code{GNATprove} for the formal verification tool. A given tool only
9062 takes into account pragma Warnings that do not specify a tool name, or that
9063 specify the matching tool name. This makes it possible to disable warnings
9064 selectively for each tool, and as a consequence to detect useless pragma
9065 Warnings with switch @code{-gnatw.w}.
9067 @node Pragma Weak_External,Pragma Wide_Character_Encoding,Pragma Warnings,Implementation Defined Pragmas
9068 @anchor{gnat_rm/implementation_defined_pragmas pragma-weak-external}@anchor{122}
9069 @section Pragma Weak_External
9072 Syntax:
9074 @example
9075 pragma Weak_External ([Entity =>] LOCAL_NAME);
9076 @end example
9078 @code{LOCAL_NAME} must refer to an object that is declared at the library
9079 level. This pragma specifies that the given entity should be marked as a
9080 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
9081 in GNU C and causes @code{LOCAL_NAME} to be emitted as a weak symbol instead
9082 of a regular symbol, that is to say a symbol that does not have to be
9083 resolved by the linker if used in conjunction with a pragma Import.
9085 When a weak symbol is not resolved by the linker, its address is set to
9086 zero. This is useful in writing interfaces to external modules that may
9087 or may not be linked in the final executable, for example depending on
9088 configuration settings.
9090 If a program references at run time an entity to which this pragma has been
9091 applied, and the corresponding symbol was not resolved at link time, then
9092 the execution of the program is erroneous. It is not erroneous to take the
9093 Address of such an entity, for example to guard potential references,
9094 as shown in the example below.
9096 Some file formats do not support weak symbols so not all target machines
9097 support this pragma.
9099 @example
9100 --  Example of the use of pragma Weak_External
9102 package External_Module is
9103   key : Integer;
9104   pragma Import (C, key);
9105   pragma Weak_External (key);
9106   function Present return boolean;
9107 end External_Module;
9109 with System; use System;
9110 package body External_Module is
9111   function Present return boolean is
9112   begin
9113     return key'Address /= System.Null_Address;
9114   end Present;
9115 end External_Module;
9116 @end example
9118 @node Pragma Wide_Character_Encoding,,Pragma Weak_External,Implementation Defined Pragmas
9119 @anchor{gnat_rm/implementation_defined_pragmas pragma-wide-character-encoding}@anchor{123}
9120 @section Pragma Wide_Character_Encoding
9123 Syntax:
9125 @example
9126 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
9127 @end example
9129 This pragma specifies the wide character encoding to be used in program
9130 source text appearing subsequently. It is a configuration pragma, but may
9131 also be used at any point that a pragma is allowed, and it is permissible
9132 to have more than one such pragma in a file, allowing multiple encodings
9133 to appear within the same file.
9135 However, note that the pragma cannot immediately precede the relevant
9136 wide character, because then the previous encoding will still be in
9137 effect, causing “illegal character” errors.
9139 The argument can be an identifier or a character literal. In the identifier
9140 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
9141 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
9142 case it is correspondingly one of the characters @code{h}, @code{u},
9143 @code{s}, @code{e}, @code{8}, or @code{b}.
9145 Note that when the pragma is used within a file, it affects only the
9146 encoding within that file, and does not affect withed units, specs,
9147 or subunits.
9149 @node Implementation Defined Aspects,Implementation Defined Attributes,Implementation Defined Pragmas,Top
9150 @anchor{gnat_rm/implementation_defined_aspects doc}@anchor{124}@anchor{gnat_rm/implementation_defined_aspects id1}@anchor{125}@anchor{gnat_rm/implementation_defined_aspects implementation-defined-aspects}@anchor{126}
9151 @chapter Implementation Defined Aspects
9154 Ada defines (throughout the Ada 2012 reference manual, summarized
9155 in Annex K) a set of aspects that can be specified for certain entities.
9156 These language defined aspects are implemented in GNAT in Ada 2012 mode
9157 and work as described in the Ada 2012 Reference Manual.
9159 In addition, Ada 2012 allows implementations to define additional aspects
9160 whose meaning is defined by the implementation.  GNAT provides
9161 a number of these implementation-defined aspects which can be used
9162 to extend and enhance the functionality of the compiler.  This section of
9163 the GNAT reference manual describes these additional aspects.
9165 Note that any program using these aspects may not be portable to
9166 other compilers (although GNAT implements this set of aspects on all
9167 platforms).  Therefore if portability to other compilers is an important
9168 consideration, you should minimize the use of these aspects.
9170 Note that for many of these aspects, the effect is essentially similar
9171 to the use of a pragma or attribute specification with the same name
9172 applied to the entity. For example, if we write:
9174 @example
9175 type R is range 1 .. 100
9176   with Value_Size => 10;
9177 @end example
9179 then the effect is the same as:
9181 @example
9182 type R is range 1 .. 100;
9183 for R'Value_Size use 10;
9184 @end example
9186 and if we write:
9188 @example
9189 type R is new Integer
9190   with Shared => True;
9191 @end example
9193 then the effect is the same as:
9195 @example
9196 type R is new Integer;
9197 pragma Shared (R);
9198 @end example
9200 In the documentation below, such cases are simply marked
9201 as being boolean aspects equivalent to the corresponding pragma
9202 or attribute definition clause.
9204 @menu
9205 * Aspect Abstract_State:: 
9206 * Aspect Annotate:: 
9207 * Aspect Async_Readers:: 
9208 * Aspect Async_Writers:: 
9209 * Aspect Constant_After_Elaboration:: 
9210 * Aspect Contract_Cases:: 
9211 * Aspect Depends:: 
9212 * Aspect Default_Initial_Condition:: 
9213 * Aspect Dimension:: 
9214 * Aspect Dimension_System:: 
9215 * Aspect Disable_Controlled:: 
9216 * Aspect Effective_Reads:: 
9217 * Aspect Effective_Writes:: 
9218 * Aspect Extensions_Visible:: 
9219 * Aspect Favor_Top_Level:: 
9220 * Aspect Ghost:: 
9221 * Aspect Ghost_Predicate:: 
9222 * Aspect Global:: 
9223 * Aspect Initial_Condition:: 
9224 * Aspect Initializes:: 
9225 * Aspect Inline_Always:: 
9226 * Aspect Invariant:: 
9227 * Aspect Invariant’Class:: 
9228 * Aspect Iterable:: 
9229 * Aspect Linker_Section:: 
9230 * Aspect Local_Restrictions:: 
9231 * Aspect Lock_Free:: 
9232 * Aspect Max_Queue_Length:: 
9233 * Aspect No_Caching:: 
9234 * Aspect No_Elaboration_Code_All:: 
9235 * Aspect No_Inline:: 
9236 * Aspect No_Tagged_Streams:: 
9237 * Aspect No_Task_Parts:: 
9238 * Aspect Object_Size:: 
9239 * Aspect Obsolescent:: 
9240 * Aspect Part_Of:: 
9241 * Aspect Persistent_BSS:: 
9242 * Aspect Predicate:: 
9243 * Aspect Pure_Function:: 
9244 * Aspect Refined_Depends:: 
9245 * Aspect Refined_Global:: 
9246 * Aspect Refined_Post:: 
9247 * Aspect Refined_State:: 
9248 * Aspect Relaxed_Initialization:: 
9249 * Aspect Remote_Access_Type:: 
9250 * Aspect Secondary_Stack_Size:: 
9251 * Aspect Scalar_Storage_Order:: 
9252 * Aspect Shared:: 
9253 * Aspect Side_Effects:: 
9254 * Aspect Simple_Storage_Pool:: 
9255 * Aspect Simple_Storage_Pool_Type:: 
9256 * Aspect SPARK_Mode:: 
9257 * Aspect Suppress_Debug_Info:: 
9258 * Aspect Suppress_Initialization:: 
9259 * Aspect Test_Case:: 
9260 * Aspect Thread_Local_Storage:: 
9261 * Aspect Universal_Aliasing:: 
9262 * Aspect Unmodified:: 
9263 * Aspect Unreferenced:: 
9264 * Aspect Unreferenced_Objects:: 
9265 * Aspect User_Aspect:: 
9266 * Aspect Value_Size:: 
9267 * Aspect Volatile_Full_Access:: 
9268 * Aspect Volatile_Function:: 
9269 * Aspect Warnings:: 
9271 @end menu
9273 @node Aspect Abstract_State,Aspect Annotate,,Implementation Defined Aspects
9274 @anchor{gnat_rm/implementation_defined_aspects aspect-abstract-state}@anchor{127}
9275 @section Aspect Abstract_State
9278 @geindex Abstract_State
9280 This aspect is equivalent to @ref{1e,,pragma Abstract_State}.
9282 @node Aspect Annotate,Aspect Async_Readers,Aspect Abstract_State,Implementation Defined Aspects
9283 @anchor{gnat_rm/implementation_defined_aspects aspect-annotate}@anchor{128}
9284 @section Aspect Annotate
9287 @geindex Annotate
9289 There are three forms of this aspect (where ID is an identifier,
9290 and ARG is a general expression),
9291 corresponding to @ref{29,,pragma Annotate}.
9294 @table @asis
9296 @item `Annotate => ID'
9298 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9300 @item `Annotate => (ID)'
9302 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9304 @item `Annotate => (ID ,ID @{, ARG@})'
9306 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
9307 @end table
9309 @node Aspect Async_Readers,Aspect Async_Writers,Aspect Annotate,Implementation Defined Aspects
9310 @anchor{gnat_rm/implementation_defined_aspects aspect-async-readers}@anchor{129}
9311 @section Aspect Async_Readers
9314 @geindex Async_Readers
9316 This boolean aspect is equivalent to @ref{30,,pragma Async_Readers}.
9318 @node Aspect Async_Writers,Aspect Constant_After_Elaboration,Aspect Async_Readers,Implementation Defined Aspects
9319 @anchor{gnat_rm/implementation_defined_aspects aspect-async-writers}@anchor{12a}
9320 @section Aspect Async_Writers
9323 @geindex Async_Writers
9325 This boolean aspect is equivalent to @ref{32,,pragma Async_Writers}.
9327 @node Aspect Constant_After_Elaboration,Aspect Contract_Cases,Aspect Async_Writers,Implementation Defined Aspects
9328 @anchor{gnat_rm/implementation_defined_aspects aspect-constant-after-elaboration}@anchor{12b}
9329 @section Aspect Constant_After_Elaboration
9332 @geindex Constant_After_Elaboration
9334 This aspect is equivalent to @ref{42,,pragma Constant_After_Elaboration}.
9336 @node Aspect Contract_Cases,Aspect Depends,Aspect Constant_After_Elaboration,Implementation Defined Aspects
9337 @anchor{gnat_rm/implementation_defined_aspects aspect-contract-cases}@anchor{12c}
9338 @section Aspect Contract_Cases
9341 @geindex Contract_Cases
9343 This aspect is equivalent to @ref{44,,pragma Contract_Cases}, the sequence
9344 of clauses being enclosed in parentheses so that syntactically it is an
9345 aggregate.
9347 @node Aspect Depends,Aspect Default_Initial_Condition,Aspect Contract_Cases,Implementation Defined Aspects
9348 @anchor{gnat_rm/implementation_defined_aspects aspect-depends}@anchor{12d}
9349 @section Aspect Depends
9352 @geindex Depends
9354 This aspect is equivalent to @ref{54,,pragma Depends}.
9356 @node Aspect Default_Initial_Condition,Aspect Dimension,Aspect Depends,Implementation Defined Aspects
9357 @anchor{gnat_rm/implementation_defined_aspects aspect-default-initial-condition}@anchor{12e}
9358 @section Aspect Default_Initial_Condition
9361 @geindex Default_Initial_Condition
9363 This aspect is equivalent to @ref{50,,pragma Default_Initial_Condition}.
9365 @node Aspect Dimension,Aspect Dimension_System,Aspect Default_Initial_Condition,Implementation Defined Aspects
9366 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension}@anchor{12f}
9367 @section Aspect Dimension
9370 @geindex Dimension
9372 The @code{Dimension} aspect is used to specify the dimensions of a given
9373 subtype of a dimensioned numeric type. The aspect also specifies a symbol
9374 used when doing formatted output of dimensioned quantities. The syntax is:
9376 @example
9377 with Dimension =>
9378   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
9380 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
9382 DIMENSION_VALUE ::=
9383   RATIONAL
9384 | others               => RATIONAL
9385 | DISCRETE_CHOICE_LIST => RATIONAL
9387 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
9388 @end example
9390 This aspect can only be applied to a subtype whose parent type has
9391 a @code{Dimension_System} aspect. The aspect must specify values for
9392 all dimensions of the system. The rational values are the powers of the
9393 corresponding dimensions that are used by the compiler to verify that
9394 physical (numeric) computations are dimensionally consistent. For example,
9395 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
9396 For further examples of the usage
9397 of this aspect, see package @code{System.Dim.Mks}.
9398 Note that when the dimensioned type is an integer type, then any
9399 dimension value must be an integer literal.
9401 @node Aspect Dimension_System,Aspect Disable_Controlled,Aspect Dimension,Implementation Defined Aspects
9402 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension-system}@anchor{130}
9403 @section Aspect Dimension_System
9406 @geindex Dimension_System
9408 The @code{Dimension_System} aspect is used to define a system of
9409 dimensions that will be used in subsequent subtype declarations with
9410 @code{Dimension} aspects that reference this system. The syntax is:
9412 @example
9413 with Dimension_System => (DIMENSION @{, DIMENSION@});
9415 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
9416                [Unit_Symbol =>] SYMBOL,
9417                [Dim_Symbol  =>] SYMBOL)
9419 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
9420 @end example
9422 This aspect is applied to a type, which must be a numeric derived type
9423 (typically a floating-point type), that
9424 will represent values within the dimension system. Each @code{DIMENSION}
9425 corresponds to one particular dimension. A maximum of 7 dimensions may
9426 be specified. @code{Unit_Name} is the name of the dimension (for example
9427 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
9428 of this dimension (for example @code{m} for @code{Meter}).
9429 @code{Dim_Symbol} gives
9430 the identification within the dimension system (typically this is a
9431 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
9432 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
9433 The @code{Dim_Symbol} is used in error messages when numeric operations have
9434 inconsistent dimensions.
9436 GNAT provides the standard definition of the International MKS system in
9437 the run-time package @code{System.Dim.Mks}. You can easily define
9438 similar packages for cgs units or British units, and define conversion factors
9439 between values in different systems. The MKS system is characterized by the
9440 following aspect:
9442 @example
9443 type Mks_Type is new Long_Long_Float with
9444   Dimension_System => (
9445     (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
9446     (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
9447     (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
9448     (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
9449     (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@@'),
9450     (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
9451     (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
9452 @end example
9454 Note that in the above type definition, we use the @code{at} symbol (@code{@@}) to
9455 represent a theta character (avoiding the use of extended Latin-1
9456 characters in this context).
9458 See section ‘Performing Dimensionality Analysis in GNAT’ in the GNAT Users
9459 Guide for detailed examples of use of the dimension system.
9461 @node Aspect Disable_Controlled,Aspect Effective_Reads,Aspect Dimension_System,Implementation Defined Aspects
9462 @anchor{gnat_rm/implementation_defined_aspects aspect-disable-controlled}@anchor{131}
9463 @section Aspect Disable_Controlled
9466 @geindex Disable_Controlled
9468 The aspect  @code{Disable_Controlled} is defined for controlled record types. If
9469 active, this aspect causes suppression of all related calls to @code{Initialize},
9470 @code{Adjust}, and @code{Finalize}. The intended use is for conditional compilation,
9471 where for example you might want a record to be controlled or not depending on
9472 whether some run-time check is enabled or suppressed.
9474 @node Aspect Effective_Reads,Aspect Effective_Writes,Aspect Disable_Controlled,Implementation Defined Aspects
9475 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-reads}@anchor{132}
9476 @section Aspect Effective_Reads
9479 @geindex Effective_Reads
9481 This aspect is equivalent to @ref{59,,pragma Effective_Reads}.
9483 @node Aspect Effective_Writes,Aspect Extensions_Visible,Aspect Effective_Reads,Implementation Defined Aspects
9484 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-writes}@anchor{133}
9485 @section Aspect Effective_Writes
9488 @geindex Effective_Writes
9490 This aspect is equivalent to @ref{5b,,pragma Effective_Writes}.
9492 @node Aspect Extensions_Visible,Aspect Favor_Top_Level,Aspect Effective_Writes,Implementation Defined Aspects
9493 @anchor{gnat_rm/implementation_defined_aspects aspect-extensions-visible}@anchor{134}
9494 @section Aspect Extensions_Visible
9497 @geindex Extensions_Visible
9499 This aspect is equivalent to @ref{69,,pragma Extensions_Visible}.
9501 @node Aspect Favor_Top_Level,Aspect Ghost,Aspect Extensions_Visible,Implementation Defined Aspects
9502 @anchor{gnat_rm/implementation_defined_aspects aspect-favor-top-level}@anchor{135}
9503 @section Aspect Favor_Top_Level
9506 @geindex Favor_Top_Level
9508 This boolean aspect is equivalent to @ref{6e,,pragma Favor_Top_Level}.
9510 @node Aspect Ghost,Aspect Ghost_Predicate,Aspect Favor_Top_Level,Implementation Defined Aspects
9511 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost}@anchor{136}
9512 @section Aspect Ghost
9515 @geindex Ghost
9517 This aspect is equivalent to @ref{72,,pragma Ghost}.
9519 @node Aspect Ghost_Predicate,Aspect Global,Aspect Ghost,Implementation Defined Aspects
9520 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost-predicate}@anchor{137}
9521 @section Aspect Ghost_Predicate
9524 @geindex Ghost_Predicate
9526 This aspect introduces a subtype predicate that can reference ghost
9527 entities. The subtype cannot appear as a subtype_mark in a membership test.
9529 For the detailed semantics of this aspect, see the entry for subtype predicates
9530 in the SPARK Reference Manual, section 3.2.4.
9532 @node Aspect Global,Aspect Initial_Condition,Aspect Ghost_Predicate,Implementation Defined Aspects
9533 @anchor{gnat_rm/implementation_defined_aspects aspect-global}@anchor{138}
9534 @section Aspect Global
9537 @geindex Global
9539 This aspect is equivalent to @ref{74,,pragma Global}.
9541 @node Aspect Initial_Condition,Aspect Initializes,Aspect Global,Implementation Defined Aspects
9542 @anchor{gnat_rm/implementation_defined_aspects aspect-initial-condition}@anchor{139}
9543 @section Aspect Initial_Condition
9546 @geindex Initial_Condition
9548 This aspect is equivalent to @ref{81,,pragma Initial_Condition}.
9550 @node Aspect Initializes,Aspect Inline_Always,Aspect Initial_Condition,Implementation Defined Aspects
9551 @anchor{gnat_rm/implementation_defined_aspects aspect-initializes}@anchor{13a}
9552 @section Aspect Initializes
9555 @geindex Initializes
9557 This aspect is equivalent to @ref{84,,pragma Initializes}.
9559 @node Aspect Inline_Always,Aspect Invariant,Aspect Initializes,Implementation Defined Aspects
9560 @anchor{gnat_rm/implementation_defined_aspects aspect-inline-always}@anchor{13b}
9561 @section Aspect Inline_Always
9564 @geindex Inline_Always
9566 This boolean aspect is equivalent to @ref{86,,pragma Inline_Always}.
9568 @node Aspect Invariant,Aspect Invariant’Class,Aspect Inline_Always,Implementation Defined Aspects
9569 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant}@anchor{13c}
9570 @section Aspect Invariant
9573 @geindex Invariant
9575 This aspect is equivalent to @ref{8d,,pragma Invariant}. It is a
9576 synonym for the language defined aspect @code{Type_Invariant} except
9577 that it is separately controllable using pragma @code{Assertion_Policy}.
9579 @node Aspect Invariant’Class,Aspect Iterable,Aspect Invariant,Implementation Defined Aspects
9580 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant-class}@anchor{13d}
9581 @section Aspect Invariant’Class
9584 @geindex Invariant'Class
9586 This aspect is equivalent to @ref{106,,pragma Type_Invariant_Class}. It is a
9587 synonym for the language defined aspect @code{Type_Invariant'Class} except
9588 that it is separately controllable using pragma @code{Assertion_Policy}.
9590 @node Aspect Iterable,Aspect Linker_Section,Aspect Invariant’Class,Implementation Defined Aspects
9591 @anchor{gnat_rm/implementation_defined_aspects aspect-iterable}@anchor{13e}
9592 @section Aspect Iterable
9595 @geindex Iterable
9597 This aspect provides a light-weight mechanism for loops and quantified
9598 expressions over container types, without the overhead imposed by the tampering
9599 checks of standard Ada 2012 iterators. The value of the aspect is an aggregate
9600 with six named components, of which the last three are optional: @code{First},
9601 @code{Next}, @code{Has_Element}, @code{Element}, @code{Last}, and @code{Previous}.
9602 When only the first three components are specified, only the
9603 @code{for .. in} form of iteration over cursors is available. When @code{Element}
9604 is specified, both this form and the @code{for .. of} form of iteration over
9605 elements are available. If the last two components are specified, reverse
9606 iterations over the container can be specified (analogous to what can be done
9607 over predefined containers that support the @code{Reverse_Iterator} interface).
9608 The following is a typical example of use:
9610 @example
9611 type List is private with
9612     Iterable => (First       => First_Cursor,
9613                  Next        => Advance,
9614                  Has_Element => Cursor_Has_Element
9615                [,Element     => Get_Element]
9616                [,Last        => Last_Cursor]
9617                [,Previous    => Retreat]);
9618 @end example
9621 @itemize *
9623 @item 
9624 The values of @code{First} and @code{Last} are primitive operations of the
9625 container type that return a @code{Cursor}, which must be a type declared in
9626 the container package or visible from it. For example:
9627 @end itemize
9629 @example
9630 function First_Cursor (Cont : Container) return Cursor;
9631 function Last_Cursor  (Cont : Container) return Cursor;
9632 @end example
9635 @itemize *
9637 @item 
9638 The values of @code{Next} and @code{Previous} are primitive operations of the container type that take
9639 both a container and a cursor and yield a cursor. For example:
9640 @end itemize
9642 @example
9643 function Advance (Cont : Container; Position : Cursor) return Cursor;
9644 function Retreat (Cont : Container; Position : Cursor) return Cursor;
9645 @end example
9648 @itemize *
9650 @item 
9651 The value of @code{Has_Element} is a primitive operation of the container type
9652 that takes both a container and a cursor and yields a boolean. For example:
9653 @end itemize
9655 @example
9656 function Cursor_Has_Element (Cont : Container; Position : Cursor) return Boolean;
9657 @end example
9660 @itemize *
9662 @item 
9663 The value of @code{Element} is a primitive operation of the container type that
9664 takes both a container and a cursor and yields an @code{Element_Type}, which must
9665 be a type declared in the container package or visible from it. For example:
9666 @end itemize
9668 @example
9669 function Get_Element (Cont : Container; Position : Cursor) return Element_Type;
9670 @end example
9672 This aspect is used in the GNAT-defined formal container packages.
9674 @node Aspect Linker_Section,Aspect Local_Restrictions,Aspect Iterable,Implementation Defined Aspects
9675 @anchor{gnat_rm/implementation_defined_aspects aspect-linker-section}@anchor{13f}
9676 @section Aspect Linker_Section
9679 @geindex Linker_Section
9681 This aspect is equivalent to @ref{95,,pragma Linker_Section}.
9683 @node Aspect Local_Restrictions,Aspect Lock_Free,Aspect Linker_Section,Implementation Defined Aspects
9684 @anchor{gnat_rm/implementation_defined_aspects aspect-local-restrictions}@anchor{140}
9685 @section Aspect Local_Restrictions
9688 @geindex Local_Restrictions
9690 This aspect may be specified for a subprogram (and for other declarations
9691 as described below). It is used to specify that a particular subprogram does
9692 not violate one or more local restrictions, nor can it call a subprogram
9693 that is not subject to the same requirement. Positional aggregate syntax
9694 (with parentheses, not square brackets) may be used to specify more than one
9695 local restriction, as in
9697 @example
9698 procedure Do_Something
9699   with Local_Restrictions => (Some_Restriction, Another_Restriction);
9700 @end example
9702 Parentheses are currently required even in the case of specifying a single
9703 local restriction (this requirement may be relaxed in the future).
9704 Supported local restrictions currently include (only) No_Heap_Allocations and
9705 No_Secondary_Stack.
9706 No_Secondary_Stack corresponds to the GNAT-defined (global) restriction
9707 of the same name. No_Heap_Allocations corresponds to the conjunction of the
9708 Ada-defined restrictions No_Allocators and No_Implicit_Heap_Allocations.
9710 Additional requirements are imposed in order to ensure that restriction
9711 violations cannot be achieved via overriding dispatching operations,
9712 calling through an access-to-subprogram value, calling a generic formal
9713 subprogram, or calling through a subprogram renaming.
9714 For a dispatching operation, an overrider must be subject to (at least) the
9715 same restrictions as the overridden inherited subprogram; similarly, the
9716 actual subprogram corresponding to a generic formal subprogram
9717 in an instantiation must be subject to (at least) the same restrictions
9718 as the formal subprogram. A call through an access-to-subprogram value
9719 is conservatively assumed to violate all local restrictions; tasking-related
9720 constructs (notably entry calls) are treated similarly. A renaming-as-body is
9721 treated like a subprogram body containing a call to the renamed subprogram.
9723 The Local_Restrictions aspect can be specified for a package specification,
9724 in which case the aspect specification also applies to all eligible entities
9725 declared with the package. This includes types. Default initialization of an
9726 object of a given type is treated like a call to an implicitly-declared
9727 initialization subprogram. Such a “call” is subject to the same local
9728 restriction checks as any other call. If a type is subject to a local
9729 restriction, then any violations of that restriction within the default
9730 initialization expressions (if any) of the type are rejected. This may
9731 include “calls” to the default initialization subprograms of other types.
9733 Local_Restrictions aspect specifications are additive (for example, in the
9734 case of a declaration that occurs within nested packages that each have
9735 a Local_Restrictions specification).
9737 @node Aspect Lock_Free,Aspect Max_Queue_Length,Aspect Local_Restrictions,Implementation Defined Aspects
9738 @anchor{gnat_rm/implementation_defined_aspects aspect-lock-free}@anchor{141}
9739 @section Aspect Lock_Free
9742 @geindex Lock_Free
9744 This boolean aspect is equivalent to @ref{97,,pragma Lock_Free}.
9746 @node Aspect Max_Queue_Length,Aspect No_Caching,Aspect Lock_Free,Implementation Defined Aspects
9747 @anchor{gnat_rm/implementation_defined_aspects aspect-max-queue-length}@anchor{142}
9748 @section Aspect Max_Queue_Length
9751 @geindex Max_Queue_Length
9753 This aspect is equivalent to @ref{9f,,pragma Max_Queue_Length}.
9755 @node Aspect No_Caching,Aspect No_Elaboration_Code_All,Aspect Max_Queue_Length,Implementation Defined Aspects
9756 @anchor{gnat_rm/implementation_defined_aspects aspect-no-caching}@anchor{143}
9757 @section Aspect No_Caching
9760 @geindex No_Caching
9762 This boolean aspect is equivalent to @ref{a2,,pragma No_Caching}.
9764 @node Aspect No_Elaboration_Code_All,Aspect No_Inline,Aspect No_Caching,Implementation Defined Aspects
9765 @anchor{gnat_rm/implementation_defined_aspects aspect-no-elaboration-code-all}@anchor{144}
9766 @section Aspect No_Elaboration_Code_All
9769 @geindex No_Elaboration_Code_All
9771 This aspect is equivalent to @ref{a5,,pragma No_Elaboration_Code_All}
9772 for a program unit.
9774 @node Aspect No_Inline,Aspect No_Tagged_Streams,Aspect No_Elaboration_Code_All,Implementation Defined Aspects
9775 @anchor{gnat_rm/implementation_defined_aspects aspect-no-inline}@anchor{145}
9776 @section Aspect No_Inline
9779 @geindex No_Inline
9781 This boolean aspect is equivalent to @ref{a8,,pragma No_Inline}.
9783 @node Aspect No_Tagged_Streams,Aspect No_Task_Parts,Aspect No_Inline,Implementation Defined Aspects
9784 @anchor{gnat_rm/implementation_defined_aspects aspect-no-tagged-streams}@anchor{146}
9785 @section Aspect No_Tagged_Streams
9788 @geindex No_Tagged_Streams
9790 This aspect is equivalent to @ref{ac,,pragma No_Tagged_Streams} with an
9791 argument specifying a root tagged type (thus this aspect can only be
9792 applied to such a type).
9794 @node Aspect No_Task_Parts,Aspect Object_Size,Aspect No_Tagged_Streams,Implementation Defined Aspects
9795 @anchor{gnat_rm/implementation_defined_aspects aspect-no-task-parts}@anchor{147}
9796 @section Aspect No_Task_Parts
9799 @geindex No_Task_Parts
9801 Applies to a type. If True, requires that the type and any descendants
9802 do not have any task parts. The rules for this aspect are the same as
9803 for the language-defined No_Controlled_Parts aspect (see RM-H.4.1),
9804 replacing “controlled” with “task”.
9806 If No_Task_Parts is True for a type T, then the compiler can optimize
9807 away certain tasking-related code that would otherwise be needed
9808 for T’Class, because descendants of T might contain tasks.
9810 @node Aspect Object_Size,Aspect Obsolescent,Aspect No_Task_Parts,Implementation Defined Aspects
9811 @anchor{gnat_rm/implementation_defined_aspects aspect-object-size}@anchor{148}
9812 @section Aspect Object_Size
9815 @geindex Object_Size
9817 This aspect is equivalent to @ref{149,,attribute Object_Size}.
9819 @node Aspect Obsolescent,Aspect Part_Of,Aspect Object_Size,Implementation Defined Aspects
9820 @anchor{gnat_rm/implementation_defined_aspects aspect-obsolescent}@anchor{14a}
9821 @section Aspect Obsolescent
9824 @geindex Obsolescent
9826 This aspect is equivalent to @ref{af,,pragma Obsolescent}. Note that the
9827 evaluation of this aspect happens at the point of occurrence, it is not
9828 delayed until the freeze point.
9830 @node Aspect Part_Of,Aspect Persistent_BSS,Aspect Obsolescent,Implementation Defined Aspects
9831 @anchor{gnat_rm/implementation_defined_aspects aspect-part-of}@anchor{14b}
9832 @section Aspect Part_Of
9835 @geindex Part_Of
9837 This aspect is equivalent to @ref{b5,,pragma Part_Of}.
9839 @node Aspect Persistent_BSS,Aspect Predicate,Aspect Part_Of,Implementation Defined Aspects
9840 @anchor{gnat_rm/implementation_defined_aspects aspect-persistent-bss}@anchor{14c}
9841 @section Aspect Persistent_BSS
9844 @geindex Persistent_BSS
9846 This boolean aspect is equivalent to @ref{b9,,pragma Persistent_BSS}.
9848 @node Aspect Predicate,Aspect Pure_Function,Aspect Persistent_BSS,Implementation Defined Aspects
9849 @anchor{gnat_rm/implementation_defined_aspects aspect-predicate}@anchor{14d}
9850 @section Aspect Predicate
9853 @geindex Predicate
9855 This aspect is equivalent to @ref{c0,,pragma Predicate}. It is thus
9856 similar to the language defined aspects @code{Dynamic_Predicate}
9857 and @code{Static_Predicate} except that whether the resulting
9858 predicate is static or dynamic is controlled by the form of the
9859 expression. It is also separately controllable using pragma
9860 @code{Assertion_Policy}.
9862 @node Aspect Pure_Function,Aspect Refined_Depends,Aspect Predicate,Implementation Defined Aspects
9863 @anchor{gnat_rm/implementation_defined_aspects aspect-pure-function}@anchor{14e}
9864 @section Aspect Pure_Function
9867 @geindex Pure_Function
9869 This boolean aspect is equivalent to @ref{cc,,pragma Pure_Function}.
9871 @node Aspect Refined_Depends,Aspect Refined_Global,Aspect Pure_Function,Implementation Defined Aspects
9872 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-depends}@anchor{14f}
9873 @section Aspect Refined_Depends
9876 @geindex Refined_Depends
9878 This aspect is equivalent to @ref{d0,,pragma Refined_Depends}.
9880 @node Aspect Refined_Global,Aspect Refined_Post,Aspect Refined_Depends,Implementation Defined Aspects
9881 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-global}@anchor{150}
9882 @section Aspect Refined_Global
9885 @geindex Refined_Global
9887 This aspect is equivalent to @ref{d2,,pragma Refined_Global}.
9889 @node Aspect Refined_Post,Aspect Refined_State,Aspect Refined_Global,Implementation Defined Aspects
9890 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-post}@anchor{151}
9891 @section Aspect Refined_Post
9894 @geindex Refined_Post
9896 This aspect is equivalent to @ref{d4,,pragma Refined_Post}.
9898 @node Aspect Refined_State,Aspect Relaxed_Initialization,Aspect Refined_Post,Implementation Defined Aspects
9899 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-state}@anchor{152}
9900 @section Aspect Refined_State
9903 @geindex Refined_State
9905 This aspect is equivalent to @ref{d6,,pragma Refined_State}.
9907 @node Aspect Relaxed_Initialization,Aspect Remote_Access_Type,Aspect Refined_State,Implementation Defined Aspects
9908 @anchor{gnat_rm/implementation_defined_aspects aspect-relaxed-initialization}@anchor{153}
9909 @section Aspect Relaxed_Initialization
9912 @geindex Refined_Initialization
9914 For the syntax and semantics of this aspect, see the SPARK 2014 Reference
9915 Manual, section 6.10.
9917 @node Aspect Remote_Access_Type,Aspect Secondary_Stack_Size,Aspect Relaxed_Initialization,Implementation Defined Aspects
9918 @anchor{gnat_rm/implementation_defined_aspects aspect-remote-access-type}@anchor{154}
9919 @section Aspect Remote_Access_Type
9922 @geindex Remote_Access_Type
9924 This aspect is equivalent to @ref{d9,,pragma Remote_Access_Type}.
9926 @node Aspect Secondary_Stack_Size,Aspect Scalar_Storage_Order,Aspect Remote_Access_Type,Implementation Defined Aspects
9927 @anchor{gnat_rm/implementation_defined_aspects aspect-secondary-stack-size}@anchor{155}
9928 @section Aspect Secondary_Stack_Size
9931 @geindex Secondary_Stack_Size
9933 This aspect is equivalent to @ref{df,,pragma Secondary_Stack_Size}.
9935 @node Aspect Scalar_Storage_Order,Aspect Shared,Aspect Secondary_Stack_Size,Implementation Defined Aspects
9936 @anchor{gnat_rm/implementation_defined_aspects aspect-scalar-storage-order}@anchor{156}
9937 @section Aspect Scalar_Storage_Order
9940 @geindex Scalar_Storage_Order
9942 This aspect is equivalent to a @ref{157,,attribute Scalar_Storage_Order}.
9944 @node Aspect Shared,Aspect Side_Effects,Aspect Scalar_Storage_Order,Implementation Defined Aspects
9945 @anchor{gnat_rm/implementation_defined_aspects aspect-shared}@anchor{158}
9946 @section Aspect Shared
9949 @geindex Shared
9951 This boolean aspect is equivalent to @ref{e2,,pragma Shared}
9952 and is thus a synonym for aspect @code{Atomic}.
9954 @node Aspect Side_Effects,Aspect Simple_Storage_Pool,Aspect Shared,Implementation Defined Aspects
9955 @anchor{gnat_rm/implementation_defined_aspects aspect-side-effects}@anchor{159}
9956 @section Aspect Side_Effects
9959 @geindex Side_Effects
9961 This aspect is equivalent to @ref{e6,,pragma Side_Effects}.
9963 @node Aspect Simple_Storage_Pool,Aspect Simple_Storage_Pool_Type,Aspect Side_Effects,Implementation Defined Aspects
9964 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool}@anchor{15a}
9965 @section Aspect Simple_Storage_Pool
9968 @geindex Simple_Storage_Pool
9970 This aspect is equivalent to @ref{e9,,attribute Simple_Storage_Pool}.
9972 @node Aspect Simple_Storage_Pool_Type,Aspect SPARK_Mode,Aspect Simple_Storage_Pool,Implementation Defined Aspects
9973 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool-type}@anchor{15b}
9974 @section Aspect Simple_Storage_Pool_Type
9977 @geindex Simple_Storage_Pool_Type
9979 This boolean aspect is equivalent to @ref{e8,,pragma Simple_Storage_Pool_Type}.
9981 @node Aspect SPARK_Mode,Aspect Suppress_Debug_Info,Aspect Simple_Storage_Pool_Type,Implementation Defined Aspects
9982 @anchor{gnat_rm/implementation_defined_aspects aspect-spark-mode}@anchor{15c}
9983 @section Aspect SPARK_Mode
9986 @geindex SPARK_Mode
9988 This aspect is equivalent to @ref{f0,,pragma SPARK_Mode} and
9989 may be specified for either or both of the specification and body
9990 of a subprogram or package.
9992 @node Aspect Suppress_Debug_Info,Aspect Suppress_Initialization,Aspect SPARK_Mode,Implementation Defined Aspects
9993 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-debug-info}@anchor{15d}
9994 @section Aspect Suppress_Debug_Info
9997 @geindex Suppress_Debug_Info
9999 This boolean aspect is equivalent to @ref{f8,,pragma Suppress_Debug_Info}.
10001 @node Aspect Suppress_Initialization,Aspect Test_Case,Aspect Suppress_Debug_Info,Implementation Defined Aspects
10002 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-initialization}@anchor{15e}
10003 @section Aspect Suppress_Initialization
10006 @geindex Suppress_Initialization
10008 This boolean aspect is equivalent to @ref{fb,,pragma Suppress_Initialization}.
10010 @node Aspect Test_Case,Aspect Thread_Local_Storage,Aspect Suppress_Initialization,Implementation Defined Aspects
10011 @anchor{gnat_rm/implementation_defined_aspects aspect-test-case}@anchor{15f}
10012 @section Aspect Test_Case
10015 @geindex Test_Case
10017 This aspect is equivalent to @ref{ff,,pragma Test_Case}.
10019 @node Aspect Thread_Local_Storage,Aspect Universal_Aliasing,Aspect Test_Case,Implementation Defined Aspects
10020 @anchor{gnat_rm/implementation_defined_aspects aspect-thread-local-storage}@anchor{160}
10021 @section Aspect Thread_Local_Storage
10024 @geindex Thread_Local_Storage
10026 This boolean aspect is equivalent to @ref{101,,pragma Thread_Local_Storage}.
10028 @node Aspect Universal_Aliasing,Aspect Unmodified,Aspect Thread_Local_Storage,Implementation Defined Aspects
10029 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-aliasing}@anchor{161}
10030 @section Aspect Universal_Aliasing
10033 @geindex Universal_Aliasing
10035 This boolean aspect is equivalent to @ref{10c,,pragma Universal_Aliasing}.
10037 @node Aspect Unmodified,Aspect Unreferenced,Aspect Universal_Aliasing,Implementation Defined Aspects
10038 @anchor{gnat_rm/implementation_defined_aspects aspect-unmodified}@anchor{162}
10039 @section Aspect Unmodified
10042 @geindex Unmodified
10044 This boolean aspect is equivalent to @ref{10e,,pragma Unmodified}.
10046 @node Aspect Unreferenced,Aspect Unreferenced_Objects,Aspect Unmodified,Implementation Defined Aspects
10047 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced}@anchor{163}
10048 @section Aspect Unreferenced
10051 @geindex Unreferenced
10053 This boolean aspect is equivalent to @ref{110,,pragma Unreferenced}.
10055 When using the @code{-gnat2022} switch, this aspect is also supported on formal
10056 parameters, which is in particular the only form possible for expression
10057 functions.
10059 @node Aspect Unreferenced_Objects,Aspect User_Aspect,Aspect Unreferenced,Implementation Defined Aspects
10060 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced-objects}@anchor{164}
10061 @section Aspect Unreferenced_Objects
10064 @geindex Unreferenced_Objects
10066 This boolean aspect is equivalent to @ref{112,,pragma Unreferenced_Objects}.
10068 @node Aspect User_Aspect,Aspect Value_Size,Aspect Unreferenced_Objects,Implementation Defined Aspects
10069 @anchor{gnat_rm/implementation_defined_aspects aspect-user-aspect}@anchor{165}
10070 @section Aspect User_Aspect
10073 @geindex User_Aspect
10075 This aspect takes an argument that is the name of an aspect defined by a
10076 User_Aspect_Definition configuration pragma.
10077 A User_Aspect aspect specification is semantically equivalent to
10078 replicating the set of aspect specifications associated with the named
10079 pragma-defined aspect.
10081 @node Aspect Value_Size,Aspect Volatile_Full_Access,Aspect User_Aspect,Implementation Defined Aspects
10082 @anchor{gnat_rm/implementation_defined_aspects aspect-value-size}@anchor{166}
10083 @section Aspect Value_Size
10086 @geindex Value_Size
10088 This aspect is equivalent to @ref{167,,attribute Value_Size}.
10090 @node Aspect Volatile_Full_Access,Aspect Volatile_Function,Aspect Value_Size,Implementation Defined Aspects
10091 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-full-access}@anchor{168}
10092 @section Aspect Volatile_Full_Access
10095 @geindex Volatile_Full_Access
10097 This boolean aspect is equivalent to @ref{11c,,pragma Volatile_Full_Access}.
10099 @node Aspect Volatile_Function,Aspect Warnings,Aspect Volatile_Full_Access,Implementation Defined Aspects
10100 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-function}@anchor{169}
10101 @section Aspect Volatile_Function
10104 @geindex Volatile_Function
10106 This boolean aspect is equivalent to @ref{11e,,pragma Volatile_Function}.
10108 @node Aspect Warnings,,Aspect Volatile_Function,Implementation Defined Aspects
10109 @anchor{gnat_rm/implementation_defined_aspects aspect-warnings}@anchor{16a}
10110 @section Aspect Warnings
10113 @geindex Warnings
10115 This aspect is equivalent to the two argument form of @ref{120,,pragma Warnings},
10116 where the first argument is @code{ON} or @code{OFF} and the second argument
10117 is the entity.
10119 @node Implementation Defined Attributes,Standard and Implementation Defined Restrictions,Implementation Defined Aspects,Top
10120 @anchor{gnat_rm/implementation_defined_attributes doc}@anchor{16b}@anchor{gnat_rm/implementation_defined_attributes id1}@anchor{16c}@anchor{gnat_rm/implementation_defined_attributes implementation-defined-attributes}@anchor{8}
10121 @chapter Implementation Defined Attributes
10124 Ada defines (throughout the Ada reference manual,
10125 summarized in Annex K),
10126 a set of attributes that provide useful additional functionality in all
10127 areas of the language.  These language defined attributes are implemented
10128 in GNAT and work as described in the Ada Reference Manual.
10130 In addition, Ada allows implementations to define additional
10131 attributes whose meaning is defined by the implementation.  GNAT provides
10132 a number of these implementation-dependent attributes which can be used
10133 to extend and enhance the functionality of the compiler.  This section of
10134 the GNAT reference manual describes these additional attributes.  It also
10135 describes additional implementation-dependent features of standard
10136 language-defined attributes.
10138 Note that any program using these attributes may not be portable to
10139 other compilers (although GNAT implements this set of attributes on all
10140 platforms).  Therefore if portability to other compilers is an important
10141 consideration, you should minimize the use of these attributes.
10143 @menu
10144 * Attribute Abort_Signal:: 
10145 * Attribute Address_Size:: 
10146 * Attribute Asm_Input:: 
10147 * Attribute Asm_Output:: 
10148 * Attribute Atomic_Always_Lock_Free:: 
10149 * Attribute Bit:: 
10150 * Attribute Bit_Position:: 
10151 * Attribute Code_Address:: 
10152 * Attribute Compiler_Version:: 
10153 * Attribute Constrained:: 
10154 * Attribute Default_Bit_Order:: 
10155 * Attribute Default_Scalar_Storage_Order:: 
10156 * Attribute Deref:: 
10157 * Attribute Descriptor_Size:: 
10158 * Attribute Elaborated:: 
10159 * Attribute Elab_Body:: 
10160 * Attribute Elab_Spec:: 
10161 * Attribute Elab_Subp_Body:: 
10162 * Attribute Emax:: 
10163 * Attribute Enabled:: 
10164 * Attribute Enum_Rep:: 
10165 * Attribute Enum_Val:: 
10166 * Attribute Epsilon:: 
10167 * Attribute Fast_Math:: 
10168 * Attribute Finalization_Size:: 
10169 * Attribute Fixed_Value:: 
10170 * Attribute From_Any:: 
10171 * Attribute Has_Access_Values:: 
10172 * Attribute Has_Discriminants:: 
10173 * Attribute Has_Tagged_Values:: 
10174 * Attribute Img:: 
10175 * Attribute Initialized:: 
10176 * Attribute Integer_Value:: 
10177 * Attribute Invalid_Value:: 
10178 * Attribute Iterable:: 
10179 * Attribute Large:: 
10180 * Attribute Library_Level:: 
10181 * Attribute Loop_Entry:: 
10182 * Attribute Machine_Size:: 
10183 * Attribute Mantissa:: 
10184 * Attribute Maximum_Alignment:: 
10185 * Attribute Max_Integer_Size:: 
10186 * Attribute Mechanism_Code:: 
10187 * Attribute Null_Parameter:: 
10188 * Attribute Object_Size:: 
10189 * Attribute Old:: 
10190 * Attribute Passed_By_Reference:: 
10191 * Attribute Pool_Address:: 
10192 * Attribute Range_Length:: 
10193 * Attribute Restriction_Set:: 
10194 * Attribute Result:: 
10195 * Attribute Safe_Emax:: 
10196 * Attribute Safe_Large:: 
10197 * Attribute Safe_Small:: 
10198 * Attribute Scalar_Storage_Order:: 
10199 * Attribute Simple_Storage_Pool:: 
10200 * Attribute Small:: 
10201 * Attribute Small_Denominator:: 
10202 * Attribute Small_Numerator:: 
10203 * Attribute Storage_Unit:: 
10204 * Attribute Stub_Type:: 
10205 * Attribute System_Allocator_Alignment:: 
10206 * Attribute Target_Name:: 
10207 * Attribute To_Address:: 
10208 * Attribute To_Any:: 
10209 * Attribute Type_Class:: 
10210 * Attribute Type_Key:: 
10211 * Attribute TypeCode:: 
10212 * Attribute Unconstrained_Array:: 
10213 * Attribute Universal_Literal_String:: 
10214 * Attribute Unrestricted_Access:: 
10215 * Attribute Update:: 
10216 * Attribute Valid_Value:: 
10217 * Attribute Valid_Scalars:: 
10218 * Attribute VADS_Size:: 
10219 * Attribute Value_Size:: 
10220 * Attribute Wchar_T_Size:: 
10221 * Attribute Word_Size:: 
10223 @end menu
10225 @node Attribute Abort_Signal,Attribute Address_Size,,Implementation Defined Attributes
10226 @anchor{gnat_rm/implementation_defined_attributes attribute-abort-signal}@anchor{16d}
10227 @section Attribute Abort_Signal
10230 @geindex Abort_Signal
10232 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
10233 prefix) provides the entity for the special exception used to signal
10234 task abort or asynchronous transfer of control.  Normally this attribute
10235 should only be used in the tasking runtime (it is highly peculiar, and
10236 completely outside the normal semantics of Ada, for a user program to
10237 intercept the abort exception).
10239 @node Attribute Address_Size,Attribute Asm_Input,Attribute Abort_Signal,Implementation Defined Attributes
10240 @anchor{gnat_rm/implementation_defined_attributes attribute-address-size}@anchor{16e}
10241 @section Attribute Address_Size
10244 @geindex Size of `@w{`}Address`@w{`}
10246 @geindex Address_Size
10248 @code{Standard'Address_Size} (@code{Standard} is the only allowed
10249 prefix) is a static constant giving the number of bits in an
10250 @code{Address}. It is the same value as System.Address’Size,
10251 but has the advantage of being static, while a direct
10252 reference to System.Address’Size is nonstatic because Address
10253 is a private type.
10255 @node Attribute Asm_Input,Attribute Asm_Output,Attribute Address_Size,Implementation Defined Attributes
10256 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-input}@anchor{16f}
10257 @section Attribute Asm_Input
10260 @geindex Asm_Input
10262 The @code{Asm_Input} attribute denotes a function that takes two
10263 parameters.  The first is a string, the second is an expression of the
10264 type designated by the prefix.  The first (string) argument is required
10265 to be a static expression, and is the constraint for the parameter,
10266 (e.g., what kind of register is required).  The second argument is the
10267 value to be used as the input argument.  The possible values for the
10268 constant are the same as those used in the RTL, and are dependent on
10269 the configuration file used to built the GCC back end.
10270 @ref{170,,Machine Code Insertions}
10272 @node Attribute Asm_Output,Attribute Atomic_Always_Lock_Free,Attribute Asm_Input,Implementation Defined Attributes
10273 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-output}@anchor{171}
10274 @section Attribute Asm_Output
10277 @geindex Asm_Output
10279 The @code{Asm_Output} attribute denotes a function that takes two
10280 parameters.  The first is a string, the second is the name of a variable
10281 of the type designated by the attribute prefix.  The first (string)
10282 argument is required to be a static expression and designates the
10283 constraint for the parameter (e.g., what kind of register is
10284 required).  The second argument is the variable to be updated with the
10285 result.  The possible values for constraint are the same as those used in
10286 the RTL, and are dependent on the configuration file used to build the
10287 GCC back end.  If there are no output operands, then this argument may
10288 either be omitted, or explicitly given as @code{No_Output_Operands}.
10289 @ref{170,,Machine Code Insertions}
10291 @node Attribute Atomic_Always_Lock_Free,Attribute Bit,Attribute Asm_Output,Implementation Defined Attributes
10292 @anchor{gnat_rm/implementation_defined_attributes attribute-atomic-always-lock-free}@anchor{172}
10293 @section Attribute Atomic_Always_Lock_Free
10296 @geindex Atomic_Always_Lock_Free
10298 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
10299 The result is a Boolean value which is True if the type has discriminants,
10300 and False otherwise.  The result indicate whether atomic operations are
10301 supported by the target for the given type.
10303 @node Attribute Bit,Attribute Bit_Position,Attribute Atomic_Always_Lock_Free,Implementation Defined Attributes
10304 @anchor{gnat_rm/implementation_defined_attributes attribute-bit}@anchor{173}
10305 @section Attribute Bit
10308 @geindex Bit
10310 @code{obj'Bit}, where @code{obj} is any object, yields the bit
10311 offset within the storage unit (byte) that contains the first bit of
10312 storage allocated for the object.  The value of this attribute is of the
10313 type `universal_integer' and is always a nonnegative number smaller
10314 than @code{System.Storage_Unit}.
10316 For an object that is a variable or a constant allocated in a register,
10317 the value is zero.  (The use of this attribute does not force the
10318 allocation of a variable to memory).
10320 For an object that is a formal parameter, this attribute applies
10321 to either the matching actual parameter or to a copy of the
10322 matching actual parameter.
10324 For an access object the value is zero.  Note that
10325 @code{obj.all'Bit} is subject to an @code{Access_Check} for the
10326 designated object.  Similarly for a record component
10327 @code{X.C'Bit} is subject to a discriminant check and
10328 @code{X(I).Bit} and @code{X(I1..I2)'Bit}
10329 are subject to index checks.
10331 This attribute is designed to be compatible with the DEC Ada 83 definition
10332 and implementation of the @code{Bit} attribute.
10334 @node Attribute Bit_Position,Attribute Code_Address,Attribute Bit,Implementation Defined Attributes
10335 @anchor{gnat_rm/implementation_defined_attributes attribute-bit-position}@anchor{174}
10336 @section Attribute Bit_Position
10339 @geindex Bit_Position
10341 @code{R.C'Bit_Position}, where @code{R} is a record object and @code{C} is one
10342 of the fields of the record type, yields the bit
10343 offset within the record contains the first bit of
10344 storage allocated for the object.  The value of this attribute is of the
10345 type `universal_integer'.  The value depends only on the field
10346 @code{C} and is independent of the alignment of
10347 the containing record @code{R}.
10349 @node Attribute Code_Address,Attribute Compiler_Version,Attribute Bit_Position,Implementation Defined Attributes
10350 @anchor{gnat_rm/implementation_defined_attributes attribute-code-address}@anchor{175}
10351 @section Attribute Code_Address
10354 @geindex Code_Address
10356 @geindex Subprogram address
10358 @geindex Address of subprogram code
10360 The @code{'Address}
10361 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
10362 intended effect seems to be to provide
10363 an address value which can be used to call the subprogram by means of
10364 an address clause as in the following example:
10366 @example
10367 procedure K is ...
10369 procedure L;
10370 for L'Address use K'Address;
10371 pragma Import (Ada, L);
10372 @end example
10374 A call to @code{L} is then expected to result in a call to @code{K}.
10375 In Ada 83, where there were no access-to-subprogram values, this was
10376 a common work-around for getting the effect of an indirect call.
10377 GNAT implements the above use of @code{Address} and the technique
10378 illustrated by the example code works correctly.
10380 However, for some purposes, it is useful to have the address of the start
10381 of the generated code for the subprogram.  On some architectures, this is
10382 not necessarily the same as the @code{Address} value described above.
10383 For example, the @code{Address} value may reference a subprogram
10384 descriptor rather than the subprogram itself.
10386 The @code{'Code_Address} attribute, which can only be applied to
10387 subprogram entities, always returns the address of the start of the
10388 generated code of the specified subprogram, which may or may not be
10389 the same value as is returned by the corresponding @code{'Address}
10390 attribute.
10392 @node Attribute Compiler_Version,Attribute Constrained,Attribute Code_Address,Implementation Defined Attributes
10393 @anchor{gnat_rm/implementation_defined_attributes attribute-compiler-version}@anchor{176}
10394 @section Attribute Compiler_Version
10397 @geindex Compiler_Version
10399 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
10400 prefix) yields a static string identifying the version of the compiler
10401 being used to compile the unit containing the attribute reference.
10403 @node Attribute Constrained,Attribute Default_Bit_Order,Attribute Compiler_Version,Implementation Defined Attributes
10404 @anchor{gnat_rm/implementation_defined_attributes attribute-constrained}@anchor{177}
10405 @section Attribute Constrained
10408 @geindex Constrained
10410 In addition to the usage of this attribute in the Ada RM, GNAT
10411 also permits the use of the @code{'Constrained} attribute
10412 in a generic template
10413 for any type, including types without discriminants. The value of this
10414 attribute in the generic instance when applied to a scalar type or a
10415 record type without discriminants is always @code{True}. This usage is
10416 compatible with older Ada compilers, including notably DEC Ada.
10418 @node Attribute Default_Bit_Order,Attribute Default_Scalar_Storage_Order,Attribute Constrained,Implementation Defined Attributes
10419 @anchor{gnat_rm/implementation_defined_attributes attribute-default-bit-order}@anchor{178}
10420 @section Attribute Default_Bit_Order
10423 @geindex Big endian
10425 @geindex Little endian
10427 @geindex Default_Bit_Order
10429 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
10430 allowed prefix), provides the value @code{System.Default_Bit_Order}
10431 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
10432 @code{Low_Order_First}).  This is used to construct the definition of
10433 @code{Default_Bit_Order} in package @code{System}.
10435 @node Attribute Default_Scalar_Storage_Order,Attribute Deref,Attribute Default_Bit_Order,Implementation Defined Attributes
10436 @anchor{gnat_rm/implementation_defined_attributes attribute-default-scalar-storage-order}@anchor{179}
10437 @section Attribute Default_Scalar_Storage_Order
10440 @geindex Big endian
10442 @geindex Little endian
10444 @geindex Default_Scalar_Storage_Order
10446 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
10447 allowed prefix), provides the current value of the default scalar storage
10448 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
10449 equal to @code{Default_Bit_Order} if unspecified) as a
10450 @code{System.Bit_Order} value. This is a static attribute.
10452 @node Attribute Deref,Attribute Descriptor_Size,Attribute Default_Scalar_Storage_Order,Implementation Defined Attributes
10453 @anchor{gnat_rm/implementation_defined_attributes attribute-deref}@anchor{17a}
10454 @section Attribute Deref
10457 @geindex Deref
10459 The attribute @code{typ'Deref(expr)} where @code{expr} is of type @code{System.Address} yields
10460 the variable of type @code{typ} that is located at the given address. It is similar
10461 to @code{(totyp (expr).all)}, where @code{totyp} is an unchecked conversion from address to
10462 a named access-to-@cite{typ} type, except that it yields a variable, so it can be
10463 used on the left side of an assignment.
10465 @node Attribute Descriptor_Size,Attribute Elaborated,Attribute Deref,Implementation Defined Attributes
10466 @anchor{gnat_rm/implementation_defined_attributes attribute-descriptor-size}@anchor{17b}
10467 @section Attribute Descriptor_Size
10470 @geindex Descriptor
10472 @geindex Dope vector
10474 @geindex Descriptor_Size
10476 Nonstatic attribute @code{Descriptor_Size} returns the size in bits of the
10477 descriptor allocated for a type.  The result is non-zero only for unconstrained
10478 array types and the returned value is of type universal integer.  In GNAT, an
10479 array descriptor contains bounds information and is located immediately before
10480 the first element of the array.
10482 @example
10483 type Unconstr_Array is array (Short_Short_Integer range <>) of Positive;
10484 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
10485 @end example
10487 The attribute takes into account any padding due to the alignment of the
10488 component type. In the example above, the descriptor contains two values
10489 of type @code{Short_Short_Integer} representing the low and high bound. But,
10490 since @code{Positive} has an alignment of 4, the size of the descriptor is
10491 @code{2 * Short_Short_Integer'Size} rounded up to the next multiple of 32,
10492 which yields a size of 32 bits, i.e. including 16 bits of padding.
10494 @node Attribute Elaborated,Attribute Elab_Body,Attribute Descriptor_Size,Implementation Defined Attributes
10495 @anchor{gnat_rm/implementation_defined_attributes attribute-elaborated}@anchor{17c}
10496 @section Attribute Elaborated
10499 @geindex Elaborated
10501 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
10502 value is a Boolean which indicates whether or not the given unit has been
10503 elaborated.  This attribute is primarily intended for internal use by the
10504 generated code for dynamic elaboration checking, but it can also be used
10505 in user programs.  The value will always be True once elaboration of all
10506 units has been completed.  An exception is for units which need no
10507 elaboration, the value is always False for such units.
10509 @node Attribute Elab_Body,Attribute Elab_Spec,Attribute Elaborated,Implementation Defined Attributes
10510 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-body}@anchor{17d}
10511 @section Attribute Elab_Body
10514 @geindex Elab_Body
10516 This attribute can only be applied to a program unit name.  It returns
10517 the entity for the corresponding elaboration procedure for elaborating
10518 the body of the referenced unit.  This is used in the main generated
10519 elaboration procedure by the binder and is not normally used in any
10520 other context.  However, there may be specialized situations in which it
10521 is useful to be able to call this elaboration procedure from Ada code,
10522 e.g., if it is necessary to do selective re-elaboration to fix some
10523 error.
10525 @node Attribute Elab_Spec,Attribute Elab_Subp_Body,Attribute Elab_Body,Implementation Defined Attributes
10526 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-spec}@anchor{17e}
10527 @section Attribute Elab_Spec
10530 @geindex Elab_Spec
10532 This attribute can only be applied to a program unit name.  It returns
10533 the entity for the corresponding elaboration procedure for elaborating
10534 the spec of the referenced unit.  This is used in the main
10535 generated elaboration procedure by the binder and is not normally used
10536 in any other context.  However, there may be specialized situations in
10537 which it is useful to be able to call this elaboration procedure from
10538 Ada code, e.g., if it is necessary to do selective re-elaboration to fix
10539 some error.
10541 @node Attribute Elab_Subp_Body,Attribute Emax,Attribute Elab_Spec,Implementation Defined Attributes
10542 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-subp-body}@anchor{17f}
10543 @section Attribute Elab_Subp_Body
10546 @geindex Elab_Subp_Body
10548 This attribute can only be applied to a library level subprogram
10549 name and is only allowed in CodePeer mode. It returns the entity
10550 for the corresponding elaboration procedure for elaborating the body
10551 of the referenced subprogram unit. This is used in the main generated
10552 elaboration procedure by the binder in CodePeer mode only and is unrecognized
10553 otherwise.
10555 @node Attribute Emax,Attribute Enabled,Attribute Elab_Subp_Body,Implementation Defined Attributes
10556 @anchor{gnat_rm/implementation_defined_attributes attribute-emax}@anchor{180}
10557 @section Attribute Emax
10560 @geindex Ada 83 attributes
10562 @geindex Emax
10564 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
10565 the Ada 83 reference manual for an exact description of the semantics of
10566 this attribute.
10568 @node Attribute Enabled,Attribute Enum_Rep,Attribute Emax,Implementation Defined Attributes
10569 @anchor{gnat_rm/implementation_defined_attributes attribute-enabled}@anchor{181}
10570 @section Attribute Enabled
10573 @geindex Enabled
10575 The @code{Enabled} attribute allows an application program to check at compile
10576 time to see if the designated check is currently enabled. The prefix is a
10577 simple identifier, referencing any predefined check name (other than
10578 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
10579 no argument is given for the attribute, the check is for the general state
10580 of the check, if an argument is given, then it is an entity name, and the
10581 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
10582 given naming the entity (if not, then the argument is ignored).
10584 Note that instantiations inherit the check status at the point of the
10585 instantiation, so a useful idiom is to have a library package that
10586 introduces a check name with @code{pragma Check_Name}, and then contains
10587 generic packages or subprograms which use the @code{Enabled} attribute
10588 to see if the check is enabled. A user of this package can then issue
10589 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
10590 the package or subprogram, controlling whether the check will be present.
10592 @node Attribute Enum_Rep,Attribute Enum_Val,Attribute Enabled,Implementation Defined Attributes
10593 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-rep}@anchor{182}
10594 @section Attribute Enum_Rep
10597 @geindex Representation of enums
10599 @geindex Enum_Rep
10601 Note that this attribute is now standard in Ada 202x and is available
10602 as an implementation defined attribute for earlier Ada versions.
10604 For every enumeration subtype @code{S}, @code{S'Enum_Rep} denotes a
10605 function with the following spec:
10607 @example
10608 function S'Enum_Rep (Arg : S'Base) return <Universal_Integer>;
10609 @end example
10611 It is also allowable to apply @code{Enum_Rep} directly to an object of an
10612 enumeration type or to a non-overloaded enumeration
10613 literal.  In this case @code{S'Enum_Rep} is equivalent to
10614 @code{typ'Enum_Rep(S)} where @code{typ} is the type of the
10615 enumeration literal or object.
10617 The function returns the representation value for the given enumeration
10618 value.  This will be equal to value of the @code{Pos} attribute in the
10619 absence of an enumeration representation clause.  This is a static
10620 attribute (i.e., the result is static if the argument is static).
10622 @code{S'Enum_Rep} can also be used with integer types and objects,
10623 in which case it simply returns the integer value.  The reason for this
10624 is to allow it to be used for @code{(<>)} discrete formal arguments in
10625 a generic unit that can be instantiated with either enumeration types
10626 or integer types.  Note that if @code{Enum_Rep} is used on a modular
10627 type whose upper bound exceeds the upper bound of the largest signed
10628 integer type, and the argument is a variable, so that the universal
10629 integer calculation is done at run time, then the call to @code{Enum_Rep}
10630 may raise @code{Constraint_Error}.
10632 @node Attribute Enum_Val,Attribute Epsilon,Attribute Enum_Rep,Implementation Defined Attributes
10633 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-val}@anchor{183}
10634 @section Attribute Enum_Val
10637 @geindex Representation of enums
10639 @geindex Enum_Val
10641 Note that this attribute is now standard in Ada 202x and is available
10642 as an implementation defined attribute for earlier Ada versions.
10644 For every enumeration subtype @code{S}, @code{S'Enum_Val} denotes a
10645 function with the following spec:
10647 @example
10648 function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;
10649 @end example
10651 The function returns the enumeration value whose representation matches the
10652 argument, or raises Constraint_Error if no enumeration literal of the type
10653 has the matching value.
10654 This will be equal to value of the @code{Val} attribute in the
10655 absence of an enumeration representation clause.  This is a static
10656 attribute (i.e., the result is static if the argument is static).
10658 @node Attribute Epsilon,Attribute Fast_Math,Attribute Enum_Val,Implementation Defined Attributes
10659 @anchor{gnat_rm/implementation_defined_attributes attribute-epsilon}@anchor{184}
10660 @section Attribute Epsilon
10663 @geindex Ada 83 attributes
10665 @geindex Epsilon
10667 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
10668 the Ada 83 reference manual for an exact description of the semantics of
10669 this attribute.
10671 @node Attribute Fast_Math,Attribute Finalization_Size,Attribute Epsilon,Implementation Defined Attributes
10672 @anchor{gnat_rm/implementation_defined_attributes attribute-fast-math}@anchor{185}
10673 @section Attribute Fast_Math
10676 @geindex Fast_Math
10678 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
10679 prefix) yields a static Boolean value that is True if pragma
10680 @code{Fast_Math} is active, and False otherwise.
10682 @node Attribute Finalization_Size,Attribute Fixed_Value,Attribute Fast_Math,Implementation Defined Attributes
10683 @anchor{gnat_rm/implementation_defined_attributes attribute-finalization-size}@anchor{186}
10684 @section Attribute Finalization_Size
10687 @geindex Finalization_Size
10689 The prefix of attribute @code{Finalization_Size} must be an object or
10690 a non-class-wide type. This attribute returns the size of any hidden data
10691 reserved by the compiler to handle finalization-related actions. The type of
10692 the attribute is `universal_integer'.
10694 @code{Finalization_Size} yields a value of zero for a type with no controlled
10695 parts, an object whose type has no controlled parts, or an object of a
10696 class-wide type whose tag denotes a type with no controlled parts.
10698 Note that only heap-allocated objects contain finalization data.
10700 @node Attribute Fixed_Value,Attribute From_Any,Attribute Finalization_Size,Implementation Defined Attributes
10701 @anchor{gnat_rm/implementation_defined_attributes attribute-fixed-value}@anchor{187}
10702 @section Attribute Fixed_Value
10705 @geindex Fixed_Value
10707 For every fixed-point type @code{S}, @code{S'Fixed_Value} denotes a
10708 function with the following specification:
10710 @example
10711 function S'Fixed_Value (Arg : <Universal_Integer>) return S;
10712 @end example
10714 The value returned is the fixed-point value @code{V} such that:
10716 @example
10717 V = Arg * S'Small
10718 @end example
10720 The effect is thus similar to first converting the argument to the
10721 integer type used to represent @code{S}, and then doing an unchecked
10722 conversion to the fixed-point type.  The difference is
10723 that there are full range checks, to ensure that the result is in range.
10724 This attribute is primarily intended for use in implementation of the
10725 input-output functions for fixed-point values.
10727 @node Attribute From_Any,Attribute Has_Access_Values,Attribute Fixed_Value,Implementation Defined Attributes
10728 @anchor{gnat_rm/implementation_defined_attributes attribute-from-any}@anchor{188}
10729 @section Attribute From_Any
10732 @geindex From_Any
10734 This internal attribute is used for the generation of remote subprogram
10735 stubs in the context of the Distributed Systems Annex.
10737 @node Attribute Has_Access_Values,Attribute Has_Discriminants,Attribute From_Any,Implementation Defined Attributes
10738 @anchor{gnat_rm/implementation_defined_attributes attribute-has-access-values}@anchor{189}
10739 @section Attribute Has_Access_Values
10742 @geindex Access values
10743 @geindex testing for
10745 @geindex Has_Access_Values
10747 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
10748 is a Boolean value which is True if the is an access type, or is a composite
10749 type with a component (at any nesting depth) that is an access type, and is
10750 False otherwise.
10751 The intended use of this attribute is in conjunction with generic
10752 definitions.  If the attribute is applied to a generic private type, it
10753 indicates whether or not the corresponding actual type has access values.
10755 @node Attribute Has_Discriminants,Attribute Has_Tagged_Values,Attribute Has_Access_Values,Implementation Defined Attributes
10756 @anchor{gnat_rm/implementation_defined_attributes attribute-has-discriminants}@anchor{18a}
10757 @section Attribute Has_Discriminants
10760 @geindex Discriminants
10761 @geindex testing for
10763 @geindex Has_Discriminants
10765 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
10766 is a Boolean value which is True if the type has discriminants, and False
10767 otherwise.  The intended use of this attribute is in conjunction with generic
10768 definitions.  If the attribute is applied to a generic private type, it
10769 indicates whether or not the corresponding actual type has discriminants.
10771 @node Attribute Has_Tagged_Values,Attribute Img,Attribute Has_Discriminants,Implementation Defined Attributes
10772 @anchor{gnat_rm/implementation_defined_attributes attribute-has-tagged-values}@anchor{18b}
10773 @section Attribute Has_Tagged_Values
10776 @geindex Tagged values
10777 @geindex testing for
10779 @geindex Has_Tagged_Values
10781 The prefix of the @code{Has_Tagged_Values} attribute is a type. The result is a
10782 Boolean value which is True if the type is a composite type (array or record)
10783 that is either a tagged type or has a subcomponent that is tagged, and is False
10784 otherwise. The intended use of this attribute is in conjunction with generic
10785 definitions. If the attribute is applied to a generic private type, it
10786 indicates whether or not the corresponding actual type has access values.
10788 @node Attribute Img,Attribute Initialized,Attribute Has_Tagged_Values,Implementation Defined Attributes
10789 @anchor{gnat_rm/implementation_defined_attributes attribute-img}@anchor{18c}
10790 @section Attribute Img
10793 @geindex Img
10795 The @code{Img} attribute differs from @code{Image} in that, while both can be
10796 applied directly to an object, @code{Img} cannot be applied to types.
10798 Example usage of the attribute:
10800 @example
10801 Put_Line ("X = " & X'Img);
10802 @end example
10804 which has the same meaning as the more verbose:
10806 @example
10807 Put_Line ("X = " & T'Image (X));
10808 @end example
10810 where @code{T} is the (sub)type of the object @code{X}.
10812 Note that technically, in analogy to @code{Image},
10813 @code{X'Img} returns a parameterless function
10814 that returns the appropriate string when called. This means that
10815 @code{X'Img} can be renamed as a function-returning-string, or used
10816 in an instantiation as a function parameter.
10818 @node Attribute Initialized,Attribute Integer_Value,Attribute Img,Implementation Defined Attributes
10819 @anchor{gnat_rm/implementation_defined_attributes attribute-initialized}@anchor{18d}
10820 @section Attribute Initialized
10823 @geindex Initialized
10825 For the syntax and semantics of this attribute, see the SPARK 2014 Reference
10826 Manual, section 6.10.
10828 @node Attribute Integer_Value,Attribute Invalid_Value,Attribute Initialized,Implementation Defined Attributes
10829 @anchor{gnat_rm/implementation_defined_attributes attribute-integer-value}@anchor{18e}
10830 @section Attribute Integer_Value
10833 @geindex Integer_Value
10835 For every integer type @code{S}, @code{S'Integer_Value} denotes a
10836 function with the following spec:
10838 @example
10839 function S'Integer_Value (Arg : <Universal_Fixed>) return S;
10840 @end example
10842 The value returned is the integer value @code{V}, such that:
10844 @example
10845 Arg = V * T'Small
10846 @end example
10848 where @code{T} is the type of @code{Arg}.
10849 The effect is thus similar to first doing an unchecked conversion from
10850 the fixed-point type to its corresponding implementation type, and then
10851 converting the result to the target integer type.  The difference is
10852 that there are full range checks, to ensure that the result is in range.
10853 This attribute is primarily intended for use in implementation of the
10854 standard input-output functions for fixed-point values.
10856 @node Attribute Invalid_Value,Attribute Iterable,Attribute Integer_Value,Implementation Defined Attributes
10857 @anchor{gnat_rm/implementation_defined_attributes attribute-invalid-value}@anchor{18f}
10858 @section Attribute Invalid_Value
10861 @geindex Invalid_Value
10863 For every scalar type S, S’Invalid_Value returns an undefined value of the
10864 type. If possible this value is an invalid representation for the type. The
10865 value returned is identical to the value used to initialize an otherwise
10866 uninitialized value of the type if pragma Initialize_Scalars is used,
10867 including the ability to modify the value with the binder -Sxx flag and
10868 relevant environment variables at run time.
10870 @node Attribute Iterable,Attribute Large,Attribute Invalid_Value,Implementation Defined Attributes
10871 @anchor{gnat_rm/implementation_defined_attributes attribute-iterable}@anchor{190}
10872 @section Attribute Iterable
10875 @geindex Iterable
10877 Equivalent to Aspect Iterable.
10879 @node Attribute Large,Attribute Library_Level,Attribute Iterable,Implementation Defined Attributes
10880 @anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{191}
10881 @section Attribute Large
10884 @geindex Ada 83 attributes
10886 @geindex Large
10888 The @code{Large} attribute is provided for compatibility with Ada 83.  See
10889 the Ada 83 reference manual for an exact description of the semantics of
10890 this attribute.
10892 @node Attribute Library_Level,Attribute Loop_Entry,Attribute Large,Implementation Defined Attributes
10893 @anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{192}
10894 @section Attribute Library_Level
10897 @geindex Library_Level
10899 @code{P'Library_Level}, where P is an entity name,
10900 returns a Boolean value which is True if the entity is declared
10901 at the library level, and False otherwise. Note that within a
10902 generic instantiation, the name of the generic unit denotes the
10903 instance, which means that this attribute can be used to test
10904 if a generic is instantiated at the library level, as shown
10905 in this example:
10907 @example
10908 generic
10909   ...
10910 package Gen is
10911   pragma Compile_Time_Error
10912     (not Gen'Library_Level,
10913      "Gen can only be instantiated at library level");
10914   ...
10915 end Gen;
10916 @end example
10918 @node Attribute Loop_Entry,Attribute Machine_Size,Attribute Library_Level,Implementation Defined Attributes
10919 @anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{193}
10920 @section Attribute Loop_Entry
10923 @geindex Loop_Entry
10925 Syntax:
10927 @example
10928 X'Loop_Entry [(loop_name)]
10929 @end example
10931 The @code{Loop_Entry} attribute is used to refer to the value that an
10932 expression had upon entry to a given loop in much the same way that the
10933 @code{Old} attribute in a subprogram postcondition can be used to refer
10934 to the value an expression had upon entry to the subprogram. The
10935 relevant loop is either identified by the given loop name, or it is the
10936 innermost enclosing loop when no loop name is given.
10938 A @code{Loop_Entry} attribute can only occur within an @code{Assert},
10939 @code{Assert_And_Cut}, @code{Assume}, @code{Loop_Variant} or @code{Loop_Invariant} pragma.
10940 In addition, such a pragma must be one of the items in the sequence
10941 of statements of a loop body, or nested inside block statements that
10942 appear in the sequence of statements of a loop body.
10943 A common use of @code{Loop_Entry} is to compare the current value of objects with
10944 their initial value at loop entry, in a @code{Loop_Invariant} pragma.
10946 The effect of using @code{X'Loop_Entry} is the same as declaring
10947 a constant initialized with the initial value of @code{X} at loop
10948 entry. This copy is not performed if the loop is not entered, or if the
10949 corresponding pragmas are ignored or disabled.
10951 @node Attribute Machine_Size,Attribute Mantissa,Attribute Loop_Entry,Implementation Defined Attributes
10952 @anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{194}
10953 @section Attribute Machine_Size
10956 @geindex Machine_Size
10958 This attribute is identical to the @code{Object_Size} attribute.  It is
10959 provided for compatibility with the DEC Ada 83 attribute of this name.
10961 @node Attribute Mantissa,Attribute Maximum_Alignment,Attribute Machine_Size,Implementation Defined Attributes
10962 @anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{195}
10963 @section Attribute Mantissa
10966 @geindex Ada 83 attributes
10968 @geindex Mantissa
10970 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
10971 the Ada 83 reference manual for an exact description of the semantics of
10972 this attribute.
10974 @node Attribute Maximum_Alignment,Attribute Max_Integer_Size,Attribute Mantissa,Implementation Defined Attributes
10975 @anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{196}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{197}
10976 @section Attribute Maximum_Alignment
10979 @geindex Alignment
10980 @geindex maximum
10982 @geindex Maximum_Alignment
10984 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
10985 allowed prefix) provides the maximum useful alignment value for the
10986 target.  This is a static value that can be used to specify the alignment
10987 for an object, guaranteeing that it is properly aligned in all
10988 cases.
10990 @node Attribute Max_Integer_Size,Attribute Mechanism_Code,Attribute Maximum_Alignment,Implementation Defined Attributes
10991 @anchor{gnat_rm/implementation_defined_attributes attribute-max-integer-size}@anchor{198}
10992 @section Attribute Max_Integer_Size
10995 @geindex Max_Integer_Size
10997 @code{Standard'Max_Integer_Size} (@code{Standard} is the only allowed
10998 prefix) provides the size of the largest supported integer type for
10999 the target. The result is a static constant.
11001 @node Attribute Mechanism_Code,Attribute Null_Parameter,Attribute Max_Integer_Size,Implementation Defined Attributes
11002 @anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{199}
11003 @section Attribute Mechanism_Code
11006 @geindex Return values
11007 @geindex passing mechanism
11009 @geindex Parameters
11010 @geindex passing mechanism
11012 @geindex Mechanism_Code
11014 @code{func'Mechanism_Code} yields an integer code for the
11015 mechanism used for the result of function @code{func}, and
11016 @code{subprog'Mechanism_Code (n)} yields the mechanism
11017 used for formal parameter number `n' (a static integer value, with 1
11018 meaning the first parameter) of subprogram @code{subprog}.  The code returned is:
11021 @table @asis
11023 @item `1'
11025 by copy (value)
11027 @item `2'
11029 by reference
11030 @end table
11032 @node Attribute Null_Parameter,Attribute Object_Size,Attribute Mechanism_Code,Implementation Defined Attributes
11033 @anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{19a}
11034 @section Attribute Null_Parameter
11037 @geindex Zero address
11038 @geindex passing
11040 @geindex Null_Parameter
11042 A reference @code{T'Null_Parameter} denotes an imaginary object of
11043 type or subtype @code{T} allocated at machine address zero.  The attribute
11044 is allowed only as the default expression of a formal parameter, or as
11045 an actual expression of a subprogram call.  In either case, the
11046 subprogram must be imported.
11048 The identity of the object is represented by the address zero in the
11049 argument list, independent of the passing mechanism (explicit or
11050 default).
11052 This capability is needed to specify that a zero address should be
11053 passed for a record or other composite object passed by reference.
11054 There is no way of indicating this without the @code{Null_Parameter}
11055 attribute.
11057 @node Attribute Object_Size,Attribute Old,Attribute Null_Parameter,Implementation Defined Attributes
11058 @anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{149}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{19b}
11059 @section Attribute Object_Size
11062 @geindex Size
11063 @geindex used for objects
11065 @geindex Object_Size
11067 The size of an object is not necessarily the same as the size of the type
11068 of an object.  This is because by default object sizes are increased to be
11069 a multiple of the alignment of the object.  For example,
11070 @code{Natural'Size} is
11071 31, but by default objects of type @code{Natural} will have a size of 32 bits.
11072 Similarly, a record containing an integer and a character:
11074 @example
11075 type Rec is record
11076    I : Integer;
11077    C : Character;
11078 end record;
11079 @end example
11081 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
11082 alignment will be 4, because of the
11083 integer field, and so the default size of record objects for this type
11084 will be 64 (8 bytes).
11086 If the alignment of the above record is specified to be 1, then the
11087 object size will be 40 (5 bytes). This is true by default, and also
11088 an object size of 40 can be explicitly specified in this case.
11090 A consequence of this capability is that different object sizes can be
11091 given to subtypes that would otherwise be considered in Ada to be
11092 statically matching.  But it makes no sense to consider such subtypes
11093 as statically matching.  Consequently, GNAT adds a rule
11094 to the static matching rules that requires object sizes to match.
11095 Consider this example:
11097 @example
11098  1. procedure BadAVConvert is
11099  2.    type R is new Integer;
11100  3.    subtype R1 is R range 1 .. 10;
11101  4.    subtype R2 is R range 1 .. 10;
11102  5.    for R1'Object_Size use 8;
11103  6.    for R2'Object_Size use 16;
11104  7.    type R1P is access all R1;
11105  8.    type R2P is access all R2;
11106  9.    R1PV : R1P := new R1'(4);
11107 10.    R2PV : R2P;
11108 11. begin
11109 12.    R2PV := R2P (R1PV);
11110                |
11111        >>> target designated subtype not compatible with
11112            type "R1" defined at line 3
11114 13. end;
11115 @end example
11117 In the absence of lines 5 and 6,
11118 types @code{R1} and @code{R2} statically match and
11119 hence the conversion on line 12 is legal. But since lines 5 and 6
11120 cause the object sizes to differ, GNAT considers that types
11121 @code{R1} and @code{R2} are not statically matching, and line 12
11122 generates the diagnostic shown above.
11124 Similar additional checks are performed in other contexts requiring
11125 statically matching subtypes.
11127 @node Attribute Old,Attribute Passed_By_Reference,Attribute Object_Size,Implementation Defined Attributes
11128 @anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{19c}
11129 @section Attribute Old
11132 @geindex Old
11134 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
11135 within @code{Post} aspect), GNAT also permits the use of this attribute
11136 in implementation defined pragmas @code{Postcondition},
11137 @code{Contract_Cases} and @code{Test_Case}. Also usages of
11138 @code{Old} which would be illegal according to the Ada 2012 RM
11139 definition are allowed under control of
11140 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
11142 @node Attribute Passed_By_Reference,Attribute Pool_Address,Attribute Old,Implementation Defined Attributes
11143 @anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{19d}
11144 @section Attribute Passed_By_Reference
11147 @geindex Parameters
11148 @geindex when passed by reference
11150 @geindex Passed_By_Reference
11152 @code{typ'Passed_By_Reference} for any subtype @cite{typ} returns
11153 a value of type @code{Boolean} value that is @code{True} if the type is
11154 normally passed by reference and @code{False} if the type is normally
11155 passed by copy in calls.  For scalar types, the result is always @code{False}
11156 and is static.  For non-scalar types, the result is nonstatic.
11158 @node Attribute Pool_Address,Attribute Range_Length,Attribute Passed_By_Reference,Implementation Defined Attributes
11159 @anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{19e}
11160 @section Attribute Pool_Address
11163 @geindex Pool_Address
11165 @code{X'Pool_Address} for any object @code{X} returns the address
11166 of X within its storage pool. This is the same as
11167 @code{X'Address}, except that for an unconstrained array whose
11168 bounds are allocated just before the first component,
11169 @code{X'Pool_Address} returns the address of those bounds,
11170 whereas @code{X'Address} returns the address of the first
11171 component.
11173 Here, we are interpreting ‘storage pool’ broadly to mean
11174 @code{wherever the object is allocated}, which could be a
11175 user-defined storage pool,
11176 the global heap, on the stack, or in a static memory area.
11177 For an object created by @code{new}, @code{Ptr.all'Pool_Address} is
11178 what is passed to @code{Allocate} and returned from @code{Deallocate}.
11180 @node Attribute Range_Length,Attribute Restriction_Set,Attribute Pool_Address,Implementation Defined Attributes
11181 @anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{19f}
11182 @section Attribute Range_Length
11185 @geindex Range_Length
11187 @code{typ'Range_Length} for any discrete type @cite{typ} yields
11188 the number of values represented by the subtype (zero for a null
11189 range).  The result is static for static subtypes.  @code{Range_Length}
11190 applied to the index subtype of a one dimensional array always gives the
11191 same result as @code{Length} applied to the array itself.
11193 @node Attribute Restriction_Set,Attribute Result,Attribute Range_Length,Implementation Defined Attributes
11194 @anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{1a0}
11195 @section Attribute Restriction_Set
11198 @geindex Restriction_Set
11200 @geindex Restrictions
11202 This attribute allows compile time testing of restrictions that
11203 are currently in effect. It is primarily intended for specializing
11204 code in the run-time based on restrictions that are active (e.g.
11205 don’t need to save fpt registers if restriction No_Floating_Point
11206 is known to be in effect), but can be used anywhere.
11208 There are two forms:
11210 @example
11211 System'Restriction_Set (partition_boolean_restriction_NAME)
11212 System'Restriction_Set (No_Dependence => library_unit_NAME);
11213 @end example
11215 In the case of the first form, the only restriction names
11216 allowed are parameterless restrictions that are checked
11217 for consistency at bind time. For a complete list see the
11218 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
11220 The result returned is True if the restriction is known to
11221 be in effect, and False if the restriction is known not to
11222 be in effect. An important guarantee is that the value of
11223 a Restriction_Set attribute is known to be consistent throughout
11224 all the code of a partition.
11226 This is trivially achieved if the entire partition is compiled
11227 with a consistent set of restriction pragmas. However, the
11228 compilation model does not require this. It is possible to
11229 compile one set of units with one set of pragmas, and another
11230 set of units with another set of pragmas. It is even possible
11231 to compile a spec with one set of pragmas, and then WITH the
11232 same spec with a different set of pragmas. Inconsistencies
11233 in the actual use of the restriction are checked at bind time.
11235 In order to achieve the guarantee of consistency for the
11236 Restriction_Set pragma, we consider that a use of the pragma
11237 that yields False is equivalent to a violation of the
11238 restriction.
11240 So for example if you write
11242 @example
11243 if System'Restriction_Set (No_Floating_Point) then
11244    ...
11245 else
11246    ...
11247 end if;
11248 @end example
11250 And the result is False, so that the else branch is executed,
11251 you can assume that this restriction is not set for any unit
11252 in the partition. This is checked by considering this use of
11253 the restriction pragma to be a violation of the restriction
11254 No_Floating_Point. This means that no other unit can attempt
11255 to set this restriction (if some unit does attempt to set it,
11256 the binder will refuse to bind the partition).
11258 Technical note: The restriction name and the unit name are
11259 intepreted entirely syntactically, as in the corresponding
11260 Restrictions pragma, they are not analyzed semantically,
11261 so they do not have a type.
11263 @node Attribute Result,Attribute Safe_Emax,Attribute Restriction_Set,Implementation Defined Attributes
11264 @anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{1a1}
11265 @section Attribute Result
11268 @geindex Result
11270 @code{function'Result} can only be used with in a Postcondition pragma
11271 for a function. The prefix must be the name of the corresponding function. This
11272 is used to refer to the result of the function in the postcondition expression.
11273 For a further discussion of the use of this attribute and examples of its use,
11274 see the description of pragma Postcondition.
11276 @node Attribute Safe_Emax,Attribute Safe_Large,Attribute Result,Implementation Defined Attributes
11277 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{1a2}
11278 @section Attribute Safe_Emax
11281 @geindex Ada 83 attributes
11283 @geindex Safe_Emax
11285 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
11286 the Ada 83 reference manual for an exact description of the semantics of
11287 this attribute.
11289 @node Attribute Safe_Large,Attribute Safe_Small,Attribute Safe_Emax,Implementation Defined Attributes
11290 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{1a3}
11291 @section Attribute Safe_Large
11294 @geindex Ada 83 attributes
11296 @geindex Safe_Large
11298 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
11299 the Ada 83 reference manual for an exact description of the semantics of
11300 this attribute.
11302 @node Attribute Safe_Small,Attribute Scalar_Storage_Order,Attribute Safe_Large,Implementation Defined Attributes
11303 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{1a4}
11304 @section Attribute Safe_Small
11307 @geindex Ada 83 attributes
11309 @geindex Safe_Small
11311 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
11312 the Ada 83 reference manual for an exact description of the semantics of
11313 this attribute.
11315 @node Attribute Scalar_Storage_Order,Attribute Simple_Storage_Pool,Attribute Safe_Small,Implementation Defined Attributes
11316 @anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{157}@anchor{gnat_rm/implementation_defined_attributes id4}@anchor{1a5}
11317 @section Attribute Scalar_Storage_Order
11320 @geindex Endianness
11322 @geindex Scalar storage order
11324 @geindex Scalar_Storage_Order
11326 For every array or record type @code{S}, the representation attribute
11327 @code{Scalar_Storage_Order} denotes the order in which storage elements
11328 that make up scalar components are ordered within S. The value given must
11329 be a static expression of type System.Bit_Order. The following is an example
11330 of the use of this feature:
11332 @example
11333 --  Component type definitions
11335 subtype Yr_Type is Natural range 0 .. 127;
11336 subtype Mo_Type is Natural range 1 .. 12;
11337 subtype Da_Type is Natural range 1 .. 31;
11339 --  Record declaration
11341 type Date is record
11342    Years_Since_1980 : Yr_Type;
11343    Month            : Mo_Type;
11344    Day_Of_Month     : Da_Type;
11345 end record;
11347 --  Record representation clause
11349 for Date use record
11350    Years_Since_1980 at 0 range 0  ..  6;
11351    Month            at 0 range 7  .. 10;
11352    Day_Of_Month     at 0 range 11 .. 15;
11353 end record;
11355 --  Attribute definition clauses
11357 for Date'Bit_Order use System.High_Order_First;
11358 for Date'Scalar_Storage_Order use System.High_Order_First;
11359 --  If Scalar_Storage_Order is specified, it must be consistent with
11360 --  Bit_Order, so it's best to always define the latter explicitly if
11361 --  the former is used.
11362 @end example
11364 Other properties are as for the standard representation attribute @code{Bit_Order}
11365 defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
11367 For a record type @code{T}, if @code{T'Scalar_Storage_Order} is
11368 specified explicitly, it shall be equal to @code{T'Bit_Order}. Note:
11369 this means that if a @code{Scalar_Storage_Order} attribute definition
11370 clause is not confirming, then the type’s @code{Bit_Order} shall be
11371 specified explicitly and set to the same value.
11373 Derived types inherit an explicitly set scalar storage order from their parent
11374 types. This may be overridden for the derived type by giving an explicit scalar
11375 storage order for it. However, for a record extension, the derived type must
11376 have the same scalar storage order as the parent type.
11378 A component of a record type that is itself a record or an array and that does
11379 not start and end on a byte boundary must have have the same scalar storage
11380 order as the record type. A component of a bit-packed array type that is itself
11381 a record or an array must have the same scalar storage order as the array type.
11383 No component of a type that has an explicit @code{Scalar_Storage_Order}
11384 attribute definition may be aliased.
11386 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
11387 with a value equal to @code{System.Default_Bit_Order}) has no effect.
11389 If the opposite storage order is specified, then whenever the value of
11390 a scalar component of an object of type @code{S} is read, the storage
11391 elements of the enclosing machine scalar are first reversed (before
11392 retrieving the component value, possibly applying some shift and mask
11393 operatings on the enclosing machine scalar), and the opposite operation
11394 is done for writes.
11396 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
11397 are relaxed. Instead, the following rules apply:
11400 @itemize *
11402 @item 
11403 the underlying storage elements are those at positions
11404 @code{(position + first_bit / storage_element_size) .. (position + (last_bit + storage_element_size - 1) / storage_element_size)}
11406 @item 
11407 the sequence of underlying storage elements shall have
11408 a size no greater than the largest machine scalar
11410 @item 
11411 the enclosing machine scalar is defined as the smallest machine
11412 scalar starting at a position no greater than
11413 @code{position + first_bit / storage_element_size} and covering
11414 storage elements at least up to @code{position + (last_bit + storage_element_size - 1) / storage_element_size}
11416 @item 
11417 the position of the component is interpreted relative to that machine
11418 scalar.
11419 @end itemize
11421 If no scalar storage order is specified for a type (either directly, or by
11422 inheritance in the case of a derived type), then the default is normally
11423 the native ordering of the target, but this default can be overridden using
11424 pragma @code{Default_Scalar_Storage_Order}.
11426 If a component of @code{T} is itself of a record or array type, the specfied
11427 @code{Scalar_Storage_Order} does `not' apply to that nested type: an explicit
11428 attribute definition clause must be provided for the component type as well
11429 if desired.
11431 Representation changes that explicitly or implicitly toggle the scalar storage
11432 order are not supported and may result in erroneous execution of the program,
11433 except when performed by means of an instance of @code{Ada.Unchecked_Conversion}.
11435 In particular, overlays are not supported and a warning is given for them:
11437 @example
11438 type Rec_LE is record
11439    I : Integer;
11440 end record;
11442 for Rec_LE use record
11443    I at 0 range 0 .. 31;
11444 end record;
11446 for Rec_LE'Bit_Order use System.Low_Order_First;
11447 for Rec_LE'Scalar_Storage_Order use System.Low_Order_First;
11449 type Rec_BE is record
11450    I : Integer;
11451 end record;
11453 for Rec_BE use record
11454    I at 0 range 0 .. 31;
11455 end record;
11457 for Rec_BE'Bit_Order use System.High_Order_First;
11458 for Rec_BE'Scalar_Storage_Order use System.High_Order_First;
11460 R_LE : Rec_LE;
11462 R_BE : Rec_BE;
11463 for R_BE'Address use R_LE'Address;
11464 @end example
11466 @code{warning: overlay changes scalar storage order [enabled by default]}
11468 In most cases, such representation changes ought to be replaced by an
11469 instantiation of a function or procedure provided by @code{GNAT.Byte_Swapping}.
11471 Note that the scalar storage order only affects the in-memory data
11472 representation. It has no effect on the representation used by stream
11473 attributes.
11475 Note that debuggers may be unable to display the correct value of scalar
11476 components of a type for which the opposite storage order is specified.
11478 @node Attribute Simple_Storage_Pool,Attribute Small,Attribute Scalar_Storage_Order,Implementation Defined Attributes
11479 @anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{e9}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{1a6}
11480 @section Attribute Simple_Storage_Pool
11483 @geindex Storage pool
11484 @geindex simple
11486 @geindex Simple storage pool
11488 @geindex Simple_Storage_Pool
11490 For every nonformal, nonderived access-to-object type @code{Acc}, the
11491 representation attribute @code{Simple_Storage_Pool} may be specified
11492 via an attribute_definition_clause (or by specifying the equivalent aspect):
11494 @example
11495 My_Pool : My_Simple_Storage_Pool_Type;
11497 type Acc is access My_Data_Type;
11499 for Acc'Simple_Storage_Pool use My_Pool;
11500 @end example
11502 The name given in an attribute_definition_clause for the
11503 @code{Simple_Storage_Pool} attribute shall denote a variable of
11504 a ‘simple storage pool type’ (see pragma @cite{Simple_Storage_Pool_Type}).
11506 The use of this attribute is only allowed for a prefix denoting a type
11507 for which it has been specified. The type of the attribute is the type
11508 of the variable specified as the simple storage pool of the access type,
11509 and the attribute denotes that variable.
11511 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
11512 for the same access type.
11514 If the @code{Simple_Storage_Pool} attribute has been specified for an access
11515 type, then applying the @code{Storage_Pool} attribute to the type is flagged
11516 with a warning and its evaluation raises the exception @code{Program_Error}.
11518 If the Simple_Storage_Pool attribute has been specified for an access
11519 type @code{S}, then the evaluation of the attribute @code{S'Storage_Size}
11520 returns the result of calling @code{Storage_Size (S'Simple_Storage_Pool)},
11521 which is intended to indicate the number of storage elements reserved for
11522 the simple storage pool. If the Storage_Size function has not been defined
11523 for the simple storage pool type, then this attribute returns zero.
11525 If an access type @code{S} has a specified simple storage pool of type
11526 @code{SSP}, then the evaluation of an allocator for that access type calls
11527 the primitive @code{Allocate} procedure for type @code{SSP}, passing
11528 @code{S'Simple_Storage_Pool} as the pool parameter. The detailed
11529 semantics of such allocators is the same as those defined for allocators
11530 in section 13.11 of the @cite{Ada Reference Manual}, with the term
11531 `simple storage pool' substituted for `storage pool'.
11533 If an access type @code{S} has a specified simple storage pool of type
11534 @code{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
11535 for that access type invokes the primitive @code{Deallocate} procedure
11536 for type @code{SSP}, passing @code{S'Simple_Storage_Pool} as the pool
11537 parameter. The detailed semantics of such unchecked deallocations is the same
11538 as defined in section 13.11.2 of the Ada Reference Manual, except that the
11539 term `simple storage pool' is substituted for `storage pool'.
11541 @node Attribute Small,Attribute Small_Denominator,Attribute Simple_Storage_Pool,Implementation Defined Attributes
11542 @anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1a7}
11543 @section Attribute Small
11546 @geindex Ada 83 attributes
11548 @geindex Small
11550 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
11551 fixed-point types.
11552 GNAT also allows this attribute to be applied to floating-point types
11553 for compatibility with Ada 83.  See
11554 the Ada 83 reference manual for an exact description of the semantics of
11555 this attribute when applied to floating-point types.
11557 @node Attribute Small_Denominator,Attribute Small_Numerator,Attribute Small,Implementation Defined Attributes
11558 @anchor{gnat_rm/implementation_defined_attributes attribute-small-denominator}@anchor{1a8}
11559 @section Attribute Small_Denominator
11562 @geindex Small
11564 @geindex Small_Denominator
11566 @code{typ'Small_Denominator} for any fixed-point subtype @cite{typ} yields the
11567 denominator in the representation of @code{typ'Small} as a rational number
11568 with coprime factors (i.e. as an irreducible fraction).
11570 @node Attribute Small_Numerator,Attribute Storage_Unit,Attribute Small_Denominator,Implementation Defined Attributes
11571 @anchor{gnat_rm/implementation_defined_attributes attribute-small-numerator}@anchor{1a9}
11572 @section Attribute Small_Numerator
11575 @geindex Small
11577 @geindex Small_Numerator
11579 @code{typ'Small_Numerator} for any fixed-point subtype @cite{typ} yields the
11580 numerator in the representation of @code{typ'Small} as a rational number
11581 with coprime factors (i.e. as an irreducible fraction).
11583 @node Attribute Storage_Unit,Attribute Stub_Type,Attribute Small_Numerator,Implementation Defined Attributes
11584 @anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1aa}
11585 @section Attribute Storage_Unit
11588 @geindex Storage_Unit
11590 @code{Standard'Storage_Unit} (@code{Standard} is the only allowed
11591 prefix) provides the same value as @code{System.Storage_Unit}.
11593 @node Attribute Stub_Type,Attribute System_Allocator_Alignment,Attribute Storage_Unit,Implementation Defined Attributes
11594 @anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1ab}
11595 @section Attribute Stub_Type
11598 @geindex Stub_Type
11600 The GNAT implementation of remote access-to-classwide types is
11601 organized as described in AARM section E.4 (20.t): a value of an RACW type
11602 (designating a remote object) is represented as a normal access
11603 value, pointing to a “stub” object which in turn contains the
11604 necessary information to contact the designated remote object. A
11605 call on any dispatching operation of such a stub object does the
11606 remote call, if necessary, using the information in the stub object
11607 to locate the target partition, etc.
11609 For a prefix @code{T} that denotes a remote access-to-classwide type,
11610 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
11612 By construction, the layout of @code{T'Stub_Type} is identical to that of
11613 type @code{RACW_Stub_Type} declared in the internal implementation-defined
11614 unit @code{System.Partition_Interface}. Use of this attribute will create
11615 an implicit dependency on this unit.
11617 @node Attribute System_Allocator_Alignment,Attribute Target_Name,Attribute Stub_Type,Implementation Defined Attributes
11618 @anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1ac}
11619 @section Attribute System_Allocator_Alignment
11622 @geindex Alignment
11623 @geindex allocator
11625 @geindex System_Allocator_Alignment
11627 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
11628 allowed prefix) provides the observable guaranteed to be honored by
11629 the system allocator (malloc). This is a static value that can be used
11630 in user storage pools based on malloc either to reject allocation
11631 with alignment too large or to enable a realignment circuitry if the
11632 alignment request is larger than this value.
11634 @node Attribute Target_Name,Attribute To_Address,Attribute System_Allocator_Alignment,Implementation Defined Attributes
11635 @anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1ad}
11636 @section Attribute Target_Name
11639 @geindex Target_Name
11641 @code{Standard'Target_Name} (@code{Standard} is the only allowed
11642 prefix) provides a static string value that identifies the target
11643 for the current compilation. For GCC implementations, this is the
11644 standard gcc target name without the terminating slash (for
11645 example, GNAT 5.0 on windows yields “i586-pc-mingw32msv”).
11647 @node Attribute To_Address,Attribute To_Any,Attribute Target_Name,Implementation Defined Attributes
11648 @anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1ae}
11649 @section Attribute To_Address
11652 @geindex To_Address
11654 The @code{System'To_Address}
11655 (@code{System} is the only allowed prefix)
11656 denotes a function identical to
11657 @code{System.Storage_Elements.To_Address} except that
11658 it is a static attribute.  This means that if its argument is
11659 a static expression, then the result of the attribute is a
11660 static expression.  This means that such an expression can be
11661 used in contexts (e.g., preelaborable packages) which require a
11662 static expression and where the function call could not be used
11663 (since the function call is always nonstatic, even if its
11664 argument is static). The argument must be in the range
11665 -(2**(m-1)) .. 2**m-1, where m is the memory size
11666 (typically 32 or 64). Negative values are intepreted in a
11667 modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on
11668 a 32 bits machine).
11670 @node Attribute To_Any,Attribute Type_Class,Attribute To_Address,Implementation Defined Attributes
11671 @anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1af}
11672 @section Attribute To_Any
11675 @geindex To_Any
11677 This internal attribute is used for the generation of remote subprogram
11678 stubs in the context of the Distributed Systems Annex.
11680 @node Attribute Type_Class,Attribute Type_Key,Attribute To_Any,Implementation Defined Attributes
11681 @anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1b0}
11682 @section Attribute Type_Class
11685 @geindex Type_Class
11687 @code{typ'Type_Class} for any type or subtype @cite{typ} yields
11688 the value of the type class for the full type of @cite{typ}.  If
11689 @cite{typ} is a generic formal type, the value is the value for the
11690 corresponding actual subtype.  The value of this attribute is of type
11691 @code{System.Aux_DEC.Type_Class}, which has the following definition:
11693 @example
11694 type Type_Class is
11695   (Type_Class_Enumeration,
11696    Type_Class_Integer,
11697    Type_Class_Fixed_Point,
11698    Type_Class_Floating_Point,
11699    Type_Class_Array,
11700    Type_Class_Record,
11701    Type_Class_Access,
11702    Type_Class_Task,
11703    Type_Class_Address);
11704 @end example
11706 Protected types yield the value @code{Type_Class_Task}, which thus
11707 applies to all concurrent types.  This attribute is designed to
11708 be compatible with the DEC Ada 83 attribute of the same name.
11710 @node Attribute Type_Key,Attribute TypeCode,Attribute Type_Class,Implementation Defined Attributes
11711 @anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1b1}
11712 @section Attribute Type_Key
11715 @geindex Type_Key
11717 The @code{Type_Key} attribute is applicable to a type or subtype and
11718 yields a value of type Standard.String containing encoded information
11719 about the type or subtype. This provides improved compatibility with
11720 other implementations that support this attribute.
11722 @node Attribute TypeCode,Attribute Unconstrained_Array,Attribute Type_Key,Implementation Defined Attributes
11723 @anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1b2}
11724 @section Attribute TypeCode
11727 @geindex TypeCode
11729 This internal attribute is used for the generation of remote subprogram
11730 stubs in the context of the Distributed Systems Annex.
11732 @node Attribute Unconstrained_Array,Attribute Universal_Literal_String,Attribute TypeCode,Implementation Defined Attributes
11733 @anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1b3}
11734 @section Attribute Unconstrained_Array
11737 @geindex Unconstrained_Array
11739 The @code{Unconstrained_Array} attribute can be used with a prefix that
11740 denotes any type or subtype. It is a static attribute that yields
11741 @code{True} if the prefix designates an unconstrained array,
11742 and @code{False} otherwise. In a generic instance, the result is
11743 still static, and yields the result of applying this test to the
11744 generic actual.
11746 @node Attribute Universal_Literal_String,Attribute Unrestricted_Access,Attribute Unconstrained_Array,Implementation Defined Attributes
11747 @anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1b4}
11748 @section Attribute Universal_Literal_String
11751 @geindex Named numbers
11752 @geindex representation of
11754 @geindex Universal_Literal_String
11756 The prefix of @code{Universal_Literal_String} must be a named
11757 number.  The static result is the string consisting of the characters of
11758 the number as defined in the original source.  This allows the user
11759 program to access the actual text of named numbers without intermediate
11760 conversions and without the need to enclose the strings in quotes (which
11761 would preclude their use as numbers).
11763 For example, the following program prints the first 50 digits of pi:
11765 @example
11766 with Text_IO; use Text_IO;
11767 with Ada.Numerics;
11768 procedure Pi is
11769 begin
11770    Put (Ada.Numerics.Pi'Universal_Literal_String);
11771 end;
11772 @end example
11774 @node Attribute Unrestricted_Access,Attribute Update,Attribute Universal_Literal_String,Implementation Defined Attributes
11775 @anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1b5}
11776 @section Attribute Unrestricted_Access
11779 @geindex Access
11780 @geindex unrestricted
11782 @geindex Unrestricted_Access
11784 The @code{Unrestricted_Access} attribute is similar to @code{Access}
11785 except that all accessibility and aliased view checks are omitted.  This
11786 is a user-beware attribute.
11788 For objects, it is similar to @code{Address}, for which it is a
11789 desirable replacement where the value desired is an access type.
11790 In other words, its effect is similar to first applying the
11791 @code{Address} attribute and then doing an unchecked conversion to a
11792 desired access type.
11794 For subprograms, @code{P'Unrestricted_Access} may be used where
11795 @code{P'Access} would be illegal, to construct a value of a
11796 less-nested named access type that designates a more-nested
11797 subprogram. This value may be used in indirect calls, so long as the
11798 more-nested subprogram still exists; once the subprogram containing it
11799 has returned, such calls are erroneous. For example:
11801 @example
11802 package body P is
11804    type Less_Nested is not null access procedure;
11805    Global : Less_Nested;
11807    procedure P1 is
11808    begin
11809       Global.all;
11810    end P1;
11812    procedure P2 is
11813       Local_Var : Integer;
11815       procedure More_Nested is
11816       begin
11817          ... Local_Var ...
11818       end More_Nested;
11819    begin
11820       Global := More_Nested'Unrestricted_Access;
11821       P1;
11822    end P2;
11824 end P;
11825 @end example
11827 When P1 is called from P2, the call via Global is OK, but if P1 were
11828 called after P2 returns, it would be an erroneous use of a dangling
11829 pointer.
11831 For objects, it is possible to use @code{Unrestricted_Access} for any
11832 type. However, if the result is of an access-to-unconstrained array
11833 subtype, then the resulting pointer has the same scope as the context
11834 of the attribute, and must not be returned to some enclosing scope.
11835 For instance, if a function uses @code{Unrestricted_Access} to create
11836 an access-to-unconstrained-array and returns that value to the caller,
11837 the result will involve dangling pointers. In addition, it is only
11838 valid to create pointers to unconstrained arrays using this attribute
11839 if the pointer has the normal default ‘fat’ representation where a
11840 pointer has two components, one points to the array and one points to
11841 the bounds. If a size clause is used to force ‘thin’ representation
11842 for a pointer to unconstrained where there is only space for a single
11843 pointer, then the resulting pointer is not usable.
11845 In the simple case where a direct use of Unrestricted_Access attempts
11846 to make a thin pointer for a non-aliased object, the compiler will
11847 reject the use as illegal, as shown in the following example:
11849 @example
11850 with System; use System;
11851 procedure SliceUA2 is
11852    type A is access all String;
11853    for A'Size use Standard'Address_Size;
11855    procedure P (Arg : A) is
11856    begin
11857       null;
11858    end P;
11860    X : String := "hello world!";
11861    X2 : aliased String := "hello world!";
11863    AV : A := X'Unrestricted_Access;    -- ERROR
11864              |
11865 >>> illegal use of Unrestricted_Access attribute
11866 >>> attempt to generate thin pointer to unaliased object
11868 begin
11869    P (X'Unrestricted_Access);          -- ERROR
11870       |
11871 >>> illegal use of Unrestricted_Access attribute
11872 >>> attempt to generate thin pointer to unaliased object
11874    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
11875       |
11876 >>> illegal use of Unrestricted_Access attribute
11877 >>> attempt to generate thin pointer to unaliased object
11879    P (X2'Unrestricted_Access);         -- OK
11880 end;
11881 @end example
11883 but other cases cannot be detected by the compiler, and are
11884 considered to be erroneous. Consider the following example:
11886 @example
11887 with System; use System;
11888 with System; use System;
11889 procedure SliceUA is
11890    type AF is access all String;
11892    type A is access all String;
11893    for A'Size use Standard'Address_Size;
11895    procedure P (Arg : A) is
11896    begin
11897       if Arg'Length /= 6 then
11898          raise Program_Error;
11899       end if;
11900    end P;
11902    X : String := "hello world!";
11903    Y : AF := X (7 .. 12)'Unrestricted_Access;
11905 begin
11906    P (A (Y));
11907 end;
11908 @end example
11910 A normal unconstrained array value
11911 or a constrained array object marked as aliased has the bounds in memory
11912 just before the array, so a thin pointer can retrieve both the data and
11913 the bounds.  But in this case, the non-aliased object @code{X} does not have the
11914 bounds before the string.  If the size clause for type @code{A}
11915 were not present, then the pointer
11916 would be a fat pointer, where one component is a pointer to the bounds,
11917 and all would be well.  But with the size clause present, the conversion from
11918 fat pointer to thin pointer in the call loses the bounds, and so this
11919 is erroneous, and the program likely raises a @code{Program_Error} exception.
11921 In general, it is advisable to completely
11922 avoid mixing the use of thin pointers and the use of
11923 @code{Unrestricted_Access} where the designated type is an
11924 unconstrained array.  The use of thin pointers should be restricted to
11925 cases of porting legacy code that implicitly assumes the size of pointers,
11926 and such code should not in any case be using this attribute.
11928 Another erroneous situation arises if the attribute is
11929 applied to a constant. The resulting pointer can be used to access the
11930 constant, but the effect of trying to modify a constant in this manner
11931 is not well-defined. Consider this example:
11933 @example
11934 P : constant Integer := 4;
11935 type R is access all Integer;
11936 RV : R := P'Unrestricted_Access;
11938 RV.all := 3;
11939 @end example
11941 Here we attempt to modify the constant P from 4 to 3, but the compiler may
11942 or may not notice this attempt, and subsequent references to P may yield
11943 either the value 3 or the value 4 or the assignment may blow up if the
11944 compiler decides to put P in read-only memory. One particular case where
11945 @code{Unrestricted_Access} can be used in this way is to modify the
11946 value of an @code{in} parameter:
11948 @example
11949 procedure K (S : in String) is
11950    type R is access all Character;
11951    RV : R := S (3)'Unrestricted_Access;
11952 begin
11953    RV.all := 'a';
11954 end;
11955 @end example
11957 In general this is a risky approach. It may appear to “work” but such uses of
11958 @code{Unrestricted_Access} are potentially non-portable, even from one version
11959 of GNAT to another, so are best avoided if possible.
11961 @node Attribute Update,Attribute Valid_Value,Attribute Unrestricted_Access,Implementation Defined Attributes
11962 @anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1b6}
11963 @section Attribute Update
11966 @geindex Update
11968 The @code{Update} attribute creates a copy of an array or record value
11969 with one or more modified components. The syntax is:
11971 @example
11972 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
11973 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
11974 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
11975                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
11977 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
11978 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
11979 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
11980 @end example
11982 where @code{PREFIX} is the name of an array or record object, the
11983 association list in parentheses does not contain an @code{others}
11984 choice and the box symbol @code{<>} may not appear in any
11985 expression. The effect is to yield a copy of the array or record value
11986 which is unchanged apart from the components mentioned in the
11987 association list, which are changed to the indicated value. The
11988 original value of the array or record value is not affected. For
11989 example:
11991 @example
11992 type Arr is Array (1 .. 5) of Integer;
11994 Avar1 : Arr := (1,2,3,4,5);
11995 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
11996 @end example
11998 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
11999 begin unmodified. Similarly:
12001 @example
12002 type Rec is A, B, C : Integer;
12004 Rvar1 : Rec := (A => 1, B => 2, C => 3);
12005 Rvar2 : Rec := Rvar1'Update (B => 20);
12006 @end example
12008 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
12009 with @code{Rvar1} being unmodifed.
12010 Note that the value of the attribute reference is computed
12011 completely before it is used. This means that if you write:
12013 @example
12014 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
12015 @end example
12017 then the value of @code{Avar1} is not modified if @code{Function_Call}
12018 raises an exception, unlike the effect of a series of direct assignments
12019 to elements of @code{Avar1}. In general this requires that
12020 two extra complete copies of the object are required, which should be
12021 kept in mind when considering efficiency.
12023 The @code{Update} attribute cannot be applied to prefixes of a limited
12024 type, and cannot reference discriminants in the case of a record type.
12025 The accessibility level of an Update attribute result object is defined
12026 as for an aggregate.
12028 In the record case, no component can be mentioned more than once. In
12029 the array case, two overlapping ranges can appear in the association list,
12030 in which case the modifications are processed left to right.
12032 Multi-dimensional arrays can be modified, as shown by this example:
12034 @example
12035 A : array (1 .. 10, 1 .. 10) of Integer;
12037 A := A'Update ((1, 2) => 20, (3, 4) => 30);
12038 @end example
12040 which changes element (1,2) to 20 and (3,4) to 30.
12042 @node Attribute Valid_Value,Attribute Valid_Scalars,Attribute Update,Implementation Defined Attributes
12043 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-value}@anchor{1b7}
12044 @section Attribute Valid_Value
12047 @geindex Valid_Value
12049 The @code{'Valid_Value} attribute is defined for enumeration types other than
12050 those in package Standard. This attribute is a function that takes
12051 a String, and returns Boolean. @code{T'Valid_Value (S)} returns True
12052 if and only if @code{T'Value (S)} would not raise Constraint_Error.
12054 @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Valid_Value,Implementation Defined Attributes
12055 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1b8}
12056 @section Attribute Valid_Scalars
12059 @geindex Valid_Scalars
12061 The @code{'Valid_Scalars} attribute is intended to make it easier to check the
12062 validity of scalar subcomponents of composite objects. The attribute is defined
12063 for any prefix @code{P} which denotes an object. Prefix @code{P} can be any type
12064 except for tagged private or @code{Unchecked_Union} types. The value of the
12065 attribute is of type @code{Boolean}.
12067 @code{P'Valid_Scalars} yields @code{True} if and only if the evaluation of
12068 @code{C'Valid} yields @code{True} for every scalar subcomponent @code{C} of @code{P}, or if
12069 @code{P} has no scalar subcomponents. Attribute @code{'Valid_Scalars} is equivalent
12070 to attribute @code{'Valid} for scalar types.
12072 It is not specified in what order the subcomponents are checked, nor whether
12073 any more are checked after any one of them is determined to be invalid. If the
12074 prefix @code{P} is of a class-wide type @code{T'Class} (where @code{T} is the associated
12075 specific type), or if the prefix @code{P} is of a specific tagged type @code{T}, then
12076 only the subcomponents of @code{T} are checked; in other words, components of
12077 extensions of @code{T} are not checked even if @code{T'Class (P)'Tag /= T'Tag}.
12079 The compiler will issue a warning if it can be determined at compile time that
12080 the prefix of the attribute has no scalar subcomponents.
12082 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case of
12083 a large variant record. If the attribute is called in many places in the same
12084 program applied to objects of the same type, it can reduce program size to
12085 write a function with a single use of the attribute, and then call that
12086 function from multiple places.
12088 @node Attribute VADS_Size,Attribute Value_Size,Attribute Valid_Scalars,Implementation Defined Attributes
12089 @anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1b9}
12090 @section Attribute VADS_Size
12093 @geindex Size
12094 @geindex VADS compatibility
12096 @geindex VADS_Size
12098 The @code{'VADS_Size} attribute is intended to make it easier to port
12099 legacy code which relies on the semantics of @code{'Size} as implemented
12100 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
12101 same semantic interpretation.  In particular, @code{'VADS_Size} applied
12102 to a predefined or other primitive type with no Size clause yields the
12103 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
12104 typical machines).  In addition @code{'VADS_Size} applied to an object
12105 gives the result that would be obtained by applying the attribute to
12106 the corresponding type.
12108 @node Attribute Value_Size,Attribute Wchar_T_Size,Attribute VADS_Size,Implementation Defined Attributes
12109 @anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{167}@anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1ba}
12110 @section Attribute Value_Size
12113 @geindex Size
12114 @geindex setting for not-first subtype
12116 @geindex Value_Size
12118 @code{type'Value_Size} is the number of bits required to represent
12119 a value of the given subtype.  It is the same as @code{type'Size},
12120 but, unlike @code{Size}, may be set for non-first subtypes.
12122 @node Attribute Wchar_T_Size,Attribute Word_Size,Attribute Value_Size,Implementation Defined Attributes
12123 @anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1bb}
12124 @section Attribute Wchar_T_Size
12127 @geindex Wchar_T_Size
12129 @code{Standard'Wchar_T_Size} (@code{Standard} is the only allowed
12130 prefix) provides the size in bits of the C @code{wchar_t} type
12131 primarily for constructing the definition of this type in
12132 package @code{Interfaces.C}. The result is a static constant.
12134 @node Attribute Word_Size,,Attribute Wchar_T_Size,Implementation Defined Attributes
12135 @anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1bc}
12136 @section Attribute Word_Size
12139 @geindex Word_Size
12141 @code{Standard'Word_Size} (@code{Standard} is the only allowed
12142 prefix) provides the value @code{System.Word_Size}. The result is
12143 a static constant.
12145 @node Standard and Implementation Defined Restrictions,Implementation Advice,Implementation Defined Attributes,Top
12146 @anchor{gnat_rm/standard_and_implementation_defined_restrictions doc}@anchor{1bd}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1be}@anchor{gnat_rm/standard_and_implementation_defined_restrictions standard-and-implementation-defined-restrictions}@anchor{9}
12147 @chapter Standard and Implementation Defined Restrictions
12150 All Ada Reference Manual-defined Restriction identifiers are implemented:
12153 @itemize *
12155 @item 
12156 language-defined restrictions (see 13.12.1)
12158 @item 
12159 tasking restrictions (see D.7)
12161 @item 
12162 high integrity restrictions (see H.4)
12163 @end itemize
12165 GNAT implements additional restriction identifiers. All restrictions, whether
12166 language defined or GNAT-specific, are listed in the following.
12168 @menu
12169 * Partition-Wide Restrictions:: 
12170 * Program Unit Level Restrictions:: 
12172 @end menu
12174 @node Partition-Wide Restrictions,Program Unit Level Restrictions,,Standard and Implementation Defined Restrictions
12175 @anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1bf}@anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1c0}
12176 @section Partition-Wide Restrictions
12179 There are two separate lists of restriction identifiers. The first
12180 set requires consistency throughout a partition (in other words, if the
12181 restriction identifier is used for any compilation unit in the partition,
12182 then all compilation units in the partition must obey the restriction).
12184 @menu
12185 * Immediate_Reclamation:: 
12186 * Max_Asynchronous_Select_Nesting:: 
12187 * Max_Entry_Queue_Length:: 
12188 * Max_Protected_Entries:: 
12189 * Max_Select_Alternatives:: 
12190 * Max_Storage_At_Blocking:: 
12191 * Max_Task_Entries:: 
12192 * Max_Tasks:: 
12193 * No_Abort_Statements:: 
12194 * No_Access_Parameter_Allocators:: 
12195 * No_Access_Subprograms:: 
12196 * No_Allocators:: 
12197 * No_Anonymous_Allocators:: 
12198 * No_Asynchronous_Control:: 
12199 * No_Calendar:: 
12200 * No_Coextensions:: 
12201 * No_Default_Initialization:: 
12202 * No_Delay:: 
12203 * No_Dependence:: 
12204 * No_Direct_Boolean_Operators:: 
12205 * No_Dispatch:: 
12206 * No_Dispatching_Calls:: 
12207 * No_Dynamic_Attachment:: 
12208 * No_Dynamic_Priorities:: 
12209 * No_Entry_Calls_In_Elaboration_Code:: 
12210 * No_Enumeration_Maps:: 
12211 * No_Exception_Handlers:: 
12212 * No_Exception_Propagation:: 
12213 * No_Exception_Registration:: 
12214 * No_Exceptions:: 
12215 * No_Finalization:: 
12216 * No_Fixed_Point:: 
12217 * No_Floating_Point:: 
12218 * No_Implicit_Conditionals:: 
12219 * No_Implicit_Dynamic_Code:: 
12220 * No_Implicit_Heap_Allocations:: 
12221 * No_Implicit_Protected_Object_Allocations:: 
12222 * No_Implicit_Task_Allocations:: 
12223 * No_Initialize_Scalars:: 
12224 * No_IO:: 
12225 * No_Local_Allocators:: 
12226 * No_Local_Protected_Objects:: 
12227 * No_Local_Tagged_Types:: 
12228 * No_Local_Timing_Events:: 
12229 * No_Long_Long_Integers:: 
12230 * No_Multiple_Elaboration:: 
12231 * No_Nested_Finalization:: 
12232 * No_Protected_Type_Allocators:: 
12233 * No_Protected_Types:: 
12234 * No_Recursion:: 
12235 * No_Reentrancy:: 
12236 * No_Relative_Delay:: 
12237 * No_Requeue_Statements:: 
12238 * No_Secondary_Stack:: 
12239 * No_Select_Statements:: 
12240 * No_Specific_Termination_Handlers:: 
12241 * No_Specification_of_Aspect:: 
12242 * No_Standard_Allocators_After_Elaboration:: 
12243 * No_Standard_Storage_Pools:: 
12244 * No_Stream_Optimizations:: 
12245 * No_Streams:: 
12246 * No_Tagged_Type_Registration:: 
12247 * No_Task_Allocators:: 
12248 * No_Task_At_Interrupt_Priority:: 
12249 * No_Task_Attributes_Package:: 
12250 * No_Task_Hierarchy:: 
12251 * No_Task_Termination:: 
12252 * No_Tasking:: 
12253 * No_Terminate_Alternatives:: 
12254 * No_Unchecked_Access:: 
12255 * No_Unchecked_Conversion:: 
12256 * No_Unchecked_Deallocation:: 
12257 * No_Use_Of_Attribute:: 
12258 * No_Use_Of_Entity:: 
12259 * No_Use_Of_Pragma:: 
12260 * Pure_Barriers:: 
12261 * Simple_Barriers:: 
12262 * Static_Priorities:: 
12263 * Static_Storage_Size:: 
12265 @end menu
12267 @node Immediate_Reclamation,Max_Asynchronous_Select_Nesting,,Partition-Wide Restrictions
12268 @anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1c1}
12269 @subsection Immediate_Reclamation
12272 @geindex Immediate_Reclamation
12274 [RM H.4] This restriction ensures that, except for storage occupied by
12275 objects created by allocators and not deallocated via unchecked
12276 deallocation, any storage reserved at run time for an object is
12277 immediately reclaimed when the object no longer exists.
12279 @node Max_Asynchronous_Select_Nesting,Max_Entry_Queue_Length,Immediate_Reclamation,Partition-Wide Restrictions
12280 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1c2}
12281 @subsection Max_Asynchronous_Select_Nesting
12284 @geindex Max_Asynchronous_Select_Nesting
12286 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
12287 selects. Violations of this restriction with a value of zero are
12288 detected at compile time. Violations of this restriction with values
12289 other than zero cause Storage_Error to be raised.
12291 @node Max_Entry_Queue_Length,Max_Protected_Entries,Max_Asynchronous_Select_Nesting,Partition-Wide Restrictions
12292 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1c3}
12293 @subsection Max_Entry_Queue_Length
12296 @geindex Max_Entry_Queue_Length
12298 [RM D.7] This restriction is a declaration that any protected entry compiled in
12299 the scope of the restriction has at most the specified number of
12300 tasks waiting on the entry at any one time, and so no queue is required.
12301 Note that this restriction is checked at run time. Violation of this
12302 restriction results in the raising of Program_Error exception at the point of
12303 the call.
12305 @geindex Max_Entry_Queue_Depth
12307 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
12308 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
12309 compatibility purposes (and a warning will be generated for its use if
12310 warnings on obsolescent features are activated).
12312 @node Max_Protected_Entries,Max_Select_Alternatives,Max_Entry_Queue_Length,Partition-Wide Restrictions
12313 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1c4}
12314 @subsection Max_Protected_Entries
12317 @geindex Max_Protected_Entries
12319 [RM D.7] Specifies the maximum number of entries per protected type. The
12320 bounds of every entry family of a protected unit shall be static, or shall be
12321 defined by a discriminant of a subtype whose corresponding bound is static.
12323 @node Max_Select_Alternatives,Max_Storage_At_Blocking,Max_Protected_Entries,Partition-Wide Restrictions
12324 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1c5}
12325 @subsection Max_Select_Alternatives
12328 @geindex Max_Select_Alternatives
12330 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
12332 @node Max_Storage_At_Blocking,Max_Task_Entries,Max_Select_Alternatives,Partition-Wide Restrictions
12333 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1c6}
12334 @subsection Max_Storage_At_Blocking
12337 @geindex Max_Storage_At_Blocking
12339 [RM D.7] Specifies the maximum portion (in storage elements) of a task’s
12340 Storage_Size that can be retained by a blocked task. A violation of this
12341 restriction causes Storage_Error to be raised.
12343 @node Max_Task_Entries,Max_Tasks,Max_Storage_At_Blocking,Partition-Wide Restrictions
12344 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1c7}
12345 @subsection Max_Task_Entries
12348 @geindex Max_Task_Entries
12350 [RM D.7] Specifies the maximum number of entries
12351 per task.  The bounds of every entry family
12352 of a task unit shall be static, or shall be
12353 defined by a discriminant of a subtype whose
12354 corresponding bound is static.
12356 @node Max_Tasks,No_Abort_Statements,Max_Task_Entries,Partition-Wide Restrictions
12357 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1c8}
12358 @subsection Max_Tasks
12361 @geindex Max_Tasks
12363 [RM D.7] Specifies the maximum number of task that may be created, not
12364 counting the creation of the environment task.  Violations of this
12365 restriction with a value of zero are detected at compile
12366 time. Violations of this restriction with values other than zero cause
12367 Storage_Error to be raised.
12369 @node No_Abort_Statements,No_Access_Parameter_Allocators,Max_Tasks,Partition-Wide Restrictions
12370 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1c9}
12371 @subsection No_Abort_Statements
12374 @geindex No_Abort_Statements
12376 [RM D.7] There are no abort_statements, and there are
12377 no calls to Task_Identification.Abort_Task.
12379 @node No_Access_Parameter_Allocators,No_Access_Subprograms,No_Abort_Statements,Partition-Wide Restrictions
12380 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1ca}
12381 @subsection No_Access_Parameter_Allocators
12384 @geindex No_Access_Parameter_Allocators
12386 [RM H.4] This restriction ensures at compile time that there are no
12387 occurrences of an allocator as the actual parameter to an access
12388 parameter.
12390 @node No_Access_Subprograms,No_Allocators,No_Access_Parameter_Allocators,Partition-Wide Restrictions
12391 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1cb}
12392 @subsection No_Access_Subprograms
12395 @geindex No_Access_Subprograms
12397 [RM H.4] This restriction ensures at compile time that there are no
12398 declarations of access-to-subprogram types.
12400 @node No_Allocators,No_Anonymous_Allocators,No_Access_Subprograms,Partition-Wide Restrictions
12401 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1cc}
12402 @subsection No_Allocators
12405 @geindex No_Allocators
12407 [RM H.4] This restriction ensures at compile time that there are no
12408 occurrences of an allocator.
12410 @node No_Anonymous_Allocators,No_Asynchronous_Control,No_Allocators,Partition-Wide Restrictions
12411 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1cd}
12412 @subsection No_Anonymous_Allocators
12415 @geindex No_Anonymous_Allocators
12417 [RM H.4] This restriction ensures at compile time that there are no
12418 occurrences of an allocator of anonymous access type.
12420 @node No_Asynchronous_Control,No_Calendar,No_Anonymous_Allocators,Partition-Wide Restrictions
12421 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1ce}
12422 @subsection No_Asynchronous_Control
12425 @geindex No_Asynchronous_Control
12427 [RM J.13] This restriction ensures at compile time that there are no semantic
12428 dependences on the predefined package Asynchronous_Task_Control.
12430 @node No_Calendar,No_Coextensions,No_Asynchronous_Control,Partition-Wide Restrictions
12431 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1cf}
12432 @subsection No_Calendar
12435 @geindex No_Calendar
12437 [GNAT] This restriction ensures at compile time that there are no semantic
12438 dependences on package Calendar.
12440 @node No_Coextensions,No_Default_Initialization,No_Calendar,Partition-Wide Restrictions
12441 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1d0}
12442 @subsection No_Coextensions
12445 @geindex No_Coextensions
12447 [RM H.4] This restriction ensures at compile time that there are no
12448 coextensions. See 3.10.2.
12450 @node No_Default_Initialization,No_Delay,No_Coextensions,Partition-Wide Restrictions
12451 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1d1}
12452 @subsection No_Default_Initialization
12455 @geindex No_Default_Initialization
12457 [GNAT] This restriction prohibits any instance of default initialization
12458 of variables.  The binder implements a consistency rule which prevents
12459 any unit compiled without the restriction from with’ing a unit with the
12460 restriction (this allows the generation of initialization procedures to
12461 be skipped, since you can be sure that no call is ever generated to an
12462 initialization procedure in a unit with the restriction active). If used
12463 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
12464 is to prohibit all cases of variables declared without a specific
12465 initializer (including the case of OUT scalar parameters).
12467 @node No_Delay,No_Dependence,No_Default_Initialization,Partition-Wide Restrictions
12468 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1d2}
12469 @subsection No_Delay
12472 @geindex No_Delay
12474 [RM H.4] This restriction ensures at compile time that there are no
12475 delay statements and no semantic dependences on package Calendar.
12477 @node No_Dependence,No_Direct_Boolean_Operators,No_Delay,Partition-Wide Restrictions
12478 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1d3}
12479 @subsection No_Dependence
12482 @geindex No_Dependence
12484 [RM 13.12.1] This restriction ensures at compile time that there are no
12485 dependences on a library unit. For GNAT, this includes implicit implementation
12486 dependences on units of the runtime library that are created by the compiler
12487 to support specific constructs of the language. Here are some examples:
12490 @itemize *
12492 @item 
12493 @code{System.Arith_64}: 64-bit arithmetics for 32-bit platforms,
12495 @item 
12496 @code{System.Arith_128}: 128-bit arithmetics for 64-bit platforms,
12498 @item 
12499 @code{System.Memory}: heap memory allocation routines,
12501 @item 
12502 @code{System.Memory_Compare}: memory comparison routine (aka @code{memcmp} for C),
12504 @item 
12505 @code{System.Memory_Copy}: memory copy routine (aka @code{memcpy} for C),
12507 @item 
12508 @code{System.Memory_Move}: memoy move routine (aka @code{memmove} for C),
12510 @item 
12511 @code{System.Memory_Set}: memory set routine (aka @code{memset} for C),
12513 @item 
12514 @code{System.Stack_Checking[.Operations]}: stack checking without MMU,
12516 @item 
12517 @code{System.GCC}: support routines from the GCC library.
12518 @end itemize
12520 @node No_Direct_Boolean_Operators,No_Dispatch,No_Dependence,Partition-Wide Restrictions
12521 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1d4}
12522 @subsection No_Direct_Boolean_Operators
12525 @geindex No_Direct_Boolean_Operators
12527 [GNAT] This restriction ensures that no logical operators (and/or/xor)
12528 are used on operands of type Boolean (or any type derived from Boolean).
12529 This is intended for use in safety critical programs where the certification
12530 protocol requires the use of short-circuit (and then, or else) forms for all
12531 composite boolean operations.
12533 @node No_Dispatch,No_Dispatching_Calls,No_Direct_Boolean_Operators,Partition-Wide Restrictions
12534 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1d5}
12535 @subsection No_Dispatch
12538 @geindex No_Dispatch
12540 [RM H.4] This restriction ensures at compile time that there are no
12541 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
12543 @node No_Dispatching_Calls,No_Dynamic_Attachment,No_Dispatch,Partition-Wide Restrictions
12544 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1d6}
12545 @subsection No_Dispatching_Calls
12548 @geindex No_Dispatching_Calls
12550 [GNAT] This restriction ensures at compile time that the code generated by the
12551 compiler involves no dispatching calls. The use of this restriction allows the
12552 safe use of record extensions, classwide membership tests and other classwide
12553 features not involving implicit dispatching. This restriction ensures that
12554 the code contains no indirect calls through a dispatching mechanism. Note that
12555 this includes internally-generated calls created by the compiler, for example
12556 in the implementation of class-wide objects assignments. The
12557 membership test is allowed in the presence of this restriction, because its
12558 implementation requires no dispatching.
12559 This restriction is comparable to the official Ada restriction
12560 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
12561 all classwide constructs that do not imply dispatching.
12562 The following example indicates constructs that violate this restriction.
12564 @example
12565 package Pkg is
12566   type T is tagged record
12567     Data : Natural;
12568   end record;
12569   procedure P (X : T);
12571   type DT is new T with record
12572     More_Data : Natural;
12573   end record;
12574   procedure Q (X : DT);
12575 end Pkg;
12577 with Pkg; use Pkg;
12578 procedure Example is
12579   procedure Test (O : T'Class) is
12580     N : Natural := O'Size; --  Error: Dispatching call
12581     C : T'Class := O;      --  Error: implicit Dispatching Call
12582   begin
12583     if O in DT'Class then  --  OK   : Membership test
12584        Q (DT (O));         --  OK   : Type conversion plus direct call
12585     else
12586        P (O);              --  Error: Dispatching call
12587     end if;
12588   end Test;
12590   Obj : DT;
12591 begin
12592   P (Obj);                 --  OK   : Direct call
12593   P (T (Obj));             --  OK   : Type conversion plus direct call
12594   P (T'Class (Obj));       --  Error: Dispatching call
12596   Test (Obj);              --  OK   : Type conversion
12598   if Obj in T'Class then   --  OK   : Membership test
12599      null;
12600   end if;
12601 end Example;
12602 @end example
12604 @node No_Dynamic_Attachment,No_Dynamic_Priorities,No_Dispatching_Calls,Partition-Wide Restrictions
12605 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1d7}
12606 @subsection No_Dynamic_Attachment
12609 @geindex No_Dynamic_Attachment
12611 [RM D.7] This restriction ensures that there is no call to any of the
12612 operations defined in package Ada.Interrupts
12613 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
12614 Detach_Handler, and Reference).
12616 @geindex No_Dynamic_Interrupts
12618 The restriction @code{No_Dynamic_Interrupts} is recognized as a
12619 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
12620 compatibility purposes (and a warning will be generated for its use if
12621 warnings on obsolescent features are activated).
12623 @node No_Dynamic_Priorities,No_Entry_Calls_In_Elaboration_Code,No_Dynamic_Attachment,Partition-Wide Restrictions
12624 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1d8}
12625 @subsection No_Dynamic_Priorities
12628 @geindex No_Dynamic_Priorities
12630 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
12632 @node No_Entry_Calls_In_Elaboration_Code,No_Enumeration_Maps,No_Dynamic_Priorities,Partition-Wide Restrictions
12633 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1d9}
12634 @subsection No_Entry_Calls_In_Elaboration_Code
12637 @geindex No_Entry_Calls_In_Elaboration_Code
12639 [GNAT] This restriction ensures at compile time that no task or protected entry
12640 calls are made during elaboration code.  As a result of the use of this
12641 restriction, the compiler can assume that no code past an accept statement
12642 in a task can be executed at elaboration time.
12644 @node No_Enumeration_Maps,No_Exception_Handlers,No_Entry_Calls_In_Elaboration_Code,Partition-Wide Restrictions
12645 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1da}
12646 @subsection No_Enumeration_Maps
12649 @geindex No_Enumeration_Maps
12651 [GNAT] This restriction ensures at compile time that no operations requiring
12652 enumeration maps are used (that is Image and Value attributes applied
12653 to enumeration types).
12655 @node No_Exception_Handlers,No_Exception_Propagation,No_Enumeration_Maps,Partition-Wide Restrictions
12656 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1db}
12657 @subsection No_Exception_Handlers
12660 @geindex No_Exception_Handlers
12662 [GNAT] This restriction ensures at compile time that there are no explicit
12663 exception handlers. It also indicates that no exception propagation will
12664 be provided. In this mode, exceptions may be raised but will result in
12665 an immediate call to the last chance handler, a routine that the user
12666 must define with the following profile:
12668 @example
12669 procedure Last_Chance_Handler
12670   (Source_Location : System.Address; Line : Integer);
12671 pragma Export (C, Last_Chance_Handler,
12672                "__gnat_last_chance_handler");
12673 @end example
12675 The parameter is a C null-terminated string representing a message to be
12676 associated with the exception (typically the source location of the raise
12677 statement generated by the compiler). The Line parameter when nonzero
12678 represents the line number in the source program where the raise occurs.
12680 @node No_Exception_Propagation,No_Exception_Registration,No_Exception_Handlers,Partition-Wide Restrictions
12681 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1dc}
12682 @subsection No_Exception_Propagation
12685 @geindex No_Exception_Propagation
12687 [GNAT] This restriction guarantees that exceptions are never propagated
12688 to an outer subprogram scope. The only case in which an exception may
12689 be raised is when the handler is statically in the same subprogram, so
12690 that the effect of a raise is essentially like a goto statement. Any
12691 other raise statement (implicit or explicit) will be considered
12692 unhandled. Exception handlers are allowed, but may not contain an
12693 exception occurrence identifier (exception choice). In addition, use of
12694 the package GNAT.Current_Exception is not permitted, and reraise
12695 statements (raise with no operand) are not permitted.
12697 @node No_Exception_Registration,No_Exceptions,No_Exception_Propagation,Partition-Wide Restrictions
12698 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1dd}
12699 @subsection No_Exception_Registration
12702 @geindex No_Exception_Registration
12704 [GNAT] This restriction ensures at compile time that no stream operations for
12705 types Exception_Id or Exception_Occurrence are used. This also makes it
12706 impossible to pass exceptions to or from a partition with this restriction
12707 in a distributed environment. If this restriction is active, the generated
12708 code is simplified by omitting the otherwise-required global registration
12709 of exceptions when they are declared.
12711 @node No_Exceptions,No_Finalization,No_Exception_Registration,Partition-Wide Restrictions
12712 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1de}
12713 @subsection No_Exceptions
12716 @geindex No_Exceptions
12718 [RM H.4] This restriction ensures at compile time that there are no
12719 raise statements and no exception handlers and also suppresses the
12720 generation of language-defined run-time checks.
12722 @node No_Finalization,No_Fixed_Point,No_Exceptions,Partition-Wide Restrictions
12723 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1df}
12724 @subsection No_Finalization
12727 @geindex No_Finalization
12729 [GNAT] This restriction disables the language features described in
12730 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
12731 performed by the compiler to support these features. The following types
12732 are no longer considered controlled when this restriction is in effect:
12735 @itemize *
12737 @item 
12738 @code{Ada.Finalization.Controlled}
12740 @item 
12741 @code{Ada.Finalization.Limited_Controlled}
12743 @item 
12744 Derivations from @code{Controlled} or @code{Limited_Controlled}
12746 @item 
12747 Class-wide types
12749 @item 
12750 Protected types
12752 @item 
12753 Task types
12755 @item 
12756 Array and record types with controlled components
12757 @end itemize
12759 The compiler no longer generates code to initialize, finalize or adjust an
12760 object or a nested component, either declared on the stack or on the heap. The
12761 deallocation of a controlled object no longer finalizes its contents.
12763 @node No_Fixed_Point,No_Floating_Point,No_Finalization,Partition-Wide Restrictions
12764 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1e0}
12765 @subsection No_Fixed_Point
12768 @geindex No_Fixed_Point
12770 [RM H.4] This restriction ensures at compile time that there are no
12771 occurrences of fixed point types and operations.
12773 @node No_Floating_Point,No_Implicit_Conditionals,No_Fixed_Point,Partition-Wide Restrictions
12774 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1e1}
12775 @subsection No_Floating_Point
12778 @geindex No_Floating_Point
12780 [RM H.4] This restriction ensures at compile time that there are no
12781 occurrences of floating point types and operations.
12783 @node No_Implicit_Conditionals,No_Implicit_Dynamic_Code,No_Floating_Point,Partition-Wide Restrictions
12784 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1e2}
12785 @subsection No_Implicit_Conditionals
12788 @geindex No_Implicit_Conditionals
12790 [GNAT] This restriction ensures that the generated code does not contain any
12791 implicit conditionals, either by modifying the generated code where possible,
12792 or by rejecting any construct that would otherwise generate an implicit
12793 conditional. Note that this check does not include run time constraint
12794 checks, which on some targets may generate implicit conditionals as
12795 well. To control the latter, constraint checks can be suppressed in the
12796 normal manner. Constructs generating implicit conditionals include comparisons
12797 of composite objects and the Max/Min attributes.
12799 @node No_Implicit_Dynamic_Code,No_Implicit_Heap_Allocations,No_Implicit_Conditionals,Partition-Wide Restrictions
12800 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1e3}
12801 @subsection No_Implicit_Dynamic_Code
12804 @geindex No_Implicit_Dynamic_Code
12806 @geindex trampoline
12808 [GNAT] This restriction prevents the compiler from building ‘trampolines’.
12809 This is a structure that is built on the stack and contains dynamic
12810 code to be executed at run time. On some targets, a trampoline is
12811 built for the following features: @code{Access},
12812 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
12813 nested task bodies; primitive operations of nested tagged types.
12814 Trampolines do not work on machines that prevent execution of stack
12815 data. For example, on windows systems, enabling DEP (data execution
12816 protection) will cause trampolines to raise an exception.
12817 Trampolines are also quite slow at run time.
12819 On many targets, trampolines have been largely eliminated. Look at the
12820 version of system.ads for your target — if it has
12821 Always_Compatible_Rep equal to False, then trampolines are largely
12822 eliminated. In particular, a trampoline is built for the following
12823 features: @code{Address} of a nested subprogram;
12824 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
12825 but only if pragma Favor_Top_Level applies, or the access type has a
12826 foreign-language convention; primitive operations of nested tagged
12827 types.
12829 @node No_Implicit_Heap_Allocations,No_Implicit_Protected_Object_Allocations,No_Implicit_Dynamic_Code,Partition-Wide Restrictions
12830 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1e4}
12831 @subsection No_Implicit_Heap_Allocations
12834 @geindex No_Implicit_Heap_Allocations
12836 [RM D.7] No constructs are allowed to cause implicit heap allocation.
12838 @node No_Implicit_Protected_Object_Allocations,No_Implicit_Task_Allocations,No_Implicit_Heap_Allocations,Partition-Wide Restrictions
12839 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1e5}
12840 @subsection No_Implicit_Protected_Object_Allocations
12843 @geindex No_Implicit_Protected_Object_Allocations
12845 [GNAT] No constructs are allowed to cause implicit heap allocation of a
12846 protected object.
12848 @node No_Implicit_Task_Allocations,No_Initialize_Scalars,No_Implicit_Protected_Object_Allocations,Partition-Wide Restrictions
12849 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1e6}
12850 @subsection No_Implicit_Task_Allocations
12853 @geindex No_Implicit_Task_Allocations
12855 [GNAT] No constructs are allowed to cause implicit heap allocation of a task.
12857 @node No_Initialize_Scalars,No_IO,No_Implicit_Task_Allocations,Partition-Wide Restrictions
12858 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1e7}
12859 @subsection No_Initialize_Scalars
12862 @geindex No_Initialize_Scalars
12864 [GNAT] This restriction ensures that no unit in the partition is compiled with
12865 pragma Initialize_Scalars. This allows the generation of more efficient
12866 code, and in particular eliminates dummy null initialization routines that
12867 are otherwise generated for some record and array types.
12869 @node No_IO,No_Local_Allocators,No_Initialize_Scalars,Partition-Wide Restrictions
12870 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1e8}
12871 @subsection No_IO
12874 @geindex No_IO
12876 [RM H.4] This restriction ensures at compile time that there are no
12877 dependences on any of the library units Sequential_IO, Direct_IO,
12878 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
12880 @node No_Local_Allocators,No_Local_Protected_Objects,No_IO,Partition-Wide Restrictions
12881 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1e9}
12882 @subsection No_Local_Allocators
12885 @geindex No_Local_Allocators
12887 [RM H.4] This restriction ensures at compile time that there are no
12888 occurrences of an allocator in subprograms, generic subprograms, tasks,
12889 and entry bodies.
12891 @node No_Local_Protected_Objects,No_Local_Tagged_Types,No_Local_Allocators,Partition-Wide Restrictions
12892 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1ea}
12893 @subsection No_Local_Protected_Objects
12896 @geindex No_Local_Protected_Objects
12898 [RM D.7] This restriction ensures at compile time that protected objects are
12899 only declared at the library level.
12901 @node No_Local_Tagged_Types,No_Local_Timing_Events,No_Local_Protected_Objects,Partition-Wide Restrictions
12902 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-tagged-types}@anchor{1eb}
12903 @subsection No_Local_Tagged_Types
12906 @geindex No_Local_Tagged_Types
12908 [GNAT] This restriction ensures at compile time that tagged types are only
12909 declared at the library level.
12911 @node No_Local_Timing_Events,No_Long_Long_Integers,No_Local_Tagged_Types,Partition-Wide Restrictions
12912 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1ec}
12913 @subsection No_Local_Timing_Events
12916 @geindex No_Local_Timing_Events
12918 [RM D.7] All objects of type Ada.Real_Time.Timing_Events.Timing_Event are
12919 declared at the library level.
12921 @node No_Long_Long_Integers,No_Multiple_Elaboration,No_Local_Timing_Events,Partition-Wide Restrictions
12922 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1ed}
12923 @subsection No_Long_Long_Integers
12926 @geindex No_Long_Long_Integers
12928 [GNAT] This partition-wide restriction forbids any explicit reference to
12929 type Standard.Long_Long_Integer, and also forbids declaring range types whose
12930 implicit base type is Long_Long_Integer, and modular types whose size exceeds
12931 Long_Integer’Size.
12933 @node No_Multiple_Elaboration,No_Nested_Finalization,No_Long_Long_Integers,Partition-Wide Restrictions
12934 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1ee}
12935 @subsection No_Multiple_Elaboration
12938 @geindex No_Multiple_Elaboration
12940 [GNAT] When this restriction is active and the static elaboration model is
12941 used, and -fpreserve-control-flow is not used, the compiler is allowed to
12942 suppress the elaboration counter normally associated with the unit, even if
12943 the unit has elaboration code. This counter is typically used to check for
12944 access before elaboration and to control multiple elaboration attempts. If the
12945 restriction is used, then the situations in which multiple elaboration is
12946 possible, including non-Ada main programs and Stand Alone libraries, are not
12947 permitted and will be diagnosed by the binder.
12949 @node No_Nested_Finalization,No_Protected_Type_Allocators,No_Multiple_Elaboration,Partition-Wide Restrictions
12950 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1ef}
12951 @subsection No_Nested_Finalization
12954 @geindex No_Nested_Finalization
12956 [RM D.7] All objects requiring finalization are declared at the library level.
12958 @node No_Protected_Type_Allocators,No_Protected_Types,No_Nested_Finalization,Partition-Wide Restrictions
12959 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1f0}
12960 @subsection No_Protected_Type_Allocators
12963 @geindex No_Protected_Type_Allocators
12965 [RM D.7] This restriction ensures at compile time that there are no allocator
12966 expressions that attempt to allocate protected objects.
12968 @node No_Protected_Types,No_Recursion,No_Protected_Type_Allocators,Partition-Wide Restrictions
12969 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1f1}
12970 @subsection No_Protected_Types
12973 @geindex No_Protected_Types
12975 [RM H.4] This restriction ensures at compile time that there are no
12976 declarations of protected types or protected objects.
12978 @node No_Recursion,No_Reentrancy,No_Protected_Types,Partition-Wide Restrictions
12979 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1f2}
12980 @subsection No_Recursion
12983 @geindex No_Recursion
12985 [RM H.4] A program execution is erroneous if a subprogram is invoked as
12986 part of its execution.
12988 @node No_Reentrancy,No_Relative_Delay,No_Recursion,Partition-Wide Restrictions
12989 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1f3}
12990 @subsection No_Reentrancy
12993 @geindex No_Reentrancy
12995 [RM H.4] A program execution is erroneous if a subprogram is executed by
12996 two tasks at the same time.
12998 @node No_Relative_Delay,No_Requeue_Statements,No_Reentrancy,Partition-Wide Restrictions
12999 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1f4}
13000 @subsection No_Relative_Delay
13003 @geindex No_Relative_Delay
13005 [RM D.7] This restriction ensures at compile time that there are no delay
13006 relative statements and prevents expressions such as @code{delay 1.23;} from
13007 appearing in source code.
13009 @node No_Requeue_Statements,No_Secondary_Stack,No_Relative_Delay,Partition-Wide Restrictions
13010 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1f5}
13011 @subsection No_Requeue_Statements
13014 @geindex No_Requeue_Statements
13016 [RM D.7] This restriction ensures at compile time that no requeue statements
13017 are permitted and prevents keyword @code{requeue} from being used in source
13018 code.
13020 @geindex No_Requeue
13022 The restriction @code{No_Requeue} is recognized as a
13023 synonym for @code{No_Requeue_Statements}. This is retained for historical
13024 compatibility purposes (and a warning will be generated for its use if
13025 warnings on oNobsolescent features are activated).
13027 @node No_Secondary_Stack,No_Select_Statements,No_Requeue_Statements,Partition-Wide Restrictions
13028 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1f6}
13029 @subsection No_Secondary_Stack
13032 @geindex No_Secondary_Stack
13034 [GNAT] This restriction ensures at compile time that the generated code
13035 does not contain any reference to the secondary stack.  The secondary
13036 stack is used to implement functions returning unconstrained objects
13037 (arrays or records) on some targets. Suppresses the allocation of
13038 secondary stacks for tasks (excluding the environment task) at run time.
13040 @node No_Select_Statements,No_Specific_Termination_Handlers,No_Secondary_Stack,Partition-Wide Restrictions
13041 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1f7}
13042 @subsection No_Select_Statements
13045 @geindex No_Select_Statements
13047 [RM D.7] This restriction ensures at compile time no select statements of any
13048 kind are permitted, that is the keyword @code{select} may not appear.
13050 @node No_Specific_Termination_Handlers,No_Specification_of_Aspect,No_Select_Statements,Partition-Wide Restrictions
13051 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1f8}
13052 @subsection No_Specific_Termination_Handlers
13055 @geindex No_Specific_Termination_Handlers
13057 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
13058 or to Ada.Task_Termination.Specific_Handler.
13060 @node No_Specification_of_Aspect,No_Standard_Allocators_After_Elaboration,No_Specific_Termination_Handlers,Partition-Wide Restrictions
13061 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{1f9}
13062 @subsection No_Specification_of_Aspect
13065 @geindex No_Specification_of_Aspect
13067 [RM 13.12.1] This restriction checks at compile time that no aspect
13068 specification, attribute definition clause, or pragma is given for a
13069 given aspect.
13071 @node No_Standard_Allocators_After_Elaboration,No_Standard_Storage_Pools,No_Specification_of_Aspect,Partition-Wide Restrictions
13072 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{1fa}
13073 @subsection No_Standard_Allocators_After_Elaboration
13076 @geindex No_Standard_Allocators_After_Elaboration
13078 [RM D.7] Specifies that an allocator using a standard storage pool
13079 should never be evaluated at run time after the elaboration of the
13080 library items of the partition has completed. Otherwise, Storage_Error
13081 is raised.
13083 @node No_Standard_Storage_Pools,No_Stream_Optimizations,No_Standard_Allocators_After_Elaboration,Partition-Wide Restrictions
13084 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{1fb}
13085 @subsection No_Standard_Storage_Pools
13088 @geindex No_Standard_Storage_Pools
13090 [GNAT] This restriction ensures at compile time that no access types
13091 use the standard default storage pool.  Any access type declared must
13092 have an explicit Storage_Pool attribute defined specifying a
13093 user-defined storage pool.
13095 @node No_Stream_Optimizations,No_Streams,No_Standard_Storage_Pools,Partition-Wide Restrictions
13096 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{1fc}
13097 @subsection No_Stream_Optimizations
13100 @geindex No_Stream_Optimizations
13102 [GNAT] This restriction affects the performance of stream operations on types
13103 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
13104 compiler uses block reads and writes when manipulating @code{String} objects
13105 due to their superior performance. When this restriction is in effect, the
13106 compiler performs all IO operations on a per-character basis.
13108 @node No_Streams,No_Tagged_Type_Registration,No_Stream_Optimizations,Partition-Wide Restrictions
13109 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{1fd}
13110 @subsection No_Streams
13113 @geindex No_Streams
13115 [GNAT] This restriction ensures at compile/bind time that there are no
13116 stream objects created and no use of stream attributes.
13117 This restriction does not forbid dependences on the package
13118 @code{Ada.Streams}. So it is permissible to with
13119 @code{Ada.Streams} (or another package that does so itself)
13120 as long as no actual stream objects are created and no
13121 stream attributes are used.
13123 Note that the use of restriction allows optimization of tagged types,
13124 since they do not need to worry about dispatching stream operations.
13125 To take maximum advantage of this space-saving optimization, any
13126 unit declaring a tagged type should be compiled with the restriction,
13127 though this is not required.
13129 @node No_Tagged_Type_Registration,No_Task_Allocators,No_Streams,Partition-Wide Restrictions
13130 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tagged-type-registration}@anchor{1fe}
13131 @subsection No_Tagged_Type_Registration
13134 @geindex No_Tagged_Type_Registration
13136 [GNAT] If this restriction is active, then class-wide streaming
13137 attributes are not supported. In addition, the subprograms in
13138 Ada.Tags are not supported.
13139 If this restriction is active, the generated code is simplified by
13140 omitting the otherwise-required global registration of tagged types when they
13141 are declared. This restriction may be necessary in order to also apply
13142 the No_Elaboration_Code restriction.
13144 @node No_Task_Allocators,No_Task_At_Interrupt_Priority,No_Tagged_Type_Registration,Partition-Wide Restrictions
13145 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{1ff}
13146 @subsection No_Task_Allocators
13149 @geindex No_Task_Allocators
13151 [RM D.7] There are no allocators for task types
13152 or types containing task subcomponents.
13154 @node No_Task_At_Interrupt_Priority,No_Task_Attributes_Package,No_Task_Allocators,Partition-Wide Restrictions
13155 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{200}
13156 @subsection No_Task_At_Interrupt_Priority
13159 @geindex No_Task_At_Interrupt_Priority
13161 [GNAT] This restriction ensures at compile time that there is no
13162 Interrupt_Priority aspect or pragma for a task or a task type. As
13163 a consequence, the tasks are always created with a priority below
13164 that an interrupt priority.
13166 @node No_Task_Attributes_Package,No_Task_Hierarchy,No_Task_At_Interrupt_Priority,Partition-Wide Restrictions
13167 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{201}
13168 @subsection No_Task_Attributes_Package
13171 @geindex No_Task_Attributes_Package
13173 [GNAT] This restriction ensures at compile time that there are no implicit or
13174 explicit dependencies on the package @code{Ada.Task_Attributes}.
13176 @geindex No_Task_Attributes
13178 The restriction @code{No_Task_Attributes} is recognized as a synonym
13179 for @code{No_Task_Attributes_Package}. This is retained for historical
13180 compatibility purposes (and a warning will be generated for its use if
13181 warnings on obsolescent features are activated).
13183 @node No_Task_Hierarchy,No_Task_Termination,No_Task_Attributes_Package,Partition-Wide Restrictions
13184 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{202}
13185 @subsection No_Task_Hierarchy
13188 @geindex No_Task_Hierarchy
13190 [RM D.7] All (non-environment) tasks depend
13191 directly on the environment task of the partition.
13193 @node No_Task_Termination,No_Tasking,No_Task_Hierarchy,Partition-Wide Restrictions
13194 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{203}
13195 @subsection No_Task_Termination
13198 @geindex No_Task_Termination
13200 [RM D.7] Tasks that terminate are erroneous.
13202 @node No_Tasking,No_Terminate_Alternatives,No_Task_Termination,Partition-Wide Restrictions
13203 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{204}
13204 @subsection No_Tasking
13207 @geindex No_Tasking
13209 [GNAT] This restriction prevents the declaration of tasks or task types
13210 throughout the partition.  It is similar in effect to the use of
13211 @code{Max_Tasks => 0} except that violations are caught at compile time
13212 and cause an error message to be output either by the compiler or
13213 binder.
13215 @node No_Terminate_Alternatives,No_Unchecked_Access,No_Tasking,Partition-Wide Restrictions
13216 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{205}
13217 @subsection No_Terminate_Alternatives
13220 @geindex No_Terminate_Alternatives
13222 [RM D.7] There are no selective accepts with terminate alternatives.
13224 @node No_Unchecked_Access,No_Unchecked_Conversion,No_Terminate_Alternatives,Partition-Wide Restrictions
13225 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{206}
13226 @subsection No_Unchecked_Access
13229 @geindex No_Unchecked_Access
13231 [RM H.4] This restriction ensures at compile time that there are no
13232 occurrences of the Unchecked_Access attribute.
13234 @node No_Unchecked_Conversion,No_Unchecked_Deallocation,No_Unchecked_Access,Partition-Wide Restrictions
13235 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{207}
13236 @subsection No_Unchecked_Conversion
13239 @geindex No_Unchecked_Conversion
13241 [RM J.13] This restriction ensures at compile time that there are no semantic
13242 dependences on the predefined generic function Unchecked_Conversion.
13244 @node No_Unchecked_Deallocation,No_Use_Of_Attribute,No_Unchecked_Conversion,Partition-Wide Restrictions
13245 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{208}
13246 @subsection No_Unchecked_Deallocation
13249 @geindex No_Unchecked_Deallocation
13251 [RM J.13] This restriction ensures at compile time that there are no semantic
13252 dependences on the predefined generic procedure Unchecked_Deallocation.
13254 @node No_Use_Of_Attribute,No_Use_Of_Entity,No_Unchecked_Deallocation,Partition-Wide Restrictions
13255 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-attribute}@anchor{209}
13256 @subsection No_Use_Of_Attribute
13259 @geindex No_Use_Of_Attribute
13261 [RM 13.12.1] This is a standard Ada 2012 restriction that is GNAT defined in
13262 earlier versions of Ada.
13264 @node No_Use_Of_Entity,No_Use_Of_Pragma,No_Use_Of_Attribute,Partition-Wide Restrictions
13265 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{20a}
13266 @subsection No_Use_Of_Entity
13269 @geindex No_Use_Of_Entity
13271 [GNAT] This restriction ensures at compile time that there are no references
13272 to the entity given in the form
13274 @example
13275 No_Use_Of_Entity => Name
13276 @end example
13278 where @code{Name} is the fully qualified entity, for example
13280 @example
13281 No_Use_Of_Entity => Ada.Text_IO.Put_Line
13282 @end example
13284 @node No_Use_Of_Pragma,Pure_Barriers,No_Use_Of_Entity,Partition-Wide Restrictions
13285 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-pragma}@anchor{20b}
13286 @subsection No_Use_Of_Pragma
13289 @geindex No_Use_Of_Pragma
13291 [RM 13.12.1] This is a standard Ada 2012 restriction that is GNAT defined in
13292 earlier versions of Ada.
13294 @node Pure_Barriers,Simple_Barriers,No_Use_Of_Pragma,Partition-Wide Restrictions
13295 @anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{20c}
13296 @subsection Pure_Barriers
13299 @geindex Pure_Barriers
13301 [GNAT] This restriction ensures at compile time that protected entry
13302 barriers are restricted to:
13305 @itemize *
13307 @item 
13308 components of the protected object (excluding selection from dereferences),
13310 @item 
13311 constant declarations,
13313 @item 
13314 named numbers,
13316 @item 
13317 enumeration literals,
13319 @item 
13320 integer literals,
13322 @item 
13323 real literals,
13325 @item 
13326 character literals,
13328 @item 
13329 implicitly defined comparison operators,
13331 @item 
13332 uses of the Standard.”not” operator,
13334 @item 
13335 short-circuit operator,
13337 @item 
13338 the Count attribute
13339 @end itemize
13341 This restriction is a relaxation of the Simple_Barriers restriction,
13342 but still ensures absence of side effects, exceptions, and recursion
13343 during the evaluation of the barriers.
13345 @node Simple_Barriers,Static_Priorities,Pure_Barriers,Partition-Wide Restrictions
13346 @anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{20d}
13347 @subsection Simple_Barriers
13350 @geindex Simple_Barriers
13352 [RM D.7] This restriction ensures at compile time that barriers in entry
13353 declarations for protected types are restricted to either static boolean
13354 expressions or references to simple boolean variables defined in the private
13355 part of the protected type.  No other form of entry barriers is permitted.
13357 @geindex Boolean_Entry_Barriers
13359 The restriction @code{Boolean_Entry_Barriers} is recognized as a
13360 synonym for @code{Simple_Barriers}. This is retained for historical
13361 compatibility purposes (and a warning will be generated for its use if
13362 warnings on obsolescent features are activated).
13364 @node Static_Priorities,Static_Storage_Size,Simple_Barriers,Partition-Wide Restrictions
13365 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{20e}
13366 @subsection Static_Priorities
13369 @geindex Static_Priorities
13371 [GNAT] This restriction ensures at compile time that all priority expressions
13372 are static, and that there are no dependences on the package
13373 @code{Ada.Dynamic_Priorities}.
13375 @node Static_Storage_Size,,Static_Priorities,Partition-Wide Restrictions
13376 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{20f}
13377 @subsection Static_Storage_Size
13380 @geindex Static_Storage_Size
13382 [GNAT] This restriction ensures at compile time that any expression appearing
13383 in a Storage_Size pragma or attribute definition clause is static.
13385 @node Program Unit Level Restrictions,,Partition-Wide Restrictions,Standard and Implementation Defined Restrictions
13386 @anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{210}@anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{211}
13387 @section Program Unit Level Restrictions
13390 The second set of restriction identifiers
13391 does not require partition-wide consistency.
13392 The restriction may be enforced for a single
13393 compilation unit without any effect on any of the
13394 other compilation units in the partition.
13396 @menu
13397 * No_Elaboration_Code:: 
13398 * No_Dynamic_Accessibility_Checks:: 
13399 * No_Dynamic_Sized_Objects:: 
13400 * No_Entry_Queue:: 
13401 * No_Implementation_Aspect_Specifications:: 
13402 * No_Implementation_Attributes:: 
13403 * No_Implementation_Identifiers:: 
13404 * No_Implementation_Pragmas:: 
13405 * No_Implementation_Restrictions:: 
13406 * No_Implementation_Units:: 
13407 * No_Implicit_Aliasing:: 
13408 * No_Implicit_Loops:: 
13409 * No_Obsolescent_Features:: 
13410 * No_Wide_Characters:: 
13411 * Static_Dispatch_Tables:: 
13412 * SPARK_05:: 
13414 @end menu
13416 @node No_Elaboration_Code,No_Dynamic_Accessibility_Checks,,Program Unit Level Restrictions
13417 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{212}
13418 @subsection No_Elaboration_Code
13421 @geindex No_Elaboration_Code
13423 [GNAT] This restriction ensures at compile time that no elaboration code is
13424 generated.  Note that this is not the same condition as is enforced
13425 by pragma @code{Preelaborate}.  There are cases in which pragma
13426 @code{Preelaborate} still permits code to be generated (e.g., code
13427 to initialize a large array to all zeroes), and there are cases of units
13428 which do not meet the requirements for pragma @code{Preelaborate},
13429 but for which no elaboration code is generated.  Generally, it is
13430 the case that preelaborable units will meet the restrictions, with
13431 the exception of large aggregates initialized with an others_clause,
13432 and exception declarations (which generate calls to a run-time
13433 registry procedure).  This restriction is enforced on
13434 a unit by unit basis, it need not be obeyed consistently
13435 throughout a partition.
13437 In the case of aggregates with others, if the aggregate has a dynamic
13438 size, there is no way to eliminate the elaboration code (such dynamic
13439 bounds would be incompatible with @code{Preelaborate} in any case). If
13440 the bounds are static, then use of this restriction actually modifies
13441 the code choice of the compiler to avoid generating a loop, and instead
13442 generate the aggregate statically if possible, no matter how many times
13443 the data for the others clause must be repeatedly generated.
13445 It is not possible to precisely document
13446 the constructs which are compatible with this restriction, since,
13447 unlike most other restrictions, this is not a restriction on the
13448 source code, but a restriction on the generated object code. For
13449 example, if the source contains a declaration:
13451 @example
13452 Val : constant Integer := X;
13453 @end example
13455 where X is not a static constant, it may be possible, depending
13456 on complex optimization circuitry, for the compiler to figure
13457 out the value of X at compile time, in which case this initialization
13458 can be done by the loader, and requires no initialization code. It
13459 is not possible to document the precise conditions under which the
13460 optimizer can figure this out.
13462 Note that this the implementation of this restriction requires full
13463 code generation. If it is used in conjunction with “semantics only”
13464 checking, then some cases of violations may be missed.
13466 When this restriction is active, we are not requesting control-flow
13467 preservation with -fpreserve-control-flow, and the static elaboration model is
13468 used, the compiler is allowed to suppress the elaboration counter normally
13469 associated with the unit. This counter is typically used to check for access
13470 before elaboration and to control multiple elaboration attempts.
13472 @node No_Dynamic_Accessibility_Checks,No_Dynamic_Sized_Objects,No_Elaboration_Code,Program Unit Level Restrictions
13473 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-accessibility-checks}@anchor{213}
13474 @subsection No_Dynamic_Accessibility_Checks
13477 @geindex No_Dynamic_Accessibility_Checks
13479 [GNAT] No dynamic accessibility checks are generated when this restriction is
13480 in effect. Instead, dangling references are prevented via more conservative
13481 compile-time checking. More specifically, existing compile-time checks are
13482 enforced but with more conservative assumptions about the accessibility levels
13483 of the relevant entities. These conservative assumptions eliminate the need for
13484 dynamic accessibility checks.
13486 These new rules for computing (at compile-time) the accessibility level of an
13487 anonymous access type T are as follows:
13490 @itemize *
13492 @item 
13493 If T is a function result type then, from the caller’s perspective, its level
13494 is that of the innermost master enclosing the function call. From the callee’s
13495 perspective, the level of parameters and local variables of the callee is
13496 statically deeper than the level of T.
13498 For any other accessibility level L such that the level of parameters and local
13499 variables of the callee is statically deeper than L, the level of T (from the
13500 callee’s perspective) is also statically deeper than L.
13502 @item 
13503 If T is the type of a formal parameter then, from the caller’s perspective,
13504 its level is at least as deep as that of the type of the corresponding actual
13505 parameter (whatever that actual parameter might be). From the callee’s
13506 perspective, the level of parameters and local variables of the callee is
13507 statically deeper than the level of T.
13509 @item 
13510 If T is the type of a discriminant then its level is that of the discriminated
13511 type.
13513 @item 
13514 If T is the type of a stand-alone object then its level is the level of the
13515 object.
13517 @item 
13518 In all other cases, the level of T is as defined by the existing rules of Ada.
13519 @end itemize
13521 @node No_Dynamic_Sized_Objects,No_Entry_Queue,No_Dynamic_Accessibility_Checks,Program Unit Level Restrictions
13522 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{214}
13523 @subsection No_Dynamic_Sized_Objects
13526 @geindex No_Dynamic_Sized_Objects
13528 [GNAT] This restriction disallows certain constructs that might lead to the
13529 creation of dynamic-sized composite objects (or array or discriminated type).
13530 An array subtype indication is illegal if the bounds are not static
13531 or references to discriminants of an enclosing type.
13532 A discriminated subtype indication is illegal if the type has
13533 discriminant-dependent array components or a variant part, and the
13534 discriminants are not static. In addition, array and record aggregates are
13535 illegal in corresponding cases. Note that this restriction does not forbid
13536 access discriminants. It is often a good idea to combine this restriction
13537 with No_Secondary_Stack.
13539 @node No_Entry_Queue,No_Implementation_Aspect_Specifications,No_Dynamic_Sized_Objects,Program Unit Level Restrictions
13540 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{215}
13541 @subsection No_Entry_Queue
13544 @geindex No_Entry_Queue
13546 [GNAT] This restriction is a declaration that any protected entry compiled in
13547 the scope of the restriction has at most one task waiting on the entry
13548 at any one time, and so no queue is required.  This restriction is not
13549 checked at compile time.  A program execution is erroneous if an attempt
13550 is made to queue a second task on such an entry.
13552 @node No_Implementation_Aspect_Specifications,No_Implementation_Attributes,No_Entry_Queue,Program Unit Level Restrictions
13553 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{216}
13554 @subsection No_Implementation_Aspect_Specifications
13557 @geindex No_Implementation_Aspect_Specifications
13559 [RM 13.12.1] This restriction checks at compile time that no
13560 GNAT-defined aspects are present.  With this restriction, the only
13561 aspects that can be used are those defined in the Ada Reference Manual.
13563 @node No_Implementation_Attributes,No_Implementation_Identifiers,No_Implementation_Aspect_Specifications,Program Unit Level Restrictions
13564 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{217}
13565 @subsection No_Implementation_Attributes
13568 @geindex No_Implementation_Attributes
13570 [RM 13.12.1] This restriction checks at compile time that no
13571 GNAT-defined attributes are present.  With this restriction, the only
13572 attributes that can be used are those defined in the Ada Reference
13573 Manual.
13575 @node No_Implementation_Identifiers,No_Implementation_Pragmas,No_Implementation_Attributes,Program Unit Level Restrictions
13576 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{218}
13577 @subsection No_Implementation_Identifiers
13580 @geindex No_Implementation_Identifiers
13582 [RM 13.12.1] This restriction checks at compile time that no
13583 implementation-defined identifiers (marked with pragma Implementation_Defined)
13584 occur within language-defined packages.
13586 @node No_Implementation_Pragmas,No_Implementation_Restrictions,No_Implementation_Identifiers,Program Unit Level Restrictions
13587 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{219}
13588 @subsection No_Implementation_Pragmas
13591 @geindex No_Implementation_Pragmas
13593 [RM 13.12.1] This restriction checks at compile time that no
13594 GNAT-defined pragmas are present.  With this restriction, the only
13595 pragmas that can be used are those defined in the Ada Reference Manual.
13597 @node No_Implementation_Restrictions,No_Implementation_Units,No_Implementation_Pragmas,Program Unit Level Restrictions
13598 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{21a}
13599 @subsection No_Implementation_Restrictions
13602 @geindex No_Implementation_Restrictions
13604 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
13605 identifiers (other than @code{No_Implementation_Restrictions} itself)
13606 are present.  With this restriction, the only other restriction identifiers
13607 that can be used are those defined in the Ada Reference Manual.
13609 @node No_Implementation_Units,No_Implicit_Aliasing,No_Implementation_Restrictions,Program Unit Level Restrictions
13610 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{21b}
13611 @subsection No_Implementation_Units
13614 @geindex No_Implementation_Units
13616 [RM 13.12.1] This restriction checks at compile time that there is no
13617 mention in the context clause of any implementation-defined descendants
13618 of packages Ada, Interfaces, or System.
13620 @node No_Implicit_Aliasing,No_Implicit_Loops,No_Implementation_Units,Program Unit Level Restrictions
13621 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{21c}
13622 @subsection No_Implicit_Aliasing
13625 @geindex No_Implicit_Aliasing
13627 [GNAT] This restriction, which is not required to be partition-wide consistent,
13628 requires an explicit aliased keyword for an object to which ‘Access,
13629 ‘Unchecked_Access, or ‘Address is applied, and forbids entirely the use of
13630 the ‘Unrestricted_Access attribute for objects. Note: the reason that
13631 Unrestricted_Access is forbidden is that it would require the prefix
13632 to be aliased, and in such cases, it can always be replaced by
13633 the standard attribute Unchecked_Access which is preferable.
13635 @node No_Implicit_Loops,No_Obsolescent_Features,No_Implicit_Aliasing,Program Unit Level Restrictions
13636 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{21d}
13637 @subsection No_Implicit_Loops
13640 @geindex No_Implicit_Loops
13642 [GNAT] This restriction ensures that the generated code of the unit marked
13643 with this restriction does not contain any implicit @code{for} loops, either by
13644 modifying the generated code where possible, or by rejecting any construct
13645 that would otherwise generate an implicit @code{for} loop. If this restriction is
13646 active, it is possible to build large array aggregates with all static
13647 components without generating an intermediate temporary, and without generating
13648 a loop to initialize individual components. Otherwise, a loop is created for
13649 arrays larger than about 5000 scalar components. Note that if this restriction
13650 is set in the spec of a package, it will not apply to its body.
13652 @node No_Obsolescent_Features,No_Wide_Characters,No_Implicit_Loops,Program Unit Level Restrictions
13653 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{21e}
13654 @subsection No_Obsolescent_Features
13657 @geindex No_Obsolescent_Features
13659 [RM 13.12.1] This restriction checks at compile time that no obsolescent
13660 features are used, as defined in Annex J of the Ada Reference Manual.
13662 @node No_Wide_Characters,Static_Dispatch_Tables,No_Obsolescent_Features,Program Unit Level Restrictions
13663 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{21f}
13664 @subsection No_Wide_Characters
13667 @geindex No_Wide_Characters
13669 [GNAT] This restriction ensures at compile time that no uses of the types
13670 @code{Wide_Character} or @code{Wide_String} or corresponding wide
13671 wide types
13672 appear, and that no wide or wide wide string or character literals
13673 appear in the program (that is literals representing characters not in
13674 type @code{Character}).
13676 @node Static_Dispatch_Tables,SPARK_05,No_Wide_Characters,Program Unit Level Restrictions
13677 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{220}
13678 @subsection Static_Dispatch_Tables
13681 @geindex Static_Dispatch_Tables
13683 [GNAT] This restriction checks at compile time that all the artifacts
13684 associated with dispatch tables can be placed in read-only memory.
13686 @node SPARK_05,,Static_Dispatch_Tables,Program Unit Level Restrictions
13687 @anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{221}
13688 @subsection SPARK_05
13691 @geindex SPARK_05
13693 [GNAT] This restriction no longer has any effect and is superseded by
13694 SPARK 2014, whose restrictions are checked by the tool GNATprove. To check that
13695 a codebase respects SPARK 2014 restrictions, mark the code with pragma or
13696 aspect @code{SPARK_Mode}, and run the tool GNATprove at Stone assurance level, as
13697 follows:
13699 @example
13700 gnatprove -P project.gpr --mode=stone
13701 @end example
13703 or equivalently:
13705 @example
13706 gnatprove -P project.gpr --mode=check_all
13707 @end example
13709 @node Implementation Advice,Implementation Defined Characteristics,Standard and Implementation Defined Restrictions,Top
13710 @anchor{gnat_rm/implementation_advice doc}@anchor{222}@anchor{gnat_rm/implementation_advice id1}@anchor{223}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a}
13711 @chapter Implementation Advice
13714 The main text of the Ada Reference Manual describes the required
13715 behavior of all Ada compilers, and the GNAT compiler conforms to
13716 these requirements.
13718 In addition, there are sections throughout the Ada Reference Manual headed
13719 by the phrase ‘Implementation advice’.  These sections are not normative,
13720 i.e., they do not specify requirements that all compilers must
13721 follow.  Rather they provide advice on generally desirable behavior.
13722 They are not requirements, because they describe behavior that cannot
13723 be provided on all systems, or may be undesirable on some systems.
13725 As far as practical, GNAT follows the implementation advice in
13726 the Ada Reference Manual.  Each such RM section corresponds to a section
13727 in this chapter whose title specifies the
13728 RM section number and paragraph number and the subject of
13729 the advice.  The contents of each section consists of the RM text within
13730 quotation marks,
13731 followed by the GNAT interpretation of the advice.  Most often, this simply says
13732 ‘followed’, which means that GNAT follows the advice.  However, in a
13733 number of cases, GNAT deliberately deviates from this advice, in which
13734 case the text describes what GNAT does and why.
13736 @geindex Error detection
13738 @menu
13739 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection. 
13740 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units. 
13741 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors. 
13742 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas. 
13743 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas. 
13744 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets. 
13745 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types. 
13746 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types. 
13747 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values. 
13748 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types. 
13749 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays. 
13750 * RM 9.6(30-31); Duration’Small: RM 9 6 30-31 Duration’Small. 
13751 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation. 
13752 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information. 
13753 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks. 
13754 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses. 
13755 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types. 
13756 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses. 
13757 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses. 
13758 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses. 
13759 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses. 
13760 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses. 
13761 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses. 
13762 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses. 
13763 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes. 
13764 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering. 
13765 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private. 
13766 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations. 
13767 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion. 
13768 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage. 
13769 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation. 
13770 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes. 
13771 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types. 
13772 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling. 
13773 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling. 
13774 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation. 
13775 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate. 
13776 * RM A.18; Containers: RM A 18 Containers. 
13777 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export. 
13778 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces. 
13779 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C. 
13780 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL. 
13781 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran. 
13782 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations. 
13783 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations. 
13784 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support. 
13785 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers. 
13786 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts. 
13787 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements. 
13788 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names. 
13789 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes. 
13790 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies. 
13791 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies. 
13792 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort. 
13793 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions. 
13794 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time. 
13795 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem. 
13796 * RM F(7); COBOL Support: RM F 7 COBOL Support. 
13797 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support. 
13798 * RM G; Numerics: RM G Numerics. 
13799 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types. 
13800 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions. 
13801 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements. 
13802 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy. 
13803 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy. 
13805 @end menu
13807 @node RM 1 1 3 20 Error Detection,RM 1 1 3 31 Child Units,,Implementation Advice
13808 @anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{224}
13809 @section RM 1.1.3(20): Error Detection
13812 @quotation
13814 “If an implementation detects the use of an unsupported Specialized Needs
13815 Annex feature at run time, it should raise @code{Program_Error} if
13816 feasible.”
13817 @end quotation
13819 Not relevant.  All specialized needs annex features are either supported,
13820 or diagnosed at compile time.
13822 @geindex Child Units
13824 @node RM 1 1 3 31 Child Units,RM 1 1 5 12 Bounded Errors,RM 1 1 3 20 Error Detection,Implementation Advice
13825 @anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{225}
13826 @section RM 1.1.3(31): Child Units
13829 @quotation
13831 “If an implementation wishes to provide implementation-defined
13832 extensions to the functionality of a language-defined library unit, it
13833 should normally do so by adding children to the library unit.”
13834 @end quotation
13836 Followed.
13838 @geindex Bounded errors
13840 @node RM 1 1 5 12 Bounded Errors,RM 2 8 16 Pragmas,RM 1 1 3 31 Child Units,Implementation Advice
13841 @anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{226}
13842 @section RM 1.1.5(12): Bounded Errors
13845 @quotation
13847 “If an implementation detects a bounded error or erroneous
13848 execution, it should raise @code{Program_Error}.”
13849 @end quotation
13851 Followed in all cases in which the implementation detects a bounded
13852 error or erroneous execution.  Not all such situations are detected at
13853 runtime.
13855 @geindex Pragmas
13857 @node RM 2 8 16 Pragmas,RM 2 8 17-19 Pragmas,RM 1 1 5 12 Bounded Errors,Implementation Advice
13858 @anchor{gnat_rm/implementation_advice id2}@anchor{227}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{228}
13859 @section RM 2.8(16): Pragmas
13862 @quotation
13864 “Normally, implementation-defined pragmas should have no semantic effect
13865 for error-free programs; that is, if the implementation-defined pragmas
13866 are removed from a working program, the program should still be legal,
13867 and should still have the same semantics.”
13868 @end quotation
13870 The following implementation defined pragmas are exceptions to this
13871 rule:
13874 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxx} 
13875 @headitem
13877 Pragma
13879 @tab
13881 Explanation
13883 @item
13885 `Abort_Defer'
13887 @tab
13889 Affects semantics
13891 @item
13893 `Ada_83'
13895 @tab
13897 Affects legality
13899 @item
13901 `Assert'
13903 @tab
13905 Affects semantics
13907 @item
13909 `CPP_Class'
13911 @tab
13913 Affects semantics
13915 @item
13917 `CPP_Constructor'
13919 @tab
13921 Affects semantics
13923 @item
13925 `Debug'
13927 @tab
13929 Affects semantics
13931 @item
13933 `Interface_Name'
13935 @tab
13937 Affects semantics
13939 @item
13941 `Machine_Attribute'
13943 @tab
13945 Affects semantics
13947 @item
13949 `Unimplemented_Unit'
13951 @tab
13953 Affects legality
13955 @item
13957 `Unchecked_Union'
13959 @tab
13961 Affects semantics
13963 @end multitable
13966 In each of the above cases, it is essential to the purpose of the pragma
13967 that this advice not be followed.  For details see
13968 @ref{7,,Implementation Defined Pragmas}.
13970 @node RM 2 8 17-19 Pragmas,RM 3 5 2 5 Alternative Character Sets,RM 2 8 16 Pragmas,Implementation Advice
13971 @anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{229}
13972 @section RM 2.8(17-19): Pragmas
13975 @quotation
13977 “Normally, an implementation should not define pragmas that can
13978 make an illegal program legal, except as follows:
13981 @itemize *
13983 @item 
13984 A pragma used to complete a declaration, such as a pragma @code{Import};
13986 @item 
13987 A pragma used to configure the environment by adding, removing, or
13988 replacing @code{library_items}.”
13989 @end itemize
13990 @end quotation
13992 See @ref{228,,RM 2.8(16); Pragmas}.
13994 @geindex Character Sets
13996 @geindex Alternative Character Sets
13998 @node RM 3 5 2 5 Alternative Character Sets,RM 3 5 4 28 Integer Types,RM 2 8 17-19 Pragmas,Implementation Advice
13999 @anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{22a}
14000 @section RM 3.5.2(5): Alternative Character Sets
14003 @quotation
14005 “If an implementation supports a mode with alternative interpretations
14006 for @code{Character} and @code{Wide_Character}, the set of graphic
14007 characters of @code{Character} should nevertheless remain a proper
14008 subset of the set of graphic characters of @code{Wide_Character}.  Any
14009 character set ‘localizations’ should be reflected in the results of
14010 the subprograms defined in the language-defined package
14011 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
14012 an alternative interpretation of @code{Character}, the implementation should
14013 also support a corresponding change in what is a legal
14014 @code{identifier_letter}.”
14015 @end quotation
14017 Not all wide character modes follow this advice, in particular the JIS
14018 and IEC modes reflect standard usage in Japan, and in these encoding,
14019 the upper half of the Latin-1 set is not part of the wide-character
14020 subset, since the most significant bit is used for wide character
14021 encoding.  However, this only applies to the external forms.  Internally
14022 there is no such restriction.
14024 @geindex Integer types
14026 @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
14027 @anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{22b}
14028 @section RM 3.5.4(28): Integer Types
14031 @quotation
14033 “An implementation should support @code{Long_Integer} in addition to
14034 @code{Integer} if the target machine supports 32-bit (or longer)
14035 arithmetic.  No other named integer subtypes are recommended for package
14036 @code{Standard}.  Instead, appropriate named integer subtypes should be
14037 provided in the library package @code{Interfaces} (see B.2).”
14038 @end quotation
14040 @code{Long_Integer} is supported.  Other standard integer types are supported
14041 so this advice is not fully followed.  These types
14042 are supported for convenient interface to C, and so that all hardware
14043 types of the machine are easily available.
14045 @node RM 3 5 4 29 Integer Types,RM 3 5 5 8 Enumeration Values,RM 3 5 4 28 Integer Types,Implementation Advice
14046 @anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{22c}
14047 @section RM 3.5.4(29): Integer Types
14050 @quotation
14052 “An implementation for a two’s complement machine should support
14053 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
14054 implementation should support a non-binary modules up to @code{Integer'Last}.”
14055 @end quotation
14057 Followed.
14059 @geindex Enumeration values
14061 @node RM 3 5 5 8 Enumeration Values,RM 3 5 7 17 Float Types,RM 3 5 4 29 Integer Types,Implementation Advice
14062 @anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{22d}
14063 @section RM 3.5.5(8): Enumeration Values
14066 @quotation
14068 “For the evaluation of a call on @code{S'Pos} for an enumeration
14069 subtype, if the value of the operand does not correspond to the internal
14070 code for any enumeration literal of its type (perhaps due to an
14071 un-initialized variable), then the implementation should raise
14072 @code{Program_Error}.  This is particularly important for enumeration
14073 types with noncontiguous internal codes specified by an
14074 enumeration_representation_clause.”
14075 @end quotation
14077 Followed.
14079 @geindex Float types
14081 @node RM 3 5 7 17 Float Types,RM 3 6 2 11 Multidimensional Arrays,RM 3 5 5 8 Enumeration Values,Implementation Advice
14082 @anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{22e}
14083 @section RM 3.5.7(17): Float Types
14086 @quotation
14088 “An implementation should support @code{Long_Float} in addition to
14089 @code{Float} if the target machine supports 11 or more digits of
14090 precision.  No other named floating point subtypes are recommended for
14091 package @code{Standard}.  Instead, appropriate named floating point subtypes
14092 should be provided in the library package @code{Interfaces} (see B.2).”
14093 @end quotation
14095 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
14096 former provides improved compatibility with other implementations
14097 supporting this type.  The latter corresponds to the highest precision
14098 floating-point type supported by the hardware.  On most machines, this
14099 will be the same as @code{Long_Float}, but on some machines, it will
14100 correspond to the IEEE extended form.  The notable case is all x86
14101 implementations, where @code{Long_Long_Float} corresponds to the 80-bit
14102 extended precision format supported in hardware on this processor.
14103 Note that the 128-bit format on SPARC is not supported, since this
14104 is a software rather than a hardware format.
14106 @geindex Multidimensional arrays
14108 @geindex Arrays
14109 @geindex multidimensional
14111 @node RM 3 6 2 11 Multidimensional Arrays,RM 9 6 30-31 Duration’Small,RM 3 5 7 17 Float Types,Implementation Advice
14112 @anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{22f}
14113 @section RM 3.6.2(11): Multidimensional Arrays
14116 @quotation
14118 “An implementation should normally represent multidimensional arrays in
14119 row-major order, consistent with the notation used for multidimensional
14120 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
14121 (@code{Fortran}, …) applies to a multidimensional array type, then
14122 column-major order should be used instead (see B.5, `Interfacing with Fortran').”
14123 @end quotation
14125 Followed.
14127 @geindex Duration'Small
14129 @node RM 9 6 30-31 Duration’Small,RM 10 2 1 12 Consistent Representation,RM 3 6 2 11 Multidimensional Arrays,Implementation Advice
14130 @anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{230}
14131 @section RM 9.6(30-31): Duration’Small
14134 @quotation
14136 “Whenever possible in an implementation, the value of @code{Duration'Small}
14137 should be no greater than 100 microseconds.”
14138 @end quotation
14140 Followed.  (@code{Duration'Small} = 10**(-9)).
14142 @quotation
14144 “The time base for @code{delay_relative_statements} should be monotonic;
14145 it need not be the same time base as used for @code{Calendar.Clock}.”
14146 @end quotation
14148 Followed.
14150 @node RM 10 2 1 12 Consistent Representation,RM 11 4 1 19 Exception Information,RM 9 6 30-31 Duration’Small,Implementation Advice
14151 @anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{231}
14152 @section RM 10.2.1(12): Consistent Representation
14155 @quotation
14157 “In an implementation, a type declared in a pre-elaborated package should
14158 have the same representation in every elaboration of a given version of
14159 the package, whether the elaborations occur in distinct executions of
14160 the same program, or in executions of distinct programs or partitions
14161 that include the given version.”
14162 @end quotation
14164 Followed, except in the case of tagged types.  Tagged types involve
14165 implicit pointers to a local copy of a dispatch table, and these pointers
14166 have representations which thus depend on a particular elaboration of the
14167 package.  It is not easy to see how it would be possible to follow this
14168 advice without severely impacting efficiency of execution.
14170 @geindex Exception information
14172 @node RM 11 4 1 19 Exception Information,RM 11 5 28 Suppression of Checks,RM 10 2 1 12 Consistent Representation,Implementation Advice
14173 @anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{232}
14174 @section RM 11.4.1(19): Exception Information
14177 @quotation
14179 “@code{Exception_Message} by default and @code{Exception_Information}
14180 should produce information useful for
14181 debugging.  @code{Exception_Message} should be short, about one
14182 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
14183 should not include the
14184 @code{Exception_Name}.  @code{Exception_Information} should include both
14185 the @code{Exception_Name} and the @code{Exception_Message}.”
14186 @end quotation
14188 Followed.  For each exception that doesn’t have a specified
14189 @code{Exception_Message}, the compiler generates one containing the location
14190 of the raise statement.  This location has the form ‘file_name:line’, where
14191 file_name is the short file name (without path information) and line is the line
14192 number in the file.  Note that in the case of the Zero Cost Exception
14193 mechanism, these messages become redundant with the Exception_Information that
14194 contains a full backtrace of the calling sequence, so they are disabled.
14195 To disable explicitly the generation of the source location message, use the
14196 Pragma @code{Discard_Names}.
14198 @geindex Suppression of checks
14200 @geindex Checks
14201 @geindex suppression of
14203 @node RM 11 5 28 Suppression of Checks,RM 13 1 21-24 Representation Clauses,RM 11 4 1 19 Exception Information,Implementation Advice
14204 @anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{233}
14205 @section RM 11.5(28): Suppression of Checks
14208 @quotation
14210 “The implementation should minimize the code executed for checks that
14211 have been suppressed.”
14212 @end quotation
14214 Followed.
14216 @geindex Representation clauses
14218 @node RM 13 1 21-24 Representation Clauses,RM 13 2 6-8 Packed Types,RM 11 5 28 Suppression of Checks,Implementation Advice
14219 @anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{234}
14220 @section RM 13.1 (21-24): Representation Clauses
14223 @quotation
14225 “The recommended level of support for all representation items is
14226 qualified as follows:
14228 An implementation need not support representation items containing
14229 nonstatic expressions, except that an implementation should support a
14230 representation item for a given entity if each nonstatic expression in
14231 the representation item is a name that statically denotes a constant
14232 declared before the entity.”
14233 @end quotation
14235 Followed.  In fact, GNAT goes beyond the recommended level of support
14236 by allowing nonstatic expressions in some representation clauses even
14237 without the need to declare constants initialized with the values of
14238 such expressions.
14239 For example:
14241 @example
14242   X : Integer;
14243   Y : Float;
14244   for Y'Address use X'Address;>>
14247 "An implementation need not support a specification for the `@w{`}Size`@w{`}
14248 for a given composite subtype, nor the size or storage place for an
14249 object (including a component) of a given composite subtype, unless the
14250 constraints on the subtype and its composite subcomponents (if any) are
14251 all static constraints."
14252 @end example
14254 Followed.  Size Clauses are not permitted on nonstatic components, as
14255 described above.
14257 @quotation
14259 “An aliased component, or a component whose type is by-reference, should
14260 always be allocated at an addressable location.”
14261 @end quotation
14263 Followed.
14265 @geindex Packed types
14267 @node RM 13 2 6-8 Packed Types,RM 13 3 14-19 Address Clauses,RM 13 1 21-24 Representation Clauses,Implementation Advice
14268 @anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{235}
14269 @section RM 13.2(6-8): Packed Types
14272 @quotation
14274 “If a type is packed, then the implementation should try to minimize
14275 storage allocated to objects of the type, possibly at the expense of
14276 speed of accessing components, subject to reasonable complexity in
14277 addressing calculations.
14279 The recommended level of support pragma @code{Pack} is:
14281 For a packed record type, the components should be packed as tightly as
14282 possible subject to the Sizes of the component subtypes, and subject to
14283 any `record_representation_clause' that applies to the type; the
14284 implementation may, but need not, reorder components or cross aligned
14285 word boundaries to improve the packing.  A component whose @code{Size} is
14286 greater than the word size may be allocated an integral number of words.”
14287 @end quotation
14289 Followed.  Tight packing of arrays is supported for all component sizes
14290 up to 64-bits. If the array component size is 1 (that is to say, if
14291 the component is a boolean type or an enumeration type with two values)
14292 then values of the type are implicitly initialized to zero. This
14293 happens both for objects of the packed type, and for objects that have a
14294 subcomponent of the packed type.
14296 @geindex Address clauses
14298 @node RM 13 3 14-19 Address Clauses,RM 13 3 29-35 Alignment Clauses,RM 13 2 6-8 Packed Types,Implementation Advice
14299 @anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{236}
14300 @section RM 13.3(14-19): Address Clauses
14303 @quotation
14305 “For an array @code{X}, @code{X'Address} should point at the first
14306 component of the array, and not at the array bounds.”
14307 @end quotation
14309 Followed.
14311 @quotation
14313 “The recommended level of support for the @code{Address} attribute is:
14315 @code{X'Address} should produce a useful result if @code{X} is an
14316 object that is aliased or of a by-reference type, or is an entity whose
14317 @code{Address} has been specified.”
14318 @end quotation
14320 Followed.  A valid address will be produced even if none of those
14321 conditions have been met.  If necessary, the object is forced into
14322 memory to ensure the address is valid.
14324 @quotation
14326 “An implementation should support @code{Address} clauses for imported
14327 subprograms.”
14328 @end quotation
14330 Followed.
14332 @quotation
14334 “Objects (including subcomponents) that are aliased or of a by-reference
14335 type should be allocated on storage element boundaries.”
14336 @end quotation
14338 Followed.
14340 @quotation
14342 “If the @code{Address} of an object is specified, or it is imported or exported,
14343 then the implementation should not perform optimizations based on
14344 assumptions of no aliases.”
14345 @end quotation
14347 Followed.
14349 @geindex Alignment clauses
14351 @node RM 13 3 29-35 Alignment Clauses,RM 13 3 42-43 Size Clauses,RM 13 3 14-19 Address Clauses,Implementation Advice
14352 @anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{237}
14353 @section RM 13.3(29-35): Alignment Clauses
14356 @quotation
14358 “The recommended level of support for the @code{Alignment} attribute for
14359 subtypes is:
14361 An implementation should support specified Alignments that are factors
14362 and multiples of the number of storage elements per word, subject to the
14363 following:”
14364 @end quotation
14366 Followed.
14368 @quotation
14370 “An implementation need not support specified Alignments for
14371 combinations of Sizes and Alignments that cannot be easily
14372 loaded and stored by available machine instructions.”
14373 @end quotation
14375 Followed.
14377 @quotation
14379 “An implementation need not support specified Alignments that are
14380 greater than the maximum @code{Alignment} the implementation ever returns by
14381 default.”
14382 @end quotation
14384 Followed.
14386 @quotation
14388 “The recommended level of support for the @code{Alignment} attribute for
14389 objects is:
14391 Same as above, for subtypes, but in addition:”
14392 @end quotation
14394 Followed.
14396 @quotation
14398 “For stand-alone library-level objects of statically constrained
14399 subtypes, the implementation should support all alignments
14400 supported by the target linker.  For example, page alignment is likely to
14401 be supported for such objects, but not for subtypes.”
14402 @end quotation
14404 Followed.
14406 @geindex Size clauses
14408 @node RM 13 3 42-43 Size Clauses,RM 13 3 50-56 Size Clauses,RM 13 3 29-35 Alignment Clauses,Implementation Advice
14409 @anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{238}
14410 @section RM 13.3(42-43): Size Clauses
14413 @quotation
14415 “The recommended level of support for the @code{Size} attribute of
14416 objects is:
14418 A @code{Size} clause should be supported for an object if the specified
14419 @code{Size} is at least as large as its subtype’s @code{Size}, and
14420 corresponds to a size in storage elements that is a multiple of the
14421 object’s @code{Alignment} (if the @code{Alignment} is nonzero).”
14422 @end quotation
14424 Followed.
14426 @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
14427 @anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{239}
14428 @section RM 13.3(50-56): Size Clauses
14431 @quotation
14433 “If the @code{Size} of a subtype is specified, and allows for efficient
14434 independent addressability (see 9.10) on the target architecture, then
14435 the @code{Size} of the following objects of the subtype should equal the
14436 @code{Size} of the subtype:
14438 Aliased objects (including components).”
14439 @end quotation
14441 Followed.
14443 @quotation
14445 “@cite{Size} clause on a composite subtype should not affect the
14446 internal layout of components.”
14447 @end quotation
14449 Followed. But note that this can be overridden by use of the implementation
14450 pragma Implicit_Packing in the case of packed arrays.
14452 @quotation
14454 “The recommended level of support for the @code{Size} attribute of subtypes is:
14456 The @code{Size} (if not specified) of a static discrete or fixed point
14457 subtype should be the number of bits needed to represent each value
14458 belonging to the subtype using an unbiased representation, leaving space
14459 for a sign bit only if the subtype contains negative values.  If such a
14460 subtype is a first subtype, then an implementation should support a
14461 specified @code{Size} for it that reflects this representation.”
14462 @end quotation
14464 Followed.
14466 @quotation
14468 “For a subtype implemented with levels of indirection, the @code{Size}
14469 should include the size of the pointers, but not the size of what they
14470 point at.”
14471 @end quotation
14473 Followed.
14475 @geindex Component_Size clauses
14477 @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
14478 @anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{23a}
14479 @section RM 13.3(71-73): Component Size Clauses
14482 @quotation
14484 “The recommended level of support for the @code{Component_Size}
14485 attribute is:
14487 An implementation need not support specified @code{Component_Sizes} that are
14488 less than the @code{Size} of the component subtype.”
14489 @end quotation
14491 Followed.
14493 @quotation
14495 “An implementation should support specified Component_Sizes that
14496 are factors and multiples of the word size.  For such
14497 Component_Sizes, the array should contain no gaps between
14498 components.  For other Component_Sizes (if supported), the array
14499 should contain no gaps between components when packing is also
14500 specified; the implementation should forbid this combination in cases
14501 where it cannot support a no-gaps representation.”
14502 @end quotation
14504 Followed.
14506 @geindex Enumeration representation clauses
14508 @geindex Representation clauses
14509 @geindex enumeration
14511 @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
14512 @anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{23b}
14513 @section RM 13.4(9-10): Enumeration Representation Clauses
14516 @quotation
14518 “The recommended level of support for enumeration representation clauses
14521 An implementation need not support enumeration representation clauses
14522 for boolean types, but should at minimum support the internal codes in
14523 the range @code{System.Min_Int .. System.Max_Int}.”
14524 @end quotation
14526 Followed.
14528 @geindex Record representation clauses
14530 @geindex Representation clauses
14531 @geindex records
14533 @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
14534 @anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{23c}
14535 @section RM 13.5.1(17-22): Record Representation Clauses
14538 @quotation
14540 “The recommended level of support for
14541 `record_representation_clause's is:
14543 An implementation should support storage places that can be extracted
14544 with a load, mask, shift sequence of machine code, and set with a load,
14545 shift, mask, store sequence, given the available machine instructions
14546 and run-time model.”
14547 @end quotation
14549 Followed.
14551 @quotation
14553 “A storage place should be supported if its size is equal to the
14554 @code{Size} of the component subtype, and it starts and ends on a
14555 boundary that obeys the @code{Alignment} of the component subtype.”
14556 @end quotation
14558 Followed.
14560 @quotation
14562 “If the default bit ordering applies to the declaration of a given type,
14563 then for a component whose subtype’s @code{Size} is less than the word
14564 size, any storage place that does not cross an aligned word boundary
14565 should be supported.”
14566 @end quotation
14568 Followed.
14570 @quotation
14572 “An implementation may reserve a storage place for the tag field of a
14573 tagged type, and disallow other components from overlapping that place.”
14574 @end quotation
14576 Followed.  The storage place for the tag field is the beginning of the tagged
14577 record, and its size is Address’Size.  GNAT will reject an explicit component
14578 clause for the tag field.
14580 @quotation
14582 “An implementation need not support a `component_clause' for a
14583 component of an extension part if the storage place is not after the
14584 storage places of all components of the parent type, whether or not
14585 those storage places had been specified.”
14586 @end quotation
14588 Followed.  The above advice on record representation clauses is followed,
14589 and all mentioned features are implemented.
14591 @geindex Storage place attributes
14593 @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
14594 @anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{23d}
14595 @section RM 13.5.2(5): Storage Place Attributes
14598 @quotation
14600 “If a component is represented using some form of pointer (such as an
14601 offset) to the actual data of the component, and this data is contiguous
14602 with the rest of the object, then the storage place attributes should
14603 reflect the place of the actual data, not the pointer.  If a component is
14604 allocated discontinuously from the rest of the object, then a warning
14605 should be generated upon reference to one of its storage place
14606 attributes.”
14607 @end quotation
14609 Followed.  There are no such components in GNAT.
14611 @geindex Bit ordering
14613 @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
14614 @anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{23e}
14615 @section RM 13.5.3(7-8): Bit Ordering
14618 @quotation
14620 “The recommended level of support for the non-default bit ordering is:
14622 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
14623 should support the non-default bit ordering in addition to the default
14624 bit ordering.”
14625 @end quotation
14627 Followed.  Word size does not equal storage size in this implementation.
14628 Thus non-default bit ordering is not supported.
14630 @geindex Address
14631 @geindex as private type
14633 @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
14634 @anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{23f}
14635 @section RM 13.7(37): Address as Private
14638 @quotation
14640 “@cite{Address} should be of a private type.”
14641 @end quotation
14643 Followed.
14645 @geindex Operations
14646 @geindex on `@w{`}Address`@w{`}
14648 @geindex Address
14649 @geindex operations of
14651 @node RM 13 7 1 16 Address Operations,RM 13 9 14-17 Unchecked Conversion,RM 13 7 37 Address as Private,Implementation Advice
14652 @anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{240}
14653 @section RM 13.7.1(16): Address Operations
14656 @quotation
14658 “Operations in @code{System} and its children should reflect the target
14659 environment semantics as closely as is reasonable.  For example, on most
14660 machines, it makes sense for address arithmetic to ‘wrap around’.
14661 Operations that do not make sense should raise @code{Program_Error}.”
14662 @end quotation
14664 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
14665 operation raises @code{Program_Error}, since all operations make sense.
14667 @geindex Unchecked conversion
14669 @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
14670 @anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{241}
14671 @section RM 13.9(14-17): Unchecked Conversion
14674 @quotation
14676 “The @code{Size} of an array object should not include its bounds; hence,
14677 the bounds should not be part of the converted data.”
14678 @end quotation
14680 Followed.
14682 @quotation
14684 “The implementation should not generate unnecessary run-time checks to
14685 ensure that the representation of @code{S} is a representation of the
14686 target type.  It should take advantage of the permission to return by
14687 reference when possible.  Restrictions on unchecked conversions should be
14688 avoided unless required by the target environment.”
14689 @end quotation
14691 Followed.  There are no restrictions on unchecked conversion.  A warning is
14692 generated if the source and target types do not have the same size since
14693 the semantics in this case may be target dependent.
14695 @quotation
14697 “The recommended level of support for unchecked conversions is:
14699 Unchecked conversions should be supported and should be reversible in
14700 the cases where this clause defines the result.  To enable meaningful use
14701 of unchecked conversion, a contiguous representation should be used for
14702 elementary subtypes, for statically constrained array subtypes whose
14703 component subtype is one of the subtypes described in this paragraph,
14704 and for record subtypes without discriminants whose component subtypes
14705 are described in this paragraph.”
14706 @end quotation
14708 Followed.
14710 @geindex Heap usage
14711 @geindex implicit
14713 @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
14714 @anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{242}
14715 @section RM 13.11(23-25): Implicit Heap Usage
14718 @quotation
14720 “An implementation should document any cases in which it dynamically
14721 allocates heap storage for a purpose other than the evaluation of an
14722 allocator.”
14723 @end quotation
14725 Followed, the only other points at which heap storage is dynamically
14726 allocated are as follows:
14729 @itemize *
14731 @item 
14732 At initial elaboration time, to allocate dynamically sized global
14733 objects.
14735 @item 
14736 To allocate space for a task when a task is created.
14738 @item 
14739 To extend the secondary stack dynamically when needed.  The secondary
14740 stack is used for returning variable length results.
14741 @end itemize
14744 @quotation
14746 “A default (implementation-provided) storage pool for an
14747 access-to-constant type should not have overhead to support deallocation of
14748 individual objects.”
14749 @end quotation
14751 Followed.
14753 @quotation
14755 “A storage pool for an anonymous access type should be created at the
14756 point of an allocator for the type, and be reclaimed when the designated
14757 object becomes inaccessible.”
14758 @end quotation
14760 Followed.
14762 @geindex Unchecked deallocation
14764 @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
14765 @anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{243}
14766 @section RM 13.11.2(17): Unchecked Deallocation
14769 @quotation
14771 “For a standard storage pool, @code{Free} should actually reclaim the
14772 storage.”
14773 @end quotation
14775 Followed.
14777 @geindex Stream oriented attributes
14779 @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
14780 @anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{244}
14781 @section RM 13.13.2(1.6): Stream Oriented Attributes
14784 @quotation
14786 “If not specified, the value of Stream_Size for an elementary type
14787 should be the number of bits that corresponds to the minimum number of
14788 stream elements required by the first subtype of the type, rounded up
14789 to the nearest factor or multiple of the word size that is also a
14790 multiple of the stream element size.”
14791 @end quotation
14793 Followed, except that the number of stream elements is 1, 2, 3, 4 or 8.
14794 The Stream_Size may be used to override the default choice.
14796 The default implementation is based on direct binary representations and is
14797 therefore target- and endianness-dependent.  To address this issue, GNAT also
14798 supplies an alternate implementation of the stream attributes @code{Read} and
14799 @code{Write}, which uses the target-independent XDR standard representation for
14800 scalar types. This XDR alternative can be enabled via the binder switch -xdr.
14802 @geindex XDR representation
14804 @geindex Read attribute
14806 @geindex Write attribute
14808 @geindex Stream oriented attributes
14810 @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
14811 @anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{245}
14812 @section RM A.1(52): Names of Predefined Numeric Types
14815 @quotation
14817 “If an implementation provides additional named predefined integer types,
14818 then the names should end with @code{Integer} as in
14819 @code{Long_Integer}.  If an implementation provides additional named
14820 predefined floating point types, then the names should end with
14821 @code{Float} as in @code{Long_Float}.”
14822 @end quotation
14824 Followed.
14826 @geindex Ada.Characters.Handling
14828 @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
14829 @anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{246}
14830 @section RM A.3.2(49): @code{Ada.Characters.Handling}
14833 @quotation
14835 “If an implementation provides a localized definition of @code{Character}
14836 or @code{Wide_Character}, then the effects of the subprograms in
14837 @code{Characters.Handling} should reflect the localizations.
14838 See also 3.5.2.”
14839 @end quotation
14841 Followed.  GNAT provides no such localized definitions.
14843 @geindex Bounded-length strings
14845 @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
14846 @anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{247}
14847 @section RM A.4.4(106): Bounded-Length String Handling
14850 @quotation
14852 “Bounded string objects should not be implemented by implicit pointers
14853 and dynamic allocation.”
14854 @end quotation
14856 Followed.  No implicit pointers or dynamic allocation are used.
14858 @geindex Random number generation
14860 @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
14861 @anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{248}
14862 @section RM A.5.2(46-47): Random Number Generation
14865 @quotation
14867 “Any storage associated with an object of type @code{Generator} should be
14868 reclaimed on exit from the scope of the object.”
14869 @end quotation
14871 Followed.
14873 @quotation
14875 “If the generator period is sufficiently long in relation to the number
14876 of distinct initiator values, then each possible value of
14877 @code{Initiator} passed to @code{Reset} should initiate a sequence of
14878 random numbers that does not, in a practical sense, overlap the sequence
14879 initiated by any other value.  If this is not possible, then the mapping
14880 between initiator values and generator states should be a rapidly
14881 varying function of the initiator value.”
14882 @end quotation
14884 Followed.  The generator period is sufficiently long for the first
14885 condition here to hold true.
14887 @geindex Get_Immediate
14889 @node RM A 10 7 23 Get_Immediate,RM A 18 Containers,RM A 5 2 46-47 Random Number Generation,Implementation Advice
14890 @anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{249}
14891 @section RM A.10.7(23): @code{Get_Immediate}
14894 @quotation
14896 “The @code{Get_Immediate} procedures should be implemented with
14897 unbuffered input.  For a device such as a keyboard, input should be
14898 available if a key has already been typed, whereas for a disk
14899 file, input should always be available except at end of file.  For a file
14900 associated with a keyboard-like device, any line-editing features of the
14901 underlying operating system should be disabled during the execution of
14902 @code{Get_Immediate}.”
14903 @end quotation
14905 Followed on all targets except VxWorks. For VxWorks, there is no way to
14906 provide this functionality that does not result in the input buffer being
14907 flushed before the @code{Get_Immediate} call. A special unit
14908 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
14909 this functionality.
14911 @geindex Containers
14913 @node RM A 18 Containers,RM B 1 39-41 Pragma Export,RM A 10 7 23 Get_Immediate,Implementation Advice
14914 @anchor{gnat_rm/implementation_advice rm-a-18-containers}@anchor{24a}
14915 @section RM A.18: @code{Containers}
14918 All implementation advice pertaining to Ada.Containers and its
14919 child units (that is, all implementation advice occurring within
14920 section A.18 and its subsections) is followed except for A.18.24(17):
14922 @quotation
14924 “Bounded ordered set objects should be implemented without implicit pointers or dynamic allocation. “
14925 @end quotation
14927 The implementations of the two Reference_Preserving_Key functions of
14928 the generic package Ada.Containers.Bounded_Ordered_Sets each currently make
14929 use of dynamic allocation; other operations on bounded ordered set objects
14930 follow the implementation advice.
14932 @geindex Export
14934 @node RM B 1 39-41 Pragma Export,RM B 2 12-13 Package Interfaces,RM A 18 Containers,Implementation Advice
14935 @anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{24b}
14936 @section RM B.1(39-41): Pragma @code{Export}
14939 @quotation
14941 “If an implementation supports pragma @code{Export} to a given language,
14942 then it should also allow the main subprogram to be written in that
14943 language.  It should support some mechanism for invoking the elaboration
14944 of the Ada library units included in the system, and for invoking the
14945 finalization of the environment task.  On typical systems, the
14946 recommended mechanism is to provide two subprograms whose link names are
14947 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
14948 elaboration code for library units.  @code{adafinal} should contain the
14949 finalization code.  These subprograms should have no effect the second
14950 and subsequent time they are called.”
14951 @end quotation
14953 Followed.
14955 @quotation
14957 “Automatic elaboration of pre-elaborated packages should be
14958 provided when pragma @code{Export} is supported.”
14959 @end quotation
14961 Followed when the main program is in Ada.  If the main program is in a
14962 foreign language, then
14963 @code{adainit} must be called to elaborate pre-elaborated
14964 packages.
14966 @quotation
14968 “For each supported convention `L' other than @code{Intrinsic}, an
14969 implementation should support @code{Import} and @code{Export} pragmas
14970 for objects of `L'-compatible types and for subprograms, and pragma
14971 @cite{Convention} for `L'-eligible types and for subprograms,
14972 presuming the other language has corresponding features.  Pragma
14973 @code{Convention} need not be supported for scalar types.”
14974 @end quotation
14976 Followed.
14978 @geindex Package Interfaces
14980 @geindex Interfaces
14982 @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
14983 @anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{24c}
14984 @section RM B.2(12-13): Package @code{Interfaces}
14987 @quotation
14989 “For each implementation-defined convention identifier, there should be a
14990 child package of package Interfaces with the corresponding name.  This
14991 package should contain any declarations that would be useful for
14992 interfacing to the language (implementation) represented by the
14993 convention.  Any declarations useful for interfacing to any language on
14994 the given hardware architecture should be provided directly in
14995 @code{Interfaces}.”
14996 @end quotation
14998 Followed.
15000 @quotation
15002 “An implementation supporting an interface to C, COBOL, or Fortran should
15003 provide the corresponding package or packages described in the following
15004 clauses.”
15005 @end quotation
15007 Followed.  GNAT provides all the packages described in this section.
15009 @geindex C
15010 @geindex interfacing with
15012 @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
15013 @anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{24d}
15014 @section RM B.3(63-71): Interfacing with C
15017 @quotation
15019 “An implementation should support the following interface correspondences
15020 between Ada and C.”
15021 @end quotation
15023 Followed.
15025 @quotation
15027 “An Ada procedure corresponds to a void-returning C function.”
15028 @end quotation
15030 Followed.
15032 @quotation
15034 “An Ada function corresponds to a non-void C function.”
15035 @end quotation
15037 Followed.
15039 @quotation
15041 “An Ada @code{in} scalar parameter is passed as a scalar argument to a C
15042 function.”
15043 @end quotation
15045 Followed.
15047 @quotation
15049 “An Ada @code{in} parameter of an access-to-object type with designated
15050 type @code{T} is passed as a @code{t*} argument to a C function,
15051 where @code{t} is the C type corresponding to the Ada type @code{T}.”
15052 @end quotation
15054 Followed.
15056 @quotation
15058 “An Ada access @code{T} parameter, or an Ada @code{out} or @code{in out}
15059 parameter of an elementary type @code{T}, is passed as a @code{t*}
15060 argument to a C function, where @code{t} is the C type corresponding to
15061 the Ada type @code{T}.  In the case of an elementary @code{out} or
15062 @code{in out} parameter, a pointer to a temporary copy is used to
15063 preserve by-copy semantics.”
15064 @end quotation
15066 Followed.
15068 @quotation
15070 “An Ada parameter of a record type @code{T}, of any mode, is passed as a
15071 @code{t*} argument to a C function, where @code{t} is the C
15072 structure corresponding to the Ada type @code{T}.”
15073 @end quotation
15075 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
15076 pragma, or Convention, or by explicitly specifying the mechanism for a given
15077 call using an extended import or export pragma.
15079 @quotation
15081 “An Ada parameter of an array type with component type @code{T}, of any
15082 mode, is passed as a @code{t*} argument to a C function, where
15083 @code{t} is the C type corresponding to the Ada type @code{T}.”
15084 @end quotation
15086 Followed.
15088 @quotation
15090 “An Ada parameter of an access-to-subprogram type is passed as a pointer
15091 to a C function whose prototype corresponds to the designated
15092 subprogram’s specification.”
15093 @end quotation
15095 Followed.
15097 @geindex COBOL
15098 @geindex interfacing with
15100 @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
15101 @anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{24e}
15102 @section RM B.4(95-98): Interfacing with COBOL
15105 @quotation
15107 “An Ada implementation should support the following interface
15108 correspondences between Ada and COBOL.”
15109 @end quotation
15111 Followed.
15113 @quotation
15115 “An Ada access @code{T} parameter is passed as a @code{BY REFERENCE} data item of
15116 the COBOL type corresponding to @code{T}.”
15117 @end quotation
15119 Followed.
15121 @quotation
15123 “An Ada in scalar parameter is passed as a @code{BY CONTENT} data item of
15124 the corresponding COBOL type.”
15125 @end quotation
15127 Followed.
15129 @quotation
15131 “Any other Ada parameter is passed as a @code{BY REFERENCE} data item of the
15132 COBOL type corresponding to the Ada parameter type; for scalars, a local
15133 copy is used if necessary to ensure by-copy semantics.”
15134 @end quotation
15136 Followed.
15138 @geindex Fortran
15139 @geindex interfacing with
15141 @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
15142 @anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{24f}
15143 @section RM B.5(22-26): Interfacing with Fortran
15146 @quotation
15148 “An Ada implementation should support the following interface
15149 correspondences between Ada and Fortran:”
15150 @end quotation
15152 Followed.
15154 @quotation
15156 “An Ada procedure corresponds to a Fortran subroutine.”
15157 @end quotation
15159 Followed.
15161 @quotation
15163 “An Ada function corresponds to a Fortran function.”
15164 @end quotation
15166 Followed.
15168 @quotation
15170 “An Ada parameter of an elementary, array, or record type @code{T} is
15171 passed as a @code{T} argument to a Fortran procedure, where @code{T} is
15172 the Fortran type corresponding to the Ada type @code{T}, and where the
15173 INTENT attribute of the corresponding dummy argument matches the Ada
15174 formal parameter mode; the Fortran implementation’s parameter passing
15175 conventions are used.  For elementary types, a local copy is used if
15176 necessary to ensure by-copy semantics.”
15177 @end quotation
15179 Followed.
15181 @quotation
15183 “An Ada parameter of an access-to-subprogram type is passed as a
15184 reference to a Fortran procedure whose interface corresponds to the
15185 designated subprogram’s specification.”
15186 @end quotation
15188 Followed.
15190 @geindex Machine operations
15192 @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
15193 @anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{250}
15194 @section RM C.1(3-5): Access to Machine Operations
15197 @quotation
15199 “The machine code or intrinsic support should allow access to all
15200 operations normally available to assembly language programmers for the
15201 target environment, including privileged instructions, if any.”
15202 @end quotation
15204 Followed.
15206 @quotation
15208 “The interfacing pragmas (see Annex B) should support interface to
15209 assembler; the default assembler should be associated with the
15210 convention identifier @code{Assembler}.”
15211 @end quotation
15213 Followed.
15215 @quotation
15217 “If an entity is exported to assembly language, then the implementation
15218 should allocate it at an addressable location, and should ensure that it
15219 is retained by the linking process, even if not otherwise referenced
15220 from the Ada code.  The implementation should assume that any call to a
15221 machine code or assembler subprogram is allowed to read or update every
15222 object that is specified as exported.”
15223 @end quotation
15225 Followed.
15227 @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
15228 @anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{251}
15229 @section RM C.1(10-16): Access to Machine Operations
15232 @quotation
15234 “The implementation should ensure that little or no overhead is
15235 associated with calling intrinsic and machine-code subprograms.”
15236 @end quotation
15238 Followed for both intrinsics and machine-code subprograms.
15240 @quotation
15242 “It is recommended that intrinsic subprograms be provided for convenient
15243 access to any machine operations that provide special capabilities or
15244 efficiency and that are not otherwise available through the language
15245 constructs.”
15246 @end quotation
15248 Followed.  A full set of machine operation intrinsic subprograms is provided.
15250 @quotation
15252 “Atomic read-modify-write operations—e.g., test and set, compare and
15253 swap, decrement and test, enqueue/dequeue.”
15254 @end quotation
15256 Followed on any target supporting such operations.
15258 @quotation
15260 “Standard numeric functions—e.g.:, sin, log.”
15261 @end quotation
15263 Followed on any target supporting such operations.
15265 @quotation
15267 “String manipulation operations—e.g.:, translate and test.”
15268 @end quotation
15270 Followed on any target supporting such operations.
15272 @quotation
15274 “Vector operations—e.g.:, compare vector against thresholds.”
15275 @end quotation
15277 Followed on any target supporting such operations.
15279 @quotation
15281 “Direct operations on I/O ports.”
15282 @end quotation
15284 Followed on any target supporting such operations.
15286 @geindex Interrupt support
15288 @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
15289 @anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{252}
15290 @section RM C.3(28): Interrupt Support
15293 @quotation
15295 “If the @code{Ceiling_Locking} policy is not in effect, the
15296 implementation should provide means for the application to specify which
15297 interrupts are to be blocked during protected actions, if the underlying
15298 system allows for a finer-grain control of interrupt blocking.”
15299 @end quotation
15301 Followed.  The underlying system does not allow for finer-grain control
15302 of interrupt blocking.
15304 @geindex Protected procedure handlers
15306 @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
15307 @anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{253}
15308 @section RM C.3.1(20-21): Protected Procedure Handlers
15311 @quotation
15313 “Whenever possible, the implementation should allow interrupt handlers to
15314 be called directly by the hardware.”
15315 @end quotation
15317 Followed on any target where the underlying operating system permits
15318 such direct calls.
15320 @quotation
15322 “Whenever practical, violations of any
15323 implementation-defined restrictions should be detected before run time.”
15324 @end quotation
15326 Followed.  Compile time warnings are given when possible.
15328 @geindex Package `@w{`}Interrupts`@w{`}
15330 @geindex Interrupts
15332 @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
15333 @anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{254}
15334 @section RM C.3.2(25): Package @code{Interrupts}
15337 @quotation
15339 “If implementation-defined forms of interrupt handler procedures are
15340 supported, such as protected procedures with parameters, then for each
15341 such form of a handler, a type analogous to @code{Parameterless_Handler}
15342 should be specified in a child package of @code{Interrupts}, with the
15343 same operations as in the predefined package Interrupts.”
15344 @end quotation
15346 Followed.
15348 @geindex Pre-elaboration requirements
15350 @node RM C 4 14 Pre-elaboration Requirements,RM C 5 8 Pragma Discard_Names,RM C 3 2 25 Package Interrupts,Implementation Advice
15351 @anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{255}
15352 @section RM C.4(14): Pre-elaboration Requirements
15355 @quotation
15357 “It is recommended that pre-elaborated packages be implemented in such a
15358 way that there should be little or no code executed at run time for the
15359 elaboration of entities not already covered by the Implementation
15360 Requirements.”
15361 @end quotation
15363 Followed.  Executable code is generated in some cases, e.g., loops
15364 to initialize large arrays.
15366 @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
15367 @anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{256}
15368 @section RM C.5(8): Pragma @code{Discard_Names}
15371 @quotation
15373 “If the pragma applies to an entity, then the implementation should
15374 reduce the amount of storage used for storing names associated with that
15375 entity.”
15376 @end quotation
15378 Followed.
15380 @geindex Package Task_Attributes
15382 @geindex Task_Attributes
15384 @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
15385 @anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{257}
15386 @section RM C.7.2(30): The Package Task_Attributes
15389 @quotation
15391 “Some implementations are targeted to domains in which memory use at run
15392 time must be completely deterministic.  For such implementations, it is
15393 recommended that the storage for task attributes will be pre-allocated
15394 statically and not from the heap.  This can be accomplished by either
15395 placing restrictions on the number and the size of the task’s
15396 attributes, or by using the pre-allocated storage for the first @code{N}
15397 attribute objects, and the heap for the others.  In the latter case,
15398 @code{N} should be documented.”
15399 @end quotation
15401 Not followed.  This implementation is not targeted to such a domain.
15403 @geindex Locking Policies
15405 @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
15406 @anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{258}
15407 @section RM D.3(17): Locking Policies
15410 @quotation
15412 “The implementation should use names that end with @code{_Locking} for
15413 locking policies defined by the implementation.”
15414 @end quotation
15416 Followed.  Two implementation-defined locking policies are defined,
15417 whose names (@code{Inheritance_Locking} and
15418 @code{Concurrent_Readers_Locking}) follow this suggestion.
15420 @geindex Entry queuing policies
15422 @node RM D 4 16 Entry Queuing Policies,RM D 6 9-10 Preemptive Abort,RM D 3 17 Locking Policies,Implementation Advice
15423 @anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{259}
15424 @section RM D.4(16): Entry Queuing Policies
15427 @quotation
15429 “Names that end with @code{_Queuing} should be used
15430 for all implementation-defined queuing policies.”
15431 @end quotation
15433 Followed.  No such implementation-defined queuing policies exist.
15435 @geindex Preemptive abort
15437 @node RM D 6 9-10 Preemptive Abort,RM D 7 21 Tasking Restrictions,RM D 4 16 Entry Queuing Policies,Implementation Advice
15438 @anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{25a}
15439 @section RM D.6(9-10): Preemptive Abort
15442 @quotation
15444 “Even though the `abort_statement' is included in the list of
15445 potentially blocking operations (see 9.5.1), it is recommended that this
15446 statement be implemented in a way that never requires the task executing
15447 the `abort_statement' to block.”
15448 @end quotation
15450 Followed.
15452 @quotation
15454 “On a multi-processor, the delay associated with aborting a task on
15455 another processor should be bounded; the implementation should use
15456 periodic polling, if necessary, to achieve this.”
15457 @end quotation
15459 Followed.
15461 @geindex Tasking restrictions
15463 @node RM D 7 21 Tasking Restrictions,RM D 8 47-49 Monotonic Time,RM D 6 9-10 Preemptive Abort,Implementation Advice
15464 @anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{25b}
15465 @section RM D.7(21): Tasking Restrictions
15468 @quotation
15470 “When feasible, the implementation should take advantage of the specified
15471 restrictions to produce a more efficient implementation.”
15472 @end quotation
15474 GNAT currently takes advantage of these restrictions by providing an optimized
15475 run time when the Ravenscar profile and the GNAT restricted run time set
15476 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
15477 pragma @code{Profile (Restricted)} for more details.
15479 @geindex Time
15480 @geindex monotonic
15482 @node RM D 8 47-49 Monotonic Time,RM E 5 28-29 Partition Communication Subsystem,RM D 7 21 Tasking Restrictions,Implementation Advice
15483 @anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{25c}
15484 @section RM D.8(47-49): Monotonic Time
15487 @quotation
15489 “When appropriate, implementations should provide configuration
15490 mechanisms to change the value of @code{Tick}.”
15491 @end quotation
15493 Such configuration mechanisms are not appropriate to this implementation
15494 and are thus not supported.
15496 @quotation
15498 “It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
15499 be implemented as transformations of the same time base.”
15500 @end quotation
15502 Followed.
15504 @quotation
15506 “It is recommended that the best time base which exists in
15507 the underlying system be available to the application through
15508 @code{Clock}.  @cite{Best} may mean highest accuracy or largest range.”
15509 @end quotation
15511 Followed.
15513 @geindex Partition communication subsystem
15515 @geindex PCS
15517 @node RM E 5 28-29 Partition Communication Subsystem,RM F 7 COBOL Support,RM D 8 47-49 Monotonic Time,Implementation Advice
15518 @anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{25d}
15519 @section RM E.5(28-29): Partition Communication Subsystem
15522 @quotation
15524 “Whenever possible, the PCS on the called partition should allow for
15525 multiple tasks to call the RPC-receiver with different messages and
15526 should allow them to block until the corresponding subprogram body
15527 returns.”
15528 @end quotation
15530 Followed by GLADE, a separately supplied PCS that can be used with
15531 GNAT.
15533 @quotation
15535 “The @code{Write} operation on a stream of type @code{Params_Stream_Type}
15536 should raise @code{Storage_Error} if it runs out of space trying to
15537 write the @code{Item} into the stream.”
15538 @end quotation
15540 Followed by GLADE, a separately supplied PCS that can be used with
15541 GNAT.
15543 @geindex COBOL support
15545 @node RM F 7 COBOL Support,RM F 1 2 Decimal Radix Support,RM E 5 28-29 Partition Communication Subsystem,Implementation Advice
15546 @anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{25e}
15547 @section RM F(7): COBOL Support
15550 @quotation
15552 “If COBOL (respectively, C) is widely supported in the target
15553 environment, implementations supporting the Information Systems Annex
15554 should provide the child package @code{Interfaces.COBOL} (respectively,
15555 @code{Interfaces.C}) specified in Annex B and should support a
15556 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
15557 pragmas (see Annex B), thus allowing Ada programs to interface with
15558 programs written in that language.”
15559 @end quotation
15561 Followed.
15563 @geindex Decimal radix support
15565 @node RM F 1 2 Decimal Radix Support,RM G Numerics,RM F 7 COBOL Support,Implementation Advice
15566 @anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{25f}
15567 @section RM F.1(2): Decimal Radix Support
15570 @quotation
15572 “Packed decimal should be used as the internal representation for objects
15573 of subtype @code{S} when @code{S}’Machine_Radix = 10.”
15574 @end quotation
15576 Not followed.  GNAT ignores @code{S}’Machine_Radix and always uses binary
15577 representations.
15579 @geindex Numerics
15581 @node RM G Numerics,RM G 1 1 56-58 Complex Types,RM F 1 2 Decimal Radix Support,Implementation Advice
15582 @anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{260}
15583 @section RM G: Numerics
15586 @quotation
15588 “If Fortran (respectively, C) is widely supported in the target
15589 environment, implementations supporting the Numerics Annex
15590 should provide the child package @code{Interfaces.Fortran} (respectively,
15591 @code{Interfaces.C}) specified in Annex B and should support a
15592 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
15593 pragmas (see Annex B), thus allowing Ada programs to interface with
15594 programs written in that language.”
15595 @end quotation
15597 Followed.
15599 @geindex Complex types
15601 @node RM G 1 1 56-58 Complex Types,RM G 1 2 49 Complex Elementary Functions,RM G Numerics,Implementation Advice
15602 @anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{261}
15603 @section RM G.1.1(56-58): Complex Types
15606 @quotation
15608 “Because the usual mathematical meaning of multiplication of a complex
15609 operand and a real operand is that of the scaling of both components of
15610 the former by the latter, an implementation should not perform this
15611 operation by first promoting the real operand to complex type and then
15612 performing a full complex multiplication.  In systems that, in the
15613 future, support an Ada binding to IEC 559:1989, the latter technique
15614 will not generate the required result when one of the components of the
15615 complex operand is infinite.  (Explicit multiplication of the infinite
15616 component by the zero component obtained during promotion yields a NaN
15617 that propagates into the final result.) Analogous advice applies in the
15618 case of multiplication of a complex operand and a pure-imaginary
15619 operand, and in the case of division of a complex operand by a real or
15620 pure-imaginary operand.”
15621 @end quotation
15623 Not followed.
15625 @quotation
15627 “Similarly, because the usual mathematical meaning of addition of a
15628 complex operand and a real operand is that the imaginary operand remains
15629 unchanged, an implementation should not perform this operation by first
15630 promoting the real operand to complex type and then performing a full
15631 complex addition.  In implementations in which the @code{Signed_Zeros}
15632 attribute of the component type is @code{True} (and which therefore
15633 conform to IEC 559:1989 in regard to the handling of the sign of zero in
15634 predefined arithmetic operations), the latter technique will not
15635 generate the required result when the imaginary component of the complex
15636 operand is a negatively signed zero.  (Explicit addition of the negative
15637 zero to the zero obtained during promotion yields a positive zero.)
15638 Analogous advice applies in the case of addition of a complex operand
15639 and a pure-imaginary operand, and in the case of subtraction of a
15640 complex operand and a real or pure-imaginary operand.”
15641 @end quotation
15643 Not followed.
15645 @quotation
15647 “Implementations in which @code{Real'Signed_Zeros} is @code{True} should
15648 attempt to provide a rational treatment of the signs of zero results and
15649 result components.  As one example, the result of the @code{Argument}
15650 function should have the sign of the imaginary component of the
15651 parameter @code{X} when the point represented by that parameter lies on
15652 the positive real axis; as another, the sign of the imaginary component
15653 of the @code{Compose_From_Polar} function should be the same as
15654 (respectively, the opposite of) that of the @code{Argument} parameter when that
15655 parameter has a value of zero and the @code{Modulus} parameter has a
15656 nonnegative (respectively, negative) value.”
15657 @end quotation
15659 Followed.
15661 @geindex Complex elementary functions
15663 @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
15664 @anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{262}
15665 @section RM G.1.2(49): Complex Elementary Functions
15668 @quotation
15670 “Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
15671 @code{True} should attempt to provide a rational treatment of the signs
15672 of zero results and result components.  For example, many of the complex
15673 elementary functions have components that are odd functions of one of
15674 the parameter components; in these cases, the result component should
15675 have the sign of the parameter component at the origin.  Other complex
15676 elementary functions have zero components whose sign is opposite that of
15677 a parameter component at the origin, or is always positive or always
15678 negative.”
15679 @end quotation
15681 Followed.
15683 @geindex Accuracy requirements
15685 @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
15686 @anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{263}
15687 @section RM G.2.4(19): Accuracy Requirements
15690 @quotation
15692 “The versions of the forward trigonometric functions without a
15693 @code{Cycle} parameter should not be implemented by calling the
15694 corresponding version with a @code{Cycle} parameter of
15695 @code{2.0*Numerics.Pi}, since this will not provide the required
15696 accuracy in some portions of the domain.  For the same reason, the
15697 version of @code{Log} without a @code{Base} parameter should not be
15698 implemented by calling the corresponding version with a @code{Base}
15699 parameter of @code{Numerics.e}.”
15700 @end quotation
15702 Followed.
15704 @geindex Complex arithmetic accuracy
15706 @geindex Accuracy
15707 @geindex complex arithmetic
15709 @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
15710 @anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{264}
15711 @section RM G.2.6(15): Complex Arithmetic Accuracy
15714 @quotation
15716 “The version of the @code{Compose_From_Polar} function without a
15717 @code{Cycle} parameter should not be implemented by calling the
15718 corresponding version with a @code{Cycle} parameter of
15719 @code{2.0*Numerics.Pi}, since this will not provide the required
15720 accuracy in some portions of the domain.”
15721 @end quotation
15723 Followed.
15725 @geindex Sequential elaboration policy
15727 @node RM H 6 15/2 Pragma Partition_Elaboration_Policy,,RM G 2 6 15 Complex Arithmetic Accuracy,Implementation Advice
15728 @anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{265}
15729 @section RM H.6(15/2): Pragma Partition_Elaboration_Policy
15732 @quotation
15734 “If the partition elaboration policy is @code{Sequential} and the
15735 Environment task becomes permanently blocked during elaboration then the
15736 partition is deadlocked and it is recommended that the partition be
15737 immediately terminated.”
15738 @end quotation
15740 Not followed.
15742 @node Implementation Defined Characteristics,Intrinsic Subprograms,Implementation Advice,Top
15743 @anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{266}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{267}@anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b}
15744 @chapter Implementation Defined Characteristics
15747 In addition to the implementation dependent pragmas and attributes, and the
15748 implementation advice, there are a number of other Ada features that are
15749 potentially implementation dependent and are designated as
15750 implementation-defined. These are mentioned throughout the Ada Reference
15751 Manual, and are summarized in Annex M.
15753 A requirement for conforming Ada compilers is that they provide
15754 documentation describing how the implementation deals with each of these
15755 issues.  In this chapter you will find each point in Annex M listed,
15756 followed by a description of how GNAT handles the implementation dependence.
15758 You can use this chapter as a guide to minimizing implementation
15759 dependent features in your programs if portability to other compilers
15760 and other operating systems is an important consideration.  The numbers
15761 in each entry below correspond to the paragraph numbers in the Ada
15762 Reference Manual.
15765 @itemize *
15767 @item 
15768 “Whether or not each recommendation given in Implementation
15769 Advice is followed.  See 1.1.2(37).”
15770 @end itemize
15772 See @ref{a,,Implementation Advice}.
15775 @itemize *
15777 @item 
15778 “Capacity limitations of the implementation.  See 1.1.3(3).”
15779 @end itemize
15781 The complexity of programs that can be processed is limited only by the
15782 total amount of available virtual memory, and disk space for the
15783 generated object files.
15786 @itemize *
15788 @item 
15789 “Variations from the standard that are impractical to avoid
15790 given the implementation’s execution environment.  See 1.1.3(6).”
15791 @end itemize
15793 There are no variations from the standard.
15796 @itemize *
15798 @item 
15799 “Which code_statements cause external
15800 interactions.  See 1.1.3(10).”
15801 @end itemize
15803 Any `code_statement' can potentially cause external interactions.
15806 @itemize *
15808 @item 
15809 “The coded representation for the text of an Ada
15810 program.  See 2.1(4).”
15811 @end itemize
15813 See separate section on source representation.
15816 @itemize *
15818 @item 
15819 “The semantics of an Ada program whose text is not in
15820 Normalization Form C.  See 2.1(4).”
15821 @end itemize
15823 See separate section on source representation.
15826 @itemize *
15828 @item 
15829 “The representation for an end of line.  See 2.2(2).”
15830 @end itemize
15832 See separate section on source representation.
15835 @itemize *
15837 @item 
15838 “Maximum supported line length and lexical element
15839 length.  See 2.2(15).”
15840 @end itemize
15842 The maximum line length is 255 characters and the maximum length of
15843 a lexical element is also 255 characters. This is the default setting
15844 if not overridden by the use of compiler switch `-gnaty' (which
15845 sets the maximum to 79) or `-gnatyMnn' which allows the maximum
15846 line length to be specified to be any value up to 32767. The maximum
15847 length of a lexical element is the same as the maximum line length.
15850 @itemize *
15852 @item 
15853 “Implementation defined pragmas.  See 2.8(14).”
15854 @end itemize
15856 See @ref{7,,Implementation Defined Pragmas}.
15859 @itemize *
15861 @item 
15862 “Effect of pragma @code{Optimize}.  See 2.8(27).”
15863 @end itemize
15865 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
15866 parameter, checks that the optimization flag is set, and aborts if it is
15867 not.
15870 @itemize *
15872 @item 
15873 “The message string associated with the Assertion_Error exception raised
15874 by the failure of a predicate check if there is no applicable
15875 Predicate_Failure aspect.  See 3.2.4(31).”
15876 @end itemize
15878 In the case of a Dynamic_Predicate aspect, the string is
15879 “Dynamic_Predicate failed at <source position>”, where
15880 “<source position>” might be something like “foo.adb:123”.
15881 The Static_Predicate case is handled analogously.
15884 @itemize *
15886 @item 
15887 “The predefined integer types declared in
15888 @code{Standard}.  See 3.5.4(25).”
15889 @end itemize
15892 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
15893 @headitem
15895 Type
15897 @tab
15899 Representation
15901 @item
15903 `Short_Short_Integer'
15905 @tab
15907 8-bit signed
15909 @item
15911 `Short_Integer'
15913 @tab
15915 16-bit signed
15917 @item
15919 `Integer'
15921 @tab
15923 32-bit signed
15925 @item
15927 `Long_Integer'
15929 @tab
15931 64-bit signed (on most 64-bit targets,
15932 depending on the C definition of long)
15933 32-bit signed (on all other targets)
15935 @item
15937 `Long_Long_Integer'
15939 @tab
15941 64-bit signed
15943 @item
15945 `Long_Long_Long_Integer'
15947 @tab
15949 128-bit signed (on 64-bit targets)
15950 64-bit signed (on 32-bit targets)
15952 @end multitable
15956 @itemize *
15958 @item 
15959 “Any nonstandard integer types and the operators defined
15960 for them.  See 3.5.4(26).”
15961 @end itemize
15963 There are no nonstandard integer types.
15966 @itemize *
15968 @item 
15969 “Any nonstandard real types and the operators defined for
15970 them.  See 3.5.6(8).”
15971 @end itemize
15973 There are no nonstandard real types.
15976 @itemize *
15978 @item 
15979 “What combinations of requested decimal precision and range
15980 are supported for floating point types.  See 3.5.7(7).”
15981 @end itemize
15983 The precision and range are defined by the IEEE Standard for Floating-Point
15984 Arithmetic (IEEE 754-2019).
15987 @itemize *
15989 @item 
15990 “The predefined floating point types declared in
15991 @code{Standard}.  See 3.5.7(16).”
15992 @end itemize
15995 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
15996 @headitem
15998 Type
16000 @tab
16002 Representation
16004 @item
16006 `Short_Float'
16008 @tab
16010 IEEE Binary32 (Single)
16012 @item
16014 `Float'
16016 @tab
16018 IEEE Binary32 (Single)
16020 @item
16022 `Long_Float'
16024 @tab
16026 IEEE Binary64 (Double)
16028 @item
16030 `Long_Long_Float'
16032 @tab
16034 IEEE Binary64 (Double) on non-x86 architectures
16035 IEEE 80-bit Extended on x86 architecture
16037 @end multitable
16040 The default rounding mode specified by the IEEE 754 Standard is assumed both
16041 for static and dynamic computations (that is, round to nearest, ties to even).
16042 The input routines yield correctly rounded values for Short_Float, Float, and
16043 Long_Float at least. The output routines can compute up to twice as many exact
16044 digits as the value of @code{T'Digits} for any type, for example 30 digits for
16045 Long_Float; if more digits are requested, zeros are printed.
16048 @itemize *
16050 @item 
16051 “The small of an ordinary fixed point type.  See 3.5.9(8).”
16052 @end itemize
16054 The small is the largest power of two that does not exceed the delta.
16057 @itemize *
16059 @item 
16060 “What combinations of small, range, and digits are
16061 supported for fixed point types.  See 3.5.9(10).”
16062 @end itemize
16064 For an ordinary fixed point type, on 32-bit platforms, the small must lie in
16065 2.0**(-80) .. 2.0**80 and the range in -9.0E+36 .. 9.0E+36; any combination
16066 is permitted that does not result in a mantissa larger than 63 bits.
16068 On 64-bit platforms, the small must lie in 2.0**(-127) .. 2.0**127 and the
16069 range in -1.0E+76 .. 1.0E+76; any combination is permitted that does not
16070 result in a mantissa larger than 63 bits, and any combination is permitted
16071 that results in a mantissa between 64 and 127 bits if the small is the
16072 ratio of two integers that lie in 1 .. 2.0**127.
16074 If the small is the ratio of two integers with 64-bit magnitude on 32-bit
16075 platforms and 128-bit magnitude on 64-bit platforms, which is the case if
16076 no @code{small} clause is provided, then the operations of the fixed point
16077 type are entirely implemented by means of integer instructions.  In the
16078 other cases, some operations, in particular input and output, may be
16079 implemented by means of floating-point instructions and may be affected
16080 by accuracy issues on architectures other than x86.
16082 For a decimal fixed point type, on 32-bit platforms, the small must lie in
16083 1.0E-18 .. 1.0E+18 and the digits in 1 .. 18.  On 64-bit platforms, the
16084 small must lie in 1.0E-38 .. 1.0E+38 and the digits in 1 .. 38.
16087 @itemize *
16089 @item 
16090 “The result of @code{Tags.Expanded_Name} for types declared
16091 within an unnamed `block_statement'.  See 3.9(10).”
16092 @end itemize
16094 Block numbers of the form @code{B@var{nnn}}, where `nnn' is a
16095 decimal integer are allocated.
16098 @itemize *
16100 @item 
16101 “The sequence of characters of the value returned by Tags.Expanded_Name
16102 (respectively, Tags.Wide_Expanded_Name) when some of the graphic
16103 characters of Tags.Wide_Wide_Expanded_Name are not defined in Character
16104 (respectively, Wide_Character).  See 3.9(10.1).”
16105 @end itemize
16107 This is handled in the same way as the implementation-defined behavior
16108 referenced in A.4.12(34).
16111 @itemize *
16113 @item 
16114 “Implementation-defined attributes.  See 4.1.4(12).”
16115 @end itemize
16117 See @ref{8,,Implementation Defined Attributes}.
16120 @itemize *
16122 @item 
16123 “The value of the parameter to Empty for some container aggregates.
16124 See 4.3.5(40).”
16125 @end itemize
16127 As per the suggestion given in the Annotated Ada RM, the default value
16128 of the formal parameter is used if one exists and zero is used otherwise.
16131 @itemize *
16133 @item 
16134 “The maximum number of chunks for a parallel reduction expression without
16135 a chunk_specification.  See 4.5.10(21).”
16136 @end itemize
16138 Feature unimplemented.
16141 @itemize *
16143 @item 
16144 “Rounding of real static expressions which are exactly half-way between
16145 two machine numbers.  See 4.9(38).”
16146 @end itemize
16148 Round to even is used in all such cases.
16151 @itemize *
16153 @item 
16154 “The maximum number of chunks for a parallel generalized iterator without
16155 a chunk_specification.  See 5.5.2(10).”
16156 @end itemize
16158 Feature unimplemented.
16161 @itemize *
16163 @item 
16164 “The number of chunks for an array component iterator.  See 5.5.2(11).”
16165 @end itemize
16167 Feature unimplemented.
16170 @itemize *
16172 @item 
16173 “Any extensions of the Global aspect.  See 6.1.2(43).”
16174 @end itemize
16176 Feature unimplemented.
16179 @itemize *
16181 @item 
16182 “The circumstances the implementation passes in the null value for a view
16183 conversion of an access type used as an out parameter.  See 6.4.1(19).”
16184 @end itemize
16186 Difficult to characterize.
16189 @itemize *
16191 @item 
16192 “Any extensions of the Default_Initial_Condition aspect.  See 7.3.3(11).”
16193 @end itemize
16195 SPARK allows specifying `null' as the Default_Initial_Condition
16196 aspect of a type. See the SPARK reference manual for further details.
16199 @itemize *
16201 @item 
16202 “Any implementation-defined time types.  See 9.6(6).”
16203 @end itemize
16205 There are no implementation-defined time types.
16208 @itemize *
16210 @item 
16211 “The time base associated with relative delays.  See 9.6(20).”
16212 @end itemize
16214 See 9.6(20).  The time base used is that provided by the C library
16215 function @code{gettimeofday}.
16218 @itemize *
16220 @item 
16221 “The time base of the type @code{Calendar.Time}.  See 9.6(23).”
16222 @end itemize
16224 The time base used is that provided by the C library function
16225 @code{gettimeofday}.
16228 @itemize *
16230 @item 
16231 “The time zone used for package @code{Calendar}
16232 operations.  See 9.6(24).”
16233 @end itemize
16235 The time zone used by package @code{Calendar} is the current system time zone
16236 setting for local time, as accessed by the C library function
16237 @code{localtime}.
16240 @itemize *
16242 @item 
16243 “Any limit on `delay_until_statements' of
16244 `select_statements'.  See 9.6(29).”
16245 @end itemize
16247 There are no such limits.
16250 @itemize *
16252 @item 
16253 “The result of Calendar.Formatting.Image if its argument represents more
16254 than 100 hours.  See 9.6.1(86).”
16255 @end itemize
16257 Calendar.Time_Error is raised.
16260 @itemize *
16262 @item 
16263 “Implementation-defined conflict check policies.  See 9.10.1(5).”
16264 @end itemize
16266 There are no implementation-defined conflict check policies.
16269 @itemize *
16271 @item 
16272 “The representation for a compilation.  See 10.1(2).”
16273 @end itemize
16275 A compilation is represented by a sequence of files presented to the
16276 compiler in a single invocation of the `gcc' command.
16279 @itemize *
16281 @item 
16282 “Any restrictions on compilations that contain multiple
16283 compilation_units.  See 10.1(4).”
16284 @end itemize
16286 No single file can contain more than one compilation unit, but any
16287 sequence of files can be presented to the compiler as a single
16288 compilation.
16291 @itemize *
16293 @item 
16294 “The mechanisms for creating an environment and for adding
16295 and replacing compilation units.  See 10.1.4(3).”
16296 @end itemize
16298 See separate section on compilation model.
16301 @itemize *
16303 @item 
16304 “The manner of explicitly assigning library units to a
16305 partition.  See 10.2(2).”
16306 @end itemize
16308 If a unit contains an Ada main program, then the Ada units for the partition
16309 are determined by recursive application of the rules in the Ada Reference
16310 Manual section 10.2(2-6).  In other words, the Ada units will be those that
16311 are needed by the main program, and then this definition of need is applied
16312 recursively to those units, and the partition contains the transitive
16313 closure determined by this relationship.  In short, all the necessary units
16314 are included, with no need to explicitly specify the list.  If additional
16315 units are required, e.g., by foreign language units, then all units must be
16316 mentioned in the context clause of one of the needed Ada units.
16318 If the partition contains no main program, or if the main program is in
16319 a language other than Ada, then GNAT
16320 provides the binder options `-z' and `-n' respectively, and in
16321 this case a list of units can be explicitly supplied to the binder for
16322 inclusion in the partition (all units needed by these units will also
16323 be included automatically).  For full details on the use of these
16324 options, refer to `GNAT Make Program gnatmake' in the
16325 @cite{GNAT User’s Guide}.
16328 @itemize *
16330 @item 
16331 “The implementation-defined means, if any, of specifying which compilation
16332 units are needed by a given compilation unit.  See 10.2(2).”
16333 @end itemize
16335 The units needed by a given compilation unit are as defined in
16336 the Ada Reference Manual section 10.2(2-6).  There are no
16337 implementation-defined pragmas or other implementation-defined
16338 means for specifying needed units.
16341 @itemize *
16343 @item 
16344 “The manner of designating the main subprogram of a
16345 partition.  See 10.2(7).”
16346 @end itemize
16348 The main program is designated by providing the name of the
16349 corresponding @code{ALI} file as the input parameter to the binder.
16352 @itemize *
16354 @item 
16355 “The order of elaboration of `library_items'.  See 10.2(18).”
16356 @end itemize
16358 The first constraint on ordering is that it meets the requirements of
16359 Chapter 10 of the Ada Reference Manual.  This still leaves some
16360 implementation-dependent choices, which are resolved by analyzing
16361 the elaboration code of each unit and identifying implicit
16362 elaboration-order dependencies.
16365 @itemize *
16367 @item 
16368 “Parameter passing and function return for the main
16369 subprogram.  See 10.2(21).”
16370 @end itemize
16372 The main program has no parameters.  It may be a procedure, or a function
16373 returning an integer type.  In the latter case, the returned integer
16374 value is the return code of the program (overriding any value that
16375 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
16378 @itemize *
16380 @item 
16381 “The mechanisms for building and running partitions.  See 10.2(24).”
16382 @end itemize
16384 GNAT itself supports programs with only a single partition. The GNATDIST
16385 tool provided with the GLADE package (which also includes an implementation
16386 of the PCS) provides a completely flexible method for building and running
16387 programs consisting of multiple partitions. See the separate GLADE manual
16388 for details.
16391 @itemize *
16393 @item 
16394 “The details of program execution, including program
16395 termination.  See 10.2(25).”
16396 @end itemize
16398 See separate section on compilation model.
16401 @itemize *
16403 @item 
16404 “The semantics of any non-active partitions supported by the
16405 implementation.  See 10.2(28).”
16406 @end itemize
16408 Passive partitions are supported on targets where shared memory is
16409 provided by the operating system. See the GLADE reference manual for
16410 further details.
16413 @itemize *
16415 @item 
16416 “The information returned by @code{Exception_Message}.  See 11.4.1(10).”
16417 @end itemize
16419 Exception message returns the null string unless a specific message has
16420 been passed by the program.
16423 @itemize *
16425 @item 
16426 “The result of @code{Exceptions.Exception_Name} for types
16427 declared within an unnamed `block_statement'.  See 11.4.1(12).”
16428 @end itemize
16430 Blocks have implementation defined names of the form @code{B@var{nnn}}
16431 where `nnn' is an integer.
16434 @itemize *
16436 @item 
16437 “The information returned by
16438 @code{Exception_Information}.  See 11.4.1(13).”
16439 @end itemize
16441 @code{Exception_Information} returns a string in the following format:
16443 @example
16444 *Exception_Name:* nnnnn
16445 *Message:* mmmmm
16446 *PID:* ppp
16447 *Load address:* 0xhhhh
16448 *Call stack traceback locations:*
16449 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
16450 @end example
16452 where
16454 @quotation
16457 @itemize *
16459 @item 
16460 @code{nnnn} is the fully qualified name of the exception in all upper
16461 case letters. This line is always present.
16463 @item 
16464 @code{mmmm} is the message (this line present only if message is non-null)
16466 @item 
16467 @code{ppp} is the Process Id value as a decimal integer (this line is
16468 present only if the Process Id is nonzero). Currently we are
16469 not making use of this field.
16471 @item 
16472 The Load address line, the Call stack traceback locations line and the
16473 following values are present only if at least one traceback location was
16474 recorded. The Load address indicates the address at which the main executable
16475 was loaded; this line may not be present if operating system hasn’t relocated
16476 the main executable. The values are given in C style format, with lower case
16477 letters for a-f, and only as many digits present as are necessary.
16478 The line terminator sequence at the end of each line, including
16479 the last line is a single @code{LF} character (@code{16#0A#}).
16480 @end itemize
16481 @end quotation
16484 @itemize *
16486 @item 
16487 “The sequence of characters of the value returned by
16488 Exceptions.Exception_Name (respectively, Exceptions.Wide_Exception_Name)
16489 when some of the graphic characters of Exceptions.Wide_Wide_Exception_Name
16490 are not defined in Character (respectively, Wide_Character).
16491 See 11.4.1(12.1).”
16492 @end itemize
16494 This is handled in the same way as the implementation-defined behavior
16495 referenced in A.4.12(34).
16498 @itemize *
16500 @item 
16501 “The information returned by Exception_Information.  See 11.4.1(13).”
16502 @end itemize
16504 The exception name and the source location at which the exception was
16505 raised are included.
16508 @itemize *
16510 @item 
16511 “Implementation-defined policy_identifiers and assertion_aspect_marks
16512 allowed in a pragma Assertion_Policy.  See 11.4.2(9).”
16513 @end itemize
16515 Implementation-defined assertion_aspect_marks include Assert_And_Cut,
16516 Assume, Contract_Cases, Debug, Ghost, Initial_Condition, Loop_Invariant,
16517 Loop_Variant, Postcondition, Precondition, Predicate, Refined_Post,
16518 Statement_Assertions, and Subprogram_Variant. Implementation-defined
16519 policy_identifiers include Ignore and Suppressible.
16522 @itemize *
16524 @item 
16525 “The default assertion policy.  See 11.4.2(10).”
16526 @end itemize
16528 The default assertion policy is Ignore, although this can be overridden
16529 via compiler switches such as “-gnata”.
16532 @itemize *
16534 @item 
16535 “Implementation-defined check names.  See 11.5(27).”
16536 @end itemize
16538 The implementation defined check names include Alignment_Check,
16539 Atomic_Synchronization, Duplicated_Tag_Check, Container_Checks,
16540 Tampering_Check, Predicate_Check, and Validity_Check. In addition, a user
16541 program can add implementation-defined check names by means of the pragma
16542 Check_Name. See the description of pragma @code{Suppress} for full details.
16545 @itemize *
16547 @item 
16548 “Existence and meaning of second parameter of pragma Unsuppress.
16549 See 11.5(27.1).”
16550 @end itemize
16552 The legality rules for and semantics of the second parameter of pragma
16553 Unsuppress match those for the second argument of pragma Suppress.
16556 @itemize *
16558 @item 
16559 “The cases that cause conflicts between the representation of the
16560 ancestors of a type_declaration.  See 13.1(13.1).”
16561 @end itemize
16563 No such cases exist.
16566 @itemize *
16568 @item 
16569 “The interpretation of each representation aspect.  See 13.1(20).”
16570 @end itemize
16572 See separate section on data representations.
16575 @itemize *
16577 @item 
16578 “Any restrictions placed upon the specification of representation aspects.
16579 See 13.1(20).”
16580 @end itemize
16582 See separate section on data representations.
16585 @itemize *
16587 @item 
16588 “Implementation-defined aspects, including the syntax for specifying
16589 such aspects and the legality rules for such aspects.  See 13.1.1(38).”
16590 @end itemize
16592 See @ref{126,,Implementation Defined Aspects}.
16595 @itemize *
16597 @item 
16598 “The set of machine scalars.  See 13.3(8.1).”
16599 @end itemize
16601 See separate section on data representations.
16604 @itemize *
16606 @item 
16607 “The meaning of @code{Size} for indefinite subtypes.  See 13.3(48).”
16608 @end itemize
16610 The Size attribute of an indefinite subtype is not less than the Size
16611 attribute of any object of that type.
16614 @itemize *
16616 @item 
16617 “The meaning of Object_Size for indefinite subtypes.  See 13.3(58).”
16618 @end itemize
16620 The Object_Size attribute of an indefinite subtype is not less than the
16621 Object_Size attribute of any object of that type.
16624 @itemize *
16626 @item 
16627 “The default external representation for a type tag.  See 13.3(75).”
16628 @end itemize
16630 The default external representation for a type tag is the fully expanded
16631 name of the type in upper case letters.
16634 @itemize *
16636 @item 
16637 “What determines whether a compilation unit is the same in
16638 two different partitions.  See 13.3(76).”
16639 @end itemize
16641 A compilation unit is the same in two different partitions if and only
16642 if it derives from the same source file.
16645 @itemize *
16647 @item 
16648 “Implementation-defined components.  See 13.5.1(15).”
16649 @end itemize
16651 The only implementation defined component is the tag for a tagged type,
16652 which contains a pointer to the dispatching table.
16655 @itemize *
16657 @item 
16658 “If @code{Word_Size} = @code{Storage_Unit}, the default bit
16659 ordering.  See 13.5.3(5).”
16660 @end itemize
16662 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
16663 implementation, so no non-default bit ordering is supported.  The default
16664 bit ordering corresponds to the natural endianness of the target architecture.
16667 @itemize *
16669 @item 
16670 “The contents of the visible part of package @code{System}.  See 13.7(2).”
16671 @end itemize
16673 See the definition of package System in @code{system.ads}.
16674 Note that two declarations are added to package System.
16676 @example
16677 Max_Priority           : constant Positive := Priority'Last;
16678 Max_Interrupt_Priority : constant Positive := Interrupt_Priority'Last;
16679 @end example
16682 @itemize *
16684 @item 
16685 “The range of Storage_Elements.Storage_Offset, the modulus of
16686 Storage_Elements.Storage_Element, and the declaration of
16687 Storage_Elements.Integer_Address.  See 13.7.1(11).”
16688 @end itemize
16690 See the definition of package System.Storage_Elements in @code{s-stoele.ads}.
16693 @itemize *
16695 @item 
16696 “The contents of the visible part of package @code{System.Machine_Code},
16697 and the meaning of `code_statements'.  See 13.8(7).”
16698 @end itemize
16700 See the definition and documentation in file @code{s-maccod.ads}.
16703 @itemize *
16705 @item 
16706 “The result of unchecked conversion for instances with scalar result
16707 types whose result is not defined by the language.  See 13.9(11).”
16708 @end itemize
16710 Unchecked conversion between types of the same size
16711 results in an uninterpreted transmission of the bits from one type
16712 to the other.  If the types are of unequal sizes, then in the case of
16713 discrete types, a shorter source is first zero or sign extended as
16714 necessary, and a shorter target is simply truncated on the left.
16715 For all non-discrete types, the source is first copied if necessary
16716 to ensure that the alignment requirements of the target are met, then
16717 a pointer is constructed to the source value, and the result is obtained
16718 by dereferencing this pointer after converting it to be a pointer to the
16719 target type. Unchecked conversions where the target subtype is an
16720 unconstrained array are not permitted. If the target alignment is
16721 greater than the source alignment, then a copy of the result is
16722 made with appropriate alignment
16725 @itemize *
16727 @item 
16728 “The result of unchecked conversion for instances with nonscalar result
16729 types whose result is not defined by the language.  See 13.9(11).”
16730 @end itemize
16732 See preceding definition for the scalar result case.
16735 @itemize *
16737 @item 
16738 “Whether or not the implementation provides user-accessible
16739 names for the standard pool type(s).  See 13.11(17).”
16740 @end itemize
16742 There are 3 different standard pools used by the compiler when
16743 @code{Storage_Pool} is not specified depending whether the type is local
16744 to a subprogram or defined at the library level and whether
16745 @code{Storage_Size`@w{`}is specified or not. See documentation in the runtime
16746 library units `@w{`}System.Pool_Global}, @code{System.Pool_Size} and
16747 @code{System.Pool_Local} in files @code{s-poosiz.ads},
16748 @code{s-pooglo.ads} and @code{s-pooloc.ads} for full details on the
16749 default pools used.  All these pools are accessible by means of @cite{with}ing
16750 these units.
16753 @itemize *
16755 @item 
16756 “The meaning of @code{Storage_Size} when neither the Storage_Size nor the
16757 Storage_Pool is specified for an access type.  See 13.11(18).”
16758 @end itemize
16760 @code{Storage_Size} is measured in storage units, and refers to the
16761 total space available for an access type collection, or to the primary
16762 stack space for a task.
16765 @itemize *
16767 @item 
16768 “The effect of specifying aspect Default_Storage_Pool on an instance
16769 of a language-defined generic unit.  See 13.11.3(5).”
16770 @end itemize
16772 Instances of language-defined generic units are treated the same as other
16773 instances with respect to the Default_Storage_Pool aspect.
16776 @itemize *
16778 @item 
16779 “Implementation-defined restrictions allowed in a pragma
16780 @code{Restrictions}.  See 13.12(8.7).”
16781 @end itemize
16783 See @ref{9,,Standard and Implementation Defined Restrictions}.
16786 @itemize *
16788 @item 
16789 “The consequences of violating limitations on
16790 @code{Restrictions} pragmas.  See 13.12(9).”
16791 @end itemize
16793 Restrictions that can be checked at compile time are enforced at
16794 compile time; violations are illegal. For other restrictions, any
16795 violation during program execution results in erroneous execution.
16798 @itemize *
16800 @item 
16801 “Implementation-defined usage profiles allowed in a pragma Profile.
16802 See 13.12(15).”
16803 @end itemize
16805 See @ref{7,,Implementation Defined Pragmas}.
16808 @itemize *
16810 @item 
16811 “The contents of the stream elements read and written by the Read and
16812 Write attributes of elementary types.  See 13.13.2(9).”
16813 @end itemize
16815 The representation is the in-memory representation of the base type of
16816 the type, using the number of bits corresponding to the
16817 @code{type'Size} value, and the natural ordering of the machine.
16820 @itemize *
16822 @item 
16823 “The names and characteristics of the numeric subtypes
16824 declared in the visible part of package @code{Standard}.  See A.1(3).”
16825 @end itemize
16827 See items describing the integer and floating-point types supported.
16830 @itemize *
16832 @item 
16833 “The values returned by Strings.Hash.  See A.4.9(3).”
16834 @end itemize
16836 This hash function has predictable collisions and is subject to
16837 equivalent substring attacks. It is not suitable for construction of a
16838 hash table keyed on possibly malicious user input.
16841 @itemize *
16843 @item 
16844 “The value returned by a call to a Text_Buffer Get procedure if any
16845 character in the returned sequence is not defined in Character.
16846 See A.4.12(34).”
16847 @end itemize
16849 The contents of a buffer is represented internally as a UTF_8 string.
16850 The value return by Text_Buffer.Get is the result of passing that
16851 UTF_8 string to UTF_Encoding.Strings.Decode.
16854 @itemize *
16856 @item 
16857 “The value returned by a call to a Text_Buffer Wide_Get procedure if
16858 any character in the returned sequence is not defined in Wide_Character.
16859 See A.4.12(34).”
16860 @end itemize
16862 The contents of a buffer is represented internally as a UTF_8 string.
16863 The value return by Text_Buffer.Wide_Get is the result of passing that
16864 UTF_8 string to UTF_Encoding.Wide_Strings.Decode.
16867 @itemize *
16869 @item 
16870 “The accuracy actually achieved by the elementary
16871 functions.  See A.5.1(1).”
16872 @end itemize
16874 The elementary functions correspond to the functions available in the C
16875 library.  Only fast math mode is implemented.
16878 @itemize *
16880 @item 
16881 “The sign of a zero result from some of the operators or
16882 functions in @code{Numerics.Generic_Elementary_Functions}, when
16883 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).”
16884 @end itemize
16886 The sign of zeroes follows the requirements of the IEEE 754 standard on
16887 floating-point.
16890 @itemize *
16892 @item 
16893 “The value of
16894 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).”
16895 @end itemize
16897 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16900 @itemize *
16902 @item 
16903 “The value of
16904 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).”
16905 @end itemize
16907 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16910 @itemize *
16912 @item 
16913 “The string representation of a random number generator’s
16914 state.  See A.5.2(38).”
16915 @end itemize
16917 The value returned by the Image function is the concatenation of
16918 the fixed-width decimal representations of the 624 32-bit integers
16919 of the state vector.
16922 @itemize *
16924 @item 
16925 “The values of the @code{Model_Mantissa},
16926 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
16927 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
16928 Annex is not supported.  See A.5.3(72).”
16929 @end itemize
16931 Running the compiler with `-gnatS' to produce a listing of package
16932 @code{Standard} displays the values of these attributes.
16935 @itemize *
16937 @item 
16938 “The value of @code{Buffer_Size} in @code{Storage_IO}.  See A.9(10).”
16939 @end itemize
16941 All type representations are contiguous, and the @code{Buffer_Size} is
16942 the value of @code{type'Size} rounded up to the next storage unit
16943 boundary.
16946 @itemize *
16948 @item 
16949 “External files for standard input, standard output, and
16950 standard error See A.10(5).”
16951 @end itemize
16953 These files are mapped onto the files provided by the C streams
16954 libraries. See source file @code{i-cstrea.ads} for further details.
16957 @itemize *
16959 @item 
16960 “The accuracy of the value produced by @code{Put}.  See A.10.9(36).”
16961 @end itemize
16963 If more digits are requested in the output than are represented by the
16964 precision of the value, zeroes are output in the corresponding least
16965 significant digit positions.
16968 @itemize *
16970 @item 
16971 “Current size for a stream file for which positioning is not supported.
16972 See A.12.1(1.1).”
16973 @end itemize
16975 Positioning is supported.
16978 @itemize *
16980 @item 
16981 “The meaning of @code{Argument_Count}, @code{Argument}, and
16982 @code{Command_Name}.  See A.15(1).”
16983 @end itemize
16985 These are mapped onto the @code{argv} and @code{argc} parameters of the
16986 main program in the natural manner.
16989 @itemize *
16991 @item 
16992 “The interpretation of file names and directory names.  See A.16(46).”
16993 @end itemize
16995 These names are interpreted consistently with the underlying file system.
16998 @itemize *
17000 @item 
17001 “The maxium value for a file size in Directories.  See A.16(87).”
17002 @end itemize
17004 Directories.File_Size’Last is equal to Long_Long_Integer’Last .
17007 @itemize *
17009 @item 
17010 “The result for Directories.Size for a directory or special file.
17011 See A.16(93).”
17012 @end itemize
17014 Name_Error is raised.
17017 @itemize *
17019 @item 
17020 “The result for Directories.Modification_Time for a directory or special file.
17021 See A.16(93).”
17022 @end itemize
17024 Name_Error is raised.
17027 @itemize *
17029 @item 
17030 “The interpretation of a nonnull search pattern in Directories.
17031 See A.16(104).”
17032 @end itemize
17034 When the @code{Pattern} parameter is not the null string, it is interpreted
17035 according to the syntax of regular expressions as defined in the
17036 @code{GNAT.Regexp} package.
17038 See @ref{268,,GNAT.Regexp (g-regexp.ads)}.
17041 @itemize *
17043 @item 
17044 “The results of a Directories search if the contents of the directory are
17045 altered while a search is in progress.  See A.16(110).”
17046 @end itemize
17048 The effect of a call to Get_Next_Entry is determined by the current
17049 state of the directory.
17052 @itemize *
17054 @item 
17055 “The definition and meaning of an environment variable.  See A.17(1).”
17056 @end itemize
17058 This definition is determined by the underlying operating system.
17061 @itemize *
17063 @item 
17064 “The circumstances where an environment variable cannot be defined.
17065 See A.17(16).”
17066 @end itemize
17068 There are no such implementation-defined circumstances.
17071 @itemize *
17073 @item 
17074 “Environment names for which Set has the effect of Clear.  See A.17(17).”
17075 @end itemize
17077 There are no such names.
17080 @itemize *
17082 @item 
17083 “The value of Containers.Hash_Type’Modulus. The value of
17084 Containers.Count_Type’Last.  See A.18.1(7).”
17085 @end itemize
17087 Containers.Hash_Type’Modulus is 2**32.
17088 Containers.Count_Type’Last is 2**31 - 1.
17091 @itemize *
17093 @item 
17094 “Implementation-defined convention names.  See B.1(11).”
17095 @end itemize
17097 The following convention names are supported
17100 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
17101 @headitem
17103 Convention Name
17105 @tab
17107 Interpretation
17109 @item
17111 `Ada'
17113 @tab
17117 @item
17119 `Ada_Pass_By_Copy'
17121 @tab
17123 Allowed for any types except by-reference types such as limited
17124 records. Compatible with convention Ada, but causes any parameters
17125 with this convention to be passed by copy.
17127 @item
17129 `Ada_Pass_By_Reference'
17131 @tab
17133 Allowed for any types except by-copy types such as scalars.
17134 Compatible with convention Ada, but causes any parameters
17135 with this convention to be passed by reference.
17137 @item
17139 `Assembler'
17141 @tab
17143 Assembly language
17145 @item
17147 `Asm'
17149 @tab
17151 Synonym for Assembler
17153 @item
17155 `Assembly'
17157 @tab
17159 Synonym for Assembler
17161 @item
17165 @tab
17169 @item
17171 `C_Pass_By_Copy'
17173 @tab
17175 Allowed only for record types, like C, but also notes that record
17176 is to be passed by copy rather than reference.
17178 @item
17180 `COBOL'
17182 @tab
17184 COBOL
17186 @item
17188 `C_Plus_Plus (or CPP)'
17190 @tab
17194 @item
17196 `Default'
17198 @tab
17200 Treated the same as C
17202 @item
17204 `External'
17206 @tab
17208 Treated the same as C
17210 @item
17212 `Fortran'
17214 @tab
17216 Fortran
17218 @item
17220 `Intrinsic'
17222 @tab
17224 For support of pragma @code{Import} with convention Intrinsic, see
17225 separate section on Intrinsic Subprograms.
17227 @item
17229 `Stdcall'
17231 @tab
17233 Stdcall (used for Windows implementations only).  This convention correspond
17234 to the WINAPI (previously called Pascal convention) C/C++ convention under
17235 Windows.  A routine with this convention cleans the stack before
17236 exit. This pragma cannot be applied to a dispatching call.
17238 @item
17240 `DLL'
17242 @tab
17244 Synonym for Stdcall
17246 @item
17248 `Win32'
17250 @tab
17252 Synonym for Stdcall
17254 @item
17256 `Stubbed'
17258 @tab
17260 Stubbed is a special convention used to indicate that the body of the
17261 subprogram will be entirely ignored.  Any call to the subprogram
17262 is converted into a raise of the @code{Program_Error} exception.  If a
17263 pragma @code{Import} specifies convention @code{stubbed} then no body need
17264 be present at all.  This convention is useful during development for the
17265 inclusion of subprograms whose body has not yet been written.
17266 In addition, all otherwise unrecognized convention names are also
17267 treated as being synonymous with convention C.  In all implementations,
17268 use of such other names results in a warning.
17270 @end multitable
17274 @itemize *
17276 @item 
17277 “The meaning of link names.  See B.1(36).”
17278 @end itemize
17280 Link names are the actual names used by the linker.
17283 @itemize *
17285 @item 
17286 “The manner of choosing link names when neither the link name nor the
17287 address of an imported or exported entity is specified.  See B.1(36).”
17288 @end itemize
17290 The default linker name is that which would be assigned by the relevant
17291 external language, interpreting the Ada name as being in all lower case
17292 letters.
17295 @itemize *
17297 @item 
17298 “The effect of pragma @code{Linker_Options}.  See B.1(37).”
17299 @end itemize
17301 The string passed to @code{Linker_Options} is presented uninterpreted as
17302 an argument to the link command, unless it contains ASCII.NUL characters.
17303 NUL characters if they appear act as argument separators, so for example
17305 @example
17306 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
17307 @end example
17309 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
17310 linker. The order of linker options is preserved for a given unit. The final
17311 list of options passed to the linker is in reverse order of the elaboration
17312 order. For example, linker options for a body always appear before the options
17313 from the corresponding package spec.
17316 @itemize *
17318 @item 
17319 “The contents of the visible part of package
17320 @code{Interfaces} and its language-defined descendants.  See B.2(1).”
17321 @end itemize
17323 See files with prefix @code{i-} in the distributed library.
17326 @itemize *
17328 @item 
17329 “Implementation-defined children of package
17330 @code{Interfaces}.  The contents of the visible part of package
17331 @code{Interfaces}.  See B.2(11).”
17332 @end itemize
17334 See files with prefix @code{i-} in the distributed library.
17337 @itemize *
17339 @item 
17340 “The definitions of certain types and constants in Interfaces.C.
17341 See B.3(41).”
17342 @end itemize
17344 See source file @code{i-c.ads}.
17347 @itemize *
17349 @item 
17350 “The types @code{Floating}, @code{Long_Floating},
17351 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
17352 @code{COBOL_Character}; and the initialization of the variables
17353 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
17354 @code{Interfaces.COBOL}.  See B.4(50).”
17355 @end itemize
17358 @multitable {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
17359 @headitem
17361 COBOL
17363 @tab
17367 @item
17369 `Floating'
17371 @tab
17373 Float
17375 @item
17377 `Long_Floating'
17379 @tab
17381 (Floating) Long_Float
17383 @item
17385 `Binary'
17387 @tab
17389 Integer
17391 @item
17393 `Long_Binary'
17395 @tab
17397 Long_Long_Integer
17399 @item
17401 `Decimal_Element'
17403 @tab
17405 Character
17407 @item
17409 `COBOL_Character'
17411 @tab
17413 Character
17415 @end multitable
17418 For initialization, see the file @code{i-cobol.ads} in the distributed library.
17421 @itemize *
17423 @item 
17424 “The types Fortran_Integer, Real, Double_Precision, and Character_Set
17425 in Interfaces.Fortran.  See B.5(17).”
17426 @end itemize
17428 See source file @code{i-fortra.ads}. These types are derived, respectively,
17429 from Integer, Float, Long_Float, and Character.
17432 @itemize *
17434 @item 
17435 “Implementation-defined intrinsic subprograms.  See C.1(1).”
17436 @end itemize
17438 See separate section on Intrinsic Subprograms.
17441 @itemize *
17443 @item 
17444 “Any restrictions on a protected procedure or its containing type when an
17445 aspect Attach_handler or Interrupt_Handler is specified.  See C.3.1(17).”
17446 @end itemize
17448 There are no such restrictions.
17451 @itemize *
17453 @item 
17454 “Any other forms of interrupt handler supported by the Attach_Handler and
17455 Interrupt_Handler aspects.  See C.3.1(19).”
17456 @end itemize
17458 There are no such forms.
17461 @itemize *
17463 @item 
17464 “The semantics of some attributes and functions of an entity for which
17465 aspect Discard_Names is True.  See C.5(7).”
17466 @end itemize
17468 If Discard_Names is True for an enumeration type, the Image attribute
17469 provides the image of the Pos of the literal, and Value accepts
17470 Pos values.
17472 If both of the aspects`@w{`}Discard_Names`@w{`} and @code{No_Tagged_Streams} are true
17473 for a tagged type, its Expanded_Name and External_Tag values are
17474 empty strings. This is useful to avoid exposing entity names at binary
17475 level.
17478 @itemize *
17480 @item 
17481 “The modulus and size of Test_and_Set_Flag.  See C.6.3(8).”
17482 @end itemize
17484 The modulus is 2**8. The size is 8.
17487 @itemize *
17489 @item 
17490 “The value used to represent the set value for Atomic_Test_and_Set.
17491 See C.6.3(10).”
17492 @end itemize
17494 The value is 1.
17497 @itemize *
17499 @item 
17500 “The result of the @code{Task_Identification.Image}
17501 attribute.  See C.7.1(7).”
17502 @end itemize
17504 The result of this attribute is a string that identifies
17505 the object or component that denotes a given task. If a variable @code{Var}
17506 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
17507 where the suffix `XXXXXXXX'
17508 is the hexadecimal representation of the virtual address of the corresponding
17509 task control block. If the variable is an array of tasks, the image of each
17510 task will have the form of an indexed component indicating the position of a
17511 given task in the array, e.g., @code{Group(5)_@var{XXXXXXX}}. If the task is a
17512 component of a record, the image of the task will have the form of a selected
17513 component. These rules are fully recursive, so that the image of a task that
17514 is a subcomponent of a composite object corresponds to the expression that
17515 designates this task.
17517 If a task is created by an allocator, its image depends on the context. If the
17518 allocator is part of an object declaration, the rules described above are used
17519 to construct its image, and this image is not affected by subsequent
17520 assignments. If the allocator appears within an expression, the image
17521 includes only the name of the task type.
17523 If the configuration pragma Discard_Names is present, or if the restriction
17524 No_Implicit_Heap_Allocation is in effect,  the image reduces to
17525 the numeric suffix, that is to say the hexadecimal representation of the
17526 virtual address of the control block of the task.
17529 @itemize *
17531 @item 
17532 “The value of @code{Current_Task} when in a protected entry
17533 or interrupt handler.  See C.7.1(17).”
17534 @end itemize
17536 Protected entries or interrupt handlers can be executed by any
17537 convenient thread, so the value of @code{Current_Task} is undefined.
17540 @itemize *
17542 @item 
17543 “Granularity of locking for Task_Attributes.  See C.7.2(16).”
17544 @end itemize
17546 No locking is needed if the formal type Attribute has the size and
17547 alignment of either Integer or System.Address and the bit representation
17548 of Initial_Value is all zeroes. Otherwise, locking is performed.
17551 @itemize *
17553 @item 
17554 “The declarations of @code{Any_Priority} and
17555 @code{Priority}.  See D.1(11).”
17556 @end itemize
17558 See declarations in file @code{system.ads}.
17561 @itemize *
17563 @item 
17564 “Implementation-defined execution resources.  See D.1(15).”
17565 @end itemize
17567 There are no implementation-defined execution resources.
17570 @itemize *
17572 @item 
17573 “Whether, on a multiprocessor, a task that is waiting for
17574 access to a protected object keeps its processor busy.  See D.2.1(3).”
17575 @end itemize
17577 On a multi-processor, a task that is waiting for access to a protected
17578 object does not keep its processor busy.
17581 @itemize *
17583 @item 
17584 “The affect of implementation defined execution resources
17585 on task dispatching.  See D.2.1(9).”
17586 @end itemize
17588 Tasks map to threads in the threads package used by GNAT.  Where possible
17589 and appropriate, these threads correspond to native threads of the
17590 underlying operating system.
17593 @itemize *
17595 @item 
17596 “Implementation-defined task dispatching policies.  See D.2.2(3).”
17597 @end itemize
17599 There are no implementation-defined task dispatching policies.
17602 @itemize *
17604 @item 
17605 “The value of Default_Quantum in Dispatching.Round_Robin.  See D.2.5(4).”
17606 @end itemize
17608 The value is 10 milliseconds.
17611 @itemize *
17613 @item 
17614 “Implementation-defined `policy_identifiers' allowed
17615 in a pragma @code{Locking_Policy}.  See D.3(4).”
17616 @end itemize
17618 The two implementation defined policies permitted in GNAT are
17619 @code{Inheritance_Locking} and  @code{Concurrent_Readers_Locking}. On
17620 targets that support the @code{Inheritance_Locking} policy, locking is
17621 implemented by inheritance, i.e., the task owning the lock operates
17622 at a priority equal to the highest priority of any task currently
17623 requesting the lock. On targets that support the
17624 @code{Concurrent_Readers_Locking} policy, locking is implemented with a
17625 read/write lock allowing multiple protected object functions to enter
17626 concurrently.
17629 @itemize *
17631 @item 
17632 “Default ceiling priorities.  See D.3(10).”
17633 @end itemize
17635 The ceiling priority of protected objects of the type
17636 @code{System.Interrupt_Priority'Last} as described in the Ada
17637 Reference Manual D.3(10),
17640 @itemize *
17642 @item 
17643 “The ceiling of any protected object used internally by
17644 the implementation.  See D.3(16).”
17645 @end itemize
17647 The ceiling priority of internal protected objects is
17648 @code{System.Priority'Last}.
17651 @itemize *
17653 @item 
17654 “Implementation-defined queuing policies.  See D.4(1).”
17655 @end itemize
17657 There are no implementation-defined queuing policies.
17660 @itemize *
17662 @item 
17663 “Implementation-defined admission policies.  See D.4.1(1).”
17664 @end itemize
17666 There are no implementation-defined admission policies.
17669 @itemize *
17671 @item 
17672 “Any operations that implicitly require heap storage
17673 allocation.  See D.7(8).”
17674 @end itemize
17676 The only operation that implicitly requires heap storage allocation is
17677 task creation.
17680 @itemize *
17682 @item 
17683 “When restriction No_Dynamic_CPU_Assignment applies to a partition, the
17684 processor on which a task with a CPU value of a Not_A_Specific_CPU will
17685 execute.  See D.7(10).”
17686 @end itemize
17688 Unknown.
17691 @itemize *
17693 @item 
17694 “When restriction No_Task_Termination applies to a partition, what happens
17695 when a task terminates.  See D.7(15.1).”
17696 @end itemize
17698 Execution is erroneous in that case.
17701 @itemize *
17703 @item 
17704 “The behavior when restriction Max_Storage_At_Blocking is violated.
17705 See D.7(17).”
17706 @end itemize
17708 Execution is erroneous in that case.
17711 @itemize *
17713 @item 
17714 “The behavior when restriction Max_Asynchronous_Select_Nesting is violated.
17715 See D.7(18).”
17716 @end itemize
17718 Execution is erroneous in that case.
17721 @itemize *
17723 @item 
17724 “The behavior when restriction Max_Tasks is violated.  See D.7(19).”
17725 @end itemize
17727 Execution is erroneous in that case.
17730 @itemize *
17732 @item 
17733 “Whether the use of pragma Restrictions results in a reduction in program
17734 code or data size or execution time.  See D.7(20).”
17735 @end itemize
17737 Yes it can, but the precise circumstances and properties of such reductions
17738 are difficult to characterize.
17741 @itemize *
17743 @item 
17744 “The value of Barrier_Limit’Last in Synchronous_Barriers.  See D.10.1(4).”
17745 @end itemize
17747 Synchronous_Barriers.Barrier_Limit’Last is Integer’Last .
17750 @itemize *
17752 @item 
17753 “When an aborted task that is waiting on a Synchronous_Barrier is aborted.
17754 See D.10.1(13).”
17755 @end itemize
17757 Difficult to characterize.
17760 @itemize *
17762 @item 
17763 “The value of Min_Handler_Ceiling in Execution_Time.Group_Budgets.
17764 See D.14.2(7).”
17765 @end itemize
17767 See source file @code{a-etgrbu.ads}.
17770 @itemize *
17772 @item 
17773 “The value of CPU_Range’Last in System.Multiprocessors.  See D.16(4).”
17774 @end itemize
17776 See source file @code{s-multip.ads}.
17779 @itemize *
17781 @item 
17782 “The processor on which the environment task executes in the absence
17783 of a value for the aspect CPU.  See D.16(13).”
17784 @end itemize
17786 Unknown.
17789 @itemize *
17791 @item 
17792 “The means for creating and executing distributed
17793 programs.  See E(5).”
17794 @end itemize
17796 The GLADE package provides a utility GNATDIST for creating and executing
17797 distributed programs. See the GLADE reference manual for further details.
17800 @itemize *
17802 @item 
17803 “Any events that can result in a partition becoming
17804 inaccessible.  See E.1(7).”
17805 @end itemize
17807 See the GLADE reference manual for full details on such events.
17810 @itemize *
17812 @item 
17813 “The scheduling policies, treatment of priorities, and management of
17814 shared resources between partitions in certain cases.  See E.1(11).”
17815 @end itemize
17817 See the GLADE reference manual for full details on these aspects of
17818 multi-partition execution.
17821 @itemize *
17823 @item 
17824 “Whether the execution of the remote subprogram is
17825 immediately aborted as a result of cancellation.  See E.4(13).”
17826 @end itemize
17828 See the GLADE reference manual for details on the effect of abort in
17829 a distributed application.
17832 @itemize *
17834 @item 
17835 “The range of type System.RPC.Partition_Id.  See E.5(14).”
17836 @end itemize
17838 System.RPC.Partition_ID’Last is Integer’Last. See source file @code{s-rpc.ads}.
17841 @itemize *
17843 @item 
17844 “Implementation-defined interfaces in the PCS.  See E.5(26).”
17845 @end itemize
17847 See the GLADE reference manual for a full description of all
17848 implementation defined interfaces.
17851 @itemize *
17853 @item 
17854 “The values of named numbers in the package
17855 @code{Decimal}.  See F.2(7).”
17856 @end itemize
17859 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxx} 
17860 @headitem
17862 Named Number
17864 @tab
17866 Value
17868 @item
17870 `Max_Scale'
17872 @tab
17876 @item
17878 `Min_Scale'
17880 @tab
17884 @item
17886 `Min_Delta'
17888 @tab
17890 1.0E-18
17892 @item
17894 `Max_Delta'
17896 @tab
17898 1.0E+18
17900 @item
17902 `Max_Decimal_Digits'
17904 @tab
17908 @end multitable
17912 @itemize *
17914 @item 
17915 “The value of @code{Max_Picture_Length} in the package
17916 @code{Text_IO.Editing}.  See F.3.3(16).”
17920 @item 
17921 “The value of @code{Max_Picture_Length} in the package
17922 @code{Wide_Text_IO.Editing}.  See F.3.4(5).”
17926 @item 
17927 “The accuracy actually achieved by the complex elementary
17928 functions and by other complex arithmetic operations.  See G.1(1).”
17929 @end itemize
17931 Standard library functions are used for the complex arithmetic
17932 operations.  Only fast math mode is currently supported.
17935 @itemize *
17937 @item 
17938 “The sign of a zero result (or a component thereof) from
17939 any operator or function in @code{Numerics.Generic_Complex_Types}, when
17940 @code{Real'Signed_Zeros} is True.  See G.1.1(53).”
17941 @end itemize
17943 The signs of zero values are as recommended by the relevant
17944 implementation advice.
17947 @itemize *
17949 @item 
17950 “The sign of a zero result (or a component thereof) from
17951 any operator or function in
17952 @code{Numerics.Generic_Complex_Elementary_Functions}, when
17953 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).”
17954 @end itemize
17956 The signs of zero values are as recommended by the relevant
17957 implementation advice.
17960 @itemize *
17962 @item 
17963 “Whether the strict mode or the relaxed mode is the
17964 default.  See G.2(2).”
17965 @end itemize
17967 The strict mode is the default.  There is no separate relaxed mode.  GNAT
17968 provides a highly efficient implementation of strict mode.
17971 @itemize *
17973 @item 
17974 “The result interval in certain cases of fixed-to-float
17975 conversion.  See G.2.1(10).”
17976 @end itemize
17978 For cases where the result interval is implementation dependent, the
17979 accuracy is that provided by performing all operations in 64-bit IEEE
17980 floating-point format.
17983 @itemize *
17985 @item 
17986 “The result of a floating point arithmetic operation in
17987 overflow situations, when the @code{Machine_Overflows} attribute of the
17988 result type is @code{False}.  See G.2.1(13).”
17989 @end itemize
17991 Infinite and NaN values are produced as dictated by the IEEE
17992 floating-point standard.
17993 Note that on machines that are not fully compliant with the IEEE
17994 floating-point standard, such as Alpha, the `-mieee' compiler flag
17995 must be used for achieving IEEE conforming behavior (although at the cost
17996 of a significant performance penalty), so infinite and NaN values are
17997 properly generated.
18000 @itemize *
18002 @item 
18003 “The result interval for division (or exponentiation by a
18004 negative exponent), when the floating point hardware implements division
18005 as multiplication by a reciprocal.  See G.2.1(16).”
18006 @end itemize
18008 Not relevant, division is IEEE exact.
18011 @itemize *
18013 @item 
18014 “The definition of close result set, which determines the accuracy of
18015 certain fixed point multiplications and divisions.  See G.2.3(5).”
18016 @end itemize
18018 Operations in the close result set are performed using IEEE long format
18019 floating-point arithmetic.  The input operands are converted to
18020 floating-point, the operation is done in floating-point, and the result
18021 is converted to the target type.
18024 @itemize *
18026 @item 
18027 “Conditions on a `universal_real' operand of a fixed
18028 point multiplication or division for which the result shall be in the
18029 perfect result set.  See G.2.3(22).”
18030 @end itemize
18032 The result is only defined to be in the perfect result set if the result
18033 can be computed by a single scaling operation involving a scale factor
18034 representable in 64 bits.
18037 @itemize *
18039 @item 
18040 “The result of a fixed point arithmetic operation in
18041 overflow situations, when the @code{Machine_Overflows} attribute of the
18042 result type is @code{False}.  See G.2.3(27).”
18043 @end itemize
18045 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
18046 types.
18049 @itemize *
18051 @item 
18052 “The result of an elementary function reference in
18053 overflow situations, when the @code{Machine_Overflows} attribute of the
18054 result type is @code{False}.  See G.2.4(4).”
18055 @end itemize
18057 IEEE infinite and Nan values are produced as appropriate.
18060 @itemize *
18062 @item 
18063 “The value of the angle threshold, within which certain
18064 elementary functions, complex arithmetic operations, and complex
18065 elementary functions yield results conforming to a maximum relative
18066 error bound.  See G.2.4(10).”
18067 @end itemize
18069 Information on this subject is not yet available.
18072 @itemize *
18074 @item 
18075 “The accuracy of certain elementary functions for
18076 parameters beyond the angle threshold.  See G.2.4(10).”
18077 @end itemize
18079 Information on this subject is not yet available.
18082 @itemize *
18084 @item 
18085 “The result of a complex arithmetic operation or complex
18086 elementary function reference in overflow situations, when the
18087 @code{Machine_Overflows} attribute of the corresponding real type is
18088 @code{False}.  See G.2.6(5).”
18089 @end itemize
18091 IEEE infinite and Nan values are produced as appropriate.
18094 @itemize *
18096 @item 
18097 “The accuracy of certain complex arithmetic operations and
18098 certain complex elementary functions for parameters (or components
18099 thereof) beyond the angle threshold.  See G.2.6(8).”
18100 @end itemize
18102 Information on those subjects is not yet available.
18105 @itemize *
18107 @item 
18108 “The accuracy requirements for the subprograms Solve, Inverse,
18109 Determinant, Eigenvalues and Eigensystem for type Real_Matrix.
18110 See G.3.1(81).”
18111 @end itemize
18113 Information on those subjects is not yet available.
18116 @itemize *
18118 @item 
18119 “The accuracy requirements for the subprograms Solve, Inverse,
18120 Determinant, Eigenvalues and Eigensystem for type Complex_Matrix.
18121 See G.3.2(149).”
18122 @end itemize
18124 Information on those subjects is not yet available.
18127 @itemize *
18129 @item 
18130 “The consequences of violating No_Hidden_Indirect_Globals.  See H.4(23.9).”
18131 @end itemize
18133 Execution is erroneous in that case.
18135 @node Intrinsic Subprograms,Representation Clauses and Pragmas,Implementation Defined Characteristics,Top
18136 @anchor{gnat_rm/intrinsic_subprograms doc}@anchor{269}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{26a}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c}
18137 @chapter Intrinsic Subprograms
18140 @geindex Intrinsic Subprograms
18142 GNAT allows a user application program to write the declaration:
18144 @example
18145 pragma Import (Intrinsic, name);
18146 @end example
18148 providing that the name corresponds to one of the implemented intrinsic
18149 subprograms in GNAT, and that the parameter profile of the referenced
18150 subprogram meets the requirements.  This chapter describes the set of
18151 implemented intrinsic subprograms, and the requirements on parameter profiles.
18152 Note that no body is supplied; as with other uses of pragma Import, the
18153 body is supplied elsewhere (in this case by the compiler itself).  Note
18154 that any use of this feature is potentially non-portable, since the
18155 Ada standard does not require Ada compilers to implement this feature.
18157 @menu
18158 * Intrinsic Operators:: 
18159 * Compilation_ISO_Date:: 
18160 * Compilation_Date:: 
18161 * Compilation_Time:: 
18162 * Enclosing_Entity:: 
18163 * Exception_Information:: 
18164 * Exception_Message:: 
18165 * Exception_Name:: 
18166 * File:: 
18167 * Line:: 
18168 * Shifts and Rotates:: 
18169 * Source_Location:: 
18171 @end menu
18173 @node Intrinsic Operators,Compilation_ISO_Date,,Intrinsic Subprograms
18174 @anchor{gnat_rm/intrinsic_subprograms id2}@anchor{26b}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{26c}
18175 @section Intrinsic Operators
18178 @geindex Intrinsic operator
18180 All the predefined numeric operators in package Standard
18181 in @code{pragma Import (Intrinsic,..)}
18182 declarations.  In the binary operator case, the operands must have the same
18183 size.  The operand or operands must also be appropriate for
18184 the operator.  For example, for addition, the operands must
18185 both be floating-point or both be fixed-point, and the
18186 right operand for @code{"**"} must have a root type of
18187 @code{Standard.Integer'Base}.
18188 You can use an intrinsic operator declaration as in the following example:
18190 @example
18191 type Int1 is new Integer;
18192 type Int2 is new Integer;
18194 function "+" (X1 : Int1; X2 : Int2) return Int1;
18195 function "+" (X1 : Int1; X2 : Int2) return Int2;
18196 pragma Import (Intrinsic, "+");
18197 @end example
18199 This declaration would permit ‘mixed mode’ arithmetic on items
18200 of the differing types @code{Int1} and @code{Int2}.
18201 It is also possible to specify such operators for private types, if the
18202 full views are appropriate arithmetic types.
18204 @node Compilation_ISO_Date,Compilation_Date,Intrinsic Operators,Intrinsic Subprograms
18205 @anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{26d}@anchor{gnat_rm/intrinsic_subprograms id3}@anchor{26e}
18206 @section Compilation_ISO_Date
18209 @geindex Compilation_ISO_Date
18211 This intrinsic subprogram is used in the implementation of the
18212 library package @code{GNAT.Source_Info}.  The only useful use of the
18213 intrinsic import in this case is the one in this unit, so an
18214 application program should simply call the function
18215 @code{GNAT.Source_Info.Compilation_ISO_Date} to obtain the date of
18216 the current compilation (in local time format YYYY-MM-DD).
18218 @node Compilation_Date,Compilation_Time,Compilation_ISO_Date,Intrinsic Subprograms
18219 @anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{26f}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{270}
18220 @section Compilation_Date
18223 @geindex Compilation_Date
18225 Same as Compilation_ISO_Date, except the string is in the form
18226 MMM DD YYYY.
18228 @node Compilation_Time,Enclosing_Entity,Compilation_Date,Intrinsic Subprograms
18229 @anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{271}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{272}
18230 @section Compilation_Time
18233 @geindex Compilation_Time
18235 This intrinsic subprogram is used in the implementation of the
18236 library package @code{GNAT.Source_Info}.  The only useful use of the
18237 intrinsic import in this case is the one in this unit, so an
18238 application program should simply call the function
18239 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
18240 the current compilation (in local time format HH:MM:SS).
18242 @node Enclosing_Entity,Exception_Information,Compilation_Time,Intrinsic Subprograms
18243 @anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{273}@anchor{gnat_rm/intrinsic_subprograms id6}@anchor{274}
18244 @section Enclosing_Entity
18247 @geindex Enclosing_Entity
18249 This intrinsic subprogram is used in the implementation of the
18250 library package @code{GNAT.Source_Info}.  The only useful use of the
18251 intrinsic import in this case is the one in this unit, so an
18252 application program should simply call the function
18253 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
18254 the current subprogram, package, task, entry, or protected subprogram.
18256 @node Exception_Information,Exception_Message,Enclosing_Entity,Intrinsic Subprograms
18257 @anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{275}@anchor{gnat_rm/intrinsic_subprograms id7}@anchor{276}
18258 @section Exception_Information
18261 @geindex Exception_Information'
18263 This intrinsic subprogram is used in the implementation of the
18264 library package @code{GNAT.Current_Exception}.  The only useful
18265 use of the intrinsic import in this case is the one in this unit,
18266 so an application program should simply call the function
18267 @code{GNAT.Current_Exception.Exception_Information} to obtain
18268 the exception information associated with the current exception.
18270 @node Exception_Message,Exception_Name,Exception_Information,Intrinsic Subprograms
18271 @anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{277}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{278}
18272 @section Exception_Message
18275 @geindex Exception_Message
18277 This intrinsic subprogram is used in the implementation of the
18278 library package @code{GNAT.Current_Exception}.  The only useful
18279 use of the intrinsic import in this case is the one in this unit,
18280 so an application program should simply call the function
18281 @code{GNAT.Current_Exception.Exception_Message} to obtain
18282 the message associated with the current exception.
18284 @node Exception_Name,File,Exception_Message,Intrinsic Subprograms
18285 @anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{279}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{27a}
18286 @section Exception_Name
18289 @geindex Exception_Name
18291 This intrinsic subprogram is used in the implementation of the
18292 library package @code{GNAT.Current_Exception}.  The only useful
18293 use of the intrinsic import in this case is the one in this unit,
18294 so an application program should simply call the function
18295 @code{GNAT.Current_Exception.Exception_Name} to obtain
18296 the name of the current exception.
18298 @node File,Line,Exception_Name,Intrinsic Subprograms
18299 @anchor{gnat_rm/intrinsic_subprograms file}@anchor{27b}@anchor{gnat_rm/intrinsic_subprograms id10}@anchor{27c}
18300 @section File
18303 @geindex File
18305 This intrinsic subprogram is used in the implementation of the
18306 library package @code{GNAT.Source_Info}.  The only useful use of the
18307 intrinsic import in this case is the one in this unit, so an
18308 application program should simply call the function
18309 @code{GNAT.Source_Info.File} to obtain the name of the current
18310 file.
18312 @node Line,Shifts and Rotates,File,Intrinsic Subprograms
18313 @anchor{gnat_rm/intrinsic_subprograms id11}@anchor{27d}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{27e}
18314 @section Line
18317 @geindex Line
18319 This intrinsic subprogram is used in the implementation of the
18320 library package @code{GNAT.Source_Info}.  The only useful use of the
18321 intrinsic import in this case is the one in this unit, so an
18322 application program should simply call the function
18323 @code{GNAT.Source_Info.Line} to obtain the number of the current
18324 source line.
18326 @node Shifts and Rotates,Source_Location,Line,Intrinsic Subprograms
18327 @anchor{gnat_rm/intrinsic_subprograms id12}@anchor{27f}@anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{280}
18328 @section Shifts and Rotates
18331 @geindex Shift_Left
18333 @geindex Shift_Right
18335 @geindex Shift_Right_Arithmetic
18337 @geindex Rotate_Left
18339 @geindex Rotate_Right
18341 In standard Ada, the shift and rotate functions are available only
18342 for the predefined modular types in package @code{Interfaces}.  However, in
18343 GNAT it is possible to define these functions for any integer
18344 type (signed or modular), as in this example:
18346 @example
18347 function Shift_Left
18348   (Value  : T;
18349    Amount : Natural) return T
18350 with Import, Convention => Intrinsic;
18351 @end example
18353 The function name must be one of
18354 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
18355 Rotate_Right. T must be an integer type. T’Size must be
18356 8, 16, 32 or 64 bits; if T is modular, the modulus
18357 must be 2**8, 2**16, 2**32 or 2**64.
18358 The result type must be the same as the type of @code{Value}.
18359 The shift amount must be Natural.
18360 The formal parameter names can be anything.
18362 A more convenient way of providing these shift operators is to use the
18363 Provide_Shift_Operators pragma, which provides the function declarations and
18364 corresponding pragma Import’s for all five shift functions. For signed types
18365 the semantics of these operators is to interpret the bitwise result of the
18366 corresponding operator for modular type. In particular, shifting a negative
18367 number may change its sign bit to positive.
18369 @node Source_Location,,Shifts and Rotates,Intrinsic Subprograms
18370 @anchor{gnat_rm/intrinsic_subprograms id13}@anchor{281}@anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{282}
18371 @section Source_Location
18374 @geindex Source_Location
18376 This intrinsic subprogram is used in the implementation of the
18377 library routine @code{GNAT.Source_Info}.  The only useful use of the
18378 intrinsic import in this case is the one in this unit, so an
18379 application program should simply call the function
18380 @code{GNAT.Source_Info.Source_Location} to obtain the current
18381 source file location.
18383 @node Representation Clauses and Pragmas,Standard Library Routines,Intrinsic Subprograms,Top
18384 @anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{283}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{284}@anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d}
18385 @chapter Representation Clauses and Pragmas
18388 @geindex Representation Clauses
18390 @geindex Representation Clause
18392 @geindex Representation Pragma
18394 @geindex Pragma
18395 @geindex representation
18397 This section describes the representation clauses accepted by GNAT, and
18398 their effect on the representation of corresponding data objects.
18400 GNAT fully implements Annex C (Systems Programming).  This means that all
18401 the implementation advice sections in chapter 13 are fully implemented.
18402 However, these sections only require a minimal level of support for
18403 representation clauses.  GNAT provides much more extensive capabilities,
18404 and this section describes the additional capabilities provided.
18406 @menu
18407 * Alignment Clauses:: 
18408 * Size Clauses:: 
18409 * Storage_Size Clauses:: 
18410 * Size of Variant Record Objects:: 
18411 * Biased Representation:: 
18412 * Value_Size and Object_Size Clauses:: 
18413 * Component_Size Clauses:: 
18414 * Bit_Order Clauses:: 
18415 * Effect of Bit_Order on Byte Ordering:: 
18416 * Pragma Pack for Arrays:: 
18417 * Pragma Pack for Records:: 
18418 * Record Representation Clauses:: 
18419 * Handling of Records with Holes:: 
18420 * Enumeration Clauses:: 
18421 * Address Clauses:: 
18422 * Use of Address Clauses for Memory-Mapped I/O:: 
18423 * Effect of Convention on Representation:: 
18424 * Conventions and Anonymous Access Types:: 
18425 * Determining the Representations chosen by GNAT:: 
18427 @end menu
18429 @node Alignment Clauses,Size Clauses,,Representation Clauses and Pragmas
18430 @anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{285}@anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{286}
18431 @section Alignment Clauses
18434 @geindex Alignment Clause
18436 GNAT requires that all alignment clauses specify 0 or a power of 2, and
18437 all default alignments are always a power of 2. Specifying 0 is the
18438 same as specifying 1.
18440 The default alignment values are as follows:
18443 @itemize *
18445 @item 
18446 `Elementary Types'.
18448 For elementary types, the alignment is the minimum of the actual size of
18449 objects of the type divided by @code{Storage_Unit},
18450 and the maximum alignment supported by the target.
18451 (This maximum alignment is given by the GNAT-specific attribute
18452 @code{Standard'Maximum_Alignment}; see @ref{196,,Attribute Maximum_Alignment}.)
18454 @geindex Maximum_Alignment attribute
18456 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
18457 default alignment will be 8 on any target that supports alignments
18458 this large, but on some targets, the maximum alignment may be smaller
18459 than 8, in which case objects of type @code{Long_Float} will be maximally
18460 aligned.
18462 @item 
18463 `Arrays'.
18465 For arrays, the alignment is equal to the alignment of the component type
18466 for the normal case where no packing or component size is given.  If the
18467 array is packed, and the packing is effective (see separate section on
18468 packed arrays), then the alignment will be either 4, 2, or 1 for long packed
18469 arrays or arrays whose length is not known at compile time, depending on
18470 whether the component size is divisible by 4, 2, or is odd.  For short packed
18471 arrays, which are handled internally as modular types, the alignment
18472 will be as described for elementary types, e.g. a packed array of length
18473 31 bits will have an object size of four bytes, and an alignment of 4.
18475 @item 
18476 `Records'.
18478 For the normal unpacked case, the alignment of a record is equal to
18479 the maximum alignment of any of its components.  For tagged records, this
18480 includes the implicit access type used for the tag.  If a pragma @code{Pack}
18481 is used and all components are packable (see separate section on pragma
18482 @code{Pack}), then the resulting alignment is 1, unless the layout of the
18483 record makes it profitable to increase it.
18485 A special case is when:
18488 @itemize *
18490 @item 
18491 the size of the record is given explicitly, or a
18492 full record representation clause is given, and
18494 @item 
18495 the size of the record is 2, 4, or 8 bytes.
18496 @end itemize
18498 In this case, an alignment is chosen to match the
18499 size of the record. For example, if we have:
18501 @example
18502 type Small is record
18503    A, B : Character;
18504 end record;
18505 for Small'Size use 16;
18506 @end example
18508 then the default alignment of the record type @code{Small} is 2, not 1. This
18509 leads to more efficient code when the record is treated as a unit, and also
18510 allows the type to specified as @code{Atomic} on architectures requiring
18511 strict alignment.
18512 @end itemize
18514 An alignment clause may specify a larger alignment than the default value
18515 up to some maximum value dependent on the target (obtainable by using the
18516 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
18517 a smaller alignment than the default value for enumeration, integer and
18518 fixed point types, as well as for record types, for example
18520 @example
18521 type V is record
18522    A : Integer;
18523 end record;
18525 for V'alignment use 1;
18526 @end example
18528 @geindex Alignment
18529 @geindex default
18531 The default alignment for the type @code{V} is 4, as a result of the
18532 Integer field in the record, but it is permissible, as shown, to
18533 override the default alignment of the record with a smaller value.
18535 @geindex Alignment
18536 @geindex subtypes
18538 Note that according to the Ada standard, an alignment clause applies only
18539 to the first named subtype. If additional subtypes are declared, then the
18540 compiler is allowed to choose any alignment it likes, and there is no way
18541 to control this choice. Consider:
18543 @example
18544 type R is range 1 .. 10_000;
18545 for R'Alignment use 1;
18546 subtype RS is R range 1 .. 1000;
18547 @end example
18549 The alignment clause specifies an alignment of 1 for the first named subtype
18550 @code{R} but this does not necessarily apply to @code{RS}. When writing
18551 portable Ada code, you should avoid writing code that explicitly or
18552 implicitly relies on the alignment of such subtypes.
18554 For the GNAT compiler, if an explicit alignment clause is given, this
18555 value is also used for any subsequent subtypes. So for GNAT, in the
18556 above example, you can count on the alignment of @code{RS} being 1. But this
18557 assumption is non-portable, and other compilers may choose different
18558 alignments for the subtype @code{RS}.
18560 @node Size Clauses,Storage_Size Clauses,Alignment Clauses,Representation Clauses and Pragmas
18561 @anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{287}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{288}
18562 @section Size Clauses
18565 @geindex Size Clause
18567 The default size for a type @code{T} is obtainable through the
18568 language-defined attribute @code{T'Size} and also through the
18569 equivalent GNAT-defined attribute @code{T'Value_Size}.
18570 For objects of type @code{T}, GNAT will generally increase the type size
18571 so that the object size (obtainable through the GNAT-defined attribute
18572 @code{T'Object_Size})
18573 is a multiple of @code{T'Alignment * Storage_Unit}.
18575 For example:
18577 @example
18578 type Smallint is range 1 .. 6;
18580 type Rec is record
18581    Y1 : integer;
18582    Y2 : boolean;
18583 end record;
18584 @end example
18586 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
18587 as specified by the RM rules,
18588 but objects of this type will have a size of 8
18589 (@code{Smallint'Object_Size} = 8),
18590 since objects by default occupy an integral number
18591 of storage units.  On some targets, notably older
18592 versions of the Digital Alpha, the size of stand
18593 alone objects of this type may be 32, reflecting
18594 the inability of the hardware to do byte load/stores.
18596 Similarly, the size of type @code{Rec} is 40 bits
18597 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
18598 the alignment is 4, so objects of this type will have
18599 their size increased to 64 bits so that it is a multiple
18600 of the alignment (in bits).  This decision is
18601 in accordance with the specific Implementation Advice in RM 13.3(43):
18603 @quotation
18605 “A @code{Size} clause should be supported for an object if the specified
18606 @code{Size} is at least as large as its subtype’s @code{Size}, and corresponds
18607 to a size in storage elements that is a multiple of the object’s
18608 @code{Alignment} (if the @code{Alignment} is nonzero).”
18609 @end quotation
18611 An explicit size clause may be used to override the default size by
18612 increasing it.  For example, if we have:
18614 @example
18615 type My_Boolean is new Boolean;
18616 for My_Boolean'Size use 32;
18617 @end example
18619 then values of this type will always be 32-bit long.  In the case of discrete
18620 types, the size can be increased up to 64 bits on 32-bit targets and 128 bits
18621 on 64-bit targets, with the effect that the entire specified field is used to
18622 hold the value, sign- or zero-extended as appropriate.  If more than 64 bits
18623 or 128 bits resp. is specified, then padding space is allocated after the
18624 value, and a warning is issued that there are unused bits.
18626 Similarly the size of records and arrays may be increased, and the effect
18627 is to add padding bits after the value.  This also causes a warning message
18628 to be generated.
18630 The largest Size value permitted in GNAT is 2**31-1.  Since this is a
18631 Size in bits, this corresponds to an object of size 256 megabytes (minus
18632 one).  This limitation is true on all targets.  The reason for this
18633 limitation is that it improves the quality of the code in many cases
18634 if it is known that a Size value can be accommodated in an object of
18635 type Integer.
18637 @node Storage_Size Clauses,Size of Variant Record Objects,Size Clauses,Representation Clauses and Pragmas
18638 @anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{289}@anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{28a}
18639 @section Storage_Size Clauses
18642 @geindex Storage_Size Clause
18644 For tasks, the @code{Storage_Size} clause specifies the amount of space
18645 to be allocated for the task stack.  This cannot be extended, and if the
18646 stack is exhausted, then @code{Storage_Error} will be raised (if stack
18647 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
18648 or a @code{Storage_Size} pragma in the task definition to set the
18649 appropriate required size.  A useful technique is to include in every
18650 task definition a pragma of the form:
18652 @example
18653 pragma Storage_Size (Default_Stack_Size);
18654 @end example
18656 Then @code{Default_Stack_Size} can be defined in a global package, and
18657 modified as required. Any tasks requiring stack sizes different from the
18658 default can have an appropriate alternative reference in the pragma.
18660 You can also use the `-d' binder switch to modify the default stack
18661 size.
18663 For access types, the @code{Storage_Size} clause specifies the maximum
18664 space available for allocation of objects of the type.  If this space is
18665 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
18666 In the case where the access type is declared local to a subprogram, the
18667 use of a @code{Storage_Size} clause triggers automatic use of a special
18668 predefined storage pool (@code{System.Pool_Size}) that ensures that all
18669 space for the pool is automatically reclaimed on exit from the scope in
18670 which the type is declared.
18672 A special case recognized by the compiler is the specification of a
18673 @code{Storage_Size} of zero for an access type.  This means that no
18674 items can be allocated from the pool, and this is recognized at compile
18675 time, and all the overhead normally associated with maintaining a fixed
18676 size storage pool is eliminated.  Consider the following example:
18678 @example
18679 procedure p is
18680    type R is array (Natural) of Character;
18681    type P is access all R;
18682    for P'Storage_Size use 0;
18683    --  Above access type intended only for interfacing purposes
18685    y : P;
18687    procedure g (m : P);
18688    pragma Import (C, g);
18690    --  ...
18692 begin
18693    --  ...
18694    y := new R;
18695 end;
18696 @end example
18698 As indicated in this example, these dummy storage pools are often useful in
18699 connection with interfacing where no object will ever be allocated.  If you
18700 compile the above example, you get the warning:
18702 @example
18703 p.adb:16:09: warning: allocation from empty storage pool
18704 p.adb:16:09: warning: Storage_Error will be raised at run time
18705 @end example
18707 Of course in practice, there will not be any explicit allocators in the
18708 case of such an access declaration.
18710 @node Size of Variant Record Objects,Biased Representation,Storage_Size Clauses,Representation Clauses and Pragmas
18711 @anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{28b}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{28c}
18712 @section Size of Variant Record Objects
18715 @geindex Size
18716 @geindex variant record objects
18718 @geindex Variant record objects
18719 @geindex size
18721 In the case of variant record objects, there is a question whether Size gives
18722 information about a particular variant, or the maximum size required
18723 for any variant.  Consider the following program
18725 @example
18726 with Text_IO; use Text_IO;
18727 procedure q is
18728    type R1 (A : Boolean := False) is record
18729      case A is
18730        when True  => X : Character;
18731        when False => null;
18732      end case;
18733    end record;
18735    V1 : R1 (False);
18736    V2 : R1;
18738 begin
18739    Put_Line (Integer'Image (V1'Size));
18740    Put_Line (Integer'Image (V2'Size));
18741 end q;
18742 @end example
18744 Here we are dealing with a variant record, where the True variant
18745 requires 16 bits, and the False variant requires 8 bits.
18746 In the above example, both V1 and V2 contain the False variant,
18747 which is only 8 bits long.  However, the result of running the
18748 program is:
18750 @example
18753 @end example
18755 The reason for the difference here is that the discriminant value of
18756 V1 is fixed, and will always be False.  It is not possible to assign
18757 a True variant value to V1, therefore 8 bits is sufficient.  On the
18758 other hand, in the case of V2, the initial discriminant value is
18759 False (from the default), but it is possible to assign a True
18760 variant value to V2, therefore 16 bits must be allocated for V2
18761 in the general case, even fewer bits may be needed at any particular
18762 point during the program execution.
18764 As can be seen from the output of this program, the @code{'Size}
18765 attribute applied to such an object in GNAT gives the actual allocated
18766 size of the variable, which is the largest size of any of the variants.
18767 The Ada Reference Manual is not completely clear on what choice should
18768 be made here, but the GNAT behavior seems most consistent with the
18769 language in the RM.
18771 In some cases, it may be desirable to obtain the size of the current
18772 variant, rather than the size of the largest variant.  This can be
18773 achieved in GNAT by making use of the fact that in the case of a
18774 subprogram parameter, GNAT does indeed return the size of the current
18775 variant (because a subprogram has no way of knowing how much space
18776 is actually allocated for the actual).
18778 Consider the following modified version of the above program:
18780 @example
18781 with Text_IO; use Text_IO;
18782 procedure q is
18783    type R1 (A : Boolean := False) is record
18784      case A is
18785        when True  => X : Character;
18786        when False => null;
18787      end case;
18788    end record;
18790    V2 : R1;
18792    function Size (V : R1) return Integer is
18793    begin
18794       return V'Size;
18795    end Size;
18797 begin
18798    Put_Line (Integer'Image (V2'Size));
18799    Put_Line (Integer'Image (Size (V2)));
18800    V2 := (True, 'x');
18801    Put_Line (Integer'Image (V2'Size));
18802    Put_Line (Integer'Image (Size (V2)));
18803 end q;
18804 @end example
18806 The output from this program is
18808 @example
18813 @end example
18815 Here we see that while the @code{'Size} attribute always returns
18816 the maximum size, regardless of the current variant value, the
18817 @code{Size} function does indeed return the size of the current
18818 variant value.
18820 @node Biased Representation,Value_Size and Object_Size Clauses,Size of Variant Record Objects,Representation Clauses and Pragmas
18821 @anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{28d}@anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{28e}
18822 @section Biased Representation
18825 @geindex Size for biased representation
18827 @geindex Biased representation
18829 In the case of scalars with a range starting at other than zero, it is
18830 possible in some cases to specify a size smaller than the default minimum
18831 value, and in such cases, GNAT uses an unsigned biased representation,
18832 in which zero is used to represent the lower bound, and successive values
18833 represent successive values of the type.
18835 For example, suppose we have the declaration:
18837 @example
18838 type Small is range -7 .. -4;
18839 for Small'Size use 2;
18840 @end example
18842 Although the default size of type @code{Small} is 4, the @code{Size}
18843 clause is accepted by GNAT and results in the following representation
18844 scheme:
18846 @example
18847 -7 is represented as 2#00#
18848 -6 is represented as 2#01#
18849 -5 is represented as 2#10#
18850 -4 is represented as 2#11#
18851 @end example
18853 Biased representation is only used if the specified @code{Size} clause
18854 cannot be accepted in any other manner.  These reduced sizes that force
18855 biased representation can be used for all discrete types except for
18856 enumeration types for which a representation clause is given.
18858 @node Value_Size and Object_Size Clauses,Component_Size Clauses,Biased Representation,Representation Clauses and Pragmas
18859 @anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{28f}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{290}
18860 @section Value_Size and Object_Size Clauses
18863 @geindex Value_Size
18865 @geindex Object_Size
18867 @geindex Size
18868 @geindex of objects
18870 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
18871 number of bits required to hold values of type @code{T}.
18872 Although this interpretation was allowed in Ada 83, it was not required,
18873 and this requirement in practice can cause some significant difficulties.
18874 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
18875 However, in Ada 95 and Ada 2005,
18876 @code{Natural'Size} is
18877 typically 31.  This means that code may change in behavior when moving
18878 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
18880 @example
18881 type Rec is record
18882    A : Natural;
18883    B : Natural;
18884 end record;
18886 for Rec use record
18887    A at 0 range 0 .. Natural'Size - 1;
18888    B at 0 range Natural'Size .. 2 * Natural'Size - 1;
18889 end record;
18890 @end example
18892 In the above code, since the typical size of @code{Natural} objects
18893 is 32 bits and @code{Natural'Size} is 31, the above code can cause
18894 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
18895 there are cases where the fact that the object size can exceed the
18896 size of the type causes surprises.
18898 To help get around this problem GNAT provides two implementation
18899 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
18900 applied to a type, these attributes yield the size of the type
18901 (corresponding to the RM defined size attribute), and the size of
18902 objects of the type respectively.
18904 The @code{Object_Size} is used for determining the default size of
18905 objects and components.  This size value can be referred to using the
18906 @code{Object_Size} attribute.  The phrase ‘is used’ here means that it is
18907 the basis of the determination of the size.  The backend is free to
18908 pad this up if necessary for efficiency, e.g., an 8-bit stand-alone
18909 character might be stored in 32 bits on a machine with no efficient
18910 byte access instructions such as the Alpha.
18912 The default rules for the value of @code{Object_Size} for
18913 discrete types are as follows:
18916 @itemize *
18918 @item 
18919 The @code{Object_Size} for base subtypes reflect the natural hardware
18920 size in bits (run the compiler with `-gnatS' to find those values
18921 for numeric types). Enumeration types and fixed-point base subtypes have
18922 8, 16, 32, or 64 bits for this size, depending on the range of values
18923 to be stored.
18925 @item 
18926 The @code{Object_Size} of a subtype is the same as the
18927 @code{Object_Size} of
18928 the type from which it is obtained.
18930 @item 
18931 The @code{Object_Size} of a derived base type is copied from the parent
18932 base type, and the @code{Object_Size} of a derived first subtype is copied
18933 from the parent first subtype.
18934 @end itemize
18936 The @code{Value_Size} attribute
18937 is the (minimum) number of bits required to store a value
18938 of the type.
18939 This value is used to determine how tightly to pack
18940 records or arrays with components of this type, and also affects
18941 the semantics of unchecked conversion (unchecked conversions where
18942 the @code{Value_Size} values differ generate a warning, and are potentially
18943 target dependent).
18945 The default rules for the value of @code{Value_Size} are as follows:
18948 @itemize *
18950 @item 
18951 The @code{Value_Size} for a base subtype is the minimum number of bits
18952 required to store all values of the type (including the sign bit
18953 only if negative values are possible).
18955 @item 
18956 If a subtype statically matches the first subtype of a given type, then it has
18957 by default the same @code{Value_Size} as the first subtype.  (This is a
18958 consequence of RM 13.1(14): “if two subtypes statically match,
18959 then their subtype-specific aspects are the same”.)
18961 @item 
18962 All other subtypes have a @code{Value_Size} corresponding to the minimum
18963 number of bits required to store all values of the subtype.  For
18964 dynamic bounds, it is assumed that the value can range down or up
18965 to the corresponding bound of the ancestor
18966 @end itemize
18968 The RM defined attribute @code{Size} corresponds to the
18969 @code{Value_Size} attribute.
18971 The @code{Size} attribute may be defined for a first-named subtype.  This sets
18972 the @code{Value_Size} of
18973 the first-named subtype to the given value, and the
18974 @code{Object_Size} of this first-named subtype to the given value padded up
18975 to an appropriate boundary.  It is a consequence of the default rules
18976 above that this @code{Object_Size} will apply to all further subtypes.  On the
18977 other hand, @code{Value_Size} is affected only for the first subtype, any
18978 dynamic subtypes obtained from it directly, and any statically matching
18979 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
18981 @code{Value_Size} and
18982 @code{Object_Size} may be explicitly set for any subtype using
18983 an attribute definition clause.  Note that the use of these attributes
18984 can cause the RM 13.1(14) rule to be violated.  If two access types
18985 reference aliased objects whose subtypes have differing @code{Object_Size}
18986 values as a result of explicit attribute definition clauses, then it
18987 is illegal to convert from one access subtype to the other. For a more
18988 complete description of this additional legality rule, see the
18989 description of the @code{Object_Size} attribute.
18991 To get a feel for the difference, consider the following examples (note
18992 that in each case the base is @code{Short_Short_Integer} with a size of 8):
18995 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} 
18996 @headitem
18998 Type or subtype declaration
19000 @tab
19002 Object_Size
19004 @tab
19006 Value_Size
19008 @item
19010 @code{type x1 is range 0 .. 5;}
19012 @tab
19016 @tab
19020 @item
19022 @code{type x2 is range 0 .. 5;}
19023 @code{for x2'size use 12;}
19025 @tab
19029 @tab
19033 @item
19035 @code{subtype x3 is x2 range 0 .. 3;}
19037 @tab
19041 @tab
19045 @item
19047 @code{subtype x4 is x2'base range 0 .. 10;}
19049 @tab
19053 @tab
19057 @item
19059 @code{dynamic : x2'Base range -64 .. +63;}
19061 @tab
19063 @tab
19065 @item
19067 @code{subtype x5 is x2 range 0 .. dynamic;}
19069 @tab
19073 @tab
19077 @item
19079 @code{subtype x6 is x2'base range 0 .. dynamic;}
19081 @tab
19085 @tab
19089 @end multitable
19092 Note: the entries marked ‘*’ are not actually specified by the Ada
19093 Reference Manual, which has nothing to say about size in the dynamic
19094 case. What GNAT does is to allocate sufficient bits to accommodate any
19095 possible dynamic values for the bounds at run-time.
19097 So far, so good, but GNAT has to obey the RM rules, so the question is
19098 under what conditions must the RM @code{Size} be used.
19099 The following is a list
19100 of the occasions on which the RM @code{Size} must be used:
19103 @itemize *
19105 @item 
19106 Component size for packed arrays or records
19108 @item 
19109 Value of the attribute @code{Size} for a type
19111 @item 
19112 Warning about sizes not matching for unchecked conversion
19113 @end itemize
19115 For record types, the @code{Object_Size} is always a multiple of the
19116 alignment of the type (this is true for all types). In some cases the
19117 @code{Value_Size} can be smaller. Consider:
19119 @example
19120 type R is record
19121   X : Integer;
19122   Y : Character;
19123 end record;
19124 @end example
19126 On a typical 32-bit architecture, the X component will occupy four bytes
19127 and the Y component will occupy one byte, for a total of 5 bytes. As a
19128 result @code{R'Value_Size} will be 40 (bits) since this is the minimum size
19129 required to store a value of this type. For example, it is permissible
19130 to have a component of type R in an array whose component size is
19131 specified to be 40 bits.
19133 However, @code{R'Object_Size} will be 64 (bits). The difference is due to
19134 the alignment requirement for objects of the record type. The X
19135 component will require four-byte alignment because that is what type
19136 Integer requires, whereas the Y component, a Character, will only
19137 require 1-byte alignment. Since the alignment required for X is the
19138 greatest of all the components’ alignments, that is the alignment
19139 required for the enclosing record type, i.e., 4 bytes or 32 bits. As
19140 indicated above, the actual object size must be rounded up so that it is
19141 a multiple of the alignment value. Therefore, 40 bits rounded up to the
19142 next multiple of 32 yields 64 bits.
19144 For all other types, the @code{Object_Size}
19145 and @code{Value_Size} are the same (and equivalent to the RM attribute @code{Size}).
19146 Only @code{Size} may be specified for such types.
19148 Note that @code{Value_Size} can be used to force biased representation
19149 for a particular subtype. Consider this example:
19151 @example
19152 type R is (A, B, C, D, E, F);
19153 subtype RAB is R range A .. B;
19154 subtype REF is R range E .. F;
19155 @end example
19157 By default, @code{RAB}
19158 has a size of 1 (sufficient to accommodate the representation
19159 of @code{A} and @code{B}, 0 and 1), and @code{REF}
19160 has a size of 3 (sufficient to accommodate the representation
19161 of @code{E} and @code{F}, 4 and 5). But if we add the
19162 following @code{Value_Size} attribute definition clause:
19164 @example
19165 for REF'Value_Size use 1;
19166 @end example
19168 then biased representation is forced for @code{REF},
19169 and 0 will represent @code{E} and 1 will represent @code{F}.
19170 A warning is issued when a @code{Value_Size} attribute
19171 definition clause forces biased representation. This
19172 warning can be turned off using @code{-gnatw.B}.
19174 @node Component_Size Clauses,Bit_Order Clauses,Value_Size and Object_Size Clauses,Representation Clauses and Pragmas
19175 @anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{291}@anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{292}
19176 @section Component_Size Clauses
19179 @geindex Component_Size Clause
19181 Normally, the value specified in a component size clause must be consistent
19182 with the subtype of the array component with regard to size and alignment.
19183 In other words, the value specified must be at least equal to the size
19184 of this subtype, and must be a multiple of the alignment value.
19186 In addition, component size clauses are allowed which cause the array
19187 to be packed, by specifying a smaller value.  A first case is for
19188 component size values in the range 1 through 63 on 32-bit targets,
19189 and 1 through 127 on 64-bit targets.  The value specified may not
19190 be smaller than the Size of the subtype.  GNAT will accurately
19191 honor all packing requests in this range.  For example, if we have:
19193 @example
19194 type r is array (1 .. 8) of Natural;
19195 for r'Component_Size use 31;
19196 @end example
19198 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
19199 Of course access to the components of such an array is considerably
19200 less efficient than if the natural component size of 32 is used.
19201 A second case is when the subtype of the component is a record type
19202 padded because of its default alignment.  For example, if we have:
19204 @example
19205 type r is record
19206   i : Integer;
19207   j : Integer;
19208   b : Boolean;
19209 end record;
19211 type a is array (1 .. 8) of r;
19212 for a'Component_Size use 72;
19213 @end example
19215 then the resulting array has a length of 72 bytes, instead of 96 bytes
19216 if the alignment of the record (4) was obeyed.
19218 Note that there is no point in giving both a component size clause
19219 and a pragma Pack for the same array type. if such duplicate
19220 clauses are given, the pragma Pack will be ignored.
19222 @node Bit_Order Clauses,Effect of Bit_Order on Byte Ordering,Component_Size Clauses,Representation Clauses and Pragmas
19223 @anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{293}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{294}
19224 @section Bit_Order Clauses
19227 @geindex Bit_Order Clause
19229 @geindex bit ordering
19231 @geindex ordering
19232 @geindex of bits
19234 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
19235 attribute.  The specification may either correspond to the default bit
19236 order for the target, in which case the specification has no effect and
19237 places no additional restrictions, or it may be for the non-standard
19238 setting (that is the opposite of the default).
19240 In the case where the non-standard value is specified, the effect is
19241 to renumber bits within each byte, but the ordering of bytes is not
19242 affected.  There are certain
19243 restrictions placed on component clauses as follows:
19246 @itemize *
19248 @item 
19249 Components fitting within a single storage unit.
19251 These are unrestricted, and the effect is merely to renumber bits.  For
19252 example if we are on a little-endian machine with @code{Low_Order_First}
19253 being the default, then the following two declarations have exactly
19254 the same effect:
19256 @example
19257 type R1 is record
19258    A : Boolean;
19259    B : Integer range 1 .. 120;
19260 end record;
19262 for R1 use record
19263    A at 0 range 0 .. 0;
19264    B at 0 range 1 .. 7;
19265 end record;
19267 type R2 is record
19268    A : Boolean;
19269    B : Integer range 1 .. 120;
19270 end record;
19272 for R2'Bit_Order use High_Order_First;
19274 for R2 use record
19275    A at 0 range 7 .. 7;
19276    B at 0 range 0 .. 6;
19277 end record;
19278 @end example
19280 The useful application here is to write the second declaration with the
19281 @code{Bit_Order} attribute definition clause, and know that it will be treated
19282 the same, regardless of whether the target is little-endian or big-endian.
19284 @item 
19285 Components occupying an integral number of bytes.
19287 These are components that exactly fit in two or more bytes.  Such component
19288 declarations are allowed, but have no effect, since it is important to realize
19289 that the @code{Bit_Order} specification does not affect the ordering of bytes.
19290 In particular, the following attempt at getting an endian-independent integer
19291 does not work:
19293 @example
19294 type R2 is record
19295    A : Integer;
19296 end record;
19298 for R2'Bit_Order use High_Order_First;
19300 for R2 use record
19301    A at 0 range 0 .. 31;
19302 end record;
19303 @end example
19305 This declaration will result in a little-endian integer on a
19306 little-endian machine, and a big-endian integer on a big-endian machine.
19307 If byte flipping is required for interoperability between big- and
19308 little-endian machines, this must be explicitly programmed.  This capability
19309 is not provided by @code{Bit_Order}.
19311 @item 
19312 Components that are positioned across byte boundaries.
19314 but do not occupy an integral number of bytes.  Given that bytes are not
19315 reordered, such fields would occupy a non-contiguous sequence of bits
19316 in memory, requiring non-trivial code to reassemble.  They are for this
19317 reason not permitted, and any component clause specifying such a layout
19318 will be flagged as illegal by GNAT.
19319 @end itemize
19321 Since the misconception that Bit_Order automatically deals with all
19322 endian-related incompatibilities is a common one, the specification of
19323 a component field that is an integral number of bytes will always
19324 generate a warning.  This warning may be suppressed using @code{pragma Warnings (Off)}
19325 if desired.  The following section contains additional
19326 details regarding the issue of byte ordering.
19328 @node Effect of Bit_Order on Byte Ordering,Pragma Pack for Arrays,Bit_Order Clauses,Representation Clauses and Pragmas
19329 @anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{295}@anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{296}
19330 @section Effect of Bit_Order on Byte Ordering
19333 @geindex byte ordering
19335 @geindex ordering
19336 @geindex of bytes
19338 In this section we will review the effect of the @code{Bit_Order} attribute
19339 definition clause on byte ordering.  Briefly, it has no effect at all, but
19340 a detailed example will be helpful.  Before giving this
19341 example, let us review the precise
19342 definition of the effect of defining @code{Bit_Order}.  The effect of a
19343 non-standard bit order is described in section 13.5.3 of the Ada
19344 Reference Manual:
19346 @quotation
19348 “2   A bit ordering is a method of interpreting the meaning of
19349 the storage place attributes.”
19350 @end quotation
19352 To understand the precise definition of storage place attributes in
19353 this context, we visit section 13.5.1 of the manual:
19355 @quotation
19357 “13   A record_representation_clause (without the mod_clause)
19358 specifies the layout.  The storage place attributes (see 13.5.2)
19359 are taken from the values of the position, first_bit, and last_bit
19360 expressions after normalizing those values so that first_bit is
19361 less than Storage_Unit.”
19362 @end quotation
19364 The critical point here is that storage places are taken from
19365 the values after normalization, not before.  So the @code{Bit_Order}
19366 interpretation applies to normalized values.  The interpretation
19367 is described in the later part of the 13.5.3 paragraph:
19369 @quotation
19371 “2   A bit ordering is a method of interpreting the meaning of
19372 the storage place attributes.  High_Order_First (known in the
19373 vernacular as ‘big endian’) means that the first bit of a
19374 storage element (bit 0) is the most significant bit (interpreting
19375 the sequence of bits that represent a component as an unsigned
19376 integer value).  Low_Order_First (known in the vernacular as
19377 ‘little endian’) means the opposite: the first bit is the
19378 least significant.”
19379 @end quotation
19381 Note that the numbering is with respect to the bits of a storage
19382 unit.  In other words, the specification affects only the numbering
19383 of bits within a single storage unit.
19385 We can make the effect clearer by giving an example.
19387 Suppose that we have an external device which presents two bytes, the first
19388 byte presented, which is the first (low addressed byte) of the two byte
19389 record is called Master, and the second byte is called Slave.
19391 The left most (most significant) bit is called Control for each byte, and
19392 the remaining 7 bits are called V1, V2, … V7, where V7 is the rightmost
19393 (least significant) bit.
19395 On a big-endian machine, we can write the following representation clause
19397 @example
19398 type Data is record
19399    Master_Control : Bit;
19400    Master_V1      : Bit;
19401    Master_V2      : Bit;
19402    Master_V3      : Bit;
19403    Master_V4      : Bit;
19404    Master_V5      : Bit;
19405    Master_V6      : Bit;
19406    Master_V7      : Bit;
19407    Slave_Control  : Bit;
19408    Slave_V1       : Bit;
19409    Slave_V2       : Bit;
19410    Slave_V3       : Bit;
19411    Slave_V4       : Bit;
19412    Slave_V5       : Bit;
19413    Slave_V6       : Bit;
19414    Slave_V7       : Bit;
19415 end record;
19417 for Data use record
19418    Master_Control at 0 range 0 .. 0;
19419    Master_V1      at 0 range 1 .. 1;
19420    Master_V2      at 0 range 2 .. 2;
19421    Master_V3      at 0 range 3 .. 3;
19422    Master_V4      at 0 range 4 .. 4;
19423    Master_V5      at 0 range 5 .. 5;
19424    Master_V6      at 0 range 6 .. 6;
19425    Master_V7      at 0 range 7 .. 7;
19426    Slave_Control  at 1 range 0 .. 0;
19427    Slave_V1       at 1 range 1 .. 1;
19428    Slave_V2       at 1 range 2 .. 2;
19429    Slave_V3       at 1 range 3 .. 3;
19430    Slave_V4       at 1 range 4 .. 4;
19431    Slave_V5       at 1 range 5 .. 5;
19432    Slave_V6       at 1 range 6 .. 6;
19433    Slave_V7       at 1 range 7 .. 7;
19434 end record;
19435 @end example
19437 Now if we move this to a little endian machine, then the bit ordering within
19438 the byte is backwards, so we have to rewrite the record rep clause as:
19440 @example
19441 for Data use record
19442    Master_Control at 0 range 7 .. 7;
19443    Master_V1      at 0 range 6 .. 6;
19444    Master_V2      at 0 range 5 .. 5;
19445    Master_V3      at 0 range 4 .. 4;
19446    Master_V4      at 0 range 3 .. 3;
19447    Master_V5      at 0 range 2 .. 2;
19448    Master_V6      at 0 range 1 .. 1;
19449    Master_V7      at 0 range 0 .. 0;
19450    Slave_Control  at 1 range 7 .. 7;
19451    Slave_V1       at 1 range 6 .. 6;
19452    Slave_V2       at 1 range 5 .. 5;
19453    Slave_V3       at 1 range 4 .. 4;
19454    Slave_V4       at 1 range 3 .. 3;
19455    Slave_V5       at 1 range 2 .. 2;
19456    Slave_V6       at 1 range 1 .. 1;
19457    Slave_V7       at 1 range 0 .. 0;
19458 end record;
19459 @end example
19461 It is a nuisance to have to rewrite the clause, especially if
19462 the code has to be maintained on both machines.  However,
19463 this is a case that we can handle with the
19464 @code{Bit_Order} attribute if it is implemented.
19465 Note that the implementation is not required on byte addressed
19466 machines, but it is indeed implemented in GNAT.
19467 This means that we can simply use the
19468 first record clause, together with the declaration
19470 @example
19471 for Data'Bit_Order use High_Order_First;
19472 @end example
19474 and the effect is what is desired, namely the layout is exactly the same,
19475 independent of whether the code is compiled on a big-endian or little-endian
19476 machine.
19478 The important point to understand is that byte ordering is not affected.
19479 A @code{Bit_Order} attribute definition never affects which byte a field
19480 ends up in, only where it ends up in that byte.
19481 To make this clear, let us rewrite the record rep clause of the previous
19482 example as:
19484 @example
19485 for Data'Bit_Order use High_Order_First;
19486 for Data use record
19487    Master_Control at 0 range  0 .. 0;
19488    Master_V1      at 0 range  1 .. 1;
19489    Master_V2      at 0 range  2 .. 2;
19490    Master_V3      at 0 range  3 .. 3;
19491    Master_V4      at 0 range  4 .. 4;
19492    Master_V5      at 0 range  5 .. 5;
19493    Master_V6      at 0 range  6 .. 6;
19494    Master_V7      at 0 range  7 .. 7;
19495    Slave_Control  at 0 range  8 .. 8;
19496    Slave_V1       at 0 range  9 .. 9;
19497    Slave_V2       at 0 range 10 .. 10;
19498    Slave_V3       at 0 range 11 .. 11;
19499    Slave_V4       at 0 range 12 .. 12;
19500    Slave_V5       at 0 range 13 .. 13;
19501    Slave_V6       at 0 range 14 .. 14;
19502    Slave_V7       at 0 range 15 .. 15;
19503 end record;
19504 @end example
19506 This is exactly equivalent to saying (a repeat of the first example):
19508 @example
19509 for Data'Bit_Order use High_Order_First;
19510 for Data use record
19511    Master_Control at 0 range 0 .. 0;
19512    Master_V1      at 0 range 1 .. 1;
19513    Master_V2      at 0 range 2 .. 2;
19514    Master_V3      at 0 range 3 .. 3;
19515    Master_V4      at 0 range 4 .. 4;
19516    Master_V5      at 0 range 5 .. 5;
19517    Master_V6      at 0 range 6 .. 6;
19518    Master_V7      at 0 range 7 .. 7;
19519    Slave_Control  at 1 range 0 .. 0;
19520    Slave_V1       at 1 range 1 .. 1;
19521    Slave_V2       at 1 range 2 .. 2;
19522    Slave_V3       at 1 range 3 .. 3;
19523    Slave_V4       at 1 range 4 .. 4;
19524    Slave_V5       at 1 range 5 .. 5;
19525    Slave_V6       at 1 range 6 .. 6;
19526    Slave_V7       at 1 range 7 .. 7;
19527 end record;
19528 @end example
19530 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
19531 field.  The storage place attributes are obtained by normalizing the
19532 values given so that the @code{First_Bit} value is less than 8.  After
19533 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
19534 we specified in the other case.
19536 Now one might expect that the @code{Bit_Order} attribute might affect
19537 bit numbering within the entire record component (two bytes in this
19538 case, thus affecting which byte fields end up in), but that is not
19539 the way this feature is defined, it only affects numbering of bits,
19540 not which byte they end up in.
19542 Consequently it never makes sense to specify a starting bit number
19543 greater than 7 (for a byte addressable field) if an attribute
19544 definition for @code{Bit_Order} has been given, and indeed it
19545 may be actively confusing to specify such a value, so the compiler
19546 generates a warning for such usage.
19548 If you do need to control byte ordering then appropriate conditional
19549 values must be used.  If in our example, the slave byte came first on
19550 some machines we might write:
19552 @example
19553 Master_Byte_First constant Boolean := ...;
19555 Master_Byte : constant Natural :=
19556                 1 - Boolean'Pos (Master_Byte_First);
19557 Slave_Byte  : constant Natural :=
19558                 Boolean'Pos (Master_Byte_First);
19560 for Data'Bit_Order use High_Order_First;
19561 for Data use record
19562    Master_Control at Master_Byte range 0 .. 0;
19563    Master_V1      at Master_Byte range 1 .. 1;
19564    Master_V2      at Master_Byte range 2 .. 2;
19565    Master_V3      at Master_Byte range 3 .. 3;
19566    Master_V4      at Master_Byte range 4 .. 4;
19567    Master_V5      at Master_Byte range 5 .. 5;
19568    Master_V6      at Master_Byte range 6 .. 6;
19569    Master_V7      at Master_Byte range 7 .. 7;
19570    Slave_Control  at Slave_Byte  range 0 .. 0;
19571    Slave_V1       at Slave_Byte  range 1 .. 1;
19572    Slave_V2       at Slave_Byte  range 2 .. 2;
19573    Slave_V3       at Slave_Byte  range 3 .. 3;
19574    Slave_V4       at Slave_Byte  range 4 .. 4;
19575    Slave_V5       at Slave_Byte  range 5 .. 5;
19576    Slave_V6       at Slave_Byte  range 6 .. 6;
19577    Slave_V7       at Slave_Byte  range 7 .. 7;
19578 end record;
19579 @end example
19581 Now to switch between machines, all that is necessary is
19582 to set the boolean constant @code{Master_Byte_First} in
19583 an appropriate manner.
19585 @node Pragma Pack for Arrays,Pragma Pack for Records,Effect of Bit_Order on Byte Ordering,Representation Clauses and Pragmas
19586 @anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{297}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{298}
19587 @section Pragma Pack for Arrays
19590 @geindex Pragma Pack (for arrays)
19592 Pragma @code{Pack} applied to an array has an effect that depends upon whether the
19593 component type is `packable'.  For a component type to be `packable', it must
19594 be one of the following cases:
19597 @itemize *
19599 @item 
19600 Any elementary type.
19602 @item 
19603 Any small packed array type with a static size.
19605 @item 
19606 Any small simple record type with a static size.
19607 @end itemize
19609 For all these cases, if the component subtype size is in the range
19610 1 through 63 on 32-bit targets, and 1 through 127 on 64-bit targets,
19611 then the effect of the pragma @code{Pack} is exactly as though a
19612 component size were specified giving the component subtype size.
19614 All other types are non-packable, they occupy an integral number of storage
19615 units and the only effect of pragma Pack is to remove alignment gaps.
19617 For example if we have:
19619 @example
19620 type r is range 0 .. 17;
19622 type ar is array (1 .. 8) of r;
19623 pragma Pack (ar);
19624 @end example
19626 Then the component size of @code{ar} will be set to 5 (i.e., to @code{r'size},
19627 and the size of the array @code{ar} will be exactly 40 bits).
19629 Note that in some cases this rather fierce approach to packing can produce
19630 unexpected effects.  For example, in Ada 95 and Ada 2005,
19631 subtype @code{Natural} typically has a size of 31, meaning that if you
19632 pack an array of @code{Natural}, you get 31-bit
19633 close packing, which saves a few bits, but results in far less efficient
19634 access.  Since many other Ada compilers will ignore such a packing request,
19635 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
19636 might not be what is intended.  You can easily remove this warning by
19637 using an explicit @code{Component_Size} setting instead, which never generates
19638 a warning, since the intention of the programmer is clear in this case.
19640 GNAT treats packed arrays in one of two ways.  If the size of the array is
19641 known at compile time and is at most 64 bits on 32-bit targets, and at most
19642 128 bits on 64-bit targets, then internally the array is represented as a
19643 single modular type, of exactly the appropriate number of bits.  If the
19644 length is greater than 64 bits on 32-bit targets, and greater than 128
19645 bits on 64-bit targets, or is not known at compile time, then the packed
19646 array is represented as an array of bytes, and its length is always a
19647 multiple of 8 bits.
19649 Note that to represent a packed array as a modular type, the alignment must
19650 be suitable for the modular type involved. For example, on typical machines
19651 a 32-bit packed array will be represented by a 32-bit modular integer with
19652 an alignment of four bytes. If you explicitly override the default alignment
19653 with an alignment clause that is too small, the modular representation
19654 cannot be used. For example, consider the following set of declarations:
19656 @example
19657 type R is range 1 .. 3;
19658 type S is array (1 .. 31) of R;
19659 for S'Component_Size use 2;
19660 for S'Size use 62;
19661 for S'Alignment use 1;
19662 @end example
19664 If the alignment clause were not present, then a 62-bit modular
19665 representation would be chosen (typically with an alignment of 4 or 8
19666 bytes depending on the target). But the default alignment is overridden
19667 with the explicit alignment clause. This means that the modular
19668 representation cannot be used, and instead the array of bytes
19669 representation must be used, meaning that the length must be a multiple
19670 of 8. Thus the above set of declarations will result in a diagnostic
19671 rejecting the size clause and noting that the minimum size allowed is 64.
19673 @geindex Pragma Pack (for type Natural)
19675 @geindex Pragma Pack warning
19677 One special case that is worth noting occurs when the base type of the
19678 component size is 8/16/32 and the subtype is one bit less. Notably this
19679 occurs with subtype @code{Natural}. Consider:
19681 @example
19682 type Arr is array (1 .. 32) of Natural;
19683 pragma Pack (Arr);
19684 @end example
19686 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
19687 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
19688 Ada 83 compilers did not attempt 31 bit packing.
19690 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
19691 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
19692 substantial unintended performance penalty when porting legacy Ada 83 code.
19693 To help prevent this, GNAT generates a warning in such cases. If you really
19694 want 31 bit packing in a case like this, you can set the component size
19695 explicitly:
19697 @example
19698 type Arr is array (1 .. 32) of Natural;
19699 for Arr'Component_Size use 31;
19700 @end example
19702 Here 31-bit packing is achieved as required, and no warning is generated,
19703 since in this case the programmer intention is clear.
19705 @node Pragma Pack for Records,Record Representation Clauses,Pragma Pack for Arrays,Representation Clauses and Pragmas
19706 @anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{299}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{29a}
19707 @section Pragma Pack for Records
19710 @geindex Pragma Pack (for records)
19712 Pragma @code{Pack} applied to a record will pack the components to reduce
19713 wasted space from alignment gaps and by reducing the amount of space
19714 taken by components.  We distinguish between `packable' components and
19715 `non-packable' components.
19716 Components of the following types are considered packable:
19719 @itemize *
19721 @item 
19722 Components of an elementary type are packable unless they are aliased,
19723 independent or atomic.
19725 @item 
19726 Small packed arrays, where the size is statically known, are represented
19727 internally as modular integers, and so they are also packable.
19729 @item 
19730 Small simple records, where the size is statically known, are also packable.
19731 @end itemize
19733 For all these cases, if the @code{'Size} value is in the range 1 through 64 on
19734 32-bit targets, and 1 through 128 on 64-bit targets, the components occupy
19735 the exact number of bits corresponding to this value and are packed with no
19736 padding bits, i.e. they can start on an arbitrary bit boundary.
19738 All other types are non-packable, they occupy an integral number of storage
19739 units and the only effect of pragma @code{Pack} is to remove alignment gaps.
19741 For example, consider the record
19743 @example
19744 type Rb1 is array (1 .. 13) of Boolean;
19745 pragma Pack (Rb1);
19747 type Rb2 is array (1 .. 65) of Boolean;
19748 pragma Pack (Rb2);
19750 type AF is new Float with Atomic;
19752 type X2 is record
19753    L1 : Boolean;
19754    L2 : Duration;
19755    L3 : AF;
19756    L4 : Boolean;
19757    L5 : Rb1;
19758    L6 : Rb2;
19759 end record;
19760 pragma Pack (X2);
19761 @end example
19763 The representation for the record @code{X2} is as follows on 32-bit targets:
19765 @example
19766 for X2'Size use 224;
19767 for X2 use record
19768    L1 at  0 range  0 .. 0;
19769    L2 at  0 range  1 .. 64;
19770    L3 at 12 range  0 .. 31;
19771    L4 at 16 range  0 .. 0;
19772    L5 at 16 range  1 .. 13;
19773    L6 at 18 range  0 .. 71;
19774 end record;
19775 @end example
19777 Studying this example, we see that the packable fields @code{L1}
19778 and @code{L2} are of length equal to their sizes, and placed at
19779 specific bit boundaries (and not byte boundaries) to eliminate
19780 padding.  But @code{L3} is of a non-packable float type (because
19781 it is aliased), so it is on the next appropriate alignment boundary.
19783 The next two fields are fully packable, so @code{L4} and @code{L5} are
19784 minimally packed with no gaps.  However, type @code{Rb2} is a packed
19785 array that is longer than 64 bits, so it is itself non-packable on
19786 32-bit targets.  Thus the @code{L6} field is aligned to the next byte
19787 boundary, and takes an integral number of bytes, i.e., 72 bits.
19789 @node Record Representation Clauses,Handling of Records with Holes,Pragma Pack for Records,Representation Clauses and Pragmas
19790 @anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{29b}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{29c}
19791 @section Record Representation Clauses
19794 @geindex Record Representation Clause
19796 Record representation clauses may be given for all record types, including
19797 types obtained by record extension.  Component clauses are allowed for any
19798 static component.  The restrictions on component clauses depend on the type
19799 of the component.
19801 @geindex Component Clause
19803 For all components of an elementary type, the only restriction on component
19804 clauses is that the size must be at least the @code{'Size} value of the type
19805 (actually the Value_Size).  There are no restrictions due to alignment,
19806 and such components may freely cross storage boundaries.
19808 Packed arrays with a size up to and including 64 bits on 32-bit targets,
19809 and up to and including 128 bits on 64-bit targets, are represented
19810 internally using a modular type with the appropriate number of bits, and
19811 thus the same lack of restriction applies.  For example, if you declare:
19813 @example
19814 type R is array (1 .. 49) of Boolean;
19815 pragma Pack (R);
19816 for R'Size use 49;
19817 @end example
19819 then a component clause for a component of type @code{R} may start on any
19820 specified bit boundary, and may specify a value of 49 bits or greater.
19822 For packed bit arrays that are longer than 64 bits on 32-bit targets,
19823 and longer than 128 bits on 64-bit targets, there are two cases. If the
19824 component size is a power of 2 (1,2,4,8,16,32,64 bits), including the
19825 important case of single bits or boolean values, then there are no
19826 limitations on placement of such components, and they may start and
19827 end at arbitrary bit boundaries.
19829 If the component size is not a power of 2 (e.g., 3 or 5), then an array
19830 of this type must always be placed on on a storage unit (byte) boundary
19831 and occupy an integral number of storage units (bytes). Any component
19832 clause that does not meet this requirement will be rejected.
19834 Any aliased component, or component of an aliased type, must have its
19835 normal alignment and size. A component clause that does not meet this
19836 requirement will be rejected.
19838 The tag field of a tagged type always occupies an address sized field at
19839 the start of the record.  No component clause may attempt to overlay this
19840 tag. When a tagged type appears as a component, the tag field must have
19841 proper alignment
19843 In the case of a record extension @code{T1}, of a type @code{T}, no component
19844 clause applied to the type @code{T1} can specify a storage location that
19845 would overlap the first @code{T'Object_Size} bits of the record.
19847 For all other component types, including non-bit-packed arrays,
19848 the component can be placed at an arbitrary bit boundary,
19849 so for example, the following is permitted:
19851 @example
19852 type R is array (1 .. 10) of Boolean;
19853 for R'Size use 80;
19855 type Q is record
19856    G, H : Boolean;
19857    L, M : R;
19858 end record;
19860 for Q use record
19861    G at 0 range  0 ..   0;
19862    H at 0 range  1 ..   1;
19863    L at 0 range  2 ..  81;
19864    R at 0 range 82 .. 161;
19865 end record;
19866 @end example
19868 @node Handling of Records with Holes,Enumeration Clauses,Record Representation Clauses,Representation Clauses and Pragmas
19869 @anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{29d}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{29e}
19870 @section Handling of Records with Holes
19873 @geindex Handling of Records with Holes
19875 As a result of alignment considerations, records may contain “holes”
19876 or gaps which do not correspond to the data bits of any of the components.
19877 Record representation clauses can also result in holes in records.
19879 GNAT does not attempt to clear these holes, so in record objects,
19880 they should be considered to hold undefined rubbish. The generated
19881 equality routine just tests components so does not access these
19882 undefined bits, and assignment and copy operations may or may not
19883 preserve the contents of these holes (for assignments, the holes
19884 in the target will in practice contain either the bits that are
19885 present in the holes in the source, or the bits that were present
19886 in the target before the assignment).
19888 If it is necessary to ensure that holes in records have all zero
19889 bits, then record objects for which this initialization is desired
19890 should be explicitly set to all zero values using Unchecked_Conversion
19891 or address overlays. For example
19893 @example
19894 type HRec is record
19895    C : Character;
19896    I : Integer;
19897 end record;
19898 @end example
19900 On typical machines, integers need to be aligned on a four-byte
19901 boundary, resulting in three bytes of undefined rubbish following
19902 the 8-bit field for C. To ensure that the hole in a variable of
19903 type HRec is set to all zero bits,
19904 you could for example do:
19906 @example
19907 type Base is record
19908    Dummy1, Dummy2 : Integer := 0;
19909 end record;
19911 BaseVar : Base;
19912 RealVar : Hrec;
19913 for RealVar'Address use BaseVar'Address;
19914 @end example
19916 Now the 8-bytes of the value of RealVar start out containing all zero
19917 bits. A safer approach is to just define dummy fields, avoiding the
19918 holes, as in:
19920 @example
19921 type HRec is record
19922    C      : Character;
19923    Dummy1 : Short_Short_Integer := 0;
19924    Dummy2 : Short_Short_Integer := 0;
19925    Dummy3 : Short_Short_Integer := 0;
19926    I      : Integer;
19927 end record;
19928 @end example
19930 And to make absolutely sure that the intent of this is followed, you
19931 can use representation clauses:
19933 @example
19934 for Hrec use record
19935    C      at 0 range 0 .. 7;
19936    Dummy1 at 1 range 0 .. 7;
19937    Dummy2 at 2 range 0 .. 7;
19938    Dummy3 at 3 range 0 .. 7;
19939    I      at 4 range 0 .. 31;
19940 end record;
19941 for Hrec'Size use 64;
19942 @end example
19944 @node Enumeration Clauses,Address Clauses,Handling of Records with Holes,Representation Clauses and Pragmas
19945 @anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{29f}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{2a0}
19946 @section Enumeration Clauses
19949 The only restriction on enumeration clauses is that the range of values
19950 must be representable.  For the signed case, if one or more of the
19951 representation values are negative, all values must be in the range:
19953 @example
19954 System.Min_Int .. System.Max_Int
19955 @end example
19957 For the unsigned case, where all values are nonnegative, the values must
19958 be in the range:
19960 @example
19961 0 .. System.Max_Binary_Modulus;
19962 @end example
19964 A `confirming' representation clause is one in which the values range
19965 from 0 in sequence, i.e., a clause that confirms the default representation
19966 for an enumeration type.
19967 Such a confirming representation
19968 is permitted by these rules, and is specially recognized by the compiler so
19969 that no extra overhead results from the use of such a clause.
19971 If an array has an index type which is an enumeration type to which an
19972 enumeration clause has been applied, then the array is stored in a compact
19973 manner.  Consider the declarations:
19975 @example
19976 type r is (A, B, C);
19977 for r use (A => 1, B => 5, C => 10);
19978 type t is array (r) of Character;
19979 @end example
19981 The array type t corresponds to a vector with exactly three elements and
19982 has a default size equal to @code{3*Character'Size}.  This ensures efficient
19983 use of space, but means that accesses to elements of the array will incur
19984 the overhead of converting representation values to the corresponding
19985 positional values, (i.e., the value delivered by the @code{Pos} attribute).
19987 @node Address Clauses,Use of Address Clauses for Memory-Mapped I/O,Enumeration Clauses,Representation Clauses and Pragmas
19988 @anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{2a1}@anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{2a2}
19989 @section Address Clauses
19992 @geindex Address Clause
19994 The reference manual allows a general restriction on representation clauses,
19995 as found in RM 13.1(22):
19997 @quotation
19999 “An implementation need not support representation
20000 items containing nonstatic expressions, except that
20001 an implementation should support a representation item
20002 for a given entity if each nonstatic expression in the
20003 representation item is a name that statically denotes
20004 a constant declared before the entity.”
20005 @end quotation
20007 In practice this is applicable only to address clauses, since this is the
20008 only case in which a nonstatic expression is permitted by the syntax.  As
20009 the AARM notes in sections 13.1 (22.a-22.h):
20011 @quotation
20013 22.a   Reason: This is to avoid the following sort of thing:
20015 22.b        X : Integer := F(…);
20016 Y : Address := G(…);
20017 for X’Address use Y;
20019 22.c   In the above, we have to evaluate the
20020 initialization expression for X before we
20021 know where to put the result.  This seems
20022 like an unreasonable implementation burden.
20024 22.d   The above code should instead be written
20025 like this:
20027 22.e        Y : constant Address := G(…);
20028 X : Integer := F(…);
20029 for X’Address use Y;
20031 22.f   This allows the expression ‘Y’ to be safely
20032 evaluated before X is created.
20034 22.g   The constant could be a formal parameter of mode in.
20036 22.h   An implementation can support other nonstatic
20037 expressions if it wants to.  Expressions of type
20038 Address are hardly ever static, but their value
20039 might be known at compile time anyway in many
20040 cases.
20041 @end quotation
20043 GNAT does indeed permit many additional cases of nonstatic expressions.  In
20044 particular, if the type involved is elementary there are no restrictions
20045 (since in this case, holding a temporary copy of the initialization value,
20046 if one is present, is inexpensive).  In addition, if there is no implicit or
20047 explicit initialization, then there are no restrictions.  GNAT will reject
20048 only the case where all three of these conditions hold:
20051 @itemize *
20053 @item 
20054 The type of the item is non-elementary (e.g., a record or array).
20056 @item 
20057 There is explicit or implicit initialization required for the object.
20058 Note that access values are always implicitly initialized.
20060 @item 
20061 The address value is nonstatic.  Here GNAT is more permissive than the
20062 RM, and allows the address value to be the address of a previously declared
20063 stand-alone variable, as long as it does not itself have an address clause.
20065 @example
20066 Anchor  : Some_Initialized_Type;
20067 Overlay : Some_Initialized_Type;
20068 for Overlay'Address use Anchor'Address;
20069 @end example
20071 However, the prefix of the address clause cannot be an array component, or
20072 a component of a discriminated record.
20073 @end itemize
20075 As noted above in section 22.h, address values are typically nonstatic.  In
20076 particular the To_Address function, even if applied to a literal value, is
20077 a nonstatic function call.  To avoid this minor annoyance, GNAT provides
20078 the implementation defined attribute ‘To_Address.  The following two
20079 expressions have identical values:
20081 @geindex Attribute
20083 @geindex To_Address
20085 @example
20086 To_Address (16#1234_0000#)
20087 System'To_Address (16#1234_0000#);
20088 @end example
20090 except that the second form is considered to be a static expression, and
20091 thus when used as an address clause value is always permitted.
20093 Additionally, GNAT treats as static an address clause that is an
20094 unchecked_conversion of a static integer value.  This simplifies the porting
20095 of legacy code, and provides a portable equivalent to the GNAT attribute
20096 @code{To_Address}.
20098 Another issue with address clauses is the interaction with alignment
20099 requirements.  When an address clause is given for an object, the address
20100 value must be consistent with the alignment of the object (which is usually
20101 the same as the alignment of the type of the object).  If an address clause
20102 is given that specifies an inappropriately aligned address value, then the
20103 program execution is erroneous.
20105 Since this source of erroneous behavior can have unfortunate effects on
20106 machines with strict alignment requirements, GNAT
20107 checks (at compile time if possible, generating a warning, or at execution
20108 time with a run-time check) that the alignment is appropriate.  If the
20109 run-time check fails, then @code{Program_Error} is raised.  This run-time
20110 check is suppressed if range checks are suppressed, or if the special GNAT
20111 check Alignment_Check is suppressed, or if
20112 @code{pragma Restrictions (No_Elaboration_Code)} is in effect. It is also
20113 suppressed by default on non-strict alignment machines (such as the x86).
20115 In some cases, GNAT does not support an address specification (using either
20116 form of aspect specification syntax) for the declaration of an object that has
20117 an indefinite nominal subtype. An object declaration has an indefinite
20118 nominal subtype if it takes its bounds (for an array type), discriminant
20119 values (for a discriminated type whose discriminants lack defaults), or tag
20120 (for a class-wide type) from its initial value, as in
20122 @example
20123 X : String := Some_Function_Call;
20124 -- String has no constraint, so bounds for X come from function call
20125 @end example
20127 This restriction does not apply if the size of the object’s initial value is
20128 known at compile time and the type of the object is not class-wide.
20130 @geindex Export
20132 An address clause cannot be given for an exported object.  More
20133 understandably the real restriction is that objects with an address
20134 clause cannot be exported.  This is because such variables are not
20135 defined by the Ada program, so there is no external object to export.
20137 @geindex Import
20139 It is permissible to give an address clause and a pragma Import for the
20140 same object.  In this case, the variable is not really defined by the
20141 Ada program, so there is no external symbol to be linked.  The link name
20142 and the external name are ignored in this case.  The reason that we allow this
20143 combination is that it provides a useful idiom to avoid unwanted
20144 initializations on objects with address clauses.
20146 When an address clause is given for an object that has implicit or
20147 explicit initialization, then by default initialization takes place.  This
20148 means that the effect of the object declaration is to overwrite the
20149 memory at the specified address.  This is almost always not what the
20150 programmer wants, so GNAT will output a warning:
20152 @example
20153 with System;
20154 package G is
20155    type R is record
20156       M : Integer := 0;
20157    end record;
20159    Ext : R;
20160    for Ext'Address use System'To_Address (16#1234_1234#);
20161        |
20162 >>> warning: implicit initialization of "Ext" may
20163     modify overlaid storage
20164 >>> warning: use pragma Import for "Ext" to suppress
20165     initialization (RM B(24))
20167 end G;
20168 @end example
20170 As indicated by the warning message, the solution is to use a (dummy) pragma
20171 Import to suppress this initialization.  The pragma tell the compiler that the
20172 object is declared and initialized elsewhere.  The following package compiles
20173 without warnings (and the initialization is suppressed):
20175 @example
20176 with System;
20177 package G is
20178    type R is record
20179       M : Integer := 0;
20180    end record;
20182    Ext : R;
20183    for Ext'Address use System'To_Address (16#1234_1234#);
20184    pragma Import (Ada, Ext);
20185 end G;
20186 @end example
20188 A final issue with address clauses involves their use for overlaying
20189 variables, as in the following example:
20191 @geindex Overlaying of objects
20193 @example
20194 A : Integer;
20195 B : Integer;
20196 for B'Address use A'Address;
20197 @end example
20199 or alternatively, using the form recommended by the RM:
20201 @example
20202 A    : Integer;
20203 Addr : constant Address := A'Address;
20204 B    : Integer;
20205 for B'Address use Addr;
20206 @end example
20208 In both of these cases, @code{A} and @code{B} become aliased to one another
20209 via the address clause. This use of address clauses to overlay
20210 variables, achieving an effect similar to unchecked conversion
20211 was erroneous in Ada 83, but in Ada 95 and Ada 2005
20212 the effect is implementation defined. Furthermore, the
20213 Ada RM specifically recommends that in a situation
20214 like this, @code{B} should be subject to the following
20215 implementation advice (RM 13.3(19)):
20217 @quotation
20219 “19  If the Address of an object is specified, or it is imported
20220 or exported, then the implementation should not perform
20221 optimizations based on assumptions of no aliases.”
20222 @end quotation
20224 GNAT follows this recommendation, and goes further by also applying
20225 this recommendation to the overlaid variable (@code{A} in the above example)
20226 in this case. This means that the overlay works “as expected”, in that
20227 a modification to one of the variables will affect the value of the other.
20229 More generally, GNAT interprets this recommendation conservatively for
20230 address clauses: in the cases other than overlays, it considers that the
20231 object is effectively subject to pragma @code{Volatile} and implements the
20232 associated semantics.
20234 Note that when address clause overlays are used in this way, there is an
20235 issue of unintentional initialization, as shown by this example:
20237 @example
20238 package Overwrite_Record is
20239    type R is record
20240       A : Character := 'C';
20241       B : Character := 'A';
20242    end record;
20243    X : Short_Integer := 3;
20244    Y : R;
20245    for Y'Address use X'Address;
20246        |
20247 >>> warning: default initialization of "Y" may
20248     modify "X", use pragma Import for "Y" to
20249     suppress initialization (RM B.1(24))
20251 end Overwrite_Record;
20252 @end example
20254 Here the default initialization of @code{Y} will clobber the value
20255 of @code{X}, which justifies the warning. The warning notes that
20256 this effect can be eliminated by adding a @code{pragma Import}
20257 which suppresses the initialization:
20259 @example
20260 package Overwrite_Record is
20261    type R is record
20262       A : Character := 'C';
20263       B : Character := 'A';
20264    end record;
20265    X : Short_Integer := 3;
20266    Y : R;
20267    for Y'Address use X'Address;
20268    pragma Import (Ada, Y);
20269 end Overwrite_Record;
20270 @end example
20272 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
20273 be initialized when they would not otherwise have been in the absence
20274 of the use of this pragma. This may cause an overlay to have this
20275 unintended clobbering effect. The compiler avoids this for scalar
20276 types, but not for composite objects (where in general the effect
20277 of @code{Initialize_Scalars} is part of the initialization routine
20278 for the composite object):
20280 @example
20281 pragma Initialize_Scalars;
20282 with Ada.Text_IO;  use Ada.Text_IO;
20283 procedure Overwrite_Array is
20284    type Arr is array (1 .. 5) of Integer;
20285    X : Arr := (others => 1);
20286    A : Arr;
20287    for A'Address use X'Address;
20288        |
20289 >>> warning: default initialization of "A" may
20290     modify "X", use pragma Import for "A" to
20291     suppress initialization (RM B.1(24))
20293 begin
20294    if X /= Arr'(others => 1) then
20295       Put_Line ("X was clobbered");
20296    else
20297       Put_Line ("X was not clobbered");
20298    end if;
20299 end Overwrite_Array;
20300 @end example
20302 The above program generates the warning as shown, and at execution
20303 time, prints @code{X was clobbered}. If the @code{pragma Import} is
20304 added as suggested:
20306 @example
20307 pragma Initialize_Scalars;
20308 with Ada.Text_IO;  use Ada.Text_IO;
20309 procedure Overwrite_Array is
20310    type Arr is array (1 .. 5) of Integer;
20311    X : Arr := (others => 1);
20312    A : Arr;
20313    for A'Address use X'Address;
20314    pragma Import (Ada, A);
20315 begin
20316    if X /= Arr'(others => 1) then
20317       Put_Line ("X was clobbered");
20318    else
20319       Put_Line ("X was not clobbered");
20320    end if;
20321 end Overwrite_Array;
20322 @end example
20324 then the program compiles without the warning and when run will generate
20325 the output @code{X was not clobbered}.
20327 @node Use of Address Clauses for Memory-Mapped I/O,Effect of Convention on Representation,Address Clauses,Representation Clauses and Pragmas
20328 @anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{2a3}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{2a4}
20329 @section Use of Address Clauses for Memory-Mapped I/O
20332 @geindex Memory-mapped I/O
20334 A common pattern is to use an address clause to map an atomic variable to
20335 a location in memory that corresponds to a memory-mapped I/O operation or
20336 operations, for example:
20338 @example
20339 type Mem_Word is record
20340    A,B,C,D : Byte;
20341 end record;
20342 pragma Atomic (Mem_Word);
20343 for Mem_Word_Size use 32;
20345 Mem : Mem_Word;
20346 for Mem'Address use some-address;
20348 Temp := Mem;
20349 Temp.A := 32;
20350 Mem := Temp;
20351 @end example
20353 For a full access (reference or modification) of the variable (Mem) in this
20354 case, as in the above examples, GNAT guarantees that the entire atomic word
20355 will be accessed, in accordance with the RM C.6(15) clause.
20357 A problem arises with a component access such as:
20359 @example
20360 Mem.A := 32;
20361 @end example
20363 Note that the component A is not declared as atomic. This means that it is
20364 not clear what this assignment means. It could correspond to full word read
20365 and write as given in the first example, or on architectures that supported
20366 such an operation it might be a single byte store instruction. The RM does
20367 not have anything to say in this situation, and GNAT does not make any
20368 guarantee. The code generated may vary from target to target. GNAT will issue
20369 a warning in such a case:
20371 @example
20372 Mem.A := 32;
20374 >>> warning: access to non-atomic component of atomic array,
20375     may cause unexpected accesses to atomic object
20376 @end example
20378 It is best to be explicit in this situation, by either declaring the
20379 components to be atomic if you want the byte store, or explicitly writing
20380 the full word access sequence if that is what the hardware requires.
20381 Alternatively, if the full word access sequence is required, GNAT also
20382 provides the pragma @code{Volatile_Full_Access} which can be used in lieu of
20383 pragma @code{Atomic} and will give the additional guarantee.
20385 @node Effect of Convention on Representation,Conventions and Anonymous Access Types,Use of Address Clauses for Memory-Mapped I/O,Representation Clauses and Pragmas
20386 @anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{2a5}@anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{2a6}
20387 @section Effect of Convention on Representation
20390 @geindex Convention
20391 @geindex effect on representation
20393 Normally the specification of a foreign language convention for a type or
20394 an object has no effect on the chosen representation.  In particular, the
20395 representation chosen for data in GNAT generally meets the standard system
20396 conventions, and for example records are laid out in a manner that is
20397 consistent with C.  This means that specifying convention C (for example)
20398 has no effect.
20400 There are four exceptions to this general rule:
20403 @itemize *
20405 @item 
20406 `Convention Fortran and array subtypes'.
20408 If pragma Convention Fortran is specified for an array subtype, then in
20409 accordance with the implementation advice in section 3.6.2(11) of the
20410 Ada Reference Manual, the array will be stored in a Fortran-compatible
20411 column-major manner, instead of the normal default row-major order.
20413 @item 
20414 `Convention C and enumeration types'
20416 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
20417 to accommodate all values of the type.  For example, for the enumeration
20418 type declared by:
20420 @example
20421 type Color is (Red, Green, Blue);
20422 @end example
20424 8 bits is sufficient to store all values of the type, so by default, objects
20425 of type @code{Color} will be represented using 8 bits.  However, normal C
20426 convention is to use 32 bits for all enum values in C, since enum values
20427 are essentially of type int.  If pragma @code{Convention C} is specified for an
20428 Ada enumeration type, then the size is modified as necessary (usually to
20429 32 bits) to be consistent with the C convention for enum values.
20431 Note that this treatment applies only to types. If Convention C is given for
20432 an enumeration object, where the enumeration type is not Convention C, then
20433 Object_Size bits are allocated. For example, for a normal enumeration type,
20434 with less than 256 elements, only 8 bits will be allocated for the object.
20435 Since this may be a surprise in terms of what C expects, GNAT will issue a
20436 warning in this situation. The warning can be suppressed by giving an explicit
20437 size clause specifying the desired size.
20439 @item 
20440 `Convention C/Fortran and Boolean types'
20442 In C, the usual convention for boolean values, that is values used for
20443 conditions, is that zero represents false, and nonzero values represent
20444 true.  In Ada, the normal convention is that two specific values, typically
20445 0/1, are used to represent false/true respectively.
20447 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
20448 value represents true).
20450 To accommodate the Fortran and C conventions, if a pragma Convention specifies
20451 C or Fortran convention for a derived Boolean, as in the following example:
20453 @example
20454 type C_Switch is new Boolean;
20455 pragma Convention (C, C_Switch);
20456 @end example
20458 then the GNAT generated code will treat any nonzero value as true.  For truth
20459 values generated by GNAT, the conventional value 1 will be used for True, but
20460 when one of these values is read, any nonzero value is treated as True.
20461 @end itemize
20463 @node Conventions and Anonymous Access Types,Determining the Representations chosen by GNAT,Effect of Convention on Representation,Representation Clauses and Pragmas
20464 @anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{2a7}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{2a8}
20465 @section Conventions and Anonymous Access Types
20468 @geindex Anonymous access types
20470 @geindex Convention for anonymous access types
20472 The RM is not entirely clear on convention handling in a number of cases,
20473 and in particular, it is not clear on the convention to be given to
20474 anonymous access types in general, and in particular what is to be
20475 done for the case of anonymous access-to-subprogram.
20477 In GNAT, we decide that if an explicit Convention is applied
20478 to an object or component, and its type is such an anonymous type,
20479 then the convention will apply to this anonymous type as well. This
20480 seems to make sense since it is anomolous in any case to have a
20481 different convention for an object and its type, and there is clearly
20482 no way to explicitly specify a convention for an anonymous type, since
20483 it doesn’t have a name to specify!
20485 Furthermore, we decide that if a convention is applied to a record type,
20486 then this convention is inherited by any of its components that are of an
20487 anonymous access type which do not have an explicitly specified convention.
20489 The following program shows these conventions in action:
20491 @example
20492 package ConvComp is
20493    type Foo is range 1 .. 10;
20494    type T1 is record
20495       A : access function (X : Foo) return Integer;
20496       B : Integer;
20497    end record;
20498    pragma Convention (C, T1);
20500    type T2 is record
20501       A : access function (X : Foo) return Integer;
20502       pragma Convention  (C, A);
20503       B : Integer;
20504    end record;
20505    pragma Convention (COBOL, T2);
20507    type T3 is record
20508       A : access function (X : Foo) return Integer;
20509       pragma Convention  (COBOL, A);
20510       B : Integer;
20511    end record;
20512    pragma Convention (C, T3);
20514    type T4 is record
20515       A : access function (X : Foo) return Integer;
20516       B : Integer;
20517    end record;
20518    pragma Convention (COBOL, T4);
20520    function F (X : Foo) return Integer;
20521    pragma Convention (C, F);
20523    function F (X : Foo) return Integer is (13);
20525    TV1 : T1 := (F'Access, 12);  -- OK
20526    TV2 : T2 := (F'Access, 13);  -- OK
20528    TV3 : T3 := (F'Access, 13);  -- ERROR
20529                 |
20530 >>> subprogram "F" has wrong convention
20531 >>> does not match access to subprogram declared at line 17
20532      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
20533                 |
20534 >>> subprogram "F" has wrong convention
20535 >>> does not match access to subprogram declared at line 24
20536      39. end ConvComp;
20537 @end example
20539 @node Determining the Representations chosen by GNAT,,Conventions and Anonymous Access Types,Representation Clauses and Pragmas
20540 @anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{2a9}@anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{2aa}
20541 @section Determining the Representations chosen by GNAT
20544 @geindex Representation
20545 @geindex determination of
20547 @geindex -gnatR (gcc)
20549 Although the descriptions in this section are intended to be complete, it is
20550 often easier to simply experiment to see what GNAT accepts and what the
20551 effect is on the layout of types and objects.
20553 As required by the Ada RM, if a representation clause is not accepted, then
20554 it must be rejected as illegal by the compiler.  However, when a
20555 representation clause or pragma is accepted, there can still be questions
20556 of what the compiler actually does.  For example, if a partial record
20557 representation clause specifies the location of some components and not
20558 others, then where are the non-specified components placed? Or if pragma
20559 @code{Pack} is used on a record, then exactly where are the resulting
20560 fields placed? The section on pragma @code{Pack} in this chapter can be
20561 used to answer the second question, but it is often easier to just see
20562 what the compiler does.
20564 For this purpose, GNAT provides the option `-gnatR'.  If you compile
20565 with this option, then the compiler will output information on the actual
20566 representations chosen, in a format similar to source representation
20567 clauses.  For example, if we compile the package:
20569 @example
20570 package q is
20571    type r (x : boolean) is tagged record
20572       case x is
20573          when True => S : String (1 .. 100);
20574          when False => null;
20575       end case;
20576    end record;
20578    type r2 is new r (false) with record
20579       y2 : integer;
20580    end record;
20582    for r2 use record
20583       y2 at 16 range 0 .. 31;
20584    end record;
20586    type x is record
20587       y : character;
20588    end record;
20590    type x1 is array (1 .. 10) of x;
20591    for x1'component_size use 11;
20593    type ia is access integer;
20595    type Rb1 is array (1 .. 13) of Boolean;
20596    pragma Pack (rb1);
20598    type Rb2 is array (1 .. 65) of Boolean;
20599    pragma Pack (rb2);
20601    type x2 is record
20602       l1 : Boolean;
20603       l2 : Duration;
20604       l3 : Float;
20605       l4 : Boolean;
20606       l5 : Rb1;
20607       l6 : Rb2;
20608    end record;
20609    pragma Pack (x2);
20610 end q;
20611 @end example
20613 using the switch `-gnatR' we obtain the following output:
20615 @example
20616 Representation information for unit q
20617 -------------------------------------
20619 for r'Size use ??;
20620 for r'Alignment use 4;
20621 for r use record
20622    x    at 4 range  0 .. 7;
20623    _tag at 0 range  0 .. 31;
20624    s    at 5 range  0 .. 799;
20625 end record;
20627 for r2'Size use 160;
20628 for r2'Alignment use 4;
20629 for r2 use record
20630    x       at  4 range  0 .. 7;
20631    _tag    at  0 range  0 .. 31;
20632    _parent at  0 range  0 .. 63;
20633    y2      at 16 range  0 .. 31;
20634 end record;
20636 for x'Size use 8;
20637 for x'Alignment use 1;
20638 for x use record
20639    y at 0 range  0 .. 7;
20640 end record;
20642 for x1'Size use 112;
20643 for x1'Alignment use 1;
20644 for x1'Component_Size use 11;
20646 for rb1'Size use 13;
20647 for rb1'Alignment use 2;
20648 for rb1'Component_Size use 1;
20650 for rb2'Size use 72;
20651 for rb2'Alignment use 1;
20652 for rb2'Component_Size use 1;
20654 for x2'Size use 224;
20655 for x2'Alignment use 4;
20656 for x2 use record
20657    l1 at  0 range  0 .. 0;
20658    l2 at  0 range  1 .. 64;
20659    l3 at 12 range  0 .. 31;
20660    l4 at 16 range  0 .. 0;
20661    l5 at 16 range  1 .. 13;
20662    l6 at 18 range  0 .. 71;
20663 end record;
20664 @end example
20666 The Size values are actually the Object_Size, i.e., the default size that
20667 will be allocated for objects of the type.
20668 The @code{??} size for type r indicates that we have a variant record, and the
20669 actual size of objects will depend on the discriminant value.
20671 The Alignment values show the actual alignment chosen by the compiler
20672 for each record or array type.
20674 The record representation clause for type r shows where all fields
20675 are placed, including the compiler generated tag field (whose location
20676 cannot be controlled by the programmer).
20678 The record representation clause for the type extension r2 shows all the
20679 fields present, including the parent field, which is a copy of the fields
20680 of the parent type of r2, i.e., r1.
20682 The component size and size clauses for types rb1 and rb2 show
20683 the exact effect of pragma @code{Pack} on these arrays, and the record
20684 representation clause for type x2 shows how pragma @cite{Pack} affects
20685 this record type.
20687 In some cases, it may be useful to cut and paste the representation clauses
20688 generated by the compiler into the original source to fix and guarantee
20689 the actual representation to be used.
20691 @node Standard Library Routines,The Implementation of Standard I/O,Representation Clauses and Pragmas,Top
20692 @anchor{gnat_rm/standard_library_routines doc}@anchor{2ab}@anchor{gnat_rm/standard_library_routines id1}@anchor{2ac}@anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e}
20693 @chapter Standard Library Routines
20696 The Ada Reference Manual contains in Annex A a full description of an
20697 extensive set of standard library routines that can be used in any Ada
20698 program, and which must be provided by all Ada compilers.  They are
20699 analogous to the standard C library used by C programs.
20701 GNAT implements all of the facilities described in annex A, and for most
20702 purposes the description in the Ada Reference Manual, or appropriate Ada
20703 text book, will be sufficient for making use of these facilities.
20705 In the case of the input-output facilities,
20706 @ref{f,,The Implementation of Standard I/O},
20707 gives details on exactly how GNAT interfaces to the
20708 file system.  For the remaining packages, the Ada Reference Manual
20709 should be sufficient.  The following is a list of the packages included,
20710 together with a brief description of the functionality that is provided.
20712 For completeness, references are included to other predefined library
20713 routines defined in other sections of the Ada Reference Manual (these are
20714 cross-indexed from Annex A). For further details see the relevant
20715 package declarations in the run-time library. In particular, a few units
20716 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
20717 and in this case the package declaration contains comments explaining why
20718 the unit is not implemented.
20721 @table @asis
20723 @item @code{Ada} `(A.2)'
20725 This is a parent package for all the standard library packages.  It is
20726 usually included implicitly in your program, and itself contains no
20727 useful data or routines.
20729 @item @code{Ada.Assertions} `(11.4.2)'
20731 @code{Assertions} provides the @code{Assert} subprograms, and also
20732 the declaration of the @code{Assertion_Error} exception.
20734 @item @code{Ada.Asynchronous_Task_Control} `(D.11)'
20736 @code{Asynchronous_Task_Control} provides low level facilities for task
20737 synchronization. It is typically not implemented. See package spec for details.
20739 @item @code{Ada.Calendar} `(9.6)'
20741 @code{Calendar} provides time of day access, and routines for
20742 manipulating times and durations.
20744 @item @code{Ada.Calendar.Arithmetic} `(9.6.1)'
20746 This package provides additional arithmetic
20747 operations for @code{Calendar}.
20749 @item @code{Ada.Calendar.Formatting} `(9.6.1)'
20751 This package provides formatting operations for @code{Calendar}.
20753 @item @code{Ada.Calendar.Time_Zones} `(9.6.1)'
20755 This package provides additional @code{Calendar} facilities
20756 for handling time zones.
20758 @item @code{Ada.Characters} `(A.3.1)'
20760 This is a dummy parent package that contains no useful entities
20762 @item @code{Ada.Characters.Conversions} `(A.3.2)'
20764 This package provides character conversion functions.
20766 @item @code{Ada.Characters.Handling} `(A.3.2)'
20768 This package provides some basic character handling capabilities,
20769 including classification functions for classes of characters (e.g., test
20770 for letters, or digits).
20772 @item @code{Ada.Characters.Latin_1} `(A.3.3)'
20774 This package includes a complete set of definitions of the characters
20775 that appear in type CHARACTER.  It is useful for writing programs that
20776 will run in international environments.  For example, if you want an
20777 upper case E with an acute accent in a string, it is often better to use
20778 the definition of @code{UC_E_Acute} in this package.  Then your program
20779 will print in an understandable manner even if your environment does not
20780 support these extended characters.
20782 @item @code{Ada.Command_Line} `(A.15)'
20784 This package provides access to the command line parameters and the name
20785 of the current program (analogous to the use of @code{argc} and @code{argv}
20786 in C), and also allows the exit status for the program to be set in a
20787 system-independent manner.
20789 @item @code{Ada.Complex_Text_IO} `(G.1.3)'
20791 This package provides text input and output of complex numbers.
20793 @item @code{Ada.Containers} `(A.18.1)'
20795 A top level package providing a few basic definitions used by all the
20796 following specific child packages that provide specific kinds of
20797 containers.
20798 @end table
20800 @code{Ada.Containers.Bounded_Priority_Queues} `(A.18.31)'
20802 @code{Ada.Containers.Bounded_Synchronized_Queues} `(A.18.29)'
20804 @code{Ada.Containers.Doubly_Linked_Lists} `(A.18.3)'
20806 @code{Ada.Containers.Generic_Array_Sort} `(A.18.26)'
20808 @code{Ada.Containers.Generic_Constrained_Array_Sort} `(A.18.26)'
20810 @code{Ada.Containers.Generic_Sort} `(A.18.26)'
20812 @code{Ada.Containers.Hashed_Maps} `(A.18.5)'
20814 @code{Ada.Containers.Hashed_Sets} `(A.18.8)'
20816 @code{Ada.Containers.Indefinite_Doubly_Linked_Lists} `(A.18.12)'
20818 @code{Ada.Containers.Indefinite_Hashed_Maps} `(A.18.13)'
20820 @code{Ada.Containers.Indefinite_Hashed_Sets} `(A.18.15)'
20822 @code{Ada.Containers.Indefinite_Holders} `(A.18.18)'
20824 @code{Ada.Containers.Indefinite_Multiway_Trees} `(A.18.17)'
20826 @code{Ada.Containers.Indefinite_Ordered_Maps} `(A.18.14)'
20828 @code{Ada.Containers.Indefinite_Ordered_Sets} `(A.18.16)'
20830 @code{Ada.Containers.Indefinite_Vectors} `(A.18.11)'
20832 @code{Ada.Containers.Multiway_Trees} `(A.18.10)'
20834 @code{Ada.Containers.Ordered_Maps} `(A.18.6)'
20836 @code{Ada.Containers.Ordered_Sets} `(A.18.9)'
20838 @code{Ada.Containers.Synchronized_Queue_Interfaces} `(A.18.27)'
20840 @code{Ada.Containers.Unbounded_Priority_Queues} `(A.18.30)'
20842 @code{Ada.Containers.Unbounded_Synchronized_Queues} `(A.18.28)'
20844 @code{Ada.Containers.Vectors} `(A.18.2)'
20847 @table @asis
20849 @item @code{Ada.Directories} `(A.16)'
20851 This package provides operations on directories.
20853 @item @code{Ada.Directories.Hierarchical_File_Names} `(A.16.1)'
20855 This package provides additional directory operations handling
20856 hierarchical file names.
20858 @item @code{Ada.Directories.Information} `(A.16)'
20860 This is an implementation defined package for additional directory
20861 operations, which is not implemented in GNAT.
20863 @item @code{Ada.Decimal} `(F.2)'
20865 This package provides constants describing the range of decimal numbers
20866 implemented, and also a decimal divide routine (analogous to the COBOL
20867 verb DIVIDE … GIVING … REMAINDER …)
20869 @item @code{Ada.Direct_IO} `(A.8.4)'
20871 This package provides input-output using a model of a set of records of
20872 fixed-length, containing an arbitrary definite Ada type, indexed by an
20873 integer record number.
20875 @item @code{Ada.Dispatching} `(D.2.1)'
20877 A parent package containing definitions for task dispatching operations.
20879 @item @code{Ada.Dispatching.EDF} `(D.2.6)'
20881 Not implemented in GNAT.
20883 @item @code{Ada.Dispatching.Non_Preemptive} `(D.2.4)'
20885 Not implemented in GNAT.
20887 @item @code{Ada.Dispatching.Round_Robin} `(D.2.5)'
20889 Not implemented in GNAT.
20891 @item @code{Ada.Dynamic_Priorities} `(D.5)'
20893 This package allows the priorities of a task to be adjusted dynamically
20894 as the task is running.
20896 @item @code{Ada.Environment_Variables} `(A.17)'
20898 This package provides facilities for accessing environment variables.
20900 @item @code{Ada.Exceptions} `(11.4.1)'
20902 This package provides additional information on exceptions, and also
20903 contains facilities for treating exceptions as data objects, and raising
20904 exceptions with associated messages.
20906 @item @code{Ada.Execution_Time} `(D.14)'
20908 This package provides CPU clock functionalities. It is not implemented on
20909 all targets (see package spec for details).
20911 @item @code{Ada.Execution_Time.Group_Budgets} `(D.14.2)'
20913 Not implemented in GNAT.
20915 @item @code{Ada.Execution_Time.Timers} `(D.14.1)’'
20917 Not implemented in GNAT.
20919 @item @code{Ada.Finalization} `(7.6)'
20921 This package contains the declarations and subprograms to support the
20922 use of controlled types, providing for automatic initialization and
20923 finalization (analogous to the constructors and destructors of C++).
20925 @item @code{Ada.Float_Text_IO} `(A.10.9)'
20927 A library level instantiation of Text_IO.Float_IO for type Float.
20929 @item @code{Ada.Float_Wide_Text_IO} `(A.10.9)'
20931 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
20933 @item @code{Ada.Float_Wide_Wide_Text_IO} `(A.10.9)'
20935 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
20937 @item @code{Ada.Integer_Text_IO} `(A.10.9)'
20939 A library level instantiation of Text_IO.Integer_IO for type Integer.
20941 @item @code{Ada.Integer_Wide_Text_IO} `(A.10.9)'
20943 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
20945 @item @code{Ada.Integer_Wide_Wide_Text_IO} `(A.10.9)'
20947 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
20949 @item @code{Ada.Interrupts} `(C.3.2)'
20951 This package provides facilities for interfacing to interrupts, which
20952 includes the set of signals or conditions that can be raised and
20953 recognized as interrupts.
20955 @item @code{Ada.Interrupts.Names} `(C.3.2)'
20957 This package provides the set of interrupt names (actually signal
20958 or condition names) that can be handled by GNAT.
20960 @item @code{Ada.IO_Exceptions} `(A.13)'
20962 This package defines the set of exceptions that can be raised by use of
20963 the standard IO packages.
20965 @item @code{Ada.Iterator_Interfaces} `(5.5.1)'
20967 This package provides a generic interface to generalized iterators.
20969 @item @code{Ada.Locales} `(A.19)'
20971 This package provides declarations providing information (Language
20972 and Country) about the current locale.
20974 @item @code{Ada.Numerics}
20976 This package contains some standard constants and exceptions used
20977 throughout the numerics packages.  Note that the constants pi and e are
20978 defined here, and it is better to use these definitions than rolling
20979 your own.
20981 @item @code{Ada.Numerics.Complex_Arrays} `(G.3.2)'
20983 Provides operations on arrays of complex numbers.
20985 @item @code{Ada.Numerics.Complex_Elementary_Functions}
20987 Provides the implementation of standard elementary functions (such as
20988 log and trigonometric functions) operating on complex numbers using the
20989 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
20990 created by the package @code{Numerics.Complex_Types}.
20992 @item @code{Ada.Numerics.Complex_Types}
20994 This is a predefined instantiation of
20995 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
20996 build the type @code{Complex} and @code{Imaginary}.
20998 @item @code{Ada.Numerics.Discrete_Random}
21000 This generic package provides a random number generator suitable for generating
21001 uniformly distributed values of a specified discrete subtype.
21003 @item @code{Ada.Numerics.Float_Random}
21005 This package provides a random number generator suitable for generating
21006 uniformly distributed floating point values in the unit interval.
21008 @item @code{Ada.Numerics.Generic_Complex_Elementary_Functions}
21010 This is a generic version of the package that provides the
21011 implementation of standard elementary functions (such as log and
21012 trigonometric functions) for an arbitrary complex type.
21014 The following predefined instantiations of this package are provided:
21017 @itemize *
21019 @item 
21020 @code{Short_Float}
21022 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
21024 @item 
21025 @code{Float}
21027 @code{Ada.Numerics.Complex_Elementary_Functions}
21029 @item 
21030 @code{Long_Float}
21032 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
21033 @end itemize
21035 @item @code{Ada.Numerics.Generic_Complex_Types}
21037 This is a generic package that allows the creation of complex types,
21038 with associated complex arithmetic operations.
21040 The following predefined instantiations of this package exist
21043 @itemize *
21045 @item 
21046 @code{Short_Float}
21048 @code{Ada.Numerics.Short_Complex_Complex_Types}
21050 @item 
21051 @code{Float}
21053 @code{Ada.Numerics.Complex_Complex_Types}
21055 @item 
21056 @code{Long_Float}
21058 @code{Ada.Numerics.Long_Complex_Complex_Types}
21059 @end itemize
21061 @item @code{Ada.Numerics.Generic_Elementary_Functions}
21063 This is a generic package that provides the implementation of standard
21064 elementary functions (such as log an trigonometric functions) for an
21065 arbitrary float type.
21067 The following predefined instantiations of this package exist
21070 @itemize *
21072 @item 
21073 @code{Short_Float}
21075 @code{Ada.Numerics.Short_Elementary_Functions}
21077 @item 
21078 @code{Float}
21080 @code{Ada.Numerics.Elementary_Functions}
21082 @item 
21083 @code{Long_Float}
21085 @code{Ada.Numerics.Long_Elementary_Functions}
21086 @end itemize
21088 @item @code{Ada.Numerics.Generic_Real_Arrays} `(G.3.1)'
21090 Generic operations on arrays of reals
21092 @item @code{Ada.Numerics.Real_Arrays} `(G.3.1)'
21094 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
21096 @item @code{Ada.Real_Time} `(D.8)'
21098 This package provides facilities similar to those of @code{Calendar}, but
21099 operating with a finer clock suitable for real time control. Note that
21100 annex D requires that there be no backward clock jumps, and GNAT generally
21101 guarantees this behavior, but of course if the external clock on which
21102 the GNAT runtime depends is deliberately reset by some external event,
21103 then such a backward jump may occur.
21105 @item @code{Ada.Real_Time.Timing_Events} `(D.15)'
21107 Not implemented in GNAT.
21109 @item @code{Ada.Sequential_IO} `(A.8.1)'
21111 This package provides input-output facilities for sequential files,
21112 which can contain a sequence of values of a single type, which can be
21113 any Ada type, including indefinite (unconstrained) types.
21115 @item @code{Ada.Storage_IO} `(A.9)'
21117 This package provides a facility for mapping arbitrary Ada types to and
21118 from a storage buffer.  It is primarily intended for the creation of new
21119 IO packages.
21121 @item @code{Ada.Streams} `(13.13.1)'
21123 This is a generic package that provides the basic support for the
21124 concept of streams as used by the stream attributes (@code{Input},
21125 @code{Output}, @code{Read} and @code{Write}).
21127 @item @code{Ada.Streams.Stream_IO} `(A.12.1)'
21129 This package is a specialization of the type @code{Streams} defined in
21130 package @code{Streams} together with a set of operations providing
21131 Stream_IO capability.  The Stream_IO model permits both random and
21132 sequential access to a file which can contain an arbitrary set of values
21133 of one or more Ada types.
21135 @item @code{Ada.Strings} `(A.4.1)'
21137 This package provides some basic constants used by the string handling
21138 packages.
21140 @item @code{Ada.Strings.Bounded} `(A.4.4)'
21142 This package provides facilities for handling variable length
21143 strings.  The bounded model requires a maximum length.  It is thus
21144 somewhat more limited than the unbounded model, but avoids the use of
21145 dynamic allocation or finalization.
21147 @item @code{Ada.Strings.Bounded.Equal_Case_Insensitive} `(A.4.10)'
21149 Provides case-insensitive comparisons of bounded strings
21151 @item @code{Ada.Strings.Bounded.Hash} `(A.4.9)'
21153 This package provides a generic hash function for bounded strings
21155 @item @code{Ada.Strings.Bounded.Hash_Case_Insensitive} `(A.4.9)'
21157 This package provides a generic hash function for bounded strings that
21158 converts the string to be hashed to lower case.
21160 @item @code{Ada.Strings.Bounded.Less_Case_Insensitive} `(A.4.10)'
21162 This package provides a comparison function for bounded strings that works
21163 in a case insensitive manner by converting to lower case before the comparison.
21165 @item @code{Ada.Strings.Fixed} `(A.4.3)'
21167 This package provides facilities for handling fixed length strings.
21169 @item @code{Ada.Strings.Fixed.Equal_Case_Insensitive} `(A.4.10)'
21171 This package provides an equality function for fixed strings that compares
21172 the strings after converting both to lower case.
21174 @item @code{Ada.Strings.Fixed.Hash_Case_Insensitive} `(A.4.9)'
21176 This package provides a case insensitive hash function for fixed strings that
21177 converts the string to lower case before computing the hash.
21179 @item @code{Ada.Strings.Fixed.Less_Case_Insensitive} `(A.4.10)'
21181 This package provides a comparison function for fixed strings that works
21182 in a case insensitive manner by converting to lower case before the comparison.
21184 @item @code{Ada.Strings.Hash} `(A.4.9)'
21186 This package provides a hash function for strings.
21188 @item @code{Ada.Strings.Hash_Case_Insensitive} `(A.4.9)'
21190 This package provides a hash function for strings that is case insensitive.
21191 The string is converted to lower case before computing the hash.
21193 @item @code{Ada.Strings.Less_Case_Insensitive} `(A.4.10)'
21195 This package provides a comparison function for\strings that works
21196 in a case insensitive manner by converting to lower case before the comparison.
21198 @item @code{Ada.Strings.Maps} `(A.4.2)'
21200 This package provides facilities for handling character mappings and
21201 arbitrarily defined subsets of characters.  For instance it is useful in
21202 defining specialized translation tables.
21204 @item @code{Ada.Strings.Maps.Constants} `(A.4.6)'
21206 This package provides a standard set of predefined mappings and
21207 predefined character sets.  For example, the standard upper to lower case
21208 conversion table is found in this package.  Note that upper to lower case
21209 conversion is non-trivial if you want to take the entire set of
21210 characters, including extended characters like E with an acute accent,
21211 into account.  You should use the mappings in this package (rather than
21212 adding 32 yourself) to do case mappings.
21214 @item @code{Ada.Strings.Unbounded} `(A.4.5)'
21216 This package provides facilities for handling variable length
21217 strings.  The unbounded model allows arbitrary length strings, but
21218 requires the use of dynamic allocation and finalization.
21220 @item @code{Ada.Strings.Unbounded.Equal_Case_Insensitive} `(A.4.10)'
21222 Provides case-insensitive comparisons of unbounded strings
21224 @item @code{Ada.Strings.Unbounded.Hash} `(A.4.9)'
21226 This package provides a generic hash function for unbounded strings
21228 @item @code{Ada.Strings.Unbounded.Hash_Case_Insensitive} `(A.4.9)'
21230 This package provides a generic hash function for unbounded strings that
21231 converts the string to be hashed to lower case.
21233 @item @code{Ada.Strings.Unbounded.Less_Case_Insensitive} `(A.4.10)'
21235 This package provides a comparison function for unbounded strings that works
21236 in a case insensitive manner by converting to lower case before the comparison.
21238 @item @code{Ada.Strings.UTF_Encoding} `(A.4.11)'
21240 This package provides basic definitions for dealing with UTF-encoded strings.
21242 @item @code{Ada.Strings.UTF_Encoding.Conversions} `(A.4.11)'
21244 This package provides conversion functions for UTF-encoded strings.
21245 @end table
21247 @code{Ada.Strings.UTF_Encoding.Strings} `(A.4.11)'
21249 @code{Ada.Strings.UTF_Encoding.Wide_Strings} `(A.4.11)'
21252 @table @asis
21254 @item @code{Ada.Strings.UTF_Encoding.Wide_Wide_Strings} `(A.4.11)'
21256 These packages provide facilities for handling UTF encodings for
21257 Strings, Wide_Strings and Wide_Wide_Strings.
21258 @end table
21260 @code{Ada.Strings.Wide_Bounded} `(A.4.7)'
21262 @code{Ada.Strings.Wide_Fixed} `(A.4.7)'
21264 @code{Ada.Strings.Wide_Maps} `(A.4.7)'
21267 @table @asis
21269 @item @code{Ada.Strings.Wide_Unbounded} `(A.4.7)'
21271 These packages provide analogous capabilities to the corresponding
21272 packages without @code{Wide_} in the name, but operate with the types
21273 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
21274 and @code{Character}. Versions of all the child packages are available.
21275 @end table
21277 @code{Ada.Strings.Wide_Wide_Bounded} `(A.4.7)'
21279 @code{Ada.Strings.Wide_Wide_Fixed} `(A.4.7)'
21281 @code{Ada.Strings.Wide_Wide_Maps} `(A.4.7)'
21284 @table @asis
21286 @item @code{Ada.Strings.Wide_Wide_Unbounded} `(A.4.7)'
21288 These packages provide analogous capabilities to the corresponding
21289 packages without @code{Wide_} in the name, but operate with the types
21290 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
21291 of @code{String} and @code{Character}.
21293 @item @code{Ada.Synchronous_Barriers} `(D.10.1)'
21295 This package provides facilities for synchronizing tasks at a low level
21296 with barriers.
21298 @item @code{Ada.Synchronous_Task_Control} `(D.10)'
21300 This package provides some standard facilities for controlling task
21301 communication in a synchronous manner.
21303 @item @code{Ada.Synchronous_Task_Control.EDF} `(D.10)'
21305 Not implemented in GNAT.
21307 @item @code{Ada.Tags}
21309 This package contains definitions for manipulation of the tags of tagged
21310 values.
21312 @item @code{Ada.Tags.Generic_Dispatching_Constructor} `(3.9)'
21314 This package provides a way of constructing tagged class-wide values given
21315 only the tag value.
21317 @item @code{Ada.Task_Attributes} `(C.7.2)'
21319 This package provides the capability of associating arbitrary
21320 task-specific data with separate tasks.
21322 @item @code{Ada.Task_Identification} `(C.7.1)'
21324 This package provides capabilities for task identification.
21326 @item @code{Ada.Task_Termination} `(C.7.3)'
21328 This package provides control over task termination.
21330 @item @code{Ada.Text_IO}
21332 This package provides basic text input-output capabilities for
21333 character, string and numeric data.  The subpackages of this
21334 package are listed next. Note that although these are defined
21335 as subpackages in the RM, they are actually transparently
21336 implemented as child packages in GNAT, meaning that they
21337 are only loaded if needed.
21339 @item @code{Ada.Text_IO.Decimal_IO}
21341 Provides input-output facilities for decimal fixed-point types
21343 @item @code{Ada.Text_IO.Enumeration_IO}
21345 Provides input-output facilities for enumeration types.
21347 @item @code{Ada.Text_IO.Fixed_IO}
21349 Provides input-output facilities for ordinary fixed-point types.
21351 @item @code{Ada.Text_IO.Float_IO}
21353 Provides input-output facilities for float types.  The following
21354 predefined instantiations of this generic package are available:
21357 @itemize *
21359 @item 
21360 @code{Short_Float}
21362 @code{Short_Float_Text_IO}
21364 @item 
21365 @code{Float}
21367 @code{Float_Text_IO}
21369 @item 
21370 @code{Long_Float}
21372 @code{Long_Float_Text_IO}
21373 @end itemize
21375 @item @code{Ada.Text_IO.Integer_IO}
21377 Provides input-output facilities for integer types.  The following
21378 predefined instantiations of this generic package are available:
21381 @itemize *
21383 @item 
21384 @code{Short_Short_Integer}
21386 @code{Ada.Short_Short_Integer_Text_IO}
21388 @item 
21389 @code{Short_Integer}
21391 @code{Ada.Short_Integer_Text_IO}
21393 @item 
21394 @code{Integer}
21396 @code{Ada.Integer_Text_IO}
21398 @item 
21399 @code{Long_Integer}
21401 @code{Ada.Long_Integer_Text_IO}
21403 @item 
21404 @code{Long_Long_Integer}
21406 @code{Ada.Long_Long_Integer_Text_IO}
21407 @end itemize
21409 @item @code{Ada.Text_IO.Modular_IO}
21411 Provides input-output facilities for modular (unsigned) types.
21413 @item @code{Ada.Text_IO.Bounded_IO (A.10.11)}
21415 Provides input-output facilities for bounded strings.
21417 @item @code{Ada.Text_IO.Complex_IO (G.1.3)}
21419 This package provides basic text input-output capabilities for complex
21420 data.
21422 @item @code{Ada.Text_IO.Editing (F.3.3)}
21424 This package contains routines for edited output, analogous to the use
21425 of pictures in COBOL.  The picture formats used by this package are a
21426 close copy of the facility in COBOL.
21428 @item @code{Ada.Text_IO.Text_Streams (A.12.2)}
21430 This package provides a facility that allows Text_IO files to be treated
21431 as streams, so that the stream attributes can be used for writing
21432 arbitrary data, including binary data, to Text_IO files.
21434 @item @code{Ada.Text_IO.Unbounded_IO (A.10.12)}
21436 This package provides input-output facilities for unbounded strings.
21438 @item @code{Ada.Unchecked_Conversion (13.9)}
21440 This generic package allows arbitrary conversion from one type to
21441 another of the same size, providing for breaking the type safety in
21442 special circumstances.
21444 If the types have the same Size (more accurately the same Value_Size),
21445 then the effect is simply to transfer the bits from the source to the
21446 target type without any modification.  This usage is well defined, and
21447 for simple types whose representation is typically the same across
21448 all implementations, gives a portable method of performing such
21449 conversions.
21451 If the types do not have the same size, then the result is implementation
21452 defined, and thus may be non-portable.  The following describes how GNAT
21453 handles such unchecked conversion cases.
21455 If the types are of different sizes, and are both discrete types, then
21456 the effect is of a normal type conversion without any constraint checking.
21457 In particular if the result type has a larger size, the result will be
21458 zero or sign extended.  If the result type has a smaller size, the result
21459 will be truncated by ignoring high order bits.
21461 If the types are of different sizes, and are not both discrete types,
21462 then the conversion works as though pointers were created to the source
21463 and target, and the pointer value is converted.  The effect is that bits
21464 are copied from successive low order storage units and bits of the source
21465 up to the length of the target type.
21467 A warning is issued if the lengths differ, since the effect in this
21468 case is implementation dependent, and the above behavior may not match
21469 that of some other compiler.
21471 A pointer to one type may be converted to a pointer to another type using
21472 unchecked conversion.  The only case in which the effect is undefined is
21473 when one or both pointers are pointers to unconstrained array types.  In
21474 this case, the bounds information may get incorrectly transferred, and in
21475 particular, GNAT uses double size pointers for such types, and it is
21476 meaningless to convert between such pointer types.  GNAT will issue a
21477 warning if the alignment of the target designated type is more strict
21478 than the alignment of the source designated type (since the result may
21479 be unaligned in this case).
21481 A pointer other than a pointer to an unconstrained array type may be
21482 converted to and from System.Address.  Such usage is common in Ada 83
21483 programs, but note that Ada.Address_To_Access_Conversions is the
21484 preferred method of performing such conversions in Ada 95 and Ada 2005.
21485 Neither
21486 unchecked conversion nor Ada.Address_To_Access_Conversions should be
21487 used in conjunction with pointers to unconstrained objects, since
21488 the bounds information cannot be handled correctly in this case.
21490 @item @code{Ada.Unchecked_Deallocation} `(13.11.2)'
21492 This generic package allows explicit freeing of storage previously
21493 allocated by use of an allocator.
21495 @item @code{Ada.Wide_Text_IO} `(A.11)'
21497 This package is similar to @code{Ada.Text_IO}, except that the external
21498 file supports wide character representations, and the internal types are
21499 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21500 and @code{String}. The corresponding set of nested packages and child
21501 packages are defined.
21503 @item @code{Ada.Wide_Wide_Text_IO} `(A.11)'
21505 This package is similar to @code{Ada.Text_IO}, except that the external
21506 file supports wide character representations, and the internal types are
21507 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21508 and @code{String}. The corresponding set of nested packages and child
21509 packages are defined.
21510 @end table
21512 For packages in Interfaces and System, all the RM defined packages are
21513 available in GNAT, see the Ada 2012 RM for full details.
21515 @node The Implementation of Standard I/O,The GNAT Library,Standard Library Routines,Top
21516 @anchor{gnat_rm/the_implementation_of_standard_i_o doc}@anchor{2ad}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{2ae}@anchor{gnat_rm/the_implementation_of_standard_i_o the-implementation-of-standard-i-o}@anchor{f}
21517 @chapter The Implementation of Standard I/O
21520 GNAT implements all the required input-output facilities described in
21521 A.6 through A.14.  These sections of the Ada Reference Manual describe the
21522 required behavior of these packages from the Ada point of view, and if
21523 you are writing a portable Ada program that does not need to know the
21524 exact manner in which Ada maps to the outside world when it comes to
21525 reading or writing external files, then you do not need to read this
21526 chapter.  As long as your files are all regular files (not pipes or
21527 devices), and as long as you write and read the files only from Ada, the
21528 description in the Ada Reference Manual is sufficient.
21530 However, if you want to do input-output to pipes or other devices, such
21531 as the keyboard or screen, or if the files you are dealing with are
21532 either generated by some other language, or to be read by some other
21533 language, then you need to know more about the details of how the GNAT
21534 implementation of these input-output facilities behaves.
21536 In this chapter we give a detailed description of exactly how GNAT
21537 interfaces to the file system.  As always, the sources of the system are
21538 available to you for answering questions at an even more detailed level,
21539 but for most purposes the information in this chapter will suffice.
21541 Another reason that you may need to know more about how input-output is
21542 implemented arises when you have a program written in mixed languages
21543 where, for example, files are shared between the C and Ada sections of
21544 the same program.  GNAT provides some additional facilities, in the form
21545 of additional child library packages, that facilitate this sharing, and
21546 these additional facilities are also described in this chapter.
21548 @menu
21549 * Standard I/O Packages:: 
21550 * FORM Strings:: 
21551 * Direct_IO:: 
21552 * Sequential_IO:: 
21553 * Text_IO:: 
21554 * Wide_Text_IO:: 
21555 * Wide_Wide_Text_IO:: 
21556 * Stream_IO:: 
21557 * Text Translation:: 
21558 * Shared Files:: 
21559 * Filenames encoding:: 
21560 * File content encoding:: 
21561 * Open Modes:: 
21562 * Operations on C Streams:: 
21563 * Interfacing to C Streams:: 
21565 @end menu
21567 @node Standard I/O Packages,FORM Strings,,The Implementation of Standard I/O
21568 @anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2af}@anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{2b0}
21569 @section Standard I/O Packages
21572 The Standard I/O packages described in Annex A for
21575 @itemize *
21577 @item 
21578 Ada.Text_IO
21580 @item 
21581 Ada.Text_IO.Complex_IO
21583 @item 
21584 Ada.Text_IO.Text_Streams
21586 @item 
21587 Ada.Wide_Text_IO
21589 @item 
21590 Ada.Wide_Text_IO.Complex_IO
21592 @item 
21593 Ada.Wide_Text_IO.Text_Streams
21595 @item 
21596 Ada.Wide_Wide_Text_IO
21598 @item 
21599 Ada.Wide_Wide_Text_IO.Complex_IO
21601 @item 
21602 Ada.Wide_Wide_Text_IO.Text_Streams
21604 @item 
21605 Ada.Stream_IO
21607 @item 
21608 Ada.Sequential_IO
21610 @item 
21611 Ada.Direct_IO
21612 @end itemize
21614 are implemented using the C
21615 library streams facility; where
21618 @itemize *
21620 @item 
21621 All files are opened using @code{fopen}.
21623 @item 
21624 All input/output operations use @code{fread}/@cite{fwrite}.
21625 @end itemize
21627 There is no internal buffering of any kind at the Ada library level. The only
21628 buffering is that provided at the system level in the implementation of the
21629 library routines that support streams. This facilitates shared use of these
21630 streams by mixed language programs. Note though that system level buffering is
21631 explicitly enabled at elaboration of the standard I/O packages and that can
21632 have an impact on mixed language programs, in particular those using I/O before
21633 calling the Ada elaboration routine (e.g., adainit). It is recommended to call
21634 the Ada elaboration routine before performing any I/O or when impractical,
21635 flush the common I/O streams and in particular Standard_Output before
21636 elaborating the Ada code.
21638 @node FORM Strings,Direct_IO,Standard I/O Packages,The Implementation of Standard I/O
21639 @anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2b1}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2b2}
21640 @section FORM Strings
21643 The format of a FORM string in GNAT is:
21645 @example
21646 "keyword=value,keyword=value,...,keyword=value"
21647 @end example
21649 where letters may be in upper or lower case, and there are no spaces
21650 between values.  The order of the entries is not important.  Currently
21651 the following keywords defined.
21653 @example
21654 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
21655 SHARED=[YES|NO]
21656 WCEM=[n|h|u|s|e|8|b]
21657 ENCODING=[UTF8|8BITS]
21658 @end example
21660 The use of these parameters is described later in this section. If an
21661 unrecognized keyword appears in a form string, it is silently ignored
21662 and not considered invalid.
21664 @node Direct_IO,Sequential_IO,FORM Strings,The Implementation of Standard I/O
21665 @anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2b3}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2b4}
21666 @section Direct_IO
21669 Direct_IO can only be instantiated for definite types.  This is a
21670 restriction of the Ada language, which means that the records are fixed
21671 length (the length being determined by @code{type'Size}, rounded
21672 up to the next storage unit boundary if necessary).
21674 The records of a Direct_IO file are simply written to the file in index
21675 sequence, with the first record starting at offset zero, and subsequent
21676 records following.  There is no control information of any kind.  For
21677 example, if 32-bit integers are being written, each record takes
21678 4-bytes, so the record at index @code{K} starts at offset
21679 (@code{K}-1)*4.
21681 There is no limit on the size of Direct_IO files, they are expanded as
21682 necessary to accommodate whatever records are written to the file.
21684 @node Sequential_IO,Text_IO,Direct_IO,The Implementation of Standard I/O
21685 @anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2b5}@anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2b6}
21686 @section Sequential_IO
21689 Sequential_IO may be instantiated with either a definite (constrained)
21690 or indefinite (unconstrained) type.
21692 For the definite type case, the elements written to the file are simply
21693 the memory images of the data values with no control information of any
21694 kind.  The resulting file should be read using the same type, no validity
21695 checking is performed on input.
21697 For the indefinite type case, the elements written consist of two
21698 parts.  First is the size of the data item, written as the memory image
21699 of a @code{Interfaces.C.size_t} value, followed by the memory image of
21700 the data value.  The resulting file can only be read using the same
21701 (unconstrained) type.  Normal assignment checks are performed on these
21702 read operations, and if these checks fail, @code{Data_Error} is
21703 raised.  In particular, in the array case, the lengths must match, and in
21704 the variant record case, if the variable for a particular read operation
21705 is constrained, the discriminants must match.
21707 Note that it is not possible to use Sequential_IO to write variable
21708 length array items, and then read the data back into different length
21709 arrays.  For example, the following will raise @code{Data_Error}:
21711 @example
21712 package IO is new Sequential_IO (String);
21713 F : IO.File_Type;
21714 S : String (1..4);
21716 IO.Create (F)
21717 IO.Write (F, "hello!")
21718 IO.Reset (F, Mode=>In_File);
21719 IO.Read (F, S);
21720 Put_Line (S);
21721 @end example
21723 On some Ada implementations, this will print @code{hell}, but the program is
21724 clearly incorrect, since there is only one element in the file, and that
21725 element is the string @code{hello!}.
21727 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
21728 using Stream_IO, and this is the preferred mechanism.  In particular, the
21729 above program fragment rewritten to use Stream_IO will work correctly.
21731 @node Text_IO,Wide_Text_IO,Sequential_IO,The Implementation of Standard I/O
21732 @anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2b7}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2b8}
21733 @section Text_IO
21736 Text_IO files consist of a stream of characters containing the following
21737 special control characters:
21739 @example
21740 LF (line feed, 16#0A#) Line Mark
21741 FF (form feed, 16#0C#) Page Mark
21742 @end example
21744 A canonical Text_IO file is defined as one in which the following
21745 conditions are met:
21748 @itemize *
21750 @item 
21751 The character @code{LF} is used only as a line mark, i.e., to mark the end
21752 of the line.
21754 @item 
21755 The character @code{FF} is used only as a page mark, i.e., to mark the
21756 end of a page and consequently can appear only immediately following a
21757 @code{LF} (line mark) character.
21759 @item 
21760 The file ends with either @code{LF} (line mark) or @code{LF}-@cite{FF}
21761 (line mark, page mark).  In the former case, the page mark is implicitly
21762 assumed to be present.
21763 @end itemize
21765 A file written using Text_IO will be in canonical form provided that no
21766 explicit @code{LF} or @code{FF} characters are written using @code{Put}
21767 or @code{Put_Line}.  There will be no @code{FF} character at the end of
21768 the file unless an explicit @code{New_Page} operation was performed
21769 before closing the file.
21771 A canonical Text_IO file that is a regular file (i.e., not a device or a
21772 pipe) can be read using any of the routines in Text_IO.  The
21773 semantics in this case will be exactly as defined in the Ada Reference
21774 Manual, and all the routines in Text_IO are fully implemented.
21776 A text file that does not meet the requirements for a canonical Text_IO
21777 file has one of the following:
21780 @itemize *
21782 @item 
21783 The file contains @code{FF} characters not immediately following a
21784 @code{LF} character.
21786 @item 
21787 The file contains @code{LF} or @code{FF} characters written by
21788 @code{Put} or @code{Put_Line}, which are not logically considered to be
21789 line marks or page marks.
21791 @item 
21792 The file ends in a character other than @code{LF} or @code{FF},
21793 i.e., there is no explicit line mark or page mark at the end of the file.
21794 @end itemize
21796 Text_IO can be used to read such non-standard text files but subprograms
21797 to do with line or page numbers do not have defined meanings.  In
21798 particular, a @code{FF} character that does not follow a @code{LF}
21799 character may or may not be treated as a page mark from the point of
21800 view of page and line numbering.  Every @code{LF} character is considered
21801 to end a line, and there is an implied @code{LF} character at the end of
21802 the file.
21804 @menu
21805 * Stream Pointer Positioning:: 
21806 * Reading and Writing Non-Regular Files:: 
21807 * Get_Immediate:: 
21808 * Treating Text_IO Files as Streams:: 
21809 * Text_IO Extensions:: 
21810 * Text_IO Facilities for Unbounded Strings:: 
21812 @end menu
21814 @node Stream Pointer Positioning,Reading and Writing Non-Regular Files,,Text_IO
21815 @anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2b9}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2ba}
21816 @subsection Stream Pointer Positioning
21819 @code{Ada.Text_IO} has a definition of current position for a file that
21820 is being read.  No internal buffering occurs in Text_IO, and usually the
21821 physical position in the stream used to implement the file corresponds
21822 to this logical position defined by Text_IO.  There are two exceptions:
21825 @itemize *
21827 @item 
21828 After a call to @code{End_Of_Page} that returns @code{True}, the stream
21829 is positioned past the @code{LF} (line mark) that precedes the page
21830 mark.  Text_IO maintains an internal flag so that subsequent read
21831 operations properly handle the logical position which is unchanged by
21832 the @code{End_Of_Page} call.
21834 @item 
21835 After a call to @code{End_Of_File} that returns @code{True}, if the
21836 Text_IO file was positioned before the line mark at the end of file
21837 before the call, then the logical position is unchanged, but the stream
21838 is physically positioned right at the end of file (past the line mark,
21839 and past a possible page mark following the line mark.  Again Text_IO
21840 maintains internal flags so that subsequent read operations properly
21841 handle the logical position.
21842 @end itemize
21844 These discrepancies have no effect on the observable behavior of
21845 Text_IO, but if a single Ada stream is shared between a C program and
21846 Ada program, or shared (using @code{shared=yes} in the form string)
21847 between two Ada files, then the difference may be observable in some
21848 situations.
21850 @node Reading and Writing Non-Regular Files,Get_Immediate,Stream Pointer Positioning,Text_IO
21851 @anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2bb}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2bc}
21852 @subsection Reading and Writing Non-Regular Files
21855 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
21856 can be used for reading and writing.  Writing is not affected and the
21857 sequence of characters output is identical to the normal file case, but
21858 for reading, the behavior of Text_IO is modified to avoid undesirable
21859 look-ahead as follows:
21861 An input file that is not a regular file is considered to have no page
21862 marks.  Any @code{Ascii.FF} characters (the character normally used for a
21863 page mark) appearing in the file are considered to be data
21864 characters.  In particular:
21867 @itemize *
21869 @item 
21870 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
21871 following a line mark.  If a page mark appears, it will be treated as a
21872 data character.
21874 @item 
21875 This avoids the need to wait for an extra character to be typed or
21876 entered from the pipe to complete one of these operations.
21878 @item 
21879 @code{End_Of_Page} always returns @code{False}
21881 @item 
21882 @code{End_Of_File} will return @code{False} if there is a page mark at
21883 the end of the file.
21884 @end itemize
21886 Output to non-regular files is the same as for regular files.  Page marks
21887 may be written to non-regular files using @code{New_Page}, but as noted
21888 above they will not be treated as page marks on input if the output is
21889 piped to another Ada program.
21891 Another important discrepancy when reading non-regular files is that the end
21892 of file indication is not ‘sticky’.  If an end of file is entered, e.g., by
21893 pressing the @code{EOT} key,
21894 then end of file
21895 is signaled once (i.e., the test @code{End_Of_File}
21896 will yield @code{True}, or a read will
21897 raise @code{End_Error}), but then reading can resume
21898 to read data past that end of
21899 file indication, until another end of file indication is entered.
21901 @node Get_Immediate,Treating Text_IO Files as Streams,Reading and Writing Non-Regular Files,Text_IO
21902 @anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2bd}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2be}
21903 @subsection Get_Immediate
21906 @geindex Get_Immediate
21908 Get_Immediate returns the next character (including control characters)
21909 from the input file.  In particular, Get_Immediate will return LF or FF
21910 characters used as line marks or page marks.  Such operations leave the
21911 file positioned past the control character, and it is thus not treated
21912 as having its normal function.  This means that page, line and column
21913 counts after this kind of Get_Immediate call are set as though the mark
21914 did not occur.  In the case where a Get_Immediate leaves the file
21915 positioned between the line mark and page mark (which is not normally
21916 possible), it is undefined whether the FF character will be treated as a
21917 page mark.
21919 @node Treating Text_IO Files as Streams,Text_IO Extensions,Get_Immediate,Text_IO
21920 @anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2bf}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2c0}
21921 @subsection Treating Text_IO Files as Streams
21924 @geindex Stream files
21926 The package @code{Text_IO.Streams} allows a @code{Text_IO} file to be treated
21927 as a stream.  Data written to a @code{Text_IO} file in this stream mode is
21928 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
21929 16#0C# (@code{FF}), the resulting file may have non-standard
21930 format.  Similarly if read operations are used to read from a Text_IO
21931 file treated as a stream, then @code{LF} and @code{FF} characters may be
21932 skipped and the effect is similar to that described above for
21933 @code{Get_Immediate}.
21935 @node Text_IO Extensions,Text_IO Facilities for Unbounded Strings,Treating Text_IO Files as Streams,Text_IO
21936 @anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2c1}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2c2}
21937 @subsection Text_IO Extensions
21940 @geindex Text_IO extensions
21942 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
21943 to the standard @code{Text_IO} package:
21946 @itemize *
21948 @item 
21949 function File_Exists (Name : String) return Boolean;
21950 Determines if a file of the given name exists.
21952 @item 
21953 function Get_Line return String;
21954 Reads a string from the standard input file.  The value returned is exactly
21955 the length of the line that was read.
21957 @item 
21958 function Get_Line (File : Ada.Text_IO.File_Type) return String;
21959 Similar, except that the parameter File specifies the file from which
21960 the string is to be read.
21961 @end itemize
21963 @node Text_IO Facilities for Unbounded Strings,,Text_IO Extensions,Text_IO
21964 @anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2c3}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2c4}
21965 @subsection Text_IO Facilities for Unbounded Strings
21968 @geindex Text_IO for unbounded strings
21970 @geindex Unbounded_String
21971 @geindex Text_IO operations
21973 The package @code{Ada.Strings.Unbounded.Text_IO}
21974 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
21975 subprograms useful for Text_IO operations on unbounded strings:
21978 @itemize *
21980 @item 
21981 function Get_Line (File : File_Type) return Unbounded_String;
21982 Reads a line from the specified file
21983 and returns the result as an unbounded string.
21985 @item 
21986 procedure Put (File : File_Type; U : Unbounded_String);
21987 Writes the value of the given unbounded string to the specified file
21988 Similar to the effect of
21989 @code{Put (To_String (U))} except that an extra copy is avoided.
21991 @item 
21992 procedure Put_Line (File : File_Type; U : Unbounded_String);
21993 Writes the value of the given unbounded string to the specified file,
21994 followed by a @code{New_Line}.
21995 Similar to the effect of @code{Put_Line (To_String (U))} except
21996 that an extra copy is avoided.
21997 @end itemize
21999 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
22000 and is optional.  If the parameter is omitted, then the standard input or
22001 output file is referenced as appropriate.
22003 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
22004 files @code{a-swuwti.ads} and @code{a-swuwti.adb} provides similar extended
22005 @code{Wide_Text_IO} functionality for unbounded wide strings.
22007 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
22008 files @code{a-szuzti.ads} and @code{a-szuzti.adb} provides similar extended
22009 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
22011 @node Wide_Text_IO,Wide_Wide_Text_IO,Text_IO,The Implementation of Standard I/O
22012 @anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2c5}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2c6}
22013 @section Wide_Text_IO
22016 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
22017 both input and output files may contain special sequences that represent
22018 wide character values.  The encoding scheme for a given file may be
22019 specified using a FORM parameter:
22021 @example
22022 WCEM=`x`
22023 @end example
22025 as part of the FORM string (WCEM = wide character encoding method),
22026 where @code{x} is one of the following characters
22029 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
22030 @headitem
22032 Character
22034 @tab
22036 Encoding
22038 @item
22042 @tab
22044 Hex ESC encoding
22046 @item
22050 @tab
22052 Upper half encoding
22054 @item
22058 @tab
22060 Shift-JIS encoding
22062 @item
22066 @tab
22068 EUC Encoding
22070 @item
22074 @tab
22076 UTF-8 encoding
22078 @item
22082 @tab
22084 Brackets encoding
22086 @end multitable
22089 The encoding methods match those that
22090 can be used in a source
22091 program, but there is no requirement that the encoding method used for
22092 the source program be the same as the encoding method used for files,
22093 and different files may use different encoding methods.
22095 The default encoding method for the standard files, and for opened files
22096 for which no WCEM parameter is given in the FORM string matches the
22097 wide character encoding specified for the main program (the default
22098 being brackets encoding if no coding method was specified with -gnatW).
22101 @table @asis
22103 @item `Hex Coding'
22105 In this encoding, a wide character is represented by a five character
22106 sequence:
22107 @end table
22109 @example
22110 ESC a b c d
22111 @end example
22114 @quotation
22116 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22117 characters (using upper case letters) of the wide character code.  For
22118 example, ESC A345 is used to represent the wide character with code
22119 16#A345#.  This scheme is compatible with use of the full
22120 @code{Wide_Character} set.
22121 @end quotation
22124 @table @asis
22126 @item `Upper Half Coding'
22128 The wide character with encoding 16#abcd#, where the upper bit is on
22129 (i.e., a is in the range 8-F) is represented as two bytes 16#ab# and
22130 16#cd#.  The second byte may never be a format control character, but is
22131 not required to be in the upper half.  This method can be also used for
22132 shift-JIS or EUC where the internal coding matches the external coding.
22134 @item `Shift JIS Coding'
22136 A wide character is represented by a two character sequence 16#ab# and
22137 16#cd#, with the restrictions described for upper half encoding as
22138 described above.  The internal character code is the corresponding JIS
22139 character according to the standard algorithm for Shift-JIS
22140 conversion.  Only characters defined in the JIS code set table can be
22141 used with this encoding method.
22143 @item `EUC Coding'
22145 A wide character is represented by a two character sequence 16#ab# and
22146 16#cd#, with both characters being in the upper half.  The internal
22147 character code is the corresponding JIS character according to the EUC
22148 encoding algorithm.  Only characters defined in the JIS code set table
22149 can be used with this encoding method.
22151 @item `UTF-8 Coding'
22153 A wide character is represented using
22154 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22155 10646-1/Am.2.  Depending on the character value, the representation
22156 is a one, two, or three byte sequence:
22157 @end table
22159 @example
22160 16#0000#-16#007f#: 2#0xxxxxxx#
22161 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
22162 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22163 @end example
22166 @quotation
22168 where the @code{xxx} bits correspond to the left-padded bits of the
22169 16-bit character value.  Note that all lower half ASCII characters
22170 are represented as ASCII bytes and all upper half characters and
22171 other wide characters are represented as sequences of upper-half
22172 (The full UTF-8 scheme allows for encoding 31-bit characters as
22173 6-byte sequences, but in this implementation, all UTF-8 sequences
22174 of four or more bytes length will raise a Constraint_Error, as
22175 will all invalid UTF-8 sequences.)
22176 @end quotation
22179 @table @asis
22181 @item `Brackets Coding'
22183 In this encoding, a wide character is represented by the following eight
22184 character sequence:
22185 @end table
22187 @example
22188 [ " a b c d " ]
22189 @end example
22192 @quotation
22194 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22195 characters (using uppercase letters) of the wide character code.  For
22196 example, @code{["A345"]} is used to represent the wide character with code
22197 @code{16#A345#}.
22198 This scheme is compatible with use of the full Wide_Character set.
22199 On input, brackets coding can also be used for upper half characters,
22200 e.g., @code{["C1"]} for lower case a.  However, on output, brackets notation
22201 is only used for wide characters with a code greater than @code{16#FF#}.
22203 Note that brackets coding is not normally used in the context of
22204 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
22205 a portable way of encoding source files. In the context of Wide_Text_IO
22206 or Wide_Wide_Text_IO, it can only be used if the file does not contain
22207 any instance of the left bracket character other than to encode wide
22208 character values using the brackets encoding method. In practice it is
22209 expected that some standard wide character encoding method such
22210 as UTF-8 will be used for text input output.
22212 If brackets notation is used, then any occurrence of a left bracket
22213 in the input file which is not the start of a valid wide character
22214 sequence will cause Constraint_Error to be raised. It is possible to
22215 encode a left bracket as [“5B”] and Wide_Text_IO and Wide_Wide_Text_IO
22216 input will interpret this as a left bracket.
22218 However, when a left bracket is output, it will be output as a left bracket
22219 and not as [“5B”]. We make this decision because for normal use of
22220 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
22221 brackets. For example, if we write:
22223 @example
22224 Put_Line ("Start of output [first run]");
22225 @end example
22227 we really do not want to have the left bracket in this message clobbered so
22228 that the output reads:
22229 @end quotation
22231 @example
22232 Start of output ["5B"]first run]
22233 @end example
22236 @quotation
22238 In practice brackets encoding is reasonably useful for normal Put_Line use
22239 since we won’t get confused between left brackets and wide character
22240 sequences in the output. But for input, or when files are written out
22241 and read back in, it really makes better sense to use one of the standard
22242 encoding methods such as UTF-8.
22243 @end quotation
22245 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
22246 not all wide character
22247 values can be represented.  An attempt to output a character that cannot
22248 be represented using the encoding scheme for the file causes
22249 Constraint_Error to be raised.  An invalid wide character sequence on
22250 input also causes Constraint_Error to be raised.
22252 @menu
22253 * Stream Pointer Positioning: Stream Pointer Positioning<2>. 
22254 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>. 
22256 @end menu
22258 @node Stream Pointer Positioning<2>,Reading and Writing Non-Regular Files<2>,,Wide_Text_IO
22259 @anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2c7}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2c8}
22260 @subsection Stream Pointer Positioning
22263 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22264 of stream pointer positioning (@ref{2b8,,Text_IO}).  There is one additional
22265 case:
22267 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
22268 normal lower ASCII set, i.e. a character in the range:
22270 @example
22271 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
22272 @end example
22274 then although the logical position of the file pointer is unchanged by
22275 the @code{Look_Ahead} call, the stream is physically positioned past the
22276 wide character sequence.  Again this is to avoid the need for buffering
22277 or backup, and all @code{Wide_Text_IO} routines check the internal
22278 indication that this situation has occurred so that this is not visible
22279 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
22280 can be observed if the wide text file shares a stream with another file.
22282 @node Reading and Writing Non-Regular Files<2>,,Stream Pointer Positioning<2>,Wide_Text_IO
22283 @anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2c9}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2ca}
22284 @subsection Reading and Writing Non-Regular Files
22287 As in the case of Text_IO, when a non-regular file is read, it is
22288 assumed that the file contains no page marks (any form characters are
22289 treated as data characters), and @code{End_Of_Page} always returns
22290 @code{False}.  Similarly, the end of file indication is not sticky, so
22291 it is possible to read beyond an end of file.
22293 @node Wide_Wide_Text_IO,Stream_IO,Wide_Text_IO,The Implementation of Standard I/O
22294 @anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2cb}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2cc}
22295 @section Wide_Wide_Text_IO
22298 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
22299 both input and output files may contain special sequences that represent
22300 wide wide character values.  The encoding scheme for a given file may be
22301 specified using a FORM parameter:
22303 @example
22304 WCEM=`x`
22305 @end example
22307 as part of the FORM string (WCEM = wide character encoding method),
22308 where @code{x} is one of the following characters
22311 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
22312 @headitem
22314 Character
22316 @tab
22318 Encoding
22320 @item
22324 @tab
22326 Hex ESC encoding
22328 @item
22332 @tab
22334 Upper half encoding
22336 @item
22340 @tab
22342 Shift-JIS encoding
22344 @item
22348 @tab
22350 EUC Encoding
22352 @item
22356 @tab
22358 UTF-8 encoding
22360 @item
22364 @tab
22366 Brackets encoding
22368 @end multitable
22371 The encoding methods match those that
22372 can be used in a source
22373 program, but there is no requirement that the encoding method used for
22374 the source program be the same as the encoding method used for files,
22375 and different files may use different encoding methods.
22377 The default encoding method for the standard files, and for opened files
22378 for which no WCEM parameter is given in the FORM string matches the
22379 wide character encoding specified for the main program (the default
22380 being brackets encoding if no coding method was specified with -gnatW).
22383 @table @asis
22385 @item `UTF-8 Coding'
22387 A wide character is represented using
22388 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22389 10646-1/Am.2.  Depending on the character value, the representation
22390 is a one, two, three, or four byte sequence:
22391 @end table
22393 @example
22394 16#000000#-16#00007f#: 2#0xxxxxxx#
22395 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
22396 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22397 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
22398 @end example
22401 @quotation
22403 where the @code{xxx} bits correspond to the left-padded bits of the
22404 21-bit character value.  Note that all lower half ASCII characters
22405 are represented as ASCII bytes and all upper half characters and
22406 other wide characters are represented as sequences of upper-half
22407 characters.
22408 @end quotation
22411 @table @asis
22413 @item `Brackets Coding'
22415 In this encoding, a wide wide character is represented by the following eight
22416 character sequence if is in wide character range
22417 @end table
22419 @example
22420 [ " a b c d " ]
22421 @end example
22424 @quotation
22426 and by the following ten character sequence if not
22427 @end quotation
22429 @example
22430 [ " a b c d e f " ]
22431 @end example
22434 @quotation
22436 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
22437 are the four or six hexadecimal
22438 characters (using uppercase letters) of the wide wide character code.  For
22439 example, @code{["01A345"]} is used to represent the wide wide character
22440 with code @code{16#01A345#}.
22442 This scheme is compatible with use of the full Wide_Wide_Character set.
22443 On input, brackets coding can also be used for upper half characters,
22444 e.g., @code{["C1"]} for lower case a.  However, on output, brackets notation
22445 is only used for wide characters with a code greater than @code{16#FF#}.
22446 @end quotation
22448 If is also possible to use the other Wide_Character encoding methods,
22449 such as Shift-JIS, but the other schemes cannot support the full range
22450 of wide wide characters.
22451 An attempt to output a character that cannot
22452 be represented using the encoding scheme for the file causes
22453 Constraint_Error to be raised.  An invalid wide character sequence on
22454 input also causes Constraint_Error to be raised.
22456 @menu
22457 * Stream Pointer Positioning: Stream Pointer Positioning<3>. 
22458 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>. 
22460 @end menu
22462 @node Stream Pointer Positioning<3>,Reading and Writing Non-Regular Files<3>,,Wide_Wide_Text_IO
22463 @anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2cd}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2ce}
22464 @subsection Stream Pointer Positioning
22467 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22468 of stream pointer positioning (@ref{2b8,,Text_IO}).  There is one additional
22469 case:
22471 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
22472 normal lower ASCII set, i.e. a character in the range:
22474 @example
22475 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
22476 @end example
22478 then although the logical position of the file pointer is unchanged by
22479 the @code{Look_Ahead} call, the stream is physically positioned past the
22480 wide character sequence.  Again this is to avoid the need for buffering
22481 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
22482 indication that this situation has occurred so that this is not visible
22483 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
22484 can be observed if the wide text file shares a stream with another file.
22486 @node Reading and Writing Non-Regular Files<3>,,Stream Pointer Positioning<3>,Wide_Wide_Text_IO
22487 @anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2cf}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2d0}
22488 @subsection Reading and Writing Non-Regular Files
22491 As in the case of Text_IO, when a non-regular file is read, it is
22492 assumed that the file contains no page marks (any form characters are
22493 treated as data characters), and @code{End_Of_Page} always returns
22494 @code{False}.  Similarly, the end of file indication is not sticky, so
22495 it is possible to read beyond an end of file.
22497 @node Stream_IO,Text Translation,Wide_Wide_Text_IO,The Implementation of Standard I/O
22498 @anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2d1}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2d2}
22499 @section Stream_IO
22502 A stream file is a sequence of bytes, where individual elements are
22503 written to the file as described in the Ada Reference Manual.  The type
22504 @code{Stream_Element} is simply a byte.  There are two ways to read or
22505 write a stream file.
22508 @itemize *
22510 @item 
22511 The operations @code{Read} and @code{Write} directly read or write a
22512 sequence of stream elements with no control information.
22514 @item 
22515 The stream attributes applied to a stream file transfer data in the
22516 manner described for stream attributes.
22517 @end itemize
22519 @node Text Translation,Shared Files,Stream_IO,The Implementation of Standard I/O
22520 @anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2d3}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2d4}
22521 @section Text Translation
22524 @code{Text_Translation=xxx} may be used as the Form parameter
22525 passed to Text_IO.Create and Text_IO.Open. @code{Text_Translation=xxx}
22526 has no effect on Unix systems. Possible values are:
22529 @itemize *
22531 @item 
22532 @code{Yes} or @code{Text} is the default, which means to
22533 translate LF to/from CR/LF on Windows systems.
22535 @code{No} disables this translation; i.e. it
22536 uses binary mode. For output files, @code{Text_Translation=No}
22537 may be used to create Unix-style files on
22538 Windows.
22540 @item 
22541 @code{wtext} translation enabled in Unicode mode.
22542 (corresponds to _O_WTEXT).
22544 @item 
22545 @code{u8text} translation enabled in Unicode UTF-8 mode.
22546 (corresponds to O_U8TEXT).
22548 @item 
22549 @code{u16text} translation enabled in Unicode UTF-16
22550 mode. (corresponds to_O_U16TEXT).
22551 @end itemize
22553 @node Shared Files,Filenames encoding,Text Translation,The Implementation of Standard I/O
22554 @anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2d5}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2d6}
22555 @section Shared Files
22558 Section A.14 of the Ada Reference Manual allows implementations to
22559 provide a wide variety of behavior if an attempt is made to access the
22560 same external file with two or more internal files.
22562 To provide a full range of functionality, while at the same time
22563 minimizing the problems of portability caused by this implementation
22564 dependence, GNAT handles file sharing as follows:
22567 @itemize *
22569 @item 
22570 In the absence of a @code{shared=xxx} form parameter, an attempt
22571 to open two or more files with the same full name is considered an error
22572 and is not supported.  The exception @code{Use_Error} will be
22573 raised.  Note that a file that is not explicitly closed by the program
22574 remains open until the program terminates.
22576 @item 
22577 If the form parameter @code{shared=no} appears in the form string, the
22578 file can be opened or created with its own separate stream identifier,
22579 regardless of whether other files sharing the same external file are
22580 opened.  The exact effect depends on how the C stream routines handle
22581 multiple accesses to the same external files using separate streams.
22583 @item 
22584 If the form parameter @code{shared=yes} appears in the form string for
22585 each of two or more files opened using the same full name, the same
22586 stream is shared between these files, and the semantics are as described
22587 in Ada Reference Manual, Section A.14.
22588 @end itemize
22590 When a program that opens multiple files with the same name is ported
22591 from another Ada compiler to GNAT, the effect will be that
22592 @code{Use_Error} is raised.
22594 The documentation of the original compiler and the documentation of the
22595 program should then be examined to determine if file sharing was
22596 expected, and @code{shared=xxx} parameters added to @code{Open}
22597 and @code{Create} calls as required.
22599 When a program is ported from GNAT to some other Ada compiler, no
22600 special attention is required unless the @code{shared=xxx} form
22601 parameter is used in the program.  In this case, you must examine the
22602 documentation of the new compiler to see if it supports the required
22603 file sharing semantics, and form strings modified appropriately.  Of
22604 course it may be the case that the program cannot be ported if the
22605 target compiler does not support the required functionality.  The best
22606 approach in writing portable code is to avoid file sharing (and hence
22607 the use of the @code{shared=xxx} parameter in the form string)
22608 completely.
22610 One common use of file sharing in Ada 83 is the use of instantiations of
22611 Sequential_IO on the same file with different types, to achieve
22612 heterogeneous input-output.  Although this approach will work in GNAT if
22613 @code{shared=yes} is specified, it is preferable in Ada to use Stream_IO
22614 for this purpose (using the stream attributes)
22616 @node Filenames encoding,File content encoding,Shared Files,The Implementation of Standard I/O
22617 @anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2d7}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2d8}
22618 @section Filenames encoding
22621 An encoding form parameter can be used to specify the filename
22622 encoding @code{encoding=xxx}.
22625 @itemize *
22627 @item 
22628 If the form parameter @code{encoding=utf8} appears in the form string, the
22629 filename must be encoded in UTF-8.
22631 @item 
22632 If the form parameter @code{encoding=8bits} appears in the form
22633 string, the filename must be a standard 8bits string.
22634 @end itemize
22636 In the absence of a @code{encoding=xxx} form parameter, the
22637 encoding is controlled by the @code{GNAT_CODE_PAGE} environment
22638 variable. And if not set @code{utf8} is assumed.
22641 @table @asis
22643 @item `CP_ACP'
22645 The current system Windows ANSI code page.
22647 @item `CP_UTF8'
22649 UTF-8 encoding
22650 @end table
22652 This encoding form parameter is only supported on the Windows
22653 platform. On the other Operating Systems the run-time is supporting
22654 UTF-8 natively.
22656 @node File content encoding,Open Modes,Filenames encoding,The Implementation of Standard I/O
22657 @anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2d9}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2da}
22658 @section File content encoding
22661 For text files it is possible to specify the encoding to use. This is
22662 controlled by the by the @code{GNAT_CCS_ENCODING} environment
22663 variable. And if not set @code{TEXT} is assumed.
22665 The possible values are those supported on Windows:
22668 @table @asis
22670 @item `TEXT'
22672 Translated text mode
22674 @item `WTEXT'
22676 Translated unicode encoding
22678 @item `U16TEXT'
22680 Unicode 16-bit encoding
22682 @item `U8TEXT'
22684 Unicode 8-bit encoding
22685 @end table
22687 This encoding is only supported on the Windows platform.
22689 @node Open Modes,Operations on C Streams,File content encoding,The Implementation of Standard I/O
22690 @anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2db}@anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2dc}
22691 @section Open Modes
22694 @code{Open} and @code{Create} calls result in a call to @code{fopen}
22695 using the mode shown in the following table:
22698 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxx} 
22699 @headitem
22701 @code{Open} and @code{Create} Call Modes
22703 @tab
22705 @tab
22707 @item
22709 @tab
22711 `OPEN'
22713 @tab
22715 `CREATE'
22717 @item
22719 Append_File
22721 @tab
22723 “r+”
22725 @tab
22727 “w+”
22729 @item
22731 In_File
22733 @tab
22735 “r”
22737 @tab
22739 “w+”
22741 @item
22743 Out_File (Direct_IO)
22745 @tab
22747 “r+”
22749 @tab
22751 “w”
22753 @item
22755 Out_File (all other cases)
22757 @tab
22759 “w”
22761 @tab
22763 “w”
22765 @item
22767 Inout_File
22769 @tab
22771 “r+”
22773 @tab
22775 “w+”
22777 @end multitable
22780 If text file translation is required, then either @code{b} or @code{t}
22781 is added to the mode, depending on the setting of Text.  Text file
22782 translation refers to the mapping of CR/LF sequences in an external file
22783 to LF characters internally.  This mapping only occurs in DOS and
22784 DOS-like systems, and is not relevant to other systems.
22786 A special case occurs with Stream_IO.  As shown in the above table, the
22787 file is initially opened in @code{r} or @code{w} mode for the
22788 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
22789 subsequently requires switching from reading to writing or vice-versa,
22790 then the file is reopened in @code{r+} mode to permit the required operation.
22792 @node Operations on C Streams,Interfacing to C Streams,Open Modes,The Implementation of Standard I/O
22793 @anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2dd}@anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2de}
22794 @section Operations on C Streams
22797 The package @code{Interfaces.C_Streams} provides an Ada program with direct
22798 access to the C library functions for operations on C streams:
22800 @example
22801 package Interfaces.C_Streams is
22802   -- Note: the reason we do not use the types that are in
22803   -- Interfaces.C is that we want to avoid dragging in the
22804   -- code in this unit if possible.
22805   subtype chars is System.Address;
22806   -- Pointer to null-terminated array of characters
22807   subtype FILEs is System.Address;
22808   -- Corresponds to the C type FILE*
22809   subtype voids is System.Address;
22810   -- Corresponds to the C type void*
22811   subtype int is Integer;
22812   subtype long is Long_Integer;
22813   -- Note: the above types are subtypes deliberately, and it
22814   -- is part of this spec that the above correspondences are
22815   -- guaranteed.  This means that it is legitimate to, for
22816   -- example, use Integer instead of int.  We provide these
22817   -- synonyms for clarity, but in some cases it may be
22818   -- convenient to use the underlying types (for example to
22819   -- avoid an unnecessary dependency of a spec on the spec
22820   -- of this unit).
22821   type size_t is mod 2 ** Standard'Address_Size;
22822   NULL_Stream : constant FILEs;
22823   -- Value returned (NULL in C) to indicate an
22824   -- fdopen/fopen/tmpfile error
22825   ----------------------------------
22826   -- Constants Defined in stdio.h --
22827   ----------------------------------
22828   EOF : constant int;
22829   -- Used by a number of routines to indicate error or
22830   -- end of file
22831   IOFBF : constant int;
22832   IOLBF : constant int;
22833   IONBF : constant int;
22834   -- Used to indicate buffering mode for setvbuf call
22835   SEEK_CUR : constant int;
22836   SEEK_END : constant int;
22837   SEEK_SET : constant int;
22838   -- Used to indicate origin for fseek call
22839   function stdin return FILEs;
22840   function stdout return FILEs;
22841   function stderr return FILEs;
22842   -- Streams associated with standard files
22843   --------------------------
22844   -- Standard C functions --
22845   --------------------------
22846   -- The functions selected below are ones that are
22847   -- available in UNIX (but not necessarily in ANSI C).
22848   -- These are very thin interfaces
22849   -- which copy exactly the C headers.  For more
22850   -- documentation on these functions, see the Microsoft C
22851   -- "Run-Time Library Reference" (Microsoft Press, 1990,
22852   -- ISBN 1-55615-225-6), which includes useful information
22853   -- on system compatibility.
22854   procedure clearerr (stream : FILEs);
22855   function fclose (stream : FILEs) return int;
22856   function fdopen (handle : int; mode : chars) return FILEs;
22857   function feof (stream : FILEs) return int;
22858   function ferror (stream : FILEs) return int;
22859   function fflush (stream : FILEs) return int;
22860   function fgetc (stream : FILEs) return int;
22861   function fgets (strng : chars; n : int; stream : FILEs)
22862       return chars;
22863   function fileno (stream : FILEs) return int;
22864   function fopen (filename : chars; Mode : chars)
22865       return FILEs;
22866   -- Note: to maintain target independence, use
22867   -- text_translation_required, a boolean variable defined in
22868   -- a-sysdep.c to deal with the target dependent text
22869   -- translation requirement.  If this variable is set,
22870   -- then  b/t should be appended to the standard mode
22871   -- argument to set the text translation mode off or on
22872   -- as required.
22873   function fputc (C : int; stream : FILEs) return int;
22874   function fputs (Strng : chars; Stream : FILEs) return int;
22875   function fread
22876      (buffer : voids;
22877       size : size_t;
22878       count : size_t;
22879       stream : FILEs)
22880       return size_t;
22881   function freopen
22882      (filename : chars;
22883       mode : chars;
22884       stream : FILEs)
22885       return FILEs;
22886   function fseek
22887      (stream : FILEs;
22888       offset : long;
22889       origin : int)
22890       return int;
22891   function ftell (stream : FILEs) return long;
22892   function fwrite
22893      (buffer : voids;
22894       size : size_t;
22895       count : size_t;
22896       stream : FILEs)
22897       return size_t;
22898   function isatty (handle : int) return int;
22899   procedure mktemp (template : chars);
22900   -- The return value (which is just a pointer to template)
22901   -- is discarded
22902   procedure rewind (stream : FILEs);
22903   function rmtmp return int;
22904   function setvbuf
22905      (stream : FILEs;
22906       buffer : chars;
22907       mode : int;
22908       size : size_t)
22909       return int;
22911   function tmpfile return FILEs;
22912   function ungetc (c : int; stream : FILEs) return int;
22913   function unlink (filename : chars) return int;
22914   ---------------------
22915   -- Extra functions --
22916   ---------------------
22917   -- These functions supply slightly thicker bindings than
22918   -- those above.  They are derived from functions in the
22919   -- C Run-Time Library, but may do a bit more work than
22920   -- just directly calling one of the Library functions.
22921   function is_regular_file (handle : int) return int;
22922   -- Tests if given handle is for a regular file (result 1)
22923   -- or for a non-regular file (pipe or device, result 0).
22924   ---------------------------------
22925   -- Control of Text/Binary Mode --
22926   ---------------------------------
22927   -- If text_translation_required is true, then the following
22928   -- functions may be used to dynamically switch a file from
22929   -- binary to text mode or vice versa.  These functions have
22930   -- no effect if text_translation_required is false (i.e., in
22931   -- normal UNIX mode).  Use fileno to get a stream handle.
22932   procedure set_binary_mode (handle : int);
22933   procedure set_text_mode (handle : int);
22934   ----------------------------
22935   -- Full Path Name support --
22936   ----------------------------
22937   procedure full_name (nam : chars; buffer : chars);
22938   -- Given a NUL terminated string representing a file
22939   -- name, returns in buffer a NUL terminated string
22940   -- representing the full path name for the file name.
22941   -- On systems where it is relevant the   drive is also
22942   -- part of the full path name.  It is the responsibility
22943   -- of the caller to pass an actual parameter for buffer
22944   -- that is big enough for any full path name.  Use
22945   -- max_path_len given below as the size of buffer.
22946   max_path_len : integer;
22947   -- Maximum length of an allowable full path name on the
22948   -- system, including a terminating NUL character.
22949 end Interfaces.C_Streams;
22950 @end example
22952 @node Interfacing to C Streams,,Operations on C Streams,The Implementation of Standard I/O
22953 @anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2df}@anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2e0}
22954 @section Interfacing to C Streams
22957 The packages in this section permit interfacing Ada files to C Stream
22958 operations.
22960 @example
22961 with Interfaces.C_Streams;
22962 package Ada.Sequential_IO.C_Streams is
22963    function C_Stream (F : File_Type)
22964       return Interfaces.C_Streams.FILEs;
22965    procedure Open
22966      (File : in out File_Type;
22967       Mode : in File_Mode;
22968       C_Stream : in Interfaces.C_Streams.FILEs;
22969       Form : in String := "");
22970 end Ada.Sequential_IO.C_Streams;
22972  with Interfaces.C_Streams;
22973  package Ada.Direct_IO.C_Streams is
22974     function C_Stream (F : File_Type)
22975        return Interfaces.C_Streams.FILEs;
22976     procedure Open
22977       (File : in out File_Type;
22978        Mode : in File_Mode;
22979        C_Stream : in Interfaces.C_Streams.FILEs;
22980        Form : in String := "");
22981  end Ada.Direct_IO.C_Streams;
22983  with Interfaces.C_Streams;
22984  package Ada.Text_IO.C_Streams is
22985     function C_Stream (F : File_Type)
22986        return Interfaces.C_Streams.FILEs;
22987     procedure Open
22988       (File : in out File_Type;
22989        Mode : in File_Mode;
22990        C_Stream : in Interfaces.C_Streams.FILEs;
22991        Form : in String := "");
22992  end Ada.Text_IO.C_Streams;
22994  with Interfaces.C_Streams;
22995  package Ada.Wide_Text_IO.C_Streams is
22996     function C_Stream (F : File_Type)
22997        return Interfaces.C_Streams.FILEs;
22998     procedure Open
22999       (File : in out File_Type;
23000        Mode : in File_Mode;
23001        C_Stream : in Interfaces.C_Streams.FILEs;
23002        Form : in String := "");
23003 end Ada.Wide_Text_IO.C_Streams;
23005  with Interfaces.C_Streams;
23006  package Ada.Wide_Wide_Text_IO.C_Streams is
23007     function C_Stream (F : File_Type)
23008        return Interfaces.C_Streams.FILEs;
23009     procedure Open
23010       (File : in out File_Type;
23011        Mode : in File_Mode;
23012        C_Stream : in Interfaces.C_Streams.FILEs;
23013        Form : in String := "");
23014 end Ada.Wide_Wide_Text_IO.C_Streams;
23016 with Interfaces.C_Streams;
23017 package Ada.Stream_IO.C_Streams is
23018    function C_Stream (F : File_Type)
23019       return Interfaces.C_Streams.FILEs;
23020    procedure Open
23021      (File : in out File_Type;
23022       Mode : in File_Mode;
23023       C_Stream : in Interfaces.C_Streams.FILEs;
23024       Form : in String := "");
23025 end Ada.Stream_IO.C_Streams;
23026 @end example
23028 In each of these six packages, the @code{C_Stream} function obtains the
23029 @code{FILE} pointer from a currently opened Ada file.  It is then
23030 possible to use the @code{Interfaces.C_Streams} package to operate on
23031 this stream, or the stream can be passed to a C program which can
23032 operate on it directly.  Of course the program is responsible for
23033 ensuring that only appropriate sequences of operations are executed.
23035 One particular use of relevance to an Ada program is that the
23036 @code{setvbuf} function can be used to control the buffering of the
23037 stream used by an Ada file.  In the absence of such a call the standard
23038 default buffering is used.
23040 The @code{Open} procedures in these packages open a file giving an
23041 existing C Stream instead of a file name.  Typically this stream is
23042 imported from a C program, allowing an Ada file to operate on an
23043 existing C file.
23045 @node The GNAT Library,Interfacing to Other Languages,The Implementation of Standard I/O,Top
23046 @anchor{gnat_rm/the_gnat_library doc}@anchor{2e1}@anchor{gnat_rm/the_gnat_library id1}@anchor{2e2}@anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10}
23047 @chapter The GNAT Library
23050 The GNAT library contains a number of general and special purpose packages.
23051 It represents functionality that the GNAT developers have found useful, and
23052 which is made available to GNAT users.  The packages described here are fully
23053 supported, and upwards compatibility will be maintained in future releases,
23054 so you can use these facilities with the confidence that the same functionality
23055 will be available in future releases.
23057 The chapter here simply gives a brief summary of the facilities available.
23058 The full documentation is found in the spec file for the package.  The full
23059 sources of these library packages, including both spec and body, are provided
23060 with all GNAT releases.  For example, to find out the full specifications of
23061 the SPITBOL pattern matching capability, including a full tutorial and
23062 extensive examples, look in the @code{g-spipat.ads} file in the library.
23064 For each entry here, the package name (as it would appear in a @code{with}
23065 clause) is given, followed by the name of the corresponding spec file in
23066 parentheses.  The packages are children in four hierarchies, @code{Ada},
23067 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
23068 GNAT-specific hierarchy.
23070 Note that an application program should only use packages in one of these
23071 four hierarchies if the package is defined in the Ada Reference Manual,
23072 or is listed in this section of the GNAT Programmers Reference Manual.
23073 All other units should be considered internal implementation units and
23074 should not be directly @code{with}ed by application code.  The use of
23075 a @code{with} clause that references one of these internal implementation
23076 units makes an application potentially dependent on changes in versions
23077 of GNAT, and will generate a warning message.
23079 @menu
23080 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads. 
23081 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads. 
23082 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads): Ada Characters Wide_Latin_9 a-cwila9 ads. 
23083 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads. 
23084 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads. 
23085 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads. 
23086 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads. 
23087 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads. 
23088 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads. 
23089 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads. 
23090 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads. 
23091 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads. 
23092 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads. 
23093 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads. 
23094 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads. 
23095 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads. 
23096 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads. 
23097 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads. 
23098 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads. 
23099 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads. 
23100 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads. 
23101 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads. 
23102 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads. 
23103 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads. 
23104 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads. 
23105 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads. 
23106 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads. 
23107 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads. 
23108 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads. 
23109 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads. 
23110 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads. 
23111 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads. 
23112 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads. 
23113 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads. 
23114 * GNAT.Binary_Search (g-binsea.ads): GNAT Binary_Search g-binsea ads. 
23115 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads. 
23116 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads. 
23117 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads. 
23118 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads. 
23119 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads. 
23120 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads. 
23121 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads. 
23122 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads. 
23123 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads. 
23124 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads. 
23125 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads. 
23126 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads. 
23127 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads. 
23128 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads. 
23129 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads. 
23130 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads. 
23131 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads. 
23132 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads. 
23133 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads. 
23134 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads. 
23135 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads. 
23136 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads. 
23137 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads. 
23138 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads. 
23139 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads. 
23140 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads. 
23141 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads. 
23142 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads. 
23143 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads. 
23144 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads. 
23145 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads. 
23146 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads. 
23147 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads. 
23148 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads. 
23149 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads. 
23150 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads. 
23151 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads. 
23152 * GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads): GNAT Generic_Fast_Math_Functions g-gfmafu ads. 
23153 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads. 
23154 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads. 
23155 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads. 
23156 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads. 
23157 * GNAT.IO (g-io.ads): GNAT IO g-io ads. 
23158 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads. 
23159 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads. 
23160 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads. 
23161 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads. 
23162 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads. 
23163 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads. 
23164 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads. 
23165 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads. 
23166 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads. 
23167 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads. 
23168 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads. 
23169 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads. 
23170 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads. 
23171 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads. 
23172 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads. 
23173 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads. 
23174 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads. 
23175 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads. 
23176 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads. 
23177 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads. 
23178 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads. 
23179 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads. 
23180 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads. 
23181 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads. 
23182 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads. 
23183 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads. 
23184 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads. 
23185 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads. 
23186 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads. 
23187 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads. 
23188 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads. 
23189 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads. 
23190 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads. 
23191 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads. 
23192 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads. 
23193 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads. 
23194 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads. 
23195 * GNAT.Table (g-table.ads): GNAT Table g-table ads. 
23196 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads. 
23197 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads. 
23198 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads. 
23199 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads. 
23200 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads. 
23201 * GNAT.UTF_32 (g-utf_32.ads): GNAT UTF_32 g-utf_32 ads. 
23202 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads): GNAT UTF_32_Spelling_Checker g-u3spch ads. 
23203 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads. 
23204 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads. 
23205 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads. 
23206 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads. 
23207 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads. 
23208 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads. 
23209 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads. 
23210 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads. 
23211 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads. 
23212 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads. 
23213 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads. 
23214 * System.Assertions (s-assert.ads): System Assertions s-assert ads. 
23215 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads. 
23216 * System.Memory (s-memory.ads): System Memory s-memory ads. 
23217 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads. 
23218 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads. 
23219 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads. 
23220 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads. 
23221 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads. 
23222 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads. 
23223 * System.Rident (s-rident.ads): System Rident s-rident ads. 
23224 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads. 
23225 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads. 
23226 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads. 
23227 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads. 
23229 @end menu
23231 @node Ada Characters Latin_9 a-chlat9 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,,The GNAT Library
23232 @anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2e3}@anchor{gnat_rm/the_gnat_library id2}@anchor{2e4}
23233 @section @code{Ada.Characters.Latin_9} (@code{a-chlat9.ads})
23236 @geindex Ada.Characters.Latin_9 (a-chlat9.ads)
23238 @geindex Latin_9 constants for Character
23240 This child of @code{Ada.Characters}
23241 provides a set of definitions corresponding to those in the
23242 RM-defined package @code{Ada.Characters.Latin_1} but with the
23243 few modifications required for @code{Latin-9}.
23244 The provision of such a package
23245 is specifically authorized by the Ada Reference Manual
23246 (RM A.3.3(27)).
23248 @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
23249 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2e5}@anchor{gnat_rm/the_gnat_library id3}@anchor{2e6}
23250 @section @code{Ada.Characters.Wide_Latin_1} (@code{a-cwila1.ads})
23253 @geindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
23255 @geindex Latin_1 constants for Wide_Character
23257 This child of @code{Ada.Characters}
23258 provides a set of definitions corresponding to those in the
23259 RM-defined package @code{Ada.Characters.Latin_1} but with the
23260 types of the constants being @code{Wide_Character}
23261 instead of @code{Character}.  The provision of such a package
23262 is specifically authorized by the Ada Reference Manual
23263 (RM A.3.3(27)).
23265 @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
23266 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila9-ads}@anchor{2e7}@anchor{gnat_rm/the_gnat_library id4}@anchor{2e8}
23267 @section @code{Ada.Characters.Wide_Latin_9} (@code{a-cwila9.ads})
23270 @geindex Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
23272 @geindex Latin_9 constants for Wide_Character
23274 This child of @code{Ada.Characters}
23275 provides a set of definitions corresponding to those in the
23276 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23277 types of the constants being @code{Wide_Character}
23278 instead of @code{Character}.  The provision of such a package
23279 is specifically authorized by the Ada Reference Manual
23280 (RM A.3.3(27)).
23282 @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
23283 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2e9}@anchor{gnat_rm/the_gnat_library id5}@anchor{2ea}
23284 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@code{a-chzla1.ads})
23287 @geindex Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
23289 @geindex Latin_1 constants for Wide_Wide_Character
23291 This child of @code{Ada.Characters}
23292 provides a set of definitions corresponding to those in the
23293 RM-defined package @code{Ada.Characters.Latin_1} but with the
23294 types of the constants being @code{Wide_Wide_Character}
23295 instead of @code{Character}.  The provision of such a package
23296 is specifically authorized by the Ada Reference Manual
23297 (RM A.3.3(27)).
23299 @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
23300 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2eb}@anchor{gnat_rm/the_gnat_library id6}@anchor{2ec}
23301 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@code{a-chzla9.ads})
23304 @geindex Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
23306 @geindex Latin_9 constants for Wide_Wide_Character
23308 This child of @code{Ada.Characters}
23309 provides a set of definitions corresponding to those in the
23310 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23311 types of the constants being @code{Wide_Wide_Character}
23312 instead of @code{Character}.  The provision of such a package
23313 is specifically authorized by the Ada Reference Manual
23314 (RM A.3.3(27)).
23316 @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
23317 @anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2ed}@anchor{gnat_rm/the_gnat_library id7}@anchor{2ee}
23318 @section @code{Ada.Containers.Bounded_Holders} (@code{a-coboho.ads})
23321 @geindex Ada.Containers.Bounded_Holders (a-coboho.ads)
23323 @geindex Formal container for vectors
23325 This child of @code{Ada.Containers} defines a modified version of
23326 Indefinite_Holders that avoids heap allocation.
23328 @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
23329 @anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2ef}@anchor{gnat_rm/the_gnat_library id8}@anchor{2f0}
23330 @section @code{Ada.Command_Line.Environment} (@code{a-colien.ads})
23333 @geindex Ada.Command_Line.Environment (a-colien.ads)
23335 @geindex Environment entries
23337 This child of @code{Ada.Command_Line}
23338 provides a mechanism for obtaining environment values on systems
23339 where this concept makes sense.
23341 @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
23342 @anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f1}@anchor{gnat_rm/the_gnat_library id9}@anchor{2f2}
23343 @section @code{Ada.Command_Line.Remove} (@code{a-colire.ads})
23346 @geindex Ada.Command_Line.Remove (a-colire.ads)
23348 @geindex Removing command line arguments
23350 @geindex Command line
23351 @geindex argument removal
23353 This child of @code{Ada.Command_Line}
23354 provides a mechanism for logically removing
23355 arguments from the argument list.  Once removed, an argument is not visible
23356 to further calls to the subprograms in @code{Ada.Command_Line}. These calls
23357 will not see the removed argument.
23359 @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
23360 @anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2f3}@anchor{gnat_rm/the_gnat_library id10}@anchor{2f4}
23361 @section @code{Ada.Command_Line.Response_File} (@code{a-clrefi.ads})
23364 @geindex Ada.Command_Line.Response_File (a-clrefi.ads)
23366 @geindex Response file for command line
23368 @geindex Command line
23369 @geindex response file
23371 @geindex Command line
23372 @geindex handling long command lines
23374 This child of @code{Ada.Command_Line} provides a mechanism facilities for
23375 getting command line arguments from a text file, called a “response file”.
23376 Using a response file allow passing a set of arguments to an executable longer
23377 than the maximum allowed by the system on the command line.
23379 @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
23380 @anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2f5}@anchor{gnat_rm/the_gnat_library id11}@anchor{2f6}
23381 @section @code{Ada.Direct_IO.C_Streams} (@code{a-diocst.ads})
23384 @geindex Ada.Direct_IO.C_Streams (a-diocst.ads)
23386 @geindex C Streams
23387 @geindex Interfacing with Direct_IO
23389 This package provides subprograms that allow interfacing between
23390 C streams and @code{Direct_IO}.  The stream identifier can be
23391 extracted from a file opened on the Ada side, and an Ada file
23392 can be constructed from a stream opened on the C side.
23394 @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
23395 @anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2f7}@anchor{gnat_rm/the_gnat_library id12}@anchor{2f8}
23396 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@code{a-einuoc.ads})
23399 @geindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
23401 @geindex Null_Occurrence
23402 @geindex testing for
23404 This child subprogram provides a way of testing for the null
23405 exception occurrence (@code{Null_Occurrence}) without raising
23406 an exception.
23408 @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
23409 @anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{2f9}@anchor{gnat_rm/the_gnat_library id13}@anchor{2fa}
23410 @section @code{Ada.Exceptions.Last_Chance_Handler} (@code{a-elchha.ads})
23413 @geindex Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
23415 @geindex Null_Occurrence
23416 @geindex testing for
23418 This child subprogram is used for handling otherwise unhandled
23419 exceptions (hence the name last chance), and perform clean ups before
23420 terminating the program. Note that this subprogram never returns.
23422 @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
23423 @anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{2fb}@anchor{gnat_rm/the_gnat_library id14}@anchor{2fc}
23424 @section @code{Ada.Exceptions.Traceback} (@code{a-exctra.ads})
23427 @geindex Ada.Exceptions.Traceback (a-exctra.ads)
23429 @geindex Traceback for Exception Occurrence
23431 This child package provides the subprogram (@code{Tracebacks}) to
23432 give a traceback array of addresses based on an exception
23433 occurrence.
23435 @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
23436 @anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{2fd}@anchor{gnat_rm/the_gnat_library id15}@anchor{2fe}
23437 @section @code{Ada.Sequential_IO.C_Streams} (@code{a-siocst.ads})
23440 @geindex Ada.Sequential_IO.C_Streams (a-siocst.ads)
23442 @geindex C Streams
23443 @geindex Interfacing with Sequential_IO
23445 This package provides subprograms that allow interfacing between
23446 C streams and @code{Sequential_IO}.  The stream identifier can be
23447 extracted from a file opened on the Ada side, and an Ada file
23448 can be constructed from a stream opened on the C side.
23450 @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
23451 @anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{2ff}@anchor{gnat_rm/the_gnat_library id16}@anchor{300}
23452 @section @code{Ada.Streams.Stream_IO.C_Streams} (@code{a-ssicst.ads})
23455 @geindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
23457 @geindex C Streams
23458 @geindex Interfacing with Stream_IO
23460 This package provides subprograms that allow interfacing between
23461 C streams and @code{Stream_IO}.  The stream identifier can be
23462 extracted from a file opened on the Ada side, and an Ada file
23463 can be constructed from a stream opened on the C side.
23465 @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
23466 @anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{301}@anchor{gnat_rm/the_gnat_library id17}@anchor{302}
23467 @section @code{Ada.Strings.Unbounded.Text_IO} (@code{a-suteio.ads})
23470 @geindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
23472 @geindex Unbounded_String
23473 @geindex IO support
23475 @geindex Text_IO
23476 @geindex extensions for unbounded strings
23478 This package provides subprograms for Text_IO for unbounded
23479 strings, avoiding the necessity for an intermediate operation
23480 with ordinary strings.
23482 @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
23483 @anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{303}@anchor{gnat_rm/the_gnat_library id18}@anchor{304}
23484 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@code{a-swuwti.ads})
23487 @geindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
23489 @geindex Unbounded_Wide_String
23490 @geindex IO support
23492 @geindex Text_IO
23493 @geindex extensions for unbounded wide strings
23495 This package provides subprograms for Text_IO for unbounded
23496 wide strings, avoiding the necessity for an intermediate operation
23497 with ordinary wide strings.
23499 @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
23500 @anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{305}@anchor{gnat_rm/the_gnat_library id19}@anchor{306}
23501 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@code{a-szuzti.ads})
23504 @geindex Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
23506 @geindex Unbounded_Wide_Wide_String
23507 @geindex IO support
23509 @geindex Text_IO
23510 @geindex extensions for unbounded wide wide strings
23512 This package provides subprograms for Text_IO for unbounded
23513 wide wide strings, avoiding the necessity for an intermediate operation
23514 with ordinary wide wide strings.
23516 @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
23517 @anchor{gnat_rm/the_gnat_library ada-task-initialization-a-tasini-ads}@anchor{307}@anchor{gnat_rm/the_gnat_library id20}@anchor{308}
23518 @section @code{Ada.Task_Initialization} (@code{a-tasini.ads})
23521 @geindex Ada.Task_Initialization (a-tasini.ads)
23523 This package provides a way to set a global initialization handler that
23524 is automatically invoked whenever a task is activated. Handlers are
23525 parameterless procedures. Note that such a handler is only invoked for
23526 those tasks activated after the handler is set.
23528 @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
23529 @anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{309}@anchor{gnat_rm/the_gnat_library id21}@anchor{30a}
23530 @section @code{Ada.Text_IO.C_Streams} (@code{a-tiocst.ads})
23533 @geindex Ada.Text_IO.C_Streams (a-tiocst.ads)
23535 @geindex C Streams
23536 @geindex Interfacing with `@w{`}Text_IO`@w{`}
23538 This package provides subprograms that allow interfacing between
23539 C streams and @code{Text_IO}.  The stream identifier can be
23540 extracted from a file opened on the Ada side, and an Ada file
23541 can be constructed from a stream opened on the C side.
23543 @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
23544 @anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{30b}@anchor{gnat_rm/the_gnat_library id22}@anchor{30c}
23545 @section @code{Ada.Text_IO.Reset_Standard_Files} (@code{a-tirsfi.ads})
23548 @geindex Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
23550 @geindex Text_IO resetting standard files
23552 This procedure is used to reset the status of the standard files used
23553 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
23554 embedded application) where the status of the files may change during
23555 execution (for example a standard input file may be redefined to be
23556 interactive).
23558 @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
23559 @anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{30d}@anchor{gnat_rm/the_gnat_library id23}@anchor{30e}
23560 @section @code{Ada.Wide_Characters.Unicode} (@code{a-wichun.ads})
23563 @geindex Ada.Wide_Characters.Unicode (a-wichun.ads)
23565 @geindex Unicode categorization
23566 @geindex Wide_Character
23568 This package provides subprograms that allow categorization of
23569 Wide_Character values according to Unicode categories.
23571 @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
23572 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{30f}@anchor{gnat_rm/the_gnat_library id24}@anchor{310}
23573 @section @code{Ada.Wide_Text_IO.C_Streams} (@code{a-wtcstr.ads})
23576 @geindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
23578 @geindex C Streams
23579 @geindex Interfacing with `@w{`}Wide_Text_IO`@w{`}
23581 This package provides subprograms that allow interfacing between
23582 C streams and @code{Wide_Text_IO}.  The stream identifier can be
23583 extracted from a file opened on the Ada side, and an Ada file
23584 can be constructed from a stream opened on the C side.
23586 @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
23587 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{311}@anchor{gnat_rm/the_gnat_library id25}@anchor{312}
23588 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@code{a-wrstfi.ads})
23591 @geindex Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
23593 @geindex Wide_Text_IO resetting standard files
23595 This procedure is used to reset the status of the standard files used
23596 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
23597 embedded application) where the status of the files may change during
23598 execution (for example a standard input file may be redefined to be
23599 interactive).
23601 @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
23602 @anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{313}@anchor{gnat_rm/the_gnat_library id26}@anchor{314}
23603 @section @code{Ada.Wide_Wide_Characters.Unicode} (@code{a-zchuni.ads})
23606 @geindex Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
23608 @geindex Unicode categorization
23609 @geindex Wide_Wide_Character
23611 This package provides subprograms that allow categorization of
23612 Wide_Wide_Character values according to Unicode categories.
23614 @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
23615 @anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{315}@anchor{gnat_rm/the_gnat_library id27}@anchor{316}
23616 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@code{a-ztcstr.ads})
23619 @geindex Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
23621 @geindex C Streams
23622 @geindex Interfacing with `@w{`}Wide_Wide_Text_IO`@w{`}
23624 This package provides subprograms that allow interfacing between
23625 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
23626 extracted from a file opened on the Ada side, and an Ada file
23627 can be constructed from a stream opened on the C side.
23629 @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
23630 @anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{317}@anchor{gnat_rm/the_gnat_library id28}@anchor{318}
23631 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@code{a-zrstfi.ads})
23634 @geindex Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
23636 @geindex Wide_Wide_Text_IO resetting standard files
23638 This procedure is used to reset the status of the standard files used
23639 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
23640 restart in an embedded application) where the status of the files may
23641 change during execution (for example a standard input file may be
23642 redefined to be interactive).
23644 @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
23645 @anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{319}@anchor{gnat_rm/the_gnat_library id29}@anchor{31a}
23646 @section @code{GNAT.Altivec} (@code{g-altive.ads})
23649 @geindex GNAT.Altivec (g-altive.ads)
23651 @geindex AltiVec
23653 This is the root package of the GNAT AltiVec binding. It provides
23654 definitions of constants and types common to all the versions of the
23655 binding.
23657 @node GNAT Altivec Conversions g-altcon ads,GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec g-altive ads,The GNAT Library
23658 @anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{31b}@anchor{gnat_rm/the_gnat_library id30}@anchor{31c}
23659 @section @code{GNAT.Altivec.Conversions} (@code{g-altcon.ads})
23662 @geindex GNAT.Altivec.Conversions (g-altcon.ads)
23664 @geindex AltiVec
23666 This package provides the Vector/View conversion routines.
23668 @node GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Conversions g-altcon ads,The GNAT Library
23669 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{31d}@anchor{gnat_rm/the_gnat_library id31}@anchor{31e}
23670 @section @code{GNAT.Altivec.Vector_Operations} (@code{g-alveop.ads})
23673 @geindex GNAT.Altivec.Vector_Operations (g-alveop.ads)
23675 @geindex AltiVec
23677 This package exposes the Ada interface to the AltiVec operations on
23678 vector objects. A soft emulation is included by default in the GNAT
23679 library. The hard binding is provided as a separate package. This unit
23680 is common to both bindings.
23682 @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
23683 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{31f}@anchor{gnat_rm/the_gnat_library id32}@anchor{320}
23684 @section @code{GNAT.Altivec.Vector_Types} (@code{g-alvety.ads})
23687 @geindex GNAT.Altivec.Vector_Types (g-alvety.ads)
23689 @geindex AltiVec
23691 This package exposes the various vector types part of the Ada binding
23692 to AltiVec facilities.
23694 @node GNAT Altivec Vector_Views g-alvevi ads,GNAT Array_Split g-arrspl ads,GNAT Altivec Vector_Types g-alvety ads,The GNAT Library
23695 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{321}@anchor{gnat_rm/the_gnat_library id33}@anchor{322}
23696 @section @code{GNAT.Altivec.Vector_Views} (@code{g-alvevi.ads})
23699 @geindex GNAT.Altivec.Vector_Views (g-alvevi.ads)
23701 @geindex AltiVec
23703 This package provides public ‘View’ data types from/to which private
23704 vector representations can be converted via
23705 GNAT.Altivec.Conversions. This allows convenient access to individual
23706 vector elements and provides a simple way to initialize vector
23707 objects.
23709 @node GNAT Array_Split g-arrspl ads,GNAT AWK g-awk ads,GNAT Altivec Vector_Views g-alvevi ads,The GNAT Library
23710 @anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{323}@anchor{gnat_rm/the_gnat_library id34}@anchor{324}
23711 @section @code{GNAT.Array_Split} (@code{g-arrspl.ads})
23714 @geindex GNAT.Array_Split (g-arrspl.ads)
23716 @geindex Array splitter
23718 Useful array-manipulation routines: given a set of separators, split
23719 an array wherever the separators appear, and provide direct access
23720 to the resulting slices.
23722 @node GNAT AWK g-awk ads,GNAT Binary_Search g-binsea ads,GNAT Array_Split g-arrspl ads,The GNAT Library
23723 @anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{325}@anchor{gnat_rm/the_gnat_library id35}@anchor{326}
23724 @section @code{GNAT.AWK} (@code{g-awk.ads})
23727 @geindex GNAT.AWK (g-awk.ads)
23729 @geindex Parsing
23731 @geindex AWK
23733 Provides AWK-like parsing functions, with an easy interface for parsing one
23734 or more files containing formatted data.  The file is viewed as a database
23735 where each record is a line and a field is a data element in this line.
23737 @node GNAT Binary_Search g-binsea ads,GNAT Bind_Environment g-binenv ads,GNAT AWK g-awk ads,The GNAT Library
23738 @anchor{gnat_rm/the_gnat_library gnat-binary-search-g-binsea-ads}@anchor{327}@anchor{gnat_rm/the_gnat_library id36}@anchor{328}
23739 @section @code{GNAT.Binary_Search} (@code{g-binsea.ads})
23742 @geindex GNAT.Binary_Search (g-binsea.ads)
23744 @geindex Binary search
23746 Allow binary search of a sorted array (or of an array-like container;
23747 the generic does not reference the array directly).
23749 @node GNAT Bind_Environment g-binenv ads,GNAT Branch_Prediction g-brapre ads,GNAT Binary_Search g-binsea ads,The GNAT Library
23750 @anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{329}@anchor{gnat_rm/the_gnat_library id37}@anchor{32a}
23751 @section @code{GNAT.Bind_Environment} (@code{g-binenv.ads})
23754 @geindex GNAT.Bind_Environment (g-binenv.ads)
23756 @geindex Bind environment
23758 Provides access to key=value associations captured at bind time.
23759 These associations can be specified using the @code{-V} binder command
23760 line switch.
23762 @node GNAT Branch_Prediction g-brapre ads,GNAT Bounded_Buffers g-boubuf ads,GNAT Bind_Environment g-binenv ads,The GNAT Library
23763 @anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{32b}@anchor{gnat_rm/the_gnat_library id38}@anchor{32c}
23764 @section @code{GNAT.Branch_Prediction} (@code{g-brapre.ads})
23767 @geindex GNAT.Branch_Prediction (g-brapre.ads)
23769 @geindex Branch Prediction
23771 Provides routines giving hints to the branch predictor of the code generator.
23773 @node GNAT Bounded_Buffers g-boubuf ads,GNAT Bounded_Mailboxes g-boumai ads,GNAT Branch_Prediction g-brapre ads,The GNAT Library
23774 @anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{32d}@anchor{gnat_rm/the_gnat_library id39}@anchor{32e}
23775 @section @code{GNAT.Bounded_Buffers} (@code{g-boubuf.ads})
23778 @geindex GNAT.Bounded_Buffers (g-boubuf.ads)
23780 @geindex Parsing
23782 @geindex Bounded Buffers
23784 Provides a concurrent generic bounded buffer abstraction.  Instances are
23785 useful directly or as parts of the implementations of other abstractions,
23786 such as mailboxes.
23788 @node GNAT Bounded_Mailboxes g-boumai ads,GNAT Bubble_Sort g-bubsor ads,GNAT Bounded_Buffers g-boubuf ads,The GNAT Library
23789 @anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{32f}@anchor{gnat_rm/the_gnat_library id40}@anchor{330}
23790 @section @code{GNAT.Bounded_Mailboxes} (@code{g-boumai.ads})
23793 @geindex GNAT.Bounded_Mailboxes (g-boumai.ads)
23795 @geindex Parsing
23797 @geindex Mailboxes
23799 Provides a thread-safe asynchronous intertask mailbox communication facility.
23801 @node GNAT Bubble_Sort g-bubsor ads,GNAT Bubble_Sort_A g-busora ads,GNAT Bounded_Mailboxes g-boumai ads,The GNAT Library
23802 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{331}@anchor{gnat_rm/the_gnat_library id41}@anchor{332}
23803 @section @code{GNAT.Bubble_Sort} (@code{g-bubsor.ads})
23806 @geindex GNAT.Bubble_Sort (g-bubsor.ads)
23808 @geindex Sorting
23810 @geindex Bubble sort
23812 Provides a general implementation of bubble sort usable for sorting arbitrary
23813 data items.  Exchange and comparison procedures are provided by passing
23814 access-to-procedure values.
23816 @node GNAT Bubble_Sort_A g-busora ads,GNAT Bubble_Sort_G g-busorg ads,GNAT Bubble_Sort g-bubsor ads,The GNAT Library
23817 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{333}@anchor{gnat_rm/the_gnat_library id42}@anchor{334}
23818 @section @code{GNAT.Bubble_Sort_A} (@code{g-busora.ads})
23821 @geindex GNAT.Bubble_Sort_A (g-busora.ads)
23823 @geindex Sorting
23825 @geindex Bubble sort
23827 Provides a general implementation of bubble sort usable for sorting arbitrary
23828 data items.  Move and comparison procedures are provided by passing
23829 access-to-procedure values. This is an older version, retained for
23830 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
23832 @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
23833 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{335}@anchor{gnat_rm/the_gnat_library id43}@anchor{336}
23834 @section @code{GNAT.Bubble_Sort_G} (@code{g-busorg.ads})
23837 @geindex GNAT.Bubble_Sort_G (g-busorg.ads)
23839 @geindex Sorting
23841 @geindex Bubble sort
23843 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
23844 are provided as generic parameters, this improves efficiency, especially
23845 if the procedures can be inlined, at the expense of duplicating code for
23846 multiple instantiations.
23848 @node GNAT Byte_Order_Mark g-byorma ads,GNAT Byte_Swapping g-bytswa ads,GNAT Bubble_Sort_G g-busorg ads,The GNAT Library
23849 @anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{337}@anchor{gnat_rm/the_gnat_library id44}@anchor{338}
23850 @section @code{GNAT.Byte_Order_Mark} (@code{g-byorma.ads})
23853 @geindex GNAT.Byte_Order_Mark (g-byorma.ads)
23855 @geindex UTF-8 representation
23857 @geindex Wide characte representations
23859 Provides a routine which given a string, reads the start of the string to
23860 see whether it is one of the standard byte order marks (BOM’s) which signal
23861 the encoding of the string. The routine includes detection of special XML
23862 sequences for various UCS input formats.
23864 @node GNAT Byte_Swapping g-bytswa ads,GNAT Calendar g-calend ads,GNAT Byte_Order_Mark g-byorma ads,The GNAT Library
23865 @anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{339}@anchor{gnat_rm/the_gnat_library id45}@anchor{33a}
23866 @section @code{GNAT.Byte_Swapping} (@code{g-bytswa.ads})
23869 @geindex GNAT.Byte_Swapping (g-bytswa.ads)
23871 @geindex Byte swapping
23873 @geindex Endianness
23875 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
23876 Machine-specific implementations are available in some cases.
23878 @node GNAT Calendar g-calend ads,GNAT Calendar Time_IO g-catiio ads,GNAT Byte_Swapping g-bytswa ads,The GNAT Library
23879 @anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{33b}@anchor{gnat_rm/the_gnat_library id46}@anchor{33c}
23880 @section @code{GNAT.Calendar} (@code{g-calend.ads})
23883 @geindex GNAT.Calendar (g-calend.ads)
23885 @geindex Calendar
23887 Extends the facilities provided by @code{Ada.Calendar} to include handling
23888 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
23889 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
23890 C @code{timeval} format.
23892 @node GNAT Calendar Time_IO g-catiio ads,GNAT CRC32 g-crc32 ads,GNAT Calendar g-calend ads,The GNAT Library
23893 @anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{33d}@anchor{gnat_rm/the_gnat_library id47}@anchor{33e}
23894 @section @code{GNAT.Calendar.Time_IO} (@code{g-catiio.ads})
23897 @geindex Calendar
23899 @geindex Time
23901 @geindex GNAT.Calendar.Time_IO (g-catiio.ads)
23903 @node GNAT CRC32 g-crc32 ads,GNAT Case_Util g-casuti ads,GNAT Calendar Time_IO g-catiio ads,The GNAT Library
23904 @anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{33f}@anchor{gnat_rm/the_gnat_library id48}@anchor{340}
23905 @section @code{GNAT.CRC32} (@code{g-crc32.ads})
23908 @geindex GNAT.CRC32 (g-crc32.ads)
23910 @geindex CRC32
23912 @geindex Cyclic Redundancy Check
23914 This package implements the CRC-32 algorithm.  For a full description
23915 of this algorithm see
23916 `Computation of Cyclic Redundancy Checks via Table Look-Up',
23917 @cite{Communications of the ACM}, Vol. 31 No. 8, pp. 1008-1013,
23918 Aug. 1988.  Sarwate, D.V.
23920 @node GNAT Case_Util g-casuti ads,GNAT CGI g-cgi ads,GNAT CRC32 g-crc32 ads,The GNAT Library
23921 @anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{341}@anchor{gnat_rm/the_gnat_library id49}@anchor{342}
23922 @section @code{GNAT.Case_Util} (@code{g-casuti.ads})
23925 @geindex GNAT.Case_Util (g-casuti.ads)
23927 @geindex Casing utilities
23929 @geindex Character handling (`@w{`}GNAT.Case_Util`@w{`})
23931 A set of simple routines for handling upper and lower casing of strings
23932 without the overhead of the full casing tables
23933 in @code{Ada.Characters.Handling}.
23935 @node GNAT CGI g-cgi ads,GNAT CGI Cookie g-cgicoo ads,GNAT Case_Util g-casuti ads,The GNAT Library
23936 @anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{343}@anchor{gnat_rm/the_gnat_library id50}@anchor{344}
23937 @section @code{GNAT.CGI} (@code{g-cgi.ads})
23940 @geindex GNAT.CGI (g-cgi.ads)
23942 @geindex CGI (Common Gateway Interface)
23944 This is a package for interfacing a GNAT program with a Web server via the
23945 Common Gateway Interface (CGI).  Basically this package parses the CGI
23946 parameters, which are a set of key/value pairs sent by the Web server.  It
23947 builds a table whose index is the key and provides some services to deal
23948 with this table.
23950 @node GNAT CGI Cookie g-cgicoo ads,GNAT CGI Debug g-cgideb ads,GNAT CGI g-cgi ads,The GNAT Library
23951 @anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{345}@anchor{gnat_rm/the_gnat_library id51}@anchor{346}
23952 @section @code{GNAT.CGI.Cookie} (@code{g-cgicoo.ads})
23955 @geindex GNAT.CGI.Cookie (g-cgicoo.ads)
23957 @geindex CGI (Common Gateway Interface) cookie support
23959 @geindex Cookie support in CGI
23961 This is a package to interface a GNAT program with a Web server via the
23962 Common Gateway Interface (CGI).  It exports services to deal with Web
23963 cookies (piece of information kept in the Web client software).
23965 @node GNAT CGI Debug g-cgideb ads,GNAT Command_Line g-comlin ads,GNAT CGI Cookie g-cgicoo ads,The GNAT Library
23966 @anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{347}@anchor{gnat_rm/the_gnat_library id52}@anchor{348}
23967 @section @code{GNAT.CGI.Debug} (@code{g-cgideb.ads})
23970 @geindex GNAT.CGI.Debug (g-cgideb.ads)
23972 @geindex CGI (Common Gateway Interface) debugging
23974 This is a package to help debugging CGI (Common Gateway Interface)
23975 programs written in Ada.
23977 @node GNAT Command_Line g-comlin ads,GNAT Compiler_Version g-comver ads,GNAT CGI Debug g-cgideb ads,The GNAT Library
23978 @anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{349}@anchor{gnat_rm/the_gnat_library id53}@anchor{34a}
23979 @section @code{GNAT.Command_Line} (@code{g-comlin.ads})
23982 @geindex GNAT.Command_Line (g-comlin.ads)
23984 @geindex Command line
23986 Provides a high level interface to @code{Ada.Command_Line} facilities,
23987 including the ability to scan for named switches with optional parameters
23988 and expand file names using wildcard notations.
23990 @node GNAT Compiler_Version g-comver ads,GNAT Ctrl_C g-ctrl_c ads,GNAT Command_Line g-comlin ads,The GNAT Library
23991 @anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{34b}@anchor{gnat_rm/the_gnat_library id54}@anchor{34c}
23992 @section @code{GNAT.Compiler_Version} (@code{g-comver.ads})
23995 @geindex GNAT.Compiler_Version (g-comver.ads)
23997 @geindex Compiler Version
23999 @geindex Version
24000 @geindex of compiler
24002 Provides a routine for obtaining the version of the compiler used to
24003 compile the program. More accurately this is the version of the binder
24004 used to bind the program (this will normally be the same as the version
24005 of the compiler if a consistent tool set is used to compile all units
24006 of a partition).
24008 @node GNAT Ctrl_C g-ctrl_c ads,GNAT Current_Exception g-curexc ads,GNAT Compiler_Version g-comver ads,The GNAT Library
24009 @anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{34d}@anchor{gnat_rm/the_gnat_library id55}@anchor{34e}
24010 @section @code{GNAT.Ctrl_C} (@code{g-ctrl_c.ads})
24013 @geindex GNAT.Ctrl_C (g-ctrl_c.ads)
24015 @geindex Interrupt
24017 Provides a simple interface to handle Ctrl-C keyboard events.
24019 @node GNAT Current_Exception g-curexc ads,GNAT Debug_Pools g-debpoo ads,GNAT Ctrl_C g-ctrl_c ads,The GNAT Library
24020 @anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{34f}@anchor{gnat_rm/the_gnat_library id56}@anchor{350}
24021 @section @code{GNAT.Current_Exception} (@code{g-curexc.ads})
24024 @geindex GNAT.Current_Exception (g-curexc.ads)
24026 @geindex Current exception
24028 @geindex Exception retrieval
24030 Provides access to information on the current exception that has been raised
24031 without the need for using the Ada 95 / Ada 2005 exception choice parameter
24032 specification syntax.
24033 This is particularly useful in simulating typical facilities for
24034 obtaining information about exceptions provided by Ada 83 compilers.
24036 @node GNAT Debug_Pools g-debpoo ads,GNAT Debug_Utilities g-debuti ads,GNAT Current_Exception g-curexc ads,The GNAT Library
24037 @anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{351}@anchor{gnat_rm/the_gnat_library id57}@anchor{352}
24038 @section @code{GNAT.Debug_Pools} (@code{g-debpoo.ads})
24041 @geindex GNAT.Debug_Pools (g-debpoo.ads)
24043 @geindex Debugging
24045 @geindex Debug pools
24047 @geindex Memory corruption debugging
24049 Provides a debugging storage pools that helps tracking memory corruption
24050 problems.
24051 See @code{The GNAT Debug_Pool Facility} section in the @cite{GNAT User’s Guide}.
24053 @node GNAT Debug_Utilities g-debuti ads,GNAT Decode_String g-decstr ads,GNAT Debug_Pools g-debpoo ads,The GNAT Library
24054 @anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{353}@anchor{gnat_rm/the_gnat_library id58}@anchor{354}
24055 @section @code{GNAT.Debug_Utilities} (@code{g-debuti.ads})
24058 @geindex GNAT.Debug_Utilities (g-debuti.ads)
24060 @geindex Debugging
24062 Provides a few useful utilities for debugging purposes, including conversion
24063 to and from string images of address values. Supports both C and Ada formats
24064 for hexadecimal literals.
24066 @node GNAT Decode_String g-decstr ads,GNAT Decode_UTF8_String g-deutst ads,GNAT Debug_Utilities g-debuti ads,The GNAT Library
24067 @anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{355}@anchor{gnat_rm/the_gnat_library id59}@anchor{356}
24068 @section @code{GNAT.Decode_String} (@code{g-decstr.ads})
24071 @geindex GNAT.Decode_String (g-decstr.ads)
24073 @geindex Decoding strings
24075 @geindex String decoding
24077 @geindex Wide character encoding
24079 @geindex UTF-8
24081 @geindex Unicode
24083 A generic package providing routines for decoding wide character and wide wide
24084 character strings encoded as sequences of 8-bit characters using a specified
24085 encoding method. Includes validation routines, and also routines for stepping
24086 to next or previous encoded character in an encoded string.
24087 Useful in conjunction with Unicode character coding. Note there is a
24088 preinstantiation for UTF-8. See next entry.
24090 @node GNAT Decode_UTF8_String g-deutst ads,GNAT Directory_Operations g-dirope ads,GNAT Decode_String g-decstr ads,The GNAT Library
24091 @anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{357}@anchor{gnat_rm/the_gnat_library id60}@anchor{358}
24092 @section @code{GNAT.Decode_UTF8_String} (@code{g-deutst.ads})
24095 @geindex GNAT.Decode_UTF8_String (g-deutst.ads)
24097 @geindex Decoding strings
24099 @geindex Decoding UTF-8 strings
24101 @geindex UTF-8 string decoding
24103 @geindex Wide character decoding
24105 @geindex UTF-8
24107 @geindex Unicode
24109 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
24111 @node GNAT Directory_Operations g-dirope ads,GNAT Directory_Operations Iteration g-diopit ads,GNAT Decode_UTF8_String g-deutst ads,The GNAT Library
24112 @anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{359}@anchor{gnat_rm/the_gnat_library id61}@anchor{35a}
24113 @section @code{GNAT.Directory_Operations} (@code{g-dirope.ads})
24116 @geindex GNAT.Directory_Operations (g-dirope.ads)
24118 @geindex Directory operations
24120 Provides a set of routines for manipulating directories, including changing
24121 the current directory, making new directories, and scanning the files in a
24122 directory.
24124 @node GNAT Directory_Operations Iteration g-diopit ads,GNAT Dynamic_HTables g-dynhta ads,GNAT Directory_Operations g-dirope ads,The GNAT Library
24125 @anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{35b}@anchor{gnat_rm/the_gnat_library id62}@anchor{35c}
24126 @section @code{GNAT.Directory_Operations.Iteration} (@code{g-diopit.ads})
24129 @geindex GNAT.Directory_Operations.Iteration (g-diopit.ads)
24131 @geindex Directory operations iteration
24133 A child unit of GNAT.Directory_Operations providing additional operations
24134 for iterating through directories.
24136 @node GNAT Dynamic_HTables g-dynhta ads,GNAT Dynamic_Tables g-dyntab ads,GNAT Directory_Operations Iteration g-diopit ads,The GNAT Library
24137 @anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{35d}@anchor{gnat_rm/the_gnat_library id63}@anchor{35e}
24138 @section @code{GNAT.Dynamic_HTables} (@code{g-dynhta.ads})
24141 @geindex GNAT.Dynamic_HTables (g-dynhta.ads)
24143 @geindex Hash tables
24145 A generic implementation of hash tables that can be used to hash arbitrary
24146 data.  Provided in two forms, a simple form with built in hash functions,
24147 and a more complex form in which the hash function is supplied.
24149 This package provides a facility similar to that of @code{GNAT.HTable},
24150 except that this package declares a type that can be used to define
24151 dynamic instances of the hash table, while an instantiation of
24152 @code{GNAT.HTable} creates a single instance of the hash table.
24154 @node GNAT Dynamic_Tables g-dyntab ads,GNAT Encode_String g-encstr ads,GNAT Dynamic_HTables g-dynhta ads,The GNAT Library
24155 @anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{35f}@anchor{gnat_rm/the_gnat_library id64}@anchor{360}
24156 @section @code{GNAT.Dynamic_Tables} (@code{g-dyntab.ads})
24159 @geindex GNAT.Dynamic_Tables (g-dyntab.ads)
24161 @geindex Table implementation
24163 @geindex Arrays
24164 @geindex extendable
24166 A generic package providing a single dimension array abstraction where the
24167 length of the array can be dynamically modified.
24169 This package provides a facility similar to that of @code{GNAT.Table},
24170 except that this package declares a type that can be used to define
24171 dynamic instances of the table, while an instantiation of
24172 @code{GNAT.Table} creates a single instance of the table type.
24174 @node GNAT Encode_String g-encstr ads,GNAT Encode_UTF8_String g-enutst ads,GNAT Dynamic_Tables g-dyntab ads,The GNAT Library
24175 @anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{361}@anchor{gnat_rm/the_gnat_library id65}@anchor{362}
24176 @section @code{GNAT.Encode_String} (@code{g-encstr.ads})
24179 @geindex GNAT.Encode_String (g-encstr.ads)
24181 @geindex Encoding strings
24183 @geindex String encoding
24185 @geindex Wide character encoding
24187 @geindex UTF-8
24189 @geindex Unicode
24191 A generic package providing routines for encoding wide character and wide
24192 wide character strings as sequences of 8-bit characters using a specified
24193 encoding method. Useful in conjunction with Unicode character coding.
24194 Note there is a preinstantiation for UTF-8. See next entry.
24196 @node GNAT Encode_UTF8_String g-enutst ads,GNAT Exception_Actions g-excact ads,GNAT Encode_String g-encstr ads,The GNAT Library
24197 @anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{363}@anchor{gnat_rm/the_gnat_library id66}@anchor{364}
24198 @section @code{GNAT.Encode_UTF8_String} (@code{g-enutst.ads})
24201 @geindex GNAT.Encode_UTF8_String (g-enutst.ads)
24203 @geindex Encoding strings
24205 @geindex Encoding UTF-8 strings
24207 @geindex UTF-8 string encoding
24209 @geindex Wide character encoding
24211 @geindex UTF-8
24213 @geindex Unicode
24215 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
24217 @node GNAT Exception_Actions g-excact ads,GNAT Exception_Traces g-exctra ads,GNAT Encode_UTF8_String g-enutst ads,The GNAT Library
24218 @anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{365}@anchor{gnat_rm/the_gnat_library id67}@anchor{366}
24219 @section @code{GNAT.Exception_Actions} (@code{g-excact.ads})
24222 @geindex GNAT.Exception_Actions (g-excact.ads)
24224 @geindex Exception actions
24226 Provides callbacks when an exception is raised. Callbacks can be registered
24227 for specific exceptions, or when any exception is raised. This
24228 can be used for instance to force a core dump to ease debugging.
24230 @node GNAT Exception_Traces g-exctra ads,GNAT Exceptions g-except ads,GNAT Exception_Actions g-excact ads,The GNAT Library
24231 @anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{367}@anchor{gnat_rm/the_gnat_library id68}@anchor{368}
24232 @section @code{GNAT.Exception_Traces} (@code{g-exctra.ads})
24235 @geindex GNAT.Exception_Traces (g-exctra.ads)
24237 @geindex Exception traces
24239 @geindex Debugging
24241 Provides an interface allowing to control automatic output upon exception
24242 occurrences.
24244 @node GNAT Exceptions g-except ads,GNAT Expect g-expect ads,GNAT Exception_Traces g-exctra ads,The GNAT Library
24245 @anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{369}@anchor{gnat_rm/the_gnat_library id69}@anchor{36a}
24246 @section @code{GNAT.Exceptions} (@code{g-except.ads})
24249 @geindex GNAT.Exceptions (g-except.ads)
24251 @geindex Exceptions
24252 @geindex Pure
24254 @geindex Pure packages
24255 @geindex exceptions
24257 Normally it is not possible to raise an exception with
24258 a message from a subprogram in a pure package, since the
24259 necessary types and subprograms are in @code{Ada.Exceptions}
24260 which is not a pure unit. @code{GNAT.Exceptions} provides a
24261 facility for getting around this limitation for a few
24262 predefined exceptions, and for example allows raising
24263 @code{Constraint_Error} with a message from a pure subprogram.
24265 @node GNAT Expect g-expect ads,GNAT Expect TTY g-exptty ads,GNAT Exceptions g-except ads,The GNAT Library
24266 @anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{36b}@anchor{gnat_rm/the_gnat_library id70}@anchor{36c}
24267 @section @code{GNAT.Expect} (@code{g-expect.ads})
24270 @geindex GNAT.Expect (g-expect.ads)
24272 Provides a set of subprograms similar to what is available
24273 with the standard Tcl Expect tool.
24274 It allows you to easily spawn and communicate with an external process.
24275 You can send commands or inputs to the process, and compare the output
24276 with some expected regular expression. Currently @code{GNAT.Expect}
24277 is implemented on all native GNAT ports.
24278 It is not implemented for cross ports, and in particular is not
24279 implemented for VxWorks or LynxOS.
24281 @node GNAT Expect TTY g-exptty ads,GNAT Float_Control g-flocon ads,GNAT Expect g-expect ads,The GNAT Library
24282 @anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{36d}@anchor{gnat_rm/the_gnat_library id71}@anchor{36e}
24283 @section @code{GNAT.Expect.TTY} (@code{g-exptty.ads})
24286 @geindex GNAT.Expect.TTY (g-exptty.ads)
24288 As GNAT.Expect but using pseudo-terminal.
24289 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
24290 ports. It is not implemented for cross ports, and
24291 in particular is not implemented for VxWorks or LynxOS.
24293 @node GNAT Float_Control g-flocon ads,GNAT Formatted_String g-forstr ads,GNAT Expect TTY g-exptty ads,The GNAT Library
24294 @anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{36f}@anchor{gnat_rm/the_gnat_library id72}@anchor{370}
24295 @section @code{GNAT.Float_Control} (@code{g-flocon.ads})
24298 @geindex GNAT.Float_Control (g-flocon.ads)
24300 @geindex Floating-Point Processor
24302 Provides an interface for resetting the floating-point processor into the
24303 mode required for correct semantic operation in Ada.  Some third party
24304 library calls may cause this mode to be modified, and the Reset procedure
24305 in this package can be used to reestablish the required mode.
24307 @node GNAT Formatted_String g-forstr ads,GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Float_Control g-flocon ads,The GNAT Library
24308 @anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{371}@anchor{gnat_rm/the_gnat_library id73}@anchor{372}
24309 @section @code{GNAT.Formatted_String} (@code{g-forstr.ads})
24312 @geindex GNAT.Formatted_String (g-forstr.ads)
24314 @geindex Formatted String
24316 Provides support for C/C++ printf() formatted strings. The format is
24317 copied from the printf() routine and should therefore give identical
24318 output. Some generic routines are provided to be able to use types
24319 derived from Integer, Float or enumerations as values for the
24320 formatted string.
24322 @node GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Heap_Sort g-heasor ads,GNAT Formatted_String g-forstr ads,The GNAT Library
24323 @anchor{gnat_rm/the_gnat_library gnat-generic-fast-math-functions-g-gfmafu-ads}@anchor{373}@anchor{gnat_rm/the_gnat_library id74}@anchor{374}
24324 @section @code{GNAT.Generic_Fast_Math_Functions} (@code{g-gfmafu.ads})
24327 @geindex GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads)
24329 @geindex Mathematical functions
24331 Provides direct access to the underlying implementation of the common
24332 mathematical functions, generally from the system mathematical library.
24333 This differs from @code{Ada.Numerics.Generic_Elementary_Functions} in that
24334 the implementation may deviate from the semantics specified for these
24335 functions in the Reference Manual, for example @code{Numerics.Argument_Error}
24336 is not raised. On selected platforms, some of these functions may also
24337 have a vector implementation that can be automatically used by the
24338 compiler when auto-vectorization is enabled.
24340 @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
24341 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{375}@anchor{gnat_rm/the_gnat_library id75}@anchor{376}
24342 @section @code{GNAT.Heap_Sort} (@code{g-heasor.ads})
24345 @geindex GNAT.Heap_Sort (g-heasor.ads)
24347 @geindex Sorting
24349 Provides a general implementation of heap sort usable for sorting arbitrary
24350 data items. Exchange and comparison procedures are provided by passing
24351 access-to-procedure values.  The algorithm used is a modified heap sort
24352 that performs approximately N*log(N) comparisons in the worst case.
24354 @node GNAT Heap_Sort_A g-hesora ads,GNAT Heap_Sort_G g-hesorg ads,GNAT Heap_Sort g-heasor ads,The GNAT Library
24355 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{377}@anchor{gnat_rm/the_gnat_library id76}@anchor{378}
24356 @section @code{GNAT.Heap_Sort_A} (@code{g-hesora.ads})
24359 @geindex GNAT.Heap_Sort_A (g-hesora.ads)
24361 @geindex Sorting
24363 Provides a general implementation of heap sort usable for sorting arbitrary
24364 data items. Move and comparison procedures are provided by passing
24365 access-to-procedure values.  The algorithm used is a modified heap sort
24366 that performs approximately N*log(N) comparisons in the worst case.
24367 This differs from @code{GNAT.Heap_Sort} in having a less convenient
24368 interface, but may be slightly more efficient.
24370 @node GNAT Heap_Sort_G g-hesorg ads,GNAT HTable g-htable ads,GNAT Heap_Sort_A g-hesora ads,The GNAT Library
24371 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{379}@anchor{gnat_rm/the_gnat_library id77}@anchor{37a}
24372 @section @code{GNAT.Heap_Sort_G} (@code{g-hesorg.ads})
24375 @geindex GNAT.Heap_Sort_G (g-hesorg.ads)
24377 @geindex Sorting
24379 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
24380 are provided as generic parameters, this improves efficiency, especially
24381 if the procedures can be inlined, at the expense of duplicating code for
24382 multiple instantiations.
24384 @node GNAT HTable g-htable ads,GNAT IO g-io ads,GNAT Heap_Sort_G g-hesorg ads,The GNAT Library
24385 @anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{37b}@anchor{gnat_rm/the_gnat_library id78}@anchor{37c}
24386 @section @code{GNAT.HTable} (@code{g-htable.ads})
24389 @geindex GNAT.HTable (g-htable.ads)
24391 @geindex Hash tables
24393 A generic implementation of hash tables that can be used to hash arbitrary
24394 data.  Provides two approaches, one a simple static approach, and the other
24395 allowing arbitrary dynamic hash tables.
24397 @node GNAT IO g-io ads,GNAT IO_Aux g-io_aux ads,GNAT HTable g-htable ads,The GNAT Library
24398 @anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{37d}@anchor{gnat_rm/the_gnat_library id79}@anchor{37e}
24399 @section @code{GNAT.IO} (@code{g-io.ads})
24402 @geindex GNAT.IO (g-io.ads)
24404 @geindex Simple I/O
24406 @geindex Input/Output facilities
24408 A simple preelaborable input-output package that provides a subset of
24409 simple Text_IO functions for reading characters and strings from
24410 Standard_Input, and writing characters, strings and integers to either
24411 Standard_Output or Standard_Error.
24413 @node GNAT IO_Aux g-io_aux ads,GNAT Lock_Files g-locfil ads,GNAT IO g-io ads,The GNAT Library
24414 @anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{37f}@anchor{gnat_rm/the_gnat_library id80}@anchor{380}
24415 @section @code{GNAT.IO_Aux} (@code{g-io_aux.ads})
24418 @geindex GNAT.IO_Aux (g-io_aux.ads)
24420 @geindex Text_IO
24422 @geindex Input/Output facilities
24424 Provides some auxiliary functions for use with Text_IO, including a test
24425 for whether a file exists, and functions for reading a line of text.
24427 @node GNAT Lock_Files g-locfil ads,GNAT MBBS_Discrete_Random g-mbdira ads,GNAT IO_Aux g-io_aux ads,The GNAT Library
24428 @anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{381}@anchor{gnat_rm/the_gnat_library id81}@anchor{382}
24429 @section @code{GNAT.Lock_Files} (@code{g-locfil.ads})
24432 @geindex GNAT.Lock_Files (g-locfil.ads)
24434 @geindex File locking
24436 @geindex Locking using files
24438 Provides a general interface for using files as locks.  Can be used for
24439 providing program level synchronization.
24441 @node GNAT MBBS_Discrete_Random g-mbdira ads,GNAT MBBS_Float_Random g-mbflra ads,GNAT Lock_Files g-locfil ads,The GNAT Library
24442 @anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{383}@anchor{gnat_rm/the_gnat_library id82}@anchor{384}
24443 @section @code{GNAT.MBBS_Discrete_Random} (@code{g-mbdira.ads})
24446 @geindex GNAT.MBBS_Discrete_Random (g-mbdira.ads)
24448 @geindex Random number generation
24450 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
24451 a modified version of the Blum-Blum-Shub generator.
24453 @node GNAT MBBS_Float_Random g-mbflra ads,GNAT MD5 g-md5 ads,GNAT MBBS_Discrete_Random g-mbdira ads,The GNAT Library
24454 @anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{385}@anchor{gnat_rm/the_gnat_library id83}@anchor{386}
24455 @section @code{GNAT.MBBS_Float_Random} (@code{g-mbflra.ads})
24458 @geindex GNAT.MBBS_Float_Random (g-mbflra.ads)
24460 @geindex Random number generation
24462 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
24463 a modified version of the Blum-Blum-Shub generator.
24465 @node GNAT MD5 g-md5 ads,GNAT Memory_Dump g-memdum ads,GNAT MBBS_Float_Random g-mbflra ads,The GNAT Library
24466 @anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{387}@anchor{gnat_rm/the_gnat_library id84}@anchor{388}
24467 @section @code{GNAT.MD5} (@code{g-md5.ads})
24470 @geindex GNAT.MD5 (g-md5.ads)
24472 @geindex Message Digest MD5
24474 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
24475 the HMAC-MD5 message authentication function as described in RFC 2104 and
24476 FIPS PUB 198.
24478 @node GNAT Memory_Dump g-memdum ads,GNAT Most_Recent_Exception g-moreex ads,GNAT MD5 g-md5 ads,The GNAT Library
24479 @anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{389}@anchor{gnat_rm/the_gnat_library id85}@anchor{38a}
24480 @section @code{GNAT.Memory_Dump} (@code{g-memdum.ads})
24483 @geindex GNAT.Memory_Dump (g-memdum.ads)
24485 @geindex Dump Memory
24487 Provides a convenient routine for dumping raw memory to either the
24488 standard output or standard error files. Uses GNAT.IO for actual
24489 output.
24491 @node GNAT Most_Recent_Exception g-moreex ads,GNAT OS_Lib g-os_lib ads,GNAT Memory_Dump g-memdum ads,The GNAT Library
24492 @anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{38b}@anchor{gnat_rm/the_gnat_library id86}@anchor{38c}
24493 @section @code{GNAT.Most_Recent_Exception} (@code{g-moreex.ads})
24496 @geindex GNAT.Most_Recent_Exception (g-moreex.ads)
24498 @geindex Exception
24499 @geindex obtaining most recent
24501 Provides access to the most recently raised exception.  Can be used for
24502 various logging purposes, including duplicating functionality of some
24503 Ada 83 implementation dependent extensions.
24505 @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
24506 @anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{38d}@anchor{gnat_rm/the_gnat_library id87}@anchor{38e}
24507 @section @code{GNAT.OS_Lib} (@code{g-os_lib.ads})
24510 @geindex GNAT.OS_Lib (g-os_lib.ads)
24512 @geindex Operating System interface
24514 @geindex Spawn capability
24516 Provides a range of target independent operating system interface functions,
24517 including time/date management, file operations, subprocess management,
24518 including a portable spawn procedure, and access to environment variables
24519 and error return codes.
24521 @node GNAT Perfect_Hash_Generators g-pehage ads,GNAT Random_Numbers g-rannum ads,GNAT OS_Lib g-os_lib ads,The GNAT Library
24522 @anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{38f}@anchor{gnat_rm/the_gnat_library id88}@anchor{390}
24523 @section @code{GNAT.Perfect_Hash_Generators} (@code{g-pehage.ads})
24526 @geindex GNAT.Perfect_Hash_Generators (g-pehage.ads)
24528 @geindex Hash functions
24530 Provides a generator of static minimal perfect hash functions. No
24531 collisions occur and each item can be retrieved from the table in one
24532 probe (perfect property). The hash table size corresponds to the exact
24533 size of the key set and no larger (minimal property). The key set has to
24534 be known in advance (static property). The hash functions are also order
24535 preserving. If w2 is inserted after w1 in the generator, their
24536 hashcode are in the same order. These hashing functions are very
24537 convenient for use with realtime applications.
24539 @node GNAT Random_Numbers g-rannum ads,GNAT Regexp g-regexp ads,GNAT Perfect_Hash_Generators g-pehage ads,The GNAT Library
24540 @anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{391}@anchor{gnat_rm/the_gnat_library id89}@anchor{392}
24541 @section @code{GNAT.Random_Numbers} (@code{g-rannum.ads})
24544 @geindex GNAT.Random_Numbers (g-rannum.ads)
24546 @geindex Random number generation
24548 Provides random number capabilities which extend those available in the
24549 standard Ada library and are more convenient to use.
24551 @node GNAT Regexp g-regexp ads,GNAT Registry g-regist ads,GNAT Random_Numbers g-rannum ads,The GNAT Library
24552 @anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{268}@anchor{gnat_rm/the_gnat_library id90}@anchor{393}
24553 @section @code{GNAT.Regexp} (@code{g-regexp.ads})
24556 @geindex GNAT.Regexp (g-regexp.ads)
24558 @geindex Regular expressions
24560 @geindex Pattern matching
24562 A simple implementation of regular expressions, using a subset of regular
24563 expression syntax copied from familiar Unix style utilities.  This is the
24564 simplest of the three pattern matching packages provided, and is particularly
24565 suitable for ‘file globbing’ applications.
24567 @node GNAT Registry g-regist ads,GNAT Regpat g-regpat ads,GNAT Regexp g-regexp ads,The GNAT Library
24568 @anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{394}@anchor{gnat_rm/the_gnat_library id91}@anchor{395}
24569 @section @code{GNAT.Registry} (@code{g-regist.ads})
24572 @geindex GNAT.Registry (g-regist.ads)
24574 @geindex Windows Registry
24576 This is a high level binding to the Windows registry.  It is possible to
24577 do simple things like reading a key value, creating a new key.  For full
24578 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
24579 package provided with the Win32Ada binding
24581 @node GNAT Regpat g-regpat ads,GNAT Rewrite_Data g-rewdat ads,GNAT Registry g-regist ads,The GNAT Library
24582 @anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{396}@anchor{gnat_rm/the_gnat_library id92}@anchor{397}
24583 @section @code{GNAT.Regpat} (@code{g-regpat.ads})
24586 @geindex GNAT.Regpat (g-regpat.ads)
24588 @geindex Regular expressions
24590 @geindex Pattern matching
24592 A complete implementation of Unix-style regular expression matching, copied
24593 from the original V7 style regular expression library written in C by
24594 Henry Spencer (and binary compatible with this C library).
24596 @node GNAT Rewrite_Data g-rewdat ads,GNAT Secondary_Stack_Info g-sestin ads,GNAT Regpat g-regpat ads,The GNAT Library
24597 @anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{398}@anchor{gnat_rm/the_gnat_library id93}@anchor{399}
24598 @section @code{GNAT.Rewrite_Data} (@code{g-rewdat.ads})
24601 @geindex GNAT.Rewrite_Data (g-rewdat.ads)
24603 @geindex Rewrite data
24605 A unit to rewrite on-the-fly string occurrences in a stream of
24606 data. The implementation has a very minimal memory footprint as the
24607 full content to be processed is not loaded into memory all at once. This makes
24608 this interface usable for large files or socket streams.
24610 @node GNAT Secondary_Stack_Info g-sestin ads,GNAT Semaphores g-semaph ads,GNAT Rewrite_Data g-rewdat ads,The GNAT Library
24611 @anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{39a}@anchor{gnat_rm/the_gnat_library id94}@anchor{39b}
24612 @section @code{GNAT.Secondary_Stack_Info} (@code{g-sestin.ads})
24615 @geindex GNAT.Secondary_Stack_Info (g-sestin.ads)
24617 @geindex Secondary Stack Info
24619 Provides the capability to query the high water mark of the current task’s
24620 secondary stack.
24622 @node GNAT Semaphores g-semaph ads,GNAT Serial_Communications g-sercom ads,GNAT Secondary_Stack_Info g-sestin ads,The GNAT Library
24623 @anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{39c}@anchor{gnat_rm/the_gnat_library id95}@anchor{39d}
24624 @section @code{GNAT.Semaphores} (@code{g-semaph.ads})
24627 @geindex GNAT.Semaphores (g-semaph.ads)
24629 @geindex Semaphores
24631 Provides classic counting and binary semaphores using protected types.
24633 @node GNAT Serial_Communications g-sercom ads,GNAT SHA1 g-sha1 ads,GNAT Semaphores g-semaph ads,The GNAT Library
24634 @anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{39e}@anchor{gnat_rm/the_gnat_library id96}@anchor{39f}
24635 @section @code{GNAT.Serial_Communications} (@code{g-sercom.ads})
24638 @geindex GNAT.Serial_Communications (g-sercom.ads)
24640 @geindex Serial_Communications
24642 Provides a simple interface to send and receive data over a serial
24643 port. This is only supported on GNU/Linux and Windows.
24645 @node GNAT SHA1 g-sha1 ads,GNAT SHA224 g-sha224 ads,GNAT Serial_Communications g-sercom ads,The GNAT Library
24646 @anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{3a0}@anchor{gnat_rm/the_gnat_library id97}@anchor{3a1}
24647 @section @code{GNAT.SHA1} (@code{g-sha1.ads})
24650 @geindex GNAT.SHA1 (g-sha1.ads)
24652 @geindex Secure Hash Algorithm SHA-1
24654 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
24655 and RFC 3174, and the HMAC-SHA1 message authentication function as described
24656 in RFC 2104 and FIPS PUB 198.
24658 @node GNAT SHA224 g-sha224 ads,GNAT SHA256 g-sha256 ads,GNAT SHA1 g-sha1 ads,The GNAT Library
24659 @anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a2}@anchor{gnat_rm/the_gnat_library id98}@anchor{3a3}
24660 @section @code{GNAT.SHA224} (@code{g-sha224.ads})
24663 @geindex GNAT.SHA224 (g-sha224.ads)
24665 @geindex Secure Hash Algorithm SHA-224
24667 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
24668 and the HMAC-SHA224 message authentication function as described
24669 in RFC 2104 and FIPS PUB 198.
24671 @node GNAT SHA256 g-sha256 ads,GNAT SHA384 g-sha384 ads,GNAT SHA224 g-sha224 ads,The GNAT Library
24672 @anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3a4}@anchor{gnat_rm/the_gnat_library id99}@anchor{3a5}
24673 @section @code{GNAT.SHA256} (@code{g-sha256.ads})
24676 @geindex GNAT.SHA256 (g-sha256.ads)
24678 @geindex Secure Hash Algorithm SHA-256
24680 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
24681 and the HMAC-SHA256 message authentication function as described
24682 in RFC 2104 and FIPS PUB 198.
24684 @node GNAT SHA384 g-sha384 ads,GNAT SHA512 g-sha512 ads,GNAT SHA256 g-sha256 ads,The GNAT Library
24685 @anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3a6}@anchor{gnat_rm/the_gnat_library id100}@anchor{3a7}
24686 @section @code{GNAT.SHA384} (@code{g-sha384.ads})
24689 @geindex GNAT.SHA384 (g-sha384.ads)
24691 @geindex Secure Hash Algorithm SHA-384
24693 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
24694 and the HMAC-SHA384 message authentication function as described
24695 in RFC 2104 and FIPS PUB 198.
24697 @node GNAT SHA512 g-sha512 ads,GNAT Signals g-signal ads,GNAT SHA384 g-sha384 ads,The GNAT Library
24698 @anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3a8}@anchor{gnat_rm/the_gnat_library id101}@anchor{3a9}
24699 @section @code{GNAT.SHA512} (@code{g-sha512.ads})
24702 @geindex GNAT.SHA512 (g-sha512.ads)
24704 @geindex Secure Hash Algorithm SHA-512
24706 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
24707 and the HMAC-SHA512 message authentication function as described
24708 in RFC 2104 and FIPS PUB 198.
24710 @node GNAT Signals g-signal ads,GNAT Sockets g-socket ads,GNAT SHA512 g-sha512 ads,The GNAT Library
24711 @anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3aa}@anchor{gnat_rm/the_gnat_library id102}@anchor{3ab}
24712 @section @code{GNAT.Signals} (@code{g-signal.ads})
24715 @geindex GNAT.Signals (g-signal.ads)
24717 @geindex Signals
24719 Provides the ability to manipulate the blocked status of signals on supported
24720 targets.
24722 @node GNAT Sockets g-socket ads,GNAT Source_Info g-souinf ads,GNAT Signals g-signal ads,The GNAT Library
24723 @anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3ac}@anchor{gnat_rm/the_gnat_library id103}@anchor{3ad}
24724 @section @code{GNAT.Sockets} (@code{g-socket.ads})
24727 @geindex GNAT.Sockets (g-socket.ads)
24729 @geindex Sockets
24731 A high level and portable interface to develop sockets based applications.
24732 This package is based on the sockets thin binding found in
24733 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
24734 on all native GNAT ports and on VxWorks cross ports.  It is not implemented for
24735 the LynxOS cross port.
24737 @node GNAT Source_Info g-souinf ads,GNAT Spelling_Checker g-speche ads,GNAT Sockets g-socket ads,The GNAT Library
24738 @anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3ae}@anchor{gnat_rm/the_gnat_library id104}@anchor{3af}
24739 @section @code{GNAT.Source_Info} (@code{g-souinf.ads})
24742 @geindex GNAT.Source_Info (g-souinf.ads)
24744 @geindex Source Information
24746 Provides subprograms that give access to source code information known at
24747 compile time, such as the current file name and line number. Also provides
24748 subprograms yielding the date and time of the current compilation (like the
24749 C macros @code{__DATE__} and @code{__TIME__})
24751 @node GNAT Spelling_Checker g-speche ads,GNAT Spelling_Checker_Generic g-spchge ads,GNAT Source_Info g-souinf ads,The GNAT Library
24752 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b0}@anchor{gnat_rm/the_gnat_library id105}@anchor{3b1}
24753 @section @code{GNAT.Spelling_Checker} (@code{g-speche.ads})
24756 @geindex GNAT.Spelling_Checker (g-speche.ads)
24758 @geindex Spell checking
24760 Provides a function for determining whether one string is a plausible
24761 near misspelling of another string.
24763 @node GNAT Spelling_Checker_Generic g-spchge ads,GNAT Spitbol Patterns g-spipat ads,GNAT Spelling_Checker g-speche ads,The GNAT Library
24764 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b2}@anchor{gnat_rm/the_gnat_library id106}@anchor{3b3}
24765 @section @code{GNAT.Spelling_Checker_Generic} (@code{g-spchge.ads})
24768 @geindex GNAT.Spelling_Checker_Generic (g-spchge.ads)
24770 @geindex Spell checking
24772 Provides a generic function that can be instantiated with a string type for
24773 determining whether one string is a plausible near misspelling of another
24774 string.
24776 @node GNAT Spitbol Patterns g-spipat ads,GNAT Spitbol g-spitbo ads,GNAT Spelling_Checker_Generic g-spchge ads,The GNAT Library
24777 @anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3b4}@anchor{gnat_rm/the_gnat_library id107}@anchor{3b5}
24778 @section @code{GNAT.Spitbol.Patterns} (@code{g-spipat.ads})
24781 @geindex GNAT.Spitbol.Patterns (g-spipat.ads)
24783 @geindex SPITBOL pattern matching
24785 @geindex Pattern matching
24787 A complete implementation of SNOBOL4 style pattern matching.  This is the
24788 most elaborate of the pattern matching packages provided.  It fully duplicates
24789 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
24790 efficient algorithm developed by Robert Dewar for the SPITBOL system.
24792 @node GNAT Spitbol g-spitbo ads,GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Patterns g-spipat ads,The GNAT Library
24793 @anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3b6}@anchor{gnat_rm/the_gnat_library id108}@anchor{3b7}
24794 @section @code{GNAT.Spitbol} (@code{g-spitbo.ads})
24797 @geindex GNAT.Spitbol (g-spitbo.ads)
24799 @geindex SPITBOL interface
24801 The top level package of the collection of SPITBOL-style functionality, this
24802 package provides basic SNOBOL4 string manipulation functions, such as
24803 Pad, Reverse, Trim, Substr capability, as well as a generic table function
24804 useful for constructing arbitrary mappings from strings in the style of
24805 the SNOBOL4 TABLE function.
24807 @node GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol g-spitbo ads,The GNAT Library
24808 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3b8}@anchor{gnat_rm/the_gnat_library id109}@anchor{3b9}
24809 @section @code{GNAT.Spitbol.Table_Boolean} (@code{g-sptabo.ads})
24812 @geindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
24814 @geindex Sets of strings
24816 @geindex SPITBOL Tables
24818 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24819 for type @code{Standard.Boolean}, giving an implementation of sets of
24820 string values.
24822 @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
24823 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3ba}@anchor{gnat_rm/the_gnat_library id110}@anchor{3bb}
24824 @section @code{GNAT.Spitbol.Table_Integer} (@code{g-sptain.ads})
24827 @geindex GNAT.Spitbol.Table_Integer (g-sptain.ads)
24829 @geindex Integer maps
24831 @geindex Maps
24833 @geindex SPITBOL Tables
24835 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24836 for type @code{Standard.Integer}, giving an implementation of maps
24837 from string to integer values.
24839 @node GNAT Spitbol Table_VString g-sptavs ads,GNAT SSE g-sse ads,GNAT Spitbol Table_Integer g-sptain ads,The GNAT Library
24840 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3bc}@anchor{gnat_rm/the_gnat_library id111}@anchor{3bd}
24841 @section @code{GNAT.Spitbol.Table_VString} (@code{g-sptavs.ads})
24844 @geindex GNAT.Spitbol.Table_VString (g-sptavs.ads)
24846 @geindex String maps
24848 @geindex Maps
24850 @geindex SPITBOL Tables
24852 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
24853 a variable length string type, giving an implementation of general
24854 maps from strings to strings.
24856 @node GNAT SSE g-sse ads,GNAT SSE Vector_Types g-ssvety ads,GNAT Spitbol Table_VString g-sptavs ads,The GNAT Library
24857 @anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3be}@anchor{gnat_rm/the_gnat_library id112}@anchor{3bf}
24858 @section @code{GNAT.SSE} (@code{g-sse.ads})
24861 @geindex GNAT.SSE (g-sse.ads)
24863 Root of a set of units aimed at offering Ada bindings to a subset of
24864 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
24865 targets.  It exposes vector component types together with a general
24866 introduction to the binding contents and use.
24868 @node GNAT SSE Vector_Types g-ssvety ads,GNAT String_Hash g-strhas ads,GNAT SSE g-sse ads,The GNAT Library
24869 @anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3c0}@anchor{gnat_rm/the_gnat_library id113}@anchor{3c1}
24870 @section @code{GNAT.SSE.Vector_Types} (@code{g-ssvety.ads})
24873 @geindex GNAT.SSE.Vector_Types (g-ssvety.ads)
24875 SSE vector types for use with SSE related intrinsics.
24877 @node GNAT String_Hash g-strhas ads,GNAT Strings g-string ads,GNAT SSE Vector_Types g-ssvety ads,The GNAT Library
24878 @anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c2}@anchor{gnat_rm/the_gnat_library id114}@anchor{3c3}
24879 @section @code{GNAT.String_Hash} (@code{g-strhas.ads})
24882 @geindex GNAT.String_Hash (g-strhas.ads)
24884 @geindex Hash functions
24886 Provides a generic hash function working on arrays of scalars. Both the scalar
24887 type and the hash result type are parameters.
24889 @node GNAT Strings g-string ads,GNAT String_Split g-strspl ads,GNAT String_Hash g-strhas ads,The GNAT Library
24890 @anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3c4}@anchor{gnat_rm/the_gnat_library id115}@anchor{3c5}
24891 @section @code{GNAT.Strings} (@code{g-string.ads})
24894 @geindex GNAT.Strings (g-string.ads)
24896 Common String access types and related subprograms. Basically it
24897 defines a string access and an array of string access types.
24899 @node GNAT String_Split g-strspl ads,GNAT Table g-table ads,GNAT Strings g-string ads,The GNAT Library
24900 @anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3c6}@anchor{gnat_rm/the_gnat_library id116}@anchor{3c7}
24901 @section @code{GNAT.String_Split} (@code{g-strspl.ads})
24904 @geindex GNAT.String_Split (g-strspl.ads)
24906 @geindex String splitter
24908 Useful string manipulation routines: given a set of separators, split
24909 a string wherever the separators appear, and provide direct access
24910 to the resulting slices. This package is instantiated from
24911 @code{GNAT.Array_Split}.
24913 @node GNAT Table g-table ads,GNAT Task_Lock g-tasloc ads,GNAT String_Split g-strspl ads,The GNAT Library
24914 @anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3c8}@anchor{gnat_rm/the_gnat_library id117}@anchor{3c9}
24915 @section @code{GNAT.Table} (@code{g-table.ads})
24918 @geindex GNAT.Table (g-table.ads)
24920 @geindex Table implementation
24922 @geindex Arrays
24923 @geindex extendable
24925 A generic package providing a single dimension array abstraction where the
24926 length of the array can be dynamically modified.
24928 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
24929 except that this package declares a single instance of the table type,
24930 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
24931 used to define dynamic instances of the table.
24933 @node GNAT Task_Lock g-tasloc ads,GNAT Time_Stamp g-timsta ads,GNAT Table g-table ads,The GNAT Library
24934 @anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3ca}@anchor{gnat_rm/the_gnat_library id118}@anchor{3cb}
24935 @section @code{GNAT.Task_Lock} (@code{g-tasloc.ads})
24938 @geindex GNAT.Task_Lock (g-tasloc.ads)
24940 @geindex Task synchronization
24942 @geindex Task locking
24944 @geindex Locking
24946 A very simple facility for locking and unlocking sections of code using a
24947 single global task lock.  Appropriate for use in situations where contention
24948 between tasks is very rarely expected.
24950 @node GNAT Time_Stamp g-timsta ads,GNAT Threads g-thread ads,GNAT Task_Lock g-tasloc ads,The GNAT Library
24951 @anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3cc}@anchor{gnat_rm/the_gnat_library id119}@anchor{3cd}
24952 @section @code{GNAT.Time_Stamp} (@code{g-timsta.ads})
24955 @geindex GNAT.Time_Stamp (g-timsta.ads)
24957 @geindex Time stamp
24959 @geindex Current time
24961 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
24962 represents the current date and time in ISO 8601 format. This is a very simple
24963 routine with minimal code and there are no dependencies on any other unit.
24965 @node GNAT Threads g-thread ads,GNAT Traceback g-traceb ads,GNAT Time_Stamp g-timsta ads,The GNAT Library
24966 @anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3ce}@anchor{gnat_rm/the_gnat_library id120}@anchor{3cf}
24967 @section @code{GNAT.Threads} (@code{g-thread.ads})
24970 @geindex GNAT.Threads (g-thread.ads)
24972 @geindex Foreign threads
24974 @geindex Threads
24975 @geindex foreign
24977 Provides facilities for dealing with foreign threads which need to be known
24978 by the GNAT run-time system. Consult the documentation of this package for
24979 further details if your program has threads that are created by a non-Ada
24980 environment which then accesses Ada code.
24982 @node GNAT Traceback g-traceb ads,GNAT Traceback Symbolic g-trasym ads,GNAT Threads g-thread ads,The GNAT Library
24983 @anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d0}@anchor{gnat_rm/the_gnat_library id121}@anchor{3d1}
24984 @section @code{GNAT.Traceback} (@code{g-traceb.ads})
24987 @geindex GNAT.Traceback (g-traceb.ads)
24989 @geindex Trace back facilities
24991 Provides a facility for obtaining non-symbolic traceback information, useful
24992 in various debugging situations.
24994 @node GNAT Traceback Symbolic g-trasym ads,GNAT UTF_32 g-utf_32 ads,GNAT Traceback g-traceb ads,The GNAT Library
24995 @anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d2}@anchor{gnat_rm/the_gnat_library id122}@anchor{3d3}
24996 @section @code{GNAT.Traceback.Symbolic} (@code{g-trasym.ads})
24999 @geindex GNAT.Traceback.Symbolic (g-trasym.ads)
25001 @geindex Trace back facilities
25003 @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
25004 @anchor{gnat_rm/the_gnat_library gnat-utf-32-g-utf-32-ads}@anchor{3d4}@anchor{gnat_rm/the_gnat_library id123}@anchor{3d5}
25005 @section @code{GNAT.UTF_32} (@code{g-utf_32.ads})
25008 @geindex GNAT.UTF_32 (g-utf_32.ads)
25010 @geindex Wide character codes
25012 This is a package intended to be used in conjunction with the
25013 @code{Wide_Character} type in Ada 95 and the
25014 @code{Wide_Wide_Character} type in Ada 2005 (available
25015 in @code{GNAT} in Ada 2005 mode). This package contains
25016 Unicode categorization routines, as well as lexical
25017 categorization routines corresponding to the Ada 2005
25018 lexical rules for identifiers and strings, and also a
25019 lower case to upper case fold routine corresponding to
25020 the Ada 2005 rules for identifier equivalence.
25022 @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
25023 @anchor{gnat_rm/the_gnat_library gnat-utf-32-spelling-checker-g-u3spch-ads}@anchor{3d6}@anchor{gnat_rm/the_gnat_library id124}@anchor{3d7}
25024 @section @code{GNAT.UTF_32_Spelling_Checker} (@code{g-u3spch.ads})
25027 @geindex GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
25029 @geindex Spell checking
25031 Provides a function for determining whether one wide wide string is a plausible
25032 near misspelling of another wide wide string, where the strings are represented
25033 using the UTF_32_String type defined in System.Wch_Cnv.
25035 @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
25036 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3d8}@anchor{gnat_rm/the_gnat_library id125}@anchor{3d9}
25037 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-wispch.ads})
25040 @geindex GNAT.Wide_Spelling_Checker (g-wispch.ads)
25042 @geindex Spell checking
25044 Provides a function for determining whether one wide string is a plausible
25045 near misspelling of another wide string.
25047 @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
25048 @anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3da}@anchor{gnat_rm/the_gnat_library id126}@anchor{3db}
25049 @section @code{GNAT.Wide_String_Split} (@code{g-wistsp.ads})
25052 @geindex GNAT.Wide_String_Split (g-wistsp.ads)
25054 @geindex Wide_String splitter
25056 Useful wide string manipulation routines: given a set of separators, split
25057 a wide string wherever the separators appear, and provide direct access
25058 to the resulting slices. This package is instantiated from
25059 @code{GNAT.Array_Split}.
25061 @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
25062 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3dc}@anchor{gnat_rm/the_gnat_library id127}@anchor{3dd}
25063 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@code{g-zspche.ads})
25066 @geindex GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
25068 @geindex Spell checking
25070 Provides a function for determining whether one wide wide string is a plausible
25071 near misspelling of another wide wide string.
25073 @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
25074 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3de}@anchor{gnat_rm/the_gnat_library id128}@anchor{3df}
25075 @section @code{GNAT.Wide_Wide_String_Split} (@code{g-zistsp.ads})
25078 @geindex GNAT.Wide_Wide_String_Split (g-zistsp.ads)
25080 @geindex Wide_Wide_String splitter
25082 Useful wide wide string manipulation routines: given a set of separators, split
25083 a wide wide string wherever the separators appear, and provide direct access
25084 to the resulting slices. This package is instantiated from
25085 @code{GNAT.Array_Split}.
25087 @node Interfaces C Extensions i-cexten ads,Interfaces C Streams i-cstrea ads,GNAT Wide_Wide_String_Split g-zistsp ads,The GNAT Library
25088 @anchor{gnat_rm/the_gnat_library id129}@anchor{3e0}@anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3e1}
25089 @section @code{Interfaces.C.Extensions} (@code{i-cexten.ads})
25092 @geindex Interfaces.C.Extensions (i-cexten.ads)
25094 This package contains additional C-related definitions, intended
25095 for use with either manually or automatically generated bindings
25096 to C libraries.
25098 @node Interfaces C Streams i-cstrea ads,Interfaces Packed_Decimal i-pacdec ads,Interfaces C Extensions i-cexten ads,The GNAT Library
25099 @anchor{gnat_rm/the_gnat_library id130}@anchor{3e2}@anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3e3}
25100 @section @code{Interfaces.C.Streams} (@code{i-cstrea.ads})
25103 @geindex Interfaces.C.Streams (i-cstrea.ads)
25105 @geindex C streams
25106 @geindex interfacing
25108 This package is a binding for the most commonly used operations
25109 on C streams.
25111 @node Interfaces Packed_Decimal i-pacdec ads,Interfaces VxWorks i-vxwork ads,Interfaces C Streams i-cstrea ads,The GNAT Library
25112 @anchor{gnat_rm/the_gnat_library id131}@anchor{3e4}@anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3e5}
25113 @section @code{Interfaces.Packed_Decimal} (@code{i-pacdec.ads})
25116 @geindex Interfaces.Packed_Decimal (i-pacdec.ads)
25118 @geindex IBM Packed Format
25120 @geindex Packed Decimal
25122 This package provides a set of routines for conversions to and
25123 from a packed decimal format compatible with that used on IBM
25124 mainframes.
25126 @node Interfaces VxWorks i-vxwork ads,Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces Packed_Decimal i-pacdec ads,The GNAT Library
25127 @anchor{gnat_rm/the_gnat_library id132}@anchor{3e6}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3e7}
25128 @section @code{Interfaces.VxWorks} (@code{i-vxwork.ads})
25131 @geindex Interfaces.VxWorks (i-vxwork.ads)
25133 @geindex Interfacing to VxWorks
25135 @geindex VxWorks
25136 @geindex interfacing
25138 This package provides a limited binding to the VxWorks API.
25139 In particular, it interfaces with the
25140 VxWorks hardware interrupt facilities.
25142 @node Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces VxWorks IO i-vxwoio ads,Interfaces VxWorks i-vxwork ads,The GNAT Library
25143 @anchor{gnat_rm/the_gnat_library id133}@anchor{3e8}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-int-connection-i-vxinco-ads}@anchor{3e9}
25144 @section @code{Interfaces.VxWorks.Int_Connection} (@code{i-vxinco.ads})
25147 @geindex Interfaces.VxWorks.Int_Connection (i-vxinco.ads)
25149 @geindex Interfacing to VxWorks
25151 @geindex VxWorks
25152 @geindex interfacing
25154 This package provides a way for users to replace the use of
25155 intConnect() with a custom routine for installing interrupt
25156 handlers.
25158 @node Interfaces VxWorks IO i-vxwoio ads,System Address_Image s-addima ads,Interfaces VxWorks Int_Connection i-vxinco ads,The GNAT Library
25159 @anchor{gnat_rm/the_gnat_library id134}@anchor{3ea}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3eb}
25160 @section @code{Interfaces.VxWorks.IO} (@code{i-vxwoio.ads})
25163 @geindex Interfaces.VxWorks.IO (i-vxwoio.ads)
25165 @geindex Interfacing to VxWorks' I/O
25167 @geindex VxWorks
25168 @geindex I/O interfacing
25170 @geindex VxWorks
25171 @geindex Get_Immediate
25173 @geindex Get_Immediate
25174 @geindex VxWorks
25176 This package provides a binding to the ioctl (IO/Control)
25177 function of VxWorks, defining a set of option values and
25178 function codes. A particular use of this package is
25179 to enable the use of Get_Immediate under VxWorks.
25181 @node System Address_Image s-addima ads,System Assertions s-assert ads,Interfaces VxWorks IO i-vxwoio ads,The GNAT Library
25182 @anchor{gnat_rm/the_gnat_library id135}@anchor{3ec}@anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3ed}
25183 @section @code{System.Address_Image} (@code{s-addima.ads})
25186 @geindex System.Address_Image (s-addima.ads)
25188 @geindex Address image
25190 @geindex Image
25191 @geindex of an address
25193 This function provides a useful debugging
25194 function that gives an (implementation dependent)
25195 string which identifies an address.
25197 @node System Assertions s-assert ads,System Atomic_Counters s-atocou ads,System Address_Image s-addima ads,The GNAT Library
25198 @anchor{gnat_rm/the_gnat_library id136}@anchor{3ee}@anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3ef}
25199 @section @code{System.Assertions} (@code{s-assert.ads})
25202 @geindex System.Assertions (s-assert.ads)
25204 @geindex Assertions
25206 @geindex Assert_Failure
25207 @geindex exception
25209 This package provides the declaration of the exception raised
25210 by an run-time assertion failure, as well as the routine that
25211 is used internally to raise this assertion.
25213 @node System Atomic_Counters s-atocou ads,System Memory s-memory ads,System Assertions s-assert ads,The GNAT Library
25214 @anchor{gnat_rm/the_gnat_library id137}@anchor{3f0}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f1}
25215 @section @code{System.Atomic_Counters} (@code{s-atocou.ads})
25218 @geindex System.Atomic_Counters (s-atocou.ads)
25220 This package provides the declaration of an atomic counter type,
25221 together with efficient routines (using hardware
25222 synchronization primitives) for incrementing, decrementing,
25223 and testing of these counters. This package is implemented
25224 on most targets, including all Alpha, AARCH64, ARM, ia64, PowerPC, SPARC V9,
25225 x86, and x86_64 platforms.
25227 @node System Memory s-memory ads,System Multiprocessors s-multip ads,System Atomic_Counters s-atocou ads,The GNAT Library
25228 @anchor{gnat_rm/the_gnat_library id138}@anchor{3f2}@anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f3}
25229 @section @code{System.Memory} (@code{s-memory.ads})
25232 @geindex System.Memory (s-memory.ads)
25234 @geindex Memory allocation
25236 This package provides the interface to the low level routines used
25237 by the generated code for allocation and freeing storage for the
25238 default storage pool (analogous to the C routines malloc and free).
25239 It also provides a reallocation interface analogous to the C routine
25240 realloc. The body of this unit may be modified to provide alternative
25241 allocation mechanisms for the default pool, and in addition, direct
25242 calls to this unit may be made for low level allocation uses (for
25243 example see the body of @code{GNAT.Tables}).
25245 @node System Multiprocessors s-multip ads,System Multiprocessors Dispatching_Domains s-mudido ads,System Memory s-memory ads,The GNAT Library
25246 @anchor{gnat_rm/the_gnat_library id139}@anchor{3f4}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3f5}
25247 @section @code{System.Multiprocessors} (@code{s-multip.ads})
25250 @geindex System.Multiprocessors (s-multip.ads)
25252 @geindex Multiprocessor interface
25254 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25255 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25256 technically an implementation-defined addition).
25258 @node System Multiprocessors Dispatching_Domains s-mudido ads,System Partition_Interface s-parint ads,System Multiprocessors s-multip ads,The GNAT Library
25259 @anchor{gnat_rm/the_gnat_library id140}@anchor{3f6}@anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3f7}
25260 @section @code{System.Multiprocessors.Dispatching_Domains} (@code{s-mudido.ads})
25263 @geindex System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
25265 @geindex Multiprocessor interface
25267 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25268 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25269 technically an implementation-defined addition).
25271 @node System Partition_Interface s-parint ads,System Pool_Global s-pooglo ads,System Multiprocessors Dispatching_Domains s-mudido ads,The GNAT Library
25272 @anchor{gnat_rm/the_gnat_library id141}@anchor{3f8}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3f9}
25273 @section @code{System.Partition_Interface} (@code{s-parint.ads})
25276 @geindex System.Partition_Interface (s-parint.ads)
25278 @geindex Partition interfacing functions
25280 This package provides facilities for partition interfacing.  It
25281 is used primarily in a distribution context when using Annex E
25282 with @code{GLADE}.
25284 @node System Pool_Global s-pooglo ads,System Pool_Local s-pooloc ads,System Partition_Interface s-parint ads,The GNAT Library
25285 @anchor{gnat_rm/the_gnat_library id142}@anchor{3fa}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{3fb}
25286 @section @code{System.Pool_Global} (@code{s-pooglo.ads})
25289 @geindex System.Pool_Global (s-pooglo.ads)
25291 @geindex Storage pool
25292 @geindex global
25294 @geindex Global storage pool
25296 This package provides a storage pool that is equivalent to the default
25297 storage pool used for access types for which no pool is specifically
25298 declared. It uses malloc/free to allocate/free and does not attempt to
25299 do any automatic reclamation.
25301 @node System Pool_Local s-pooloc ads,System Restrictions s-restri ads,System Pool_Global s-pooglo ads,The GNAT Library
25302 @anchor{gnat_rm/the_gnat_library id143}@anchor{3fc}@anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{3fd}
25303 @section @code{System.Pool_Local} (@code{s-pooloc.ads})
25306 @geindex System.Pool_Local (s-pooloc.ads)
25308 @geindex Storage pool
25309 @geindex local
25311 @geindex Local storage pool
25313 This package provides a storage pool that is intended for use with locally
25314 defined access types. It uses malloc/free for allocate/free, and maintains
25315 a list of allocated blocks, so that all storage allocated for the pool can
25316 be freed automatically when the pool is finalized.
25318 @node System Restrictions s-restri ads,System Rident s-rident ads,System Pool_Local s-pooloc ads,The GNAT Library
25319 @anchor{gnat_rm/the_gnat_library id144}@anchor{3fe}@anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{3ff}
25320 @section @code{System.Restrictions} (@code{s-restri.ads})
25323 @geindex System.Restrictions (s-restri.ads)
25325 @geindex Run-time restrictions access
25327 This package provides facilities for accessing at run time
25328 the status of restrictions specified at compile time for
25329 the partition. Information is available both with regard
25330 to actual restrictions specified, and with regard to
25331 compiler determined information on which restrictions
25332 are violated by one or more packages in the partition.
25334 @node System Rident s-rident ads,System Strings Stream_Ops s-ststop ads,System Restrictions s-restri ads,The GNAT Library
25335 @anchor{gnat_rm/the_gnat_library id145}@anchor{400}@anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{401}
25336 @section @code{System.Rident} (@code{s-rident.ads})
25339 @geindex System.Rident (s-rident.ads)
25341 @geindex Restrictions definitions
25343 This package provides definitions of the restrictions
25344 identifiers supported by GNAT, and also the format of
25345 the restrictions provided in package System.Restrictions.
25346 It is not normally necessary to @code{with} this generic package
25347 since the necessary instantiation is included in
25348 package System.Restrictions.
25350 @node System Strings Stream_Ops s-ststop ads,System Unsigned_Types s-unstyp ads,System Rident s-rident ads,The GNAT Library
25351 @anchor{gnat_rm/the_gnat_library id146}@anchor{402}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{403}
25352 @section @code{System.Strings.Stream_Ops} (@code{s-ststop.ads})
25355 @geindex System.Strings.Stream_Ops (s-ststop.ads)
25357 @geindex Stream operations
25359 @geindex String stream operations
25361 This package provides a set of stream subprograms for standard string types.
25362 It is intended primarily to support implicit use of such subprograms when
25363 stream attributes are applied to string types, but the subprograms in this
25364 package can be used directly by application programs.
25366 @node System Unsigned_Types s-unstyp ads,System Wch_Cnv s-wchcnv ads,System Strings Stream_Ops s-ststop ads,The GNAT Library
25367 @anchor{gnat_rm/the_gnat_library id147}@anchor{404}@anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{405}
25368 @section @code{System.Unsigned_Types} (@code{s-unstyp.ads})
25371 @geindex System.Unsigned_Types (s-unstyp.ads)
25373 This package contains definitions of standard unsigned types that
25374 correspond in size to the standard signed types declared in Standard,
25375 and (unlike the types in Interfaces) have corresponding names. It
25376 also contains some related definitions for other specialized types
25377 used by the compiler in connection with packed array types.
25379 @node System Wch_Cnv s-wchcnv ads,System Wch_Con s-wchcon ads,System Unsigned_Types s-unstyp ads,The GNAT Library
25380 @anchor{gnat_rm/the_gnat_library id148}@anchor{406}@anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{407}
25381 @section @code{System.Wch_Cnv} (@code{s-wchcnv.ads})
25384 @geindex System.Wch_Cnv (s-wchcnv.ads)
25386 @geindex Wide Character
25387 @geindex Representation
25389 @geindex Wide String
25390 @geindex Conversion
25392 @geindex Representation of wide characters
25394 This package provides routines for converting between
25395 wide and wide wide characters and a representation as a value of type
25396 @code{Standard.String}, using a specified wide character
25397 encoding method.  It uses definitions in
25398 package @code{System.Wch_Con}.
25400 @node System Wch_Con s-wchcon ads,,System Wch_Cnv s-wchcnv ads,The GNAT Library
25401 @anchor{gnat_rm/the_gnat_library id149}@anchor{408}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{409}
25402 @section @code{System.Wch_Con} (@code{s-wchcon.ads})
25405 @geindex System.Wch_Con (s-wchcon.ads)
25407 This package provides definitions and descriptions of
25408 the various methods used for encoding wide characters
25409 in ordinary strings.  These definitions are used by
25410 the package @code{System.Wch_Cnv}.
25412 @node Interfacing to Other Languages,Specialized Needs Annexes,The GNAT Library,Top
25413 @anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{40a}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{40b}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11}
25414 @chapter Interfacing to Other Languages
25417 The facilities in Annex B of the Ada Reference Manual are fully
25418 implemented in GNAT, and in addition, a full interface to C++ is
25419 provided.
25421 @menu
25422 * Interfacing to C:: 
25423 * Interfacing to C++:: 
25424 * Interfacing to COBOL:: 
25425 * Interfacing to Fortran:: 
25426 * Interfacing to non-GNAT Ada code:: 
25428 @end menu
25430 @node Interfacing to C,Interfacing to C++,,Interfacing to Other Languages
25431 @anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{40c}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{40d}
25432 @section Interfacing to C
25435 Interfacing to C with GNAT can use one of two approaches:
25438 @itemize *
25440 @item 
25441 The types in the package @code{Interfaces.C} may be used.
25443 @item 
25444 Standard Ada types may be used directly.  This may be less portable to
25445 other compilers, but will work on all GNAT compilers, which guarantee
25446 correspondence between the C and Ada types.
25447 @end itemize
25449 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
25450 effect, since this is the default.  The following table shows the
25451 correspondence between Ada scalar types and the corresponding C types.
25454 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} 
25455 @headitem
25457 Ada Type
25459 @tab
25461 C Type
25463 @item
25465 @code{Integer}
25467 @tab
25469 @code{int}
25471 @item
25473 @code{Short_Integer}
25475 @tab
25477 @code{short}
25479 @item
25481 @code{Short_Short_Integer}
25483 @tab
25485 @code{signed char}
25487 @item
25489 @code{Long_Integer}
25491 @tab
25493 @code{long}
25495 @item
25497 @code{Long_Long_Integer}
25499 @tab
25501 @code{long long}
25503 @item
25505 @code{Short_Float}
25507 @tab
25509 @code{float}
25511 @item
25513 @code{Float}
25515 @tab
25517 @code{float}
25519 @item
25521 @code{Long_Float}
25523 @tab
25525 @code{double}
25527 @item
25529 @code{Long_Long_Float}
25531 @tab
25533 This is the longest floating-point type supported by the hardware.
25535 @end multitable
25538 Additionally, there are the following general correspondences between Ada
25539 and C types:
25542 @itemize *
25544 @item 
25545 Ada enumeration types map to C enumeration types directly if pragma
25546 @code{Convention C} is specified, which causes them to have a length of
25547 32 bits, except for boolean types which map to C99 @code{bool} and for
25548 which the length is 8 bits.
25549 Without pragma @code{Convention C}, Ada enumeration types map to
25550 8, 16, or 32 bits (i.e., C types @code{signed char}, @code{short},
25551 @code{int}, respectively) depending on the number of values passed.
25552 This is the only case in which pragma @code{Convention C} affects the
25553 representation of an Ada type.
25555 @item 
25556 Ada access types map to C pointers, except for the case of pointers to
25557 unconstrained types in Ada, which have no direct C equivalent.
25559 @item 
25560 Ada arrays map directly to C arrays.
25562 @item 
25563 Ada records map directly to C structures.
25565 @item 
25566 Packed Ada records map to C structures where all members are bit fields
25567 of the length corresponding to the @code{type'Size} value in Ada.
25568 @end itemize
25570 @node Interfacing to C++,Interfacing to COBOL,Interfacing to C,Interfacing to Other Languages
25571 @anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{47}@anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{40e}
25572 @section Interfacing to C++
25575 The interface to C++ makes use of the following pragmas, which are
25576 primarily intended to be constructed automatically using a binding generator
25577 tool, although it is possible to construct them by hand.
25579 Using these pragmas it is possible to achieve complete
25580 inter-operability between Ada tagged types and C++ class definitions.
25581 See @ref{7,,Implementation Defined Pragmas}, for more details.
25584 @table @asis
25586 @item @code{pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})}
25588 The argument denotes an entity in the current declarative region that is
25589 declared as a tagged or untagged record type. It indicates that the type
25590 corresponds to an externally declared C++ class type, and is to be laid
25591 out the same way that C++ would lay out the type.
25593 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
25594 for backward compatibility but its functionality is available
25595 using pragma @code{Import} with @code{Convention} = @code{CPP}.
25597 @item @code{pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})}
25599 This pragma identifies an imported function (imported in the usual way
25600 with pragma @code{Import}) as corresponding to a C++ constructor.
25601 @end table
25603 A few restrictions are placed on the use of the @code{Access} attribute
25604 in conjunction with subprograms subject to convention @code{CPP}: the
25605 attribute may be used neither on primitive operations of a tagged
25606 record type with convention @code{CPP}, imported or not, nor on
25607 subprograms imported with pragma @code{CPP_Constructor}.
25609 In addition, C++ exceptions are propagated and can be handled in an
25610 @code{others} choice of an exception handler. The corresponding Ada
25611 occurrence has no message, and the simple name of the exception identity
25612 contains @code{Foreign_Exception}. Finalization and awaiting dependent
25613 tasks works properly when such foreign exceptions are propagated.
25615 It is also possible to import a C++ exception using the following syntax:
25617 @example
25618 LOCAL_NAME : exception;
25619 pragma Import (Cpp,
25620   [Entity =>] LOCAL_NAME,
25621   [External_Name =>] static_string_EXPRESSION);
25622 @end example
25624 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
25625 cover a specific C++ exception in an exception handler.
25627 @node Interfacing to COBOL,Interfacing to Fortran,Interfacing to C++,Interfacing to Other Languages
25628 @anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{40f}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{410}
25629 @section Interfacing to COBOL
25632 Interfacing to COBOL is achieved as described in section B.4 of
25633 the Ada Reference Manual.
25635 @node Interfacing to Fortran,Interfacing to non-GNAT Ada code,Interfacing to COBOL,Interfacing to Other Languages
25636 @anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{411}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{412}
25637 @section Interfacing to Fortran
25640 Interfacing to Fortran is achieved as described in section B.5 of the
25641 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
25642 multi-dimensional array causes the array to be stored in column-major
25643 order as required for convenient interface to Fortran.
25645 @node Interfacing to non-GNAT Ada code,,Interfacing to Fortran,Interfacing to Other Languages
25646 @anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{413}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{414}
25647 @section Interfacing to non-GNAT Ada code
25650 It is possible to specify the convention @code{Ada} in a pragma
25651 @code{Import} or pragma @code{Export}.  However this refers to
25652 the calling conventions used by GNAT, which may or may not be
25653 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
25654 compiler to allow interoperation.
25656 If arguments types are kept simple, and if the foreign compiler generally
25657 follows system calling conventions, then it may be possible to integrate
25658 files compiled by other Ada compilers, provided that the elaboration
25659 issues are adequately addressed (for example by eliminating the
25660 need for any load time elaboration).
25662 In particular, GNAT running on VMS is designed to
25663 be highly compatible with the DEC Ada 83 compiler, so this is one
25664 case in which it is possible to import foreign units of this type,
25665 provided that the data items passed are restricted to simple scalar
25666 values or simple record types without variants, or simple array
25667 types with fixed bounds.
25669 @node Specialized Needs Annexes,Implementation of Specific Ada Features,Interfacing to Other Languages,Top
25670 @anchor{gnat_rm/specialized_needs_annexes doc}@anchor{415}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{416}@anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12}
25671 @chapter Specialized Needs Annexes
25674 Ada 95, Ada 2005, and Ada 2012 define a number of Specialized Needs Annexes, which are not
25675 required in all implementations.  However, as described in this chapter,
25676 GNAT implements all of these annexes:
25679 @table @asis
25681 @item `Systems Programming (Annex C)'
25683 The Systems Programming Annex is fully implemented.
25685 @item `Real-Time Systems (Annex D)'
25687 The Real-Time Systems Annex is fully implemented.
25689 @item `Distributed Systems (Annex E)'
25691 Stub generation is fully implemented in the GNAT compiler.  In addition,
25692 a complete compatible PCS is available as part of the GLADE system,
25693 a separate product.  When the two
25694 products are used in conjunction, this annex is fully implemented.
25696 @item `Information Systems (Annex F)'
25698 The Information Systems annex is fully implemented.
25700 @item `Numerics (Annex G)'
25702 The Numerics Annex is fully implemented.
25704 @item `Safety and Security / High-Integrity Systems (Annex H)'
25706 The Safety and Security Annex (termed the High-Integrity Systems Annex
25707 in Ada 2005) is fully implemented.
25708 @end table
25710 @node Implementation of Specific Ada Features,Implementation of Ada 2012 Features,Specialized Needs Annexes,Top
25711 @anchor{gnat_rm/implementation_of_specific_ada_features doc}@anchor{417}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{418}@anchor{gnat_rm/implementation_of_specific_ada_features implementation-of-specific-ada-features}@anchor{13}
25712 @chapter Implementation of Specific Ada Features
25715 This chapter describes the GNAT implementation of several Ada language
25716 facilities.
25718 @menu
25719 * Machine Code Insertions:: 
25720 * GNAT Implementation of Tasking:: 
25721 * GNAT Implementation of Shared Passive Packages:: 
25722 * Code Generation for Array Aggregates:: 
25723 * The Size of Discriminated Records with Default Discriminants:: 
25724 * Image Values For Nonscalar Types:: 
25725 * Strict Conformance to the Ada Reference Manual:: 
25727 @end menu
25729 @node Machine Code Insertions,GNAT Implementation of Tasking,,Implementation of Specific Ada Features
25730 @anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{419}@anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{170}
25731 @section Machine Code Insertions
25734 @geindex Machine Code insertions
25736 Package @code{Machine_Code} provides machine code support as described
25737 in the Ada Reference Manual in two separate forms:
25740 @itemize *
25742 @item 
25743 Machine code statements, consisting of qualified expressions that
25744 fit the requirements of RM section 13.8.
25746 @item 
25747 An intrinsic callable procedure, providing an alternative mechanism of
25748 including machine instructions in a subprogram.
25749 @end itemize
25751 The two features are similar, and both are closely related to the mechanism
25752 provided by the asm instruction in the GNU C compiler.  Full understanding
25753 and use of the facilities in this package requires understanding the asm
25754 instruction, see the section on Extended Asm in
25755 @cite{Using_the_GNU_Compiler_Collection_(GCC)}.
25757 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
25758 semantic restrictions and effects as described below.  Both are provided so
25759 that the procedure call can be used as a statement, and the function call
25760 can be used to form a code_statement.
25762 Consider this C @code{asm} instruction:
25764 @example
25765 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
25766 @end example
25768 The equivalent can be written for GNAT as:
25770 @example
25771 Asm ("fsinx %1 %0",
25772      My_Float'Asm_Output ("=f", result),
25773      My_Float'Asm_Input  ("f",  angle));
25774 @end example
25776 The first argument to @code{Asm} is the assembler template, and is
25777 identical to what is used in GNU C.  This string must be a static
25778 expression.  The second argument is the output operand list.  It is
25779 either a single @code{Asm_Output} attribute reference, or a list of such
25780 references enclosed in parentheses (technically an array aggregate of
25781 such references).
25783 The @code{Asm_Output} attribute denotes a function that takes two
25784 parameters.  The first is a string, the second is the name of a variable
25785 of the type designated by the attribute prefix.  The first (string)
25786 argument is required to be a static expression and designates the
25787 constraint (see the section on Constraints in
25788 @cite{Using_the_GNU_Compiler_Collection_(GCC)})
25789 for the parameter; e.g., what kind of register is required.  The second
25790 argument is the variable to be written or updated with the
25791 result.  The possible values for constraint are the same as those used in
25792 the RTL, and are dependent on the configuration file used to build the
25793 GCC back end.  If there are no output operands, then this argument may
25794 either be omitted, or explicitly given as @code{No_Output_Operands}.
25795 No support is provided for GNU C’s symbolic names for output parameters.
25797 The second argument of @code{my_float'Asm_Output} functions as
25798 though it were an @code{out} parameter, which is a little curious, but
25799 all names have the form of expressions, so there is no syntactic
25800 irregularity, even though normally functions would not be permitted
25801 @code{out} parameters.  The third argument is the list of input
25802 operands.  It is either a single @code{Asm_Input} attribute reference, or
25803 a list of such references enclosed in parentheses (technically an array
25804 aggregate of such references).
25806 The @code{Asm_Input} attribute denotes a function that takes two
25807 parameters.  The first is a string, the second is an expression of the
25808 type designated by the prefix.  The first (string) argument is required
25809 to be a static expression, and is the constraint for the parameter,
25810 (e.g., what kind of register is required).  The second argument is the
25811 value to be used as the input argument.  The possible values for the
25812 constraint are the same as those used in the RTL, and are dependent on
25813 the configuration file used to built the GCC back end.
25814 No support is provided for GNU C’s symbolic names for input parameters.
25816 If there are no input operands, this argument may either be omitted, or
25817 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
25818 present in the above example, is a list of register names, called the
25819 `clobber' argument.  This argument, if given, must be a static string
25820 expression, and is a space or comma separated list of names of registers
25821 that must be considered destroyed as a result of the @code{Asm} call.  If
25822 this argument is the null string (the default value), then the code
25823 generator assumes that no additional registers are destroyed.
25824 In addition to registers, the special clobbers @code{memory} and
25825 @code{cc} as described in the GNU C docs are both supported.
25827 The fifth argument, not present in the above example, called the
25828 `volatile' argument, is by default @code{False}.  It can be set to
25829 the literal value @code{True} to indicate to the code generator that all
25830 optimizations with respect to the instruction specified should be
25831 suppressed, and in particular an instruction that has outputs
25832 will still be generated, even if none of the outputs are
25833 used.  See @cite{Using_the_GNU_Compiler_Collection_(GCC)}
25834 for the full description.
25835 Generally it is strongly advisable to use Volatile for any ASM statement
25836 that is missing either input or output operands or to avoid unwanted
25837 optimizations. A warning is generated if this advice is not followed.
25839 No support is provided for GNU C’s @code{asm goto} feature.
25841 The @code{Asm} subprograms may be used in two ways.  First the procedure
25842 forms can be used anywhere a procedure call would be valid, and
25843 correspond to what the RM calls ‘intrinsic’ routines.  Such calls can
25844 be used to intersperse machine instructions with other Ada statements.
25845 Second, the function forms, which return a dummy value of the limited
25846 private type @code{Asm_Insn}, can be used in code statements, and indeed
25847 this is the only context where such calls are allowed.  Code statements
25848 appear as aggregates of the form:
25850 @example
25851 Asm_Insn'(Asm (...));
25852 Asm_Insn'(Asm_Volatile (...));
25853 @end example
25855 In accordance with RM rules, such code statements are allowed only
25856 within subprograms whose entire body consists of such statements.  It is
25857 not permissible to intermix such statements with other Ada statements.
25859 Typically the form using intrinsic procedure calls is more convenient
25860 and more flexible.  The code statement form is provided to meet the RM
25861 suggestion that such a facility should be made available.  The following
25862 is the exact syntax of the call to @code{Asm}. As usual, if named notation
25863 is used, the arguments may be given in arbitrary order, following the
25864 normal rules for use of positional and named arguments:
25866 @example
25867 ASM_CALL ::= Asm (
25868                  [Template =>] static_string_EXPRESSION
25869                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
25870                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
25871                [,[Clobber  =>] static_string_EXPRESSION ]
25872                [,[Volatile =>] static_boolean_EXPRESSION] )
25874 OUTPUT_OPERAND_LIST ::=
25875   [PREFIX.]No_Output_Operands
25876 | OUTPUT_OPERAND_ATTRIBUTE
25877 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
25879 OUTPUT_OPERAND_ATTRIBUTE ::=
25880   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
25882 INPUT_OPERAND_LIST ::=
25883   [PREFIX.]No_Input_Operands
25884 | INPUT_OPERAND_ATTRIBUTE
25885 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
25887 INPUT_OPERAND_ATTRIBUTE ::=
25888   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
25889 @end example
25891 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
25892 are declared in the package @code{Machine_Code} and must be referenced
25893 according to normal visibility rules. In particular if there is no
25894 @code{use} clause for this package, then appropriate package name
25895 qualification is required.
25897 @node GNAT Implementation of Tasking,GNAT Implementation of Shared Passive Packages,Machine Code Insertions,Implementation of Specific Ada Features
25898 @anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41a}@anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{41b}
25899 @section GNAT Implementation of Tasking
25902 This chapter outlines the basic GNAT approach to tasking (in particular,
25903 a multi-layered library for portability) and discusses issues related
25904 to compliance with the Real-Time Systems Annex.
25906 @menu
25907 * Mapping Ada Tasks onto the Underlying Kernel Threads:: 
25908 * Ensuring Compliance with the Real-Time Annex:: 
25909 * Support for Locking Policies:: 
25911 @end menu
25913 @node Mapping Ada Tasks onto the Underlying Kernel Threads,Ensuring Compliance with the Real-Time Annex,,GNAT Implementation of Tasking
25914 @anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{41c}@anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{41d}
25915 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
25918 GNAT’s run-time support comprises two layers:
25921 @itemize *
25923 @item 
25924 GNARL (GNAT Run-time Layer)
25926 @item 
25927 GNULL (GNAT Low-level Library)
25928 @end itemize
25930 In GNAT, Ada’s tasking services rely on a platform and OS independent
25931 layer known as GNARL.  This code is responsible for implementing the
25932 correct semantics of Ada’s task creation, rendezvous, protected
25933 operations etc.
25935 GNARL decomposes Ada’s tasking semantics into simpler lower level
25936 operations such as create a thread, set the priority of a thread,
25937 yield, create a lock, lock/unlock, etc.  The spec for these low-level
25938 operations constitutes GNULLI, the GNULL Interface.  This interface is
25939 directly inspired from the POSIX real-time API.
25941 If the underlying executive or OS implements the POSIX standard
25942 faithfully, the GNULL Interface maps as is to the services offered by
25943 the underlying kernel.  Otherwise, some target dependent glue code maps
25944 the services offered by the underlying kernel to the semantics expected
25945 by GNARL.
25947 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
25948 key point is that each Ada task is mapped on a thread in the underlying
25949 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
25951 In addition Ada task priorities map onto the underlying thread priorities.
25952 Mapping Ada tasks onto the underlying kernel threads has several advantages:
25955 @itemize *
25957 @item 
25958 The underlying scheduler is used to schedule the Ada tasks.  This
25959 makes Ada tasks as efficient as kernel threads from a scheduling
25960 standpoint.
25962 @item 
25963 Interaction with code written in C containing threads is eased
25964 since at the lowest level Ada tasks and C threads map onto the same
25965 underlying kernel concept.
25967 @item 
25968 When an Ada task is blocked during I/O the remaining Ada tasks are
25969 able to proceed.
25971 @item 
25972 On multiprocessor systems Ada tasks can execute in parallel.
25973 @end itemize
25975 Some threads libraries offer a mechanism to fork a new process, with the
25976 child process duplicating the threads from the parent.
25977 GNAT does not
25978 support this functionality when the parent contains more than one task.
25980 @geindex Forking a new process
25982 @node Ensuring Compliance with the Real-Time Annex,Support for Locking Policies,Mapping Ada Tasks onto the Underlying Kernel Threads,GNAT Implementation of Tasking
25983 @anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{41e}@anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{41f}
25984 @subsection Ensuring Compliance with the Real-Time Annex
25987 @geindex Real-Time Systems Annex compliance
25989 Although mapping Ada tasks onto
25990 the underlying threads has significant advantages, it does create some
25991 complications when it comes to respecting the scheduling semantics
25992 specified in the real-time annex (Annex D).
25994 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
25995 scheduling policy states:
25997 @quotation
25999 `When the active priority of a ready task that is not running
26000 changes, or the setting of its base priority takes effect, the
26001 task is removed from the ready queue for its old active priority
26002 and is added at the tail of the ready queue for its new active
26003 priority, except in the case where the active priority is lowered
26004 due to the loss of inherited priority, in which case the task is
26005 added at the head of the ready queue for its new active priority.'
26006 @end quotation
26008 While most kernels do put tasks at the end of the priority queue when
26009 a task changes its priority, (which respects the main
26010 FIFO_Within_Priorities requirement), almost none keep a thread at the
26011 beginning of its priority queue when its priority drops from the loss
26012 of inherited priority.
26014 As a result most vendors have provided incomplete Annex D implementations.
26016 The GNAT run-time, has a nice cooperative solution to this problem
26017 which ensures that accurate FIFO_Within_Priorities semantics are
26018 respected.
26020 The principle is as follows.  When an Ada task T is about to start
26021 running, it checks whether some other Ada task R with the same
26022 priority as T has been suspended due to the loss of priority
26023 inheritance.  If this is the case, T yields and is placed at the end of
26024 its priority queue.  When R arrives at the front of the queue it
26025 executes.
26027 Note that this simple scheme preserves the relative order of the tasks
26028 that were ready to execute in the priority queue where R has been
26029 placed at the end.
26031 @c Support_for_Locking_Policies
26033 @node Support for Locking Policies,,Ensuring Compliance with the Real-Time Annex,GNAT Implementation of Tasking
26034 @anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{420}
26035 @subsection Support for Locking Policies
26038 This section specifies which policies specified by pragma Locking_Policy
26039 are supported on which platforms.
26041 GNAT supports the standard @code{Ceiling_Locking} policy, and the
26042 implementation defined @code{Inheritance_Locking} and
26043 @code{Concurrent_Readers_Locking} policies.
26045 @code{Ceiling_Locking} is supported on all platforms if the operating system
26046 supports it. In particular, @code{Ceiling_Locking} is not supported on
26047 VxWorks.
26048 @code{Inheritance_Locking} is supported on
26049 Linux,
26050 Darwin (Mac OS X),
26051 LynxOS 178,
26052 and VxWorks.
26053 @code{Concurrent_Readers_Locking} is supported on Linux.
26055 Notes about @code{Ceiling_Locking} on Linux:
26056 If the process is running as ‘root’, ceiling locking is used.
26057 If the capabilities facility is installed
26058 (“sudo apt-get –assume-yes install libcap-dev” on Ubuntu,
26059 for example),
26060 and the program is linked against that library
26061 (“-largs -lcap”),
26062 and the executable file has the cap_sys_nice capability
26063 (“sudo /sbin/setcap cap_sys_nice=ep executable_file_name”),
26064 then ceiling locking is used.
26065 Otherwise, the @code{Ceiling_Locking} policy is ignored.
26067 @node GNAT Implementation of Shared Passive Packages,Code Generation for Array Aggregates,GNAT Implementation of Tasking,Implementation of Specific Ada Features
26068 @anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{421}@anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{422}
26069 @section GNAT Implementation of Shared Passive Packages
26072 @geindex Shared passive packages
26074 GNAT fully implements the 
26075 @geindex pragma Shared_Passive
26076 pragma
26077 @code{Shared_Passive} for
26078 the purpose of designating shared passive packages.
26079 This allows the use of passive partitions in the
26080 context described in the Ada Reference Manual; i.e., for communication
26081 between separate partitions of a distributed application using the
26082 features in Annex E.
26084 @geindex Annex E
26086 @geindex Distribution Systems Annex
26088 However, the implementation approach used by GNAT provides for more
26089 extensive usage as follows:
26092 @table @asis
26094 @item `Communication between separate programs'
26096 This allows separate programs to access the data in passive
26097 partitions, using protected objects for synchronization where
26098 needed. The only requirement is that the two programs have a
26099 common shared file system. It is even possible for programs
26100 running on different machines with different architectures
26101 (e.g., different endianness) to communicate via the data in
26102 a passive partition.
26104 @item `Persistence between program runs'
26106 The data in a passive package can persist from one run of a
26107 program to another, so that a later program sees the final
26108 values stored by a previous run of the same program.
26109 @end table
26111 The implementation approach used is to store the data in files. A
26112 separate stream file is created for each object in the package, and
26113 an access to an object causes the corresponding file to be read or
26114 written.
26116 @geindex SHARED_MEMORY_DIRECTORY environment variable
26118 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
26119 set to the directory to be used for these files.
26120 The files in this directory
26121 have names that correspond to their fully qualified names. For
26122 example, if we have the package
26124 @example
26125 package X is
26126   pragma Shared_Passive (X);
26127   Y : Integer;
26128   Z : Float;
26129 end X;
26130 @end example
26132 and the environment variable is set to @code{/stemp/}, then the files created
26133 will have the names:
26135 @example
26136 /stemp/x.y
26137 /stemp/x.z
26138 @end example
26140 These files are created when a value is initially written to the object, and
26141 the files are retained until manually deleted. This provides the persistence
26142 semantics. If no file exists, it means that no partition has assigned a value
26143 to the variable; in this case the initial value declared in the package
26144 will be used. This model ensures that there are no issues in synchronizing
26145 the elaboration process, since elaboration of passive packages elaborates the
26146 initial values, but does not create the files.
26148 The files are written using normal @code{Stream_IO} access.
26149 If you want to be able
26150 to communicate between programs or partitions running on different
26151 architectures, then you should use the XDR versions of the stream attribute
26152 routines, since these are architecture independent.
26154 If active synchronization is required for access to the variables in the
26155 shared passive package, then as described in the Ada Reference Manual, the
26156 package may contain protected objects used for this purpose. In this case
26157 a lock file (whose name is @code{___lock}, with three underscores)
26158 is created in the shared memory directory.
26160 @geindex ___lock file (for shared passive packages)
26162 This is used to provide the required locking
26163 semantics for proper protected object synchronization.
26165 @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
26166 @anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{423}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{424}
26167 @section Code Generation for Array Aggregates
26170 Aggregates have a rich syntax and allow the user to specify the values of
26171 complex data structures by means of a single construct.  As a result, the
26172 code generated for aggregates can be quite complex and involve loops, case
26173 statements and multiple assignments.  In the simplest cases, however, the
26174 compiler will recognize aggregates whose components and constraints are
26175 fully static, and in those cases the compiler will generate little or no
26176 executable code.  The following is an outline of the code that GNAT generates
26177 for various aggregate constructs.  For further details, you will find it
26178 useful to examine the output produced by the -gnatG flag to see the expanded
26179 source that is input to the code generator.  You may also want to examine
26180 the assembly code generated at various levels of optimization.
26182 The code generated for aggregates depends on the context, the component values,
26183 and the type.  In the context of an object declaration the code generated is
26184 generally simpler than in the case of an assignment.  As a general rule, static
26185 component values and static subtypes also lead to simpler code.
26187 @menu
26188 * Static constant aggregates with static bounds:: 
26189 * Constant aggregates with unconstrained nominal types:: 
26190 * Aggregates with static bounds:: 
26191 * Aggregates with nonstatic bounds:: 
26192 * Aggregates in assignment statements:: 
26194 @end menu
26196 @node Static constant aggregates with static bounds,Constant aggregates with unconstrained nominal types,,Code Generation for Array Aggregates
26197 @anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{425}@anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{426}
26198 @subsection Static constant aggregates with static bounds
26201 For the declarations:
26203 @example
26204 type One_Dim is array (1..10) of integer;
26205 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
26206 @end example
26208 GNAT generates no executable code: the constant ar0 is placed in static memory.
26209 The same is true for constant aggregates with named associations:
26211 @example
26212 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
26213 Cr3 : constant One_Dim := (others => 7777);
26214 @end example
26216 The same is true for multidimensional constant arrays such as:
26218 @example
26219 type two_dim is array (1..3, 1..3) of integer;
26220 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
26221 @end example
26223 The same is true for arrays of one-dimensional arrays: the following are
26224 static:
26226 @example
26227 type ar1b  is array (1..3) of boolean;
26228 type ar_ar is array (1..3) of ar1b;
26229 None  : constant ar1b := (others => false);     --  fully static
26230 None2 : constant ar_ar := (1..3 => None);       --  fully static
26231 @end example
26233 However, for multidimensional aggregates with named associations, GNAT will
26234 generate assignments and loops, even if all associations are static.  The
26235 following two declarations generate a loop for the first dimension, and
26236 individual component assignments for the second dimension:
26238 @example
26239 Zero1: constant two_dim := (1..3 => (1..3 => 0));
26240 Zero2: constant two_dim := (others => (others => 0));
26241 @end example
26243 @node Constant aggregates with unconstrained nominal types,Aggregates with static bounds,Static constant aggregates with static bounds,Code Generation for Array Aggregates
26244 @anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{427}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{428}
26245 @subsection Constant aggregates with unconstrained nominal types
26248 In such cases the aggregate itself establishes the subtype, so that
26249 associations with @code{others} cannot be used.  GNAT determines the
26250 bounds for the actual subtype of the aggregate, and allocates the
26251 aggregate statically as well.  No code is generated for the following:
26253 @example
26254 type One_Unc is array (natural range <>) of integer;
26255 Cr_Unc : constant One_Unc := (12,24,36);
26256 @end example
26258 @node Aggregates with static bounds,Aggregates with nonstatic bounds,Constant aggregates with unconstrained nominal types,Code Generation for Array Aggregates
26259 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{429}@anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{42a}
26260 @subsection Aggregates with static bounds
26263 In all previous examples the aggregate was the initial (and immutable) value
26264 of a constant.  If the aggregate initializes a variable, then code is generated
26265 for it as a combination of individual assignments and loops over the target
26266 object.  The declarations
26268 @example
26269 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
26270 Cr_Var2 : One_Dim := (others > -1);
26271 @end example
26273 generate the equivalent of
26275 @example
26276 Cr_Var1 (1) := 2;
26277 Cr_Var1 (2) := 3;
26278 Cr_Var1 (3) := 5;
26279 Cr_Var1 (4) := 11;
26281 for I in Cr_Var2'range loop
26282    Cr_Var2 (I) := -1;
26283 end loop;
26284 @end example
26286 @node Aggregates with nonstatic bounds,Aggregates in assignment statements,Aggregates with static bounds,Code Generation for Array Aggregates
26287 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{42b}@anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{42c}
26288 @subsection Aggregates with nonstatic bounds
26291 If the bounds of the aggregate are not statically compatible with the bounds
26292 of the nominal subtype  of the target, then constraint checks have to be
26293 generated on the bounds.  For a multidimensional array, constraint checks may
26294 have to be applied to sub-arrays individually, if they do not have statically
26295 compatible subtypes.
26297 @node Aggregates in assignment statements,,Aggregates with nonstatic bounds,Code Generation for Array Aggregates
26298 @anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{42d}@anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{42e}
26299 @subsection Aggregates in assignment statements
26302 In general, aggregate assignment requires the construction of a temporary,
26303 and a copy from the temporary to the target of the assignment.  This is because
26304 it is not always possible to convert the assignment into a series of individual
26305 component assignments.  For example, consider the simple case:
26307 @example
26308 A := (A(2), A(1));
26309 @end example
26311 This cannot be converted into:
26313 @example
26314 A(1) := A(2);
26315 A(2) := A(1);
26316 @end example
26318 So the aggregate has to be built first in a separate location, and then
26319 copied into the target.  GNAT recognizes simple cases where this intermediate
26320 step is not required, and the assignments can be performed in place, directly
26321 into the target.  The following sufficient criteria are applied:
26324 @itemize *
26326 @item 
26327 The bounds of the aggregate are static, and the associations are static.
26329 @item 
26330 The components of the aggregate are static constants, names of
26331 simple variables that are not renamings, or expressions not involving
26332 indexed components whose operands obey these rules.
26333 @end itemize
26335 If any of these conditions are violated, the aggregate will be built in
26336 a temporary (created either by the front-end or the code generator) and then
26337 that temporary will be copied onto the target.
26339 @node The Size of Discriminated Records with Default Discriminants,Image Values For Nonscalar Types,Code Generation for Array Aggregates,Implementation of Specific Ada Features
26340 @anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{42f}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{430}
26341 @section The Size of Discriminated Records with Default Discriminants
26344 If a discriminated type @code{T} has discriminants with default values, it is
26345 possible to declare an object of this type without providing an explicit
26346 constraint:
26348 @example
26349 type Size is range 1..100;
26351 type Rec (D : Size := 15) is record
26352    Name : String (1..D);
26353 end T;
26355 Word : Rec;
26356 @end example
26358 Such an object is said to be `unconstrained'.
26359 The discriminant of the object
26360 can be modified by a full assignment to the object, as long as it preserves the
26361 relation between the value of the discriminant, and the value of the components
26362 that depend on it:
26364 @example
26365 Word := (3, "yes");
26367 Word := (5, "maybe");
26369 Word := (5, "no"); -- raises Constraint_Error
26370 @end example
26372 In order to support this behavior efficiently, an unconstrained object is
26373 given the maximum size that any value of the type requires. In the case
26374 above, @code{Word} has storage for the discriminant and for
26375 a @code{String} of length 100.
26376 It is important to note that unconstrained objects do not require dynamic
26377 allocation. It would be an improper implementation to place on the heap those
26378 components whose size depends on discriminants. (This improper implementation
26379 was used by some Ada83 compilers, where the @code{Name} component above
26380 would have
26381 been stored as a pointer to a dynamic string). Following the principle that
26382 dynamic storage management should never be introduced implicitly,
26383 an Ada compiler should reserve the full size for an unconstrained declared
26384 object, and place it on the stack.
26386 This maximum size approach
26387 has been a source of surprise to some users, who expect the default
26388 values of the discriminants to determine the size reserved for an
26389 unconstrained object: “If the default is 15, why should the object occupy
26390 a larger size?”
26391 The answer, of course, is that the discriminant may be later modified,
26392 and its full range of values must be taken into account. This is why the
26393 declaration:
26395 @example
26396 type Rec (D : Positive := 15) is record
26397    Name : String (1..D);
26398 end record;
26400 Too_Large : Rec;
26401 @end example
26403 is flagged by the compiler with a warning:
26404 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
26405 because the required size includes @code{Positive'Last}
26406 bytes. As the first example indicates, the proper approach is to declare an
26407 index type of ‘reasonable’ range so that unconstrained objects are not too
26408 large.
26410 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
26411 created in the heap by means of an allocator, then it is `not'
26412 unconstrained:
26413 it is constrained by the default values of the discriminants, and those values
26414 cannot be modified by full assignment. This is because in the presence of
26415 aliasing all views of the object (which may be manipulated by different tasks,
26416 say) must be consistent, so it is imperative that the object, once created,
26417 remain invariant.
26419 @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
26420 @anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{431}@anchor{gnat_rm/implementation_of_specific_ada_features image-values-for-nonscalar-types}@anchor{432}
26421 @section Image Values For Nonscalar Types
26424 Ada 2022 defines the Image, Wide_Image, and Wide_Wide image attributes
26425 for nonscalar types; earlier Ada versions defined these attributes only
26426 for scalar types. Ada RM 4.10 provides some general guidance regarding
26427 the default implementation of these attributes and the GNAT compiler
26428 follows that guidance. However, beyond that the precise details of the
26429 image text generated in these cases are deliberately not documented and are
26430 subject to change. In particular, users should not rely on formatting details
26431 (such as spaces or line breaking), record field order, image values for access
26432 types, image values for types that have ancestor or subcomponent types
26433 declared in non-Ada2022 code, image values for predefined types, or the
26434 compiler’s choices regarding the implementation permissions described in
26435 Ada RM 4.10. This list is not intended to be exhaustive. If more precise
26436 control of image text is required for some type T, then T’Put_Image should be
26437 explicitly specified.
26439 @node Strict Conformance to the Ada Reference Manual,,Image Values For Nonscalar Types,Implementation of Specific Ada Features
26440 @anchor{gnat_rm/implementation_of_specific_ada_features id15}@anchor{433}@anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{434}
26441 @section Strict Conformance to the Ada Reference Manual
26444 The dynamic semantics defined by the Ada Reference Manual impose a set of
26445 run-time checks to be generated. By default, the GNAT compiler will insert many
26446 run-time checks into the compiled code, including most of those required by the
26447 Ada Reference Manual. However, there are two checks that are not enabled in
26448 the default mode for efficiency reasons: checks for access before elaboration
26449 on subprogram calls, and stack overflow checking (most operating systems do not
26450 perform this check by default).
26452 Strict conformance to the Ada Reference Manual can be achieved by adding two
26453 compiler options for dynamic checks for access-before-elaboration on subprogram
26454 calls and generic instantiations (`-gnatE'), and stack overflow checking
26455 (`-fstack-check').
26457 Note that the result of a floating point arithmetic operation in overflow and
26458 invalid situations, when the @code{Machine_Overflows} attribute of the result
26459 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
26460 case for machines compliant with the IEEE floating-point standard, but on
26461 machines that are not fully compliant with this standard, such as Alpha, the
26462 `-mieee' compiler flag must be used for achieving IEEE confirming
26463 behavior (although at the cost of a significant performance penalty), so
26464 infinite and NaN values are properly generated.
26466 @node Implementation of Ada 2012 Features,GNAT language extensions,Implementation of Specific Ada Features,Top
26467 @anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{435}@anchor{gnat_rm/implementation_of_ada_2012_features id1}@anchor{436}@anchor{gnat_rm/implementation_of_ada_2012_features implementation-of-ada-2012-features}@anchor{14}
26468 @chapter Implementation of Ada 2012 Features
26471 @geindex Ada 2012 implementation status
26473 @geindex -gnat12 option (gcc)
26475 @geindex pragma Ada_2012
26477 @geindex configuration pragma Ada_2012
26479 @geindex Ada_2012 configuration pragma
26481 This chapter contains a complete list of Ada 2012 features that have been
26482 implemented.
26483 Generally, these features are only
26484 available if the `-gnat12' (Ada 2012 features enabled) option is set,
26485 which is the default behavior,
26486 or if the configuration pragma @code{Ada_2012} is used.
26488 However, new pragmas, attributes, and restrictions are
26489 unconditionally available, since the Ada 95 standard allows the addition of
26490 new pragmas, attributes, and restrictions (there are exceptions, which are
26491 documented in the individual descriptions), and also certain packages
26492 were made available in earlier versions of Ada.
26494 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
26495 This date shows the implementation date of the feature. Any wavefront
26496 subsequent to this date will contain the indicated feature, as will any
26497 subsequent releases. A date of 0000-00-00 means that GNAT has always
26498 implemented the feature, or implemented it as soon as it appeared as a
26499 binding interpretation.
26501 Each feature corresponds to an Ada Issue (‘AI’) approved by the Ada
26502 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
26503 The features are ordered based on the relevant sections of the Ada
26504 Reference Manual (“RM”).  When a given AI relates to multiple points
26505 in the RM, the earliest is used.
26507 A complete description of the AIs may be found in
26508 @indicateurl{http://www.ada-auth.org/ai05-summary.html}.
26510 @geindex AI-0176 (Ada 2012 feature)
26513 @itemize *
26515 @item 
26516 `AI-0176 Quantified expressions (2010-09-29)'
26518 Both universally and existentially quantified expressions are implemented.
26519 They use the new syntax for iterators proposed in AI05-139-2, as well as
26520 the standard Ada loop syntax.
26522 RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
26523 @end itemize
26525 @geindex AI-0079 (Ada 2012 feature)
26528 @itemize *
26530 @item 
26531 `AI-0079 Allow other_format characters in source (2010-07-10)'
26533 Wide characters in the unicode category `other_format' are now allowed in
26534 source programs between tokens, but not within a token such as an identifier.
26536 RM References:  2.01 (4/2)   2.02 (7)
26537 @end itemize
26539 @geindex AI-0091 (Ada 2012 feature)
26542 @itemize *
26544 @item 
26545 `AI-0091 Do not allow other_format in identifiers (0000-00-00)'
26547 Wide characters in the unicode category `other_format' are not permitted
26548 within  an identifier, since this can be a security problem. The error
26549 message for this case has been improved to be more specific, but GNAT has
26550 never allowed such characters to appear in identifiers.
26552 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)
26553 @end itemize
26555 @geindex AI-0100 (Ada 2012 feature)
26558 @itemize *
26560 @item 
26561 `AI-0100 Placement of pragmas  (2010-07-01)'
26563 This AI is an earlier version of AI-163. It simplifies the rules
26564 for legal placement of pragmas. In the case of lists that allow pragmas, if
26565 the list may have no elements, then the list may consist solely of pragmas.
26567 RM References:  2.08 (7)
26568 @end itemize
26570 @geindex AI-0163 (Ada 2012 feature)
26573 @itemize *
26575 @item 
26576 `AI-0163 Pragmas in place of null (2010-07-01)'
26578 A statement sequence may be composed entirely of pragmas. It is no longer
26579 necessary to add a dummy @code{null} statement to make the sequence legal.
26581 RM References:  2.08 (7)   2.08 (16)
26582 @end itemize
26584 @geindex AI-0080 (Ada 2012 feature)
26587 @itemize *
26589 @item 
26590 `AI-0080 ‘View of’ not needed if clear from context (0000-00-00)'
26592 This is an editorial change only, described as non-testable in the AI.
26594 RM References:  3.01 (7)
26595 @end itemize
26597 @geindex AI-0183 (Ada 2012 feature)
26600 @itemize *
26602 @item 
26603 `AI-0183 Aspect specifications (2010-08-16)'
26605 Aspect specifications have been fully implemented except for pre and post-
26606 conditions, and type invariants, which have their own separate AI’s. All
26607 forms of declarations listed in the AI are supported. The following is a
26608 list of the aspects supported (with GNAT implementation aspects marked)
26609 @end itemize
26612 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxx} 
26613 @headitem
26615 Supported Aspect
26617 @tab
26619 Source
26621 @item
26623 @code{Ada_2005}
26625 @tab
26627 – GNAT
26629 @item
26631 @code{Ada_2012}
26633 @tab
26635 – GNAT
26637 @item
26639 @code{Address}
26641 @tab
26643 @item
26645 @code{Alignment}
26647 @tab
26649 @item
26651 @code{Atomic}
26653 @tab
26655 @item
26657 @code{Atomic_Components}
26659 @tab
26661 @item
26663 @code{Bit_Order}
26665 @tab
26667 @item
26669 @code{Component_Size}
26671 @tab
26673 @item
26675 @code{Contract_Cases}
26677 @tab
26679 – GNAT
26681 @item
26683 @code{Discard_Names}
26685 @tab
26687 @item
26689 @code{External_Tag}
26691 @tab
26693 @item
26695 @code{Favor_Top_Level}
26697 @tab
26699 – GNAT
26701 @item
26703 @code{Inline}
26705 @tab
26707 @item
26709 @code{Inline_Always}
26711 @tab
26713 – GNAT
26715 @item
26717 @code{Invariant}
26719 @tab
26721 – GNAT
26723 @item
26725 @code{Machine_Radix}
26727 @tab
26729 @item
26731 @code{No_Return}
26733 @tab
26735 @item
26737 @code{Object_Size}
26739 @tab
26741 – GNAT
26743 @item
26745 @code{Pack}
26747 @tab
26749 @item
26751 @code{Persistent_BSS}
26753 @tab
26755 – GNAT
26757 @item
26759 @code{Post}
26761 @tab
26763 @item
26765 @code{Pre}
26767 @tab
26769 @item
26771 @code{Predicate}
26773 @tab
26775 @item
26777 @code{Preelaborable_Initialization}
26779 @tab
26781 @item
26783 @code{Pure_Function}
26785 @tab
26787 – GNAT
26789 @item
26791 @code{Remote_Access_Type}
26793 @tab
26795 – GNAT
26797 @item
26799 @code{Shared}
26801 @tab
26803 – GNAT
26805 @item
26807 @code{Size}
26809 @tab
26811 @item
26813 @code{Storage_Pool}
26815 @tab
26817 @item
26819 @code{Storage_Size}
26821 @tab
26823 @item
26825 @code{Stream_Size}
26827 @tab
26829 @item
26831 @code{Suppress}
26833 @tab
26835 @item
26837 @code{Suppress_Debug_Info}
26839 @tab
26841 – GNAT
26843 @item
26845 @code{Test_Case}
26847 @tab
26849 – GNAT
26851 @item
26853 @code{Thread_Local_Storage}
26855 @tab
26857 – GNAT
26859 @item
26861 @code{Type_Invariant}
26863 @tab
26865 @item
26867 @code{Unchecked_Union}
26869 @tab
26871 @item
26873 @code{Universal_Aliasing}
26875 @tab
26877 – GNAT
26879 @item
26881 @code{Unmodified}
26883 @tab
26885 – GNAT
26887 @item
26889 @code{Unreferenced}
26891 @tab
26893 – GNAT
26895 @item
26897 @code{Unreferenced_Objects}
26899 @tab
26901 – GNAT
26903 @item
26905 @code{Unsuppress}
26907 @tab
26909 @item
26911 @code{Value_Size}
26913 @tab
26915 – GNAT
26917 @item
26919 @code{Volatile}
26921 @tab
26923 @item
26925 @code{Volatile_Components}
26927 @tab
26929 @item
26931 @code{Warnings}
26933 @tab
26935 – GNAT
26937 @end multitable
26940 @quotation
26942 Note that for aspects with an expression, e.g. @code{Size}, the expression is
26943 treated like a default expression (visibility is analyzed at the point of
26944 occurrence of the aspect, but evaluation of the expression occurs at the
26945 freeze point of the entity involved).
26947 RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
26948 3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
26949 (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
26950 9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
26951 12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
26952 13.03.01 (0)
26953 @end quotation
26955 @geindex AI-0128 (Ada 2012 feature)
26958 @itemize *
26960 @item 
26961 `AI-0128 Inequality is a primitive operation (0000-00-00)'
26963 If an equality operator (“=”) is declared for a type, then the implicitly
26964 declared inequality operator (“/=”) is a primitive operation of the type.
26965 This is the only reasonable interpretation, and is the one always implemented
26966 by GNAT, but the RM was not entirely clear in making this point.
26968 RM References:  3.02.03 (6)   6.06 (6)
26969 @end itemize
26971 @geindex AI-0003 (Ada 2012 feature)
26974 @itemize *
26976 @item 
26977 `AI-0003 Qualified expressions as names (2010-07-11)'
26979 In Ada 2012, a qualified expression is considered to be syntactically a name,
26980 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
26981 useful in disambiguating some cases of overloading.
26983 RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
26984 5.04 (7)
26985 @end itemize
26987 @geindex AI-0120 (Ada 2012 feature)
26990 @itemize *
26992 @item 
26993 `AI-0120 Constant instance of protected object (0000-00-00)'
26995 This is an RM editorial change only. The section that lists objects that are
26996 constant failed to include the current instance of a protected object
26997 within a protected function. This has always been treated as a constant
26998 in GNAT.
27000 RM References:  3.03 (21)
27001 @end itemize
27003 @geindex AI-0008 (Ada 2012 feature)
27006 @itemize *
27008 @item 
27009 `AI-0008 General access to constrained objects (0000-00-00)'
27011 The wording in the RM implied that if you have a general access to a
27012 constrained object, it could be used to modify the discriminants. This was
27013 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
27014 has always done so in this situation.
27016 RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
27017 @end itemize
27019 @geindex AI-0093 (Ada 2012 feature)
27022 @itemize *
27024 @item 
27025 `AI-0093 Additional rules use immutably limited (0000-00-00)'
27027 This is an editorial change only, to make more widespread use of the Ada 2012
27028 ‘immutably limited’.
27030 RM References:  3.03 (23.4/3)
27031 @end itemize
27033 @geindex AI-0096 (Ada 2012 feature)
27036 @itemize *
27038 @item 
27039 `AI-0096 Deriving from formal private types (2010-07-20)'
27041 In general it is illegal for a type derived from a formal limited type to be
27042 nonlimited.  This AI makes an exception to this rule: derivation is legal
27043 if it appears in the private part of the generic, and the formal type is not
27044 tagged. If the type is tagged, the legality check must be applied to the
27045 private part of the package.
27047 RM References:  3.04 (5.1/2)   6.02 (7)
27048 @end itemize
27050 @geindex AI-0181 (Ada 2012 feature)
27053 @itemize *
27055 @item 
27056 `AI-0181 Soft hyphen is a non-graphic character (2010-07-23)'
27058 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
27059 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
27060 @code{Image} and @code{Value} attributes for the character types. Strictly
27061 speaking this is an inconsistency with Ada 95, but in practice the use of
27062 these attributes is so obscure that it will not cause problems.
27064 RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
27065 @end itemize
27067 @geindex AI-0182 (Ada 2012 feature)
27070 @itemize *
27072 @item 
27073 `AI-0182 Additional forms for' @code{Character'Value} `(0000-00-00)'
27075 This AI allows @code{Character'Value} to accept the string @code{'?'} where
27076 @code{?} is any character including non-graphic control characters. GNAT has
27077 always accepted such strings. It also allows strings such as
27078 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
27079 permission and raises @code{Constraint_Error}, as is certainly still
27080 permitted.
27082 RM References:  3.05 (56/2)
27083 @end itemize
27085 @geindex AI-0214 (Ada 2012 feature)
27088 @itemize *
27090 @item 
27091 `AI-0214 Defaulted discriminants for limited tagged (2010-10-01)'
27093 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
27094 to have default expressions by allowing them when the type is limited. It
27095 is often useful to define a default value for a discriminant even though
27096 it can’t be changed by assignment.
27098 RM References:  3.07 (9.1/2)   3.07.02 (3)
27099 @end itemize
27101 @geindex AI-0102 (Ada 2012 feature)
27104 @itemize *
27106 @item 
27107 `AI-0102 Some implicit conversions are illegal (0000-00-00)'
27109 It is illegal to assign an anonymous access constant to an anonymous access
27110 variable. The RM did not have a clear rule to prevent this, but GNAT has
27111 always generated an error for this usage.
27113 RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
27114 @end itemize
27116 @geindex AI-0158 (Ada 2012 feature)
27119 @itemize *
27121 @item 
27122 `AI-0158 Generalizing membership tests (2010-09-16)'
27124 This AI extends the syntax of membership tests to simplify complex conditions
27125 that can be expressed as membership in a subset of values of any type. It
27126 introduces syntax for a list of expressions that may be used in loop contexts
27127 as well.
27129 RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
27130 @end itemize
27132 @geindex AI-0173 (Ada 2012 feature)
27135 @itemize *
27137 @item 
27138 `AI-0173 Testing if tags represent abstract types (2010-07-03)'
27140 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
27141 with the tag of an abstract type, and @code{False} otherwise.
27143 RM References:  3.09 (7.4/2)   3.09 (12.4/2)
27144 @end itemize
27146 @geindex AI-0076 (Ada 2012 feature)
27149 @itemize *
27151 @item 
27152 `AI-0076 function with controlling result (0000-00-00)'
27154 This is an editorial change only. The RM defines calls with controlling
27155 results, but uses the term ‘function with controlling result’ without an
27156 explicit definition.
27158 RM References:  3.09.02 (2/2)
27159 @end itemize
27161 @geindex AI-0126 (Ada 2012 feature)
27164 @itemize *
27166 @item 
27167 `AI-0126 Dispatching with no declared operation (0000-00-00)'
27169 This AI clarifies dispatching rules, and simply confirms that dispatching
27170 executes the operation of the parent type when there is no explicitly or
27171 implicitly declared operation for the descendant type. This has always been
27172 the case in all versions of GNAT.
27174 RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
27175 @end itemize
27177 @geindex AI-0097 (Ada 2012 feature)
27180 @itemize *
27182 @item 
27183 `AI-0097 Treatment of abstract null extension (2010-07-19)'
27185 The RM as written implied that in some cases it was possible to create an
27186 object of an abstract type, by having an abstract extension inherit a non-
27187 abstract constructor from its parent type. This mistake has been corrected
27188 in GNAT and in the RM, and this construct is now illegal.
27190 RM References:  3.09.03 (4/2)
27191 @end itemize
27193 @geindex AI-0203 (Ada 2012 feature)
27196 @itemize *
27198 @item 
27199 `AI-0203 Extended return cannot be abstract (0000-00-00)'
27201 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
27202 permitted such usage.
27204 RM References:  3.09.03 (8/3)
27205 @end itemize
27207 @geindex AI-0198 (Ada 2012 feature)
27210 @itemize *
27212 @item 
27213 `AI-0198 Inheriting abstract operators  (0000-00-00)'
27215 This AI resolves a conflict between two rules involving inherited abstract
27216 operations and predefined operators. If a derived numeric type inherits
27217 an abstract operator, it overrides the predefined one. This interpretation
27218 was always the one implemented in GNAT.
27220 RM References:  3.09.03 (4/3)
27221 @end itemize
27223 @geindex AI-0073 (Ada 2012 feature)
27226 @itemize *
27228 @item 
27229 `AI-0073 Functions returning abstract types (2010-07-10)'
27231 This AI covers a number of issues regarding returning abstract types. In
27232 particular generic functions cannot have abstract result types or access
27233 result types designated an abstract type. There are some other cases which
27234 are detailed in the AI. Note that this binding interpretation has not been
27235 retrofitted to operate before Ada 2012 mode, since it caused a significant
27236 number of regressions.
27238 RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
27239 @end itemize
27241 @geindex AI-0070 (Ada 2012 feature)
27244 @itemize *
27246 @item 
27247 `AI-0070 Elaboration of interface types (0000-00-00)'
27249 This is an editorial change only, there are no testable consequences short of
27250 checking for the absence of generated code for an interface declaration.
27252 RM References:  3.09.04 (18/2)
27253 @end itemize
27255 @geindex AI-0208 (Ada 2012 feature)
27258 @itemize *
27260 @item 
27261 `AI-0208 Characteristics of incomplete views (0000-00-00)'
27263 The wording in the Ada 2005 RM concerning characteristics of incomplete views
27264 was incorrect and implied that some programs intended to be legal were now
27265 illegal. GNAT had never considered such programs illegal, so it has always
27266 implemented the intent of this AI.
27268 RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
27269 @end itemize
27271 @geindex AI-0162 (Ada 2012 feature)
27274 @itemize *
27276 @item 
27277 `AI-0162 Incomplete type completed by partial view (2010-09-15)'
27279 Incomplete types are made more useful by allowing them to be completed by
27280 private types and private extensions.
27282 RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
27283 @end itemize
27285 @geindex AI-0098 (Ada 2012 feature)
27288 @itemize *
27290 @item 
27291 `AI-0098 Anonymous subprogram access restrictions (0000-00-00)'
27293 An unintentional omission in the RM implied some inconsistent restrictions on
27294 the use of anonymous access to subprogram values. These restrictions were not
27295 intentional, and have never been enforced by GNAT.
27297 RM References:  3.10.01 (6)   3.10.01 (9.2/2)
27298 @end itemize
27300 @geindex AI-0199 (Ada 2012 feature)
27303 @itemize *
27305 @item 
27306 `AI-0199 Aggregate with anonymous access components (2010-07-14)'
27308 A choice list in a record aggregate can include several components of
27309 (distinct) anonymous access types as long as they have matching designated
27310 subtypes.
27312 RM References:  4.03.01 (16)
27313 @end itemize
27315 @geindex AI-0220 (Ada 2012 feature)
27318 @itemize *
27320 @item 
27321 `AI-0220 Needed components for aggregates (0000-00-00)'
27323 This AI addresses a wording problem in the RM that appears to permit some
27324 complex cases of aggregates with nonstatic discriminants. GNAT has always
27325 implemented the intended semantics.
27327 RM References:  4.03.01 (17)
27328 @end itemize
27330 @geindex AI-0147 (Ada 2012 feature)
27333 @itemize *
27335 @item 
27336 `AI-0147 Conditional expressions (2009-03-29)'
27338 Conditional expressions are permitted. The form of such an expression is:
27340 @example
27341 (if expr then expr @{elsif expr then expr@} [else expr])
27342 @end example
27344 The parentheses can be omitted in contexts where parentheses are present
27345 anyway, such as subprogram arguments and pragma arguments. If the `else'
27346 clause is omitted, `else' `True' is assumed;
27347 thus @code{(if A then B)} is a way to conveniently represent
27348 `(A implies B)' in standard logic.
27350 RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
27351 4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
27352 @end itemize
27354 @geindex AI-0037 (Ada 2012 feature)
27357 @itemize *
27359 @item 
27360 `AI-0037 Out-of-range box associations in aggregate (0000-00-00)'
27362 This AI confirms that an association of the form @code{Indx => <>} in an
27363 array aggregate must raise @code{Constraint_Error} if @code{Indx}
27364 is out of range. The RM specified a range check on other associations, but
27365 not when the value of the association was defaulted. GNAT has always inserted
27366 a constraint check on the index value.
27368 RM References:  4.03.03 (29)
27369 @end itemize
27371 @geindex AI-0123 (Ada 2012 feature)
27374 @itemize *
27376 @item 
27377 `AI-0123 Composability of equality (2010-04-13)'
27379 Equality of untagged record composes, so that the predefined equality for a
27380 composite type that includes a component of some untagged record type
27381 @code{R} uses the equality operation of @code{R} (which may be user-defined
27382 or predefined). This makes the behavior of untagged records identical to that
27383 of tagged types in this respect.
27385 This change is an incompatibility with previous versions of Ada, but it
27386 corrects a non-uniformity that was often a source of confusion. Analysis of
27387 a large number of industrial programs indicates that in those rare cases
27388 where a composite type had an untagged record component with a user-defined
27389 equality, either there was no use of the composite equality, or else the code
27390 expected the same composability as for tagged types, and thus had a bug that
27391 would be fixed by this change.
27393 RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
27394 8.05.04 (8)
27395 @end itemize
27397 @geindex AI-0088 (Ada 2012 feature)
27400 @itemize *
27402 @item 
27403 `AI-0088 The value of exponentiation (0000-00-00)'
27405 This AI clarifies the equivalence rule given for the dynamic semantics of
27406 exponentiation: the value of the operation can be obtained by repeated
27407 multiplication, but the operation can be implemented otherwise (for example
27408 using the familiar divide-by-two-and-square algorithm, even if this is less
27409 accurate), and does not imply repeated reads of a volatile base.
27411 RM References:  4.05.06 (11)
27412 @end itemize
27414 @geindex AI-0188 (Ada 2012 feature)
27417 @itemize *
27419 @item 
27420 `AI-0188 Case expressions (2010-01-09)'
27422 Case expressions are permitted. This allows use of constructs such as:
27424 @example
27425 X := (case Y is when 1 => 2, when 2 => 3, when others => 31)
27426 @end example
27428 RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
27429 @end itemize
27431 @geindex AI-0104 (Ada 2012 feature)
27434 @itemize *
27436 @item 
27437 `AI-0104 Null exclusion and uninitialized allocator (2010-07-15)'
27439 The assignment @code{Ptr := new not null Some_Ptr;} will raise
27440 @code{Constraint_Error} because the default value of the allocated object is
27441 `null'. This useless construct is illegal in Ada 2012.
27443 RM References:  4.08 (2)
27444 @end itemize
27446 @geindex AI-0157 (Ada 2012 feature)
27449 @itemize *
27451 @item 
27452 `AI-0157 Allocation/Deallocation from empty pool (2010-07-11)'
27454 Allocation and Deallocation from an empty storage pool (i.e. allocation or
27455 deallocation of a pointer for which a static storage size clause of zero
27456 has been given) is now illegal and is detected as such. GNAT
27457 previously gave a warning but not an error.
27459 RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
27460 @end itemize
27462 @geindex AI-0179 (Ada 2012 feature)
27465 @itemize *
27467 @item 
27468 `AI-0179 Statement not required after label (2010-04-10)'
27470 It is not necessary to have a statement following a label, so a label
27471 can appear at the end of a statement sequence without the need for putting a
27472 null statement afterwards, but it is not allowable to have only labels and
27473 no real statements in a statement sequence.
27475 RM References:  5.01 (2)
27476 @end itemize
27478 @geindex AI-0139-2 (Ada 2012 feature)
27481 @itemize *
27483 @item 
27484 `AI-0139-2 Syntactic sugar for iterators (2010-09-29)'
27486 The new syntax for iterating over arrays and containers is now implemented.
27487 Iteration over containers is for now limited to read-only iterators. Only
27488 default iterators are supported, with the syntax:  @code{for Elem of C}.
27490 RM References:  5.05
27491 @end itemize
27493 @geindex AI-0134 (Ada 2012 feature)
27496 @itemize *
27498 @item 
27499 `AI-0134 Profiles must match for full conformance (0000-00-00)'
27501 For full conformance, the profiles of anonymous-access-to-subprogram
27502 parameters must match. GNAT has always enforced this rule.
27504 RM References:  6.03.01 (18)
27505 @end itemize
27507 @geindex AI-0207 (Ada 2012 feature)
27510 @itemize *
27512 @item 
27513 `AI-0207 Mode conformance and access constant (0000-00-00)'
27515 This AI confirms that access_to_constant indication must match for mode
27516 conformance. This was implemented in GNAT when the qualifier was originally
27517 introduced in Ada 2005.
27519 RM References:  6.03.01 (16/2)
27520 @end itemize
27522 @geindex AI-0046 (Ada 2012 feature)
27525 @itemize *
27527 @item 
27528 `AI-0046 Null exclusion match for full conformance (2010-07-17)'
27530 For full conformance, in the case of access parameters, the null exclusion
27531 must match (either both or neither must have @code{not null}).
27533 RM References:  6.03.02 (18)
27534 @end itemize
27536 @geindex AI-0118 (Ada 2012 feature)
27539 @itemize *
27541 @item 
27542 `AI-0118 The association of parameter associations (0000-00-00)'
27544 This AI clarifies the rules for named associations in subprogram calls and
27545 generic instantiations. The rules have been in place since Ada 83.
27547 RM References:  6.04.01 (2)   12.03 (9)
27548 @end itemize
27550 @geindex AI-0196 (Ada 2012 feature)
27553 @itemize *
27555 @item 
27556 `AI-0196 Null exclusion tests for out parameters (0000-00-00)'
27558 Null exclusion checks are not made for @code{out} parameters when
27559 evaluating the actual parameters. GNAT has never generated these checks.
27561 RM References:  6.04.01 (13)
27562 @end itemize
27564 @geindex AI-0015 (Ada 2012 feature)
27567 @itemize *
27569 @item 
27570 `AI-0015 Constant return objects (0000-00-00)'
27572 The return object declared in an `extended_return_statement' may be
27573 declared constant. This was always intended, and GNAT has always allowed it.
27575 RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
27576 6.05 (5.7/2)
27577 @end itemize
27579 @geindex AI-0032 (Ada 2012 feature)
27582 @itemize *
27584 @item 
27585 `AI-0032 Extended return for class-wide functions (0000-00-00)'
27587 If a function returns a class-wide type, the object of an extended return
27588 statement can be declared with a specific type that is covered by the class-
27589 wide type. This has been implemented in GNAT since the introduction of
27590 extended returns. Note AI-0103 complements this AI by imposing matching
27591 rules for constrained return types.
27593 RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
27594 6.05 (8/2)
27595 @end itemize
27597 @geindex AI-0103 (Ada 2012 feature)
27600 @itemize *
27602 @item 
27603 `AI-0103 Static matching for extended return (2010-07-23)'
27605 If the return subtype of a function is an elementary type or a constrained
27606 type, the subtype indication in an extended return statement must match
27607 statically this return subtype.
27609 RM References:  6.05 (5.2/2)
27610 @end itemize
27612 @geindex AI-0058 (Ada 2012 feature)
27615 @itemize *
27617 @item 
27618 `AI-0058 Abnormal completion of an extended return (0000-00-00)'
27620 The RM had some incorrect wording implying wrong treatment of abnormal
27621 completion in an extended return. GNAT has always implemented the intended
27622 correct semantics as described by this AI.
27624 RM References:  6.05 (22/2)
27625 @end itemize
27627 @geindex AI-0050 (Ada 2012 feature)
27630 @itemize *
27632 @item 
27633 `AI-0050 Raising Constraint_Error early for function call (0000-00-00)'
27635 The implementation permissions for raising @code{Constraint_Error} early on a function call
27636 when it was clear an exception would be raised were over-permissive and allowed
27637 mishandling of discriminants in some cases. GNAT did
27638 not take advantage of these incorrect permissions in any case.
27640 RM References:  6.05 (24/2)
27641 @end itemize
27643 @geindex AI-0125 (Ada 2012 feature)
27646 @itemize *
27648 @item 
27649 `AI-0125 Nonoverridable operations of an ancestor (2010-09-28)'
27651 In Ada 2012, the declaration of a primitive operation of a type extension
27652 or private extension can also override an inherited primitive that is not
27653 visible at the point of this declaration.
27655 RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
27656 @end itemize
27658 @geindex AI-0062 (Ada 2012 feature)
27661 @itemize *
27663 @item 
27664 `AI-0062 Null exclusions and deferred constants (0000-00-00)'
27666 A full constant may have a null exclusion even if its associated deferred
27667 constant does not. GNAT has always allowed this.
27669 RM References:  7.04 (6/2)   7.04 (7.1/2)
27670 @end itemize
27672 @geindex AI-0178 (Ada 2012 feature)
27675 @itemize *
27677 @item 
27678 `AI-0178 Incomplete views are limited (0000-00-00)'
27680 This AI clarifies the role of incomplete views and plugs an omission in the
27681 RM. GNAT always correctly restricted the use of incomplete views and types.
27683 RM References:  7.05 (3/2)   7.05 (6/2)
27684 @end itemize
27686 @geindex AI-0087 (Ada 2012 feature)
27689 @itemize *
27691 @item 
27692 `AI-0087 Actual for formal nonlimited derived type (2010-07-15)'
27694 The actual for a formal nonlimited derived type cannot be limited. In
27695 particular, a formal derived type that extends a limited interface but which
27696 is not explicitly limited cannot be instantiated with a limited type.
27698 RM References:  7.05 (5/2)   12.05.01 (5.1/2)
27699 @end itemize
27701 @geindex AI-0099 (Ada 2012 feature)
27704 @itemize *
27706 @item 
27707 `AI-0099 Tag determines whether finalization needed (0000-00-00)'
27709 This AI clarifies that ‘needs finalization’ is part of dynamic semantics,
27710 and therefore depends on the run-time characteristics of an object (i.e. its
27711 tag) and not on its nominal type. As the AI indicates: “we do not expect
27712 this to affect any implementation’’.
27714 RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
27715 @end itemize
27717 @geindex AI-0064 (Ada 2012 feature)
27720 @itemize *
27722 @item 
27723 `AI-0064 Redundant finalization rule (0000-00-00)'
27725 This is an editorial change only. The intended behavior is already checked
27726 by an existing ACATS test, which GNAT has always executed correctly.
27728 RM References:  7.06.01 (17.1/1)
27729 @end itemize
27731 @geindex AI-0026 (Ada 2012 feature)
27734 @itemize *
27736 @item 
27737 `AI-0026 Missing rules for Unchecked_Union (2010-07-07)'
27739 Record representation clauses concerning Unchecked_Union types cannot mention
27740 the discriminant of the type. The type of a component declared in the variant
27741 part of an Unchecked_Union cannot be controlled, have controlled components,
27742 nor have protected or task parts. If an Unchecked_Union type is declared
27743 within the body of a generic unit or its descendants, then the type of a
27744 component declared in the variant part cannot be a formal private type or a
27745 formal private extension declared within the same generic unit.
27747 RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
27748 @end itemize
27750 @geindex AI-0205 (Ada 2012 feature)
27753 @itemize *
27755 @item 
27756 `AI-0205 Extended return declares visible name (0000-00-00)'
27758 This AI corrects a simple omission in the RM. Return objects have always
27759 been visible within an extended return statement.
27761 RM References:  8.03 (17)
27762 @end itemize
27764 @geindex AI-0042 (Ada 2012 feature)
27767 @itemize *
27769 @item 
27770 `AI-0042 Overriding versus implemented-by (0000-00-00)'
27772 This AI fixes a wording gap in the RM. An operation of a synchronized
27773 interface can be implemented by a protected or task entry, but the abstract
27774 operation is not being overridden in the usual sense, and it must be stated
27775 separately that this implementation is legal. This has always been the case
27776 in GNAT.
27778 RM References:  9.01 (9.2/2)   9.04 (11.1/2)
27779 @end itemize
27781 @geindex AI-0030 (Ada 2012 feature)
27784 @itemize *
27786 @item 
27787 `AI-0030 Requeue on synchronized interfaces (2010-07-19)'
27789 Requeue is permitted to a protected, synchronized or task interface primitive
27790 providing it is known that the overriding operation is an entry. Otherwise
27791 the requeue statement has the same effect as a procedure call. Use of pragma
27792 @code{Implemented} provides a way to impose a static requirement on the
27793 overriding operation by adhering to one of the implementation kinds: entry,
27794 protected procedure or any of the above.
27796 RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
27797 9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
27798 @end itemize
27800 @geindex AI-0201 (Ada 2012 feature)
27803 @itemize *
27805 @item 
27806 `AI-0201 Independence of atomic object components (2010-07-22)'
27808 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
27809 attribute, then individual components may not be addressable by independent
27810 tasks. However, if the representation clause has no effect (is confirming),
27811 then independence is not compromised. Furthermore, in GNAT, specification of
27812 other appropriately addressable component sizes (e.g. 16 for 8-bit
27813 characters) also preserves independence. GNAT now gives very clear warnings
27814 both for the declaration of such a type, and for any assignment to its components.
27816 RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
27817 @end itemize
27819 @geindex AI-0009 (Ada 2012 feature)
27822 @itemize *
27824 @item 
27825 `AI-0009 Pragma Independent[_Components] (2010-07-23)'
27827 This AI introduces the new pragmas @code{Independent} and
27828 @code{Independent_Components},
27829 which control guaranteeing independence of access to objects and components.
27830 The AI also requires independence not unaffected by confirming rep clauses.
27832 RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
27833 C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
27834 @end itemize
27836 @geindex AI-0072 (Ada 2012 feature)
27839 @itemize *
27841 @item 
27842 `AI-0072 Task signalling using ‘Terminated (0000-00-00)'
27844 This AI clarifies that task signalling for reading @code{'Terminated} only
27845 occurs if the result is True. GNAT semantics has always been consistent with
27846 this notion of task signalling.
27848 RM References:  9.10 (6.1/1)
27849 @end itemize
27851 @geindex AI-0108 (Ada 2012 feature)
27854 @itemize *
27856 @item 
27857 `AI-0108 Limited incomplete view and discriminants (0000-00-00)'
27859 This AI confirms that an incomplete type from a limited view does not have
27860 discriminants. This has always been the case in GNAT.
27862 RM References:  10.01.01 (12.3/2)
27863 @end itemize
27865 @geindex AI-0129 (Ada 2012 feature)
27868 @itemize *
27870 @item 
27871 `AI-0129 Limited views and incomplete types (0000-00-00)'
27873 This AI clarifies the description of limited views: a limited view of a
27874 package includes only one view of a type that has an incomplete declaration
27875 and a full declaration (there is no possible ambiguity in a client package).
27876 This AI also fixes an omission: a nested package in the private part has no
27877 limited view. GNAT always implemented this correctly.
27879 RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
27880 @end itemize
27882 @geindex AI-0077 (Ada 2012 feature)
27885 @itemize *
27887 @item 
27888 `AI-0077 Limited withs and scope of declarations (0000-00-00)'
27890 This AI clarifies that a declaration does not include a context clause,
27891 and confirms that it is illegal to have a context in which both a limited
27892 and a nonlimited view of a package are accessible. Such double visibility
27893 was always rejected by GNAT.
27895 RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
27896 @end itemize
27898 @geindex AI-0122 (Ada 2012 feature)
27901 @itemize *
27903 @item 
27904 `AI-0122 Private with and children of generics (0000-00-00)'
27906 This AI clarifies the visibility of private children of generic units within
27907 instantiations of a parent. GNAT has always handled this correctly.
27909 RM References:  10.01.02 (12/2)
27910 @end itemize
27912 @geindex AI-0040 (Ada 2012 feature)
27915 @itemize *
27917 @item 
27918 `AI-0040 Limited with clauses on descendant (0000-00-00)'
27920 This AI confirms that a limited with clause in a child unit cannot name
27921 an ancestor of the unit. This has always been checked in GNAT.
27923 RM References:  10.01.02 (20/2)
27924 @end itemize
27926 @geindex AI-0132 (Ada 2012 feature)
27929 @itemize *
27931 @item 
27932 `AI-0132 Placement of library unit pragmas (0000-00-00)'
27934 This AI fills a gap in the description of library unit pragmas. The pragma
27935 clearly must apply to a library unit, even if it does not carry the name
27936 of the enclosing unit. GNAT has always enforced the required check.
27938 RM References:  10.01.05 (7)
27939 @end itemize
27941 @geindex AI-0034 (Ada 2012 feature)
27944 @itemize *
27946 @item 
27947 `AI-0034 Categorization of limited views (0000-00-00)'
27949 The RM makes certain limited with clauses illegal because of categorization
27950 considerations, when the corresponding normal with would be legal. This is
27951 not intended, and GNAT has always implemented the recommended behavior.
27953 RM References:  10.02.01 (11/1)   10.02.01 (17/2)
27954 @end itemize
27956 @geindex AI-0035 (Ada 2012 feature)
27959 @itemize *
27961 @item 
27962 `AI-0035 Inconsistencies with Pure units (0000-00-00)'
27964 This AI remedies some inconsistencies in the legality rules for Pure units.
27965 Derived access types are legal in a pure unit (on the assumption that the
27966 rule for a zero storage pool size has been enforced on the ancestor type).
27967 The rules are enforced in generic instances and in subunits. GNAT has always
27968 implemented the recommended behavior.
27970 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)
27971 @end itemize
27973 @geindex AI-0219 (Ada 2012 feature)
27976 @itemize *
27978 @item 
27979 `AI-0219 Pure permissions and limited parameters (2010-05-25)'
27981 This AI refines the rules for the cases with limited parameters which do not
27982 allow the implementations to omit ‘redundant’. GNAT now properly conforms
27983 to the requirements of this binding interpretation.
27985 RM References:  10.02.01 (18/2)
27986 @end itemize
27988 @geindex AI-0043 (Ada 2012 feature)
27991 @itemize *
27993 @item 
27994 `AI-0043 Rules about raising exceptions (0000-00-00)'
27996 This AI covers various omissions in the RM regarding the raising of
27997 exceptions. GNAT has always implemented the intended semantics.
27999 RM References:  11.04.01 (10.1/2)   11 (2)
28000 @end itemize
28002 @geindex AI-0200 (Ada 2012 feature)
28005 @itemize *
28007 @item 
28008 `AI-0200 Mismatches in formal package declarations (0000-00-00)'
28010 This AI plugs a gap in the RM which appeared to allow some obviously intended
28011 illegal instantiations. GNAT has never allowed these instantiations.
28013 RM References:  12.07 (16)
28014 @end itemize
28016 @geindex AI-0112 (Ada 2012 feature)
28019 @itemize *
28021 @item 
28022 `AI-0112 Detection of duplicate pragmas (2010-07-24)'
28024 This AI concerns giving names to various representation aspects, but the
28025 practical effect is simply to make the use of duplicate
28026 @code{Atomic[_Components]},
28027 @code{Volatile[_Components]}, and
28028 @code{Independent[_Components]} pragmas illegal, and GNAT
28029 now performs this required check.
28031 RM References:  13.01 (8)
28032 @end itemize
28034 @geindex AI-0106 (Ada 2012 feature)
28037 @itemize *
28039 @item 
28040 `AI-0106 No representation pragmas on generic formals (0000-00-00)'
28042 The RM appeared to allow representation pragmas on generic formal parameters,
28043 but this was not intended, and GNAT has never permitted this usage.
28045 RM References:  13.01 (9.1/1)
28046 @end itemize
28048 @geindex AI-0012 (Ada 2012 feature)
28051 @itemize *
28053 @item 
28054 `AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)'
28056 It is now illegal to give an inappropriate component size or a pragma
28057 @code{Pack} that attempts to change the component size in the case of atomic
28058 or aliased components. Previously GNAT ignored such an attempt with a
28059 warning.
28061 RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
28062 @end itemize
28064 @geindex AI-0039 (Ada 2012 feature)
28067 @itemize *
28069 @item 
28070 `AI-0039 Stream attributes cannot be dynamic (0000-00-00)'
28072 The RM permitted the use of dynamic expressions (such as @code{ptr.all})`
28073 for stream attributes, but these were never useful and are now illegal. GNAT
28074 has always regarded such expressions as illegal.
28076 RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
28077 @end itemize
28079 @geindex AI-0095 (Ada 2012 feature)
28082 @itemize *
28084 @item 
28085 `AI-0095 Address of intrinsic subprograms (0000-00-00)'
28087 The prefix of @code{'Address} cannot statically denote a subprogram with
28088 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
28089 @code{Program_Error} if the prefix denotes a subprogram with convention
28090 @code{Intrinsic}.
28092 RM References:  13.03 (11/1)
28093 @end itemize
28095 @geindex AI-0116 (Ada 2012 feature)
28098 @itemize *
28100 @item 
28101 `AI-0116 Alignment of class-wide objects (0000-00-00)'
28103 This AI requires that the alignment of a class-wide object be no greater
28104 than the alignment of any type in the class. GNAT has always followed this
28105 recommendation.
28107 RM References:  13.03 (29)   13.11 (16)
28108 @end itemize
28110 @geindex AI-0146 (Ada 2012 feature)
28113 @itemize *
28115 @item 
28116 `AI-0146 Type invariants (2009-09-21)'
28118 Type invariants may be specified for private types using the aspect notation.
28119 Aspect @code{Type_Invariant} may be specified for any private type,
28120 @code{Type_Invariant'Class} can
28121 only be specified for tagged types, and is inherited by any descendent of the
28122 tagged types. The invariant is a boolean expression that is tested for being
28123 true in the following situations: conversions to the private type, object
28124 declarations for the private type that are default initialized, and
28125 [`in'] `out'
28126 parameters and returned result on return from any primitive operation for
28127 the type that is visible to a client.
28128 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
28129 @code{Invariant'Class} for @code{Type_Invariant'Class}.
28131 RM References:  13.03.03 (00)
28132 @end itemize
28134 @geindex AI-0078 (Ada 2012 feature)
28137 @itemize *
28139 @item 
28140 `AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)'
28142 In Ada 2012, compilers are required to support unchecked conversion where the
28143 target alignment is a multiple of the source alignment. GNAT always supported
28144 this case (and indeed all cases of differing alignments, doing copies where
28145 required if the alignment was reduced).
28147 RM References:  13.09 (7)
28148 @end itemize
28150 @geindex AI-0195 (Ada 2012 feature)
28153 @itemize *
28155 @item 
28156 `AI-0195 Invalid value handling is implementation defined (2010-07-03)'
28158 The handling of invalid values is now designated to be implementation
28159 defined. This is a documentation change only, requiring Annex M in the GNAT
28160 Reference Manual to document this handling.
28161 In GNAT, checks for invalid values are made
28162 only when necessary to avoid erroneous behavior. Operations like assignments
28163 which cannot cause erroneous behavior ignore the possibility of invalid
28164 values and do not do a check. The date given above applies only to the
28165 documentation change, this behavior has always been implemented by GNAT.
28167 RM References:  13.09.01 (10)
28168 @end itemize
28170 @geindex AI-0193 (Ada 2012 feature)
28173 @itemize *
28175 @item 
28176 `AI-0193 Alignment of allocators (2010-09-16)'
28178 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
28179 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
28180 of size.
28182 RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
28183 13.11.01 (2)   13.11.01 (3)
28184 @end itemize
28186 @geindex AI-0177 (Ada 2012 feature)
28189 @itemize *
28191 @item 
28192 `AI-0177 Parameterized expressions (2010-07-10)'
28194 The new Ada 2012 notion of parameterized expressions is implemented. The form
28197 @example
28198 function-specification is (expression)
28199 @end example
28201 This is exactly equivalent to the
28202 corresponding function body that returns the expression, but it can appear
28203 in a package spec. Note that the expression must be parenthesized.
28205 RM References:  13.11.01 (3/2)
28206 @end itemize
28208 @geindex AI-0033 (Ada 2012 feature)
28211 @itemize *
28213 @item 
28214 `AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)'
28216 Neither of these two pragmas may appear within a generic template, because
28217 the generic might be instantiated at other than the library level.
28219 RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
28220 @end itemize
28222 @geindex AI-0161 (Ada 2012 feature)
28225 @itemize *
28227 @item 
28228 `AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)'
28230 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
28231 of the default stream attributes for elementary types. If this restriction is
28232 in force, then it is necessary to provide explicit subprograms for any
28233 stream attributes used.
28235 RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
28236 @end itemize
28238 @geindex AI-0194 (Ada 2012 feature)
28241 @itemize *
28243 @item 
28244 `AI-0194 Value of Stream_Size attribute (0000-00-00)'
28246 The @code{Stream_Size} attribute returns the default number of bits in the
28247 stream representation of the given type.
28248 This value is not affected by the presence
28249 of stream subprogram attributes for the type. GNAT has always implemented
28250 this interpretation.
28252 RM References:  13.13.02 (1.2/2)
28253 @end itemize
28255 @geindex AI-0109 (Ada 2012 feature)
28258 @itemize *
28260 @item 
28261 `AI-0109 Redundant check in S’Class’Input (0000-00-00)'
28263 This AI is an editorial change only. It removes the need for a tag check
28264 that can never fail.
28266 RM References:  13.13.02 (34/2)
28267 @end itemize
28269 @geindex AI-0007 (Ada 2012 feature)
28272 @itemize *
28274 @item 
28275 `AI-0007 Stream read and private scalar types (0000-00-00)'
28277 The RM as written appeared to limit the possibilities of declaring read
28278 attribute procedures for private scalar types. This limitation was not
28279 intended, and has never been enforced by GNAT.
28281 RM References:  13.13.02 (50/2)   13.13.02 (51/2)
28282 @end itemize
28284 @geindex AI-0065 (Ada 2012 feature)
28287 @itemize *
28289 @item 
28290 `AI-0065 Remote access types and external streaming (0000-00-00)'
28292 This AI clarifies the fact that all remote access types support external
28293 streaming. This fixes an obvious oversight in the definition of the
28294 language, and GNAT always implemented the intended correct rules.
28296 RM References:  13.13.02 (52/2)
28297 @end itemize
28299 @geindex AI-0019 (Ada 2012 feature)
28302 @itemize *
28304 @item 
28305 `AI-0019 Freezing of primitives for tagged types (0000-00-00)'
28307 The RM suggests that primitive subprograms of a specific tagged type are
28308 frozen when the tagged type is frozen. This would be an incompatible change
28309 and is not intended. GNAT has never attempted this kind of freezing and its
28310 behavior is consistent with the recommendation of this AI.
28312 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)
28313 @end itemize
28315 @geindex AI-0017 (Ada 2012 feature)
28318 @itemize *
28320 @item 
28321 `AI-0017 Freezing and incomplete types (0000-00-00)'
28323 So-called ‘Taft-amendment types’ (i.e., types that are completed in package
28324 bodies) are not frozen by the occurrence of bodies in the
28325 enclosing declarative part. GNAT always implemented this properly.
28327 RM References:  13.14 (3/1)
28328 @end itemize
28330 @geindex AI-0060 (Ada 2012 feature)
28333 @itemize *
28335 @item 
28336 `AI-0060 Extended definition of remote access types (0000-00-00)'
28338 This AI extends the definition of remote access types to include access
28339 to limited, synchronized, protected or task class-wide interface types.
28340 GNAT already implemented this extension.
28342 RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
28343 @end itemize
28345 @geindex AI-0114 (Ada 2012 feature)
28348 @itemize *
28350 @item 
28351 `AI-0114 Classification of letters (0000-00-00)'
28353 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
28354 181 (@code{MICRO SIGN}), and
28355 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
28356 lower case letters by Unicode.
28357 However, they are not allowed in identifiers, and they
28358 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
28359 This behavior is consistent with that defined in Ada 95.
28361 RM References:  A.03.02 (59)   A.04.06 (7)
28362 @end itemize
28364 @geindex AI-0185 (Ada 2012 feature)
28367 @itemize *
28369 @item 
28370 `AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)'
28372 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
28373 classification functions for @code{Wide_Character} and
28374 @code{Wide_Wide_Character}, as well as providing
28375 case folding routines for @code{Wide_[Wide_]Character} and
28376 @code{Wide_[Wide_]String}.
28378 RM References:  A.03.05 (0)   A.03.06 (0)
28379 @end itemize
28381 @geindex AI-0031 (Ada 2012 feature)
28384 @itemize *
28386 @item 
28387 `AI-0031 Add From parameter to Find_Token (2010-07-25)'
28389 A new version of @code{Find_Token} is added to all relevant string packages,
28390 with an extra parameter @code{From}. Instead of starting at the first
28391 character of the string, the search for a matching Token starts at the
28392 character indexed by the value of @code{From}.
28393 These procedures are available in all versions of Ada
28394 but if used in versions earlier than Ada 2012 they will generate a warning
28395 that an Ada 2012 subprogram is being used.
28397 RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
28398 A.04.05 (46)
28399 @end itemize
28401 @geindex AI-0056 (Ada 2012 feature)
28404 @itemize *
28406 @item 
28407 `AI-0056 Index on null string returns zero (0000-00-00)'
28409 The wording in the Ada 2005 RM implied an incompatible handling of the
28410 @code{Index} functions, resulting in raising an exception instead of
28411 returning zero in some situations.
28412 This was not intended and has been corrected.
28413 GNAT always returned zero, and is thus consistent with this AI.
28415 RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
28416 @end itemize
28418 @geindex AI-0137 (Ada 2012 feature)
28421 @itemize *
28423 @item 
28424 `AI-0137 String encoding package (2010-03-25)'
28426 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
28427 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
28428 and @code{Wide_Wide_Strings} have been
28429 implemented. These packages (whose documentation can be found in the spec
28430 files @code{a-stuten.ads}, @code{a-suenco.ads}, @code{a-suenst.ads},
28431 @code{a-suewst.ads}, @code{a-suezst.ads}) allow encoding and decoding of
28432 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
28433 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
28434 UTF-16), as well as conversions between the different UTF encodings. With
28435 the exception of @code{Wide_Wide_Strings}, these packages are available in
28436 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
28437 The @code{Wide_Wide_Strings} package
28438 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
28439 mode since it uses @code{Wide_Wide_Character}).
28441 RM References:  A.04.11
28442 @end itemize
28444 @geindex AI-0038 (Ada 2012 feature)
28447 @itemize *
28449 @item 
28450 `AI-0038 Minor errors in Text_IO (0000-00-00)'
28452 These are minor errors in the description on three points. The intent on
28453 all these points has always been clear, and GNAT has always implemented the
28454 correct intended semantics.
28456 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)
28457 @end itemize
28459 @geindex AI-0044 (Ada 2012 feature)
28462 @itemize *
28464 @item 
28465 `AI-0044 Restrictions on container instantiations (0000-00-00)'
28467 This AI places restrictions on allowed instantiations of generic containers.
28468 These restrictions are not checked by the compiler, so there is nothing to
28469 change in the implementation. This affects only the RM documentation.
28471 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)
28472 @end itemize
28474 @geindex AI-0127 (Ada 2012 feature)
28477 @itemize *
28479 @item 
28480 `AI-0127 Adding Locale Capabilities (2010-09-29)'
28482 This package provides an interface for identifying the current locale.
28484 RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
28485 A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
28486 @end itemize
28488 @geindex AI-0002 (Ada 2012 feature)
28491 @itemize *
28493 @item 
28494 `AI-0002 Export C with unconstrained arrays (0000-00-00)'
28496 The compiler is not required to support exporting an Ada subprogram with
28497 convention C if there are parameters or a return type of an unconstrained
28498 array type (such as @code{String}). GNAT allows such declarations but
28499 generates warnings. It is possible, but complicated, to write the
28500 corresponding C code and certainly such code would be specific to GNAT and
28501 non-portable.
28503 RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
28504 @end itemize
28506 @geindex AI05-0216 (Ada 2012 feature)
28509 @itemize *
28511 @item 
28512 `AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)'
28514 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
28515 forbid tasks declared locally within subprograms, or functions returning task
28516 objects, and that is the implementation that GNAT has always provided.
28517 However the language in the RM was not sufficiently clear on this point.
28518 Thus this is a documentation change in the RM only.
28520 RM References:  D.07 (3/3)
28521 @end itemize
28523 @geindex AI-0211 (Ada 2012 feature)
28526 @itemize *
28528 @item 
28529 `AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)'
28531 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
28532 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
28534 RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
28535 @end itemize
28537 @geindex AI-0190 (Ada 2012 feature)
28540 @itemize *
28542 @item 
28543 `AI-0190 pragma Default_Storage_Pool (2010-09-15)'
28545 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
28546 used to control storage pools globally.
28547 In particular, you can force every access
28548 type that is used for allocation (`new') to have an explicit storage pool,
28549 or you can declare a pool globally to be used for all access types that lack
28550 an explicit one.
28552 RM References:  D.07 (8)
28553 @end itemize
28555 @geindex AI-0189 (Ada 2012 feature)
28558 @itemize *
28560 @item 
28561 `AI-0189 No_Allocators_After_Elaboration (2010-01-23)'
28563 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
28564 which says that no dynamic allocation will occur once elaboration is
28565 completed.
28566 In general this requires a run-time check, which is not required, and which
28567 GNAT does not attempt. But the static cases of allocators in a task body or
28568 in the body of the main program are detected and flagged at compile or bind
28569 time.
28571 RM References:  D.07 (19.1/2)   H.04 (23.3/2)
28572 @end itemize
28574 @geindex AI-0171 (Ada 2012 feature)
28577 @itemize *
28579 @item 
28580 `AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)'
28582 A new package @code{System.Multiprocessors} is added, together with the
28583 definition of pragma @code{CPU} for controlling task affinity. A new no
28584 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
28585 is added to the Ravenscar profile.
28587 RM References:  D.13.01 (4/2)   D.16
28588 @end itemize
28590 @geindex AI-0210 (Ada 2012 feature)
28593 @itemize *
28595 @item 
28596 `AI-0210 Correct Timing_Events metric (0000-00-00)'
28598 This is a documentation only issue regarding wording of metric requirements,
28599 that does not affect the implementation of the compiler.
28601 RM References:  D.15 (24/2)
28602 @end itemize
28604 @geindex AI-0206 (Ada 2012 feature)
28607 @itemize *
28609 @item 
28610 `AI-0206 Remote types packages and preelaborate (2010-07-24)'
28612 Remote types packages are now allowed to depend on preelaborated packages.
28613 This was formerly considered illegal.
28615 RM References:  E.02.02 (6)
28616 @end itemize
28618 @geindex AI-0152 (Ada 2012 feature)
28621 @itemize *
28623 @item 
28624 `AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)'
28626 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
28627 where the type of the returned value is an anonymous access type.
28629 RM References:  H.04 (8/1)
28630 @end itemize
28632 @node GNAT language extensions,Security Hardening Features,Implementation of Ada 2012 Features,Top
28633 @anchor{gnat_rm/gnat_language_extensions doc}@anchor{437}@anchor{gnat_rm/gnat_language_extensions gnat-language-extensions}@anchor{438}@anchor{gnat_rm/gnat_language_extensions id1}@anchor{439}
28634 @chapter GNAT language extensions
28637 The GNAT compiler implements a certain number of language extensions on top of
28638 the latest Ada standard, implementing its own extended superset of Ada.
28640 There are two sets of language extensions:
28643 @itemize *
28645 @item 
28646 The first is the curated set. The features in that set are features that we
28647 consider being worthy additions to the Ada language, and that we want to make
28648 available to users early on.
28650 @item 
28651 The second is the experimental set. It includes the first, but also
28652 experimental features, that are here because they’re still in an early
28653 prototyping phase.
28654 @end itemize
28656 @menu
28657 * How to activate the extended GNAT Ada superset:: 
28658 * Curated Extensions:: 
28659 * Experimental Language Extensions:: 
28661 @end menu
28663 @node How to activate the extended GNAT Ada superset,Curated Extensions,,GNAT language extensions
28664 @anchor{gnat_rm/gnat_language_extensions how-to-activate-the-extended-gnat-ada-superset}@anchor{43a}
28665 @section How to activate the extended GNAT Ada superset
28668 There are two ways to activate the extended GNAT Ada superset:
28671 @itemize *
28673 @item 
28674 The @ref{65,,Pragma Extensions_Allowed}. To activate
28675 the curated set of extensions, you should use
28676 @end itemize
28678 @example
28679 pragma Extensions_Allowed (On)
28680 @end example
28682 As a configuration pragma, you can either put it at the beginning of a source
28683 file, or in a @code{.adc} file corresponding to your project.
28686 @itemize *
28688 @item 
28689 The @code{-gnatX} option, that you can pass to the compiler directly, will
28690 activate the curated subset of extensions.
28691 @end itemize
28693 @cartouche
28694 @quotation Attention 
28695 You can activate the extended set of extensions by using either
28696 the @code{-gnatX0} command line flag, or the pragma @code{Extensions_Allowed} with
28697 @code{All} as an argument. However, it is not recommended you use this subset
28698 for serious projects, and is only means as a playground/technology preview.
28699 @end quotation
28700 @end cartouche
28702 @node Curated Extensions,Experimental Language Extensions,How to activate the extended GNAT Ada superset,GNAT language extensions
28703 @anchor{gnat_rm/gnat_language_extensions curated-extensions}@anchor{43b}@anchor{gnat_rm/gnat_language_extensions curated-language-extensions}@anchor{66}
28704 @section Curated Extensions
28707 @menu
28708 * Local Declarations Without Block:: 
28709 * Conditional when constructs:: 
28710 * Case pattern matching:: 
28711 * Fixed lower bounds for array types and subtypes:: 
28712 * Prefixed-view notation for calls to primitive subprograms of untagged types:: 
28713 * Expression defaults for generic formal functions:: 
28714 * String interpolation:: 
28715 * Constrained attribute for generic objects:: 
28716 * Static aspect on intrinsic functions:: 
28718 @end menu
28720 @node Local Declarations Without Block,Conditional when constructs,,Curated Extensions
28721 @anchor{gnat_rm/gnat_language_extensions local-declarations-without-block}@anchor{43c}
28722 @subsection Local Declarations Without Block
28725 A basic_declarative_item may appear at the place of any statement.
28726 This avoids the heavy syntax of block_statements just to declare
28727 something locally.
28729 Link to the original RFC:
28730 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-local-vars-without-block.md}
28731 For example:
28733 @example
28734 if X > 5 then
28735    X := X + 1;
28737    Squared : constant Integer := X**2;
28739    X := X + Squared;
28740 end if;
28741 @end example
28743 @node Conditional when constructs,Case pattern matching,Local Declarations Without Block,Curated Extensions
28744 @anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{43d}
28745 @subsection Conditional when constructs
28748 This feature extends the use of @code{when} as a way to condition a control-flow
28749 related statement, to all control-flow related statements.
28751 To do a conditional return in a procedure the following syntax should be used:
28753 @example
28754 procedure P (Condition : Boolean) is
28755 begin
28756    return when Condition;
28757 end;
28758 @end example
28760 This will return from the procedure if @code{Condition} is true.
28762 When being used in a function the conditional part comes after the return value:
28764 @example
28765 function Is_Null (I : Integer) return Boolean is
28766 begin
28767    return True when I = 0;
28768    return False;
28769 end;
28770 @end example
28772 In a similar way to the @code{exit when} a @code{goto ... when} can be employed:
28774 @example
28775 procedure Low_Level_Optimized is
28776    Flags : Bitmapping;
28777 begin
28778    Do_1 (Flags);
28779    goto Cleanup when Flags (1);
28781    Do_2 (Flags);
28782    goto Cleanup when Flags (32);
28784    --  ...
28786 <<Cleanup>>
28787    --  ...
28788 end;
28789 @end example
28791 @c code-block
28793 To use a conditional raise construct:
28795 @example
28796 procedure Foo is
28797 begin
28798    raise Error when Imported_C_Func /= 0;
28799 end;
28800 @end example
28802 An exception message can also be added:
28804 @example
28805 procedure Foo is
28806 begin
28807    raise Error with "Unix Error"
28808      when Imported_C_Func /= 0;
28809 end;
28810 @end example
28812 Link to the original RFC:
28813 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-conditional-when-constructs.rst}
28815 @node Case pattern matching,Fixed lower bounds for array types and subtypes,Conditional when constructs,Curated Extensions
28816 @anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{43e}
28817 @subsection Case pattern matching
28820 The selector for a case statement (but not yet for a case expression) may be of a composite type, subject to
28821 some restrictions (described below). Aggregate syntax is used for choices
28822 of such a case statement; however, in cases where a “normal” aggregate would
28823 require a discrete value, a discrete subtype may be used instead; box
28824 notation can also be used to match all values.
28826 Consider this example:
28828 @example
28829 type Rec is record
28830    F1, F2 : Integer;
28831 end record;
28833 procedure Caser_1 (X : Rec) is
28834 begin
28835    case X is
28836       when (F1 => Positive, F2 => Positive) =>
28837          Do_This;
28838       when (F1 => Natural, F2 => <>) | (F1 => <>, F2 => Natural) =>
28839          Do_That;
28840       when others =>
28841           Do_The_Other_Thing;
28842    end case;
28843 end Caser_1;
28844 @end example
28846 If @code{Caser_1} is called and both components of X are positive, then
28847 @code{Do_This} will be called; otherwise, if either component is nonnegative
28848 then @code{Do_That} will be called; otherwise, @code{Do_The_Other_Thing} will be
28849 called.
28851 In addition, pattern bindings are supported. This is a mechanism
28852 for binding a name to a component of a matching value for use within
28853 an alternative of a case statement. For a component association
28854 that occurs within a case choice, the expression may be followed by
28855 @code{is <identifier>}. In the special case of a “box” component association,
28856 the identifier may instead be provided within the box. Either of these
28857 indicates that the given identifier denotes (a constant view of) the matching
28858 subcomponent of the case selector.
28860 @cartouche
28861 @quotation Attention 
28862 Binding is not yet supported for arrays or subcomponents
28863 thereof.
28864 @end quotation
28865 @end cartouche
28867 Consider this example (which uses type @code{Rec} from the previous example):
28869 @example
28870 procedure Caser_2 (X : Rec) is
28871 begin
28872    case X is
28873       when (F1 => Positive is Abc, F2 => Positive) =>
28874          Do_This (Abc)
28875       when (F1 => Natural is N1, F2 => <N2>) |
28876            (F1 => <N2>, F2 => Natural is N1) =>
28877          Do_That (Param_1 => N1, Param_2 => N2);
28878       when others =>
28879          Do_The_Other_Thing;
28880    end case;
28881 end Caser_2;
28882 @end example
28884 This example is the same as the previous one with respect to determining
28885 whether @code{Do_This}, @code{Do_That}, or @code{Do_The_Other_Thing} will be called. But
28886 for this version, @code{Do_This} takes a parameter and @code{Do_That} takes two
28887 parameters. If @code{Do_This} is called, the actual parameter in the call will be
28888 @code{X.F1}.
28890 If @code{Do_That} is called, the situation is more complex because there are two
28891 choices for that alternative. If @code{Do_That} is called because the first choice
28892 matched (i.e., because @code{X.F1} is nonnegative and either @code{X.F1} or @code{X.F2}
28893 is zero or negative), then the actual parameters of the call will be (in order)
28894 @code{X.F1} and @code{X.F2}. If @code{Do_That} is called because the second choice
28895 matched (and the first one did not), then the actual parameters will be
28896 reversed.
28898 Within the choice list for single alternative, each choice must define the same
28899 set of bindings and the component subtypes for for a given identifer must all
28900 statically match. Currently, the case of a binding for a nondiscrete component
28901 is not implemented.
28903 If the set of values that match the choice(s) of an earlier alternative
28904 overlaps the corresponding set of a later alternative, then the first set shall
28905 be a proper subset of the second (and the later alternative will not be
28906 executed if the earlier alternative “matches”). All possible values of the
28907 composite type shall be covered. The composite type of the selector shall be an
28908 array or record type that is neither limited nor class-wide. Currently, a “when
28909 others =>” case choice is required; it is intended that this requirement will
28910 be relaxed at some point.
28912 If a subcomponent’s subtype does not meet certain restrictions, then the only
28913 value that can be specified for that subcomponent in a case choice expression
28914 is a “box” component association (which matches all possible values for the
28915 subcomponent). This restriction applies if:
28918 @itemize -
28920 @item 
28921 the component subtype is not a record, array, or discrete type; or
28923 @item 
28924 the component subtype is subject to a non-static constraint or has a
28925 predicate; or:
28927 @item 
28928 the component type is an enumeration type that is subject to an enumeration
28929 representation clause; or
28931 @item 
28932 the component type is a multidimensional array type or an array type with a
28933 nonstatic index subtype.
28934 @end itemize
28936 Support for casing on arrays (and on records that contain arrays) is
28937 currently subject to some restrictions. Non-positional
28938 array aggregates are not supported as (or within) case choices. Likewise
28939 for array type and subtype names. The current implementation exceeds
28940 compile-time capacity limits in some annoyingly common scenarios; the
28941 message generated in such cases is usually “Capacity exceeded in compiling
28942 case statement with composite selector type”.
28944 Link to the original RFC:
28945 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-pattern-matching.rst}
28947 @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
28948 @anchor{gnat_rm/gnat_language_extensions fixed-lower-bounds-for-array-types-and-subtypes}@anchor{43f}
28949 @subsection Fixed lower bounds for array types and subtypes
28952 Unconstrained array types and subtypes can be specified with a lower bound that
28953 is fixed to a certain value, by writing an index range that uses the syntax
28954 @code{<lower-bound-expression> .. <>}. This guarantees that all objects of the
28955 type or subtype will have the specified lower bound.
28957 For example, a matrix type with fixed lower bounds of zero for each dimension
28958 can be declared by the following:
28960 @example
28961 type Matrix is
28962   array (Natural range 0 .. <>, Natural range 0 .. <>) of Integer;
28963 @end example
28965 Objects of type @code{Matrix} declared with an index constraint must have index
28966 ranges starting at zero:
28968 @example
28969 M1 : Matrix (0 .. 9, 0 .. 19);
28970 M2 : Matrix (2 .. 11, 3 .. 22);  -- Warning about bounds; will raise CE
28971 @end example
28973 Similarly, a subtype of @code{String} can be declared that specifies the lower
28974 bound of objects of that subtype to be @code{1}:
28976 @quotation
28978 @example
28979 subtype String_1 is String (1 .. <>);
28980 @end example
28981 @end quotation
28983 If a string slice is passed to a formal of subtype @code{String_1} in a call to a
28984 subprogram @code{S}, the slice’s bounds will “slide” so that the lower bound is
28985 @code{1}.
28987 Within @code{S}, the lower bound of the formal is known to be @code{1}, so, unlike a
28988 normal unconstrained @code{String} formal, there is no need to worry about
28989 accounting for other possible lower-bound values. Sliding of bounds also occurs
28990 in other contexts, such as for object declarations with an unconstrained
28991 subtype with fixed lower bound, as well as in subtype conversions.
28993 Use of this feature increases safety by simplifying code, and can also improve
28994 the efficiency of indexing operations, since the compiler statically knows the
28995 lower bound of unconstrained array formals when the formal’s subtype has index
28996 ranges with static fixed lower bounds.
28998 Link to the original RFC:
28999 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-fixed-lower-bound.rst}
29001 @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
29002 @anchor{gnat_rm/gnat_language_extensions prefixed-view-notation-for-calls-to-primitive-subprograms-of-untagged-types}@anchor{440}
29003 @subsection Prefixed-view notation for calls to primitive subprograms of untagged types
29006 When operating on an untagged type, if it has any primitive operations, and the
29007 first parameter of an operation is of the type (or is an access parameter with
29008 an anonymous type that designates the type), you may invoke these operations
29009 using an @code{object.op(...)} notation, where the parameter that would normally be
29010 the first parameter is brought out front, and the remaining parameters (if any)
29011 appear within parentheses after the name of the primitive operation.
29013 This same notation is already available for tagged types. This extension allows
29014 for untagged types. It is allowed for all primitive operations of the type
29015 independent of whether they were originally declared in a package spec or its
29016 private part, or were inherited and/or overridden as part of a derived type
29017 declaration occuring anywhere, so long as the first parameter is of the type,
29018 or an access parameter designating the type.
29020 For example:
29022 @example
29023 generic
29024    type Elem_Type is private;
29025 package Vectors is
29026     type Vector is private;
29027     procedure Add_Element (V : in out Vector; Elem : Elem_Type);
29028     function Nth_Element (V : Vector; N : Positive) return Elem_Type;
29029     function Length (V : Vector) return Natural;
29030 private
29031     function Capacity (V : Vector) return Natural;
29032        --  Return number of elements that may be added without causing
29033        --  any new allocation of space
29035     type Vector is ...
29036       with Type_Invariant => Vector.Length <= Vector.Capacity;
29037     ...
29038 end Vectors;
29040 package Int_Vecs is new Vectors(Integer);
29042 V : Int_Vecs.Vector;
29044 V.Add_Element(42);
29045 V.Add_Element(-33);
29047 pragma Assert (V.Length = 2);
29048 pragma Assert (V.Nth_Element(1) = 42);
29049 @end example
29051 Link to the original RFC:
29052 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-prefixed-untagged.rst}
29054 @node Expression defaults for generic formal functions,String interpolation,Prefixed-view notation for calls to primitive subprograms of untagged types,Curated Extensions
29055 @anchor{gnat_rm/gnat_language_extensions expression-defaults-for-generic-formal-functions}@anchor{441}
29056 @subsection Expression defaults for generic formal functions
29059 The declaration of a generic formal function is allowed to specify
29060 an expression as a default, using the syntax of an expression function.
29062 Here is an example of this feature:
29064 @example
29065 generic
29066    type T is private;
29067    with function Copy (Item : T) return T is (Item); -- Defaults to Item
29068 package Stacks is
29070    type Stack is limited private;
29072    procedure Push (S : in out Stack; X : T); -- Calls Copy on X
29073    function Pop (S : in out Stack) return T; -- Calls Copy to return item
29075 private
29076    -- ...
29077 end Stacks;
29078 @end example
29080 Link to the original RFC:
29081 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-expression-functions-as-default-for-generic-formal-function-parameters.rst}
29083 @node String interpolation,Constrained attribute for generic objects,Expression defaults for generic formal functions,Curated Extensions
29084 @anchor{gnat_rm/gnat_language_extensions string-interpolation}@anchor{442}
29085 @subsection String interpolation
29088 The syntax for string literals is extended to support string interpolation.
29090 Within an interpolated string literal, an arbitrary expression, when
29091 enclosed in @code{@{ ... @}}, is expanded at run time into the result of calling
29092 @code{'Image} on the result of evaluating the expression enclosed by the brace
29093 characters, unless it is already a string or a single character.
29095 Here is an example of this feature where the expressions @code{Name} and @code{X + Y}
29096 will be evaluated and included in the string.
29098 @example
29099 procedure Test_Interpolation is
29100    X    : Integer := 12;
29101    Y    : Integer := 15;
29102    Name : String := "Leo";
29103 begin
29104    Put_Line (f"The name is @{Name@} and the sum is @{X + Y@}.");
29105 end Test_Interpolation;
29106 @end example
29108 In addition, an escape character (@code{\}) is provided for inserting certain
29109 standard control characters (such as @code{\t} for tabulation or @code{\n} for
29110 newline) or to escape characters with special significance to the
29111 interpolated string syntax, namely @code{"}, @code{@{}, @code{@}},and @code{\} itself.
29114 @multitable {xxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx} 
29115 @item
29117 escaped_character
29119 @tab
29121 meaning
29123 @item
29125 @code{\a}
29127 @tab
29129 ALERT
29131 @item
29133 @code{\b}
29135 @tab
29137 BACKSPACE
29139 @item
29141 @code{\f}
29143 @tab
29145 FORM FEED
29147 @item
29149 @code{\n}
29151 @tab
29153 LINE FEED
29155 @item
29157 @code{\r}
29159 @tab
29161 CARRIAGE RETURN
29163 @item
29165 @code{\t}
29167 @tab
29169 CHARACTER TABULATION
29171 @item
29173 @code{\v}
29175 @tab
29177 LINE TABULATION
29179 @item
29181 @code{\0}
29183 @tab
29187 @item
29189 @code{\\}
29191 @tab
29193 @code{\}
29195 @item
29197 @code{\"}
29199 @tab
29201 @code{"}
29203 @item
29205 @code{\@{}
29207 @tab
29209 @code{@{}
29211 @item
29213 @code{\@}}
29215 @tab
29217 @code{@}}
29219 @end multitable
29222 Note that, unlike normal string literals, doubled characters have no
29223 special significance. So to include a double-quote or a brace character
29224 in an interpolated string, they must be preceded by a @code{\}.
29225 For example:
29227 @example
29228 Put_Line
29229   (f"X = @{X@} and Y = @{Y@} and X+Y = @{X+Y@};\n" &
29230    f" a double quote is \" and" &
29231    f" an open brace is \@{");
29232 @end example
29234 Finally, a syntax is provided for creating multi-line string literals,
29235 without having to explicitly use an escape sequence such as @code{\n}. For
29236 example:
29238 @example
29239 Put_Line
29240   (f"This is a multi-line"
29241     "string literal"
29242     "There is no ambiguity about how many"
29243     "spaces are included in each line");
29244 @end example
29246 Here is a link to the original RFC   :
29247 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst}
29249 @node Constrained attribute for generic objects,Static aspect on intrinsic functions,String interpolation,Curated Extensions
29250 @anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{443}
29251 @subsection Constrained attribute for generic objects
29254 The @code{Constrained} attribute is permitted for objects of generic types. The
29255 result indicates whether the corresponding actual is constrained.
29257 @node Static aspect on intrinsic functions,,Constrained attribute for generic objects,Curated Extensions
29258 @anchor{gnat_rm/gnat_language_extensions static-aspect-on-intrinsic-functions}@anchor{444}
29259 @subsection @code{Static} aspect on intrinsic functions
29262 The Ada 202x @code{Static} aspect can be specified on Intrinsic imported functions
29263 and the compiler will evaluate some of these intrinsics statically, in
29264 particular the @code{Shift_Left} and @code{Shift_Right} intrinsics.
29266 @node Experimental Language Extensions,,Curated Extensions,GNAT language extensions
29267 @anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{67}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{445}
29268 @section Experimental Language Extensions
29271 @menu
29272 * Pragma Storage_Model:: 
29273 * Simpler accessibility model:: 
29275 @end menu
29277 @node Pragma Storage_Model,Simpler accessibility model,,Experimental Language Extensions
29278 @anchor{gnat_rm/gnat_language_extensions pragma-storage-model}@anchor{446}
29279 @subsection Pragma Storage_Model
29282 This feature proposes to redesign the concepts of Storage Pools into a more
29283 efficient model allowing higher performances and easier integration with low
29284 footprint embedded run-times.
29286 It also extends it to support distributed memory models, in particular to
29287 support interactions with GPU.
29289 Here is a link to the full RFC:
29290 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-storage-model.rst}
29292 @node Simpler accessibility model,,Pragma Storage_Model,Experimental Language Extensions
29293 @anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{447}
29294 @subsection Simpler accessibility model
29297 The goal of this feature is to restore a common understanding of accessibility
29298 rules for implementers and users alike. The new rules should both be effective
29299 at preventing errors and feel natural and compatible in an Ada environment
29300 while removing dynamic accessibility checking.
29302 Here is a link to the full RFC:
29303 @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-simpler-accessibility.md}
29305 @node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top
29306 @anchor{gnat_rm/security_hardening_features doc}@anchor{448}@anchor{gnat_rm/security_hardening_features id1}@anchor{449}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15}
29307 @chapter Security Hardening Features
29310 This chapter describes Ada extensions aimed at security hardening that
29311 are provided by GNAT.
29313 The features in this chapter are currently experimental and subject to
29314 change.
29316 @c Register Scrubbing:
29318 @menu
29319 * Register Scrubbing:: 
29320 * Stack Scrubbing:: 
29321 * Hardened Conditionals:: 
29322 * Hardened Booleans:: 
29323 * Control Flow Redundancy:: 
29325 @end menu
29327 @node Register Scrubbing,Stack Scrubbing,,Security Hardening Features
29328 @anchor{gnat_rm/security_hardening_features register-scrubbing}@anchor{44a}
29329 @section Register Scrubbing
29332 GNAT can generate code to zero-out hardware registers before returning
29333 from a subprogram.
29335 It can be enabled with the @code{-fzero-call-used-regs=`choice'}
29336 command-line option, to affect all subprograms in a compilation, and
29337 with a @code{Machine_Attribute} pragma, to affect only specific
29338 subprograms.
29340 @example
29341 procedure Foo;
29342 pragma Machine_Attribute (Foo, "zero_call_used_regs", "used");
29343 --  Before returning, Foo scrubs only call-clobbered registers
29344 --  that it uses itself.
29346 function Bar return Integer;
29347 pragma Machine_Attribute (Bar, "zero_call_used_regs", "all");
29348 --  Before returning, Bar scrubs all call-clobbered registers.
29350 function Baz return Integer;
29351 pragma Machine_Attribute (Bar, "zero_call_used_regs", "leafy");
29352 --  Before returning, Bar scrubs call-clobbered registers, either
29353 --  those it uses itself, if it can be identified as a leaf
29354 --  function, or all of them otherwise.
29355 @end example
29357 For usage and more details on the command-line option, on the
29358 @code{zero_call_used_regs} attribute, and on their use with other
29359 programming languages, see @cite{Using the GNU Compiler Collection (GCC)}.
29361 @c Stack Scrubbing:
29363 @node Stack Scrubbing,Hardened Conditionals,Register Scrubbing,Security Hardening Features
29364 @anchor{gnat_rm/security_hardening_features stack-scrubbing}@anchor{44b}
29365 @section Stack Scrubbing
29368 GNAT can generate code to zero-out stack frames used by subprograms.
29370 It can be activated with the @code{Machine_Attribute} pragma, on
29371 specific subprograms and variables, or their types.  (This attribute
29372 always applies to a type, even when it is associated with a subprogram
29373 or a variable.)
29375 @example
29376 function Foo returns Integer;
29377 pragma Machine_Attribute (Foo, "strub");
29378 --  Foo and its callers are modified so as to scrub the stack
29379 --  space used by Foo after it returns.  Shorthand for:
29380 --  pragma Machine_Attribute (Foo, "strub", "at-calls");
29382 procedure Bar;
29383 pragma Machine_Attribute (Bar, "strub", "internal");
29384 --  Bar is turned into a wrapper for its original body,
29385 --  and they scrub the stack used by the original body.
29387 Var : Integer;
29388 pragma Machine_Attribute (Var, "strub");
29389 --  Reading from Var in a subprogram enables stack scrubbing
29390 --  of the stack space used by the subprogram.  Furthermore, if
29391 --  Var is declared within a subprogram, this also enables
29392 --  scrubbing of the stack space used by that subprogram.
29393 @end example
29395 Given these declarations, Foo has its type and body modified as
29396 follows:
29398 @example
29399 function Foo (<WaterMark> : in out System.Address) returns Integer
29401   --  ...
29402 begin
29403   <__strub_update> (<WaterMark>);  --  Updates the stack WaterMark.
29404   --  ...
29405 end;
29406 @end example
29408 whereas its callers are modified from:
29410 @example
29411 X := Foo;
29412 @end example
29416 @example
29417 declare
29418   <WaterMark> : System.Address;
29419 begin
29420   <__strub_enter> (<WaterMark>);  -- Initialize <WaterMark>.
29421   X := Foo (<WaterMark>);
29422   <__strub_leave> (<WaterMark>);  -- Scrubs stack up to <WaterMark>.
29423 end;
29424 @end example
29426 As for Bar, because it is strubbed in internal mode, its callers are
29427 not modified.  Its definition is modified roughly as follows:
29429 @example
29430 procedure Bar is
29431   <WaterMark> : System.Address;
29432   procedure Strubbed_Bar (<WaterMark> : in out System.Address) is
29433   begin
29434     <__strub_update> (<WaterMark>);  --  Updates the stack WaterMark.
29435     -- original Bar body.
29436   end Strubbed_Bar;
29437 begin
29438   <__strub_enter> (<WaterMark>);  -- Initialize <WaterMark>.
29439   Strubbed_Bar (<WaterMark>);
29440   <__strub_leave> (<WaterMark>);  -- Scrubs stack up to <WaterMark>.
29441 end Bar;
29442 @end example
29444 There are also @code{-fstrub=`choice'} command-line options to
29445 control default settings.  For usage and more details on the
29446 command-line options, on the @code{strub} attribute, and their use with
29447 other programming languages, see @cite{Using the GNU Compiler Collection (GCC)}.
29449 Note that Ada secondary stacks are not scrubbed.  The restriction
29450 @code{No_Secondary_Stack} avoids their use, and thus their accidental
29451 preservation of data that should be scrubbed.
29453 Attributes @code{Access} and @code{Unconstrained_Access} of variables and
29454 constants with @code{strub} enabled require types with @code{strub} enabled;
29455 there is no way to express an access-to-strub type otherwise.
29456 @code{Unchecked_Access} bypasses this constraint, but the resulting
29457 access type designates a non-strub type.
29459 @example
29460 VI : aliased Integer;
29461 pragma Machine_Attribute (VI, "strub");
29462 XsVI : access Integer := VI'Access; -- Error.
29463 UXsVI : access Integer := VI'Unchecked_Access; -- OK,
29464 --  UXsVI does *not* enable strub in subprograms that
29465 --  dereference it to obtain the UXsVI.all value.
29467 type Strub_Int is new Integer;
29468 pragma Machine_Attribute (Strub_Int, "strub");
29469 VSI : aliased Strub_Int;
29470 XsVSI : access Strub_Int := VSI'Access; -- OK,
29471 --  VSI and XsVSI.all both enable strub in subprograms that
29472 --  read their values.
29473 @end example
29475 Every access-to-subprogram type, renaming, and overriding and
29476 overridden dispatching operations that may refer to a subprogram with
29477 an attribute-modified interface must be annotated with the same
29478 interface-modifying attribute.  Access-to-subprogram types can be
29479 explicitly converted to different strub modes, as long as they are
29480 interface-compatible (i.e., adding or removing @code{at-calls} is not
29481 allowed).  For example, a @code{strub}-@code{disabled} subprogram can be
29482 turned @code{callable} through such an explicit conversion:
29484 @example
29485 type TBar is access procedure;
29487 type TBar_Callable is access procedure;
29488 pragma Machine_Attribute (TBar_Callable, "strub", "callable");
29489 --  The attribute modifies the procedure type, rather than the
29490 --  access type, because of the extra argument after "strub",
29491 --  only applicable to subprogram types.
29493 Bar_Callable_Ptr : constant TBar_Callable
29494            := TBar_Callable (TBar'(Bar'Access));
29496 procedure Bar_Callable renames Bar_Callable_Ptr.all;
29497 pragma Machine_Attribute (Bar_Callable, "strub", "callable");
29498 @end example
29500 Note that the renaming declaration is expanded to a full subprogram
29501 body, it won’t be just an alias.  Only if it is inlined will it be as
29502 efficient as a call by dereferencing the access-to-subprogram constant
29503 Bar_Callable_Ptr.
29505 @c Hardened Conditionals:
29507 @node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features
29508 @anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{44c}
29509 @section Hardened Conditionals
29512 GNAT can harden conditionals to protect against control-flow attacks.
29514 This is accomplished by two complementary transformations, each
29515 activated by a separate command-line option.
29517 The option @code{-fharden-compares} enables hardening of compares
29518 that compute results stored in variables, adding verification that the
29519 reversed compare yields the opposite result, turning:
29521 @example
29522 B := X = Y;
29523 @end example
29525 into:
29527 @example
29528 B := X = Y;
29529 declare
29530   NotB : Boolean := X /= Y; -- Computed independently of B.
29531 begin
29532   if B = NotB then
29533     <__builtin_trap>;
29534   end if;
29535 end;
29536 @end example
29538 The option @code{-fharden-conditional-branches} enables hardening
29539 of compares that guard conditional branches, adding verification of
29540 the reversed compare to both execution paths, turning:
29542 @example
29543 if X = Y then
29544   X := Z + 1;
29545 else
29546   Y := Z - 1;
29547 end if;
29548 @end example
29550 into:
29552 @example
29553 if X = Y then
29554   if X /= Y then -- Computed independently of X = Y.
29555     <__builtin_trap>;
29556   end if;
29557   X := Z + 1;
29558 else
29559   if X /= Y then -- Computed independently of X = Y.
29560     null;
29561   else
29562     <__builtin_trap>;
29563   end if;
29564   Y := Z - 1;
29565 end if;
29566 @end example
29568 These transformations are introduced late in the compilation pipeline,
29569 long after boolean expressions are decomposed into separate compares,
29570 each one turned into either a conditional branch or a compare whose
29571 result is stored in a boolean variable or temporary.  Compiler
29572 optimizations, if enabled, may also turn conditional branches into
29573 stored compares, and vice-versa, or into operations with implied
29574 conditionals (e.g. MIN and MAX).  Conditionals may also be optimized
29575 out entirely, if their value can be determined at compile time, and
29576 occasionally multiple compares can be combined into one.
29578 It is thus difficult to predict which of these two options will affect
29579 a specific compare operation expressed in source code.  Using both
29580 options ensures that every compare that is neither optimized out nor
29581 optimized into implied conditionals will be hardened.
29583 The addition of reversed compares can be observed by enabling the dump
29584 files of the corresponding passes, through command-line options
29585 @code{-fdump-tree-hardcmp} and @code{-fdump-tree-hardcbr},
29586 respectively.
29588 They are separate options, however, because of the significantly
29589 different performance impact of the hardening transformations.
29591 For usage and more details on the command-line options, see
29592 @cite{Using the GNU Compiler Collection (GCC)}.  These options can
29593 be used with other programming languages supported by GCC.
29595 @c Hardened Booleans:
29597 @node Hardened Booleans,Control Flow Redundancy,Hardened Conditionals,Security Hardening Features
29598 @anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{44d}
29599 @section Hardened Booleans
29602 Ada has built-in support for introducing boolean types with
29603 alternative representations, using representation clauses:
29605 @example
29606 type HBool is new Boolean;
29607 for HBool use (16#5a#, 16#a5#);
29608 for HBool'Size use 8;
29609 @end example
29611 When validity checking is enabled, the compiler will check that
29612 variables of such types hold values corresponding to the selected
29613 representations.
29615 There are multiple strategies for where to introduce validity checking
29616 (see @code{-gnatV} options).  Their goal is to guard against
29617 various kinds of programming errors, and GNAT strives to omit checks
29618 when program logic rules out an invalid value, and optimizers may
29619 further remove checks found to be redundant.
29621 For additional hardening, the @code{hardbool} @code{Machine_Attribute}
29622 pragma can be used to annotate boolean types with representation
29623 clauses, so that expressions of such types used as conditions are
29624 checked even when compiling with @code{-gnatVT}:
29626 @example
29627 pragma Machine_Attribute (HBool, "hardbool");
29629 function To_Boolean (X : HBool) returns Boolean is (Boolean (X));
29630 @end example
29632 is compiled roughly like:
29634 @example
29635 function To_Boolean (X : HBool) returns Boolean is
29636 begin
29637   if X not in True | False then
29638     raise Constraint_Error;
29639   elsif X in True then
29640     return True;
29641   else
29642     return False;
29643   end if;
29644 end To_Boolean;
29645 @end example
29647 Note that @code{-gnatVn} will disable even @code{hardbool} testing.
29649 Analogous behavior is available as a GCC extension to the C and
29650 Objective C programming languages, through the @code{hardbool} attribute,
29651 with the difference that, instead of raising a Constraint_Error
29652 exception, when a hardened boolean variable is found to hold a value
29653 that stands for neither True nor False, the program traps.  For usage
29654 and more details on that attribute, see @cite{Using the GNU Compiler Collection (GCC)}.
29656 @c Control Flow Redundancy:
29658 @node Control Flow Redundancy,,Hardened Booleans,Security Hardening Features
29659 @anchor{gnat_rm/security_hardening_features control-flow-redundancy}@anchor{44e}
29660 @section Control Flow Redundancy
29663 GNAT can guard against unexpected execution flows, such as branching
29664 into the middle of subprograms, as in Return Oriented Programming
29665 exploits.
29667 In units compiled with @code{-fharden-control-flow-redundancy},
29668 subprograms are instrumented so that, every time they are called,
29669 basic blocks take note as control flows through them, and, before
29670 returning, subprograms verify that the taken notes are consistent with
29671 the control-flow graph.
29673 The performance impact of verification on leaf subprograms can be much
29674 higher, while the averted risks are much lower on them.
29675 Instrumentation can be disabled for leaf subprograms with
29676 @code{-fhardcfr-skip-leaf}.
29678 Functions with too many basic blocks, or with multiple return points,
29679 call a run-time function to perform the verification.  Other functions
29680 perform the verification inline before returning.
29682 Optimizing the inlined verification can be quite time consuming, so
29683 the default upper limit for the inline mode is set at 16 blocks.
29684 Command-line option @code{--param hardcfr-max-inline-blocks=} can
29685 override it.
29687 Even though typically sparse control-flow graphs exhibit run-time
29688 verification time nearly proportional to the block count of a
29689 subprogram, it may become very significant for generated subprograms
29690 with thousands of blocks.  Command-line option
29691 @code{--param hardcfr-max-blocks=} can set an upper limit for
29692 instrumentation.
29694 For each block that is marked as visited, the mechanism checks that at
29695 least one of its predecessors, and at least one of its successors, are
29696 also marked as visited.
29698 Verification is performed just before a subprogram returns.  The
29699 following fragment:
29701 @example
29702 if X then
29703   Y := F (Z);
29704   return;
29705 end if;
29706 @end example
29708 gets turned into:
29710 @example
29711 type Visited_Bitmap is array (1..N) of Boolean with Pack;
29712 Visited : aliased Visited_Bitmap := (others => False);
29713 --  Bitmap of visited blocks.  N is the basic block count.
29714 [...]
29715 --  Basic block #I
29716 Visited(I) := True;
29717 if X then
29718   --  Basic block #J
29719   Visited(J) := True;
29720   Y := F (Z);
29721   CFR.Check (N, Visited'Access, CFG'Access);
29722   --  CFR is a hypothetical package whose Check procedure calls
29723   --  libgcc's __hardcfr_check, that traps if the Visited bitmap
29724   --  does not hold a valid path in CFG, the run-time
29725   --  representation of the control flow graph in the enclosing
29726   --  subprogram.
29727   return;
29728 end if;
29729 --  Basic block #K
29730 Visited(K) := True;
29731 @end example
29733 Verification would also be performed before tail calls, if any
29734 front-ends marked them as mandatory or desirable, but none do.
29735 Regular calls are optimized into tail calls too late for this
29736 transformation to act on it.
29738 In order to avoid adding verification after potential tail calls,
29739 which would prevent tail-call optimization, we recognize returning
29740 calls, i.e., calls whose result, if any, is returned by the calling
29741 subprogram to its caller immediately after the call returns.
29742 Verification is performed before such calls, whether or not they are
29743 ultimately optimized to tail calls.  This behavior is enabled by
29744 default whenever sibcall optimization is enabled (see
29745 @code{-foptimize-sibling-calls}); it may be disabled with
29746 @code{-fno-hardcfr-check-returning-calls}, or enabled with
29747 @code{-fhardcfr-check-returning-calls}, regardless of the
29748 optimization, but the lack of other optimizations may prevent calls
29749 from being recognized as returning calls:
29751 @example
29752 --  CFR.Check here, with -fhardcfr-check-returning-calls.
29753 P (X);
29754 --  CFR.Check here, with -fno-hardcfr-check-returning-calls.
29755 return;
29756 @end example
29760 @example
29761 --  CFR.Check here, with -fhardcfr-check-returning-calls.
29762 R := F (X);
29763 --  CFR.Check here, with -fno-hardcfr-check-returning-calls.
29764 return R;
29765 @end example
29767 Any subprogram from which an exception may escape, i.e., that may
29768 raise or propagate an exception that isn’t handled internally, is
29769 conceptually enclosed by a cleanup handler that performs verification,
29770 unless this is disabled with @code{-fno-hardcfr-check-exceptions}.
29771 With this feature enabled, a subprogram body containing:
29773 @example
29774 --  ...
29775   Y := F (X);  -- May raise exceptions.
29776 --  ...
29777   raise E;  -- Not handled internally.
29778 --  ...
29779 @end example
29781 gets modified as follows:
29783 @example
29784 begin
29785   --  ...
29786     Y := F (X);  -- May raise exceptions.
29787   --  ...
29788     raise E;  -- Not handled internally.
29789   --  ...
29790 exception
29791   when others =>
29792     CFR.Check (N, Visited'Access, CFG'Access);
29793     raise;
29794 end;
29795 @end example
29797 Verification may also be performed before No_Return calls, whether all
29798 of them, with @code{-fhardcfr-check-noreturn-calls=always}; all but
29799 internal subprograms involved in exception-raising or -reraising or
29800 subprograms explicitly marked with both @code{No_Return} and
29801 @code{Machine_Attribute} @code{expected_throw} pragmas, with
29802 @code{-fhardcfr-check-noreturn-calls=no-xthrow} (default); only
29803 nothrow ones, with @code{-fhardcfr-check-noreturn-calls=nothrow};
29804 or none, with @code{-fhardcfr-check-noreturn-calls=never}.
29806 When a No_Return call returns control to its caller through an
29807 exception, verification may have already been performed before the
29808 call, if @code{-fhardcfr-check-noreturn-calls=always} or
29809 @code{-fhardcfr-check-noreturn-calls=no-xthrow} is in effect.  The
29810 compiler arranges for already-checked No_Return calls without a
29811 preexisting handler to bypass the implicitly-added cleanup handler and
29812 thus the redundant check, but a local exception or cleanup handler, if
29813 present, will modify the set of visited blocks, and checking will take
29814 place again when the caller reaches the next verification point,
29815 whether it is a return or reraise statement after the exception is
29816 otherwise handled, or even another No_Return call.
29818 The instrumentation for hardening with control flow redundancy can be
29819 observed in dump files generated by the command-line option
29820 @code{-fdump-tree-hardcfr}.
29822 For more details on the control flow redundancy command-line options,
29823 see @cite{Using the GNU Compiler Collection (GCC)}.  These options
29824 can be used with other programming languages supported by GCC.
29826 @node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top
29827 @anchor{gnat_rm/obsolescent_features doc}@anchor{44f}@anchor{gnat_rm/obsolescent_features id1}@anchor{450}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
29828 @chapter Obsolescent Features
29831 This chapter describes features that are provided by GNAT, but are
29832 considered obsolescent since there are preferred ways of achieving
29833 the same effect. These features are provided solely for historical
29834 compatibility purposes.
29836 @menu
29837 * pragma No_Run_Time:: 
29838 * pragma Ravenscar:: 
29839 * pragma Restricted_Run_Time:: 
29840 * pragma Task_Info:: 
29841 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads. 
29843 @end menu
29845 @node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
29846 @anchor{gnat_rm/obsolescent_features id2}@anchor{451}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{452}
29847 @section pragma No_Run_Time
29850 The pragma @code{No_Run_Time} is used to achieve an affect similar
29851 to the use of the “Zero Foot Print” configurable run time, but without
29852 requiring a specially configured run time. The result of using this
29853 pragma, which must be used for all units in a partition, is to restrict
29854 the use of any language features requiring run-time support code. The
29855 preferred usage is to use an appropriately configured run-time that
29856 includes just those features that are to be made accessible.
29858 @node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
29859 @anchor{gnat_rm/obsolescent_features id3}@anchor{453}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{454}
29860 @section pragma Ravenscar
29863 The pragma @code{Ravenscar} has exactly the same effect as pragma
29864 @code{Profile (Ravenscar)}. The latter usage is preferred since it
29865 is part of the new Ada 2005 standard.
29867 @node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
29868 @anchor{gnat_rm/obsolescent_features id4}@anchor{455}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{456}
29869 @section pragma Restricted_Run_Time
29872 The pragma @code{Restricted_Run_Time} has exactly the same effect as
29873 pragma @code{Profile (Restricted)}. The latter usage is
29874 preferred since the Ada 2005 pragma @code{Profile} is intended for
29875 this kind of implementation dependent addition.
29877 @node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
29878 @anchor{gnat_rm/obsolescent_features id5}@anchor{457}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{458}
29879 @section pragma Task_Info
29882 The functionality provided by pragma @code{Task_Info} is now part of the
29883 Ada language. The @code{CPU} aspect and the package
29884 @code{System.Multiprocessors} offer a less system-dependent way to specify
29885 task affinity or to query the number of processors.
29887 Syntax
29889 @example
29890 pragma Task_Info (EXPRESSION);
29891 @end example
29893 This pragma appears within a task definition (like pragma
29894 @code{Priority}) and applies to the task in which it appears.  The
29895 argument must be of type @code{System.Task_Info.Task_Info_Type}.
29896 The @code{Task_Info} pragma provides system dependent control over
29897 aspects of tasking implementation, for example, the ability to map
29898 tasks to specific processors.  For details on the facilities available
29899 for the version of GNAT that you are using, see the documentation
29900 in the spec of package System.Task_Info in the runtime
29901 library.
29903 @node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
29904 @anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{459}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{45a}
29905 @section package System.Task_Info (@code{s-tasinf.ads})
29908 This package provides target dependent functionality that is used
29909 to support the @code{Task_Info} pragma. The predefined Ada package
29910 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
29911 standard replacement for GNAT’s @code{Task_Info} functionality.
29913 @node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
29914 @anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{45b}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{45c}
29915 @chapter Compatibility and Porting Guide
29918 This chapter presents some guidelines for developing portable Ada code,
29919 describes the compatibility issues that may arise between
29920 GNAT and other Ada compilation systems (including those for Ada 83),
29921 and shows how GNAT can expedite porting
29922 applications developed in other Ada environments.
29924 @menu
29925 * Writing Portable Fixed-Point Declarations:: 
29926 * Compatibility with Ada 83:: 
29927 * Compatibility between Ada 95 and Ada 2005:: 
29928 * Implementation-dependent characteristics:: 
29929 * Compatibility with Other Ada Systems:: 
29930 * Representation Clauses:: 
29931 * Compatibility with HP Ada 83:: 
29933 @end menu
29935 @node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
29936 @anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{45d}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{45e}
29937 @section Writing Portable Fixed-Point Declarations
29940 The Ada Reference Manual gives an implementation freedom to choose bounds
29941 that are narrower by @code{Small} from the given bounds.
29942 For example, if we write
29944 @example
29945 type F1 is delta 1.0 range -128.0 .. +128.0;
29946 @end example
29948 then the implementation is allowed to choose -128.0 .. +127.0 if it
29949 likes, but is not required to do so.
29951 This leads to possible portability problems, so let’s have a closer
29952 look at this, and figure out how to avoid these problems.
29954 First, why does this freedom exist, and why would an implementation
29955 take advantage of it? To answer this, take a closer look at the type
29956 declaration for @code{F1} above. If the compiler uses the given bounds,
29957 it would need 9 bits to hold the largest positive value (and typically
29958 that means 16 bits on all machines). But if the implementation chooses
29959 the +127.0 bound then it can fit values of the type in 8 bits.
29961 Why not make the user write +127.0 if that’s what is wanted?
29962 The rationale is that if you are thinking of fixed point
29963 as a kind of ‘poor man’s floating-point’, then you don’t want
29964 to be thinking about the scaled integers that are used in its
29965 representation. Let’s take another example:
29967 @example
29968 type F2 is delta 2.0**(-15) range -1.0 .. +1.0;
29969 @end example
29971 Looking at this declaration, it seems casually as though
29972 it should fit in 16 bits, but again that extra positive value
29973 +1.0 has the scaled integer equivalent of 2**15 which is one too
29974 big for signed 16 bits. The implementation can treat this as:
29976 @example
29977 type F2 is delta 2.0**(-15) range -1.0 .. +1.0-(2.0**(-15));
29978 @end example
29980 and the Ada language design team felt that this was too annoying
29981 to require. We don’t need to debate this decision at this point,
29982 since it is well established (the rule about narrowing the ranges
29983 dates to Ada 83).
29985 But the important point is that an implementation is not required
29986 to do this narrowing, so we have a potential portability problem.
29987 We could imagine three types of implementation:
29990 @enumerate a
29992 @item 
29993 those that narrow the range automatically if they can figure
29994 out that the narrower range will allow storage in a smaller machine unit,
29996 @item 
29997 those that will narrow only if forced to by a @code{'Size} clause, and
29999 @item 
30000 those that will never narrow.
30001 @end enumerate
30003 Now if we are language theoreticians, we can imagine a fourth
30004 approach: to narrow all the time, e.g. to treat
30006 @example
30007 type F3 is delta 1.0 range -10.0 .. +23.0;
30008 @end example
30010 as though it had been written:
30012 @example
30013 type F3 is delta 1.0 range -9.0 .. +22.0;
30014 @end example
30016 But although technically allowed, such a behavior would be hostile and silly,
30017 and no real compiler would do this. All real compilers will fall into one of
30018 the categories (a), (b) or (c) above.
30020 So, how do you get the compiler to do what you want? The answer is give the
30021 actual bounds you want, and then use a @code{'Small} clause and a
30022 @code{'Size} clause to absolutely pin down what the compiler does.
30023 E.g., for @code{F2} above, we will write:
30025 @example
30026 My_Small : constant := 2.0**(-15);
30027 My_First : constant := -1.0;
30028 My_Last  : constant := +1.0 - My_Small;
30030 type F2 is delta My_Small range My_First .. My_Last;
30031 @end example
30033 and then add
30035 @example
30036 for F2'Small use my_Small;
30037 for F2'Size  use 16;
30038 @end example
30040 In practice all compilers will do the same thing here and will give you
30041 what you want, so the above declarations are fully portable. If you really
30042 want to play language lawyer and guard against ludicrous behavior by the
30043 compiler you could add
30045 @example
30046 Test1 : constant := 1 / Boolean'Pos (F2'First = My_First);
30047 Test2 : constant := 1 / Boolean'Pos (F2'Last  = My_Last);
30048 @end example
30050 One or other or both are allowed to be illegal if the compiler is
30051 behaving in a silly manner, but at least the silly compiler will not
30052 get away with silently messing with your (very clear) intentions.
30054 If you follow this scheme you will be guaranteed that your fixed-point
30055 types will be portable.
30057 @node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
30058 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{45f}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{460}
30059 @section Compatibility with Ada 83
30062 @geindex Compatibility (between Ada 83 and Ada 95 / Ada 2005 / Ada 2012)
30064 Ada 95 and the subsequent revisions Ada 2005 and Ada 2012
30065 are highly upwards compatible with Ada 83.  In
30066 particular, the design intention was that the difficulties associated
30067 with moving from Ada 83 to later versions of the standard should be no greater
30068 than those that occur when moving from one Ada 83 system to another.
30070 However, there are a number of points at which there are minor
30071 incompatibilities.  The @cite{Ada 95 Annotated Reference Manual} contains
30072 full details of these issues as they relate to Ada 95,
30073 and should be consulted for a complete treatment.
30074 In practice the
30075 following subsections treat the most likely issues to be encountered.
30077 @menu
30078 * Legal Ada 83 programs that are illegal in Ada 95:: 
30079 * More deterministic semantics:: 
30080 * Changed semantics:: 
30081 * Other language compatibility issues:: 
30083 @end menu
30085 @node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
30086 @anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{461}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{462}
30087 @subsection Legal Ada 83 programs that are illegal in Ada 95
30090 Some legal Ada 83 programs are illegal (i.e., they will fail to compile) in
30091 Ada 95 and later versions of the standard:
30094 @itemize *
30096 @item 
30097 `Character literals'
30099 Some uses of character literals are ambiguous.  Since Ada 95 has introduced
30100 @code{Wide_Character} as a new predefined character type, some uses of
30101 character literals that were legal in Ada 83 are illegal in Ada 95.
30102 For example:
30104 @example
30105 for Char in 'A' .. 'Z' loop ... end loop;
30106 @end example
30108 The problem is that ‘A’ and ‘Z’ could be from either
30109 @code{Character} or @code{Wide_Character}.  The simplest correction
30110 is to make the type explicit; e.g.:
30112 @example
30113 for Char in Character range 'A' .. 'Z' loop ... end loop;
30114 @end example
30116 @item 
30117 `New reserved words'
30119 The identifiers @code{abstract}, @code{aliased}, @code{protected},
30120 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
30121 Existing Ada 83 code using any of these identifiers must be edited to
30122 use some alternative name.
30124 @item 
30125 `Freezing rules'
30127 The rules in Ada 95 are slightly different with regard to the point at
30128 which entities are frozen, and representation pragmas and clauses are
30129 not permitted past the freeze point.  This shows up most typically in
30130 the form of an error message complaining that a representation item
30131 appears too late, and the appropriate corrective action is to move
30132 the item nearer to the declaration of the entity to which it refers.
30134 A particular case is that representation pragmas
30135 cannot be applied to a subprogram body.  If necessary, a separate subprogram
30136 declaration must be introduced to which the pragma can be applied.
30138 @item 
30139 `Optional bodies for library packages'
30141 In Ada 83, a package that did not require a package body was nevertheless
30142 allowed to have one.  This lead to certain surprises in compiling large
30143 systems (situations in which the body could be unexpectedly ignored by the
30144 binder).  In Ada 95, if a package does not require a body then it is not
30145 permitted to have a body.  To fix this problem, simply remove a redundant
30146 body if it is empty, or, if it is non-empty, introduce a dummy declaration
30147 into the spec that makes the body required.  One approach is to add a private
30148 part to the package declaration (if necessary), and define a parameterless
30149 procedure called @code{Requires_Body}, which must then be given a dummy
30150 procedure body in the package body, which then becomes required.
30151 Another approach (assuming that this does not introduce elaboration
30152 circularities) is to add an @code{Elaborate_Body} pragma to the package spec,
30153 since one effect of this pragma is to require the presence of a package body.
30155 @item 
30156 `Numeric_Error is the same exception as Constraint_Error'
30158 In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
30159 This means that it is illegal to have separate exception handlers for
30160 the two exceptions.  The fix is simply to remove the handler for the
30161 @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
30162 @code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
30164 @item 
30165 `Indefinite subtypes in generics'
30167 In Ada 83, it was permissible to pass an indefinite type (e.g, @code{String})
30168 as the actual for a generic formal private type, but then the instantiation
30169 would be illegal if there were any instances of declarations of variables
30170 of this type in the generic body.  In Ada 95, to avoid this clear violation
30171 of the methodological principle known as the ‘contract model’,
30172 the generic declaration explicitly indicates whether
30173 or not such instantiations are permitted.  If a generic formal parameter
30174 has explicit unknown discriminants, indicated by using @code{(<>)} after the
30175 subtype name, then it can be instantiated with indefinite types, but no
30176 stand-alone variables can be declared of this type.  Any attempt to declare
30177 such a variable will result in an illegality at the time the generic is
30178 declared.  If the @code{(<>)} notation is not used, then it is illegal
30179 to instantiate the generic with an indefinite type.
30180 This is the potential incompatibility issue when porting Ada 83 code to Ada 95.
30181 It will show up as a compile time error, and
30182 the fix is usually simply to add the @code{(<>)} to the generic declaration.
30183 @end itemize
30185 @node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
30186 @anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{463}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{464}
30187 @subsection More deterministic semantics
30191 @itemize *
30193 @item 
30194 `Conversions'
30196 Conversions from real types to integer types round away from 0.  In Ada 83
30197 the conversion Integer(2.5) could deliver either 2 or 3 as its value.  This
30198 implementation freedom was intended to support unbiased rounding in
30199 statistical applications, but in practice it interfered with portability.
30200 In Ada 95 the conversion semantics are unambiguous, and rounding away from 0
30201 is required.  Numeric code may be affected by this change in semantics.
30202 Note, though, that this issue is no worse than already existed in Ada 83
30203 when porting code from one vendor to another.
30205 @item 
30206 `Tasking'
30208 The Real-Time Annex introduces a set of policies that define the behavior of
30209 features that were implementation dependent in Ada 83, such as the order in
30210 which open select branches are executed.
30211 @end itemize
30213 @node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
30214 @anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{465}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{466}
30215 @subsection Changed semantics
30218 The worst kind of incompatibility is one where a program that is legal in
30219 Ada 83 is also legal in Ada 95 but can have an effect in Ada 95 that was not
30220 possible in Ada 83.  Fortunately this is extremely rare, but the one
30221 situation that you should be alert to is the change in the predefined type
30222 @code{Character} from 7-bit ASCII to 8-bit Latin-1.
30224 @quotation
30226 @geindex Latin-1
30227 @end quotation
30230 @itemize *
30232 @item 
30233 `Range of type `@w{`}Character`@w{`}'
30235 The range of @code{Standard.Character} is now the full 256 characters
30236 of Latin-1, whereas in most Ada 83 implementations it was restricted
30237 to 128 characters. Although some of the effects of
30238 this change will be manifest in compile-time rejection of legal
30239 Ada 83 programs it is possible for a working Ada 83 program to have
30240 a different effect in Ada 95, one that was not permitted in Ada 83.
30241 As an example, the expression
30242 @code{Character'Pos(Character'Last)} returned @code{127} in Ada 83 and now
30243 delivers @code{255} as its value.
30244 In general, you should look at the logic of any
30245 character-processing Ada 83 program and see whether it needs to be adapted
30246 to work correctly with Latin-1.  Note that the predefined Ada 95 API has a
30247 character handling package that may be relevant if code needs to be adapted
30248 to account for the additional Latin-1 elements.
30249 The desirable fix is to
30250 modify the program to accommodate the full character set, but in some cases
30251 it may be convenient to define a subtype or derived type of Character that
30252 covers only the restricted range.
30253 @end itemize
30255 @node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
30256 @anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{467}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{468}
30257 @subsection Other language compatibility issues
30261 @itemize *
30263 @item 
30264 `-gnat83' switch
30266 All implementations of GNAT provide a switch that causes GNAT to operate
30267 in Ada 83 mode.  In this mode, some but not all compatibility problems
30268 of the type described above are handled automatically.  For example, the
30269 new reserved words introduced in Ada 95 and Ada 2005 are treated simply
30270 as identifiers as in Ada 83.  However,
30271 in practice, it is usually advisable to make the necessary modifications
30272 to the program to remove the need for using this switch.
30273 See the @code{Compiling Different Versions of Ada} section in
30274 the @cite{GNAT User’s Guide}.
30276 @item 
30277 Support for removed Ada 83 pragmas and attributes
30279 A number of pragmas and attributes from Ada 83 were removed from Ada 95,
30280 generally because they were replaced by other mechanisms.  Ada 95 and Ada 2005
30281 compilers are allowed, but not required, to implement these missing
30282 elements.  In contrast with some other compilers, GNAT implements all
30283 such pragmas and attributes, eliminating this compatibility concern.  These
30284 include @code{pragma Interface} and the floating point type attributes
30285 (@code{Emax}, @code{Mantissa}, etc.), among other items.
30286 @end itemize
30288 @node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
30289 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{469}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{46a}
30290 @section Compatibility between Ada 95 and Ada 2005
30293 @geindex Compatibility between Ada 95 and Ada 2005
30295 Although Ada 2005 was designed to be upwards compatible with Ada 95, there are
30296 a number of incompatibilities. Several are enumerated below;
30297 for a complete description please see the
30298 @cite{Annotated Ada 2005 Reference Manual}, or section 9.1.1 in
30299 @cite{Rationale for Ada 2005}.
30302 @itemize *
30304 @item 
30305 `New reserved words.'
30307 The words @code{interface}, @code{overriding} and @code{synchronized} are
30308 reserved in Ada 2005.
30309 A pre-Ada 2005 program that uses any of these as an identifier will be
30310 illegal.
30312 @item 
30313 `New declarations in predefined packages.'
30315 A number of packages in the predefined environment contain new declarations:
30316 @code{Ada.Exceptions}, @code{Ada.Real_Time}, @code{Ada.Strings},
30317 @code{Ada.Strings.Fixed}, @code{Ada.Strings.Bounded},
30318 @code{Ada.Strings.Unbounded}, @code{Ada.Strings.Wide_Fixed},
30319 @code{Ada.Strings.Wide_Bounded}, @code{Ada.Strings.Wide_Unbounded},
30320 @code{Ada.Tags}, @code{Ada.Text_IO}, and @code{Interfaces.C}.
30321 If an Ada 95 program does a @code{with} and @code{use} of any of these
30322 packages, the new declarations may cause name clashes.
30324 @item 
30325 `Access parameters.'
30327 A nondispatching subprogram with an access parameter cannot be renamed
30328 as a dispatching operation.  This was permitted in Ada 95.
30330 @item 
30331 `Access types, discriminants, and constraints.'
30333 Rule changes in this area have led to some incompatibilities; for example,
30334 constrained subtypes of some access types are not permitted in Ada 2005.
30336 @item 
30337 `Aggregates for limited types.'
30339 The allowance of aggregates for limited types in Ada 2005 raises the
30340 possibility of ambiguities in legal Ada 95 programs, since additional types
30341 now need to be considered in expression resolution.
30343 @item 
30344 `Fixed-point multiplication and division.'
30346 Certain expressions involving ‘*’ or ‘/’ for a fixed-point type, which
30347 were legal in Ada 95 and invoked the predefined versions of these operations,
30348 are now ambiguous.
30349 The ambiguity may be resolved either by applying a type conversion to the
30350 expression, or by explicitly invoking the operation from package
30351 @code{Standard}.
30353 @item 
30354 `Return-by-reference types.'
30356 The Ada 95 return-by-reference mechanism has been removed.  Instead, the user
30357 can declare a function returning a value from an anonymous access type.
30358 @end itemize
30360 @node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
30361 @anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{46b}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{46c}
30362 @section Implementation-dependent characteristics
30365 Although the Ada language defines the semantics of each construct as
30366 precisely as practical, in some situations (for example for reasons of
30367 efficiency, or where the effect is heavily dependent on the host or target
30368 platform) the implementation is allowed some freedom.  In porting Ada 83
30369 code to GNAT, you need to be aware of whether / how the existing code
30370 exercised such implementation dependencies.  Such characteristics fall into
30371 several categories, and GNAT offers specific support in assisting the
30372 transition from certain Ada 83 compilers.
30374 @menu
30375 * Implementation-defined pragmas:: 
30376 * Implementation-defined attributes:: 
30377 * Libraries:: 
30378 * Elaboration order:: 
30379 * Target-specific aspects:: 
30381 @end menu
30383 @node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
30384 @anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{46d}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{46e}
30385 @subsection Implementation-defined pragmas
30388 Ada compilers are allowed to supplement the language-defined pragmas, and
30389 these are a potential source of non-portability.  All GNAT-defined pragmas
30390 are described in @ref{7,,Implementation Defined Pragmas},
30391 and these include several that are specifically
30392 intended to correspond to other vendors’ Ada 83 pragmas.
30393 For migrating from VADS, the pragma @code{Use_VADS_Size} may be useful.
30394 For compatibility with HP Ada 83, GNAT supplies the pragmas
30395 @code{Extend_System}, @code{Ident}, @code{Inline_Generic},
30396 @code{Interface_Name}, @code{Passive}, @code{Suppress_All},
30397 and @code{Volatile}.
30398 Other relevant pragmas include @code{External} and @code{Link_With}.
30399 Some vendor-specific
30400 Ada 83 pragmas (@code{Share_Generic}, @code{Subtitle}, and @code{Title}) are
30401 recognized, thus
30402 avoiding compiler rejection of units that contain such pragmas; they are not
30403 relevant in a GNAT context and hence are not otherwise implemented.
30405 @node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
30406 @anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{46f}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{470}
30407 @subsection Implementation-defined attributes
30410 Analogous to pragmas, the set of attributes may be extended by an
30411 implementation.  All GNAT-defined attributes are described in
30412 @ref{8,,Implementation Defined Attributes},
30413 and these include several that are specifically intended
30414 to correspond to other vendors’ Ada 83 attributes.  For migrating from VADS,
30415 the attribute @code{VADS_Size} may be useful.  For compatibility with HP
30416 Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
30417 @code{Type_Class}.
30419 @node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
30420 @anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{471}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{472}
30421 @subsection Libraries
30424 Vendors may supply libraries to supplement the standard Ada API.  If Ada 83
30425 code uses vendor-specific libraries then there are several ways to manage
30426 this in Ada 95 and later versions of the standard:
30429 @itemize *
30431 @item 
30432 If the source code for the libraries (specs and bodies) are
30433 available, then the libraries can be migrated in the same way as the
30434 application.
30436 @item 
30437 If the source code for the specs but not the bodies are
30438 available, then you can reimplement the bodies.
30440 @item 
30441 Some features introduced by Ada 95 obviate the need for library support.  For
30442 example most Ada 83 vendors supplied a package for unsigned integers.  The
30443 Ada 95 modular type feature is the preferred way to handle this need, so
30444 instead of migrating or reimplementing the unsigned integer package it may
30445 be preferable to retrofit the application using modular types.
30446 @end itemize
30448 @node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
30449 @anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{473}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{474}
30450 @subsection Elaboration order
30453 The implementation can choose any elaboration order consistent with the unit
30454 dependency relationship.  This freedom means that some orders can result in
30455 Program_Error being raised due to an ‘Access Before Elaboration’: an attempt
30456 to invoke a subprogram before its body has been elaborated, or to instantiate
30457 a generic before the generic body has been elaborated.  By default GNAT
30458 attempts to choose a safe order (one that will not encounter access before
30459 elaboration problems) by implicitly inserting @code{Elaborate} or
30460 @code{Elaborate_All} pragmas where
30461 needed.  However, this can lead to the creation of elaboration circularities
30462 and a resulting rejection of the program by gnatbind.  This issue is
30463 thoroughly described in the `Elaboration Order Handling in GNAT' appendix
30464 in the @cite{GNAT User’s Guide}.
30465 In brief, there are several
30466 ways to deal with this situation:
30469 @itemize *
30471 @item 
30472 Modify the program to eliminate the circularities, e.g., by moving
30473 elaboration-time code into explicitly-invoked procedures
30475 @item 
30476 Constrain the elaboration order by including explicit @code{Elaborate_Body} or
30477 @code{Elaborate} pragmas, and then inhibit the generation of implicit
30478 @code{Elaborate_All}
30479 pragmas either globally (as an effect of the `-gnatE' switch) or locally
30480 (by selectively suppressing elaboration checks via pragma
30481 @code{Suppress(Elaboration_Check)} when it is safe to do so).
30482 @end itemize
30484 @node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
30485 @anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{475}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{476}
30486 @subsection Target-specific aspects
30489 Low-level applications need to deal with machine addresses, data
30490 representations, interfacing with assembler code, and similar issues.  If
30491 such an Ada 83 application is being ported to different target hardware (for
30492 example where the byte endianness has changed) then you will need to
30493 carefully examine the program logic; the porting effort will heavily depend
30494 on the robustness of the original design.  Moreover, Ada 95 (and thus
30495 Ada 2005 and Ada 2012) are sometimes
30496 incompatible with typical Ada 83 compiler practices regarding implicit
30497 packing, the meaning of the Size attribute, and the size of access values.
30498 GNAT’s approach to these issues is described in @ref{477,,Representation Clauses}.
30500 @node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
30501 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{478}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{479}
30502 @section Compatibility with Other Ada Systems
30505 If programs avoid the use of implementation dependent and
30506 implementation defined features, as documented in the
30507 @cite{Ada Reference Manual}, there should be a high degree of portability between
30508 GNAT and other Ada systems.  The following are specific items which
30509 have proved troublesome in moving Ada 95 programs from GNAT to other Ada 95
30510 compilers, but do not affect porting code to GNAT.
30511 (As of January 2007, GNAT is the only compiler available for Ada 2005;
30512 the following issues may or may not arise for Ada 2005 programs
30513 when other compilers appear.)
30516 @itemize *
30518 @item 
30519 `Ada 83 Pragmas and Attributes'
30521 Ada 95 compilers are allowed, but not required, to implement the missing
30522 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
30523 GNAT implements all such pragmas and attributes, eliminating this as
30524 a compatibility concern, but some other Ada 95 compilers reject these
30525 pragmas and attributes.
30527 @item 
30528 `Specialized Needs Annexes'
30530 GNAT implements the full set of special needs annexes.  At the
30531 current time, it is the only Ada 95 compiler to do so.  This means that
30532 programs making use of these features may not be portable to other Ada
30533 95 compilation systems.
30535 @item 
30536 `Representation Clauses'
30538 Some other Ada 95 compilers implement only the minimal set of
30539 representation clauses required by the Ada 95 reference manual.  GNAT goes
30540 far beyond this minimal set, as described in the next section.
30541 @end itemize
30543 @node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
30544 @anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{47a}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{477}
30545 @section Representation Clauses
30548 The Ada 83 reference manual was quite vague in describing both the minimal
30549 required implementation of representation clauses, and also their precise
30550 effects.  Ada 95 (and thus also Ada 2005) are much more explicit, but the
30551 minimal set of capabilities required is still quite limited.
30553 GNAT implements the full required set of capabilities in
30554 Ada 95 and Ada 2005, but also goes much further, and in particular
30555 an effort has been made to be compatible with existing Ada 83 usage to the
30556 greatest extent possible.
30558 A few cases exist in which Ada 83 compiler behavior is incompatible with
30559 the requirements in Ada 95 (and thus also Ada 2005).  These are instances of
30560 intentional or accidental dependence on specific implementation dependent
30561 characteristics of these Ada 83 compilers.  The following is a list of
30562 the cases most likely to arise in existing Ada 83 code.
30565 @itemize *
30567 @item 
30568 `Implicit Packing'
30570 Some Ada 83 compilers allowed a Size specification to cause implicit
30571 packing of an array or record.  This could cause expensive implicit
30572 conversions for change of representation in the presence of derived
30573 types, and the Ada design intends to avoid this possibility.
30574 Subsequent AI’s were issued to make it clear that such implicit
30575 change of representation in response to a Size clause is inadvisable,
30576 and this recommendation is represented explicitly in the Ada 95 (and Ada 2005)
30577 Reference Manuals as implementation advice that is followed by GNAT.
30578 The problem will show up as an error
30579 message rejecting the size clause.  The fix is simply to provide
30580 the explicit pragma @code{Pack}, or for more fine tuned control, provide
30581 a Component_Size clause.
30583 @item 
30584 `Meaning of Size Attribute'
30586 The Size attribute in Ada 95 (and Ada 2005) for discrete types is defined as
30587 the minimal number of bits required to hold values of the type.  For example,
30588 on a 32-bit machine, the size of @code{Natural} will typically be 31 and not
30589 32 (since no sign bit is required).  Some Ada 83 compilers gave 31, and
30590 some 32 in this situation.  This problem will usually show up as a compile
30591 time error, but not always.  It is a good idea to check all uses of the
30592 ‘Size attribute when porting Ada 83 code.  The GNAT specific attribute
30593 Object_Size can provide a useful way of duplicating the behavior of
30594 some Ada 83 compiler systems.
30596 @item 
30597 `Size of Access Types'
30599 A common assumption in Ada 83 code is that an access type is in fact a pointer,
30600 and that therefore it will be the same size as a System.Address value.  This
30601 assumption is true for GNAT in most cases with one exception.  For the case of
30602 a pointer to an unconstrained array type (where the bounds may vary from one
30603 value of the access type to another), the default is to use a ‘fat pointer’,
30604 which is represented as two separate pointers, one to the bounds, and one to
30605 the array.  This representation has a number of advantages, including improved
30606 efficiency.  However, it may cause some difficulties in porting existing Ada 83
30607 code which makes the assumption that, for example, pointers fit in 32 bits on
30608 a machine with 32-bit addressing.
30610 To get around this problem, GNAT also permits the use of ‘thin pointers’ for
30611 access types in this case (where the designated type is an unconstrained array
30612 type).  These thin pointers are indeed the same size as a System.Address value.
30613 To specify a thin pointer, use a size clause for the type, for example:
30615 @example
30616 type X is access all String;
30617 for X'Size use Standard'Address_Size;
30618 @end example
30620 which will cause the type X to be represented using a single pointer.
30621 When using this representation, the bounds are right behind the array.
30622 This representation is slightly less efficient, and does not allow quite
30623 such flexibility in the use of foreign pointers or in using the
30624 Unrestricted_Access attribute to create pointers to non-aliased objects.
30625 But for any standard portable use of the access type it will work in
30626 a functionally correct manner and allow porting of existing code.
30627 Note that another way of forcing a thin pointer representation
30628 is to use a component size clause for the element size in an array,
30629 or a record representation clause for an access field in a record.
30631 See the documentation of Unrestricted_Access in the GNAT RM for a
30632 full discussion of possible problems using this attribute in conjunction
30633 with thin pointers.
30634 @end itemize
30636 @node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
30637 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{47b}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{47c}
30638 @section Compatibility with HP Ada 83
30641 All the HP Ada 83 pragmas and attributes are recognized, although only a subset
30642 of them can sensibly be implemented.  The description of pragmas in
30643 @ref{7,,Implementation Defined Pragmas} indicates whether or not they are
30644 applicable to GNAT.
30647 @itemize *
30649 @item 
30650 `Default floating-point representation'
30652 In GNAT, the default floating-point format is IEEE, whereas in HP Ada 83,
30653 it is VMS format.
30655 @item 
30656 `System'
30658 the package System in GNAT exactly corresponds to the definition in the
30659 Ada 95 reference manual, which means that it excludes many of the
30660 HP Ada 83 extensions.  However, a separate package Aux_DEC is provided
30661 that contains the additional definitions, and a special pragma,
30662 Extend_System allows this package to be treated transparently as an
30663 extension of package System.
30664 @end itemize
30666 @node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
30667 @anchor{share/gnu_free_documentation_license doc}@anchor{47d}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{47e}
30668 @chapter GNU Free Documentation License
30671 Version 1.3, 3 November 2008
30673 Copyright  2000, 2001, 2002, 2007, 2008  Free Software Foundation, Inc
30674 @indicateurl{https://fsf.org/}
30676 Everyone is permitted to copy and distribute verbatim copies of this
30677 license document, but changing it is not allowed.
30679 `Preamble'
30681 The purpose of this License is to make a manual, textbook, or other
30682 functional and useful document “free” in the sense of freedom: to
30683 assure everyone the effective freedom to copy and redistribute it,
30684 with or without modifying it, either commercially or noncommercially.
30685 Secondarily, this License preserves for the author and publisher a way
30686 to get credit for their work, while not being considered responsible
30687 for modifications made by others.
30689 This License is a kind of “copyleft”, which means that derivative
30690 works of the document must themselves be free in the same sense.  It
30691 complements the GNU General Public License, which is a copyleft
30692 license designed for free software.
30694 We have designed this License in order to use it for manuals for free
30695 software, because free software needs free documentation: a free
30696 program should come with manuals providing the same freedoms that the
30697 software does.  But this License is not limited to software manuals;
30698 it can be used for any textual work, regardless of subject matter or
30699 whether it is published as a printed book.  We recommend this License
30700 principally for works whose purpose is instruction or reference.
30702 `1. APPLICABILITY AND DEFINITIONS'
30704 This License applies to any manual or other work, in any medium, that
30705 contains a notice placed by the copyright holder saying it can be
30706 distributed under the terms of this License.  Such a notice grants a
30707 world-wide, royalty-free license, unlimited in duration, to use that
30708 work under the conditions stated herein.  The `Document', below,
30709 refers to any such manual or work.  Any member of the public is a
30710 licensee, and is addressed as “`you'”.  You accept the license if you
30711 copy, modify or distribute the work in a way requiring permission
30712 under copyright law.
30714 A “`Modified Version'” of the Document means any work containing the
30715 Document or a portion of it, either copied verbatim, or with
30716 modifications and/or translated into another language.
30718 A “`Secondary Section'” is a named appendix or a front-matter section of
30719 the Document that deals exclusively with the relationship of the
30720 publishers or authors of the Document to the Document’s overall subject
30721 (or to related matters) and contains nothing that could fall directly
30722 within that overall subject.  (Thus, if the Document is in part a
30723 textbook of mathematics, a Secondary Section may not explain any
30724 mathematics.)  The relationship could be a matter of historical
30725 connection with the subject or with related matters, or of legal,
30726 commercial, philosophical, ethical or political position regarding
30727 them.
30729 The “`Invariant Sections'” are certain Secondary Sections whose titles
30730 are designated, as being those of Invariant Sections, in the notice
30731 that says that the Document is released under this License.  If a
30732 section does not fit the above definition of Secondary then it is not
30733 allowed to be designated as Invariant.  The Document may contain zero
30734 Invariant Sections.  If the Document does not identify any Invariant
30735 Sections then there are none.
30737 The “`Cover Texts'” are certain short passages of text that are listed,
30738 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
30739 the Document is released under this License.  A Front-Cover Text may
30740 be at most 5 words, and a Back-Cover Text may be at most 25 words.
30742 A “`Transparent'” copy of the Document means a machine-readable copy,
30743 represented in a format whose specification is available to the
30744 general public, that is suitable for revising the document
30745 straightforwardly with generic text editors or (for images composed of
30746 pixels) generic paint programs or (for drawings) some widely available
30747 drawing editor, and that is suitable for input to text formatters or
30748 for automatic translation to a variety of formats suitable for input
30749 to text formatters.  A copy made in an otherwise Transparent file
30750 format whose markup, or absence of markup, has been arranged to thwart
30751 or discourage subsequent modification by readers is not Transparent.
30752 An image format is not Transparent if used for any substantial amount
30753 of text.  A copy that is not “Transparent” is called `Opaque'.
30755 Examples of suitable formats for Transparent copies include plain
30756 ASCII without markup, Texinfo input format, LaTeX input format, SGML
30757 or XML using a publicly available DTD, and standard-conforming simple
30758 HTML, PostScript or PDF designed for human modification.  Examples of
30759 transparent image formats include PNG, XCF and JPG.  Opaque formats
30760 include proprietary formats that can be read and edited only by
30761 proprietary word processors, SGML or XML for which the DTD and/or
30762 processing tools are not generally available, and the
30763 machine-generated HTML, PostScript or PDF produced by some word
30764 processors for output purposes only.
30766 The “`Title Page'” means, for a printed book, the title page itself,
30767 plus such following pages as are needed to hold, legibly, the material
30768 this License requires to appear in the title page.  For works in
30769 formats which do not have any title page as such, “Title Page” means
30770 the text near the most prominent appearance of the work’s title,
30771 preceding the beginning of the body of the text.
30773 The “`publisher'” means any person or entity that distributes
30774 copies of the Document to the public.
30776 A section “`Entitled XYZ'” means a named subunit of the Document whose
30777 title either is precisely XYZ or contains XYZ in parentheses following
30778 text that translates XYZ in another language.  (Here XYZ stands for a
30779 specific section name mentioned below, such as “`Acknowledgements'”,
30780 “`Dedications'”, “`Endorsements'”, or “`History'”.)
30781 To “`Preserve the Title'”
30782 of such a section when you modify the Document means that it remains a
30783 section “Entitled XYZ” according to this definition.
30785 The Document may include Warranty Disclaimers next to the notice which
30786 states that this License applies to the Document.  These Warranty
30787 Disclaimers are considered to be included by reference in this
30788 License, but only as regards disclaiming warranties: any other
30789 implication that these Warranty Disclaimers may have is void and has
30790 no effect on the meaning of this License.
30792 `2. VERBATIM COPYING'
30794 You may copy and distribute the Document in any medium, either
30795 commercially or noncommercially, provided that this License, the
30796 copyright notices, and the license notice saying this License applies
30797 to the Document are reproduced in all copies, and that you add no other
30798 conditions whatsoever to those of this License.  You may not use
30799 technical measures to obstruct or control the reading or further
30800 copying of the copies you make or distribute.  However, you may accept
30801 compensation in exchange for copies.  If you distribute a large enough
30802 number of copies you must also follow the conditions in section 3.
30804 You may also lend copies, under the same conditions stated above, and
30805 you may publicly display copies.
30807 `3. COPYING IN QUANTITY'
30809 If you publish printed copies (or copies in media that commonly have
30810 printed covers) of the Document, numbering more than 100, and the
30811 Document’s license notice requires Cover Texts, you must enclose the
30812 copies in covers that carry, clearly and legibly, all these Cover
30813 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
30814 the back cover.  Both covers must also clearly and legibly identify
30815 you as the publisher of these copies.  The front cover must present
30816 the full title with all words of the title equally prominent and
30817 visible.  You may add other material on the covers in addition.
30818 Copying with changes limited to the covers, as long as they preserve
30819 the title of the Document and satisfy these conditions, can be treated
30820 as verbatim copying in other respects.
30822 If the required texts for either cover are too voluminous to fit
30823 legibly, you should put the first ones listed (as many as fit
30824 reasonably) on the actual cover, and continue the rest onto adjacent
30825 pages.
30827 If you publish or distribute Opaque copies of the Document numbering
30828 more than 100, you must either include a machine-readable Transparent
30829 copy along with each Opaque copy, or state in or with each Opaque copy
30830 a computer-network location from which the general network-using
30831 public has access to download using public-standard network protocols
30832 a complete Transparent copy of the Document, free of added material.
30833 If you use the latter option, you must take reasonably prudent steps,
30834 when you begin distribution of Opaque copies in quantity, to ensure
30835 that this Transparent copy will remain thus accessible at the stated
30836 location until at least one year after the last time you distribute an
30837 Opaque copy (directly or through your agents or retailers) of that
30838 edition to the public.
30840 It is requested, but not required, that you contact the authors of the
30841 Document well before redistributing any large number of copies, to give
30842 them a chance to provide you with an updated version of the Document.
30844 `4. MODIFICATIONS'
30846 You may copy and distribute a Modified Version of the Document under
30847 the conditions of sections 2 and 3 above, provided that you release
30848 the Modified Version under precisely this License, with the Modified
30849 Version filling the role of the Document, thus licensing distribution
30850 and modification of the Modified Version to whoever possesses a copy
30851 of it.  In addition, you must do these things in the Modified Version:
30854 @enumerate A
30856 @item 
30857 Use in the Title Page (and on the covers, if any) a title distinct
30858 from that of the Document, and from those of previous versions
30859 (which should, if there were any, be listed in the History section
30860 of the Document).  You may use the same title as a previous version
30861 if the original publisher of that version gives permission.
30863 @item 
30864 List on the Title Page, as authors, one or more persons or entities
30865 responsible for authorship of the modifications in the Modified
30866 Version, together with at least five of the principal authors of the
30867 Document (all of its principal authors, if it has fewer than five),
30868 unless they release you from this requirement.
30870 @item 
30871 State on the Title page the name of the publisher of the
30872 Modified Version, as the publisher.
30874 @item 
30875 Preserve all the copyright notices of the Document.
30877 @item 
30878 Add an appropriate copyright notice for your modifications
30879 adjacent to the other copyright notices.
30881 @item 
30882 Include, immediately after the copyright notices, a license notice
30883 giving the public permission to use the Modified Version under the
30884 terms of this License, in the form shown in the Addendum below.
30886 @item 
30887 Preserve in that license notice the full lists of Invariant Sections
30888 and required Cover Texts given in the Document’s license notice.
30890 @item 
30891 Include an unaltered copy of this License.
30893 @item 
30894 Preserve the section Entitled “History”, Preserve its Title, and add
30895 to it an item stating at least the title, year, new authors, and
30896 publisher of the Modified Version as given on the Title Page.  If
30897 there is no section Entitled “History” in the Document, create one
30898 stating the title, year, authors, and publisher of the Document as
30899 given on its Title Page, then add an item describing the Modified
30900 Version as stated in the previous sentence.
30902 @item 
30903 Preserve the network location, if any, given in the Document for
30904 public access to a Transparent copy of the Document, and likewise
30905 the network locations given in the Document for previous versions
30906 it was based on.  These may be placed in the “History” section.
30907 You may omit a network location for a work that was published at
30908 least four years before the Document itself, or if the original
30909 publisher of the version it refers to gives permission.
30911 @item 
30912 For any section Entitled “Acknowledgements” or “Dedications”,
30913 Preserve the Title of the section, and preserve in the section all
30914 the substance and tone of each of the contributor acknowledgements
30915 and/or dedications given therein.
30917 @item 
30918 Preserve all the Invariant Sections of the Document,
30919 unaltered in their text and in their titles.  Section numbers
30920 or the equivalent are not considered part of the section titles.
30922 @item 
30923 Delete any section Entitled “Endorsements”.  Such a section
30924 may not be included in the Modified Version.
30926 @item 
30927 Do not retitle any existing section to be Entitled “Endorsements”
30928 or to conflict in title with any Invariant Section.
30930 @item 
30931 Preserve any Warranty Disclaimers.
30932 @end enumerate
30934 If the Modified Version includes new front-matter sections or
30935 appendices that qualify as Secondary Sections and contain no material
30936 copied from the Document, you may at your option designate some or all
30937 of these sections as invariant.  To do this, add their titles to the
30938 list of Invariant Sections in the Modified Version’s license notice.
30939 These titles must be distinct from any other section titles.
30941 You may add a section Entitled “Endorsements”, provided it contains
30942 nothing but endorsements of your Modified Version by various
30943 parties—for example, statements of peer review or that the text has
30944 been approved by an organization as the authoritative definition of a
30945 standard.
30947 You may add a passage of up to five words as a Front-Cover Text, and a
30948 passage of up to 25 words as a Back-Cover Text, to the end of the list
30949 of Cover Texts in the Modified Version.  Only one passage of
30950 Front-Cover Text and one of Back-Cover Text may be added by (or
30951 through arrangements made by) any one entity.  If the Document already
30952 includes a cover text for the same cover, previously added by you or
30953 by arrangement made by the same entity you are acting on behalf of,
30954 you may not add another; but you may replace the old one, on explicit
30955 permission from the previous publisher that added the old one.
30957 The author(s) and publisher(s) of the Document do not by this License
30958 give permission to use their names for publicity for or to assert or
30959 imply endorsement of any Modified Version.
30961 `5. COMBINING DOCUMENTS'
30963 You may combine the Document with other documents released under this
30964 License, under the terms defined in section 4 above for modified
30965 versions, provided that you include in the combination all of the
30966 Invariant Sections of all of the original documents, unmodified, and
30967 list them all as Invariant Sections of your combined work in its
30968 license notice, and that you preserve all their Warranty Disclaimers.
30970 The combined work need only contain one copy of this License, and
30971 multiple identical Invariant Sections may be replaced with a single
30972 copy.  If there are multiple Invariant Sections with the same name but
30973 different contents, make the title of each such section unique by
30974 adding at the end of it, in parentheses, the name of the original
30975 author or publisher of that section if known, or else a unique number.
30976 Make the same adjustment to the section titles in the list of
30977 Invariant Sections in the license notice of the combined work.
30979 In the combination, you must combine any sections Entitled “History”
30980 in the various original documents, forming one section Entitled
30981 “History”; likewise combine any sections Entitled “Acknowledgements”,
30982 and any sections Entitled “Dedications”.  You must delete all sections
30983 Entitled “Endorsements”.
30985 `6. COLLECTIONS OF DOCUMENTS'
30987 You may make a collection consisting of the Document and other documents
30988 released under this License, and replace the individual copies of this
30989 License in the various documents with a single copy that is included in
30990 the collection, provided that you follow the rules of this License for
30991 verbatim copying of each of the documents in all other respects.
30993 You may extract a single document from such a collection, and distribute
30994 it individually under this License, provided you insert a copy of this
30995 License into the extracted document, and follow this License in all
30996 other respects regarding verbatim copying of that document.
30998 `7. AGGREGATION WITH INDEPENDENT WORKS'
31000 A compilation of the Document or its derivatives with other separate
31001 and independent documents or works, in or on a volume of a storage or
31002 distribution medium, is called an “aggregate” if the copyright
31003 resulting from the compilation is not used to limit the legal rights
31004 of the compilation’s users beyond what the individual works permit.
31005 When the Document is included in an aggregate, this License does not
31006 apply to the other works in the aggregate which are not themselves
31007 derivative works of the Document.
31009 If the Cover Text requirement of section 3 is applicable to these
31010 copies of the Document, then if the Document is less than one half of
31011 the entire aggregate, the Document’s Cover Texts may be placed on
31012 covers that bracket the Document within the aggregate, or the
31013 electronic equivalent of covers if the Document is in electronic form.
31014 Otherwise they must appear on printed covers that bracket the whole
31015 aggregate.
31017 `8. TRANSLATION'
31019 Translation is considered a kind of modification, so you may
31020 distribute translations of the Document under the terms of section 4.
31021 Replacing Invariant Sections with translations requires special
31022 permission from their copyright holders, but you may include
31023 translations of some or all Invariant Sections in addition to the
31024 original versions of these Invariant Sections.  You may include a
31025 translation of this License, and all the license notices in the
31026 Document, and any Warranty Disclaimers, provided that you also include
31027 the original English version of this License and the original versions
31028 of those notices and disclaimers.  In case of a disagreement between
31029 the translation and the original version of this License or a notice
31030 or disclaimer, the original version will prevail.
31032 If a section in the Document is Entitled “Acknowledgements”,
31033 “Dedications”, or “History”, the requirement (section 4) to Preserve
31034 its Title (section 1) will typically require changing the actual
31035 title.
31037 `9. TERMINATION'
31039 You may not copy, modify, sublicense, or distribute the Document
31040 except as expressly provided under this License.  Any attempt
31041 otherwise to copy, modify, sublicense, or distribute it is void, and
31042 will automatically terminate your rights under this License.
31044 However, if you cease all violation of this License, then your license
31045 from a particular copyright holder is reinstated (a) provisionally,
31046 unless and until the copyright holder explicitly and finally
31047 terminates your license, and (b) permanently, if the copyright holder
31048 fails to notify you of the violation by some reasonable means prior to
31049 60 days after the cessation.
31051 Moreover, your license from a particular copyright holder is
31052 reinstated permanently if the copyright holder notifies you of the
31053 violation by some reasonable means, this is the first time you have
31054 received notice of violation of this License (for any work) from that
31055 copyright holder, and you cure the violation prior to 30 days after
31056 your receipt of the notice.
31058 Termination of your rights under this section does not terminate the
31059 licenses of parties who have received copies or rights from you under
31060 this License.  If your rights have been terminated and not permanently
31061 reinstated, receipt of a copy of some or all of the same material does
31062 not give you any rights to use it.
31064 `10. FUTURE REVISIONS OF THIS LICENSE'
31066 The Free Software Foundation may publish new, revised versions
31067 of the GNU Free Documentation License from time to time.  Such new
31068 versions will be similar in spirit to the present version, but may
31069 differ in detail to address new problems or concerns.  See
31070 @indicateurl{https://www.gnu.org/copyleft/}.
31072 Each version of the License is given a distinguishing version number.
31073 If the Document specifies that a particular numbered version of this
31074 License “or any later version” applies to it, you have the option of
31075 following the terms and conditions either of that specified version or
31076 of any later version that has been published (not as a draft) by the
31077 Free Software Foundation.  If the Document does not specify a version
31078 number of this License, you may choose any version ever published (not
31079 as a draft) by the Free Software Foundation.  If the Document
31080 specifies that a proxy can decide which future versions of this
31081 License can be used, that proxy’s public statement of acceptance of a
31082 version permanently authorizes you to choose that version for the
31083 Document.
31085 `11. RELICENSING'
31087 “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
31088 World Wide Web server that publishes copyrightable works and also
31089 provides prominent facilities for anybody to edit those works.  A
31090 public wiki that anybody can edit is an example of such a server.  A
31091 “Massive Multiauthor Collaboration” (or “MMC”) contained in the
31092 site means any set of copyrightable works thus published on the MMC
31093 site.
31095 “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
31096 license published by Creative Commons Corporation, a not-for-profit
31097 corporation with a principal place of business in San Francisco,
31098 California, as well as future copyleft versions of that license
31099 published by that same organization.
31101 “Incorporate” means to publish or republish a Document, in whole or
31102 in part, as part of another Document.
31104 An MMC is “eligible for relicensing” if it is licensed under this
31105 License, and if all works that were first published under this License
31106 somewhere other than this MMC, and subsequently incorporated in whole
31107 or in part into the MMC, (1) had no cover texts or invariant sections,
31108 and (2) were thus incorporated prior to November 1, 2008.
31110 The operator of an MMC Site may republish an MMC contained in the site
31111 under CC-BY-SA on the same site at any time before August 1, 2009,
31112 provided the MMC is eligible for relicensing.
31114 `ADDENDUM: How to use this License for your documents'
31116 To use this License in a document you have written, include a copy of
31117 the License in the document and put the following copyright and
31118 license notices just after the title page:
31120 @quotation
31122 Copyright © YEAR  YOUR NAME.
31123 Permission is granted to copy, distribute and/or modify this document
31124 under the terms of the GNU Free Documentation License, Version 1.3
31125 or any later version published by the Free Software Foundation;
31126 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
31127 A copy of the license is included in the section entitled “GNU
31128 Free Documentation License”.
31129 @end quotation
31131 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
31132 replace the “with … Texts.” line with this:
31134 @quotation
31136 with the Invariant Sections being LIST THEIR TITLES, with the
31137 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
31138 @end quotation
31140 If you have Invariant Sections without Cover Texts, or some other
31141 combination of the three, merge those two alternatives to suit the
31142 situation.
31144 If your document contains nontrivial examples of program code, we
31145 recommend releasing these examples in parallel under your choice of
31146 free software license, such as the GNU General Public License,
31147 to permit their use in free software.
31149 @node Index,,GNU Free Documentation License,Top
31150 @unnumbered Index
31153 @printindex ge
31156 @c %**end of body
31157 @bye