[multiple changes]
[official-gcc.git] / gcc / ada / gnat_rm.texi
bloba824ca9feba421f9ba489740e68127ae57561f70
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
28 @set EDITION GNAT
30 @settitle GNAT Reference Manual
32 @setchapternewpage odd
33 @syncodeindex fn cp
35 @include gcc-common.texi
37 @dircategory GNU Ada tools
38 @direntry
39 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
40 @end direntry
42 @titlepage
43 @title GNAT Reference Manual
44 @subtitle GNAT, The GNU Ada Development Environment
45 @versionsubtitle
46 @author AdaCore
47 @page
48 @vskip 0pt plus 1filll
50 @insertcopying
52 @end titlepage
54 @ifnottex
55 @node Top, About This Guide, (dir), (dir)
56 @top GNAT Reference Manual
58 @noindent
59 GNAT Reference Manual
61 @noindent
62 GNAT, The GNU Ada Development Environment@*
63 GCC version @value{version-GCC}@*
65 @noindent
66 AdaCore
68 @menu
69 * About This Guide::
70 * Implementation Defined Pragmas::
71 * Implementation Defined Aspects::
72 * Implementation Defined Attributes::
73 * Standard and Implementation Defined Restrictions::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index:Concept Index.
89 @detailmenu
90  --- The Detailed Node Listing ---
92 About This Guide
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
100 * Pragma Abstract_State::
101 * Pragma Ada_83::
102 * Pragma Ada_95::
103 * Pragma Ada_05::
104 * Pragma Ada_2005::
105 * Pragma Ada_12::
106 * Pragma Ada_2012::
107 * Pragma Allow_Integer_Address::
108 * Pragma Annotate::
109 * Pragma Assert::
110 * Pragma Assert_And_Cut::
111 * Pragma Assertion_Policy::
112 * Pragma Assume::
113 * Pragma Assume_No_Invalid_Values::
114 * Pragma AST_Entry::
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 CIL_Constructor::
124 * Pragma Comment::
125 * Pragma Common_Object::
126 * Pragma Compile_Time_Error::
127 * Pragma Compile_Time_Warning::
128 * Pragma Compiler_Unit::
129 * Pragma Compiler_Unit_Warning::
130 * Pragma Complete_Representation::
131 * Pragma Complex_Representation::
132 * Pragma Component_Alignment::
133 * Pragma Contract_Cases::
134 * Pragma Convention_Identifier::
135 * Pragma CPP_Class::
136 * Pragma CPP_Constructor::
137 * Pragma CPP_Virtual::
138 * Pragma CPP_Vtable::
139 * Pragma CPU::
140 * Pragma Debug::
141 * Pragma Debug_Policy::
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_Exception::
154 * Pragma Export_Function::
155 * Pragma Export_Object::
156 * Pragma Export_Procedure::
157 * Pragma Export_Value::
158 * Pragma Export_Valued_Procedure::
159 * Pragma Extend_System::
160 * Pragma Extensions_Allowed::
161 * Pragma External::
162 * Pragma External_Name_Casing::
163 * Pragma Fast_Math::
164 * Pragma Favor_Top_Level::
165 * Pragma Finalize_Storage_Only::
166 * Pragma Float_Representation::
167 * Pragma Global::
168 * Pragma Ident::
169 * Pragma Implementation_Defined::
170 * Pragma Implemented::
171 * Pragma Implicit_Packing::
172 * Pragma Import_Exception::
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 Java_Constructor::
190 * Pragma Java_Interface::
191 * Pragma Keep_Names::
192 * Pragma License::
193 * Pragma Link_With::
194 * Pragma Linker_Alias::
195 * Pragma Linker_Constructor::
196 * Pragma Linker_Destructor::
197 * Pragma Linker_Section::
198 * Pragma Lock_Free::
199 * Pragma Long_Float::
200 * Pragma Loop_Invariant::
201 * Pragma Loop_Optimize::
202 * Pragma Loop_Variant::
203 * Pragma Machine_Attribute::
204 * Pragma Main::
205 * Pragma Main_Storage::
206 * Pragma No_Body::
207 * Pragma No_Elaboration_Code_All::
208 * Pragma No_Inline::
209 * Pragma No_Return::
210 * Pragma No_Run_Time::
211 * Pragma No_Strict_Aliasing ::
212 * Pragma Normalize_Scalars::
213 * Pragma Obsolescent::
214 * Pragma Optimize_Alignment::
215 * Pragma Ordered::
216 * Pragma Overflow_Mode::
217 * Pragma Overriding_Renamings::
218 * Pragma Partition_Elaboration_Policy::
219 * Pragma Part_Of::
220 * Pragma Passive::
221 * Pragma Persistent_BSS::
222 * Pragma Polling::
223 * Pragma Post::
224 * Pragma Postcondition::
225 * Pragma Post_Class::
226 * Pragma Pre::
227 * Pragma Precondition::
228 * Pragma Predicate::
229 * Pragma Preelaborable_Initialization::
230 * Pragma Prefix_Exception_Messages::
231 * Pragma Pre_Class::
232 * Pragma Priority_Specific_Dispatching::
233 * Pragma Profile::
234 * Pragma Profile_Warnings::
235 * Pragma Propagate_Exceptions::
236 * Pragma Provide_Shift_Operators::
237 * Pragma Psect_Object::
238 * Pragma Pure_Function::
239 * Pragma Rational::
240 * Pragma Ravenscar::
241 * Pragma Refined_Depends::
242 * Pragma Refined_Global::
243 * Pragma Refined_Post::
244 * Pragma Refined_State::
245 * Pragma Relative_Deadline::
246 * Pragma Remote_Access_Type::
247 * Pragma Restricted_Run_Time::
248 * Pragma Restriction_Warnings::
249 * Pragma Reviewable::
250 * Pragma Share_Generic::
251 * Pragma Shared::
252 * Pragma Short_Circuit_And_Or::
253 * Pragma Short_Descriptors::
254 * Pragma Simple_Storage_Pool_Type::
255 * Pragma Source_File_Name::
256 * Pragma Source_File_Name_Project::
257 * Pragma Source_Reference::
258 * Pragma SPARK_Mode::
259 * Pragma Static_Elaboration_Desired::
260 * Pragma Stream_Convert::
261 * Pragma Style_Checks::
262 * Pragma Subtitle::
263 * Pragma Suppress::
264 * Pragma Suppress_All::
265 * Pragma Suppress_Debug_Info::
266 * Pragma Suppress_Exception_Locations::
267 * Pragma Suppress_Initialization::
268 * Pragma Task_Name::
269 * Pragma Task_Storage::
270 * Pragma Test_Case::
271 * Pragma Thread_Local_Storage::
272 * Pragma Time_Slice::
273 * Pragma Title::
274 * Pragma Type_Invariant::
275 * Pragma Type_Invariant_Class::
276 * Pragma Unchecked_Union::
277 * Pragma Unevaluated_Use_Of_Old::
278 * Pragma Unimplemented_Unit::
279 * Pragma Universal_Aliasing ::
280 * Pragma Universal_Data::
281 * Pragma Unmodified::
282 * Pragma Unreferenced::
283 * Pragma Unreferenced_Objects::
284 * Pragma Unreserve_All_Interrupts::
285 * Pragma Unsuppress::
286 * Pragma Use_VADS_Size::
287 * Pragma Validity_Checks::
288 * Pragma Volatile::
289 * Pragma Warning_As_Error::
290 * Pragma Warnings::
291 * Pragma Weak_External::
292 * Pragma Wide_Character_Encoding::
294 Implementation Defined Aspects
296 * Aspect Abstract_State::
297 * Aspect Annotate::
298 * Aspect Async_Readers::
299 * Aspect Async_Writers::
300 * Aspect Contract_Cases::
301 * Aspect Depends::
302 * Aspect Dimension::
303 * Aspect Dimension_System::
304 * Aspect Effective_Reads::
305 * Aspect Effective_Writes::
306 * Aspect Favor_Top_Level::
307 * Aspect Global::
308 * Aspect Initial_Condition::
309 * Aspect Initializes::
310 * Aspect Inline_Always::
311 * Aspect Invariant::
312 * Aspect Invariant'Class::
313 * Aspect Iterable::
314 * Aspect Linker_Section::
315 * Aspect No_Elaboration_Code_All::
316 * Aspect Object_Size::
317 * Aspect Obsolescent::
318 * Aspect Part_Of::
319 * Aspect Persistent_BSS::
320 * Aspect Predicate::
321 * Aspect Pure_Function::
322 * Aspect Refined_Depends::
323 * Aspect Refined_Global::
324 * Aspect Refined_Post::
325 * Aspect Refined_State::
326 * Aspect Remote_Access_Type::
327 * Aspect Scalar_Storage_Order::
328 * Aspect Shared::
329 * Aspect Simple_Storage_Pool::
330 * Aspect Simple_Storage_Pool_Type::
331 * Aspect SPARK_Mode::
332 * Aspect Suppress_Debug_Info::
333 * Aspect Test_Case::
334 * Aspect Thread_Local_Storage::
335 * Aspect Universal_Aliasing::
336 * Aspect Universal_Data::
337 * Aspect Unmodified::
338 * Aspect Unreferenced::
339 * Aspect Unreferenced_Objects::
340 * Aspect Value_Size::
341 * Aspect Warnings::
343 Implementation Defined Attributes
345 * Attribute Abort_Signal::
346 * Attribute Address_Size::
347 * Attribute Asm_Input::
348 * Attribute Asm_Output::
349 * Attribute AST_Entry::
350 * Attribute Atomic_Always_Lock_Free::
351 * Attribute Bit::
352 * Attribute Bit_Position::
353 * Attribute Code_Address::
354 * Attribute Compiler_Version::
355 * Attribute Constrained::
356 * Attribute Default_Bit_Order::
357 * Attribute Default_Scalar_Storage_Order::
358 * Attribute Descriptor_Size::
359 * Attribute Elaborated::
360 * Attribute Elab_Body::
361 * Attribute Elab_Spec::
362 * Attribute Elab_Subp_Body::
363 * Attribute Emax::
364 * Attribute Enabled::
365 * Attribute Enum_Rep::
366 * Attribute Enum_Val::
367 * Attribute Epsilon::
368 * Attribute Fast_Math::
369 * Attribute Fixed_Value::
370 * Attribute From_Any::
371 * Attribute Has_Access_Values::
372 * Attribute Has_Discriminants::
373 * Attribute Img::
374 * Attribute Integer_Value::
375 * Attribute Invalid_Value::
376 * Attribute Iterable::
377 * Attribute Large::
378 * Attribute Library_Level::
379 * Attribute Lock_Free::
380 * Attribute Loop_Entry::
381 * Attribute Machine_Size::
382 * Attribute Mantissa::
383 * Attribute Maximum_Alignment::
384 * Attribute Mechanism_Code::
385 * Attribute Null_Parameter::
386 * Attribute Object_Size::
387 * Attribute Old::
388 * Attribute Passed_By_Reference::
389 * Attribute Pool_Address::
390 * Attribute Range_Length::
391 * Attribute Ref::
392 * Attribute Restriction_Set::
393 * Attribute Result::
394 * Attribute Safe_Emax::
395 * Attribute Safe_Large::
396 * Attribute Safe_Small::
397 * Attribute Scalar_Storage_Order::
398 * Attribute Simple_Storage_Pool::
399 * Attribute Small::
400 * Attribute Storage_Unit::
401 * Attribute Stub_Type::
402 * Attribute System_Allocator_Alignment::
403 * Attribute Target_Name::
404 * Attribute To_Address::
405 * Attribute To_Any::
406 * Attribute Type_Class::
407 * Attribute Type_Key::
408 * Attribute TypeCode::
409 * Attribute UET_Address::
410 * Attribute Unconstrained_Array::
411 * Attribute Universal_Literal_String::
412 * Attribute Unrestricted_Access::
413 * Attribute Update::
414 * Attribute VADS_Size::
415 * Attribute Valid_Scalars::
416 * Attribute Value_Size::
417 * Attribute Wchar_T_Size::
418 * Attribute Word_Size::
420 Standard and Implementation Defined Restrictions
422 * Partition-Wide Restrictions::
423 * Program Unit Level Restrictions::
425 Partition-Wide Restrictions
427 * Immediate_Reclamation::
428 * Max_Asynchronous_Select_Nesting::
429 * Max_Entry_Queue_Length::
430 * Max_Protected_Entries::
431 * Max_Select_Alternatives::
432 * Max_Storage_At_Blocking::
433 * Max_Task_Entries::
434 * Max_Tasks::
435 * No_Abort_Statements::
436 * No_Access_Parameter_Allocators::
437 * No_Access_Subprograms::
438 * No_Allocators::
439 * No_Anonymous_Allocators::
440 * No_Calendar::
441 * No_Coextensions::
442 * No_Default_Initialization::
443 * No_Delay::
444 * No_Dependence::
445 * No_Direct_Boolean_Operators::
446 * No_Dispatch::
447 * No_Dispatching_Calls::
448 * No_Dynamic_Attachment::
449 * No_Dynamic_Priorities::
450 * No_Entry_Calls_In_Elaboration_Code::
451 * No_Enumeration_Maps::
452 * No_Exception_Handlers::
453 * No_Exception_Propagation::
454 * No_Exception_Registration::
455 * No_Exceptions::
456 * No_Finalization::
457 * No_Fixed_Point::
458 * No_Floating_Point::
459 * No_Implicit_Conditionals::
460 * No_Implicit_Dynamic_Code::
461 * No_Implicit_Heap_Allocations::
462 * No_Implicit_Loops::
463 * No_Initialize_Scalars::
464 * No_IO::
465 * No_Local_Allocators::
466 * No_Local_Protected_Objects::
467 * No_Local_Timing_Events::
468 * No_Long_Long_Integers::
469 * No_Multiple_Elaboration::
470 * No_Nested_Finalization::
471 * No_Protected_Type_Allocators::
472 * No_Protected_Types::
473 * No_Recursion::
474 * No_Reentrancy::
475 * No_Relative_Delay::
476 * No_Requeue_Statements::
477 * No_Secondary_Stack::
478 * No_Select_Statements::
479 * No_Specific_Termination_Handlers::
480 * No_Specification_of_Aspect::
481 * No_Standard_Allocators_After_Elaboration::
482 * No_Standard_Storage_Pools::
483 * No_Stream_Optimizations::
484 * No_Streams::
485 * No_Task_Allocators::
486 * No_Task_Attributes_Package::
487 * No_Task_Hierarchy::
488 * No_Task_Termination::
489 * No_Tasking::
490 * No_Terminate_Alternatives::
491 * No_Unchecked_Access::
492 * Simple_Barriers::
493 * Static_Priorities::
494 * Static_Storage_Size::
496 Program Unit Level Restrictions
498 * No_Elaboration_Code::
499 * No_Entry_Queue::
500 * No_Implementation_Aspect_Specifications::
501 * No_Implementation_Attributes::
502 * No_Implementation_Identifiers::
503 * No_Implementation_Pragmas::
504 * No_Implementation_Restrictions::
505 * No_Implementation_Units::
506 * No_Implicit_Aliasing::
507 * No_Obsolescent_Features::
508 * No_Wide_Characters::
509 * SPARK_05::
511 The Implementation of Standard I/O
513 * Standard I/O Packages::
514 * FORM Strings::
515 * Direct_IO::
516 * Sequential_IO::
517 * Text_IO::
518 * Wide_Text_IO::
519 * Wide_Wide_Text_IO::
520 * Stream_IO::
521 * Text Translation::
522 * Shared Files::
523 * Filenames encoding::
524 * File content encoding::
525 * Open Modes::
526 * Operations on C Streams::
527 * Interfacing to C Streams::
529 The GNAT Library
531 * Ada.Characters.Latin_9 (a-chlat9.ads)::
532 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
533 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
534 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
535 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
536 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
537 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
538 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
539 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
540 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
541 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
542 * Ada.Command_Line.Environment (a-colien.ads)::
543 * Ada.Command_Line.Remove (a-colire.ads)::
544 * Ada.Command_Line.Response_File (a-clrefi.ads)::
545 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
546 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
547 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
548 * Ada.Exceptions.Traceback (a-exctra.ads)::
549 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
550 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
551 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
552 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
553 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
554 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
555 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
556 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
557 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
558 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
559 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
560 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
561 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
562 * GNAT.Altivec (g-altive.ads)::
563 * GNAT.Altivec.Conversions (g-altcon.ads)::
564 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
565 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
566 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
567 * GNAT.Array_Split (g-arrspl.ads)::
568 * GNAT.AWK (g-awk.ads)::
569 * GNAT.Bounded_Buffers (g-boubuf.ads)::
570 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
571 * GNAT.Bubble_Sort (g-bubsor.ads)::
572 * GNAT.Bubble_Sort_A (g-busora.ads)::
573 * GNAT.Bubble_Sort_G (g-busorg.ads)::
574 * GNAT.Byte_Order_Mark (g-byorma.ads)::
575 * GNAT.Byte_Swapping (g-bytswa.ads)::
576 * GNAT.Calendar (g-calend.ads)::
577 * GNAT.Calendar.Time_IO (g-catiio.ads)::
578 * GNAT.Case_Util (g-casuti.ads)::
579 * GNAT.CGI (g-cgi.ads)::
580 * GNAT.CGI.Cookie (g-cgicoo.ads)::
581 * GNAT.CGI.Debug (g-cgideb.ads)::
582 * GNAT.Command_Line (g-comlin.ads)::
583 * GNAT.Compiler_Version (g-comver.ads)::
584 * GNAT.Ctrl_C (g-ctrl_c.ads)::
585 * GNAT.CRC32 (g-crc32.ads)::
586 * GNAT.Current_Exception (g-curexc.ads)::
587 * GNAT.Debug_Pools (g-debpoo.ads)::
588 * GNAT.Debug_Utilities (g-debuti.ads)::
589 * GNAT.Decode_String (g-decstr.ads)::
590 * GNAT.Decode_UTF8_String (g-deutst.ads)::
591 * GNAT.Directory_Operations (g-dirope.ads)::
592 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
593 * GNAT.Dynamic_HTables (g-dynhta.ads)::
594 * GNAT.Dynamic_Tables (g-dyntab.ads)::
595 * GNAT.Encode_String (g-encstr.ads)::
596 * GNAT.Encode_UTF8_String (g-enutst.ads)::
597 * GNAT.Exception_Actions (g-excact.ads)::
598 * GNAT.Exception_Traces (g-exctra.ads)::
599 * GNAT.Exceptions (g-except.ads)::
600 * GNAT.Expect (g-expect.ads)::
601 * GNAT.Expect.TTY (g-exptty.ads)::
602 * GNAT.Float_Control (g-flocon.ads)::
603 * GNAT.Formatted_String (g-forstr.ads)::
604 * GNAT.Heap_Sort (g-heasor.ads)::
605 * GNAT.Heap_Sort_A (g-hesora.ads)::
606 * GNAT.Heap_Sort_G (g-hesorg.ads)::
607 * GNAT.HTable (g-htable.ads)::
608 * GNAT.IO (g-io.ads)::
609 * GNAT.IO_Aux (g-io_aux.ads)::
610 * GNAT.Lock_Files (g-locfil.ads)::
611 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
612 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
613 * GNAT.MD5 (g-md5.ads)::
614 * GNAT.Memory_Dump (g-memdum.ads)::
615 * GNAT.Most_Recent_Exception (g-moreex.ads)::
616 * GNAT.OS_Lib (g-os_lib.ads)::
617 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
618 * GNAT.Random_Numbers (g-rannum.ads)::
619 * GNAT.Regexp (g-regexp.ads)::
620 * GNAT.Registry (g-regist.ads)::
621 * GNAT.Regpat (g-regpat.ads)::
622 * GNAT.Rewrite_Data (g-rewdat.ads)::
623 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
624 * GNAT.Semaphores (g-semaph.ads)::
625 * GNAT.Serial_Communications (g-sercom.ads)::
626 * GNAT.SHA1 (g-sha1.ads)::
627 * GNAT.SHA224 (g-sha224.ads)::
628 * GNAT.SHA256 (g-sha256.ads)::
629 * GNAT.SHA384 (g-sha384.ads)::
630 * GNAT.SHA512 (g-sha512.ads)::
631 * GNAT.Signals (g-signal.ads)::
632 * GNAT.Sockets (g-socket.ads)::
633 * GNAT.Source_Info (g-souinf.ads)::
634 * GNAT.Spelling_Checker (g-speche.ads)::
635 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
636 * GNAT.Spitbol.Patterns (g-spipat.ads)::
637 * GNAT.Spitbol (g-spitbo.ads)::
638 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
639 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
640 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
641 * GNAT.SSE (g-sse.ads)::
642 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
643 * GNAT.Strings (g-string.ads)::
644 * GNAT.String_Split (g-strspl.ads)::
645 * GNAT.Table (g-table.ads)::
646 * GNAT.Task_Lock (g-tasloc.ads)::
647 * GNAT.Threads (g-thread.ads)::
648 * GNAT.Time_Stamp (g-timsta.ads)::
649 * GNAT.Traceback (g-traceb.ads)::
650 * GNAT.Traceback.Symbolic (g-trasym.ads)::
651 * GNAT.UTF_32 (g-utf_32.ads)::
652 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
653 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
654 * GNAT.Wide_String_Split (g-wistsp.ads)::
655 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
656 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
657 * Interfaces.C.Extensions (i-cexten.ads)::
658 * Interfaces.C.Streams (i-cstrea.ads)::
659 * Interfaces.Packed_Decimal (i-pacdec.ads)::
660 * Interfaces.VxWorks (i-vxwork.ads)::
661 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
662 * System.Address_Image (s-addima.ads)::
663 * System.Assertions (s-assert.ads)::
664 * System.Atomic_Counters (s-atocou.ads)::
665 * System.Memory (s-memory.ads)::
666 * System.Multiprocessors (s-multip.ads)::
667 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
668 * System.Partition_Interface (s-parint.ads)::
669 * System.Pool_Global (s-pooglo.ads)::
670 * System.Pool_Local (s-pooloc.ads)::
671 * System.Restrictions (s-restri.ads)::
672 * System.Rident (s-rident.ads)::
673 * System.Strings.Stream_Ops (s-ststop.ads)::
674 * System.Unsigned_Types (s-unstyp.ads)::
675 * System.Wch_Cnv (s-wchcnv.ads)::
676 * System.Wch_Con (s-wchcon.ads)::
678 Text_IO
680 * Text_IO Stream Pointer Positioning::
681 * Text_IO Reading and Writing Non-Regular Files::
682 * Get_Immediate::
683 * Treating Text_IO Files as Streams::
684 * Text_IO Extensions::
685 * Text_IO Facilities for Unbounded Strings::
687 Wide_Text_IO
689 * Wide_Text_IO Stream Pointer Positioning::
690 * Wide_Text_IO Reading and Writing Non-Regular Files::
692 Wide_Wide_Text_IO
694 * Wide_Wide_Text_IO Stream Pointer Positioning::
695 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
697 Interfacing to Other Languages
699 * Interfacing to C::
700 * Interfacing to C++::
701 * Interfacing to COBOL::
702 * Interfacing to Fortran::
703 * Interfacing to non-GNAT Ada code::
705 Specialized Needs Annexes
707 Implementation of Specific Ada Features
708 * Machine Code Insertions::
709 * GNAT Implementation of Tasking::
710 * GNAT Implementation of Shared Passive Packages::
711 * Code Generation for Array Aggregates::
712 * The Size of Discriminated Records with Default Discriminants::
713 * Strict Conformance to the Ada Reference Manual::
715 Implementation of Ada 2012 Features
717 Obsolescent Features
719 GNU Free Documentation License
721 Index
722 @end detailmenu
723 @end menu
725 @end ifnottex
727 @node About This Guide
728 @unnumbered About This Guide
730 @noindent
731 This manual contains useful information in writing programs using the
732 @value{EDITION} compiler.  It includes information on implementation dependent
733 characteristics of @value{EDITION}, including all the information required by
734 Annex M of the Ada language standard.
736 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
737 invoked in Ada 83 compatibility mode.
738 By default, @value{EDITION} assumes Ada 2012,
739 but you can override with a compiler switch
740 to explicitly specify the language version.
741 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
742 @value{EDITION} User's Guide}, for details on these switches.)
743 Throughout this manual, references to ``Ada'' without a year suffix
744 apply to all the Ada versions of the language.
746 Ada is designed to be highly portable.
747 In general, a program will have the same effect even when compiled by
748 different compilers on different platforms.
749 However, since Ada is designed to be used in a
750 wide variety of applications, it also contains a number of system
751 dependent features to be used in interfacing to the external world.
752 @cindex Implementation-dependent features
753 @cindex Portability
755 Note: Any program that makes use of implementation-dependent features
756 may be non-portable.  You should follow good programming practice and
757 isolate and clearly document any sections of your program that make use
758 of these features in a non-portable manner.
760 @ifset PROEDITION
761 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
762 ``GNAT'' in the remainder of this document.
763 @end ifset
765 @menu
766 * What This Reference Manual Contains::
767 * Conventions::
768 * Related Information::
769 @end menu
771 @node What This Reference Manual Contains
772 @unnumberedsec What This Reference Manual Contains
774 @noindent
775 This reference manual contains the following chapters:
777 @itemize @bullet
778 @item
779 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
780 pragmas, which can be used to extend and enhance the functionality of the
781 compiler.
783 @item
784 @ref{Implementation Defined Attributes}, lists GNAT
785 implementation-dependent attributes, which can be used to extend and
786 enhance the functionality of the compiler.
788 @item
789 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
790 implementation-dependent restrictions, which can be used to extend and
791 enhance the functionality of the compiler.
793 @item
794 @ref{Implementation Advice}, provides information on generally
795 desirable behavior which are not requirements that all compilers must
796 follow since it cannot be provided on all systems, or which may be
797 undesirable on some systems.
799 @item
800 @ref{Implementation Defined Characteristics}, provides a guide to
801 minimizing implementation dependent features.
803 @item
804 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
805 implemented by GNAT, and how they can be imported into user
806 application programs.
808 @item
809 @ref{Representation Clauses and Pragmas}, describes in detail the
810 way that GNAT represents data, and in particular the exact set
811 of representation clauses and pragmas that is accepted.
813 @item
814 @ref{Standard Library Routines}, provides a listing of packages and a
815 brief description of the functionality that is provided by Ada's
816 extensive set of standard library routines as implemented by GNAT@.
818 @item
819 @ref{The Implementation of Standard I/O}, details how the GNAT
820 implementation of the input-output facilities.
822 @item
823 @ref{The GNAT Library}, is a catalog of packages that complement
824 the Ada predefined library.
826 @item
827 @ref{Interfacing to Other Languages}, describes how programs
828 written in Ada using GNAT can be interfaced to other programming
829 languages.
831 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
832 of the specialized needs annexes.
834 @item
835 @ref{Implementation of Specific Ada Features}, discusses issues related
836 to GNAT's implementation of machine code insertions, tasking, and several
837 other features.
839 @item
840 @ref{Implementation of Ada 2012 Features}, describes the status of the
841 GNAT implementation of the Ada 2012 language standard.
843 @item
844 @ref{Obsolescent Features} documents implementation dependent features,
845 including pragmas and attributes, which are considered obsolescent, since
846 there are other preferred ways of achieving the same results. These
847 obsolescent forms are retained for backwards compatibility.
849 @end itemize
851 @cindex Ada 95 Language Reference Manual
852 @cindex Ada 2005 Language Reference Manual
853 @noindent
854 This reference manual assumes a basic familiarity with the Ada 95 language, as
855 described in the International Standard ANSI/ISO/IEC-8652:1995,
856 January 1995.
857 It does not require knowledge of the new features introduced by Ada 2005,
858 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
859 and Amendment 1).
860 Both reference manuals are included in the GNAT documentation
861 package.
863 @node Conventions
864 @unnumberedsec Conventions
865 @cindex Conventions, typographical
866 @cindex Typographical conventions
868 @noindent
869 Following are examples of the typographical and graphic conventions used
870 in this guide:
872 @itemize @bullet
873 @item
874 @code{Functions}, @code{utility program names}, @code{standard names},
875 and @code{classes}.
877 @item
878 @code{Option flags}
880 @item
881 @file{File names}, @samp{button names}, and @samp{field names}.
883 @item
884 @code{Variables}, @env{environment variables}, and @var{metasyntactic
885 variables}.
887 @item
888 @emph{Emphasis}.
890 @item
891 [optional information or parameters]
893 @item
894 Examples are described by text
895 @smallexample
896 and then shown this way.
897 @end smallexample
898 @end itemize
900 @noindent
901 Commands that are entered by the user are preceded in this manual by the
902 characters @samp{$ } (dollar sign followed by space).  If your system uses this
903 sequence as a prompt, then the commands will appear exactly as you see them
904 in the manual.  If your system uses some other prompt, then the command will
905 appear with the @samp{$} replaced by whatever prompt character you are using.
907 @node Related Information
908 @unnumberedsec Related Information
909 @noindent
910 See the following documents for further information on GNAT:
912 @itemize @bullet
913 @item
914 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
915 @value{EDITION} User's Guide}, which provides information on how to use the
916 GNAT compiler system.
918 @item
919 @cite{Ada 95 Reference Manual}, which contains all reference
920 material for the Ada 95 programming language.
922 @item
923 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
924 of the Ada 95 standard.  The annotations describe
925 detailed aspects of the design decision, and in particular contain useful
926 sections on Ada 83 compatibility.
928 @item
929 @cite{Ada 2005 Reference Manual}, which contains all reference
930 material for the Ada 2005 programming language.
932 @item
933 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
934 of the Ada 2005 standard.  The annotations describe
935 detailed aspects of the design decision, and in particular contain useful
936 sections on Ada 83 and Ada 95 compatibility.
938 @item
939 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
940 which contains specific information on compatibility between GNAT and
941 DEC Ada 83 systems.
943 @item
944 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
945 describes in detail the pragmas and attributes provided by the DEC Ada 83
946 compiler system.
948 @end itemize
950 @node Implementation Defined Pragmas
951 @chapter Implementation Defined Pragmas
953 @noindent
954 Ada defines a set of pragmas that can be used to supply additional
955 information to the compiler.  These language defined pragmas are
956 implemented in GNAT and work as described in the Ada Reference Manual.
958 In addition, Ada allows implementations to define additional pragmas
959 whose meaning is defined by the implementation.  GNAT provides a number
960 of these implementation-defined pragmas, which can be used to extend
961 and enhance the functionality of the compiler.  This section of the GNAT
962 Reference Manual describes these additional pragmas.
964 Note that any program using these pragmas might not be portable to other
965 compilers (although GNAT implements this set of pragmas on all
966 platforms).  Therefore if portability to other compilers is an important
967 consideration, the use of these pragmas should be minimized.
969 @menu
970 * Pragma Abort_Defer::
971 * Pragma Abstract_State::
972 * Pragma Ada_83::
973 * Pragma Ada_95::
974 * Pragma Ada_05::
975 * Pragma Ada_2005::
976 * Pragma Ada_12::
977 * Pragma Ada_2012::
978 * Pragma Allow_Integer_Address::
979 * Pragma Annotate::
980 * Pragma Assert::
981 * Pragma Assert_And_Cut::
982 * Pragma Assertion_Policy::
983 * Pragma Assume::
984 * Pragma Assume_No_Invalid_Values::
985 * Pragma AST_Entry::
986 * Pragma Async_Readers::
987 * Pragma Async_Writers::
988 * Pragma Attribute_Definition::
989 * Pragma C_Pass_By_Copy::
990 * Pragma Check::
991 * Pragma Check_Float_Overflow::
992 * Pragma Check_Name::
993 * Pragma Check_Policy::
994 * Pragma CIL_Constructor::
995 * Pragma Comment::
996 * Pragma Common_Object::
997 * Pragma Compile_Time_Error::
998 * Pragma Compile_Time_Warning::
999 * Pragma Compiler_Unit::
1000 * Pragma Compiler_Unit_Warning::
1001 * Pragma Complete_Representation::
1002 * Pragma Complex_Representation::
1003 * Pragma Component_Alignment::
1004 * Pragma Contract_Cases::
1005 * Pragma Convention_Identifier::
1006 * Pragma CPP_Class::
1007 * Pragma CPP_Constructor::
1008 * Pragma CPP_Virtual::
1009 * Pragma CPP_Vtable::
1010 * Pragma CPU::
1011 * Pragma Debug::
1012 * Pragma Debug_Policy::
1013 * Pragma Default_Scalar_Storage_Order::
1014 * Pragma Default_Storage_Pool::
1015 * Pragma Depends::
1016 * Pragma Detect_Blocking::
1017 * Pragma Disable_Atomic_Synchronization::
1018 * Pragma Dispatching_Domain::
1019 * Pragma Effective_Reads::
1020 * Pragma Effective_Writes::
1021 * Pragma Elaboration_Checks::
1022 * Pragma Eliminate::
1023 * Pragma Enable_Atomic_Synchronization::
1024 * Pragma Export_Exception::
1025 * Pragma Export_Function::
1026 * Pragma Export_Object::
1027 * Pragma Export_Procedure::
1028 * Pragma Export_Value::
1029 * Pragma Export_Valued_Procedure::
1030 * Pragma Extend_System::
1031 * Pragma Extensions_Allowed::
1032 * Pragma External::
1033 * Pragma External_Name_Casing::
1034 * Pragma Fast_Math::
1035 * Pragma Favor_Top_Level::
1036 * Pragma Finalize_Storage_Only::
1037 * Pragma Float_Representation::
1038 * Pragma Global::
1039 * Pragma Ident::
1040 * Pragma Implementation_Defined::
1041 * Pragma Implemented::
1042 * Pragma Implicit_Packing::
1043 * Pragma Import_Exception::
1044 * Pragma Import_Function::
1045 * Pragma Import_Object::
1046 * Pragma Import_Procedure::
1047 * Pragma Import_Valued_Procedure::
1048 * Pragma Independent::
1049 * Pragma Independent_Components::
1050 * Pragma Initial_Condition::
1051 * Pragma Initialize_Scalars::
1052 * Pragma Initializes::
1053 * Pragma Inline_Always::
1054 * Pragma Inline_Generic::
1055 * Pragma Interface::
1056 * Pragma Interface_Name::
1057 * Pragma Interrupt_Handler::
1058 * Pragma Interrupt_State::
1059 * Pragma Invariant::
1060 * Pragma Java_Constructor::
1061 * Pragma Java_Interface::
1062 * Pragma Keep_Names::
1063 * Pragma License::
1064 * Pragma Link_With::
1065 * Pragma Linker_Alias::
1066 * Pragma Linker_Constructor::
1067 * Pragma Linker_Destructor::
1068 * Pragma Linker_Section::
1069 * Pragma Lock_Free::
1070 * Pragma Long_Float::
1071 * Pragma Loop_Invariant::
1072 * Pragma Loop_Optimize::
1073 * Pragma Loop_Variant::
1074 * Pragma Machine_Attribute::
1075 * Pragma Main::
1076 * Pragma Main_Storage::
1077 * Pragma No_Body::
1078 * Pragma No_Elaboration_Code_All::
1079 * Pragma No_Inline::
1080 * Pragma No_Return::
1081 * Pragma No_Run_Time::
1082 * Pragma No_Strict_Aliasing::
1083 * Pragma Normalize_Scalars::
1084 * Pragma Obsolescent::
1085 * Pragma Optimize_Alignment::
1086 * Pragma Ordered::
1087 * Pragma Overflow_Mode::
1088 * Pragma Overriding_Renamings::
1089 * Pragma Partition_Elaboration_Policy::
1090 * Pragma Part_Of::
1091 * Pragma Passive::
1092 * Pragma Persistent_BSS::
1093 * Pragma Polling::
1094 * Pragma Post::
1095 * Pragma Postcondition::
1096 * Pragma Post_Class::
1097 * Pragma Pre::
1098 * Pragma Precondition::
1099 * Pragma Predicate::
1100 * Pragma Preelaborable_Initialization::
1101 * Pragma Prefix_Exception_Messages::
1102 * Pragma Pre_Class::
1103 * Pragma Priority_Specific_Dispatching::
1104 * Pragma Profile::
1105 * Pragma Profile_Warnings::
1106 * Pragma Propagate_Exceptions::
1107 * Pragma Provide_Shift_Operators::
1108 * Pragma Psect_Object::
1109 * Pragma Pure_Function::
1110 * Pragma Rational::
1111 * Pragma Ravenscar::
1112 * Pragma Refined_Depends::
1113 * Pragma Refined_Global::
1114 * Pragma Refined_Post::
1115 * Pragma Refined_State::
1116 * Pragma Relative_Deadline::
1117 * Pragma Remote_Access_Type::
1118 * Pragma Restricted_Run_Time::
1119 * Pragma Restriction_Warnings::
1120 * Pragma Reviewable::
1121 * Pragma Share_Generic::
1122 * Pragma Shared::
1123 * Pragma Short_Circuit_And_Or::
1124 * Pragma Short_Descriptors::
1125 * Pragma Simple_Storage_Pool_Type::
1126 * Pragma Source_File_Name::
1127 * Pragma Source_File_Name_Project::
1128 * Pragma Source_Reference::
1129 * Pragma SPARK_Mode::
1130 * Pragma Static_Elaboration_Desired::
1131 * Pragma Stream_Convert::
1132 * Pragma Style_Checks::
1133 * Pragma Subtitle::
1134 * Pragma Suppress::
1135 * Pragma Suppress_All::
1136 * Pragma Suppress_Debug_Info::
1137 * Pragma Suppress_Exception_Locations::
1138 * Pragma Suppress_Initialization::
1139 * Pragma Task_Name::
1140 * Pragma Task_Storage::
1141 * Pragma Test_Case::
1142 * Pragma Thread_Local_Storage::
1143 * Pragma Time_Slice::
1144 * Pragma Title::
1145 * Pragma Type_Invariant::
1146 * Pragma Type_Invariant_Class::
1147 * Pragma Unchecked_Union::
1148 * Pragma Unevaluated_Use_Of_Old::
1149 * Pragma Unimplemented_Unit::
1150 * Pragma Universal_Aliasing ::
1151 * Pragma Universal_Data::
1152 * Pragma Unmodified::
1153 * Pragma Unreferenced::
1154 * Pragma Unreferenced_Objects::
1155 * Pragma Unreserve_All_Interrupts::
1156 * Pragma Unsuppress::
1157 * Pragma Use_VADS_Size::
1158 * Pragma Validity_Checks::
1159 * Pragma Volatile::
1160 * Pragma Warning_As_Error::
1161 * Pragma Warnings::
1162 * Pragma Weak_External::
1163 * Pragma Wide_Character_Encoding::
1164 @end menu
1166 @node Pragma Abort_Defer
1167 @unnumberedsec Pragma Abort_Defer
1168 @findex Abort_Defer
1169 @cindex Deferring aborts
1170 @noindent
1171 Syntax:
1172 @smallexample
1173 pragma Abort_Defer;
1174 @end smallexample
1176 @noindent
1177 This pragma must appear at the start of the statement sequence of a
1178 handled sequence of statements (right after the @code{begin}).  It has
1179 the effect of deferring aborts for the sequence of statements (but not
1180 for the declarations or handlers, if any, associated with this statement
1181 sequence).
1183 @node Pragma Abstract_State
1184 @unnumberedsec Pragma Abstract_State
1185 @findex Abstract_State
1186 @noindent
1187 For the description of this pragma, see SPARK 2014 Reference Manual,
1188 section 7.1.4.
1190 @node Pragma Ada_83
1191 @unnumberedsec Pragma Ada_83
1192 @findex Ada_83
1193 @noindent
1194 Syntax:
1195 @smallexample @c ada
1196 pragma Ada_83;
1197 @end smallexample
1199 @noindent
1200 A configuration pragma that establishes Ada 83 mode for the unit to
1201 which it applies, regardless of the mode set by the command line
1202 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
1203 the syntax and semantics of Ada 83, as defined in the original Ada
1204 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
1205 and Ada 2005 are not recognized, optional package bodies are allowed,
1206 and generics may name types with unknown discriminants without using
1207 the @code{(<>)} notation.  In addition, some but not all of the additional
1208 restrictions of Ada 83 are enforced.
1210 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
1211 Ada 83 code to be compiled and adapted to GNAT with less effort.
1212 Secondly, it aids in keeping code backwards compatible with Ada 83.
1213 However, there is no guarantee that code that is processed correctly
1214 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1215 83 compiler, since GNAT does not enforce all the additional checks
1216 required by Ada 83.
1218 @node Pragma Ada_95
1219 @unnumberedsec Pragma Ada_95
1220 @findex Ada_95
1221 @noindent
1222 Syntax:
1223 @smallexample @c ada
1224 pragma Ada_95;
1225 @end smallexample
1227 @noindent
1228 A configuration pragma that establishes Ada 95 mode for the unit to which
1229 it applies, regardless of the mode set by the command line switches.
1230 This mode is set automatically for the @code{Ada} and @code{System}
1231 packages and their children, so you need not specify it in these
1232 contexts.  This pragma is useful when writing a reusable component that
1233 itself uses Ada 95 features, but which is intended to be usable from
1234 either Ada 83 or Ada 95 programs.
1236 @node Pragma Ada_05
1237 @unnumberedsec Pragma Ada_05
1238 @findex Ada_05
1239 @noindent
1240 Syntax:
1241 @smallexample @c ada
1242 pragma Ada_05;
1243 pragma Ada_05 (local_NAME);
1244 @end smallexample
1246 @noindent
1247 A configuration pragma that establishes Ada 2005 mode for the unit to which
1248 it applies, regardless of the mode set by the command line switches.
1249 This pragma is useful when writing a reusable component that
1250 itself uses Ada 2005 features, but which is intended to be usable from
1251 either Ada 83 or Ada 95 programs.
1253 The one argument form (which is not a configuration pragma)
1254 is used for managing the transition from
1255 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1256 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1257 mode will generate a warning. In addition, in Ada_83 or Ada_95
1258 mode, a preference rule is established which does not choose
1259 such an entity unless it is unambiguously specified. This avoids
1260 extra subprograms marked this way from generating ambiguities in
1261 otherwise legal pre-Ada_2005 programs. The one argument form is
1262 intended for exclusive use in the GNAT run-time library.
1264 @node Pragma Ada_2005
1265 @unnumberedsec Pragma Ada_2005
1266 @findex Ada_2005
1267 @noindent
1268 Syntax:
1269 @smallexample @c ada
1270 pragma Ada_2005;
1271 @end smallexample
1273 @noindent
1274 This configuration pragma is a synonym for pragma Ada_05 and has the
1275 same syntax and effect.
1277 @node Pragma Ada_12
1278 @unnumberedsec Pragma Ada_12
1279 @findex Ada_12
1280 @noindent
1281 Syntax:
1282 @smallexample @c ada
1283 pragma Ada_12;
1284 pragma Ada_12 (local_NAME);
1285 @end smallexample
1287 @noindent
1288 A configuration pragma that establishes Ada 2012 mode for the unit to which
1289 it applies, regardless of the mode set by the command line switches.
1290 This mode is set automatically for the @code{Ada} and @code{System}
1291 packages and their children, so you need not specify it in these
1292 contexts.  This pragma is useful when writing a reusable component that
1293 itself uses Ada 2012 features, but which is intended to be usable from
1294 Ada 83, Ada 95, or Ada 2005 programs.
1296 The one argument form, which is not a configuration pragma,
1297 is used for managing the transition from Ada
1298 2005 to Ada 2012 in the run-time library. If an entity is marked
1299 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1300 mode will generate a warning. In addition, in any pre-Ada_2012
1301 mode, a preference rule is established which does not choose
1302 such an entity unless it is unambiguously specified. This avoids
1303 extra subprograms marked this way from generating ambiguities in
1304 otherwise legal pre-Ada_2012 programs. The one argument form is
1305 intended for exclusive use in the GNAT run-time library.
1307 @node Pragma Ada_2012
1308 @unnumberedsec Pragma Ada_2012
1309 @findex Ada_2005
1310 @noindent
1311 Syntax:
1312 @smallexample @c ada
1313 pragma Ada_2012;
1314 @end smallexample
1316 @noindent
1317 This configuration pragma is a synonym for pragma Ada_12 and has the
1318 same syntax and effect.
1320 @node Pragma Allow_Integer_Address
1321 @unnumberedsec Pragma Allow_Integer_Address
1322 @findex Allow_Integer_Address
1323 @noindent
1324 Syntax:
1325 @smallexample @c ada
1326 pragma Allow_Integer_Address;
1327 @end smallexample
1329 @noindent
1330 In almost all versions of GNAT, @code{System.Address} is a private
1331 type in accordance with the implementation advice in the RM. This
1332 means that integer values,
1333 in particular integer literals, are not allowed as address values.
1334 If the configuration pragma
1335 @code{Allow_Integer_Address} is given, then integer expressions may
1336 be used anywhere a value of type @code{System.Address} is required.
1337 The effect is to introduce an implicit unchecked conversion from the
1338 integer value to type @code{System.Address}. The reverse case of using
1339 an address where an integer type is required is handled analogously.
1340 The following example compiles without errors:
1342 @smallexample @c ada
1343 pragma Allow_Integer_Address;
1344 with System; use System;
1345 package AddrAsInt is
1346    X : Integer;
1347    Y : Integer;
1348    for X'Address use 16#1240#;
1349    for Y use at 16#3230#;
1350    m : Address := 16#4000#;
1351    n : constant Address := 4000;
1352    p : constant Address := Address (X + Y);
1353    v : Integer := y'Address;
1354    w : constant Integer := Integer (Y'Address);
1355    type R is new integer;
1356    RR : R := 1000;
1357    Z : Integer;
1358    for Z'Address use RR;
1359 end AddrAsInt;
1360 @end smallexample
1362 @noindent
1363 Note that pragma @code{Allow_Integer_Address} is ignored if
1364 @code{System.Address}
1365 is not a private type. In implementations of @code{GNAT} where
1366 System.Address is a visible integer type (notably the implementations
1367 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1368 rather than rejected to allow common sets of sources to be used
1369 in the two situations.
1371 @node Pragma Annotate
1372 @unnumberedsec Pragma Annotate
1373 @findex Annotate
1374 @noindent
1375 Syntax:
1376 @smallexample @c ada
1377 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}] [entity => local_NAME]);
1379 ARG ::= NAME | EXPRESSION
1380 @end smallexample
1382 @noindent
1383 This pragma is used to annotate programs.  @var{identifier} identifies
1384 the type of annotation.  GNAT verifies that it is an identifier, but does
1385 not otherwise analyze it. The second optional identifier is also left
1386 unanalyzed, and by convention is used to control the action of the tool to
1387 which the annotation is addressed.  The remaining @var{arg} arguments
1388 can be either string literals or more generally expressions.
1389 String literals are assumed to be either of type
1390 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1391 depending on the character literals they contain.
1392 All other kinds of arguments are analyzed as expressions, and must be
1393 unambiguous. The last argument if present must have the identifier
1394 @code{Entity} and GNAT verifies that a local name is given.
1396 The analyzed pragma is retained in the tree, but not otherwise processed
1397 by any part of the GNAT compiler, except to generate corresponding note
1398 lines in the generated ALI file. For the format of these note lines, see
1399 the compiler source file lib-writ.ads. This pragma is intended for use by
1400 external tools, including ASIS@. The use of pragma Annotate does not
1401 affect the compilation process in any way. This pragma may be used as
1402 a configuration pragma.
1404 @node Pragma Assert
1405 @unnumberedsec Pragma Assert
1406 @findex Assert
1407 @noindent
1408 Syntax:
1409 @smallexample @c ada
1410 pragma Assert (
1411   boolean_EXPRESSION
1412   [, string_EXPRESSION]);
1413 @end smallexample
1415 @noindent
1416 The effect of this pragma depends on whether the corresponding command
1417 line switch is set to activate assertions.  The pragma expands into code
1418 equivalent to the following:
1420 @smallexample @c ada
1421 if assertions-enabled then
1422    if not boolean_EXPRESSION then
1423       System.Assertions.Raise_Assert_Failure
1424         (string_EXPRESSION);
1425    end if;
1426 end if;
1427 @end smallexample
1429 @noindent
1430 The string argument, if given, is the message that will be associated
1431 with the exception occurrence if the exception is raised.  If no second
1432 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1433 where @var{file} is the name of the source file containing the assert,
1434 and @var{nnn} is the line number of the assert.  A pragma is not a
1435 statement, so if a statement sequence contains nothing but a pragma
1436 assert, then a null statement is required in addition, as in:
1438 @smallexample @c ada
1439 @dots{}
1440 if J > 3 then
1441    pragma Assert (K > 3, "Bad value for K");
1442    null;
1443 end if;
1444 @end smallexample
1446 @noindent
1447 Note that, as with the @code{if} statement to which it is equivalent, the
1448 type of the expression is either @code{Standard.Boolean}, or any type derived
1449 from this standard type.
1451 Assert checks can be either checked or ignored. By default they are ignored.
1452 They will be checked if either the command line switch @option{-gnata} is
1453 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1454 to enable @code{Assert_Checks}.
1456 If assertions are ignored, then there
1457 is no run-time effect (and in particular, any side effects from the
1458 expression will not occur at run time).  (The expression is still
1459 analyzed at compile time, and may cause types to be frozen if they are
1460 mentioned here for the first time).
1462 If assertions are checked, then the given expression is tested, and if
1463 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1464 which results in the raising of @code{Assert_Failure} with the given message.
1466 You should generally avoid side effects in the expression arguments of
1467 this pragma, because these side effects will turn on and off with the
1468 setting of the assertions mode, resulting in assertions that have an
1469 effect on the program.  However, the expressions are analyzed for
1470 semantic correctness whether or not assertions are enabled, so turning
1471 assertions on and off cannot affect the legality of a program.
1473 Note that the implementation defined policy @code{DISABLE}, given in a
1474 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1476 Note: this is a standard language-defined pragma in versions
1477 of Ada from 2005 on. In GNAT, it is implemented in all versions
1478 of Ada, and the DISABLE policy is an implementation-defined
1479 addition.
1481 @node Pragma Assert_And_Cut
1482 @unnumberedsec Pragma Assert_And_Cut
1483 @findex Assert_And_Cut
1484 @noindent
1485 Syntax:
1486 @smallexample @c ada
1487 pragma Assert_And_Cut (
1488   boolean_EXPRESSION
1489   [, string_EXPRESSION]);
1490 @end smallexample
1492 @noindent
1493 The effect of this pragma is identical to that of pragma @code{Assert},
1494 except that in an @code{Assertion_Policy} pragma, the identifier
1495 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1496 (or disabled).
1498 The intention is that this be used within a subprogram when the
1499 given test expresion sums up all the work done so far in the
1500 subprogram, so that the rest of the subprogram can be verified
1501 (informally or formally) using only the entry preconditions,
1502 and the expression in this pragma. This allows dividing up
1503 a subprogram into sections for the purposes of testing or
1504 formal verification. The pragma also serves as useful
1505 documentation.
1507 @node Pragma Assertion_Policy
1508 @unnumberedsec Pragma Assertion_Policy
1509 @findex Assertion_Policy
1510 @noindent
1511 Syntax:
1512 @smallexample @c ada
1513 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1515 pragma Assertion_Policy (
1516     ASSERTION_KIND => POLICY_IDENTIFIER
1517  @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1519 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1521 RM_ASSERTION_KIND ::= Assert               |
1522                       Static_Predicate     |
1523                       Dynamic_Predicate    |
1524                       Pre                  |
1525                       Pre'Class            |
1526                       Post                 |
1527                       Post'Class           |
1528                       Type_Invariant       |
1529                       Type_Invariant'Class
1531 ID_ASSERTION_KIND ::= Assertions           |
1532                       Assert_And_Cut       |
1533                       Assume               |
1534                       Contract_Cases       |
1535                       Debug                |
1536                       Invariant            |
1537                       Invariant'Class      |
1538                       Loop_Invariant       |
1539                       Loop_Variant         |
1540                       Postcondition        |
1541                       Precondition         |
1542                       Predicate            |
1543                       Refined_Post         |
1544                       Statement_Assertions
1546 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1547 @end smallexample
1549 @noindent
1550 This is a standard Ada 2012 pragma that is available as an
1551 implementation-defined pragma in earlier versions of Ada.
1552 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1553 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1554 are implementation defined additions recognized by the GNAT compiler.
1556 The pragma applies in both cases to pragmas and aspects with matching
1557 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1558 applies to both the @code{Precondition} pragma
1559 and the aspect @code{Precondition}. Note that the identifiers for
1560 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1561 Pre_Class and Post_Class), since these pragmas are intended to be
1562 identical to the corresponding aspects).
1564 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1565 the corresponding pragma or aspect is activated.
1566 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1567 the corresponding pragma or aspect is deactivated.
1568 This pragma overrides the effect of the @option{-gnata} switch on the
1569 command line.
1571 The implementation defined policy @code{DISABLE} is like
1572 @code{IGNORE} except that it completely disables semantic
1573 checking of the corresponding pragma or aspect. This is
1574 useful when the pragma or aspect argument references subprograms
1575 in a with'ed package which is replaced by a dummy package
1576 for the final build.
1578 The implementation defined assertion kind @code{Assertions} applies to all
1579 assertion kinds. The form with no assertion kind given implies this
1580 choice, so it applies to all assertion kinds (RM defined, and
1581 implementation defined).
1583 The implementation defined assertion kind @code{Statement_Assertions}
1584 applies to @code{Assert}, @code{Assert_And_Cut},
1585 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1587 @node Pragma Assume
1588 @unnumberedsec Pragma Assume
1589 @findex Assume
1590 @noindent
1591 Syntax:
1592 @smallexample @c ada
1593 pragma Assume (
1594   boolean_EXPRESSION
1595   [, string_EXPRESSION]);
1596 @end smallexample
1598 @noindent
1599 The effect of this pragma is identical to that of pragma @code{Assert},
1600 except that in an @code{Assertion_Policy} pragma, the identifier
1601 @code{Assume} is used to control whether it is ignored or checked
1602 (or disabled).
1604 The intention is that this be used for assumptions about the
1605 external environment. So you cannot expect to verify formally
1606 or informally that the condition is met, this must be
1607 established by examining things outside the program itself.
1608 For example, we may have code that depends on the size of
1609 @code{Long_Long_Integer} being at least 64. So we could write:
1611 @smallexample @c ada
1612 pragma Assume (Long_Long_Integer'Size >= 64);
1613 @end smallexample
1615 @noindent
1616 This assumption cannot be proved from the program itself,
1617 but it acts as a useful run-time check that the assumption
1618 is met, and documents the need to ensure that it is met by
1619 reference to information outside the program.
1621 @node Pragma Assume_No_Invalid_Values
1622 @unnumberedsec Pragma Assume_No_Invalid_Values
1623 @findex Assume_No_Invalid_Values
1624 @cindex Invalid representations
1625 @cindex Invalid values
1626 @noindent
1627 Syntax:
1628 @smallexample @c ada
1629 pragma Assume_No_Invalid_Values (On | Off);
1630 @end smallexample
1632 @noindent
1633 This is a configuration pragma that controls the assumptions made by the
1634 compiler about the occurrence of invalid representations (invalid values)
1635 in the code.
1637 The default behavior (corresponding to an Off argument for this pragma), is
1638 to assume that values may in general be invalid unless the compiler can
1639 prove they are valid. Consider the following example:
1641 @smallexample @c ada
1642 V1 : Integer range 1 .. 10;
1643 V2 : Integer range 11 .. 20;
1645 for J in V2 .. V1 loop
1646    ...
1647 end loop;
1648 @end smallexample
1650 @noindent
1651 if V1 and V2 have valid values, then the loop is known at compile
1652 time not to execute since the lower bound must be greater than the
1653 upper bound. However in default mode, no such assumption is made,
1654 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1655 is given, the compiler will assume that any occurrence of a variable
1656 other than in an explicit @code{'Valid} test always has a valid
1657 value, and the loop above will be optimized away.
1659 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1660 you know your code is free of uninitialized variables and other
1661 possible sources of invalid representations, and may result in
1662 more efficient code. A program that accesses an invalid representation
1663 with this pragma in effect is erroneous, so no guarantees can be made
1664 about its behavior.
1666 It is peculiar though permissible to use this pragma in conjunction
1667 with validity checking (-gnatVa). In such cases, accessing invalid
1668 values will generally give an exception, though formally the program
1669 is erroneous so there are no guarantees that this will always be the
1670 case, and it is recommended that these two options not be used together.
1672 @node Pragma Async_Readers
1673 @unnumberedsec Pragma Async_Readers
1674 @findex Async_Readers
1675 @noindent
1676 For the description of this pragma, see SPARK 2014 Reference Manual,
1677 section 7.1.2.
1679 @node Pragma Async_Writers
1680 @unnumberedsec Pragma Async_Writers
1681 @findex Async_Writers
1682 @noindent
1683 For the description of this pragma, see SPARK 2014 Reference Manual,
1684 section 7.1.2.
1686 @node Pragma AST_Entry
1687 @unnumberedsec Pragma AST_Entry
1688 @cindex OpenVMS
1689 @findex AST_Entry
1690 @noindent
1691 Syntax:
1692 @smallexample @c ada
1693 pragma AST_Entry (entry_IDENTIFIER);
1694 @end smallexample
1696 @noindent
1697 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1698 argument is the simple name of a single entry; at most one @code{AST_Entry}
1699 pragma is allowed for any given entry.  This pragma must be used in
1700 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1701 the entry declaration and in the same task type specification or single task
1702 as the entry to which it applies.  This pragma specifies that the given entry
1703 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1704 resulting from an OpenVMS system service call.  The pragma does not affect
1705 normal use of the entry.  For further details on this pragma, see the
1706 DEC Ada Language Reference Manual, section 9.12a.
1708 @node Pragma Attribute_Definition
1709 @unnumberedsec Pragma Attribute_Definition
1710 @findex Attribute_Definition
1711 @noindent
1712 Syntax:
1713 @smallexample @c ada
1714 pragma Attribute_Definition
1715   ([Attribute  =>] ATTRIBUTE_DESIGNATOR,
1716    [Entity     =>] LOCAL_NAME,
1717    [Expression =>] EXPRESSION | NAME);
1718 @end smallexample
1720 @noindent
1721 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1722 the attribute definition clause:
1724 @smallexample @c ada
1725   for Entity'Attribute use Expression;
1726 @end smallexample
1728 If @code{Attribute} is not a recognized attribute name, the pragma is
1729 ignored, and a warning is emitted. This allows source
1730 code to be written that takes advantage of some new attribute, while remaining
1731 compilable with earlier compilers.
1733 @node Pragma C_Pass_By_Copy
1734 @unnumberedsec Pragma C_Pass_By_Copy
1735 @cindex Passing by copy
1736 @findex C_Pass_By_Copy
1737 @noindent
1738 Syntax:
1739 @smallexample @c ada
1740 pragma C_Pass_By_Copy
1741   ([Max_Size =>] static_integer_EXPRESSION);
1742 @end smallexample
1744 @noindent
1745 Normally the default mechanism for passing C convention records to C
1746 convention subprograms is to pass them by reference, as suggested by RM
1747 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1748 this default, by requiring that record formal parameters be passed by
1749 copy if all of the following conditions are met:
1751 @itemize @bullet
1752 @item
1753 The size of the record type does not exceed the value specified for
1754 @code{Max_Size}.
1755 @item
1756 The record type has @code{Convention C}.
1757 @item
1758 The formal parameter has this record type, and the subprogram has a
1759 foreign (non-Ada) convention.
1760 @end itemize
1762 @noindent
1763 If these conditions are met the argument is passed by copy, i.e.@: in a
1764 manner consistent with what C expects if the corresponding formal in the
1765 C prototype is a struct (rather than a pointer to a struct).
1767 You can also pass records by copy by specifying the convention
1768 @code{C_Pass_By_Copy} for the record type, or by using the extended
1769 @code{Import} and @code{Export} pragmas, which allow specification of
1770 passing mechanisms on a parameter by parameter basis.
1772 @node Pragma Check
1773 @unnumberedsec Pragma Check
1774 @cindex Assertions
1775 @cindex Named assertions
1776 @findex Check
1777 @noindent
1778 Syntax:
1779 @smallexample @c ada
1780 pragma Check (
1781      [Name    =>] CHECK_KIND,
1782      [Check   =>] Boolean_EXPRESSION
1783   [, [Message =>] string_EXPRESSION] );
1785 CHECK_KIND ::= IDENTIFIER           |
1786                Pre'Class            |
1787                Post'Class           |
1788                Type_Invariant'Class |
1789                Invariant'Class
1790 @end smallexample
1792 @noindent
1793 This pragma is similar to the predefined pragma @code{Assert} except that an
1794 extra identifier argument is present. In conjunction with pragma
1795 @code{Check_Policy}, this can be used to define groups of assertions that can
1796 be independently controlled. The identifier @code{Assertion} is special, it
1797 refers to the normal set of pragma @code{Assert} statements.
1799 Checks introduced by this pragma are normally deactivated by default. They can
1800 be activated either by the command line option @option{-gnata}, which turns on
1801 all checks, or individually controlled using pragma @code{Check_Policy}.
1803 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1804 permitted as check kinds, since this would cause confusion with the use
1805 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1806 pragmas, where they are used to refer to sets of assertions.
1808 @node Pragma Check_Float_Overflow
1809 @unnumberedsec Pragma Check_Float_Overflow
1810 @cindex Floating-point overflow
1811 @findex Check_Float_Overflow
1812 @noindent
1813 Syntax:
1814 @smallexample @c ada
1815 pragma Check_Float_Overflow;
1816 @end smallexample
1818 @noindent
1819 In Ada, the predefined floating-point types (@code{Short_Float},
1820 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1821 defined to be @emph{unconstrained}. This means that even though each
1822 has a well-defined base range, an operation that delivers a result
1823 outside this base range is not required to raise an exception.
1824 This implementation permission accommodates the notion
1825 of infinities in IEEE floating-point, and corresponds to the
1826 efficient execution mode on most machines. GNAT will not raise
1827 overflow exceptions on these machines; instead it will generate
1828 infinities and NaN's as defined in the IEEE standard.
1830 Generating infinities, although efficient, is not always desirable.
1831 Often the preferable approach is to check for overflow, even at the
1832 (perhaps considerable) expense of run-time performance.
1833 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1834 range constraints -- and indeed such a subtype
1835 can have the same base range as its base type. For example:
1837 @smallexample @c ada
1838 subtype My_Float is Float range Float'Range;
1839 @end smallexample
1841 @noindent
1842 Here @code{My_Float} has the same range as
1843 @code{Float} but is constrained, so operations on
1844 @code{My_Float} values will be checked for overflow
1845 against this range.
1847 This style will achieve the desired goal, but
1848 it is often more convenient to be able to simply use
1849 the standard predefined floating-point types as long
1850 as overflow checking could be guaranteed.
1851 The @code{Check_Float_Overflow}
1852 configuration pragma achieves this effect. If a unit is compiled
1853 subject to this configuration pragma, then all operations
1854 on predefined floating-point types including operations on
1855 base types of these floating-point types will be treated as
1856 though those types were constrained, and overflow checks
1857 will be generated. The @code{Constraint_Error}
1858 exception is raised if the result is out of range.
1860 This mode can also be set by use of the compiler
1861 switch @option{-gnateF}.
1863 @node Pragma Check_Name
1864 @unnumberedsec Pragma Check_Name
1865 @cindex Defining check names
1866 @cindex Check names, defining
1867 @findex Check_Name
1868 @noindent
1869 Syntax:
1870 @smallexample @c ada
1871 pragma Check_Name (check_name_IDENTIFIER);
1872 @end smallexample
1874 @noindent
1875 This is a configuration pragma that defines a new implementation
1876 defined check name (unless IDENTIFIER matches one of the predefined
1877 check names, in which case the pragma has no effect). Check names
1878 are global to a partition, so if two or more configuration pragmas
1879 are present in a partition mentioning the same name, only one new
1880 check name is introduced.
1882 An implementation defined check name introduced with this pragma may
1883 be used in only three contexts: @code{pragma Suppress},
1884 @code{pragma Unsuppress},
1885 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1886 any of these three cases, the check name must be visible. A check
1887 name is visible if it is in the configuration pragmas applying to
1888 the current unit, or if it appears at the start of any unit that
1889 is part of the dependency set of the current unit (e.g., units that
1890 are mentioned in @code{with} clauses).
1892 Check names introduced by this pragma are subject to control by compiler
1893 switches (in particular -gnatp) in the usual manner.
1895 @node Pragma Check_Policy
1896 @unnumberedsec Pragma Check_Policy
1897 @cindex Controlling assertions
1898 @cindex Assertions, control
1899 @cindex Check pragma control
1900 @cindex Named assertions
1901 @findex Check
1902 @noindent
1903 Syntax:
1904 @smallexample @c ada
1905 pragma Check_Policy
1906  ([Name   =>] CHECK_KIND,
1907   [Policy =>] POLICY_IDENTIFIER);
1909 pragma Check_Policy (
1910     CHECK_KIND => POLICY_IDENTIFIER
1911  @{, CHECK_KIND => POLICY_IDENTIFIER@});
1913 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1915 CHECK_KIND ::= IDENTIFIER           |
1916                Pre'Class            |
1917                Post'Class           |
1918                Type_Invariant'Class |
1919                Invariant'Class
1921 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1922 avoids confusion between the two possible syntax forms for this pragma.
1924 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1925 @end smallexample
1927 @noindent
1928 This pragma is used to set the checking policy for assertions (specified
1929 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1930 to be checked using the @code{Check} pragma. It may appear either as
1931 a configuration pragma, or within a declarative part of package. In the
1932 latter case, it applies from the point where it appears to the end of
1933 the declarative region (like pragma @code{Suppress}).
1935 The @code{Check_Policy} pragma is similar to the
1936 predefined @code{Assertion_Policy} pragma,
1937 and if the check kind corresponds to one of the assertion kinds that
1938 are allowed by @code{Assertion_Policy}, then the effect is identical.
1940 If the first argument is Debug, then the policy applies to Debug pragmas,
1941 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1942 @code{IGNORE}, and allowing them to execute with normal semantics if
1943 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1944 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1945 be totally ignored and not analyzed semantically.
1947 Finally the first argument may be some other identifier than the above
1948 possibilities, in which case it controls a set of named assertions
1949 that can be checked using pragma @code{Check}. For example, if the pragma:
1951 @smallexample @c ada
1952 pragma Check_Policy (Critical_Error, OFF);
1953 @end smallexample
1955 @noindent
1956 is given, then subsequent @code{Check} pragmas whose first argument is also
1957 @code{Critical_Error} will be disabled.
1959 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1960 to turn on corresponding checks. The default for a set of checks for which no
1961 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1962 @option{-gnata} is given, which turns on all checks by default.
1964 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1965 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1966 compatibility with the standard @code{Assertion_Policy} pragma. The check
1967 policy setting @code{DISABLE} causes the second argument of a corresponding
1968 @code{Check} pragma to be completely ignored and not analyzed.
1970 @node Pragma CIL_Constructor
1971 @unnumberedsec Pragma CIL_Constructor
1972 @findex CIL_Constructor
1973 @noindent
1974 Syntax:
1976 @smallexample @c ada
1977 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1978 @end smallexample
1980 @noindent
1981 This pragma is used to assert that the specified Ada function should be
1982 mapped to the .NET constructor for some Ada tagged record type.
1984 See section 4.1 of the
1985 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1986 for related information.
1988 @node Pragma Comment
1989 @unnumberedsec Pragma Comment
1990 @findex Comment
1991 @noindent
1992 Syntax:
1994 @smallexample @c ada
1995 pragma Comment (static_string_EXPRESSION);
1996 @end smallexample
1998 @noindent
1999 This is almost identical in effect to pragma @code{Ident}.  It allows the
2000 placement of a comment into the object file and hence into the
2001 executable file if the operating system permits such usage.  The
2002 difference is that @code{Comment}, unlike @code{Ident}, has
2003 no limitations on placement of the pragma (it can be placed
2004 anywhere in the main source unit), and if more than one pragma
2005 is used, all comments are retained.
2007 @node Pragma Common_Object
2008 @unnumberedsec Pragma Common_Object
2009 @findex Common_Object
2010 @noindent
2011 Syntax:
2013 @smallexample @c ada
2014 pragma Common_Object (
2015      [Internal =>] LOCAL_NAME
2016   [, [External =>] EXTERNAL_SYMBOL]
2017   [, [Size     =>] EXTERNAL_SYMBOL] );
2019 EXTERNAL_SYMBOL ::=
2020   IDENTIFIER
2021 | static_string_EXPRESSION
2022 @end smallexample
2024 @noindent
2025 This pragma enables the shared use of variables stored in overlaid
2026 linker areas corresponding to the use of @code{COMMON}
2027 in Fortran.  The single
2028 object @var{LOCAL_NAME} is assigned to the area designated by
2029 the @var{External} argument.
2030 You may define a record to correspond to a series
2031 of fields.  The @var{Size} argument
2032 is syntax checked in GNAT, but otherwise ignored.
2034 @code{Common_Object} is not supported on all platforms.  If no
2035 support is available, then the code generator will issue a message
2036 indicating that the necessary attribute for implementation of this
2037 pragma is not available.
2039 @node Pragma Compile_Time_Error
2040 @unnumberedsec Pragma Compile_Time_Error
2041 @findex Compile_Time_Error
2042 @noindent
2043 Syntax:
2045 @smallexample @c ada
2046 pragma Compile_Time_Error
2047          (boolean_EXPRESSION, static_string_EXPRESSION);
2048 @end smallexample
2050 @noindent
2051 This pragma can be used to generate additional compile time
2052 error messages. It
2053 is particularly useful in generics, where errors can be issued for
2054 specific problematic instantiations. The first parameter is a boolean
2055 expression. The pragma is effective only if the value of this expression
2056 is known at compile time, and has the value True. The set of expressions
2057 whose values are known at compile time includes all static boolean
2058 expressions, and also other values which the compiler can determine
2059 at compile time (e.g., the size of a record type set by an explicit
2060 size representation clause, or the value of a variable which was
2061 initialized to a constant and is known not to have been modified).
2062 If these conditions are met, an error message is generated using
2063 the value given as the second argument. This string value may contain
2064 embedded ASCII.LF characters to break the message into multiple lines.
2066 @node Pragma Compile_Time_Warning
2067 @unnumberedsec Pragma Compile_Time_Warning
2068 @findex Compile_Time_Warning
2069 @noindent
2070 Syntax:
2072 @smallexample @c ada
2073 pragma Compile_Time_Warning
2074          (boolean_EXPRESSION, static_string_EXPRESSION);
2075 @end smallexample
2077 @noindent
2078 Same as pragma Compile_Time_Error, except a warning is issued instead
2079 of an error message. Note that if this pragma is used in a package that
2080 is with'ed by a client, the client will get the warning even though it
2081 is issued by a with'ed package (normally warnings in with'ed units are
2082 suppressed, but this is a special exception to that rule).
2084 One typical use is within a generic where compile time known characteristics
2085 of formal parameters are tested, and warnings given appropriately. Another use
2086 with a first parameter of True is to warn a client about use of a package,
2087 for example that it is not fully implemented.
2089 @node Pragma Compiler_Unit
2090 @unnumberedsec Pragma Compiler_Unit
2091 @findex Compiler_Unit
2092 @noindent
2093 Syntax:
2095 @smallexample @c ada
2096 pragma Compiler_Unit;
2097 @end smallexample
2099 @noindent
2100 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2101 retained so that old versions of the GNAT run-time that use this pragma can
2102 be compiled with newer versions of the compiler.
2104 @node Pragma Compiler_Unit_Warning
2105 @unnumberedsec Pragma Compiler_Unit_Warning
2106 @findex Compiler_Unit_Warning
2107 @noindent
2108 Syntax:
2110 @smallexample @c ada
2111 pragma Compiler_Unit_Warning;
2112 @end smallexample
2114 @noindent
2115 This pragma is intended only for internal use in the GNAT run-time library.
2116 It indicates that the unit is used as part of the compiler build. The effect
2117 is to generate warnings for the use of constructs (for example, conditional
2118 expressions) that would cause trouble when bootstrapping using an older
2119 version of GNAT. For the exact list of restrictions, see the compiler sources
2120 and references to Check_Compiler_Unit.
2122 @node Pragma Complete_Representation
2123 @unnumberedsec Pragma Complete_Representation
2124 @findex Complete_Representation
2125 @noindent
2126 Syntax:
2128 @smallexample @c ada
2129 pragma Complete_Representation;
2130 @end smallexample
2132 @noindent
2133 This pragma must appear immediately within a record representation
2134 clause. Typical placements are before the first component clause
2135 or after the last component clause. The effect is to give an error
2136 message if any component is missing a component clause. This pragma
2137 may be used to ensure that a record representation clause is
2138 complete, and that this invariant is maintained if fields are
2139 added to the record in the future.
2141 @node Pragma Complex_Representation
2142 @unnumberedsec Pragma Complex_Representation
2143 @findex Complex_Representation
2144 @noindent
2145 Syntax:
2147 @smallexample @c ada
2148 pragma Complex_Representation
2149         ([Entity =>] LOCAL_NAME);
2150 @end smallexample
2152 @noindent
2153 The @var{Entity} argument must be the name of a record type which has
2154 two fields of the same floating-point type.  The effect of this pragma is
2155 to force gcc to use the special internal complex representation form for
2156 this record, which may be more efficient.  Note that this may result in
2157 the code for this type not conforming to standard ABI (application
2158 binary interface) requirements for the handling of record types.  For
2159 example, in some environments, there is a requirement for passing
2160 records by pointer, and the use of this pragma may result in passing
2161 this type in floating-point registers.
2163 @node Pragma Component_Alignment
2164 @unnumberedsec Pragma Component_Alignment
2165 @cindex Alignments of components
2166 @findex Component_Alignment
2167 @noindent
2168 Syntax:
2170 @smallexample @c ada
2171 pragma Component_Alignment (
2172      [Form =>] ALIGNMENT_CHOICE
2173   [, [Name =>] type_LOCAL_NAME]);
2175 ALIGNMENT_CHOICE ::=
2176   Component_Size
2177 | Component_Size_4
2178 | Storage_Unit
2179 | Default
2180 @end smallexample
2182 @noindent
2183 Specifies the alignment of components in array or record types.
2184 The meaning of the @var{Form} argument is as follows:
2186 @table @code
2187 @findex Component_Size
2188 @item Component_Size
2189 Aligns scalar components and subcomponents of the array or record type
2190 on boundaries appropriate to their inherent size (naturally
2191 aligned).  For example, 1-byte components are aligned on byte boundaries,
2192 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2193 integer components are aligned on 4-byte boundaries and so on.  These
2194 alignment rules correspond to the normal rules for C compilers on all
2195 machines except the VAX@.
2197 @findex Component_Size_4
2198 @item Component_Size_4
2199 Naturally aligns components with a size of four or fewer
2200 bytes.  Components that are larger than 4 bytes are placed on the next
2201 4-byte boundary.
2203 @findex Storage_Unit
2204 @item Storage_Unit
2205 Specifies that array or record components are byte aligned, i.e.@:
2206 aligned on boundaries determined by the value of the constant
2207 @code{System.Storage_Unit}.
2209 @cindex OpenVMS
2210 @item Default
2211 Specifies that array or record components are aligned on default
2212 boundaries, appropriate to the underlying hardware or operating system or
2213 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
2214 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
2215 the @code{Default} choice is the same as @code{Component_Size} (natural
2216 alignment).
2217 @end table
2219 @noindent
2220 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2221 refer to a local record or array type, and the specified alignment
2222 choice applies to the specified type.  The use of
2223 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2224 @code{Component_Alignment} pragma to be ignored.  The use of
2225 @code{Component_Alignment} together with a record representation clause
2226 is only effective for fields not specified by the representation clause.
2228 If the @code{Name} parameter is absent, the pragma can be used as either
2229 a configuration pragma, in which case it applies to one or more units in
2230 accordance with the normal rules for configuration pragmas, or it can be
2231 used within a declarative part, in which case it applies to types that
2232 are declared within this declarative part, or within any nested scope
2233 within this declarative part.  In either case it specifies the alignment
2234 to be applied to any record or array type which has otherwise standard
2235 representation.
2237 If the alignment for a record or array type is not specified (using
2238 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2239 clause), the GNAT uses the default alignment as described previously.
2241 @node Pragma Contract_Cases
2242 @unnumberedsec Pragma Contract_Cases
2243 @cindex Contract cases
2244 @findex Contract_Cases
2245 @noindent
2246 Syntax:
2248 @smallexample @c ada
2249 pragma Contract_Cases (
2250    Condition => Consequence
2251  @{,Condition => Consequence@});
2252 @end smallexample
2254 @noindent
2255 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2256 that can complement or replace the contract given by a precondition and a
2257 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2258 by testing and formal verification tools. The compiler checks its validity and,
2259 depending on the assertion policy at the point of declaration of the pragma,
2260 it may insert a check in the executable. For code generation, the contract
2261 cases
2263 @smallexample @c ada
2264 pragma Contract_Cases (
2265   Cond1 => Pred1,
2266   Cond2 => Pred2);
2267 @end smallexample
2269 @noindent
2270 are equivalent to
2272 @smallexample @c ada
2273 C1 : constant Boolean := Cond1;  --  evaluated at subprogram entry
2274 C2 : constant Boolean := Cond2;  --  evaluated at subprogram entry
2275 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2276 pragma Postcondition (if C1 then Pred1);
2277 pragma Postcondition (if C2 then Pred2);
2278 @end smallexample
2280 @noindent
2281 The precondition ensures that one and only one of the conditions is
2282 satisfied on entry to the subprogram.
2283 The postcondition ensures that for the condition that was True on entry,
2284 the corrresponding consequence is True on exit. Other consequence expressions
2285 are not evaluated.
2287 A precondition @code{P} and postcondition @code{Q} can also be
2288 expressed as contract cases:
2290 @smallexample @c ada
2291 pragma Contract_Cases (P => Q);
2292 @end smallexample
2294 The placement and visibility rules for @code{Contract_Cases} pragmas are
2295 identical to those described for preconditions and postconditions.
2297 The compiler checks that boolean expressions given in conditions and
2298 consequences are valid, where the rules for conditions are the same as
2299 the rule for an expression in @code{Precondition} and the rules for
2300 consequences are the same as the rule for an expression in
2301 @code{Postcondition}. In particular, attributes @code{'Old} and
2302 @code{'Result} can only be used within consequence expressions.
2303 The condition for the last contract case may be @code{others}, to denote
2304 any case not captured by the previous cases. The
2305 following is an example of use within a package spec:
2307 @smallexample @c ada
2308 package Math_Functions is
2309    ...
2310    function Sqrt (Arg : Float) return Float;
2311    pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2312                           Arg >= 100       => Sqrt'Result >= 10,
2313                           others           => Sqrt'Result = 0);
2314    ...
2315 end Math_Functions;
2316 @end smallexample
2318 @noindent
2319 The meaning of contract cases is that only one case should apply at each
2320 call, as determined by the corresponding condition evaluating to True,
2321 and that the consequence for this case should hold when the subprogram
2322 returns.
2324 @node Pragma Convention_Identifier
2325 @unnumberedsec Pragma Convention_Identifier
2326 @findex Convention_Identifier
2327 @cindex Conventions, synonyms
2328 @noindent
2329 Syntax:
2331 @smallexample @c ada
2332 pragma Convention_Identifier (
2333          [Name =>]       IDENTIFIER,
2334          [Convention =>] convention_IDENTIFIER);
2335 @end smallexample
2337 @noindent
2338 This pragma provides a mechanism for supplying synonyms for existing
2339 convention identifiers. The @code{Name} identifier can subsequently
2340 be used as a synonym for the given convention in other pragmas (including
2341 for example pragma @code{Import} or another @code{Convention_Identifier}
2342 pragma). As an example of the use of this, suppose you had legacy code
2343 which used Fortran77 as the identifier for Fortran. Then the pragma:
2345 @smallexample @c ada
2346 pragma Convention_Identifier (Fortran77, Fortran);
2347 @end smallexample
2349 @noindent
2350 would allow the use of the convention identifier @code{Fortran77} in
2351 subsequent code, avoiding the need to modify the sources. As another
2352 example, you could use this to parameterize convention requirements
2353 according to systems. Suppose you needed to use @code{Stdcall} on
2354 windows systems, and @code{C} on some other system, then you could
2355 define a convention identifier @code{Library} and use a single
2356 @code{Convention_Identifier} pragma to specify which convention
2357 would be used system-wide.
2359 @node Pragma CPP_Class
2360 @unnumberedsec Pragma CPP_Class
2361 @findex CPP_Class
2362 @cindex Interfacing with C++
2363 @noindent
2364 Syntax:
2366 @smallexample @c ada
2367 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2368 @end smallexample
2370 @noindent
2371 The argument denotes an entity in the current declarative region that is
2372 declared as a record type. It indicates that the type corresponds to an
2373 externally declared C++ class type, and is to be laid out the same way
2374 that C++ would lay out the type. If the C++ class has virtual primitives
2375 then the record must be declared as a tagged record type.
2377 Types for which @code{CPP_Class} is specified do not have assignment or
2378 equality operators defined (such operations can be imported or declared
2379 as subprograms as required). Initialization is allowed only by constructor
2380 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2381 limited if not explicitly declared as limited or derived from a limited
2382 type, and an error is issued in that case.
2384 See @ref{Interfacing to C++} for related information.
2386 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2387 for backward compatibility but its functionality is available
2388 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2390 @node Pragma CPP_Constructor
2391 @unnumberedsec Pragma CPP_Constructor
2392 @cindex Interfacing with C++
2393 @findex CPP_Constructor
2394 @noindent
2395 Syntax:
2397 @smallexample @c ada
2398 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2399   [, [External_Name =>] static_string_EXPRESSION ]
2400   [, [Link_Name     =>] static_string_EXPRESSION ]);
2401 @end smallexample
2403 @noindent
2404 This pragma identifies an imported function (imported in the usual way
2405 with pragma @code{Import}) as corresponding to a C++ constructor. If
2406 @code{External_Name} and @code{Link_Name} are not specified then the
2407 @code{Entity} argument is a name that must have been previously mentioned
2408 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2409 must be of one of the following forms:
2411 @itemize @bullet
2412 @item
2413 @code{function @var{Fname} return @var{T}}
2415 @itemize @bullet
2416 @item
2417 @code{function @var{Fname} return @var{T}'Class}
2419 @item
2420 @code{function @var{Fname} (@dots{}) return @var{T}}
2421 @end itemize
2423 @item
2424 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2425 @end itemize
2427 @noindent
2428 where @var{T} is a limited record type imported from C++ with pragma
2429 @code{Import} and @code{Convention} = @code{CPP}.
2431 The first two forms import the default constructor, used when an object
2432 of type @var{T} is created on the Ada side with no explicit constructor.
2433 The latter two forms cover all the non-default constructors of the type.
2434 See the @value{EDITION} User's Guide for details.
2436 If no constructors are imported, it is impossible to create any objects
2437 on the Ada side and the type is implicitly declared abstract.
2439 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2440 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2441 GCC switch).
2442 See @ref{Interfacing to C++} for more related information.
2444 Note: The use of functions returning class-wide types for constructors is
2445 currently obsolete. They are supported for backward compatibility. The
2446 use of functions returning the type T leave the Ada sources more clear
2447 because the imported C++ constructors always return an object of type T;
2448 that is, they never return an object whose type is a descendant of type T.
2450 @node Pragma CPP_Virtual
2451 @unnumberedsec Pragma CPP_Virtual
2452 @cindex Interfacing to C++
2453 @findex CPP_Virtual
2454 @noindent
2455 This pragma is now obsolete and, other than generating a warning if warnings
2456 on obsolescent features are enabled, is completely ignored.
2457 It is retained for compatibility
2458 purposes. It used to be required to ensure compoatibility with C++, but
2459 is no longer required for that purpose because GNAT generates
2460 the same object layout as the G++ compiler by default.
2462 See @ref{Interfacing to C++} for related information.
2464 @node Pragma CPP_Vtable
2465 @unnumberedsec Pragma CPP_Vtable
2466 @cindex Interfacing with C++
2467 @findex CPP_Vtable
2468 @noindent
2469 This pragma is now obsolete and, other than generating a warning if warnings
2470 on obsolescent features are enabled, is completely ignored.
2471 It used to be required to ensure compatibility with C++, but
2472 is no longer required for that purpose because GNAT generates
2473 the same object layout as the G++ compiler by default.
2475 See @ref{Interfacing to C++} for related information.
2477 @node Pragma CPU
2478 @unnumberedsec Pragma CPU
2479 @findex CPU
2480 @noindent
2481 Syntax:
2483 @smallexample @c ada
2484 pragma CPU (EXPRESSION);
2485 @end smallexample
2487 @noindent
2488 This pragma is standard in Ada 2012, but is available in all earlier
2489 versions of Ada as an implementation-defined pragma.
2490 See Ada 2012 Reference Manual for details.
2492 @node Pragma Debug
2493 @unnumberedsec Pragma Debug
2494 @findex Debug
2495 @noindent
2496 Syntax:
2498 @smallexample @c ada
2499 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2501 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2502   PROCEDURE_NAME
2503 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2504 @end smallexample
2506 @noindent
2507 The procedure call argument has the syntactic form of an expression, meeting
2508 the syntactic requirements for pragmas.
2510 If debug pragmas are not enabled or if the condition is present and evaluates
2511 to False, this pragma has no effect. If debug pragmas are enabled, the
2512 semantics of the pragma is exactly equivalent to the procedure call statement
2513 corresponding to the argument with a terminating semicolon. Pragmas are
2514 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2515 intersperse calls to debug procedures in the middle of declarations. Debug
2516 pragmas can be enabled either by use of the command line switch @option{-gnata}
2517 or by use of the pragma @code{Check_Policy} with a first argument of
2518 @code{Debug}.
2520 @node Pragma Debug_Policy
2521 @unnumberedsec Pragma Debug_Policy
2522 @findex Debug_Policy
2523 @noindent
2524 Syntax:
2526 @smallexample @c ada
2527 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2528 @end smallexample
2530 @noindent
2531 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2532 with a first argument of @code{Debug}. It is retained for historical
2533 compatibility reasons.
2535 @node Pragma Default_Scalar_Storage_Order
2536 @unnumberedsec Pragma Default_Scalar_Storage_Order
2537 @cindex Default_Scalar_Storage_Order
2538 @cindex Scalar_Storage_Order
2539 @findex Default_Scalar_Storage_Order
2540 @noindent
2541 Syntax:
2543 @smallexample @c ada
2544 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2545 @end smallexample
2547 @noindent
2548 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2549 type or array type, then the scalar storage order defaults to the ordinary
2550 default for the target. But this default may be overridden using this pragma.
2551 The pragma may appear as a configuration pragma, or locally within a package
2552 spec or declarative part. In the latter case, it applies to all subsequent
2553 types declared within that package spec or declarative part.
2555 If this pragma is used as a configuration pragma which appears within a
2556 configuration pragma file (as opposed to appearing explicitly at the start
2557 of a single unit), then the binder will require that all units in a partition
2558 be compiled in a similar manner, including all units in the run-time that
2559 are included in the partition.
2561 The following example shows the use of this pragma:
2563 @smallexample @c ada
2564 pragma Default_Scalar_Storage_Order (High_Order_First);
2565 with System; use System;
2566 package DSSO1 is
2567    type H1 is record
2568       a : Integer;
2569    end record;
2571    type L2 is record
2572       a : Integer;
2573    end record;
2574    for L2'Scalar_Storage_Order use Low_Order_First;
2576    type L2a is new L2;
2578    package Inner is
2579       type H3 is record
2580          a : Integer;
2581       end record;
2583       pragma Default_Scalar_Storage_Order (Low_Order_First);
2585       type L4 is record
2586          a : Integer;
2587       end record;
2588    end Inner;
2590    type H4a is new Inner.L4;
2592    type H5 is record
2593       a : Integer;
2594    end record;
2595 end DSSO1;
2596 @end smallexample
2598 @noindent
2599 In this example record types L.. have @code{Low_Order_First} scalar
2600 storage order, and record types H.. have @code{High_Order_First}.
2601 Note that in the case of @code{H4a}, the order is not inherited
2602 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2603 gets inherited on type derivation.
2605 @node Pragma Default_Storage_Pool
2606 @unnumberedsec Pragma Default_Storage_Pool
2607 @cindex Default_Storage_Pool
2608 @findex Default_Storage_Pool
2609 @noindent
2610 Syntax:
2612 @smallexample @c ada
2613 pragma Default_Storage_Pool (storage_pool_NAME | null);
2614 @end smallexample
2616 @noindent
2617 This pragma is standard in Ada 2012, but is available in all earlier
2618 versions of Ada as an implementation-defined pragma.
2619 See Ada 2012 Reference Manual for details.
2621 @node Pragma Depends
2622 @unnumberedsec Pragma Depends
2623 @findex Depends
2624 @noindent
2625 For the description of this pragma, see SPARK 2014 Reference Manual,
2626 section 6.1.5.
2628 @node Pragma Detect_Blocking
2629 @unnumberedsec Pragma Detect_Blocking
2630 @findex Detect_Blocking
2631 @noindent
2632 Syntax:
2634 @smallexample @c ada
2635 pragma Detect_Blocking;
2636 @end smallexample
2638 @noindent
2639 This is a standard pragma in Ada 2005, that is available in all earlier
2640 versions of Ada as an implementation-defined pragma.
2642 This is a configuration pragma that forces the detection of potentially
2643 blocking operations within a protected operation, and to raise Program_Error
2644 if that happens.
2646 @node Pragma Disable_Atomic_Synchronization
2647 @unnumberedsec Pragma Disable_Atomic_Synchronization
2648 @cindex Atomic Synchronization
2649 @findex Disable_Atomic_Synchronization
2650 @noindent
2651 Syntax:
2653 @smallexample @c ada
2654 pragma Disable_Atomic_Synchronization [(Entity)];
2655 @end smallexample
2657 @noindent
2658 Ada requires that accesses (reads or writes) of an atomic variable be
2659 regarded as synchronization points in the case of multiple tasks.
2660 Particularly in the case of multi-processors this may require special
2661 handling, e.g. the generation of memory barriers. This capability may
2662 be turned off using this pragma in cases where it is known not to be
2663 required.
2665 The placement and scope rules for this pragma are the same as those
2666 for @code{pragma Suppress}. In particular it can be used as a
2667 configuration  pragma, or in a declaration sequence where it applies
2668 till the end of the scope. If an @code{Entity} argument is present,
2669 the action applies only to that entity.
2671 @node Pragma Dispatching_Domain
2672 @unnumberedsec Pragma Dispatching_Domain
2673 @findex Dispatching_Domain
2674 @noindent
2675 Syntax:
2677 @smallexample @c ada
2678 pragma Dispatching_Domain (EXPRESSION);
2679 @end smallexample
2681 @noindent
2682 This pragma is standard in Ada 2012, but is available in all earlier
2683 versions of Ada as an implementation-defined pragma.
2684 See Ada 2012 Reference Manual for details.
2686 @node Pragma Effective_Reads
2687 @unnumberedsec Pragma Effective_Reads
2688 @findex Effective_Reads
2689 @noindent
2690 For the description of this pragma, see SPARK 2014 Reference Manual,
2691 section 7.1.2.
2693 @node Pragma Effective_Writes
2694 @unnumberedsec Pragma Effective_Writes
2695 @findex Effective_Writes
2696 @noindent
2697 For the description of this pragma, see SPARK 2014 Reference Manual,
2698 section 7.1.2.
2700 @node Pragma Elaboration_Checks
2701 @unnumberedsec Pragma Elaboration_Checks
2702 @cindex Elaboration control
2703 @findex Elaboration_Checks
2704 @noindent
2705 Syntax:
2707 @smallexample @c ada
2708 pragma Elaboration_Checks (Dynamic | Static);
2709 @end smallexample
2711 @noindent
2712 This is a configuration pragma that provides control over the
2713 elaboration model used by the compilation affected by the
2714 pragma.  If the parameter is @code{Dynamic},
2715 then the dynamic elaboration
2716 model described in the Ada Reference Manual is used, as though
2717 the @option{-gnatE} switch had been specified on the command
2718 line.  If the parameter is @code{Static}, then the default GNAT static
2719 model is used.  This configuration pragma overrides the setting
2720 of the command line.  For full details on the elaboration models
2721 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2722 gnat_ugn, @value{EDITION} User's Guide}.
2724 @node Pragma Eliminate
2725 @unnumberedsec Pragma Eliminate
2726 @cindex Elimination of unused subprograms
2727 @findex Eliminate
2728 @noindent
2729 Syntax:
2731 @smallexample @c ada
2732 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
2733                   [Source_Location =>] STRING_LITERAL);
2734 @end smallexample
2736 @noindent
2737 The string literal given for the source location is a string which
2738 specifies the line number of the occurrence of the entity, using
2739 the syntax for SOURCE_TRACE given below:
2741 @smallexample @c ada
2742  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2744  LBRACKET         ::= [
2745  RBRACKET         ::= ]
2747  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2749  LINE_NUMBER      ::= DIGIT @{DIGIT@}
2750 @end smallexample
2752 @noindent
2753 Spaces around the colon in a @code{Source_Reference} are optional.
2755 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2756 explicit subprogram declaration, where the @code{entity} name in this
2757 designator appears on the source line specified by the source location.
2759 The source trace that is given as the @code{Source_Location} shall obey the
2760 following rules. The @code{FILE_NAME} is the short name (with no directory
2761 information) of an Ada source file, given using exactly the required syntax
2762 for the underlying file system (e.g. case is important if the underlying
2763 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2764 number of the occurrence of the @code{entity}
2765 as a decimal literal without an exponent or point. If an @code{entity} is not
2766 declared in a generic instantiation (this includes generic subprogram
2767 instances), the source trace includes only one source reference. If an entity
2768 is declared inside a generic instantiation, its source trace (when parsing
2769 from left to right) starts with the source location of the declaration of the
2770 entity in the generic unit and ends with the source location of the
2771 instantiation (it is given in square brackets). This approach is recursively
2772 used in case of nested instantiations: the rightmost (nested most deeply in
2773 square brackets) element of the source trace is the location of the outermost
2774 instantiation, the next to left element is the location of the next (first
2775 nested) instantiation in the code of the corresponding generic unit, and so
2776 on, and the leftmost element (that is out of any square brackets) is the
2777 location of the declaration of the entity to eliminate in a generic unit.
2779 Note that the @code{Source_Location} argument specifies which of a set of
2780 similarly named entities is being eliminated, dealing both with overloading,
2781 and also appearance of the same entity name in different scopes.
2783 This pragma indicates that the given entity is not used in the program to be
2784 compiled and built. The effect of the pragma is to allow the compiler to
2785 eliminate the code or data associated with the named entity. Any reference to
2786 an eliminated entity causes a compile-time or link-time error.
2788 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2789 in a system-independent manner, with unused entities eliminated, without
2790 needing to modify the source text. Normally the required set of
2791 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2793 Any source file change that removes, splits, or
2794 adds lines may make the set of Eliminate pragmas invalid because their
2795 @code{Source_Location} argument values may get out of date.
2797 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2798 operation. In this case all the subprograms to which the given operation can
2799 dispatch are considered to be unused (are never called as a result of a direct
2800 or a dispatching call).
2802 @node Pragma Enable_Atomic_Synchronization
2803 @unnumberedsec Pragma Enable_Atomic_Synchronization
2804 @cindex Atomic Synchronization
2805 @findex Enable_Atomic_Synchronization
2806 @noindent
2807 Syntax:
2809 @smallexample @c ada
2810 pragma Enable_Atomic_Synchronization [(Entity)];
2811 @end smallexample
2813 @noindent
2814 Ada requires that accesses (reads or writes) of an atomic variable be
2815 regarded as synchronization points in the case of multiple tasks.
2816 Particularly in the case of multi-processors this may require special
2817 handling, e.g. the generation of memory barriers. This synchronization
2818 is performed by default, but can be turned off using
2819 @code{pragma Disable_Atomic_Synchronization}. The
2820 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2821 it back on.
2823 The placement and scope rules for this pragma are the same as those
2824 for @code{pragma Unsuppress}. In particular it can be used as a
2825 configuration  pragma, or in a declaration sequence where it applies
2826 till the end of the scope. If an @code{Entity} argument is present,
2827 the action applies only to that entity.
2829 @node Pragma Export_Exception
2830 @unnumberedsec Pragma Export_Exception
2831 @cindex OpenVMS
2832 @findex Export_Exception
2833 @noindent
2834 Syntax:
2836 @smallexample @c ada
2837 pragma Export_Exception (
2838      [Internal =>] LOCAL_NAME
2839   [, [External =>] EXTERNAL_SYMBOL]
2840   [, [Form     =>] Ada | VMS]
2841   [, [Code     =>] static_integer_EXPRESSION]);
2843 EXTERNAL_SYMBOL ::=
2844   IDENTIFIER
2845 | static_string_EXPRESSION
2846 @end smallexample
2848 @noindent
2849 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
2850 causes the specified exception to be propagated outside of the Ada program,
2851 so that it can be handled by programs written in other OpenVMS languages.
2852 This pragma establishes an external name for an Ada exception and makes the
2853 name available to the OpenVMS Linker as a global symbol.  For further details
2854 on this pragma, see the
2855 DEC Ada Language Reference Manual, section 13.9a3.2.
2857 @node Pragma Export_Function
2858 @unnumberedsec Pragma Export_Function
2859 @cindex Argument passing mechanisms
2860 @findex Export_Function
2862 @noindent
2863 Syntax:
2865 @smallexample @c ada
2866 pragma Export_Function (
2867      [Internal         =>] LOCAL_NAME
2868   [, [External         =>] EXTERNAL_SYMBOL]
2869   [, [Parameter_Types  =>] PARAMETER_TYPES]
2870   [, [Result_Type      =>] result_SUBTYPE_MARK]
2871   [, [Mechanism        =>] MECHANISM]
2872   [, [Result_Mechanism =>] MECHANISM_NAME]);
2874 EXTERNAL_SYMBOL ::=
2875   IDENTIFIER
2876 | static_string_EXPRESSION
2877 | ""
2879 PARAMETER_TYPES ::=
2880   null
2881 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2883 TYPE_DESIGNATOR ::=
2884   subtype_NAME
2885 | subtype_Name ' Access
2887 MECHANISM ::=
2888   MECHANISM_NAME
2889 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2891 MECHANISM_ASSOCIATION ::=
2892   [formal_parameter_NAME =>] MECHANISM_NAME
2894 MECHANISM_NAME ::= Value | Reference
2895 @end smallexample
2897 @noindent
2898 Use this pragma to make a function externally callable and optionally
2899 provide information on mechanisms to be used for passing parameter and
2900 result values.  We recommend, for the purposes of improving portability,
2901 this pragma always be used in conjunction with a separate pragma
2902 @code{Export}, which must precede the pragma @code{Export_Function}.
2903 GNAT does not require a separate pragma @code{Export}, but if none is
2904 present, @code{Convention Ada} is assumed, which is usually
2905 not what is wanted, so it is usually appropriate to use this
2906 pragma in conjunction with a @code{Export} or @code{Convention}
2907 pragma that specifies the desired foreign convention.
2908 Pragma @code{Export_Function}
2909 (and @code{Export}, if present) must appear in the same declarative
2910 region as the function to which they apply.
2912 @var{internal_name} must uniquely designate the function to which the
2913 pragma applies.  If more than one function name exists of this name in
2914 the declarative part you must use the @code{Parameter_Types} and
2915 @code{Result_Type} parameters is mandatory to achieve the required
2916 unique designation.  @var{subtype_mark}s in these parameters must
2917 exactly match the subtypes in the corresponding function specification,
2918 using positional notation to match parameters with subtype marks.
2919 The form with an @code{'Access} attribute can be used to match an
2920 anonymous access parameter.
2922 @cindex Suppressing external name
2923 Special treatment is given if the EXTERNAL is an explicit null
2924 string or a static string expressions that evaluates to the null
2925 string. In this case, no external name is generated. This form
2926 still allows the specification of parameter mechanisms.
2928 @node Pragma Export_Object
2929 @unnumberedsec Pragma Export_Object
2930 @findex Export_Object
2931 @noindent
2932 Syntax:
2934 @smallexample @c ada
2935 pragma Export_Object
2936       [Internal =>] LOCAL_NAME
2937    [, [External =>] EXTERNAL_SYMBOL]
2938    [, [Size     =>] EXTERNAL_SYMBOL]
2940 EXTERNAL_SYMBOL ::=
2941   IDENTIFIER
2942 | static_string_EXPRESSION
2943 @end smallexample
2945 @noindent
2946 This pragma designates an object as exported, and apart from the
2947 extended rules for external symbols, is identical in effect to the use of
2948 the normal @code{Export} pragma applied to an object.  You may use a
2949 separate Export pragma (and you probably should from the point of view
2950 of portability), but it is not required.  @var{Size} is syntax checked,
2951 but otherwise ignored by GNAT@.
2953 @node Pragma Export_Procedure
2954 @unnumberedsec Pragma Export_Procedure
2955 @findex Export_Procedure
2956 @noindent
2957 Syntax:
2959 @smallexample @c ada
2960 pragma Export_Procedure (
2961      [Internal        =>] LOCAL_NAME
2962   [, [External        =>] EXTERNAL_SYMBOL]
2963   [, [Parameter_Types =>] PARAMETER_TYPES]
2964   [, [Mechanism       =>] MECHANISM]);
2966 EXTERNAL_SYMBOL ::=
2967   IDENTIFIER
2968 | static_string_EXPRESSION
2969 | ""
2971 PARAMETER_TYPES ::=
2972   null
2973 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2975 TYPE_DESIGNATOR ::=
2976   subtype_NAME
2977 | subtype_Name ' Access
2979 MECHANISM ::=
2980   MECHANISM_NAME
2981 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2983 MECHANISM_ASSOCIATION ::=
2984   [formal_parameter_NAME =>] MECHANISM_NAME
2986 MECHANISM_NAME ::= Value | Reference
2987 @end smallexample
2989 @noindent
2990 This pragma is identical to @code{Export_Function} except that it
2991 applies to a procedure rather than a function and the parameters
2992 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2993 GNAT does not require a separate pragma @code{Export}, but if none is
2994 present, @code{Convention Ada} is assumed, which is usually
2995 not what is wanted, so it is usually appropriate to use this
2996 pragma in conjunction with a @code{Export} or @code{Convention}
2997 pragma that specifies the desired foreign convention.
2999 @cindex Suppressing external name
3000 Special treatment is given if the EXTERNAL is an explicit null
3001 string or a static string expressions that evaluates to the null
3002 string. In this case, no external name is generated. This form
3003 still allows the specification of parameter mechanisms.
3005 @node Pragma Export_Value
3006 @unnumberedsec Pragma Export_Value
3007 @findex Export_Value
3008 @noindent
3009 Syntax:
3011 @smallexample @c ada
3012 pragma Export_Value (
3013   [Value     =>] static_integer_EXPRESSION,
3014   [Link_Name =>] static_string_EXPRESSION);
3015 @end smallexample
3017 @noindent
3018 This pragma serves to export a static integer value for external use.
3019 The first argument specifies the value to be exported. The Link_Name
3020 argument specifies the symbolic name to be associated with the integer
3021 value. This pragma is useful for defining a named static value in Ada
3022 that can be referenced in assembly language units to be linked with
3023 the application. This pragma is currently supported only for the
3024 AAMP target and is ignored for other targets.
3026 @node Pragma Export_Valued_Procedure
3027 @unnumberedsec Pragma Export_Valued_Procedure
3028 @findex Export_Valued_Procedure
3029 @noindent
3030 Syntax:
3032 @smallexample @c ada
3033 pragma Export_Valued_Procedure (
3034      [Internal        =>] LOCAL_NAME
3035   [, [External        =>] EXTERNAL_SYMBOL]
3036   [, [Parameter_Types =>] PARAMETER_TYPES]
3037   [, [Mechanism       =>] MECHANISM]);
3039 EXTERNAL_SYMBOL ::=
3040   IDENTIFIER
3041 | static_string_EXPRESSION
3042 | ""
3044 PARAMETER_TYPES ::=
3045   null
3046 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3048 TYPE_DESIGNATOR ::=
3049   subtype_NAME
3050 | subtype_Name ' Access
3052 MECHANISM ::=
3053   MECHANISM_NAME
3054 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3056 MECHANISM_ASSOCIATION ::=
3057   [formal_parameter_NAME =>] MECHANISM_NAME
3059 MECHANISM_NAME ::= Value | Reference
3060 @end smallexample
3062 @noindent
3063 This pragma is identical to @code{Export_Procedure} except that the
3064 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3065 mode @code{OUT}, and externally the subprogram is treated as a function
3066 with this parameter as the result of the function.  GNAT provides for
3067 this capability to allow the use of @code{OUT} and @code{IN OUT}
3068 parameters in interfacing to external functions (which are not permitted
3069 in Ada functions).
3070 GNAT does not require a separate pragma @code{Export}, but if none is
3071 present, @code{Convention Ada} is assumed, which is almost certainly
3072 not what is wanted since the whole point of this pragma is to interface
3073 with foreign language functions, so it is usually appropriate to use this
3074 pragma in conjunction with a @code{Export} or @code{Convention}
3075 pragma that specifies the desired foreign convention.
3077 @cindex Suppressing external name
3078 Special treatment is given if the EXTERNAL is an explicit null
3079 string or a static string expressions that evaluates to the null
3080 string. In this case, no external name is generated. This form
3081 still allows the specification of parameter mechanisms.
3083 @node Pragma Extend_System
3084 @unnumberedsec Pragma Extend_System
3085 @cindex @code{system}, extending
3086 @cindex Dec Ada 83
3087 @findex Extend_System
3088 @noindent
3089 Syntax:
3091 @smallexample @c ada
3092 pragma Extend_System ([Name =>] IDENTIFIER);
3093 @end smallexample
3095 @noindent
3096 This pragma is used to provide backwards compatibility with other
3097 implementations that extend the facilities of package @code{System}.  In
3098 GNAT, @code{System} contains only the definitions that are present in
3099 the Ada RM@.  However, other implementations, notably the DEC Ada 83
3100 implementation, provide many extensions to package @code{System}.
3102 For each such implementation accommodated by this pragma, GNAT provides a
3103 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3104 implementation, which provides the required additional definitions.  You
3105 can use this package in two ways.  You can @code{with} it in the normal
3106 way and access entities either by selection or using a @code{use}
3107 clause.  In this case no special processing is required.
3109 However, if existing code contains references such as
3110 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3111 definitions provided in package @code{System}, you may use this pragma
3112 to extend visibility in @code{System} in a non-standard way that
3113 provides greater compatibility with the existing code.  Pragma
3114 @code{Extend_System} is a configuration pragma whose single argument is
3115 the name of the package containing the extended definition
3116 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
3117 control of this pragma will be processed using special visibility
3118 processing that looks in package @code{System.Aux_@var{xxx}} where
3119 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3120 package @code{System}, but not found in package @code{System}.
3122 You can use this pragma either to access a predefined @code{System}
3123 extension supplied with the compiler, for example @code{Aux_DEC} or
3124 you can construct your own extension unit following the above
3125 definition.  Note that such a package is a child of @code{System}
3126 and thus is considered part of the implementation.
3127 To compile it you will have to use the @option{-gnatg} switch,
3128 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3129 for compiling System units, as explained in the
3130 @value{EDITION} User's Guide.
3132 @node Pragma Extensions_Allowed
3133 @unnumberedsec Pragma Extensions_Allowed
3134 @cindex Ada Extensions
3135 @cindex GNAT Extensions
3136 @findex Extensions_Allowed
3137 @noindent
3138 Syntax:
3140 @smallexample @c ada
3141 pragma Extensions_Allowed (On | Off);
3142 @end smallexample
3144 @noindent
3145 This configuration pragma enables or disables the implementation
3146 extension mode (the use of Off as a parameter cancels the effect
3147 of the @option{-gnatX} command switch).
3149 In extension mode, the latest version of the Ada language is
3150 implemented (currently Ada 2012), and in addition a small number
3151 of GNAT specific extensions are recognized as follows:
3153 @table @asis
3154 @item Constrained attribute for generic objects
3155 The @code{Constrained} attribute is permitted for objects of
3156 generic types. The result indicates if the corresponding actual
3157 is constrained.
3159 @end table
3161 @node Pragma External
3162 @unnumberedsec Pragma External
3163 @findex External
3164 @noindent
3165 Syntax:
3167 @smallexample @c ada
3168 pragma External (
3169   [   Convention    =>] convention_IDENTIFIER,
3170   [   Entity        =>] LOCAL_NAME
3171   [, [External_Name =>] static_string_EXPRESSION ]
3172   [, [Link_Name     =>] static_string_EXPRESSION ]);
3173 @end smallexample
3175 @noindent
3176 This pragma is identical in syntax and semantics to pragma
3177 @code{Export} as defined in the Ada Reference Manual.  It is
3178 provided for compatibility with some Ada 83 compilers that
3179 used this pragma for exactly the same purposes as pragma
3180 @code{Export} before the latter was standardized.
3182 @node Pragma External_Name_Casing
3183 @unnumberedsec Pragma External_Name_Casing
3184 @cindex Dec Ada 83 casing compatibility
3185 @cindex External Names, casing
3186 @cindex Casing of External names
3187 @findex External_Name_Casing
3188 @noindent
3189 Syntax:
3191 @smallexample @c ada
3192 pragma External_Name_Casing (
3193   Uppercase | Lowercase
3194   [, Uppercase | Lowercase | As_Is]);
3195 @end smallexample
3197 @noindent
3198 This pragma provides control over the casing of external names associated
3199 with Import and Export pragmas.  There are two cases to consider:
3201 @table @asis
3202 @item Implicit external names
3203 Implicit external names are derived from identifiers.  The most common case
3204 arises when a standard Ada Import or Export pragma is used with only two
3205 arguments, as in:
3207 @smallexample @c ada
3208    pragma Import (C, C_Routine);
3209 @end smallexample
3211 @noindent
3212 Since Ada is a case-insensitive language, the spelling of the identifier in
3213 the Ada source program does not provide any information on the desired
3214 casing of the external name, and so a convention is needed.  In GNAT the
3215 default treatment is that such names are converted to all lower case
3216 letters.  This corresponds to the normal C style in many environments.
3217 The first argument of pragma @code{External_Name_Casing} can be used to
3218 control this treatment.  If @code{Uppercase} is specified, then the name
3219 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3220 then the normal default of all lower case letters will be used.
3222 This same implicit treatment is also used in the case of extended DEC Ada 83
3223 compatible Import and Export pragmas where an external name is explicitly
3224 specified using an identifier rather than a string.
3226 @item Explicit external names
3227 Explicit external names are given as string literals.  The most common case
3228 arises when a standard Ada Import or Export pragma is used with three
3229 arguments, as in:
3231 @smallexample @c ada
3232 pragma Import (C, C_Routine, "C_routine");
3233 @end smallexample
3235 @noindent
3236 In this case, the string literal normally provides the exact casing required
3237 for the external name.  The second argument of pragma
3238 @code{External_Name_Casing} may be used to modify this behavior.
3239 If @code{Uppercase} is specified, then the name
3240 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
3241 then the name will be forced to all lowercase letters.  A specification of
3242 @code{As_Is} provides the normal default behavior in which the casing is
3243 taken from the string provided.
3244 @end table
3246 @noindent
3247 This pragma may appear anywhere that a pragma is valid.  In particular, it
3248 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3249 case it applies to all subsequent compilations, or it can be used as a program
3250 unit pragma, in which case it only applies to the current unit, or it can
3251 be used more locally to control individual Import/Export pragmas.
3253 It is primarily intended for use with OpenVMS systems, where many
3254 compilers convert all symbols to upper case by default.  For interfacing to
3255 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3256 the pragma:
3258 @smallexample @c ada
3259 pragma External_Name_Casing (Uppercase, Uppercase);
3260 @end smallexample
3262 @noindent
3263 to enforce the upper casing of all external symbols.
3265 @node Pragma Fast_Math
3266 @unnumberedsec Pragma Fast_Math
3267 @findex Fast_Math
3268 @noindent
3269 Syntax:
3271 @smallexample @c ada
3272 pragma Fast_Math;
3273 @end smallexample
3275 @noindent
3276 This is a configuration pragma which activates a mode in which speed is
3277 considered more important for floating-point operations than absolutely
3278 accurate adherence to the requirements of the standard. Currently the
3279 following operations are affected:
3281 @table @asis
3282 @item Complex Multiplication
3283 The normal simple formula for complex multiplication can result in intermediate
3284 overflows for numbers near the end of the range. The Ada standard requires that
3285 this situation be detected and corrected by scaling, but in Fast_Math mode such
3286 cases will simply result in overflow. Note that to take advantage of this you
3287 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3288 under control of the pragma, rather than use the preinstantiated versions.
3289 @end table
3291 @node Pragma Favor_Top_Level
3292 @unnumberedsec Pragma Favor_Top_Level
3293 @findex Favor_Top_Level
3294 @noindent
3295 Syntax:
3297 @smallexample @c ada
3298 pragma Favor_Top_Level (type_NAME);
3299 @end smallexample
3301 @noindent
3302 The named type must be an access-to-subprogram type. This pragma is an
3303 efficiency hint to the compiler, regarding the use of 'Access or
3304 'Unrestricted_Access on nested (non-library-level) subprograms. The
3305 pragma means that nested subprograms are not used with this type, or
3306 are rare, so that the generated code should be efficient in the
3307 top-level case. When this pragma is used, dynamically generated
3308 trampolines may be used on some targets for nested subprograms.
3309 See also the No_Implicit_Dynamic_Code restriction.
3311 @node Pragma Finalize_Storage_Only
3312 @unnumberedsec Pragma Finalize_Storage_Only
3313 @findex Finalize_Storage_Only
3314 @noindent
3315 Syntax:
3317 @smallexample @c ada
3318 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3319 @end smallexample
3321 @noindent
3322 This pragma allows the compiler not to emit a Finalize call for objects
3323 defined at the library level.  This is mostly useful for types where
3324 finalization is only used to deal with storage reclamation since in most
3325 environments it is not necessary to reclaim memory just before terminating
3326 execution, hence the name.
3328 @node Pragma Float_Representation
3329 @unnumberedsec Pragma Float_Representation
3330 @cindex OpenVMS
3331 @findex Float_Representation
3332 @noindent
3333 Syntax:
3335 @smallexample @c ada
3336 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3338 FLOAT_REP ::= VAX_Float | IEEE_Float
3339 @end smallexample
3341 @noindent
3342 In the one argument form, this pragma is a configuration pragma which
3343 allows control over the internal representation chosen for the predefined
3344 floating point types declared in the packages @code{Standard} and
3345 @code{System}. On all systems other than OpenVMS, the argument must
3346 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3347 argument may be @code{VAX_Float} to specify the use of the VAX float
3348 format for the floating-point types in Standard. This requires that
3349 the standard runtime libraries be recompiled.
3351 The two argument form specifies the representation to be used for
3352 the specified floating-point type. On all systems other than OpenVMS,
3353 the argument must
3354 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3356 @itemize @bullet
3357 @item
3358 For a digits value of 6, 32-bit IEEE short format will be used.
3359 @item
3360 For a digits value of 15, 64-bit IEEE long format will be used.
3361 @item
3362 No other value of digits is permitted.
3363 @end itemize
3365 On OpenVMS, the
3366 argument may be @code{VAX_Float} to specify the use of the VAX float
3367 format, as follows:
3369 @itemize @bullet
3370 @item
3371 For digits values up to 6, F float format will be used.
3372 @item
3373 For digits values from 7 to 9, D float format will be used.
3374 @item
3375 For digits values from 10 to 15, G float format will be used.
3376 @item
3377 Digits values above 15 are not allowed.
3378 @end itemize
3380 @node Pragma Global
3381 @unnumberedsec Pragma Global
3382 @findex Global
3383 @noindent
3384 For the description of this pragma, see SPARK 2014 Reference Manual,
3385 section 6.1.4.
3387 @node Pragma Ident
3388 @unnumberedsec Pragma Ident
3389 @findex Ident
3390 @noindent
3391 Syntax:
3393 @smallexample @c ada
3394 pragma Ident (static_string_EXPRESSION);
3395 @end smallexample
3397 @noindent
3398 This pragma is identical in effect to pragma @code{Comment}. It is provided
3399 for compatibility with other Ada compilers providing this pragma.
3401 @node Pragma Implementation_Defined
3402 @unnumberedsec Pragma Implementation_Defined
3403 @findex Implementation_Defined
3404 @noindent
3405 Syntax:
3407 @smallexample @c ada
3408 pragma Implementation_Defined (local_NAME);
3409 @end smallexample
3411 @noindent
3412 This pragma marks a previously declared entioty as implementation-defined.
3413 For an overloaded entity, applies to the most recent homonym.
3415 @smallexample @c ada
3416 pragma Implementation_Defined;
3417 @end smallexample
3419 @noindent
3420 The form with no arguments appears anywhere within a scope, most
3421 typically a package spec, and indicates that all entities that are
3422 defined within the package spec are Implementation_Defined.
3424 This pragma is used within the GNAT runtime library to identify
3425 implementation-defined entities introduced in language-defined units,
3426 for the purpose of implementing the No_Implementation_Identifiers
3427 restriction.
3429 @node Pragma Implemented
3430 @unnumberedsec Pragma Implemented
3431 @findex Implemented
3432 @noindent
3433 Syntax:
3435 @smallexample @c ada
3436 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3438 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3439 @end smallexample
3441 @noindent
3442 This is an Ada 2012 representation pragma which applies to protected, task
3443 and synchronized interface primitives. The use of pragma Implemented provides
3444 a way to impose a static requirement on the overriding operation by adhering
3445 to one of the three implementation kinds: entry, protected procedure or any of
3446 the above. This pragma is available in all earlier versions of Ada as an
3447 implementation-defined pragma.
3449 @smallexample @c ada
3450 type Synch_Iface is synchronized interface;
3451 procedure Prim_Op (Obj : in out Iface) is abstract;
3452 pragma Implemented (Prim_Op, By_Protected_Procedure);
3454 protected type Prot_1 is new Synch_Iface with
3455    procedure Prim_Op;  --  Legal
3456 end Prot_1;
3458 protected type Prot_2 is new Synch_Iface with
3459    entry Prim_Op;      --  Illegal
3460 end Prot_2;
3462 task type Task_Typ is new Synch_Iface with
3463    entry Prim_Op;      --  Illegal
3464 end Task_Typ;
3465 @end smallexample
3467 @noindent
3468 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3469 Implemented determines the runtime behavior of the requeue. Implementation kind
3470 By_Entry guarantees that the action of requeueing will proceed from an entry to
3471 another entry. Implementation kind By_Protected_Procedure transforms the
3472 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3473 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3474 the target's overriding subprogram kind.
3476 @node Pragma Implicit_Packing
3477 @unnumberedsec Pragma Implicit_Packing
3478 @findex Implicit_Packing
3479 @cindex Rational Profile
3480 @noindent
3481 Syntax:
3483 @smallexample @c ada
3484 pragma Implicit_Packing;
3485 @end smallexample
3487 @noindent
3488 This is a configuration pragma that requests implicit packing for packed
3489 arrays for which a size clause is given but no explicit pragma Pack or
3490 specification of Component_Size is present. It also applies to records
3491 where no record representation clause is present. Consider this example:
3493 @smallexample @c ada
3494 type R is array (0 .. 7) of Boolean;
3495 for R'Size use 8;
3496 @end smallexample
3498 @noindent
3499 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3500 does not change the layout of a composite object. So the Size clause in the
3501 above example is normally rejected, since the default layout of the array uses
3502 8-bit components, and thus the array requires a minimum of 64 bits.
3504 If this declaration is compiled in a region of code covered by an occurrence
3505 of the configuration pragma Implicit_Packing, then the Size clause in this
3506 and similar examples will cause implicit packing and thus be accepted. For
3507 this implicit packing to occur, the type in question must be an array of small
3508 components whose size is known at compile time, and the Size clause must
3509 specify the exact size that corresponds to the number of elements in the array
3510 multiplied by the size in bits of the component type (both single and
3511 multi-dimensioned arrays can be controlled with this pragma).
3513 @cindex Array packing
3515 Similarly, the following example shows the use in the record case
3517 @smallexample @c ada
3518 type r is record
3519    a, b, c, d, e, f, g, h : boolean;
3520    chr                    : character;
3521 end record;
3522 for r'size use 16;
3523 @end smallexample
3525 @noindent
3526 Without a pragma Pack, each Boolean field requires 8 bits, so the
3527 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3528 sufficient. The use of pragma Implicit_Packing allows this record
3529 declaration to compile without an explicit pragma Pack.
3530 @node Pragma Import_Exception
3531 @unnumberedsec Pragma Import_Exception
3532 @cindex OpenVMS
3533 @findex Import_Exception
3534 @noindent
3535 Syntax:
3537 @smallexample @c ada
3538 pragma Import_Exception (
3539      [Internal =>] LOCAL_NAME
3540   [, [External =>] EXTERNAL_SYMBOL]
3541   [, [Form     =>] Ada | VMS]
3542   [, [Code     =>] static_integer_EXPRESSION]);
3544 EXTERNAL_SYMBOL ::=
3545   IDENTIFIER
3546 | static_string_EXPRESSION
3547 @end smallexample
3549 @noindent
3550 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3551 It allows OpenVMS conditions (for example, from OpenVMS system services or
3552 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3553 The pragma specifies that the exception associated with an exception
3554 declaration in an Ada program be defined externally (in non-Ada code).
3555 For further details on this pragma, see the
3556 DEC Ada Language Reference Manual, section 13.9a.3.1.
3558 @node Pragma Import_Function
3559 @unnumberedsec Pragma Import_Function
3560 @findex Import_Function
3561 @noindent
3562 Syntax:
3564 @smallexample @c ada
3565 pragma Import_Function (
3566      [Internal                 =>] LOCAL_NAME,
3567   [, [External                 =>] EXTERNAL_SYMBOL]
3568   [, [Parameter_Types          =>] PARAMETER_TYPES]
3569   [, [Result_Type              =>] SUBTYPE_MARK]
3570   [, [Mechanism                =>] MECHANISM]
3571   [, [Result_Mechanism         =>] MECHANISM_NAME]);
3573 EXTERNAL_SYMBOL ::=
3574   IDENTIFIER
3575 | static_string_EXPRESSION
3577 PARAMETER_TYPES ::=
3578   null
3579 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3581 TYPE_DESIGNATOR ::=
3582   subtype_NAME
3583 | subtype_Name ' Access
3585 MECHANISM ::=
3586   MECHANISM_NAME
3587 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3589 MECHANISM_ASSOCIATION ::=
3590   [formal_parameter_NAME =>] MECHANISM_NAME
3592 MECHANISM_NAME ::=
3593   Value
3594 | Reference
3595 @end smallexample
3597 @noindent
3598 This pragma is used in conjunction with a pragma @code{Import} to
3599 specify additional information for an imported function.  The pragma
3600 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3601 @code{Import_Function} pragma and both must appear in the same
3602 declarative part as the function specification.
3604 The @var{Internal} argument must uniquely designate
3605 the function to which the
3606 pragma applies.  If more than one function name exists of this name in
3607 the declarative part you must use the @code{Parameter_Types} and
3608 @var{Result_Type} parameters to achieve the required unique
3609 designation.  Subtype marks in these parameters must exactly match the
3610 subtypes in the corresponding function specification, using positional
3611 notation to match parameters with subtype marks.
3612 The form with an @code{'Access} attribute can be used to match an
3613 anonymous access parameter.
3615 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3616 parameters to specify passing mechanisms for the
3617 parameters and result.  If you specify a single mechanism name, it
3618 applies to all parameters.  Otherwise you may specify a mechanism on a
3619 parameter by parameter basis using either positional or named
3620 notation.  If the mechanism is not specified, the default mechanism
3621 is used.
3623 @node Pragma Import_Object
3624 @unnumberedsec Pragma Import_Object
3625 @findex Import_Object
3626 @noindent
3627 Syntax:
3629 @smallexample @c ada
3630 pragma Import_Object
3631      [Internal =>] LOCAL_NAME
3632   [, [External =>] EXTERNAL_SYMBOL]
3633   [, [Size     =>] EXTERNAL_SYMBOL]);
3635 EXTERNAL_SYMBOL ::=
3636   IDENTIFIER
3637 | static_string_EXPRESSION
3638 @end smallexample
3640 @noindent
3641 This pragma designates an object as imported, and apart from the
3642 extended rules for external symbols, is identical in effect to the use of
3643 the normal @code{Import} pragma applied to an object.  Unlike the
3644 subprogram case, you need not use a separate @code{Import} pragma,
3645 although you may do so (and probably should do so from a portability
3646 point of view).  @var{size} is syntax checked, but otherwise ignored by
3647 GNAT@.
3649 @node Pragma Import_Procedure
3650 @unnumberedsec Pragma Import_Procedure
3651 @findex Import_Procedure
3652 @noindent
3653 Syntax:
3655 @smallexample @c ada
3656 pragma Import_Procedure (
3657      [Internal                 =>] LOCAL_NAME
3658   [, [External                 =>] EXTERNAL_SYMBOL]
3659   [, [Parameter_Types          =>] PARAMETER_TYPES]
3660   [, [Mechanism                =>] MECHANISM]);
3662 EXTERNAL_SYMBOL ::=
3663   IDENTIFIER
3664 | static_string_EXPRESSION
3666 PARAMETER_TYPES ::=
3667   null
3668 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3670 TYPE_DESIGNATOR ::=
3671   subtype_NAME
3672 | subtype_Name ' Access
3674 MECHANISM ::=
3675   MECHANISM_NAME
3676 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3678 MECHANISM_ASSOCIATION ::=
3679   [formal_parameter_NAME =>] MECHANISM_NAME
3681 MECHANISM_NAME ::= Value | Reference
3682 @end smallexample
3684 @noindent
3685 This pragma is identical to @code{Import_Function} except that it
3686 applies to a procedure rather than a function and the parameters
3687 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3689 @node Pragma Import_Valued_Procedure
3690 @unnumberedsec Pragma Import_Valued_Procedure
3691 @findex Import_Valued_Procedure
3692 @noindent
3693 Syntax:
3695 @smallexample @c ada
3696 pragma Import_Valued_Procedure (
3697      [Internal                 =>] LOCAL_NAME
3698   [, [External                 =>] EXTERNAL_SYMBOL]
3699   [, [Parameter_Types          =>] PARAMETER_TYPES]
3700   [, [Mechanism                =>] MECHANISM]);
3702 EXTERNAL_SYMBOL ::=
3703   IDENTIFIER
3704 | static_string_EXPRESSION
3706 PARAMETER_TYPES ::=
3707   null
3708 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3710 TYPE_DESIGNATOR ::=
3711   subtype_NAME
3712 | subtype_Name ' Access
3714 MECHANISM ::=
3715   MECHANISM_NAME
3716 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3718 MECHANISM_ASSOCIATION ::=
3719   [formal_parameter_NAME =>] MECHANISM_NAME
3721 MECHANISM_NAME ::= Value | Reference
3722 @end smallexample
3724 @noindent
3725 This pragma is identical to @code{Import_Procedure} except that the
3726 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3727 mode @code{OUT}, and externally the subprogram is treated as a function
3728 with this parameter as the result of the function.  The purpose of this
3729 capability is to allow the use of @code{OUT} and @code{IN OUT}
3730 parameters in interfacing to external functions (which are not permitted
3731 in Ada functions).  You may optionally use the @code{Mechanism}
3732 parameters to specify passing mechanisms for the parameters.
3733 If you specify a single mechanism name, it applies to all parameters.
3734 Otherwise you may specify a mechanism on a parameter by parameter
3735 basis using either positional or named notation.  If the mechanism is not
3736 specified, the default mechanism is used.
3738 Note that it is important to use this pragma in conjunction with a separate
3739 pragma Import that specifies the desired convention, since otherwise the
3740 default convention is Ada, which is almost certainly not what is required.
3742 @node Pragma Independent
3743 @unnumberedsec Pragma Independent
3744 @findex Independent
3745 @noindent
3746 Syntax:
3748 @smallexample @c ada
3749 pragma Independent (Local_NAME);
3750 @end smallexample
3752 @noindent
3753 This pragma is standard in Ada 2012 mode (which also provides an aspect
3754 of the same name). It is also available as an implementation-defined
3755 pragma in all earlier versions. It specifies that the
3756 designated object or all objects of the designated type must be
3757 independently addressable. This means that separate tasks can safely
3758 manipulate such objects. For example, if two components of a record are
3759 independent, then two separate tasks may access these two components.
3760 This may place
3761 constraints on the representation of the object (for instance prohibiting
3762 tight packing).
3764 @node Pragma Independent_Components
3765 @unnumberedsec Pragma Independent_Components
3766 @findex Independent_Components
3767 @noindent
3768 Syntax:
3770 @smallexample @c ada
3771 pragma Independent_Components (Local_NAME);
3772 @end smallexample
3774 @noindent
3775 This pragma is standard in Ada 2012 mode (which also provides an aspect
3776 of the same name). It is also available as an implementation-defined
3777 pragma in all earlier versions. It specifies that the components of the
3778 designated object, or the components of each object of the designated
3779 type, must be
3780 independently addressable. This means that separate tasks can safely
3781 manipulate separate components in the composite object. This may place
3782 constraints on the representation of the object (for instance prohibiting
3783 tight packing).
3785 @node Pragma Initial_Condition
3786 @unnumberedsec Pragma Initial_Condition
3787 @findex Initial_Condition
3788 @noindent
3789 For the description of this pragma, see SPARK 2014 Reference Manual,
3790 section 7.1.6.
3792 @node Pragma Initialize_Scalars
3793 @unnumberedsec Pragma Initialize_Scalars
3794 @findex Initialize_Scalars
3795 @cindex debugging with Initialize_Scalars
3796 @noindent
3797 Syntax:
3799 @smallexample @c ada
3800 pragma Initialize_Scalars;
3801 @end smallexample
3803 @noindent
3804 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3805 two important differences.  First, there is no requirement for the pragma
3806 to be used uniformly in all units of a partition, in particular, it is fine
3807 to use this just for some or all of the application units of a partition,
3808 without needing to recompile the run-time library.
3810 In the case where some units are compiled with the pragma, and some without,
3811 then a declaration of a variable where the type is defined in package
3812 Standard or is locally declared will always be subject to initialization,
3813 as will any declaration of a scalar variable.  For composite variables,
3814 whether the variable is initialized may also depend on whether the package
3815 in which the type of the variable is declared is compiled with the pragma.
3817 The other important difference is that you can control the value used
3818 for initializing scalar objects.  At bind time, you can select several
3819 options for initialization. You can
3820 initialize with invalid values (similar to Normalize_Scalars, though for
3821 Initialize_Scalars it is not always possible to determine the invalid
3822 values in complex cases like signed component fields with non-standard
3823 sizes). You can also initialize with high or
3824 low values, or with a specified bit pattern.  See the @value{EDITION}
3825 User's Guide for binder options for specifying these cases.
3827 This means that you can compile a program, and then without having to
3828 recompile the program, you can run it with different values being used
3829 for initializing otherwise uninitialized values, to test if your program
3830 behavior depends on the choice.  Of course the behavior should not change,
3831 and if it does, then most likely you have an incorrect reference to an
3832 uninitialized value.
3834 It is even possible to change the value at execution time eliminating even
3835 the need to rebind with a different switch using an environment variable.
3836 See the @value{EDITION} User's Guide for details.
3838 Note that pragma @code{Initialize_Scalars} is particularly useful in
3839 conjunction with the enhanced validity checking that is now provided
3840 in GNAT, which checks for invalid values under more conditions.
3841 Using this feature (see description of the @option{-gnatV} flag in the
3842 @value{EDITION} User's Guide) in conjunction with
3843 pragma @code{Initialize_Scalars}
3844 provides a powerful new tool to assist in the detection of problems
3845 caused by uninitialized variables.
3847 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3848 effect on the generated code. This may cause your code to be
3849 substantially larger. It may also cause an increase in the amount
3850 of stack required, so it is probably a good idea to turn on stack
3851 checking (see description of stack checking in the @value{EDITION}
3852 User's Guide) when using this pragma.
3854 @node Pragma Initializes
3855 @unnumberedsec Pragma Initializes
3856 @findex Initializes
3857 @noindent
3858 For the description of this pragma, see SPARK 2014 Reference Manual,
3859 section 7.1.5.
3861 @node Pragma Inline_Always
3862 @unnumberedsec Pragma Inline_Always
3863 @findex Inline_Always
3864 @noindent
3865 Syntax:
3867 @smallexample @c ada
3868 pragma Inline_Always (NAME [, NAME]);
3869 @end smallexample
3871 @noindent
3872 Similar to pragma @code{Inline} except that inlining is not subject to
3873 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3874 happens regardless of whether these options are used.
3876 @node Pragma Inline_Generic
3877 @unnumberedsec Pragma Inline_Generic
3878 @findex Inline_Generic
3879 @noindent
3880 Syntax:
3882 @smallexample @c ada
3883 pragma Inline_Generic (GNAME @{, GNAME@});
3885 GNAME ::= generic_unit_NAME | generic_instance_NAME
3886 @end smallexample
3888 @noindent
3889 This pragma is provided for compatibility with Dec Ada 83. It has
3890 no effect in @code{GNAT} (which always inlines generics), other
3891 than to check that the given names are all names of generic units or
3892 generic instances.
3894 @node Pragma Interface
3895 @unnumberedsec Pragma Interface
3896 @findex Interface
3897 @noindent
3898 Syntax:
3900 @smallexample @c ada
3901 pragma Interface (
3902      [Convention    =>] convention_identifier,
3903      [Entity        =>] local_NAME
3904   [, [External_Name =>] static_string_expression]
3905   [, [Link_Name     =>] static_string_expression]);
3906 @end smallexample
3908 @noindent
3909 This pragma is identical in syntax and semantics to
3910 the standard Ada pragma @code{Import}.  It is provided for compatibility
3911 with Ada 83.  The definition is upwards compatible both with pragma
3912 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3913 with some extended implementations of this pragma in certain Ada 83
3914 implementations.  The only difference between pragma @code{Interface}
3915 and pragma @code{Import} is that there is special circuitry to allow
3916 both pragmas to appear for the same subprogram entity (normally it
3917 is illegal to have multiple @code{Import} pragmas. This is useful in
3918 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3919 Ada 83 compilers.
3921 @node Pragma Interface_Name
3922 @unnumberedsec Pragma Interface_Name
3923 @findex Interface_Name
3924 @noindent
3925 Syntax:
3927 @smallexample @c ada
3928 pragma Interface_Name (
3929      [Entity        =>] LOCAL_NAME
3930   [, [External_Name =>] static_string_EXPRESSION]
3931   [, [Link_Name     =>] static_string_EXPRESSION]);
3932 @end smallexample
3934 @noindent
3935 This pragma provides an alternative way of specifying the interface name
3936 for an interfaced subprogram, and is provided for compatibility with Ada
3937 83 compilers that use the pragma for this purpose.  You must provide at
3938 least one of @var{External_Name} or @var{Link_Name}.
3940 @node Pragma Interrupt_Handler
3941 @unnumberedsec Pragma Interrupt_Handler
3942 @findex Interrupt_Handler
3943 @noindent
3944 Syntax:
3946 @smallexample @c ada
3947 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3948 @end smallexample
3950 @noindent
3951 This program unit pragma is supported for parameterless protected procedures
3952 as described in Annex C of the Ada Reference Manual. On the AAMP target
3953 the pragma can also be specified for nonprotected parameterless procedures
3954 that are declared at the library level (which includes procedures
3955 declared at the top level of a library package). In the case of AAMP,
3956 when this pragma is applied to a nonprotected procedure, the instruction
3957 @code{IERET} is generated for returns from the procedure, enabling
3958 maskable interrupts, in place of the normal return instruction.
3960 @node Pragma Interrupt_State
3961 @unnumberedsec Pragma Interrupt_State
3962 @findex Interrupt_State
3963 @noindent
3964 Syntax:
3966 @smallexample @c ada
3967 pragma Interrupt_State
3968  ([Name  =>] value,
3969   [State =>] SYSTEM | RUNTIME | USER);
3970 @end smallexample
3972 @noindent
3973 Normally certain interrupts are reserved to the implementation.  Any attempt
3974 to attach an interrupt causes Program_Error to be raised, as described in
3975 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3976 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3977 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3978 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3979 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3980 Ada exceptions, or used to implement run-time functions such as the
3981 @code{abort} statement and stack overflow checking.
3983 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3984 such uses of interrupts.  It subsumes the functionality of pragma
3985 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3986 available on Windows or VMS.  On all other platforms than VxWorks,
3987 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3988 and may be used to mark interrupts required by the board support package
3989 as reserved.
3991 Interrupts can be in one of three states:
3992 @itemize @bullet
3993 @item System
3995 The interrupt is reserved (no Ada handler can be installed), and the
3996 Ada run-time may not install a handler. As a result you are guaranteed
3997 standard system default action if this interrupt is raised.
3999 @item Runtime
4001 The interrupt is reserved (no Ada handler can be installed). The run time
4002 is allowed to install a handler for internal control purposes, but is
4003 not required to do so.
4005 @item User
4007 The interrupt is unreserved.  The user may install a handler to provide
4008 some other action.
4009 @end itemize
4011 @noindent
4012 These states are the allowed values of the @code{State} parameter of the
4013 pragma.  The @code{Name} parameter is a value of the type
4014 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
4015 @code{Ada.Interrupts.Names}.
4017 This is a configuration pragma, and the binder will check that there
4018 are no inconsistencies between different units in a partition in how a
4019 given interrupt is specified. It may appear anywhere a pragma is legal.
4021 The effect is to move the interrupt to the specified state.
4023 By declaring interrupts to be SYSTEM, you guarantee the standard system
4024 action, such as a core dump.
4026 By declaring interrupts to be USER, you guarantee that you can install
4027 a handler.
4029 Note that certain signals on many operating systems cannot be caught and
4030 handled by applications.  In such cases, the pragma is ignored.  See the
4031 operating system documentation, or the value of the array @code{Reserved}
4032 declared in the spec of package @code{System.OS_Interface}.
4034 Overriding the default state of signals used by the Ada runtime may interfere
4035 with an application's runtime behavior in the cases of the synchronous signals,
4036 and in the case of the signal used to implement the @code{abort} statement.
4038 @node Pragma Invariant
4039 @unnumberedsec Pragma Invariant
4040 @findex Invariant
4041 @noindent
4042 Syntax:
4044 @smallexample @c ada
4045 pragma Invariant
4046   ([Entity =>]    private_type_LOCAL_NAME,
4047    [Check  =>]    EXPRESSION
4048    [,[Message =>] String_Expression]);
4049 @end smallexample
4051 @noindent
4052 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4053 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4054 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4055 requires the use of the aspect syntax, which is not available except in 2012
4056 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4057 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4058 note that the aspect Invariant is a synonym in GNAT for the aspect
4059 Type_Invariant, but there is no pragma Type_Invariant.
4061 The pragma must appear within the visible part of the package specification,
4062 after the type to which its Entity argument appears. As with the Invariant
4063 aspect, the Check expression is not analyzed until the end of the visible
4064 part of the package, so it may contain forward references. The Message
4065 argument, if present, provides the exception message used if the invariant
4066 is violated. If no Message parameter is provided, a default message that
4067 identifies the line on which the pragma appears is used.
4069 It is permissible to have multiple Invariants for the same type entity, in
4070 which case they are and'ed together. It is permissible to use this pragma
4071 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4072 invariant pragma for the same entity.
4074 For further details on the use of this pragma, see the Ada 2012 documentation
4075 of the Type_Invariant aspect.
4077 @node Pragma Java_Constructor
4078 @unnumberedsec Pragma Java_Constructor
4079 @findex Java_Constructor
4080 @noindent
4081 Syntax:
4083 @smallexample @c ada
4084 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4085 @end smallexample
4087 @noindent
4088 This pragma is used to assert that the specified Ada function should be
4089 mapped to the Java constructor for some Ada tagged record type.
4091 See section 7.3.2 of the
4092 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4093 for related information.
4095 @node Pragma Java_Interface
4096 @unnumberedsec Pragma Java_Interface
4097 @findex Java_Interface
4098 @noindent
4099 Syntax:
4101 @smallexample @c ada
4102 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4103 @end smallexample
4105 @noindent
4106 This pragma is used to assert that the specified Ada abstract tagged type
4107 is to be mapped to a Java interface name.
4109 See sections 7.1 and 7.2 of the
4110 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4111 for related information.
4113 @node Pragma Keep_Names
4114 @unnumberedsec Pragma Keep_Names
4115 @findex Keep_Names
4116 @noindent
4117 Syntax:
4119 @smallexample @c ada
4120 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4121 @end smallexample
4123 @noindent
4124 The @var{LOCAL_NAME} argument
4125 must refer to an enumeration first subtype
4126 in the current declarative part. The effect is to retain the enumeration
4127 literal names for use by @code{Image} and @code{Value} even if a global
4128 @code{Discard_Names} pragma applies. This is useful when you want to
4129 generally suppress enumeration literal names and for example you therefore
4130 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4131 want to retain the names for specific enumeration types.
4133 @node Pragma License
4134 @unnumberedsec Pragma License
4135 @findex License
4136 @cindex License checking
4137 @noindent
4138 Syntax:
4140 @smallexample @c ada
4141 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4142 @end smallexample
4144 @noindent
4145 This pragma is provided to allow automated checking for appropriate license
4146 conditions with respect to the standard and modified GPL@.  A pragma
4147 @code{License}, which is a configuration pragma that typically appears at
4148 the start of a source file or in a separate @file{gnat.adc} file, specifies
4149 the licensing conditions of a unit as follows:
4151 @itemize @bullet
4152 @item Unrestricted
4153 This is used for a unit that can be freely used with no license restrictions.
4154 Examples of such units are public domain units, and units from the Ada
4155 Reference Manual.
4157 @item GPL
4158 This is used for a unit that is licensed under the unmodified GPL, and which
4159 therefore cannot be @code{with}'ed by a restricted unit.
4161 @item Modified_GPL
4162 This is used for a unit licensed under the GNAT modified GPL that includes
4163 a special exception paragraph that specifically permits the inclusion of
4164 the unit in programs without requiring the entire program to be released
4165 under the GPL@.
4167 @item Restricted
4168 This is used for a unit that is restricted in that it is not permitted to
4169 depend on units that are licensed under the GPL@.  Typical examples are
4170 proprietary code that is to be released under more restrictive license
4171 conditions.  Note that restricted units are permitted to @code{with} units
4172 which are licensed under the modified GPL (this is the whole point of the
4173 modified GPL).
4175 @end itemize
4177 @noindent
4178 Normally a unit with no @code{License} pragma is considered to have an
4179 unknown license, and no checking is done.  However, standard GNAT headers
4180 are recognized, and license information is derived from them as follows.
4182 A GNAT license header starts with a line containing 78 hyphens.  The following
4183 comment text is searched for the appearance of any of the following strings.
4185 If the string ``GNU General Public License'' is found, then the unit is assumed
4186 to have GPL license, unless the string ``As a special exception'' follows, in
4187 which case the license is assumed to be modified GPL@.
4189 If one of the strings
4190 ``This specification is adapted from the Ada Semantic Interface'' or
4191 ``This specification is derived from the Ada Reference Manual'' is found
4192 then the unit is assumed to be unrestricted.
4194 @noindent
4195 These default actions means that a program with a restricted license pragma
4196 will automatically get warnings if a GPL unit is inappropriately
4197 @code{with}'ed.  For example, the program:
4199 @smallexample @c ada
4200 with Sem_Ch3;
4201 with GNAT.Sockets;
4202 procedure Secret_Stuff is
4203   @dots{}
4204 end Secret_Stuff
4205 @end smallexample
4207 @noindent
4208 if compiled with pragma @code{License} (@code{Restricted}) in a
4209 @file{gnat.adc} file will generate the warning:
4211 @smallexample
4212 1.  with Sem_Ch3;
4213         |
4214    >>> license of withed unit "Sem_Ch3" is incompatible
4216 2.  with GNAT.Sockets;
4217 3.  procedure Secret_Stuff is
4218 @end smallexample
4220 @noindent
4221 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4222 compiler and is licensed under the
4223 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4224 run time, and is therefore licensed under the modified GPL@.
4226 @node Pragma Link_With
4227 @unnumberedsec Pragma Link_With
4228 @findex Link_With
4229 @noindent
4230 Syntax:
4232 @smallexample @c ada
4233 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4234 @end smallexample
4236 @noindent
4237 This pragma is provided for compatibility with certain Ada 83 compilers.
4238 It has exactly the same effect as pragma @code{Linker_Options} except
4239 that spaces occurring within one of the string expressions are treated
4240 as separators. For example, in the following case:
4242 @smallexample @c ada
4243 pragma Link_With ("-labc -ldef");
4244 @end smallexample
4246 @noindent
4247 results in passing the strings @code{-labc} and @code{-ldef} as two
4248 separate arguments to the linker. In addition pragma Link_With allows
4249 multiple arguments, with the same effect as successive pragmas.
4251 @node Pragma Linker_Alias
4252 @unnumberedsec Pragma Linker_Alias
4253 @findex Linker_Alias
4254 @noindent
4255 Syntax:
4257 @smallexample @c ada
4258 pragma Linker_Alias (
4259   [Entity =>] LOCAL_NAME,
4260   [Target =>] static_string_EXPRESSION);
4261 @end smallexample
4263 @noindent
4264 @var{LOCAL_NAME} must refer to an object that is declared at the library
4265 level. This pragma establishes the given entity as a linker alias for the
4266 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4267 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4268 @var{static_string_EXPRESSION} in the object file, that is to say no space
4269 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4270 to the same address as @var{static_string_EXPRESSION} by the linker.
4272 The actual linker name for the target must be used (e.g.@: the fully
4273 encoded name with qualification in Ada, or the mangled name in C++),
4274 or it must be declared using the C convention with @code{pragma Import}
4275 or @code{pragma Export}.
4277 Not all target machines support this pragma. On some of them it is accepted
4278 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4280 @smallexample @c ada
4281 --  Example of the use of pragma Linker_Alias
4283 package p is
4284   i : Integer := 1;
4285   pragma Export (C, i);
4287   new_name_for_i : Integer;
4288   pragma Linker_Alias (new_name_for_i, "i");
4289 end p;
4290 @end smallexample
4292 @node Pragma Linker_Constructor
4293 @unnumberedsec Pragma Linker_Constructor
4294 @findex Linker_Constructor
4295 @noindent
4296 Syntax:
4298 @smallexample @c ada
4299 pragma Linker_Constructor (procedure_LOCAL_NAME);
4300 @end smallexample
4302 @noindent
4303 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4304 is declared at the library level. A procedure to which this pragma is
4305 applied will be treated as an initialization routine by the linker.
4306 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4307 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4308 of the executable is called (or immediately after the shared library is
4309 loaded if the procedure is linked in a shared library), in particular
4310 before the Ada run-time environment is set up.
4312 Because of these specific contexts, the set of operations such a procedure
4313 can perform is very limited and the type of objects it can manipulate is
4314 essentially restricted to the elementary types. In particular, it must only
4315 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4317 This pragma is used by GNAT to implement auto-initialization of shared Stand
4318 Alone Libraries, which provides a related capability without the restrictions
4319 listed above. Where possible, the use of Stand Alone Libraries is preferable
4320 to the use of this pragma.
4322 @node Pragma Linker_Destructor
4323 @unnumberedsec Pragma Linker_Destructor
4324 @findex Linker_Destructor
4325 @noindent
4326 Syntax:
4328 @smallexample @c ada
4329 pragma Linker_Destructor (procedure_LOCAL_NAME);
4330 @end smallexample
4332 @noindent
4333 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4334 is declared at the library level. A procedure to which this pragma is
4335 applied will be treated as a finalization routine by the linker.
4336 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4337 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4338 of the executable has exited (or immediately before the shared library
4339 is unloaded if the procedure is linked in a shared library), in particular
4340 after the Ada run-time environment is shut down.
4342 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4343 because of these specific contexts.
4345 @node Pragma Linker_Section
4346 @unnumberedsec Pragma Linker_Section
4347 @findex Linker_Section
4348 @noindent
4349 Syntax:
4351 @smallexample @c ada
4352 pragma Linker_Section (
4353   [Entity  =>] LOCAL_NAME,
4354   [Section =>] static_string_EXPRESSION);
4355 @end smallexample
4357 @noindent
4358 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4359 declared at the library level. This pragma specifies the name of the
4360 linker section for the given entity. It is equivalent to
4361 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4362 be placed in the @var{static_string_EXPRESSION} section of the
4363 executable (assuming the linker doesn't rename the section).
4364 GNAT also provides an implementation defined aspect of the same name.
4366 In the case of specifying this aspect for a type, the effect is to
4367 specify the corresponding for all library level objects of the type which
4368 do not have an explicit linker section set. Note that this only applies to
4369 whole objects, not to components of composite objects.
4371 In the case of a subprogram, the linker section applies to all previously
4372 declared matching overloaded subprograms in the current declarative part
4373 which do not already have a linker section assigned. The linker section
4374 aspect is useful in this case for specifying different linker sections
4375 for different elements of such an overloaded set.
4377 Note that an empty string specifies that no linker section is specified.
4378 This is not quite the same as omitting the pragma or aspect, since it
4379 can be used to specify that one element of an overloaded set of subprograms
4380 has the default linker section, or that one object of a type for which a
4381 linker section is specified should has the default linker section.
4383 The compiler normally places library-level entities in standard sections
4384 depending on the class: procedures and functions generally go in the
4385 @code{.text} section, initialized variables in the @code{.data} section
4386 and uninitialized variables in the @code{.bss} section.
4388 Other, special sections may exist on given target machines to map special
4389 hardware, for example I/O ports or flash memory. This pragma is a means to
4390 defer the final layout of the executable to the linker, thus fully working
4391 at the symbolic level with the compiler.
4393 Some file formats do not support arbitrary sections so not all target
4394 machines support this pragma. The use of this pragma may cause a program
4395 execution to be erroneous if it is used to place an entity into an
4396 inappropriate section (e.g.@: a modified variable into the @code{.text}
4397 section). See also @code{pragma Persistent_BSS}.
4399 @smallexample @c ada
4400 --  Example of the use of pragma Linker_Section
4402 package IO_Card is
4403   Port_A : Integer;
4404   pragma Volatile (Port_A);
4405   pragma Linker_Section (Port_A, ".bss.port_a");
4407   Port_B : Integer;
4408   pragma Volatile (Port_B);
4409   pragma Linker_Section (Port_B, ".bss.port_b");
4411   type Port_Type is new Integer with Linker_Section => ".bss";
4412   PA : Port_Type with Linker_Section => ".bss.PA";
4413   PB : Port_Type; --  ends up in linker section ".bss"
4415   procedure Q with Linker_Section => "Qsection";
4416 end IO_Card;
4417 @end smallexample
4419 @node Pragma Lock_Free
4420 @unnumberedsec Pragma Lock_Free
4421 @findex Lock_Free
4422 @noindent
4423 Syntax:
4424 This pragma may be specified for protected types or objects. It specifies that
4425 the implementation of protected operations must be implemented without locks.
4426 Compilation fails if the compiler cannot generate lock-free code for the
4427 operations.
4429 @node Pragma Long_Float
4430 @unnumberedsec Pragma Long_Float
4431 @cindex OpenVMS
4432 @findex Long_Float
4433 @noindent
4434 Syntax:
4436 @smallexample @c ada
4437 pragma Long_Float (FLOAT_FORMAT);
4439 FLOAT_FORMAT ::= D_Float | G_Float
4440 @end smallexample
4442 @noindent
4443 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4444 It allows control over the internal representation chosen for the predefined
4445 type @code{Long_Float} and for floating point type representations with
4446 @code{digits} specified in the range 7 through 15.
4447 For further details on this pragma, see the
4448 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
4449 this pragma, the standard runtime libraries must be recompiled.
4451 @node Pragma Loop_Invariant
4452 @unnumberedsec Pragma Loop_Invariant
4453 @findex Loop_Invariant
4454 @noindent
4455 Syntax:
4457 @smallexample @c ada
4458 pragma Loop_Invariant ( boolean_EXPRESSION );
4459 @end smallexample
4461 @noindent
4462 The effect of this pragma is similar to that of pragma @code{Assert},
4463 except that in an @code{Assertion_Policy} pragma, the identifier
4464 @code{Loop_Invariant} is used to control whether it is ignored or checked
4465 (or disabled).
4467 @code{Loop_Invariant} can only appear as one of the items in the sequence
4468 of statements of a loop body, or nested inside block statements that
4469 appear in the sequence of statements of a loop body.
4470 The intention is that it be used to
4471 represent a "loop invariant" assertion, i.e. something that is true each
4472 time through the loop, and which can be used to show that the loop is
4473 achieving its purpose.
4475 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4476 apply to the same loop should be grouped in the same sequence of
4477 statements.
4479 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4480 may be used to refer to the value of an expression on entry to the loop. This
4481 attribute can only be used within the expression of a @code{Loop_Invariant}
4482 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4484 @node Pragma Loop_Optimize
4485 @unnumberedsec Pragma Loop_Optimize
4486 @findex Loop_Optimize
4487 @noindent
4488 Syntax:
4490 @smallexample @c ada
4491 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4493 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4494 @end smallexample
4496 @noindent
4497 This pragma must appear immediately within a loop statement.  It allows the
4498 programmer to specify optimization hints for the enclosing loop.  The hints
4499 are not mutually exclusive and can be freely mixed, but not all combinations
4500 will yield a sensible outcome.
4502 There are five supported optimization hints for a loop:
4504 @itemize @bullet
4505 @item Ivdep
4507 The programmer asserts that there are no loop-carried dependencies
4508 which would prevent consecutive iterations of the loop from being
4509 executed simultaneously.
4511 @item No_Unroll
4513 The loop must not be unrolled.  This is a strong hint: the compiler will not
4514 unroll a loop marked with this hint.
4516 @item Unroll
4518 The loop should be unrolled.  This is a weak hint: the compiler will try to
4519 apply unrolling to this loop preferably to other optimizations, notably
4520 vectorization, but there is no guarantee that the loop will be unrolled.
4522 @item No_Vector
4524 The loop must not be vectorized.  This is a strong hint: the compiler will not
4525 vectorize a loop marked with this hint.
4527 @item Vector
4529 The loop should be vectorized.  This is a weak hint: the compiler will try to
4530 apply vectorization to this loop preferably to other optimizations, notably
4531 unrolling, but there is no guarantee that the loop will be vectorized.
4533 @end itemize
4535 These hints do not remove the need to pass the appropriate switches to the
4536 compiler in order to enable the relevant optimizations, that is to say
4537 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4538 vectorization.
4540 @node Pragma Loop_Variant
4541 @unnumberedsec Pragma Loop_Variant
4542 @findex Loop_Variant
4543 @noindent
4544 Syntax:
4546 @smallexample @c ada
4547 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4548 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4549 CHANGE_DIRECTION ::= Increases | Decreases
4550 @end smallexample
4552 @noindent
4553 @code{Loop_Variant} can only appear as one of the items in the sequence
4554 of statements of a loop body, or nested inside block statements that
4555 appear in the sequence of statements of a loop body.
4556 It allows the specification of quantities which must always
4557 decrease or increase in successive iterations of the loop. In its simplest
4558 form, just one expression is specified, whose value must increase or decrease
4559 on each iteration of the loop.
4561 In a more complex form, multiple arguments can be given which are intepreted
4562 in a nesting lexicographic manner. For example:
4564 @smallexample @c ada
4565 pragma Loop_Variant (Increases => X, Decreases => Y);
4566 @end smallexample
4568 @noindent
4569 specifies that each time through the loop either X increases, or X stays
4570 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4571 loop is making progress. It can be useful in helping to show informally
4572 or prove formally that the loop always terminates.
4574 @code{Loop_Variant} is an assertion whose effect can be controlled using
4575 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4576 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4577 to ignore the check (in which case the pragma has no effect on the program),
4578 or @code{Disable} in which case the pragma is not even checked for correct
4579 syntax.
4581 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4582 apply to the same loop should be grouped in the same sequence of
4583 statements.
4585 The @code{Loop_Entry} attribute may be used within the expressions of the
4586 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4588 @node Pragma Machine_Attribute
4589 @unnumberedsec Pragma Machine_Attribute
4590 @findex Machine_Attribute
4591 @noindent
4592 Syntax:
4594 @smallexample @c ada
4595 pragma Machine_Attribute (
4596      [Entity         =>] LOCAL_NAME,
4597      [Attribute_Name =>] static_string_EXPRESSION
4598   [, [Info           =>] static_EXPRESSION] );
4599 @end smallexample
4601 @noindent
4602 Machine-dependent attributes can be specified for types and/or
4603 declarations.  This pragma is semantically equivalent to
4604 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4605 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4606 in GNU C, where @code{@var{attribute_name}} is recognized by the
4607 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4608 specific macro.  A string literal for the optional parameter @var{info}
4609 is transformed into an identifier, which may make this pragma unusable
4610 for some attributes.  @xref{Target Attributes,, Defining target-specific
4611 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4612 Internals}, further information.
4614 @node Pragma Main
4615 @unnumberedsec Pragma Main
4616 @cindex OpenVMS
4617 @findex Main
4618 @noindent
4619 Syntax:
4621 @smallexample @c ada
4622 pragma Main
4623  (MAIN_OPTION [, MAIN_OPTION]);
4625 MAIN_OPTION ::=
4626   [Stack_Size              =>] static_integer_EXPRESSION
4627 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4628 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
4629 @end smallexample
4631 @noindent
4632 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4633 no effect in GNAT, other than being syntax checked.
4635 @node Pragma Main_Storage
4636 @unnumberedsec Pragma Main_Storage
4637 @cindex OpenVMS
4638 @findex Main_Storage
4639 @noindent
4640 Syntax:
4642 @smallexample @c ada
4643 pragma Main_Storage
4644   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4646 MAIN_STORAGE_OPTION ::=
4647   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4648 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
4649 @end smallexample
4651 @noindent
4652 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
4653 no effect in GNAT, other than being syntax checked.  Note that the pragma
4654 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4656 @node Pragma No_Body
4657 @unnumberedsec Pragma No_Body
4658 @findex No_Body
4659 @noindent
4660 Syntax:
4662 @smallexample @c ada
4663 pragma No_Body;
4664 @end smallexample
4666 @noindent
4667 There are a number of cases in which a package spec does not require a body,
4668 and in fact a body is not permitted. GNAT will not permit the spec to be
4669 compiled if there is a body around. The pragma No_Body allows you to provide
4670 a body file, even in a case where no body is allowed. The body file must
4671 contain only comments and a single No_Body pragma. This is recognized by
4672 the compiler as indicating that no body is logically present.
4674 This is particularly useful during maintenance when a package is modified in
4675 such a way that a body needed before is no longer needed. The provision of a
4676 dummy body with a No_Body pragma ensures that there is no interference from
4677 earlier versions of the package body.
4679 @node Pragma No_Elaboration_Code_All
4680 @unnumberedsec Pragma No_Elaboration_Code_All
4681 @findex No_Elaboration_Code_All
4682 @noindent
4683 Syntax:
4685 @smallexample @c ada
4686 pragma No_Elaboration_Code_All [(program_unit_NAME)];
4687 @end smallexample
4689 @noindent
4690 This is a program unit pragma (there is also an equivalent aspect of the
4691 same name) that establishes the restriction @code{No_Elaboration_Code} for
4692 the current unit and any extended main source units (body and subunits.
4693 It also has has the effect of enforcing a transitive application of this
4694 aspect, so that if any unit is implicitly or explicitly WITH'ed by the
4695 current unit, it must also have the No_Elaboration_Code_All aspect set.
4697 @node Pragma No_Inline
4698 @unnumberedsec Pragma No_Inline
4699 @findex No_Inline
4700 @noindent
4701 Syntax:
4703 @smallexample @c ada
4704 pragma No_Inline (NAME @{, NAME@});
4705 @end smallexample
4707 @noindent
4708 This pragma suppresses inlining for the callable entity or the instances of
4709 the generic subprogram designated by @var{NAME}, including inlining that
4710 results from the use of pragma @code{Inline}.  This pragma is always active,
4711 in particular it is not subject to the use of option @option{-gnatn} or
4712 @option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
4713 pragma @code{Inline_Always} for the same @var{NAME}.
4715 @node Pragma No_Return
4716 @unnumberedsec Pragma No_Return
4717 @findex No_Return
4718 @noindent
4719 Syntax:
4721 @smallexample @c ada
4722 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4723 @end smallexample
4725 @noindent
4726 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4727 declarations in the current declarative part.  A procedure to which this
4728 pragma is applied may not contain any explicit @code{return} statements.
4729 In addition, if the procedure contains any implicit returns from falling
4730 off the end of a statement sequence, then execution of that implicit
4731 return will cause Program_Error to be raised.
4733 One use of this pragma is to identify procedures whose only purpose is to raise
4734 an exception. Another use of this pragma is to suppress incorrect warnings
4735 about missing returns in functions, where the last statement of a function
4736 statement sequence is a call to such a procedure.
4738 Note that in Ada 2005 mode, this pragma is part of the language. It is
4739 available in all earlier versions of Ada as an implementation-defined
4740 pragma.
4742 @node Pragma No_Run_Time
4743 @unnumberedsec Pragma No_Run_Time
4744 @findex No_Run_Time
4745 @noindent
4746 Syntax:
4748 @smallexample @c ada
4749 pragma No_Run_Time;
4750 @end smallexample
4752 @noindent
4753 This is an obsolete configuration pragma that historically was used to
4754 set up a runtime library with no object code. It is now used only for
4755 internal testing. The pragma has been superseded by the reconfigurable
4756 runtime capability of @code{GNAT}.
4758 @node Pragma No_Strict_Aliasing
4759 @unnumberedsec Pragma No_Strict_Aliasing
4760 @findex No_Strict_Aliasing
4761 @noindent
4762 Syntax:
4764 @smallexample @c ada
4765 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4766 @end smallexample
4768 @noindent
4769 @var{type_LOCAL_NAME} must refer to an access type
4770 declaration in the current declarative part.  The effect is to inhibit
4771 strict aliasing optimization for the given type.  The form with no
4772 arguments is a configuration pragma which applies to all access types
4773 declared in units to which the pragma applies. For a detailed
4774 description of the strict aliasing optimization, and the situations
4775 in which it must be suppressed, see @ref{Optimization and Strict
4776 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4778 This pragma currently has no effects on access to unconstrained array types.
4780 @node Pragma Normalize_Scalars
4781 @unnumberedsec Pragma Normalize_Scalars
4782 @findex Normalize_Scalars
4783 @noindent
4784 Syntax:
4786 @smallexample @c ada
4787 pragma Normalize_Scalars;
4788 @end smallexample
4790 @noindent
4791 This is a language defined pragma which is fully implemented in GNAT@.  The
4792 effect is to cause all scalar objects that are not otherwise initialized
4793 to be initialized.  The initial values are implementation dependent and
4794 are as follows:
4796 @table @code
4797 @item Standard.Character
4798 @noindent
4799 Objects whose root type is Standard.Character are initialized to
4800 Character'Last unless the subtype range excludes NUL (in which case
4801 NUL is used). This choice will always generate an invalid value if
4802 one exists.
4804 @item Standard.Wide_Character
4805 @noindent
4806 Objects whose root type is Standard.Wide_Character are initialized to
4807 Wide_Character'Last unless the subtype range excludes NUL (in which case
4808 NUL is used). This choice will always generate an invalid value if
4809 one exists.
4811 @item Standard.Wide_Wide_Character
4812 @noindent
4813 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4814 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4815 which case NUL is used). This choice will always generate an invalid value if
4816 one exists.
4818 @item Integer types
4819 @noindent
4820 Objects of an integer type are treated differently depending on whether
4821 negative values are present in the subtype. If no negative values are
4822 present, then all one bits is used as the initial value except in the
4823 special case where zero is excluded from the subtype, in which case
4824 all zero bits are used. This choice will always generate an invalid
4825 value if one exists.
4827 For subtypes with negative values present, the largest negative number
4828 is used, except in the unusual case where this largest negative number
4829 is in the subtype, and the largest positive number is not, in which case
4830 the largest positive value is used. This choice will always generate
4831 an invalid value if one exists.
4833 @item Floating-Point Types
4834 Objects of all floating-point types are initialized to all 1-bits. For
4835 standard IEEE format, this corresponds to a NaN (not a number) which is
4836 indeed an invalid value.
4838 @item Fixed-Point Types
4839 Objects of all fixed-point types are treated as described above for integers,
4840 with the rules applying to the underlying integer value used to represent
4841 the fixed-point value.
4843 @item Modular types
4844 Objects of a modular type are initialized to all one bits, except in
4845 the special case where zero is excluded from the subtype, in which
4846 case all zero bits are used. This choice will always generate an
4847 invalid value if one exists.
4849 @item Enumeration types
4850 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4851 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4852 whose Pos value is zero, in which case a code of zero is used. This choice
4853 will always generate an invalid value if one exists.
4855 @end table
4857 @node Pragma Obsolescent
4858 @unnumberedsec Pragma Obsolescent
4859 @findex Obsolescent
4860 @noindent
4861 Syntax:
4863 @smallexample @c ada
4864 pragma Obsolescent;
4866 pragma Obsolescent (
4867   [Message =>] static_string_EXPRESSION
4868 [,[Version =>] Ada_05]]);
4870 pragma Obsolescent (
4871   [Entity  =>] NAME
4872 [,[Message =>] static_string_EXPRESSION
4873 [,[Version =>] Ada_05]] );
4874 @end smallexample
4876 @noindent
4877 This pragma can occur immediately following a declaration of an entity,
4878 including the case of a record component. If no Entity argument is present,
4879 then this declaration is the one to which the pragma applies. If an Entity
4880 parameter is present, it must either match the name of the entity in this
4881 declaration, or alternatively, the pragma can immediately follow an enumeration
4882 type declaration, where the Entity argument names one of the enumeration
4883 literals.
4885 This pragma is used to indicate that the named entity
4886 is considered obsolescent and should not be used. Typically this is
4887 used when an API must be modified by eventually removing or modifying
4888 existing subprograms or other entities. The pragma can be used at an
4889 intermediate stage when the entity is still present, but will be
4890 removed later.
4892 The effect of this pragma is to output a warning message on a reference to
4893 an entity thus marked that the subprogram is obsolescent if the appropriate
4894 warning option in the compiler is activated. If the Message parameter is
4895 present, then a second warning message is given containing this text. In
4896 addition, a reference to the entity is considered to be a violation of pragma
4897 Restrictions (No_Obsolescent_Features).
4899 This pragma can also be used as a program unit pragma for a package,
4900 in which case the entity name is the name of the package, and the
4901 pragma indicates that the entire package is considered
4902 obsolescent. In this case a client @code{with}'ing such a package
4903 violates the restriction, and the @code{with} statement is
4904 flagged with warnings if the warning option is set.
4906 If the Version parameter is present (which must be exactly
4907 the identifier Ada_05, no other argument is allowed), then the
4908 indication of obsolescence applies only when compiling in Ada 2005
4909 mode. This is primarily intended for dealing with the situations
4910 in the predefined library where subprograms or packages
4911 have become defined as obsolescent in Ada 2005
4912 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4914 The following examples show typical uses of this pragma:
4916 @smallexample @c ada
4917 package p is
4918    pragma Obsolescent (p, Message => "use pp instead of p");
4919 end p;
4921 package q is
4922    procedure q2;
4923    pragma Obsolescent ("use q2new instead");
4925    type R is new integer;
4926    pragma Obsolescent
4927      (Entity  => R,
4928       Message => "use RR in Ada 2005",
4929       Version => Ada_05);
4931    type M is record
4932       F1 : Integer;
4933       F2 : Integer;
4934       pragma Obsolescent;
4935       F3 : Integer;
4936    end record;
4938    type E is (a, bc, 'd', quack);
4939    pragma Obsolescent (Entity => bc)
4940    pragma Obsolescent (Entity => 'd')
4942    function "+"
4943      (a, b : character) return character;
4944    pragma Obsolescent (Entity => "+");
4945 end;
4946 @end smallexample
4948 @noindent
4949 Note that, as for all pragmas, if you use a pragma argument identifier,
4950 then all subsequent parameters must also use a pragma argument identifier.
4951 So if you specify "Entity =>" for the Entity argument, and a Message
4952 argument is present, it must be preceded by "Message =>".
4954 @node Pragma Optimize_Alignment
4955 @unnumberedsec Pragma Optimize_Alignment
4956 @findex Optimize_Alignment
4957 @cindex Alignment, default settings
4958 @noindent
4959 Syntax:
4961 @smallexample @c ada
4962 pragma Optimize_Alignment (TIME | SPACE | OFF);
4963 @end smallexample
4965 @noindent
4966 This is a configuration pragma which affects the choice of default alignments
4967 for types and objects where no alignment is explicitly specified. There is a
4968 time/space trade-off in the selection of these values. Large alignments result
4969 in more efficient code, at the expense of larger data space, since sizes have
4970 to be increased to match these alignments. Smaller alignments save space, but
4971 the access code is slower. The normal choice of default alignments for types
4972 and individual alignment promotions for objects (which is what you get if you
4973 do not use this pragma, or if you use an argument of OFF), tries to balance
4974 these two requirements.
4976 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4977 First any packed record is given an alignment of 1. Second, if a size is given
4978 for the type, then the alignment is chosen to avoid increasing this size. For
4979 example, consider:
4981 @smallexample @c ada
4982    type R is record
4983       X : Integer;
4984       Y : Character;
4985    end record;
4987    for R'Size use 5*8;
4988 @end smallexample
4990 @noindent
4991 In the default mode, this type gets an alignment of 4, so that access to the
4992 Integer field X are efficient. But this means that objects of the type end up
4993 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4994 allowed to be bigger than the size of the type, but it can waste space if for
4995 example fields of type R appear in an enclosing record. If the above type is
4996 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4998 However, there is one case in which SPACE is ignored. If a variable length
4999 record (that is a discriminated record with a component which is an array
5000 whose length depends on a discriminant), has a pragma Pack, then it is not
5001 in general possible to set the alignment of such a record to one, so the
5002 pragma is ignored in this case (with a warning).
5004 Specifying SPACE also disables alignment promotions for standalone objects,
5005 which occur when the compiler increases the alignment of a specific object
5006 without changing the alignment of its type.
5008 Specifying TIME causes larger default alignments to be chosen in the case of
5009 small types with sizes that are not a power of 2. For example, consider:
5011 @smallexample @c ada
5012    type R is record
5013       A : Character;
5014       B : Character;
5015       C : Boolean;
5016    end record;
5018    pragma Pack (R);
5019    for R'Size use 17;
5020 @end smallexample
5022 @noindent
5023 The default alignment for this record is normally 1, but if this type is
5024 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5025 to 4, which wastes space for objects of the type, since they are now 4 bytes
5026 long, but results in more efficient access when the whole record is referenced.
5028 As noted above, this is a configuration pragma, and there is a requirement
5029 that all units in a partition be compiled with a consistent setting of the
5030 optimization setting. This would normally be achieved by use of a configuration
5031 pragma file containing the appropriate setting. The exception to this rule is
5032 that units with an explicit configuration pragma in the same file as the source
5033 unit are excluded from the consistency check, as are all predefined units. The
5034 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5035 pragma appears at the start of the file.
5037 @node Pragma Ordered
5038 @unnumberedsec Pragma Ordered
5039 @findex Ordered
5040 @findex pragma @code{Ordered}
5041 @noindent
5042 Syntax:
5044 @smallexample @c ada
5045 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5046 @end smallexample
5048 @noindent
5049 Most enumeration types are from a conceptual point of view unordered.
5050 For example, consider:
5052 @smallexample @c ada
5053 type Color is (Red, Blue, Green, Yellow);
5054 @end smallexample
5056 @noindent
5057 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5058 but really these relations make no sense; the enumeration type merely
5059 specifies a set of possible colors, and the order is unimportant.
5061 For unordered enumeration types, it is generally a good idea if
5062 clients avoid comparisons (other than equality or inequality) and
5063 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5064 other than the unit where the type is declared, its body, and its subunits.)
5065 For example, if code buried in some client says:
5067 @smallexample @c ada
5068 if Current_Color < Yellow then ...
5069 if Current_Color in Blue .. Green then ...
5070 @end smallexample
5072 @noindent
5073 then the client code is relying on the order, which is undesirable.
5074 It makes the code hard to read and creates maintenance difficulties if
5075 entries have to be added to the enumeration type. Instead,
5076 the code in the client should list the possibilities, or an
5077 appropriate subtype should be declared in the unit that declares
5078 the original enumeration type. E.g., the following subtype could
5079 be declared along with the type @code{Color}:
5081 @smallexample @c ada
5082 subtype RBG is Color range Red .. Green;
5083 @end smallexample
5085 @noindent
5086 and then the client could write:
5088 @smallexample @c ada
5089 if Current_Color in RBG then ...
5090 if Current_Color = Blue or Current_Color = Green then ...
5091 @end smallexample
5093 @noindent
5094 However, some enumeration types are legitimately ordered from a conceptual
5095 point of view. For example, if you declare:
5097 @smallexample @c ada
5098 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5099 @end smallexample
5101 @noindent
5102 then the ordering imposed by the language is reasonable, and
5103 clients can depend on it, writing for example:
5105 @smallexample @c ada
5106 if D in Mon .. Fri then ...
5107 if D < Wed then ...
5108 @end smallexample
5110 @noindent
5111 The pragma @option{Ordered} is provided to mark enumeration types that
5112 are conceptually ordered, alerting the reader that clients may depend
5113 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5114 rather than one to mark them as unordered, since in our experience,
5115 the great majority of enumeration types are conceptually unordered.
5117 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5118 and @code{Wide_Wide_Character}
5119 are considered to be ordered types, so each is declared with a
5120 pragma @code{Ordered} in package @code{Standard}.
5122 Normally pragma @code{Ordered} serves only as documentation and a guide for
5123 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5124 requests warnings for inappropriate uses (comparisons and explicit
5125 subranges) for unordered types. If this switch is used, then any
5126 enumeration type not marked with pragma @code{Ordered} will be considered
5127 as unordered, and will generate warnings for inappropriate uses.
5129 For additional information please refer to the description of the
5130 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5132 @node Pragma Overflow_Mode
5133 @unnumberedsec Pragma Overflow_Mode
5134 @findex Overflow checks
5135 @findex Overflow mode
5136 @findex pragma @code{Overflow_Mode}
5137 @noindent
5138 Syntax:
5140 @smallexample @c ada
5141 pragma Overflow_Mode
5142  (  [General    =>] MODE
5143   [,[Assertions =>] MODE]);
5145 MODE ::= STRICT | MINIMIZED | ELIMINATED
5146 @end smallexample
5148 @noindent
5149 This pragma sets the current overflow mode to the given setting. For details
5150 of the meaning of these modes, please refer to the
5151 ``Overflow Check Handling in GNAT'' appendix in the
5152 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5153 the given mode applies to all expressions. If both parameters are present,
5154 the @code{General} mode applies to expressions outside assertions, and
5155 the @code{Eliminated} mode applies to expressions within assertions.
5157 The case of the @code{MODE} parameter is ignored,
5158 so @code{MINIMIZED}, @code{Minimized} and
5159 @code{minimized} all have the same effect.
5161 The @code{Overflow_Mode} pragma has the same scoping and placement
5162 rules as pragma @code{Suppress}, so it can occur either as a
5163 configuration pragma, specifying a default for the whole
5164 program, or in a declarative scope, where it applies to the
5165 remaining declarations and statements in that scope.
5167 The pragma @code{Suppress (Overflow_Check)} suppresses
5168 overflow checking, but does not affect the overflow mode.
5170 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5171 overflow checking, but does not affect the overflow mode.
5173 @node Pragma Overriding_Renamings
5174 @unnumberedsec Pragma Overriding_Renamings
5175 @findex Overriding_Renamings
5176 @cindex Rational profile
5177 @cindex Rational compatibility
5178 @noindent
5179 Syntax:
5181 @smallexample @c ada
5182 pragma Overriding_Renamings;
5183 @end smallexample
5185 @noindent
5186 This is a GNAT configuration pragma to simplify porting
5187 legacy code accepted by the Rational
5188 Ada compiler. In the presence of this pragma, a renaming declaration that
5189 renames an inherited operation declared in the same scope is legal if selected
5190 notation is used as in:
5192 @smallexample @c ada
5193 pragma Overriding_Renamings;
5195 package R is
5196   function F (..);
5197   ...
5198   function F (..) renames R.F;
5199 end R;
5200 @end smallexample
5202 even though
5203 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5204 declaration of the overriding operation.
5206 @node Pragma Partition_Elaboration_Policy
5207 @unnumberedsec Pragma Partition_Elaboration_Policy
5208 @findex Partition_Elaboration_Policy
5209 @noindent
5210 Syntax:
5212 @smallexample @c ada
5213 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5215 POLICY_IDENTIFIER ::= Concurrent | Sequential
5216 @end smallexample
5218 @noindent
5219 This pragma is standard in Ada 2005, but is available in all earlier
5220 versions of Ada as an implementation-defined pragma.
5221 See Ada 2012 Reference Manual for details.
5223 @node Pragma Part_Of
5224 @unnumberedsec Pragma Part_Of
5225 @findex Part_Of
5226 @noindent
5227 For the description of this pragma, see SPARK 2014 Reference Manual,
5228 section 7.2.6.
5230 @node Pragma Passive
5231 @unnumberedsec Pragma Passive
5232 @findex Passive
5233 @noindent
5234 Syntax:
5236 @smallexample @c ada
5237 pragma Passive [(Semaphore | No)];
5238 @end smallexample
5240 @noindent
5241 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
5242 compatibility with DEC Ada 83 implementations, where it is used within a
5243 task definition to request that a task be made passive.  If the argument
5244 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5245 treats the pragma as an assertion that the containing task is passive
5246 and that optimization of context switch with this task is permitted and
5247 desired.  If the argument @code{No} is present, the task must not be
5248 optimized.  GNAT does not attempt to optimize any tasks in this manner
5249 (since protected objects are available in place of passive tasks).
5251 For more information on the subject of passive tasks, see the section
5252 ``Passive Task Optimization'' in the GNAT Users Guide.
5254 @node Pragma Persistent_BSS
5255 @unnumberedsec Pragma Persistent_BSS
5256 @findex Persistent_BSS
5257 @noindent
5258 Syntax:
5260 @smallexample @c ada
5261 pragma Persistent_BSS [(LOCAL_NAME)]
5262 @end smallexample
5264 @noindent
5265 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5266 section. On some targets the linker and loader provide for special
5267 treatment of this section, allowing a program to be reloaded without
5268 affecting the contents of this data (hence the name persistent).
5270 There are two forms of usage. If an argument is given, it must be the
5271 local name of a library level object, with no explicit initialization
5272 and whose type is potentially persistent. If no argument is given, then
5273 the pragma is a configuration pragma, and applies to all library level
5274 objects with no explicit initialization of potentially persistent types.
5276 A potentially persistent type is a scalar type, or an untagged,
5277 non-discriminated record, all of whose components have no explicit
5278 initialization and are themselves of a potentially persistent type,
5279 or an array, all of whose constraints are static, and whose component
5280 type is potentially persistent.
5282 If this pragma is used on a target where this feature is not supported,
5283 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5285 @node Pragma Polling
5286 @unnumberedsec Pragma Polling
5287 @findex Polling
5288 @noindent
5289 Syntax:
5291 @smallexample @c ada
5292 pragma Polling (ON | OFF);
5293 @end smallexample
5295 @noindent
5296 This pragma controls the generation of polling code.  This is normally off.
5297 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5298 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
5299 runtime library, and can be found in file @file{a-excpol.adb}.
5301 Pragma @code{Polling} can appear as a configuration pragma (for example it
5302 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5303 can be used in the statement or declaration sequence to control polling
5304 more locally.
5306 A call to the polling routine is generated at the start of every loop and
5307 at the start of every subprogram call.  This guarantees that the @code{Poll}
5308 routine is called frequently, and places an upper bound (determined by
5309 the complexity of the code) on the period between two @code{Poll} calls.
5311 The primary purpose of the polling interface is to enable asynchronous
5312 aborts on targets that cannot otherwise support it (for example Windows
5313 NT), but it may be used for any other purpose requiring periodic polling.
5314 The standard version is null, and can be replaced by a user program.  This
5315 will require re-compilation of the @code{Ada.Exceptions} package that can
5316 be found in files @file{a-except.ads} and @file{a-except.adb}.
5318 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5319 distribution) is used to enable the asynchronous abort capability on
5320 targets that do not normally support the capability.  The version of
5321 @code{Poll} in this file makes a call to the appropriate runtime routine
5322 to test for an abort condition.
5324 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5325 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5326 details.
5328 @node Pragma Post
5329 @unnumberedsec Pragma Post
5330 @cindex Post
5331 @cindex Checks, postconditions
5332 @findex Postconditions
5333 @noindent
5334 Syntax:
5336 @smallexample @c ada
5337 pragma Post (Boolean_Expression);
5338 @end smallexample
5340 @noindent
5341 The @code{Post} pragma is intended to be an exact replacement for
5342 the language-defined
5343 @code{Post} aspect, and shares its restrictions and semantics.
5344 It must appear either immediately following the corresponding
5345 subprogram declaration (only other pragmas may intervene), or
5346 if there is no separate subprogram declaration, then it can
5347 appear at the start of the declarations in a subprogram body
5348 (preceded only by other pragmas).
5350 @node Pragma Postcondition
5351 @unnumberedsec Pragma Postcondition
5352 @cindex Postcondition
5353 @cindex Checks, postconditions
5354 @findex Postconditions
5355 @noindent
5356 Syntax:
5358 @smallexample @c ada
5359 pragma Postcondition (
5360    [Check   =>] Boolean_Expression
5361  [,[Message =>] String_Expression]);
5362 @end smallexample
5364 @noindent
5365 The @code{Postcondition} pragma allows specification of automatic
5366 postcondition checks for subprograms. These checks are similar to
5367 assertions, but are automatically inserted just prior to the return
5368 statements of the subprogram with which they are associated (including
5369 implicit returns at the end of procedure bodies and associated
5370 exception handlers).
5372 In addition, the boolean expression which is the condition which
5373 must be true may contain references to function'Result in the case
5374 of a function to refer to the returned value.
5376 @code{Postcondition} pragmas may appear either immediately following the
5377 (separate) declaration of a subprogram, or at the start of the
5378 declarations of a subprogram body. Only other pragmas may intervene
5379 (that is appear between the subprogram declaration and its
5380 postconditions, or appear before the postcondition in the
5381 declaration sequence in a subprogram body). In the case of a
5382 postcondition appearing after a subprogram declaration, the
5383 formal arguments of the subprogram are visible, and can be
5384 referenced in the postcondition expressions.
5386 The postconditions are collected and automatically tested just
5387 before any return (implicit or explicit) in the subprogram body.
5388 A postcondition is only recognized if postconditions are active
5389 at the time the pragma is encountered. The compiler switch @option{gnata}
5390 turns on all postconditions by default, and pragma @code{Check_Policy}
5391 with an identifier of @code{Postcondition} can also be used to
5392 control whether postconditions are active.
5394 The general approach is that postconditions are placed in the spec
5395 if they represent functional aspects which make sense to the client.
5396 For example we might have:
5398 @smallexample @c ada
5399    function Direction return Integer;
5400    pragma Postcondition
5401     (Direction'Result = +1
5402        or else
5403      Direction'Result = -1);
5404 @end smallexample
5406 @noindent
5407 which serves to document that the result must be +1 or -1, and
5408 will test that this is the case at run time if postcondition
5409 checking is active.
5411 Postconditions within the subprogram body can be used to
5412 check that some internal aspect of the implementation,
5413 not visible to the client, is operating as expected.
5414 For instance if a square root routine keeps an internal
5415 counter of the number of times it is called, then we
5416 might have the following postcondition:
5418 @smallexample @c ada
5419    Sqrt_Calls : Natural := 0;
5421    function Sqrt (Arg : Float) return Float is
5422      pragma Postcondition
5423        (Sqrt_Calls = Sqrt_Calls'Old + 1);
5424      ...
5425    end Sqrt
5426 @end smallexample
5428 @noindent
5429 As this example, shows, the use of the @code{Old} attribute
5430 is often useful in postconditions to refer to the state on
5431 entry to the subprogram.
5433 Note that postconditions are only checked on normal returns
5434 from the subprogram. If an abnormal return results from
5435 raising an exception, then the postconditions are not checked.
5437 If a postcondition fails, then the exception
5438 @code{System.Assertions.Assert_Failure} is raised. If
5439 a message argument was supplied, then the given string
5440 will be used as the exception message. If no message
5441 argument was supplied, then the default message has
5442 the form "Postcondition failed at file:line". The
5443 exception is raised in the context of the subprogram
5444 body, so it is possible to catch postcondition failures
5445 within the subprogram body itself.
5447 Within a package spec, normal visibility rules
5448 in Ada would prevent forward references within a
5449 postcondition pragma to functions defined later in
5450 the same package. This would introduce undesirable
5451 ordering constraints. To avoid this problem, all
5452 postcondition pragmas are analyzed at the end of
5453 the package spec, allowing forward references.
5455 The following example shows that this even allows
5456 mutually recursive postconditions as in:
5458 @smallexample @c ada
5459 package Parity_Functions is
5460    function Odd  (X : Natural) return Boolean;
5461    pragma Postcondition
5462      (Odd'Result =
5463         (x = 1
5464           or else
5465         (x /= 0 and then Even (X - 1))));
5467    function Even (X : Natural) return Boolean;
5468    pragma Postcondition
5469      (Even'Result =
5470         (x = 0
5471           or else
5472         (x /= 1 and then Odd (X - 1))));
5474 end Parity_Functions;
5475 @end smallexample
5477 @noindent
5478 There are no restrictions on the complexity or form of
5479 conditions used within @code{Postcondition} pragmas.
5480 The following example shows that it is even possible
5481 to verify performance behavior.
5483 @smallexample @c ada
5484 package Sort is
5486    Performance : constant Float;
5487    --  Performance constant set by implementation
5488    --  to match target architecture behavior.
5490    procedure Treesort (Arg : String);
5491    --  Sorts characters of argument using N*logN sort
5492    pragma Postcondition
5493      (Float (Clock - Clock'Old) <=
5494         Float (Arg'Length) *
5495         log (Float (Arg'Length)) *
5496         Performance);
5497 end Sort;
5498 @end smallexample
5500 @noindent
5501 Note: postcondition pragmas associated with subprograms that are
5502 marked as Inline_Always, or those marked as Inline with front-end
5503 inlining (-gnatN option set) are accepted and legality-checked
5504 by the compiler, but are ignored at run-time even if postcondition
5505 checking is enabled.
5507 Note that pragma @code{Postcondition} differs from the language-defined
5508 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5509 multiple occurrences, allowing occurences in the body even if there
5510 is a separate spec, and allowing a second string parameter, and the
5511 use of the pragma identifier @code{Check}. Historically, pragma
5512 @code{Postcondition} was implemented prior to the development of
5513 Ada 2012, and has been retained in its original form for
5514 compatibility purposes.
5516 @node Pragma Post_Class
5517 @unnumberedsec Pragma Post_Class
5518 @cindex Post
5519 @cindex Checks, postconditions
5520 @findex Postconditions
5521 @noindent
5522 Syntax:
5524 @smallexample @c ada
5525 pragma Post_Class (Boolean_Expression);
5526 @end smallexample
5528 @noindent
5529 The @code{Post_Class} pragma is intended to be an exact replacement for
5530 the language-defined
5531 @code{Post'Class} aspect, and shares its restrictions and semantics.
5532 It must appear either immediately following the corresponding
5533 subprogram declaration (only other pragmas may intervene), or
5534 if there is no separate subprogram declaration, then it can
5535 appear at the start of the declarations in a subprogram body
5536 (preceded only by other pragmas).
5538 Note: This pragma is called @code{Post_Class} rather than
5539 @code{Post'Class} because the latter would not be strictly
5540 conforming to the allowed syntax for pragmas. The motivation
5541 for provinding pragmas equivalent to the aspects is to allow a program
5542 to be written using the pragmas, and then compiled if necessary
5543 using an Ada compiler that does not recognize the pragmas or
5544 aspects, but is prepared to ignore the pragmas. The assertion
5545 policy that controls this pragma is @code{Post'Class}, not
5546 @code{Post_Class}.
5548 @node Pragma Pre
5549 @unnumberedsec Pragma Pre
5550 @cindex Pre
5551 @cindex Checks, preconditions
5552 @findex Preconditions
5553 @noindent
5554 Syntax:
5556 @smallexample @c ada
5557 pragma Pre (Boolean_Expression);
5558 @end smallexample
5560 @noindent
5561 The @code{Pre} pragma is intended to be an exact replacement for
5562 the language-defined
5563 @code{Pre} aspect, and shares its restrictions and semantics.
5564 It must appear either immediately following the corresponding
5565 subprogram declaration (only other pragmas may intervene), or
5566 if there is no separate subprogram declaration, then it can
5567 appear at the start of the declarations in a subprogram body
5568 (preceded only by other pragmas).
5570 @node Pragma Precondition
5571 @unnumberedsec Pragma Precondition
5572 @cindex Preconditions
5573 @cindex Checks, preconditions
5574 @findex Preconditions
5575 @noindent
5576 Syntax:
5578 @smallexample @c ada
5579 pragma Precondition (
5580    [Check   =>] Boolean_Expression
5581  [,[Message =>] String_Expression]);
5582 @end smallexample
5584 @noindent
5585 The @code{Precondition} pragma is similar to @code{Postcondition}
5586 except that the corresponding checks take place immediately upon
5587 entry to the subprogram, and if a precondition fails, the exception
5588 is raised in the context of the caller, and the attribute 'Result
5589 cannot be used within the precondition expression.
5591 Otherwise, the placement and visibility rules are identical to those
5592 described for postconditions. The following is an example of use
5593 within a package spec:
5595 @smallexample @c ada
5596 package Math_Functions is
5597    ...
5598    function Sqrt (Arg : Float) return Float;
5599    pragma Precondition (Arg >= 0.0)
5600    ...
5601 end Math_Functions;
5602 @end smallexample
5604 @noindent
5605 @code{Precondition} pragmas may appear either immediately following the
5606 (separate) declaration of a subprogram, or at the start of the
5607 declarations of a subprogram body. Only other pragmas may intervene
5608 (that is appear between the subprogram declaration and its
5609 postconditions, or appear before the postcondition in the
5610 declaration sequence in a subprogram body).
5612 Note: precondition pragmas associated with subprograms that are
5613 marked as Inline_Always, or those marked as Inline with front-end
5614 inlining (-gnatN option set) are accepted and legality-checked
5615 by the compiler, but are ignored at run-time even if precondition
5616 checking is enabled.
5618 Note that pragma @code{Precondition} differs from the language-defined
5619 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5620 multiple occurrences, allowing occurences in the body even if there
5621 is a separate spec, and allowing a second string parameter, and the
5622 use of the pragma identifier @code{Check}. Historically, pragma
5623 @code{Precondition} was implemented prior to the development of
5624 Ada 2012, and has been retained in its original form for
5625 compatibility purposes.
5627 @node Pragma Predicate
5628 @unnumberedsec Pragma Predicate
5629 @findex Predicate
5630 @findex Predicate pragma
5631 @noindent
5632 Syntax:
5634 @smallexample @c ada
5635 pragma Predicate
5636   ([Entity =>] type_LOCAL_NAME,
5637    [Check  =>] EXPRESSION);
5638 @end smallexample
5640 @noindent
5641 This pragma (available in all versions of Ada in GNAT) encompasses both
5642 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5643 Ada 2012. A predicate is regarded as static if it has an allowed form
5644 for @code{Static_Predicate} and is otherwise treated as a
5645 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5646 pragma behave exactly as described in the Ada 2012 reference manual.
5647 For example, if we have
5649 @smallexample @c ada
5650 type R is range 1 .. 10;
5651 subtype S is R;
5652 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5653 subtype Q is R
5654 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5655 @end smallexample
5657 @noindent
5658 the effect is identical to the following Ada 2012 code:
5660 @smallexample @c ada
5661 type R is range 1 .. 10;
5662 subtype S is R with
5663   Static_Predicate => S not in 4 .. 6;
5664 subtype Q is R with
5665   Dynamic_Predicate => F(Q) or G(Q);
5666 @end smallexample
5668 Note that there is are no pragmas @code{Dynamic_Predicate}
5669 or @code{Static_Predicate}. That is
5670 because these pragmas would affect legality and semantics of
5671 the program and thus do not have a neutral effect if ignored.
5672 The motivation behind providing pragmas equivalent to
5673 corresponding aspects is to allow a program to be written
5674 using the pragmas, and then compiled with a compiler that
5675 will ignore the pragmas. That doesn't work in the case of
5676 static and dynamic predicates, since if the corresponding
5677 pragmas are ignored, then the behavior of the program is
5678 fundamentally changed (for example a membership test
5679 @code{A in B} would not take into account a predicate
5680 defined for subtype B). When following this approach, the
5681 use of predicates should be avoided.
5683 @node Pragma Preelaborable_Initialization
5684 @unnumberedsec Pragma Preelaborable_Initialization
5685 @findex Preelaborable_Initialization
5686 @noindent
5687 Syntax:
5689 @smallexample @c ada
5690 pragma Preelaborable_Initialization (DIRECT_NAME);
5691 @end smallexample
5693 @noindent
5694 This pragma is standard in Ada 2005, but is available in all earlier
5695 versions of Ada as an implementation-defined pragma.
5696 See Ada 2012 Reference Manual for details.
5698 @node Pragma Prefix_Exception_Messages
5699 @unnumberedsec Pragma Prefix_Exception_Messages
5700 @cindex Prefix_Exception_Messages
5701 @cindex exception
5702 @cindex Exception_Message
5703 @findex Exceptions
5704 @noindent
5705 Syntax:
5707 @smallexample @c ada
5708 pragma Prefix_Exception_Messages;
5709 @end smallexample
5711 @noindent
5712 This is an implementation-defined configuration pragma that affects the
5713 behavior of raise statements with a message given as a static string
5714 constant (typically a string literal). In such cases, the string will
5715 be automatically prefixed by the name of the enclosing entity (giving
5716 the package and subprogram containing the raise statement). This helps
5717 to identify where messages are coming from, and this mode is automatic
5718 for the run-time library.
5720 The pragma has no effect if the message is computed with an expression other
5721 than a static string constant, since the assumption in this case is that
5722 the program computes exactly the string it wants. If you still want the
5723 prefixing in this case, you can always call
5724 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
5726 @node Pragma Pre_Class
5727 @unnumberedsec Pragma Pre_Class
5728 @cindex Pre_Class
5729 @cindex Checks, preconditions
5730 @findex Preconditions
5731 @noindent
5732 Syntax:
5734 @smallexample @c ada
5735 pragma Pre_Class (Boolean_Expression);
5736 @end smallexample
5738 @noindent
5739 The @code{Pre_Class} pragma is intended to be an exact replacement for
5740 the language-defined
5741 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5742 It must appear either immediately following the corresponding
5743 subprogram declaration (only other pragmas may intervene), or
5744 if there is no separate subprogram declaration, then it can
5745 appear at the start of the declarations in a subprogram body
5746 (preceded only by other pragmas).
5748 Note: This pragma is called @code{Pre_Class} rather than
5749 @code{Pre'Class} because the latter would not be strictly
5750 conforming to the allowed syntax for pragmas. The motivation
5751 for providing pragmas equivalent to the aspects is to allow a program
5752 to be written using the pragmas, and then compiled if necessary
5753 using an Ada compiler that does not recognize the pragmas or
5754 aspects, but is prepared to ignore the pragmas. The assertion
5755 policy that controls this pragma is @code{Pre'Class}, not
5756 @code{Pre_Class}.
5758 @node Pragma Priority_Specific_Dispatching
5759 @unnumberedsec Pragma Priority_Specific_Dispatching
5760 @findex Priority_Specific_Dispatching
5761 @noindent
5762 Syntax:
5764 @smallexample @c ada
5765 pragma Priority_Specific_Dispatching (
5766    POLICY_IDENTIFIER,
5767    first_priority_EXPRESSION,
5768    last_priority_EXPRESSION)
5770 POLICY_IDENTIFIER ::=
5771    EDF_Across_Priorities            |
5772    FIFO_Within_Priorities           |
5773    Non_Preemptive_Within_Priorities |
5774    Round_Robin_Within_Priorities
5775 @end smallexample
5777 @noindent
5778 This pragma is standard in Ada 2005, but is available in all earlier
5779 versions of Ada as an implementation-defined pragma.
5780 See Ada 2012 Reference Manual for details.
5782 @node Pragma Profile
5783 @unnumberedsec Pragma Profile
5784 @findex Profile
5785 @noindent
5786 Syntax:
5788 @smallexample @c ada
5789 pragma Profile (Ravenscar | Restricted | Rational);
5790 @end smallexample
5792 @noindent
5793 This pragma is standard in Ada 2005, but is available in all earlier
5794 versions of Ada as an implementation-defined pragma. This is a
5795 configuration pragma that establishes a set of configiuration pragmas
5796 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5797 The other two possibilities (@code{Restricted} or @code{Rational})
5798 are implementation-defined. The set of configuration pragmas
5799 is defined in the following sections.
5801 @itemize
5803 @item Pragma Profile (Ravenscar)
5804 @findex Ravenscar
5805 @noindent
5807 The @code{Ravenscar} profile is standard in Ada 2005,
5808 but is available in all earlier
5809 versions of Ada as an implementation-defined pragma. This profile
5810 establishes the following set of configuration pragmas:
5812 @table @code
5813 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5814 [RM D.2.2] Tasks are dispatched following a preemptive
5815 priority-ordered scheduling policy.
5817 @item Locking_Policy (Ceiling_Locking)
5818 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5819 the ceiling priority of the corresponding protected object.
5821 @item Detect_Blocking
5822 This pragma forces the detection of potentially blocking operations within a
5823 protected operation, and to raise Program_Error if that happens.
5824 @end table
5825 @noindent
5827 plus the following set of restrictions:
5829 @table @code
5830 @item Max_Entry_Queue_Length => 1
5831 No task can be queued on a protected entry.
5832 @item Max_Protected_Entries => 1
5833 @item Max_Task_Entries => 0
5834 No rendezvous statements are allowed.
5835 @item No_Abort_Statements
5836 @item No_Dynamic_Attachment
5837 @item No_Dynamic_Priorities
5838 @item No_Implicit_Heap_Allocations
5839 @item No_Local_Protected_Objects
5840 @item No_Local_Timing_Events
5841 @item No_Protected_Type_Allocators
5842 @item No_Relative_Delay
5843 @item No_Requeue_Statements
5844 @item No_Select_Statements
5845 @item No_Specific_Termination_Handlers
5846 @item No_Task_Allocators
5847 @item No_Task_Hierarchy
5848 @item No_Task_Termination
5849 @item Simple_Barriers
5850 @end table
5851 @noindent
5853 The Ravenscar profile also includes the following restrictions that specify
5854 that there are no semantic dependences on the corresponding predefined
5855 packages:
5857 @table @code
5858 @item No_Dependence => Ada.Asynchronous_Task_Control
5859 @item No_Dependence => Ada.Calendar
5860 @item No_Dependence => Ada.Execution_Time.Group_Budget
5861 @item No_Dependence => Ada.Execution_Time.Timers
5862 @item No_Dependence => Ada.Task_Attributes
5863 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5864 @end table
5866 @noindent
5868 This set of configuration pragmas and restrictions correspond to the
5869 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5870 published by the @cite{International Real-Time Ada Workshop}, 1997,
5871 and whose most recent description is available at
5872 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5874 The original definition of the profile was revised at subsequent IRTAW
5875 meetings. It has been included in the ISO
5876 @cite{Guide for the Use of the Ada Programming Language in High
5877 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5878 the next revision of the standard. The formal definition given by
5879 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5880 AI-305) available at
5881 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5882 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5884 The above set is a superset of the restrictions provided by pragma
5885 @code{Profile (Restricted)}, it includes six additional restrictions
5886 (@code{Simple_Barriers}, @code{No_Select_Statements},
5887 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5888 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
5889 that pragma @code{Profile (Ravenscar)}, like the pragma
5890 @code{Profile (Restricted)},
5891 automatically causes the use of a simplified,
5892 more efficient version of the tasking run-time system.
5894 @item Pragma Profile (Restricted)
5895 @findex Restricted Run Time
5896 @noindent
5897 This profile corresponds to the GNAT restricted run time. It
5898 establishes the following set of restrictions:
5900 @itemize @bullet
5901 @item No_Abort_Statements
5902 @item No_Entry_Queue
5903 @item No_Task_Hierarchy
5904 @item No_Task_Allocators
5905 @item No_Dynamic_Priorities
5906 @item No_Terminate_Alternatives
5907 @item No_Dynamic_Attachment
5908 @item No_Protected_Type_Allocators
5909 @item No_Local_Protected_Objects
5910 @item No_Requeue_Statements
5911 @item No_Task_Attributes_Package
5912 @item Max_Asynchronous_Select_Nesting =  0
5913 @item Max_Task_Entries =  0
5914 @item Max_Protected_Entries = 1
5915 @item Max_Select_Alternatives = 0
5916 @end itemize
5918 @noindent
5919 This set of restrictions causes the automatic selection of a simplified
5920 version of the run time that provides improved performance for the
5921 limited set of tasking functionality permitted by this set of restrictions.
5923 @item Pragma Profile (Rational)
5924 @findex Rational compatibility mode
5925 @noindent
5926 The Rational profile is intended to facilitate porting legacy code that
5927 compiles with the Rational APEX compiler, even when the code includes non-
5928 conforming Ada constructs.  The profile enables the following three pragmas:
5930 @itemize @bullet
5931 @item pragma Implicit_Packing
5932 @item pragma Overriding_Renamings
5933 @item pragma Use_VADS_Size
5934 @end itemize
5936 @end itemize
5938 @node Pragma Profile_Warnings
5939 @unnumberedsec Pragma Profile_Warnings
5940 @findex Profile_Warnings
5941 @noindent
5942 Syntax:
5944 @smallexample @c ada
5945 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5946 @end smallexample
5948 @noindent
5949 This is an implementation-defined pragma that is similar in
5950 effect to @code{pragma Profile} except that instead of
5951 generating @code{Restrictions} pragmas, it generates
5952 @code{Restriction_Warnings} pragmas. The result is that
5953 violations of the profile generate warning messages instead
5954 of error messages.
5956 @node Pragma Propagate_Exceptions
5957 @unnumberedsec Pragma Propagate_Exceptions
5958 @cindex Interfacing to C++
5959 @findex Propagate_Exceptions
5960 @noindent
5961 Syntax:
5963 @smallexample @c ada
5964 pragma Propagate_Exceptions;
5965 @end smallexample
5967 @noindent
5968 This pragma is now obsolete and, other than generating a warning if warnings
5969 on obsolescent features are enabled, is ignored.
5970 It is retained for compatibility
5971 purposes. It used to be used in connection with optimization of
5972 a now-obsolete mechanism for implementation of exceptions.
5974 @node Pragma Provide_Shift_Operators
5975 @unnumberedsec Pragma Provide_Shift_Operators
5976 @cindex Shift operators
5977 @findex Provide_Shift_Operators
5978 @noindent
5979 Syntax:
5981 @smallexample @c ada
5982 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5983 @end smallexample
5985 @noindent
5986 This pragma can be applied to a first subtype local name that specifies
5987 either an unsigned or signed type. It has the effect of providing the
5988 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5989 Rotate_Left and Rotate_Right) for the given type. It is similar to
5990 including the function declarations for these five operators, together
5991 with the pragma Import (Intrinsic, ...) statements.
5993 @node Pragma Psect_Object
5994 @unnumberedsec Pragma Psect_Object
5995 @findex Psect_Object
5996 @noindent
5997 Syntax:
5999 @smallexample @c ada
6000 pragma Psect_Object (
6001      [Internal =>] LOCAL_NAME,
6002   [, [External =>] EXTERNAL_SYMBOL]
6003   [, [Size     =>] EXTERNAL_SYMBOL]);
6005 EXTERNAL_SYMBOL ::=
6006   IDENTIFIER
6007 | static_string_EXPRESSION
6008 @end smallexample
6010 @noindent
6011 This pragma is identical in effect to pragma @code{Common_Object}.
6013 @node Pragma Pure_Function
6014 @unnumberedsec Pragma Pure_Function
6015 @findex Pure_Function
6016 @noindent
6017 Syntax:
6019 @smallexample @c ada
6020 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6021 @end smallexample
6023 @noindent
6024 This pragma appears in the same declarative part as a function
6025 declaration (or a set of function declarations if more than one
6026 overloaded declaration exists, in which case the pragma applies
6027 to all entities).  It specifies that the function @code{Entity} is
6028 to be considered pure for the purposes of code generation.  This means
6029 that the compiler can assume that there are no side effects, and
6030 in particular that two calls with identical arguments produce the
6031 same result.  It also means that the function can be used in an
6032 address clause.
6034 Note that, quite deliberately, there are no static checks to try
6035 to ensure that this promise is met, so @code{Pure_Function} can be used
6036 with functions that are conceptually pure, even if they do modify
6037 global variables.  For example, a square root function that is
6038 instrumented to count the number of times it is called is still
6039 conceptually pure, and can still be optimized, even though it
6040 modifies a global variable (the count).  Memo functions are another
6041 example (where a table of previous calls is kept and consulted to
6042 avoid re-computation).
6044 Note also that the normal rules excluding optimization of subprograms
6045 in pure units (when parameter types are descended from System.Address,
6046 or when the full view of a parameter type is limited), do not apply
6047 for the Pure_Function case. If you explicitly specify Pure_Function,
6048 the compiler may optimize away calls with identical arguments, and
6049 if that results in unexpected behavior, the proper action is not to
6050 use the pragma for subprograms that are not (conceptually) pure.
6052 @findex Pure
6053 Note: Most functions in a @code{Pure} package are automatically pure, and
6054 there is no need to use pragma @code{Pure_Function} for such functions.  One
6055 exception is any function that has at least one formal of type
6056 @code{System.Address} or a type derived from it.  Such functions are not
6057 considered pure by default, since the compiler assumes that the
6058 @code{Address} parameter may be functioning as a pointer and that the
6059 referenced data may change even if the address value does not.
6060 Similarly, imported functions are not considered to be pure by default,
6061 since there is no way of checking that they are in fact pure.  The use
6062 of pragma @code{Pure_Function} for such a function will override these default
6063 assumption, and cause the compiler to treat a designated subprogram as pure
6064 in these cases.
6066 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6067 applies to the underlying renamed function.  This can be used to
6068 disambiguate cases of overloading where some but not all functions
6069 in a set of overloaded functions are to be designated as pure.
6071 If pragma @code{Pure_Function} is applied to a library level function, the
6072 function is also considered pure from an optimization point of view, but the
6073 unit is not a Pure unit in the categorization sense. So for example, a function
6074 thus marked is free to @code{with} non-pure units.
6076 @node Pragma Rational
6077 @unnumberedsec Pragma Rational
6078 @findex Rational
6079 @noindent
6080 Syntax:
6082 @smallexample @c ada
6083 pragma Rational;
6084 @end smallexample
6086 @noindent
6087 This pragma is considered obsolescent, but is retained for
6088 compatibility purposes. It is equivalent to:
6090 @smallexample @c ada
6091 pragma Profile (Rational);
6092 @end smallexample
6094 @node Pragma Ravenscar
6095 @unnumberedsec Pragma Ravenscar
6096 @findex Pragma Ravenscar
6097 @noindent
6098 Syntax:
6100 @smallexample @c ada
6101 pragma Ravenscar;
6102 @end smallexample
6104 @noindent
6105 This pragma is considered obsolescent, but is retained for
6106 compatibility purposes. It is equivalent to:
6108 @smallexample @c ada
6109 pragma Profile (Ravenscar);
6110 @end smallexample
6112 @noindent
6113 which is the preferred method of setting the @code{Ravenscar} profile.
6115 @node Pragma Refined_Depends
6116 @unnumberedsec Pragma Refined_Depends
6117 @findex Refined_Depends
6118 @noindent
6119 For the description of this pragma, see SPARK 2014 Reference Manual,
6120 section 6.1.5.
6122 @node Pragma Refined_Global
6123 @unnumberedsec Pragma Refined_Global
6124 @findex Refined_Global
6125 @noindent
6126 For the description of this pragma, see SPARK 2014 Reference Manual,
6127 section 6.1.4.
6129 @node Pragma Refined_Post
6130 @unnumberedsec Pragma Refined_Post
6131 @findex Refined_Post
6132 @noindent
6133 For the description of this pragma, see SPARK 2014 Reference Manual,
6134 section 7.2.7.
6136 @node Pragma Refined_State
6137 @unnumberedsec Pragma Refined_State
6138 @findex Refined_State
6139 @noindent
6140 For the description of this pragma, see SPARK 2014 Reference Manual,
6141 section 7.2.2.
6143 @node Pragma Relative_Deadline
6144 @unnumberedsec Pragma Relative_Deadline
6145 @findex Relative_Deadline
6146 @noindent
6147 Syntax:
6149 @smallexample @c ada
6150 pragma Relative_Deadline (time_span_EXPRESSION);
6151 @end smallexample
6153 @noindent
6154 This pragma is standard in Ada 2005, but is available in all earlier
6155 versions of Ada as an implementation-defined pragma.
6156 See Ada 2012 Reference Manual for details.
6158 @node Pragma Remote_Access_Type
6159 @unnumberedsec Pragma Remote_Access_Type
6160 @findex Remote_Access_Type
6161 @noindent
6162 Syntax:
6164 @smallexample @c ada
6165 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6166 @end smallexample
6168 @noindent
6169 This pragma appears in the formal part of a generic declaration.
6170 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6171 the use of a remote access to class-wide type as actual for a formal
6172 access type.
6174 When this pragma applies to a formal access type @code{Entity}, that
6175 type is treated as a remote access to class-wide type in the generic.
6176 It must be a formal general access type, and its designated type must
6177 be the class-wide type of a formal tagged limited private type from the
6178 same generic declaration.
6180 In the generic unit, the formal type is subject to all restrictions
6181 pertaining to remote access to class-wide types. At instantiation, the
6182 actual type must be a remote access to class-wide type.
6184 @node Pragma Restricted_Run_Time
6185 @unnumberedsec Pragma Restricted_Run_Time
6186 @findex Pragma Restricted_Run_Time
6187 @noindent
6188 Syntax:
6190 @smallexample @c ada
6191 pragma Restricted_Run_Time;
6192 @end smallexample
6194 @noindent
6195 This pragma is considered obsolescent, but is retained for
6196 compatibility purposes. It is equivalent to:
6198 @smallexample @c ada
6199 pragma Profile (Restricted);
6200 @end smallexample
6202 @noindent
6203 which is the preferred method of setting the restricted run time
6204 profile.
6206 @node Pragma Restriction_Warnings
6207 @unnumberedsec Pragma Restriction_Warnings
6208 @findex Restriction_Warnings
6209 @noindent
6210 Syntax:
6212 @smallexample @c ada
6213 pragma Restriction_Warnings
6214   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6215 @end smallexample
6217 @noindent
6218 This pragma allows a series of restriction identifiers to be
6219 specified (the list of allowed identifiers is the same as for
6220 pragma @code{Restrictions}). For each of these identifiers
6221 the compiler checks for violations of the restriction, but
6222 generates a warning message rather than an error message
6223 if the restriction is violated.
6225 One use of this is in situations where you want to know
6226 about violations of a restriction, but you want to ignore some of
6227 these violations. Consider this example, where you want to set
6228 Ada_95 mode and enable style checks, but you want to know about
6229 any other use of implementation pragmas:
6231 @smallexample @c ada
6232 pragma Restriction_Warnings (No_Implementation_Pragmas);
6233 7 (Off, "violation of*No_Implementation_Pragmas*");
6234 pragma Ada_95;
6235 pragma Style_Checks ("2bfhkM160");
6236 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6237 @end smallexample
6239 @noindent
6240 By including the above lines in a configuration pragmas file,
6241 the Ada_95 and Style_Checks pragmas are accepted without
6242 generating a warning, but any other use of implementation
6243 defined pragmas will cause a warning to be generated.
6245 @node Pragma Reviewable
6246 @unnumberedsec Pragma Reviewable
6247 @findex Reviewable
6248 @noindent
6249 Syntax:
6251 @smallexample @c ada
6252 pragma Reviewable;
6253 @end smallexample
6255 @noindent
6256 This pragma is an RM-defined standard pragma, but has no effect on the
6257 program being compiled, or on the code generated for the program.
6259 To obtain the required output specified in RM H.3.1, the compiler must be
6260 run with various special switches as follows:
6262 @table @i
6264 @item Where compiler-generated run-time checks remain
6266 The switch @option{-gnatGL}
6267 @findex @option{-gnatGL}
6268 may be used to list the expanded code in pseudo-Ada form.
6269 Runtime checks show up in the listing either as explicit
6270 checks or operators marked with @{@} to indicate a check is present.
6272 @item An identification of known exceptions at compile time
6274 If the program is compiled with @option{-gnatwa},
6275 @findex @option{-gnatwa}
6276 the compiler warning messages will indicate all cases where the compiler
6277 detects that an exception is certain to occur at run time.
6279 @item Possible reads of uninitialized variables
6281 The compiler warns of many such cases, but its output is incomplete.
6282 @ifclear FSFEDITION
6283 The CodePeer analysis tool
6284 @findex CodePeer static analysis tool
6285 @end ifclear
6286 @ifset FSFEDITION
6287 A supplemental static analysis tool
6288 @end ifset
6289 may be used to obtain a comprehensive list of all
6290 possible points at which uninitialized data may be read.
6292 @item Where run-time support routines are implicitly invoked
6294 In the output from @option{-gnatGL},
6295 @findex @option{-gnatGL}
6296 run-time calls are explicitly listed as calls to the relevant
6297 run-time routine.
6299 @item Object code listing
6301 This may be obtained either by using the @option{-S} switch,
6302 @findex @option{-S}
6303 or the objdump utility.
6304 @findex objdump
6306 @item Constructs known to be erroneous at compile time
6308 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6309 @findex @option{-gnatwa}
6311 @item Stack usage information
6313 Static stack usage data (maximum per-subprogram) can be obtained via the
6314 @option{-fstack-usage} switch to the compiler.
6315 @findex @option{-fstack-usage}
6316 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6317 to gnatbind
6318 @findex @option{-u}
6319 @ifclear FSFEDITION
6320 The gnatstack utility
6321 @findex gnatstack
6322 can be used to provide additional information on stack usage.
6323 @end ifclear
6325 @item Object code listing of entire partition
6327 This can be obtained by compiling the partition with @option{-S},
6328 @findex @option{-S}
6329 or by applying objdump
6330 @findex objdump
6331 to all the object files that are part of the partition.
6333 @item A description of the run-time model
6335 The full sources of the run-time are available, and the documentation of
6336 these routines describes how these run-time routines interface to the
6337 underlying operating system facilities.
6339 @item Control and data-flow information
6341 @ifclear FSFEDITION
6342 The CodePeer tool
6343 @findex CodePeer static analysis tool
6344 @end ifclear
6345 @ifset FSFEDITION
6346 A supplemental static analysis tool
6347 @end ifset
6348 may be used to obtain complete control and data-flow information, as well as
6349 comprehensive messages identifying possible problems based on this
6350 information.
6351 @end table
6353 @node Pragma Share_Generic
6354 @unnumberedsec Pragma Share_Generic
6355 @findex Share_Generic
6356 @noindent
6357 Syntax:
6359 @smallexample @c ada
6360 pragma Share_Generic (GNAME @{, GNAME@});
6362 GNAME ::= generic_unit_NAME | generic_instance_NAME
6363 @end smallexample
6365 @noindent
6366 This pragma is provided for compatibility with Dec Ada 83. It has
6367 no effect in @code{GNAT} (which does not implement shared generics), other
6368 than to check that the given names are all names of generic units or
6369 generic instances.
6371 @node Pragma Shared
6372 @unnumberedsec Pragma Shared
6373 @findex Shared
6375 @noindent
6376 This pragma is provided for compatibility with Ada 83. The syntax and
6377 semantics are identical to pragma Atomic.
6379 @node Pragma Short_Circuit_And_Or
6380 @unnumberedsec Pragma Short_Circuit_And_Or
6381 @findex Short_Circuit_And_Or
6382 @noindent
6383 Syntax:
6385 @smallexample @c ada
6386 pragma Short_Circuit_And_Or;
6387 @end smallexample
6389 @noindent
6390 This configuration pragma causes any occurrence of the AND operator applied to
6391 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6392 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6393 may be useful in the context of certification protocols requiring the use of
6394 short-circuited logical operators. If this configuration pragma occurs locally
6395 within the file being compiled, it applies only to the file being compiled.
6396 There is no requirement that all units in a partition use this option.
6398 @node Pragma Short_Descriptors
6399 @unnumberedsec Pragma Short_Descriptors
6400 @findex Short_Descriptors
6401 @noindent
6402 Syntax:
6404 @smallexample @c ada
6405 pragma Short_Descriptors
6406 @end smallexample
6408 @noindent
6409 This pragma is provided for compatibility with other Ada implementations. It
6410 is recognized but ignored by all current versions of GNAT.
6412 @node Pragma Simple_Storage_Pool_Type
6413 @unnumberedsec Pragma Simple_Storage_Pool_Type
6414 @findex Simple_Storage_Pool_Type
6415 @cindex Storage pool, simple
6416 @cindex Simple storage pool
6417 @noindent
6418 Syntax:
6420 @smallexample @c ada
6421 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6422 @end smallexample
6424 @noindent
6425 A type can be established as a ``simple storage pool type'' by applying
6426 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6427 A type named in the pragma must be a library-level immutably limited record
6428 type or limited tagged type declared immediately within a package declaration.
6429 The type can also be a limited private type whose full type is allowed as
6430 a simple storage pool type.
6432 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6433 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6434 are subtype conformant with the following subprogram declarations:
6436 @smallexample @c ada
6437 procedure Allocate
6438   (Pool                     : in out SSP;
6439    Storage_Address          : out System.Address;
6440    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6441    Alignment                : System.Storage_Elements.Storage_Count);
6443 procedure Deallocate
6444   (Pool : in out SSP;
6445    Storage_Address          : System.Address;
6446    Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6447    Alignment                : System.Storage_Elements.Storage_Count);
6449 function Storage_Size (Pool : SSP)
6450   return System.Storage_Elements.Storage_Count;
6451 @end smallexample
6453 @noindent
6454 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6455 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6456 applying an unchecked deallocation has no effect other than to set its actual
6457 parameter to null. If @code{Storage_Size} is not declared, then the
6458 @code{Storage_Size} attribute applied to an access type associated with
6459 a pool object of type SSP returns zero. Additional operations can be declared
6460 for a simple storage pool type (such as for supporting a mark/release
6461 storage-management discipline).
6463 An object of a simple storage pool type can be associated with an access
6464 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6466 @smallexample @c ada
6468 My_Pool : My_Simple_Storage_Pool_Type;
6470 type Acc is access My_Data_Type;
6472 for Acc'Simple_Storage_Pool use My_Pool;
6474 @end smallexample
6476 @noindent
6477 See attribute @code{Simple_Storage_Pool} for further details.
6479 @node Pragma Source_File_Name
6480 @unnumberedsec Pragma Source_File_Name
6481 @findex Source_File_Name
6482 @noindent
6483 Syntax:
6485 @smallexample @c ada
6486 pragma Source_File_Name (
6487   [Unit_Name   =>] unit_NAME,
6488   Spec_File_Name =>  STRING_LITERAL,
6489   [Index => INTEGER_LITERAL]);
6491 pragma Source_File_Name (
6492   [Unit_Name   =>] unit_NAME,
6493   Body_File_Name =>  STRING_LITERAL,
6494   [Index => INTEGER_LITERAL]);
6495 @end smallexample
6497 @noindent
6498 Use this to override the normal naming convention.  It is a configuration
6499 pragma, and so has the usual applicability of configuration pragmas
6500 (i.e.@: it applies to either an entire partition, or to all units in a
6501 compilation, or to a single unit, depending on how it is used.
6502 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
6503 the second argument is required, and indicates whether this is the file
6504 name for the spec or for the body.
6506 The optional Index argument should be used when a file contains multiple
6507 units, and when you do not want to use @code{gnatchop} to separate then
6508 into multiple files (which is the recommended procedure to limit the
6509 number of recompilations that are needed when some sources change).
6510 For instance, if the source file @file{source.ada} contains
6512 @smallexample @c ada
6513 package B is
6515 end B;
6517 with B;
6518 procedure A is
6519 begin
6520    ..
6521 end A;
6522 @end smallexample
6524 you could use the following configuration pragmas:
6526 @smallexample @c ada
6527 pragma Source_File_Name
6528   (B, Spec_File_Name => "source.ada", Index => 1);
6529 pragma Source_File_Name
6530   (A, Body_File_Name => "source.ada", Index => 2);
6531 @end smallexample
6533 Note that the @code{gnatname} utility can also be used to generate those
6534 configuration pragmas.
6536 Another form of the @code{Source_File_Name} pragma allows
6537 the specification of patterns defining alternative file naming schemes
6538 to apply to all files.
6540 @smallexample @c ada
6541 pragma Source_File_Name
6542   (  [Spec_File_Name  =>] STRING_LITERAL
6543    [,[Casing          =>] CASING_SPEC]
6544    [,[Dot_Replacement =>] STRING_LITERAL]);
6546 pragma Source_File_Name
6547   (  [Body_File_Name  =>] STRING_LITERAL
6548    [,[Casing          =>] CASING_SPEC]
6549    [,[Dot_Replacement =>] STRING_LITERAL]);
6551 pragma Source_File_Name
6552   (  [Subunit_File_Name =>] STRING_LITERAL
6553    [,[Casing            =>] CASING_SPEC]
6554    [,[Dot_Replacement   =>] STRING_LITERAL]);
6556 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6557 @end smallexample
6559 @noindent
6560 The first argument is a pattern that contains a single asterisk indicating
6561 the point at which the unit name is to be inserted in the pattern string
6562 to form the file name.  The second argument is optional.  If present it
6563 specifies the casing of the unit name in the resulting file name string.
6564 The default is lower case.  Finally the third argument allows for systematic
6565 replacement of any dots in the unit name by the specified string literal.
6567 Note that Source_File_Name pragmas should not be used if you are using
6568 project files. The reason for this rule is that the project manager is not
6569 aware of these pragmas, and so other tools that use the projet file would not
6570 be aware of the intended naming conventions. If you are using project files,
6571 file naming is controlled by Source_File_Name_Project pragmas, which are
6572 usually supplied automatically by the project manager. A pragma
6573 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6575 For more details on the use of the @code{Source_File_Name} pragma,
6576 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6577 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6578 User's Guide}.
6580 @node Pragma Source_File_Name_Project
6581 @unnumberedsec Pragma Source_File_Name_Project
6582 @findex Source_File_Name_Project
6583 @noindent
6585 This pragma has the same syntax and semantics as pragma Source_File_Name.
6586 It is only allowed as a stand alone configuration pragma.
6587 It cannot appear after a @ref{Pragma Source_File_Name}, and
6588 most importantly, once pragma Source_File_Name_Project appears,
6589 no further Source_File_Name pragmas are allowed.
6591 The intention is that Source_File_Name_Project pragmas are always
6592 generated by the Project Manager in a manner consistent with the naming
6593 specified in a project file, and when naming is controlled in this manner,
6594 it is not permissible to attempt to modify this naming scheme using
6595 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6596 known to the project manager).
6598 @node Pragma Source_Reference
6599 @unnumberedsec Pragma Source_Reference
6600 @findex Source_Reference
6601 @noindent
6602 Syntax:
6604 @smallexample @c ada
6605 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6606 @end smallexample
6608 @noindent
6609 This pragma must appear as the first line of a source file.
6610 @var{integer_literal} is the logical line number of the line following
6611 the pragma line (for use in error messages and debugging
6612 information).  @var{string_literal} is a static string constant that
6613 specifies the file name to be used in error messages and debugging
6614 information.  This is most notably used for the output of @code{gnatchop}
6615 with the @option{-r} switch, to make sure that the original unchopped
6616 source file is the one referred to.
6618 The second argument must be a string literal, it cannot be a static
6619 string expression other than a string literal.  This is because its value
6620 is needed for error messages issued by all phases of the compiler.
6622 @node Pragma SPARK_Mode
6623 @unnumberedsec Pragma SPARK_Mode
6624 @findex SPARK_Mode
6625 @noindent
6626 Syntax:
6628 @smallexample @c ada
6629 pragma SPARK_Mode [(On | Off)] ;
6630 @end smallexample
6632 @noindent
6633 In general a program can have some parts that are in SPARK 2014 (and
6634 follow all the rules in the SPARK Reference Manual), and some parts
6635 that are full Ada 2012.
6637 The SPARK_Mode pragma is used to identify which parts are in SPARK
6638 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6639 be used in the following places:
6641 @itemize @bullet
6643 @item
6644 As a configuration pragma, in which case it sets the default mode for
6645 all units compiled with this pragma.
6647 @item
6648 Immediately following a library-level subprogram spec
6650 @item
6651 Immediately within a library-level package body
6653 @item
6654 Immediately following the @code{private} keyword of a library-level
6655 package spec
6657 @item
6658 Immediately following the @code{begin} keyword of a library-level
6659 package body
6661 @item
6662 Immediately within a library-level subprogram body
6664 @end itemize
6666 @noindent
6667 Normally a subprogram or package spec/body inherits the current mode
6668 that is active at the point it is declared. But this can be overridden
6669 by pragma within the spec or body as above.
6671 The basic consistency rule is that you can't turn SPARK_Mode back
6672 @code{On}, once you have explicitly (with a pragma) turned if
6673 @code{Off}. So the following rules apply:
6675 @noindent
6676 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6677 also have SPARK_Mode @code{Off}.
6679 @noindent
6680 For a package, we have four parts:
6682 @itemize
6683 @item
6684 the package public declarations
6685 @item
6686 the package private part
6687 @item
6688 the body of the package
6689 @item
6690 the elaboration code after @code{begin}
6691 @end itemize
6693 @noindent
6694 For a package, the rule is that if you explicitly turn SPARK_Mode
6695 @code{Off} for any part, then all the following parts must have
6696 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6697 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6698 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6699 default everywhere, and one particular package spec has pragma
6700 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6701 the package body.
6703 @node Pragma Static_Elaboration_Desired
6704 @unnumberedsec Pragma Static_Elaboration_Desired
6705 @findex Static_Elaboration_Desired
6706 @noindent
6707 Syntax:
6709 @smallexample @c ada
6710 pragma Static_Elaboration_Desired;
6711 @end smallexample
6713 @noindent
6714 This pragma is used to indicate that the compiler should attempt to initialize
6715 statically the objects declared in the library unit to which the pragma applies,
6716 when these objects are initialized (explicitly or implicitly) by an aggregate.
6717 In the absence of this pragma, aggregates in object declarations are expanded
6718 into assignments and loops, even when the aggregate components are static
6719 constants. When the aggregate is present the compiler builds a static expression
6720 that requires no run-time code, so that the initialized object can be placed in
6721 read-only data space. If the components are not static, or the aggregate has
6722 more that 100 components, the compiler emits a warning that the pragma cannot
6723 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6724 construction of larger aggregates with static components that include an others
6725 choice.)
6727 @node Pragma Stream_Convert
6728 @unnumberedsec Pragma Stream_Convert
6729 @findex Stream_Convert
6730 @noindent
6731 Syntax:
6733 @smallexample @c ada
6734 pragma Stream_Convert (
6735   [Entity =>] type_LOCAL_NAME,
6736   [Read   =>] function_NAME,
6737   [Write  =>] function_NAME);
6738 @end smallexample
6740 @noindent
6741 This pragma provides an efficient way of providing user-defined stream
6742 attributes.  Not only is it simpler to use than specifying the attributes
6743 directly, but more importantly, it allows the specification to be made in such
6744 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6745 needed (i.e. unless the stream attributes are actually used); the use of
6746 the Stream_Convert pragma adds no overhead at all, unless the stream
6747 attributes are actually used on the designated type.
6749 The first argument specifies the type for which stream functions are
6750 provided.  The second parameter provides a function used to read values
6751 of this type.  It must name a function whose argument type may be any
6752 subtype, and whose returned type must be the type given as the first
6753 argument to the pragma.
6755 The meaning of the @var{Read} parameter is that if a stream attribute directly
6756 or indirectly specifies reading of the type given as the first parameter,
6757 then a value of the type given as the argument to the Read function is
6758 read from the stream, and then the Read function is used to convert this
6759 to the required target type.
6761 Similarly the @var{Write} parameter specifies how to treat write attributes
6762 that directly or indirectly apply to the type given as the first parameter.
6763 It must have an input parameter of the type specified by the first parameter,
6764 and the return type must be the same as the input type of the Read function.
6765 The effect is to first call the Write function to convert to the given stream
6766 type, and then write the result type to the stream.
6768 The Read and Write functions must not be overloaded subprograms.  If necessary
6769 renamings can be supplied to meet this requirement.
6770 The usage of this attribute is best illustrated by a simple example, taken
6771 from the GNAT implementation of package Ada.Strings.Unbounded:
6773 @smallexample @c ada
6774 function To_Unbounded (S : String)
6775            return Unbounded_String
6776   renames To_Unbounded_String;
6778 pragma Stream_Convert
6779   (Unbounded_String, To_Unbounded, To_String);
6780 @end smallexample
6782 @noindent
6783 The specifications of the referenced functions, as given in the Ada
6784 Reference Manual are:
6786 @smallexample @c ada
6787 function To_Unbounded_String (Source : String)
6788   return Unbounded_String;
6790 function To_String (Source : Unbounded_String)
6791   return String;
6792 @end smallexample
6794 @noindent
6795 The effect is that if the value of an unbounded string is written to a stream,
6796 then the representation of the item in the stream is in the same format that
6797 would be used for @code{Standard.String'Output}, and this same representation
6798 is expected when a value of this type is read from the stream. Note that the
6799 value written always includes the bounds, even for Unbounded_String'Write,
6800 since Unbounded_String is not an array type.
6802 Note that the @code{Stream_Convert} pragma is not effective in the case of
6803 a derived type of a non-limited tagged type. If such a type is specified then
6804 the pragma is silently ignored, and the default implementation of the stream
6805 attributes is used instead.
6807 @node Pragma Style_Checks
6808 @unnumberedsec Pragma Style_Checks
6809 @findex Style_Checks
6810 @noindent
6811 Syntax:
6813 @smallexample @c ada
6814 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6815                      On | Off [, LOCAL_NAME]);
6816 @end smallexample
6818 @noindent
6819 This pragma is used in conjunction with compiler switches to control the
6820 built in style checking provided by GNAT@.  The compiler switches, if set,
6821 provide an initial setting for the switches, and this pragma may be used
6822 to modify these settings, or the settings may be provided entirely by
6823 the use of the pragma.  This pragma can be used anywhere that a pragma
6824 is legal, including use as a configuration pragma (including use in
6825 the @file{gnat.adc} file).
6827 The form with a string literal specifies which style options are to be
6828 activated.  These are additive, so they apply in addition to any previously
6829 set style check options.  The codes for the options are the same as those
6830 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6831 For example the following two methods can be used to enable
6832 layout checking:
6834 @itemize @bullet
6835 @item
6836 @smallexample @c ada
6837 pragma Style_Checks ("l");
6838 @end smallexample
6840 @item
6841 @smallexample
6842 gcc -c -gnatyl @dots{}
6843 @end smallexample
6844 @end itemize
6846 @noindent
6847 The form ALL_CHECKS activates all standard checks (its use is equivalent
6848 to the use of the @code{gnaty} switch with no options.  @xref{Top,
6849 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6850 @value{EDITION} User's Guide}, for details.)
6852 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6853 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6854 options (i.e. equivalent to -gnatyg).
6856 The forms with @code{Off} and @code{On}
6857 can be used to temporarily disable style checks
6858 as shown in the following example:
6860 @smallexample @c ada
6861 @iftex
6862 @leftskip=0cm
6863 @end iftex
6864 pragma Style_Checks ("k"); -- requires keywords in lower case
6865 pragma Style_Checks (Off); -- turn off style checks
6866 NULL;                      -- this will not generate an error message
6867 pragma Style_Checks (On);  -- turn style checks back on
6868 NULL;                      -- this will generate an error message
6869 @end smallexample
6871 @noindent
6872 Finally the two argument form is allowed only if the first argument is
6873 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
6874 for the specified entity, as shown in the following example:
6876 @smallexample @c ada
6877 @iftex
6878 @leftskip=0cm
6879 @end iftex
6880 pragma Style_Checks ("r"); -- require consistency of identifier casing
6881 Arg : Integer;
6882 Rf1 : Integer := ARG;      -- incorrect, wrong case
6883 pragma Style_Checks (Off, Arg);
6884 Rf2 : Integer := ARG;      -- OK, no error
6885 @end smallexample
6887 @node Pragma Subtitle
6888 @unnumberedsec Pragma Subtitle
6889 @findex Subtitle
6890 @noindent
6891 Syntax:
6893 @smallexample @c ada
6894 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6895 @end smallexample
6897 @noindent
6898 This pragma is recognized for compatibility with other Ada compilers
6899 but is ignored by GNAT@.
6901 @node Pragma Suppress
6902 @unnumberedsec Pragma Suppress
6903 @findex Suppress
6904 @noindent
6905 Syntax:
6907 @smallexample @c ada
6908 pragma Suppress (Identifier [, [On =>] Name]);
6909 @end smallexample
6911 @noindent
6912 This is a standard pragma, and supports all the check names required in
6913 the RM. It is included here because GNAT recognizes some additional check
6914 names that are implementation defined (as permitted by the RM):
6916 @itemize @bullet
6918 @item
6919 @code{Alignment_Check} can be used to suppress alignment checks
6920 on addresses used in address clauses. Such checks can also be suppressed
6921 by suppressing range checks, but the specific use of @code{Alignment_Check}
6922 allows suppression of alignment checks without suppressing other range checks.
6924 @item
6925 @code{Atomic_Synchronization} can be used to suppress the special memory
6926 synchronization instructions that are normally generated for access to
6927 @code{Atomic} variables to ensure correct synchronization between tasks
6928 that use such variables for synchronization purposes.
6930 @item
6931 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6932 for a duplicated tag value when a tagged type is declared.
6934 @item
6935 @code{Predicate_Check} can be used to control whether predicate checks are
6936 active. It is applicable only to predicates for which the policy is
6937 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6938 predicate is ignored or checked for the whole program, the use of
6939 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6940 predicate to be turned on and off at specific points in the program.
6942 @item
6943 @code{Validity_Check} can be used specifically to control validity checks.
6944 If @code{Suppress} is used to suppress validity checks, then no validity
6945 checks are performed, including those specified by the appropriate compiler
6946 switch or the @code{Validity_Checks} pragma.
6948 @item
6949 Additional check names previously introduced by use of the @code{Check_Name}
6950 pragma are also allowed.
6952 @end itemize
6954 @noindent
6955 Note that pragma Suppress gives the compiler permission to omit
6956 checks, but does not require the compiler to omit checks. The compiler
6957 will generate checks if they are essentially free, even when they are
6958 suppressed. In particular, if the compiler can prove that a certain
6959 check will necessarily fail, it will generate code to do an
6960 unconditional ``raise'', even if checks are suppressed. The compiler
6961 warns in this case.
6963 Of course, run-time checks are omitted whenever the compiler can prove
6964 that they will not fail, whether or not checks are suppressed.
6966 @node Pragma Suppress_All
6967 @unnumberedsec Pragma Suppress_All
6968 @findex Suppress_All
6969 @noindent
6970 Syntax:
6972 @smallexample @c ada
6973 pragma Suppress_All;
6974 @end smallexample
6976 @noindent
6977 This pragma can appear anywhere within a unit.
6978 The effect is to apply @code{Suppress (All_Checks)} to the unit
6979 in which it appears.  This pragma is implemented for compatibility with DEC
6980 Ada 83 usage where it appears at the end of a unit, and for compatibility
6981 with Rational Ada, where it appears as a program unit pragma.
6982 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6983 as a normal configuration pragma is the preferred usage in GNAT@.
6985 @node Pragma Suppress_Debug_Info
6986 @unnumberedsec Pragma Suppress_Debug_Info
6987 @findex Suppress_Debug_Info
6988 @noindent
6989 Syntax:
6991 @smallexample @c ada
6992 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6993 @end smallexample
6995 @noindent
6996 This pragma can be used to suppress generation of debug information
6997 for the specified entity. It is intended primarily for use in debugging
6998 the debugger, and navigating around debugger problems.
7000 @node Pragma Suppress_Exception_Locations
7001 @unnumberedsec Pragma Suppress_Exception_Locations
7002 @findex Suppress_Exception_Locations
7003 @noindent
7004 Syntax:
7006 @smallexample @c ada
7007 pragma Suppress_Exception_Locations;
7008 @end smallexample
7010 @noindent
7011 In normal mode, a raise statement for an exception by default generates
7012 an exception message giving the file name and line number for the location
7013 of the raise. This is useful for debugging and logging purposes, but this
7014 entails extra space for the strings for the messages. The configuration
7015 pragma @code{Suppress_Exception_Locations} can be used to suppress the
7016 generation of these strings, with the result that space is saved, but the
7017 exception message for such raises is null. This configuration pragma may
7018 appear in a global configuration pragma file, or in a specific unit as
7019 usual. It is not required that this pragma be used consistently within
7020 a partition, so it is fine to have some units within a partition compiled
7021 with this pragma and others compiled in normal mode without it.
7023 @node Pragma Suppress_Initialization
7024 @unnumberedsec Pragma Suppress_Initialization
7025 @findex Suppress_Initialization
7026 @cindex Suppressing initialization
7027 @cindex Initialization, suppression of
7028 @noindent
7029 Syntax:
7031 @smallexample @c ada
7032 pragma Suppress_Initialization ([Entity =>] subtype_Name);
7033 @end smallexample
7035 @noindent
7036 Here subtype_Name is the name introduced by a type declaration
7037 or subtype declaration.
7038 This pragma suppresses any implicit or explicit initialization
7039 for all variables of the given type or subtype,
7040 including initialization resulting from the use of pragmas
7041 Normalize_Scalars or Initialize_Scalars.
7043 This is considered a representation item, so it cannot be given after
7044 the type is frozen. It applies to all subsequent object declarations,
7045 and also any allocator that creates objects of the type.
7047 If the pragma is given for the first subtype, then it is considered
7048 to apply to the base type and all its subtypes. If the pragma is given
7049 for other than a first subtype, then it applies only to the given subtype.
7050 The pragma may not be given after the type is frozen.
7052 Note that this includes eliminating initialization of discriminants
7053 for discriminated types, and tags for tagged types. In these cases,
7054 you will have to use some non-portable mechanism (e.g. address
7055 overlays or unchecked conversion) to achieve required initialization
7056 of these fields before accessing any object of the corresponding type.
7058 @node Pragma Task_Name
7059 @unnumberedsec Pragma Task_Name
7060 @findex Task_Name
7061 @noindent
7062 Syntax
7064 @smallexample @c ada
7065 pragma Task_Name (string_EXPRESSION);
7066 @end smallexample
7068 @noindent
7069 This pragma appears within a task definition (like pragma
7070 @code{Priority}) and applies to the task in which it appears.  The
7071 argument must be of type String, and provides a name to be used for
7072 the task instance when the task is created.  Note that this expression
7073 is not required to be static, and in particular, it can contain
7074 references to task discriminants.  This facility can be used to
7075 provide different names for different tasks as they are created,
7076 as illustrated in the example below.
7078 The task name is recorded internally in the run-time structures
7079 and is accessible to tools like the debugger.  In addition the
7080 routine @code{Ada.Task_Identification.Image} will return this
7081 string, with a unique task address appended.
7083 @smallexample @c ada
7084 --  Example of the use of pragma Task_Name
7086 with Ada.Task_Identification;
7087 use Ada.Task_Identification;
7088 with Text_IO; use Text_IO;
7089 procedure t3 is
7091    type Astring is access String;
7093    task type Task_Typ (Name : access String) is
7094       pragma Task_Name (Name.all);
7095    end Task_Typ;
7097    task body Task_Typ is
7098       Nam : constant String := Image (Current_Task);
7099    begin
7100       Put_Line ("-->" & Nam (1 .. 14) & "<--");
7101    end Task_Typ;
7103    type Ptr_Task is access Task_Typ;
7104    Task_Var : Ptr_Task;
7106 begin
7107    Task_Var :=
7108      new Task_Typ (new String'("This is task 1"));
7109    Task_Var :=
7110      new Task_Typ (new String'("This is task 2"));
7111 end;
7112 @end smallexample
7114 @node Pragma Task_Storage
7115 @unnumberedsec Pragma Task_Storage
7116 @findex Task_Storage
7117 Syntax:
7119 @smallexample @c ada
7120 pragma Task_Storage (
7121   [Task_Type =>] LOCAL_NAME,
7122   [Top_Guard =>] static_integer_EXPRESSION);
7123 @end smallexample
7125 @noindent
7126 This pragma specifies the length of the guard area for tasks.  The guard
7127 area is an additional storage area allocated to a task.  A value of zero
7128 means that either no guard area is created or a minimal guard area is
7129 created, depending on the target.  This pragma can appear anywhere a
7130 @code{Storage_Size} attribute definition clause is allowed for a task
7131 type.
7133 @node Pragma Test_Case
7134 @unnumberedsec Pragma Test_Case
7135 @cindex Test cases
7136 @findex Test_Case
7137 @noindent
7138 Syntax:
7140 @smallexample @c ada
7141 pragma Test_Case (
7142    [Name     =>] static_string_Expression
7143   ,[Mode     =>] (Nominal | Robustness)
7144  [, Requires =>  Boolean_Expression]
7145  [, Ensures  =>  Boolean_Expression]);
7146 @end smallexample
7148 @noindent
7149 The @code{Test_Case} pragma allows defining fine-grain specifications
7150 for use by testing tools.
7151 The compiler checks the validity of the @code{Test_Case} pragma, but its
7152 presence does not lead to any modification of the code generated by the
7153 compiler.
7155 @code{Test_Case} pragmas may only appear immediately following the
7156 (separate) declaration of a subprogram in a package declaration, inside
7157 a package spec unit. Only other pragmas may intervene (that is appear
7158 between the subprogram declaration and a test case).
7160 The compiler checks that boolean expressions given in @code{Requires} and
7161 @code{Ensures} are valid, where the rules for @code{Requires} are the
7162 same as the rule for an expression in @code{Precondition} and the rules
7163 for @code{Ensures} are the same as the rule for an expression in
7164 @code{Postcondition}. In particular, attributes @code{'Old} and
7165 @code{'Result} can only be used within the @code{Ensures}
7166 expression. The following is an example of use within a package spec:
7168 @smallexample @c ada
7169 package Math_Functions is
7170    ...
7171    function Sqrt (Arg : Float) return Float;
7172    pragma Test_Case (Name     => "Test 1",
7173                      Mode     => Nominal,
7174                      Requires => Arg < 10000,
7175                      Ensures  => Sqrt'Result < 10);
7176    ...
7177 end Math_Functions;
7178 @end smallexample
7180 @noindent
7181 The meaning of a test case is that there is at least one context where
7182 @code{Requires} holds such that, if the associated subprogram is executed in
7183 that context, then @code{Ensures} holds when the subprogram returns.
7184 Mode @code{Nominal} indicates that the input context should also satisfy the
7185 precondition of the subprogram, and the output context should also satisfy its
7186 postcondition. Mode @code{Robustness} indicates that the precondition and
7187 postcondition of the subprogram should be ignored for this test case.
7189 @node Pragma Thread_Local_Storage
7190 @unnumberedsec Pragma Thread_Local_Storage
7191 @findex Thread_Local_Storage
7192 @cindex Task specific storage
7193 @cindex TLS (Thread Local Storage)
7194 @cindex Task_Attributes
7195 Syntax:
7197 @smallexample @c ada
7198 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7199 @end smallexample
7201 @noindent
7202 This pragma specifies that the specified entity, which must be
7203 a variable declared in a library level package, is to be marked as
7204 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7205 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7206 (and hence each Ada task) to see a distinct copy of the variable.
7208 The variable may not have default initialization, and if there is
7209 an explicit initialization, it must be either @code{null} for an
7210 access variable, or a static expression for a scalar variable.
7211 This provides a low level mechanism similar to that provided by
7212 the @code{Ada.Task_Attributes} package, but much more efficient
7213 and is also useful in writing interface code that will interact
7214 with foreign threads.
7216 If this pragma is used on a system where @code{TLS} is not supported,
7217 then an error message will be generated and the program will be rejected.
7219 @node Pragma Time_Slice
7220 @unnumberedsec Pragma Time_Slice
7221 @findex Time_Slice
7222 @noindent
7223 Syntax:
7225 @smallexample @c ada
7226 pragma Time_Slice (static_duration_EXPRESSION);
7227 @end smallexample
7229 @noindent
7230 For implementations of GNAT on operating systems where it is possible
7231 to supply a time slice value, this pragma may be used for this purpose.
7232 It is ignored if it is used in a system that does not allow this control,
7233 or if it appears in other than the main program unit.
7234 @cindex OpenVMS
7235 Note that the effect of this pragma is identical to the effect of the
7236 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7238 @node Pragma Title
7239 @unnumberedsec Pragma Title
7240 @findex Title
7241 @noindent
7242 Syntax:
7244 @smallexample @c ada
7245 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7247 TITLING_OPTION ::=
7248   [Title    =>] STRING_LITERAL,
7249 | [Subtitle =>] STRING_LITERAL
7250 @end smallexample
7252 @noindent
7253 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
7254 pragma used in DEC Ada 83 implementations to provide a title and/or
7255 subtitle for the program listing.  The program listing generated by GNAT
7256 does not have titles or subtitles.
7258 Unlike other pragmas, the full flexibility of named notation is allowed
7259 for this pragma, i.e.@: the parameters may be given in any order if named
7260 notation is used, and named and positional notation can be mixed
7261 following the normal rules for procedure calls in Ada.
7263 @node Pragma Type_Invariant
7264 @unnumberedsec Pragma Type_Invariant
7265 @findex Invariant
7266 @findex Type_Invariant pragma
7267 @noindent
7268 Syntax:
7270 @smallexample @c ada
7271 pragma Type_Invariant
7272   ([Entity =>] type_LOCAL_NAME,
7273    [Check  =>] EXPRESSION);
7274 @end smallexample
7276 @noindent
7277 The @code{Type_Invariant} pragma is intended to be an exact
7278 replacement for the language-defined @code{Type_Invariant}
7279 aspect, and shares its restrictions and semantics. It differs
7280 from the language defined @code{Invariant} pragma in that it
7281 does not permit a string parameter, and it is
7282 controlled by the assertion identifier @code{Type_Invariant}
7283 rather than @code{Invariant}.
7285 @node Pragma Type_Invariant_Class
7286 @unnumberedsec Pragma Type_Invariant_Class
7287 @findex Invariant
7288 @findex Type_Invariant_Class pragma
7289 @noindent
7290 Syntax:
7292 @smallexample @c ada
7293 pragma Type_Invariant_Class
7294   ([Entity =>] type_LOCAL_NAME,
7295    [Check  =>] EXPRESSION);
7296 @end smallexample
7298 @noindent
7299 The @code{Type_Invariant_Class} pragma is intended to be an exact
7300 replacement for the language-defined @code{Type_Invariant'Class}
7301 aspect, and shares its restrictions and semantics.
7303 Note: This pragma is called @code{Type_Invariant_Class} rather than
7304 @code{Type_Invariant'Class} because the latter would not be strictly
7305 conforming to the allowed syntax for pragmas. The motivation
7306 for providing pragmas equivalent to the aspects is to allow a program
7307 to be written using the pragmas, and then compiled if necessary
7308 using an Ada compiler that does not recognize the pragmas or
7309 aspects, but is prepared to ignore the pragmas. The assertion
7310 policy that controls this pragma is @code{Type_Invariant'Class},
7311 not @code{Type_Invariant_Class}.
7313 @node Pragma Unchecked_Union
7314 @unnumberedsec Pragma Unchecked_Union
7315 @cindex Unions in C
7316 @findex Unchecked_Union
7317 @noindent
7318 Syntax:
7320 @smallexample @c ada
7321 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7322 @end smallexample
7324 @noindent
7325 This pragma is used to specify a representation of a record type that is
7326 equivalent to a C union. It was introduced as a GNAT implementation defined
7327 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7328 pragma, making it language defined, and GNAT fully implements this extended
7329 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7330 details, consult the Ada 2012 Reference Manual, section B.3.3.
7332 @node Pragma Unevaluated_Use_Of_Old
7333 @unnumberedsec Pragma Unevaluated_Use_Of_Old
7334 @cindex Attribute Old
7335 @cindex Attribute Loop_Entry
7336 @cindex Unevaluated_Use_Of_Old
7337 @findex Unevaluated_Use_Of_Old
7338 @noindent
7339 Syntax:
7341 @smallexample @c ada
7342 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
7343 @end smallexample
7345 @noindent
7346 This pragma controls the processing of attributes Old and Loop_Entry.
7347 If either of these attributes is used in a potentially unevaluated
7348 expression  (e.g. the then or else parts of an if expression), then
7349 normally this usage is considered illegal if the prefix of the attribute
7350 is other than an entity name. The language requires this
7351 behavior for Old, and GNAT copies the same rule for Loop_Entry.
7353 The reason for this rule is that otherwise, we can have a situation
7354 where we save the Old value, and this results in an exception, even
7355 though we might not evaluate the attribute. Consider this example:
7357 @smallexample @c ada
7358 package UnevalOld is
7359    K : Character;
7360    procedure U (A : String; C : Boolean)  -- ERROR
7361      with Post => (if C then A(1)'Old = K else True);
7362 end;
7363 @end smallexample
7365 @noindent
7366 If procedure U is called with a string with a lower bound of 2, and
7367 C false, then an exception would be raised trying to evaluate A(1)
7368 on entry even though the value would not be actually used.
7370 Although the rule guarantees against this possibility, it is sometimes
7371 too restrictive. For example if we know that the string has a lower
7372 bound of 1, then we will never raise an exception.
7373 The pragma @code{Unevaluated_Use_Of_Old} can be
7374 used to modify this behavior. If the argument is @code{Error} then an
7375 error is given (this is the default RM behavior). If the argument is
7376 @code{Warn} then the usage is allowed as legal but with a warning
7377 that an exception might be raised. If the argument is @code{Allow}
7378 then the usage is allowed as legal without generating a warning.
7380 This pragma may appear as a configuration pragma, or in a declarative
7381 part or package specification. In the latter case it applies to
7382 uses up to the end of the corresponding statement sequence or
7383 sequence of package declarations.
7385 @node Pragma Unimplemented_Unit
7386 @unnumberedsec Pragma Unimplemented_Unit
7387 @findex Unimplemented_Unit
7388 @noindent
7389 Syntax:
7391 @smallexample @c ada
7392 pragma Unimplemented_Unit;
7393 @end smallexample
7395 @noindent
7396 If this pragma occurs in a unit that is processed by the compiler, GNAT
7397 aborts with the message @samp{@var{xxx} not implemented}, where
7398 @var{xxx} is the name of the current compilation unit.  This pragma is
7399 intended to allow the compiler to handle unimplemented library units in
7400 a clean manner.
7402 The abort only happens if code is being generated.  Thus you can use
7403 specs of unimplemented packages in syntax or semantic checking mode.
7405 @node Pragma Universal_Aliasing
7406 @unnumberedsec Pragma Universal_Aliasing
7407 @findex Universal_Aliasing
7408 @noindent
7409 Syntax:
7411 @smallexample @c ada
7412 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7413 @end smallexample
7415 @noindent
7416 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7417 declarative part.  The effect is to inhibit strict type-based aliasing
7418 optimization for the given type.  In other words, the effect is as though
7419 access types designating this type were subject to pragma No_Strict_Aliasing.
7420 For a detailed description of the strict aliasing optimization, and the
7421 situations in which it must be suppressed, @xref{Optimization and Strict
7422 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7424 @node Pragma Universal_Data
7425 @unnumberedsec Pragma Universal_Data
7426 @findex Universal_Data
7427 @noindent
7428 Syntax:
7430 @smallexample @c ada
7431 pragma Universal_Data [(library_unit_Name)];
7432 @end smallexample
7434 @noindent
7435 This pragma is supported only for the AAMP target and is ignored for
7436 other targets. The pragma specifies that all library-level objects
7437 (Counter 0 data) associated with the library unit are to be accessed
7438 and updated using universal addressing (24-bit addresses for AAMP5)
7439 rather than the default of 16-bit Data Environment (DENV) addressing.
7440 Use of this pragma will generally result in less efficient code for
7441 references to global data associated with the library unit, but
7442 allows such data to be located anywhere in memory. This pragma is
7443 a library unit pragma, but can also be used as a configuration pragma
7444 (including use in the @file{gnat.adc} file). The functionality
7445 of this pragma is also available by applying the -univ switch on the
7446 compilations of units where universal addressing of the data is desired.
7448 @node Pragma Unmodified
7449 @unnumberedsec Pragma Unmodified
7450 @findex Unmodified
7451 @cindex Warnings, unmodified
7452 @noindent
7453 Syntax:
7455 @smallexample @c ada
7456 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7457 @end smallexample
7459 @noindent
7460 This pragma signals that the assignable entities (variables,
7461 @code{out} parameters, @code{in out} parameters) whose names are listed are
7462 deliberately not assigned in the current source unit. This
7463 suppresses warnings about the
7464 entities being referenced but not assigned, and in addition a warning will be
7465 generated if one of these entities is in fact assigned in the
7466 same unit as the pragma (or in the corresponding body, or one
7467 of its subunits).
7469 This is particularly useful for clearly signaling that a particular
7470 parameter is not modified, even though the spec suggests that it might
7473 For the variable case, warnings are never given for unreferenced variables
7474 whose name contains one of the substrings
7475 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7476 are typically to be used in cases where such warnings are expected.
7477 Thus it is never necessary to use @code{pragma Unmodified} for such
7478 variables, though it is harmless to do so.
7480 @node Pragma Unreferenced
7481 @unnumberedsec Pragma Unreferenced
7482 @findex Unreferenced
7483 @cindex Warnings, unreferenced
7484 @noindent
7485 Syntax:
7487 @smallexample @c ada
7488 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7489 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7490 @end smallexample
7492 @noindent
7493 This pragma signals that the entities whose names are listed are
7494 deliberately not referenced in the current source unit after the
7495 occurrence of the pragma. This
7496 suppresses warnings about the
7497 entities being unreferenced, and in addition a warning will be
7498 generated if one of these entities is in fact subsequently referenced in the
7499 same unit as the pragma (or in the corresponding body, or one
7500 of its subunits).
7502 This is particularly useful for clearly signaling that a particular
7503 parameter is not referenced in some particular subprogram implementation
7504 and that this is deliberate. It can also be useful in the case of
7505 objects declared only for their initialization or finalization side
7506 effects.
7508 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7509 current scope, then the entity most recently declared is the one to which
7510 the pragma applies. Note that in the case of accept formals, the pragma
7511 Unreferenced may appear immediately after the keyword @code{do} which
7512 allows the indication of whether or not accept formals are referenced
7513 or not to be given individually for each accept statement.
7515 The left hand side of an assignment does not count as a reference for the
7516 purpose of this pragma. Thus it is fine to assign to an entity for which
7517 pragma Unreferenced is given.
7519 Note that if a warning is desired for all calls to a given subprogram,
7520 regardless of whether they occur in the same unit as the subprogram
7521 declaration, then this pragma should not be used (calls from another
7522 unit would not be flagged); pragma Obsolescent can be used instead
7523 for this purpose, see @xref{Pragma Obsolescent}.
7525 The second form of pragma @code{Unreferenced} is used within a context
7526 clause. In this case the arguments must be unit names of units previously
7527 mentioned in @code{with} clauses (similar to the usage of pragma
7528 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7529 units and unreferenced entities within these units.
7531 For the variable case, warnings are never given for unreferenced variables
7532 whose name contains one of the substrings
7533 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7534 are typically to be used in cases where such warnings are expected.
7535 Thus it is never necessary to use @code{pragma Unreferenced} for such
7536 variables, though it is harmless to do so.
7538 @node Pragma Unreferenced_Objects
7539 @unnumberedsec Pragma Unreferenced_Objects
7540 @findex Unreferenced_Objects
7541 @cindex Warnings, unreferenced
7542 @noindent
7543 Syntax:
7545 @smallexample @c ada
7546 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7547 @end smallexample
7549 @noindent
7550 This pragma signals that for the types or subtypes whose names are
7551 listed, objects which are declared with one of these types or subtypes may
7552 not be referenced, and if no references appear, no warnings are given.
7554 This is particularly useful for objects which are declared solely for their
7555 initialization and finalization effect. Such variables are sometimes referred
7556 to as RAII variables (Resource Acquisition Is Initialization). Using this
7557 pragma on the relevant type (most typically a limited controlled type), the
7558 compiler will automatically suppress unwanted warnings about these variables
7559 not being referenced.
7561 @node Pragma Unreserve_All_Interrupts
7562 @unnumberedsec Pragma Unreserve_All_Interrupts
7563 @findex Unreserve_All_Interrupts
7564 @noindent
7565 Syntax:
7567 @smallexample @c ada
7568 pragma Unreserve_All_Interrupts;
7569 @end smallexample
7571 @noindent
7572 Normally certain interrupts are reserved to the implementation.  Any attempt
7573 to attach an interrupt causes Program_Error to be raised, as described in
7574 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
7575 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
7576 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7577 interrupt execution.
7579 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7580 a program, then all such interrupts are unreserved.  This allows the
7581 program to handle these interrupts, but disables their standard
7582 functions.  For example, if this pragma is used, then pressing
7583 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
7584 a program can then handle the @code{SIGINT} interrupt as it chooses.
7586 For a full list of the interrupts handled in a specific implementation,
7587 see the source code for the spec of @code{Ada.Interrupts.Names} in
7588 file @file{a-intnam.ads}.  This is a target dependent file that contains the
7589 list of interrupts recognized for a given target.  The documentation in
7590 this file also specifies what interrupts are affected by the use of
7591 the @code{Unreserve_All_Interrupts} pragma.
7593 For a more general facility for controlling what interrupts can be
7594 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7595 of the @code{Unreserve_All_Interrupts} pragma.
7597 @node Pragma Unsuppress
7598 @unnumberedsec Pragma Unsuppress
7599 @findex Unsuppress
7600 @noindent
7601 Syntax:
7603 @smallexample @c ada
7604 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7605 @end smallexample
7607 @noindent
7608 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
7609 there is no corresponding pragma @code{Suppress} in effect, it has no
7610 effect.  The range of the effect is the same as for pragma
7611 @code{Suppress}.  The meaning of the arguments is identical to that used
7612 in pragma @code{Suppress}.
7614 One important application is to ensure that checks are on in cases where
7615 code depends on the checks for its correct functioning, so that the code
7616 will compile correctly even if the compiler switches are set to suppress
7617 checks. For example, in a program that depends on external names of tagged
7618 types and wants to ensure that the duplicated tag check occurs even if all
7619 run-time checks are suppressed by a compiler switch, the following
7620 configuration pragma will ensure this test is not suppressed:
7622 @smallexample @c ada
7623 pragma Unsuppress (Duplicated_Tag_Check);
7624 @end smallexample
7626 @noindent
7627 This pragma is standard in Ada 2005. It is available in all earlier versions
7628 of Ada as an implementation-defined pragma.
7630 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7631 a number of implementation-defined check names. See description of pragma
7632 @code{Suppress} for full details.
7634 @node Pragma Use_VADS_Size
7635 @unnumberedsec Pragma Use_VADS_Size
7636 @cindex @code{Size}, VADS compatibility
7637 @cindex Rational profile
7638 @findex Use_VADS_Size
7639 @noindent
7640 Syntax:
7642 @smallexample @c ada
7643 pragma Use_VADS_Size;
7644 @end smallexample
7646 @noindent
7647 This is a configuration pragma.  In a unit to which it applies, any use
7648 of the 'Size attribute is automatically interpreted as a use of the
7649 'VADS_Size attribute.  Note that this may result in incorrect semantic
7650 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
7651 the handling of existing code which depends on the interpretation of Size
7652 as implemented in the VADS compiler.  See description of the VADS_Size
7653 attribute for further details.
7655 @node Pragma Validity_Checks
7656 @unnumberedsec Pragma Validity_Checks
7657 @findex Validity_Checks
7658 @noindent
7659 Syntax:
7661 @smallexample @c ada
7662 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7663 @end smallexample
7665 @noindent
7666 This pragma is used in conjunction with compiler switches to control the
7667 built-in validity checking provided by GNAT@.  The compiler switches, if set
7668 provide an initial setting for the switches, and this pragma may be used
7669 to modify these settings, or the settings may be provided entirely by
7670 the use of the pragma.  This pragma can be used anywhere that a pragma
7671 is legal, including use as a configuration pragma (including use in
7672 the @file{gnat.adc} file).
7674 The form with a string literal specifies which validity options are to be
7675 activated.  The validity checks are first set to include only the default
7676 reference manual settings, and then a string of letters in the string
7677 specifies the exact set of options required.  The form of this string
7678 is exactly as described for the @option{-gnatVx} compiler switch (see the
7679 @value{EDITION} User's Guide for details).  For example the following two
7680 methods can be used to enable validity checking for mode @code{in} and
7681 @code{in out} subprogram parameters:
7683 @itemize @bullet
7684 @item
7685 @smallexample @c ada
7686 pragma Validity_Checks ("im");
7687 @end smallexample
7689 @item
7690 @smallexample
7691 gcc -c -gnatVim @dots{}
7692 @end smallexample
7693 @end itemize
7695 @noindent
7696 The form ALL_CHECKS activates all standard checks (its use is equivalent
7697 to the use of the @code{gnatva} switch.
7699 The forms with @code{Off} and @code{On}
7700 can be used to temporarily disable validity checks
7701 as shown in the following example:
7703 @smallexample @c ada
7704 @iftex
7705 @leftskip=0cm
7706 @end iftex
7707 pragma Validity_Checks ("c"); -- validity checks for copies
7708 pragma Validity_Checks (Off); -- turn off validity checks
7709 A := B;                       -- B will not be validity checked
7710 pragma Validity_Checks (On);  -- turn validity checks back on
7711 A := C;                       -- C will be validity checked
7712 @end smallexample
7714 @node Pragma Volatile
7715 @unnumberedsec Pragma Volatile
7716 @findex Volatile
7717 @noindent
7718 Syntax:
7720 @smallexample @c ada
7721 pragma Volatile (LOCAL_NAME);
7722 @end smallexample
7724 @noindent
7725 This pragma is defined by the Ada Reference Manual, and the GNAT
7726 implementation is fully conformant with this definition.  The reason it
7727 is mentioned in this section is that a pragma of the same name was supplied
7728 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
7729 implementation of pragma Volatile is upwards compatible with the
7730 implementation in DEC Ada 83.
7732 @node Pragma Warning_As_Error
7733 @unnumberedsec Pragma Warning_As_Error
7734 @findex Warning_As_Error
7735 @noindent
7736 Syntax:
7738 @smallexample @c ada
7739 pragma Warning_As_Error (static_string_EXPRESSION);
7740 @end smallexample
7742 @noindent
7743 This configuration pragma allows the programmer to specify a set
7744 of warnings that will be treated as errors. Any warning which
7745 matches the pattern given by the pragma argument will be treated
7746 as an error. This gives much more precise control that -gnatwe
7747 which treats all warnings as errors.
7749 The pattern may contain asterisks, which match zero or more characters in
7750 the message. For example, you can use
7751 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7752 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7753 expression notations are permitted. All characters other than asterisk in
7754 these three specific cases are treated as literal characters in the match.
7755 The match is case insensitive, for example XYZ matches xyz.
7757 Note that the pattern matches if it occurs anywhere within the warning
7758 message string (it is not necessary to put an asterisk at the start and
7759 the end of the message, since this is implied).
7761 Another possibility for the static_string_EXPRESSION which works whether
7762 or not error tags are enabled (@option{-gnatw.d}) is to use the
7763 @option{-gnatw} tag string, enclosed in brackets,
7764 as shown in the example below, to treat a class of warnings as errors.
7766 The above use of patterns to match the message applies only to warning
7767 messages generated by the front end. This pragma can also be applied to
7768 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7769 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7770 can also be treated as errors.
7772 The pragma can appear either in a global configuration pragma file
7773 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7774 configuration pragma file containing:
7776 @smallexample @c ada
7777 pragma Warning_As_Error ("[-gnatwj]");
7778 @end smallexample
7780 @noindent
7781 which will treat all obsolescent feature warnings as errors, the
7782 following program compiles as shown (compile options here are
7783 @option{-gnatwa.d -gnatl -gnatj55}).
7785 @smallexample @c ada
7786      1. pragma Warning_As_Error ("*never assigned*");
7787      2. function Warnerr return String is
7788      3.    X : Integer;
7789            |
7790         >>> error: variable "X" is never read and
7791             never assigned [-gnatwv] [warning-as-error]
7793      4.    Y : Integer;
7794            |
7795         >>> warning: variable "Y" is assigned but
7796             never read [-gnatwu]
7798      5. begin
7799      6.    Y := 0;
7800      7.    return %ABC%;
7801                   |
7802         >>> error: use of "%" is an obsolescent
7803             feature (RM J.2(4)), use """ instead
7804             [-gnatwj] [warning-as-error]
7806      8. end;
7808  8 lines: No errors, 3 warnings (2 treated as errors)
7809 @end smallexample
7811 @noindent
7812 Note that this pragma does not affect the set of warnings issued in
7813 any way, it merely changes the effect of a matching warning if one
7814 is produced as a result of other warnings options. As shown in this
7815 example, if the pragma results in a warning being treated as an error,
7816 the tag is changed from "warning:" to "error:" and the string
7817 "[warning-as-error]" is appended to the end of the message.
7819 @node Pragma Warnings
7820 @unnumberedsec Pragma Warnings
7821 @findex Warnings
7822 @noindent
7823 Syntax:
7825 @smallexample @c ada
7826 pragma Warnings (On | Off [,REASON]);
7827 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7828 pragma Warnings (static_string_EXPRESSION [,REASON]);
7829 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7831 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7833 Note: in Ada 83 mode, a string literal may be used in place of
7834 a static string expression (which does not exist in Ada 83).
7835 @end smallexample
7837 @noindent
7838 Normally warnings are enabled, with the output being controlled by
7839 the command line switch.  Warnings (@code{Off}) turns off generation of
7840 warnings until a Warnings (@code{On}) is encountered or the end of the
7841 current unit.  If generation of warnings is turned off using this
7842 pragma, then some or all of the warning messages are suppressed,
7843 regardless of the setting of the command line switches.
7845 The @code{Reason} parameter may optionally appear as the last argument
7846 in any of the forms of this pragma. It is intended purely for the
7847 purposes of documenting the reason for the @code{Warnings} pragma.
7848 The compiler will check that the argument is a static string but
7849 otherwise ignore this argument. Other tools may provide specialized
7850 processing for this string.
7852 The form with a single argument (or two arguments if Reason present),
7853 where the first argument is @code{ON} or @code{OFF}
7854 may be used as a configuration pragma.
7856 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7857 the specified entity.  This suppression is effective from the point where
7858 it occurs till the end of the extended scope of the variable (similar to
7859 the scope of @code{Suppress}). This form cannot be used as a configuration
7860 pragma.
7862 In the case where the first argument is other than @code{ON} or
7863 @code{OFF},
7864 the third form with a single static_string_EXPRESSION argument (and possible
7865 reason) provides more precise
7866 control over which warnings are active. The string is a list of letters
7867 specifying which warnings are to be activated and which deactivated. The
7868 code for these letters is the same as the string used in the command
7869 line switch controlling warnings. For a brief summary, use the gnatmake
7870 command with no arguments, which will generate usage information containing
7871 the list of warnings switches supported. For
7872 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7873 User's Guide}. This form can also be used as a configuration pragma.
7875 @noindent
7876 The warnings controlled by the @option{-gnatw} switch are generated by the
7877 front end of the compiler. The GCC back end can provide additional warnings
7878 and they are controlled by the @option{-W} switch. Such warnings can be
7879 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7880 message which designates the @option{-Wxxx} switch that controls the message.
7881 The form with a single static_string_EXPRESSION argument also works for these
7882 warnings, but the string must be a single full @option{-Wxxx} switch in this
7883 case. The above reference lists a few examples of these additional warnings.
7885 @noindent
7886 The specified warnings will be in effect until the end of the program
7887 or another pragma Warnings is encountered. The effect of the pragma is
7888 cumulative. Initially the set of warnings is the standard default set
7889 as possibly modified by compiler switches. Then each pragma Warning
7890 modifies this set of warnings as specified. This form of the pragma may
7891 also be used as a configuration pragma.
7893 The fourth form, with an @code{On|Off} parameter and a string, is used to
7894 control individual messages, based on their text. The string argument
7895 is a pattern that is used to match against the text of individual
7896 warning messages (not including the initial "warning: " tag).
7898 The pattern may contain asterisks, which match zero or more characters in
7899 the message. For example, you can use
7900 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7901 message @code{warning: 960 bits of "a" unused}. No other regular
7902 expression notations are permitted. All characters other than asterisk in
7903 these three specific cases are treated as literal characters in the match.
7904 The match is case insensitive, for example XYZ matches xyz.
7906 Note that the pattern matches if it occurs anywhere within the warning
7907 message string (it is not necessary to put an asterisk at the start and
7908 the end of the message, since this is implied).
7910 The above use of patterns to match the message applies only to warning
7911 messages generated by the front end. This form of the pragma with a string
7912 argument can also be used to control warnings provided by the back end and
7913 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7914 such warnings can be turned on and off.
7916 There are two ways to use the pragma in this form. The OFF form can be used
7917 as a configuration pragma. The effect is to suppress all warnings (if any)
7918 that match the pattern string throughout the compilation (or match the
7919 -W switch in the back end case).
7921 The second usage is to suppress a warning locally, and in this case, two
7922 pragmas must appear in sequence:
7924 @smallexample @c ada
7925 pragma Warnings (Off, Pattern);
7926 @dots{} code where given warning is to be suppressed
7927 pragma Warnings (On, Pattern);
7928 @end smallexample
7930 @noindent
7931 In this usage, the pattern string must match in the Off and On pragmas,
7932 and at least one matching warning must be suppressed.
7934 Note: to write a string that will match any warning, use the string
7935 @code{"***"}. It will not work to use a single asterisk or two asterisks
7936 since this looks like an operator name. This form with three asterisks
7937 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7938 matching @code{pragma Warnings (On, "***")} will be required. This can be
7939 helpful in avoiding forgetting to turn warnings back on.
7941 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7942 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7943 be useful in checking whether obsolete pragmas in existing programs are hiding
7944 real problems.
7946 Note: pragma Warnings does not affect the processing of style messages. See
7947 separate entry for pragma Style_Checks for control of style messages.
7949 @node Pragma Weak_External
7950 @unnumberedsec Pragma Weak_External
7951 @findex Weak_External
7952 @noindent
7953 Syntax:
7955 @smallexample @c ada
7956 pragma Weak_External ([Entity =>] LOCAL_NAME);
7957 @end smallexample
7959 @noindent
7960 @var{LOCAL_NAME} must refer to an object that is declared at the library
7961 level. This pragma specifies that the given entity should be marked as a
7962 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7963 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7964 of a regular symbol, that is to say a symbol that does not have to be
7965 resolved by the linker if used in conjunction with a pragma Import.
7967 When a weak symbol is not resolved by the linker, its address is set to
7968 zero. This is useful in writing interfaces to external modules that may
7969 or may not be linked in the final executable, for example depending on
7970 configuration settings.
7972 If a program references at run time an entity to which this pragma has been
7973 applied, and the corresponding symbol was not resolved at link time, then
7974 the execution of the program is erroneous. It is not erroneous to take the
7975 Address of such an entity, for example to guard potential references,
7976 as shown in the example below.
7978 Some file formats do not support weak symbols so not all target machines
7979 support this pragma.
7981 @smallexample @c ada
7982 --  Example of the use of pragma Weak_External
7984 package External_Module is
7985   key : Integer;
7986   pragma Import (C, key);
7987   pragma Weak_External (key);
7988   function Present return boolean;
7989 end External_Module;
7991 with System; use System;
7992 package body External_Module is
7993   function Present return boolean is
7994   begin
7995     return key'Address /= System.Null_Address;
7996   end Present;
7997 end External_Module;
7998 @end smallexample
8000 @node Pragma Wide_Character_Encoding
8001 @unnumberedsec Pragma Wide_Character_Encoding
8002 @findex Wide_Character_Encoding
8003 @noindent
8004 Syntax:
8006 @smallexample @c ada
8007 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
8008 @end smallexample
8010 @noindent
8011 This pragma specifies the wide character encoding to be used in program
8012 source text appearing subsequently. It is a configuration pragma, but may
8013 also be used at any point that a pragma is allowed, and it is permissible
8014 to have more than one such pragma in a file, allowing multiple encodings
8015 to appear within the same file.
8017 The argument can be an identifier or a character literal. In the identifier
8018 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
8019 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
8020 case it is correspondingly one of the characters @samp{h}, @samp{u},
8021 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
8023 Note that when the pragma is used within a file, it affects only the
8024 encoding within that file, and does not affect withed units, specs,
8025 or subunits.
8027 @node Implementation Defined Aspects
8028 @chapter Implementation Defined Aspects
8029 Ada defines (throughout the Ada 2012 reference manual, summarized
8030 in Annex K) a set of aspects that can be specified for certain entities.
8031 These language defined aspects are implemented in GNAT in Ada 2012 mode
8032 and work as described in the Ada 2012 Reference Manual.
8034 In addition, Ada 2012 allows implementations to define additional aspects
8035 whose meaning is defined by the implementation.  GNAT provides
8036 a number of these implementation-defined aspects which can be used
8037 to extend and enhance the functionality of the compiler.  This section of
8038 the GNAT reference manual describes these additional aspects.
8040 Note that any program using these aspects may not be portable to
8041 other compilers (although GNAT implements this set of aspects on all
8042 platforms).  Therefore if portability to other compilers is an important
8043 consideration, you should minimize the use of these aspects.
8045 Note that for many of these aspects, the effect is essentially similar
8046 to the use of a pragma or attribute specification with the same name
8047 applied to the entity. For example, if we write:
8049 @smallexample @c ada
8050 type R is range 1 .. 100
8051   with Value_Size => 10;
8052 @end smallexample
8054 @noindent
8055 then the effect is the same as:
8057 @smallexample @c ada
8058 type R is range 1 .. 100;
8059 for R'Value_Size use 10;
8060 @end smallexample
8062 @noindent
8063 and if we write:
8065 @smallexample @c ada
8066 type R is new Integer
8067   with Shared => True;
8068 @end smallexample
8070 @noindent
8071 then the effect is the same as:
8073 @smallexample @c ada
8074 type R is new Integer;
8075 pragma Shared (R);
8076 @end smallexample
8078 @noindent
8079 In the documentation below, such cases are simply marked
8080 as being equivalent to the corresponding pragma or attribute definition
8081 clause.
8083 @menu
8084 * Aspect Abstract_State::
8085 * Aspect Annotate::
8086 * Aspect Async_Readers::
8087 * Aspect Async_Writers::
8088 * Aspect Contract_Cases::
8089 * Aspect Depends::
8090 * Aspect Dimension::
8091 * Aspect Dimension_System::
8092 * Aspect Effective_Reads::
8093 * Aspect Effective_Writes::
8094 * Aspect Favor_Top_Level::
8095 * Aspect Global::
8096 * Aspect Initial_Condition::
8097 * Aspect Initializes::
8098 * Aspect Inline_Always::
8099 * Aspect Invariant::
8100 * Aspect Invariant'Class::
8101 * Aspect Iterable::
8102 * Aspect Linker_Section::
8103 * Aspect Lock_Free::
8104 * Aspect No_Elaboration_Code_All::
8105 * Aspect Object_Size::
8106 * Aspect Obsolescent::
8107 * Aspect Part_Of::
8108 * Aspect Persistent_BSS::
8109 * Aspect Predicate::
8110 * Aspect Pure_Function::
8111 * Aspect Refined_Depends::
8112 * Aspect Refined_Global::
8113 * Aspect Refined_Post::
8114 * Aspect Refined_State::
8115 * Aspect Remote_Access_Type::
8116 * Aspect Scalar_Storage_Order::
8117 * Aspect Shared::
8118 * Aspect Simple_Storage_Pool::
8119 * Aspect Simple_Storage_Pool_Type::
8120 * Aspect SPARK_Mode::
8121 * Aspect Suppress_Debug_Info::
8122 * Aspect Test_Case::
8123 * Aspect Thread_Local_Storage::
8124 * Aspect Universal_Aliasing::
8125 * Aspect Universal_Data::
8126 * Aspect Unmodified::
8127 * Aspect Unreferenced::
8128 * Aspect Unreferenced_Objects::
8129 * Aspect Value_Size::
8130 * Aspect Warnings::
8131 @end menu
8133 @node Aspect Abstract_State
8134 @unnumberedsec Aspect Abstract_State
8135 @findex Abstract_State
8136 @noindent
8137 This aspect is equivalent to pragma @code{Abstract_State}.
8139 @node Aspect Annotate
8140 @unnumberedsec Annotate
8141 @findex Annotate
8142 @noindent
8143 There are three forms of this aspect (where ID is an identifier,
8144 and ARG is a general expression).
8146 @table @code
8147 @item Annotate => ID
8148 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8150 @item Annotate => (ID)
8151 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8153 @item Annotate => (ID ,ID @{, ARG@})
8154 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
8155 @end table
8157 @node Aspect Async_Readers
8158 @unnumberedsec Aspect Async_Readers
8159 @findex Async_Readers
8160 @noindent
8161 This aspect is equivalent to pragma @code{Async_Readers}.
8163 @node Aspect Async_Writers
8164 @unnumberedsec Aspect Async_Writers
8165 @findex Async_Writers
8166 @noindent
8167 This aspect is equivalent to pragma @code{Async_Writers}.
8169 @node Aspect Contract_Cases
8170 @unnumberedsec Aspect Contract_Cases
8171 @findex Contract_Cases
8172 @noindent
8173 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8174 of clauses being enclosed in parentheses so that syntactically it is an
8175 aggregate.
8177 @node Aspect Depends
8178 @unnumberedsec Aspect Depends
8179 @findex Depends
8180 @noindent
8181 This aspect is equivalent to pragma @code{Depends}.
8183 @node Aspect Dimension
8184 @unnumberedsec Aspect Dimension
8185 @findex Dimension
8186 @noindent
8187 The @code{Dimension} aspect is used to specify the dimensions of a given
8188 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8189 used when doing formatted output of dimensioned quantities. The syntax is:
8191 @smallexample @c ada
8192 with Dimension =>
8193   ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8195 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8197 DIMENSION_VALUE ::=
8198   RATIONAL
8199 | others               => RATIONAL
8200 | DISCRETE_CHOICE_LIST => RATIONAL
8202 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8203 @end smallexample
8205 @noindent
8206 This aspect can only be applied to a subtype whose parent type has
8207 a @code{Dimension_Systen} aspect. The aspect must specify values for
8208 all dimensions of the system. The rational values are the powers of the
8209 corresponding dimensions that are used by the compiler to verify that
8210 physical (numeric) computations are dimensionally consistent. For example,
8211 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8212 For further examples of the usage
8213 of this aspect, see package @code{System.Dim.Mks}.
8214 Note that when the dimensioned type is an integer type, then any
8215 dimension value must be an integer literal.
8217 @node Aspect Dimension_System
8218 @unnumberedsec Aspect Dimension_System
8219 @findex Dimension_System
8220 @noindent
8221 The @code{Dimension_System} aspect is used to define a system of
8222 dimensions that will be used in subsequent subtype declarations with
8223 @code{Dimension} aspects that reference this system. The syntax is:
8225 @smallexample @c ada
8226 with Dimension_System => (DIMENSION @{, DIMENSION@});
8228 DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
8229                [Unit_Symbol =>] SYMBOL,
8230                [Dim_Symbol  =>] SYMBOL)
8232 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8233 @end smallexample
8235 @noindent
8236 This aspect is applied to a type, which must be a numeric derived type
8237 (typically a floating-point type), that
8238 will represent values within the dimension system. Each @code{DIMENSION}
8239 corresponds to one particular dimension. A maximum of 7 dimensions may
8240 be specified. @code{Unit_Name} is the name of the dimension (for example
8241 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8242 of this dimension (for example @code{m} for @code{Meter}).
8243 @code{Dim_Symbol} gives
8244 the identification within the dimension system (typically this is a
8245 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8246 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8247 The @code{Dim_Symbol} is used in error messages when numeric operations have
8248 inconsistent dimensions.
8250 GNAT provides the standard definition of the International MKS system in
8251 the run-time package @code{System.Dim.Mks}. You can easily define
8252 similar packages for cgs units or British units, and define conversion factors
8253 between values in different systems. The MKS system is characterized by the
8254 following aspect:
8256 @smallexample @c ada
8257    type Mks_Type is new Long_Long_Float with
8258      Dimension_System => (
8259        (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
8260        (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
8261        (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
8262        (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
8263        (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => '@'),
8264        (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
8265        (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));
8266 @end smallexample
8268 @noindent
8269 Note that in the above type definition, we use the symbol @code{@@} to
8270 represent a theta character (avoiding the use of extended Latin-1
8271 characters in this context).
8273 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8274 Guide for detailed examples of use of the dimension system.
8276 @node Aspect Effective_Reads
8277 @unnumberedsec Aspect Effective_Reads
8278 @findex Effective_Reads
8279 @noindent
8280 This aspect is equivalent to pragma @code{Effective_Reads}.
8282 @node Aspect Effective_Writes
8283 @unnumberedsec Aspect Effective_Writes
8284 @findex Effective_Writes
8285 @noindent
8286 This aspect is equivalent to pragma @code{Effective_Writes}.
8288 @node Aspect Favor_Top_Level
8289 @unnumberedsec Aspect Favor_Top_Level
8290 @findex Favor_Top_Level
8291 @noindent
8292 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8294 @node Aspect Global
8295 @unnumberedsec Aspect Global
8296 @findex Global
8297 @noindent
8298 This aspect is equivalent to pragma @code{Global}.
8300 @node Aspect Initial_Condition
8301 @unnumberedsec Aspect Initial_Condition
8302 @findex Initial_Condition
8303 @noindent
8304 This aspect is equivalent to pragma @code{Initial_Condition}.
8306 @node Aspect Initializes
8307 @unnumberedsec Aspect Initializes
8308 @findex Initializes
8309 @noindent
8310 This aspect is equivalent to pragma @code{Initializes}.
8312 @node Aspect Inline_Always
8313 @unnumberedsec Aspect Inline_Always
8314 @findex Inline_Always
8315 @noindent
8316 This aspect is equivalent to pragma @code{Inline_Always}.
8318 @node Aspect Invariant
8319 @unnumberedsec Aspect Invariant
8320 @findex Invariant
8321 @noindent
8322 This aspect is equivalent to pragma @code{Invariant}. It is a
8323 synonym for the language defined aspect @code{Type_Invariant} except
8324 that it is separately controllable using pragma @code{Assertion_Policy}.
8326 @node Aspect Invariant'Class
8327 @unnumberedsec Aspect Invariant'Class
8328 @findex Invariant'Class
8329 @noindent
8330 This aspect is equivalent to pragma @code{Type_Invariant_Class}. It is a
8331 synonym for the language defined aspect @code{Type_Invariant'Class} except
8332 that it is separately controllable using pragma @code{Assertion_Policy}.
8334 @node Aspect Iterable
8335 @unnumberedsec Aspect Iterable
8336 @findex Iterable
8337 @noindent
8338 This aspect is used in the GNAT-defined formal container packages, to provide
8339 a light-weight mechanism for loops over such containers, without the overhead
8340 imposed by the tampering checks of standard Ada2012 iterators. The value of the
8341 aspect is a aggregate with four named  components: First, Next, Has_Element,
8342 and Element. The following is a typical example of use:
8344 @smallexample @c ada
8345 type List is private with
8346     Iterable => (First        => First_Element,
8347                  Next         => Advance,
8348                  Has_Element  => Get_Element,
8349                  Element      => List_Element);
8350 @end smallexample
8351 @itemize @bullet
8352 @item The value denoted by @code{First} must denote a primitive operation of
8353 the  container type that returns a Cursor, which must a be a type declared in
8354 the container package.
8355 @item The value of @code{Next} is a primitive operation of the container type
8356 that takes a cursor and yields a cursor.
8357 @item @code{Has_Element} is an operation that applies to a cursor a yields an
8358 element of the container.
8359 @item @code{Element} is the type of the elements of the container type, and
8360 thus the result of the function denoted by Has_Element.
8361 @end itemize
8363 @node Aspect Linker_Section
8364 @unnumberedsec Aspect Linker_Section
8365 @findex Linker_Section
8366 @noindent
8367 This aspect is equivalent to an @code{Linker_Section} pragma.
8369 @node Aspect Lock_Free
8370 @unnumberedsec Aspect Lock_Free
8371 @findex Lock_Free
8372 @noindent
8373 This aspect is equivalent to pragma @code{Lock_Free}.
8375 @node Aspect No_Elaboration_Code_All
8376 @unnumberedsec Aspect No_Elaboration_Code_All
8377 @findex No_Elaboration_Code_All
8378 @noindent
8379 This aspect is equivalent to a @code{pragma No_Elaboration_Code_All}
8380 statement for a program unit.
8382 @node Aspect Object_Size
8383 @unnumberedsec Aspect Object_Size
8384 @findex Object_Size
8385 @noindent
8386 This aspect is equivalent to an @code{Object_Size} attribute definition
8387 clause.
8389 @node Aspect Obsolescent
8390 @unnumberedsec Aspect Obsolescent
8391 @findex Obsolsecent
8392 @noindent
8393 This aspect is equivalent to an @code{Obsolescent} pragma. Note that the
8394 evaluation of this aspect happens at the point of occurrence, it is not
8395 delayed until the freeze point.
8397 @node Aspect Part_Of
8398 @unnumberedsec Aspect Part_Of
8399 @findex Part_Of
8400 @noindent
8401 This aspect is equivalent to pragma @code{Part_Of}.
8403 @node Aspect Persistent_BSS
8404 @unnumberedsec Aspect Persistent_BSS
8405 @findex Persistent_BSS
8406 @noindent
8407 This aspect is equivalent to pragma @code{Persistent_BSS}.
8409 @node Aspect Predicate
8410 @unnumberedsec Aspect Predicate
8411 @findex Predicate
8412 @noindent
8413 This aspect is equivalent to pragma @code{Predicate}. It is thus
8414 similar to the language defined aspects @code{Dynamic_Predicate}
8415 and @code{Static_Predicate} except that whether the resulting
8416 predicate is static or dynamic is controlled by the form of the
8417 expression. It is also separately controllable using pragma
8418 @code{Assertion_Policy}.
8420 @node Aspect Pure_Function
8421 @unnumberedsec Aspect Pure_Function
8422 @findex Pure_Function
8423 @noindent
8424 This aspect is equivalent to pragma @code{Pure_Function}.
8426 @node Aspect Refined_Depends
8427 @unnumberedsec Aspect Refined_Depends
8428 @findex Refined_Depends
8429 @noindent
8430 This aspect is equivalent to pragma @code{Refined_Depends}.
8432 @node Aspect Refined_Global
8433 @unnumberedsec Aspect Refined_Global
8434 @findex Refined_Global
8435 @noindent
8436 This aspect is equivalent to pragma @code{Refined_Global}.
8438 @node Aspect Refined_Post
8439 @unnumberedsec Aspect Refined_Post
8440 @findex Refined_Post
8441 @noindent
8442 This aspect is equivalent to pragma @code{Refined_Post}.
8444 @node Aspect Refined_State
8445 @unnumberedsec Aspect Refined_State
8446 @findex Refined_State
8447 @noindent
8448 This aspect is equivalent to pragma @code{Refined_State}.
8450 @node Aspect Remote_Access_Type
8451 @unnumberedsec Aspect Remote_Access_Type
8452 @findex Remote_Access_Type
8453 @noindent
8454 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8456 @node Aspect Scalar_Storage_Order
8457 @unnumberedsec Aspect Scalar_Storage_Order
8458 @findex Scalar_Storage_Order
8459 @noindent
8460 This aspect is equivalent to a @code{Scalar_Storage_Order}
8461 attribute definition clause.
8463 @node Aspect Shared
8464 @unnumberedsec Aspect Shared
8465 @findex Shared
8466 @noindent
8467 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8468 for aspect @code{Atomic}.
8470 @node Aspect Simple_Storage_Pool
8471 @unnumberedsec Aspect Simple_Storage_Pool
8472 @findex Simple_Storage_Pool
8473 @noindent
8474 This aspect is equivalent to a @code{Simple_Storage_Pool}
8475 attribute definition clause.
8477 @node Aspect Simple_Storage_Pool_Type
8478 @unnumberedsec Aspect Simple_Storage_Pool_Type
8479 @findex Simple_Storage_Pool_Type
8480 @noindent
8481 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8483 @node Aspect SPARK_Mode
8484 @unnumberedsec Aspect SPARK_Mode
8485 @findex SPARK_Mode
8486 @noindent
8487 This aspect is equivalent to pragma @code{SPARK_Mode} and
8488 may be specified for either or both of the specification and body
8489 of a subprogram or package.
8491 @node Aspect Suppress_Debug_Info
8492 @unnumberedsec Aspect Suppress_Debug_Info
8493 @findex Suppress_Debug_Info
8494 @noindent
8495 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8497 @node Aspect Test_Case
8498 @unnumberedsec Aspect Test_Case
8499 @findex Test_Case
8500 @noindent
8501 This aspect is equivalent to pragma @code{Test_Case}.
8503 @node Aspect Thread_Local_Storage
8504 @unnumberedsec Aspect Thread_Local_Storage
8505 @findex Thread_Local_Storage
8506 @noindent
8507 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8509 @node Aspect Universal_Aliasing
8510 @unnumberedsec Aspect Universal_Aliasing
8511 @findex Universal_Aliasing
8512 @noindent
8513 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8515 @node Aspect Universal_Data
8516 @unnumberedsec Aspect Universal_Data
8517 @findex Universal_Data
8518 @noindent
8519 This aspect is equivalent to pragma @code{Universal_Data}.
8521 @node Aspect Unmodified
8522 @unnumberedsec Aspect Unmodified
8523 @findex Unmodified
8524 @noindent
8525 This aspect is equivalent to pragma @code{Unmodified}.
8527 @node Aspect Unreferenced
8528 @unnumberedsec Aspect Unreferenced
8529 @findex Unreferenced
8530 @noindent
8531 This aspect is equivalent to pragma @code{Unreferenced}.
8533 @node Aspect Unreferenced_Objects
8534 @unnumberedsec Aspect Unreferenced_Objects
8535 @findex Unreferenced_Objects
8536 @noindent
8537 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8539 @node Aspect Value_Size
8540 @unnumberedsec Aspect Value_Size
8541 @findex Value_Size
8542 @noindent
8543 This aspect is equivalent to a @code{Value_Size}
8544 attribute definition clause.
8546 @node Aspect Warnings
8547 @unnumberedsec Aspect Warnings
8548 @findex Warnings
8549 @noindent
8550 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8551 where the first argument is @code{ON} or @code{OFF} and the second argument
8552 is the entity.
8555 @node Implementation Defined Attributes
8556 @chapter Implementation Defined Attributes
8557 Ada defines (throughout the Ada reference manual,
8558 summarized in Annex K),
8559 a set of attributes that provide useful additional functionality in all
8560 areas of the language.  These language defined attributes are implemented
8561 in GNAT and work as described in the Ada Reference Manual.
8563 In addition, Ada allows implementations to define additional
8564 attributes whose meaning is defined by the implementation.  GNAT provides
8565 a number of these implementation-dependent attributes which can be used
8566 to extend and enhance the functionality of the compiler.  This section of
8567 the GNAT reference manual describes these additional attributes.  It also
8568 describes additional implementation-dependent features of standard
8569 language-defined attributes.
8571 Note that any program using these attributes may not be portable to
8572 other compilers (although GNAT implements this set of attributes on all
8573 platforms).  Therefore if portability to other compilers is an important
8574 consideration, you should minimize the use of these attributes.
8576 @menu
8577 * Attribute Abort_Signal::
8578 * Attribute Address_Size::
8579 * Attribute Asm_Input::
8580 * Attribute Asm_Output::
8581 * Attribute AST_Entry::
8582 * Attribute Atomic_Always_Lock_Free::
8583 * Attribute Bit::
8584 * Attribute Bit_Position::
8585 * Attribute Code_Address::
8586 * Attribute Compiler_Version::
8587 * Attribute Constrained::
8588 * Attribute Default_Bit_Order::
8589 * Attribute Default_Scalar_Storage_Order::
8590 * Attribute Descriptor_Size::
8591 * Attribute Elaborated::
8592 * Attribute Elab_Body::
8593 * Attribute Elab_Spec::
8594 * Attribute Elab_Subp_Body::
8595 * Attribute Emax::
8596 * Attribute Enabled::
8597 * Attribute Enum_Rep::
8598 * Attribute Enum_Val::
8599 * Attribute Epsilon::
8600 * Attribute Fast_Math::
8601 * Attribute Fixed_Value::
8602 * Attribute From_Any::
8603 * Attribute Has_Access_Values::
8604 * Attribute Has_Discriminants::
8605 * Attribute Img::
8606 * Attribute Integer_Value::
8607 * Attribute Invalid_Value::
8608 * Attribute Iterable::
8609 * Attribute Large::
8610 * Attribute Library_Level::
8611 * Attribute Lock_Free::
8612 * Attribute Loop_Entry::
8613 * Attribute Machine_Size::
8614 * Attribute Mantissa::
8615 * Attribute Maximum_Alignment::
8616 * Attribute Mechanism_Code::
8617 * Attribute Null_Parameter::
8618 * Attribute Object_Size::
8619 * Attribute Old::
8620 * Attribute Passed_By_Reference::
8621 * Attribute Pool_Address::
8622 * Attribute Range_Length::
8623 * Attribute Ref::
8624 * Attribute Restriction_Set::
8625 * Attribute Result::
8626 * Attribute Safe_Emax::
8627 * Attribute Safe_Large::
8628 * Attribute Safe_Small::
8629 * Attribute Scalar_Storage_Order::
8630 * Attribute Simple_Storage_Pool::
8631 * Attribute Small::
8632 * Attribute Storage_Unit::
8633 * Attribute Stub_Type::
8634 * Attribute System_Allocator_Alignment::
8635 * Attribute Target_Name::
8636 * Attribute To_Address::
8637 * Attribute To_Any::
8638 * Attribute Type_Class::
8639 * Attribute Type_Key::
8640 * Attribute TypeCode::
8641 * Attribute UET_Address::
8642 * Attribute Unconstrained_Array::
8643 * Attribute Universal_Literal_String::
8644 * Attribute Unrestricted_Access::
8645 * Attribute Update::
8646 * Attribute VADS_Size::
8647 * Attribute Valid_Scalars::
8648 * Attribute Value_Size::
8649 * Attribute Wchar_T_Size::
8650 * Attribute Word_Size::
8651 @end menu
8653 @node Attribute Abort_Signal
8654 @unnumberedsec Attribute Abort_Signal
8655 @findex Abort_Signal
8656 @noindent
8657 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8658 prefix) provides the entity for the special exception used to signal
8659 task abort or asynchronous transfer of control.  Normally this attribute
8660 should only be used in the tasking runtime (it is highly peculiar, and
8661 completely outside the normal semantics of Ada, for a user program to
8662 intercept the abort exception).
8664 @node Attribute Address_Size
8665 @unnumberedsec Attribute Address_Size
8666 @cindex Size of @code{Address}
8667 @findex Address_Size
8668 @noindent
8669 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8670 prefix) is a static constant giving the number of bits in an
8671 @code{Address}. It is the same value as System.Address'Size,
8672 but has the advantage of being static, while a direct
8673 reference to System.Address'Size is non-static because Address
8674 is a private type.
8676 @node Attribute Asm_Input
8677 @unnumberedsec Attribute Asm_Input
8678 @findex Asm_Input
8679 @noindent
8680 The @code{Asm_Input} attribute denotes a function that takes two
8681 parameters.  The first is a string, the second is an expression of the
8682 type designated by the prefix.  The first (string) argument is required
8683 to be a static expression, and is the constraint for the parameter,
8684 (e.g.@: what kind of register is required).  The second argument is the
8685 value to be used as the input argument.  The possible values for the
8686 constant are the same as those used in the RTL, and are dependent on
8687 the configuration file used to built the GCC back end.
8688 @ref{Machine Code Insertions}
8690 @node Attribute Asm_Output
8691 @unnumberedsec Attribute Asm_Output
8692 @findex Asm_Output
8693 @noindent
8694 The @code{Asm_Output} attribute denotes a function that takes two
8695 parameters.  The first is a string, the second is the name of a variable
8696 of the type designated by the attribute prefix.  The first (string)
8697 argument is required to be a static expression and designates the
8698 constraint for the parameter (e.g.@: what kind of register is
8699 required).  The second argument is the variable to be updated with the
8700 result.  The possible values for constraint are the same as those used in
8701 the RTL, and are dependent on the configuration file used to build the
8702 GCC back end.  If there are no output operands, then this argument may
8703 either be omitted, or explicitly given as @code{No_Output_Operands}.
8704 @ref{Machine Code Insertions}
8706 @node Attribute AST_Entry
8707 @unnumberedsec Attribute AST_Entry
8708 @cindex OpenVMS
8709 @findex AST_Entry
8710 @noindent
8711 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
8712 the name of an entry, it yields a value of the predefined type AST_Handler
8713 (declared in the predefined package System, as extended by the use of
8714 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
8715 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
8716 Language Reference Manual}, section 9.12a.
8718 @node Attribute Atomic_Always_Lock_Free
8719 @unnumberedsec Attribute Atomic_Always_Lock_Free
8720 @findex Atomic_Always_Lock_Free
8721 @noindent
8723 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
8724 The result is a Boolean value which is True if the type has discriminants,
8725 and False otherwise.  The result indicate whether atomic operations are
8726 supported by the target for the given type.
8728 @node Attribute Bit
8729 @unnumberedsec Attribute Bit
8730 @findex Bit
8731 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8732 offset within the storage unit (byte) that contains the first bit of
8733 storage allocated for the object.  The value of this attribute is of the
8734 type @code{Universal_Integer}, and is always a non-negative number not
8735 exceeding the value of @code{System.Storage_Unit}.
8737 For an object that is a variable or a constant allocated in a register,
8738 the value is zero.  (The use of this attribute does not force the
8739 allocation of a variable to memory).
8741 For an object that is a formal parameter, this attribute applies
8742 to either the matching actual parameter or to a copy of the
8743 matching actual parameter.
8745 For an access object the value is zero.  Note that
8746 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8747 designated object.  Similarly for a record component
8748 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8749 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8750 are subject to index checks.
8752 This attribute is designed to be compatible with the DEC Ada 83 definition
8753 and implementation of the @code{Bit} attribute.
8755 @node Attribute Bit_Position
8756 @unnumberedsec Attribute Bit_Position
8757 @findex Bit_Position
8758 @noindent
8759 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8760 of the fields of the record type, yields the bit
8761 offset within the record contains the first bit of
8762 storage allocated for the object.  The value of this attribute is of the
8763 type @code{Universal_Integer}.  The value depends only on the field
8764 @var{C} and is independent of the alignment of
8765 the containing record @var{R}.
8767 @node Attribute Code_Address
8768 @unnumberedsec Attribute Code_Address
8769 @findex Code_Address
8770 @cindex Subprogram address
8771 @cindex Address of subprogram code
8772 @noindent
8773 The @code{'Address}
8774 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8775 intended effect seems to be to provide
8776 an address value which can be used to call the subprogram by means of
8777 an address clause as in the following example:
8779 @smallexample @c ada
8780 procedure K is @dots{}
8782 procedure L;
8783 for L'Address use K'Address;
8784 pragma Import (Ada, L);
8785 @end smallexample
8787 @noindent
8788 A call to @code{L} is then expected to result in a call to @code{K}@.
8789 In Ada 83, where there were no access-to-subprogram values, this was
8790 a common work-around for getting the effect of an indirect call.
8791 GNAT implements the above use of @code{Address} and the technique
8792 illustrated by the example code works correctly.
8794 However, for some purposes, it is useful to have the address of the start
8795 of the generated code for the subprogram.  On some architectures, this is
8796 not necessarily the same as the @code{Address} value described above.
8797 For example, the @code{Address} value may reference a subprogram
8798 descriptor rather than the subprogram itself.
8800 The @code{'Code_Address} attribute, which can only be applied to
8801 subprogram entities, always returns the address of the start of the
8802 generated code of the specified subprogram, which may or may not be
8803 the same value as is returned by the corresponding @code{'Address}
8804 attribute.
8806 @node Attribute Compiler_Version
8807 @unnumberedsec Attribute Compiler_Version
8808 @findex Compiler_Version
8809 @noindent
8810 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8811 prefix) yields a static string identifying the version of the compiler
8812 being used to compile the unit containing the attribute reference. A
8813 typical result would be something like
8814 "@value{EDITION} @value{gnat_version} (20090221)".
8816 @node Attribute Constrained
8817 @unnumberedsec Attribute Constrained
8818 @findex Constrained
8819 @noindent
8820 In addition to the usage of this attribute in the Ada RM, @code{GNAT}
8821 also permits the use of the @code{'Constrained} attribute
8822 in a generic template
8823 for any type, including types without discriminants. The value of this
8824 attribute in the generic instance when applied to a scalar type or a
8825 record type without discriminants is always @code{True}. This usage is
8826 compatible with older Ada compilers, including notably DEC Ada.
8828 @node Attribute Default_Bit_Order
8829 @unnumberedsec Attribute Default_Bit_Order
8830 @cindex Big endian
8831 @cindex Little endian
8832 @findex Default_Bit_Order
8833 @noindent
8834 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8835 permissible prefix), provides the value @code{System.Default_Bit_Order}
8836 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8837 @code{Low_Order_First}).  This is used to construct the definition of
8838 @code{Default_Bit_Order} in package @code{System}.
8840 @node Attribute Default_Scalar_Storage_Order
8841 @unnumberedsec Attribute Default_Scalar_Storage_Order
8842 @cindex Big endian
8843 @cindex Little endian
8844 @findex Default_Scalar_Storage_Order
8845 @noindent
8846 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
8847 permissible prefix), provides the current value of the default scalar storage
8848 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
8849 equal to @code{Default_Bit_Order} if unspecified) as a
8850 @code{System.Bit_Order} value. This is a static attribute.
8852 @node Attribute Descriptor_Size
8853 @unnumberedsec Attribute Descriptor_Size
8854 @cindex Descriptor
8855 @cindex Dope vector
8856 @findex Descriptor_Size
8857 @noindent
8858 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8859 descriptor allocated for a type.  The result is non-zero only for unconstrained
8860 array types and the returned value is of type universal integer.  In GNAT, an
8861 array descriptor contains bounds information and is located immediately before
8862 the first element of the array.
8864 @smallexample @c ada
8865 type Unconstr_Array is array (Positive range <>) of Boolean;
8866 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8867 @end smallexample
8869 @noindent
8870 The attribute takes into account any additional padding due to type alignment.
8871 In the example above, the descriptor contains two values of type
8872 @code{Positive} representing the low and high bound.  Since @code{Positive} has
8873 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8874 Positive'Size + 2} or 64 bits.
8876 @node Attribute Elaborated
8877 @unnumberedsec Attribute Elaborated
8878 @findex Elaborated
8879 @noindent
8880 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
8881 value is a Boolean which indicates whether or not the given unit has been
8882 elaborated.  This attribute is primarily intended for internal use by the
8883 generated code for dynamic elaboration checking, but it can also be used
8884 in user programs.  The value will always be True once elaboration of all
8885 units has been completed.  An exception is for units which need no
8886 elaboration, the value is always False for such units.
8888 @node Attribute Elab_Body
8889 @unnumberedsec Attribute Elab_Body
8890 @findex Elab_Body
8891 @noindent
8892 This attribute can only be applied to a program unit name.  It returns
8893 the entity for the corresponding elaboration procedure for elaborating
8894 the body of the referenced unit.  This is used in the main generated
8895 elaboration procedure by the binder and is not normally used in any
8896 other context.  However, there may be specialized situations in which it
8897 is useful to be able to call this elaboration procedure from Ada code,
8898 e.g.@: if it is necessary to do selective re-elaboration to fix some
8899 error.
8901 @node Attribute Elab_Spec
8902 @unnumberedsec Attribute Elab_Spec
8903 @findex Elab_Spec
8904 @noindent
8905 This attribute can only be applied to a program unit name.  It returns
8906 the entity for the corresponding elaboration procedure for elaborating
8907 the spec of the referenced unit.  This is used in the main
8908 generated elaboration procedure by the binder and is not normally used
8909 in any other context.  However, there may be specialized situations in
8910 which it is useful to be able to call this elaboration procedure from
8911 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8912 some error.
8914 @node Attribute Elab_Subp_Body
8915 @unnumberedsec Attribute Elab_Subp_Body
8916 @findex Elab_Subp_Body
8917 @noindent
8918 This attribute can only be applied to a library level subprogram
8919 name and is only allowed in CodePeer mode. It returns the entity
8920 for the corresponding elaboration procedure for elaborating the body
8921 of the referenced subprogram unit. This is used in the main generated
8922 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8923 otherwise.
8925 @node Attribute Emax
8926 @unnumberedsec Attribute Emax
8927 @cindex Ada 83 attributes
8928 @findex Emax
8929 @noindent
8930 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
8931 the Ada 83 reference manual for an exact description of the semantics of
8932 this attribute.
8934 @node Attribute Enabled
8935 @unnumberedsec Attribute Enabled
8936 @findex Enabled
8937 @noindent
8938 The @code{Enabled} attribute allows an application program to check at compile
8939 time to see if the designated check is currently enabled. The prefix is a
8940 simple identifier, referencing any predefined check name (other than
8941 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8942 no argument is given for the attribute, the check is for the general state
8943 of the check, if an argument is given, then it is an entity name, and the
8944 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8945 given naming the entity (if not, then the argument is ignored).
8947 Note that instantiations inherit the check status at the point of the
8948 instantiation, so a useful idiom is to have a library package that
8949 introduces a check name with @code{pragma Check_Name}, and then contains
8950 generic packages or subprograms which use the @code{Enabled} attribute
8951 to see if the check is enabled. A user of this package can then issue
8952 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8953 the package or subprogram, controlling whether the check will be present.
8955 @node Attribute Enum_Rep
8956 @unnumberedsec Attribute Enum_Rep
8957 @cindex Representation of enums
8958 @findex Enum_Rep
8959 @noindent
8960 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8961 function with the following spec:
8963 @smallexample @c ada
8964 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8965   return @i{Universal_Integer};
8966 @end smallexample
8968 @noindent
8969 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8970 enumeration type or to a non-overloaded enumeration
8971 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
8972 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8973 enumeration literal or object.
8975 The function returns the representation value for the given enumeration
8976 value.  This will be equal to value of the @code{Pos} attribute in the
8977 absence of an enumeration representation clause.  This is a static
8978 attribute (i.e.@: the result is static if the argument is static).
8980 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8981 in which case it simply returns the integer value.  The reason for this
8982 is to allow it to be used for @code{(<>)} discrete formal arguments in
8983 a generic unit that can be instantiated with either enumeration types
8984 or integer types.  Note that if @code{Enum_Rep} is used on a modular
8985 type whose upper bound exceeds the upper bound of the largest signed
8986 integer type, and the argument is a variable, so that the universal
8987 integer calculation is done at run time, then the call to @code{Enum_Rep}
8988 may raise @code{Constraint_Error}.
8990 @node Attribute Enum_Val
8991 @unnumberedsec Attribute Enum_Val
8992 @cindex Representation of enums
8993 @findex Enum_Val
8994 @noindent
8995 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8996 function with the following spec:
8998 @smallexample @c ada
8999 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
9000   return @var{S}'Base};
9001 @end smallexample
9003 @noindent
9004 The function returns the enumeration value whose representation matches the
9005 argument, or raises Constraint_Error if no enumeration literal of the type
9006 has the matching value.
9007 This will be equal to value of the @code{Val} attribute in the
9008 absence of an enumeration representation clause.  This is a static
9009 attribute (i.e.@: the result is static if the argument is static).
9011 @node Attribute Epsilon
9012 @unnumberedsec Attribute Epsilon
9013 @cindex Ada 83 attributes
9014 @findex Epsilon
9015 @noindent
9016 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
9017 the Ada 83 reference manual for an exact description of the semantics of
9018 this attribute.
9020 @node Attribute Fast_Math
9021 @unnumberedsec Attribute Fast_Math
9022 @findex Fast_Math
9023 @noindent
9024 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
9025 prefix) yields a static Boolean value that is True if pragma
9026 @code{Fast_Math} is active, and False otherwise.
9028 @node Attribute Fixed_Value
9029 @unnumberedsec Attribute Fixed_Value
9030 @findex Fixed_Value
9031 @noindent
9032 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
9033 function with the following specification:
9035 @smallexample @c ada
9036 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
9037   return @var{S};
9038 @end smallexample
9040 @noindent
9041 The value returned is the fixed-point value @var{V} such that
9043 @smallexample @c ada
9044 @var{V} = Arg * @var{S}'Small
9045 @end smallexample
9047 @noindent
9048 The effect is thus similar to first converting the argument to the
9049 integer type used to represent @var{S}, and then doing an unchecked
9050 conversion to the fixed-point type.  The difference is
9051 that there are full range checks, to ensure that the result is in range.
9052 This attribute is primarily intended for use in implementation of the
9053 input-output functions for fixed-point values.
9055 @node Attribute From_Any
9056 @unnumberedsec Attribute From_Any
9057 @findex From_Any
9058 @noindent
9059 This internal attribute is used for the generation of remote subprogram
9060 stubs in the context of the Distributed Systems Annex.
9062 @node Attribute Has_Access_Values
9063 @unnumberedsec Attribute Has_Access_Values
9064 @cindex Access values, testing for
9065 @findex Has_Access_Values
9066 @noindent
9067 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
9068 is a Boolean value which is True if the is an access type, or is a composite
9069 type with a component (at any nesting depth) that is an access type, and is
9070 False otherwise.
9071 The intended use of this attribute is in conjunction with generic
9072 definitions.  If the attribute is applied to a generic private type, it
9073 indicates whether or not the corresponding actual type has access values.
9075 @node Attribute Has_Discriminants
9076 @unnumberedsec Attribute Has_Discriminants
9077 @cindex Discriminants, testing for
9078 @findex Has_Discriminants
9079 @noindent
9080 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
9081 is a Boolean value which is True if the type has discriminants, and False
9082 otherwise.  The intended use of this attribute is in conjunction with generic
9083 definitions.  If the attribute is applied to a generic private type, it
9084 indicates whether or not the corresponding actual type has discriminants.
9086 @node Attribute Img
9087 @unnumberedsec Attribute Img
9088 @findex Img
9089 @noindent
9090 The @code{Img} attribute differs from @code{Image} in that it is applied
9091 directly to an object, and yields the same result as
9092 @code{Image} for the subtype of the object.  This is convenient for
9093 debugging:
9095 @smallexample @c ada
9096 Put_Line ("X = " & X'Img);
9097 @end smallexample
9099 @noindent
9100 has the same meaning as the more verbose:
9102 @smallexample @c ada
9103 Put_Line ("X = " & @var{T}'Image (X));
9104 @end smallexample
9106 @noindent
9107 where @var{T} is the (sub)type of the object @code{X}.
9109 Note that technically, in analogy to @code{Image},
9110 @code{X'Img} returns a parameterless function
9111 that returns the appropriate string when called. This means that
9112 @code{X'Img} can be renamed as a function-returning-string, or used
9113 in an instantiation as a function parameter.
9115 @node Attribute Integer_Value
9116 @unnumberedsec Attribute Integer_Value
9117 @findex Integer_Value
9118 @noindent
9119 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
9120 function with the following spec:
9122 @smallexample @c ada
9123 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
9124   return @var{S};
9125 @end smallexample
9127 @noindent
9128 The value returned is the integer value @var{V}, such that
9130 @smallexample @c ada
9131 Arg = @var{V} * @var{T}'Small
9132 @end smallexample
9134 @noindent
9135 where @var{T} is the type of @code{Arg}.
9136 The effect is thus similar to first doing an unchecked conversion from
9137 the fixed-point type to its corresponding implementation type, and then
9138 converting the result to the target integer type.  The difference is
9139 that there are full range checks, to ensure that the result is in range.
9140 This attribute is primarily intended for use in implementation of the
9141 standard input-output functions for fixed-point values.
9143 @node Attribute Invalid_Value
9144 @unnumberedsec Attribute Invalid_Value
9145 @findex Invalid_Value
9146 @noindent
9147 For every scalar type S, S'Invalid_Value returns an undefined value of the
9148 type. If possible this value is an invalid representation for the type. The
9149 value returned is identical to the value used to initialize an otherwise
9150 uninitialized value of the type if pragma Initialize_Scalars is used,
9151 including the ability to modify the value with the binder -Sxx flag and
9152 relevant environment variables at run time.
9154 @node Attribute Iterable
9155 @unnumberedsec Attribute Iterable
9156 @findex Iterable
9157 @noindent
9158 Equivalent to Aspect Iterable.
9160 @node Attribute Large
9161 @unnumberedsec Attribute Large
9162 @cindex Ada 83 attributes
9163 @findex Large
9164 @noindent
9165 The @code{Large} attribute is provided for compatibility with Ada 83.  See
9166 the Ada 83 reference manual for an exact description of the semantics of
9167 this attribute.
9169 @node Attribute Library_Level
9170 @unnumberedsec Attribute Library_Level
9171 @findex Library_Level
9172 @noindent
9173 @noindent
9174 @code{P'Library_Level}, where P is an entity name,
9175 returns a Boolean value which is True if the entity is declared
9176 at the library level, and False otherwise. Note that within a
9177 generic instantition, the name of the generic unit denotes the
9178 instance, which means that this attribute can be used to test
9179 if a generic is instantiated at the library level, as shown
9180 in this example:
9182 @smallexample @c ada
9183 generic
9184   ...
9185 package Gen is
9186   pragma Compile_Time_Error
9187     (not Gen'Library_Level,
9188      "Gen can only be instantiated at library level");
9189   ...
9190 end Gen;
9191 @end smallexample
9193 @node Attribute Lock_Free
9194 @unnumberedsec Attribute Lock_Free
9195 @findex Lock_Free
9196 @noindent
9197 @code{P'Lock_Free}, where P is a protected object, returns True if a
9198 pragma @code{Lock_Free} applies to P.
9200 @node Attribute Loop_Entry
9201 @unnumberedsec Attribute Loop_Entry
9202 @findex Loop_Entry
9203 @noindent
9204 Syntax:
9206 @smallexample @c ada
9207 X'Loop_Entry [(loop_name)]
9208 @end smallexample
9210 @noindent
9211 The @code{Loop_Entry} attribute is used to refer to the value that an
9212 expression had upon entry to a given loop in much the same way that the
9213 @code{Old} attribute in a subprogram postcondition can be used to refer
9214 to the value an expression had upon entry to the subprogram. The
9215 relevant loop is either identified by the given loop name, or it is the
9216 innermost enclosing loop when no loop name is given.
9218 @noindent
9219 A @code{Loop_Entry} attribute can only occur within a
9220 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
9221 @code{Loop_Entry} is to compare the current value of objects with their
9222 initial value at loop entry, in a @code{Loop_Invariant} pragma.
9224 @noindent
9225 The effect of using @code{X'Loop_Entry} is the same as declaring
9226 a constant initialized with the initial value of @code{X} at loop
9227 entry. This copy is not performed if the loop is not entered, or if the
9228 corresponding pragmas are ignored or disabled.
9230 @node Attribute Machine_Size
9231 @unnumberedsec Attribute Machine_Size
9232 @findex Machine_Size
9233 @noindent
9234 This attribute is identical to the @code{Object_Size} attribute.  It is
9235 provided for compatibility with the DEC Ada 83 attribute of this name.
9237 @node Attribute Mantissa
9238 @unnumberedsec Attribute Mantissa
9239 @cindex Ada 83 attributes
9240 @findex Mantissa
9241 @noindent
9242 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
9243 the Ada 83 reference manual for an exact description of the semantics of
9244 this attribute.
9246 @node Attribute Maximum_Alignment
9247 @unnumberedsec Attribute Maximum_Alignment
9248 @cindex Alignment, maximum
9249 @findex Maximum_Alignment
9250 @noindent
9251 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
9252 permissible prefix) provides the maximum useful alignment value for the
9253 target.  This is a static value that can be used to specify the alignment
9254 for an object, guaranteeing that it is properly aligned in all
9255 cases.
9257 @node Attribute Mechanism_Code
9258 @unnumberedsec Attribute Mechanism_Code
9259 @cindex Return values, passing mechanism
9260 @cindex Parameters, passing mechanism
9261 @findex Mechanism_Code
9262 @noindent
9263 @code{@var{function}'Mechanism_Code} yields an integer code for the
9264 mechanism used for the result of function, and
9265 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
9266 used for formal parameter number @var{n} (a static integer value with 1
9267 meaning the first parameter) of @var{subprogram}.  The code returned is:
9269 @table @asis
9270 @item 1
9271 by copy (value)
9272 @item 2
9273 by reference
9274 @end table
9276 @node Attribute Null_Parameter
9277 @unnumberedsec Attribute Null_Parameter
9278 @cindex Zero address, passing
9279 @findex Null_Parameter
9280 @noindent
9281 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9282 type or subtype @var{T} allocated at machine address zero.  The attribute
9283 is allowed only as the default expression of a formal parameter, or as
9284 an actual expression of a subprogram call.  In either case, the
9285 subprogram must be imported.
9287 The identity of the object is represented by the address zero in the
9288 argument list, independent of the passing mechanism (explicit or
9289 default).
9291 This capability is needed to specify that a zero address should be
9292 passed for a record or other composite object passed by reference.
9293 There is no way of indicating this without the @code{Null_Parameter}
9294 attribute.
9296 @node Attribute Object_Size
9297 @unnumberedsec Attribute Object_Size
9298 @cindex Size, used for objects
9299 @findex Object_Size
9300 @noindent
9301 The size of an object is not necessarily the same as the size of the type
9302 of an object.  This is because by default object sizes are increased to be
9303 a multiple of the alignment of the object.  For example,
9304 @code{Natural'Size} is
9305 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9306 Similarly, a record containing an integer and a character:
9308 @smallexample @c ada
9309 type Rec is record
9310    I : Integer;
9311    C : Character;
9312 end record;
9313 @end smallexample
9315 @noindent
9316 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
9317 alignment will be 4, because of the
9318 integer field, and so the default size of record objects for this type
9319 will be 64 (8 bytes).
9321 If the alignment of the above record is specified to be 1, then the
9322 object size will be 40 (5 bytes). This is true by default, and also
9323 an object size of 40 can be explicitly specified in this case.
9325 A consequence of this capability is that different object sizes can be
9326 given to subtypes that would otherwise be considered in Ada to be
9327 statically matching.  But it makes no sense to consider such subtypes
9328 as statically matching.  Consequently, in @code{GNAT} we add a rule
9329 to the static matching rules that requires object sizes to match.
9330 Consider this example:
9332 @smallexample @c ada
9333  1. procedure BadAVConvert is
9334  2.    type R is new Integer;
9335  3.    subtype R1 is R range 1 .. 10;
9336  4.    subtype R2 is R range 1 .. 10;
9337  5.    for R1'Object_Size use 8;
9338  6.    for R2'Object_Size use 16;
9339  7.    type R1P is access all R1;
9340  8.    type R2P is access all R2;
9341  9.    R1PV : R1P := new R1'(4);
9342 10.    R2PV : R2P;
9343 11. begin
9344 12.    R2PV := R2P (R1PV);
9345                |
9346        >>> target designated subtype not compatible with
9347            type "R1" defined at line 3
9349 13. end;
9350 @end smallexample
9352 @noindent
9353 In the absence of lines 5 and 6,
9354 types @code{R1} and @code{R2} statically match and
9355 hence the conversion on line 12 is legal. But since lines 5 and 6
9356 cause the object sizes to differ, @code{GNAT} considers that types
9357 @code{R1} and @code{R2} are not statically matching, and line 12
9358 generates the diagnostic shown above.
9360 @noindent
9361 Similar additional checks are performed in other contexts requiring
9362 statically matching subtypes.
9364 @node Attribute Old
9365 @unnumberedsec Attribute Old
9366 @findex Old
9367 @noindent
9368 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
9369 within @code{Post} aspect), GNAT also permits the use of this attribute
9370 in implementation defined pragmas @code{Postcondition},
9371 @code{Contract_Cases} and @code{Test_Case}. Also usages of
9372 @code{Old} which would be illegal according to the Ada 2012 RM
9373 definition are allowed under control of
9374 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
9376 @node Attribute Passed_By_Reference
9377 @unnumberedsec Attribute Passed_By_Reference
9378 @cindex Parameters, when passed by reference
9379 @findex Passed_By_Reference
9380 @noindent
9381 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9382 a value of type @code{Boolean} value that is @code{True} if the type is
9383 normally passed by reference and @code{False} if the type is normally
9384 passed by copy in calls.  For scalar types, the result is always @code{False}
9385 and is static.  For non-scalar types, the result is non-static.
9387 @node Attribute Pool_Address
9388 @unnumberedsec Attribute Pool_Address
9389 @cindex Parameters, when passed by reference
9390 @findex Pool_Address
9391 @noindent
9392 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9393 of X within its storage pool. This is the same as
9394 @code{@var{X}'Address}, except that for an unconstrained array whose
9395 bounds are allocated just before the first component,
9396 @code{@var{X}'Pool_Address} returns the address of those bounds,
9397 whereas @code{@var{X}'Address} returns the address of the first
9398 component.
9400 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9401 the object is allocated'', which could be a user-defined storage pool,
9402 the global heap, on the stack, or in a static memory area. For an
9403 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9404 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9406 @node Attribute Range_Length
9407 @unnumberedsec Attribute Range_Length
9408 @findex Range_Length
9409 @noindent
9410 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9411 the number of values represented by the subtype (zero for a null
9412 range).  The result is static for static subtypes.  @code{Range_Length}
9413 applied to the index subtype of a one dimensional array always gives the
9414 same result as @code{Length} applied to the array itself.
9416 @node Attribute Ref
9417 @unnumberedsec Attribute Ref
9418 @findex Ref
9419 @noindent
9422 @node Attribute Restriction_Set
9423 @unnumberedsec Attribute Restriction_Set
9424 @findex Restriction_Set
9425 @cindex Restrictions
9426 @noindent
9427 This attribute allows compile time testing of restrictions that
9428 are currently in effect. It is primarily intended for specializing
9429 code in the run-time based on restrictions that are active (e.g.
9430 don't need to save fpt registers if restriction No_Floating_Point
9431 is known to be in effect), but can be used anywhere.
9433 There are two forms:
9435 @smallexample @c ada
9436 System'Restriction_Set (partition_boolean_restriction_NAME)
9437 System'Restriction_Set (No_Dependence => library_unit_NAME);
9438 @end smallexample
9440 @noindent
9441 In the case of the first form, the only restriction names
9442 allowed are parameterless restrictions that are checked
9443 for consistency at bind time. For a complete list see the
9444 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9446 The result returned is True if the restriction is known to
9447 be in effect, and False if the restriction is known not to
9448 be in effect. An important guarantee is that the value of
9449 a Restriction_Set attribute is known to be consistent throughout
9450 all the code of a partition.
9452 This is trivially achieved if the entire partition is compiled
9453 with a consistent set of restriction pragmas. However, the
9454 compilation model does not require this. It is possible to
9455 compile one set of units with one set of pragmas, and another
9456 set of units with another set of pragmas. It is even possible
9457 to compile a spec with one set of pragmas, and then WITH the
9458 same spec with a different set of pragmas. Inconsistencies
9459 in the actual use of the restriction are checked at bind time.
9461 In order to achieve the guarantee of consistency for the
9462 Restriction_Set pragma, we consider that a use of the pragma
9463 that yields False is equivalent to a violation of the
9464 restriction.
9466 So for example if you write
9468 @smallexample @c ada
9469 if System'Restriction_Set (No_Floating_Point) then
9470    ...
9471 else
9472    ...
9473 end if;
9474 @end smallexample
9476 @noindent
9477 And the result is False, so that the else branch is executed,
9478 you can assume that this restriction is not set for any unit
9479 in the partition. This is checked by considering this use of
9480 the restriction pragma to be a violation of the restriction
9481 No_Floating_Point. This means that no other unit can attempt
9482 to set this restriction (if some unit does attempt to set it,
9483 the binder will refuse to bind the partition).
9485 Technical note: The restriction name and the unit name are
9486 intepreted entirely syntactically, as in the corresponding
9487 Restrictions pragma, they are not analyzed semantically,
9488 so they do not have a type.
9490 @node Attribute Result
9491 @unnumberedsec Attribute Result
9492 @findex Result
9493 @noindent
9494 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9495 for a function. The prefix must be the name of the corresponding function. This
9496 is used to refer to the result of the function in the postcondition expression.
9497 For a further discussion of the use of this attribute and examples of its use,
9498 see the description of pragma Postcondition.
9500 @node Attribute Safe_Emax
9501 @unnumberedsec Attribute Safe_Emax
9502 @cindex Ada 83 attributes
9503 @findex Safe_Emax
9504 @noindent
9505 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
9506 the Ada 83 reference manual for an exact description of the semantics of
9507 this attribute.
9509 @node Attribute Safe_Large
9510 @unnumberedsec Attribute Safe_Large
9511 @cindex Ada 83 attributes
9512 @findex Safe_Large
9513 @noindent
9514 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
9515 the Ada 83 reference manual for an exact description of the semantics of
9516 this attribute.
9518 @node Attribute Safe_Small
9519 @unnumberedsec Attribute Safe_Small
9520 @cindex Ada 83 attributes
9521 @findex Safe_Small
9522 @noindent
9523 The @code{Safe_Small} attribute is provided for compatibility with Ada 83.  See
9524 the Ada 83 reference manual for an exact description of the semantics of
9525 this attribute.
9527 @node Attribute Scalar_Storage_Order
9528 @unnumberedsec Attribute Scalar_Storage_Order
9529 @cindex Endianness
9530 @cindex Scalar storage order
9531 @findex Scalar_Storage_Order
9532 @noindent
9533 For every array or record type @var{S}, the representation attribute
9534 @code{Scalar_Storage_Order} denotes the order in which storage elements
9535 that make up scalar components are ordered within S. The value given must
9536 be a static expression of type System.Bit_Order. The following is an example
9537 of the use of this feature:
9539 @smallexample @c ada
9540    --  Component type definitions
9542    subtype Yr_Type is Natural range 0 .. 127;
9543    subtype Mo_Type is Natural range 1 .. 12;
9544    subtype Da_Type is Natural range 1 .. 31;
9546    --  Record declaration
9548    type Date is record
9549       Years_Since_1980 : Yr_Type;
9550       Month            : Mo_Type;
9551       Day_Of_Month     : Da_Type;
9552    end record;
9554    --  Record representation clause
9556    for Date use record
9557       Years_Since_1980 at 0 range 0  ..  6;
9558       Month            at 0 range 7  .. 10;
9559       Day_Of_Month     at 0 range 11 .. 15;
9560    end record;
9562    --  Attribute definition clauses
9564    for Date'Bit_Order use System.High_Order_First;
9565    for Date'Scalar_Storage_Order use System.High_Order_First;
9566    --  If Scalar_Storage_Order is specified, it must be consistent with
9567    --  Bit_Order, so it's best to always define the latter explicitly if
9568    --  the former is used.
9569 @end smallexample
9571 @noindent
9572 Other properties are as for standard representation attribute @code{Bit_Order},
9573 as defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9575 For a record type @var{T}, if @code{@var{T}'Scalar_Storage_Order} is
9576 specified explicitly, it shall be equal to @code{@var{T}'Bit_Order}. Note:
9577 this means that if a @code{Scalar_Storage_Order} attribute definition
9578 clause is not confirming, then the type's @code{Bit_Order} shall be
9579 specified explicitly and set to the same value.
9581 Derived types inherit an explicitly set scalar storage order from their parent
9582 types. This may be overridden for the derived type by giving an explicit scalar
9583 storage order for the derived type. For a record extension, the derived type
9584 must have the same scalar storage order as the parent type.
9586 If a component of @var{T} is of a record or array type, then that type must
9587 also have a @code{Scalar_Storage_Order} attribute definition clause.
9589 A component of a record or array type that is a packed array, or that
9590 does not start on a byte boundary, must have the same scalar storage order
9591 as the enclosing record or array type.
9593 No component of a type that has an explicit @code{Scalar_Storage_Order}
9594 attribute definition may be aliased.
9596 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9597 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9599 If the opposite storage order is specified, then whenever the value of
9600 a scalar component of an object of type @var{S} is read, the storage
9601 elements of the enclosing machine scalar are first reversed (before
9602 retrieving the component value, possibly applying some shift and mask
9603 operatings on the enclosing machine scalar), and the opposite operation
9604 is done for writes.
9606 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9607 are relaxed. Instead, the following rules apply:
9609 @itemize @bullet
9610 @item the underlying storage elements are those at positions
9611   @code{(position + first_bit / storage_element_size) ..
9612         (position + (last_bit + storage_element_size - 1) /
9613                     storage_element_size)}
9614 @item the sequence of underlying storage elements shall have
9615         a size no greater than the largest machine scalar
9616 @item the enclosing machine scalar is defined as the smallest machine
9617         scalar starting at a position no greater than
9618         @code{position + first_bit / storage_element_size} and covering
9619         storage elements at least up to @code{position + (last_bit +
9620         storage_element_size - 1) / storage_element_size}
9621 @item the position of the component is interpreted relative to that machine
9622  scalar.
9624 @end itemize
9626 If no scalar storage order is specified for a type (either directly, or by
9627 inheritance in the case of a derived type), then the default is normally
9628 the native ordering of the target, but this default can be overridden using
9629 pragma @code{Default_Scalar_Storage_Order}.
9631 @node Attribute Simple_Storage_Pool
9632 @unnumberedsec Attribute Simple_Storage_Pool
9633 @cindex Storage pool, simple
9634 @cindex Simple storage pool
9635 @findex Simple_Storage_Pool
9636 @noindent
9637 For every nonformal, nonderived access-to-object type @var{Acc}, the
9638 representation attribute @code{Simple_Storage_Pool} may be specified
9639 via an attribute_definition_clause (or by specifying the equivalent aspect):
9641 @smallexample @c ada
9643 My_Pool : My_Simple_Storage_Pool_Type;
9645 type Acc is access My_Data_Type;
9647 for Acc'Simple_Storage_Pool use My_Pool;
9649 @end smallexample
9651 @noindent
9652 The name given in an attribute_definition_clause for the
9653 @code{Simple_Storage_Pool} attribute shall denote a variable of
9654 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9656 The use of this attribute is only allowed for a prefix denoting a type
9657 for which it has been specified. The type of the attribute is the type
9658 of the variable specified as the simple storage pool of the access type,
9659 and the attribute denotes that variable.
9661 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9662 for the same access type.
9664 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9665 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9666 with a warning and its evaluation raises the exception @code{Program_Error}.
9668 If the Simple_Storage_Pool attribute has been specified for an access
9669 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9670 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9671 which is intended to indicate the number of storage elements reserved for
9672 the simple storage pool. If the Storage_Size function has not been defined
9673 for the simple storage pool type, then this attribute returns zero.
9675 If an access type @var{S} has a specified simple storage pool of type
9676 @var{SSP}, then the evaluation of an allocator for that access type calls
9677 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9678 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9679 semantics of such allocators is the same as those defined for allocators
9680 in section 13.11 of the Ada Reference Manual, with the term
9681 ``simple storage pool'' substituted for ``storage pool''.
9683 If an access type @var{S} has a specified simple storage pool of type
9684 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9685 for that access type invokes the primitive @code{Deallocate} procedure
9686 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9687 parameter. The detailed semantics of such unchecked deallocations is the same
9688 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9689 term ``simple storage pool'' is substituted for ``storage pool''.
9691 @node Attribute Small
9692 @unnumberedsec Attribute Small
9693 @cindex Ada 83 attributes
9694 @findex Small
9695 @noindent
9696 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9697 fixed-point types.
9698 GNAT also allows this attribute to be applied to floating-point types
9699 for compatibility with Ada 83.  See
9700 the Ada 83 reference manual for an exact description of the semantics of
9701 this attribute when applied to floating-point types.
9703 @node Attribute Storage_Unit
9704 @unnumberedsec Attribute Storage_Unit
9705 @findex Storage_Unit
9706 @noindent
9707 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9708 prefix) provides the same value as @code{System.Storage_Unit}.
9710 @node Attribute Stub_Type
9711 @unnumberedsec Attribute Stub_Type
9712 @findex Stub_Type
9713 @noindent
9714 The GNAT implementation of remote access-to-classwide types is
9715 organized as described in AARM section E.4 (20.t): a value of an RACW type
9716 (designating a remote object) is represented as a normal access
9717 value, pointing to a "stub" object which in turn contains the
9718 necessary information to contact the designated remote object. A
9719 call on any dispatching operation of such a stub object does the
9720 remote call, if necessary, using the information in the stub object
9721 to locate the target partition, etc.
9723 For a prefix @code{T} that denotes a remote access-to-classwide type,
9724 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9726 By construction, the layout of @code{T'Stub_Type} is identical to that of
9727 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9728 unit @code{System.Partition_Interface}. Use of this attribute will create
9729 an implicit dependency on this unit.
9731 @node Attribute System_Allocator_Alignment
9732 @unnumberedsec Attribute System_Allocator_Alignment
9733 @cindex Alignment, allocator
9734 @findex System_Allocator_Alignment
9735 @noindent
9736 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9737 permissible prefix) provides the observable guaranted to be honored by
9738 the system allocator (malloc). This is a static value that can be used
9739 in user storage pools based on malloc either to reject allocation
9740 with alignment too large or to enable a realignment circuitry if the
9741 alignment request is larger than this value.
9743 @node Attribute Target_Name
9744 @unnumberedsec Attribute Target_Name
9745 @findex Target_Name
9746 @noindent
9747 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9748 prefix) provides a static string value that identifies the target
9749 for the current compilation. For GCC implementations, this is the
9750 standard gcc target name without the terminating slash (for
9751 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9753 @node Attribute To_Address
9754 @unnumberedsec Attribute To_Address
9755 @findex To_Address
9756 @noindent
9757 The @code{System'To_Address}
9758 (@code{System} is the only permissible prefix)
9759 denotes a function identical to
9760 @code{System.Storage_Elements.To_Address} except that
9761 it is a static attribute.  This means that if its argument is
9762 a static expression, then the result of the attribute is a
9763 static expression.  This means that such an expression can be
9764 used in contexts (e.g.@: preelaborable packages) which require a
9765 static expression and where the function call could not be used
9766 (since the function call is always non-static, even if its
9767 argument is static). The argument must be in the range
9768 -(2**(m-1) .. 2**m-1, where m is the memory size
9769 (typically 32 or 64). Negative values are intepreted in a
9770 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9771 a 32 bits machine).
9773 @node Attribute To_Any
9774 @unnumberedsec Attribute To_Any
9775 @findex To_Any
9776 @noindent
9777 This internal attribute is used for the generation of remote subprogram
9778 stubs in the context of the Distributed Systems Annex.
9780 @node Attribute Type_Class
9781 @unnumberedsec Attribute Type_Class
9782 @findex Type_Class
9783 @noindent
9784 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9785 the value of the type class for the full type of @var{type}.  If
9786 @var{type} is a generic formal type, the value is the value for the
9787 corresponding actual subtype.  The value of this attribute is of type
9788 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9790 @smallexample @c ada
9791 type Type_Class is
9792   (Type_Class_Enumeration,
9793    Type_Class_Integer,
9794    Type_Class_Fixed_Point,
9795    Type_Class_Floating_Point,
9796    Type_Class_Array,
9797    Type_Class_Record,
9798    Type_Class_Access,
9799    Type_Class_Task,
9800    Type_Class_Address);
9801 @end smallexample
9803 @noindent
9804 Protected types yield the value @code{Type_Class_Task}, which thus
9805 applies to all concurrent types.  This attribute is designed to
9806 be compatible with the DEC Ada 83 attribute of the same name.
9808 @node Attribute Type_Key
9809 @unnumberedsec Attribute Type_Key
9810 @findex Type_Key
9811 @noindent
9812 The @code{Type_Key} attribute is applicable to a type or subtype and
9813 yields a value of type Standard.String containing encoded information
9814 about the type or subtype. This provides improved compatibility with
9815 other implementations that support this attribute.
9817 @node Attribute TypeCode
9818 @unnumberedsec Attribute TypeCode
9819 @findex TypeCode
9820 @noindent
9821 This internal attribute is used for the generation of remote subprogram
9822 stubs in the context of the Distributed Systems Annex.
9824 @node Attribute UET_Address
9825 @unnumberedsec Attribute UET_Address
9826 @findex UET_Address
9827 @noindent
9828 The @code{UET_Address} attribute can only be used for a prefix which
9829 denotes a library package.  It yields the address of the unit exception
9830 table when zero cost exception handling is used.  This attribute is
9831 intended only for use within the GNAT implementation.  See the unit
9832 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9833 for details on how this attribute is used in the implementation.
9835 @node Attribute Unconstrained_Array
9836 @unnumberedsec Attribute Unconstrained_Array
9837 @findex Unconstrained_Array
9838 @noindent
9839 The @code{Unconstrained_Array} attribute can be used with a prefix that
9840 denotes any type or subtype. It is a static attribute that yields
9841 @code{True} if the prefix designates an unconstrained array,
9842 and @code{False} otherwise. In a generic instance, the result is
9843 still static, and yields the result of applying this test to the
9844 generic actual.
9846 @node Attribute Universal_Literal_String
9847 @unnumberedsec Attribute Universal_Literal_String
9848 @cindex Named numbers, representation of
9849 @findex Universal_Literal_String
9850 @noindent
9851 The prefix of @code{Universal_Literal_String} must be a named
9852 number.  The static result is the string consisting of the characters of
9853 the number as defined in the original source.  This allows the user
9854 program to access the actual text of named numbers without intermediate
9855 conversions and without the need to enclose the strings in quotes (which
9856 would preclude their use as numbers).
9858 For example, the following program prints the first 50 digits of pi:
9860 @smallexample @c ada
9861 with Text_IO; use Text_IO;
9862 with Ada.Numerics;
9863 procedure Pi is
9864 begin
9865    Put (Ada.Numerics.Pi'Universal_Literal_String);
9866 end;
9867 @end smallexample
9869 @node Attribute Unrestricted_Access
9870 @unnumberedsec Attribute Unrestricted_Access
9871 @cindex @code{Access}, unrestricted
9872 @findex Unrestricted_Access
9873 @noindent
9874 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9875 except that all accessibility and aliased view checks are omitted.  This
9876 is a user-beware attribute.
9878 For objects, it is similar to @code{Address}, for which it is a
9879 desirable replacement where the value desired is an access type.
9880 In other words, its effect is similar to first applying the
9881 @code{Address} attribute and then doing an unchecked conversion to a
9882 desired access type.
9884 For subprograms, @code{P'Unrestricted_Access} may be used where
9885 @code{P'Access} would be illegal, to construct a value of a
9886 less-nested named access type that designates a more-nested
9887 subprogram. This value may be used in indirect calls, so long as the
9888 more-nested subprogram still exists; once the subprogram containing it
9889 has returned, such calls are erroneous. For example:
9891 @smallexample @c ada
9892 package body P is
9894    type Less_Nested is not null access procedure;
9895    Global : Less_Nested;
9897    procedure P1 is
9898    begin
9899       Global.all;
9900    end P1;
9902    procedure P2 is
9903       Local_Var : Integer;
9905       procedure More_Nested is
9906       begin
9907          ... Local_Var ...
9908       end More_Nested;
9909    begin
9910       Global := More_Nested'Unrestricted_Access;
9911       P1;
9912    end P2;
9914 end P;
9915 @end smallexample
9917 When P1 is called from P2, the call via Global is OK, but if P1 were
9918 called after P2 returns, it would be an erroneous use of a dangling
9919 pointer.
9921 For objects, it is possible to use @code{Unrestricted_Access} for any
9922 type, but care must be exercised if it is used to create pointers to
9923 unconstrained array objects.  In this case, the resulting pointer has
9924 the same scope as the context of the attribute, and may not be
9925 returned to some enclosing scope.  For instance, a function cannot use
9926 @code{Unrestricted_Access} to create a pointer to unconstrained and
9927 then return that value to the caller.  In addition, it is only valid
9928 to create pointers to unconstrained arrays using this attribute if the
9929 pointer has the normal default ``fat'' representation where a pointer
9930 has two components, one points to the array and one points to the
9931 bounds.  If a size clause is used to force ``thin'' representation for
9932 a pointer to unconstrained where there is only space for a single
9933 pointer, then the resulting pointer is not usable.
9935 In the simple case where a direct use of Unrestricted_Access attempts
9936 to make a thin pointer for a non-aliased object, the compiler will
9937 reject the use as illegal, as shown in the following example:
9939 @smallexample @c ada
9940 with System; use System;
9941 procedure SliceUA2 is
9942    type A is access all String;
9943    for A'Size use Standard'Address_Size;
9945    procedure P (Arg : A) is
9946    begin
9947       null;
9948    end P;
9950    X : String := "hello world!";
9951    X2 : aliased String := "hello world!";
9953    AV : A := X'Unrestricted_Access;    -- ERROR
9954              |
9955 >>> illegal use of Unrestricted_Access attribute
9956 >>> attempt to generate thin pointer to unaliased object
9958 begin
9959    P (X'Unrestricted_Access);          -- ERROR
9960       |
9961 >>> illegal use of Unrestricted_Access attribute
9962 >>> attempt to generate thin pointer to unaliased object
9964    P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9965       |
9966 >>> illegal use of Unrestricted_Access attribute
9967 >>> attempt to generate thin pointer to unaliased object
9969    P (X2'Unrestricted_Access);         -- OK
9970 end;
9971 @end smallexample
9973 @noindent
9974 but other cases cannot be detected by the compiler, and are
9975 considered to be erroneous. Consider the following example:
9977 @smallexample @c ada
9978 with System; use System;
9979 with System; use System;
9980 procedure SliceUA is
9981    type AF is access all String;
9983    type A is access all String;
9984    for A'Size use Standard'Address_Size;
9986    procedure P (Arg : A) is
9987    begin
9988       if Arg'Length /= 6 then
9989          raise Program_Error;
9990       end if;
9991    end P;
9993    X : String := "hello world!";
9994    Y : AF := X (7 .. 12)'Unrestricted_Access;
9996 begin
9997    P (A (Y));
9998 end;
9999 @end smallexample
10001 @noindent
10002 A normal unconstrained array value
10003 or a constrained array object marked as aliased has the bounds in memory
10004 just before the array, so a thin pointer can retrieve both the data and
10005 the bounds.  But in this case, the non-aliased object @code{X} does not have the
10006 bounds before the string.  If the size clause for type @code{A}
10007 were not present, then the pointer
10008 would be a fat pointer, where one component is a pointer to the bounds,
10009 and all would be well.  But with the size clause present, the conversion from
10010 fat pointer to thin pointer in the call loses the bounds, and so this
10011 is erroneous, and the program likely raises a @code{Program_Error} exception.
10013 In general, it is advisable to completely
10014 avoid mixing the use of thin pointers and the use of
10015 @code{Unrestricted_Access} where the designated type is an
10016 unconstrained array.  The use of thin pointers should be restricted to
10017 cases of porting legacy code that implicitly assumes the size of pointers,
10018 and such code should not in any case be using this attribute.
10020 Another erroneous situation arises if the attribute is
10021 applied to a constant. The resulting pointer can be used to access the
10022 constant, but the effect of trying to modify a constant in this manner
10023 is not well-defined. Consider this example:
10025 @smallexample @c ada
10026 P : constant Integer := 4;
10027 type R is access all Integer;
10028 RV : R := P'Unrestricted_Access;
10030 RV.all := 3;
10031 @end smallexample
10033 @noindent
10034 Here we attempt to modify the constant P from 4 to 3, but the compiler may
10035 or may not notice this attempt, and subsequent references to P may yield
10036 either the value 3 or the value 4 or the assignment may blow up if the
10037 compiler decides to put P in read-only memory. One particular case where
10038 @code{Unrestricted_Access} can be used in this way is to modify the
10039 value of an @code{IN} parameter:
10041 @smallexample @c ada
10042 procedure K (S : in String) is
10043    type R is access all Character;
10044    RV : R := S (3)'Unrestricted_Access;
10045 begin
10046    RV.all := 'a';
10047 end;
10048 @end smallexample
10050 @noindent
10051 In general this is a risky approach. It may appear to "work" but such uses of
10052 @code{Unrestricted_Access} are potentially non-portable, even from one version
10053 of @code{GNAT} to another, so are best avoided if possible.
10055 @node Attribute Update
10056 @unnumberedsec Attribute Update
10057 @findex Update
10058 @noindent
10059 The @code{Update} attribute creates a copy of an array or record value
10060 with one or more modified components. The syntax is:
10062 @smallexample @c ada
10063 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
10064 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
10065 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
10066                 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
10068 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
10069 INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
10070 INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION @{, EXPRESSION @} )
10071 @end smallexample
10073 @noindent
10074 where @code{PREFIX} is the name of an array or record object, and
10075 the association list in parentheses does not contain an @code{others}
10076 choice. The effect is to yield a copy of the array or record value which
10077 is unchanged apart from the components mentioned in the association list, which
10078 are changed to the indicated value. The original value of the array or
10079 record value is not affected. For example:
10081 @smallexample @c ada
10082 type Arr is Array (1 .. 5) of Integer;
10084 Avar1 : Arr := (1,2,3,4,5);
10085 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
10086 @end smallexample
10088 @noindent
10089 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
10090 begin unmodified. Similarly:
10092 @smallexample @c ada
10093 type Rec is A, B, C : Integer;
10095 Rvar1 : Rec := (A => 1, B => 2, C => 3);
10096 Rvar2 : Rec := Rvar1'Update (B => 20);
10097 @end smallexample
10099 @noindent
10100 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
10101 with @code{Rvar1} being unmodifed.
10102 Note that the value of the attribute reference is computed
10103 completely before it is used. This means that if you write:
10105 @smallexample @c ada
10106 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
10107 @end smallexample
10109 @noindent
10110 then the value of @code{Avar1} is not modified if @code{Function_Call}
10111 raises an exception, unlike the effect of a series of direct assignments
10112 to elements of @code{Avar1}. In general this requires that
10113 two extra complete copies of the object are required, which should be
10114 kept in mind when considering efficiency.
10116 The @code{Update} attribute cannot be applied to prefixes of a limited
10117 type, and cannot reference discriminants in the case of a record type.
10118 The accessibility level of an Update attribute result object is defined
10119 as for an aggregate.
10121 In the record case, no component can be mentioned more than once. In
10122 the array case, two overlapping ranges can appear in the association list,
10123 in which case the modifications are processed left to right.
10125 Multi-dimensional arrays can be modified, as shown by this example:
10127 @smallexample @c ada
10128 A : array (1 .. 10, 1 .. 10) of Integer;
10130 A := A'Update ((1, 2) => 20, (3, 4) => 30);
10131 @end smallexample
10133 @noindent
10134 which changes element (1,2) to 20 and (3,4) to 30.
10136 @node Attribute Valid_Scalars
10137 @unnumberedsec Attribute Valid_Scalars
10138 @findex Valid_Scalars
10139 @noindent
10140 The @code{'Valid_Scalars} attribute is intended to make it easier to
10141 check the validity of scalar subcomponents of composite objects. It
10142 is defined for any prefix @code{X} that denotes an object.
10143 The value of this attribute is of the predefined type Boolean.
10144 @code{X'Valid_Scalars} yields True if and only if evaluation of
10145 @code{P'Valid} yields True for every scalar part P of X or if X has
10146 no scalar parts. It is not specified in what order the scalar parts
10147 are checked, nor whether any more are checked after any one of them
10148 is determined to be invalid. If the prefix @code{X} is of a class-wide
10149 type @code{T'Class} (where @code{T} is the associated specific type),
10150 or if the prefix @code{X} is of a specific tagged type @code{T}, then
10151 only the scalar parts of components of @code{T} are traversed; in other
10152 words, components of extensions of @code{T} are not traversed even if
10153 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
10154 be determined at compile time that the prefix of the attribute has no
10155 scalar parts (e.g., if the prefix is of an access type, an interface type,
10156 an undiscriminated task type, or an undiscriminated protected type).
10158 For scalar types, @code{Valid_Scalars} is equivalent to @code{Valid}. The use
10159 of this attribute is not permitted for @code{Unchecked_Union} types for which
10160 in general it is not possible to determine the values of the discriminants.
10162 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case
10163 of a large variant record. If the attribute is called in many places in the
10164 same program applied to objects of the same type, it can reduce program size
10165 to write a function with a single use of the attribute, and then call that
10166 function from multiple places.
10168 @node Attribute VADS_Size
10169 @unnumberedsec Attribute VADS_Size
10170 @cindex @code{Size}, VADS compatibility
10171 @findex VADS_Size
10172 @noindent
10173 The @code{'VADS_Size} attribute is intended to make it easier to port
10174 legacy code which relies on the semantics of @code{'Size} as implemented
10175 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
10176 same semantic interpretation.  In particular, @code{'VADS_Size} applied
10177 to a predefined or other primitive type with no Size clause yields the
10178 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
10179 typical machines).  In addition @code{'VADS_Size} applied to an object
10180 gives the result that would be obtained by applying the attribute to
10181 the corresponding type.
10183 @node Attribute Value_Size
10184 @unnumberedsec Attribute Value_Size
10185 @cindex @code{Size}, setting for not-first subtype
10186 @findex Value_Size
10187 @code{@var{type}'Value_Size} is the number of bits required to represent
10188 a value of the given subtype.  It is the same as @code{@var{type}'Size},
10189 but, unlike @code{Size}, may be set for non-first subtypes.
10191 @node Attribute Wchar_T_Size
10192 @unnumberedsec Attribute Wchar_T_Size
10193 @findex Wchar_T_Size
10194 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
10195 prefix) provides the size in bits of the C @code{wchar_t} type
10196 primarily for constructing the definition of this type in
10197 package @code{Interfaces.C}. The result is a static constant.
10199 @node Attribute Word_Size
10200 @unnumberedsec Attribute Word_Size
10201 @findex Word_Size
10202 @code{Standard'Word_Size} (@code{Standard} is the only permissible
10203 prefix) provides the value @code{System.Word_Size}. The result is
10204 a static constant.
10206 @node Standard and Implementation Defined Restrictions
10207 @chapter Standard and Implementation Defined Restrictions
10209 @noindent
10210 All RM defined Restriction identifiers are implemented:
10212 @itemize @bullet
10213 @item language-defined restrictions (see 13.12.1)
10214 @item tasking restrictions (see D.7)
10215 @item high integrity restrictions (see H.4)
10216 @end itemize
10218 @noindent
10219 GNAT implements additional restriction identifiers. All restrictions, whether
10220 language defined or GNAT-specific, are listed in the following.
10222 @menu
10223 * Partition-Wide Restrictions::
10224 * Program Unit Level Restrictions::
10225 @end menu
10227 @node Partition-Wide Restrictions
10228 @section Partition-Wide Restrictions
10230 There are two separate lists of restriction identifiers. The first
10231 set requires consistency throughout a partition (in other words, if the
10232 restriction identifier is used for any compilation unit in the partition,
10233 then all compilation units in the partition must obey the restriction).
10235 @menu
10236 * Immediate_Reclamation::
10237 * Max_Asynchronous_Select_Nesting::
10238 * Max_Entry_Queue_Length::
10239 * Max_Protected_Entries::
10240 * Max_Select_Alternatives::
10241 * Max_Storage_At_Blocking::
10242 * Max_Task_Entries::
10243 * Max_Tasks::
10244 * No_Abort_Statements::
10245 * No_Access_Parameter_Allocators::
10246 * No_Access_Subprograms::
10247 * No_Allocators::
10248 * No_Anonymous_Allocators::
10249 * No_Calendar::
10250 * No_Coextensions::
10251 * No_Default_Initialization::
10252 * No_Delay::
10253 * No_Dependence::
10254 * No_Direct_Boolean_Operators::
10255 * No_Dispatch::
10256 * No_Dispatching_Calls::
10257 * No_Dynamic_Attachment::
10258 * No_Dynamic_Priorities::
10259 * No_Entry_Calls_In_Elaboration_Code::
10260 * No_Enumeration_Maps::
10261 * No_Exception_Handlers::
10262 * No_Exception_Propagation::
10263 * No_Exception_Registration::
10264 * No_Exceptions::
10265 * No_Finalization::
10266 * No_Fixed_Point::
10267 * No_Floating_Point::
10268 * No_Implicit_Conditionals::
10269 * No_Implicit_Dynamic_Code::
10270 * No_Implicit_Heap_Allocations::
10271 * No_Implicit_Loops::
10272 * No_Initialize_Scalars::
10273 * No_IO::
10274 * No_Local_Allocators::
10275 * No_Local_Protected_Objects::
10276 * No_Local_Timing_Events::
10277 * No_Long_Long_Integers::
10278 * No_Multiple_Elaboration::
10279 * No_Nested_Finalization::
10280 * No_Protected_Type_Allocators::
10281 * No_Protected_Types::
10282 * No_Recursion::
10283 * No_Reentrancy::
10284 * No_Relative_Delay::
10285 * No_Requeue_Statements::
10286 * No_Secondary_Stack::
10287 * No_Select_Statements::
10288 * No_Specific_Termination_Handlers::
10289 * No_Specification_of_Aspect::
10290 * No_Standard_Allocators_After_Elaboration::
10291 * No_Standard_Storage_Pools::
10292 * No_Stream_Optimizations::
10293 * No_Streams::
10294 * No_Task_Allocators::
10295 * No_Task_Attributes_Package::
10296 * No_Task_Hierarchy::
10297 * No_Task_Termination::
10298 * No_Tasking::
10299 * No_Terminate_Alternatives::
10300 * No_Unchecked_Access::
10301 * Simple_Barriers::
10302 * Static_Priorities::
10303 * Static_Storage_Size::
10304 @end menu
10306 @node Immediate_Reclamation
10307 @unnumberedsubsec Immediate_Reclamation
10308 @findex Immediate_Reclamation
10309 [RM H.4] This restriction ensures that, except for storage occupied by
10310 objects created by allocators and not deallocated via unchecked
10311 deallocation, any storage reserved at run time for an object is
10312 immediately reclaimed when the object no longer exists.
10314 @node Max_Asynchronous_Select_Nesting
10315 @unnumberedsubsec Max_Asynchronous_Select_Nesting
10316 @findex Max_Asynchronous_Select_Nesting
10317 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
10318 selects. Violations of this restriction with a value of zero are
10319 detected at compile time. Violations of this restriction with values
10320 other than zero cause Storage_Error to be raised.
10322 @node Max_Entry_Queue_Length
10323 @unnumberedsubsec Max_Entry_Queue_Length
10324 @findex Max_Entry_Queue_Length
10325 [RM D.7] This restriction is a declaration that any protected entry compiled in
10326 the scope of the restriction has at most the specified number of
10327 tasks waiting on the entry at any one time, and so no queue is required.
10328 Note that this restriction is checked at run time. Violation of this
10329 restriction results in the raising of Program_Error exception at the point of
10330 the call.
10332 @findex Max_Entry_Queue_Depth
10333 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
10334 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
10335 compatibility purposes (and a warning will be generated for its use if
10336 warnings on obsolescent features are activated).
10338 @node Max_Protected_Entries
10339 @unnumberedsubsec Max_Protected_Entries
10340 @findex Max_Protected_Entries
10341 [RM D.7] Specifies the maximum number of entries per protected type. The
10342 bounds of every entry family of a protected unit shall be static, or shall be
10343 defined by a discriminant of a subtype whose corresponding bound is static.
10345 @node Max_Select_Alternatives
10346 @unnumberedsubsec Max_Select_Alternatives
10347 @findex Max_Select_Alternatives
10348 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
10350 @node Max_Storage_At_Blocking
10351 @unnumberedsubsec Max_Storage_At_Blocking
10352 @findex Max_Storage_At_Blocking
10353 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
10354 Storage_Size that can be retained by a blocked task. A violation of this
10355 restriction causes Storage_Error to be raised.
10357 @node Max_Task_Entries
10358 @unnumberedsubsec Max_Task_Entries
10359 @findex Max_Task_Entries
10360 [RM D.7] Specifies the maximum number of entries
10361 per task.  The bounds of every entry family
10362 of a task unit shall be static, or shall be
10363 defined by a discriminant of a subtype whose
10364 corresponding bound is static.
10366 @node Max_Tasks
10367 @unnumberedsubsec Max_Tasks
10368 @findex Max_Tasks
10369 [RM D.7] Specifies the maximum number of task that may be created, not
10370 counting the creation of the environment task.  Violations of this
10371 restriction with a value of zero are detected at compile
10372 time. Violations of this restriction with values other than zero cause
10373 Storage_Error to be raised.
10375 @node No_Abort_Statements
10376 @unnumberedsubsec No_Abort_Statements
10377 @findex No_Abort_Statements
10378 [RM D.7] There are no abort_statements, and there are
10379 no calls to Task_Identification.Abort_Task.
10381 @node No_Access_Parameter_Allocators
10382 @unnumberedsubsec No_Access_Parameter_Allocators
10383 @findex No_Access_Parameter_Allocators
10384 [RM H.4] This restriction ensures at compile time that there are no
10385 occurrences of an allocator as the actual parameter to an access
10386 parameter.
10388 @node No_Access_Subprograms
10389 @unnumberedsubsec No_Access_Subprograms
10390 @findex No_Access_Subprograms
10391 [RM H.4] This restriction ensures at compile time that there are no
10392 declarations of access-to-subprogram types.
10394 @node No_Allocators
10395 @unnumberedsubsec No_Allocators
10396 @findex No_Allocators
10397 [RM H.4] This restriction ensures at compile time that there are no
10398 occurrences of an allocator.
10400 @node No_Anonymous_Allocators
10401 @unnumberedsubsec No_Anonymous_Allocators
10402 @findex No_Anonymous_Allocators
10403 [RM H.4] This restriction ensures at compile time that there are no
10404 occurrences of an allocator of anonymous access type.
10406 @node No_Calendar
10407 @unnumberedsubsec No_Calendar
10408 @findex No_Calendar
10409 [GNAT] This restriction ensures at compile time that there is no implicit or
10410 explicit dependence on the package @code{Ada.Calendar}.
10412 @node No_Coextensions
10413 @unnumberedsubsec No_Coextensions
10414 @findex No_Coextensions
10415 [RM H.4] This restriction ensures at compile time that there are no
10416 coextensions. See 3.10.2.
10418 @node No_Default_Initialization
10419 @unnumberedsubsec No_Default_Initialization
10420 @findex No_Default_Initialization
10422 [GNAT] This restriction prohibits any instance of default initialization
10423 of variables.  The binder implements a consistency rule which prevents
10424 any unit compiled without the restriction from with'ing a unit with the
10425 restriction (this allows the generation of initialization procedures to
10426 be skipped, since you can be sure that no call is ever generated to an
10427 initialization procedure in a unit with the restriction active). If used
10428 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10429 is to prohibit all cases of variables declared without a specific
10430 initializer (including the case of OUT scalar parameters).
10432 @node No_Delay
10433 @unnumberedsubsec No_Delay
10434 @findex No_Delay
10435 [RM H.4] This restriction ensures at compile time that there are no
10436 delay statements and no dependences on package Calendar.
10438 @node No_Dependence
10439 @unnumberedsubsec No_Dependence
10440 @findex No_Dependence
10441 [RM 13.12.1] This restriction checks at compile time that there are no
10442 dependence on a library unit.
10444 @node No_Direct_Boolean_Operators
10445 @unnumberedsubsec No_Direct_Boolean_Operators
10446 @findex No_Direct_Boolean_Operators
10447 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10448 are used on operands of type Boolean (or any type derived from Boolean).
10449 This is intended for use in safety critical programs where the certification
10450 protocol requires the use of short-circuit (and then, or else) forms for all
10451 composite boolean operations.
10453 @node No_Dispatch
10454 @unnumberedsubsec No_Dispatch
10455 @findex No_Dispatch
10456 [RM H.4] This restriction ensures at compile time that there are no
10457 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10459 @node No_Dispatching_Calls
10460 @unnumberedsubsec No_Dispatching_Calls
10461 @findex No_Dispatching_Calls
10462 [GNAT] This restriction ensures at compile time that the code generated by the
10463 compiler involves no dispatching calls. The use of this restriction allows the
10464 safe use of record extensions, classwide membership tests and other classwide
10465 features not involving implicit dispatching. This restriction ensures that
10466 the code contains no indirect calls through a dispatching mechanism. Note that
10467 this includes internally-generated calls created by the compiler, for example
10468 in the implementation of class-wide objects assignments. The
10469 membership test is allowed in the presence of this restriction, because its
10470 implementation requires no dispatching.
10471 This restriction is comparable to the official Ada restriction
10472 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10473 all classwide constructs that do not imply dispatching.
10474 The following example indicates constructs that violate this restriction.
10476 @smallexample
10477 package Pkg is
10478   type T is tagged record
10479     Data : Natural;
10480   end record;
10481   procedure P (X : T);
10483   type DT is new T with record
10484     More_Data : Natural;
10485   end record;
10486   procedure Q (X : DT);
10487 end Pkg;
10489 with Pkg; use Pkg;
10490 procedure Example is
10491   procedure Test (O : T'Class) is
10492     N : Natural  := O'Size;--  Error: Dispatching call
10493     C : T'Class := O;      --  Error: implicit Dispatching Call
10494   begin
10495     if O in DT'Class then  --  OK   : Membership test
10496        Q (DT (O));         --  OK   : Type conversion plus direct call
10497     else
10498        P (O);              --  Error: Dispatching call
10499     end if;
10500   end Test;
10502   Obj : DT;
10503 begin
10504   P (Obj);                 --  OK   : Direct call
10505   P (T (Obj));             --  OK   : Type conversion plus direct call
10506   P (T'Class (Obj));       --  Error: Dispatching call
10508   Test (Obj);              --  OK   : Type conversion
10510   if Obj in T'Class then   --  OK   : Membership test
10511      null;
10512   end if;
10513 end Example;
10514 @end smallexample
10516 @node No_Dynamic_Attachment
10517 @unnumberedsubsec No_Dynamic_Attachment
10518 @findex No_Dynamic_Attachment
10519 [RM D.7] This restriction ensures that there is no call to any of the
10520 operations defined in package Ada.Interrupts
10521 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10522 Detach_Handler, and Reference).
10524 @findex No_Dynamic_Interrupts
10525 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10526 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10527 compatibility purposes (and a warning will be generated for its use if
10528 warnings on obsolescent features are activated).
10530 @node No_Dynamic_Priorities
10531 @unnumberedsubsec No_Dynamic_Priorities
10532 @findex No_Dynamic_Priorities
10533 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10535 @node No_Entry_Calls_In_Elaboration_Code
10536 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10537 @findex No_Entry_Calls_In_Elaboration_Code
10538 [GNAT] This restriction ensures at compile time that no task or protected entry
10539 calls are made during elaboration code.  As a result of the use of this
10540 restriction, the compiler can assume that no code past an accept statement
10541 in a task can be executed at elaboration time.
10543 @node No_Enumeration_Maps
10544 @unnumberedsubsec No_Enumeration_Maps
10545 @findex No_Enumeration_Maps
10546 [GNAT] This restriction ensures at compile time that no operations requiring
10547 enumeration maps are used (that is Image and Value attributes applied
10548 to enumeration types).
10550 @node No_Exception_Handlers
10551 @unnumberedsubsec No_Exception_Handlers
10552 @findex No_Exception_Handlers
10553 [GNAT] This restriction ensures at compile time that there are no explicit
10554 exception handlers. It also indicates that no exception propagation will
10555 be provided. In this mode, exceptions may be raised but will result in
10556 an immediate call to the last chance handler, a routine that the user
10557 must define with the following profile:
10559 @smallexample @c ada
10560 procedure Last_Chance_Handler
10561   (Source_Location : System.Address; Line : Integer);
10562 pragma Export (C, Last_Chance_Handler,
10563                "__gnat_last_chance_handler");
10564 @end smallexample
10566 The parameter is a C null-terminated string representing a message to be
10567 associated with the exception (typically the source location of the raise
10568 statement generated by the compiler). The Line parameter when nonzero
10569 represents the line number in the source program where the raise occurs.
10571 @node No_Exception_Propagation
10572 @unnumberedsubsec No_Exception_Propagation
10573 @findex No_Exception_Propagation
10574 [GNAT] This restriction guarantees that exceptions are never propagated
10575 to an outer subprogram scope. The only case in which an exception may
10576 be raised is when the handler is statically in the same subprogram, so
10577 that the effect of a raise is essentially like a goto statement. Any
10578 other raise statement (implicit or explicit) will be considered
10579 unhandled. Exception handlers are allowed, but may not contain an
10580 exception occurrence identifier (exception choice). In addition, use of
10581 the package GNAT.Current_Exception is not permitted, and reraise
10582 statements (raise with no operand) are not permitted.
10584 @node No_Exception_Registration
10585 @unnumberedsubsec No_Exception_Registration
10586 @findex No_Exception_Registration
10587 [GNAT] This restriction ensures at compile time that no stream operations for
10588 types Exception_Id or Exception_Occurrence are used. This also makes it
10589 impossible to pass exceptions to or from a partition with this restriction
10590 in a distributed environment. If this restriction is active, the generated
10591 code is simplified by omitting the otherwise-required global registration
10592 of exceptions when they are declared.
10594 @node No_Exceptions
10595 @unnumberedsubsec No_Exceptions
10596 @findex No_Exceptions
10597 [RM H.4] This restriction ensures at compile time that there are no
10598 raise statements and no exception handlers.
10600 @node No_Finalization
10601 @unnumberedsubsec No_Finalization
10602 @findex No_Finalization
10603 [GNAT] This restriction disables the language features described in
10604 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10605 performed by the compiler to support these features. The following types
10606 are no longer considered controlled when this restriction is in effect:
10607 @itemize @bullet
10608 @item
10609 @code{Ada.Finalization.Controlled}
10610 @item
10611 @code{Ada.Finalization.Limited_Controlled}
10612 @item
10613 Derivations from @code{Controlled} or @code{Limited_Controlled}
10614 @item
10615 Class-wide types
10616 @item
10617 Protected types
10618 @item
10619 Task types
10620 @item
10621 Array and record types with controlled components
10622 @end itemize
10623 The compiler no longer generates code to initialize, finalize or adjust an
10624 object or a nested component, either declared on the stack or on the heap. The
10625 deallocation of a controlled object no longer finalizes its contents.
10627 @node No_Fixed_Point
10628 @unnumberedsubsec No_Fixed_Point
10629 @findex No_Fixed_Point
10630 [RM H.4] This restriction ensures at compile time that there are no
10631 occurrences of fixed point types and operations.
10633 @node No_Floating_Point
10634 @unnumberedsubsec No_Floating_Point
10635 @findex No_Floating_Point
10636 [RM H.4] This restriction ensures at compile time that there are no
10637 occurrences of floating point types and operations.
10639 @node No_Implicit_Conditionals
10640 @unnumberedsubsec No_Implicit_Conditionals
10641 @findex No_Implicit_Conditionals
10642 [GNAT] This restriction ensures that the generated code does not contain any
10643 implicit conditionals, either by modifying the generated code where possible,
10644 or by rejecting any construct that would otherwise generate an implicit
10645 conditional. Note that this check does not include run time constraint
10646 checks, which on some targets may generate implicit conditionals as
10647 well. To control the latter, constraint checks can be suppressed in the
10648 normal manner. Constructs generating implicit conditionals include comparisons
10649 of composite objects and the Max/Min attributes.
10651 @node No_Implicit_Dynamic_Code
10652 @unnumberedsubsec No_Implicit_Dynamic_Code
10653 @findex No_Implicit_Dynamic_Code
10654 @cindex trampoline
10655 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10656 This is a structure that is built on the stack and contains dynamic
10657 code to be executed at run time. On some targets, a trampoline is
10658 built for the following features: @code{Access},
10659 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10660 nested task bodies; primitive operations of nested tagged types.
10661 Trampolines do not work on machines that prevent execution of stack
10662 data. For example, on windows systems, enabling DEP (data execution
10663 protection) will cause trampolines to raise an exception.
10664 Trampolines are also quite slow at run time.
10666 On many targets, trampolines have been largely eliminated. Look at the
10667 version of system.ads for your target --- if it has
10668 Always_Compatible_Rep equal to False, then trampolines are largely
10669 eliminated. In particular, a trampoline is built for the following
10670 features: @code{Address} of a nested subprogram;
10671 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10672 but only if pragma Favor_Top_Level applies, or the access type has a
10673 foreign-language convention; primitive operations of nested tagged
10674 types.
10676 @node No_Implicit_Heap_Allocations
10677 @unnumberedsubsec No_Implicit_Heap_Allocations
10678 @findex No_Implicit_Heap_Allocations
10679 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10681 @node No_Implicit_Loops
10682 @unnumberedsubsec No_Implicit_Loops
10683 @findex No_Implicit_Loops
10684 [GNAT] This restriction ensures that the generated code does not contain any
10685 implicit @code{for} loops, either by modifying
10686 the generated code where possible,
10687 or by rejecting any construct that would otherwise generate an implicit
10688 @code{for} loop. If this restriction is active, it is possible to build
10689 large array aggregates with all static components without generating an
10690 intermediate temporary, and without generating a loop to initialize individual
10691 components. Otherwise, a loop is created for arrays larger than about 5000
10692 scalar components.
10694 @node No_Initialize_Scalars
10695 @unnumberedsubsec No_Initialize_Scalars
10696 @findex No_Initialize_Scalars
10697 [GNAT] This restriction ensures that no unit in the partition is compiled with
10698 pragma Initialize_Scalars. This allows the generation of more efficient
10699 code, and in particular eliminates dummy null initialization routines that
10700 are otherwise generated for some record and array types.
10702 @node No_IO
10703 @unnumberedsubsec No_IO
10704 @findex No_IO
10705 [RM H.4] This restriction ensures at compile time that there are no
10706 dependences on any of the library units Sequential_IO, Direct_IO,
10707 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10709 @node No_Local_Allocators
10710 @unnumberedsubsec No_Local_Allocators
10711 @findex No_Local_Allocators
10712 [RM H.4] This restriction ensures at compile time that there are no
10713 occurrences of an allocator in subprograms, generic subprograms, tasks,
10714 and entry bodies.
10716 @node No_Local_Protected_Objects
10717 @unnumberedsubsec No_Local_Protected_Objects
10718 @findex No_Local_Protected_Objects
10719 [RM D.7] This restriction ensures at compile time that protected objects are
10720 only declared at the library level.
10722 @node No_Local_Timing_Events
10723 @unnumberedsubsec No_Local_Timing_Events
10724 @findex No_Local_Timing_Events
10725 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10726 declared at the library level.
10728 @node No_Long_Long_Integers
10729 @unnumberedsubsec No_Long_Long_Integers
10730 @findex No_Long_Long_Integers
10731 [GNAT] This partition-wide restriction forbids any explicit reference to
10732 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10733 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10734 Long_Integer'Size.
10736 @node No_Multiple_Elaboration
10737 @unnumberedsubsec No_Multiple_Elaboration
10738 @findex No_Multiple_Elaboration
10739 [GNAT] Normally each package contains a 16-bit counter used to check for access
10740 before elaboration, and to control multiple elaboration attempts.
10741 This counter is eliminated for units compiled with the static model
10742 of elaboration if restriction @code{No_Elaboration_Code}
10743 is active but because of
10744 the need to check for multiple elaboration in the general case, these
10745 counters cannot be eliminated if elaboration code may be present. The
10746 restriction @code{No_Multiple_Elaboration}
10747 allows suppression of these counters
10748 in static elaboration units even if they do have elaboration code. If this
10749 restriction is used, then the situations in which multiple elaboration is
10750 possible, including non-Ada main programs, and Stand Alone libraries, are not
10751 permitted, and will be diagnosed by the binder.
10753 @node No_Nested_Finalization
10754 @unnumberedsubsec No_Nested_Finalization
10755 @findex No_Nested_Finalization
10756 [RM D.7] All objects requiring finalization are declared at the library level.
10758 @node No_Protected_Type_Allocators
10759 @unnumberedsubsec No_Protected_Type_Allocators
10760 @findex No_Protected_Type_Allocators
10761 [RM D.7] This restriction ensures at compile time that there are no allocator
10762 expressions that attempt to allocate protected objects.
10764 @node No_Protected_Types
10765 @unnumberedsubsec No_Protected_Types
10766 @findex No_Protected_Types
10767 [RM H.4] This restriction ensures at compile time that there are no
10768 declarations of protected types or protected objects.
10770 @node No_Recursion
10771 @unnumberedsubsec No_Recursion
10772 @findex No_Recursion
10773 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10774 part of its execution.
10776 @node No_Reentrancy
10777 @unnumberedsubsec No_Reentrancy
10778 @findex No_Reentrancy
10779 [RM H.4] A program execution is erroneous if a subprogram is executed by
10780 two tasks at the same time.
10782 @node No_Relative_Delay
10783 @unnumberedsubsec No_Relative_Delay
10784 @findex No_Relative_Delay
10785 [RM D.7] This restriction ensures at compile time that there are no delay
10786 relative statements and prevents expressions such as @code{delay 1.23;} from
10787 appearing in source code.
10789 @node No_Requeue_Statements
10790 @unnumberedsubsec No_Requeue_Statements
10791 @findex No_Requeue_Statements
10792 [RM D.7] This restriction ensures at compile time that no requeue statements
10793 are permitted and prevents keyword @code{requeue} from being used in source
10794 code.
10796 @findex No_Requeue
10797 The restriction @code{No_Requeue} is recognized as a
10798 synonym for @code{No_Requeue_Statements}. This is retained for historical
10799 compatibility purposes (and a warning will be generated for its use if
10800 warnings on oNobsolescent features are activated).
10802 @node No_Secondary_Stack
10803 @unnumberedsubsec No_Secondary_Stack
10804 @findex No_Secondary_Stack
10805 [GNAT] This restriction ensures at compile time that the generated code
10806 does not contain any reference to the secondary stack.  The secondary
10807 stack is used to implement functions returning unconstrained objects
10808 (arrays or records) on some targets.
10810 @node No_Select_Statements
10811 @unnumberedsubsec No_Select_Statements
10812 @findex No_Select_Statements
10813 [RM D.7] This restriction ensures at compile time no select statements of any
10814 kind are permitted, that is the keyword @code{select} may not appear.
10816 @node No_Specific_Termination_Handlers
10817 @unnumberedsubsec No_Specific_Termination_Handlers
10818 @findex No_Specific_Termination_Handlers
10819 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10820 or to Ada.Task_Termination.Specific_Handler.
10822 @node No_Specification_of_Aspect
10823 @unnumberedsubsec No_Specification_of_Aspect
10824 @findex No_Specification_of_Aspect
10825 [RM 13.12.1] This restriction checks at compile time that no aspect
10826 specification, attribute definition clause, or pragma is given for a
10827 given aspect.
10829 @node No_Standard_Allocators_After_Elaboration
10830 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10831 @findex No_Standard_Allocators_After_Elaboration
10832 [RM D.7] Specifies that an allocator using a standard storage pool
10833 should never be evaluated at run time after the elaboration of the
10834 library items of the partition has completed. Otherwise, Storage_Error
10835 is raised.
10837 @node No_Standard_Storage_Pools
10838 @unnumberedsubsec No_Standard_Storage_Pools
10839 @findex No_Standard_Storage_Pools
10840 [GNAT] This restriction ensures at compile time that no access types
10841 use the standard default storage pool.  Any access type declared must
10842 have an explicit Storage_Pool attribute defined specifying a
10843 user-defined storage pool.
10845 @node No_Stream_Optimizations
10846 @unnumberedsubsec No_Stream_Optimizations
10847 @findex No_Stream_Optimizations
10848 [GNAT] This restriction affects the performance of stream operations on types
10849 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10850 compiler uses block reads and writes when manipulating @code{String} objects
10851 due to their supperior performance. When this restriction is in effect, the
10852 compiler performs all IO operations on a per-character basis.
10854 @node No_Streams
10855 @unnumberedsubsec No_Streams
10856 @findex No_Streams
10857 [GNAT] This restriction ensures at compile/bind time that there are no
10858 stream objects created and no use of stream attributes.
10859 This restriction does not forbid dependences on the package
10860 @code{Ada.Streams}. So it is permissible to with
10861 @code{Ada.Streams} (or another package that does so itself)
10862 as long as no actual stream objects are created and no
10863 stream attributes are used.
10865 Note that the use of restriction allows optimization of tagged types,
10866 since they do not need to worry about dispatching stream operations.
10867 To take maximum advantage of this space-saving optimization, any
10868 unit declaring a tagged type should be compiled with the restriction,
10869 though this is not required.
10871 @node No_Task_Allocators
10872 @unnumberedsubsec No_Task_Allocators
10873 @findex No_Task_Allocators
10874 [RM D.7] There are no allocators for task types
10875 or types containing task subcomponents.
10877 @node No_Task_Attributes_Package
10878 @unnumberedsubsec No_Task_Attributes_Package
10879 @findex No_Task_Attributes_Package
10880 [GNAT] This restriction ensures at compile time that there are no implicit or
10881 explicit dependencies on the package @code{Ada.Task_Attributes}.
10883 @findex No_Task_Attributes
10884 The restriction @code{No_Task_Attributes} is recognized as a synonym
10885 for @code{No_Task_Attributes_Package}. This is retained for historical
10886 compatibility purposes (and a warning will be generated for its use if
10887 warnings on obsolescent features are activated).
10889 @node No_Task_Hierarchy
10890 @unnumberedsubsec No_Task_Hierarchy
10891 @findex No_Task_Hierarchy
10892 [RM D.7] All (non-environment) tasks depend
10893 directly on the environment task of the partition.
10895 @node No_Task_Termination
10896 @unnumberedsubsec No_Task_Termination
10897 @findex No_Task_Termination
10898 [RM D.7] Tasks which terminate are erroneous.
10900 @node No_Tasking
10901 @unnumberedsubsec No_Tasking
10902 @findex No_Tasking
10903 [GNAT] This restriction prevents the declaration of tasks or task types
10904 throughout the partition.  It is similar in effect to the use of
10905 @code{Max_Tasks => 0} except that violations are caught at compile time
10906 and cause an error message to be output either by the compiler or
10907 binder.
10909 @node No_Terminate_Alternatives
10910 @unnumberedsubsec No_Terminate_Alternatives
10911 @findex No_Terminate_Alternatives
10912 [RM D.7] There are no selective accepts with terminate alternatives.
10914 @node No_Unchecked_Access
10915 @unnumberedsubsec No_Unchecked_Access
10916 @findex No_Unchecked_Access
10917 [RM H.4] This restriction ensures at compile time that there are no
10918 occurrences of the Unchecked_Access attribute.
10920 @node Simple_Barriers
10921 @unnumberedsubsec Simple_Barriers
10922 @findex Simple_Barriers
10923 [RM D.7] This restriction ensures at compile time that barriers in entry
10924 declarations for protected types are restricted to either static boolean
10925 expressions or references to simple boolean variables defined in the private
10926 part of the protected type.  No other form of entry barriers is permitted.
10928 @findex Boolean_Entry_Barriers
10929 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10930 synonym for @code{Simple_Barriers}. This is retained for historical
10931 compatibility purposes (and a warning will be generated for its use if
10932 warnings on obsolescent features are activated).
10934 @node Static_Priorities
10935 @unnumberedsubsec Static_Priorities
10936 @findex Static_Priorities
10937 [GNAT] This restriction ensures at compile time that all priority expressions
10938 are static, and that there are no dependences on the package
10939 @code{Ada.Dynamic_Priorities}.
10941 @node Static_Storage_Size
10942 @unnumberedsubsec Static_Storage_Size
10943 @findex Static_Storage_Size
10944 [GNAT] This restriction ensures at compile time that any expression appearing
10945 in a Storage_Size pragma or attribute definition clause is static.
10947 @node Program Unit Level Restrictions
10948 @section Program Unit Level Restrictions
10950 @noindent
10951 The second set of restriction identifiers
10952 does not require partition-wide consistency.
10953 The restriction may be enforced for a single
10954 compilation unit without any effect on any of the
10955 other compilation units in the partition.
10957 @menu
10958 * No_Elaboration_Code::
10959 * No_Entry_Queue::
10960 * No_Implementation_Aspect_Specifications::
10961 * No_Implementation_Attributes::
10962 * No_Implementation_Identifiers::
10963 * No_Implementation_Pragmas::
10964 * No_Implementation_Restrictions::
10965 * No_Implementation_Units::
10966 * No_Implicit_Aliasing::
10967 * No_Obsolescent_Features::
10968 * No_Wide_Characters::
10969 * SPARK_05::
10970 @end menu
10972 @node No_Elaboration_Code
10973 @unnumberedsubsec No_Elaboration_Code
10974 @findex No_Elaboration_Code
10975 [GNAT] This restriction ensures at compile time that no elaboration code is
10976 generated.  Note that this is not the same condition as is enforced
10977 by pragma @code{Preelaborate}.  There are cases in which pragma
10978 @code{Preelaborate} still permits code to be generated (e.g.@: code
10979 to initialize a large array to all zeroes), and there are cases of units
10980 which do not meet the requirements for pragma @code{Preelaborate},
10981 but for which no elaboration code is generated.  Generally, it is
10982 the case that preelaborable units will meet the restrictions, with
10983 the exception of large aggregates initialized with an others_clause,
10984 and exception declarations (which generate calls to a run-time
10985 registry procedure).  This restriction is enforced on
10986 a unit by unit basis, it need not be obeyed consistently
10987 throughout a partition.
10989 In the case of aggregates with others, if the aggregate has a dynamic
10990 size, there is no way to eliminate the elaboration code (such dynamic
10991 bounds would be incompatible with @code{Preelaborate} in any case). If
10992 the bounds are static, then use of this restriction actually modifies
10993 the code choice of the compiler to avoid generating a loop, and instead
10994 generate the aggregate statically if possible, no matter how many times
10995 the data for the others clause must be repeatedly generated.
10997 It is not possible to precisely document
10998 the constructs which are compatible with this restriction, since,
10999 unlike most other restrictions, this is not a restriction on the
11000 source code, but a restriction on the generated object code. For
11001 example, if the source contains a declaration:
11003 @smallexample
11004    Val : constant Integer := X;
11005 @end smallexample
11007 @noindent
11008 where X is not a static constant, it may be possible, depending
11009 on complex optimization circuitry, for the compiler to figure
11010 out the value of X at compile time, in which case this initialization
11011 can be done by the loader, and requires no initialization code. It
11012 is not possible to document the precise conditions under which the
11013 optimizer can figure this out.
11015 Note that this the implementation of this restriction requires full
11016 code generation. If it is used in conjunction with "semantics only"
11017 checking, then some cases of violations may be missed.
11019 @node No_Entry_Queue
11020 @unnumberedsubsec No_Entry_Queue
11021 @findex No_Entry_Queue
11022 [GNAT] This restriction is a declaration that any protected entry compiled in
11023 the scope of the restriction has at most one task waiting on the entry
11024 at any one time, and so no queue is required.  This restriction is not
11025 checked at compile time.  A program execution is erroneous if an attempt
11026 is made to queue a second task on such an entry.
11028 @node No_Implementation_Aspect_Specifications
11029 @unnumberedsubsec No_Implementation_Aspect_Specifications
11030 @findex No_Implementation_Aspect_Specifications
11031 [RM 13.12.1] This restriction checks at compile time that no
11032 GNAT-defined aspects are present.  With this restriction, the only
11033 aspects that can be used are those defined in the Ada Reference Manual.
11035 @node No_Implementation_Attributes
11036 @unnumberedsubsec No_Implementation_Attributes
11037 @findex No_Implementation_Attributes
11038 [RM 13.12.1] This restriction checks at compile time that no
11039 GNAT-defined attributes are present.  With this restriction, the only
11040 attributes that can be used are those defined in the Ada Reference
11041 Manual.
11043 @node No_Implementation_Identifiers
11044 @unnumberedsubsec No_Implementation_Identifiers
11045 @findex No_Implementation_Identifiers
11046 [RM 13.12.1] This restriction checks at compile time that no
11047 implementation-defined identifiers (marked with pragma Implementation_Defined)
11048 occur within language-defined packages.
11050 @node No_Implementation_Pragmas
11051 @unnumberedsubsec No_Implementation_Pragmas
11052 @findex No_Implementation_Pragmas
11053 [RM 13.12.1] This restriction checks at compile time that no
11054 GNAT-defined pragmas are present.  With this restriction, the only
11055 pragmas that can be used are those defined in the Ada Reference Manual.
11057 @node No_Implementation_Restrictions
11058 @unnumberedsubsec No_Implementation_Restrictions
11059 @findex No_Implementation_Restrictions
11060 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
11061 identifiers (other than @code{No_Implementation_Restrictions} itself)
11062 are present.  With this restriction, the only other restriction identifiers
11063 that can be used are those defined in the Ada Reference Manual.
11065 @node No_Implementation_Units
11066 @unnumberedsubsec No_Implementation_Units
11067 @findex No_Implementation_Units
11068 [RM 13.12.1] This restriction checks at compile time that there is no
11069 mention in the context clause of any implementation-defined descendants
11070 of packages Ada, Interfaces, or System.
11072 @node No_Implicit_Aliasing
11073 @unnumberedsubsec No_Implicit_Aliasing
11074 @findex No_Implicit_Aliasing
11075 [GNAT] This restriction, which is not required to be partition-wide consistent,
11076 requires an explicit aliased keyword for an object to which 'Access,
11077 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
11078 the 'Unrestricted_Access attribute for objects. Note: the reason that
11079 Unrestricted_Access is forbidden is that it would require the prefix
11080 to be aliased, and in such cases, it can always be replaced by
11081 the standard attribute Unchecked_Access which is preferable.
11083 @node No_Obsolescent_Features
11084 @unnumberedsubsec No_Obsolescent_Features
11085 @findex No_Obsolescent_Features
11086 [RM 13.12.1] This restriction checks at compile time that no obsolescent
11087 features are used, as defined in Annex J of the Ada Reference Manual.
11089 @node No_Wide_Characters
11090 @unnumberedsubsec No_Wide_Characters
11091 @findex No_Wide_Characters
11092 [GNAT] This restriction ensures at compile time that no uses of the types
11093 @code{Wide_Character} or @code{Wide_String} or corresponding wide
11094 wide types
11095 appear, and that no wide or wide wide string or character literals
11096 appear in the program (that is literals representing characters not in
11097 type @code{Character}).
11099 @node SPARK_05
11100 @unnumberedsubsec SPARK_05
11101 @findex SPARK_05
11102 [GNAT] This restriction checks at compile time that some constructs
11103 forbidden in SPARK 2005 are not present. Error messages related to
11104 SPARK restriction have the form:
11106 @smallexample
11107 violation of restriction "SPARK_05" at <source-location>
11108  <error message>
11109 @end smallexample
11111 @findex SPARK
11112 The restriction @code{SPARK} is recognized as a
11113 synonym for @code{SPARK_05}. This is retained for historical
11114 compatibility purposes (and an unconditional warning will be generated
11115 for its use, advising replacement by @code{SPARK}).
11117 This is not a replacement for the semantic checks performed by the
11118 SPARK Examiner tool, as the compiler currently only deals with code,
11119 not SPARK 2005 annotations, and does not guarantee catching all
11120 cases of constructs forbidden by SPARK 2005.
11122 Thus it may well be the case that code which passes the compiler with
11123 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
11124 the different visibility rules of the Examiner based on SPARK 2005
11125 @code{inherit} annotations.
11127 This restriction can be useful in providing an initial filter for code
11128 developed using SPARK 2005, or in examining legacy code to see how far
11129 it is from meeting SPARK restrictions.
11131 The list below summarizes the checks that are performed when this
11132 restriction is in force:
11133 @itemize @bullet
11134 @item No block statements
11135 @item No case statements with only an others clause
11136 @item Exit statements in loops must respect the SPARK 2005 language restrictions
11137 @item No goto statements
11138 @item Return can only appear as last statement in function
11139 @item Function must have return statement
11140 @item Loop parameter specification must include subtype mark
11141 @item Prefix of expanded name cannot be a loop statement
11142 @item Abstract subprogram not allowed
11143 @item User-defined operators not allowed
11144 @item Access type parameters not allowed
11145 @item Default expressions for parameters not allowed
11146 @item Default expressions for record fields not allowed
11147 @item No tasking constructs allowed
11148 @item Label needed at end of subprograms and packages
11149 @item No mixing of positional and named parameter association
11150 @item No access types as result type
11151 @item No unconstrained arrays as result types
11152 @item No null procedures
11153 @item Initial and later declarations must be in correct order (declaration can't come after body)
11154 @item No attributes on private types if full declaration not visible
11155 @item No package declaration within package specification
11156 @item No controlled types
11157 @item No discriminant types
11158 @item No overloading
11159 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
11160 @item Access attribute not allowed
11161 @item Allocator not allowed
11162 @item Result of catenation must be String
11163 @item Operands of catenation must be string literal, static char or another catenation
11164 @item No conditional expressions
11165 @item No explicit dereference
11166 @item Quantified expression not allowed
11167 @item Slicing not allowed
11168 @item No exception renaming
11169 @item No generic renaming
11170 @item No object renaming
11171 @item No use clause
11172 @item Aggregates must be qualified
11173 @item Non-static choice in array aggregates not allowed
11174 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
11175 @item No mixing of positional and named association in aggregate, no multi choice
11176 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
11177 @item Fixed point operands to * or / must be qualified or converted
11178 @item Comparison operators not allowed for Booleans or arrays (except strings)
11179 @item Equality not allowed for arrays with non-matching static bounds (except strings)
11180 @item Conversion / qualification not allowed for arrays with non-matching static bounds
11181 @item Subprogram declaration only allowed in package spec (unless followed by import)
11182 @item Access types not allowed
11183 @item Incomplete type declaration not allowed
11184 @item Object and subtype declarations must respect SPARK restrictions
11185 @item Digits or delta constraint not allowed
11186 @item Decimal fixed point type not allowed
11187 @item Aliasing of objects not allowed
11188 @item Modular type modulus must be power of 2
11189 @item Base not allowed on subtype mark
11190 @item Unary operators not allowed on modular types (except not)
11191 @item Untagged record cannot be null
11192 @item No class-wide operations
11193 @item Initialization expressions must respect SPARK restrictions
11194 @item Non-static ranges not allowed except in iteration schemes
11195 @item String subtypes must have lower bound of 1
11196 @item Subtype of Boolean cannot have constraint
11197 @item At most one tagged type or extension per package
11198 @item Interface is not allowed
11199 @item Character literal cannot be prefixed (selector name cannot be character literal)
11200 @item Record aggregate cannot contain 'others'
11201 @item Component association in record aggregate must contain a single choice
11202 @item Ancestor part cannot be a type mark
11203 @item Attributes 'Image, 'Width and 'Value not allowed
11204 @item Functions may not update globals
11205 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
11206 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
11207 @end itemize
11209 The following restrictions are enforced, but note that they are actually more
11210 strict that the latest SPARK 2005 language definition:
11212 @itemize @bullet
11213 @item No derived types other than tagged type extensions
11214 @item Subtype of unconstrained array must have constraint
11215 @end itemize
11217 This list summarises the main SPARK 2005 language rules that are not
11218 currently checked by the SPARK_05 restriction:
11220 @itemize @bullet
11221 @item SPARK annotations are treated as comments so are not checked at all
11222 @item Based real literals not allowed
11223 @item Objects cannot be initialized at declaration by calls to user-defined functions
11224 @item Objects cannot be initialized at declaration by assignments from variables
11225 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
11226 @item Ranges shall not be null
11227 @item A fixed point delta expression must be a simple expression
11228 @item Restrictions on where renaming declarations may be placed
11229 @item Externals of mode 'out' cannot be referenced
11230 @item Externals of mode 'in' cannot be updated
11231 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
11232 @item Subprogram cannot have parent unit name
11233 @item SPARK 2005 inherited subprogram must be prefixed with overriding
11234 @item External variables (or functions that reference them) may not be passed as actual parameters
11235 @item Globals must be explicitly mentioned in contract
11236 @item Deferred constants cannot be completed by pragma Import
11237 @item Package initialization cannot read/write variables from other packages
11238 @item Prefix not allowed for entities that are directly visible
11239 @item Identifier declaration can't override inherited package name
11240 @item Cannot use Standard or other predefined packages as identifiers
11241 @item After renaming, cannot use the original name
11242 @item Subprograms can only be renamed to remove package prefix
11243 @item Pragma import must be immediately after entity it names
11244 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
11245 @end itemize
11247 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
11248 violations will be reported for constructs forbidden in SPARK 95,
11249 instead of SPARK 2005.
11251 @c ------------------------
11252 @node Implementation Advice
11253 @chapter Implementation Advice
11254 @noindent
11255 The main text of the Ada Reference Manual describes the required
11256 behavior of all Ada compilers, and the GNAT compiler conforms to
11257 these requirements.
11259 In addition, there are sections throughout the Ada Reference Manual headed
11260 by the phrase ``Implementation advice''.  These sections are not normative,
11261 i.e., they do not specify requirements that all compilers must
11262 follow.  Rather they provide advice on generally desirable behavior.  You
11263 may wonder why they are not requirements.  The most typical answer is
11264 that they describe behavior that seems generally desirable, but cannot
11265 be provided on all systems, or which may be undesirable on some systems.
11267 As far as practical, GNAT follows the implementation advice sections in
11268 the Ada Reference Manual.  This chapter contains a table giving the
11269 reference manual section number, paragraph number and several keywords
11270 for each advice.  Each entry consists of the text of the advice followed
11271 by the GNAT interpretation of this advice.  Most often, this simply says
11272 ``followed'', which means that GNAT follows the advice.  However, in a
11273 number of cases, GNAT deliberately deviates from this advice, in which
11274 case the text describes what GNAT does and why.
11276 @cindex Error detection
11277 @unnumberedsec 1.1.3(20): Error Detection
11278 @sp 1
11279 @cartouche
11280 If an implementation detects the use of an unsupported Specialized Needs
11281 Annex feature at run time, it should raise @code{Program_Error} if
11282 feasible.
11283 @end cartouche
11284 Not relevant.  All specialized needs annex features are either supported,
11285 or diagnosed at compile time.
11287 @cindex Child Units
11288 @unnumberedsec 1.1.3(31): Child Units
11289 @sp 1
11290 @cartouche
11291 If an implementation wishes to provide implementation-defined
11292 extensions to the functionality of a language-defined library unit, it
11293 should normally do so by adding children to the library unit.
11294 @end cartouche
11295 Followed.
11297 @cindex Bounded errors
11298 @unnumberedsec 1.1.5(12): Bounded Errors
11299 @sp 1
11300 @cartouche
11301 If an implementation detects a bounded error or erroneous
11302 execution, it should raise @code{Program_Error}.
11303 @end cartouche
11304 Followed in all cases in which the implementation detects a bounded
11305 error or erroneous execution.  Not all such situations are detected at
11306 runtime.
11308 @cindex Pragmas
11309 @unnumberedsec 2.8(16): Pragmas
11310 @sp 1
11311 @cartouche
11312 Normally, implementation-defined pragmas should have no semantic effect
11313 for error-free programs; that is, if the implementation-defined pragmas
11314 are removed from a working program, the program should still be legal,
11315 and should still have the same semantics.
11316 @end cartouche
11317 The following implementation defined pragmas are exceptions to this
11318 rule:
11320 @table @code
11321 @item Abort_Defer
11322 Affects semantics
11323 @item Ada_83
11324 Affects legality
11325 @item Assert
11326 Affects semantics
11327 @item CPP_Class
11328 Affects semantics
11329 @item CPP_Constructor
11330 Affects semantics
11331 @item Debug
11332 Affects semantics
11333 @item Interface_Name
11334 Affects semantics
11335 @item Machine_Attribute
11336 Affects semantics
11337 @item Unimplemented_Unit
11338 Affects legality
11339 @item Unchecked_Union
11340 Affects semantics
11341 @end table
11343 @noindent
11344 In each of the above cases, it is essential to the purpose of the pragma
11345 that this advice not be followed.  For details see the separate section
11346 on implementation defined pragmas.
11348 @unnumberedsec 2.8(17-19): Pragmas
11349 @sp 1
11350 @cartouche
11351 Normally, an implementation should not define pragmas that can
11352 make an illegal program legal, except as follows:
11353 @end cartouche
11354 @sp 1
11355 @cartouche
11356 A pragma used to complete a declaration, such as a pragma @code{Import};
11357 @end cartouche
11358 @sp 1
11359 @cartouche
11360 A pragma used to configure the environment by adding, removing, or
11361 replacing @code{library_items}.
11362 @end cartouche
11363 See response to paragraph 16 of this same section.
11365 @cindex Character Sets
11366 @cindex Alternative Character Sets
11367 @unnumberedsec 3.5.2(5): Alternative Character Sets
11368 @sp 1
11369 @cartouche
11370 If an implementation supports a mode with alternative interpretations
11371 for @code{Character} and @code{Wide_Character}, the set of graphic
11372 characters of @code{Character} should nevertheless remain a proper
11373 subset of the set of graphic characters of @code{Wide_Character}.  Any
11374 character set ``localizations'' should be reflected in the results of
11375 the subprograms defined in the language-defined package
11376 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
11377 an alternative interpretation of @code{Character}, the implementation should
11378 also support a corresponding change in what is a legal
11379 @code{identifier_letter}.
11380 @end cartouche
11381 Not all wide character modes follow this advice, in particular the JIS
11382 and IEC modes reflect standard usage in Japan, and in these encoding,
11383 the upper half of the Latin-1 set is not part of the wide-character
11384 subset, since the most significant bit is used for wide character
11385 encoding.  However, this only applies to the external forms.  Internally
11386 there is no such restriction.
11388 @cindex Integer types
11389 @unnumberedsec 3.5.4(28): Integer Types
11391 @sp 1
11392 @cartouche
11393 An implementation should support @code{Long_Integer} in addition to
11394 @code{Integer} if the target machine supports 32-bit (or longer)
11395 arithmetic.  No other named integer subtypes are recommended for package
11396 @code{Standard}.  Instead, appropriate named integer subtypes should be
11397 provided in the library package @code{Interfaces} (see B.2).
11398 @end cartouche
11399 @code{Long_Integer} is supported.  Other standard integer types are supported
11400 so this advice is not fully followed.  These types
11401 are supported for convenient interface to C, and so that all hardware
11402 types of the machine are easily available.
11403 @unnumberedsec 3.5.4(29): Integer Types
11405 @sp 1
11406 @cartouche
11407 An implementation for a two's complement machine should support
11408 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
11409 implementation should support a non-binary modules up to @code{Integer'Last}.
11410 @end cartouche
11411 Followed.
11413 @cindex Enumeration values
11414 @unnumberedsec 3.5.5(8): Enumeration Values
11415 @sp 1
11416 @cartouche
11417 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11418 subtype, if the value of the operand does not correspond to the internal
11419 code for any enumeration literal of its type (perhaps due to an
11420 un-initialized variable), then the implementation should raise
11421 @code{Program_Error}.  This is particularly important for enumeration
11422 types with noncontiguous internal codes specified by an
11423 enumeration_representation_clause.
11424 @end cartouche
11425 Followed.
11427 @cindex Float types
11428 @unnumberedsec 3.5.7(17): Float Types
11429 @sp 1
11430 @cartouche
11431 An implementation should support @code{Long_Float} in addition to
11432 @code{Float} if the target machine supports 11 or more digits of
11433 precision.  No other named floating point subtypes are recommended for
11434 package @code{Standard}.  Instead, appropriate named floating point subtypes
11435 should be provided in the library package @code{Interfaces} (see B.2).
11436 @end cartouche
11437 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
11438 former provides improved compatibility with other implementations
11439 supporting this type.  The latter corresponds to the highest precision
11440 floating-point type supported by the hardware.  On most machines, this
11441 will be the same as @code{Long_Float}, but on some machines, it will
11442 correspond to the IEEE extended form.  The notable case is all ia32
11443 (x86) implementations, where @code{Long_Long_Float} corresponds to
11444 the 80-bit extended precision format supported in hardware on this
11445 processor.  Note that the 128-bit format on SPARC is not supported,
11446 since this is a software rather than a hardware format.
11448 @cindex Multidimensional arrays
11449 @cindex Arrays, multidimensional
11450 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11451 @sp 1
11452 @cartouche
11453 An implementation should normally represent multidimensional arrays in
11454 row-major order, consistent with the notation used for multidimensional
11455 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
11456 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11457 column-major order should be used instead (see B.5, ``Interfacing with
11458 Fortran'').
11459 @end cartouche
11460 Followed.
11462 @findex Duration'Small
11463 @unnumberedsec 9.6(30-31): Duration'Small
11464 @sp 1
11465 @cartouche
11466 Whenever possible in an implementation, the value of @code{Duration'Small}
11467 should be no greater than 100 microseconds.
11468 @end cartouche
11469 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
11471 @sp 1
11472 @cartouche
11473 The time base for @code{delay_relative_statements} should be monotonic;
11474 it need not be the same time base as used for @code{Calendar.Clock}.
11475 @end cartouche
11476 Followed.
11478 @unnumberedsec 10.2.1(12): Consistent Representation
11479 @sp 1
11480 @cartouche
11481 In an implementation, a type declared in a pre-elaborated package should
11482 have the same representation in every elaboration of a given version of
11483 the package, whether the elaborations occur in distinct executions of
11484 the same program, or in executions of distinct programs or partitions
11485 that include the given version.
11486 @end cartouche
11487 Followed, except in the case of tagged types.  Tagged types involve
11488 implicit pointers to a local copy of a dispatch table, and these pointers
11489 have representations which thus depend on a particular elaboration of the
11490 package.  It is not easy to see how it would be possible to follow this
11491 advice without severely impacting efficiency of execution.
11493 @cindex Exception information
11494 @unnumberedsec 11.4.1(19): Exception Information
11495 @sp 1
11496 @cartouche
11497 @code{Exception_Message} by default and @code{Exception_Information}
11498 should produce information useful for
11499 debugging.  @code{Exception_Message} should be short, about one
11500 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
11501 should not include the
11502 @code{Exception_Name}.  @code{Exception_Information} should include both
11503 the @code{Exception_Name} and the @code{Exception_Message}.
11504 @end cartouche
11505 Followed.  For each exception that doesn't have a specified
11506 @code{Exception_Message}, the compiler generates one containing the location
11507 of the raise statement.  This location has the form ``file:line'', where
11508 file is the short file name (without path information) and line is the line
11509 number in the file.  Note that in the case of the Zero Cost Exception
11510 mechanism, these messages become redundant with the Exception_Information that
11511 contains a full backtrace of the calling sequence, so they are disabled.
11512 To disable explicitly the generation of the source location message, use the
11513 Pragma @code{Discard_Names}.
11515 @cindex Suppression of checks
11516 @cindex Checks, suppression of
11517 @unnumberedsec 11.5(28): Suppression of Checks
11518 @sp 1
11519 @cartouche
11520 The implementation should minimize the code executed for checks that
11521 have been suppressed.
11522 @end cartouche
11523 Followed.
11525 @cindex Representation clauses
11526 @unnumberedsec 13.1 (21-24): Representation Clauses
11527 @sp 1
11528 @cartouche
11529 The recommended level of support for all representation items is
11530 qualified as follows:
11531 @end cartouche
11532 @sp 1
11533 @cartouche
11534 An implementation need not support representation items containing
11535 non-static expressions, except that an implementation should support a
11536 representation item for a given entity if each non-static expression in
11537 the representation item is a name that statically denotes a constant
11538 declared before the entity.
11539 @end cartouche
11540 Followed.  In fact, GNAT goes beyond the recommended level of support
11541 by allowing nonstatic expressions in some representation clauses even
11542 without the need to declare constants initialized with the values of
11543 such expressions.
11544 For example:
11546 @smallexample @c ada
11547   X : Integer;
11548   Y : Float;
11549   for Y'Address use X'Address;>>
11550 @end smallexample
11552 @sp 1
11553 @cartouche
11554 An implementation need not support a specification for the @code{Size}
11555 for a given composite subtype, nor the size or storage place for an
11556 object (including a component) of a given composite subtype, unless the
11557 constraints on the subtype and its composite subcomponents (if any) are
11558 all static constraints.
11559 @end cartouche
11560 Followed.  Size Clauses are not permitted on non-static components, as
11561 described above.
11563 @sp 1
11564 @cartouche
11565 An aliased component, or a component whose type is by-reference, should
11566 always be allocated at an addressable location.
11567 @end cartouche
11568 Followed.
11570 @cindex Packed types
11571 @unnumberedsec 13.2(6-8): Packed Types
11572 @sp 1
11573 @cartouche
11574 If a type is packed, then the implementation should try to minimize
11575 storage allocated to objects of the type, possibly at the expense of
11576 speed of accessing components, subject to reasonable complexity in
11577 addressing calculations.
11578 @end cartouche
11579 @sp 1
11580 @cartouche
11581 The recommended level of support pragma @code{Pack} is:
11583 For a packed record type, the components should be packed as tightly as
11584 possible subject to the Sizes of the component subtypes, and subject to
11585 any @code{record_representation_clause} that applies to the type; the
11586 implementation may, but need not, reorder components or cross aligned
11587 word boundaries to improve the packing.  A component whose @code{Size} is
11588 greater than the word size may be allocated an integral number of words.
11589 @end cartouche
11590 Followed.  Tight packing of arrays is supported for all component sizes
11591 up to 64-bits. If the array component size is 1 (that is to say, if
11592 the component is a boolean type or an enumeration type with two values)
11593 then values of the type are implicitly initialized to zero. This
11594 happens both for objects of the packed type, and for objects that have a
11595 subcomponent of the packed type.
11597 @sp 1
11598 @cartouche
11599 An implementation should support Address clauses for imported
11600 subprograms.
11601 @end cartouche
11602 Followed.
11603 @cindex @code{Address} clauses
11604 @unnumberedsec 13.3(14-19): Address Clauses
11606 @sp 1
11607 @cartouche
11608 For an array @var{X}, @code{@var{X}'Address} should point at the first
11609 component of the array, and not at the array bounds.
11610 @end cartouche
11611 Followed.
11613 @sp 1
11614 @cartouche
11615 The recommended level of support for the @code{Address} attribute is:
11617 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11618 object that is aliased or of a by-reference type, or is an entity whose
11619 @code{Address} has been specified.
11620 @end cartouche
11621 Followed.  A valid address will be produced even if none of those
11622 conditions have been met.  If necessary, the object is forced into
11623 memory to ensure the address is valid.
11625 @sp 1
11626 @cartouche
11627 An implementation should support @code{Address} clauses for imported
11628 subprograms.
11629 @end cartouche
11630 Followed.
11632 @sp 1
11633 @cartouche
11634 Objects (including subcomponents) that are aliased or of a by-reference
11635 type should be allocated on storage element boundaries.
11636 @end cartouche
11637 Followed.
11639 @sp 1
11640 @cartouche
11641 If the @code{Address} of an object is specified, or it is imported or exported,
11642 then the implementation should not perform optimizations based on
11643 assumptions of no aliases.
11644 @end cartouche
11645 Followed.
11647 @cindex @code{Alignment} clauses
11648 @unnumberedsec 13.3(29-35): Alignment Clauses
11649 @sp 1
11650 @cartouche
11651 The recommended level of support for the @code{Alignment} attribute for
11652 subtypes is:
11654 An implementation should support specified Alignments that are factors
11655 and multiples of the number of storage elements per word, subject to the
11656 following:
11657 @end cartouche
11658 Followed.
11660 @sp 1
11661 @cartouche
11662 An implementation need not support specified @code{Alignment}s for
11663 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11664 loaded and stored by available machine instructions.
11665 @end cartouche
11666 Followed.
11668 @sp 1
11669 @cartouche
11670 An implementation need not support specified @code{Alignment}s that are
11671 greater than the maximum @code{Alignment} the implementation ever returns by
11672 default.
11673 @end cartouche
11674 Followed.
11676 @sp 1
11677 @cartouche
11678 The recommended level of support for the @code{Alignment} attribute for
11679 objects is:
11681 Same as above, for subtypes, but in addition:
11682 @end cartouche
11683 Followed.
11685 @sp 1
11686 @cartouche
11687 For stand-alone library-level objects of statically constrained
11688 subtypes, the implementation should support all @code{Alignment}s
11689 supported by the target linker.  For example, page alignment is likely to
11690 be supported for such objects, but not for subtypes.
11691 @end cartouche
11692 Followed.
11694 @cindex @code{Size} clauses
11695 @unnumberedsec 13.3(42-43): Size Clauses
11696 @sp 1
11697 @cartouche
11698 The recommended level of support for the @code{Size} attribute of
11699 objects is:
11701 A @code{Size} clause should be supported for an object if the specified
11702 @code{Size} is at least as large as its subtype's @code{Size}, and
11703 corresponds to a size in storage elements that is a multiple of the
11704 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11705 @end cartouche
11706 Followed.
11708 @unnumberedsec 13.3(50-56): Size Clauses
11709 @sp 1
11710 @cartouche
11711 If the @code{Size} of a subtype is specified, and allows for efficient
11712 independent addressability (see 9.10) on the target architecture, then
11713 the @code{Size} of the following objects of the subtype should equal the
11714 @code{Size} of the subtype:
11716 Aliased objects (including components).
11717 @end cartouche
11718 Followed.
11720 @sp 1
11721 @cartouche
11722 @code{Size} clause on a composite subtype should not affect the
11723 internal layout of components.
11724 @end cartouche
11725 Followed. But note that this can be overridden by use of the implementation
11726 pragma Implicit_Packing in the case of packed arrays.
11728 @sp 1
11729 @cartouche
11730 The recommended level of support for the @code{Size} attribute of subtypes is:
11731 @end cartouche
11732 @sp 1
11733 @cartouche
11734 The @code{Size} (if not specified) of a static discrete or fixed point
11735 subtype should be the number of bits needed to represent each value
11736 belonging to the subtype using an unbiased representation, leaving space
11737 for a sign bit only if the subtype contains negative values.  If such a
11738 subtype is a first subtype, then an implementation should support a
11739 specified @code{Size} for it that reflects this representation.
11740 @end cartouche
11741 Followed.
11743 @sp 1
11744 @cartouche
11745 For a subtype implemented with levels of indirection, the @code{Size}
11746 should include the size of the pointers, but not the size of what they
11747 point at.
11748 @end cartouche
11749 Followed.
11751 @cindex @code{Component_Size} clauses
11752 @unnumberedsec 13.3(71-73): Component Size Clauses
11753 @sp 1
11754 @cartouche
11755 The recommended level of support for the @code{Component_Size}
11756 attribute is:
11757 @end cartouche
11758 @sp 1
11759 @cartouche
11760 An implementation need not support specified @code{Component_Sizes} that are
11761 less than the @code{Size} of the component subtype.
11762 @end cartouche
11763 Followed.
11765 @sp 1
11766 @cartouche
11767 An implementation should support specified @code{Component_Size}s that
11768 are factors and multiples of the word size.  For such
11769 @code{Component_Size}s, the array should contain no gaps between
11770 components.  For other @code{Component_Size}s (if supported), the array
11771 should contain no gaps between components when packing is also
11772 specified; the implementation should forbid this combination in cases
11773 where it cannot support a no-gaps representation.
11774 @end cartouche
11775 Followed.
11777 @cindex Enumeration representation clauses
11778 @cindex Representation clauses, enumeration
11779 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11780 @sp 1
11781 @cartouche
11782 The recommended level of support for enumeration representation clauses
11785 An implementation need not support enumeration representation clauses
11786 for boolean types, but should at minimum support the internal codes in
11787 the range @code{System.Min_Int.System.Max_Int}.
11788 @end cartouche
11789 Followed.
11791 @cindex Record representation clauses
11792 @cindex Representation clauses, records
11793 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11794 @sp 1
11795 @cartouche
11796 The recommended level of support for
11797 @*@code{record_representation_clauses} is:
11799 An implementation should support storage places that can be extracted
11800 with a load, mask, shift sequence of machine code, and set with a load,
11801 shift, mask, store sequence, given the available machine instructions
11802 and run-time model.
11803 @end cartouche
11804 Followed.
11806 @sp 1
11807 @cartouche
11808 A storage place should be supported if its size is equal to the
11809 @code{Size} of the component subtype, and it starts and ends on a
11810 boundary that obeys the @code{Alignment} of the component subtype.
11811 @end cartouche
11812 Followed.
11814 @sp 1
11815 @cartouche
11816 If the default bit ordering applies to the declaration of a given type,
11817 then for a component whose subtype's @code{Size} is less than the word
11818 size, any storage place that does not cross an aligned word boundary
11819 should be supported.
11820 @end cartouche
11821 Followed.
11823 @sp 1
11824 @cartouche
11825 An implementation may reserve a storage place for the tag field of a
11826 tagged type, and disallow other components from overlapping that place.
11827 @end cartouche
11828 Followed.  The storage place for the tag field is the beginning of the tagged
11829 record, and its size is Address'Size.  GNAT will reject an explicit component
11830 clause for the tag field.
11832 @sp 1
11833 @cartouche
11834 An implementation need not support a @code{component_clause} for a
11835 component of an extension part if the storage place is not after the
11836 storage places of all components of the parent type, whether or not
11837 those storage places had been specified.
11838 @end cartouche
11839 Followed.  The above advice on record representation clauses is followed,
11840 and all mentioned features are implemented.
11842 @cindex Storage place attributes
11843 @unnumberedsec 13.5.2(5): Storage Place Attributes
11844 @sp 1
11845 @cartouche
11846 If a component is represented using some form of pointer (such as an
11847 offset) to the actual data of the component, and this data is contiguous
11848 with the rest of the object, then the storage place attributes should
11849 reflect the place of the actual data, not the pointer.  If a component is
11850 allocated discontinuously from the rest of the object, then a warning
11851 should be generated upon reference to one of its storage place
11852 attributes.
11853 @end cartouche
11854 Followed.  There are no such components in GNAT@.
11856 @cindex Bit ordering
11857 @unnumberedsec 13.5.3(7-8): Bit Ordering
11858 @sp 1
11859 @cartouche
11860 The recommended level of support for the non-default bit ordering is:
11861 @end cartouche
11862 @sp 1
11863 @cartouche
11864 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11865 should support the non-default bit ordering in addition to the default
11866 bit ordering.
11867 @end cartouche
11868 Followed.  Word size does not equal storage size in this implementation.
11869 Thus non-default bit ordering is not supported.
11871 @cindex @code{Address}, as private type
11872 @unnumberedsec 13.7(37): Address as Private
11873 @sp 1
11874 @cartouche
11875 @code{Address} should be of a private type.
11876 @end cartouche
11877 Followed.
11879 @cindex Operations, on @code{Address}
11880 @cindex @code{Address}, operations of
11881 @unnumberedsec 13.7.1(16): Address Operations
11882 @sp 1
11883 @cartouche
11884 Operations in @code{System} and its children should reflect the target
11885 environment semantics as closely as is reasonable.  For example, on most
11886 machines, it makes sense for address arithmetic to ``wrap around''.
11887 Operations that do not make sense should raise @code{Program_Error}.
11888 @end cartouche
11889 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
11890 operation raises @code{Program_Error}, since all operations make sense.
11892 @cindex Unchecked conversion
11893 @unnumberedsec 13.9(14-17): Unchecked Conversion
11894 @sp 1
11895 @cartouche
11896 The @code{Size} of an array object should not include its bounds; hence,
11897 the bounds should not be part of the converted data.
11898 @end cartouche
11899 Followed.
11901 @sp 1
11902 @cartouche
11903 The implementation should not generate unnecessary run-time checks to
11904 ensure that the representation of @var{S} is a representation of the
11905 target type.  It should take advantage of the permission to return by
11906 reference when possible.  Restrictions on unchecked conversions should be
11907 avoided unless required by the target environment.
11908 @end cartouche
11909 Followed.  There are no restrictions on unchecked conversion.  A warning is
11910 generated if the source and target types do not have the same size since
11911 the semantics in this case may be target dependent.
11913 @sp 1
11914 @cartouche
11915 The recommended level of support for unchecked conversions is:
11916 @end cartouche
11917 @sp 1
11918 @cartouche
11919 Unchecked conversions should be supported and should be reversible in
11920 the cases where this clause defines the result.  To enable meaningful use
11921 of unchecked conversion, a contiguous representation should be used for
11922 elementary subtypes, for statically constrained array subtypes whose
11923 component subtype is one of the subtypes described in this paragraph,
11924 and for record subtypes without discriminants whose component subtypes
11925 are described in this paragraph.
11926 @end cartouche
11927 Followed.
11929 @cindex Heap usage, implicit
11930 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11931 @sp 1
11932 @cartouche
11933 An implementation should document any cases in which it dynamically
11934 allocates heap storage for a purpose other than the evaluation of an
11935 allocator.
11936 @end cartouche
11937 Followed, the only other points at which heap storage is dynamically
11938 allocated are as follows:
11940 @itemize @bullet
11941 @item
11942 At initial elaboration time, to allocate dynamically sized global
11943 objects.
11945 @item
11946 To allocate space for a task when a task is created.
11948 @item
11949 To extend the secondary stack dynamically when needed.  The secondary
11950 stack is used for returning variable length results.
11951 @end itemize
11953 @sp 1
11954 @cartouche
11955 A default (implementation-provided) storage pool for an
11956 access-to-constant type should not have overhead to support deallocation of
11957 individual objects.
11958 @end cartouche
11959 Followed.
11961 @sp 1
11962 @cartouche
11963 A storage pool for an anonymous access type should be created at the
11964 point of an allocator for the type, and be reclaimed when the designated
11965 object becomes inaccessible.
11966 @end cartouche
11967 Followed.
11969 @cindex Unchecked deallocation
11970 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11971 @sp 1
11972 @cartouche
11973 For a standard storage pool, @code{Free} should actually reclaim the
11974 storage.
11975 @end cartouche
11976 Followed.
11978 @cindex Stream oriented attributes
11979 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11980 @sp 1
11981 @cartouche
11982 If a stream element is the same size as a storage element, then the
11983 normal in-memory representation should be used by @code{Read} and
11984 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
11985 should use the smallest number of stream elements needed to represent
11986 all values in the base range of the scalar type.
11987 @end cartouche
11989 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
11990 which specifies using the size of the first subtype.
11991 However, such an implementation is based on direct binary
11992 representations and is therefore target- and endianness-dependent.
11993 To address this issue, GNAT also supplies an alternate implementation
11994 of the stream attributes @code{Read} and @code{Write},
11995 which uses the target-independent XDR standard representation
11996 for scalar types.
11997 @cindex XDR representation
11998 @cindex @code{Read} attribute
11999 @cindex @code{Write} attribute
12000 @cindex Stream oriented attributes
12001 The XDR implementation is provided as an alternative body of the
12002 @code{System.Stream_Attributes} package, in the file
12003 @file{s-stratt-xdr.adb} in the GNAT library.
12004 There is no @file{s-stratt-xdr.ads} file.
12005 In order to install the XDR implementation, do the following:
12006 @enumerate
12007 @item Replace the default implementation of the
12008 @code{System.Stream_Attributes} package with the XDR implementation.
12009 For example on a Unix platform issue the commands:
12010 @smallexample
12011 $ mv s-stratt.adb s-stratt-default.adb
12012 $ mv s-stratt-xdr.adb s-stratt.adb
12013 @end smallexample
12015 @item
12016 Rebuild the GNAT run-time library as documented in
12017 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
12018 @end enumerate
12020 @unnumberedsec A.1(52): Names of Predefined Numeric Types
12021 @sp 1
12022 @cartouche
12023 If an implementation provides additional named predefined integer types,
12024 then the names should end with @samp{Integer} as in
12025 @samp{Long_Integer}.  If an implementation provides additional named
12026 predefined floating point types, then the names should end with
12027 @samp{Float} as in @samp{Long_Float}.
12028 @end cartouche
12029 Followed.
12031 @findex Ada.Characters.Handling
12032 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
12033 @sp 1
12034 @cartouche
12035 If an implementation provides a localized definition of @code{Character}
12036 or @code{Wide_Character}, then the effects of the subprograms in
12037 @code{Characters.Handling} should reflect the localizations.  See also
12038 3.5.2.
12039 @end cartouche
12040 Followed.  GNAT provides no such localized definitions.
12042 @cindex Bounded-length strings
12043 @unnumberedsec A.4.4(106): Bounded-Length String Handling
12044 @sp 1
12045 @cartouche
12046 Bounded string objects should not be implemented by implicit pointers
12047 and dynamic allocation.
12048 @end cartouche
12049 Followed.  No implicit pointers or dynamic allocation are used.
12051 @cindex Random number generation
12052 @unnumberedsec A.5.2(46-47): Random Number Generation
12053 @sp 1
12054 @cartouche
12055 Any storage associated with an object of type @code{Generator} should be
12056 reclaimed on exit from the scope of the object.
12057 @end cartouche
12058 Followed.
12060 @sp 1
12061 @cartouche
12062 If the generator period is sufficiently long in relation to the number
12063 of distinct initiator values, then each possible value of
12064 @code{Initiator} passed to @code{Reset} should initiate a sequence of
12065 random numbers that does not, in a practical sense, overlap the sequence
12066 initiated by any other value.  If this is not possible, then the mapping
12067 between initiator values and generator states should be a rapidly
12068 varying function of the initiator value.
12069 @end cartouche
12070 Followed.  The generator period is sufficiently long for the first
12071 condition here to hold true.
12073 @findex Get_Immediate
12074 @unnumberedsec A.10.7(23): @code{Get_Immediate}
12075 @sp 1
12076 @cartouche
12077 The @code{Get_Immediate} procedures should be implemented with
12078 unbuffered input.  For a device such as a keyboard, input should be
12079 @dfn{available} if a key has already been typed, whereas for a disk
12080 file, input should always be available except at end of file.  For a file
12081 associated with a keyboard-like device, any line-editing features of the
12082 underlying operating system should be disabled during the execution of
12083 @code{Get_Immediate}.
12084 @end cartouche
12085 Followed on all targets except VxWorks. For VxWorks, there is no way to
12086 provide this functionality that does not result in the input buffer being
12087 flushed before the @code{Get_Immediate} call. A special unit
12088 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
12089 this functionality.
12091 @findex Export
12092 @unnumberedsec B.1(39-41): Pragma @code{Export}
12093 @sp 1
12094 @cartouche
12095 If an implementation supports pragma @code{Export} to a given language,
12096 then it should also allow the main subprogram to be written in that
12097 language.  It should support some mechanism for invoking the elaboration
12098 of the Ada library units included in the system, and for invoking the
12099 finalization of the environment task.  On typical systems, the
12100 recommended mechanism is to provide two subprograms whose link names are
12101 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
12102 elaboration code for library units.  @code{adafinal} should contain the
12103 finalization code.  These subprograms should have no effect the second
12104 and subsequent time they are called.
12105 @end cartouche
12106 Followed.
12108 @sp 1
12109 @cartouche
12110 Automatic elaboration of pre-elaborated packages should be
12111 provided when pragma @code{Export} is supported.
12112 @end cartouche
12113 Followed when the main program is in Ada.  If the main program is in a
12114 foreign language, then
12115 @code{adainit} must be called to elaborate pre-elaborated
12116 packages.
12118 @sp 1
12119 @cartouche
12120 For each supported convention @var{L} other than @code{Intrinsic}, an
12121 implementation should support @code{Import} and @code{Export} pragmas
12122 for objects of @var{L}-compatible types and for subprograms, and pragma
12123 @code{Convention} for @var{L}-eligible types and for subprograms,
12124 presuming the other language has corresponding features.  Pragma
12125 @code{Convention} need not be supported for scalar types.
12126 @end cartouche
12127 Followed.
12129 @cindex Package @code{Interfaces}
12130 @findex Interfaces
12131 @unnumberedsec B.2(12-13): Package @code{Interfaces}
12132 @sp 1
12133 @cartouche
12134 For each implementation-defined convention identifier, there should be a
12135 child package of package Interfaces with the corresponding name.  This
12136 package should contain any declarations that would be useful for
12137 interfacing to the language (implementation) represented by the
12138 convention.  Any declarations useful for interfacing to any language on
12139 the given hardware architecture should be provided directly in
12140 @code{Interfaces}.
12141 @end cartouche
12142 Followed.
12144 @sp 1
12145 @cartouche
12146 An implementation supporting an interface to C, COBOL, or Fortran should
12147 provide the corresponding package or packages described in the following
12148 clauses.
12149 @end cartouche
12150 Followed.  GNAT provides all the packages described in this section.
12152 @cindex C, interfacing with
12153 @unnumberedsec B.3(63-71): Interfacing with C
12154 @sp 1
12155 @cartouche
12156 An implementation should support the following interface correspondences
12157 between Ada and C@.
12158 @end cartouche
12159 Followed.
12161 @sp 1
12162 @cartouche
12163 An Ada procedure corresponds to a void-returning C function.
12164 @end cartouche
12165 Followed.
12167 @sp 1
12168 @cartouche
12169 An Ada function corresponds to a non-void C function.
12170 @end cartouche
12171 Followed.
12173 @sp 1
12174 @cartouche
12175 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
12176 function.
12177 @end cartouche
12178 Followed.
12180 @sp 1
12181 @cartouche
12182 An Ada @code{in} parameter of an access-to-object type with designated
12183 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
12184 where @var{t} is the C type corresponding to the Ada type @var{T}.
12185 @end cartouche
12186 Followed.
12188 @sp 1
12189 @cartouche
12190 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
12191 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
12192 argument to a C function, where @var{t} is the C type corresponding to
12193 the Ada type @var{T}.  In the case of an elementary @code{out} or
12194 @code{in out} parameter, a pointer to a temporary copy is used to
12195 preserve by-copy semantics.
12196 @end cartouche
12197 Followed.
12199 @sp 1
12200 @cartouche
12201 An Ada parameter of a record type @var{T}, of any mode, is passed as a
12202 @code{@var{t}*} argument to a C function, where @var{t} is the C
12203 structure corresponding to the Ada type @var{T}.
12204 @end cartouche
12205 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
12206 pragma, or Convention, or by explicitly specifying the mechanism for a given
12207 call using an extended import or export pragma.
12209 @sp 1
12210 @cartouche
12211 An Ada parameter of an array type with component type @var{T}, of any
12212 mode, is passed as a @code{@var{t}*} argument to a C function, where
12213 @var{t} is the C type corresponding to the Ada type @var{T}.
12214 @end cartouche
12215 Followed.
12217 @sp 1
12218 @cartouche
12219 An Ada parameter of an access-to-subprogram type is passed as a pointer
12220 to a C function whose prototype corresponds to the designated
12221 subprogram's specification.
12222 @end cartouche
12223 Followed.
12225 @cindex COBOL, interfacing with
12226 @unnumberedsec B.4(95-98): Interfacing with COBOL
12227 @sp 1
12228 @cartouche
12229 An Ada implementation should support the following interface
12230 correspondences between Ada and COBOL@.
12231 @end cartouche
12232 Followed.
12234 @sp 1
12235 @cartouche
12236 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
12237 the COBOL type corresponding to @var{T}.
12238 @end cartouche
12239 Followed.
12241 @sp 1
12242 @cartouche
12243 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
12244 the corresponding COBOL type.
12245 @end cartouche
12246 Followed.
12248 @sp 1
12249 @cartouche
12250 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
12251 COBOL type corresponding to the Ada parameter type; for scalars, a local
12252 copy is used if necessary to ensure by-copy semantics.
12253 @end cartouche
12254 Followed.
12256 @cindex Fortran, interfacing with
12257 @unnumberedsec B.5(22-26): Interfacing with Fortran
12258 @sp 1
12259 @cartouche
12260 An Ada implementation should support the following interface
12261 correspondences between Ada and Fortran:
12262 @end cartouche
12263 Followed.
12265 @sp 1
12266 @cartouche
12267 An Ada procedure corresponds to a Fortran subroutine.
12268 @end cartouche
12269 Followed.
12271 @sp 1
12272 @cartouche
12273 An Ada function corresponds to a Fortran function.
12274 @end cartouche
12275 Followed.
12277 @sp 1
12278 @cartouche
12279 An Ada parameter of an elementary, array, or record type @var{T} is
12280 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
12281 the Fortran type corresponding to the Ada type @var{T}, and where the
12282 INTENT attribute of the corresponding dummy argument matches the Ada
12283 formal parameter mode; the Fortran implementation's parameter passing
12284 conventions are used.  For elementary types, a local copy is used if
12285 necessary to ensure by-copy semantics.
12286 @end cartouche
12287 Followed.
12289 @sp 1
12290 @cartouche
12291 An Ada parameter of an access-to-subprogram type is passed as a
12292 reference to a Fortran procedure whose interface corresponds to the
12293 designated subprogram's specification.
12294 @end cartouche
12295 Followed.
12297 @cindex Machine operations
12298 @unnumberedsec C.1(3-5): Access to Machine Operations
12299 @sp 1
12300 @cartouche
12301 The machine code or intrinsic support should allow access to all
12302 operations normally available to assembly language programmers for the
12303 target environment, including privileged instructions, if any.
12304 @end cartouche
12305 Followed.
12307 @sp 1
12308 @cartouche
12309 The interfacing pragmas (see Annex B) should support interface to
12310 assembler; the default assembler should be associated with the
12311 convention identifier @code{Assembler}.
12312 @end cartouche
12313 Followed.
12315 @sp 1
12316 @cartouche
12317 If an entity is exported to assembly language, then the implementation
12318 should allocate it at an addressable location, and should ensure that it
12319 is retained by the linking process, even if not otherwise referenced
12320 from the Ada code.  The implementation should assume that any call to a
12321 machine code or assembler subprogram is allowed to read or update every
12322 object that is specified as exported.
12323 @end cartouche
12324 Followed.
12326 @unnumberedsec C.1(10-16): Access to Machine Operations
12327 @sp 1
12328 @cartouche
12329 The implementation should ensure that little or no overhead is
12330 associated with calling intrinsic and machine-code subprograms.
12331 @end cartouche
12332 Followed for both intrinsics and machine-code subprograms.
12334 @sp 1
12335 @cartouche
12336 It is recommended that intrinsic subprograms be provided for convenient
12337 access to any machine operations that provide special capabilities or
12338 efficiency and that are not otherwise available through the language
12339 constructs.
12340 @end cartouche
12341 Followed.  A full set of machine operation intrinsic subprograms is provided.
12343 @sp 1
12344 @cartouche
12345 Atomic read-modify-write operations---e.g.@:, test and set, compare and
12346 swap, decrement and test, enqueue/dequeue.
12347 @end cartouche
12348 Followed on any target supporting such operations.
12350 @sp 1
12351 @cartouche
12352 Standard numeric functions---e.g.@:, sin, log.
12353 @end cartouche
12354 Followed on any target supporting such operations.
12356 @sp 1
12357 @cartouche
12358 String manipulation operations---e.g.@:, translate and test.
12359 @end cartouche
12360 Followed on any target supporting such operations.
12362 @sp 1
12363 @cartouche
12364 Vector operations---e.g.@:, compare vector against thresholds.
12365 @end cartouche
12366 Followed on any target supporting such operations.
12368 @sp 1
12369 @cartouche
12370 Direct operations on I/O ports.
12371 @end cartouche
12372 Followed on any target supporting such operations.
12374 @cindex Interrupt support
12375 @unnumberedsec C.3(28): Interrupt Support
12376 @sp 1
12377 @cartouche
12378 If the @code{Ceiling_Locking} policy is not in effect, the
12379 implementation should provide means for the application to specify which
12380 interrupts are to be blocked during protected actions, if the underlying
12381 system allows for a finer-grain control of interrupt blocking.
12382 @end cartouche
12383 Followed.  The underlying system does not allow for finer-grain control
12384 of interrupt blocking.
12386 @cindex Protected procedure handlers
12387 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12388 @sp 1
12389 @cartouche
12390 Whenever possible, the implementation should allow interrupt handlers to
12391 be called directly by the hardware.
12392 @end cartouche
12393 Followed on any target where the underlying operating system permits
12394 such direct calls.
12396 @sp 1
12397 @cartouche
12398 Whenever practical, violations of any
12399 implementation-defined restrictions should be detected before run time.
12400 @end cartouche
12401 Followed.  Compile time warnings are given when possible.
12403 @cindex Package @code{Interrupts}
12404 @findex Interrupts
12405 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12407 @sp 1
12408 @cartouche
12409 If implementation-defined forms of interrupt handler procedures are
12410 supported, such as protected procedures with parameters, then for each
12411 such form of a handler, a type analogous to @code{Parameterless_Handler}
12412 should be specified in a child package of @code{Interrupts}, with the
12413 same operations as in the predefined package Interrupts.
12414 @end cartouche
12415 Followed.
12417 @cindex Pre-elaboration requirements
12418 @unnumberedsec C.4(14): Pre-elaboration Requirements
12419 @sp 1
12420 @cartouche
12421 It is recommended that pre-elaborated packages be implemented in such a
12422 way that there should be little or no code executed at run time for the
12423 elaboration of entities not already covered by the Implementation
12424 Requirements.
12425 @end cartouche
12426 Followed.  Executable code is generated in some cases, e.g.@: loops
12427 to initialize large arrays.
12429 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12430 @sp 1
12431 @cartouche
12432 If the pragma applies to an entity, then the implementation should
12433 reduce the amount of storage used for storing names associated with that
12434 entity.
12435 @end cartouche
12436 Followed.
12438 @cindex Package @code{Task_Attributes}
12439 @findex Task_Attributes
12440 @unnumberedsec C.7.2(30): The Package Task_Attributes
12441 @sp 1
12442 @cartouche
12443 Some implementations are targeted to domains in which memory use at run
12444 time must be completely deterministic.  For such implementations, it is
12445 recommended that the storage for task attributes will be pre-allocated
12446 statically and not from the heap.  This can be accomplished by either
12447 placing restrictions on the number and the size of the task's
12448 attributes, or by using the pre-allocated storage for the first @var{N}
12449 attribute objects, and the heap for the others.  In the latter case,
12450 @var{N} should be documented.
12451 @end cartouche
12452 Not followed.  This implementation is not targeted to such a domain.
12454 @cindex Locking Policies
12455 @unnumberedsec D.3(17): Locking Policies
12457 @sp 1
12458 @cartouche
12459 The implementation should use names that end with @samp{_Locking} for
12460 locking policies defined by the implementation.
12461 @end cartouche
12462 Followed.  Two implementation-defined locking policies are defined,
12463 whose names (@code{Inheritance_Locking} and
12464 @code{Concurrent_Readers_Locking}) follow this suggestion.
12466 @cindex Entry queuing policies
12467 @unnumberedsec D.4(16): Entry Queuing Policies
12468 @sp 1
12469 @cartouche
12470 Names that end with @samp{_Queuing} should be used
12471 for all implementation-defined queuing policies.
12472 @end cartouche
12473 Followed.  No such implementation-defined queuing policies exist.
12475 @cindex Preemptive abort
12476 @unnumberedsec D.6(9-10): Preemptive Abort
12477 @sp 1
12478 @cartouche
12479 Even though the @code{abort_statement} is included in the list of
12480 potentially blocking operations (see 9.5.1), it is recommended that this
12481 statement be implemented in a way that never requires the task executing
12482 the @code{abort_statement} to block.
12483 @end cartouche
12484 Followed.
12486 @sp 1
12487 @cartouche
12488 On a multi-processor, the delay associated with aborting a task on
12489 another processor should be bounded; the implementation should use
12490 periodic polling, if necessary, to achieve this.
12491 @end cartouche
12492 Followed.
12494 @cindex Tasking restrictions
12495 @unnumberedsec D.7(21): Tasking Restrictions
12496 @sp 1
12497 @cartouche
12498 When feasible, the implementation should take advantage of the specified
12499 restrictions to produce a more efficient implementation.
12500 @end cartouche
12501 GNAT currently takes advantage of these restrictions by providing an optimized
12502 run time when the Ravenscar profile and the GNAT restricted run time set
12503 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
12504 pragma @code{Profile (Restricted)} for more details.
12506 @cindex Time, monotonic
12507 @unnumberedsec D.8(47-49): Monotonic Time
12508 @sp 1
12509 @cartouche
12510 When appropriate, implementations should provide configuration
12511 mechanisms to change the value of @code{Tick}.
12512 @end cartouche
12513 Such configuration mechanisms are not appropriate to this implementation
12514 and are thus not supported.
12516 @sp 1
12517 @cartouche
12518 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12519 be implemented as transformations of the same time base.
12520 @end cartouche
12521 Followed.
12523 @sp 1
12524 @cartouche
12525 It is recommended that the @dfn{best} time base which exists in
12526 the underlying system be available to the application through
12527 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
12528 @end cartouche
12529 Followed.
12531 @cindex Partition communication subsystem
12532 @cindex PCS
12533 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12534 @sp 1
12535 @cartouche
12536 Whenever possible, the PCS on the called partition should allow for
12537 multiple tasks to call the RPC-receiver with different messages and
12538 should allow them to block until the corresponding subprogram body
12539 returns.
12540 @end cartouche
12541 Followed by GLADE, a separately supplied PCS that can be used with
12542 GNAT.
12544 @sp 1
12545 @cartouche
12546 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12547 should raise @code{Storage_Error} if it runs out of space trying to
12548 write the @code{Item} into the stream.
12549 @end cartouche
12550 Followed by GLADE, a separately supplied PCS that can be used with
12551 GNAT@.
12553 @cindex COBOL support
12554 @unnumberedsec F(7): COBOL Support
12555 @sp 1
12556 @cartouche
12557 If COBOL (respectively, C) is widely supported in the target
12558 environment, implementations supporting the Information Systems Annex
12559 should provide the child package @code{Interfaces.COBOL} (respectively,
12560 @code{Interfaces.C}) specified in Annex B and should support a
12561 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12562 pragmas (see Annex B), thus allowing Ada programs to interface with
12563 programs written in that language.
12564 @end cartouche
12565 Followed.
12567 @cindex Decimal radix support
12568 @unnumberedsec F.1(2): Decimal Radix Support
12569 @sp 1
12570 @cartouche
12571 Packed decimal should be used as the internal representation for objects
12572 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12573 @end cartouche
12574 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
12575 representations.
12577 @cindex Numerics
12578 @unnumberedsec G: Numerics
12579 @sp 2
12580 @cartouche
12581 If Fortran (respectively, C) is widely supported in the target
12582 environment, implementations supporting the Numerics Annex
12583 should provide the child package @code{Interfaces.Fortran} (respectively,
12584 @code{Interfaces.C}) specified in Annex B and should support a
12585 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12586 pragmas (see Annex B), thus allowing Ada programs to interface with
12587 programs written in that language.
12588 @end cartouche
12589 Followed.
12591 @cindex Complex types
12592 @unnumberedsec G.1.1(56-58): Complex Types
12593 @sp 2
12594 @cartouche
12595 Because the usual mathematical meaning of multiplication of a complex
12596 operand and a real operand is that of the scaling of both components of
12597 the former by the latter, an implementation should not perform this
12598 operation by first promoting the real operand to complex type and then
12599 performing a full complex multiplication.  In systems that, in the
12600 future, support an Ada binding to IEC 559:1989, the latter technique
12601 will not generate the required result when one of the components of the
12602 complex operand is infinite.  (Explicit multiplication of the infinite
12603 component by the zero component obtained during promotion yields a NaN
12604 that propagates into the final result.) Analogous advice applies in the
12605 case of multiplication of a complex operand and a pure-imaginary
12606 operand, and in the case of division of a complex operand by a real or
12607 pure-imaginary operand.
12608 @end cartouche
12609 Not followed.
12611 @sp 1
12612 @cartouche
12613 Similarly, because the usual mathematical meaning of addition of a
12614 complex operand and a real operand is that the imaginary operand remains
12615 unchanged, an implementation should not perform this operation by first
12616 promoting the real operand to complex type and then performing a full
12617 complex addition.  In implementations in which the @code{Signed_Zeros}
12618 attribute of the component type is @code{True} (and which therefore
12619 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12620 predefined arithmetic operations), the latter technique will not
12621 generate the required result when the imaginary component of the complex
12622 operand is a negatively signed zero.  (Explicit addition of the negative
12623 zero to the zero obtained during promotion yields a positive zero.)
12624 Analogous advice applies in the case of addition of a complex operand
12625 and a pure-imaginary operand, and in the case of subtraction of a
12626 complex operand and a real or pure-imaginary operand.
12627 @end cartouche
12628 Not followed.
12630 @sp 1
12631 @cartouche
12632 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12633 attempt to provide a rational treatment of the signs of zero results and
12634 result components.  As one example, the result of the @code{Argument}
12635 function should have the sign of the imaginary component of the
12636 parameter @code{X} when the point represented by that parameter lies on
12637 the positive real axis; as another, the sign of the imaginary component
12638 of the @code{Compose_From_Polar} function should be the same as
12639 (respectively, the opposite of) that of the @code{Argument} parameter when that
12640 parameter has a value of zero and the @code{Modulus} parameter has a
12641 nonnegative (respectively, negative) value.
12642 @end cartouche
12643 Followed.
12645 @cindex Complex elementary functions
12646 @unnumberedsec G.1.2(49): Complex Elementary Functions
12647 @sp 1
12648 @cartouche
12649 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12650 @code{True} should attempt to provide a rational treatment of the signs
12651 of zero results and result components.  For example, many of the complex
12652 elementary functions have components that are odd functions of one of
12653 the parameter components; in these cases, the result component should
12654 have the sign of the parameter component at the origin.  Other complex
12655 elementary functions have zero components whose sign is opposite that of
12656 a parameter component at the origin, or is always positive or always
12657 negative.
12658 @end cartouche
12659 Followed.
12661 @cindex Accuracy requirements
12662 @unnumberedsec G.2.4(19): Accuracy Requirements
12663 @sp 1
12664 @cartouche
12665 The versions of the forward trigonometric functions without a
12666 @code{Cycle} parameter should not be implemented by calling the
12667 corresponding version with a @code{Cycle} parameter of
12668 @code{2.0*Numerics.Pi}, since this will not provide the required
12669 accuracy in some portions of the domain.  For the same reason, the
12670 version of @code{Log} without a @code{Base} parameter should not be
12671 implemented by calling the corresponding version with a @code{Base}
12672 parameter of @code{Numerics.e}.
12673 @end cartouche
12674 Followed.
12676 @cindex Complex arithmetic accuracy
12677 @cindex Accuracy, complex arithmetic
12678 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12680 @sp 1
12681 @cartouche
12682 The version of the @code{Compose_From_Polar} function without a
12683 @code{Cycle} parameter should not be implemented by calling the
12684 corresponding version with a @code{Cycle} parameter of
12685 @code{2.0*Numerics.Pi}, since this will not provide the required
12686 accuracy in some portions of the domain.
12687 @end cartouche
12688 Followed.
12690 @cindex Sequential elaboration policy
12691 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12693 @sp 1
12694 @cartouche
12695 If the partition elaboration policy is @code{Sequential} and the
12696 Environment task becomes permanently blocked during elaboration then the
12697 partition is deadlocked and it is recommended that the partition be
12698 immediately terminated.
12699 @end cartouche
12700 Not followed.
12702 @c -----------------------------------------
12703 @node Implementation Defined Characteristics
12704 @chapter Implementation Defined Characteristics
12706 @noindent
12707 In addition to the implementation dependent pragmas and attributes, and the
12708 implementation advice, there are a number of other Ada features that are
12709 potentially implementation dependent and are designated as
12710 implementation-defined. These are mentioned throughout the Ada Reference
12711 Manual, and are summarized in Annex M@.
12713 A requirement for conforming Ada compilers is that they provide
12714 documentation describing how the implementation deals with each of these
12715 issues.  In this chapter you will find each point in Annex M listed,
12716 followed by a description of how GNAT
12717 handles the implementation dependence.
12719 You can use this chapter as a guide to minimizing implementation
12720 dependent features in your programs if portability to other compilers
12721 and other operating systems is an important consideration.  The numbers
12722 in each entry below correspond to the paragraph numbers in the Ada
12723 Reference Manual.
12726 @itemize @bullet
12727 @sp 1
12728 @item
12729 @cartouche
12730 @noindent
12731 Whether or not each recommendation given in Implementation
12732 Advice is followed.  See 1.1.2(37).
12733 @end cartouche
12734 @noindent
12735 @xref{Implementation Advice}.
12738 @sp 1
12739 @item
12740 @cartouche
12741 @noindent
12742 Capacity limitations of the implementation.  See 1.1.3(3).
12743 @end cartouche
12744 @noindent
12745 The complexity of programs that can be processed is limited only by the
12746 total amount of available virtual memory, and disk space for the
12747 generated object files.
12750 @sp 1
12751 @item
12752 @cartouche
12753 @noindent
12754 Variations from the standard that are impractical to avoid
12755 given the implementation's execution environment.  See 1.1.3(6).
12756 @end cartouche
12757 @noindent
12758 There are no variations from the standard.
12761 @sp 1
12762 @item
12763 @cartouche
12764 @noindent
12765 Which @code{code_statement}s cause external
12766 interactions.  See 1.1.3(10).
12767 @end cartouche
12768 @noindent
12769 Any @code{code_statement} can potentially cause external interactions.
12771 @sp 1
12772 @item
12773 @cartouche
12774 @noindent
12775 The coded representation for the text of an Ada
12776 program.  See 2.1(4).
12777 @end cartouche
12778 @noindent
12779 See separate section on source representation.
12782 @sp 1
12783 @item
12784 @cartouche
12785 @noindent
12786 The control functions allowed in comments.  See 2.1(14).
12787 @end cartouche
12788 @noindent
12789 See separate section on source representation.
12791 @sp 1
12792 @item
12793 @cartouche
12794 @noindent
12795 The representation for an end of line.  See 2.2(2).
12796 @end cartouche
12797 @noindent
12798 See separate section on source representation.
12800 @sp 1
12801 @item
12802 @cartouche
12803 @noindent
12804 Maximum supported line length and lexical element
12805 length.  See 2.2(15).
12806 @end cartouche
12807 @noindent
12808 The maximum line length is 255 characters and the maximum length of
12809 a lexical element is also 255 characters. This is the default setting
12810 if not overridden by the use of compiler switch @option{-gnaty} (which
12811 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12812 line length to be specified to be any value up to 32767. The maximum
12813 length of a lexical element is the same as the maximum line length.
12815 @sp 1
12816 @item
12817 @cartouche
12818 @noindent
12819 Implementation defined pragmas.  See 2.8(14).
12820 @end cartouche
12821 @noindent
12823 @xref{Implementation Defined Pragmas}.
12825 @sp 1
12826 @item
12827 @cartouche
12828 @noindent
12829 Effect of pragma @code{Optimize}.  See 2.8(27).
12830 @end cartouche
12831 @noindent
12832 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12833 parameter, checks that the optimization flag is set, and aborts if it is
12834 not.
12836 @sp 1
12837 @item
12838 @cartouche
12839 @noindent
12840 The sequence of characters of the value returned by
12841 @code{@var{S}'Image} when some of the graphic characters of
12842 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
12843 3.5(37).
12844 @end cartouche
12845 @noindent
12846 The sequence of characters is as defined by the wide character encoding
12847 method used for the source.  See section on source representation for
12848 further details.
12850 @sp 1
12851 @item
12852 @cartouche
12853 @noindent
12854 The predefined integer types declared in
12855 @code{Standard}.  See 3.5.4(25).
12856 @end cartouche
12857 @noindent
12858 @table @code
12859 @item Short_Short_Integer
12860 8 bit signed
12861 @item Short_Integer
12862 (Short) 16 bit signed
12863 @item Integer
12864 32 bit signed
12865 @item Long_Integer
12866 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12867 32 bit signed (all other targets)
12868 @item Long_Long_Integer
12869 64 bit signed
12870 @end table
12872 @sp 1
12873 @item
12874 @cartouche
12875 @noindent
12876 Any nonstandard integer types and the operators defined
12877 for them.  See 3.5.4(26).
12878 @end cartouche
12879 @noindent
12880 There are no nonstandard integer types.
12882 @sp 1
12883 @item
12884 @cartouche
12885 @noindent
12886 Any nonstandard real types and the operators defined for
12887 them.  See 3.5.6(8).
12888 @end cartouche
12889 @noindent
12890 There are no nonstandard real types.
12892 @sp 1
12893 @item
12894 @cartouche
12895 @noindent
12896 What combinations of requested decimal precision and range
12897 are supported for floating point types.  See 3.5.7(7).
12898 @end cartouche
12899 @noindent
12900 The precision and range is as defined by the IEEE standard.
12902 @sp 1
12903 @item
12904 @cartouche
12905 @noindent
12906 The predefined floating point types declared in
12907 @code{Standard}.  See 3.5.7(16).
12908 @end cartouche
12909 @noindent
12910 @table @code
12911 @item Short_Float
12912 32 bit IEEE short
12913 @item Float
12914 (Short) 32 bit IEEE short
12915 @item Long_Float
12916 64 bit IEEE long
12917 @item Long_Long_Float
12918 64 bit IEEE long (80 bit IEEE long on x86 processors)
12919 @end table
12921 @sp 1
12922 @item
12923 @cartouche
12924 @noindent
12925 The small of an ordinary fixed point type.  See 3.5.9(8).
12926 @end cartouche
12927 @noindent
12928 @code{Fine_Delta} is 2**(@minus{}63)
12930 @sp 1
12931 @item
12932 @cartouche
12933 @noindent
12934 What combinations of small, range, and digits are
12935 supported for fixed point types.  See 3.5.9(10).
12936 @end cartouche
12937 @noindent
12938 Any combinations are permitted that do not result in a small less than
12939 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12940 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12941 is 64 bits (true of all architectures except ia32), then the output from
12942 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
12943 is because floating-point conversions are used to convert fixed point.
12945 @sp 1
12946 @item
12947 @cartouche
12948 @noindent
12949 The result of @code{Tags.Expanded_Name} for types declared
12950 within an unnamed @code{block_statement}.  See 3.9(10).
12951 @end cartouche
12952 @noindent
12953 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12954 decimal integer are allocated.
12956 @sp 1
12957 @item
12958 @cartouche
12959 @noindent
12960 Implementation-defined attributes.  See 4.1.4(12).
12961 @end cartouche
12962 @noindent
12963 @xref{Implementation Defined Attributes}.
12965 @sp 1
12966 @item
12967 @cartouche
12968 @noindent
12969 Any implementation-defined time types.  See 9.6(6).
12970 @end cartouche
12971 @noindent
12972 There are no implementation-defined time types.
12974 @sp 1
12975 @item
12976 @cartouche
12977 @noindent
12978 The time base associated with relative delays.
12979 @end cartouche
12980 @noindent
12981 See 9.6(20).  The time base used is that provided by the C library
12982 function @code{gettimeofday}.
12984 @sp 1
12985 @item
12986 @cartouche
12987 @noindent
12988 The time base of the type @code{Calendar.Time}.  See
12989 9.6(23).
12990 @end cartouche
12991 @noindent
12992 The time base used is that provided by the C library function
12993 @code{gettimeofday}.
12995 @sp 1
12996 @item
12997 @cartouche
12998 @noindent
12999 The time zone used for package @code{Calendar}
13000 operations.  See 9.6(24).
13001 @end cartouche
13002 @noindent
13003 The time zone used by package @code{Calendar} is the current system time zone
13004 setting for local time, as accessed by the C library function
13005 @code{localtime}.
13007 @sp 1
13008 @item
13009 @cartouche
13010 @noindent
13011 Any limit on @code{delay_until_statements} of
13012 @code{select_statements}.  See 9.6(29).
13013 @end cartouche
13014 @noindent
13015 There are no such limits.
13017 @sp 1
13018 @item
13019 @cartouche
13020 @noindent
13021 Whether or not two non-overlapping parts of a composite
13022 object are independently addressable, in the case where packing, record
13023 layout, or @code{Component_Size} is specified for the object.  See
13024 9.10(1).
13025 @end cartouche
13026 @noindent
13027 Separate components are independently addressable if they do not share
13028 overlapping storage units.
13030 @sp 1
13031 @item
13032 @cartouche
13033 @noindent
13034 The representation for a compilation.  See 10.1(2).
13035 @end cartouche
13036 @noindent
13037 A compilation is represented by a sequence of files presented to the
13038 compiler in a single invocation of the @command{gcc} command.
13040 @sp 1
13041 @item
13042 @cartouche
13043 @noindent
13044 Any restrictions on compilations that contain multiple
13045 compilation_units.  See 10.1(4).
13046 @end cartouche
13047 @noindent
13048 No single file can contain more than one compilation unit, but any
13049 sequence of files can be presented to the compiler as a single
13050 compilation.
13052 @sp 1
13053 @item
13054 @cartouche
13055 @noindent
13056 The mechanisms for creating an environment and for adding
13057 and replacing compilation units.  See 10.1.4(3).
13058 @end cartouche
13059 @noindent
13060 See separate section on compilation model.
13062 @sp 1
13063 @item
13064 @cartouche
13065 @noindent
13066 The manner of explicitly assigning library units to a
13067 partition.  See 10.2(2).
13068 @end cartouche
13069 @noindent
13070 If a unit contains an Ada main program, then the Ada units for the partition
13071 are determined by recursive application of the rules in the Ada Reference
13072 Manual section 10.2(2-6).  In other words, the Ada units will be those that
13073 are needed by the main program, and then this definition of need is applied
13074 recursively to those units, and the partition contains the transitive
13075 closure determined by this relationship.  In short, all the necessary units
13076 are included, with no need to explicitly specify the list.  If additional
13077 units are required, e.g.@: by foreign language units, then all units must be
13078 mentioned in the context clause of one of the needed Ada units.
13080 If the partition contains no main program, or if the main program is in
13081 a language other than Ada, then GNAT
13082 provides the binder options @option{-z} and @option{-n} respectively, and in
13083 this case a list of units can be explicitly supplied to the binder for
13084 inclusion in the partition (all units needed by these units will also
13085 be included automatically).  For full details on the use of these
13086 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
13087 @value{EDITION} User's Guide}.
13089 @sp 1
13090 @item
13091 @cartouche
13092 @noindent
13093 The implementation-defined means, if any, of specifying
13094 which compilation units are needed by a given compilation unit.  See
13095 10.2(2).
13096 @end cartouche
13097 @noindent
13098 The units needed by a given compilation unit are as defined in
13099 the Ada Reference Manual section 10.2(2-6).  There are no
13100 implementation-defined pragmas or other implementation-defined
13101 means for specifying needed units.
13103 @sp 1
13104 @item
13105 @cartouche
13106 @noindent
13107 The manner of designating the main subprogram of a
13108 partition.  See 10.2(7).
13109 @end cartouche
13110 @noindent
13111 The main program is designated by providing the name of the
13112 corresponding @file{ALI} file as the input parameter to the binder.
13114 @sp 1
13115 @item
13116 @cartouche
13117 @noindent
13118 The order of elaboration of @code{library_items}.  See
13119 10.2(18).
13120 @end cartouche
13121 @noindent
13122 The first constraint on ordering is that it meets the requirements of
13123 Chapter 10 of the Ada Reference Manual.  This still leaves some
13124 implementation dependent choices, which are resolved by first
13125 elaborating bodies as early as possible (i.e., in preference to specs
13126 where there is a choice), and second by evaluating the immediate with
13127 clauses of a unit to determine the probably best choice, and
13128 third by elaborating in alphabetical order of unit names
13129 where a choice still remains.
13131 @sp 1
13132 @item
13133 @cartouche
13134 @noindent
13135 Parameter passing and function return for the main
13136 subprogram.  See 10.2(21).
13137 @end cartouche
13138 @noindent
13139 The main program has no parameters.  It may be a procedure, or a function
13140 returning an integer type.  In the latter case, the returned integer
13141 value is the return code of the program (overriding any value that
13142 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
13144 @sp 1
13145 @item
13146 @cartouche
13147 @noindent
13148 The mechanisms for building and running partitions.  See
13149 10.2(24).
13150 @end cartouche
13151 @noindent
13152 GNAT itself supports programs with only a single partition.  The GNATDIST
13153 tool provided with the GLADE package (which also includes an implementation
13154 of the PCS) provides a completely flexible method for building and running
13155 programs consisting of multiple partitions.  See the separate GLADE manual
13156 for details.
13158 @sp 1
13159 @item
13160 @cartouche
13161 @noindent
13162 The details of program execution, including program
13163 termination.  See 10.2(25).
13164 @end cartouche
13165 @noindent
13166 See separate section on compilation model.
13168 @sp 1
13169 @item
13170 @cartouche
13171 @noindent
13172 The semantics of any non-active partitions supported by the
13173 implementation.  See 10.2(28).
13174 @end cartouche
13175 @noindent
13176 Passive partitions are supported on targets where shared memory is
13177 provided by the operating system.  See the GLADE reference manual for
13178 further details.
13180 @sp 1
13181 @item
13182 @cartouche
13183 @noindent
13184 The information returned by @code{Exception_Message}.  See
13185 11.4.1(10).
13186 @end cartouche
13187 @noindent
13188 Exception message returns the null string unless a specific message has
13189 been passed by the program.
13191 @sp 1
13192 @item
13193 @cartouche
13194 @noindent
13195 The result of @code{Exceptions.Exception_Name} for types
13196 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
13197 @end cartouche
13198 @noindent
13199 Blocks have implementation defined names of the form @code{B@var{nnn}}
13200 where @var{nnn} is an integer.
13202 @sp 1
13203 @item
13204 @cartouche
13205 @noindent
13206 The information returned by
13207 @code{Exception_Information}.  See 11.4.1(13).
13208 @end cartouche
13209 @noindent
13210 @code{Exception_Information} returns a string in the following format:
13212 @smallexample
13213 @emph{Exception_Name:} nnnnn
13214 @emph{Message:} mmmmm
13215 @emph{PID:} ppp
13216 @emph{Load address:} 0xhhhh
13217 @emph{Call stack traceback locations:}
13218 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
13219 @end smallexample
13221 @noindent
13222 where
13224 @itemize @bullet
13225 @item
13226 @code{nnnn} is the fully qualified name of the exception in all upper
13227 case letters. This line is always present.
13229 @item
13230 @code{mmmm} is the message (this line present only if message is non-null)
13232 @item
13233 @code{ppp} is the Process Id value as a decimal integer (this line is
13234 present only if the Process Id is nonzero). Currently we are
13235 not making use of this field.
13237 @item
13238 The Load address line, the Call stack traceback locations line and the
13239 following values are present only if at least one traceback location was
13240 recorded. The Load address indicates the address at which the main executable
13241 was loaded; this line may not be present if operating system hasn't relocated
13242 the main executable. The values are given in C style format, with lower case
13243 letters for a-f, and only as many digits present as are necessary.
13244 @end itemize
13246 @noindent
13247 The line terminator sequence at the end of each line, including
13248 the last line is a single @code{LF} character (@code{16#0A#}).
13250 @sp 1
13251 @item
13252 @cartouche
13253 @noindent
13254 Implementation-defined check names.  See 11.5(27).
13255 @end cartouche
13256 @noindent
13257 The implementation defined check name Alignment_Check controls checking of
13258 address clause values for proper alignment (that is, the address supplied
13259 must be consistent with the alignment of the type).
13261 The implementation defined check name Predicate_Check controls whether
13262 predicate checks are generated.
13264 The implementation defined check name Validity_Check controls whether
13265 validity checks are generated.
13267 In addition, a user program can add implementation-defined check names
13268 by means of the pragma Check_Name.
13270 @sp 1
13271 @item
13272 @cartouche
13273 @noindent
13274 The interpretation of each aspect of representation.  See
13275 13.1(20).
13276 @end cartouche
13277 @noindent
13278 See separate section on data representations.
13280 @sp 1
13281 @item
13282 @cartouche
13283 @noindent
13284 Any restrictions placed upon representation items.  See
13285 13.1(20).
13286 @end cartouche
13287 @noindent
13288 See separate section on data representations.
13290 @sp 1
13291 @item
13292 @cartouche
13293 @noindent
13294 The meaning of @code{Size} for indefinite subtypes.  See
13295 13.3(48).
13296 @end cartouche
13297 @noindent
13298 Size for an indefinite subtype is the maximum possible size, except that
13299 for the case of a subprogram parameter, the size of the parameter object
13300 is the actual size.
13302 @sp 1
13303 @item
13304 @cartouche
13305 @noindent
13306 The default external representation for a type tag.  See
13307 13.3(75).
13308 @end cartouche
13309 @noindent
13310 The default external representation for a type tag is the fully expanded
13311 name of the type in upper case letters.
13313 @sp 1
13314 @item
13315 @cartouche
13316 @noindent
13317 What determines whether a compilation unit is the same in
13318 two different partitions.  See 13.3(76).
13319 @end cartouche
13320 @noindent
13321 A compilation unit is the same in two different partitions if and only
13322 if it derives from the same source file.
13324 @sp 1
13325 @item
13326 @cartouche
13327 @noindent
13328 Implementation-defined components.  See 13.5.1(15).
13329 @end cartouche
13330 @noindent
13331 The only implementation defined component is the tag for a tagged type,
13332 which contains a pointer to the dispatching table.
13334 @sp 1
13335 @item
13336 @cartouche
13337 @noindent
13338 If @code{Word_Size} = @code{Storage_Unit}, the default bit
13339 ordering.  See 13.5.3(5).
13340 @end cartouche
13341 @noindent
13342 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
13343 implementation, so no non-default bit ordering is supported.  The default
13344 bit ordering corresponds to the natural endianness of the target architecture.
13346 @sp 1
13347 @item
13348 @cartouche
13349 @noindent
13350 The contents of the visible part of package @code{System}
13351 and its language-defined children.  See 13.7(2).
13352 @end cartouche
13353 @noindent
13354 See the definition of these packages in files @file{system.ads} and
13355 @file{s-stoele.ads}. Note that two declarations are added to package
13356 System.
13358 @smallexample @c ada
13359    Max_Priority           : constant Positive :=
13360      Priority'Last;
13361    Max_Interrupt_Priority : constant Positive :=
13362      Interrupt_Priority'Last;
13363 @end smallexample
13365 @sp 1
13366 @item
13367 @cartouche
13368 @noindent
13369 The contents of the visible part of package
13370 @code{System.Machine_Code}, and the meaning of
13371 @code{code_statements}.  See 13.8(7).
13372 @end cartouche
13373 @noindent
13374 See the definition and documentation in file @file{s-maccod.ads}.
13376 @sp 1
13377 @item
13378 @cartouche
13379 @noindent
13380 The effect of unchecked conversion.  See 13.9(11).
13381 @end cartouche
13382 @noindent
13383 Unchecked conversion between types of the same size
13384 results in an uninterpreted transmission of the bits from one type
13385 to the other.  If the types are of unequal sizes, then in the case of
13386 discrete types, a shorter source is first zero or sign extended as
13387 necessary, and a shorter target is simply truncated on the left.
13388 For all non-discrete types, the source is first copied if necessary
13389 to ensure that the alignment requirements of the target are met, then
13390 a pointer is constructed to the source value, and the result is obtained
13391 by dereferencing this pointer after converting it to be a pointer to the
13392 target type. Unchecked conversions where the target subtype is an
13393 unconstrained array are not permitted. If the target alignment is
13394 greater than the source alignment, then a copy of the result is
13395 made with appropriate alignment
13397 @sp 1
13398 @item
13399 @cartouche
13400 @noindent
13401 The semantics of operations on invalid representations.
13402 See 13.9.2(10-11).
13403 @end cartouche
13404 @noindent
13405 For assignments and other operations where the use of invalid values cannot
13406 result in erroneous behavior, the compiler ignores the possibility of invalid
13407 values. An exception is raised at the point where an invalid value would
13408 result in erroneous behavior. For example executing:
13410 @smallexample @c ada
13411 procedure invalidvals is
13412    X : Integer := -1;
13413    Y : Natural range 1 .. 10;
13414    for Y'Address use X'Address;
13415    Z : Natural range 1 .. 10;
13416    A : array (Natural range 1 .. 10) of Integer;
13417 begin
13418    Z := Y;     -- no exception
13419    A (Z) := 3; -- exception raised;
13420 end;
13421 @end smallexample
13423 @noindent
13424 As indicated, an exception is raised on the array assignment, but not
13425 on the simple assignment of the invalid negative value from Y to Z.
13427 @sp 1
13428 @item
13429 @cartouche
13430 @noindent
13431 The manner of choosing a storage pool for an access type
13432 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
13433 @end cartouche
13434 @noindent
13435 There are 3 different standard pools used by the compiler when
13436 @code{Storage_Pool} is not specified depending whether the type is local
13437 to a subprogram or defined at the library level and whether
13438 @code{Storage_Size}is specified or not.  See documentation in the runtime
13439 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13440 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13441 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13442 default pools used.
13444 @sp 1
13445 @item
13446 @cartouche
13447 @noindent
13448 Whether or not the implementation provides user-accessible
13449 names for the standard pool type(s).  See 13.11(17).
13450 @end cartouche
13451 @noindent
13453 See documentation in the sources of the run time mentioned in the previous
13454 paragraph.  All these pools are accessible by means of @code{with}'ing
13455 these units.
13457 @sp 1
13458 @item
13459 @cartouche
13460 @noindent
13461 The meaning of @code{Storage_Size}.  See 13.11(18).
13462 @end cartouche
13463 @noindent
13464 @code{Storage_Size} is measured in storage units, and refers to the
13465 total space available for an access type collection, or to the primary
13466 stack space for a task.
13468 @sp 1
13469 @item
13470 @cartouche
13471 @noindent
13472 Implementation-defined aspects of storage pools.  See
13473 13.11(22).
13474 @end cartouche
13475 @noindent
13476 See documentation in the sources of the run time mentioned in the
13477 paragraph about standard storage pools above
13478 for details on GNAT-defined aspects of storage pools.
13480 @sp 1
13481 @item
13482 @cartouche
13483 @noindent
13484 The set of restrictions allowed in a pragma
13485 @code{Restrictions}.  See 13.12(7).
13486 @end cartouche
13487 @noindent
13488 @xref{Standard and Implementation Defined Restrictions}.
13490 @sp 1
13491 @item
13492 @cartouche
13493 @noindent
13494 The consequences of violating limitations on
13495 @code{Restrictions} pragmas.  See 13.12(9).
13496 @end cartouche
13497 @noindent
13498 Restrictions that can be checked at compile time result in illegalities
13499 if violated.  Currently there are no other consequences of violating
13500 restrictions.
13502 @sp 1
13503 @item
13504 @cartouche
13505 @noindent
13506 The representation used by the @code{Read} and
13507 @code{Write} attributes of elementary types in terms of stream
13508 elements.  See 13.13.2(9).
13509 @end cartouche
13510 @noindent
13511 The representation is the in-memory representation of the base type of
13512 the type, using the number of bits corresponding to the
13513 @code{@var{type}'Size} value, and the natural ordering of the machine.
13515 @sp 1
13516 @item
13517 @cartouche
13518 @noindent
13519 The names and characteristics of the numeric subtypes
13520 declared in the visible part of package @code{Standard}.  See A.1(3).
13521 @end cartouche
13522 @noindent
13523 See items describing the integer and floating-point types supported.
13525 @sp 1
13526 @item
13527 @cartouche
13528 @noindent
13529 The string returned by @code{Character_Set_Version}.
13530 See A.3.5(3).
13531 @end cartouche
13532 @noindent
13533 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13534 the string "Unicode 4.0", referring to version 4.0 of the
13535 Unicode specification.
13537 @sp 1
13538 @item
13539 @cartouche
13540 @noindent
13541 The accuracy actually achieved by the elementary
13542 functions.  See A.5.1(1).
13543 @end cartouche
13544 @noindent
13545 The elementary functions correspond to the functions available in the C
13546 library.  Only fast math mode is implemented.
13548 @sp 1
13549 @item
13550 @cartouche
13551 @noindent
13552 The sign of a zero result from some of the operators or
13553 functions in @code{Numerics.Generic_Elementary_Functions}, when
13554 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
13555 @end cartouche
13556 @noindent
13557 The sign of zeroes follows the requirements of the IEEE 754 standard on
13558 floating-point.
13560 @sp 1
13561 @item
13562 @cartouche
13563 @noindent
13564 The value of
13565 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
13566 @end cartouche
13567 @noindent
13568 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13570 @sp 1
13571 @item
13572 @cartouche
13573 @noindent
13574 The value of
13575 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
13576 @end cartouche
13577 @noindent
13578 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13580 @sp 1
13581 @item
13582 @cartouche
13583 @noindent
13584 The algorithms for random number generation.  See
13585 A.5.2(32).
13586 @end cartouche
13587 @noindent
13588 The algorithm is the Mersenne Twister, as documented in the source file
13589 @file{s-rannum.adb}. This version of the algorithm has a period of
13590 2**19937-1.
13592 @sp 1
13593 @item
13594 @cartouche
13595 @noindent
13596 The string representation of a random number generator's
13597 state.  See A.5.2(38).
13598 @end cartouche
13599 @noindent
13600 The value returned by the Image function is the concatenation of
13601 the fixed-width decimal representations of the 624 32-bit integers
13602 of the state vector.
13604 @sp 1
13605 @item
13606 @cartouche
13607 @noindent
13608 The minimum time interval between calls to the
13609 time-dependent Reset procedure that are guaranteed to initiate different
13610 random number sequences.  See A.5.2(45).
13611 @end cartouche
13612 @noindent
13613 The minimum period between reset calls to guarantee distinct series of
13614 random numbers is one microsecond.
13616 @sp 1
13617 @item
13618 @cartouche
13619 @noindent
13620 The values of the @code{Model_Mantissa},
13621 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13622 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13623 Annex is not supported.  See A.5.3(72).
13624 @end cartouche
13625 @noindent
13626 Run the compiler with @option{-gnatS} to produce a listing of package
13627 @code{Standard}, has the values of all numeric attributes.
13629 @sp 1
13630 @item
13631 @cartouche
13632 @noindent
13633 Any implementation-defined characteristics of the
13634 input-output packages.  See A.7(14).
13635 @end cartouche
13636 @noindent
13637 There are no special implementation defined characteristics for these
13638 packages.
13640 @sp 1
13641 @item
13642 @cartouche
13643 @noindent
13644 The value of @code{Buffer_Size} in @code{Storage_IO}.  See
13645 A.9(10).
13646 @end cartouche
13647 @noindent
13648 All type representations are contiguous, and the @code{Buffer_Size} is
13649 the value of @code{@var{type}'Size} rounded up to the next storage unit
13650 boundary.
13652 @sp 1
13653 @item
13654 @cartouche
13655 @noindent
13656 External files for standard input, standard output, and
13657 standard error See A.10(5).
13658 @end cartouche
13659 @noindent
13660 These files are mapped onto the files provided by the C streams
13661 libraries.  See source file @file{i-cstrea.ads} for further details.
13663 @sp 1
13664 @item
13665 @cartouche
13666 @noindent
13667 The accuracy of the value produced by @code{Put}.  See
13668 A.10.9(36).
13669 @end cartouche
13670 @noindent
13671 If more digits are requested in the output than are represented by the
13672 precision of the value, zeroes are output in the corresponding least
13673 significant digit positions.
13675 @sp 1
13676 @item
13677 @cartouche
13678 @noindent
13679 The meaning of @code{Argument_Count}, @code{Argument}, and
13680 @code{Command_Name}.  See A.15(1).
13681 @end cartouche
13682 @noindent
13683 These are mapped onto the @code{argv} and @code{argc} parameters of the
13684 main program in the natural manner.
13686 @sp 1
13687 @item
13688 @cartouche
13689 @noindent
13690 The interpretation of the @code{Form} parameter in procedure
13691 @code{Create_Directory}.  See A.16(56).
13692 @end cartouche
13693 @noindent
13694 The @code{Form} parameter is not used.
13696 @sp 1
13697 @item
13698 @cartouche
13699 @noindent
13700 The interpretation of the @code{Form} parameter in procedure
13701 @code{Create_Path}.  See A.16(60).
13702 @end cartouche
13703 @noindent
13704 The @code{Form} parameter is not used.
13706 @sp 1
13707 @item
13708 @cartouche
13709 @noindent
13710 The interpretation of the @code{Form} parameter in procedure
13711 @code{Copy_File}.  See A.16(68).
13712 @end cartouche
13713 @noindent
13714 The @code{Form} parameter is case-insensitive.
13716 Two fields are recognized in the @code{Form} parameter:
13718 @table @code
13720 @item preserve=<value>
13722 @item mode=<value>
13724 @end table
13726 @noindent
13727 <value> starts immediately after the character '=' and ends with the
13728 character immediately preceding the next comma (',') or with the last
13729 character of the parameter.
13731 The only possible values for preserve= are:
13733 @table @code
13735 @item no_attributes
13736 Do not try to preserve any file attributes. This is the default if no
13737 preserve= is found in Form.
13739 @item all_attributes
13740 Try to preserve all file attributes (timestamps, access rights).
13742 @item timestamps
13743 Preserve the timestamp of the copied file, but not the other file attributes.
13745 @end table
13747 @noindent
13748 The only possible values for mode= are:
13750 @table @code
13752 @item copy
13753 Only do the copy if the destination file does not already exist. If it already
13754 exists, Copy_File fails.
13756 @item overwrite
13757 Copy the file in all cases. Overwrite an already existing destination file.
13759 @item append
13760 Append the original file to the destination file. If the destination file does
13761 not exist, the destination file is a copy of the source file. When mode=append,
13762 the field preserve=, if it exists, is not taken into account.
13764 @end table
13766 @noindent
13767 If the Form parameter includes one or both of the fields and the value or
13768 values are incorrect, Copy_file fails with Use_Error.
13770 Examples of correct Forms:
13772 @smallexample
13773 Form => "preserve=no_attributes,mode=overwrite" (the default)
13774 Form => "mode=append"
13775 Form => "mode=copy, preserve=all_attributes"
13776 @end smallexample
13778 @noindent
13779 Examples of incorrect Forms
13781 @smallexample
13782 Form => "preserve=junk"
13783 Form => "mode=internal, preserve=timestamps"
13784 @end smallexample
13786 @sp 1
13787 @item
13788 @cartouche
13789 @noindent
13790 The interpretation of the @code{Pattern} parameter, when not the null string,
13791 in the @code{Start_Search} and @code{Search} procedures.
13792 See A.16(104) and A.16(112).
13793 @end cartouche
13794 @noindent
13795 When the @code{Pattern} parameter is not the null string, it is interpreted
13796 according to the syntax of regular expressions as defined in the
13797 @code{GNAT.Regexp} package.
13798 @xref{GNAT.Regexp (g-regexp.ads)}.
13800 @sp 1
13801 @item
13802 @cartouche
13803 @noindent
13804 Implementation-defined convention names.  See B.1(11).
13805 @end cartouche
13806 @noindent
13807 The following convention names are supported
13809 @table @code
13810 @item  Ada
13812 @item Ada_Pass_By_Copy
13813 Allowed for any types except by-reference types such as limited
13814 records. Compatible with convention Ada, but causes any parameters
13815 with this convention to be passed by copy.
13816 @item Ada_Pass_By_Reference
13817 Allowed for any types except by-copy types such as scalars.
13818 Compatible with convention Ada, but causes any parameters
13819 with this convention to be passed by reference.
13820 @item Assembler
13821 Assembly language
13822 @item Asm
13823 Synonym for Assembler
13824 @item Assembly
13825 Synonym for Assembler
13826 @item C
13828 @item C_Pass_By_Copy
13829 Allowed only for record types, like C, but also notes that record
13830 is to be passed by copy rather than reference.
13831 @item COBOL
13832 COBOL
13833 @item C_Plus_Plus (or CPP)
13835 @item Default
13836 Treated the same as C
13837 @item External
13838 Treated the same as C
13839 @item Fortran
13840 Fortran
13841 @item Intrinsic
13842 For support of pragma @code{Import} with convention Intrinsic, see
13843 separate section on Intrinsic Subprograms.
13844 @item Stdcall
13845 Stdcall (used for Windows implementations only).  This convention correspond
13846 to the WINAPI (previously called Pascal convention) C/C++ convention under
13847 Windows.  A routine with this convention cleans the stack before
13848 exit. This pragma cannot be applied to a dispatching call.
13849 @item DLL
13850 Synonym for Stdcall
13851 @item Win32
13852 Synonym for Stdcall
13853 @item Stubbed
13854 Stubbed is a special convention used to indicate that the body of the
13855 subprogram will be entirely ignored.  Any call to the subprogram
13856 is converted into a raise of the @code{Program_Error} exception.  If a
13857 pragma @code{Import} specifies convention @code{stubbed} then no body need
13858 be present at all.  This convention is useful during development for the
13859 inclusion of subprograms whose body has not yet been written.
13861 @end table
13862 @noindent
13863 In addition, all otherwise unrecognized convention names are also
13864 treated as being synonymous with convention C@.  In all implementations
13865 except for VMS, use of such other names results in a warning.  In VMS
13866 implementations, these names are accepted silently.
13868 @sp 1
13869 @item
13870 @cartouche
13871 @noindent
13872 The meaning of link names.  See B.1(36).
13873 @end cartouche
13874 @noindent
13875 Link names are the actual names used by the linker.
13877 @sp 1
13878 @item
13879 @cartouche
13880 @noindent
13881 The manner of choosing link names when neither the link
13882 name nor the address of an imported or exported entity is specified.  See
13883 B.1(36).
13884 @end cartouche
13885 @noindent
13886 The default linker name is that which would be assigned by the relevant
13887 external language, interpreting the Ada name as being in all lower case
13888 letters.
13890 @sp 1
13891 @item
13892 @cartouche
13893 @noindent
13894 The effect of pragma @code{Linker_Options}.  See B.1(37).
13895 @end cartouche
13896 @noindent
13897 The string passed to @code{Linker_Options} is presented uninterpreted as
13898 an argument to the link command, unless it contains ASCII.NUL characters.
13899 NUL characters if they appear act as argument separators, so for example
13901 @smallexample @c ada
13902 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13903 @end smallexample
13905 @noindent
13906 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13907 linker. The order of linker options is preserved for a given unit. The final
13908 list of options passed to the linker is in reverse order of the elaboration
13909 order. For example, linker options for a body always appear before the options
13910 from the corresponding package spec.
13912 @sp 1
13913 @item
13914 @cartouche
13915 @noindent
13916 The contents of the visible part of package
13917 @code{Interfaces} and its language-defined descendants.  See B.2(1).
13918 @end cartouche
13919 @noindent
13920 See files with prefix @file{i-} in the distributed library.
13922 @sp 1
13923 @item
13924 @cartouche
13925 @noindent
13926 Implementation-defined children of package
13927 @code{Interfaces}.  The contents of the visible part of package
13928 @code{Interfaces}.  See B.2(11).
13929 @end cartouche
13930 @noindent
13931 See files with prefix @file{i-} in the distributed library.
13933 @sp 1
13934 @item
13935 @cartouche
13936 @noindent
13937 The types @code{Floating}, @code{Long_Floating},
13938 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13939 @code{COBOL_Character}; and the initialization of the variables
13940 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13941 @code{Interfaces.COBOL}.  See B.4(50).
13942 @end cartouche
13943 @noindent
13944 @table @code
13945 @item Floating
13946 Float
13947 @item Long_Floating
13948 (Floating) Long_Float
13949 @item Binary
13950 Integer
13951 @item Long_Binary
13952 Long_Long_Integer
13953 @item Decimal_Element
13954 Character
13955 @item COBOL_Character
13956 Character
13957 @end table
13959 @noindent
13960 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13962 @sp 1
13963 @item
13964 @cartouche
13965 @noindent
13966 Support for access to machine instructions.  See C.1(1).
13967 @end cartouche
13968 @noindent
13969 See documentation in file @file{s-maccod.ads} in the distributed library.
13971 @sp 1
13972 @item
13973 @cartouche
13974 @noindent
13975 Implementation-defined aspects of access to machine
13976 operations.  See C.1(9).
13977 @end cartouche
13978 @noindent
13979 See documentation in file @file{s-maccod.ads} in the distributed library.
13981 @sp 1
13982 @item
13983 @cartouche
13984 @noindent
13985 Implementation-defined aspects of interrupts.  See C.3(2).
13986 @end cartouche
13987 @noindent
13988 Interrupts are mapped to signals or conditions as appropriate.  See
13989 definition of unit
13990 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13991 on the interrupts supported on a particular target.
13993 @sp 1
13994 @item
13995 @cartouche
13996 @noindent
13997 Implementation-defined aspects of pre-elaboration.  See
13998 C.4(13).
13999 @end cartouche
14000 @noindent
14001 GNAT does not permit a partition to be restarted without reloading,
14002 except under control of the debugger.
14004 @sp 1
14005 @item
14006 @cartouche
14007 @noindent
14008 The semantics of pragma @code{Discard_Names}.  See C.5(7).
14009 @end cartouche
14010 @noindent
14011 Pragma @code{Discard_Names} causes names of enumeration literals to
14012 be suppressed.  In the presence of this pragma, the Image attribute
14013 provides the image of the Pos of the literal, and Value accepts
14014 Pos values.
14016 @sp 1
14017 @item
14018 @cartouche
14019 @noindent
14020 The result of the @code{Task_Identification.Image}
14021 attribute.  See C.7.1(7).
14022 @end cartouche
14023 @noindent
14024 The result of this attribute is a string that identifies
14025 the object or component that denotes a given task. If a variable @code{Var}
14026 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
14027 where the suffix
14028 is the hexadecimal representation of the virtual address of the corresponding
14029 task control block. If the variable is an array of tasks, the image of each
14030 task will have the form of an indexed component indicating the position of a
14031 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
14032 component of a record, the image of the task will have the form of a selected
14033 component. These rules are fully recursive, so that the image of a task that
14034 is a subcomponent of a composite object corresponds to the expression that
14035 designates this task.
14036 @noindent
14037 If a task is created by an allocator, its image depends on the context. If the
14038 allocator is part of an object declaration, the rules described above are used
14039 to construct its image, and this image is not affected by subsequent
14040 assignments. If the allocator appears within an expression, the image
14041 includes only the name of the task type.
14042 @noindent
14043 If the configuration pragma Discard_Names is present, or if the restriction
14044 No_Implicit_Heap_Allocation is in effect,  the image reduces to
14045 the numeric suffix, that is to say the hexadecimal representation of the
14046 virtual address of the control block of the task.
14047 @sp 1
14048 @item
14049 @cartouche
14050 @noindent
14051 The value of @code{Current_Task} when in a protected entry
14052 or interrupt handler.  See C.7.1(17).
14053 @end cartouche
14054 @noindent
14055 Protected entries or interrupt handlers can be executed by any
14056 convenient thread, so the value of @code{Current_Task} is undefined.
14058 @sp 1
14059 @item
14060 @cartouche
14061 @noindent
14062 The effect of calling @code{Current_Task} from an entry
14063 body or interrupt handler.  See C.7.1(19).
14064 @end cartouche
14065 @noindent
14066 The effect of calling @code{Current_Task} from an entry body or
14067 interrupt handler is to return the identification of the task currently
14068 executing the code.
14070 @sp 1
14071 @item
14072 @cartouche
14073 @noindent
14074 Implementation-defined aspects of
14075 @code{Task_Attributes}.  See C.7.2(19).
14076 @end cartouche
14077 @noindent
14078 There are no implementation-defined aspects of @code{Task_Attributes}.
14080 @sp 1
14081 @item
14082 @cartouche
14083 @noindent
14084 Values of all @code{Metrics}.  See D(2).
14085 @end cartouche
14086 @noindent
14087 The metrics information for GNAT depends on the performance of the
14088 underlying operating system.  The sources of the run-time for tasking
14089 implementation, together with the output from @option{-gnatG} can be
14090 used to determine the exact sequence of operating systems calls made
14091 to implement various tasking constructs.  Together with appropriate
14092 information on the performance of the underlying operating system,
14093 on the exact target in use, this information can be used to determine
14094 the required metrics.
14096 @sp 1
14097 @item
14098 @cartouche
14099 @noindent
14100 The declarations of @code{Any_Priority} and
14101 @code{Priority}.  See D.1(11).
14102 @end cartouche
14103 @noindent
14104 See declarations in file @file{system.ads}.
14106 @sp 1
14107 @item
14108 @cartouche
14109 @noindent
14110 Implementation-defined execution resources.  See D.1(15).
14111 @end cartouche
14112 @noindent
14113 There are no implementation-defined execution resources.
14115 @sp 1
14116 @item
14117 @cartouche
14118 @noindent
14119 Whether, on a multiprocessor, a task that is waiting for
14120 access to a protected object keeps its processor busy.  See D.2.1(3).
14121 @end cartouche
14122 @noindent
14123 On a multi-processor, a task that is waiting for access to a protected
14124 object does not keep its processor busy.
14126 @sp 1
14127 @item
14128 @cartouche
14129 @noindent
14130 The affect of implementation defined execution resources
14131 on task dispatching.  See D.2.1(9).
14132 @end cartouche
14133 @noindent
14134 Tasks map to threads in the threads package used by GNAT@.  Where possible
14135 and appropriate, these threads correspond to native threads of the
14136 underlying operating system.
14138 @sp 1
14139 @item
14140 @cartouche
14141 @noindent
14142 Implementation-defined @code{policy_identifiers} allowed
14143 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
14144 @end cartouche
14145 @noindent
14146 There are no implementation-defined policy-identifiers allowed in this
14147 pragma.
14149 @sp 1
14150 @item
14151 @cartouche
14152 @noindent
14153 Implementation-defined aspects of priority inversion.  See
14154 D.2.2(16).
14155 @end cartouche
14156 @noindent
14157 Execution of a task cannot be preempted by the implementation processing
14158 of delay expirations for lower priority tasks.
14160 @sp 1
14161 @item
14162 @cartouche
14163 @noindent
14164 Implementation-defined task dispatching.  See D.2.2(18).
14165 @end cartouche
14166 @noindent
14167 The policy is the same as that of the underlying threads implementation.
14169 @sp 1
14170 @item
14171 @cartouche
14172 @noindent
14173 Implementation-defined @code{policy_identifiers} allowed
14174 in a pragma @code{Locking_Policy}.  See D.3(4).
14175 @end cartouche
14176 @noindent
14177 The two implementation defined policies permitted in GNAT are
14178 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
14179 targets that support the @code{Inheritance_Locking} policy, locking is
14180 implemented by inheritance, i.e.@: the task owning the lock operates
14181 at a priority equal to the highest priority of any task currently
14182 requesting the lock.  On targets that support the
14183 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
14184 read/write lock allowing multiple propected object functions to enter
14185 concurrently.
14187 @sp 1
14188 @item
14189 @cartouche
14190 @noindent
14191 Default ceiling priorities.  See D.3(10).
14192 @end cartouche
14193 @noindent
14194 The ceiling priority of protected objects of the type
14195 @code{System.Interrupt_Priority'Last} as described in the Ada
14196 Reference Manual D.3(10),
14198 @sp 1
14199 @item
14200 @cartouche
14201 @noindent
14202 The ceiling of any protected object used internally by
14203 the implementation.  See D.3(16).
14204 @end cartouche
14205 @noindent
14206 The ceiling priority of internal protected objects is
14207 @code{System.Priority'Last}.
14209 @sp 1
14210 @item
14211 @cartouche
14212 @noindent
14213 Implementation-defined queuing policies.  See D.4(1).
14214 @end cartouche
14215 @noindent
14216 There are no implementation-defined queuing policies.
14218 @sp 1
14219 @item
14220 @cartouche
14221 @noindent
14222 On a multiprocessor, any conditions that cause the
14223 completion of an aborted construct to be delayed later than what is
14224 specified for a single processor.  See D.6(3).
14225 @end cartouche
14226 @noindent
14227 The semantics for abort on a multi-processor is the same as on a single
14228 processor, there are no further delays.
14230 @sp 1
14231 @item
14232 @cartouche
14233 @noindent
14234 Any operations that implicitly require heap storage
14235 allocation.  See D.7(8).
14236 @end cartouche
14237 @noindent
14238 The only operation that implicitly requires heap storage allocation is
14239 task creation.
14241 @sp 1
14242 @item
14243 @cartouche
14244 @noindent
14245 Implementation-defined aspects of pragma
14246 @code{Restrictions}.  See D.7(20).
14247 @end cartouche
14248 @noindent
14249 There are no such implementation-defined aspects.
14251 @sp 1
14252 @item
14253 @cartouche
14254 @noindent
14255 Implementation-defined aspects of package
14256 @code{Real_Time}.  See D.8(17).
14257 @end cartouche
14258 @noindent
14259 There are no implementation defined aspects of package @code{Real_Time}.
14261 @sp 1
14262 @item
14263 @cartouche
14264 @noindent
14265 Implementation-defined aspects of
14266 @code{delay_statements}.  See D.9(8).
14267 @end cartouche
14268 @noindent
14269 Any difference greater than one microsecond will cause the task to be
14270 delayed (see D.9(7)).
14272 @sp 1
14273 @item
14274 @cartouche
14275 @noindent
14276 The upper bound on the duration of interrupt blocking
14277 caused by the implementation.  See D.12(5).
14278 @end cartouche
14279 @noindent
14280 The upper bound is determined by the underlying operating system.  In
14281 no cases is it more than 10 milliseconds.
14283 @sp 1
14284 @item
14285 @cartouche
14286 @noindent
14287 The means for creating and executing distributed
14288 programs.  See E(5).
14289 @end cartouche
14290 @noindent
14291 The GLADE package provides a utility GNATDIST for creating and executing
14292 distributed programs.  See the GLADE reference manual for further details.
14294 @sp 1
14295 @item
14296 @cartouche
14297 @noindent
14298 Any events that can result in a partition becoming
14299 inaccessible.  See E.1(7).
14300 @end cartouche
14301 @noindent
14302 See the GLADE reference manual for full details on such events.
14304 @sp 1
14305 @item
14306 @cartouche
14307 @noindent
14308 The scheduling policies, treatment of priorities, and
14309 management of shared resources between partitions in certain cases.  See
14310 E.1(11).
14311 @end cartouche
14312 @noindent
14313 See the GLADE reference manual for full details on these aspects of
14314 multi-partition execution.
14316 @sp 1
14317 @item
14318 @cartouche
14319 @noindent
14320 Events that cause the version of a compilation unit to
14321 change.  See E.3(5).
14322 @end cartouche
14323 @noindent
14324 Editing the source file of a compilation unit, or the source files of
14325 any units on which it is dependent in a significant way cause the version
14326 to change.  No other actions cause the version number to change.  All changes
14327 are significant except those which affect only layout, capitalization or
14328 comments.
14330 @sp 1
14331 @item
14332 @cartouche
14333 @noindent
14334 Whether the execution of the remote subprogram is
14335 immediately aborted as a result of cancellation.  See E.4(13).
14336 @end cartouche
14337 @noindent
14338 See the GLADE reference manual for details on the effect of abort in
14339 a distributed application.
14341 @sp 1
14342 @item
14343 @cartouche
14344 @noindent
14345 Implementation-defined aspects of the PCS@.  See E.5(25).
14346 @end cartouche
14347 @noindent
14348 See the GLADE reference manual for a full description of all implementation
14349 defined aspects of the PCS@.
14351 @sp 1
14352 @item
14353 @cartouche
14354 @noindent
14355 Implementation-defined interfaces in the PCS@.  See
14356 E.5(26).
14357 @end cartouche
14358 @noindent
14359 See the GLADE reference manual for a full description of all
14360 implementation defined interfaces.
14362 @sp 1
14363 @item
14364 @cartouche
14365 @noindent
14366 The values of named numbers in the package
14367 @code{Decimal}.  See F.2(7).
14368 @end cartouche
14369 @noindent
14370 @table @code
14371 @item Max_Scale
14373 @item Min_Scale
14375 @item Min_Delta
14376 1.0E-18
14377 @item Max_Delta
14378 1.0E+18
14379 @item Max_Decimal_Digits
14381 @end table
14383 @sp 1
14384 @item
14385 @cartouche
14386 @noindent
14387 The value of @code{Max_Picture_Length} in the package
14388 @code{Text_IO.Editing}.  See F.3.3(16).
14389 @end cartouche
14390 @noindent
14393 @sp 1
14394 @item
14395 @cartouche
14396 @noindent
14397 The value of @code{Max_Picture_Length} in the package
14398 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
14399 @end cartouche
14400 @noindent
14403 @sp 1
14404 @item
14405 @cartouche
14406 @noindent
14407 The accuracy actually achieved by the complex elementary
14408 functions and by other complex arithmetic operations.  See G.1(1).
14409 @end cartouche
14410 @noindent
14411 Standard library functions are used for the complex arithmetic
14412 operations.  Only fast math mode is currently supported.
14414 @sp 1
14415 @item
14416 @cartouche
14417 @noindent
14418 The sign of a zero result (or a component thereof) from
14419 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14420 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
14421 @end cartouche
14422 @noindent
14423 The signs of zero values are as recommended by the relevant
14424 implementation advice.
14426 @sp 1
14427 @item
14428 @cartouche
14429 @noindent
14430 The sign of a zero result (or a component thereof) from
14431 any operator or function in
14432 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14433 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
14434 @end cartouche
14435 @noindent
14436 The signs of zero values are as recommended by the relevant
14437 implementation advice.
14439 @sp 1
14440 @item
14441 @cartouche
14442 @noindent
14443 Whether the strict mode or the relaxed mode is the
14444 default.  See G.2(2).
14445 @end cartouche
14446 @noindent
14447 The strict mode is the default.  There is no separate relaxed mode.  GNAT
14448 provides a highly efficient implementation of strict mode.
14450 @sp 1
14451 @item
14452 @cartouche
14453 @noindent
14454 The result interval in certain cases of fixed-to-float
14455 conversion.  See G.2.1(10).
14456 @end cartouche
14457 @noindent
14458 For cases where the result interval is implementation dependent, the
14459 accuracy is that provided by performing all operations in 64-bit IEEE
14460 floating-point format.
14462 @sp 1
14463 @item
14464 @cartouche
14465 @noindent
14466 The result of a floating point arithmetic operation in
14467 overflow situations, when the @code{Machine_Overflows} attribute of the
14468 result type is @code{False}.  See G.2.1(13).
14469 @end cartouche
14470 @noindent
14471 Infinite and NaN values are produced as dictated by the IEEE
14472 floating-point standard.
14474 Note that on machines that are not fully compliant with the IEEE
14475 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14476 must be used for achieving IEEE conforming behavior (although at the cost
14477 of a significant performance penalty), so infinite and NaN values are
14478 properly generated.
14480 @sp 1
14481 @item
14482 @cartouche
14483 @noindent
14484 The result interval for division (or exponentiation by a
14485 negative exponent), when the floating point hardware implements division
14486 as multiplication by a reciprocal.  See G.2.1(16).
14487 @end cartouche
14488 @noindent
14489 Not relevant, division is IEEE exact.
14491 @sp 1
14492 @item
14493 @cartouche
14494 @noindent
14495 The definition of close result set, which determines the
14496 accuracy of certain fixed point multiplications and divisions.  See
14497 G.2.3(5).
14498 @end cartouche
14499 @noindent
14500 Operations in the close result set are performed using IEEE long format
14501 floating-point arithmetic.  The input operands are converted to
14502 floating-point, the operation is done in floating-point, and the result
14503 is converted to the target type.
14505 @sp 1
14506 @item
14507 @cartouche
14508 @noindent
14509 Conditions on a @code{universal_real} operand of a fixed
14510 point multiplication or division for which the result shall be in the
14511 perfect result set.  See G.2.3(22).
14512 @end cartouche
14513 @noindent
14514 The result is only defined to be in the perfect result set if the result
14515 can be computed by a single scaling operation involving a scale factor
14516 representable in 64-bits.
14518 @sp 1
14519 @item
14520 @cartouche
14521 @noindent
14522 The result of a fixed point arithmetic operation in
14523 overflow situations, when the @code{Machine_Overflows} attribute of the
14524 result type is @code{False}.  See G.2.3(27).
14525 @end cartouche
14526 @noindent
14527 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14528 types.
14530 @sp 1
14531 @item
14532 @cartouche
14533 @noindent
14534 The result of an elementary function reference in
14535 overflow situations, when the @code{Machine_Overflows} attribute of the
14536 result type is @code{False}.  See G.2.4(4).
14537 @end cartouche
14538 @noindent
14539 IEEE infinite and Nan values are produced as appropriate.
14541 @sp 1
14542 @item
14543 @cartouche
14544 @noindent
14545 The value of the angle threshold, within which certain
14546 elementary functions, complex arithmetic operations, and complex
14547 elementary functions yield results conforming to a maximum relative
14548 error bound.  See G.2.4(10).
14549 @end cartouche
14550 @noindent
14551 Information on this subject is not yet available.
14553 @sp 1
14554 @item
14555 @cartouche
14556 @noindent
14557 The accuracy of certain elementary functions for
14558 parameters beyond the angle threshold.  See G.2.4(10).
14559 @end cartouche
14560 @noindent
14561 Information on this subject is not yet available.
14563 @sp 1
14564 @item
14565 @cartouche
14566 @noindent
14567 The result of a complex arithmetic operation or complex
14568 elementary function reference in overflow situations, when the
14569 @code{Machine_Overflows} attribute of the corresponding real type is
14570 @code{False}.  See G.2.6(5).
14571 @end cartouche
14572 @noindent
14573 IEEE infinite and Nan values are produced as appropriate.
14575 @sp 1
14576 @item
14577 @cartouche
14578 @noindent
14579 The accuracy of certain complex arithmetic operations and
14580 certain complex elementary functions for parameters (or components
14581 thereof) beyond the angle threshold.  See G.2.6(8).
14582 @end cartouche
14583 @noindent
14584 Information on those subjects is not yet available.
14586 @sp 1
14587 @item
14588 @cartouche
14589 @noindent
14590 Information regarding bounded errors and erroneous
14591 execution.  See H.2(1).
14592 @end cartouche
14593 @noindent
14594 Information on this subject is not yet available.
14596 @sp 1
14597 @item
14598 @cartouche
14599 @noindent
14600 Implementation-defined aspects of pragma
14601 @code{Inspection_Point}.  See H.3.2(8).
14602 @end cartouche
14603 @noindent
14604 Pragma @code{Inspection_Point} ensures that the variable is live and can
14605 be examined by the debugger at the inspection point.
14607 @sp 1
14608 @item
14609 @cartouche
14610 @noindent
14611 Implementation-defined aspects of pragma
14612 @code{Restrictions}.  See H.4(25).
14613 @end cartouche
14614 @noindent
14615 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
14616 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14617 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
14619 @sp 1
14620 @item
14621 @cartouche
14622 @noindent
14623 Any restrictions on pragma @code{Restrictions}.  See
14624 H.4(27).
14625 @end cartouche
14626 @noindent
14627 There are no restrictions on pragma @code{Restrictions}.
14629 @end itemize
14632 @c =======================
14633 @node Intrinsic Subprograms
14634 @chapter Intrinsic Subprograms
14635 @cindex Intrinsic Subprograms
14637 @menu
14638 * Intrinsic Operators::
14639 * Compilation_Date::
14640 * Compilation_Time::
14641 * Enclosing_Entity::
14642 * Exception_Information::
14643 * Exception_Message::
14644 * Exception_Name::
14645 * File::
14646 * Line::
14647 * Shifts and Rotates::
14648 * Source_Location::
14649 @end menu
14651 @noindent
14652 GNAT allows a user application program to write the declaration:
14654 @smallexample @c ada
14655    pragma Import (Intrinsic, name);
14656 @end smallexample
14658 @noindent
14659 providing that the name corresponds to one of the implemented intrinsic
14660 subprograms in GNAT, and that the parameter profile of the referenced
14661 subprogram meets the requirements.  This chapter describes the set of
14662 implemented intrinsic subprograms, and the requirements on parameter profiles.
14663 Note that no body is supplied; as with other uses of pragma Import, the
14664 body is supplied elsewhere (in this case by the compiler itself).  Note
14665 that any use of this feature is potentially non-portable, since the
14666 Ada standard does not require Ada compilers to implement this feature.
14668 @node Intrinsic Operators
14669 @section Intrinsic Operators
14670 @cindex Intrinsic operator
14672 @noindent
14673 All the predefined numeric operators in package Standard
14674 in @code{pragma Import (Intrinsic,..)}
14675 declarations.  In the binary operator case, the operands must have the same
14676 size.  The operand or operands must also be appropriate for
14677 the operator.  For example, for addition, the operands must
14678 both be floating-point or both be fixed-point, and the
14679 right operand for @code{"**"} must have a root type of
14680 @code{Standard.Integer'Base}.
14681 You can use an intrinsic operator declaration as in the following example:
14683 @smallexample @c ada
14684    type Int1 is new Integer;
14685    type Int2 is new Integer;
14687    function "+" (X1 : Int1; X2 : Int2) return Int1;
14688    function "+" (X1 : Int1; X2 : Int2) return Int2;
14689    pragma Import (Intrinsic, "+");
14690 @end smallexample
14692 @noindent
14693 This declaration would permit ``mixed mode'' arithmetic on items
14694 of the differing types @code{Int1} and @code{Int2}.
14695 It is also possible to specify such operators for private types, if the
14696 full views are appropriate arithmetic types.
14698 @node Compilation_Date
14699 @section Compilation_Date
14700 @cindex Compilation_Date
14701 @noindent
14702 This intrinsic subprogram is used in the implementation of the
14703 library package @code{GNAT.Source_Info}.  The only useful use of the
14704 intrinsic import in this case is the one in this unit, so an
14705 application program should simply call the function
14706 @code{GNAT.Source_Info.Compilation_Date} to obtain the date of
14707 the current compilation (in local time format MMM DD YYYY).
14709 @node Compilation_Time
14710 @section Compilation_Time
14711 @cindex Compilation_Time
14712 @noindent
14713 This intrinsic subprogram is used in the implementation of the
14714 library package @code{GNAT.Source_Info}.  The only useful use of the
14715 intrinsic import in this case is the one in this unit, so an
14716 application program should simply call the function
14717 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
14718 the current compilation (in local time format HH:MM:SS).
14720 @node Enclosing_Entity
14721 @section Enclosing_Entity
14722 @cindex Enclosing_Entity
14723 @noindent
14724 This intrinsic subprogram is used in the implementation of the
14725 library package @code{GNAT.Source_Info}.  The only useful use of the
14726 intrinsic import in this case is the one in this unit, so an
14727 application program should simply call the function
14728 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14729 the current subprogram, package, task, entry, or protected subprogram.
14731 @node Exception_Information
14732 @section Exception_Information
14733 @cindex Exception_Information'
14734 @noindent
14735 This intrinsic subprogram is used in the implementation of the
14736 library package @code{GNAT.Current_Exception}.  The only useful
14737 use of the intrinsic import in this case is the one in this unit,
14738 so an application program should simply call the function
14739 @code{GNAT.Current_Exception.Exception_Information} to obtain
14740 the exception information associated with the current exception.
14742 @node Exception_Message
14743 @section Exception_Message
14744 @cindex Exception_Message
14745 @noindent
14746 This intrinsic subprogram is used in the implementation of the
14747 library package @code{GNAT.Current_Exception}.  The only useful
14748 use of the intrinsic import in this case is the one in this unit,
14749 so an application program should simply call the function
14750 @code{GNAT.Current_Exception.Exception_Message} to obtain
14751 the message associated with the current exception.
14753 @node Exception_Name
14754 @section Exception_Name
14755 @cindex Exception_Name
14756 @noindent
14757 This intrinsic subprogram is used in the implementation of the
14758 library package @code{GNAT.Current_Exception}.  The only useful
14759 use of the intrinsic import in this case is the one in this unit,
14760 so an application program should simply call the function
14761 @code{GNAT.Current_Exception.Exception_Name} to obtain
14762 the name of the current exception.
14764 @node File
14765 @section File
14766 @cindex File
14767 @noindent
14768 This intrinsic subprogram is used in the implementation of the
14769 library package @code{GNAT.Source_Info}.  The only useful use of the
14770 intrinsic import in this case is the one in this unit, so an
14771 application program should simply call the function
14772 @code{GNAT.Source_Info.File} to obtain the name of the current
14773 file.
14775 @node Line
14776 @section Line
14777 @cindex Line
14778 @noindent
14779 This intrinsic subprogram is used in the implementation of the
14780 library package @code{GNAT.Source_Info}.  The only useful use of the
14781 intrinsic import in this case is the one in this unit, so an
14782 application program should simply call the function
14783 @code{GNAT.Source_Info.Line} to obtain the number of the current
14784 source line.
14786 @node Shifts and Rotates
14787 @section Shifts and Rotates
14788 @cindex Shift_Left
14789 @cindex Shift_Right
14790 @cindex Shift_Right_Arithmetic
14791 @cindex Rotate_Left
14792 @cindex Rotate_Right
14793 @noindent
14794 In standard Ada, the shift and rotate functions are available only
14795 for the predefined modular types in package @code{Interfaces}.  However, in
14796 GNAT it is possible to define these functions for any integer
14797 type (signed or modular), as in this example:
14799 @smallexample @c ada
14800    function Shift_Left
14801      (Value  : T;
14802       Amount : Natural) return T;
14803 @end smallexample
14805 @noindent
14806 The function name must be one of
14807 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14808 Rotate_Right. T must be an integer type. T'Size must be
14809 8, 16, 32 or 64 bits; if T is modular, the modulus
14810 must be 2**8, 2**16, 2**32 or 2**64.
14811 The result type must be the same as the type of @code{Value}.
14812 The shift amount must be Natural.
14813 The formal parameter names can be anything.
14815 A more convenient way of providing these shift operators is to use
14816 the Provide_Shift_Operators pragma, which provides the function declarations
14817 and corresponding pragma Import's for all five shift functions.
14819 @node Source_Location
14820 @section Source_Location
14821 @cindex Source_Location
14822 @noindent
14823 This intrinsic subprogram is used in the implementation of the
14824 library routine @code{GNAT.Source_Info}.  The only useful use of the
14825 intrinsic import in this case is the one in this unit, so an
14826 application program should simply call the function
14827 @code{GNAT.Source_Info.Source_Location} to obtain the current
14828 source file location.
14830 @node Representation Clauses and Pragmas
14831 @chapter Representation Clauses and Pragmas
14832 @cindex Representation Clauses
14834 @menu
14835 * Alignment Clauses::
14836 * Size Clauses::
14837 * Storage_Size Clauses::
14838 * Size of Variant Record Objects::
14839 * Biased Representation ::
14840 * Value_Size and Object_Size Clauses::
14841 * Component_Size Clauses::
14842 * Bit_Order Clauses::
14843 * Effect of Bit_Order on Byte Ordering::
14844 * Pragma Pack for Arrays::
14845 * Pragma Pack for Records::
14846 * Record Representation Clauses::
14847 * Handling of Records with Holes::
14848 * Enumeration Clauses::
14849 * Address Clauses::
14850 * Use of Address Clauses for Memory-Mapped I/O::
14851 * Effect of Convention on Representation::
14852 * Conventions and Anonymous Access Types::
14853 * Determining the Representations chosen by GNAT::
14854 @end menu
14856 @noindent
14857 @cindex Representation Clause
14858 @cindex Representation Pragma
14859 @cindex Pragma, representation
14860 This section describes the representation clauses accepted by GNAT, and
14861 their effect on the representation of corresponding data objects.
14863 GNAT fully implements Annex C (Systems Programming).  This means that all
14864 the implementation advice sections in chapter 13 are fully implemented.
14865 However, these sections only require a minimal level of support for
14866 representation clauses.  GNAT provides much more extensive capabilities,
14867 and this section describes the additional capabilities provided.
14869 @node Alignment Clauses
14870 @section Alignment Clauses
14871 @cindex Alignment Clause
14873 @noindent
14874 GNAT requires that all alignment clauses specify a power of 2, and all
14875 default alignments are always a power of 2.  The default alignment
14876 values are as follows:
14878 @itemize @bullet
14879 @item @emph{Primitive Types}.
14880 For primitive types, the alignment is the minimum of the actual size of
14881 objects of the type divided by @code{Storage_Unit},
14882 and the maximum alignment supported by the target.
14883 (This maximum alignment is given by the GNAT-specific attribute
14884 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14885 @cindex @code{Maximum_Alignment} attribute
14886 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14887 default alignment will be 8 on any target that supports alignments
14888 this large, but on some targets, the maximum alignment may be smaller
14889 than 8, in which case objects of type @code{Long_Float} will be maximally
14890 aligned.
14892 @item @emph{Arrays}.
14893 For arrays, the alignment is equal to the alignment of the component type
14894 for the normal case where no packing or component size is given.  If the
14895 array is packed, and the packing is effective (see separate section on
14896 packed arrays), then the alignment will be one for long packed arrays,
14897 or arrays whose length is not known at compile time.  For short packed
14898 arrays, which are handled internally as modular types, the alignment
14899 will be as described for primitive types, e.g.@: a packed array of length
14900 31 bits will have an object size of four bytes, and an alignment of 4.
14902 @item @emph{Records}.
14903 For the normal non-packed case, the alignment of a record is equal to
14904 the maximum alignment of any of its components.  For tagged records, this
14905 includes the implicit access type used for the tag.  If a pragma @code{Pack}
14906 is used and all components are packable (see separate section on pragma
14907 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14908 record makes it profitable to increase it.
14910 A special case is when:
14911 @itemize @bullet
14912 @item
14913 the size of the record is given explicitly, or a
14914 full record representation clause is given, and
14915 @item
14916 the size of the record is 2, 4, or 8 bytes.
14917 @end itemize
14918 @noindent
14919 In this case, an alignment is chosen to match the
14920 size of the record. For example, if we have:
14922 @smallexample @c ada
14923    type Small is record
14924       A, B : Character;
14925    end record;
14926    for Small'Size use 16;
14927 @end smallexample
14929 @noindent
14930 then the default alignment of the record type @code{Small} is 2, not 1. This
14931 leads to more efficient code when the record is treated as a unit, and also
14932 allows the type to specified as @code{Atomic} on architectures requiring
14933 strict alignment.
14935 @end itemize
14937 @noindent
14938 An alignment clause may specify a larger alignment than the default value
14939 up to some maximum value dependent on the target (obtainable by using the
14940 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14941 a smaller alignment than the default value for enumeration, integer and
14942 fixed point types, as well as for record types, for example
14944 @smallexample @c ada
14945   type V is record
14946      A : Integer;
14947   end record;
14949   for V'alignment use 1;
14950 @end smallexample
14952 @noindent
14953 @cindex Alignment, default
14954 The default alignment for the type @code{V} is 4, as a result of the
14955 Integer field in the record, but it is permissible, as shown, to
14956 override the default alignment of the record with a smaller value.
14958 @cindex Alignment, subtypes
14959 Note that according to the Ada standard, an alignment clause applies only
14960 to the first named subtype. If additional subtypes are declared, then the
14961 compiler is allowed to choose any alignment it likes, and there is no way
14962 to control this choice. Consider:
14964 @smallexample @c ada
14965    type R is range 1 .. 10_000;
14966    for R'Alignment use 1;
14967    subtype RS is R range 1 .. 1000;
14968 @end smallexample
14970 @noindent
14971 The alignment clause specifies an alignment of 1 for the first named subtype
14972 @code{R} but this does not necessarily apply to @code{RS}. When writing
14973 portable Ada code, you should avoid writing code that explicitly or
14974 implicitly relies on the alignment of such subtypes.
14976 For the GNAT compiler, if an explicit alignment clause is given, this
14977 value is also used for any subsequent subtypes. So for GNAT, in the
14978 above example, you can count on the alignment of @code{RS} being 1. But this
14979 assumption is non-portable, and other compilers may choose different
14980 alignments for the subtype @code{RS}.
14982 @node Size Clauses
14983 @section Size Clauses
14984 @cindex Size Clause
14986 @noindent
14987 The default size for a type @code{T} is obtainable through the
14988 language-defined attribute @code{T'Size} and also through the
14989 equivalent GNAT-defined attribute @code{T'Value_Size}.
14990 For objects of type @code{T}, GNAT will generally increase the type size
14991 so that the object size (obtainable through the GNAT-defined attribute
14992 @code{T'Object_Size})
14993 is a multiple of @code{T'Alignment * Storage_Unit}.
14994 For example
14996 @smallexample @c ada
14997    type Smallint is range 1 .. 6;
14999    type Rec is record
15000       Y1 : integer;
15001       Y2 : boolean;
15002    end record;
15003 @end smallexample
15005 @noindent
15006 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
15007 as specified by the RM rules,
15008 but objects of this type will have a size of 8
15009 (@code{Smallint'Object_Size} = 8),
15010 since objects by default occupy an integral number
15011 of storage units.  On some targets, notably older
15012 versions of the Digital Alpha, the size of stand
15013 alone objects of this type may be 32, reflecting
15014 the inability of the hardware to do byte load/stores.
15016 Similarly, the size of type @code{Rec} is 40 bits
15017 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
15018 the alignment is 4, so objects of this type will have
15019 their size increased to 64 bits so that it is a multiple
15020 of the alignment (in bits).  This decision is
15021 in accordance with the specific Implementation Advice in RM 13.3(43):
15023 @quotation
15024 A @code{Size} clause should be supported for an object if the specified
15025 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
15026 to a size in storage elements that is a multiple of the object's
15027 @code{Alignment} (if the @code{Alignment} is nonzero).
15028 @end quotation
15030 @noindent
15031 An explicit size clause may be used to override the default size by
15032 increasing it.  For example, if we have:
15034 @smallexample @c ada
15035    type My_Boolean is new Boolean;
15036    for My_Boolean'Size use 32;
15037 @end smallexample
15039 @noindent
15040 then values of this type will always be 32 bits long.  In the case of
15041 discrete types, the size can be increased up to 64 bits, with the effect
15042 that the entire specified field is used to hold the value, sign- or
15043 zero-extended as appropriate.  If more than 64 bits is specified, then
15044 padding space is allocated after the value, and a warning is issued that
15045 there are unused bits.
15047 Similarly the size of records and arrays may be increased, and the effect
15048 is to add padding bits after the value.  This also causes a warning message
15049 to be generated.
15051 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
15052 Size in bits, this corresponds to an object of size 256 megabytes (minus
15053 one).  This limitation is true on all targets.  The reason for this
15054 limitation is that it improves the quality of the code in many cases
15055 if it is known that a Size value can be accommodated in an object of
15056 type Integer.
15058 @node Storage_Size Clauses
15059 @section Storage_Size Clauses
15060 @cindex Storage_Size Clause
15062 @noindent
15063 For tasks, the @code{Storage_Size} clause specifies the amount of space
15064 to be allocated for the task stack.  This cannot be extended, and if the
15065 stack is exhausted, then @code{Storage_Error} will be raised (if stack
15066 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
15067 or a @code{Storage_Size} pragma in the task definition to set the
15068 appropriate required size.  A useful technique is to include in every
15069 task definition a pragma of the form:
15071 @smallexample @c ada
15072    pragma Storage_Size (Default_Stack_Size);
15073 @end smallexample
15075 @noindent
15076 Then @code{Default_Stack_Size} can be defined in a global package, and
15077 modified as required. Any tasks requiring stack sizes different from the
15078 default can have an appropriate alternative reference in the pragma.
15080 You can also use the @option{-d} binder switch to modify the default stack
15081 size.
15083 For access types, the @code{Storage_Size} clause specifies the maximum
15084 space available for allocation of objects of the type.  If this space is
15085 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
15086 In the case where the access type is declared local to a subprogram, the
15087 use of a @code{Storage_Size} clause triggers automatic use of a special
15088 predefined storage pool (@code{System.Pool_Size}) that ensures that all
15089 space for the pool is automatically reclaimed on exit from the scope in
15090 which the type is declared.
15092 A special case recognized by the compiler is the specification of a
15093 @code{Storage_Size} of zero for an access type.  This means that no
15094 items can be allocated from the pool, and this is recognized at compile
15095 time, and all the overhead normally associated with maintaining a fixed
15096 size storage pool is eliminated.  Consider the following example:
15098 @smallexample @c ada
15099    procedure p is
15100       type R is array (Natural) of Character;
15101       type P is access all R;
15102       for P'Storage_Size use 0;
15103       --  Above access type intended only for interfacing purposes
15105       y : P;
15107       procedure g (m : P);
15108       pragma Import (C, g);
15110       --  @dots{}
15112    begin
15113       --  @dots{}
15114       y := new R;
15115    end;
15116 @end smallexample
15118 @noindent
15119 As indicated in this example, these dummy storage pools are often useful in
15120 connection with interfacing where no object will ever be allocated.  If you
15121 compile the above example, you get the warning:
15123 @smallexample
15124    p.adb:16:09: warning: allocation from empty storage pool
15125    p.adb:16:09: warning: Storage_Error will be raised at run time
15126 @end smallexample
15128 @noindent
15129 Of course in practice, there will not be any explicit allocators in the
15130 case of such an access declaration.
15132 @node Size of Variant Record Objects
15133 @section Size of Variant Record Objects
15134 @cindex Size, variant record objects
15135 @cindex Variant record objects, size
15137 @noindent
15138 In the case of variant record objects, there is a question whether Size gives
15139 information about a particular variant, or the maximum size required
15140 for any variant.  Consider the following program
15142 @smallexample @c ada
15143 with Text_IO; use Text_IO;
15144 procedure q is
15145    type R1 (A : Boolean := False) is record
15146      case A is
15147        when True  => X : Character;
15148        when False => null;
15149      end case;
15150    end record;
15152    V1 : R1 (False);
15153    V2 : R1;
15155 begin
15156    Put_Line (Integer'Image (V1'Size));
15157    Put_Line (Integer'Image (V2'Size));
15158 end q;
15159 @end smallexample
15161 @noindent
15162 Here we are dealing with a variant record, where the True variant
15163 requires 16 bits, and the False variant requires 8 bits.
15164 In the above example, both V1 and V2 contain the False variant,
15165 which is only 8 bits long.  However, the result of running the
15166 program is:
15168 @smallexample
15171 @end smallexample
15173 @noindent
15174 The reason for the difference here is that the discriminant value of
15175 V1 is fixed, and will always be False.  It is not possible to assign
15176 a True variant value to V1, therefore 8 bits is sufficient.  On the
15177 other hand, in the case of V2, the initial discriminant value is
15178 False (from the default), but it is possible to assign a True
15179 variant value to V2, therefore 16 bits must be allocated for V2
15180 in the general case, even fewer bits may be needed at any particular
15181 point during the program execution.
15183 As can be seen from the output of this program, the @code{'Size}
15184 attribute applied to such an object in GNAT gives the actual allocated
15185 size of the variable, which is the largest size of any of the variants.
15186 The Ada Reference Manual is not completely clear on what choice should
15187 be made here, but the GNAT behavior seems most consistent with the
15188 language in the RM@.
15190 In some cases, it may be desirable to obtain the size of the current
15191 variant, rather than the size of the largest variant.  This can be
15192 achieved in GNAT by making use of the fact that in the case of a
15193 subprogram parameter, GNAT does indeed return the size of the current
15194 variant (because a subprogram has no way of knowing how much space
15195 is actually allocated for the actual).
15197 Consider the following modified version of the above program:
15199 @smallexample @c ada
15200 with Text_IO; use Text_IO;
15201 procedure q is
15202    type R1 (A : Boolean := False) is record
15203      case A is
15204        when True  => X : Character;
15205        when False => null;
15206      end case;
15207    end record;
15209    V2 : R1;
15211    function Size (V : R1) return Integer is
15212    begin
15213       return V'Size;
15214    end Size;
15216 begin
15217    Put_Line (Integer'Image (V2'Size));
15218    Put_Line (Integer'IMage (Size (V2)));
15219    V2 := (True, 'x');
15220    Put_Line (Integer'Image (V2'Size));
15221    Put_Line (Integer'IMage (Size (V2)));
15222 end q;
15223 @end smallexample
15225 @noindent
15226 The output from this program is
15228 @smallexample
15233 @end smallexample
15235 @noindent
15236 Here we see that while the @code{'Size} attribute always returns
15237 the maximum size, regardless of the current variant value, the
15238 @code{Size} function does indeed return the size of the current
15239 variant value.
15241 @node Biased Representation
15242 @section Biased Representation
15243 @cindex Size for biased representation
15244 @cindex Biased representation
15246 @noindent
15247 In the case of scalars with a range starting at other than zero, it is
15248 possible in some cases to specify a size smaller than the default minimum
15249 value, and in such cases, GNAT uses an unsigned biased representation,
15250 in which zero is used to represent the lower bound, and successive values
15251 represent successive values of the type.
15253 For example, suppose we have the declaration:
15255 @smallexample @c ada
15256    type Small is range -7 .. -4;
15257    for Small'Size use 2;
15258 @end smallexample
15260 @noindent
15261 Although the default size of type @code{Small} is 4, the @code{Size}
15262 clause is accepted by GNAT and results in the following representation
15263 scheme:
15265 @smallexample
15266   -7 is represented as 2#00#
15267   -6 is represented as 2#01#
15268   -5 is represented as 2#10#
15269   -4 is represented as 2#11#
15270 @end smallexample
15272 @noindent
15273 Biased representation is only used if the specified @code{Size} clause
15274 cannot be accepted in any other manner.  These reduced sizes that force
15275 biased representation can be used for all discrete types except for
15276 enumeration types for which a representation clause is given.
15278 @node Value_Size and Object_Size Clauses
15279 @section Value_Size and Object_Size Clauses
15280 @findex Value_Size
15281 @findex Object_Size
15282 @cindex Size, of objects
15284 @noindent
15285 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
15286 number of bits required to hold values of type @code{T}.
15287 Although this interpretation was allowed in Ada 83, it was not required,
15288 and this requirement in practice can cause some significant difficulties.
15289 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
15290 However, in Ada 95 and Ada 2005,
15291 @code{Natural'Size} is
15292 typically 31.  This means that code may change in behavior when moving
15293 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
15295 @smallexample @c ada
15296    type Rec is record;
15297       A : Natural;
15298       B : Natural;
15299    end record;
15301    for Rec use record
15302       at 0  range 0 .. Natural'Size - 1;
15303       at 0  range Natural'Size .. 2 * Natural'Size - 1;
15304    end record;
15305 @end smallexample
15307 @noindent
15308 In the above code, since the typical size of @code{Natural} objects
15309 is 32 bits and @code{Natural'Size} is 31, the above code can cause
15310 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
15311 there are cases where the fact that the object size can exceed the
15312 size of the type causes surprises.
15314 To help get around this problem GNAT provides two implementation
15315 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
15316 applied to a type, these attributes yield the size of the type
15317 (corresponding to the RM defined size attribute), and the size of
15318 objects of the type respectively.
15320 The @code{Object_Size} is used for determining the default size of
15321 objects and components.  This size value can be referred to using the
15322 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
15323 the basis of the determination of the size.  The backend is free to
15324 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
15325 character might be stored in 32 bits on a machine with no efficient
15326 byte access instructions such as the Alpha.
15328 The default rules for the value of @code{Object_Size} for
15329 discrete types are as follows:
15331 @itemize @bullet
15332 @item
15333 The @code{Object_Size} for base subtypes reflect the natural hardware
15334 size in bits (run the compiler with @option{-gnatS} to find those values
15335 for numeric types). Enumeration types and fixed-point base subtypes have
15336 8, 16, 32 or 64 bits for this size, depending on the range of values
15337 to be stored.
15339 @item
15340 The @code{Object_Size} of a subtype is the same as the
15341 @code{Object_Size} of
15342 the type from which it is obtained.
15344 @item
15345 The @code{Object_Size} of a derived base type is copied from the parent
15346 base type, and the @code{Object_Size} of a derived first subtype is copied
15347 from the parent first subtype.
15348 @end itemize
15350 @noindent
15351 The @code{Value_Size} attribute
15352 is the (minimum) number of bits required to store a value
15353 of the type.
15354 This value is used to determine how tightly to pack
15355 records or arrays with components of this type, and also affects
15356 the semantics of unchecked conversion (unchecked conversions where
15357 the @code{Value_Size} values differ generate a warning, and are potentially
15358 target dependent).
15360 The default rules for the value of @code{Value_Size} are as follows:
15362 @itemize @bullet
15363 @item
15364 The @code{Value_Size} for a base subtype is the minimum number of bits
15365 required to store all values of the type (including the sign bit
15366 only if negative values are possible).
15368 @item
15369 If a subtype statically matches the first subtype of a given type, then it has
15370 by default the same @code{Value_Size} as the first subtype.  This is a
15371 consequence of RM 13.1(14) (``if two subtypes statically match,
15372 then their subtype-specific aspects are the same''.)
15374 @item
15375 All other subtypes have a @code{Value_Size} corresponding to the minimum
15376 number of bits required to store all values of the subtype.  For
15377 dynamic bounds, it is assumed that the value can range down or up
15378 to the corresponding bound of the ancestor
15379 @end itemize
15381 @noindent
15382 The RM defined attribute @code{Size} corresponds to the
15383 @code{Value_Size} attribute.
15385 The @code{Size} attribute may be defined for a first-named subtype.  This sets
15386 the @code{Value_Size} of
15387 the first-named subtype to the given value, and the
15388 @code{Object_Size} of this first-named subtype to the given value padded up
15389 to an appropriate boundary.  It is a consequence of the default rules
15390 above that this @code{Object_Size} will apply to all further subtypes.  On the
15391 other hand, @code{Value_Size} is affected only for the first subtype, any
15392 dynamic subtypes obtained from it directly, and any statically matching
15393 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
15395 @code{Value_Size} and
15396 @code{Object_Size} may be explicitly set for any subtype using
15397 an attribute definition clause.  Note that the use of these attributes
15398 can cause the RM 13.1(14) rule to be violated.  If two access types
15399 reference aliased objects whose subtypes have differing @code{Object_Size}
15400 values as a result of explicit attribute definition clauses, then it
15401 is illegal to convert from one access subtype to the other. For a more
15402 complete description of this additional legality rule, see the
15403 description of the @code{Object_Size} attribute.
15405 At the implementation level, Esize stores the Object_Size and the
15406 RM_Size field stores the @code{Value_Size} (and hence the value of the
15407 @code{Size} attribute,
15408 which, as noted above, is equivalent to @code{Value_Size}).
15410 To get a feel for the difference, consider the following examples (note
15411 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15413 @smallexample
15414                                        Object_Size     Value_Size
15416 type x1 is range 0 .. 5;                    8               3
15418 type x2 is range 0 .. 5;
15419 for x2'size use 12;                        16              12
15421 subtype x3 is x2 range 0 .. 3;             16               2
15423 subtype x4 is x2'base range 0 .. 10;        8               4
15425 subtype x5 is x2 range 0 .. dynamic;       16               3*
15427 subtype x6 is x2'base range 0 .. dynamic;   8               3*
15429 @end smallexample
15431 @noindent
15432 Note: the entries marked ``3*'' are not actually specified by the Ada
15433 Reference Manual, but it seems in the spirit of the RM rules to allocate
15434 the minimum number of bits (here 3, given the range for @code{x2})
15435 known to be large enough to hold the given range of values.
15437 So far, so good, but GNAT has to obey the RM rules, so the question is
15438 under what conditions must the RM @code{Size} be used.
15439 The following is a list
15440 of the occasions on which the RM @code{Size} must be used:
15442 @itemize @bullet
15443 @item
15444 Component size for packed arrays or records
15446 @item
15447 Value of the attribute @code{Size} for a type
15449 @item
15450 Warning about sizes not matching for unchecked conversion
15451 @end itemize
15453 @noindent
15454 For record types, the @code{Object_Size} is always a multiple of the
15455 alignment of the type (this is true for all types). In some cases the
15456 @code{Value_Size} can be smaller. Consider:
15458 @smallexample
15459    type R is record
15460      X : Integer;
15461      Y : Character;
15462    end record;
15463 @end smallexample
15465 @noindent
15466 On a typical 32-bit architecture, the X component will be four bytes, and
15467 require four-byte alignment, and the Y component will be one byte. In this
15468 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15469 required to store a value of this type, and for example, it is permissible
15470 to have a component of type R in an outer array whose component size is
15471 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15472 since it must be rounded up so that this value is a multiple of the
15473 alignment (4 bytes = 32 bits).
15475 @noindent
15476 For all other types, the @code{Object_Size}
15477 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15478 Only @code{Size} may be specified for such types.
15480 Note that @code{Value_Size} can be used to force biased representation
15481 for a particular subtype. Consider this example:
15483 @smallexample
15484    type R is (A, B, C, D, E, F);
15485    subtype RAB is R range A .. B;
15486    subtype REF is R range E .. F;
15487 @end smallexample
15489 @noindent
15490 By default, @code{RAB}
15491 has a size of 1 (sufficient to accommodate the representation
15492 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15493 has a size of 3 (sufficient to accommodate the representation
15494 of @code{E} and @code{F}, 4 and 5). But if we add the
15495 following @code{Value_Size} attribute definition clause:
15497 @smallexample
15498    for REF'Value_Size use 1;
15499 @end smallexample
15501 @noindent
15502 then biased representation is forced for @code{REF},
15503 and 0 will represent @code{E} and 1 will represent @code{F}.
15504 A warning is issued when a @code{Value_Size} attribute
15505 definition clause forces biased representation. This
15506 warning can be turned off using @code{-gnatw.B}.
15508 @node Component_Size Clauses
15509 @section Component_Size Clauses
15510 @cindex Component_Size Clause
15512 @noindent
15513 Normally, the value specified in a component size clause must be consistent
15514 with the subtype of the array component with regard to size and alignment.
15515 In other words, the value specified must be at least equal to the size
15516 of this subtype, and must be a multiple of the alignment value.
15518 In addition, component size clauses are allowed which cause the array
15519 to be packed, by specifying a smaller value.  A first case is for
15520 component size values in the range 1 through 63.  The value specified
15521 must not be smaller than the Size of the subtype.  GNAT will accurately
15522 honor all packing requests in this range.  For example, if we have:
15524 @smallexample @c ada
15525 type r is array (1 .. 8) of Natural;
15526 for r'Component_Size use 31;
15527 @end smallexample
15529 @noindent
15530 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15531 Of course access to the components of such an array is considerably
15532 less efficient than if the natural component size of 32 is used.
15533 A second case is when the subtype of the component is a record type
15534 padded because of its default alignment.  For example, if we have:
15536 @smallexample @c ada
15537 type r is record
15538   i : Integer;
15539   j : Integer;
15540   b : Boolean;
15541 end record;
15543 type a is array (1 .. 8) of r;
15544 for a'Component_Size use 72;
15545 @end smallexample
15547 @noindent
15548 then the resulting array has a length of 72 bytes, instead of 96 bytes
15549 if the alignment of the record (4) was obeyed.
15551 Note that there is no point in giving both a component size clause
15552 and a pragma Pack for the same array type. if such duplicate
15553 clauses are given, the pragma Pack will be ignored.
15555 @node Bit_Order Clauses
15556 @section Bit_Order Clauses
15557 @cindex Bit_Order Clause
15558 @cindex bit ordering
15559 @cindex ordering, of bits
15561 @noindent
15562 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15563 attribute.  The specification may either correspond to the default bit
15564 order for the target, in which case the specification has no effect and
15565 places no additional restrictions, or it may be for the non-standard
15566 setting (that is the opposite of the default).
15568 In the case where the non-standard value is specified, the effect is
15569 to renumber bits within each byte, but the ordering of bytes is not
15570 affected.  There are certain
15571 restrictions placed on component clauses as follows:
15573 @itemize @bullet
15575 @item Components fitting within a single storage unit.
15576 @noindent
15577 These are unrestricted, and the effect is merely to renumber bits.  For
15578 example if we are on a little-endian machine with @code{Low_Order_First}
15579 being the default, then the following two declarations have exactly
15580 the same effect:
15582 @smallexample @c ada
15583    type R1 is record
15584       A : Boolean;
15585       B : Integer range 1 .. 120;
15586    end record;
15588    for R1 use record
15589       A at 0 range 0 .. 0;
15590       B at 0 range 1 .. 7;
15591    end record;
15593    type R2 is record
15594       A : Boolean;
15595       B : Integer range 1 .. 120;
15596    end record;
15598    for R2'Bit_Order use High_Order_First;
15600    for R2 use record
15601       A at 0 range 7 .. 7;
15602       B at 0 range 0 .. 6;
15603    end record;
15604 @end smallexample
15606 @noindent
15607 The useful application here is to write the second declaration with the
15608 @code{Bit_Order} attribute definition clause, and know that it will be treated
15609 the same, regardless of whether the target is little-endian or big-endian.
15611 @item Components occupying an integral number of bytes.
15612 @noindent
15613 These are components that exactly fit in two or more bytes.  Such component
15614 declarations are allowed, but have no effect, since it is important to realize
15615 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15616 In particular, the following attempt at getting an endian-independent integer
15617 does not work:
15619 @smallexample @c ada
15620    type R2 is record
15621       A : Integer;
15622    end record;
15624    for R2'Bit_Order use High_Order_First;
15626    for R2 use record
15627       A at 0 range 0 .. 31;
15628    end record;
15629 @end smallexample
15631 @noindent
15632 This declaration will result in a little-endian integer on a
15633 little-endian machine, and a big-endian integer on a big-endian machine.
15634 If byte flipping is required for interoperability between big- and
15635 little-endian machines, this must be explicitly programmed.  This capability
15636 is not provided by @code{Bit_Order}.
15638 @item Components that are positioned across byte boundaries
15639 @noindent
15640 but do not occupy an integral number of bytes.  Given that bytes are not
15641 reordered, such fields would occupy a non-contiguous sequence of bits
15642 in memory, requiring non-trivial code to reassemble.  They are for this
15643 reason not permitted, and any component clause specifying such a layout
15644 will be flagged as illegal by GNAT@.
15646 @end itemize
15648 @noindent
15649 Since the misconception that Bit_Order automatically deals with all
15650 endian-related incompatibilities is a common one, the specification of
15651 a component field that is an integral number of bytes will always
15652 generate a warning.  This warning may be suppressed using @code{pragma
15653 Warnings (Off)} if desired.  The following section contains additional
15654 details regarding the issue of byte ordering.
15656 @node Effect of Bit_Order on Byte Ordering
15657 @section Effect of Bit_Order on Byte Ordering
15658 @cindex byte ordering
15659 @cindex ordering, of bytes
15661 @noindent
15662 In this section we will review the effect of the @code{Bit_Order} attribute
15663 definition clause on byte ordering.  Briefly, it has no effect at all, but
15664 a detailed example will be helpful.  Before giving this
15665 example, let us review the precise
15666 definition of the effect of defining @code{Bit_Order}.  The effect of a
15667 non-standard bit order is described in section 15.5.3 of the Ada
15668 Reference Manual:
15670 @quotation
15671 2   A bit ordering is a method of interpreting the meaning of
15672 the storage place attributes.
15673 @end quotation
15675 @noindent
15676 To understand the precise definition of storage place attributes in
15677 this context, we visit section 13.5.1 of the manual:
15679 @quotation
15680 13   A record_representation_clause (without the mod_clause)
15681 specifies the layout.  The storage place attributes (see 13.5.2)
15682 are taken from the values of the position, first_bit, and last_bit
15683 expressions after normalizing those values so that first_bit is
15684 less than Storage_Unit.
15685 @end quotation
15687 @noindent
15688 The critical point here is that storage places are taken from
15689 the values after normalization, not before.  So the @code{Bit_Order}
15690 interpretation applies to normalized values.  The interpretation
15691 is described in the later part of the 15.5.3 paragraph:
15693 @quotation
15694 2   A bit ordering is a method of interpreting the meaning of
15695 the storage place attributes.  High_Order_First (known in the
15696 vernacular as ``big endian'') means that the first bit of a
15697 storage element (bit 0) is the most significant bit (interpreting
15698 the sequence of bits that represent a component as an unsigned
15699 integer value).  Low_Order_First (known in the vernacular as
15700 ``little endian'') means the opposite: the first bit is the
15701 least significant.
15702 @end quotation
15704 @noindent
15705 Note that the numbering is with respect to the bits of a storage
15706 unit.  In other words, the specification affects only the numbering
15707 of bits within a single storage unit.
15709 We can make the effect clearer by giving an example.
15711 Suppose that we have an external device which presents two bytes, the first
15712 byte presented, which is the first (low addressed byte) of the two byte
15713 record is called Master, and the second byte is called Slave.
15715 The left most (most significant bit is called Control for each byte, and
15716 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15717 (least significant) bit.
15719 On a big-endian machine, we can write the following representation clause
15721 @smallexample @c ada
15722    type Data is record
15723       Master_Control : Bit;
15724       Master_V1      : Bit;
15725       Master_V2      : Bit;
15726       Master_V3      : Bit;
15727       Master_V4      : Bit;
15728       Master_V5      : Bit;
15729       Master_V6      : Bit;
15730       Master_V7      : Bit;
15731       Slave_Control  : Bit;
15732       Slave_V1       : Bit;
15733       Slave_V2       : Bit;
15734       Slave_V3       : Bit;
15735       Slave_V4       : Bit;
15736       Slave_V5       : Bit;
15737       Slave_V6       : Bit;
15738       Slave_V7       : Bit;
15739    end record;
15741    for Data use record
15742       Master_Control at 0 range 0 .. 0;
15743       Master_V1      at 0 range 1 .. 1;
15744       Master_V2      at 0 range 2 .. 2;
15745       Master_V3      at 0 range 3 .. 3;
15746       Master_V4      at 0 range 4 .. 4;
15747       Master_V5      at 0 range 5 .. 5;
15748       Master_V6      at 0 range 6 .. 6;
15749       Master_V7      at 0 range 7 .. 7;
15750       Slave_Control  at 1 range 0 .. 0;
15751       Slave_V1       at 1 range 1 .. 1;
15752       Slave_V2       at 1 range 2 .. 2;
15753       Slave_V3       at 1 range 3 .. 3;
15754       Slave_V4       at 1 range 4 .. 4;
15755       Slave_V5       at 1 range 5 .. 5;
15756       Slave_V6       at 1 range 6 .. 6;
15757       Slave_V7       at 1 range 7 .. 7;
15758    end record;
15759 @end smallexample
15761 @noindent
15762 Now if we move this to a little endian machine, then the bit ordering within
15763 the byte is backwards, so we have to rewrite the record rep clause as:
15765 @smallexample @c ada
15766    for Data use record
15767       Master_Control at 0 range 7 .. 7;
15768       Master_V1      at 0 range 6 .. 6;
15769       Master_V2      at 0 range 5 .. 5;
15770       Master_V3      at 0 range 4 .. 4;
15771       Master_V4      at 0 range 3 .. 3;
15772       Master_V5      at 0 range 2 .. 2;
15773       Master_V6      at 0 range 1 .. 1;
15774       Master_V7      at 0 range 0 .. 0;
15775       Slave_Control  at 1 range 7 .. 7;
15776       Slave_V1       at 1 range 6 .. 6;
15777       Slave_V2       at 1 range 5 .. 5;
15778       Slave_V3       at 1 range 4 .. 4;
15779       Slave_V4       at 1 range 3 .. 3;
15780       Slave_V5       at 1 range 2 .. 2;
15781       Slave_V6       at 1 range 1 .. 1;
15782       Slave_V7       at 1 range 0 .. 0;
15783    end record;
15784 @end smallexample
15786 @noindent
15787 It is a nuisance to have to rewrite the clause, especially if
15788 the code has to be maintained on both machines.  However,
15789 this is a case that we can handle with the
15790 @code{Bit_Order} attribute if it is implemented.
15791 Note that the implementation is not required on byte addressed
15792 machines, but it is indeed implemented in GNAT.
15793 This means that we can simply use the
15794 first record clause, together with the declaration
15796 @smallexample @c ada
15797    for Data'Bit_Order use High_Order_First;
15798 @end smallexample
15800 @noindent
15801 and the effect is what is desired, namely the layout is exactly the same,
15802 independent of whether the code is compiled on a big-endian or little-endian
15803 machine.
15805 The important point to understand is that byte ordering is not affected.
15806 A @code{Bit_Order} attribute definition never affects which byte a field
15807 ends up in, only where it ends up in that byte.
15808 To make this clear, let us rewrite the record rep clause of the previous
15809 example as:
15811 @smallexample @c ada
15812    for Data'Bit_Order use High_Order_First;
15813    for Data use record
15814       Master_Control at 0 range  0 .. 0;
15815       Master_V1      at 0 range  1 .. 1;
15816       Master_V2      at 0 range  2 .. 2;
15817       Master_V3      at 0 range  3 .. 3;
15818       Master_V4      at 0 range  4 .. 4;
15819       Master_V5      at 0 range  5 .. 5;
15820       Master_V6      at 0 range  6 .. 6;
15821       Master_V7      at 0 range  7 .. 7;
15822       Slave_Control  at 0 range  8 .. 8;
15823       Slave_V1       at 0 range  9 .. 9;
15824       Slave_V2       at 0 range 10 .. 10;
15825       Slave_V3       at 0 range 11 .. 11;
15826       Slave_V4       at 0 range 12 .. 12;
15827       Slave_V5       at 0 range 13 .. 13;
15828       Slave_V6       at 0 range 14 .. 14;
15829       Slave_V7       at 0 range 15 .. 15;
15830    end record;
15831 @end smallexample
15833 @noindent
15834 This is exactly equivalent to saying (a repeat of the first example):
15836 @smallexample @c ada
15837    for Data'Bit_Order use High_Order_First;
15838    for Data use record
15839       Master_Control at 0 range 0 .. 0;
15840       Master_V1      at 0 range 1 .. 1;
15841       Master_V2      at 0 range 2 .. 2;
15842       Master_V3      at 0 range 3 .. 3;
15843       Master_V4      at 0 range 4 .. 4;
15844       Master_V5      at 0 range 5 .. 5;
15845       Master_V6      at 0 range 6 .. 6;
15846       Master_V7      at 0 range 7 .. 7;
15847       Slave_Control  at 1 range 0 .. 0;
15848       Slave_V1       at 1 range 1 .. 1;
15849       Slave_V2       at 1 range 2 .. 2;
15850       Slave_V3       at 1 range 3 .. 3;
15851       Slave_V4       at 1 range 4 .. 4;
15852       Slave_V5       at 1 range 5 .. 5;
15853       Slave_V6       at 1 range 6 .. 6;
15854       Slave_V7       at 1 range 7 .. 7;
15855    end record;
15856 @end smallexample
15858 @noindent
15859 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15860 field.  The storage place attributes are obtained by normalizing the
15861 values given so that the @code{First_Bit} value is less than 8.  After
15862 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15863 we specified in the other case.
15865 Now one might expect that the @code{Bit_Order} attribute might affect
15866 bit numbering within the entire record component (two bytes in this
15867 case, thus affecting which byte fields end up in), but that is not
15868 the way this feature is defined, it only affects numbering of bits,
15869 not which byte they end up in.
15871 Consequently it never makes sense to specify a starting bit number
15872 greater than 7 (for a byte addressable field) if an attribute
15873 definition for @code{Bit_Order} has been given, and indeed it
15874 may be actively confusing to specify such a value, so the compiler
15875 generates a warning for such usage.
15877 If you do need to control byte ordering then appropriate conditional
15878 values must be used.  If in our example, the slave byte came first on
15879 some machines we might write:
15881 @smallexample @c ada
15882    Master_Byte_First constant Boolean := @dots{};
15884    Master_Byte : constant Natural :=
15885                    1 - Boolean'Pos (Master_Byte_First);
15886    Slave_Byte  : constant Natural :=
15887                    Boolean'Pos (Master_Byte_First);
15889    for Data'Bit_Order use High_Order_First;
15890    for Data use record
15891       Master_Control at Master_Byte range 0 .. 0;
15892       Master_V1      at Master_Byte range 1 .. 1;
15893       Master_V2      at Master_Byte range 2 .. 2;
15894       Master_V3      at Master_Byte range 3 .. 3;
15895       Master_V4      at Master_Byte range 4 .. 4;
15896       Master_V5      at Master_Byte range 5 .. 5;
15897       Master_V6      at Master_Byte range 6 .. 6;
15898       Master_V7      at Master_Byte range 7 .. 7;
15899       Slave_Control  at Slave_Byte  range 0 .. 0;
15900       Slave_V1       at Slave_Byte  range 1 .. 1;
15901       Slave_V2       at Slave_Byte  range 2 .. 2;
15902       Slave_V3       at Slave_Byte  range 3 .. 3;
15903       Slave_V4       at Slave_Byte  range 4 .. 4;
15904       Slave_V5       at Slave_Byte  range 5 .. 5;
15905       Slave_V6       at Slave_Byte  range 6 .. 6;
15906       Slave_V7       at Slave_Byte  range 7 .. 7;
15907    end record;
15908 @end smallexample
15910 @noindent
15911 Now to switch between machines, all that is necessary is
15912 to set the boolean constant @code{Master_Byte_First} in
15913 an appropriate manner.
15915 @node Pragma Pack for Arrays
15916 @section Pragma Pack for Arrays
15917 @cindex Pragma Pack (for arrays)
15919 @noindent
15920 Pragma @code{Pack} applied to an array has no effect unless the component type
15921 is packable.  For a component type to be packable, it must be one of the
15922 following cases:
15924 @itemize @bullet
15925 @item
15926 Any scalar type
15927 @item
15928 Any type whose size is specified with a size clause
15929 @item
15930 Any packed array type with a static size
15931 @item
15932 Any record type padded because of its default alignment
15933 @end itemize
15935 @noindent
15936 For all these cases, if the component subtype size is in the range
15937 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15938 component size were specified giving the component subtype size.
15939 For example if we have:
15941 @smallexample @c ada
15942    type r is range 0 .. 17;
15944    type ar is array (1 .. 8) of r;
15945    pragma Pack (ar);
15946 @end smallexample
15948 @noindent
15949 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15950 and the size of the array @code{ar} will be exactly 40 bits.
15952 Note that in some cases this rather fierce approach to packing can produce
15953 unexpected effects.  For example, in Ada 95 and Ada 2005,
15954 subtype @code{Natural} typically has a size of 31, meaning that if you
15955 pack an array of @code{Natural}, you get 31-bit
15956 close packing, which saves a few bits, but results in far less efficient
15957 access.  Since many other Ada compilers will ignore such a packing request,
15958 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15959 might not be what is intended.  You can easily remove this warning by
15960 using an explicit @code{Component_Size} setting instead, which never generates
15961 a warning, since the intention of the programmer is clear in this case.
15963 GNAT treats packed arrays in one of two ways.  If the size of the array is
15964 known at compile time and is less than 64 bits, then internally the array
15965 is represented as a single modular type, of exactly the appropriate number
15966 of bits.  If the length is greater than 63 bits, or is not known at compile
15967 time, then the packed array is represented as an array of bytes, and the
15968 length is always a multiple of 8 bits.
15970 Note that to represent a packed array as a modular type, the alignment must
15971 be suitable for the modular type involved. For example, on typical machines
15972 a 32-bit packed array will be represented by a 32-bit modular integer with
15973 an alignment of four bytes. If you explicitly override the default alignment
15974 with an alignment clause that is too small, the modular representation
15975 cannot be used. For example, consider the following set of declarations:
15977 @smallexample @c ada
15978    type R is range 1 .. 3;
15979    type S is array (1 .. 31) of R;
15980    for S'Component_Size use 2;
15981    for S'Size use 62;
15982    for S'Alignment use 1;
15983 @end smallexample
15985 @noindent
15986 If the alignment clause were not present, then a 62-bit modular
15987 representation would be chosen (typically with an alignment of 4 or 8
15988 bytes depending on the target). But the default alignment is overridden
15989 with the explicit alignment clause. This means that the modular
15990 representation cannot be used, and instead the array of bytes
15991 representation must be used, meaning that the length must be a multiple
15992 of 8. Thus the above set of declarations will result in a diagnostic
15993 rejecting the size clause and noting that the minimum size allowed is 64.
15995 @cindex Pragma Pack (for type Natural)
15996 @cindex Pragma Pack warning
15998 One special case that is worth noting occurs when the base type of the
15999 component size is 8/16/32 and the subtype is one bit less. Notably this
16000 occurs with subtype @code{Natural}. Consider:
16002 @smallexample @c ada
16003    type Arr is array (1 .. 32) of Natural;
16004    pragma Pack (Arr);
16005 @end smallexample
16007 @noindent
16008 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
16009 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
16010 Ada 83 compilers did not attempt 31 bit packing.
16012 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
16013 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
16014 substantial unintended performance penalty when porting legacy Ada 83 code.
16015 To help prevent this, GNAT generates a warning in such cases. If you really
16016 want 31 bit packing in a case like this, you can set the component size
16017 explicitly:
16019 @smallexample @c ada
16020    type Arr is array (1 .. 32) of Natural;
16021    for Arr'Component_Size use 31;
16022 @end smallexample
16024 @noindent
16025 Here 31-bit packing is achieved as required, and no warning is generated,
16026 since in this case the programmer intention is clear.
16028 @node Pragma Pack for Records
16029 @section Pragma Pack for Records
16030 @cindex Pragma Pack (for records)
16032 @noindent
16033 Pragma @code{Pack} applied to a record will pack the components to reduce
16034 wasted space from alignment gaps and by reducing the amount of space
16035 taken by components.  We distinguish between @emph{packable} components and
16036 @emph{non-packable} components.
16037 Components of the following types are considered packable:
16038 @itemize @bullet
16039 @item
16040 Components of a primitive type are packable unless they are aliased
16041 or of an atomic type.
16043 @item
16044 Small packed arrays, whose size does not exceed 64 bits, and where the
16045 size is statically known at compile time, are represented internally
16046 as modular integers, and so they are also packable.
16048 @end itemize
16050 @noindent
16051 All packable components occupy the exact number of bits corresponding to
16052 their @code{Size} value, and are packed with no padding bits, i.e.@: they
16053 can start on an arbitrary bit boundary.
16055 All other types are non-packable, they occupy an integral number of
16056 storage units, and
16057 are placed at a boundary corresponding to their alignment requirements.
16059 For example, consider the record
16061 @smallexample @c ada
16062    type Rb1 is array (1 .. 13) of Boolean;
16063    pragma Pack (Rb1);
16065    type Rb2 is array (1 .. 65) of Boolean;
16066    pragma Pack (Rb2);
16068    type AF is new Float with Atomic;
16070    type X2 is record
16071       L1 : Boolean;
16072       L2 : Duration;
16073       L3 : AF;
16074       L4 : Boolean;
16075       L5 : Rb1;
16076       L6 : Rb2;
16077    end record;
16078    pragma Pack (X2);
16079 @end smallexample
16081 @noindent
16082 The representation for the record X2 is as follows:
16084 @smallexample @c ada
16085 for X2'Size use 224;
16086 for X2 use record
16087    L1 at  0 range  0 .. 0;
16088    L2 at  0 range  1 .. 64;
16089    L3 at 12 range  0 .. 31;
16090    L4 at 16 range  0 .. 0;
16091    L5 at 16 range  1 .. 13;
16092    L6 at 18 range  0 .. 71;
16093 end record;
16094 @end smallexample
16096 @noindent
16097 Studying this example, we see that the packable fields @code{L1}
16098 and @code{L2} are
16099 of length equal to their sizes, and placed at specific bit boundaries (and
16100 not byte boundaries) to
16101 eliminate padding.  But @code{L3} is of a non-packable float type (because
16102 it is aliased), so it is on the next appropriate alignment boundary.
16104 The next two fields are fully packable, so @code{L4} and @code{L5} are
16105 minimally packed with no gaps.  However, type @code{Rb2} is a packed
16106 array that is longer than 64 bits, so it is itself non-packable.  Thus
16107 the @code{L6} field is aligned to the next byte boundary, and takes an
16108 integral number of bytes, i.e.@: 72 bits.
16110 @node Record Representation Clauses
16111 @section Record Representation Clauses
16112 @cindex Record Representation Clause
16114 @noindent
16115 Record representation clauses may be given for all record types, including
16116 types obtained by record extension.  Component clauses are allowed for any
16117 static component.  The restrictions on component clauses depend on the type
16118 of the component.
16120 @cindex Component Clause
16121 For all components of an elementary type, the only restriction on component
16122 clauses is that the size must be at least the 'Size value of the type
16123 (actually the Value_Size).  There are no restrictions due to alignment,
16124 and such components may freely cross storage boundaries.
16126 Packed arrays with a size up to and including 64 bits are represented
16127 internally using a modular type with the appropriate number of bits, and
16128 thus the same lack of restriction applies.  For example, if you declare:
16130 @smallexample @c ada
16131    type R is array (1 .. 49) of Boolean;
16132    pragma Pack (R);
16133    for R'Size use 49;
16134 @end smallexample
16136 @noindent
16137 then a component clause for a component of type R may start on any
16138 specified bit boundary, and may specify a value of 49 bits or greater.
16140 For packed bit arrays that are longer than 64 bits, there are two
16141 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
16142 including the important case of single bits or boolean values, then
16143 there are no limitations on placement of such components, and they
16144 may start and end at arbitrary bit boundaries.
16146 If the component size is not a power of 2 (e.g.@: 3 or 5), then
16147 an array of this type longer than 64 bits must always be placed on
16148 on a storage unit (byte) boundary and occupy an integral number
16149 of storage units (bytes). Any component clause that does not
16150 meet this requirement will be rejected.
16152 Any aliased component, or component of an aliased type, must
16153 have its normal alignment and size. A component clause that
16154 does not meet this requirement will be rejected.
16156 The tag field of a tagged type always occupies an address sized field at
16157 the start of the record.  No component clause may attempt to overlay this
16158 tag. When a tagged type appears as a component, the tag field must have
16159 proper alignment
16161 In the case of a record extension T1, of a type T, no component clause applied
16162 to the type T1 can specify a storage location that would overlap the first
16163 T'Size bytes of the record.
16165 For all other component types, including non-bit-packed arrays,
16166 the component can be placed at an arbitrary bit boundary,
16167 so for example, the following is permitted:
16169 @smallexample @c ada
16170    type R is array (1 .. 10) of Boolean;
16171    for R'Size use 80;
16173    type Q is record
16174       G, H : Boolean;
16175       L, M : R;
16176    end record;
16178    for Q use record
16179       G at 0 range  0 ..   0;
16180       H at 0 range  1 ..   1;
16181       L at 0 range  2 ..  81;
16182       R at 0 range 82 .. 161;
16183    end record;
16184 @end smallexample
16186 @noindent
16187 Note: the above rules apply to recent releases of GNAT 5.
16188 In GNAT 3, there are more severe restrictions on larger components.
16189 For non-primitive types, including packed arrays with a size greater than
16190 64 bits, component clauses must respect the alignment requirement of the
16191 type, in particular, always starting on a byte boundary, and the length
16192 must be a multiple of the storage unit.
16194 @node Handling of Records with Holes
16195 @section Handling of Records with Holes
16196 @cindex Handling of Records with Holes
16198 As a result of alignment considerations, records may contain "holes"
16199 or gaps
16200 which do not correspond to the data bits of any of the components.
16201 Record representation clauses can also result in holes in records.
16203 GNAT does not attempt to clear these holes, so in record objects,
16204 they should be considered to hold undefined rubbish. The generated
16205 equality routine just tests components so does not access these
16206 undefined bits, and assignment and copy operations may or may not
16207 preserve the contents of these holes (for assignments, the holes
16208 in the target will in practice contain either the bits that are
16209 present in the holes in the source, or the bits that were present
16210 in the target before the assignment).
16212 If it is necessary to ensure that holes in records have all zero
16213 bits, then record objects for which this initialization is desired
16214 should be explicitly set to all zero values using Unchecked_Conversion
16215 or address overlays. For example
16217 @smallexample @c ada
16218 type HRec is record
16219    C : Character;
16220    I : Integer;
16221 end record;
16222 @end smallexample
16224 @noindent
16225 On typical machines, integers need to be aligned on a four-byte
16226 boundary, resulting in three bytes of undefined rubbish following
16227 the 8-bit field for C. To ensure that the hole in a variable of
16228 type HRec is set to all zero bits,
16229 you could for example do:
16231 @smallexample @c ada
16232 type Base is record
16233    Dummy1, Dummy2 : Integer := 0;
16234 end record;
16236 BaseVar : Base;
16237 RealVar : Hrec;
16238 for RealVar'Address use BaseVar'Address;
16239 @end smallexample
16241 @noindent
16242 Now the 8-bytes of the value of RealVar start out containing all zero
16243 bits. A safer approach is to just define dummy fields, avoiding the
16244 holes, as in:
16246 @smallexample @c ada
16247 type HRec is record
16248    C      : Character;
16249    Dummy1 : Short_Short_Integer := 0;
16250    Dummy2 : Short_Short_Integer := 0;
16251    Dummy3 : Short_Short_Integer := 0;
16252    I      : Integer;
16253 end record;
16254 @end smallexample
16256 @noindent
16257 And to make absolutely sure that the intent of this is followed, you
16258 can use representation clauses:
16260 @smallexample @c ada
16261 for Hrec use record
16262    C      at 0 range 0 .. 7;
16263    Dummy1 at 1 range 0 .. 7;
16264    Dummy2 at 2 range 0 .. 7;
16265    Dummy3 at 3 range 0 .. 7;
16266    I      at 4 range 0 .. 31;
16267 end record;
16268 for Hrec'Size use 64;
16269 @end smallexample
16271 @node Enumeration Clauses
16272 @section Enumeration Clauses
16274 The only restriction on enumeration clauses is that the range of values
16275 must be representable.  For the signed case, if one or more of the
16276 representation values are negative, all values must be in the range:
16278 @smallexample @c ada
16279    System.Min_Int .. System.Max_Int
16280 @end smallexample
16282 @noindent
16283 For the unsigned case, where all values are nonnegative, the values must
16284 be in the range:
16286 @smallexample @c ada
16287    0 .. System.Max_Binary_Modulus;
16288 @end smallexample
16290 @noindent
16291 A @emph{confirming} representation clause is one in which the values range
16292 from 0 in sequence, i.e.@: a clause that confirms the default representation
16293 for an enumeration type.
16294 Such a confirming representation
16295 is permitted by these rules, and is specially recognized by the compiler so
16296 that no extra overhead results from the use of such a clause.
16298 If an array has an index type which is an enumeration type to which an
16299 enumeration clause has been applied, then the array is stored in a compact
16300 manner.  Consider the declarations:
16302 @smallexample @c ada
16303    type r is (A, B, C);
16304    for r use (A => 1, B => 5, C => 10);
16305    type t is array (r) of Character;
16306 @end smallexample
16308 @noindent
16309 The array type t corresponds to a vector with exactly three elements and
16310 has a default size equal to @code{3*Character'Size}.  This ensures efficient
16311 use of space, but means that accesses to elements of the array will incur
16312 the overhead of converting representation values to the corresponding
16313 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
16315 @node Address Clauses
16316 @section Address Clauses
16317 @cindex Address Clause
16319 The reference manual allows a general restriction on representation clauses,
16320 as found in RM 13.1(22):
16322 @quotation
16323 An implementation need not support representation
16324 items containing nonstatic expressions, except that
16325 an implementation should support a representation item
16326 for a given entity if each nonstatic expression in the
16327 representation item is a name that statically denotes
16328 a constant declared before the entity.
16329 @end quotation
16331 @noindent
16332 In practice this is applicable only to address clauses, since this is the
16333 only case in which a non-static expression is permitted by the syntax.  As
16334 the AARM notes in sections 13.1 (22.a-22.h):
16336 @display
16337   22.a   Reason: This is to avoid the following sort of thing:
16339   22.b        X : Integer := F(@dots{});
16340               Y : Address := G(@dots{});
16341               for X'Address use Y;
16343   22.c   In the above, we have to evaluate the
16344          initialization expression for X before we
16345          know where to put the result.  This seems
16346          like an unreasonable implementation burden.
16348   22.d   The above code should instead be written
16349          like this:
16351   22.e        Y : constant Address := G(@dots{});
16352               X : Integer := F(@dots{});
16353               for X'Address use Y;
16355   22.f   This allows the expression ``Y'' to be safely
16356          evaluated before X is created.
16358   22.g   The constant could be a formal parameter of mode in.
16360   22.h   An implementation can support other nonstatic
16361          expressions if it wants to.  Expressions of type
16362          Address are hardly ever static, but their value
16363          might be known at compile time anyway in many
16364          cases.
16365 @end display
16367 @noindent
16368 GNAT does indeed permit many additional cases of non-static expressions.  In
16369 particular, if the type involved is elementary there are no restrictions
16370 (since in this case, holding a temporary copy of the initialization value,
16371 if one is present, is inexpensive).  In addition, if there is no implicit or
16372 explicit initialization, then there are no restrictions.  GNAT will reject
16373 only the case where all three of these conditions hold:
16375 @itemize @bullet
16377 @item
16378 The type of the item is non-elementary (e.g.@: a record or array).
16380 @item
16381 There is explicit or implicit initialization required for the object.
16382 Note that access values are always implicitly initialized.
16384 @item
16385 The address value is non-static.  Here GNAT is more permissive than the
16386 RM, and allows the address value to be the address of a previously declared
16387 stand-alone variable, as long as it does not itself have an address clause.
16389 @smallexample @c ada
16390            Anchor  : Some_Initialized_Type;
16391            Overlay : Some_Initialized_Type;
16392            for Overlay'Address use Anchor'Address;
16393 @end smallexample
16395 @noindent
16396 However, the prefix of the address clause cannot be an array component, or
16397 a component of a discriminated record.
16399 @end itemize
16401 @noindent
16402 As noted above in section 22.h, address values are typically non-static.  In
16403 particular the To_Address function, even if applied to a literal value, is
16404 a non-static function call.  To avoid this minor annoyance, GNAT provides
16405 the implementation defined attribute 'To_Address.  The following two
16406 expressions have identical values:
16408 @findex Attribute
16409 @findex To_Address
16410 @smallexample @c ada
16411    To_Address (16#1234_0000#)
16412    System'To_Address (16#1234_0000#);
16413 @end smallexample
16415 @noindent
16416 except that the second form is considered to be a static expression, and
16417 thus when used as an address clause value is always permitted.
16419 @noindent
16420 Additionally, GNAT treats as static an address clause that is an
16421 unchecked_conversion of a static integer value.  This simplifies the porting
16422 of legacy code, and provides a portable equivalent to the GNAT attribute
16423 @code{To_Address}.
16425 Another issue with address clauses is the interaction with alignment
16426 requirements.  When an address clause is given for an object, the address
16427 value must be consistent with the alignment of the object (which is usually
16428 the same as the alignment of the type of the object).  If an address clause
16429 is given that specifies an inappropriately aligned address value, then the
16430 program execution is erroneous.
16432 Since this source of erroneous behavior can have unfortunate effects, GNAT
16433 checks (at compile time if possible, generating a warning, or at execution
16434 time with a run-time check) that the alignment is appropriate.  If the
16435 run-time check fails, then @code{Program_Error} is raised.  This run-time
16436 check is suppressed if range checks are suppressed, or if the special GNAT
16437 check Alignment_Check is suppressed, or if
16438 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16440 Finally, GNAT does not permit overlaying of objects of controlled types or
16441 composite types containing a controlled component. In most cases, the compiler
16442 can detect an attempt at such overlays and will generate a warning at compile
16443 time and a Program_Error exception at run time.
16445 @findex Export
16446 An address clause cannot be given for an exported object.  More
16447 understandably the real restriction is that objects with an address
16448 clause cannot be exported.  This is because such variables are not
16449 defined by the Ada program, so there is no external object to export.
16451 @findex Import
16452 It is permissible to give an address clause and a pragma Import for the
16453 same object.  In this case, the variable is not really defined by the
16454 Ada program, so there is no external symbol to be linked.  The link name
16455 and the external name are ignored in this case.  The reason that we allow this
16456 combination is that it provides a useful idiom to avoid unwanted
16457 initializations on objects with address clauses.
16459 When an address clause is given for an object that has implicit or
16460 explicit initialization, then by default initialization takes place.  This
16461 means that the effect of the object declaration is to overwrite the
16462 memory at the specified address.  This is almost always not what the
16463 programmer wants, so GNAT will output a warning:
16465 @smallexample
16466   with System;
16467   package G is
16468      type R is record
16469         M : Integer := 0;
16470      end record;
16472      Ext : R;
16473      for Ext'Address use System'To_Address (16#1234_1234#);
16474          |
16475   >>> warning: implicit initialization of "Ext" may
16476       modify overlaid storage
16477   >>> warning: use pragma Import for "Ext" to suppress
16478       initialization (RM B(24))
16480   end G;
16481 @end smallexample
16483 @noindent
16484 As indicated by the warning message, the solution is to use a (dummy) pragma
16485 Import to suppress this initialization.  The pragma tell the compiler that the
16486 object is declared and initialized elsewhere.  The following package compiles
16487 without warnings (and the initialization is suppressed):
16489 @smallexample @c ada
16490    with System;
16491    package G is
16492       type R is record
16493          M : Integer := 0;
16494       end record;
16496       Ext : R;
16497       for Ext'Address use System'To_Address (16#1234_1234#);
16498       pragma Import (Ada, Ext);
16499    end G;
16500 @end smallexample
16502 @noindent
16503 A final issue with address clauses involves their use for overlaying
16504 variables, as in the following example:
16505 @cindex Overlaying of objects
16507 @smallexample @c ada
16508   A : Integer;
16509   B : Integer;
16510   for B'Address use A'Address;
16511 @end smallexample
16513 @noindent
16514 or alternatively, using the form recommended by the RM:
16516 @smallexample @c ada
16517   A    : Integer;
16518   Addr : constant Address := A'Address;
16519   B    : Integer;
16520   for B'Address use Addr;
16521 @end smallexample
16523 @noindent
16524 In both of these cases, @code{A}
16525 and @code{B} become aliased to one another via the
16526 address clause. This use of address clauses to overlay
16527 variables, achieving an effect similar to unchecked
16528 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16529 the effect is implementation defined. Furthermore, the
16530 Ada RM specifically recommends that in a situation
16531 like this, @code{B} should be subject to the following
16532 implementation advice (RM 13.3(19)):
16534 @quotation
16535 19  If the Address of an object is specified, or it is imported
16536     or exported, then the implementation should not perform
16537     optimizations based on assumptions of no aliases.
16538 @end quotation
16540 @noindent
16541 GNAT follows this recommendation, and goes further by also applying
16542 this recommendation to the overlaid variable (@code{A}
16543 in the above example) in this case. This means that the overlay
16544 works "as expected", in that a modification to one of the variables
16545 will affect the value of the other.
16547 Note that when address clause overlays are used in this way, there is an
16548 issue of unintentional initialization, as shown by this example:
16550 @smallexample @c ada
16551 package Overwrite_Record is
16552    type R is record
16553       A : Character := 'C';
16554       B : Character := 'A';
16555    end record;
16556    X : Short_Integer := 3;
16557    Y : R;
16558    for Y'Address use X'Address;
16559        |
16560 >>> warning: default initialization of "Y" may
16561     modify "X", use pragma Import for "Y" to
16562     suppress initialization (RM B.1(24))
16564 end Overwrite_Record;
16565 @end smallexample
16567 @noindent
16568 Here the default initialization of @code{Y} will clobber the value
16569 of @code{X}, which justifies the warning. The warning notes that
16570 this effect can be eliminated by adding a @code{pragma Import}
16571 which suppresses the initialization:
16573 @smallexample @c ada
16574 package Overwrite_Record is
16575    type R is record
16576       A : Character := 'C';
16577       B : Character := 'A';
16578    end record;
16579    X : Short_Integer := 3;
16580    Y : R;
16581    for Y'Address use X'Address;
16582    pragma Import (Ada, Y);
16583 end Overwrite_Record;
16584 @end smallexample
16586 @noindent
16587 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16588 be initialized when they would not otherwise have been in the absence
16589 of the use of this pragma. This may cause an overlay to have this
16590 unintended clobbering effect. The compiler avoids this for scalar
16591 types, but not for composite objects (where in general the effect
16592 of @code{Initialize_Scalars} is part of the initialization routine
16593 for the composite object:
16595 @smallexample @c ada
16596 pragma Initialize_Scalars;
16597 with Ada.Text_IO;  use Ada.Text_IO;
16598 procedure Overwrite_Array is
16599    type Arr is array (1 .. 5) of Integer;
16600    X : Arr := (others => 1);
16601    A : Arr;
16602    for A'Address use X'Address;
16603        |
16604 >>> warning: default initialization of "A" may
16605     modify "X", use pragma Import for "A" to
16606     suppress initialization (RM B.1(24))
16608 begin
16609    if X /= Arr'(others => 1) then
16610       Put_Line ("X was clobbered");
16611    else
16612       Put_Line ("X was not clobbered");
16613    end if;
16614 end Overwrite_Array;
16615 @end smallexample
16617 @noindent
16618 The above program generates the warning as shown, and at execution
16619 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16620 added as suggested:
16622 @smallexample @c ada
16623 pragma Initialize_Scalars;
16624 with Ada.Text_IO;  use Ada.Text_IO;
16625 procedure Overwrite_Array is
16626    type Arr is array (1 .. 5) of Integer;
16627    X : Arr := (others => 1);
16628    A : Arr;
16629    for A'Address use X'Address;
16630    pragma Import (Ada, A);
16631 begin
16632    if X /= Arr'(others => 1) then
16633       Put_Line ("X was clobbered");
16634    else
16635       Put_Line ("X was not clobbered");
16636    end if;
16637 end Overwrite_Array;
16638 @end smallexample
16640 @noindent
16641 then the program compiles without the warning and when run will generate
16642 the output @code{X was not clobbered}.
16644 @node Use of Address Clauses for Memory-Mapped I/O
16645 @section Use of Address Clauses for Memory-Mapped I/O
16646 @cindex Memory-mapped I/O
16648 A common pattern is to use an address clause to map an atomic variable to
16649 a location in memory that corresponds to a memory-mapped I/O operation or
16650 operations, for example:
16652 @smallexample @c ada
16653     type Mem_Word is record
16654        A,B,C,D : Byte;
16655     end record;
16656     pragma Atomic (Mem_Word);
16657     for Mem_Word_Size use 32;
16659     Mem : Mem_Word;
16660     for Mem'Address use some-address;
16661     ...
16662     Temp := Mem;
16663     Temp.A := 32;
16664     Mem := Temp;
16665 @end smallexample
16667 @noindent
16668 For a full access (reference or modification) of the variable (Mem) in
16669 this case, as in the above examples, GNAT guarantees that the entire atomic
16670 word will be accessed. It is not clear whether the RM requires this. For
16671 example in the above, can the compiler reference only the Mem.A field as
16672 an optimization? Whatever the answer to this question is, GNAT makes the
16673 guarantee that for such a reference, the entire word is read or written.
16675 A problem arises with a component access such as:
16677 @smallexample @c ada
16678     Mem.A := 32;
16679 @end smallexample
16681 @noindent
16682 Note that the component A is not declared as atomic. This means that it is
16683 not clear what this assignment means. It could correspond to full word read
16684 and write as given in the first example, or on architectures that supported
16685 such an operation it might be a single byte store instruction. The RM does
16686 not have anything to say in this situation, and GNAT does not make any
16687 guarantee. The code generated may vary from target to target. GNAT will issue
16688 a warning in such a case:
16690 @smallexample @c ada
16691     Mem.A := 32;
16692     |
16693     >>> warning: access to non-atomic component of atomic array,
16694         may cause unexpected accesses to atomic object
16695 @end smallexample
16697 @noindent
16698 It is best to be explicit in this situation, by either declaring the
16699 components to be atomic if you want the byte store, or explicitly writing
16700 the full word access sequence if that is what the hardware requires.
16702 @node Effect of Convention on Representation
16703 @section Effect of Convention on Representation
16704 @cindex Convention, effect on representation
16706 @noindent
16707 Normally the specification of a foreign language convention for a type or
16708 an object has no effect on the chosen representation.  In particular, the
16709 representation chosen for data in GNAT generally meets the standard system
16710 conventions, and for example records are laid out in a manner that is
16711 consistent with C@.  This means that specifying convention C (for example)
16712 has no effect.
16714 There are four exceptions to this general rule:
16716 @itemize @bullet
16718 @item Convention Fortran and array subtypes
16719 If pragma Convention Fortran is specified for an array subtype, then in
16720 accordance with the implementation advice in section 3.6.2(11) of the
16721 Ada Reference Manual, the array will be stored in a Fortran-compatible
16722 column-major manner, instead of the normal default row-major order.
16724 @item Convention C and enumeration types
16725 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16726 to accommodate all values of the type.  For example, for the enumeration
16727 type declared by:
16729 @smallexample @c ada
16730    type Color is (Red, Green, Blue);
16731 @end smallexample
16733 @noindent
16734 8 bits is sufficient to store all values of the type, so by default, objects
16735 of type @code{Color} will be represented using 8 bits.  However, normal C
16736 convention is to use 32 bits for all enum values in C, since enum values
16737 are essentially of type int.  If pragma @code{Convention C} is specified for an
16738 Ada enumeration type, then the size is modified as necessary (usually to
16739 32 bits) to be consistent with the C convention for enum values.
16741 Note that this treatment applies only to types. If Convention C is given for
16742 an enumeration object, where the enumeration type is not Convention C, then
16743 Object_Size bits are allocated. For example, for a normal enumeration type,
16744 with less than 256 elements, only 8 bits will be allocated for the object.
16745 Since this may be a surprise in terms of what C expects, GNAT will issue a
16746 warning in this situation. The warning can be suppressed by giving an explicit
16747 size clause specifying the desired size.
16749 @item Convention C/Fortran and Boolean types
16750 In C, the usual convention for boolean values, that is values used for
16751 conditions, is that zero represents false, and nonzero values represent
16752 true.  In Ada, the normal convention is that two specific values, typically
16753 0/1, are used to represent false/true respectively.
16755 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16756 value represents true).
16758 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16759 C or Fortran convention for a derived Boolean, as in the following example:
16761 @smallexample @c ada
16762    type C_Switch is new Boolean;
16763    pragma Convention (C, C_Switch);
16764 @end smallexample
16766 @noindent
16767 then the GNAT generated code will treat any nonzero value as true.  For truth
16768 values generated by GNAT, the conventional value 1 will be used for True, but
16769 when one of these values is read, any nonzero value is treated as True.
16771 @item Access types on OpenVMS
16772 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16773 arrays) are 64-bits long. An exception to this rule is for the case of
16774 C-convention access types where there is no explicit size clause present (or
16775 inherited for derived types). In this case, GNAT chooses to make these
16776 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16777 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16779 @end itemize
16781 @node Conventions and Anonymous Access Types
16782 @section Conventions and Anonymous Access Types
16783 @cindex Anonymous access types
16784 @cindex Convention for anonymous access types
16786 The RM is not entirely clear on convention handling in a number of cases,
16787 and in particular, it is not clear on the convention to be given to
16788 anonymous access types in general, and in particular what is to be
16789 done for the case of anonymous access-to-subprogram.
16791 In GNAT, we decide that if an explicit Convention is applied
16792 to an object or component, and its type is such an anonymous type,
16793 then the convention will apply to this anonymous type as well. This
16794 seems to make sense since it is anomolous in any case to have a
16795 different convention for an object and its type, and there is clearly
16796 no way to explicitly specify a convention for an anonymous type, since
16797 it doesn't have a name to specify!
16799 Furthermore, we decide that if a convention is applied to a record type,
16800 then this convention is inherited by any of its components that are of an
16801 anonymous access type which do not have an explicitly specified convention.
16803 The following program shows these conventions in action:
16805 @smallexample @c ada
16806 package ConvComp is
16807    type Foo is range 1 .. 10;
16808    type T1 is record
16809       A : access function (X : Foo) return Integer;
16810       B : Integer;
16811    end record;
16812    pragma Convention (C, T1);
16814    type T2 is record
16815       A : access function (X : Foo) return Integer;
16816       pragma Convention  (C, A);
16817       B : Integer;
16818    end record;
16819    pragma Convention (COBOL, T2);
16821    type T3 is record
16822       A : access function (X : Foo) return Integer;
16823       pragma Convention  (COBOL, A);
16824       B : Integer;
16825    end record;
16826    pragma Convention (C, T3);
16828    type T4 is record
16829       A : access function (X : Foo) return Integer;
16830       B : Integer;
16831    end record;
16832    pragma Convention (COBOL, T4);
16834    function F (X : Foo) return Integer;
16835    pragma Convention (C, F);
16837    function F (X : Foo) return Integer is (13);
16839    TV1 : T1 := (F'Access, 12);  -- OK
16840    TV2 : T2 := (F'Access, 13);  -- OK
16842    TV3 : T3 := (F'Access, 13);  -- ERROR
16843                 |
16844 >>> subprogram "F" has wrong convention
16845 >>> does not match access to subprogram declared at line 17
16846      38.    TV4 : T4 := (F'Access, 13);  -- ERROR
16847                 |
16848 >>> subprogram "F" has wrong convention
16849 >>> does not match access to subprogram declared at line 24
16850      39. end ConvComp;
16851 @end smallexample
16853 @node Determining the Representations chosen by GNAT
16854 @section Determining the Representations chosen by GNAT
16855 @cindex Representation, determination of
16856 @cindex @option{-gnatR} switch
16858 @noindent
16859 Although the descriptions in this section are intended to be complete, it is
16860 often easier to simply experiment to see what GNAT accepts and what the
16861 effect is on the layout of types and objects.
16863 As required by the Ada RM, if a representation clause is not accepted, then
16864 it must be rejected as illegal by the compiler.  However, when a
16865 representation clause or pragma is accepted, there can still be questions
16866 of what the compiler actually does.  For example, if a partial record
16867 representation clause specifies the location of some components and not
16868 others, then where are the non-specified components placed? Or if pragma
16869 @code{Pack} is used on a record, then exactly where are the resulting
16870 fields placed? The section on pragma @code{Pack} in this chapter can be
16871 used to answer the second question, but it is often easier to just see
16872 what the compiler does.
16874 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
16875 with this option, then the compiler will output information on the actual
16876 representations chosen, in a format similar to source representation
16877 clauses.  For example, if we compile the package:
16879 @smallexample @c ada
16880 package q is
16881    type r (x : boolean) is tagged record
16882       case x is
16883          when True => S : String (1 .. 100);
16884          when False => null;
16885       end case;
16886    end record;
16888    type r2 is new r (false) with record
16889       y2 : integer;
16890    end record;
16892    for r2 use record
16893       y2 at 16 range 0 .. 31;
16894    end record;
16896    type x is record
16897       y : character;
16898    end record;
16900    type x1 is array (1 .. 10) of x;
16901    for x1'component_size use 11;
16903    type ia is access integer;
16905    type Rb1 is array (1 .. 13) of Boolean;
16906    pragma Pack (rb1);
16908    type Rb2 is array (1 .. 65) of Boolean;
16909    pragma Pack (rb2);
16911    type x2 is record
16912       l1 : Boolean;
16913       l2 : Duration;
16914       l3 : Float;
16915       l4 : Boolean;
16916       l5 : Rb1;
16917       l6 : Rb2;
16918    end record;
16919    pragma Pack (x2);
16920 end q;
16921 @end smallexample
16923 @noindent
16924 using the switch @option{-gnatR} we obtain the following output:
16926 @smallexample
16927 Representation information for unit q
16928 -------------------------------------
16930 for r'Size use ??;
16931 for r'Alignment use 4;
16932 for r use record
16933    x    at 4 range  0 .. 7;
16934    _tag at 0 range  0 .. 31;
16935    s    at 5 range  0 .. 799;
16936 end record;
16938 for r2'Size use 160;
16939 for r2'Alignment use 4;
16940 for r2 use record
16941    x       at  4 range  0 .. 7;
16942    _tag    at  0 range  0 .. 31;
16943    _parent at  0 range  0 .. 63;
16944    y2      at 16 range  0 .. 31;
16945 end record;
16947 for x'Size use 8;
16948 for x'Alignment use 1;
16949 for x use record
16950    y at 0 range  0 .. 7;
16951 end record;
16953 for x1'Size use 112;
16954 for x1'Alignment use 1;
16955 for x1'Component_Size use 11;
16957 for rb1'Size use 13;
16958 for rb1'Alignment use 2;
16959 for rb1'Component_Size use 1;
16961 for rb2'Size use 72;
16962 for rb2'Alignment use 1;
16963 for rb2'Component_Size use 1;
16965 for x2'Size use 224;
16966 for x2'Alignment use 4;
16967 for x2 use record
16968    l1 at  0 range  0 .. 0;
16969    l2 at  0 range  1 .. 64;
16970    l3 at 12 range  0 .. 31;
16971    l4 at 16 range  0 .. 0;
16972    l5 at 16 range  1 .. 13;
16973    l6 at 18 range  0 .. 71;
16974 end record;
16975 @end smallexample
16977 @noindent
16978 The Size values are actually the Object_Size, i.e.@: the default size that
16979 will be allocated for objects of the type.
16980 The ?? size for type r indicates that we have a variant record, and the
16981 actual size of objects will depend on the discriminant value.
16983 The Alignment values show the actual alignment chosen by the compiler
16984 for each record or array type.
16986 The record representation clause for type r shows where all fields
16987 are placed, including the compiler generated tag field (whose location
16988 cannot be controlled by the programmer).
16990 The record representation clause for the type extension r2 shows all the
16991 fields present, including the parent field, which is a copy of the fields
16992 of the parent type of r2, i.e.@: r1.
16994 The component size and size clauses for types rb1 and rb2 show
16995 the exact effect of pragma @code{Pack} on these arrays, and the record
16996 representation clause for type x2 shows how pragma @code{Pack} affects
16997 this record type.
16999 In some cases, it may be useful to cut and paste the representation clauses
17000 generated by the compiler into the original source to fix and guarantee
17001 the actual representation to be used.
17003 @node Standard Library Routines
17004 @chapter Standard Library Routines
17006 @noindent
17007 The Ada Reference Manual contains in Annex A a full description of an
17008 extensive set of standard library routines that can be used in any Ada
17009 program, and which must be provided by all Ada compilers.  They are
17010 analogous to the standard C library used by C programs.
17012 GNAT implements all of the facilities described in annex A, and for most
17013 purposes the description in the Ada Reference Manual, or appropriate Ada
17014 text book, will be sufficient for making use of these facilities.
17016 In the case of the input-output facilities,
17017 @xref{The Implementation of Standard I/O},
17018 gives details on exactly how GNAT interfaces to the
17019 file system.  For the remaining packages, the Ada Reference Manual
17020 should be sufficient.  The following is a list of the packages included,
17021 together with a brief description of the functionality that is provided.
17023 For completeness, references are included to other predefined library
17024 routines defined in other sections of the Ada Reference Manual (these are
17025 cross-indexed from Annex A). For further details see the relevant
17026 package declarations in the run-time library. In particular, a few units
17027 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
17028 and in this case the package declaration contains comments explaining why
17029 the unit is not implemented.
17031 @table @code
17032 @item Ada (A.2)
17033 This is a parent package for all the standard library packages.  It is
17034 usually included implicitly in your program, and itself contains no
17035 useful data or routines.
17037 @item Ada.Assertions (11.4.2)
17038 @code{Assertions} provides the @code{Assert} subprograms, and also
17039 the declaration of the @code{Assertion_Error} exception.
17041 @item Ada.Asynchronous_Task_Control (D.11)
17042 @code{Asynchronous_Task_Control} provides low level facilities for task
17043 synchronization. It is typically not implemented. See package spec for details.
17045 @item Ada.Calendar (9.6)
17046 @code{Calendar} provides time of day access, and routines for
17047 manipulating times and durations.
17049 @item Ada.Calendar.Arithmetic (9.6.1)
17050 This package provides additional arithmetic
17051 operations for @code{Calendar}.
17053 @item Ada.Calendar.Formatting (9.6.1)
17054 This package provides formatting operations for @code{Calendar}.
17056 @item Ada.Calendar.Time_Zones (9.6.1)
17057 This package provides additional @code{Calendar} facilities
17058 for handling time zones.
17060 @item Ada.Characters (A.3.1)
17061 This is a dummy parent package that contains no useful entities
17063 @item Ada.Characters.Conversions (A.3.2)
17064 This package provides character conversion functions.
17066 @item Ada.Characters.Handling (A.3.2)
17067 This package provides some basic character handling capabilities,
17068 including classification functions for classes of characters (e.g.@: test
17069 for letters, or digits).
17071 @item Ada.Characters.Latin_1 (A.3.3)
17072 This package includes a complete set of definitions of the characters
17073 that appear in type CHARACTER@.  It is useful for writing programs that
17074 will run in international environments.  For example, if you want an
17075 upper case E with an acute accent in a string, it is often better to use
17076 the definition of @code{UC_E_Acute} in this package.  Then your program
17077 will print in an understandable manner even if your environment does not
17078 support these extended characters.
17080 @item Ada.Command_Line (A.15)
17081 This package provides access to the command line parameters and the name
17082 of the current program (analogous to the use of @code{argc} and @code{argv}
17083 in C), and also allows the exit status for the program to be set in a
17084 system-independent manner.
17086 @item Ada.Complex_Text_IO (G.1.3)
17087 This package provides text input and output of complex numbers.
17089 @item Ada.Containers (A.18.1)
17090 A top level package providing a few basic definitions used by all the
17091 following specific child packages that provide specific kinds of
17092 containers.
17094 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
17096 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
17098 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
17100 @item Ada.Containers.Generic_Array_Sort (A.18.26)
17102 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
17104 @item Ada.Containers.Generic_Sort (A.18.26)
17106 @item Ada.Containers.Hashed_Maps (A.18.5)
17108 @item Ada.Containers.Hashed_Sets (A.18.8)
17110 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
17112 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
17114 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
17116 @item Ada.Containers.Indefinite_Holders (A.18.18)
17118 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
17120 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
17122 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
17124 @item Ada.Containers.Indefinite_Vectors (A.18.11)
17126 @item Ada.Containers.Multiway_Trees (A.18.10)
17128 @item Ada.Containers.Ordered_Maps (A.18.6)
17130 @item Ada.Containers.Ordered_Sets (A.18.9)
17132 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
17134 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
17136 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
17138 @item Ada.Containers.Vectors (A.18.2)
17140 @item Ada.Directories (A.16)
17141 This package provides operations on directories.
17143 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
17144 This package provides additional directory operations handling
17145 hiearchical file names.
17147 @item Ada.Directories.Information (A.16)
17148 This is an implementation defined package for additional directory
17149 operations, which is not implemented in GNAT.
17151 @item Ada.Decimal (F.2)
17152 This package provides constants describing the range of decimal numbers
17153 implemented, and also a decimal divide routine (analogous to the COBOL
17154 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
17156 @item Ada.Direct_IO (A.8.4)
17157 This package provides input-output using a model of a set of records of
17158 fixed-length, containing an arbitrary definite Ada type, indexed by an
17159 integer record number.
17161 @item Ada.Dispatching (D.2.1)
17162 A parent package containing definitions for task dispatching operations.
17164 @item Ada.Dispatching.EDF (D.2.6)
17165 Not implemented in GNAT.
17167 @item Ada.Dispatching.Non_Preemptive (D.2.4)
17168 Not implemented in GNAT.
17170 @item Ada.Dispatching.Round_Robin (D.2.5)
17171 Not implemented in GNAT.
17173 @item Ada.Dynamic_Priorities (D.5)
17174 This package allows the priorities of a task to be adjusted dynamically
17175 as the task is running.
17177 @item Ada.Environment_Variables (A.17)
17178 This package provides facilities for accessing environment variables.
17180 @item Ada.Exceptions (11.4.1)
17181 This package provides additional information on exceptions, and also
17182 contains facilities for treating exceptions as data objects, and raising
17183 exceptions with associated messages.
17185 @item Ada.Execution_Time (D.14)
17186 Not implemented in GNAT.
17188 @item Ada.Execution_Time.Group_Budgets (D.14.2)
17189 Not implemented in GNAT.
17191 @item Ada.Execution_Time.Timers (D.14.1)'
17192 Not implemented in GNAT.
17194 @item Ada.Finalization (7.6)
17195 This package contains the declarations and subprograms to support the
17196 use of controlled types, providing for automatic initialization and
17197 finalization (analogous to the constructors and destructors of C++).
17199 @item Ada.Float_Text_IO (A.10.9)
17200 A library level instantiation of Text_IO.Float_IO for type Float.
17202 @item Ada.Float_Wide_Text_IO (A.10.9)
17203 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
17205 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
17206 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
17208 @item Ada.Integer_Text_IO (A.10.9)
17209 A library level instantiation of Text_IO.Integer_IO for type Integer.
17211 @item Ada.Integer_Wide_Text_IO (A.10.9)
17212 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
17214 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
17215 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
17217 @item Ada.Interrupts (C.3.2)
17218 This package provides facilities for interfacing to interrupts, which
17219 includes the set of signals or conditions that can be raised and
17220 recognized as interrupts.
17222 @item Ada.Interrupts.Names (C.3.2)
17223 This package provides the set of interrupt names (actually signal
17224 or condition names) that can be handled by GNAT@.
17226 @item Ada.IO_Exceptions (A.13)
17227 This package defines the set of exceptions that can be raised by use of
17228 the standard IO packages.
17230 @item Ada.Iterator_Interfaces (5.5.1)
17231 This package provides a generic interface to generalized iterators.
17233 @item Ada.Locales (A.19)
17234 This package provides declarations providing information (Language
17235 and Country) about the current locale.
17237 @item Ada.Numerics
17238 This package contains some standard constants and exceptions used
17239 throughout the numerics packages.  Note that the constants pi and e are
17240 defined here, and it is better to use these definitions than rolling
17241 your own.
17243 @item Ada.Numerics.Complex_Arrays (G.3.2)
17244 Provides operations on arrays of complex numbers.
17246 @item Ada.Numerics.Complex_Elementary_Functions
17247 Provides the implementation of standard elementary functions (such as
17248 log and trigonometric functions) operating on complex numbers using the
17249 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
17250 created by the package @code{Numerics.Complex_Types}.
17252 @item Ada.Numerics.Complex_Types
17253 This is a predefined instantiation of
17254 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
17255 build the type @code{Complex} and @code{Imaginary}.
17257 @item Ada.Numerics.Discrete_Random
17258 This generic package provides a random number generator suitable for generating
17259 uniformly distributed values of a specified discrete subtype.
17261 @item Ada.Numerics.Float_Random
17262 This package provides a random number generator suitable for generating
17263 uniformly distributed floating point values in the unit interval.
17265 @item Ada.Numerics.Generic_Complex_Elementary_Functions
17266 This is a generic version of the package that provides the
17267 implementation of standard elementary functions (such as log and
17268 trigonometric functions) for an arbitrary complex type.
17270 The following predefined instantiations of this package are provided:
17272 @table @code
17273 @item Short_Float
17274 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
17275 @item Float
17276 @code{Ada.Numerics.Complex_Elementary_Functions}
17277 @item Long_Float
17278 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
17279 @end table
17281 @item Ada.Numerics.Generic_Complex_Types
17282 This is a generic package that allows the creation of complex types,
17283 with associated complex arithmetic operations.
17285 The following predefined instantiations of this package exist
17286 @table @code
17287 @item Short_Float
17288 @code{Ada.Numerics.Short_Complex_Complex_Types}
17289 @item Float
17290 @code{Ada.Numerics.Complex_Complex_Types}
17291 @item Long_Float
17292 @code{Ada.Numerics.Long_Complex_Complex_Types}
17293 @end table
17295 @item Ada.Numerics.Generic_Elementary_Functions
17296 This is a generic package that provides the implementation of standard
17297 elementary functions (such as log an trigonometric functions) for an
17298 arbitrary float type.
17300 The following predefined instantiations of this package exist
17302 @table @code
17303 @item Short_Float
17304 @code{Ada.Numerics.Short_Elementary_Functions}
17305 @item Float
17306 @code{Ada.Numerics.Elementary_Functions}
17307 @item Long_Float
17308 @code{Ada.Numerics.Long_Elementary_Functions}
17309 @end table
17311 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
17312 Generic operations on arrays of reals
17314 @item Ada.Numerics.Real_Arrays (G.3.1)
17315 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
17317 @item Ada.Real_Time (D.8)
17318 This package provides facilities similar to those of @code{Calendar}, but
17319 operating with a finer clock suitable for real time control. Note that
17320 annex D requires that there be no backward clock jumps, and GNAT generally
17321 guarantees this behavior, but of course if the external clock on which
17322 the GNAT runtime depends is deliberately reset by some external event,
17323 then such a backward jump may occur.
17325 @item Ada.Real_Time.Timing_Events (D.15)
17326 Not implemented in GNAT.
17328 @item Ada.Sequential_IO (A.8.1)
17329 This package provides input-output facilities for sequential files,
17330 which can contain a sequence of values of a single type, which can be
17331 any Ada type, including indefinite (unconstrained) types.
17333 @item Ada.Storage_IO (A.9)
17334 This package provides a facility for mapping arbitrary Ada types to and
17335 from a storage buffer.  It is primarily intended for the creation of new
17336 IO packages.
17338 @item Ada.Streams (13.13.1)
17339 This is a generic package that provides the basic support for the
17340 concept of streams as used by the stream attributes (@code{Input},
17341 @code{Output}, @code{Read} and @code{Write}).
17343 @item Ada.Streams.Stream_IO (A.12.1)
17344 This package is a specialization of the type @code{Streams} defined in
17345 package @code{Streams} together with a set of operations providing
17346 Stream_IO capability.  The Stream_IO model permits both random and
17347 sequential access to a file which can contain an arbitrary set of values
17348 of one or more Ada types.
17350 @item Ada.Strings (A.4.1)
17351 This package provides some basic constants used by the string handling
17352 packages.
17354 @item Ada.Strings.Bounded (A.4.4)
17355 This package provides facilities for handling variable length
17356 strings.  The bounded model requires a maximum length.  It is thus
17357 somewhat more limited than the unbounded model, but avoids the use of
17358 dynamic allocation or finalization.
17360 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
17361 Provides case-insensitive comparisons of bounded strings
17363 @item Ada.Strings.Bounded.Hash (A.4.9)
17364 This package provides a generic hash function for bounded strings
17366 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
17367 This package provides a generic hash function for bounded strings that
17368 converts the string to be hashed to lower case.
17370 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
17371 This package provides a comparison function for bounded strings that works
17372 in a case insensitive manner by converting to lower case before the comparison.
17374 @item Ada.Strings.Fixed (A.4.3)
17375 This package provides facilities for handling fixed length strings.
17377 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
17378 This package provides an equality function for fixed strings that compares
17379 the strings after converting both to lower case.
17381 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
17382 This package provides a case insensitive hash function for fixed strings that
17383 converts the string to lower case before computing the hash.
17385 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
17386 This package provides a comparison function for fixed strings that works
17387 in a case insensitive manner by converting to lower case before the comparison.
17389 Ada.Strings.Hash (A.4.9)
17390 This package provides a hash function for strings.
17392 Ada.Strings.Hash_Case_Insensitive (A.4.9)
17393 This package provides a hash function for strings that is case insensitive.
17394 The string is converted to lower case before computing the hash.
17396 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
17397 This package provides a comparison function for\strings that works
17398 in a case insensitive manner by converting to lower case before the comparison.
17400 @item Ada.Strings.Maps (A.4.2)
17401 This package provides facilities for handling character mappings and
17402 arbitrarily defined subsets of characters.  For instance it is useful in
17403 defining specialized translation tables.
17405 @item Ada.Strings.Maps.Constants (A.4.6)
17406 This package provides a standard set of predefined mappings and
17407 predefined character sets.  For example, the standard upper to lower case
17408 conversion table is found in this package.  Note that upper to lower case
17409 conversion is non-trivial if you want to take the entire set of
17410 characters, including extended characters like E with an acute accent,
17411 into account.  You should use the mappings in this package (rather than
17412 adding 32 yourself) to do case mappings.
17414 @item Ada.Strings.Unbounded (A.4.5)
17415 This package provides facilities for handling variable length
17416 strings.  The unbounded model allows arbitrary length strings, but
17417 requires the use of dynamic allocation and finalization.
17419 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
17420 Provides case-insensitive comparisons of unbounded strings
17422 @item Ada.Strings.Unbounded.Hash (A.4.9)
17423 This package provides a generic hash function for unbounded strings
17425 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
17426 This package provides a generic hash function for unbounded strings that
17427 converts the string to be hashed to lower case.
17429 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
17430 This package provides a comparison function for unbounded strings that works
17431 in a case insensitive manner by converting to lower case before the comparison.
17433 @item Ada.Strings.UTF_Encoding (A.4.11)
17434 This package provides basic definitions for dealing with UTF-encoded strings.
17436 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
17437 This package provides conversion functions for UTF-encoded strings.
17439 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
17440 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
17441 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
17442 These packages provide facilities for handling UTF encodings for
17443 Strings, Wide_Strings and Wide_Wide_Strings.
17445 @item Ada.Strings.Wide_Bounded (A.4.7)
17446 @itemx Ada.Strings.Wide_Fixed (A.4.7)
17447 @itemx Ada.Strings.Wide_Maps (A.4.7)
17448 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
17449 These packages provide analogous capabilities to the corresponding
17450 packages without @samp{Wide_} in the name, but operate with the types
17451 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
17452 and @code{Character}. Versions of all the child packages are available.
17454 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
17455 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
17456 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
17457 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
17458 These packages provide analogous capabilities to the corresponding
17459 packages without @samp{Wide_} in the name, but operate with the types
17460 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
17461 of @code{String} and @code{Character}.
17463 @item Ada.Synchronous_Barriers (D.10.1)
17464 This package provides facilities for synchronizing tasks at a low level
17465 with barriers.
17467 @item Ada.Synchronous_Task_Control (D.10)
17468 This package provides some standard facilities for controlling task
17469 communication in a synchronous manner.
17471 @item Ada.Synchronous_Task_Control.EDF (D.10)
17472 Not implemented in GNAT.
17474 @item Ada.Tags
17475 This package contains definitions for manipulation of the tags of tagged
17476 values.
17478 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17479 This package provides a way of constructing tagged class-wide values given
17480 only the tag value.
17482 @item Ada.Task_Attributes (C.7.2)
17483 This package provides the capability of associating arbitrary
17484 task-specific data with separate tasks.
17486 @item Ada.Task_Identifification (C.7.1)
17487 This package provides capabilities for task identification.
17489 @item Ada.Task_Termination (C.7.3)
17490 This package provides control over task termination.
17492 @item Ada.Text_IO
17493 This package provides basic text input-output capabilities for
17494 character, string and numeric data.  The subpackages of this
17495 package are listed next. Note that although these are defined
17496 as subpackages in the RM, they are actually transparently
17497 implemented as child packages in GNAT, meaning that they
17498 are only loaded if needed.
17500 @item Ada.Text_IO.Decimal_IO
17501 Provides input-output facilities for decimal fixed-point types
17503 @item Ada.Text_IO.Enumeration_IO
17504 Provides input-output facilities for enumeration types.
17506 @item Ada.Text_IO.Fixed_IO
17507 Provides input-output facilities for ordinary fixed-point types.
17509 @item Ada.Text_IO.Float_IO
17510 Provides input-output facilities for float types.  The following
17511 predefined instantiations of this generic package are available:
17513 @table @code
17514 @item Short_Float
17515 @code{Short_Float_Text_IO}
17516 @item Float
17517 @code{Float_Text_IO}
17518 @item Long_Float
17519 @code{Long_Float_Text_IO}
17520 @end table
17522 @item Ada.Text_IO.Integer_IO
17523 Provides input-output facilities for integer types.  The following
17524 predefined instantiations of this generic package are available:
17526 @table @code
17527 @item Short_Short_Integer
17528 @code{Ada.Short_Short_Integer_Text_IO}
17529 @item Short_Integer
17530 @code{Ada.Short_Integer_Text_IO}
17531 @item Integer
17532 @code{Ada.Integer_Text_IO}
17533 @item Long_Integer
17534 @code{Ada.Long_Integer_Text_IO}
17535 @item Long_Long_Integer
17536 @code{Ada.Long_Long_Integer_Text_IO}
17537 @end table
17539 @item Ada.Text_IO.Modular_IO
17540 Provides input-output facilities for modular (unsigned) types.
17542 @item Ada.Text_IO.Bounded_IO (A.10.11)
17543 Provides input-output facilities for bounded strings.
17545 @item Ada.Text_IO.Complex_IO (G.1.3)
17546 This package provides basic text input-output capabilities for complex
17547 data.
17549 @item Ada.Text_IO.Editing (F.3.3)
17550 This package contains routines for edited output, analogous to the use
17551 of pictures in COBOL@.  The picture formats used by this package are a
17552 close copy of the facility in COBOL@.
17554 @item Ada.Text_IO.Text_Streams (A.12.2)
17555 This package provides a facility that allows Text_IO files to be treated
17556 as streams, so that the stream attributes can be used for writing
17557 arbitrary data, including binary data, to Text_IO files.
17559 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17560 This package provides input-output facilities for unbounded strings.
17562 @item Ada.Unchecked_Conversion (13.9)
17563 This generic package allows arbitrary conversion from one type to
17564 another of the same size, providing for breaking the type safety in
17565 special circumstances.
17567 If the types have the same Size (more accurately the same Value_Size),
17568 then the effect is simply to transfer the bits from the source to the
17569 target type without any modification.  This usage is well defined, and
17570 for simple types whose representation is typically the same across
17571 all implementations, gives a portable method of performing such
17572 conversions.
17574 If the types do not have the same size, then the result is implementation
17575 defined, and thus may be non-portable.  The following describes how GNAT
17576 handles such unchecked conversion cases.
17578 If the types are of different sizes, and are both discrete types, then
17579 the effect is of a normal type conversion without any constraint checking.
17580 In particular if the result type has a larger size, the result will be
17581 zero or sign extended.  If the result type has a smaller size, the result
17582 will be truncated by ignoring high order bits.
17584 If the types are of different sizes, and are not both discrete types,
17585 then the conversion works as though pointers were created to the source
17586 and target, and the pointer value is converted.  The effect is that bits
17587 are copied from successive low order storage units and bits of the source
17588 up to the length of the target type.
17590 A warning is issued if the lengths differ, since the effect in this
17591 case is implementation dependent, and the above behavior may not match
17592 that of some other compiler.
17594 A pointer to one type may be converted to a pointer to another type using
17595 unchecked conversion.  The only case in which the effect is undefined is
17596 when one or both pointers are pointers to unconstrained array types.  In
17597 this case, the bounds information may get incorrectly transferred, and in
17598 particular, GNAT uses double size pointers for such types, and it is
17599 meaningless to convert between such pointer types.  GNAT will issue a
17600 warning if the alignment of the target designated type is more strict
17601 than the alignment of the source designated type (since the result may
17602 be unaligned in this case).
17604 A pointer other than a pointer to an unconstrained array type may be
17605 converted to and from System.Address.  Such usage is common in Ada 83
17606 programs, but note that Ada.Address_To_Access_Conversions is the
17607 preferred method of performing such conversions in Ada 95 and Ada 2005.
17608 Neither
17609 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17610 used in conjunction with pointers to unconstrained objects, since
17611 the bounds information cannot be handled correctly in this case.
17613 @item Ada.Unchecked_Deallocation (13.11.2)
17614 This generic package allows explicit freeing of storage previously
17615 allocated by use of an allocator.
17617 @item Ada.Wide_Text_IO (A.11)
17618 This package is similar to @code{Ada.Text_IO}, except that the external
17619 file supports wide character representations, and the internal types are
17620 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17621 and @code{String}. The corresponding set of nested packages and child
17622 packages are defined.
17624 @item Ada.Wide_Wide_Text_IO (A.11)
17625 This package is similar to @code{Ada.Text_IO}, except that the external
17626 file supports wide character representations, and the internal types are
17627 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17628 and @code{String}. The corresponding set of nested packages and child
17629 packages are defined.
17631 @end table
17633 For packages in Interfaces and System, all the RM defined packages are
17634 available in GNAT, see the Ada 2012 RM for full details.
17636 @node The Implementation of Standard I/O
17637 @chapter The Implementation of Standard I/O
17639 @noindent
17640 GNAT implements all the required input-output facilities described in
17641 A.6 through A.14.  These sections of the Ada Reference Manual describe the
17642 required behavior of these packages from the Ada point of view, and if
17643 you are writing a portable Ada program that does not need to know the
17644 exact manner in which Ada maps to the outside world when it comes to
17645 reading or writing external files, then you do not need to read this
17646 chapter.  As long as your files are all regular files (not pipes or
17647 devices), and as long as you write and read the files only from Ada, the
17648 description in the Ada Reference Manual is sufficient.
17650 However, if you want to do input-output to pipes or other devices, such
17651 as the keyboard or screen, or if the files you are dealing with are
17652 either generated by some other language, or to be read by some other
17653 language, then you need to know more about the details of how the GNAT
17654 implementation of these input-output facilities behaves.
17656 In this chapter we give a detailed description of exactly how GNAT
17657 interfaces to the file system.  As always, the sources of the system are
17658 available to you for answering questions at an even more detailed level,
17659 but for most purposes the information in this chapter will suffice.
17661 Another reason that you may need to know more about how input-output is
17662 implemented arises when you have a program written in mixed languages
17663 where, for example, files are shared between the C and Ada sections of
17664 the same program.  GNAT provides some additional facilities, in the form
17665 of additional child library packages, that facilitate this sharing, and
17666 these additional facilities are also described in this chapter.
17668 @menu
17669 * Standard I/O Packages::
17670 * FORM Strings::
17671 * Direct_IO::
17672 * Sequential_IO::
17673 * Text_IO::
17674 * Wide_Text_IO::
17675 * Wide_Wide_Text_IO::
17676 * Stream_IO::
17677 * Text Translation::
17678 * Shared Files::
17679 * Filenames encoding::
17680 * File content encoding::
17681 * Open Modes::
17682 * Operations on C Streams::
17683 * Interfacing to C Streams::
17684 @end menu
17686 @node Standard I/O Packages
17687 @section Standard I/O Packages
17689 @noindent
17690 The Standard I/O packages described in Annex A for
17692 @itemize @bullet
17693 @item
17694 Ada.Text_IO
17695 @item
17696 Ada.Text_IO.Complex_IO
17697 @item
17698 Ada.Text_IO.Text_Streams
17699 @item
17700 Ada.Wide_Text_IO
17701 @item
17702 Ada.Wide_Text_IO.Complex_IO
17703 @item
17704 Ada.Wide_Text_IO.Text_Streams
17705 @item
17706 Ada.Wide_Wide_Text_IO
17707 @item
17708 Ada.Wide_Wide_Text_IO.Complex_IO
17709 @item
17710 Ada.Wide_Wide_Text_IO.Text_Streams
17711 @item
17712 Ada.Stream_IO
17713 @item
17714 Ada.Sequential_IO
17715 @item
17716 Ada.Direct_IO
17717 @end itemize
17719 @noindent
17720 are implemented using the C
17721 library streams facility; where
17723 @itemize @bullet
17724 @item
17725 All files are opened using @code{fopen}.
17726 @item
17727 All input/output operations use @code{fread}/@code{fwrite}.
17728 @end itemize
17730 @noindent
17731 There is no internal buffering of any kind at the Ada library level. The only
17732 buffering is that provided at the system level in the implementation of the
17733 library routines that support streams. This facilitates shared use of these
17734 streams by mixed language programs. Note though that system level buffering is
17735 explicitly enabled at elaboration of the standard I/O packages and that can
17736 have an impact on mixed language programs, in particular those using I/O before
17737 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17738 the Ada elaboration routine before performing any I/O or when impractical,
17739 flush the common I/O streams and in particular Standard_Output before
17740 elaborating the Ada code.
17742 @node FORM Strings
17743 @section FORM Strings
17745 @noindent
17746 The format of a FORM string in GNAT is:
17748 @smallexample
17749 "keyword=value,keyword=value,@dots{},keyword=value"
17750 @end smallexample
17752 @noindent
17753 where letters may be in upper or lower case, and there are no spaces
17754 between values.  The order of the entries is not important.  Currently
17755 the following keywords defined.
17757 @smallexample
17758 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
17759 SHARED=[YES|NO]
17760 WCEM=[n|h|u|s|e|8|b]
17761 ENCODING=[UTF8|8BITS]
17762 @end smallexample
17764 @noindent
17765 The use of these parameters is described later in this section. If an
17766 unrecognized keyword appears in a form string, it is silently ignored
17767 and not considered invalid.
17769 @noindent
17770 For OpenVMS additional FORM string keywords are available for use with
17771 RMS services.  The syntax is:
17773 @smallexample
17774 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17775 @end smallexample
17777 @noindent
17778 The following RMS keywords and values are currently defined:
17780 @smallexample
17781 Context=Force_Stream_Mode|Force_Record_Mode
17782 @end smallexample
17784 @noindent
17785 VMS RMS keys are silently ignored on non-VMS systems.  On OpenVMS
17786 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17788 @node Direct_IO
17789 @section Direct_IO
17791 @noindent
17792 Direct_IO can only be instantiated for definite types.  This is a
17793 restriction of the Ada language, which means that the records are fixed
17794 length (the length being determined by @code{@var{type}'Size}, rounded
17795 up to the next storage unit boundary if necessary).
17797 The records of a Direct_IO file are simply written to the file in index
17798 sequence, with the first record starting at offset zero, and subsequent
17799 records following.  There is no control information of any kind.  For
17800 example, if 32-bit integers are being written, each record takes
17801 4-bytes, so the record at index @var{K} starts at offset
17802 (@var{K}@minus{}1)*4.
17804 There is no limit on the size of Direct_IO files, they are expanded as
17805 necessary to accommodate whatever records are written to the file.
17807 @node Sequential_IO
17808 @section Sequential_IO
17810 @noindent
17811 Sequential_IO may be instantiated with either a definite (constrained)
17812 or indefinite (unconstrained) type.
17814 For the definite type case, the elements written to the file are simply
17815 the memory images of the data values with no control information of any
17816 kind.  The resulting file should be read using the same type, no validity
17817 checking is performed on input.
17819 For the indefinite type case, the elements written consist of two
17820 parts.  First is the size of the data item, written as the memory image
17821 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17822 the data value.  The resulting file can only be read using the same
17823 (unconstrained) type.  Normal assignment checks are performed on these
17824 read operations, and if these checks fail, @code{Data_Error} is
17825 raised.  In particular, in the array case, the lengths must match, and in
17826 the variant record case, if the variable for a particular read operation
17827 is constrained, the discriminants must match.
17829 Note that it is not possible to use Sequential_IO to write variable
17830 length array items, and then read the data back into different length
17831 arrays.  For example, the following will raise @code{Data_Error}:
17833 @smallexample @c ada
17834  package IO is new Sequential_IO (String);
17835  F : IO.File_Type;
17836  S : String (1..4);
17837  @dots{}
17838  IO.Create (F)
17839  IO.Write (F, "hello!")
17840  IO.Reset (F, Mode=>In_File);
17841  IO.Read (F, S);
17842  Put_Line (S);
17844 @end smallexample
17846 @noindent
17847 On some Ada implementations, this will print @code{hell}, but the program is
17848 clearly incorrect, since there is only one element in the file, and that
17849 element is the string @code{hello!}.
17851 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17852 using Stream_IO, and this is the preferred mechanism.  In particular, the
17853 above program fragment rewritten to use Stream_IO will work correctly.
17855 @node Text_IO
17856 @section Text_IO
17858 @noindent
17859 Text_IO files consist of a stream of characters containing the following
17860 special control characters:
17862 @smallexample
17863 LF (line feed, 16#0A#) Line Mark
17864 FF (form feed, 16#0C#) Page Mark
17865 @end smallexample
17867 @noindent
17868 A canonical Text_IO file is defined as one in which the following
17869 conditions are met:
17871 @itemize @bullet
17872 @item
17873 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17874 of the line.
17876 @item
17877 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17878 end of a page and consequently can appear only immediately following a
17879 @code{LF} (line mark) character.
17881 @item
17882 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17883 (line mark, page mark).  In the former case, the page mark is implicitly
17884 assumed to be present.
17885 @end itemize
17887 @noindent
17888 A file written using Text_IO will be in canonical form provided that no
17889 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17890 or @code{Put_Line}.  There will be no @code{FF} character at the end of
17891 the file unless an explicit @code{New_Page} operation was performed
17892 before closing the file.
17894 A canonical Text_IO file that is a regular file (i.e., not a device or a
17895 pipe) can be read using any of the routines in Text_IO@.  The
17896 semantics in this case will be exactly as defined in the Ada Reference
17897 Manual, and all the routines in Text_IO are fully implemented.
17899 A text file that does not meet the requirements for a canonical Text_IO
17900 file has one of the following:
17902 @itemize @bullet
17903 @item
17904 The file contains @code{FF} characters not immediately following a
17905 @code{LF} character.
17907 @item
17908 The file contains @code{LF} or @code{FF} characters written by
17909 @code{Put} or @code{Put_Line}, which are not logically considered to be
17910 line marks or page marks.
17912 @item
17913 The file ends in a character other than @code{LF} or @code{FF},
17914 i.e.@: there is no explicit line mark or page mark at the end of the file.
17915 @end itemize
17917 @noindent
17918 Text_IO can be used to read such non-standard text files but subprograms
17919 to do with line or page numbers do not have defined meanings.  In
17920 particular, a @code{FF} character that does not follow a @code{LF}
17921 character may or may not be treated as a page mark from the point of
17922 view of page and line numbering.  Every @code{LF} character is considered
17923 to end a line, and there is an implied @code{LF} character at the end of
17924 the file.
17926 @menu
17927 * Text_IO Stream Pointer Positioning::
17928 * Text_IO Reading and Writing Non-Regular Files::
17929 * Get_Immediate::
17930 * Treating Text_IO Files as Streams::
17931 * Text_IO Extensions::
17932 * Text_IO Facilities for Unbounded Strings::
17933 @end menu
17935 @node Text_IO Stream Pointer Positioning
17936 @subsection Stream Pointer Positioning
17938 @noindent
17939 @code{Ada.Text_IO} has a definition of current position for a file that
17940 is being read.  No internal buffering occurs in Text_IO, and usually the
17941 physical position in the stream used to implement the file corresponds
17942 to this logical position defined by Text_IO@.  There are two exceptions:
17944 @itemize @bullet
17945 @item
17946 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17947 is positioned past the @code{LF} (line mark) that precedes the page
17948 mark.  Text_IO maintains an internal flag so that subsequent read
17949 operations properly handle the logical position which is unchanged by
17950 the @code{End_Of_Page} call.
17952 @item
17953 After a call to @code{End_Of_File} that returns @code{True}, if the
17954 Text_IO file was positioned before the line mark at the end of file
17955 before the call, then the logical position is unchanged, but the stream
17956 is physically positioned right at the end of file (past the line mark,
17957 and past a possible page mark following the line mark.  Again Text_IO
17958 maintains internal flags so that subsequent read operations properly
17959 handle the logical position.
17960 @end itemize
17962 @noindent
17963 These discrepancies have no effect on the observable behavior of
17964 Text_IO, but if a single Ada stream is shared between a C program and
17965 Ada program, or shared (using @samp{shared=yes} in the form string)
17966 between two Ada files, then the difference may be observable in some
17967 situations.
17969 @node Text_IO Reading and Writing Non-Regular Files
17970 @subsection Reading and Writing Non-Regular Files
17972 @noindent
17973 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
17974 can be used for reading and writing.  Writing is not affected and the
17975 sequence of characters output is identical to the normal file case, but
17976 for reading, the behavior of Text_IO is modified to avoid undesirable
17977 look-ahead as follows:
17979 An input file that is not a regular file is considered to have no page
17980 marks.  Any @code{Ascii.FF} characters (the character normally used for a
17981 page mark) appearing in the file are considered to be data
17982 characters.  In particular:
17984 @itemize @bullet
17985 @item
17986 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17987 following a line mark.  If a page mark appears, it will be treated as a
17988 data character.
17990 @item
17991 This avoids the need to wait for an extra character to be typed or
17992 entered from the pipe to complete one of these operations.
17994 @item
17995 @code{End_Of_Page} always returns @code{False}
17997 @item
17998 @code{End_Of_File} will return @code{False} if there is a page mark at
17999 the end of the file.
18000 @end itemize
18002 @noindent
18003 Output to non-regular files is the same as for regular files.  Page marks
18004 may be written to non-regular files using @code{New_Page}, but as noted
18005 above they will not be treated as page marks on input if the output is
18006 piped to another Ada program.
18008 Another important discrepancy when reading non-regular files is that the end
18009 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
18010 pressing the @key{EOT} key,
18011 then end of file
18012 is signaled once (i.e.@: the test @code{End_Of_File}
18013 will yield @code{True}, or a read will
18014 raise @code{End_Error}), but then reading can resume
18015 to read data past that end of
18016 file indication, until another end of file indication is entered.
18018 @node Get_Immediate
18019 @subsection Get_Immediate
18020 @cindex Get_Immediate
18022 @noindent
18023 Get_Immediate returns the next character (including control characters)
18024 from the input file.  In particular, Get_Immediate will return LF or FF
18025 characters used as line marks or page marks.  Such operations leave the
18026 file positioned past the control character, and it is thus not treated
18027 as having its normal function.  This means that page, line and column
18028 counts after this kind of Get_Immediate call are set as though the mark
18029 did not occur.  In the case where a Get_Immediate leaves the file
18030 positioned between the line mark and page mark (which is not normally
18031 possible), it is undefined whether the FF character will be treated as a
18032 page mark.
18034 @node Treating Text_IO Files as Streams
18035 @subsection Treating Text_IO Files as Streams
18036 @cindex Stream files
18038 @noindent
18039 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
18040 as a stream.  Data written to a Text_IO file in this stream mode is
18041 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
18042 16#0C# (@code{FF}), the resulting file may have non-standard
18043 format.  Similarly if read operations are used to read from a Text_IO
18044 file treated as a stream, then @code{LF} and @code{FF} characters may be
18045 skipped and the effect is similar to that described above for
18046 @code{Get_Immediate}.
18048 @node Text_IO Extensions
18049 @subsection Text_IO Extensions
18050 @cindex Text_IO extensions
18052 @noindent
18053 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
18054 to the standard @code{Text_IO} package:
18056 @itemize @bullet
18057 @item function File_Exists (Name : String) return Boolean;
18058 Determines if a file of the given name exists.
18060 @item function Get_Line return String;
18061 Reads a string from the standard input file.  The value returned is exactly
18062 the length of the line that was read.
18064 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
18065 Similar, except that the parameter File specifies the file from which
18066 the string is to be read.
18068 @end itemize
18070 @node Text_IO Facilities for Unbounded Strings
18071 @subsection Text_IO Facilities for Unbounded Strings
18072 @cindex Text_IO for unbounded strings
18073 @cindex Unbounded_String, Text_IO operations
18075 @noindent
18076 The package @code{Ada.Strings.Unbounded.Text_IO}
18077 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
18078 subprograms useful for Text_IO operations on unbounded strings:
18080 @itemize @bullet
18082 @item function Get_Line (File : File_Type) return Unbounded_String;
18083 Reads a line from the specified file
18084 and returns the result as an unbounded string.
18086 @item procedure Put (File : File_Type; U : Unbounded_String);
18087 Writes the value of the given unbounded string to the specified file
18088 Similar to the effect of
18089 @code{Put (To_String (U))} except that an extra copy is avoided.
18091 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
18092 Writes the value of the given unbounded string to the specified file,
18093 followed by a @code{New_Line}.
18094 Similar to the effect of @code{Put_Line (To_String (U))} except
18095 that an extra copy is avoided.
18096 @end itemize
18098 @noindent
18099 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
18100 and is optional.  If the parameter is omitted, then the standard input or
18101 output file is referenced as appropriate.
18103 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
18104 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
18105 @code{Wide_Text_IO} functionality for unbounded wide strings.
18107 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
18108 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
18109 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
18111 @node Wide_Text_IO
18112 @section Wide_Text_IO
18114 @noindent
18115 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
18116 both input and output files may contain special sequences that represent
18117 wide character values.  The encoding scheme for a given file may be
18118 specified using a FORM parameter:
18120 @smallexample
18121 WCEM=@var{x}
18122 @end smallexample
18124 @noindent
18125 as part of the FORM string (WCEM = wide character encoding method),
18126 where @var{x} is one of the following characters
18128 @table @samp
18129 @item h
18130 Hex ESC encoding
18131 @item u
18132 Upper half encoding
18133 @item s
18134 Shift-JIS encoding
18135 @item e
18136 EUC Encoding
18137 @item 8
18138 UTF-8 encoding
18139 @item b
18140 Brackets encoding
18141 @end table
18143 @noindent
18144 The encoding methods match those that
18145 can be used in a source
18146 program, but there is no requirement that the encoding method used for
18147 the source program be the same as the encoding method used for files,
18148 and different files may use different encoding methods.
18150 The default encoding method for the standard files, and for opened files
18151 for which no WCEM parameter is given in the FORM string matches the
18152 wide character encoding specified for the main program (the default
18153 being brackets encoding if no coding method was specified with -gnatW).
18155 @table @asis
18156 @item Hex Coding
18157 In this encoding, a wide character is represented by a five character
18158 sequence:
18160 @smallexample
18161 ESC a b c d
18162 @end smallexample
18164 @noindent
18165 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
18166 characters (using upper case letters) of the wide character code.  For
18167 example, ESC A345 is used to represent the wide character with code
18168 16#A345#.  This scheme is compatible with use of the full
18169 @code{Wide_Character} set.
18171 @item Upper Half Coding
18172 The wide character with encoding 16#abcd#, where the upper bit is on
18173 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
18174 16#cd#.  The second byte may never be a format control character, but is
18175 not required to be in the upper half.  This method can be also used for
18176 shift-JIS or EUC where the internal coding matches the external coding.
18178 @item Shift JIS Coding
18179 A wide character is represented by a two character sequence 16#ab# and
18180 16#cd#, with the restrictions described for upper half encoding as
18181 described above.  The internal character code is the corresponding JIS
18182 character according to the standard algorithm for Shift-JIS
18183 conversion.  Only characters defined in the JIS code set table can be
18184 used with this encoding method.
18186 @item EUC Coding
18187 A wide character is represented by a two character sequence 16#ab# and
18188 16#cd#, with both characters being in the upper half.  The internal
18189 character code is the corresponding JIS character according to the EUC
18190 encoding algorithm.  Only characters defined in the JIS code set table
18191 can be used with this encoding method.
18193 @item UTF-8 Coding
18194 A wide character is represented using
18195 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18196 10646-1/Am.2.  Depending on the character value, the representation
18197 is a one, two, or three byte sequence:
18199 @smallexample
18200 16#0000#-16#007f#: 2#0xxxxxxx#
18201 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
18202 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18203 @end smallexample
18205 @noindent
18206 where the @var{xxx} bits correspond to the left-padded bits of the
18207 16-bit character value.  Note that all lower half ASCII characters
18208 are represented as ASCII bytes and all upper half characters and
18209 other wide characters are represented as sequences of upper-half
18210 (The full UTF-8 scheme allows for encoding 31-bit characters as
18211 6-byte sequences, but in this implementation, all UTF-8 sequences
18212 of four or more bytes length will raise a Constraint_Error, as
18213 will all invalid UTF-8 sequences.)
18215 @item Brackets Coding
18216 In this encoding, a wide character is represented by the following eight
18217 character sequence:
18219 @smallexample
18220 [ " a b c d " ]
18221 @end smallexample
18223 @noindent
18224 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
18225 characters (using uppercase letters) of the wide character code.  For
18226 example, @code{["A345"]} is used to represent the wide character with code
18227 @code{16#A345#}.
18228 This scheme is compatible with use of the full Wide_Character set.
18229 On input, brackets coding can also be used for upper half characters,
18230 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18231 is only used for wide characters with a code greater than @code{16#FF#}.
18233 Note that brackets coding is not normally used in the context of
18234 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
18235 a portable way of encoding source files. In the context of Wide_Text_IO
18236 or Wide_Wide_Text_IO, it can only be used if the file does not contain
18237 any instance of the left bracket character other than to encode wide
18238 character values using the brackets encoding method. In practice it is
18239 expected that some standard wide character encoding method such
18240 as UTF-8 will be used for text input output.
18242 If brackets notation is used, then any occurrence of a left bracket
18243 in the input file which is not the start of a valid wide character
18244 sequence will cause Constraint_Error to be raised. It is possible to
18245 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
18246 input will interpret this as a left bracket.
18248 However, when a left bracket is output, it will be output as a left bracket
18249 and not as ["5B"]. We make this decision because for normal use of
18250 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
18251 brackets. For example, if we write:
18253 @smallexample
18254    Put_Line ("Start of output [first run]");
18255 @end smallexample
18257 @noindent
18258 we really do not want to have the left bracket in this message clobbered so
18259 that the output reads:
18261 @smallexample
18262    Start of output ["5B"]first run]
18263 @end smallexample
18265 @noindent
18266 In practice brackets encoding is reasonably useful for normal Put_Line use
18267 since we won't get confused between left brackets and wide character
18268 sequences in the output. But for input, or when files are written out
18269 and read back in, it really makes better sense to use one of the standard
18270 encoding methods such as UTF-8.
18272 @end table
18274 @noindent
18275 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
18276 not all wide character
18277 values can be represented.  An attempt to output a character that cannot
18278 be represented using the encoding scheme for the file causes
18279 Constraint_Error to be raised.  An invalid wide character sequence on
18280 input also causes Constraint_Error to be raised.
18282 @menu
18283 * Wide_Text_IO Stream Pointer Positioning::
18284 * Wide_Text_IO Reading and Writing Non-Regular Files::
18285 @end menu
18287 @node Wide_Text_IO Stream Pointer Positioning
18288 @subsection Stream Pointer Positioning
18290 @noindent
18291 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18292 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18293 case:
18295 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
18296 normal lower ASCII set (i.e.@: a character in the range:
18298 @smallexample @c ada
18299 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
18300 @end smallexample
18302 @noindent
18303 then although the logical position of the file pointer is unchanged by
18304 the @code{Look_Ahead} call, the stream is physically positioned past the
18305 wide character sequence.  Again this is to avoid the need for buffering
18306 or backup, and all @code{Wide_Text_IO} routines check the internal
18307 indication that this situation has occurred so that this is not visible
18308 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
18309 can be observed if the wide text file shares a stream with another file.
18311 @node Wide_Text_IO Reading and Writing Non-Regular Files
18312 @subsection Reading and Writing Non-Regular Files
18314 @noindent
18315 As in the case of Text_IO, when a non-regular file is read, it is
18316 assumed that the file contains no page marks (any form characters are
18317 treated as data characters), and @code{End_Of_Page} always returns
18318 @code{False}.  Similarly, the end of file indication is not sticky, so
18319 it is possible to read beyond an end of file.
18321 @node Wide_Wide_Text_IO
18322 @section Wide_Wide_Text_IO
18324 @noindent
18325 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
18326 both input and output files may contain special sequences that represent
18327 wide wide character values.  The encoding scheme for a given file may be
18328 specified using a FORM parameter:
18330 @smallexample
18331 WCEM=@var{x}
18332 @end smallexample
18334 @noindent
18335 as part of the FORM string (WCEM = wide character encoding method),
18336 where @var{x} is one of the following characters
18338 @table @samp
18339 @item h
18340 Hex ESC encoding
18341 @item u
18342 Upper half encoding
18343 @item s
18344 Shift-JIS encoding
18345 @item e
18346 EUC Encoding
18347 @item 8
18348 UTF-8 encoding
18349 @item b
18350 Brackets encoding
18351 @end table
18353 @noindent
18354 The encoding methods match those that
18355 can be used in a source
18356 program, but there is no requirement that the encoding method used for
18357 the source program be the same as the encoding method used for files,
18358 and different files may use different encoding methods.
18360 The default encoding method for the standard files, and for opened files
18361 for which no WCEM parameter is given in the FORM string matches the
18362 wide character encoding specified for the main program (the default
18363 being brackets encoding if no coding method was specified with -gnatW).
18365 @table @asis
18367 @item UTF-8 Coding
18368 A wide character is represented using
18369 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18370 10646-1/Am.2.  Depending on the character value, the representation
18371 is a one, two, three, or four byte sequence:
18373 @smallexample
18374 16#000000#-16#00007f#: 2#0xxxxxxx#
18375 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
18376 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18377 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
18378 @end smallexample
18380 @noindent
18381 where the @var{xxx} bits correspond to the left-padded bits of the
18382 21-bit character value.  Note that all lower half ASCII characters
18383 are represented as ASCII bytes and all upper half characters and
18384 other wide characters are represented as sequences of upper-half
18385 characters.
18387 @item Brackets Coding
18388 In this encoding, a wide wide character is represented by the following eight
18389 character sequence if is in wide character range
18391 @smallexample
18392 [ " a b c d " ]
18393 @end smallexample
18395 and by the following ten character sequence if not
18397 @smallexample
18398 [ " a b c d e f " ]
18399 @end smallexample
18401 @noindent
18402 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
18403 are the four or six hexadecimal
18404 characters (using uppercase letters) of the wide wide character code.  For
18405 example, @code{["01A345"]} is used to represent the wide wide character
18406 with code @code{16#01A345#}.
18408 This scheme is compatible with use of the full Wide_Wide_Character set.
18409 On input, brackets coding can also be used for upper half characters,
18410 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
18411 is only used for wide characters with a code greater than @code{16#FF#}.
18413 @end table
18415 @noindent
18416 If is also possible to use the other Wide_Character encoding methods,
18417 such as Shift-JIS, but the other schemes cannot support the full range
18418 of wide wide characters.
18419 An attempt to output a character that cannot
18420 be represented using the encoding scheme for the file causes
18421 Constraint_Error to be raised.  An invalid wide character sequence on
18422 input also causes Constraint_Error to be raised.
18424 @menu
18425 * Wide_Wide_Text_IO Stream Pointer Positioning::
18426 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
18427 @end menu
18429 @node Wide_Wide_Text_IO Stream Pointer Positioning
18430 @subsection Stream Pointer Positioning
18432 @noindent
18433 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18434 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
18435 case:
18437 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
18438 normal lower ASCII set (i.e.@: a character in the range:
18440 @smallexample @c ada
18441 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
18442 @end smallexample
18444 @noindent
18445 then although the logical position of the file pointer is unchanged by
18446 the @code{Look_Ahead} call, the stream is physically positioned past the
18447 wide character sequence.  Again this is to avoid the need for buffering
18448 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
18449 indication that this situation has occurred so that this is not visible
18450 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
18451 can be observed if the wide text file shares a stream with another file.
18453 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
18454 @subsection Reading and Writing Non-Regular Files
18456 @noindent
18457 As in the case of Text_IO, when a non-regular file is read, it is
18458 assumed that the file contains no page marks (any form characters are
18459 treated as data characters), and @code{End_Of_Page} always returns
18460 @code{False}.  Similarly, the end of file indication is not sticky, so
18461 it is possible to read beyond an end of file.
18463 @node Stream_IO
18464 @section Stream_IO
18466 @noindent
18467 A stream file is a sequence of bytes, where individual elements are
18468 written to the file as described in the Ada Reference Manual.  The type
18469 @code{Stream_Element} is simply a byte.  There are two ways to read or
18470 write a stream file.
18472 @itemize @bullet
18473 @item
18474 The operations @code{Read} and @code{Write} directly read or write a
18475 sequence of stream elements with no control information.
18477 @item
18478 The stream attributes applied to a stream file transfer data in the
18479 manner described for stream attributes.
18480 @end itemize
18482 @node Text Translation
18483 @section Text Translation
18485 @noindent
18486 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18487 passed to Text_IO.Create and Text_IO.Open. @samp{Text_Translation=@var{xxx}}
18488 has no effect on Unix systems. Possible values are:
18490 @itemize @bullet
18492 @item
18493 @samp{@var{Yes} or @var{Text}} is the default, which means to
18494 translate LF to/from CR/LF on Windows systems.
18496 @samp{@var{No}} disables this translation; i.e. it
18497 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18498 may be used to create Unix-style files on
18499 Windows.
18501 @item
18502 @samp{@var{wtext}} translation enabled in Unicode mode.
18503 (corresponds to _O_WTEXT).
18505 @item
18506 @samp{@var{u8text}} translation enabled in Unicode UTF-8 mode.
18507 (corresponds to O_U8TEXT).
18509 @item
18510 @samp{@var{u16text}} translation enabled in Unicode UTF-16
18511 mode. (corresponds to_O_U16TEXT).
18513 @end itemize
18517 @node Shared Files
18518 @section Shared Files
18520 @noindent
18521 Section A.14 of the Ada Reference Manual allows implementations to
18522 provide a wide variety of behavior if an attempt is made to access the
18523 same external file with two or more internal files.
18525 To provide a full range of functionality, while at the same time
18526 minimizing the problems of portability caused by this implementation
18527 dependence, GNAT handles file sharing as follows:
18529 @itemize @bullet
18530 @item
18531 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18532 to open two or more files with the same full name is considered an error
18533 and is not supported.  The exception @code{Use_Error} will be
18534 raised.  Note that a file that is not explicitly closed by the program
18535 remains open until the program terminates.
18537 @item
18538 If the form parameter @samp{shared=no} appears in the form string, the
18539 file can be opened or created with its own separate stream identifier,
18540 regardless of whether other files sharing the same external file are
18541 opened.  The exact effect depends on how the C stream routines handle
18542 multiple accesses to the same external files using separate streams.
18544 @item
18545 If the form parameter @samp{shared=yes} appears in the form string for
18546 each of two or more files opened using the same full name, the same
18547 stream is shared between these files, and the semantics are as described
18548 in Ada Reference Manual, Section A.14.
18549 @end itemize
18551 @noindent
18552 When a program that opens multiple files with the same name is ported
18553 from another Ada compiler to GNAT, the effect will be that
18554 @code{Use_Error} is raised.
18556 The documentation of the original compiler and the documentation of the
18557 program should then be examined to determine if file sharing was
18558 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18559 and @code{Create} calls as required.
18561 When a program is ported from GNAT to some other Ada compiler, no
18562 special attention is required unless the @samp{shared=@var{xxx}} form
18563 parameter is used in the program.  In this case, you must examine the
18564 documentation of the new compiler to see if it supports the required
18565 file sharing semantics, and form strings modified appropriately.  Of
18566 course it may be the case that the program cannot be ported if the
18567 target compiler does not support the required functionality.  The best
18568 approach in writing portable code is to avoid file sharing (and hence
18569 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18570 completely.
18572 One common use of file sharing in Ada 83 is the use of instantiations of
18573 Sequential_IO on the same file with different types, to achieve
18574 heterogeneous input-output.  Although this approach will work in GNAT if
18575 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18576 for this purpose (using the stream attributes)
18578 @node Filenames encoding
18579 @section Filenames encoding
18581 @noindent
18582 An encoding form parameter can be used to specify the filename
18583 encoding @samp{encoding=@var{xxx}}.
18585 @itemize @bullet
18586 @item
18587 If the form parameter @samp{encoding=utf8} appears in the form string, the
18588 filename must be encoded in UTF-8.
18590 @item
18591 If the form parameter @samp{encoding=8bits} appears in the form
18592 string, the filename must be a standard 8bits string.
18593 @end itemize
18595 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18596 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18597 variable. And if not set @samp{utf8} is assumed.
18599 @table @samp
18600 @item CP_ACP
18601 The current system Windows ANSI code page.
18602 @item CP_UTF8
18603 UTF-8 encoding
18604 @end table
18606 This encoding form parameter is only supported on the Windows
18607 platform. On the other Operating Systems the run-time is supporting
18608 UTF-8 natively.
18610 @node File content encoding
18611 @section File content encoding
18613 @noindent
18614 For text files it is possible to specify the encoding to use. This is
18615 controlled by the by the @samp{GNAT_CCS_ENCODING} environment
18616 variable. And if not set @samp{TEXT} is assumed.
18618 The possible values are those supported on Windows:
18620 @table @samp
18621 @item TEXT
18622 Translated text mode
18623 @item WTEXT
18624 Translated unicode encoding
18625 @item U16TEXT
18626 Unicode 16-bit encoding
18627 @item U8TEXT
18628 Unicode 8-bit encoding
18629 @end table
18631 This encoding is only supported on the Windows platform.
18633 @node Open Modes
18634 @section Open Modes
18636 @noindent
18637 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18638 using the mode shown in the following table:
18640 @sp 2
18641 @center @code{Open} and @code{Create} Call Modes
18642 @smallexample
18643                                @b{OPEN }           @b{CREATE}
18644 Append_File                    "r+"             "w+"
18645 In_File                        "r"              "w+"
18646 Out_File (Direct_IO)           "r+"             "w"
18647 Out_File (all other cases)     "w"              "w"
18648 Inout_File                     "r+"             "w+"
18649 @end smallexample
18651 @noindent
18652 If text file translation is required, then either @samp{b} or @samp{t}
18653 is added to the mode, depending on the setting of Text.  Text file
18654 translation refers to the mapping of CR/LF sequences in an external file
18655 to LF characters internally.  This mapping only occurs in DOS and
18656 DOS-like systems, and is not relevant to other systems.
18658 A special case occurs with Stream_IO@.  As shown in the above table, the
18659 file is initially opened in @samp{r} or @samp{w} mode for the
18660 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
18661 subsequently requires switching from reading to writing or vice-versa,
18662 then the file is reopened in @samp{r+} mode to permit the required operation.
18664 @node Operations on C Streams
18665 @section Operations on C Streams
18666 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18667 access to the C library functions for operations on C streams:
18669 @smallexample @c adanocomment
18670 package Interfaces.C_Streams is
18671   -- Note: the reason we do not use the types that are in
18672   -- Interfaces.C is that we want to avoid dragging in the
18673   -- code in this unit if possible.
18674   subtype chars is System.Address;
18675   -- Pointer to null-terminated array of characters
18676   subtype FILEs is System.Address;
18677   -- Corresponds to the C type FILE*
18678   subtype voids is System.Address;
18679   -- Corresponds to the C type void*
18680   subtype int is Integer;
18681   subtype long is Long_Integer;
18682   -- Note: the above types are subtypes deliberately, and it
18683   -- is part of this spec that the above correspondences are
18684   -- guaranteed.  This means that it is legitimate to, for
18685   -- example, use Integer instead of int.  We provide these
18686   -- synonyms for clarity, but in some cases it may be
18687   -- convenient to use the underlying types (for example to
18688   -- avoid an unnecessary dependency of a spec on the spec
18689   -- of this unit).
18690   type size_t is mod 2 ** Standard'Address_Size;
18691   NULL_Stream : constant FILEs;
18692   -- Value returned (NULL in C) to indicate an
18693   -- fdopen/fopen/tmpfile error
18694   ----------------------------------
18695   -- Constants Defined in stdio.h --
18696   ----------------------------------
18697   EOF : constant int;
18698   -- Used by a number of routines to indicate error or
18699   -- end of file
18700   IOFBF : constant int;
18701   IOLBF : constant int;
18702   IONBF : constant int;
18703   -- Used to indicate buffering mode for setvbuf call
18704   SEEK_CUR : constant int;
18705   SEEK_END : constant int;
18706   SEEK_SET : constant int;
18707   -- Used to indicate origin for fseek call
18708   function stdin return FILEs;
18709   function stdout return FILEs;
18710   function stderr return FILEs;
18711   -- Streams associated with standard files
18712   --------------------------
18713   -- Standard C functions --
18714   --------------------------
18715   -- The functions selected below are ones that are
18716   -- available in UNIX (but not necessarily in ANSI C).
18717   -- These are very thin interfaces
18718   -- which copy exactly the C headers.  For more
18719   -- documentation on these functions, see the Microsoft C
18720   -- "Run-Time Library Reference" (Microsoft Press, 1990,
18721   -- ISBN 1-55615-225-6), which includes useful information
18722   -- on system compatibility.
18723   procedure clearerr (stream : FILEs);
18724   function fclose (stream : FILEs) return int;
18725   function fdopen (handle : int; mode : chars) return FILEs;
18726   function feof (stream : FILEs) return int;
18727   function ferror (stream : FILEs) return int;
18728   function fflush (stream : FILEs) return int;
18729   function fgetc (stream : FILEs) return int;
18730   function fgets (strng : chars; n : int; stream : FILEs)
18731       return chars;
18732   function fileno (stream : FILEs) return int;
18733   function fopen (filename : chars; Mode : chars)
18734       return FILEs;
18735   -- Note: to maintain target independence, use
18736   -- text_translation_required, a boolean variable defined in
18737   -- a-sysdep.c to deal with the target dependent text
18738   -- translation requirement.  If this variable is set,
18739   -- then  b/t should be appended to the standard mode
18740   -- argument to set the text translation mode off or on
18741   -- as required.
18742   function fputc (C : int; stream : FILEs) return int;
18743   function fputs (Strng : chars; Stream : FILEs) return int;
18744   function fread
18745      (buffer : voids;
18746       size : size_t;
18747       count : size_t;
18748       stream : FILEs)
18749       return size_t;
18750   function freopen
18751      (filename : chars;
18752       mode : chars;
18753       stream : FILEs)
18754       return FILEs;
18755   function fseek
18756      (stream : FILEs;
18757       offset : long;
18758       origin : int)
18759       return int;
18760   function ftell (stream : FILEs) return long;
18761   function fwrite
18762      (buffer : voids;
18763       size : size_t;
18764       count : size_t;
18765       stream : FILEs)
18766       return size_t;
18767   function isatty (handle : int) return int;
18768   procedure mktemp (template : chars);
18769   -- The return value (which is just a pointer to template)
18770   -- is discarded
18771   procedure rewind (stream : FILEs);
18772   function rmtmp return int;
18773   function setvbuf
18774      (stream : FILEs;
18775       buffer : chars;
18776       mode : int;
18777       size : size_t)
18778       return int;
18780   function tmpfile return FILEs;
18781   function ungetc (c : int; stream : FILEs) return int;
18782   function unlink (filename : chars) return int;
18783   ---------------------
18784   -- Extra functions --
18785   ---------------------
18786   -- These functions supply slightly thicker bindings than
18787   -- those above.  They are derived from functions in the
18788   -- C Run-Time Library, but may do a bit more work than
18789   -- just directly calling one of the Library functions.
18790   function is_regular_file (handle : int) return int;
18791   -- Tests if given handle is for a regular file (result 1)
18792   -- or for a non-regular file (pipe or device, result 0).
18793   ---------------------------------
18794   -- Control of Text/Binary Mode --
18795   ---------------------------------
18796   -- If text_translation_required is true, then the following
18797   -- functions may be used to dynamically switch a file from
18798   -- binary to text mode or vice versa.  These functions have
18799   -- no effect if text_translation_required is false (i.e.@: in
18800   -- normal UNIX mode).  Use fileno to get a stream handle.
18801   procedure set_binary_mode (handle : int);
18802   procedure set_text_mode (handle : int);
18803   ----------------------------
18804   -- Full Path Name support --
18805   ----------------------------
18806   procedure full_name (nam : chars; buffer : chars);
18807   -- Given a NUL terminated string representing a file
18808   -- name, returns in buffer a NUL terminated string
18809   -- representing the full path name for the file name.
18810   -- On systems where it is relevant the   drive is also
18811   -- part of the full path name.  It is the responsibility
18812   -- of the caller to pass an actual parameter for buffer
18813   -- that is big enough for any full path name.  Use
18814   -- max_path_len given below as the size of buffer.
18815   max_path_len : integer;
18816   -- Maximum length of an allowable full path name on the
18817   -- system, including a terminating NUL character.
18818 end Interfaces.C_Streams;
18819 @end smallexample
18821 @node Interfacing to C Streams
18822 @section Interfacing to C Streams
18824 @noindent
18825 The packages in this section permit interfacing Ada files to C Stream
18826 operations.
18828 @smallexample @c ada
18829  with Interfaces.C_Streams;
18830  package Ada.Sequential_IO.C_Streams is
18831     function C_Stream (F : File_Type)
18832        return Interfaces.C_Streams.FILEs;
18833     procedure Open
18834       (File : in out File_Type;
18835        Mode : in File_Mode;
18836        C_Stream : in Interfaces.C_Streams.FILEs;
18837        Form : in String := "");
18838  end Ada.Sequential_IO.C_Streams;
18840   with Interfaces.C_Streams;
18841   package Ada.Direct_IO.C_Streams is
18842      function C_Stream (F : File_Type)
18843         return Interfaces.C_Streams.FILEs;
18844      procedure Open
18845        (File : in out File_Type;
18846         Mode : in File_Mode;
18847         C_Stream : in Interfaces.C_Streams.FILEs;
18848         Form : in String := "");
18849   end Ada.Direct_IO.C_Streams;
18851   with Interfaces.C_Streams;
18852   package Ada.Text_IO.C_Streams is
18853      function C_Stream (F : File_Type)
18854         return Interfaces.C_Streams.FILEs;
18855      procedure Open
18856        (File : in out File_Type;
18857         Mode : in File_Mode;
18858         C_Stream : in Interfaces.C_Streams.FILEs;
18859         Form : in String := "");
18860   end Ada.Text_IO.C_Streams;
18862   with Interfaces.C_Streams;
18863   package Ada.Wide_Text_IO.C_Streams is
18864      function C_Stream (F : File_Type)
18865         return Interfaces.C_Streams.FILEs;
18866      procedure Open
18867        (File : in out File_Type;
18868         Mode : in File_Mode;
18869         C_Stream : in Interfaces.C_Streams.FILEs;
18870         Form : in String := "");
18871  end Ada.Wide_Text_IO.C_Streams;
18873   with Interfaces.C_Streams;
18874   package Ada.Wide_Wide_Text_IO.C_Streams is
18875      function C_Stream (F : File_Type)
18876         return Interfaces.C_Streams.FILEs;
18877      procedure Open
18878        (File : in out File_Type;
18879         Mode : in File_Mode;
18880         C_Stream : in Interfaces.C_Streams.FILEs;
18881         Form : in String := "");
18882  end Ada.Wide_Wide_Text_IO.C_Streams;
18884  with Interfaces.C_Streams;
18885  package Ada.Stream_IO.C_Streams is
18886     function C_Stream (F : File_Type)
18887        return Interfaces.C_Streams.FILEs;
18888     procedure Open
18889       (File : in out File_Type;
18890        Mode : in File_Mode;
18891        C_Stream : in Interfaces.C_Streams.FILEs;
18892        Form : in String := "");
18893  end Ada.Stream_IO.C_Streams;
18894 @end smallexample
18896 @noindent
18897 In each of these six packages, the @code{C_Stream} function obtains the
18898 @code{FILE} pointer from a currently opened Ada file.  It is then
18899 possible to use the @code{Interfaces.C_Streams} package to operate on
18900 this stream, or the stream can be passed to a C program which can
18901 operate on it directly.  Of course the program is responsible for
18902 ensuring that only appropriate sequences of operations are executed.
18904 One particular use of relevance to an Ada program is that the
18905 @code{setvbuf} function can be used to control the buffering of the
18906 stream used by an Ada file.  In the absence of such a call the standard
18907 default buffering is used.
18909 The @code{Open} procedures in these packages open a file giving an
18910 existing C Stream instead of a file name.  Typically this stream is
18911 imported from a C program, allowing an Ada file to operate on an
18912 existing C file.
18914 @node The GNAT Library
18915 @chapter The GNAT Library
18917 @noindent
18918 The GNAT library contains a number of general and special purpose packages.
18919 It represents functionality that the GNAT developers have found useful, and
18920 which is made available to GNAT users.  The packages described here are fully
18921 supported, and upwards compatibility will be maintained in future releases,
18922 so you can use these facilities with the confidence that the same functionality
18923 will be available in future releases.
18925 The chapter here simply gives a brief summary of the facilities available.
18926 The full documentation is found in the spec file for the package.  The full
18927 sources of these library packages, including both spec and body, are provided
18928 with all GNAT releases.  For example, to find out the full specifications of
18929 the SPITBOL pattern matching capability, including a full tutorial and
18930 extensive examples, look in the @file{g-spipat.ads} file in the library.
18932 For each entry here, the package name (as it would appear in a @code{with}
18933 clause) is given, followed by the name of the corresponding spec file in
18934 parentheses.  The packages are children in four hierarchies, @code{Ada},
18935 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18936 GNAT-specific hierarchy.
18938 Note that an application program should only use packages in one of these
18939 four hierarchies if the package is defined in the Ada Reference Manual,
18940 or is listed in this section of the GNAT Programmers Reference Manual.
18941 All other units should be considered internal implementation units and
18942 should not be directly @code{with}'ed by application code.  The use of
18943 a @code{with} statement that references one of these internal implementation
18944 units makes an application potentially dependent on changes in versions
18945 of GNAT, and will generate a warning message.
18947 @menu
18948 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18949 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18950 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18951 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18952 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18953 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18954 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18955 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18956 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18957 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18958 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18959 * Ada.Command_Line.Environment (a-colien.ads)::
18960 * Ada.Command_Line.Remove (a-colire.ads)::
18961 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18962 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18963 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18964 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18965 * Ada.Exceptions.Traceback (a-exctra.ads)::
18966 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18967 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18968 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18969 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18970 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18971 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18972 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18973 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18974 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18975 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18976 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18977 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18978 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18979 * GNAT.Altivec (g-altive.ads)::
18980 * GNAT.Altivec.Conversions (g-altcon.ads)::
18981 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18982 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18983 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18984 * GNAT.Array_Split (g-arrspl.ads)::
18985 * GNAT.AWK (g-awk.ads)::
18986 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18987 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18988 * GNAT.Bubble_Sort (g-bubsor.ads)::
18989 * GNAT.Bubble_Sort_A (g-busora.ads)::
18990 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18991 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18992 * GNAT.Byte_Swapping (g-bytswa.ads)::
18993 * GNAT.Calendar (g-calend.ads)::
18994 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18995 * GNAT.Case_Util (g-casuti.ads)::
18996 * GNAT.CGI (g-cgi.ads)::
18997 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18998 * GNAT.CGI.Debug (g-cgideb.ads)::
18999 * GNAT.Command_Line (g-comlin.ads)::
19000 * GNAT.Compiler_Version (g-comver.ads)::
19001 * GNAT.Ctrl_C (g-ctrl_c.ads)::
19002 * GNAT.CRC32 (g-crc32.ads)::
19003 * GNAT.Current_Exception (g-curexc.ads)::
19004 * GNAT.Debug_Pools (g-debpoo.ads)::
19005 * GNAT.Debug_Utilities (g-debuti.ads)::
19006 * GNAT.Decode_String (g-decstr.ads)::
19007 * GNAT.Decode_UTF8_String (g-deutst.ads)::
19008 * GNAT.Directory_Operations (g-dirope.ads)::
19009 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
19010 * GNAT.Dynamic_HTables (g-dynhta.ads)::
19011 * GNAT.Dynamic_Tables (g-dyntab.ads)::
19012 * GNAT.Encode_String (g-encstr.ads)::
19013 * GNAT.Encode_UTF8_String (g-enutst.ads)::
19014 * GNAT.Exception_Actions (g-excact.ads)::
19015 * GNAT.Exception_Traces (g-exctra.ads)::
19016 * GNAT.Exceptions (g-except.ads)::
19017 * GNAT.Expect (g-expect.ads)::
19018 * GNAT.Expect.TTY (g-exptty.ads)::
19019 * GNAT.Float_Control (g-flocon.ads)::
19020 * GNAT.Formatted_String (g-forstr.ads)::
19021 * GNAT.Heap_Sort (g-heasor.ads)::
19022 * GNAT.Heap_Sort_A (g-hesora.ads)::
19023 * GNAT.Heap_Sort_G (g-hesorg.ads)::
19024 * GNAT.HTable (g-htable.ads)::
19025 * GNAT.IO (g-io.ads)::
19026 * GNAT.IO_Aux (g-io_aux.ads)::
19027 * GNAT.Lock_Files (g-locfil.ads)::
19028 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
19029 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
19030 * GNAT.MD5 (g-md5.ads)::
19031 * GNAT.Memory_Dump (g-memdum.ads)::
19032 * GNAT.Most_Recent_Exception (g-moreex.ads)::
19033 * GNAT.OS_Lib (g-os_lib.ads)::
19034 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
19035 * GNAT.Random_Numbers (g-rannum.ads)::
19036 * GNAT.Regexp (g-regexp.ads)::
19037 * GNAT.Registry (g-regist.ads)::
19038 * GNAT.Regpat (g-regpat.ads)::
19039 * GNAT.Rewrite_Data (g-rewdat.ads)::
19040 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
19041 * GNAT.Semaphores (g-semaph.ads)::
19042 * GNAT.Serial_Communications (g-sercom.ads)::
19043 * GNAT.SHA1 (g-sha1.ads)::
19044 * GNAT.SHA224 (g-sha224.ads)::
19045 * GNAT.SHA256 (g-sha256.ads)::
19046 * GNAT.SHA384 (g-sha384.ads)::
19047 * GNAT.SHA512 (g-sha512.ads)::
19048 * GNAT.Signals (g-signal.ads)::
19049 * GNAT.Sockets (g-socket.ads)::
19050 * GNAT.Source_Info (g-souinf.ads)::
19051 * GNAT.Spelling_Checker (g-speche.ads)::
19052 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
19053 * GNAT.Spitbol.Patterns (g-spipat.ads)::
19054 * GNAT.Spitbol (g-spitbo.ads)::
19055 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
19056 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
19057 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
19058 * GNAT.SSE (g-sse.ads)::
19059 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
19060 * GNAT.Strings (g-string.ads)::
19061 * GNAT.String_Split (g-strspl.ads)::
19062 * GNAT.Table (g-table.ads)::
19063 * GNAT.Task_Lock (g-tasloc.ads)::
19064 * GNAT.Threads (g-thread.ads)::
19065 * GNAT.Time_Stamp (g-timsta.ads)::
19066 * GNAT.Traceback (g-traceb.ads)::
19067 * GNAT.Traceback.Symbolic (g-trasym.ads)::
19068 * GNAT.UTF_32 (g-utf_32.ads)::
19069 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
19070 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
19071 * GNAT.Wide_String_Split (g-wistsp.ads)::
19072 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
19073 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
19074 * Interfaces.C.Extensions (i-cexten.ads)::
19075 * Interfaces.C.Streams (i-cstrea.ads)::
19076 * Interfaces.Packed_Decimal (i-pacdec.ads)::
19077 * Interfaces.VxWorks (i-vxwork.ads)::
19078 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
19079 * System.Address_Image (s-addima.ads)::
19080 * System.Assertions (s-assert.ads)::
19081 * System.Atomic_Counters (s-atocou.ads)::
19082 * System.Memory (s-memory.ads)::
19083 * System.Multiprocessors (s-multip.ads)::
19084 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
19085 * System.Partition_Interface (s-parint.ads)::
19086 * System.Pool_Global (s-pooglo.ads)::
19087 * System.Pool_Local (s-pooloc.ads)::
19088 * System.Restrictions (s-restri.ads)::
19089 * System.Rident (s-rident.ads)::
19090 * System.Strings.Stream_Ops (s-ststop.ads)::
19091 * System.Unsigned_Types (s-unstyp.ads)::
19092 * System.Wch_Cnv (s-wchcnv.ads)::
19093 * System.Wch_Con (s-wchcon.ads)::
19094 @end menu
19096 @node Ada.Characters.Latin_9 (a-chlat9.ads)
19097 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19098 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19099 @cindex Latin_9 constants for Character
19101 @noindent
19102 This child of @code{Ada.Characters}
19103 provides a set of definitions corresponding to those in the
19104 RM-defined package @code{Ada.Characters.Latin_1} but with the
19105 few modifications required for @code{Latin-9}
19106 The provision of such a package
19107 is specifically authorized by the Ada Reference Manual
19108 (RM A.3.3(27)).
19110 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
19111 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19112 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19113 @cindex Latin_1 constants for Wide_Character
19115 @noindent
19116 This child of @code{Ada.Characters}
19117 provides a set of definitions corresponding to those in the
19118 RM-defined package @code{Ada.Characters.Latin_1} but with the
19119 types of the constants being @code{Wide_Character}
19120 instead of @code{Character}.  The provision of such a package
19121 is specifically authorized by the Ada Reference Manual
19122 (RM A.3.3(27)).
19124 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
19125 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19126 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19127 @cindex Latin_9 constants for Wide_Character
19129 @noindent
19130 This child of @code{Ada.Characters}
19131 provides a set of definitions corresponding to those in the
19132 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19133 types of the constants being @code{Wide_Character}
19134 instead of @code{Character}.  The provision of such a package
19135 is specifically authorized by the Ada Reference Manual
19136 (RM A.3.3(27)).
19138 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
19139 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19140 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19141 @cindex Latin_1 constants for Wide_Wide_Character
19143 @noindent
19144 This child of @code{Ada.Characters}
19145 provides a set of definitions corresponding to those in the
19146 RM-defined package @code{Ada.Characters.Latin_1} but with the
19147 types of the constants being @code{Wide_Wide_Character}
19148 instead of @code{Character}.  The provision of such a package
19149 is specifically authorized by the Ada Reference Manual
19150 (RM A.3.3(27)).
19152 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
19153 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19154 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19155 @cindex Latin_9 constants for Wide_Wide_Character
19157 @noindent
19158 This child of @code{Ada.Characters}
19159 provides a set of definitions corresponding to those in the
19160 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19161 types of the constants being @code{Wide_Wide_Character}
19162 instead of @code{Character}.  The provision of such a package
19163 is specifically authorized by the Ada Reference Manual
19164 (RM A.3.3(27)).
19166 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
19167 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19168 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19169 @cindex Formal container for doubly linked lists
19171 @noindent
19172 This child of @code{Ada.Containers} defines a modified version of the
19173 Ada 2005 container for doubly linked lists, meant to facilitate formal
19174 verification of code using such containers. The specification of this
19175 unit is compatible with SPARK 2014.
19177 Note that although this container was designed with formal verification
19178 in mind, it may well be generally useful in that it is a simplified more
19179 efficient version than the one defined in the standard. In particular it
19180 does not have the complex overhead required to detect cursor tampering.
19182 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
19183 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19184 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19185 @cindex Formal container for hashed maps
19187 @noindent
19188 This child of @code{Ada.Containers} defines a modified version of the
19189 Ada 2005 container for hashed maps, meant to facilitate formal
19190 verification of code using such containers. The specification of this
19191 unit is compatible with SPARK 2014.
19193 Note that although this container was designed with formal verification
19194 in mind, it may well be generally useful in that it is a simplified more
19195 efficient version than the one defined in the standard. In particular it
19196 does not have the complex overhead required to detect cursor tampering.
19198 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
19199 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19200 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19201 @cindex Formal container for hashed sets
19203 @noindent
19204 This child of @code{Ada.Containers} defines a modified version of the
19205 Ada 2005 container for hashed sets, meant to facilitate formal
19206 verification of code using such containers. The specification of this
19207 unit is compatible with SPARK 2014.
19209 Note that although this container was designed with formal verification
19210 in mind, it may well be generally useful in that it is a simplified more
19211 efficient version than the one defined in the standard. In particular it
19212 does not have the complex overhead required to detect cursor tampering.
19214 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
19215 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19216 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19217 @cindex Formal container for ordered maps
19219 @noindent
19220 This child of @code{Ada.Containers} defines a modified version of the
19221 Ada 2005 container for ordered maps, meant to facilitate formal
19222 verification of code using such containers. The specification of this
19223 unit is compatible with SPARK 2014.
19225 Note that although this container was designed with formal verification
19226 in mind, it may well be generally useful in that it is a simplified more
19227 efficient version than the one defined in the standard. In particular it
19228 does not have the complex overhead required to detect cursor tampering.
19230 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
19231 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19232 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19233 @cindex Formal container for ordered sets
19235 @noindent
19236 This child of @code{Ada.Containers} defines a modified version of the
19237 Ada 2005 container for ordered sets, meant to facilitate formal
19238 verification of code using such containers. The specification of this
19239 unit is compatible with SPARK 2014.
19241 Note that although this container was designed with formal verification
19242 in mind, it may well be generally useful in that it is a simplified more
19243 efficient version than the one defined in the standard. In particular it
19244 does not have the complex overhead required to detect cursor tampering.
19246 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
19247 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19248 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19249 @cindex Formal container for vectors
19251 @noindent
19252 This child of @code{Ada.Containers} defines a modified version of the
19253 Ada 2005 container for vectors, meant to facilitate formal
19254 verification of code using such containers. The specification of this
19255 unit is compatible with SPARK 2014.
19257 Note that although this container was designed with formal verification
19258 in mind, it may well be generally useful in that it is a simplified more
19259 efficient version than the one defined in the standard. In particular it
19260 does not have the complex overhead required to detect cursor tampering.
19262 @node Ada.Command_Line.Environment (a-colien.ads)
19263 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19264 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19265 @cindex Environment entries
19267 @noindent
19268 This child of @code{Ada.Command_Line}
19269 provides a mechanism for obtaining environment values on systems
19270 where this concept makes sense.
19272 @node Ada.Command_Line.Remove (a-colire.ads)
19273 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19274 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19275 @cindex Removing command line arguments
19276 @cindex Command line, argument removal
19278 @noindent
19279 This child of @code{Ada.Command_Line}
19280 provides a mechanism for logically removing
19281 arguments from the argument list.  Once removed, an argument is not visible
19282 to further calls on the subprograms in @code{Ada.Command_Line} will not
19283 see the removed argument.
19285 @node Ada.Command_Line.Response_File (a-clrefi.ads)
19286 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19287 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19288 @cindex Response file for command line
19289 @cindex Command line, response file
19290 @cindex Command line, handling long command lines
19292 @noindent
19293 This child of @code{Ada.Command_Line} provides a mechanism facilities for
19294 getting command line arguments from a text file, called a "response file".
19295 Using a response file allow passing a set of arguments to an executable longer
19296 than the maximum allowed by the system on the command line.
19298 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
19299 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19300 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19301 @cindex C Streams, Interfacing with Direct_IO
19303 @noindent
19304 This package provides subprograms that allow interfacing between
19305 C streams and @code{Direct_IO}.  The stream identifier can be
19306 extracted from a file opened on the Ada side, and an Ada file
19307 can be constructed from a stream opened on the C side.
19309 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
19310 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19311 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19312 @cindex Null_Occurrence, testing for
19314 @noindent
19315 This child subprogram provides a way of testing for the null
19316 exception occurrence (@code{Null_Occurrence}) without raising
19317 an exception.
19319 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
19320 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19321 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19322 @cindex Null_Occurrence, testing for
19324 @noindent
19325 This child subprogram is used for handling otherwise unhandled
19326 exceptions (hence the name last chance), and perform clean ups before
19327 terminating the program. Note that this subprogram never returns.
19329 @node Ada.Exceptions.Traceback (a-exctra.ads)
19330 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19331 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19332 @cindex Traceback for Exception Occurrence
19334 @noindent
19335 This child package provides the subprogram (@code{Tracebacks}) to
19336 give a traceback array of addresses based on an exception
19337 occurrence.
19339 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
19340 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19341 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19342 @cindex C Streams, Interfacing with Sequential_IO
19344 @noindent
19345 This package provides subprograms that allow interfacing between
19346 C streams and @code{Sequential_IO}.  The stream identifier can be
19347 extracted from a file opened on the Ada side, and an Ada file
19348 can be constructed from a stream opened on the C side.
19350 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
19351 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19352 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19353 @cindex C Streams, Interfacing with Stream_IO
19355 @noindent
19356 This package provides subprograms that allow interfacing between
19357 C streams and @code{Stream_IO}.  The stream identifier can be
19358 extracted from a file opened on the Ada side, and an Ada file
19359 can be constructed from a stream opened on the C side.
19361 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
19362 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19363 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19364 @cindex @code{Unbounded_String}, IO support
19365 @cindex @code{Text_IO}, extensions for unbounded strings
19367 @noindent
19368 This package provides subprograms for Text_IO for unbounded
19369 strings, avoiding the necessity for an intermediate operation
19370 with ordinary strings.
19372 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
19373 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19374 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19375 @cindex @code{Unbounded_Wide_String}, IO support
19376 @cindex @code{Text_IO}, extensions for unbounded wide strings
19378 @noindent
19379 This package provides subprograms for Text_IO for unbounded
19380 wide strings, avoiding the necessity for an intermediate operation
19381 with ordinary wide strings.
19383 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
19384 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19385 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19386 @cindex @code{Unbounded_Wide_Wide_String}, IO support
19387 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
19389 @noindent
19390 This package provides subprograms for Text_IO for unbounded
19391 wide wide strings, avoiding the necessity for an intermediate operation
19392 with ordinary wide wide strings.
19394 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
19395 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19396 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19397 @cindex C Streams, Interfacing with @code{Text_IO}
19399 @noindent
19400 This package provides subprograms that allow interfacing between
19401 C streams and @code{Text_IO}.  The stream identifier can be
19402 extracted from a file opened on the Ada side, and an Ada file
19403 can be constructed from a stream opened on the C side.
19405 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
19406 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19407 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19408 @cindex @code{Text_IO} resetting standard files
19410 @noindent
19411 This procedure is used to reset the status of the standard files used
19412 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
19413 embedded application) where the status of the files may change during
19414 execution (for example a standard input file may be redefined to be
19415 interactive).
19417 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
19418 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19419 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19420 @cindex Unicode categorization, Wide_Character
19422 @noindent
19423 This package provides subprograms that allow categorization of
19424 Wide_Character values according to Unicode categories.
19426 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
19427 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19428 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19429 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
19431 @noindent
19432 This package provides subprograms that allow interfacing between
19433 C streams and @code{Wide_Text_IO}.  The stream identifier can be
19434 extracted from a file opened on the Ada side, and an Ada file
19435 can be constructed from a stream opened on the C side.
19437 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
19438 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19439 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19440 @cindex @code{Wide_Text_IO} resetting standard files
19442 @noindent
19443 This procedure is used to reset the status of the standard files used
19444 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
19445 embedded application) where the status of the files may change during
19446 execution (for example a standard input file may be redefined to be
19447 interactive).
19449 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
19450 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19451 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19452 @cindex Unicode categorization, Wide_Wide_Character
19454 @noindent
19455 This package provides subprograms that allow categorization of
19456 Wide_Wide_Character values according to Unicode categories.
19458 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
19459 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19460 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19461 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
19463 @noindent
19464 This package provides subprograms that allow interfacing between
19465 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
19466 extracted from a file opened on the Ada side, and an Ada file
19467 can be constructed from a stream opened on the C side.
19469 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
19470 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19471 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19472 @cindex @code{Wide_Wide_Text_IO} resetting standard files
19474 @noindent
19475 This procedure is used to reset the status of the standard files used
19476 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
19477 restart in an embedded application) where the status of the files may
19478 change during execution (for example a standard input file may be
19479 redefined to be interactive).
19481 @node GNAT.Altivec (g-altive.ads)
19482 @section @code{GNAT.Altivec} (@file{g-altive.ads})
19483 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
19484 @cindex AltiVec
19486 @noindent
19487 This is the root package of the GNAT AltiVec binding. It provides
19488 definitions of constants and types common to all the versions of the
19489 binding.
19491 @node GNAT.Altivec.Conversions (g-altcon.ads)
19492 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19493 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19494 @cindex AltiVec
19496 @noindent
19497 This package provides the Vector/View conversion routines.
19499 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
19500 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19501 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19502 @cindex AltiVec
19504 @noindent
19505 This package exposes the Ada interface to the AltiVec operations on
19506 vector objects. A soft emulation is included by default in the GNAT
19507 library. The hard binding is provided as a separate package. This unit
19508 is common to both bindings.
19510 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19511 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19512 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19513 @cindex AltiVec
19515 @noindent
19516 This package exposes the various vector types part of the Ada binding
19517 to AltiVec facilities.
19519 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19520 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19521 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19522 @cindex AltiVec
19524 @noindent
19525 This package provides public 'View' data types from/to which private
19526 vector representations can be converted via
19527 GNAT.Altivec.Conversions. This allows convenient access to individual
19528 vector elements and provides a simple way to initialize vector
19529 objects.
19531 @node GNAT.Array_Split (g-arrspl.ads)
19532 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19533 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19534 @cindex Array splitter
19536 @noindent
19537 Useful array-manipulation routines: given a set of separators, split
19538 an array wherever the separators appear, and provide direct access
19539 to the resulting slices.
19541 @node GNAT.AWK (g-awk.ads)
19542 @section @code{GNAT.AWK} (@file{g-awk.ads})
19543 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19544 @cindex Parsing
19545 @cindex AWK
19547 @noindent
19548 Provides AWK-like parsing functions, with an easy interface for parsing one
19549 or more files containing formatted data.  The file is viewed as a database
19550 where each record is a line and a field is a data element in this line.
19552 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19553 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19554 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19555 @cindex Parsing
19556 @cindex Bounded Buffers
19558 @noindent
19559 Provides a concurrent generic bounded buffer abstraction.  Instances are
19560 useful directly or as parts of the implementations of other abstractions,
19561 such as mailboxes.
19563 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19564 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19565 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19566 @cindex Parsing
19567 @cindex Mailboxes
19569 @noindent
19570 Provides a thread-safe asynchronous intertask mailbox communication facility.
19572 @node GNAT.Bubble_Sort (g-bubsor.ads)
19573 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19574 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19575 @cindex Sorting
19576 @cindex Bubble sort
19578 @noindent
19579 Provides a general implementation of bubble sort usable for sorting arbitrary
19580 data items.  Exchange and comparison procedures are provided by passing
19581 access-to-procedure values.
19583 @node GNAT.Bubble_Sort_A (g-busora.ads)
19584 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19585 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19586 @cindex Sorting
19587 @cindex Bubble sort
19589 @noindent
19590 Provides a general implementation of bubble sort usable for sorting arbitrary
19591 data items.  Move and comparison procedures are provided by passing
19592 access-to-procedure values. This is an older version, retained for
19593 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19595 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19596 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19597 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19598 @cindex Sorting
19599 @cindex Bubble sort
19601 @noindent
19602 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19603 are provided as generic parameters, this improves efficiency, especially
19604 if the procedures can be inlined, at the expense of duplicating code for
19605 multiple instantiations.
19607 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19608 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19609 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19610 @cindex UTF-8 representation
19611 @cindex Wide characte representations
19613 @noindent
19614 Provides a routine which given a string, reads the start of the string to
19615 see whether it is one of the standard byte order marks (BOM's) which signal
19616 the encoding of the string. The routine includes detection of special XML
19617 sequences for various UCS input formats.
19619 @node GNAT.Byte_Swapping (g-bytswa.ads)
19620 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19621 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19622 @cindex Byte swapping
19623 @cindex Endianness
19625 @noindent
19626 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19627 Machine-specific implementations are available in some cases.
19629 @node GNAT.Calendar (g-calend.ads)
19630 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19631 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19632 @cindex @code{Calendar}
19634 @noindent
19635 Extends the facilities provided by @code{Ada.Calendar} to include handling
19636 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19637 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19638 C @code{timeval} format.
19640 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19641 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19642 @cindex @code{Calendar}
19643 @cindex Time
19644 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19646 @node GNAT.Case_Util (g-casuti.ads)
19647 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19648 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19649 @cindex Casing utilities
19650 @cindex Character handling (@code{GNAT.Case_Util})
19652 @noindent
19653 A set of simple routines for handling upper and lower casing of strings
19654 without the overhead of the full casing tables
19655 in @code{Ada.Characters.Handling}.
19657 @node GNAT.CGI (g-cgi.ads)
19658 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19659 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19660 @cindex CGI (Common Gateway Interface)
19662 @noindent
19663 This is a package for interfacing a GNAT program with a Web server via the
19664 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
19665 parameters, which are a set of key/value pairs sent by the Web server.  It
19666 builds a table whose index is the key and provides some services to deal
19667 with this table.
19669 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19670 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19671 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19672 @cindex CGI (Common Gateway Interface) cookie support
19673 @cindex Cookie support in CGI
19675 @noindent
19676 This is a package to interface a GNAT program with a Web server via the
19677 Common Gateway Interface (CGI).  It exports services to deal with Web
19678 cookies (piece of information kept in the Web client software).
19680 @node GNAT.CGI.Debug (g-cgideb.ads)
19681 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19682 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19683 @cindex CGI (Common Gateway Interface) debugging
19685 @noindent
19686 This is a package to help debugging CGI (Common Gateway Interface)
19687 programs written in Ada.
19689 @node GNAT.Command_Line (g-comlin.ads)
19690 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19691 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19692 @cindex Command line
19694 @noindent
19695 Provides a high level interface to @code{Ada.Command_Line} facilities,
19696 including the ability to scan for named switches with optional parameters
19697 and expand file names using wild card notations.
19699 @node GNAT.Compiler_Version (g-comver.ads)
19700 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19701 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19702 @cindex Compiler Version
19703 @cindex Version, of compiler
19705 @noindent
19706 Provides a routine for obtaining the version of the compiler used to
19707 compile the program. More accurately this is the version of the binder
19708 used to bind the program (this will normally be the same as the version
19709 of the compiler if a consistent tool set is used to compile all units
19710 of a partition).
19712 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19713 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19714 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19715 @cindex Interrupt
19717 @noindent
19718 Provides a simple interface to handle Ctrl-C keyboard events.
19720 @node GNAT.CRC32 (g-crc32.ads)
19721 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19722 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19723 @cindex CRC32
19724 @cindex Cyclic Redundancy Check
19726 @noindent
19727 This package implements the CRC-32 algorithm.  For a full description
19728 of this algorithm see
19729 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19730 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19731 Aug.@: 1988.  Sarwate, D.V@.
19733 @node GNAT.Current_Exception (g-curexc.ads)
19734 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19735 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19736 @cindex Current exception
19737 @cindex Exception retrieval
19739 @noindent
19740 Provides access to information on the current exception that has been raised
19741 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19742 specification syntax.
19743 This is particularly useful in simulating typical facilities for
19744 obtaining information about exceptions provided by Ada 83 compilers.
19746 @node GNAT.Debug_Pools (g-debpoo.ads)
19747 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19748 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19749 @cindex Debugging
19750 @cindex Debug pools
19751 @cindex Memory corruption debugging
19753 @noindent
19754 Provide a debugging storage pools that helps tracking memory corruption
19755 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19756 @value{EDITION} User's Guide}.
19758 @node GNAT.Debug_Utilities (g-debuti.ads)
19759 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19760 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19761 @cindex Debugging
19763 @noindent
19764 Provides a few useful utilities for debugging purposes, including conversion
19765 to and from string images of address values. Supports both C and Ada formats
19766 for hexadecimal literals.
19768 @node GNAT.Decode_String (g-decstr.ads)
19769 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19770 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19771 @cindex Decoding strings
19772 @cindex String decoding
19773 @cindex Wide character encoding
19774 @cindex UTF-8
19775 @cindex Unicode
19777 @noindent
19778 A generic package providing routines for decoding wide character and wide wide
19779 character strings encoded as sequences of 8-bit characters using a specified
19780 encoding method. Includes validation routines, and also routines for stepping
19781 to next or previous encoded character in an encoded string.
19782 Useful in conjunction with Unicode character coding. Note there is a
19783 preinstantiation for UTF-8. See next entry.
19785 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19786 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19787 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19788 @cindex Decoding strings
19789 @cindex Decoding UTF-8 strings
19790 @cindex UTF-8 string decoding
19791 @cindex Wide character decoding
19792 @cindex UTF-8
19793 @cindex Unicode
19795 @noindent
19796 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19798 @node GNAT.Directory_Operations (g-dirope.ads)
19799 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19800 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19801 @cindex Directory operations
19803 @noindent
19804 Provides a set of routines for manipulating directories, including changing
19805 the current directory, making new directories, and scanning the files in a
19806 directory.
19808 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19809 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19810 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19811 @cindex Directory operations iteration
19813 @noindent
19814 A child unit of GNAT.Directory_Operations providing additional operations
19815 for iterating through directories.
19817 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19818 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19819 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19820 @cindex Hash tables
19822 @noindent
19823 A generic implementation of hash tables that can be used to hash arbitrary
19824 data.  Provided in two forms, a simple form with built in hash functions,
19825 and a more complex form in which the hash function is supplied.
19827 @noindent
19828 This package provides a facility similar to that of @code{GNAT.HTable},
19829 except that this package declares a type that can be used to define
19830 dynamic instances of the hash table, while an instantiation of
19831 @code{GNAT.HTable} creates a single instance of the hash table.
19833 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19834 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19835 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19836 @cindex Table implementation
19837 @cindex Arrays, extendable
19839 @noindent
19840 A generic package providing a single dimension array abstraction where the
19841 length of the array can be dynamically modified.
19843 @noindent
19844 This package provides a facility similar to that of @code{GNAT.Table},
19845 except that this package declares a type that can be used to define
19846 dynamic instances of the table, while an instantiation of
19847 @code{GNAT.Table} creates a single instance of the table type.
19849 @node GNAT.Encode_String (g-encstr.ads)
19850 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19851 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19852 @cindex Encoding strings
19853 @cindex String encoding
19854 @cindex Wide character encoding
19855 @cindex UTF-8
19856 @cindex Unicode
19858 @noindent
19859 A generic package providing routines for encoding wide character and wide
19860 wide character strings as sequences of 8-bit characters using a specified
19861 encoding method. Useful in conjunction with Unicode character coding.
19862 Note there is a preinstantiation for UTF-8. See next entry.
19864 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19865 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19866 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19867 @cindex Encoding strings
19868 @cindex Encoding UTF-8 strings
19869 @cindex UTF-8 string encoding
19870 @cindex Wide character encoding
19871 @cindex UTF-8
19872 @cindex Unicode
19874 @noindent
19875 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19877 @node GNAT.Exception_Actions (g-excact.ads)
19878 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19879 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19880 @cindex Exception actions
19882 @noindent
19883 Provides callbacks when an exception is raised. Callbacks can be registered
19884 for specific exceptions, or when any exception is raised. This
19885 can be used for instance to force a core dump to ease debugging.
19887 @node GNAT.Exception_Traces (g-exctra.ads)
19888 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19889 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19890 @cindex Exception traces
19891 @cindex Debugging
19893 @noindent
19894 Provides an interface allowing to control automatic output upon exception
19895 occurrences.
19897 @node GNAT.Exceptions (g-except.ads)
19898 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19899 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19900 @cindex Exceptions, Pure
19901 @cindex Pure packages, exceptions
19903 @noindent
19904 Normally it is not possible to raise an exception with
19905 a message from a subprogram in a pure package, since the
19906 necessary types and subprograms are in @code{Ada.Exceptions}
19907 which is not a pure unit. @code{GNAT.Exceptions} provides a
19908 facility for getting around this limitation for a few
19909 predefined exceptions, and for example allow raising
19910 @code{Constraint_Error} with a message from a pure subprogram.
19912 @node GNAT.Expect (g-expect.ads)
19913 @section @code{GNAT.Expect} (@file{g-expect.ads})
19914 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19916 @noindent
19917 Provides a set of subprograms similar to what is available
19918 with the standard Tcl Expect tool.
19919 It allows you to easily spawn and communicate with an external process.
19920 You can send commands or inputs to the process, and compare the output
19921 with some expected regular expression. Currently @code{GNAT.Expect}
19922 is implemented on all native GNAT ports except for OpenVMS@.
19923 It is not implemented for cross ports, and in particular is not
19924 implemented for VxWorks or LynxOS@.
19926 @node GNAT.Expect.TTY (g-exptty.ads)
19927 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19928 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19930 @noindent
19931 As GNAT.Expect but using pseudo-terminal.
19932 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19933 ports except for OpenVMS@. It is not implemented for cross ports, and
19934 in particular is not implemented for VxWorks or LynxOS@.
19936 @node GNAT.Float_Control (g-flocon.ads)
19937 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19938 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19939 @cindex Floating-Point Processor
19941 @noindent
19942 Provides an interface for resetting the floating-point processor into the
19943 mode required for correct semantic operation in Ada.  Some third party
19944 library calls may cause this mode to be modified, and the Reset procedure
19945 in this package can be used to reestablish the required mode.
19947 @node GNAT.Formatted_String (g-forstr.ads)
19948 @section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19949 @cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19950 @cindex Formatted String
19952 @noindent
19953 Provides support for C/C++ printf() formatted strings. The format is
19954 copied from the printf() routine and should therefore gives identical
19955 output. Some generic routines are provided to be able to use types
19956 derived from Integer, Float or enumerations as values for the
19957 formatted string.
19959 @node GNAT.Heap_Sort (g-heasor.ads)
19960 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19961 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19962 @cindex Sorting
19964 @noindent
19965 Provides a general implementation of heap sort usable for sorting arbitrary
19966 data items. Exchange and comparison procedures are provided by passing
19967 access-to-procedure values.  The algorithm used is a modified heap sort
19968 that performs approximately N*log(N) comparisons in the worst case.
19970 @node GNAT.Heap_Sort_A (g-hesora.ads)
19971 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19972 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19973 @cindex Sorting
19975 @noindent
19976 Provides a general implementation of heap sort usable for sorting arbitrary
19977 data items. Move and comparison procedures are provided by passing
19978 access-to-procedure values.  The algorithm used is a modified heap sort
19979 that performs approximately N*log(N) comparisons in the worst case.
19980 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19981 interface, but may be slightly more efficient.
19983 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19984 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19985 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19986 @cindex Sorting
19988 @noindent
19989 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19990 are provided as generic parameters, this improves efficiency, especially
19991 if the procedures can be inlined, at the expense of duplicating code for
19992 multiple instantiations.
19994 @node GNAT.HTable (g-htable.ads)
19995 @section @code{GNAT.HTable} (@file{g-htable.ads})
19996 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19997 @cindex Hash tables
19999 @noindent
20000 A generic implementation of hash tables that can be used to hash arbitrary
20001 data.  Provides two approaches, one a simple static approach, and the other
20002 allowing arbitrary dynamic hash tables.
20004 @node GNAT.IO (g-io.ads)
20005 @section @code{GNAT.IO} (@file{g-io.ads})
20006 @cindex @code{GNAT.IO} (@file{g-io.ads})
20007 @cindex Simple I/O
20008 @cindex Input/Output facilities
20010 @noindent
20011 A simple preelaborable input-output package that provides a subset of
20012 simple Text_IO functions for reading characters and strings from
20013 Standard_Input, and writing characters, strings and integers to either
20014 Standard_Output or Standard_Error.
20016 @node GNAT.IO_Aux (g-io_aux.ads)
20017 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20018 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
20019 @cindex Text_IO
20020 @cindex Input/Output facilities
20022 Provides some auxiliary functions for use with Text_IO, including a test
20023 for whether a file exists, and functions for reading a line of text.
20025 @node GNAT.Lock_Files (g-locfil.ads)
20026 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20027 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
20028 @cindex File locking
20029 @cindex Locking using files
20031 @noindent
20032 Provides a general interface for using files as locks.  Can be used for
20033 providing program level synchronization.
20035 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
20036 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20037 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
20038 @cindex Random number generation
20040 @noindent
20041 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
20042 a modified version of the Blum-Blum-Shub generator.
20044 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
20045 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20046 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
20047 @cindex Random number generation
20049 @noindent
20050 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
20051 a modified version of the Blum-Blum-Shub generator.
20053 @node GNAT.MD5 (g-md5.ads)
20054 @section @code{GNAT.MD5} (@file{g-md5.ads})
20055 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
20056 @cindex Message Digest MD5
20058 @noindent
20059 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
20060 the HMAC-MD5 message authentication function as described in RFC 2104 and
20061 FIPS PUB 198.
20063 @node GNAT.Memory_Dump (g-memdum.ads)
20064 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20065 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20066 @cindex Dump Memory
20068 @noindent
20069 Provides a convenient routine for dumping raw memory to either the
20070 standard output or standard error files. Uses GNAT.IO for actual
20071 output.
20073 @node GNAT.Most_Recent_Exception (g-moreex.ads)
20074 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20075 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20076 @cindex Exception, obtaining most recent
20078 @noindent
20079 Provides access to the most recently raised exception.  Can be used for
20080 various logging purposes, including duplicating functionality of some
20081 Ada 83 implementation dependent extensions.
20083 @node GNAT.OS_Lib (g-os_lib.ads)
20084 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20085 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20086 @cindex Operating System interface
20087 @cindex Spawn capability
20089 @noindent
20090 Provides a range of target independent operating system interface functions,
20091 including time/date management, file operations, subprocess management,
20092 including a portable spawn procedure, and access to environment variables
20093 and error return codes.
20095 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
20096 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20097 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20098 @cindex Hash functions
20100 @noindent
20101 Provides a generator of static minimal perfect hash functions. No
20102 collisions occur and each item can be retrieved from the table in one
20103 probe (perfect property). The hash table size corresponds to the exact
20104 size of the key set and no larger (minimal property). The key set has to
20105 be know in advance (static property). The hash functions are also order
20106 preserving. If w2 is inserted after w1 in the generator, their
20107 hashcode are in the same order. These hashing functions are very
20108 convenient for use with realtime applications.
20110 @node GNAT.Random_Numbers (g-rannum.ads)
20111 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20112 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20113 @cindex Random number generation
20115 @noindent
20116 Provides random number capabilities which extend those available in the
20117 standard Ada library and are more convenient to use.
20119 @node GNAT.Regexp (g-regexp.ads)
20120 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
20121 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
20122 @cindex Regular expressions
20123 @cindex Pattern matching
20125 @noindent
20126 A simple implementation of regular expressions, using a subset of regular
20127 expression syntax copied from familiar Unix style utilities.  This is the
20128 simplest of the three pattern matching packages provided, and is particularly
20129 suitable for ``file globbing'' applications.
20131 @node GNAT.Registry (g-regist.ads)
20132 @section @code{GNAT.Registry} (@file{g-regist.ads})
20133 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
20134 @cindex Windows Registry
20136 @noindent
20137 This is a high level binding to the Windows registry.  It is possible to
20138 do simple things like reading a key value, creating a new key.  For full
20139 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
20140 package provided with the Win32Ada binding
20142 @node GNAT.Regpat (g-regpat.ads)
20143 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
20144 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
20145 @cindex Regular expressions
20146 @cindex Pattern matching
20148 @noindent
20149 A complete implementation of Unix-style regular expression matching, copied
20150 from the original V7 style regular expression library written in C by
20151 Henry Spencer (and binary compatible with this C library).
20153 @node GNAT.Rewrite_Data (g-rewdat.ads)
20154 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20155 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20156 @cindex Rewrite data
20158 @noindent
20159 A unit to rewrite on-the-fly string occurrences in a stream of
20160 data. The implementation has a very minimal memory footprint as the
20161 full content to be processed is not loaded into memory all at once. This makes
20162 this interface usable for large files or socket streams.
20164 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
20165 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20166 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20167 @cindex Secondary Stack Info
20169 @noindent
20170 Provide the capability to query the high water mark of the current task's
20171 secondary stack.
20173 @node GNAT.Semaphores (g-semaph.ads)
20174 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
20175 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
20176 @cindex Semaphores
20178 @noindent
20179 Provides classic counting and binary semaphores using protected types.
20181 @node GNAT.Serial_Communications (g-sercom.ads)
20182 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20183 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20184 @cindex Serial_Communications
20186 @noindent
20187 Provides a simple interface to send and receive data over a serial
20188 port. This is only supported on GNU/Linux and Windows.
20190 @node GNAT.SHA1 (g-sha1.ads)
20191 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
20192 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
20193 @cindex Secure Hash Algorithm SHA-1
20195 @noindent
20196 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
20197 and RFC 3174, and the HMAC-SHA1 message authentication function as described
20198 in RFC 2104 and FIPS PUB 198.
20200 @node GNAT.SHA224 (g-sha224.ads)
20201 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
20202 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
20203 @cindex Secure Hash Algorithm SHA-224
20205 @noindent
20206 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
20207 and the HMAC-SHA224 message authentication function as described
20208 in RFC 2104 and FIPS PUB 198.
20210 @node GNAT.SHA256 (g-sha256.ads)
20211 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
20212 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
20213 @cindex Secure Hash Algorithm SHA-256
20215 @noindent
20216 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
20217 and the HMAC-SHA256 message authentication function as described
20218 in RFC 2104 and FIPS PUB 198.
20220 @node GNAT.SHA384 (g-sha384.ads)
20221 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
20222 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
20223 @cindex Secure Hash Algorithm SHA-384
20225 @noindent
20226 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
20227 and the HMAC-SHA384 message authentication function as described
20228 in RFC 2104 and FIPS PUB 198.
20230 @node GNAT.SHA512 (g-sha512.ads)
20231 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
20232 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
20233 @cindex Secure Hash Algorithm SHA-512
20235 @noindent
20236 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
20237 and the HMAC-SHA512 message authentication function as described
20238 in RFC 2104 and FIPS PUB 198.
20240 @node GNAT.Signals (g-signal.ads)
20241 @section @code{GNAT.Signals} (@file{g-signal.ads})
20242 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
20243 @cindex Signals
20245 @noindent
20246 Provides the ability to manipulate the blocked status of signals on supported
20247 targets.
20249 @node GNAT.Sockets (g-socket.ads)
20250 @section @code{GNAT.Sockets} (@file{g-socket.ads})
20251 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
20252 @cindex Sockets
20254 @noindent
20255 A high level and portable interface to develop sockets based applications.
20256 This package is based on the sockets thin binding found in
20257 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
20258 on all native GNAT ports except for OpenVMS@.  It is not implemented
20259 for the LynxOS@ cross port.
20261 @node GNAT.Source_Info (g-souinf.ads)
20262 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
20263 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
20264 @cindex Source Information
20266 @noindent
20267 Provides subprograms that give access to source code information known at
20268 compile time, such as the current file name and line number. Also provides
20269 subprograms yielding the date and time of the current compilation (like the
20270 C macros @code{__DATE__} and @code{__TIME__})
20272 @node GNAT.Spelling_Checker (g-speche.ads)
20273 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20274 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20275 @cindex Spell checking
20277 @noindent
20278 Provides a function for determining whether one string is a plausible
20279 near misspelling of another string.
20281 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
20282 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20283 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20284 @cindex Spell checking
20286 @noindent
20287 Provides a generic function that can be instantiated with a string type for
20288 determining whether one string is a plausible near misspelling of another
20289 string.
20291 @node GNAT.Spitbol.Patterns (g-spipat.ads)
20292 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20293 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20294 @cindex SPITBOL pattern matching
20295 @cindex Pattern matching
20297 @noindent
20298 A complete implementation of SNOBOL4 style pattern matching.  This is the
20299 most elaborate of the pattern matching packages provided.  It fully duplicates
20300 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
20301 efficient algorithm developed by Robert Dewar for the SPITBOL system.
20303 @node GNAT.Spitbol (g-spitbo.ads)
20304 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20305 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20306 @cindex SPITBOL interface
20308 @noindent
20309 The top level package of the collection of SPITBOL-style functionality, this
20310 package provides basic SNOBOL4 string manipulation functions, such as
20311 Pad, Reverse, Trim, Substr capability, as well as a generic table function
20312 useful for constructing arbitrary mappings from strings in the style of
20313 the SNOBOL4 TABLE function.
20315 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
20316 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20317 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20318 @cindex Sets of strings
20319 @cindex SPITBOL Tables
20321 @noindent
20322 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20323 for type @code{Standard.Boolean}, giving an implementation of sets of
20324 string values.
20326 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
20327 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20328 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20329 @cindex Integer maps
20330 @cindex Maps
20331 @cindex SPITBOL Tables
20333 @noindent
20334 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20335 for type @code{Standard.Integer}, giving an implementation of maps
20336 from string to integer values.
20338 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
20339 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20340 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20341 @cindex String maps
20342 @cindex Maps
20343 @cindex SPITBOL Tables
20345 @noindent
20346 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
20347 a variable length string type, giving an implementation of general
20348 maps from strings to strings.
20350 @node GNAT.SSE (g-sse.ads)
20351 @section @code{GNAT.SSE} (@file{g-sse.ads})
20352 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
20354 @noindent
20355 Root of a set of units aimed at offering Ada bindings to a subset of
20356 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
20357 targets.  It exposes vector component types together with a general
20358 introduction to the binding contents and use.
20360 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
20361 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20362 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20364 @noindent
20365 SSE vector types for use with SSE related intrinsics.
20367 @node GNAT.Strings (g-string.ads)
20368 @section @code{GNAT.Strings} (@file{g-string.ads})
20369 @cindex @code{GNAT.Strings} (@file{g-string.ads})
20371 @noindent
20372 Common String access types and related subprograms. Basically it
20373 defines a string access and an array of string access types.
20375 @node GNAT.String_Split (g-strspl.ads)
20376 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
20377 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
20378 @cindex String splitter
20380 @noindent
20381 Useful string manipulation routines: given a set of separators, split
20382 a string wherever the separators appear, and provide direct access
20383 to the resulting slices. This package is instantiated from
20384 @code{GNAT.Array_Split}.
20386 @node GNAT.Table (g-table.ads)
20387 @section @code{GNAT.Table} (@file{g-table.ads})
20388 @cindex @code{GNAT.Table} (@file{g-table.ads})
20389 @cindex Table implementation
20390 @cindex Arrays, extendable
20392 @noindent
20393 A generic package providing a single dimension array abstraction where the
20394 length of the array can be dynamically modified.
20396 @noindent
20397 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
20398 except that this package declares a single instance of the table type,
20399 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
20400 used to define dynamic instances of the table.
20402 @node GNAT.Task_Lock (g-tasloc.ads)
20403 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20404 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20405 @cindex Task synchronization
20406 @cindex Task locking
20407 @cindex Locking
20409 @noindent
20410 A very simple facility for locking and unlocking sections of code using a
20411 single global task lock.  Appropriate for use in situations where contention
20412 between tasks is very rarely expected.
20414 @node GNAT.Threads (g-thread.ads)
20415 @section @code{GNAT.Threads} (@file{g-thread.ads})
20416 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
20417 @cindex Foreign threads
20418 @cindex Threads, foreign
20420 @noindent
20421 Provides facilities for dealing with foreign threads which need to be known
20422 by the GNAT run-time system. Consult the documentation of this package for
20423 further details if your program has threads that are created by a non-Ada
20424 environment which then accesses Ada code.
20426 @node GNAT.Time_Stamp (g-timsta.ads)
20427 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20428 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20429 @cindex Time stamp
20430 @cindex Current time
20432 @noindent
20433 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
20434 represents the current date and time in ISO 8601 format. This is a very simple
20435 routine with minimal code and there are no dependencies on any other unit.
20437 @node GNAT.Traceback (g-traceb.ads)
20438 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
20439 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
20440 @cindex Trace back facilities
20442 @noindent
20443 Provides a facility for obtaining non-symbolic traceback information, useful
20444 in various debugging situations.
20446 @node GNAT.Traceback.Symbolic (g-trasym.ads)
20447 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20448 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20449 @cindex Trace back facilities
20451 @node GNAT.UTF_32 (g-utf_32.ads)
20452 @section @code{GNAT.UTF_32} (@file{g-table.ads})
20453 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
20454 @cindex Wide character codes
20456 @noindent
20457 This is a package intended to be used in conjunction with the
20458 @code{Wide_Character} type in Ada 95 and the
20459 @code{Wide_Wide_Character} type in Ada 2005 (available
20460 in @code{GNAT} in Ada 2005 mode). This package contains
20461 Unicode categorization routines, as well as lexical
20462 categorization routines corresponding to the Ada 2005
20463 lexical rules for identifiers and strings, and also a
20464 lower case to upper case fold routine corresponding to
20465 the Ada 2005 rules for identifier equivalence.
20467 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
20468 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20469 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20470 @cindex Spell checking
20472 @noindent
20473 Provides a function for determining whether one wide wide string is a plausible
20474 near misspelling of another wide wide string, where the strings are represented
20475 using the UTF_32_String type defined in System.Wch_Cnv.
20477 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
20478 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20479 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20480 @cindex Spell checking
20482 @noindent
20483 Provides a function for determining whether one wide string is a plausible
20484 near misspelling of another wide string.
20486 @node GNAT.Wide_String_Split (g-wistsp.ads)
20487 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20488 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20489 @cindex Wide_String splitter
20491 @noindent
20492 Useful wide string manipulation routines: given a set of separators, split
20493 a wide string wherever the separators appear, and provide direct access
20494 to the resulting slices. This package is instantiated from
20495 @code{GNAT.Array_Split}.
20497 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
20498 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20499 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20500 @cindex Spell checking
20502 @noindent
20503 Provides a function for determining whether one wide wide string is a plausible
20504 near misspelling of another wide wide string.
20506 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
20507 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20508 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20509 @cindex Wide_Wide_String splitter
20511 @noindent
20512 Useful wide wide string manipulation routines: given a set of separators, split
20513 a wide wide string wherever the separators appear, and provide direct access
20514 to the resulting slices. This package is instantiated from
20515 @code{GNAT.Array_Split}.
20517 @node Interfaces.C.Extensions (i-cexten.ads)
20518 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20519 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20521 @noindent
20522 This package contains additional C-related definitions, intended
20523 for use with either manually or automatically generated bindings
20524 to C libraries.
20526 @node Interfaces.C.Streams (i-cstrea.ads)
20527 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20528 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20529 @cindex  C streams, interfacing
20531 @noindent
20532 This package is a binding for the most commonly used operations
20533 on C streams.
20535 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20536 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20537 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20538 @cindex  IBM Packed Format
20539 @cindex  Packed Decimal
20541 @noindent
20542 This package provides a set of routines for conversions to and
20543 from a packed decimal format compatible with that used on IBM
20544 mainframes.
20546 @node Interfaces.VxWorks (i-vxwork.ads)
20547 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20548 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20549 @cindex Interfacing to VxWorks
20550 @cindex VxWorks, interfacing
20552 @noindent
20553 This package provides a limited binding to the VxWorks API.
20554 In particular, it interfaces with the
20555 VxWorks hardware interrupt facilities.
20557 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20558 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20559 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20560 @cindex Interfacing to VxWorks' I/O
20561 @cindex VxWorks, I/O interfacing
20562 @cindex VxWorks, Get_Immediate
20563 @cindex Get_Immediate, VxWorks
20565 @noindent
20566 This package provides a binding to the ioctl (IO/Control)
20567 function of VxWorks, defining a set of option values and
20568 function codes. A particular use of this package is
20569 to enable the use of Get_Immediate under VxWorks.
20571 @node System.Address_Image (s-addima.ads)
20572 @section @code{System.Address_Image} (@file{s-addima.ads})
20573 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20574 @cindex Address image
20575 @cindex Image, of an address
20577 @noindent
20578 This function provides a useful debugging
20579 function that gives an (implementation dependent)
20580 string which identifies an address.
20582 @node System.Assertions (s-assert.ads)
20583 @section @code{System.Assertions} (@file{s-assert.ads})
20584 @cindex @code{System.Assertions} (@file{s-assert.ads})
20585 @cindex Assertions
20586 @cindex Assert_Failure, exception
20588 @noindent
20589 This package provides the declaration of the exception raised
20590 by an run-time assertion failure, as well as the routine that
20591 is used internally to raise this assertion.
20593 @node System.Atomic_Counters (s-atocou.ads)
20594 @section @code{System.Atomic_Counters} (@file{s-atocou.ads})
20595 @cindex @code{System.Atomic_Counters} (@file{s-atocou.ads})
20597 @noindent
20598 This package provides the declaration of an atomic counter type,
20599 together with efficient routines (using hardware
20600 synchronization primitives) for incrementing, decrementing,
20601 and testing of these counters. This package is implemented
20602 on most targets, including all Alpha, ia64, PowerPC, SPARC V9,
20603 x86, and x86_64 platforms.
20605 @node System.Memory (s-memory.ads)
20606 @section @code{System.Memory} (@file{s-memory.ads})
20607 @cindex @code{System.Memory} (@file{s-memory.ads})
20608 @cindex Memory allocation
20610 @noindent
20611 This package provides the interface to the low level routines used
20612 by the generated code for allocation and freeing storage for the
20613 default storage pool (analogous to the C routines malloc and free.
20614 It also provides a reallocation interface analogous to the C routine
20615 realloc. The body of this unit may be modified to provide alternative
20616 allocation mechanisms for the default pool, and in addition, direct
20617 calls to this unit may be made for low level allocation uses (for
20618 example see the body of @code{GNAT.Tables}).
20620 @node System.Multiprocessors (s-multip.ads)
20621 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20622 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20623 @cindex Multiprocessor interface
20624 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20625 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20626 technically an implementation-defined addition).
20628 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20629 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20630 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20631 @cindex Multiprocessor interface
20632 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20633 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20634 technically an implementation-defined addition).
20636 @node System.Partition_Interface (s-parint.ads)
20637 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20638 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20639 @cindex Partition interfacing functions
20641 @noindent
20642 This package provides facilities for partition interfacing.  It
20643 is used primarily in a distribution context when using Annex E
20644 with @code{GLADE}.
20646 @node System.Pool_Global (s-pooglo.ads)
20647 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20648 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20649 @cindex Storage pool, global
20650 @cindex Global storage pool
20652 @noindent
20653 This package provides a storage pool that is equivalent to the default
20654 storage pool used for access types for which no pool is specifically
20655 declared. It uses malloc/free to allocate/free and does not attempt to
20656 do any automatic reclamation.
20658 @node System.Pool_Local (s-pooloc.ads)
20659 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20660 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20661 @cindex Storage pool, local
20662 @cindex Local storage pool
20664 @noindent
20665 This package provides a storage pool that is intended for use with locally
20666 defined access types. It uses malloc/free for allocate/free, and maintains
20667 a list of allocated blocks, so that all storage allocated for the pool can
20668 be freed automatically when the pool is finalized.
20670 @node System.Restrictions (s-restri.ads)
20671 @section @code{System.Restrictions} (@file{s-restri.ads})
20672 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20673 @cindex Run-time restrictions access
20675 @noindent
20676 This package provides facilities for accessing at run time
20677 the status of restrictions specified at compile time for
20678 the partition. Information is available both with regard
20679 to actual restrictions specified, and with regard to
20680 compiler determined information on which restrictions
20681 are violated by one or more packages in the partition.
20683 @node System.Rident (s-rident.ads)
20684 @section @code{System.Rident} (@file{s-rident.ads})
20685 @cindex @code{System.Rident} (@file{s-rident.ads})
20686 @cindex Restrictions definitions
20688 @noindent
20689 This package provides definitions of the restrictions
20690 identifiers supported by GNAT, and also the format of
20691 the restrictions provided in package System.Restrictions.
20692 It is not normally necessary to @code{with} this generic package
20693 since the necessary instantiation is included in
20694 package System.Restrictions.
20696 @node System.Strings.Stream_Ops (s-ststop.ads)
20697 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20698 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20699 @cindex Stream operations
20700 @cindex String stream operations
20702 @noindent
20703 This package provides a set of stream subprograms for standard string types.
20704 It is intended primarily to support implicit use of such subprograms when
20705 stream attributes are applied to string types, but the subprograms in this
20706 package can be used directly by application programs.
20708 @node System.Unsigned_Types (s-unstyp.ads)
20709 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20710 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20712 @noindent
20713 This package contains definitions of standard unsigned types that
20714 correspond in size to the standard signed types declared in Standard,
20715 and (unlike the types in Interfaces) have corresponding names. It
20716 also contains some related definitions for other specialized types
20717 used by the compiler in connection with packed array types.
20719 @node System.Wch_Cnv (s-wchcnv.ads)
20720 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20721 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20722 @cindex Wide Character, Representation
20723 @cindex Wide String, Conversion
20724 @cindex Representation of wide characters
20726 @noindent
20727 This package provides routines for converting between
20728 wide and wide wide characters and a representation as a value of type
20729 @code{Standard.String}, using a specified wide character
20730 encoding method.  It uses definitions in
20731 package @code{System.Wch_Con}.
20733 @node System.Wch_Con (s-wchcon.ads)
20734 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20735 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20737 @noindent
20738 This package provides definitions and descriptions of
20739 the various methods used for encoding wide characters
20740 in ordinary strings.  These definitions are used by
20741 the package @code{System.Wch_Cnv}.
20743 @node Interfacing to Other Languages
20744 @chapter Interfacing to Other Languages
20745 @noindent
20746 The facilities in annex B of the Ada Reference Manual are fully
20747 implemented in GNAT, and in addition, a full interface to C++ is
20748 provided.
20750 @menu
20751 * Interfacing to C::
20752 * Interfacing to C++::
20753 * Interfacing to COBOL::
20754 * Interfacing to Fortran::
20755 * Interfacing to non-GNAT Ada code::
20756 @end menu
20758 @node Interfacing to C
20759 @section Interfacing to C
20761 @noindent
20762 Interfacing to C with GNAT can use one of two approaches:
20764 @itemize @bullet
20765 @item
20766 The types in the package @code{Interfaces.C} may be used.
20767 @item
20768 Standard Ada types may be used directly.  This may be less portable to
20769 other compilers, but will work on all GNAT compilers, which guarantee
20770 correspondence between the C and Ada types.
20771 @end itemize
20773 @noindent
20774 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20775 effect, since this is the default.  The following table shows the
20776 correspondence between Ada scalar types and the corresponding C types.
20778 @table @code
20779 @item Integer
20780 @code{int}
20781 @item Short_Integer
20782 @code{short}
20783 @item Short_Short_Integer
20784 @code{signed char}
20785 @item Long_Integer
20786 @code{long}
20787 @item Long_Long_Integer
20788 @code{long long}
20789 @item Short_Float
20790 @code{float}
20791 @item Float
20792 @code{float}
20793 @item Long_Float
20794 @code{double}
20795 @item Long_Long_Float
20796 This is the longest floating-point type supported by the hardware.
20797 @end table
20799 @noindent
20800 Additionally, there are the following general correspondences between Ada
20801 and C types:
20802 @itemize @bullet
20803 @item
20804 Ada enumeration types map to C enumeration types directly if pragma
20805 @code{Convention C} is specified, which causes them to have int
20806 length.  Without pragma @code{Convention C}, Ada enumeration types map to
20807 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20808 @code{int}, respectively) depending on the number of values passed.
20809 This is the only case in which pragma @code{Convention C} affects the
20810 representation of an Ada type.
20812 @item
20813 Ada access types map to C pointers, except for the case of pointers to
20814 unconstrained types in Ada, which have no direct C equivalent.
20816 @item
20817 Ada arrays map directly to C arrays.
20819 @item
20820 Ada records map directly to C structures.
20822 @item
20823 Packed Ada records map to C structures where all members are bit fields
20824 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20825 @end itemize
20827 @node Interfacing to C++
20828 @section Interfacing to C++
20830 @noindent
20831 The interface to C++ makes use of the following pragmas, which are
20832 primarily intended to be constructed automatically using a binding generator
20833 tool, although it is possible to construct them by hand.
20835 Using these pragmas it is possible to achieve complete
20836 inter-operability between Ada tagged types and C++ class definitions.
20837 See @ref{Implementation Defined Pragmas}, for more details.
20839 @table @code
20840 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20841 The argument denotes an entity in the current declarative region that is
20842 declared as a tagged or untagged record type. It indicates that the type
20843 corresponds to an externally declared C++ class type, and is to be laid
20844 out the same way that C++ would lay out the type.
20846 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20847 for backward compatibility but its functionality is available
20848 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20850 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20851 This pragma identifies an imported function (imported in the usual way
20852 with pragma @code{Import}) as corresponding to a C++ constructor.
20853 @end table
20855 A few restrictions are placed on the use of the @code{Access} attribute
20856 in conjunction with subprograms subject to convention @code{CPP}: the
20857 attribute may be used neither on primitive operations of a tagged
20858 record type with convention @code{CPP}, imported or not, nor on
20859 subprograms imported with pragma @code{CPP_Constructor}.
20861 In addition, C++ exceptions are propagated and can be handled in an
20862 @code{others} choice of an exception handler. The corresponding Ada
20863 occurrence has no message, and the simple name of the exception identity
20864 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20865 tasks works properly when such foreign exceptions are propagated.
20867 It is also possible to import a C++ exception using the following syntax:
20869 @smallexample @c ada
20870 LOCAL_NAME : exception;
20871 pragma Import (Cpp,
20872   [Entity =>] LOCAL_NAME,
20873   [External_Name =>] static_string_EXPRESSION);
20874 @end smallexample
20876 @noindent
20877 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20878 cover a specific C++ exception in an exception handler.
20880 @node Interfacing to COBOL
20881 @section Interfacing to COBOL
20883 @noindent
20884 Interfacing to COBOL is achieved as described in section B.4 of
20885 the Ada Reference Manual.
20887 @node Interfacing to Fortran
20888 @section Interfacing to Fortran
20890 @noindent
20891 Interfacing to Fortran is achieved as described in section B.5 of the
20892 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
20893 multi-dimensional array causes the array to be stored in column-major
20894 order as required for convenient interface to Fortran.
20896 @node Interfacing to non-GNAT Ada code
20897 @section Interfacing to non-GNAT Ada code
20899 It is possible to specify the convention @code{Ada} in a pragma
20900 @code{Import} or pragma @code{Export}.  However this refers to
20901 the calling conventions used by GNAT, which may or may not be
20902 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20903 compiler to allow interoperation.
20905 If arguments types are kept simple, and if the foreign compiler generally
20906 follows system calling conventions, then it may be possible to integrate
20907 files compiled by other Ada compilers, provided that the elaboration
20908 issues are adequately addressed (for example by eliminating the
20909 need for any load time elaboration).
20911 In particular, GNAT running on VMS is designed to
20912 be highly compatible with the DEC Ada 83 compiler, so this is one
20913 case in which it is possible to import foreign units of this type,
20914 provided that the data items passed are restricted to simple scalar
20915 values or simple record types without variants, or simple array
20916 types with fixed bounds.
20918 @node Specialized Needs Annexes
20919 @chapter Specialized Needs Annexes
20921 @noindent
20922 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20923 required in all implementations.  However, as described in this chapter,
20924 GNAT implements all of these annexes:
20926 @table @asis
20927 @item Systems Programming (Annex C)
20928 The Systems Programming Annex is fully implemented.
20930 @item Real-Time Systems (Annex D)
20931 The Real-Time Systems Annex is fully implemented.
20933 @item Distributed Systems (Annex E)
20934 Stub generation is fully implemented in the GNAT compiler.  In addition,
20935 a complete compatible PCS is available as part of the GLADE system,
20936 a separate product.  When the two
20937 products are used in conjunction, this annex is fully implemented.
20939 @item Information Systems (Annex F)
20940 The Information Systems annex is fully implemented.
20942 @item Numerics (Annex G)
20943 The Numerics Annex is fully implemented.
20945 @item Safety and Security / High-Integrity Systems (Annex H)
20946 The Safety and Security Annex (termed the High-Integrity Systems Annex
20947 in Ada 2005) is fully implemented.
20948 @end table
20950 @node Implementation of Specific Ada Features
20951 @chapter Implementation of Specific Ada Features
20953 @noindent
20954 This chapter describes the GNAT implementation of several Ada language
20955 facilities.
20957 @menu
20958 * Machine Code Insertions::
20959 * GNAT Implementation of Tasking::
20960 * GNAT Implementation of Shared Passive Packages::
20961 * Code Generation for Array Aggregates::
20962 * The Size of Discriminated Records with Default Discriminants::
20963 * Strict Conformance to the Ada Reference Manual::
20964 @end menu
20966 @node Machine Code Insertions
20967 @section Machine Code Insertions
20968 @cindex Machine Code insertions
20970 @noindent
20971 Package @code{Machine_Code} provides machine code support as described
20972 in the Ada Reference Manual in two separate forms:
20973 @itemize @bullet
20974 @item
20975 Machine code statements, consisting of qualified expressions that
20976 fit the requirements of RM section 13.8.
20977 @item
20978 An intrinsic callable procedure, providing an alternative mechanism of
20979 including machine instructions in a subprogram.
20980 @end itemize
20982 @noindent
20983 The two features are similar, and both are closely related to the mechanism
20984 provided by the asm instruction in the GNU C compiler.  Full understanding
20985 and use of the facilities in this package requires understanding the asm
20986 instruction, see @ref{Extended Asm,,, gcc, Using the GNU Compiler
20987 Collection (GCC)}.
20989 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20990 semantic restrictions and effects as described below.  Both are provided so
20991 that the procedure call can be used as a statement, and the function call
20992 can be used to form a code_statement.
20994 Consider this C @code{asm} instruction:
20995 @smallexample
20996    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20997 @end smallexample
20999 @noindent
21000 The equivalent can be written for GNAT as:
21002 @smallexample @c ada
21003 Asm ("fsinx %1 %0",
21004      My_Float'Asm_Output ("=f", result),
21005      My_Float'Asm_Input  ("f",  angle));
21006 @end smallexample
21008 @noindent
21009 The first argument to @code{Asm} is the assembler template, and is
21010 identical to what is used in GNU C@.  This string must be a static
21011 expression.  The second argument is the output operand list.  It is
21012 either a single @code{Asm_Output} attribute reference, or a list of such
21013 references enclosed in parentheses (technically an array aggregate of
21014 such references).
21016 The @code{Asm_Output} attribute denotes a function that takes two
21017 parameters.  The first is a string, the second is the name of a variable
21018 of the type designated by the attribute prefix.  The first (string)
21019 argument is required to be a static expression and designates the
21020 constraint (@pxref{Constraints,,, gcc, Using the GNU Compiler
21021 Collection (GCC)})
21022 for the parameter (e.g.@: what kind of register is required).  The second
21023 argument is the variable to be written or updated with the
21024 result.  The possible values for constraint are the same as those used in
21025 the RTL, and are dependent on the configuration file used to build the
21026 GCC back end.  If there are no output operands, then this argument may
21027 either be omitted, or explicitly given as @code{No_Output_Operands}.
21028 No support is provided for GNU C's symbolic names for output parameters.
21030 The second argument of @code{@var{my_float}'Asm_Output} functions as
21031 though it were an @code{out} parameter, which is a little curious, but
21032 all names have the form of expressions, so there is no syntactic
21033 irregularity, even though normally functions would not be permitted
21034 @code{out} parameters.  The third argument is the list of input
21035 operands.  It is either a single @code{Asm_Input} attribute reference, or
21036 a list of such references enclosed in parentheses (technically an array
21037 aggregate of such references).
21039 The @code{Asm_Input} attribute denotes a function that takes two
21040 parameters.  The first is a string, the second is an expression of the
21041 type designated by the prefix.  The first (string) argument is required
21042 to be a static expression, and is the constraint for the parameter,
21043 (e.g.@: what kind of register is required).  The second argument is the
21044 value to be used as the input argument.  The possible values for the
21045 constraint are the same as those used in the RTL, and are dependent on
21046 the configuration file used to built the GCC back end.
21047 No support is provided for GNU C's symbolic names for input parameters.
21049 If there are no input operands, this argument may either be omitted, or
21050 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
21051 present in the above example, is a list of register names, called the
21052 @dfn{clobber} argument.  This argument, if given, must be a static string
21053 expression, and is a space or comma separated list of names of registers
21054 that must be considered destroyed as a result of the @code{Asm} call.  If
21055 this argument is the null string (the default value), then the code
21056 generator assumes that no additional registers are destroyed.
21057 In addition to registers, the special clobbers @code{memory} and
21058 @code{cc} as described in the GNU C docs are both supported.
21060 The fifth argument, not present in the above example, called the
21061 @dfn{volatile} argument, is by default @code{False}.  It can be set to
21062 the literal value @code{True} to indicate to the code generator that all
21063 optimizations with respect to the instruction specified should be
21064 suppressed, and in particular an instruction that has outputs
21065 will still be generated, even if none of the outputs are
21066 used.  @xref{Volatile,,,
21067 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
21068 Generally it is strongly advisable to use Volatile for any ASM statement
21069 that is missing either input or output operands or to avoid unwanted
21070 optimizations. A warning is generated if this advice is not followed.
21072 No support is provided for GNU C's @code{asm goto} feature.
21074 The @code{Asm} subprograms may be used in two ways.  First the procedure
21075 forms can be used anywhere a procedure call would be valid, and
21076 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
21077 be used to intersperse machine instructions with other Ada statements.
21078 Second, the function forms, which return a dummy value of the limited
21079 private type @code{Asm_Insn}, can be used in code statements, and indeed
21080 this is the only context where such calls are allowed.  Code statements
21081 appear as aggregates of the form:
21083 @smallexample @c ada
21084 Asm_Insn'(Asm (@dots{}));
21085 Asm_Insn'(Asm_Volatile (@dots{}));
21086 @end smallexample
21088 @noindent
21089 In accordance with RM rules, such code statements are allowed only
21090 within subprograms whose entire body consists of such statements.  It is
21091 not permissible to intermix such statements with other Ada statements.
21093 Typically the form using intrinsic procedure calls is more convenient
21094 and more flexible.  The code statement form is provided to meet the RM
21095 suggestion that such a facility should be made available.  The following
21096 is the exact syntax of the call to @code{Asm}. As usual, if named notation
21097 is used, the arguments may be given in arbitrary order, following the
21098 normal rules for use of positional and named arguments:
21100 @smallexample
21101 ASM_CALL ::= Asm (
21102                  [Template =>] static_string_EXPRESSION
21103                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
21104                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
21105                [,[Clobber  =>] static_string_EXPRESSION ]
21106                [,[Volatile =>] static_boolean_EXPRESSION] )
21108 OUTPUT_OPERAND_LIST ::=
21109   [PREFIX.]No_Output_Operands
21110 | OUTPUT_OPERAND_ATTRIBUTE
21111 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
21113 OUTPUT_OPERAND_ATTRIBUTE ::=
21114   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
21116 INPUT_OPERAND_LIST ::=
21117   [PREFIX.]No_Input_Operands
21118 | INPUT_OPERAND_ATTRIBUTE
21119 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
21121 INPUT_OPERAND_ATTRIBUTE ::=
21122   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
21123 @end smallexample
21125 @noindent
21126 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
21127 are declared in the package @code{Machine_Code} and must be referenced
21128 according to normal visibility rules. In particular if there is no
21129 @code{use} clause for this package, then appropriate package name
21130 qualification is required.
21132 @node GNAT Implementation of Tasking
21133 @section GNAT Implementation of Tasking
21135 @noindent
21136 This chapter outlines the basic GNAT approach to tasking (in particular,
21137 a multi-layered library for portability) and discusses issues related
21138 to compliance with the Real-Time Systems Annex.
21140 @menu
21141 * Mapping Ada Tasks onto the Underlying Kernel Threads::
21142 * Ensuring Compliance with the Real-Time Annex::
21143 @end menu
21145 @node Mapping Ada Tasks onto the Underlying Kernel Threads
21146 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
21148 @noindent
21149 GNAT's run-time support comprises two layers:
21151 @itemize @bullet
21152 @item GNARL (GNAT Run-time Layer)
21153 @item GNULL (GNAT Low-level Library)
21154 @end itemize
21156 @noindent
21157 In GNAT, Ada's tasking services rely on a platform and OS independent
21158 layer known as GNARL@.  This code is responsible for implementing the
21159 correct semantics of Ada's task creation, rendezvous, protected
21160 operations etc.
21162 GNARL decomposes Ada's tasking semantics into simpler lower level
21163 operations such as create a thread, set the priority of a thread,
21164 yield, create a lock, lock/unlock, etc.  The spec for these low-level
21165 operations constitutes GNULLI, the GNULL Interface.  This interface is
21166 directly inspired from the POSIX real-time API@.
21168 If the underlying executive or OS implements the POSIX standard
21169 faithfully, the GNULL Interface maps as is to the services offered by
21170 the underlying kernel.  Otherwise, some target dependent glue code maps
21171 the services offered by the underlying kernel to the semantics expected
21172 by GNARL@.
21174 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
21175 key point is that each Ada task is mapped on a thread in the underlying
21176 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
21178 In addition Ada task priorities map onto the underlying thread priorities.
21179 Mapping Ada tasks onto the underlying kernel threads has several advantages:
21181 @itemize @bullet
21182 @item
21183 The underlying scheduler is used to schedule the Ada tasks.  This
21184 makes Ada tasks as efficient as kernel threads from a scheduling
21185 standpoint.
21187 @item
21188 Interaction with code written in C containing threads is eased
21189 since at the lowest level Ada tasks and C threads map onto the same
21190 underlying kernel concept.
21192 @item
21193 When an Ada task is blocked during I/O the remaining Ada tasks are
21194 able to proceed.
21196 @item
21197 On multiprocessor systems Ada tasks can execute in parallel.
21198 @end itemize
21200 @noindent
21201 Some threads libraries offer a mechanism to fork a new process, with the
21202 child process duplicating the threads from the parent.
21203 GNAT does not
21204 support this functionality when the parent contains more than one task.
21205 @cindex Forking a new process
21207 @node Ensuring Compliance with the Real-Time Annex
21208 @subsection Ensuring Compliance with the Real-Time Annex
21209 @cindex Real-Time Systems Annex compliance
21211 @noindent
21212 Although mapping Ada tasks onto
21213 the underlying threads has significant advantages, it does create some
21214 complications when it comes to respecting the scheduling semantics
21215 specified in the real-time annex (Annex D).
21217 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
21218 scheduling policy states:
21220 @quotation
21221 @emph{When the active priority of a ready task that is not running
21222 changes, or the setting of its base priority takes effect, the
21223 task is removed from the ready queue for its old active priority
21224 and is added at the tail of the ready queue for its new active
21225 priority, except in the case where the active priority is lowered
21226 due to the loss of inherited priority, in which case the task is
21227 added at the head of the ready queue for its new active priority.}
21228 @end quotation
21230 @noindent
21231 While most kernels do put tasks at the end of the priority queue when
21232 a task changes its priority, (which respects the main
21233 FIFO_Within_Priorities requirement), almost none keep a thread at the
21234 beginning of its priority queue when its priority drops from the loss
21235 of inherited priority.
21237 As a result most vendors have provided incomplete Annex D implementations.
21239 The GNAT run-time, has a nice cooperative solution to this problem
21240 which ensures that accurate FIFO_Within_Priorities semantics are
21241 respected.
21243 The principle is as follows.  When an Ada task T is about to start
21244 running, it checks whether some other Ada task R with the same
21245 priority as T has been suspended due to the loss of priority
21246 inheritance.  If this is the case, T yields and is placed at the end of
21247 its priority queue.  When R arrives at the front of the queue it
21248 executes.
21250 Note that this simple scheme preserves the relative order of the tasks
21251 that were ready to execute in the priority queue where R has been
21252 placed at the end.
21254 @node GNAT Implementation of Shared Passive Packages
21255 @section GNAT Implementation of Shared Passive Packages
21256 @cindex Shared passive packages
21258 @noindent
21259 GNAT fully implements the pragma @code{Shared_Passive} for
21260 @cindex pragma @code{Shared_Passive}
21261 the purpose of designating shared passive packages.
21262 This allows the use of passive partitions in the
21263 context described in the Ada Reference Manual; i.e., for communication
21264 between separate partitions of a distributed application using the
21265 features in Annex E.
21266 @cindex Annex E
21267 @cindex Distribution Systems Annex
21269 However, the implementation approach used by GNAT provides for more
21270 extensive usage as follows:
21272 @table @emph
21273 @item Communication between separate programs
21275 This allows separate programs to access the data in passive
21276 partitions, using protected objects for synchronization where
21277 needed. The only requirement is that the two programs have a
21278 common shared file system. It is even possible for programs
21279 running on different machines with different architectures
21280 (e.g.@: different endianness) to communicate via the data in
21281 a passive partition.
21283 @item Persistence between program runs
21285 The data in a passive package can persist from one run of a
21286 program to another, so that a later program sees the final
21287 values stored by a previous run of the same program.
21289 @end table
21291 @noindent
21292 The implementation approach used is to store the data in files. A
21293 separate stream file is created for each object in the package, and
21294 an access to an object causes the corresponding file to be read or
21295 written.
21297 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
21298 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
21299 set to the directory to be used for these files.
21300 The files in this directory
21301 have names that correspond to their fully qualified names. For
21302 example, if we have the package
21304 @smallexample @c ada
21305 package X is
21306   pragma Shared_Passive (X);
21307   Y : Integer;
21308   Z : Float;
21309 end X;
21310 @end smallexample
21312 @noindent
21313 and the environment variable is set to @code{/stemp/}, then the files created
21314 will have the names:
21316 @smallexample
21317 /stemp/x.y
21318 /stemp/x.z
21319 @end smallexample
21321 @noindent
21322 These files are created when a value is initially written to the object, and
21323 the files are retained until manually deleted. This provides the persistence
21324 semantics. If no file exists, it means that no partition has assigned a value
21325 to the variable; in this case the initial value declared in the package
21326 will be used. This model ensures that there are no issues in synchronizing
21327 the elaboration process, since elaboration of passive packages elaborates the
21328 initial values, but does not create the files.
21330 The files are written using normal @code{Stream_IO} access.
21331 If you want to be able
21332 to communicate between programs or partitions running on different
21333 architectures, then you should use the XDR versions of the stream attribute
21334 routines, since these are architecture independent.
21336 If active synchronization is required for access to the variables in the
21337 shared passive package, then as described in the Ada Reference Manual, the
21338 package may contain protected objects used for this purpose. In this case
21339 a lock file (whose name is @file{___lock} (three underscores)
21340 is created in the shared memory directory.
21341 @cindex @file{___lock} file (for shared passive packages)
21342 This is used to provide the required locking
21343 semantics for proper protected object synchronization.
21345 As of January 2003, GNAT supports shared passive packages on all platforms
21346 except for OpenVMS.
21348 @node Code Generation for Array Aggregates
21349 @section Code Generation for Array Aggregates
21351 @menu
21352 * Static constant aggregates with static bounds::
21353 * Constant aggregates with unconstrained nominal types::
21354 * Aggregates with static bounds::
21355 * Aggregates with non-static bounds::
21356 * Aggregates in assignment statements::
21357 @end menu
21359 @noindent
21360 Aggregates have a rich syntax and allow the user to specify the values of
21361 complex data structures by means of a single construct.  As a result, the
21362 code generated for aggregates can be quite complex and involve loops, case
21363 statements and multiple assignments.  In the simplest cases, however, the
21364 compiler will recognize aggregates whose components and constraints are
21365 fully static, and in those cases the compiler will generate little or no
21366 executable code.  The following is an outline of the code that GNAT generates
21367 for various aggregate constructs.  For further details, you will find it
21368 useful to examine the output produced by the -gnatG flag to see the expanded
21369 source that is input to the code generator.  You may also want to examine
21370 the assembly code generated at various levels of optimization.
21372 The code generated for aggregates depends on the context, the component values,
21373 and the type.  In the context of an object declaration the code generated is
21374 generally simpler than in the case of an assignment.  As a general rule, static
21375 component values and static subtypes also lead to simpler code.
21377 @node Static constant aggregates with static bounds
21378 @subsection Static constant aggregates with static bounds
21380 @noindent
21381 For the declarations:
21382 @smallexample @c ada
21383     type One_Dim is array (1..10) of integer;
21384     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
21385 @end smallexample
21387 @noindent
21388 GNAT generates no executable code: the constant ar0 is placed in static memory.
21389 The same is true for constant aggregates with named associations:
21391 @smallexample @c ada
21392     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
21393     Cr3 : constant One_Dim := (others => 7777);
21394 @end smallexample
21396 @noindent
21397 The same is true for multidimensional constant arrays such as:
21399 @smallexample @c ada
21400     type two_dim is array (1..3, 1..3) of integer;
21401     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
21402 @end smallexample
21404 @noindent
21405 The same is true for arrays of one-dimensional arrays: the following are
21406 static:
21408 @smallexample @c ada
21409 type ar1b  is array (1..3) of boolean;
21410 type ar_ar is array (1..3) of ar1b;
21411 None  : constant ar1b := (others => false);     --  fully static
21412 None2 : constant ar_ar := (1..3 => None);       --  fully static
21413 @end smallexample
21415 @noindent
21416 However, for multidimensional aggregates with named associations, GNAT will
21417 generate assignments and loops, even if all associations are static.  The
21418 following two declarations generate a loop for the first dimension, and
21419 individual component assignments for the second dimension:
21421 @smallexample @c ada
21422 Zero1: constant two_dim := (1..3 => (1..3 => 0));
21423 Zero2: constant two_dim := (others => (others => 0));
21424 @end smallexample
21426 @node Constant aggregates with unconstrained nominal types
21427 @subsection Constant aggregates with unconstrained nominal types
21429 @noindent
21430 In such cases the aggregate itself establishes the subtype, so that
21431 associations with @code{others} cannot be used.  GNAT determines the
21432 bounds for the actual subtype of the aggregate, and allocates the
21433 aggregate statically as well.  No code is generated for the following:
21435 @smallexample @c ada
21436     type One_Unc is array (natural range <>) of integer;
21437     Cr_Unc : constant One_Unc := (12,24,36);
21438 @end smallexample
21440 @node Aggregates with static bounds
21441 @subsection Aggregates with static bounds
21443 @noindent
21444 In all previous examples the aggregate was the initial (and immutable) value
21445 of a constant.  If the aggregate initializes a variable, then code is generated
21446 for it as a combination of individual assignments and loops over the target
21447 object.  The declarations
21449 @smallexample @c ada
21450        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
21451        Cr_Var2 : One_Dim := (others > -1);
21452 @end smallexample
21454 @noindent
21455 generate the equivalent of
21457 @smallexample @c ada
21458        Cr_Var1 (1) := 2;
21459        Cr_Var1 (2) := 3;
21460        Cr_Var1 (3) := 5;
21461        Cr_Var1 (4) := 11;
21463        for I in Cr_Var2'range loop
21464           Cr_Var2 (I) := -1;
21465        end loop;
21466 @end smallexample
21468 @node Aggregates with non-static bounds
21469 @subsection Aggregates with non-static bounds
21471 @noindent
21472 If the bounds of the aggregate are not statically compatible with the bounds
21473 of the nominal subtype  of the target, then constraint checks have to be
21474 generated on the bounds.  For a multidimensional array, constraint checks may
21475 have to be applied to sub-arrays individually, if they do not have statically
21476 compatible subtypes.
21478 @node Aggregates in assignment statements
21479 @subsection Aggregates in assignment statements
21481 @noindent
21482 In general, aggregate assignment requires the construction of a temporary,
21483 and a copy from the temporary to the target of the assignment.  This is because
21484 it is not always possible to convert the assignment into a series of individual
21485 component assignments.  For example, consider the simple case:
21487 @smallexample @c ada
21488         A := (A(2), A(1));
21489 @end smallexample
21491 @noindent
21492 This cannot be converted into:
21494 @smallexample @c ada
21495         A(1) := A(2);
21496         A(2) := A(1);
21497 @end smallexample
21499 @noindent
21500 So the aggregate has to be built first in a separate location, and then
21501 copied into the target.  GNAT recognizes simple cases where this intermediate
21502 step is not required, and the assignments can be performed in place, directly
21503 into the target.  The following sufficient criteria are applied:
21505 @itemize @bullet
21506 @item
21507 The bounds of the aggregate are static, and the associations are static.
21508 @item
21509 The components of the aggregate are static constants, names of
21510 simple variables that are not renamings, or expressions not involving
21511 indexed components whose operands obey these rules.
21512 @end itemize
21514 @noindent
21515 If any of these conditions are violated, the aggregate will be built in
21516 a temporary (created either by the front-end or the code generator) and then
21517 that temporary will be copied onto the target.
21519 @node The Size of Discriminated Records with Default Discriminants
21520 @section The Size of Discriminated Records with Default Discriminants
21522 @noindent
21523 If a discriminated type @code{T} has discriminants with default values, it is
21524 possible to declare an object of this type without providing an explicit
21525 constraint:
21527 @smallexample @c ada
21528 @group
21529 type Size is range 1..100;
21531 type Rec (D : Size := 15) is record
21532    Name : String (1..D);
21533 end T;
21535 Word : Rec;
21536 @end group
21537 @end smallexample
21539 @noindent
21540 Such an object is said to be @emph{unconstrained}.
21541 The discriminant of the object
21542 can be modified by a full assignment to the object, as long as it preserves the
21543 relation between the value of the discriminant, and the value of the components
21544 that depend on it:
21546 @smallexample @c ada
21547 @group
21548 Word := (3, "yes");
21550 Word := (5, "maybe");
21552 Word := (5, "no"); -- raises Constraint_Error
21553 @end group
21554 @end smallexample
21556 @noindent
21557 In order to support this behavior efficiently, an unconstrained object is
21558 given the maximum size that any value of the type requires. In the case
21559 above, @code{Word} has storage for the discriminant and for
21560 a @code{String} of length 100.
21561 It is important to note that unconstrained objects do not require dynamic
21562 allocation. It would be an improper implementation to place on the heap those
21563 components whose size depends on discriminants. (This improper implementation
21564 was used by some Ada83 compilers, where the @code{Name} component above
21565 would have
21566 been stored as a pointer to a dynamic string). Following the principle that
21567 dynamic storage management should never be introduced implicitly,
21568 an Ada compiler should reserve the full size for an unconstrained declared
21569 object, and place it on the stack.
21571 This maximum size approach
21572 has been a source of surprise to some users, who expect the default
21573 values of the discriminants to determine the size reserved for an
21574 unconstrained object: ``If the default is 15, why should the object occupy
21575 a larger size?''
21576 The answer, of course, is that the discriminant may be later modified,
21577 and its full range of values must be taken into account. This is why the
21578 declaration:
21580 @smallexample
21581 @group
21582 type Rec (D : Positive := 15) is record
21583    Name : String (1..D);
21584 end record;
21586 Too_Large : Rec;
21587 @end group
21588 @end smallexample
21590 @noindent
21591 is flagged by the compiler with a warning:
21592 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21593 because the required size includes @code{Positive'Last}
21594 bytes. As the first example indicates, the proper approach is to declare an
21595 index type of ``reasonable'' range so that unconstrained objects are not too
21596 large.
21598 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21599 created in the heap by means of an allocator, then it is @emph{not}
21600 unconstrained:
21601 it is constrained by the default values of the discriminants, and those values
21602 cannot be modified by full assignment. This is because in the presence of
21603 aliasing all views of the object (which may be manipulated by different tasks,
21604 say) must be consistent, so it is imperative that the object, once created,
21605 remain invariant.
21607 @node Strict Conformance to the Ada Reference Manual
21608 @section Strict Conformance to the Ada Reference Manual
21610 @noindent
21611 The dynamic semantics defined by the Ada Reference Manual impose a set of
21612 run-time checks to be generated. By default, the GNAT compiler will insert many
21613 run-time checks into the compiled code, including most of those required by the
21614 Ada Reference Manual. However, there are three checks that are not enabled
21615 in the default mode for efficiency reasons: arithmetic overflow checking for
21616 integer operations (including division by zero), checks for access before
21617 elaboration on subprogram calls, and stack overflow checking (most operating
21618 systems do not perform this check by default).
21620 Strict conformance to the Ada Reference Manual can be achieved by adding
21621 three compiler options for overflow checking for integer operations
21622 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21623 calls and generic instantiations (@option{-gnatE}), and stack overflow
21624 checking (@option{-fstack-check}).
21626 Note that the result of a floating point arithmetic operation in overflow and
21627 invalid situations, when the @code{Machine_Overflows} attribute of the result
21628 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21629 case for machines compliant with the IEEE floating-point standard, but on
21630 machines that are not fully compliant with this standard, such as Alpha, the
21631 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21632 behavior (although at the cost of a significant performance penalty), so
21633 infinite and NaN values are properly generated.
21636 @node Implementation of Ada 2012 Features
21637 @chapter Implementation of Ada 2012 Features
21638 @cindex Ada 2012 implementation status
21640 This chapter contains a complete list of Ada 2012 features that have been
21641 implemented as of GNAT version 6.4. Generally, these features are only
21642 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21643 @cindex @option{-gnat12} option
21644 or if the configuration pragma @code{Ada_2012} is used.
21645 @cindex pragma @code{Ada_2012}
21646 @cindex configuration pragma @code{Ada_2012}
21647 @cindex @code{Ada_2012} configuration pragma
21648 However, new pragmas, attributes, and restrictions are
21649 unconditionally available, since the Ada 95 standard allows the addition of
21650 new pragmas, attributes, and restrictions (there are exceptions, which are
21651 documented in the individual descriptions), and also certain packages
21652 were made available in earlier versions of Ada.
21654 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21655 This date shows the implementation date of the feature. Any wavefront
21656 subsequent to this date will contain the indicated feature, as will any
21657 subsequent releases. A date of 0000-00-00 means that GNAT has always
21658 implemented the feature, or implemented it as soon as it appeared as a
21659 binding interpretation.
21661 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21662 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21663 The features are ordered based on the relevant sections of the Ada
21664 Reference Manual (``RM'').  When a given AI relates to multiple points
21665 in the RM, the earliest is used.
21667 A complete description of the AIs may be found in
21668 @url{www.ada-auth.org/ai05-summary.html}.
21670 @itemize @bullet
21672 @item
21673 @emph{AI-0176 Quantified expressions (2010-09-29)}
21674 @cindex AI-0176 (Ada 2012 feature)
21676 @noindent
21677   Both universally and existentially quantified expressions are implemented.
21678   They use the new syntax for iterators proposed in AI05-139-2, as well as
21679   the standard Ada loop syntax.
21681 @noindent
21682   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
21684 @item
21685 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21686 @cindex AI-0079 (Ada 2012 feature)
21688 @noindent
21689   Wide characters in the unicode category @i{other_format} are now allowed in
21690   source programs between tokens, but not within a token such as an identifier.
21692 @noindent
21693   RM References:  2.01 (4/2)   2.02 (7)
21695 @item
21696 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21697 @cindex AI-0091 (Ada 2012 feature)
21699 @noindent
21700   Wide characters in the unicode category @i{other_format} are not permitted
21701   within  an identifier, since this can be a security problem. The error
21702   message for this case has been improved to be more specific, but GNAT has
21703   never allowed such characters to appear in identifiers.
21705 @noindent
21706   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)
21708 @item
21709 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
21710 @cindex AI-0100 (Ada 2012 feature)
21712 @noindent
21713   This AI is an earlier version of AI-163. It simplifies the rules
21714   for legal placement of pragmas. In the case of lists that allow pragmas, if
21715   the list may have no elements, then the list may consist solely of pragmas.
21717 @noindent
21718   RM References:  2.08 (7)
21720 @item
21721 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21722 @cindex AI-0163 (Ada 2012 feature)
21724 @noindent
21725   A statement sequence may be composed entirely of pragmas. It is no longer
21726   necessary to add a dummy @code{null} statement to make the sequence legal.
21728 @noindent
21729   RM References:  2.08 (7)   2.08 (16)
21732 @item
21733 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21734 @cindex AI-0080 (Ada 2012 feature)
21736 @noindent
21737   This is an editorial change only, described as non-testable in the AI.
21739 @noindent
21740   RM References:  3.01 (7)
21743 @item
21744 @emph{AI-0183 Aspect specifications (2010-08-16)}
21745 @cindex AI-0183 (Ada 2012 feature)
21747 @noindent
21748   Aspect specifications have been fully implemented except for pre and post-
21749   conditions, and type invariants, which have their own separate AI's. All
21750   forms of declarations listed in the AI are supported. The following is a
21751   list of the aspects supported (with GNAT implementation aspects marked)
21753 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21754 @item @code{Ada_2005} @tab                      -- GNAT
21755 @item @code{Ada_2012} @tab                      -- GNAT
21756 @item @code{Address} @tab
21757 @item @code{Alignment} @tab
21758 @item @code{Atomic} @tab
21759 @item @code{Atomic_Components} @tab
21760 @item @code{Bit_Order} @tab
21761 @item @code{Component_Size} @tab
21762 @item @code{Contract_Cases} @tab                -- GNAT
21763 @item @code{Discard_Names} @tab
21764 @item @code{External_Tag} @tab
21765 @item @code{Favor_Top_Level} @tab               -- GNAT
21766 @item @code{Inline} @tab
21767 @item @code{Inline_Always} @tab                 -- GNAT
21768 @item @code{Invariant} @tab                     -- GNAT
21769 @item @code{Machine_Radix} @tab
21770 @item @code{No_Return} @tab
21771 @item @code{Object_Size} @tab                   -- GNAT
21772 @item @code{Pack} @tab
21773 @item @code{Persistent_BSS} @tab                -- GNAT
21774 @item @code{Post} @tab
21775 @item @code{Pre} @tab
21776 @item @code{Predicate} @tab
21777 @item @code{Preelaborable_Initialization} @tab
21778 @item @code{Pure_Function} @tab                 -- GNAT
21779 @item @code{Remote_Access_Type} @tab            -- GNAT
21780 @item @code{Shared} @tab                        -- GNAT
21781 @item @code{Size} @tab
21782 @item @code{Storage_Pool} @tab
21783 @item @code{Storage_Size} @tab
21784 @item @code{Stream_Size} @tab
21785 @item @code{Suppress} @tab
21786 @item @code{Suppress_Debug_Info} @tab           -- GNAT
21787 @item @code{Test_Case} @tab                     -- GNAT
21788 @item @code{Thread_Local_Storage} @tab          -- GNAT
21789 @item @code{Type_Invariant} @tab
21790 @item @code{Unchecked_Union} @tab
21791 @item @code{Universal_Aliasing} @tab            -- GNAT
21792 @item @code{Unmodified} @tab                    -- GNAT
21793 @item @code{Unreferenced} @tab                  -- GNAT
21794 @item @code{Unreferenced_Objects} @tab          -- GNAT
21795 @item @code{Unsuppress} @tab
21796 @item @code{Value_Size} @tab                    -- GNAT
21797 @item @code{Volatile} @tab
21798 @item @code{Volatile_Components}
21799 @item @code{Warnings} @tab                      -- GNAT
21800 @end multitable
21802 @noindent
21803   Note that for aspects with an expression, e.g. @code{Size}, the expression is
21804   treated like a default expression (visibility is analyzed at the point of
21805   occurrence of the aspect, but evaluation of the expression occurs at the
21806   freeze point of the entity involved).
21808 @noindent
21809   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
21810   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
21811   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
21812   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
21813   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
21814   13.03.01 (0)
21817 @item
21818 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21819 @cindex AI-0128 (Ada 2012 feature)
21821 @noindent
21822   If an equality operator ("=") is declared for a type, then the implicitly
21823   declared inequality operator ("/=") is a primitive operation of the type.
21824   This is the only reasonable interpretation, and is the one always implemented
21825   by GNAT, but the RM was not entirely clear in making this point.
21827 @noindent
21828   RM References:  3.02.03 (6)   6.06 (6)
21830 @item
21831 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21832 @cindex AI-0003 (Ada 2012 feature)
21834 @noindent
21835    In Ada 2012, a qualified expression is considered to be syntactically a name,
21836    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21837    useful in disambiguating some cases of overloading.
21839 @noindent
21840   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
21841   5.04 (7)
21843 @item
21844 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21845 @cindex AI-0120 (Ada 2012 feature)
21847 @noindent
21848   This is an RM editorial change only. The section that lists objects that are
21849   constant failed to include the current instance of a protected object
21850   within a protected function. This has always been treated as a constant
21851   in GNAT.
21853 @noindent
21854   RM References:  3.03 (21)
21856 @item
21857 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21858 @cindex AI-0008 (Ada 2012 feature)
21860 @noindent
21861   The wording in the RM implied that if you have a general access to a
21862   constrained object, it could be used to modify the discriminants. This was
21863   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21864   has always done so in this situation.
21866 @noindent
21867   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
21870 @item
21871 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21872 @cindex AI-0093 (Ada 2012 feature)
21874 @noindent
21875   This is an editorial change only, to make more widespread use of the Ada 2012
21876   ``immutably limited''.
21878 @noindent
21879   RM References:  3.03 (23.4/3)
21883 @item
21884 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21885 @cindex AI-0096 (Ada 2012 feature)
21887 @noindent
21888   In general it is illegal for a type derived from a formal limited type to be
21889   nonlimited.  This AI makes an exception to this rule: derivation is legal
21890   if it appears in the private part of the generic, and the formal type is not
21891   tagged. If the type is tagged, the legality check must be applied to the
21892   private part of the package.
21894 @noindent
21895   RM References:  3.04 (5.1/2)   6.02 (7)
21898 @item
21899 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21900 @cindex AI-0181 (Ada 2012 feature)
21902 @noindent
21903   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21904   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21905   @code{Image} and @code{Value} attributes for the character types. Strictly
21906   speaking this is an inconsistency with Ada 95, but in practice the use of
21907   these attributes is so obscure that it will not cause problems.
21909 @noindent
21910   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
21913 @item
21914 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21915 @cindex AI-0182 (Ada 2012 feature)
21917 @noindent
21918   This AI allows @code{Character'Value} to accept the string @code{'?'} where
21919   @code{?} is any character including non-graphic control characters. GNAT has
21920   always accepted such strings. It also allows strings such as
21921   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21922   permission and raises @code{Constraint_Error}, as is certainly still
21923   permitted.
21925 @noindent
21926   RM References:  3.05 (56/2)
21929 @item
21930 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21931 @cindex AI-0214 (Ada 2012 feature)
21933 @noindent
21934   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21935   to have default expressions by allowing them when the type is limited. It
21936   is often useful to define a default value for a discriminant even though
21937   it can't be changed by assignment.
21939 @noindent
21940   RM References:  3.07 (9.1/2)   3.07.02 (3)
21943 @item
21944 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21945 @cindex AI-0102 (Ada 2012 feature)
21947 @noindent
21948   It is illegal to assign an anonymous access constant to an anonymous access
21949   variable. The RM did not have a clear rule to prevent this, but GNAT has
21950   always generated an error for this usage.
21952 @noindent
21953   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
21956 @item
21957 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21958 @cindex AI-0158 (Ada 2012 feature)
21960 @noindent
21961   This AI extends the syntax of membership tests to simplify complex conditions
21962   that can be expressed as membership in a subset of values of any type. It
21963   introduces syntax for a list of expressions that may be used in loop contexts
21964   as well.
21966 @noindent
21967   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
21970 @item
21971 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21972 @cindex AI-0173 (Ada 2012 feature)
21974 @noindent
21975   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21976   with the tag of an abstract type, and @code{False} otherwise.
21978 @noindent
21979   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
21983 @item
21984 @emph{AI-0076 function with controlling result (0000-00-00)}
21985 @cindex AI-0076 (Ada 2012 feature)
21987 @noindent
21988   This is an editorial change only. The RM defines calls with controlling
21989   results, but uses the term ``function with controlling result'' without an
21990   explicit definition.
21992 @noindent
21993   RM References:  3.09.02 (2/2)
21996 @item
21997 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21998 @cindex AI-0126 (Ada 2012 feature)
22000 @noindent
22001   This AI clarifies dispatching rules, and simply confirms that dispatching
22002   executes the operation of the parent type when there is no explicitly or
22003   implicitly declared operation for the descendant type. This has always been
22004   the case in all versions of GNAT.
22006 @noindent
22007   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
22010 @item
22011 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
22012 @cindex AI-0097 (Ada 2012 feature)
22014 @noindent
22015   The RM as written implied that in some cases it was possible to create an
22016   object of an abstract type, by having an abstract extension inherit a non-
22017   abstract constructor from its parent type. This mistake has been corrected
22018   in GNAT and in the RM, and this construct is now illegal.
22020 @noindent
22021   RM References:  3.09.03 (4/2)
22024 @item
22025 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
22026 @cindex AI-0203 (Ada 2012 feature)
22028 @noindent
22029   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
22030   permitted such usage.
22032 @noindent
22033   RM References:  3.09.03 (8/3)
22036 @item
22037 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
22038 @cindex AI-0198 (Ada 2012 feature)
22040 @noindent
22041   This AI resolves a conflict between two rules involving inherited abstract
22042   operations and predefined operators. If a derived numeric type inherits
22043   an abstract operator, it overrides the predefined one. This interpretation
22044   was always the one implemented in GNAT.
22046 @noindent
22047   RM References:  3.09.03 (4/3)
22049 @item
22050 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
22051 @cindex AI-0073 (Ada 2012 feature)
22053 @noindent
22054   This AI covers a number of issues regarding returning abstract types. In
22055   particular generic functions cannot have abstract result types or access
22056   result types designated an abstract type. There are some other cases which
22057   are detailed in the AI. Note that this binding interpretation has not been
22058   retrofitted to operate before Ada 2012 mode, since it caused a significant
22059   number of regressions.
22061 @noindent
22062   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
22065 @item
22066 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
22067 @cindex AI-0070 (Ada 2012 feature)
22069 @noindent
22070   This is an editorial change only, there are no testable consequences short of
22071   checking for the absence of generated code for an interface declaration.
22073 @noindent
22074   RM References:  3.09.04 (18/2)
22077 @item
22078 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
22079 @cindex AI-0208 (Ada 2012 feature)
22081 @noindent
22082   The wording in the Ada 2005 RM concerning characteristics of incomplete views
22083   was incorrect and implied that some programs intended to be legal were now
22084   illegal. GNAT had never considered such programs illegal, so it has always
22085   implemented the intent of this AI.
22087 @noindent
22088   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
22091 @item
22092 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
22093 @cindex AI-0162 (Ada 2012 feature)
22095 @noindent
22096   Incomplete types are made more useful by allowing them to be completed by
22097   private types and private extensions.
22099 @noindent
22100   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
22104 @item
22105 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
22106 @cindex AI-0098 (Ada 2012 feature)
22108 @noindent
22109   An unintentional omission in the RM implied some inconsistent restrictions on
22110   the use of anonymous access to subprogram values. These restrictions were not
22111   intentional, and have never been enforced by GNAT.
22113 @noindent
22114   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
22117 @item
22118 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
22119 @cindex AI-0199 (Ada 2012 feature)
22121 @noindent
22122   A choice list in a record aggregate can include several components of
22123   (distinct) anonymous access types as long as they have matching designated
22124   subtypes.
22126 @noindent
22127   RM References:  4.03.01 (16)
22130 @item
22131 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
22132 @cindex AI-0220 (Ada 2012 feature)
22134 @noindent
22135   This AI addresses a wording problem in the RM that appears to permit some
22136   complex cases of aggregates with non-static discriminants. GNAT has always
22137   implemented the intended semantics.
22139 @noindent
22140   RM References:  4.03.01 (17)
22142 @item
22143 @emph{AI-0147 Conditional expressions (2009-03-29)}
22144 @cindex AI-0147 (Ada 2012 feature)
22146 @noindent
22147   Conditional expressions are permitted. The form of such an expression is:
22149 @smallexample
22150     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
22151 @end smallexample
22153   The parentheses can be omitted in contexts where parentheses are present
22154   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
22155   clause is omitted, @b{else True} is assumed;
22156   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
22157   @emph{(A implies B)} in standard logic.
22159 @noindent
22160   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
22161   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
22164 @item
22165 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
22166 @cindex AI-0037 (Ada 2012 feature)
22168 @noindent
22169   This AI confirms that an association of the form @code{Indx => <>} in an
22170   array aggregate must raise @code{Constraint_Error} if @code{Indx}
22171   is out of range. The RM specified a range check on other associations, but
22172   not when the value of the association was defaulted. GNAT has always inserted
22173   a constraint check on the index value.
22175 @noindent
22176   RM References:  4.03.03 (29)
22179 @item
22180 @emph{AI-0123 Composability of equality (2010-04-13)}
22181 @cindex AI-0123 (Ada 2012 feature)
22183 @noindent
22184   Equality of untagged record composes, so that the predefined equality for a
22185   composite type that includes a component of some untagged record type
22186   @code{R} uses the equality operation of @code{R} (which may be user-defined
22187   or predefined). This makes the behavior of untagged records identical to that
22188   of tagged types in this respect.
22190   This change is an incompatibility with previous versions of Ada, but it
22191   corrects a non-uniformity that was often a source of confusion. Analysis of
22192   a large number of industrial programs indicates that in those rare cases
22193   where a composite type had an untagged record component with a user-defined
22194   equality, either there was no use of the composite equality, or else the code
22195   expected the same composability as for tagged types, and thus had a bug that
22196   would be fixed by this change.
22198 @noindent
22199   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
22200   8.05.04 (8)
22203 @item
22204 @emph{AI-0088 The value of exponentiation (0000-00-00)}
22205 @cindex AI-0088 (Ada 2012 feature)
22207 @noindent
22208   This AI clarifies the equivalence rule given for the dynamic semantics of
22209   exponentiation: the value of the operation can be obtained by repeated
22210   multiplication, but the operation can be implemented otherwise (for example
22211   using the familiar divide-by-two-and-square algorithm, even if this is less
22212   accurate), and does not imply repeated reads of a volatile base.
22214 @noindent
22215   RM References:  4.05.06 (11)
22217 @item
22218 @emph{AI-0188 Case expressions (2010-01-09)}
22219 @cindex AI-0188 (Ada 2012 feature)
22221 @noindent
22222   Case expressions are permitted. This allows use of constructs such as:
22223 @smallexample
22224   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
22225 @end smallexample
22227 @noindent
22228   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
22230 @item
22231 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
22232 @cindex AI-0104 (Ada 2012 feature)
22234 @noindent
22235   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
22236   @code{Constraint_Error} because the default value of the allocated object is
22237   @b{null}. This useless construct is illegal in Ada 2012.
22239 @noindent
22240   RM References:  4.08 (2)
22242 @item
22243 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
22244 @cindex AI-0157 (Ada 2012 feature)
22246 @noindent
22247   Allocation and Deallocation from an empty storage pool (i.e. allocation or
22248   deallocation of a pointer for which a static storage size clause of zero
22249   has been given) is now illegal and is detected as such. GNAT
22250   previously gave a warning but not an error.
22252 @noindent
22253   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
22255 @item
22256 @emph{AI-0179 Statement not required after label (2010-04-10)}
22257 @cindex AI-0179 (Ada 2012 feature)
22259 @noindent
22260   It is not necessary to have a statement following a label, so a label
22261   can appear at the end of a statement sequence without the need for putting a
22262   null statement afterwards, but it is not allowable to have only labels and
22263   no real statements in a statement sequence.
22265 @noindent
22266   RM References:  5.01 (2)
22269 @item
22270 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
22271 @cindex AI-139-2 (Ada 2012 feature)
22273 @noindent
22274   The new syntax for iterating over arrays and containers is now implemented.
22275   Iteration over containers is for now limited to read-only iterators. Only
22276   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
22278 @noindent
22279   RM References:  5.05
22281 @item
22282 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
22283 @cindex AI-0134 (Ada 2012 feature)
22285 @noindent
22286   For full conformance, the profiles of anonymous-access-to-subprogram
22287   parameters must match. GNAT has always enforced this rule.
22289 @noindent
22290   RM References:  6.03.01 (18)
22292 @item
22293 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
22294 @cindex AI-0207 (Ada 2012 feature)
22296 @noindent
22297   This AI confirms that access_to_constant indication must match for mode
22298   conformance. This was implemented in GNAT when the qualifier was originally
22299   introduced in Ada 2005.
22301 @noindent
22302   RM References:  6.03.01 (16/2)
22305 @item
22306 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
22307 @cindex AI-0046 (Ada 2012 feature)
22309 @noindent
22310   For full conformance, in the case of access parameters, the null exclusion
22311   must match (either both or neither must have @code{@b{not null}}).
22313 @noindent
22314   RM References:  6.03.02 (18)
22317 @item
22318 @emph{AI-0118 The association of parameter associations (0000-00-00)}
22319 @cindex AI-0118 (Ada 2012 feature)
22321 @noindent
22322   This AI clarifies the rules for named associations in subprogram calls and
22323   generic instantiations. The rules have been in place since Ada 83.
22325 @noindent
22326   RM References:  6.04.01 (2)   12.03 (9)
22329 @item
22330 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
22331 @cindex AI-0196 (Ada 2012 feature)
22333 @noindent
22334   Null exclusion checks are not made for @code{@b{out}} parameters when
22335   evaluating the actual parameters. GNAT has never generated these checks.
22337 @noindent
22338   RM References:  6.04.01 (13)
22340 @item
22341 @emph{AI-0015 Constant return objects (0000-00-00)}
22342 @cindex AI-0015 (Ada 2012 feature)
22344 @noindent
22345   The return object declared in an @i{extended_return_statement} may be
22346   declared constant. This was always intended, and GNAT has always allowed it.
22348 @noindent
22349   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
22350   6.05 (5.7/2)
22353 @item
22354 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
22355 @cindex AI-0032 (Ada 2012 feature)
22357 @noindent
22358   If a function returns a class-wide type, the object of an extended return
22359   statement can be declared with a specific type that is covered by the class-
22360   wide type. This has been implemented in GNAT since the introduction of
22361   extended returns. Note AI-0103 complements this AI by imposing matching
22362   rules for constrained return types.
22364 @noindent
22365   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
22366   6.05 (8/2)
22368 @item
22369 @emph{AI-0103 Static matching for extended return (2010-07-23)}
22370 @cindex AI-0103 (Ada 2012 feature)
22372 @noindent
22373   If the return subtype of a function is an elementary type or a constrained
22374   type, the subtype indication in an extended return statement must match
22375   statically this return subtype.
22377 @noindent
22378   RM References:  6.05 (5.2/2)
22381 @item
22382 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
22383 @cindex AI-0058 (Ada 2012 feature)
22385 @noindent
22386   The RM had some incorrect wording implying wrong treatment of abnormal
22387   completion in an extended return. GNAT has always implemented the intended
22388   correct semantics as described by this AI.
22390 @noindent
22391   RM References:  6.05 (22/2)
22394 @item
22395 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
22396 @cindex AI-0050 (Ada 2012 feature)
22398 @noindent
22399   The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
22400   not take advantage of these incorrect permissions in any case.
22402 @noindent
22403   RM References:  6.05 (24/2)
22406 @item
22407 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
22408 @cindex AI-0125 (Ada 2012 feature)
22410 @noindent
22411   In Ada 2012, the declaration of a primitive operation of a type extension
22412   or private extension can also override an inherited primitive that is not
22413   visible at the point of this declaration.
22415 @noindent
22416   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
22418 @item
22419 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
22420 @cindex AI-0062 (Ada 2012 feature)
22422 @noindent
22423   A full constant may have a null exclusion even if its associated deferred
22424   constant does not. GNAT has always allowed this.
22426 @noindent
22427   RM References:  7.04 (6/2)   7.04 (7.1/2)
22430 @item
22431 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
22432 @cindex AI-0178 (Ada 2012 feature)
22434 @noindent
22435   This AI clarifies the role of incomplete views and plugs an omission in the
22436   RM. GNAT always correctly restricted the use of incomplete views and types.
22438 @noindent
22439   RM References:  7.05 (3/2)   7.05 (6/2)
22441 @item
22442 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
22443 @cindex AI-0087 (Ada 2012 feature)
22445 @noindent
22446   The actual for a formal nonlimited derived type cannot be limited. In
22447   particular, a formal derived type that extends a limited interface but which
22448   is not explicitly limited cannot be instantiated with a limited type.
22450 @noindent
22451   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
22453 @item
22454 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
22455 @cindex AI-0099 (Ada 2012 feature)
22457 @noindent
22458   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
22459   and therefore depends on the run-time characteristics of an object (i.e. its
22460   tag) and not on its nominal type. As the AI indicates: ``we do not expect
22461   this to affect any implementation''.
22463 @noindent
22464   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
22468 @item
22469 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
22470 @cindex AI-0064 (Ada 2012 feature)
22472 @noindent
22473   This is an editorial change only. The intended behavior is already checked
22474   by an existing ACATS test, which GNAT has always executed correctly.
22476 @noindent
22477   RM References:  7.06.01 (17.1/1)
22479 @item
22480 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
22481 @cindex AI-0026 (Ada 2012 feature)
22483 @noindent
22484   Record representation clauses concerning Unchecked_Union types cannot mention
22485   the discriminant of the type. The type of a component declared in the variant
22486   part of an Unchecked_Union cannot be controlled, have controlled components,
22487   nor have protected or task parts. If an Unchecked_Union type is declared
22488   within the body of a generic unit or its descendants, then the type of a
22489   component declared in the variant part cannot be a formal private type or a
22490   formal private extension declared within the same generic unit.
22492 @noindent
22493   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
22496 @item
22497 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
22498 @cindex AI-0205 (Ada 2012 feature)
22500 @noindent
22501   This AI corrects a simple omission in the RM. Return objects have always
22502   been visible within an extended return statement.
22504 @noindent
22505   RM References:  8.03 (17)
22508 @item
22509 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
22510 @cindex AI-0042 (Ada 2012 feature)
22512 @noindent
22513   This AI fixes a wording gap in the RM. An operation of a synchronized
22514   interface can be implemented by a protected or task entry, but the abstract
22515   operation is not being overridden in the usual sense, and it must be stated
22516   separately that this implementation is legal. This has always been the case
22517   in GNAT.
22519 @noindent
22520   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
22522 @item
22523 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
22524 @cindex AI-0030 (Ada 2012 feature)
22526 @noindent
22527   Requeue is permitted to a protected, synchronized or task interface primitive
22528   providing it is known that the overriding operation is an entry. Otherwise
22529   the requeue statement has the same effect as a procedure call. Use of pragma
22530   @code{Implemented} provides a way to impose a static requirement on the
22531   overriding operation by adhering to one of the implementation kinds: entry,
22532   protected procedure or any of the above.
22534 @noindent
22535   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
22536   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
22539 @item
22540 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22541 @cindex AI-0201 (Ada 2012 feature)
22543 @noindent
22544   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22545   attribute, then individual components may not be addressable by independent
22546   tasks. However, if the representation clause has no effect (is confirming),
22547   then independence is not compromised. Furthermore, in GNAT, specification of
22548   other appropriately addressable component sizes (e.g. 16 for 8-bit
22549   characters) also preserves independence. GNAT now gives very clear warnings
22550   both for the declaration of such a type, and for any assignment to its components.
22552 @noindent
22553   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
22555 @item
22556 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22557 @cindex AI-0009 (Ada 2012 feature)
22559 @noindent
22560   This AI introduces the new pragmas @code{Independent} and
22561   @code{Independent_Components},
22562   which control guaranteeing independence of access to objects and components.
22563   The AI also requires independence not unaffected by confirming rep clauses.
22565 @noindent
22566   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
22567   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
22570 @item
22571 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22572 @cindex AI-0072 (Ada 2012 feature)
22574 @noindent
22575   This AI clarifies that task signalling for reading @code{'Terminated} only
22576   occurs if the result is True. GNAT semantics has always been consistent with
22577   this notion of task signalling.
22579 @noindent
22580   RM References:  9.10 (6.1/1)
22582 @item
22583 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22584 @cindex AI-0108 (Ada 2012 feature)
22586 @noindent
22587   This AI confirms that an incomplete type from a limited view does not have
22588   discriminants. This has always been the case in GNAT.
22590 @noindent
22591   RM References:  10.01.01 (12.3/2)
22593 @item
22594 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22595 @cindex AI-0129 (Ada 2012 feature)
22597 @noindent
22598   This AI clarifies the description of limited views: a limited view of a
22599   package includes only one view of a type that has an incomplete declaration
22600   and a full declaration (there is no possible ambiguity in a client package).
22601   This AI also fixes an omission: a nested package in the private part has no
22602   limited view. GNAT always implemented this correctly.
22604 @noindent
22605   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
22609 @item
22610 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22611 @cindex AI-0077 (Ada 2012 feature)
22613 @noindent
22614   This AI clarifies that a declaration does not include a context clause,
22615   and confirms that it is illegal to have a context in which both a limited
22616   and a nonlimited view of a package are accessible. Such double visibility
22617   was always rejected by GNAT.
22619 @noindent
22620   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
22622 @item
22623 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22624 @cindex AI-0122 (Ada 2012 feature)
22626 @noindent
22627   This AI clarifies the visibility of private children of generic units within
22628   instantiations of a parent. GNAT has always handled this correctly.
22630 @noindent
22631   RM References:  10.01.02 (12/2)
22635 @item
22636 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22637 @cindex AI-0040 (Ada 2012 feature)
22639 @noindent
22640   This AI confirms that a limited with clause in a child unit cannot name
22641   an ancestor of the unit. This has always been checked in GNAT.
22643 @noindent
22644   RM References:  10.01.02 (20/2)
22646 @item
22647 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22648 @cindex AI-0132 (Ada 2012 feature)
22650 @noindent
22651   This AI fills a gap in the description of library unit pragmas. The pragma
22652   clearly must apply to a library unit, even if it does not carry the name
22653   of the enclosing unit. GNAT has always enforced the required check.
22655 @noindent
22656   RM References:  10.01.05 (7)
22659 @item
22660 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22661 @cindex AI-0034 (Ada 2012 feature)
22663 @noindent
22664   The RM makes certain limited with clauses illegal because of categorization
22665   considerations, when the corresponding normal with would be legal. This is
22666   not intended, and GNAT has always implemented the recommended behavior.
22668 @noindent
22669   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
22672 @item
22673 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22674 @cindex AI-0035 (Ada 2012 feature)
22676 @noindent
22677   This AI remedies some inconsistencies in the legality rules for Pure units.
22678   Derived access types are legal in a pure unit (on the assumption that the
22679   rule for a zero storage pool size has been enforced on the ancestor type).
22680   The rules are enforced in generic instances and in subunits. GNAT has always
22681   implemented the recommended behavior.
22683 @noindent
22684   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)
22687 @item
22688 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22689 @cindex AI-0219 (Ada 2012 feature)
22691 @noindent
22692   This AI refines the rules for the cases with limited parameters which do not
22693   allow the implementations to omit ``redundant''. GNAT now properly conforms
22694   to the requirements of this binding interpretation.
22696 @noindent
22697   RM References:  10.02.01 (18/2)
22699 @item
22700 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22701 @cindex AI-0043 (Ada 2012 feature)
22703 @noindent
22704   This AI covers various omissions in the RM regarding the raising of
22705   exceptions. GNAT has always implemented the intended semantics.
22707 @noindent
22708   RM References:  11.04.01 (10.1/2)   11 (2)
22711 @item
22712 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22713 @cindex AI-0200 (Ada 2012 feature)
22715 @noindent
22716   This AI plugs a gap in the RM which appeared to allow some obviously intended
22717   illegal instantiations. GNAT has never allowed these instantiations.
22719 @noindent
22720   RM References:  12.07 (16)
22723 @item
22724 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22725 @cindex AI-0112 (Ada 2012 feature)
22727 @noindent
22728   This AI concerns giving names to various representation aspects, but the
22729   practical effect is simply to make the use of duplicate
22730   @code{Atomic}[@code{_Components}],
22731   @code{Volatile}[@code{_Components}] and
22732   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22733   now performs this required check.
22735 @noindent
22736   RM References:  13.01 (8)
22738 @item
22739 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22740 @cindex AI-0106 (Ada 2012 feature)
22742 @noindent
22743   The RM appeared to allow representation pragmas on generic formal parameters,
22744   but this was not intended, and GNAT has never permitted this usage.
22746 @noindent
22747   RM References:  13.01 (9.1/1)
22750 @item
22751 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22752 @cindex AI-0012 (Ada 2012 feature)
22754 @noindent
22755   It is now illegal to give an inappropriate component size or a pragma
22756   @code{Pack} that attempts to change the component size in the case of atomic
22757   or aliased components. Previously GNAT ignored such an attempt with a
22758   warning.
22760 @noindent
22761   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
22764 @item
22765 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22766 @cindex AI-0039 (Ada 2012 feature)
22768 @noindent
22769   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22770   for stream attributes, but these were never useful and are now illegal. GNAT
22771   has always regarded such expressions as illegal.
22773 @noindent
22774   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
22777 @item
22778 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22779 @cindex AI-0095 (Ada 2012 feature)
22781 @noindent
22782   The prefix of @code{'Address} cannot statically denote a subprogram with
22783   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22784   @code{Program_Error} if the prefix denotes a subprogram with convention
22785   @code{Intrinsic}.
22787 @noindent
22788   RM References:  13.03 (11/1)
22791 @item
22792 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22793 @cindex AI-0116 (Ada 2012 feature)
22795 @noindent
22796   This AI requires that the alignment of a class-wide object be no greater
22797   than the alignment of any type in the class. GNAT has always followed this
22798   recommendation.
22800 @noindent
22801   RM References:  13.03 (29)   13.11 (16)
22804 @item
22805 @emph{AI-0146 Type invariants (2009-09-21)}
22806 @cindex AI-0146 (Ada 2012 feature)
22808 @noindent
22809   Type invariants may be specified for private types using the aspect notation.
22810   Aspect @code{Type_Invariant} may be specified for any private type,
22811   @code{Type_Invariant'Class} can
22812   only be specified for tagged types, and is inherited by any descendent of the
22813   tagged types. The invariant is a boolean expression that is tested for being
22814   true in the following situations: conversions to the private type, object
22815   declarations for the private type that are default initialized, and
22816   [@b{in}] @b{out}
22817   parameters and returned result on return from any primitive operation for
22818   the type that is visible to a client.
22819   GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22820   @code{Invariant'Class} for @code{Type_Invariant'Class}.
22822 @noindent
22823   RM References:  13.03.03 (00)
22825 @item
22826 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22827 @cindex AI-0078 (Ada 2012 feature)
22829 @noindent
22830   In Ada 2012, compilers are required to support unchecked conversion where the
22831   target alignment is a multiple of the source alignment. GNAT always supported
22832   this case (and indeed all cases of differing alignments, doing copies where
22833   required if the alignment was reduced).
22835 @noindent
22836   RM References:  13.09 (7)
22839 @item
22840 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22841 @cindex AI-0195 (Ada 2012 feature)
22843 @noindent
22844   The handling of invalid values is now designated to be implementation
22845   defined. This is a documentation change only, requiring Annex M in the GNAT
22846   Reference Manual to document this handling.
22847   In GNAT, checks for invalid values are made
22848   only when necessary to avoid erroneous behavior. Operations like assignments
22849   which cannot cause erroneous behavior ignore the possibility of invalid
22850   values and do not do a check. The date given above applies only to the
22851   documentation change, this behavior has always been implemented by GNAT.
22853 @noindent
22854   RM References:  13.09.01 (10)
22856 @item
22857 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22858 @cindex AI-0193 (Ada 2012 feature)
22860 @noindent
22861   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22862   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22863   of size.
22865 @noindent
22866   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
22867   13.11.01 (2)   13.11.01 (3)
22870 @item
22871 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22872 @cindex AI-0177 (Ada 2012 feature)
22874 @noindent
22875   The new Ada 2012 notion of parameterized expressions is implemented. The form
22876   is:
22877 @smallexample
22878   @i{function specification} @b{is} (@i{expression})
22879 @end smallexample
22881 @noindent
22882   This is exactly equivalent to the
22883   corresponding function body that returns the expression, but it can appear
22884   in a package spec. Note that the expression must be parenthesized.
22886 @noindent
22887   RM References:  13.11.01 (3/2)
22889 @item
22890 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22891 @cindex AI-0033 (Ada 2012 feature)
22893 @noindent
22894   Neither of these two pragmas may appear within a generic template, because
22895   the generic might be instantiated at other than the library level.
22897 @noindent
22898   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
22901 @item
22902 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22903 @cindex AI-0161 (Ada 2012 feature)
22905 @noindent
22906   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22907   of the default stream attributes for elementary types. If this restriction is
22908   in force, then it is necessary to provide explicit subprograms for any
22909   stream attributes used.
22911 @noindent
22912   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
22914 @item
22915 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22916 @cindex AI-0194 (Ada 2012 feature)
22918 @noindent
22919   The @code{Stream_Size} attribute returns the default number of bits in the
22920   stream representation of the given type.
22921   This value is not affected by the presence
22922   of stream subprogram attributes for the type. GNAT has always implemented
22923   this interpretation.
22925 @noindent
22926   RM References:  13.13.02 (1.2/2)
22928 @item
22929 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22930 @cindex AI-0109 (Ada 2012 feature)
22932 @noindent
22933   This AI is an editorial change only. It removes the need for a tag check
22934   that can never fail.
22936 @noindent
22937   RM References:  13.13.02 (34/2)
22939 @item
22940 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22941 @cindex AI-0007 (Ada 2012 feature)
22943 @noindent
22944   The RM as written appeared to limit the possibilities of declaring read
22945   attribute procedures for private scalar types. This limitation was not
22946   intended, and has never been enforced by GNAT.
22948 @noindent
22949   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
22952 @item
22953 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22954 @cindex AI-0065 (Ada 2012 feature)
22956 @noindent
22957   This AI clarifies the fact that all remote access types support external
22958   streaming. This fixes an obvious oversight in the definition of the
22959   language, and GNAT always implemented the intended correct rules.
22961 @noindent
22962   RM References:  13.13.02 (52/2)
22964 @item
22965 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22966 @cindex AI-0019 (Ada 2012 feature)
22968 @noindent
22969   The RM suggests that primitive subprograms of a specific tagged type are
22970   frozen when the tagged type is frozen. This would be an incompatible change
22971   and is not intended. GNAT has never attempted this kind of freezing and its
22972   behavior is consistent with the recommendation of this AI.
22974 @noindent
22975   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)
22977 @item
22978 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22979 @cindex AI-0017 (Ada 2012 feature)
22981 @noindent
22982   So-called ``Taft-amendment types'' (i.e., types that are completed in package
22983   bodies) are not frozen by the occurrence of bodies in the
22984   enclosing declarative part. GNAT always implemented this properly.
22986 @noindent
22987   RM References:  13.14 (3/1)
22990 @item
22991 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22992 @cindex AI-0060 (Ada 2012 feature)
22994 @noindent
22995   This AI extends the definition of remote access types to include access
22996   to limited, synchronized, protected or task class-wide interface types.
22997   GNAT already implemented this extension.
22999 @noindent
23000   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
23002 @item
23003 @emph{AI-0114 Classification of letters (0000-00-00)}
23004 @cindex AI-0114 (Ada 2012 feature)
23006 @noindent
23007   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
23008   181 (@code{MICRO SIGN}), and
23009   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
23010   lower case letters by Unicode.
23011   However, they are not allowed in identifiers, and they
23012   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
23013   This behavior is consistent with that defined in Ada 95.
23015 @noindent
23016   RM References:  A.03.02 (59)   A.04.06 (7)
23019 @item
23020 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
23021 @cindex AI-0185 (Ada 2012 feature)
23023 @noindent
23024   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
23025   classification functions for @code{Wide_Character} and
23026   @code{Wide_Wide_Character}, as well as providing
23027   case folding routines for @code{Wide_[Wide_]Character} and
23028   @code{Wide_[Wide_]String}.
23030 @noindent
23031   RM References:  A.03.05 (0)   A.03.06 (0)
23034 @item
23035 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
23036 @cindex AI-0031 (Ada 2012 feature)
23038 @noindent
23039   A new version of @code{Find_Token} is added to all relevant string packages,
23040   with an extra parameter @code{From}. Instead of starting at the first
23041   character of the string, the search for a matching Token starts at the
23042   character indexed by the value of @code{From}.
23043   These procedures are available in all versions of Ada
23044   but if used in versions earlier than Ada 2012 they will generate a warning
23045   that an Ada 2012 subprogram is being used.
23047 @noindent
23048   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
23049   A.04.05 (46)
23052 @item
23053 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
23054 @cindex AI-0056 (Ada 2012 feature)
23056 @noindent
23057   The wording in the Ada 2005 RM implied an incompatible handling of the
23058   @code{Index} functions, resulting in raising an exception instead of
23059   returning zero in some situations.
23060   This was not intended and has been corrected.
23061   GNAT always returned zero, and is thus consistent with this AI.
23063 @noindent
23064   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
23067 @item
23068 @emph{AI-0137 String encoding package (2010-03-25)}
23069 @cindex AI-0137 (Ada 2012 feature)
23071 @noindent
23072   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
23073   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
23074   and @code{Wide_Wide_Strings} have been
23075   implemented. These packages (whose documentation can be found in the spec
23076   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
23077   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
23078   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
23079   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
23080   UTF-16), as well as conversions between the different UTF encodings. With
23081   the exception of @code{Wide_Wide_Strings}, these packages are available in
23082   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
23083   The @code{Wide_Wide_Strings package}
23084   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
23085   mode since it uses @code{Wide_Wide_Character}).
23087 @noindent
23088   RM References:  A.04.11
23090 @item
23091 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
23092 @cindex AI-0038 (Ada 2012 feature)
23094 @noindent
23095   These are minor errors in the description on three points. The intent on
23096   all these points has always been clear, and GNAT has always implemented the
23097   correct intended semantics.
23099 @noindent
23100   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)
23102 @item
23103 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
23104 @cindex AI-0044 (Ada 2012 feature)
23106 @noindent
23107   This AI places restrictions on allowed instantiations of generic containers.
23108   These restrictions are not checked by the compiler, so there is nothing to
23109   change in the implementation. This affects only the RM documentation.
23111 @noindent
23112   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)
23114 @item
23115 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
23116 @cindex AI-0127 (Ada 2012 feature)
23118 @noindent
23119   This package provides an interface for identifying the current locale.
23121 @noindent
23122   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
23123   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
23127 @item
23128 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
23129 @cindex AI-0002 (Ada 2012 feature)
23131 @noindent
23132   The compiler is not required to support exporting an Ada subprogram with
23133   convention C if there are parameters or a return type of an unconstrained
23134   array type (such as @code{String}). GNAT allows such declarations but
23135   generates warnings. It is possible, but complicated, to write the
23136   corresponding C code and certainly such code would be specific to GNAT and
23137   non-portable.
23139 @noindent
23140   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
23143 @item
23144 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
23145 @cindex AI05-0216 (Ada 2012 feature)
23147 @noindent
23148   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
23149   forbid tasks declared locally within subprograms, or functions returning task
23150   objects, and that is the implementation that GNAT has always provided.
23151   However the language in the RM was not sufficiently clear on this point.
23152   Thus this is a documentation change in the RM only.
23154 @noindent
23155   RM References:  D.07 (3/3)
23157 @item
23158 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
23159 @cindex AI-0211 (Ada 2012 feature)
23161 @noindent
23162   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
23163   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
23165 @noindent
23166   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
23168 @item
23169 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
23170 @cindex AI-0190 (Ada 2012 feature)
23172 @noindent
23173   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
23174   used to control storage pools globally.
23175   In particular, you can force every access
23176   type that is used for allocation (@b{new}) to have an explicit storage pool,
23177   or you can declare a pool globally to be used for all access types that lack
23178   an explicit one.
23180 @noindent
23181   RM References:  D.07 (8)
23183 @item
23184 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
23185 @cindex AI-0189 (Ada 2012 feature)
23187 @noindent
23188   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
23189   which says that no dynamic allocation will occur once elaboration is
23190   completed.
23191   In general this requires a run-time check, which is not required, and which
23192   GNAT does not attempt. But the static cases of allocators in a task body or
23193   in the body of the main program are detected and flagged at compile or bind
23194   time.
23196 @noindent
23197   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
23199 @item
23200 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
23201 @cindex AI-0171 (Ada 2012 feature)
23203 @noindent
23204   A new package @code{System.Multiprocessors} is added, together with the
23205   definition of pragma @code{CPU} for controlling task affinity. A new no
23206   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
23207   is added to the Ravenscar profile.
23209 @noindent
23210   RM References:  D.13.01 (4/2)   D.16
23213 @item
23214 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
23215 @cindex AI-0210 (Ada 2012 feature)
23217 @noindent
23218   This is a documentation only issue regarding wording of metric requirements,
23219   that does not affect the implementation of the compiler.
23221 @noindent
23222   RM References:  D.15 (24/2)
23225 @item
23226 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
23227 @cindex AI-0206 (Ada 2012 feature)
23229 @noindent
23230   Remote types packages are now allowed to depend on preelaborated packages.
23231   This was formerly considered illegal.
23233 @noindent
23234   RM References:  E.02.02 (6)
23238 @item
23239 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
23240 @cindex AI-0152 (Ada 2012 feature)
23242 @noindent
23243   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
23244   where the type of the returned value is an anonymous access type.
23246 @noindent
23247   RM References:  H.04 (8/1)
23248 @end itemize
23251 @node Obsolescent Features
23252 @chapter Obsolescent Features
23254 @noindent
23255 This chapter describes features that are provided by GNAT, but are
23256 considered obsolescent since there are preferred ways of achieving
23257 the same effect. These features are provided solely for historical
23258 compatibility purposes.
23260 @menu
23261 * pragma No_Run_Time::
23262 * pragma Ravenscar::
23263 * pragma Restricted_Run_Time::
23264 * pragma Task_Info::
23265 * System.Task_Info (s-tasinf.ads)::
23266 @end menu
23268 @node pragma No_Run_Time
23269 @section pragma No_Run_Time
23271 The pragma @code{No_Run_Time} is used to achieve an affect similar
23272 to the use of the "Zero Foot Print" configurable run time, but without
23273 requiring a specially configured run time. The result of using this
23274 pragma, which must be used for all units in a partition, is to restrict
23275 the use of any language features requiring run-time support code. The
23276 preferred usage is to use an appropriately configured run-time that
23277 includes just those features that are to be made accessible.
23279 @node pragma Ravenscar
23280 @section pragma Ravenscar
23282 The pragma @code{Ravenscar} has exactly the same effect as pragma
23283 @code{Profile (Ravenscar)}. The latter usage is preferred since it
23284 is part of the new Ada 2005 standard.
23286 @node pragma Restricted_Run_Time
23287 @section pragma Restricted_Run_Time
23289 The pragma @code{Restricted_Run_Time} has exactly the same effect as
23290 pragma @code{Profile (Restricted)}. The latter usage is
23291 preferred since the Ada 2005 pragma @code{Profile} is intended for
23292 this kind of implementation dependent addition.
23294 @node pragma Task_Info
23295 @section pragma Task_Info
23297 The functionality provided by pragma @code{Task_Info} is now part of the
23298 Ada language. The @code{CPU} aspect and the package
23299 @code{System.Multiprocessors} offer a less system-dependent way to specify
23300 task affinity or to query the number of processsors.
23302 @noindent
23303 Syntax
23305 @smallexample @c ada
23306 pragma Task_Info (EXPRESSION);
23307 @end smallexample
23309 @noindent
23310 This pragma appears within a task definition (like pragma
23311 @code{Priority}) and applies to the task in which it appears.  The
23312 argument must be of type @code{System.Task_Info.Task_Info_Type}.
23313 The @code{Task_Info} pragma provides system dependent control over
23314 aspects of tasking implementation, for example, the ability to map
23315 tasks to specific processors.  For details on the facilities available
23316 for the version of GNAT that you are using, see the documentation
23317 in the spec of package System.Task_Info in the runtime
23318 library.
23320 @node System.Task_Info (s-tasinf.ads)
23321 @section package System.Task_Info (@file{s-tasinf.ads})
23323 @noindent
23324 This package provides target dependent functionality that is used
23325 to support the @code{Task_Info} pragma. The predefined Ada package
23326  @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
23327 standard replacement for GNAT's @code{Task_Info} functionality.
23329 @include fdl.texi
23330 @c GNU Free Documentation License
23332 @node Concept Index
23333 @unnumbered Index
23335 @printindex cp
23337 @contents
23339 @bye